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.

487 lines
12 KiB

  1. /********************************************************************/
  2. /** Microsoft Generic Packet Scheduler **/
  3. /** Copyright (c) Microsoft Corporation. All rights reserved. **/
  4. /********************************************************************/
  5. #ifndef __GPCIFC
  6. #define __GPCIFC
  7. //*** gpcifc.h - GPC interface definitions
  8. //
  9. // This file containes all the GPC interface definitions.
  10. /*
  11. /////////////////////////////////////////////////////////////////
  12. //
  13. // defines
  14. //
  15. /////////////////////////////////////////////////////////////////
  16. */
  17. //
  18. // Protocol Template Id's
  19. //
  20. #define GPC_PROTOCOL_TEMPLATE_IP 0
  21. #define GPC_PROTOCOL_TEMPLATE_IPX 1
  22. #define GPC_PROTOCOL_TEMPLATE_MAX 2
  23. #define GPC_PROTOCOL_TEMPLATE_NOT_SPECIFIED (-1)
  24. #define DD_GPC_DEVICE_NAME L"\\Device\\Gpc"
  25. #define GpcMajorVersion 2
  26. //
  27. // GPC max supported priorities
  28. //
  29. #define GPC_PRIORITY_MAX 16
  30. //
  31. // Classification Family IDs
  32. //
  33. #define GPC_CF_QOS 0
  34. #define GPC_CF_IPSEC_OUT 1
  35. #define GPC_CF_IPSEC_IN 2
  36. #define GPC_CF_FILTER 3
  37. #define GPC_CF_CLASS_MAP 4
  38. #define GPC_CF_MAX 5
  39. //
  40. // IPSEC specific
  41. //
  42. #define GPC_PRIORITY_IPSEC 2
  43. #define GPC_CF_IPSEC GPC_CF_IPSEC_OUT
  44. #define GPC_CF_IPSEC_MAX GPC_CF_IPSEC_IN
  45. #define GPC_CF_IPSEC_MIN GPC_CF_IPSEC_OUT
  46. //
  47. // GPC flags defined
  48. //
  49. #define GPC_FLAGS_FRAGMENT 0x00000001
  50. #define MAX_STRING_LENGTH 256
  51. //
  52. // handle definitions and error codes
  53. //
  54. #define GPC_INVALID_HANDLE (-1)
  55. #define GPC_STATUS_SUCCESS STATUS_SUCCESS
  56. #define GPC_STATUS_PENDING STATUS_PENDING
  57. #define GPC_STATUS_FAILURE STATUS_UNSUCCESSFUL
  58. #define GPC_STATUS_RESOURCES STATUS_INSUFFICIENT_RESOURCES
  59. #define GPC_STATUS_NOTREADY STATUS_DEVICE_NOT_READY
  60. #define GPC_STATUS_NOT_FOUND STATUS_NOT_FOUND
  61. #define GPC_STATUS_CONFLICT STATUS_DUPLICATE_NAME
  62. #define GPC_STATUS_INVALID_HANDLE STATUS_INVALID_HANDLE
  63. #define GPC_STATUS_INVALID_PARAMETER STATUS_INVALID_PARAMETER
  64. #define GPC_STATUS_NOT_SUPPORTED STATUS_NOT_SUPPORTED
  65. #define GPC_STATUS_NOT_EMPTY STATUS_DIRECTORY_NOT_EMPTY
  66. #define GPC_STATUS_TOO_MANY_HANDLES STATUS_TOO_MANY_OPENED_FILES
  67. #define GPC_STATUS_NOT_IMPLEMENTED STATUS_NOT_IMPLEMENTED
  68. #define GPC_STATUS_INSUFFICIENT_BUFFER STATUS_BUFFER_TOO_SMALL
  69. #define GPC_STATUS_NO_MEMORY STATUS_NO_MEMORY
  70. #define GPC_STATUS_IGNORED 1L
  71. /*
  72. /////////////////////////////////////////////////////////////////
  73. //
  74. // typedef
  75. //
  76. /////////////////////////////////////////////////////////////////
  77. */
  78. //
  79. // Gpc status
  80. //
  81. typedef NTSTATUS GPC_STATUS;
  82. //
  83. // handles
  84. //
  85. typedef HANDLE GPC_HANDLE, *PGPC_HANDLE;
  86. typedef HANDLE GPC_CLIENT_HANDLE, *PGPC_CLIENT_HANDLE;
  87. //
  88. // A classification handle is used as a reference to a classification
  89. // block by the clients
  90. //
  91. typedef ULONG CLASSIFICATION_HANDLE, *PCLASSIFICATION_HANDLE;
  92. //
  93. // A pointer to the CfInfo blob data that is stored in the GPC.
  94. // The client will use this definition in all references to a CfInfo blob.
  95. //
  96. typedef UCHAR GPC_CFINFO, *PGPC_CFINFO;
  97. typedef VOID GPC_PATTERN, *PGPC_PATTERN;
  98. typedef struct _TC_INTERFACE_ID {
  99. ULONG InterfaceId;
  100. ULONG LinkId;
  101. } TC_INTERFACE_ID, *PTC_INTERFACE_ID;
  102. //
  103. // Clients on the IP stack use the IP template.
  104. // The usage of the union is defined by the value of the ProtocolId,
  105. // which can be IP, TCP, UDP, ICMP or IPSEC.
  106. //
  107. typedef struct _GPC_IP_PATTERN {
  108. TC_INTERFACE_ID InterfaceId;
  109. ULONG SrcAddr;
  110. ULONG DstAddr;
  111. union {
  112. struct { USHORT s_srcport,s_dstport; } S_un_ports; // UDP, TCP
  113. struct { UCHAR s_type,s_code; USHORT filler; } S_un_icmp; // ICMP
  114. ULONG S_Spi; // IPSEC
  115. } S_un;
  116. UCHAR ProtocolId;
  117. UCHAR Reserved[3];
  118. #define gpcSrcPort S_un.S_un_ports.s_srcport
  119. #define gpcDstPort S_un.S_un_ports.s_dstport
  120. #define gpcIcmpType S_un.S_un_icmp.s_type
  121. #define gpcIcmpCode S_un.S_un_icmp.s_code
  122. #define gpcSpi S_un.S_Spi
  123. } GPC_IP_PATTERN, *PGPC_IP_PATTERN;
  124. //
  125. // Clients of the IPX stack will use the IPX pattern
  126. //
  127. typedef struct _GPC_IPX_PATTERN {
  128. struct {
  129. ULONG NetworkAddress;
  130. UCHAR NodeAddress[6];
  131. USHORT Socket;
  132. } Src, Dest;
  133. } GPC_IPX_PATTERN, *PGPC_IPX_PATTERN;
  134. typedef struct _GPC_GEN_PATTERN {
  135. ULONG ProtocolId;
  136. ULONG PatternSize;
  137. ULONG PatternOffset;
  138. ULONG MaskOffset;
  139. //
  140. // the pattern and mask bits will follow here...
  141. //
  142. } GPC_GEN_PATTERN, *PGPC_GEN_PATTERN;
  143. typedef struct _GPC_ENUM_CFINFO_BUFFER {
  144. ULONG Length;
  145. USHORT InstanceNameLength;
  146. WCHAR InstanceName[MAX_STRING_LENGTH];
  147. ULONG CfInfoSize;
  148. ULONG CfInfoOffset; // from the beginning of this buffer
  149. GPC_CLIENT_HANDLE OwnerClientCtx;
  150. ULONG PatternCount;
  151. ULONG PatternMaskLen;
  152. GPC_GEN_PATTERN GenericPattern[1];
  153. } GPC_ENUM_CFINFO_BUFFER, *PGPC_ENUM_CFINFO_BUFFER;
  154. /*
  155. /////////////////////////////////////////////////////////////////
  156. //
  157. // Client handler prototypes
  158. //
  159. /////////////////////////////////////////////////////////////////
  160. */
  161. typedef
  162. GPC_STATUS
  163. (*GPC_CL_ADD_CFINFO_NOTIFY_HANDLER)(
  164. IN GPC_CLIENT_HANDLE ClientContext,
  165. IN GPC_HANDLE GpcCfInfoHandle,
  166. IN ULONG CfInfoSize,
  167. IN PVOID pCfInfo,
  168. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext
  169. );
  170. typedef
  171. VOID
  172. (*GPC_CL_ADD_CFINFO_COMPLETE_HANDLER)(
  173. IN GPC_CLIENT_HANDLE ClientContext,
  174. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  175. IN GPC_STATUS Status
  176. );
  177. typedef
  178. VOID
  179. (*GPC_CL_MODIFY_CFINFO_COMPLETE_HANDLER)(
  180. IN GPC_CLIENT_HANDLE ClientContext,
  181. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  182. IN GPC_STATUS Status
  183. );
  184. typedef
  185. GPC_STATUS
  186. (*GPC_CL_MODIFY_CFINFO_NOTIFY_HANDLER)(
  187. IN GPC_CLIENT_HANDLE ClientContext,
  188. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  189. IN ULONG CfInfoSize,
  190. IN PVOID pNewCfInfo
  191. );
  192. typedef
  193. VOID
  194. (*GPC_CL_REMOVE_CFINFO_COMPLETE_HANDLER)(
  195. IN GPC_CLIENT_HANDLE ClientContext,
  196. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  197. IN GPC_STATUS Status
  198. );
  199. typedef
  200. GPC_STATUS
  201. (*GPC_CL_REMOVE_CFINFO_NOTIFY_HANDLER)(
  202. IN GPC_CLIENT_HANDLE ClientContext,
  203. IN GPC_CLIENT_HANDLE ClientCfInfoContext
  204. );
  205. typedef
  206. GPC_STATUS
  207. (*GPC_CL_GET_CFINFO_NAME)(
  208. IN GPC_CLIENT_HANDLE ClientContext,
  209. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  210. OUT PUNICODE_STRING CfInfoName
  211. );
  212. //
  213. // A function list used to pass function pointers for client registration.
  214. //
  215. typedef struct _GPC_CLIENT_FUNC_LIST {
  216. ULONG GpcVersion;
  217. GPC_CL_ADD_CFINFO_COMPLETE_HANDLER ClAddCfInfoCompleteHandler;
  218. GPC_CL_ADD_CFINFO_NOTIFY_HANDLER ClAddCfInfoNotifyHandler;
  219. GPC_CL_MODIFY_CFINFO_COMPLETE_HANDLER ClModifyCfInfoCompleteHandler;
  220. GPC_CL_MODIFY_CFINFO_NOTIFY_HANDLER ClModifyCfInfoNotifyHandler;
  221. GPC_CL_REMOVE_CFINFO_COMPLETE_HANDLER ClRemoveCfInfoCompleteHandler;
  222. GPC_CL_REMOVE_CFINFO_NOTIFY_HANDLER ClRemoveCfInfoNotifyHandler;
  223. GPC_CL_GET_CFINFO_NAME ClGetCfInfoName;
  224. } GPC_CLIENT_FUNC_LIST, *PGPC_CLIENT_FUNC_LIST;
  225. /*
  226. /////////////////////////////////////////////////////////////////
  227. //
  228. // GPC API prototypes
  229. //
  230. /////////////////////////////////////////////////////////////////
  231. */
  232. //
  233. // Calls to GPC
  234. //
  235. typedef
  236. GPC_STATUS
  237. (*GPC_GET_CFINFO_CLIENT_CONTEXT_HANDLER)(
  238. IN GPC_HANDLE ClientHandle,
  239. IN CLASSIFICATION_HANDLE ClassificationHandle,
  240. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext
  241. );
  242. typedef
  243. GPC_CLIENT_HANDLE
  244. (*GPC_GET_CFINFO_CLIENT_CONTEXT_WITH_REF_HANDLER)(
  245. IN GPC_HANDLE ClientHandle,
  246. IN CLASSIFICATION_HANDLE ClassificationHandle,
  247. IN ULONG Offset
  248. );
  249. typedef
  250. GPC_STATUS
  251. (*GPC_GET_ULONG_FROM_CFINFO_HANDLER)(
  252. IN GPC_HANDLE ClientHandle,
  253. IN CLASSIFICATION_HANDLE ClassificationHandle,
  254. IN ULONG Offset,
  255. OUT PULONG pValue
  256. );
  257. typedef
  258. GPC_STATUS
  259. (*GPC_REGISTER_CLIENT_HANDLER)(
  260. IN ULONG CfId,
  261. IN ULONG Flags,
  262. IN ULONG MaxPriorities,
  263. IN PGPC_CLIENT_FUNC_LIST pClientFuncList,
  264. IN GPC_CLIENT_HANDLE ClientContext,
  265. OUT PGPC_HANDLE pClientHandle
  266. );
  267. typedef
  268. GPC_STATUS
  269. (*GPC_DEREGISTER_CLIENT_HANDLER)(
  270. IN GPC_HANDLE ClientHandle
  271. );
  272. typedef
  273. GPC_STATUS
  274. (*GPC_ADD_CFINFO_HANDLER)(
  275. IN GPC_HANDLE ClientHandle,
  276. IN ULONG CfInfoSize,
  277. IN PVOID pClientCfInfo,
  278. IN GPC_CLIENT_HANDLE ClientCfInfoContext,
  279. OUT PGPC_HANDLE pGpcCfInfoHandle
  280. );
  281. typedef
  282. GPC_STATUS
  283. (*GPC_ADD_PATTERN_HANDLER)(
  284. IN GPC_HANDLE ClientHandle,
  285. IN ULONG ProtocolTemplate,
  286. IN PVOID Pattern,
  287. IN PVOID Mask,
  288. IN ULONG Priority,
  289. IN GPC_HANDLE GpcCfInfoHandle,
  290. OUT PGPC_HANDLE pGpcPatternHandle,
  291. OUT PCLASSIFICATION_HANDLE pClassificationHandle
  292. );
  293. typedef
  294. VOID
  295. (*GPC_ADD_CFINFO_NOTIFY_COMPLETE_HANDLER)(
  296. IN GPC_HANDLE ClientHandle,
  297. IN GPC_HANDLE GpcCfInfoHandle,
  298. IN GPC_STATUS Status,
  299. IN GPC_CLIENT_HANDLE ClientCfInfoContext
  300. );
  301. typedef
  302. GPC_STATUS
  303. (*GPC_MODIFY_CFINFO_HANDLER) (
  304. IN GPC_HANDLE ClientHandle,
  305. IN GPC_HANDLE GpcCfInfoHandle,
  306. IN ULONG CfInfoSize,
  307. IN PVOID pClientCfInfo
  308. );
  309. typedef
  310. VOID
  311. (*GPC_MODIFY_CFINFO_NOTIFY_COMPLETE_HANDLER)(
  312. IN GPC_HANDLE ClientHandle,
  313. IN GPC_HANDLE GpcCfInfoHandle,
  314. IN GPC_STATUS Status
  315. );
  316. typedef
  317. GPC_STATUS
  318. (*GPC_REMOVE_CFINFO_HANDLER) (
  319. IN GPC_HANDLE ClientHandle,
  320. IN GPC_HANDLE GpcCfInfoHandle
  321. );
  322. typedef
  323. VOID
  324. (*GPC_REMOVE_CFINFO_NOTIFY_COMPLETE_HANDLER)(
  325. IN GPC_HANDLE ClientHandle,
  326. IN GPC_HANDLE GpcCfInfoHandle,
  327. IN GPC_STATUS Status
  328. );
  329. typedef
  330. GPC_STATUS
  331. (*GPC_REMOVE_PATTERN_HANDLER) (
  332. IN GPC_HANDLE ClientHandle,
  333. IN GPC_HANDLE GpcPatternHandle
  334. );
  335. typedef
  336. GPC_STATUS
  337. (*GPC_CLASSIFY_PATTERN_HANDLER) (
  338. IN GPC_HANDLE ClientHandle,
  339. IN ULONG ProtocolTemplate,
  340. IN PVOID pPattern,
  341. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext,
  342. IN OUT PCLASSIFICATION_HANDLE pClassificationHandle,
  343. IN ULONG Offset,
  344. OUT PULONG pValue,
  345. IN BOOLEAN bNoCache
  346. );
  347. typedef
  348. GPC_STATUS
  349. (*GPC_CLASSIFY_PACKET_HANDLER) (
  350. IN GPC_HANDLE ClientHandle,
  351. IN ULONG ProtocolTemplate,
  352. IN PVOID pNdisPacket, // PNDIS_PACKET type
  353. IN ULONG TransportHeaderOffset,
  354. IN PTC_INTERFACE_ID pInterfaceId,
  355. OUT PGPC_CLIENT_HANDLE pClientCfInfoContext,
  356. IN OUT PCLASSIFICATION_HANDLE pClassificationHandle
  357. );
  358. typedef struct _GPC_EXPORTED_CALLS {
  359. ULONG GpcVersion;
  360. HANDLE Reserved;
  361. GPC_GET_CFINFO_CLIENT_CONTEXT_HANDLER GpcGetCfInfoClientContextHandler;
  362. GPC_GET_CFINFO_CLIENT_CONTEXT_WITH_REF_HANDLER GpcGetCfInfoClientContextWithRefHandler;
  363. GPC_GET_ULONG_FROM_CFINFO_HANDLER GpcGetUlongFromCfInfoHandler;
  364. GPC_REGISTER_CLIENT_HANDLER GpcRegisterClientHandler;
  365. GPC_DEREGISTER_CLIENT_HANDLER GpcDeregisterClientHandler;
  366. GPC_ADD_CFINFO_HANDLER GpcAddCfInfoHandler;
  367. GPC_ADD_PATTERN_HANDLER GpcAddPatternHandler;
  368. GPC_ADD_CFINFO_NOTIFY_COMPLETE_HANDLER GpcAddCfInfoNotifyCompleteHandler;
  369. GPC_MODIFY_CFINFO_HANDLER GpcModifyCfInfoHandler;
  370. GPC_MODIFY_CFINFO_NOTIFY_COMPLETE_HANDLER GpcModifyCfInfoNotifyCompleteHandler;
  371. GPC_REMOVE_CFINFO_HANDLER GpcRemoveCfInfoHandler;
  372. GPC_REMOVE_CFINFO_NOTIFY_COMPLETE_HANDLER GpcRemoveCfInfoNotifyCompleteHandler;
  373. GPC_REMOVE_PATTERN_HANDLER GpcRemovePatternHandler;
  374. GPC_CLASSIFY_PATTERN_HANDLER GpcClassifyPatternHandler;
  375. GPC_CLASSIFY_PACKET_HANDLER GpcClassifyPacketHandler;
  376. } GPC_EXPORTED_CALLS, *PGPC_EXPORTED_CALLS;
  377. NTSTATUS
  378. GpcInitialize(
  379. OUT PGPC_EXPORTED_CALLS pGpcEntries
  380. );
  381. NTSTATUS
  382. GpcDeinitialize(
  383. IN PGPC_EXPORTED_CALLS pGpcEntries
  384. );
  385. #if 0
  386. NTSTATUS
  387. GetInterfaceIdFromIp(
  388. IN ULONG DestAddress,
  389. IN PULONG pBestIfIndex
  390. );
  391. #endif
  392. #endif // __GPCIFC