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.

382 lines
7.2 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. net\routing\ip\ipinip\tdix.h
  5. Abstract:
  6. Interface to TDI
  7. Revision History:
  8. Copied from Steve Cobb's ntos\ndis\l2tp code
  9. Most of the comments are the original ones from SteveC.
  10. There are style and some name changes
  11. --*/
  12. #ifndef __IPINIP_TDIX_H__
  13. #define __IPINIP_TDIX_H__
  14. //
  15. // Read datagram information context used to pass context information from the
  16. // ReadDatagram event handler to the RECEIVE_DATAGRAM completion routine.
  17. //
  18. typedef struct _SEND_CONTEXT
  19. {
  20. //
  21. // The tunnel over which the send is being done
  22. //
  23. PTUNNEL pTunnel;
  24. //
  25. // Pointer to the packet being sent
  26. // This packet is not sent, rather the first buffer is sent
  27. //
  28. PNDIS_PACKET pnpPacket;
  29. //
  30. // The size of the packet
  31. //
  32. ULONG ulOutOctets;
  33. #if PROFILE
  34. LONGLONG llSendTime;
  35. LONGLONG llCallTime;
  36. LONGLONG llTransmitTime;
  37. LONGLONG llCall2Time;
  38. #endif
  39. }SEND_CONTEXT, *PSEND_CONTEXT;
  40. typedef struct _TRANSFER_CONTEXT
  41. {
  42. //
  43. // Tunnel associated with the receive
  44. //
  45. PTUNNEL pTunnel;
  46. //
  47. // The packet to transfer data into
  48. //
  49. PNDIS_PACKET pnpTransferPacket;
  50. //
  51. // The context returned by IP
  52. //
  53. PVOID pvContext;
  54. //
  55. // The offset indicated by us to IP (outer IP Header)
  56. //
  57. UINT uiProtoOffset;
  58. //
  59. // The offset into the received packet at which to begin copying data
  60. //
  61. UINT uiTransferOffset;
  62. //
  63. // The the number of bytes to transfer
  64. //
  65. UINT uiTransferLength;
  66. //
  67. // Flag to see if IP requested a transfer
  68. //
  69. BOOLEAN bRequestTransfer;
  70. #if PROFILE
  71. LONGLONG llRcvTime;
  72. #endif
  73. }TRANSFER_CONTEXT, *PTRANSFER_CONTEXT;
  74. typedef struct _QUEUE_NODE
  75. {
  76. LIST_ENTRY leQueueItemLink;
  77. //
  78. // We make the work queue item part of the struct so that
  79. // we dont need to allocate (and free) two structs
  80. //
  81. WORK_QUEUE_ITEM WorkItem;
  82. //
  83. // The ppPacketArray points to an vector of uiNumPackets NDIS_PACKETs
  84. // The common case however is uiNumPackets = 1. To optimiize for this
  85. // we make ppPacketArray point to pnpPacket and make pnpPacket point to
  86. // the packet to transmit. This way we dont need to allocate a
  87. // uiNumPackets * sizeof(PNDIS_PACKET) sized block of memory.
  88. //
  89. NDIS_PACKET **ppPacketArray;
  90. PNDIS_PACKET pnpPacket;
  91. //
  92. // The number of packets
  93. //
  94. UINT uiNumPackets;
  95. //
  96. // The next hop address. Not really important, maybe move this to
  97. // a debug only build?
  98. //
  99. DWORD dwDestAddr;
  100. #if PROFILE
  101. LONGLONG llSendTime;
  102. LONGLONG llCallTime;
  103. #endif
  104. }QUEUE_NODE, *PQUEUE_NODE;
  105. typedef struct _OPEN_CONTEXT
  106. {
  107. PKEVENT pkeEvent;
  108. NTSTATUS nStatus;
  109. }OPEN_CONTEXT, *POPEN_CONTEXT;
  110. //
  111. // The depths of the lookaside lists used to allocate send and receive
  112. // contexts
  113. //
  114. #define SEND_CONTEXT_LOOKASIDE_DEPTH 20
  115. #define TRANSFER_CONTEXT_LOOKASIDE_DEPTH 20
  116. #define QUEUE_NODE_LOOKASIDE_DEPTH 20
  117. //
  118. // The lookaside lists themselves
  119. //
  120. extern NPAGED_LOOKASIDE_LIST g_llSendCtxtBlocks;
  121. extern NPAGED_LOOKASIDE_LIST g_llTransferCtxtBlocks;
  122. extern NPAGED_LOOKASIDE_LIST g_llQueueNodeBlocks;
  123. //++
  124. // PSEND_CONTEXT
  125. // AllocateSendContext(
  126. // VOID
  127. // )
  128. //
  129. // Allocate a send context from g_llSendCtxtBlocks
  130. //
  131. //--
  132. #define AllocateSendContext() \
  133. ExAllocateFromNPagedLookasideList(&g_llSendCtxtBlocks)
  134. //++
  135. // VOID
  136. // FreeSendContext(
  137. // PSEND_CONTEXT pSndCtxt
  138. // )
  139. //
  140. // Free a send context to g_llSendCtxtBlocks
  141. //
  142. //--
  143. #define FreeSendContext(p) \
  144. ExFreeToNPagedLookasideList(&g_llSendCtxtBlocks, (p))
  145. //++
  146. // PTRANSFER_CONTEXT
  147. // AllocateTransferContext(
  148. // VOID
  149. // )
  150. //
  151. // Allocate a transfer context from g_llTransferCtxtBlocks
  152. //
  153. //--
  154. #define AllocateTransferContext() \
  155. ExAllocateFromNPagedLookasideList(&g_llTransferCtxtBlocks)
  156. //++
  157. // VOID
  158. // FreeTransferContext(
  159. // PTRANSFER_CONTEXT pTransferCtxt
  160. // )
  161. //
  162. // Free a transfer context to g_llTransferCtxtBlocks
  163. //
  164. //--
  165. #define FreeTransferContext(p) \
  166. ExFreeToNPagedLookasideList(&g_llTransferCtxtBlocks, (p))
  167. //++
  168. // PQUEUE_NODE
  169. // AllocateQueueNode(
  170. // VOID
  171. // )
  172. //
  173. // Allocate a queue node from g_llQueueNodeBlocks
  174. //
  175. //--
  176. #define AllocateQueueNode() \
  177. ExAllocateFromNPagedLookasideList(&g_llQueueNodeBlocks)
  178. //++
  179. // VOID
  180. // FreeQueueNode(
  181. // PQUEUE_NODE pQueueNode
  182. // )
  183. //
  184. // Free a work context to g_llQueueNodeBlocks
  185. //
  186. //--
  187. #define FreeQueueNode(p) \
  188. ExFreeToNPagedLookasideList(&g_llQueueNodeBlocks, (p))
  189. //
  190. // Interface prototypes
  191. //
  192. VOID
  193. TdixInitialize(
  194. PVOID pvContext
  195. );
  196. NTSTATUS
  197. TdixOpenRawIp(
  198. IN DWORD dwProtoId,
  199. OUT HANDLE *phAddrHandle,
  200. OUT FILE_OBJECT **ppAddrFileObj
  201. );
  202. VOID
  203. TdixDeinitialize(
  204. IN PDEVICE_OBJECT pDeviceObject,
  205. IN PVOID pvContext
  206. );
  207. NTSTATUS
  208. TdixInstallEventHandler(
  209. IN PFILE_OBJECT pAddrFileObj,
  210. IN INT iEventType,
  211. IN PVOID pfnEventHandler,
  212. IN PVOID pvEventContext
  213. );
  214. VOID
  215. TdixAddressArrival(
  216. PTA_ADDRESS pAddr,
  217. PUNICODE_STRING pusDeviceName,
  218. PTDI_PNP_CONTEXT pContext
  219. );
  220. VOID
  221. TdixAddressDeletion(
  222. PTA_ADDRESS pAddr,
  223. PUNICODE_STRING pusDeviceName,
  224. PTDI_PNP_CONTEXT pContext
  225. );
  226. NTSTATUS
  227. TdixReceiveIpIpDatagram(
  228. IN PVOID pvTdiEventContext,
  229. IN LONG lSourceAddressLen,
  230. IN PVOID pvSourceAddress,
  231. IN LONG plOptionsLeng,
  232. IN PVOID pvOptions,
  233. IN ULONG ulReceiveDatagramFlags,
  234. IN ULONG ulBytesIndicated,
  235. IN ULONG ulBytesAvailable,
  236. OUT PULONG pulBytesTaken,
  237. IN PVOID pvTsdu,
  238. OUT IRP **ppIoRequestPacket
  239. );
  240. NTSTATUS
  241. TdixReceiveIpIpDatagramComplete(
  242. IN PDEVICE_OBJECT DeviceObject,
  243. IN PIRP Irp,
  244. IN PVOID Context
  245. );
  246. #if PROFILE
  247. NTSTATUS
  248. TdixSendDatagram(
  249. IN PTUNNEL pTunnel,
  250. IN PNDIS_PACKET pnpPacket,
  251. IN PNDIS_BUFFER pnbFirstBuffer,
  252. IN ULONG ulBufferLength,
  253. IN LONGLONG llSendTime,
  254. IN LONGLONG llCallTime,
  255. IN LONGLONG llTransmitTime
  256. );
  257. #else
  258. NTSTATUS
  259. TdixSendDatagram(
  260. IN PTUNNEL pTunnel,
  261. IN PNDIS_PACKET pnpPacket,
  262. IN PNDIS_BUFFER pnbFirstBuffer,
  263. IN ULONG ulBufferLength
  264. );
  265. #endif
  266. NTSTATUS
  267. TdixSendDatagramComplete(
  268. IN PDEVICE_OBJECT DeviceObject,
  269. IN PIRP Irp,
  270. IN PVOID Context
  271. );
  272. NTSTATUS
  273. TdixReceiveIcmpDatagram(
  274. IN PVOID pvTdiEventContext,
  275. IN LONG lSourceAddressLen,
  276. IN PVOID pvSourceAddress,
  277. IN LONG plOptionsLeng,
  278. IN PVOID pvOptions,
  279. IN ULONG ulReceiveDatagramFlags,
  280. IN ULONG ulBytesIndicated,
  281. IN ULONG ulBytesAvailable,
  282. OUT PULONG pulBytesTaken,
  283. IN PVOID pvTsdu,
  284. OUT IRP **ppIoRequestPacket
  285. );
  286. #endif // __IPINIP_TDIX_H__