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.

385 lines
8.7 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. //
  4. // Copyright (c) 1996, 1997 Microsoft Corporation
  5. //
  6. //
  7. // Module Name:
  8. // ipsink.h
  9. //
  10. // Abstract:
  11. //
  12. //
  13. // Author:
  14. //
  15. // P Porzuczek
  16. //
  17. // Environment:
  18. //
  19. // Revision History:
  20. //
  21. //
  22. //////////////////////////////////////////////////////////////////////////////
  23. #ifndef _IPSINK_H_
  24. #define _IPSINK_H_
  25. /////////////////////////////////////////////////////////////////////////////
  26. //
  27. //
  28. #define BDA_NDIS_MINIPORT L"\\Device\\NDIS_IPSINK"
  29. #define BDA_NDIS_SYMBOLIC_NAME L"\\DosDevices\\NDIS_IPSINK"
  30. #define BDA_NDIS_STARTUP L"\\Device\\NDIS_IPSINK_STARTUP"
  31. //////////////////////////////////////////////////////////
  32. //
  33. //
  34. #define MULTICAST_LIST_SIZE 256
  35. #define ETHERNET_ADDRESS_LENGTH 6
  36. /////////////////////////////////////////////////////////////////////////////
  37. //
  38. //
  39. #define NTStatusFromNdisStatus(nsResult) ((NTSTATUS) nsResult)
  40. /////////////////////////////////////////////////////////////////////////////
  41. //
  42. //
  43. typedef struct _ADAPTER ADAPTER, *PADAPTER;
  44. typedef struct _IPSINK_FILTER_ IPSINK_FILTER, *PIPSINK_FILTER;
  45. typedef struct _LINK_ LINK, *PLINK;
  46. /////////////////////////////////////////////////////////////////////////////
  47. //
  48. //
  49. //
  50. typedef enum
  51. {
  52. IPSINK_EVENT_SHUTDOWN = 0x00000001,
  53. IPSINK_EVENT_MAX
  54. } IPSINK_EVENT;
  55. /////////////////////////////////////////////////////////////////////////////
  56. //
  57. //
  58. //
  59. typedef NTSTATUS (*QUERY_INTERFACE) (PVOID pvContext);
  60. typedef ULONG (*ADD_REF) (PVOID pvContext);
  61. typedef ULONG (*RELEASE) (PVOID pvContext);
  62. /////////////////////////////////////////////////////////////////////////////
  63. //
  64. //
  65. //
  66. typedef NTSTATUS (*NDIS_INDICATE_DATA) (PVOID pvContext, PVOID pvData, ULONG ulcbData);
  67. typedef NTSTATUS (*NDIS_INDICATE_STATUS) (PVOID pvContext, PVOID pvEvent);
  68. typedef VOID (*NDIS_INDICATE_RESET) (PVOID pvContext);
  69. typedef ULONG (*NDIS_GET_DESCRIPTION) (PVOID pvContext, PUCHAR pDescription);
  70. typedef VOID (*NDIS_CLOSE_LINK) (PVOID pvContext);
  71. typedef struct
  72. {
  73. QUERY_INTERFACE QueryInterface;
  74. ADD_REF AddRef;
  75. RELEASE Release;
  76. NDIS_INDICATE_DATA IndicateData;
  77. NDIS_INDICATE_STATUS IndicateStatus;
  78. NDIS_INDICATE_RESET IndicateReset;
  79. NDIS_GET_DESCRIPTION GetDescription;
  80. NDIS_CLOSE_LINK CloseLink;
  81. } ADAPTER_VTABLE, *PADAPTER_VTABLE;
  82. /////////////////////////////////////////////////////////////////////////////
  83. //
  84. //
  85. //
  86. typedef NTSTATUS (*STREAM_SET_MULTICASTLIST) (PVOID pvContext, PVOID pvMulticastList, ULONG ulcbList);
  87. typedef NTSTATUS (*STREAM_SIGNAL_EVENT) (PVOID pvContext, ULONG ulEvent);
  88. typedef NTSTATUS (*STREAM_RETURN_FRAME) (PVOID pvContext, PVOID pvFrame);
  89. typedef struct
  90. {
  91. QUERY_INTERFACE QueryInterface;
  92. ADD_REF AddRef;
  93. RELEASE Release;
  94. STREAM_SET_MULTICASTLIST SetMulticastList;
  95. STREAM_SIGNAL_EVENT IndicateStatus;
  96. STREAM_RETURN_FRAME ReturnFrame;
  97. } FILTER_VTABLE, *PFILTER_VTABLE;
  98. /////////////////////////////////////////////////////////////////////////////
  99. //
  100. //
  101. //
  102. typedef struct
  103. {
  104. QUERY_INTERFACE QueryInterface;
  105. ADD_REF AddRef;
  106. RELEASE Release;
  107. } FRAME_POOL_VTABLE, *PFRAME_POOL_VTABLE;
  108. /////////////////////////////////////////////////////////////////////////////
  109. //
  110. //
  111. //
  112. typedef struct
  113. {
  114. QUERY_INTERFACE QueryInterface;
  115. ADD_REF AddRef;
  116. RELEASE Release;
  117. } FRAME_VTABLE, *PFRAME_VTABLE;
  118. /////////////////////////////////////////////////////////////////////////////
  119. //
  120. //
  121. //
  122. typedef struct
  123. {
  124. ULONG ulOID_GEN_XMIT_OK;
  125. ULONG ulOID_GEN_RCV_OK;
  126. ULONG ulOID_GEN_XMIT_ERROR;
  127. ULONG ulOID_GEN_RCV_ERROR;
  128. ULONG ulOID_GEN_RCV_NO_BUFFER;
  129. ULONG ulOID_GEN_DIRECTED_BYTES_XMIT;
  130. ULONG ulOID_GEN_DIRECTED_FRAMES_XMIT;
  131. ULONG ulOID_GEN_MULTICAST_BYTES_XMIT;
  132. ULONG ulOID_GEN_MULTICAST_FRAMES_XMIT;
  133. ULONG ulOID_GEN_BROADCAST_BYTES_XMIT;
  134. ULONG ulOID_GEN_BROADCAST_FRAMES_XMIT;
  135. ULONG ulOID_GEN_DIRECTED_BYTES_RCV;
  136. ULONG ulOID_GEN_DIRECTED_FRAMES_RCV;
  137. ULONG ulOID_GEN_MULTICAST_BYTES_RCV;
  138. ULONG ulOID_GEN_MULTICAST_FRAMES_RCV;
  139. ULONG ulOID_GEN_BROADCAST_BYTES_RCV;
  140. ULONG ulOID_GEN_BROADCAST_FRAMES_RCV;
  141. ULONG ulOID_GEN_RCV_CRC_ERROR;
  142. ULONG ulOID_GEN_TRANSMIT_QUEUE_LENGTH;
  143. } NDISIP_STATS, *PNDISIP_STATS;
  144. /////////////////////////////////////////////////////////////////////////////
  145. //
  146. // The NDIS Adapter structure
  147. //
  148. typedef struct _ADAPTER
  149. {
  150. ULONG ulRefCount;
  151. //
  152. // Adapter Context passed in by NDIS to the miniport.
  153. //
  154. PVOID ndishMiniport;
  155. PDEVICE_OBJECT pDeviceObject;
  156. PVOID ndisDeviceHandle;
  157. PUCHAR pVendorDescription;
  158. ULONG ulInstance;
  159. PIPSINK_FILTER pFilter;
  160. PADAPTER_VTABLE lpVTable;
  161. PFRAME_POOL pFramePool;
  162. PFRAME pCurrentFrame;
  163. PUCHAR pIn;
  164. ULONG ulPR;
  165. ULONG ulPacketFilter;
  166. NDISIP_STATS stats;
  167. ULONG ulcbMulticastListEntries;
  168. UCHAR multicastList[MULTICAST_LIST_SIZE]
  169. [ETHERNET_ADDRESS_LENGTH];
  170. };
  171. typedef struct _STATS_
  172. {
  173. ULONG ulTotalPacketsWritten;
  174. ULONG ulTotalPacketsRead;
  175. ULONG ulTotalStreamIPPacketsWritten;
  176. ULONG ulTotalStreamIPBytesWritten;
  177. ULONG ulTotalStreamIPFrameBytesWritten;
  178. ULONG ulTotalNetPacketsWritten;
  179. ULONG ulTotalUnknownPacketsWritten;
  180. } STATS, *PSTATS;
  181. //
  182. // definition of the full HW device extension structure This is the structure
  183. // that will be allocated in HW_INITIALIZATION by the stream class driver
  184. // Any information that is used in processing a device request (as opposed to
  185. // a STREAM based request) should be in this structure. A pointer to this
  186. // structure will be passed in all requests to the minidriver. (See
  187. // HW_STREAM_REQUEST_BLOCK in STRMINI.H)
  188. //
  189. typedef struct _IPSINK_FILTER_
  190. {
  191. LIST_ENTRY AdapterSRBQueue;
  192. KSPIN_LOCK AdapterSRBSpinLock;
  193. BOOLEAN bAdapterQueueInitialized;
  194. //
  195. // Statistics
  196. //
  197. STATS Stats;
  198. //
  199. // Link to NDIS Component
  200. //
  201. LINK NdisLink;
  202. //
  203. // NDIS VTable
  204. //
  205. PADAPTER pAdapter;
  206. //
  207. //
  208. //
  209. PDEVICE_OBJECT DeviceObject;
  210. //
  211. //
  212. //
  213. PDRIVER_OBJECT DriverObject;
  214. //
  215. //
  216. //
  217. PFILTER_VTABLE lpVTable;
  218. //
  219. //
  220. //
  221. //WORK_QUEUE_ITEM WorkItem;
  222. //
  223. //
  224. //
  225. ULONG ulRefCount;
  226. //
  227. //
  228. //
  229. PKEVENT pNdisStartEvent;
  230. PHANDLE hNdisStartEvent;
  231. //
  232. //
  233. //
  234. BOOLEAN bTerminateWaitForNdis;
  235. //
  236. //
  237. //
  238. BOOLEAN bInitializationComplete;
  239. //
  240. //
  241. //
  242. PVOID pStream [2][1];
  243. ULONG ulActualInstances [2]; // Count of instances per stream
  244. //
  245. // NIC Description string pointer
  246. //
  247. PUCHAR pAdapterDescription;
  248. ULONG ulAdapterDescriptionLength;
  249. //
  250. // NIC Address string
  251. //
  252. PUCHAR pAdapterAddress;
  253. ULONG ulAdapterAddressLength;
  254. //
  255. // Multicast list local storage
  256. //
  257. ULONG ulcbMulticastListEntries;
  258. UCHAR multicastList[MULTICAST_LIST_SIZE]
  259. [ETHERNET_ADDRESS_LENGTH];
  260. };
  261. /////////////////////////////////////////////
  262. //
  263. //
  264. typedef enum
  265. {
  266. RECEIVE_DATA,
  267. MAX_IOCTLS
  268. };
  269. /////////////////////////////////////////////
  270. //
  271. //
  272. typedef enum
  273. {
  274. CMD_QUERY_INTERFACE = 0x00000001,
  275. MAX_COMMANDS
  276. };
  277. /////////////////////////////////////////////
  278. //
  279. //
  280. typedef struct _IPSINK_NDIS_COMMAND
  281. {
  282. ULONG ulCommandID;
  283. union
  284. {
  285. struct
  286. {
  287. PVOID pNdisAdapter;
  288. PVOID pStreamAdapter;
  289. } Query;
  290. } Parameter;
  291. } IPSINK_NDIS_COMMAND, *PIPSINK_NDIS_COMMAND;
  292. /////////////////////////////////////////////
  293. //
  294. //
  295. #define _IPSINK_CTL_CODE(function, method, access) CTL_CODE(FILE_DEVICE_NETWORK, function, method, access)
  296. #define IOCTL_GET_INTERFACE _IPSINK_CTL_CODE(RECEIVE_DATA, METHOD_NEITHER, FILE_ANY_ACCESS)
  297. #endif // _IPSINK_H_