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.

551 lines
12 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. traffic.h
  5. Abstract:
  6. This module contains API definitions for the traffic control interface.
  7. --*/
  8. #ifndef __TRAFFIC_H
  9. #define __TRAFFIC_H
  10. #if _MSC_VER > 1000
  11. #pragma once
  12. #endif
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. //---------------------------------------------------------------------------
  17. //
  18. // Define's
  19. //
  20. #define CURRENT_TCI_VERSION 0x0002
  21. //
  22. // Definitions of notification events. These may be passed
  23. // to the client's notification handler, to identify the
  24. // notification type
  25. //
  26. //
  27. // A TC interface has come up
  28. //
  29. #define TC_NOTIFY_IFC_UP 1
  30. //
  31. // A TC interface has come down
  32. //
  33. #define TC_NOTIFY_IFC_CLOSE 2
  34. //
  35. // A change on a TC interface, typically a change in the
  36. // list of supported network addresses
  37. //
  38. #define TC_NOTIFY_IFC_CHANGE 3
  39. //
  40. // A TC parameter has changed
  41. //
  42. #define TC_NOTIFY_PARAM_CHANGED 4
  43. //
  44. // A flow has been closed by the TC interface
  45. // for example: after a remote call close, or the whole interface
  46. // is going down
  47. //
  48. #define TC_NOTIFY_FLOW_CLOSE 5
  49. #define TC_INVALID_HANDLE ((HANDLE)0)
  50. #define MAX_STRING_LENGTH 256
  51. //---------------------------------------------------------------------------
  52. //
  53. // Typedef's and structures
  54. //
  55. #ifndef CALLBACK
  56. #define CALLBACK __stdcall
  57. #endif
  58. #ifndef APIENTRY
  59. #define APIENTRY FAR __stdcall
  60. #endif
  61. //
  62. // Handlers registered by the TCI client
  63. //
  64. typedef
  65. VOID (CALLBACK * TCI_NOTIFY_HANDLER)(
  66. IN HANDLE ClRegCtx,
  67. IN HANDLE ClIfcCtx,
  68. IN ULONG Event, // See list below
  69. IN HANDLE SubCode,
  70. IN ULONG BufSize,
  71. IN PVOID Buffer
  72. );
  73. typedef
  74. VOID (CALLBACK * TCI_ADD_FLOW_COMPLETE_HANDLER)(
  75. IN HANDLE ClFlowCtx,
  76. IN ULONG Status
  77. );
  78. typedef
  79. VOID (CALLBACK * TCI_MOD_FLOW_COMPLETE_HANDLER)(
  80. IN HANDLE ClFlowCtx,
  81. IN ULONG Status
  82. );
  83. typedef
  84. VOID (CALLBACK * TCI_DEL_FLOW_COMPLETE_HANDLER)(
  85. IN HANDLE ClFlowCtx,
  86. IN ULONG Status
  87. );
  88. typedef struct _TCI_CLIENT_FUNC_LIST {
  89. TCI_NOTIFY_HANDLER ClNotifyHandler;
  90. TCI_ADD_FLOW_COMPLETE_HANDLER ClAddFlowCompleteHandler;
  91. TCI_MOD_FLOW_COMPLETE_HANDLER ClModifyFlowCompleteHandler;
  92. TCI_DEL_FLOW_COMPLETE_HANDLER ClDeleteFlowCompleteHandler;
  93. } TCI_CLIENT_FUNC_LIST, *PTCI_CLIENT_FUNC_LIST;
  94. //
  95. // Network address descriptor
  96. //
  97. typedef struct _ADDRESS_LIST_DESCRIPTOR {
  98. ULONG MediaType;
  99. NETWORK_ADDRESS_LIST AddressList;
  100. } ADDRESS_LIST_DESCRIPTOR, *PADDRESS_LIST_DESCRIPTOR;
  101. //
  102. // An interface ID that is returned by the enumerator
  103. //
  104. typedef struct _TC_IFC_DESCRIPTOR {
  105. ULONG Length;
  106. LPWSTR pInterfaceName;
  107. LPWSTR pInterfaceID;
  108. ADDRESS_LIST_DESCRIPTOR AddressListDesc;
  109. } TC_IFC_DESCRIPTOR, *PTC_IFC_DESCRIPTOR;
  110. //
  111. // This structure is returned by a QoS data provider in reply to
  112. // GUID_QOS_SUPPORTED query or with an interface UP notification
  113. //
  114. typedef struct _TC_SUPPORTED_INFO_BUFFER {
  115. USHORT InstanceIDLength;
  116. // device or interface ID
  117. WCHAR InstanceID[MAX_STRING_LENGTH];
  118. // address list
  119. ADDRESS_LIST_DESCRIPTOR AddrListDesc;
  120. } TC_SUPPORTED_INFO_BUFFER, *PTC_SUPPORTED_INFO_BUFFER;
  121. //
  122. // Filters are used to match packets. The Pattern field
  123. // indicates the values to which bits in corresponding
  124. // positions in candidate packets should be compared. The
  125. // Mask field indicates which bits are to be compared and
  126. // which bits are don't cares.
  127. //
  128. // Different filters can be submitted on the TCI interface.
  129. // The generic filter structure is defined to include an
  130. // AddressType, which indicates the specific type of filter to
  131. // follow.
  132. //
  133. typedef struct _TC_GEN_FILTER {
  134. USHORT AddressType; // IP, IPX, etc.
  135. ULONG PatternSize; // byte count of the pattern
  136. PVOID Pattern; // specific format, e.g. IP_PATTERN
  137. PVOID Mask; // same type as Pattern
  138. } TC_GEN_FILTER, *PTC_GEN_FILTER;
  139. //
  140. // A generic flow includes two flowspecs and a freeform
  141. // buffer which contains flow specific TC objects.
  142. //
  143. typedef struct _TC_GEN_FLOW {
  144. FLOWSPEC SendingFlowspec;
  145. FLOWSPEC ReceivingFlowspec;
  146. ULONG TcObjectsLength; // number of optional bytes
  147. QOS_OBJECT_HDR TcObjects[1];
  148. } TC_GEN_FLOW, *PTC_GEN_FLOW;
  149. //
  150. // Format of specific pattern or mask used by GPC for the IP protocol
  151. //
  152. typedef struct _IP_PATTERN {
  153. ULONG Reserved1;
  154. ULONG Reserved2;
  155. ULONG SrcAddr;
  156. ULONG DstAddr;
  157. union {
  158. struct { USHORT s_srcport,s_dstport; } S_un_ports;
  159. struct { UCHAR s_type,s_code; USHORT filler; } S_un_icmp;
  160. ULONG S_Spi;
  161. } S_un;
  162. UCHAR ProtocolId;
  163. UCHAR Reserved3[3];
  164. #define tcSrcPort S_un.S_un_ports.s_srcport
  165. #define tcDstPort S_un.S_un_ports.s_dstport
  166. #define tcIcmpType S_un.S_un_icmp.s_type
  167. #define tcIcmpCode S_un.S_un_icmp.s_code
  168. #define tcSpi S_un.S_Spi
  169. } IP_PATTERN, *PIP_PATTERN;
  170. //
  171. // Format of specific pattern or mask used by GPC for the IPX protocol
  172. //
  173. typedef struct _IPX_PATTERN {
  174. struct {
  175. ULONG NetworkAddress;
  176. UCHAR NodeAddress[6];
  177. USHORT Socket;
  178. } Src, Dest;
  179. } IPX_PATTERN, *PIPX_PATTERN;
  180. //
  181. // The enumeration buffer is the flow parameters + a list of filters
  182. //
  183. typedef struct _ENUMERATION_BUFFER {
  184. ULONG Length;
  185. ULONG OwnerProcessId;
  186. USHORT FlowNameLength;
  187. WCHAR FlowName[MAX_STRING_LENGTH];
  188. PTC_GEN_FLOW pFlow;
  189. ULONG NumberOfFilters;
  190. TC_GEN_FILTER GenericFilter[1]; // one for each filter
  191. } ENUMERATION_BUFFER, *PENUMERATION_BUFFER;
  192. //
  193. // QoS objects supported by traffic
  194. //
  195. #define QOS_TRAFFIC_GENERAL_ID_BASE 4000
  196. #define QOS_OBJECT_DS_CLASS (0x00000001 + QOS_TRAFFIC_GENERAL_ID_BASE)
  197. /* QOS_DS_CLASS structure passed */
  198. #define QOS_OBJECT_TRAFFIC_CLASS (0x00000002 + QOS_TRAFFIC_GENERAL_ID_BASE)
  199. /* QOS_Traffic class structure passed */
  200. #define QOS_OBJECT_DIFFSERV (0x00000003 + QOS_TRAFFIC_GENERAL_ID_BASE)
  201. /* QOS_DIFFSERV Structure */
  202. #define QOS_OBJECT_TCP_TRAFFIC (0x00000004 + QOS_TRAFFIC_GENERAL_ID_BASE)
  203. /* QOS_TCP_TRAFFIC structure */
  204. #define QOS_OBJECT_FRIENDLY_NAME (0x00000005 + QOS_TRAFFIC_GENERAL_ID_BASE)
  205. /* QOS_FRIENDLY_NAME structure */
  206. //
  207. // This structure is used to associate a friendly name with the flow
  208. //
  209. typedef struct _QOS_FRIENDLY_NAME {
  210. QOS_OBJECT_HDR ObjectHdr;
  211. WCHAR FriendlyName[MAX_STRING_LENGTH];
  212. } QOS_FRIENDLY_NAME, *LPQOS_FRIENDLY_NAME;
  213. //
  214. // This structure may carry an 802.1 TrafficClass parameter which
  215. // has been provided to the host by a layer 2 network, for example,
  216. // in an 802.1 extended RSVP RESV message. If this object is obtained
  217. // from the network, hosts will stamp the MAC headers of corresponding
  218. // transmitted packets, with the value in the object. Otherwise, hosts
  219. // may select a value based on the standard Intserv mapping of
  220. // ServiceType to 802.1 TrafficClass.
  221. //
  222. //
  223. typedef struct _QOS_TRAFFIC_CLASS {
  224. QOS_OBJECT_HDR ObjectHdr;
  225. ULONG TrafficClass;
  226. } QOS_TRAFFIC_CLASS, *LPQOS_TRAFFIC_CLASS;
  227. //
  228. // This structure may carry an DSField parameter which has been provided to
  229. // the host by a layer 3 network, for example, in an extended RSVP RESV message.
  230. // If this object is obtained from the network, hosts will stamp the DS Field on the
  231. // IP header of transmitted packets, with the value in the object. Otherwise, hosts
  232. // may select a value based on the standard Intserv mapping of ServiceType to DS Field
  233. //
  234. typedef struct _QOS_DS_CLASS {
  235. QOS_OBJECT_HDR ObjectHdr;
  236. ULONG DSField;
  237. } QOS_DS_CLASS, *LPQOS_DS_CLASS;
  238. //
  239. // This structure is used to create DiffServ Flows. This creates flows in the packet scheduler
  240. // and allows it to classify to packets based on a particular DS field. This structure takes
  241. // a variable length array of QOS_DIFFSERV_RULE, where each DS field is specified by a
  242. // QOS_DIFFSERV_RULE
  243. //
  244. typedef struct _QOS_DIFFSERV {
  245. QOS_OBJECT_HDR ObjectHdr;
  246. ULONG DSFieldCount;
  247. UCHAR DiffservRule[1];
  248. } QOS_DIFFSERV, *LPQOS_DIFFSERV;
  249. //
  250. // The rule for a Diffserv DS codepoint.
  251. //
  252. typedef struct _QOS_DIFFSERV_RULE {
  253. UCHAR InboundDSField;
  254. UCHAR ConformingOutboundDSField;
  255. UCHAR NonConformingOutboundDSField;
  256. UCHAR ConformingUserPriority;
  257. UCHAR NonConformingUserPriority;
  258. } QOS_DIFFSERV_RULE, *LPQOS_DIFFSERV_RULE;
  259. //
  260. // This structure is passed to indicate that the IP Precedence and UserPriority mappings for the flow
  261. // have to be set to the system defaults for TCP traffic. If this object is passed,
  262. // the ServiceType ==> DSField mapping, ServiceType ==> UserPriorityMapping, QOS_OBJECT_DS_CLASS
  263. // and QOS_OBJECT_TRAFFIC_CLASS will be ignored.
  264. //
  265. typedef struct _QOS_TCP_TRAFFIC {
  266. QOS_OBJECT_HDR ObjectHdr;
  267. } QOS_TCP_TRAFFIC, *LPQOS_TCP_TRAFFIC;
  268. //---------------------------------------------------------------------------
  269. //
  270. // Interface Function Definitions
  271. //
  272. ULONG
  273. APIENTRY
  274. TcRegisterClient(
  275. IN ULONG TciVersion,
  276. IN HANDLE ClRegCtx,
  277. IN PTCI_CLIENT_FUNC_LIST ClientHandlerList,
  278. OUT PHANDLE pClientHandle
  279. );
  280. ULONG
  281. APIENTRY
  282. TcEnumerateInterfaces(
  283. IN HANDLE ClientHandle,
  284. IN OUT PULONG pBufferSize,
  285. OUT PTC_IFC_DESCRIPTOR InterfaceBuffer
  286. );
  287. ULONG
  288. APIENTRY
  289. TcOpenInterfaceA(
  290. IN LPSTR pInterfaceName,
  291. IN HANDLE ClientHandle,
  292. IN HANDLE ClIfcCtx,
  293. OUT PHANDLE pIfcHandle
  294. );
  295. ULONG
  296. APIENTRY
  297. TcOpenInterfaceW(
  298. IN LPWSTR pInterfaceName,
  299. IN HANDLE ClientHandle,
  300. IN HANDLE ClIfcCtx,
  301. OUT PHANDLE pIfcHandle
  302. );
  303. ULONG
  304. APIENTRY
  305. TcCloseInterface(
  306. IN HANDLE IfcHandle
  307. );
  308. ULONG
  309. APIENTRY
  310. TcQueryInterface(
  311. IN HANDLE IfcHandle,
  312. IN LPGUID pGuidParam,
  313. IN BOOLEAN NotifyChange,
  314. IN OUT PULONG pBufferSize,
  315. OUT PVOID Buffer
  316. );
  317. ULONG
  318. APIENTRY
  319. TcSetInterface(
  320. IN HANDLE IfcHandle,
  321. IN LPGUID pGuidParam,
  322. IN ULONG BufferSize,
  323. IN PVOID Buffer
  324. );
  325. ULONG
  326. APIENTRY
  327. TcQueryFlowA(
  328. IN LPSTR pFlowName,
  329. IN LPGUID pGuidParam,
  330. IN OUT PULONG pBufferSize,
  331. OUT PVOID Buffer
  332. );
  333. ULONG
  334. APIENTRY
  335. TcQueryFlowW(
  336. IN LPWSTR pFlowName,
  337. IN LPGUID pGuidParam,
  338. IN OUT PULONG pBufferSize,
  339. OUT PVOID Buffer
  340. );
  341. ULONG
  342. APIENTRY
  343. TcSetFlowA(
  344. IN LPSTR pFlowName,
  345. IN LPGUID pGuidParam,
  346. IN ULONG BufferSize,
  347. IN PVOID Buffer
  348. );
  349. ULONG
  350. APIENTRY
  351. TcSetFlowW(
  352. IN LPWSTR pFlowName,
  353. IN LPGUID pGuidParam,
  354. IN ULONG BufferSize,
  355. IN PVOID Buffer
  356. );
  357. ULONG
  358. APIENTRY
  359. TcAddFlow(
  360. IN HANDLE IfcHandle,
  361. IN HANDLE ClFlowCtx,
  362. IN ULONG Flags,
  363. IN PTC_GEN_FLOW pGenericFlow,
  364. OUT PHANDLE pFlowHandle
  365. );
  366. ULONG
  367. APIENTRY
  368. TcGetFlowNameA(
  369. IN HANDLE FlowHandle,
  370. IN ULONG StrSize,
  371. OUT LPSTR pFlowName
  372. );
  373. ULONG
  374. APIENTRY
  375. TcGetFlowNameW(
  376. IN HANDLE FlowHandle,
  377. IN ULONG StrSize,
  378. OUT LPWSTR pFlowName
  379. );
  380. ULONG
  381. APIENTRY
  382. TcModifyFlow(
  383. IN HANDLE FlowHandle,
  384. IN PTC_GEN_FLOW pGenericFlow
  385. );
  386. ULONG
  387. APIENTRY
  388. TcAddFilter(
  389. IN HANDLE FlowHandle,
  390. IN PTC_GEN_FILTER pGenericFilter,
  391. OUT PHANDLE pFilterHandle
  392. );
  393. ULONG
  394. APIENTRY
  395. TcDeregisterClient(
  396. IN HANDLE ClientHandle
  397. );
  398. ULONG
  399. APIENTRY
  400. TcDeleteFlow(
  401. IN HANDLE FlowHandle
  402. );
  403. ULONG
  404. APIENTRY
  405. TcDeleteFilter(
  406. IN HANDLE FilterHandle
  407. );
  408. ULONG
  409. APIENTRY
  410. TcEnumerateFlows(
  411. IN HANDLE IfcHandle,
  412. IN OUT PHANDLE pEnumHandle,
  413. IN OUT PULONG pFlowCount,
  414. IN OUT PULONG pBufSize,
  415. OUT PENUMERATION_BUFFER Buffer
  416. );
  417. #ifdef UNICODE
  418. #define TcOpenInterface TcOpenInterfaceW
  419. #define TcQueryFlow TcQueryFlowW
  420. #define TcSetFlow TcSetFlowW
  421. #define TcGetFlowName TcGetFlowNameW
  422. #else // UNICODE
  423. #define TcOpenInterface TcOpenInterfaceA
  424. #define TcQueryFlow TcQueryFlowA
  425. #define TcSetFlow TcSetFlowA
  426. #define TcGetFlowName TcGetFlowNameA
  427. #endif // UNICODE
  428. #ifdef __cplusplus
  429. }
  430. #endif
  431. #endif