OpenAFS
OpenAFS distributed network file system
|
00001 /* 00002 * Copyright 2000, International Business Machines Corporation and others. 00003 * All Rights Reserved. 00004 * 00005 * This software has been released under the terms of the IBM Public 00006 * License. For details, see the LICENSE file in the top-level source 00007 * directory or online at http://www.openafs.org/dl/license10.html 00008 */ 00009 00010 #ifndef OPENAFS_WINNT_AFSD_SMB3_H 00011 #define OPENAFS_WINNT_AFSD_SMB3_H 1 00012 00013 typedef struct smb_tran2Packet { 00014 osi_queue_t q; /* queue of all packets */ 00015 int com; /* Trans or Trans2 (0x25 or 0x32) */ 00016 int totalData; /* total # of expected data bytes */ 00017 int totalParms; /* total # of expected parm bytes */ 00018 int oldTotalParms; /* initial estimate of parm bytes */ 00019 int curData; /* current # of received data bytes */ 00020 int curParms; /* current # of received parm bytes */ 00021 int maxReturnData; /* max # of returned data bytes */ 00022 int maxReturnParms; /* max # of returned parm bytes */ 00023 int setupCount; /* setup count field */ 00024 int opcode; /* subopcode we're handling */ 00025 long flags; /* flags */ 00026 smb_vc_t *vcp; /* virtual circuit we're dealing with */ 00027 unsigned short tid; /* tid to match */ 00028 unsigned short mid; /* mid to match */ 00029 unsigned short pid; /* pid to remember */ 00030 unsigned short uid; /* uid to remember */ 00031 unsigned short res[6]; /* contains PidHigh */ 00032 unsigned int error_code; /* CM error code for the packet */ 00033 unsigned short *parmsp; /* parms */ 00034 unsigned char *datap; /* data bytes */ 00035 int pipeCommand; /* named pipe command code */ 00036 int pipeParam; /* pipe parameter, if there is one */ 00037 clientchar_t *name; /* contents of Name 00038 field. Only used for Named 00039 pipes */ 00040 cm_space_t * stringsp; /* decoded strings */ 00041 } smb_tran2Packet_t; 00042 00043 /* for flags field */ 00044 #define SMB_TRAN2PFLAG_ALLOC 1 00045 #define SMB_TRAN2PFLAG_USEUNICODE 2 00046 00047 typedef struct smb_tran2Dispatch { 00048 long (*procp)(smb_vc_t *, smb_tran2Packet_t *, smb_packet_t *); 00049 long flags; 00050 } smb_tran2Dispatch_t; 00051 00052 /* Data Structures that are written to or read from the wire directly 00053 * must be byte aligned (no padding). 00054 */ 00055 #pragma pack(push, 1) 00056 typedef struct smb_tran2QFSInfo { 00057 union { 00058 struct { 00059 unsigned long FSID; /* file system ID */ 00060 unsigned long sectorsPerAllocUnit; 00061 unsigned long totalAllocUnits; /* on the disk */ 00062 unsigned long availAllocUnits; /* free blocks */ 00063 unsigned short bytesPerSector; /* bytes per sector */ 00064 } allocInfo; 00065 struct { 00066 unsigned long vsn; /* volume serial number */ 00067 char vnCount; /* count of chars in label, incl null */ 00068 char /* STRING */ label[24]; /* pad out with nulls */ 00069 } volumeInfo; 00070 struct { 00071 FILETIME vct; /* volume creation time */ 00072 unsigned long vsn; /* volume serial number */ 00073 unsigned long vnCount; /* length of volume label in bytes */ 00074 char res[2]; /* reserved */ 00075 char /* STRING */ label[20]; /* volume label */ 00076 } FSvolumeInfo; 00077 struct { 00078 LARGE_INTEGER totalAllocUnits; /* on the disk */ 00079 LARGE_INTEGER availAllocUnits; /* free blocks */ 00080 unsigned long sectorsPerAllocUnit; 00081 unsigned long bytesPerSector; /* bytes per sector */ 00082 } FSsizeInfo; 00083 struct { 00084 unsigned long devType; /* device type */ 00085 unsigned long characteristics; 00086 } FSdeviceInfo; 00087 struct { 00088 unsigned long attributes; 00089 unsigned long maxCompLength; /* max path component length */ 00090 unsigned long FSnameLength; /* length of file system name */ 00091 unsigned char /* STRING */ FSname[24]; /* File system name */ 00092 } FSattributeInfo; 00093 } u; 00094 } smb_tran2QFSInfo_t; 00095 00096 typedef struct { 00097 union { 00098 struct { 00099 unsigned long creationDateTime; /* SMB_DATE / SMB_TIME */ 00100 unsigned long lastAccessDateTime; /* SMB_DATE / SMB_TIME */ 00101 unsigned long lastWriteDateTime; /* SMB_DATE / SMB_TIME */ 00102 unsigned long dataSize; 00103 unsigned long allocationSize; 00104 unsigned short attributes; 00105 unsigned long eaSize; 00106 } QPstandardInfo; 00107 struct { 00108 unsigned long creationDateTime; /* SMB_DATE / SMB_TIME */ 00109 unsigned long lastAccessDateTime; /* SMB_DATE / SMB_TIME */ 00110 unsigned long lastWriteDateTime; /* SMB_DATE / SMB_TIME */ 00111 unsigned long dataSize; 00112 unsigned long allocationSize; 00113 unsigned short attributes; 00114 unsigned long eaSize; 00115 } QPeaSizeInfo; 00116 struct { 00117 unsigned short maxDataCount; 00118 unsigned short eaErrorOffset; 00119 unsigned long listLength; 00120 unsigned char eaList[128]; 00121 } QPeasFromListInfo; 00122 struct { 00123 unsigned short maxDataCount; 00124 unsigned short eaErrorOffset; 00125 unsigned long listLength; 00126 unsigned char eaList[128]; 00127 } QPallEasInfo; 00128 struct { 00129 FILETIME creationTime; 00130 FILETIME lastAccessTime; 00131 FILETIME lastWriteTime; 00132 FILETIME changeTime; 00133 unsigned long attributes; 00134 unsigned long reserved; 00135 } QPfileBasicInfo; 00136 struct { 00137 LARGE_INTEGER allocationSize; 00138 LARGE_INTEGER endOfFile; 00139 unsigned long numberOfLinks; 00140 unsigned char deletePending; 00141 unsigned char directory; 00142 unsigned short reserved; 00143 } QPfileStandardInfo; 00144 struct { 00145 unsigned long eaSize; 00146 } QPfileEaInfo; 00147 struct { 00148 unsigned long fileNameLength; 00149 unsigned char fileName[512]; /* STRING */ 00150 } QPfileNameInfo; 00151 struct { 00152 FILETIME creationTime; 00153 FILETIME lastAccessTime; 00154 FILETIME lastWriteTime; 00155 FILETIME changeTime; 00156 unsigned long attributes; 00157 LARGE_INTEGER allocationSize; 00158 LARGE_INTEGER endOfFile; 00159 unsigned long numberOfLinks; 00160 unsigned char deletePending; 00161 unsigned char directory; 00162 LARGE_INTEGER indexNumber; 00163 unsigned long eaSize; 00164 unsigned long accessFlags; 00165 LARGE_INTEGER indexNumber2; 00166 LARGE_INTEGER currentByteOffset; 00167 unsigned long mode; 00168 unsigned long alignmentRequirement; 00169 unsigned long fileNameLength; 00170 unsigned char fileName[512]; /* STRING */ 00171 } QPfileAllInfo; 00172 struct { 00173 unsigned long fileNameLength; 00174 unsigned char fileName[512]; /* STRING */ 00175 } QPfileAltNameInfo; 00176 struct { 00177 unsigned long nextEntryOffset; 00178 unsigned long streamNameLength; 00179 LARGE_INTEGER streamSize; 00180 LARGE_INTEGER streamAllocationSize; 00181 unsigned char fileName[512]; /* STRING */ 00182 } QPfileStreamInfo; 00183 struct { 00184 LARGE_INTEGER compressedFileSize; 00185 unsigned short compressionFormat; 00186 unsigned char compressionUnitShift; 00187 unsigned char chuckShift; 00188 unsigned char clusterShift; 00189 unsigned char reserved[3]; 00190 } QPfileCompressionInfo; 00191 } u; 00192 } smb_tran2QPathInfo_t; 00193 00194 typedef struct { 00195 union { 00196 struct { 00197 FILETIME creationTime; 00198 FILETIME lastAccessTime; 00199 FILETIME lastWriteTime; 00200 FILETIME lastChangeTime; 00201 unsigned long attributes; 00202 } QFbasicInfo; 00203 struct { 00204 LARGE_INTEGER allocationSize; 00205 LARGE_INTEGER endOfFile; 00206 unsigned long numberOfLinks; 00207 unsigned char deletePending; 00208 unsigned char directory; 00209 } QFstandardInfo; 00210 struct { 00211 unsigned long eaSize; 00212 } QFeaInfo; 00213 struct { 00214 unsigned long fileNameLength; 00215 unsigned char fileName[512]; 00216 } QFfileNameInfo; 00217 struct { 00218 unsigned long nextEntryOffset; 00219 unsigned long streamNameLength; 00220 LARGE_INTEGER streamSize; 00221 LARGE_INTEGER streamAllocationSize; 00222 unsigned char fileName[512]; /* STRING */ 00223 } QFfileStreamInfo; 00224 struct { 00225 LARGE_INTEGER creationTime; 00226 LARGE_INTEGER lastAccessTime; 00227 LARGE_INTEGER lastWriteTime; 00228 LARGE_INTEGER lastChangeTime; 00229 LARGE_INTEGER allocationSize; 00230 LARGE_INTEGER endOfFile; 00231 unsigned long attributes; 00232 } QFnetworkOpenInfo; 00233 } u; 00234 } smb_tran2QFileInfo_t; 00235 00236 typedef struct { 00237 unsigned long creationDateTime; /* SMB_DATE / SMB_TIME */ 00238 unsigned long lastAccessDateTime; /* SMB_DATE / SMB_TIME */ 00239 unsigned long lastWriteDateTime; /* SMB_DATE / SMB_TIME */ 00240 unsigned long dataSize; 00241 unsigned long allocationSize; 00242 unsigned short attributes; 00243 } smb_V3FileAttrsShort; 00244 00245 typedef struct { 00246 FILETIME creationTime; 00247 FILETIME lastAccessTime; 00248 FILETIME lastWriteTime; 00249 FILETIME lastChangeTime; 00250 LARGE_INTEGER endOfFile; 00251 LARGE_INTEGER allocationSize; 00252 unsigned long extFileAttributes; 00253 } smb_V3FileAttrsLong; 00254 00255 typedef struct { 00256 union { 00257 struct { 00258 smb_V3FileAttrsShort fileAttrs; 00259 unsigned char fileNameLength; 00260 /* STRING fileName */ 00261 } FstandardInfo; 00262 00263 struct { 00264 smb_V3FileAttrsShort fileAttrs; 00265 unsigned long eaSize; 00266 unsigned char fileNameLength; 00267 /* STRING fileName */ 00268 } FeaSizeInfo, FeasFromListInfo; 00269 00270 struct { 00271 unsigned long nextEntryOffset; 00272 unsigned long fileIndex; 00273 smb_V3FileAttrsLong fileAttrs; 00274 unsigned long fileNameLength; 00275 /* STRING fileName */ 00276 } FfileDirectoryInfo; 00277 00278 struct { 00279 unsigned long nextEntryOffset; 00280 unsigned long fileIndex; 00281 smb_V3FileAttrsLong fileAttrs; 00282 unsigned long fileNameLength; 00283 unsigned long eaSize; 00284 /* STRING fileName */ 00285 } FfileFullDirectoryInfo; 00286 00287 struct { 00288 unsigned long nextEntryOffset; 00289 unsigned long fileIndex; 00290 smb_V3FileAttrsLong fileAttrs; 00291 unsigned long fileNameLength; 00292 unsigned long eaSize; 00293 unsigned char shortNameLength; 00294 unsigned char reserved; 00295 wchar_t shortName[12]; 00296 /* STRING fileName */ 00297 } FfileBothDirectoryInfo; 00298 00299 struct { 00300 unsigned long nextEntryOffset; 00301 unsigned long fileIndex; 00302 unsigned long fileNameLength; 00303 /* STRING fileName */ 00304 } FfileNamesInfo; 00305 } u; 00306 } smb_tran2Find_t; 00307 00308 #pragma pack(pop) 00309 00310 /* more than enough opcodes for today, anyway */ 00311 #define SMB_TRAN2_NOPCODES 20 00312 00313 extern smb_tran2Dispatch_t smb_tran2DispatchTable[SMB_TRAN2_NOPCODES]; 00314 00315 #define SMB_RAP_NOPCODES 64 00316 00317 extern smb_tran2Dispatch_t smb_rapDispatchTable[SMB_RAP_NOPCODES]; 00318 00319 extern smb_tran2Packet_t *smb_GetTran2ResponsePacket(smb_vc_t *vcp, 00320 smb_tran2Packet_t *inp, smb_packet_t *outp, 00321 int totalParms, int totalData); 00322 00323 extern void smb_FreeTran2Packet(smb_tran2Packet_t *t2p); 00324 00325 extern void smb_SendTran2Packet(smb_vc_t *vcp, smb_tran2Packet_t *t2p, smb_packet_t *tp); 00326 00327 extern long smb_ReceiveV3SessionSetupX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00328 00329 extern long smb_ReceiveV3TreeConnectX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00330 00331 extern long smb_ReceiveV3Trans(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00332 00333 extern long smb_ReceiveV3Tran2A(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00334 00335 extern long smb_ReceiveRAPNetShareEnum(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op); 00336 00337 extern long smb_ReceiveRAPNetShareGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op); 00338 00339 extern long smb_ReceiveRAPNetWkstaGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op); 00340 00341 extern long smb_ReceiveRAPNetServerGetInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op); 00342 00343 extern long smb_ReceiveTran2Open(smb_vc_t *vcp, smb_tran2Packet_t *p, 00344 smb_packet_t *outp); 00345 00346 extern long smb_ReceiveTran2FindFirst(smb_vc_t *vcp, smb_tran2Packet_t *p, 00347 smb_packet_t *outp); 00348 00349 extern long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, 00350 smb_packet_t *outp); 00351 00352 extern long smb_ReceiveTran2FindNext(smb_vc_t *vcp, smb_tran2Packet_t *p, 00353 smb_packet_t *outp); 00354 00355 extern long smb_ReceiveTran2QFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, 00356 smb_packet_t *outp); 00357 00358 extern long smb_ReceiveTran2SetFSInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, 00359 smb_packet_t *outp); 00360 00361 extern long smb_ReceiveTran2QFSInfoFid(smb_vc_t *vcp, smb_tran2Packet_t *p, 00362 smb_packet_t *outp); 00363 00364 extern long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, 00365 smb_packet_t *outp); 00366 00367 extern long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, 00368 smb_packet_t *outp); 00369 00370 extern long smb_ReceiveTran2QFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, 00371 smb_packet_t *outp); 00372 00373 extern long smb_ReceiveTran2SetFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, 00374 smb_packet_t *outp); 00375 00376 extern long smb_ReceiveTran2FSCTL(smb_vc_t *vcp, smb_tran2Packet_t *p, 00377 smb_packet_t *outp); 00378 00379 extern long smb_ReceiveTran2IOCTL(smb_vc_t *vcp, smb_tran2Packet_t *p, 00380 smb_packet_t *outp); 00381 00382 extern long smb_ReceiveTran2FindNotifyFirst(smb_vc_t *vcp, smb_tran2Packet_t *p, 00383 smb_packet_t *outp); 00384 00385 extern long smb_ReceiveTran2FindNotifyNext(smb_vc_t *vcp, smb_tran2Packet_t *p, 00386 smb_packet_t *outp); 00387 00388 extern long smb_ReceiveTran2CreateDirectory(smb_vc_t *vcp, smb_tran2Packet_t *p, 00389 smb_packet_t *outp); 00390 00391 extern long smb_ReceiveTran2SessionSetup(smb_vc_t *vcp, smb_tran2Packet_t *p, 00392 smb_packet_t *outp); 00393 00394 extern long smb_ReceiveTran2GetDFSReferral(smb_vc_t *vcp, smb_tran2Packet_t *p, 00395 smb_packet_t *outp); 00396 00397 extern long smb_ReceiveTran2ReportDFSInconsistency(smb_vc_t *vcp, smb_tran2Packet_t *p, 00398 smb_packet_t *outp); 00399 00400 extern long smb_ReceiveV3FindClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00401 00402 extern long smb_ReceiveV3FindNotifyClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00403 00404 extern long smb_ReceiveV3UserLogoffX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00405 00406 extern long smb_ReceiveV3OpenX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00407 00408 extern long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00409 00410 extern long smb_ReceiveV3GetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00411 00412 extern long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00413 00414 extern long smb_ReceiveV3WriteX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00415 00416 extern long smb_ReceiveV3SetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00417 00418 extern long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00419 00420 extern long smb_ReceiveNTTransact(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00421 00422 extern void smb_NotifyChange(DWORD action, DWORD notifyFilter, 00423 cm_scache_t *dscp, clientchar_t *filename, clientchar_t *otherFilename, 00424 BOOL isDirectParent); 00425 00426 extern long smb_ReceiveNTCancel(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00427 00428 extern long smb_ReceiveNTRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp); 00429 00430 extern unsigned long smb_ExtAttributes(cm_scache_t *scp); 00431 00432 extern void smb3_Init(); 00433 00434 /* SMB auth related functions */ 00435 extern void smb_NegotiateExtendedSecurity(void ** secBlob, int * secBlobLength); 00436 00437 /* Some of the FILE_NOTIFY_CHANGE values are undefined in winnt.h */ 00438 #define FILE_NOTIFY_CHANGE_EA 0x00000080 00439 #define FILE_NOTIFY_CHANGE_STREAM_NAME 0x00000200 00440 #define FILE_NOTIFY_CHANGE_STREAM_SIZE 0x00000400 00441 #define FILE_NOTIFY_CHANGE_STREAM_WRITE 0x00000800 00442 00443 /* NT Create Device Status bit flags */ 00444 #define NO_REPARSETAG 0x0004 00445 #define NO_SUBSTREAMS 0x0002 00446 #define NO_EAS 0x0001 00447 00448 extern afs_uint32 smb_GetLogonSID(HANDLE hToken, PSID *ppsid); 00449 extern afs_uint32 smb_GetUserSID(HANDLE hToken, PSID *ppsid); 00450 extern void smb_FreeSID (PSID psid); 00451 00452 #endif /* OPENAFS_WINNT_AFSD_SMB3_H */