Windows: Implement SRVSVC and WKSSVC RPC interfaces
[openafs.git] / src / WINNT / afsd / smb3.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #ifndef __SMB3_H_ENV__
11 #define __SMB3_H_ENV__ 1
12
13 typedef struct smb_tran2Packet {
14         osi_queue_t q;                  /* queue of all packets */
15         int com;                        /* Trans or Trans2 (0x25 or 0x32) */
16         int totalData;                  /* total # of expected data bytes */
17         int totalParms;                 /* total # of expected parm bytes */
18         int oldTotalParms;              /* initial estimate of parm bytes */
19         int curData;                    /* current # of received data bytes */
20         int curParms;                   /* current # of received parm bytes */
21         int maxReturnData;              /* max # of returned data bytes */
22         int maxReturnParms;             /* max # of returned parm bytes */
23     int setupCount;                     /* setup count field */
24         int opcode;                     /* subopcode we're handling */
25         long flags;                     /* flags */
26         smb_vc_t *vcp;                  /* virtual circuit we're dealing with */
27         unsigned short tid;             /* tid to match */
28         unsigned short mid;             /* mid to match */
29         unsigned short pid;             /* pid to remember */
30         unsigned short uid;             /* uid to remember */
31         unsigned short res[6];          /* contains PidHigh */
32     unsigned int error_code;            /* CM error code for the packet */
33         unsigned short *parmsp;         /* parms */
34         unsigned char *datap;           /* data bytes */
35     int pipeCommand;                    /* named pipe command code */
36     int pipeParam;                      /* pipe parameter, if there is one */
37     clientchar_t *name;                 /* contents of Name
38                                            field. Only used for Named
39                                            pipes */
40         cm_space_t * stringsp;          /* decoded strings */
41 } smb_tran2Packet_t;
42
43 /* for flags field */
44 #define SMB_TRAN2PFLAG_ALLOC    1
45 #define SMB_TRAN2PFLAG_USEUNICODE  2
46
47 typedef struct smb_tran2Dispatch {
48         long (*procp)(smb_vc_t *, smb_tran2Packet_t *, smb_packet_t *);
49         long flags;
50 } smb_tran2Dispatch_t;
51
52 /* Data Structures that are written to or read from the wire directly
53  * must be byte aligned (no padding).
54  */
55 #pragma pack(push, 1)
56 typedef struct smb_tran2QFSInfo {
57     union {
58         struct {
59             unsigned long FSID;                 /* file system ID */
60             unsigned long sectorsPerAllocUnit;
61             unsigned long totalAllocUnits;      /* on the disk */
62             unsigned long availAllocUnits;      /* free blocks */
63             unsigned short bytesPerSector;      /* bytes per sector */
64         } allocInfo;
65         struct {
66             unsigned long vsn;                  /* volume serial number */
67             char vnCount;                       /* count of chars in label, incl null */
68             char /* STRING */ label[24];        /* pad out with nulls */
69         } volumeInfo;
70         struct {
71             FILETIME      vct;          /* volume creation time */
72             unsigned long vsn;          /* volume serial number */
73             unsigned long vnCount;      /* length of volume label in bytes */
74             char res[2];                /* reserved */
75             char /* STRING */ label[20];        /* volume label */
76         } FSvolumeInfo;
77         struct {
78             LARGE_INTEGER totalAllocUnits;      /* on the disk */
79             LARGE_INTEGER availAllocUnits;      /* free blocks */
80             unsigned long sectorsPerAllocUnit;
81             unsigned long bytesPerSector;       /* bytes per sector */
82         } FSsizeInfo;
83         struct {
84             unsigned long devType;              /* device type */
85             unsigned long characteristics;
86         } FSdeviceInfo;
87         struct {
88             unsigned long attributes;
89             unsigned long maxCompLength;        /* max path component length */
90             unsigned long FSnameLength;         /* length of file system name */
91             unsigned char /* STRING */ FSname[24]; /* File system name */
92         } FSattributeInfo;
93     } u;
94 } smb_tran2QFSInfo_t;
95
96 typedef struct {
97     union {
98         struct {
99             unsigned long  creationDateTime;    /* SMB_DATE / SMB_TIME */
100             unsigned long  lastAccessDateTime;  /* SMB_DATE / SMB_TIME */
101             unsigned long  lastWriteDateTime;   /* SMB_DATE / SMB_TIME */
102             unsigned long  dataSize;
103             unsigned long  allocationSize;
104             unsigned short attributes;
105             unsigned long  eaSize;
106         } QPstandardInfo;
107         struct {
108             unsigned long  creationDateTime;    /* SMB_DATE / SMB_TIME */
109             unsigned long  lastAccessDateTime;  /* SMB_DATE / SMB_TIME */
110             unsigned long  lastWriteDateTime;   /* SMB_DATE / SMB_TIME */
111             unsigned long  dataSize;
112             unsigned long  allocationSize;
113             unsigned short attributes;
114             unsigned long  eaSize;
115         } QPeaSizeInfo;
116         struct {
117             unsigned short maxDataCount;
118             unsigned short eaErrorOffset;
119             unsigned long  listLength;
120             unsigned char  eaList[128];
121         } QPeasFromListInfo;
122         struct {
123             unsigned short maxDataCount;
124             unsigned short eaErrorOffset;
125             unsigned long  listLength;
126             unsigned char  eaList[128];
127         } QPallEasInfo;
128         struct {
129             FILETIME       creationTime;
130             FILETIME       lastAccessTime;
131             FILETIME       lastWriteTime;
132             FILETIME       changeTime;
133             unsigned long  attributes;
134             unsigned long  reserved;
135         } QPfileBasicInfo;
136         struct {
137             LARGE_INTEGER  allocationSize;
138             LARGE_INTEGER  endOfFile;
139             unsigned long  numberOfLinks;
140             unsigned char  deletePending;
141             unsigned char  directory;
142             unsigned short reserved;
143         } QPfileStandardInfo;
144         struct {
145             unsigned long  eaSize;
146         } QPfileEaInfo;
147         struct {
148             unsigned long  fileNameLength;
149             unsigned char  fileName[512]; /* STRING */
150         } QPfileNameInfo;
151         struct {
152             FILETIME       creationTime;
153             FILETIME       lastAccessTime;
154             FILETIME       lastWriteTime;
155             FILETIME       changeTime;
156             unsigned long  attributes;
157             LARGE_INTEGER  allocationSize;
158             LARGE_INTEGER  endOfFile;
159             unsigned long  numberOfLinks;
160             unsigned char  deletePending;
161             unsigned char  directory;
162             LARGE_INTEGER  indexNumber;
163             unsigned long  eaSize;
164             unsigned long  accessFlags;
165             LARGE_INTEGER  indexNumber2;
166             LARGE_INTEGER  currentByteOffset;
167             unsigned long  mode;
168             unsigned long  alignmentRequirement;
169             unsigned long  fileNameLength;
170             unsigned char  fileName[512]; /* STRING */
171         } QPfileAllInfo;
172         struct {
173             unsigned long  fileNameLength;
174             unsigned char  fileName[512]; /* STRING */
175         } QPfileAltNameInfo;
176         struct {
177             unsigned long  nextEntryOffset;
178             unsigned long  streamNameLength;
179             LARGE_INTEGER  streamSize;
180             LARGE_INTEGER  streamAllocationSize;
181             unsigned char  fileName[512]; /* STRING */
182         } QPfileStreamInfo;
183         struct {
184             LARGE_INTEGER  compressedFileSize;
185             unsigned short compressionFormat;
186             unsigned char  compressionUnitShift;
187             unsigned char  chuckShift;
188             unsigned char  clusterShift;
189             unsigned char  reserved[3];
190         } QPfileCompressionInfo;
191     } u;
192 } smb_tran2QPathInfo_t;
193
194 typedef struct {
195     union {
196         struct {
197             FILETIME       creationTime;
198             FILETIME       lastAccessTime;
199             FILETIME       lastWriteTime;
200             FILETIME       lastChangeTime;
201             unsigned long  attributes;
202         } QFbasicInfo;
203         struct {
204             LARGE_INTEGER  allocationSize;
205             LARGE_INTEGER  endOfFile;
206             unsigned long  numberOfLinks;
207             unsigned char  deletePending;
208             unsigned char  directory;
209         } QFstandardInfo;
210         struct {
211             unsigned long  eaSize;
212         } QFeaInfo;
213         struct {        
214             unsigned long  fileNameLength;
215             unsigned char  fileName[512];
216         } QFfileNameInfo;
217     } u;
218 } smb_tran2QFileInfo_t;
219
220 typedef struct {
221     unsigned long  creationDateTime;    /* SMB_DATE / SMB_TIME */
222     unsigned long  lastAccessDateTime;  /* SMB_DATE / SMB_TIME */
223     unsigned long  lastWriteDateTime;   /* SMB_DATE / SMB_TIME */
224     unsigned long  dataSize;
225     unsigned long  allocationSize;
226     unsigned short attributes;
227 } smb_V3FileAttrsShort;
228
229 typedef struct {
230     FILETIME       creationTime;
231     FILETIME       lastAccessTime;
232     FILETIME       lastWriteTime;
233     FILETIME       lastChangeTime;
234     LARGE_INTEGER  endOfFile;
235     LARGE_INTEGER  allocationSize;
236     unsigned long  extFileAttributes;
237 } smb_V3FileAttrsLong;
238
239 typedef struct {
240     union {
241         struct {
242             smb_V3FileAttrsShort fileAttrs;
243             unsigned char  fileNameLength;
244             /* STRING fileName */
245         } FstandardInfo;
246
247         struct {
248             smb_V3FileAttrsShort fileAttrs;
249             unsigned long  eaSize;
250             unsigned char  fileNameLength;
251             /* STRING fileName */
252         } FeaSizeInfo, FeasFromListInfo;
253
254         struct {
255             unsigned long  nextEntryOffset;
256             unsigned long  fileIndex;
257             smb_V3FileAttrsLong fileAttrs;
258             unsigned long  fileNameLength;
259             /* STRING fileName */
260         } FfileDirectoryInfo;
261
262         struct {
263             unsigned long  nextEntryOffset;
264             unsigned long  fileIndex;
265             smb_V3FileAttrsLong fileAttrs;
266             unsigned long  fileNameLength;
267             unsigned long  eaSize;
268             /* STRING fileName */
269         } FfileFullDirectoryInfo;
270
271         struct {
272             unsigned long  nextEntryOffset;
273             unsigned long  fileIndex;
274             smb_V3FileAttrsLong fileAttrs;
275             unsigned long  fileNameLength;
276             unsigned long  eaSize;
277             unsigned char  shortNameLength;
278             unsigned char  reserved;
279             wchar_t        shortName[12];
280             /* STRING fileName */
281         } FfileBothDirectoryInfo;
282
283         struct {
284             unsigned long  nextEntryOffset;
285             unsigned long  fileIndex;
286             unsigned long  fileNameLength;
287             /* STRING fileName */
288         } FfileNamesInfo;
289     } u;
290 } smb_tran2Find_t;
291
292 #pragma pack(pop)
293
294 /* more than enough opcodes for today, anyway */
295 #define SMB_TRAN2_NOPCODES              20
296
297 extern smb_tran2Dispatch_t smb_tran2DispatchTable[SMB_TRAN2_NOPCODES];
298
299 #define SMB_RAP_NOPCODES        64
300
301 extern smb_tran2Dispatch_t smb_rapDispatchTable[SMB_RAP_NOPCODES];
302
303 extern smb_tran2Packet_t *smb_GetTran2ResponsePacket(smb_vc_t *vcp,
304                                                      smb_tran2Packet_t *inp, smb_packet_t *outp,
305                                                      int totalParms, int totalData);
306
307 extern void smb_FreeTran2Packet(smb_tran2Packet_t *t2p);
308
309 extern void smb_SendTran2Packet(smb_vc_t *vcp, smb_tran2Packet_t *t2p, smb_packet_t *tp);
310
311 extern long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
312
313 extern long smb_ReceiveV3TreeConnectX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
314
315 extern long smb_ReceiveV3Trans(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
316
317 extern long smb_ReceiveV3Tran2A(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
318
319 extern long smb_ReceiveRAPNetShareEnum(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
320
321 extern long smb_ReceiveRAPNetShareGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
322
323 extern long smb_ReceiveRAPNetWkstaGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
324
325 extern long smb_ReceiveRAPNetServerGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op);
326
327 extern long smb_ReceiveTran2Open(smb_vc_t *vcp, smb_tran2Packet_t *p,
328         smb_packet_t *outp);
329
330 extern long smb_ReceiveTran2FindFirst(smb_vc_t *vcp, smb_tran2Packet_t *p,
331         smb_packet_t *outp);
332
333 extern long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p,
334         smb_packet_t *outp);
335
336 extern long smb_ReceiveTran2FindNext(smb_vc_t *vcp, smb_tran2Packet_t *p,
337         smb_packet_t *outp);
338
339 extern long smb_ReceiveTran2QFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
340         smb_packet_t *outp);
341
342 extern long smb_ReceiveTran2SetFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
343         smb_packet_t *outp);
344
345 extern long smb_ReceiveTran2QFSInfoFid(smb_vc_t *vcp, smb_tran2Packet_t *p,
346         smb_packet_t *outp);
347
348 extern long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
349         smb_packet_t *outp);
350
351 extern long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
352         smb_packet_t *outp);
353
354 extern long smb_ReceiveTran2QFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
355         smb_packet_t *outp);
356
357 extern long smb_ReceiveTran2SetFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p,
358         smb_packet_t *outp);
359
360 extern long smb_ReceiveTran2FSCTL(smb_vc_t *vcp, smb_tran2Packet_t *p,
361         smb_packet_t *outp);
362
363 extern long smb_ReceiveTran2IOCTL(smb_vc_t *vcp, smb_tran2Packet_t *p,
364         smb_packet_t *outp);
365
366 extern long smb_ReceiveTran2FindNotifyFirst(smb_vc_t *vcp, smb_tran2Packet_t *p,
367         smb_packet_t *outp);
368
369 extern long smb_ReceiveTran2FindNotifyNext(smb_vc_t *vcp, smb_tran2Packet_t *p,
370         smb_packet_t *outp);
371
372 extern long smb_ReceiveTran2CreateDirectory(smb_vc_t *vcp, smb_tran2Packet_t *p,
373         smb_packet_t *outp);
374
375 extern long smb_ReceiveTran2SessionSetup(smb_vc_t *vcp, smb_tran2Packet_t *p,
376         smb_packet_t *outp);
377
378 extern long smb_ReceiveTran2GetDFSReferral(smb_vc_t *vcp, smb_tran2Packet_t *p,
379         smb_packet_t *outp);
380
381 extern long smb_ReceiveTran2ReportDFSInconsistency(smb_vc_t *vcp, smb_tran2Packet_t *p,
382         smb_packet_t *outp);
383
384 extern long smb_ReceiveV3FindClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
385
386 extern long smb_ReceiveV3FindNotifyClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
387
388 extern long smb_ReceiveV3UserLogoffX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
389
390 extern long smb_ReceiveV3OpenX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
391
392 extern long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
393
394 extern long smb_ReceiveV3GetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
395
396 extern long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
397
398 extern long smb_ReceiveV3WriteX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
399
400 extern long smb_ReceiveV3SetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
401
402 extern long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
403
404 extern long smb_ReceiveNTTransact(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
405
406 extern void smb_NotifyChange(DWORD action, DWORD notifyFilter,
407         cm_scache_t *dscp, clientchar_t *filename, clientchar_t *otherFilename,
408         BOOL isDirectParent);
409
410 extern long smb_ReceiveNTCancel(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
411
412 extern long smb_ReceiveNTRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
413
414 extern unsigned long smb_ExtAttributes(cm_scache_t *scp);
415
416 extern void smb3_Init();
417
418 /* SMB auth related functions */
419 extern void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength);
420
421 /* Some of the FILE_NOTIFY_CHANGE values are undefined in winnt.h */
422 #define FILE_NOTIFY_CHANGE_EA           0x00000080
423 #define FILE_NOTIFY_CHANGE_STREAM_NAME  0x00000200
424 #define FILE_NOTIFY_CHANGE_STREAM_SIZE  0x00000400
425 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800
426 #endif /*  __SMB3_H_ENV__ */