summaryrefslogtreecommitdiffstats
path: root/private/nw/rdr/struct.h
blob: 6f6bdf9eb07cb05806bab206a776d978ed339213 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
/*++

Copyright (c) 1992  Microsoft Corporation

Module Name:

    Struct.h

Abstract:

    This module defines the data structures that make up the major internal
    part of the NetWare file system.

Author:

    Colin Watson     [ColinW]    18-Dec-1992

Revision History:

--*/

#ifndef _NWSTRUC_
#define _NWSTRUC_

#define byte UCHAR
#define word USHORT
#define dword ULONG

typedef enum _PACKET_TYPE {
    SAP_BROADCAST,
    NCP_CONNECT,
    NCP_FUNCTION,
    NCP_SUBFUNCTION,
    NCP_DISCONNECT,
    NCP_BURST,
    NCP_ECHO
} PACKET_TYPE;

typedef struct _NW_TDI_STRUCT {
    HANDLE Handle;
    PDEVICE_OBJECT pDeviceObject;
    PFILE_OBJECT pFileObject;
    USHORT Socket;
} NW_TDI_STRUCT, *PNW_TDI_STRUCT;

typedef
NTSTATUS
(*PEX) (
    IN struct _IRP_CONTEXT* pIrpC,
    IN ULONG BytesAvailable,
    IN PUCHAR RspData
    );

typedef
VOID
(*PRUN_ROUTINE) (
    IN struct _IRP_CONTEXT *IrpContext
    );

typedef
NTSTATUS
(*PPOST_PROCESSOR) (
    IN struct _IRP_CONTEXT *IrpContext
    );

typedef
NTSTATUS
(*PRECEIVE_ROUTINE) (
    IN struct _IRP_CONTEXT *IrpContext,
    IN ULONG BytesAvailable,
    IN PULONG BytesAccepted,
    IN PUCHAR Response,
    OUT PMDL *pReceiveMdl
    );

//
//  The Scb (Server control Block) record corresponds to every server
//  connected to by the file system.
//  They are ordered in ScbQueue.
//  This structure is allocated from paged pool
//

typedef struct _SCB {

    //
    //  The type and size of this record (must be NW_NTC_SCB)
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    //  Pointer to the non-paged part of the SCB.
    //

    struct _NONPAGED_SCB *pNpScb;

    //
    //  Prefix table entry.
    //

    UNICODE_PREFIX_TABLE_ENTRY PrefixEntry;

    //
    //  Server version number
    //

    UCHAR  MajorVersion;
    UCHAR  MinorVersion;

    //
    //  List of VCBs for this server, and a count of the VCB on the list.
    //  These fields are protected by the RCB resource.
    //

    LIST_ENTRY  ScbSpecificVcbQueue;
    ULONG       VcbCount;

    //
    //  A list of ICBs for the SCB.
    //

    LIST_ENTRY  IcbList;
    ULONG IcbCount;
    ULONG OpenNdsStreams;

    //
    //  User credentials that this Scb relates to.
    //

    LARGE_INTEGER UserUid;

    //
    //  A count of the open files for all the VCBs for this server.
    //  Plus the number of VCB that are explicitly connected.
    //

    ULONG OpenFileCount;

    //
    //  The name of the server for this SCB. Note the pNpScb->ServerName and
    //  UnicodeUid point at subparts of UidServerName->Buffer which must be
    //  non-paged pool.
    //

    UNICODE_STRING UidServerName;   // L"3e7\mars312
    UNICODE_STRING UnicodeUid;      // L"3e7"

    //
    //  The name of nds tree that this server belongs to, if any.
    //

    UNICODE_STRING NdsTreeName;     // L"MARS"

    //
    //  The username / password to use for auto-reconnect.
    //

    UNICODE_STRING UserName;
    UNICODE_STRING Password;

    //
    //  Is this the logon (preferred) server?
    //

    BOOLEAN PreferredServer;

    //
    //  Is this server waiting for us to read a message?
    //

    BOOLEAN MessageWaiting;

    //
    //  The number of tree connects to the root of the SCB.
    //

    ULONG AttachCount;

    RTL_BITMAP DriveMapHeader;
    ULONG DriveMap[ (MAX_DRIVES + 1) / 32 ];

} SCB, *PSCB;

//
//  Values for pNpScb->State
//

//
//  The SCB is on it's way up
//

#define SCB_STATE_ATTACHING              (0x0001)

//
//  The SCB is connected and logged in.
//

#define SCB_STATE_IN_USE                 (0x0003)

//
//  The SCB is being disconnected or shutdown.
//

#define SCB_STATE_DISCONNECTING          (0x0004)
#define SCB_STATE_FLAG_SHUTDOWN          (0x0005)

//
//  The SCB is waiting to be connected.
//

#define SCB_STATE_RECONNECT_REQUIRED     (0x0006)

//
//  The SCB is connected but has not been logged into
//

#define SCB_STATE_LOGIN_REQUIRED         (0x0007)

//
//  The SCB is a fake SCB used to find a dir
//  server for a tree.
//

#define SCB_STATE_TREE_SCB               (0x0008)

//
//  The NONPAGED_SCB (Server control Block) contains all the data required
//  when communicating with a server when a spinlock is held or at raised
//  IRQL such as when being called at indication time by the transport.
//  This structure must be allocated from non-paged pool.
//

typedef struct _NONPAGED_SCB {

    //
    //  The type and size of this record (must be NW_NTC_SCBNP
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    //  Reference count and state information.
    //

    ULONG Reference;
    ULONG State;

    //
    //  The time this SCB was last used.
    //

    LARGE_INTEGER LastUsedTime;

    //
    //  Sending is true between the IoCallDriver to send the datagram and
    //  the completion routine for the send.
    //

    BOOLEAN Sending;

    //
    //  Receiving is true when the transport has indicated to the driver
    //  that there is data to receive and there is too much data to handle
    //  at indication time or we have received indicated data before
    //  the the send IRP completes.
    //

    BOOLEAN Receiving;

    //
    //  Received is true when the rx data is valid. If a receive Irp is
    //  put down when Receiving is set to true then Received is set to
    //  true when the receive Irp completes.
    //

    BOOLEAN Received;

    //
    //  OkToReceive is true iff pEx should be called
    //

    BOOLEAN OkToReceive;

    //
    //  Older servers insist that reads and writes do not cross 4k offsets
    //  in the file.
    //

    BOOLEAN PageAlign;

    //
    //  The links on the global list of SCBs.
    //

    LIST_ENTRY  ScbLinks;

    //
    //  Pointer to the paged component of the Scb
    //

    PSCB pScb;

    //
    //  The list of request in progress for this SCB.
    //

    LIST_ENTRY  Requests;

    //
    //  The name of the server for this SCB.
    //

    UNICODE_STRING ServerName;

    //
    //  Transport related information.
    //

    TA_IPX_ADDRESS LocalAddress;
    TA_IPX_ADDRESS RemoteAddress;
    TA_IPX_ADDRESS EchoAddress;
    IPXaddress  ServerAddress;
    ULONG EchoCounter;

    //
    //  Server is an autoassigned a socket in the range 0x4000 to 0x7fff.
    //  The transport assigns the socket number avoiding in-use sockets.
    //  Watchdog is socket+1 and Send is socket+2.
    //

    NW_TDI_STRUCT Server;           //  Used by us to contact server
    NW_TDI_STRUCT WatchDog;         //  Used by the server to check on us
    NW_TDI_STRUCT Send;             //  Used for send messages
    NW_TDI_STRUCT Echo;             //  Used to determine max packet size
    NW_TDI_STRUCT Burst;            //  Used for burst mode read and write

    USHORT       TickCount;

    SHORT       RetryCount;         // Counts down to zero for current request
    SHORT       TimeOut;            // ticks to retransmission of current request
    UCHAR       SequenceNo;
    UCHAR       ConnectionNo;
    UCHAR       ConnectionNoHigh;
    UCHAR       ConnectionStatus;
    USHORT      MaxTimeOut;
    USHORT      BufferSize;
    UCHAR       TaskNo;

    //
    //  Burst mode parameters
    //

    ULONG SourceConnectionId;       //  High-low order
    ULONG DestinationConnectionId;  //  High-low order
    ULONG MaxPacketSize;
    ULONG MaxSendSize;
    ULONG MaxReceiveSize;
    BOOLEAN SendBurstModeEnabled;
    BOOLEAN ReceiveBurstModeEnabled;
    BOOLEAN BurstRenegotiateReqd;
    ULONG BurstSequenceNo;          //  Counts # of burst packets sent
    USHORT BurstRequestNo;          //  Counts # of burst requests sent
    LONG SendBurstSuccessCount;     //  The number of consecutive successful bursts
    LONG ReceiveBurstSuccessCount;  //  The number of consecutive successful bursts

    //
    //  Send delays and timeouts
    //

    SHORT SendTimeout;              //  Exchange timeout in ticks (1/18th sec)
    ULONG TotalWaitTime;            //  Total time, in ticks, waiting for current response

    LONG  NwLoopTime;               //  Time for a small packet to reach the server and return
    LONG  NwSingleBurstPacketTime;  //  Time for a burst packet to go to the server

    LONG NwMaxSendDelay;            //  Burst send delay time, in 100us units
    LONG NwSendDelay;               //  Burst send delay time, in 100us units
    LONG NwGoodSendDelay;           //  Burst send delay time, in 100us units
    LONG NwBadSendDelay;            //  Burst send delay time, in 100us units
    LONG BurstDataWritten;          //  Bytes written, used for dummy NCP in write.c

    LONG NwMaxReceiveDelay;         //  Burst delay time, in 100us units
    LONG NwReceiveDelay;            //  Burst delay time, in 100us units
    LONG NwGoodReceiveDelay;        //  Burst delay time, in 100us units
    LONG NwBadReceiveDelay;         //  Burst delay time, in 100us units

    LONG CurrentBurstDelay;         //  All requests in the current burst need the same value

    LARGE_INTEGER NtSendDelay;      //  Burst send delay time, in 100ns units

    //
    //  A spin lock used to protect various fields for this SCB.
    //  NpScbInterLock is used to protect pNpScb->Reference.
    //

    KSPIN_LOCK  NpScbSpinLock;
    KSPIN_LOCK  NpScbInterLock;

    //
    //  This field records the last time a time-out event was written to
    //  the event log for this server.
    //

    LARGE_INTEGER NwNextEventTime;

    //
    // LIP estimation of speed in 100bps units.
    //

    ULONG LipDataSpeed;

#ifdef MSWDBG
    BOOL RequestQueued;
    BOOL RequestDequeued;

    ULONG SequenceNumber;
#endif

} NONPAGED_SCB, *PNONPAGED_SCB;

//
//  Delete this VCB immediately if the reference count reaches zero.
//

#define  VCB_FLAG_DELETE_IMMEDIATELY  0x00000001
#define  VCB_FLAG_EXPLICIT_CONNECTION 0x00000002
#define  VCB_FLAG_PRINT_QUEUE         0x00000004
#define  VCB_FLAG_LONG_NAME           0x00000008

//
//  The VCB corresponds to a netware volume.
//

typedef struct _VCB {

    //
    //  Type and size of this record (must be NW_NTC_VCB)
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    ULONG Reference;
    LARGE_INTEGER LastUsedTime;

    //
    //  Connection the the global VCB list.
    //

    LIST_ENTRY GlobalVcbListEntry;
    ULONG SequenceNumber;

    //
    //  The requested volume name in the following form:
    //
    //  \{Server | Tree}\{Share | Volume.Object}\Path
    //

    UNICODE_STRING Name;

    //
    //  If the above name refers to an nds volume, this
    //  contains the resolved server and share name in
    //  the following form:
    //
    //  \Server\Share\Path
    //

    UNICODE_STRING ConnectName;

    //
    //  The share name in Netware compatible form.
    //

    UNICODE_STRING ShareName;

    //
    //  The prefix table entry for this volume.
    //

    UNICODE_PREFIX_TABLE_ENTRY PrefixEntry;    //  7 DWORDs

    union {

        //
        //  Disk VCB specific data.
        //

        struct {

            //
            //  The volume number
            //

            CHAR VolumeNumber;

            //
            //  The name space number for long name support.  -1 if long name
            //  space is not supported.
            //

            CHAR LongNameSpace;

            //
            //  The remote handle
            //

            CHAR Handle;

            //
            //  The Drive Letter we told the server we were mapping. Portable
            //  NetWare needs this to be different for each permanent handle
            //  we create.
            //

            CHAR DriveNumber;

        } Disk;

        //
        //  Print VCB specific data.
        //

        struct {
            ULONG QueueId;
        } Print;

    } Specific;

    //
    //  The drive letter for this VCB.  (0 if this is UNC).
    //

    WCHAR DriveLetter;

    //
    //  The SCB for this volume, and a link to the VCBs for this SCB
    //

    PSCB Scb;
    LIST_ENTRY VcbListEntry;

    //
    //  List of FCBs and DCBs for this server.  These fields are protected
    //  by the RCB resource.
    //

    LIST_ENTRY FcbList;

    //
    //  The count of open ICBs for this VCB.
    //

    ULONG OpenFileCount;

    //
    //  VCB flags
    //

    ULONG Flags;

} VCB, *PVCB;

//
//  Use default date / time when netware returns no info, or bogus info.
//

#define DEFAULT_DATE   ( 1 + (1 << 5) + (0 << 9) )   /* Jan 1, 1980 */
#define DEFAULT_TIME   ( 0 + (0 << 5) + (0 << 11) )  /* 12:00am */

//
//  The Fcb/Dcb record corresponds to every open file and directory.
//
//  The structure is really divided into two parts.  FCB can be allocated
//  from paged pool which the NONPAGED_FCB must be allocated from non-paged
//  pool.
//

typedef struct _FCB {

    //
    //  Type and size of this record (must be NW_NTC_FCB or NW_NTC_DCB)
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    //  The VCB for this file.
    //

    PVCB Vcb;

    //
    //  The following field is the fully qualified file name for this FCB/DCB.
    //  The file name relative to the root of the volume.
    //

    UNICODE_STRING FullFileName;
    UNICODE_STRING RelativeFileName;

    //
    //  Netware file information.
    //

    USHORT LastModifiedDate;
    USHORT LastModifiedTime;
    USHORT CreationDate;
    USHORT CreationTime;
    USHORT LastAccessDate;

    //
    //  The state of the FCB.
    //

    ULONG State;
    ULONG Flags;

    //
    //  A record of accesss currently granted.
    //

    SHARE_ACCESS ShareAccess;

    //
    //  The prefix table entry for this file.
    //

    UNICODE_PREFIX_TABLE_ENTRY PrefixEntry;

    //
    //  The SCB for this file, and a link to the FCB for this SCB
    //

    PSCB Scb;
    LIST_ENTRY FcbListEntry;

    //
    //  The list of ICB's for this FCB or DCB.
    //

    LIST_ENTRY IcbList;
    ULONG IcbCount;

    //
    //  A pointer to the specific non-paged data for the Fcb.
    //

    struct _NONPAGED_FCB *NonPagedFcb;

    ULONG LastReadOffset;
    ULONG LastReadSize;

} FCB, DCB;
typedef FCB *PFCB;
typedef DCB *PDCB;

typedef enum {
    ReadAhead,
    WriteBehind
} CACHE_TYPE;

typedef struct _NONPAGED_FCB {

    //
    //  The following field is used for fast I/O
    //
    //  The following comments refer to the use of the AllocationSize field
    //  of the FsRtl-defined header to the nonpaged Fcb.
    //
    //  For a directory when we create a Dcb we will not immediately
    //  initialize the cache map, instead we will postpone it until our first
    //  call to NwReadDirectoryFile or NwPrepareWriteDirectoryFile.
    //  At that time we will search the Nw to find out the current allocation
    //  size (by calling NwLookupFileAllocationSize) and then initialize the
    //  cache map to this allocation size.
    //
    //  For a file when we create an Fcb we will not immediately initialize
    //  the cache map, instead we will postpone it until we need it and
    //  then we determine the allocation size from either searching the
    //  fat to determine the real file allocation, or from the allocation
    //  that we've just allocated if we're creating a file.
    //
    //  A value of -1 indicates that we do not know what the current allocation
    //  size really is, and need to examine the fat to find it.  A value
    //  of than -1 is the real file/directory allocation size.
    //
    //  Whenever we need to extend the allocation size we call
    //  NwAddFileAllocation which (if we're really extending the allocation)
    //  will modify the Nw, Rcb, and update this field.  The caller
    //  of NwAddFileAllocation is then responsible for altering the Cache
    //  map size.
    //

    FSRTL_COMMON_FCB_HEADER Header;

    PFCB Fcb;

    //
    //  The following field contains a record of special pointers used by
    //  MM and Cache to manipluate section objects.  Note that the values
    //  are set outside of the file system.  However the file system on an
    //  open/create will set the file object's SectionObject field to point
    //  to this field
    //

    SECTION_OBJECT_POINTERS SegmentObject;

    //
    //  The following field is used to maintain a list of locks owned for
    //  this file.  It points to an ordered list of file locks.
    //

    LIST_ENTRY FileLockList;

    //
    //  The following field is used to maintain a list of pending locks
    //  for this file.  All locks in this list conflict with existing
    //  locks on the FileLockList.
    //

    LIST_ENTRY PendingLockList;

    //
    //  A resource to synchronize access to the FCB and it's ICBs
    //

    ERESOURCE Resource;

    //
    //  Netware file information.
    //

    UCHAR Attributes;

    //
    //   File data cache information
    //

    UCHAR CacheType;        // ReadAhead or WriteBehind
    PUCHAR CacheBuffer;     // The cache buffer
    PMDL CacheMdl;          // The full MDL for the cache buffer
    ULONG CacheSize;        // The size of the cache buffer
    ULONG CacheFileOffset;  // The file offset of this data
    ULONG CacheDataSize;    // The amount of file data in the cache

} NONPAGED_FCB, NONPAGED_DCB;

typedef NONPAGED_FCB *PNONPAGED_FCB;
typedef NONPAGED_DCB *PNONPAGED_DCB;

#define FCB_STATE_OPEN_PENDING           0x00000001
#define FCB_STATE_OPENED                 0x00000002
#define FCB_STATE_CLOSE_PENDING          0x00000003

#define FCB_FLAGS_DELETE_ON_CLOSE        0x00000001
#define FCB_FLAGS_TRUNCATE_ON_CLOSE      0x00000002
#define FCB_FLAGS_PAGING_FILE            0x00000004
#define FCB_FLAGS_PREFIX_INSERTED        0x00000008
#define FCB_FLAGS_FORCE_MISS_IN_PROGRESS 0x00000010
#define FCB_FLAGS_ATTRIBUTES_ARE_VALID   0x00000020
#define FCB_FLAGS_LONG_NAME              0x00000040
#define FCB_FLAGS_LAZY_SET_SHAREABLE     0x00000100

//
//  The Icb record is allocated for every file object
//

typedef struct _ICB {

    //
    //  Type and size of this record (must be NW_NTC_ICB or NW_NTC_ICB_SCB)
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    //  A link to the list of ICB's for our FCB, and our FCB.
    //

    LIST_ENTRY ListEntry;

    union {
        PFCB Fcb;
        PSCB Scb;
    } SuperType;

    PNONPAGED_FCB NpFcb;    // Valid only for node type NW_ITC_ICB

    //
    // The state of this ICB.
    //

    ULONG State;

    //
    // The remote handle;
    //

    UCHAR Handle[6];           //  Keep  WORD aligned.

    BOOLEAN HasRemoteHandle;   //  TRUE if we have a remote handle for this ICB

    //
    //  The file object for this ICB.
    //

    PFILE_OBJECT FileObject;

    //
    //  The query template is used to filter directory query requests.
    //  It originally is set to null and on the first call the NtQueryDirectory
    //  it is set the the input filename or "*" if the name is supplied.
    //  All subsquent queries then use this template
    //

    OEM_STRING NwQueryTemplate;
    UNICODE_STRING UQueryTemplate;
    ULONG IndexOfLastIcbReturned;
    UCHAR Pid;

    BOOLEAN DotReturned;
    BOOLEAN DotDotReturned;
    BOOLEAN ReturnedSomething;
    BOOLEAN ShortNameSearch;

    //
    //  More search parameters.
    //

    USHORT SearchHandle;
    UCHAR SearchVolume;
    UCHAR SearchAttributes;

    //
    //  Extra search parameters for long name support
    //

    ULONG SearchIndexLow;
    ULONG SearchIndexHigh;

    //
    //  SVR to avoid rescanning from end of dir all
    //  the way through the directory again.
    //

    ULONG LastSearchIndexLow;

    //  SVR end

    //
    //  Print parametres;
    //

    BOOLEAN IsPrintJob;
    USHORT JobId;
    BOOLEAN ActuallyPrinted;

    //
    //  This flag prevents cleanup from updating the access time.
    //

    BOOLEAN UserSetLastAccessTime;

    //
    //  The current file position.
    //

    ULONG FilePosition;

    //
    //  The size of the file if its ICB_SCB
    //

    ULONG FileSize;

    //
    //  The Next dirent offset is used by directory enumeration.  It is
    //  the offset (within the directory file) of the next dirent to examine.
    //

    //VBO OffsetToStartSearchFrom;

    //
    //  If this ICB was created with OPEN_RENAME_TARGET then the following
    //  parameters are used
    //

    BOOLEAN IsAFile;
    BOOLEAN Exists;
    BOOLEAN FailedFindNotify;

    //
    // Is this a tree handle?  We need to know for delete.
    //
    BOOLEAN IsTreeHandle;

} ICB, *PICB;

#define ICB_STATE_OPEN_PENDING           0x00000001
#define ICB_STATE_OPENED                 0x00000002
#define ICB_STATE_CLEANED_UP             0x00000003
#define ICB_STATE_CLOSE_PENDING          0x00000004

#define INVALID_PID                      0

//
//  A structure used to maintain a list of file locks.
//

typedef struct _NW_FILE_LOCK {

    //
    //  Type and size of this record (must be NW_NTC_FILE_LOCK )
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    //  A link to the list of locks for this FCB.
    //

    LIST_ENTRY ListEntry;

    //
    //  The ICB this lock belongs to.
    //

    PICB Icb;

    //
    //  The IRP Context for this lock request.
    //

    struct _IRP_CONTEXT *IrpContext;

    //
    //  The lock offset, length, and key.
    //

    LONG StartFileOffset;
    ULONG Length;
    LONG EndFileOffset;
    ULONG Key;
    USHORT Flags;

} NW_FILE_LOCK, *PNW_FILE_LOCK;

//
//  The Rcb record controls access to the redirector device
//

typedef struct _RCB {

    //
    //  Type and size of this record (must be NW_NTC_RCB)
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    //  The run state of the redirector
    //

    ULONG State;

    //
    //  The count of open handles to the RCB.
    //  Access is protected by the RCB Resource.
    //

    ULONG OpenCount;

    //
    // A resource to synchronize access to the RCB.
    //

    ERESOURCE Resource;

    //
    // A record of accesss currently granted to the RCB.
    //

    SHARE_ACCESS ShareAccess;

    //
    // A prefix table of all connected servers.
    //

    UNICODE_PREFIX_TABLE ServerNameTable;

    //
    // A prefix table of all open volumes.
    //

    UNICODE_PREFIX_TABLE VolumeNameTable;

    //
    // A prefix table of all open files
    //

    UNICODE_PREFIX_TABLE FileNameTable;

} RCB, *PRCB;


#define RCB_STATE_STOPPED                0x00000001
#define RCB_STATE_STARTING               0x00000002
#define RCB_STATE_NEED_BIND              0x00000003
#define RCB_STATE_RUNNING                0x00000004
#define RCB_STATE_SHUTDOWN               0x00000005

//
//  IRP_CONTEXT Flags bits.
//

#define IRP_FLAG_IN_FSD               0x00000001  //  This IRP is being process in the FSD
#define IRP_FLAG_ON_SCB_QUEUE         0x00000002  //  This IRP is queued to an SCB
#define IRP_FLAG_SEQUENCE_NO_REQUIRED 0x00000004  //  This packet requires a sequence #
#define IRP_FLAG_SIGNAL_EVENT         0x00000010
#define IRP_FLAG_RETRY_SEND           0x00000020  //  We are resending a timed out request
#define IRP_FLAG_RECONNECTABLE        0x00000040  //  We are allowed to try a reconnect if this request fails due to a bad connection
#define IRP_FLAG_RECONNECT_ATTEMPT    0x00000080  //  This IRP is being used to attempt a reconnect
#define IRP_FLAG_BURST_REQUEST        0x00000100  //  This is a burst request packet
#define IRP_FLAG_BURST_PACKET         0x00000200  //  This is any burst packet
#define IRP_FLAG_NOT_OK_TO_RECEIVE    0x00000400  //  Don't set ok to receive when sending this packet
#define IRP_FLAG_REROUTE_ATTEMPTED    0x00000800  //  A re-route has been attempted for this packet
#define IRP_FLAG_BURST_WRITE          0x00001000  //  We are processsing a burst write request
#define IRP_FLAG_SEND_ALWAYS          0x00002000  //  Okay to send this packet, even if RCB State is shutdown
#define IRP_FLAG_FREE_RECEIVE_MDL     0x00004000  //  Free the receive irp's MDL when the irp completes
#define IRP_FLAG_NOT_SYSTEM_PACKET    0x00008000  //  Used in burst writes to alternate system packet and normal
#define IRP_FLAG_NOCONNECT            0x00010000  //  Used to inspect server list

typedef struct _IRP_CONTEXT {

    //
    //  Type and size of this record (must be NW_NTC_IRP_CONTEXT).
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    // Information about this IRP
    //

    ULONG Flags;

    //
    //  This structure is used for posting to the Ex worker threads.
    //

    WORK_QUEUE_ITEM WorkQueueItem;  // 4*sizeof(ULONG)

    //  Workspace for exchange()
    PACKET_TYPE PacketType;

    //
    //  Server Control Block to which this request applies.
    //

    PNONPAGED_SCB pNpScb;
    PSCB pScb;

    //
    //  The socket structure to use for this request.  If NULL, use
    //  pNpScb->Server socket.
    //

    PNW_TDI_STRUCT pTdiStruct;

    //
    //  List of requests to a particular server. Listed on Scb->Requests.
    //

    LIST_ENTRY NextRequest;

    //
    //  Used for processing synchronous IRPs.
    //

    KEVENT Event;   //  4 words

    //
    //  A pointer to the originating Irp and its original contents when
    //  the I/O system submitted it to the rdr.
    //

    PIRP pOriginalIrp;
    PVOID pOriginalSystemBuffer;
    PVOID pOriginalUserBuffer;
    PMDL pOriginalMdlAddress;

    //
    //  Information used if we need to post an IRP to process the receive
    //

    PIRP ReceiveIrp;

    //
    //  Pointer to the Mdl used to transmit/receive the Ncp header.
    //

    PMDL TxMdl;
    PMDL RxMdl;

    //
    //  Routine to run when this IRP context reaches the front of the
    //  SCB queue.
    //

    PRUN_ROUTINE RunRoutine;

    //
    //  Routine to handle the response Ncp
    //

    PEX pEx;

    //
    //  Routine to handle packet receipt
    //

    PRECEIVE_ROUTINE ReceiveDataRoutine;

    //
    //  Routine to handle FSP post processing.
    //

    PPOST_PROCESSOR PostProcessRoutine;

    //
    //  Routine to run when this IRP context times out while on the SCB
    //  queue.
    //

    PRUN_ROUTINE TimeoutRoutine;

    //
    //  Routine to run when this IRP has completed a send.
    //

    PIO_COMPLETION_ROUTINE CompletionSendRoutine;

    //
    //  Work Item used for scheduling reconnect.
    //

    PWORK_QUEUE_ITEM pWorkItem;

    //
    //  Buffer used to hold the Ncb to be transmitted/received.
    //

    ULONG Signature1;

    UCHAR req[MAX_SEND_DATA];
    ULONG Signature2;

    ULONG ResponseLength;
    UCHAR rsp[MAX_RECV_DATA];
    ULONG Signature3;

    //
    //  Address to be used in the Send Datagram.
    //

    TA_IPX_ADDRESS Destination;
    TDI_CONNECTION_INFORMATION ConnectionInformation;   //  Remote server

    //
    //  The ICB being processed.
    //

    PICB Icb;

    //
    //  Per IRP processor information.  A handy place to store information
    //  for the IRP in progress.
    //

    union {
        struct {
            UNICODE_STRING FullPathName;
            UNICODE_STRING VolumeName;
            UNICODE_STRING PathName;
            UNICODE_STRING FileName;
            BOOLEAN        NdsCreate;
            BOOLEAN        NeedNdsData;
            DWORD          dwNdsOid;
            DWORD          dwNdsObjectType;
            DWORD          dwNdsShareLength;
            UNICODE_STRING UidConnectName;
            WCHAR   DriveLetter;
            ULONG   ShareType;
            BOOLEAN fExCredentialCreate;
            PUNICODE_STRING puCredentialName;
            PCHAR   FindNearestResponse[4];
            ULONG   FindNearestResponseCount;
            LARGE_INTEGER UserUid;
        } Create;

        struct {
            PVOID   Buffer;
            ULONG   Length;
            PVCB    Vcb;
            CHAR VolumeNumber;
        } QueryVolumeInformation;

        struct {
            PVOID   Buffer;
            ULONG   Length;
            PMDL    InputMdl;
            UCHAR   Function;     //  Used for special case post-processing
            UCHAR   Subfunction;  //  during UserNcpCallback

        } FileSystemControl;

        struct {
            PVOID   Buffer;
            ULONG   WriteOffset;
            ULONG   RemainingLength;
            PMDL    PartialMdl;
            PMDL    FullMdl;
            ULONG   FileOffset;
            ULONG   LastWriteLength;

            ULONG   BurstOffset;
            ULONG   BurstLength;
            NTSTATUS Status;

            ULONG   TotalWriteLength;
            ULONG   TotalWriteOffset;

            ULONG   PacketCount;
        } Write;

        struct {
            ULONG   CacheReadSize;      //  Amount of data read from the cache
            ULONG   ReadAheadSize;      //  Extra data to read

            PVOID   Buffer;             //  Buffer for the current read
            PMDL    FullMdl;
            PMDL    PartialMdl;
            ULONG   ReadOffset;
            ULONG   RemainingLength;
            ULONG   FileOffset;
            ULONG   LastReadLength;

            LIST_ENTRY PacketList;      //  List of packets received
            ULONG   BurstRequestOffset; //  Offset in burst buffer for last request
            ULONG   BurstSize;          //  Number of bytes in current burst
            PVOID   BurstBuffer;        //  Buffer for the current burst
            BOOLEAN DataReceived;
            NTSTATUS Status;
            UCHAR   Flags;

            ULONG TotalReadLength;
            ULONG TotalReadOffset;
        } Read;

        struct {
            PNW_FILE_LOCK FileLock;
            ULONG   Key;
            BOOLEAN Wait;
            BOOLEAN ByKey;
            PLIST_ENTRY LastLock;
        } Lock;

    } Specific;

    struct {
        UCHAR Error;
    } ResponseParameters;

#ifdef NWDBG
    ULONG   DebugValue;
    ULONG   SequenceNumber;
#endif
} IRP_CONTEXT, *PIRP_CONTEXT;

typedef struct _BURST_READ_ENTRY {
    LIST_ENTRY ListEntry;
    ULONG   DataOffset;
    USHORT  ByteCount;
} BURST_READ_ENTRY, *PBURST_READ_ENTRY;

typedef struct _LOGON {

    //
    // The type and size of this record.
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    // List of Login records.
    //

    LIST_ENTRY     Next;

    UNICODE_STRING UserName;
    UNICODE_STRING PassWord;
    UNICODE_STRING ServerName;
    LARGE_INTEGER  UserUid;

    //
    // The NDS credential list, default tree,
    // and default context for this user.
    //

    ERESOURCE CredentialListResource;
    LIST_ENTRY NdsCredentialList;

} LOGON, *PLOGON;

typedef struct _MINI_IRP_CONTEXT {

    //
    //  Header information
    //

    NODE_TYPE_CODE NodeTypeCode;
    NODE_BYTE_SIZE NodeByteSize;

    //
    //  A link to queue IRP contexts
    //

    LIST_ENTRY  Next;

    PIRP_CONTEXT IrpContext;
    PIRP Irp;

    PVOID Buffer;      //  The buffer for this request.
    PMDL Mdl1;         //  The MDL for the buffer
    PMDL Mdl2;         //  The MDL for the data
} MINI_IRP_CONTEXT, *PMINI_IRP_CONTEXT;

//
// Definitions for unlockable code sections.
//

typedef struct _SECTION_DESCRIPTOR {
    PVOID Base;
    PVOID Handle;
    ULONG ReferenceCount;
} SECTION_DESCRIPTOR, *PSECTION_DESCRIPTOR;

#endif // _NWSTRUC_