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.

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