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.

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