Source code of Windows XP (NT5)
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.

361 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1989-1993 Microsoft Corporation
  3. Module Name:
  4. isnspx.h
  5. Abstract:
  6. This module contains definitions specific to the
  7. SPX module of the ISN transport.
  8. Author:
  9. Adam Barr (adamba) 2-September-1993
  10. Environment:
  11. Kernel mode
  12. Revision History:
  13. --*/
  14. #define ISN_NT 1
  15. //#define DBG 1
  16. //
  17. // These are needed for CTE
  18. //
  19. #if DBG
  20. #define DEBUG 1
  21. #endif
  22. #define NT 1
  23. #include <ntosp.h>
  24. #include <tdikrnl.h>
  25. #include <ndis.h>
  26. #ifndef CTE_TYPEDEFS_DEFINED
  27. #include <cxport.h>
  28. #endif
  29. #include <bind.h>
  30. #include "wsnwlink.h"
  31. #define SPX_DEVICE_SIGNATURE (USHORT)(*(PUSHORT)"SD")
  32. #define SPX_ADDRESS_SIGNATURE (USHORT)(*(PUSHORT)"AD")
  33. #define SPX_ADDRESSFILE_SIGNATURE (USHORT)(*(PUSHORT)"AF")
  34. #define SPX_CONNFILE_SIGNATURE (USHORT)(*(PUSHORT)"CF")
  35. #define SPX_FILE_TYPE_CONTROL (ULONG)0x4701 // file is type control
  36. #define SPX_ADD_ULONG(_Pulong, _Ulong, _Lock) InterlockedExchangeAdd(_Pulong, _Ulong)
  37. typedef UCHAR BYTE, *PBYTE;
  38. typedef ULONG DWORD, *PDWORD;
  39. //
  40. // These definitions are for abstracting IRPs from the
  41. // transport for portability.
  42. //
  43. #if ISN_NT
  44. typedef IRP REQUEST, *PREQUEST;
  45. //
  46. // PREQUEST
  47. // SpxAllocateRequest(
  48. // IN PDEVICE Device,
  49. // IN PIRP Irp
  50. // );
  51. //
  52. // Allocates a request for the system-specific request structure.
  53. //
  54. #define SpxAllocateRequest(_Device,_Irp) \
  55. (_Irp)
  56. //
  57. // BOOLEAN
  58. // IF_NOT_ALLOCATED(
  59. // IN PREQUEST Request
  60. // );
  61. //
  62. // Checks if a request was not successfully allocated.
  63. //
  64. #define IF_NOT_ALLOCATED(_Request) \
  65. if (0)
  66. //
  67. // VOID
  68. // SpxFreeRequest(
  69. // IN PDEVICE Device,
  70. // IN PREQUEST Request
  71. // );
  72. //
  73. // Frees a previously allocated request.
  74. //
  75. #define SpxFreeRequest(_Device,_Request) \
  76. ;
  77. //
  78. // VOID
  79. // MARK_REQUEST_PENDING(
  80. // IN PREQUEST Request
  81. // );
  82. //
  83. // Marks that a request will pend.
  84. //
  85. #define MARK_REQUEST_PENDING(_Request) \
  86. IoMarkIrpPending(_Request)
  87. //
  88. // VOID
  89. // UNMARK_REQUEST_PENDING(
  90. // IN PREQUEST Request
  91. // );
  92. //
  93. // Marks that a request will not pend.
  94. //
  95. #define UNMARK_REQUEST_PENDING(_Request) \
  96. (((IoGetCurrentIrpStackLocation(_Request))->Control) &= ~SL_PENDING_RETURNED)
  97. //
  98. // UCHAR
  99. // REQUEST_MAJOR_FUNCTION
  100. // IN PREQUEST Request
  101. // );
  102. //
  103. // Returns the major function code of a request.
  104. //
  105. #define REQUEST_MAJOR_FUNCTION(_Request) \
  106. ((IoGetCurrentIrpStackLocation(_Request))->MajorFunction)
  107. //
  108. // UCHAR
  109. // REQUEST_MINOR_FUNCTION
  110. // IN PREQUEST Request
  111. // );
  112. //
  113. // Returns the minor function code of a request.
  114. //
  115. #define REQUEST_MINOR_FUNCTION(_Request) \
  116. ((IoGetCurrentIrpStackLocation(_Request))->MinorFunction)
  117. //
  118. // PNDIS_BUFFER
  119. // REQUEST_NDIS_BUFFER
  120. // IN PREQUEST Request
  121. // );
  122. //
  123. // Returns the NDIS buffer chain associated with a request.
  124. //
  125. #define REQUEST_NDIS_BUFFER(_Request) \
  126. ((PNDIS_BUFFER)((_Request)->MdlAddress))
  127. //
  128. // PVOID
  129. // REQUEST_TDI_BUFFER
  130. // IN PREQUEST Request
  131. // );
  132. //
  133. // Returns the TDI buffer chain associated with a request.
  134. //
  135. #define REQUEST_TDI_BUFFER(_Request) \
  136. ((PVOID)((_Request)->MdlAddress))
  137. //
  138. // PVOID
  139. // REQUEST_OPEN_CONTEXT(
  140. // IN PREQUEST Request
  141. // );
  142. //
  143. // Gets the context associated with an opened address/connection/control channel.
  144. //
  145. #define REQUEST_OPEN_CONTEXT(_Request) \
  146. (((IoGetCurrentIrpStackLocation(_Request))->FileObject)->FsContext)
  147. //
  148. // PVOID
  149. // REQUEST_OPEN_TYPE(
  150. // IN PREQUEST Request
  151. // );
  152. //
  153. // Gets the type associated with an opened address/connection/control channel.
  154. //
  155. #define REQUEST_OPEN_TYPE(_Request) \
  156. (((IoGetCurrentIrpStackLocation(_Request))->FileObject)->FsContext2)
  157. //
  158. // PFILE_FULL_EA_INFORMATION
  159. // OPEN_REQUEST_EA_INFORMATION(
  160. // IN PREQUEST Request
  161. // );
  162. //
  163. // Returns the EA information associated with an open/close request.
  164. //
  165. #define OPEN_REQUEST_EA_INFORMATION(_Request) \
  166. ((PFILE_FULL_EA_INFORMATION)((_Request)->AssociatedIrp.SystemBuffer))
  167. //
  168. // PTDI_REQUEST_KERNEL
  169. // REQUEST_PARAMETERS(
  170. // IN PREQUEST Request
  171. // );
  172. //
  173. // Obtains a pointer to the parameters of a request.
  174. //
  175. #define REQUEST_PARAMETERS(_Request) \
  176. (&((IoGetCurrentIrpStackLocation(_Request))->Parameters))
  177. //
  178. // PLIST_ENTRY
  179. // REQUEST_LINKAGE(
  180. // IN PREQUEST Request
  181. // );
  182. //
  183. // Returns a pointer to a linkage field in the request.
  184. //
  185. #define REQUEST_LINKAGE(_Request) \
  186. (&((_Request)->Tail.Overlay.ListEntry))
  187. //
  188. // PREQUEST
  189. // LIST_ENTRY_TO_REQUEST(
  190. // IN PLIST_ENTRY ListEntry
  191. // );
  192. //
  193. // Returns a request given a linkage field in it.
  194. //
  195. #define LIST_ENTRY_TO_REQUEST(_ListEntry) \
  196. ((PREQUEST)(CONTAINING_RECORD(_ListEntry, REQUEST, Tail.Overlay.ListEntry)))
  197. //
  198. // PUNICODE_STRING
  199. // REQUEST_OPEN_NAME(
  200. // IN PREQUEST Request
  201. // );
  202. //
  203. // Used to access the RemainingName field of a request.
  204. //
  205. #define REQUEST_OPEN_NAME(_Request) \
  206. (&((IoGetCurrentIrpStackLocation(_Request))->FileObject->FileName))
  207. //
  208. // NTSTATUS
  209. // REQUEST_STATUS(
  210. // IN PREQUEST Request
  211. // );
  212. //
  213. // Used to access the status field of a request.
  214. //
  215. #define REQUEST_STATUS(_Request) \
  216. (_Request)->IoStatus.Status
  217. //
  218. // ULONG
  219. // REQUEST_INFORMATION(
  220. // IN PREQUEST Request)
  221. // );
  222. //
  223. // Used to access the information field of a request.
  224. //
  225. #define REQUEST_INFORMATION(_Request) \
  226. (_Request)->IoStatus.Information
  227. //
  228. // VOID
  229. // SpxCompleteRequest(
  230. // IN PREQUEST Request
  231. // );
  232. //
  233. // Completes a request whose status and information fields have
  234. // been filled in.
  235. //
  236. #define SpxCompleteRequest(_Request) \
  237. { \
  238. CTELockHandle _CancelIrql; \
  239. DBGPRINT(TDI, INFO, \
  240. ("SpxCompleteRequest: Completing %lx with %lx\n", \
  241. (_Request), REQUEST_STATUS(_Request))); \
  242. \
  243. IoAcquireCancelSpinLock( &_CancelIrql ); \
  244. (_Request)->CancelRoutine = NULL; \
  245. IoReleaseCancelSpinLock( _CancelIrql ); \
  246. IoCompleteRequest (_Request, IO_NETWORK_INCREMENT); \
  247. }
  248. #else
  249. //
  250. // These routines must be defined for portability to a VxD.
  251. //
  252. #endif
  253. #include "fwddecls.h"
  254. #ifndef _NTIOAPI_
  255. #include "spxntdef.h"
  256. #endif
  257. #include "spxreg.h"
  258. #include "spxdev.h"
  259. #include "spxbind.h"
  260. #include "spxtimer.h"
  261. #include "spxpkt.h"
  262. #include "spxerror.h"
  263. #include "spxaddr.h"
  264. #include "spxconn.h"
  265. #include "spxrecv.h"
  266. #include "spxsend.h"
  267. #include "spxquery.h"
  268. #include "spxmem.h"
  269. #include "spxutils.h"
  270. // Globals
  271. #include "globals.h"