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.

231 lines
5.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. Stuffer.h
  5. Abstract:
  6. Prototypes for the SMBstuffer formating primitives
  7. Author:
  8. Joe Linn 3-3-95
  9. Revision History:
  10. --*/
  11. #ifndef _SMBSTUFFER_INCLUDED_
  12. #define _SMBSTUFFER_INCLUDED_
  13. //CODE.IMPROVEMENT (sweeping) all the routines in here that are defined as MRxSmb.... should be MRxSmb....
  14. IMPORTANT_STRUCTURE(SMBSTUFFER_BUFFER_STATE);
  15. #define COVERED_CALL(x) {\
  16. Status = x; \
  17. if (Status != RX_MAP_STATUS(SUCCESS)) { \
  18. RxDbgTrace(0, Dbg,("nonSUCCESS covered status = %lx\n",Status)); \
  19. goto FINALLY; \
  20. } \
  21. ASSERT (StufferState->SpecificProblem == 0); \
  22. }
  23. #define MRXSMB_PROCESS_ID_ZERO (MRXSMB_PROCESS_ID - 1)
  24. #define MRXSMB_MULTIPLX_ID_ZERO (0xdead)
  25. #define MRXSMB_USER_ID_ZERO ((USHORT)'jj')
  26. #define MRXSMB_TREE_ID_ZERO (0xbaba)
  27. #define GetServerMaximumBufferSize(SRVCALL) 4356
  28. #define SMB_REQUEST_SIZE(___x) (FIELD_OFFSET(REQ_##___x,Buffer[0]))
  29. #if DBG
  30. #define SMB_OFFSET_CHECK(___x,___y) (FIELD_OFFSET(REQ_##___x,___y)),
  31. #define SMB_WCTBCC_CHECK(___x,___y) ( ((0x8000|(___z))<<16)+(FIELD_OFFSET(REQ_##___x,ByteCount)) ),
  32. #define SMB_WCT_CHECK(___z) ((0x8000|(___z))<<16),
  33. #else
  34. #define SMB_OFFSET_CHECK(___x,___y)
  35. #define SMB_WCTBCC_CHECK(___x,___y,___z)
  36. #define SMB_WCT_CHECK(___z)
  37. #endif
  38. typedef enum _SMBbuf_STATUS_DETAIL {
  39. xSMBbufSTATUS_OK,
  40. xSMBbufSTATUS_CANT_COMPOUND,
  41. xSMBbufSTATUS_HEADER_OVERRUN,
  42. xSMBbufSTATUS_BUFFER_OVERRUN,
  43. xSMBbufSTATUS_SERVER_OVERRUN,
  44. xSMBbufSTATUS_FLAGS_CONFLICT,
  45. xSMBbufSTATUS_MAXIMUM
  46. } SMBbuf_STATUS_DETAIL;
  47. //#define STUFFER_STATE_SIGNATURE ('fftS')
  48. typedef struct _SMBSTUFFER_BUFFER_STATE {
  49. NODE_TYPE_CODE NodeTypeCode; // node type.
  50. NODE_BYTE_SIZE NodeByteSize; // node size.
  51. // this stuff is fixed
  52. PMDL HeaderMdl;
  53. PMDL HeaderPartialMdl; //used for breaking up writes to avoid reallocation
  54. PBYTE ActualBufferBase;
  55. PBYTE BufferBase;
  56. PBYTE BufferLimit;
  57. //this stuff is reinitialized
  58. PRX_CONTEXT RxContext;
  59. PSMB_EXCHANGE Exchange;
  60. PMDL DataMdl;
  61. ULONG DataSize;
  62. //PRXCE_DATA_BUFFER FinalMdl; //for later with no chain-send rule
  63. PBYTE CurrentPosition;
  64. PBYTE CurrentWct;
  65. PBYTE CurrentBcc;
  66. PBYTE CurrentDataOffset;
  67. PBYTE CurrentParamOffset;
  68. UCHAR PreviousCommand;
  69. UCHAR CurrentCommand;
  70. UCHAR SpecificProblem; //SMBbuf_STATUS_DETAIL this is set to pass back what happened
  71. BOOLEAN Started;
  72. ULONG FlagsCopy;
  73. ULONG Flags2Copy;
  74. //ULONG FlagsMask;
  75. //ULONG Flags2Mask;
  76. #if DBG
  77. ULONG Signature;
  78. PDEBUG_TRACE_CONTROLPOINT ControlPoint;
  79. BOOLEAN PrintFLoop;
  80. BOOLEAN PrintCLoop;
  81. #endif
  82. } SMBSTUFFER_BUFFER_STATE;
  83. typedef enum _SMB_STUFFER_CONTROLS {
  84. STUFFER_CTL_NORMAL=1,
  85. STUFFER_CTL_SKIP, // only w,d,b can be in a skip string
  86. STUFFER_CTL_NOBYTES,
  87. STUFFER_CTL_ENDOFARGUMENTS,
  88. STUFFER_CTL_MAXIMUM
  89. } SMB_STUFFER_CONTROLS;
  90. #define StufferCondition(___c) ((___c)?STUFFER_CTL_NORMAL:STUFFER_CTL_SKIP)
  91. #if DBG
  92. NTSTATUS
  93. MRxSmbStufferDebug(
  94. IN PRX_CONTEXT RxContext
  95. );
  96. NTSTATUS
  97. MRxSmbBuildSmbHeaderTestSurrogate(
  98. PSMB_EXCHANGE pExchange,
  99. PVOID pBuffer,
  100. ULONG BufferLength,
  101. PULONG pBufferConsumed,
  102. PUCHAR pLastCommandInHeader,
  103. PUCHAR *pCommandPtr
  104. );
  105. #endif //if DBG
  106. NTSTATUS
  107. SmbMrxInitializeStufferFacilities(
  108. void
  109. );
  110. NTSTATUS
  111. SmbMrxFinalizeStufferFacilities(
  112. void
  113. );
  114. #ifdef RDBSSTRACE
  115. #define STUFFERTRACE(CONTROLPOINT,__b__) ,(&RxDTPrefixRx CONTROLPOINT),(__b__)
  116. #define STUFFERTRACE_NOPREFIX(CONTROLPOINT,__b__) ,(CONTROLPOINT),(__b__)
  117. #define STUFFERTRACE_CONTROLPOINT_ARGS \
  118. ,IN PDEBUG_TRACE_CONTROLPOINT ControlPoint,IN ULONG EnablePrints
  119. #else
  120. #define STUFFERTRACE(__a__,__b__)
  121. #define STUFFERTRACE_NOPREFIX(__a__,__b__)
  122. #define STUFFERTRACE_CONTROLPOINT_ARGS
  123. #endif
  124. NTSTATUS
  125. MRxSmbSetInitialSMB (
  126. IN OUT PSMBSTUFFER_BUFFER_STATE StufferState
  127. STUFFERTRACE_CONTROLPOINT_ARGS
  128. );
  129. #define NO_EXTRA_DATA 0
  130. #define SMB_BEST_ALIGNMENT(__x,__y) ((__x<<16)|__y)
  131. #define NO_SPECIAL_ALIGNMENT 0
  132. #define RESPONSE_HEADER_SIZE_NOT_SPECIFIED 0
  133. typedef enum _INITIAL_SMBBUF_DISPOSITION {
  134. SetInitialSMB_yyUnconditionally, //no one should be using this right now!
  135. SetInitialSMB_ForReuse,
  136. SetInitialSMB_Never
  137. } INITIAL_SMBBUG_DISPOSITION;
  138. NTSTATUS
  139. MRxSmbStartSMBCommand (
  140. IN OUT PSMBSTUFFER_BUFFER_STATE StufferState,
  141. IN INITIAL_SMBBUG_DISPOSITION InitialSMBDisposition,
  142. IN UCHAR Command, //joejoe this next four params could come from a table...2offset and you're smaller
  143. IN ULONG MaximumBufferUsed,
  144. IN ULONG MaximumSize,
  145. IN ULONG InitialAlignment,
  146. IN ULONG MaximumResponseHeader,
  147. IN UCHAR Flags,
  148. IN UCHAR FlagsMask,
  149. IN USHORT Flags2,
  150. IN USHORT Flags2Mask
  151. STUFFERTRACE_CONTROLPOINT_ARGS
  152. );
  153. NTSTATUS
  154. MRxSmbStuffSMB (
  155. IN OUT PSMBSTUFFER_BUFFER_STATE StufferState,
  156. ...
  157. );
  158. VOID
  159. MRxSmbStuffAppendRawData(
  160. IN OUT PSMBSTUFFER_BUFFER_STATE StufferState,
  161. IN PMDL Mdl
  162. );
  163. VOID
  164. MRxSmbStuffAppendSmbData(
  165. IN OUT PSMBSTUFFER_BUFFER_STATE StufferState,
  166. IN PMDL Mdl
  167. );
  168. VOID
  169. MRxSmbStuffSetByteCount(
  170. IN OUT PSMBSTUFFER_BUFFER_STATE StufferState
  171. );
  172. BOOLEAN
  173. MrxSMBWillThisFit(
  174. IN PSMBSTUFFER_BUFFER_STATE StufferState,
  175. IN ULONG AlignmentUnit,
  176. IN ULONG DataSize
  177. );
  178. #if DBG
  179. VOID
  180. MRxSmbDumpStufferState (
  181. IN ULONG PrintLevel,
  182. IN PSZ Msg,
  183. IN PSMBSTUFFER_BUFFER_STATE StufferState //IN OUT for debug
  184. );
  185. #else
  186. #define MRxSmbDumpStufferState(a,b,c)
  187. #endif
  188. #endif // ifndef _SMBSTUFFER_INCLUDED_
  189.