Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

389 lines
10 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. smbtypes.h
  5. Abstract:
  6. This module defines types related to SMB processing.
  7. Author:
  8. Chuck Lenzmeier (chuckl) 1-Dec-1989
  9. David Treadwell (davidtr)
  10. Revision History:
  11. --*/
  12. #ifndef _SMBTYPES_
  13. #define _SMBTYPES_
  14. //#include <nt.h>
  15. //
  16. // SMBDBG determines whether the get/put macros (in smbgtpt.h) are
  17. // instead defined as function calls. (This is used to more reliably
  18. // find char/short/long mismatches.
  19. //
  20. #ifndef SMBDBG
  21. #define SMBDBG 0
  22. #endif
  23. //
  24. // SMBDBG1 determines whether the names of short and long fields in SMB
  25. // structures have an extra character appended. This is used to ensure
  26. // that these fields are only accessed via the get/put macros. SMBDBG1
  27. // must be disabled when SMBDBG is enabled.
  28. //
  29. #ifndef SMBDBG1
  30. #define SMBDBG1 0
  31. #endif
  32. #if SMBDBG && SMBDBG1
  33. #undef SMBDBG1
  34. #define SMBDBG1 0
  35. #endif
  36. //
  37. // If __unaligned support is available, or if we're compiling for a
  38. // machine that handles unaligned accesses in hardware, then define
  39. // SMB_USE_UNALIGNED as 1 (TRUE). Otherwise, define it as 0 (FALSE).
  40. // If SMB_USE_UNALIGNED is FALSE, then the macros below use byte
  41. // accesses to build up word and longword accesses to unaligned fields.
  42. //
  43. // Currently, the machines we build for all have SMB_USE_UNALIGNED as
  44. // TRUE. x86 supports unaligned accesses in hardware, while the MIPS
  45. // compiler supports the __unaligned keyword.
  46. //
  47. // Note that if SMB_USE_UNALIGNED is predefined, we use that definition.
  48. // Also, if SMB_NO_UNALIGNED is defined as TRUE, it forces
  49. // SMB_USE_ALIGNED off. This allows us to force, for testing purposes,
  50. // use of byte accesses in the macros.
  51. //
  52. #ifndef SMB_NO_UNALIGNED
  53. #define SMB_NO_UNALIGNED 0
  54. #endif
  55. #ifndef SMB_USE_UNALIGNED
  56. #if SMB_NO_UNALIGNED
  57. #define SMB_USE_UNALIGNED 0
  58. #else
  59. #define SMB_USE_UNALIGNED 1
  60. #endif
  61. #endif
  62. //
  63. // ntdef.h defines UNALIGNED as "__unaligned" or "", depending on
  64. // whether we're building for MIPS or x86, respectively. Because we
  65. // want to be able to disable use of __unaligned, we define
  66. // SMB_UNALIGNED as "UNALIGNED" or "", depending on whether
  67. // SMB_USE_UNALIGNED is TRUE or FALSE, respectively.
  68. //
  69. #if SMB_USE_UNALIGNED
  70. #define SMB_UNALIGNED UNALIGNED
  71. #else
  72. #define SMB_UNALIGNED
  73. #endif
  74. //
  75. // For ease of use, we define types for unaligned pointers to shorts
  76. // and longs in SMBs. Note that "PUSHORT UNALIGNED" doesn't work.
  77. //
  78. typedef unsigned short SMB_UNALIGNED *PSMB_USHORT;
  79. typedef unsigned long SMB_UNALIGNED *PSMB_ULONG;
  80. //
  81. // Macros for renaming short and long SMB fields.
  82. //
  83. #if SMBDBG1
  84. #define _USHORT( field ) USHORT field ## S
  85. #define _ULONG( field ) ULONG field ## L
  86. #else
  87. #define _USHORT( field ) USHORT field
  88. #define _ULONG( field ) ULONG field
  89. #endif
  90. //
  91. // Force misalignment of the following structures
  92. //
  93. #ifndef NO_PACKING
  94. #include <packon.h>
  95. #endif // ndef NO_PACKING
  96. //
  97. // The SMB_DIALECT type corresponds to the different SMB dialects
  98. // that the server can speak. Associated with it is the DialectStrings[]
  99. // array that holds information about the ASCIIZ strings that are passed
  100. // in the Negotiate SMB.s
  101. //
  102. // These are listed in order from highest preference to lowest preference.
  103. // The assigned numbers correspond to the array SrvClientTypes[] in the
  104. // server module srvdata.c.
  105. //
  106. typedef enum _SMB_DIALECT {
  107. SmbDialectCairo, // Cairo
  108. #ifdef INCLUDE_SMB_IFMODIFIED
  109. SmbDialectNtLanMan2, // NT LAN Man for beyond Win2000
  110. #endif
  111. SmbDialectNtLanMan, // NT LAN Man
  112. SmbDialectLanMan21, // OS/2 Lanman 2.1
  113. SmbDialectDosLanMan21, // DOS Lanman 2.1
  114. SmbDialectLanMan20, // OS/2 1.2 LanMan 2.0
  115. SmbDialectDosLanMan20, // DOS LanMan 2.0
  116. SmbDialectLanMan10, // 1st version of full LanMan extensions
  117. SmbDialectMsNet30, // Larger subset of LanMan extensions
  118. SmbDialectMsNet103, // Limited subset of LanMan extensions
  119. SmbDialectPcLan10, // Alternate original protocol
  120. SmbDialectPcNet10, // Original protocol
  121. SmbDialectIllegal,
  122. } SMB_DIALECT, *PSMB_DIALECT;
  123. #define FIRST_DIALECT SmbDialectCairo
  124. #ifdef INCLUDE_SMB_IFMODIFIED
  125. #define FIRST_DIALECT_EMULATED SmbDialectNtLanMan2
  126. #else
  127. #define FIRST_DIALECT_EMULATED SmbDialectNtLanMan
  128. #endif
  129. #define LAST_DIALECT SmbDialectIllegal
  130. #define IS_DOS_DIALECT(dialect) \
  131. ( (BOOLEAN)( (dialect) == SmbDialectDosLanMan21 || \
  132. (dialect) == SmbDialectDosLanMan20 || \
  133. (dialect) > SmbDialectLanMan10 ) )
  134. #define IS_OS2_DIALECT(dialect) ( (BOOLEAN)!IS_DOS_DIALECT(dialect) )
  135. #ifdef INCLUDE_SMB_IFMODIFIED
  136. #define IS_NT_DIALECT(dialect) ( (dialect) == SmbDialectNtLanMan || \
  137. (dialect) == SmbDialectNtLanMan2 || \
  138. (dialect) == SmbDialectCairo )
  139. #define IS_POSTNT5_DIALECT(dialect) ( (dialect) == SmbDialectNtLanMan2 )
  140. #else
  141. #define IS_NT_DIALECT(dialect) ( (dialect) == SmbDialectNtLanMan || \
  142. (dialect) == SmbDialectCairo )
  143. #endif
  144. #define DIALECT_HONORS_UID(dialect) \
  145. ( (BOOLEAN)(dialect <= SmbDialectDosLanMan20 ) )
  146. //
  147. // Date and time structures that conform to MS-DOS standard used in
  148. // some SMBs.
  149. //
  150. // !!! These structures are not portable--they depend on a little-endian
  151. // machine (TwoSeconds in lowest bits, etc.)
  152. //
  153. typedef union _SMB_DATE {
  154. USHORT Ushort;
  155. struct {
  156. USHORT Day : 5;
  157. USHORT Month : 4;
  158. USHORT Year : 7;
  159. } Struct;
  160. } SMB_DATE;
  161. typedef SMB_DATE SMB_UNALIGNED *PSMB_DATE;
  162. typedef union _SMB_TIME {
  163. USHORT Ushort;
  164. struct {
  165. USHORT TwoSeconds : 5;
  166. USHORT Minutes : 6;
  167. USHORT Hours : 5;
  168. } Struct;
  169. } SMB_TIME;
  170. typedef SMB_TIME SMB_UNALIGNED *PSMB_TIME;
  171. //
  172. // The SMB_FIND_BUFFER and SMB_FIND_BUFFER2 structures are used in the
  173. // Transaction2 Find protocols to return files matching the requested
  174. // specifications. They are identical except for the EaSize field
  175. // in SMB_FIND_BUFFER2.
  176. //
  177. typedef struct _SMB_FIND_BUFFER {
  178. SMB_DATE CreationDate;
  179. SMB_TIME CreationTime;
  180. SMB_DATE LastAccessDate;
  181. SMB_TIME LastAccessTime;
  182. SMB_DATE LastWriteDate;
  183. SMB_TIME LastWriteTime;
  184. _ULONG( DataSize );
  185. _ULONG( AllocationSize );
  186. _USHORT( Attributes );
  187. UCHAR FileNameLength;
  188. CHAR FileName[1];
  189. } SMB_FIND_BUFFER;
  190. typedef SMB_FIND_BUFFER SMB_UNALIGNED *PSMB_FIND_BUFFER;
  191. typedef struct _SMB_FIND_BUFFER2 {
  192. SMB_DATE CreationDate;
  193. SMB_TIME CreationTime;
  194. SMB_DATE LastAccessDate;
  195. SMB_TIME LastAccessTime;
  196. SMB_DATE LastWriteDate;
  197. SMB_TIME LastWriteTime;
  198. _ULONG( DataSize );
  199. _ULONG( AllocationSize );
  200. _USHORT( Attributes );
  201. _ULONG( EaSize ); // this field intentionally misaligned!
  202. UCHAR FileNameLength;
  203. CHAR FileName[1];
  204. } SMB_FIND_BUFFER2;
  205. typedef SMB_FIND_BUFFER2 SMB_UNALIGNED *PSMB_FIND_BUFFER2;
  206. //
  207. // The following structures are used in OS/2 1.2 for extended attributes
  208. // (EAs). OS/2 2.0 uses the same structures as NT. See the OS/2
  209. // Programmer's Reference, Volume 4, Chapter 4 for more information.
  210. //
  211. // The FEA structure holds a single EA's name and value and is the
  212. // equivalent ofthe NT structure FILE_FULL_EA_INFORMATION.
  213. //
  214. typedef struct _FEA {
  215. UCHAR fEA;
  216. UCHAR cbName;
  217. _USHORT( cbValue );
  218. } FEA;
  219. typedef FEA SMB_UNALIGNED *PFEA;
  220. //
  221. // The only legal bit in fEA is FEA_NEEDEA.
  222. //
  223. #define FEA_NEEDEA 0x80
  224. //
  225. // The FEALIST structure holds the names and values of multiple EAs
  226. // NT has no direct equivalent but rather strings together
  227. // FILE_FULL_EA_INFORMATION structures.
  228. //
  229. typedef struct _FEALIST {
  230. _ULONG( cbList );
  231. FEA list[1];
  232. } FEALIST;
  233. typedef FEALIST SMB_UNALIGNED *PFEALIST;
  234. //
  235. // The GEA structure holds the name of a single EA. It is used to
  236. // request the value of that EA in OS/2 API functions. The NT
  237. // equivalent is FILE_GET_EA_INFORMATION.
  238. //
  239. typedef struct _GEA {
  240. UCHAR cbName;
  241. CHAR szName[1];
  242. } GEA;
  243. typedef GEA SMB_UNALIGNED *PGEA;
  244. //
  245. // The GEALIST structure holds the names of multiple EAs. NT has no
  246. // direct equivalent but rather strings together FILE_GET_EA_INFORMATION
  247. // structures.
  248. //
  249. typedef struct _GEALIST {
  250. _ULONG( cbList );
  251. GEA list[1];
  252. } GEALIST;
  253. typedef GEALIST SMB_UNALIGNED *PGEALIST;
  254. //
  255. // The EAOP structure holds EA information needed by API calls. It has
  256. // no NT equivalent.
  257. //
  258. typedef struct _EAOP {
  259. PGEALIST fpGEAList;
  260. PFEALIST fpFEAList;
  261. ULONG oError;
  262. } EAOP;
  263. typedef EAOP SMB_UNALIGNED *PEAOP;
  264. //
  265. // FSALLOCATE contains information about a disk returned by
  266. // SrvSmbQueryFsInfo.
  267. //
  268. typedef struct _FSALLOCATE {
  269. _ULONG( idFileSystem );
  270. _ULONG( cSectorUnit );
  271. _ULONG( cUnit );
  272. _ULONG( cUnitAvail );
  273. _USHORT( cbSector );
  274. } FSALLOCATE, *PFSALLOCATE; // *** NOT SMB_UNALIGNED!
  275. //
  276. // VOLUMELABEL contains information about a volume label returned by
  277. // SrvSmbQueryFsInformation.
  278. //
  279. typedef struct _VOLUMELABEL {
  280. UCHAR cch;
  281. CHAR szVolLabel[12];
  282. } VOLUMELABEL, *PVOLUMELABEL; // *** NOT SMB_UNALIGNED!
  283. //
  284. // FSINFO holds information about a volume returned by
  285. // SrvSmbQueryFsInformation.
  286. //
  287. typedef struct _FSINFO {
  288. _ULONG( ulVsn );
  289. VOLUMELABEL vol;
  290. } FSINFO, *PFSINFO; // *** NOT SMB_UNALIGNED!
  291. //
  292. // File types (returned by OpenAndX and Transact2_Open)
  293. // FileTypeIPC is a private definition for the NT redirector and
  294. // is not in the smb protocol.
  295. //
  296. typedef enum _FILE_TYPE {
  297. FileTypeDisk = 0,
  298. FileTypeByteModePipe = 1,
  299. FileTypeMessageModePipe = 2,
  300. FileTypePrinter = 3,
  301. FileTypeCommDevice = 4,
  302. FileTypeIPC = 0xFFFE,
  303. FileTypeUnknown = 0xFFFF
  304. } FILE_TYPE;
  305. //
  306. // Turn structure packing back off
  307. //
  308. #ifndef NO_PACKING
  309. #include <packoff.h>
  310. #endif // ndef NO_PACKING
  311. #endif // def _SMBTYPES_