jwatraffic.pas 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. {******************************************************************************}
  2. { }
  3. { Traffic Control API interface Unit for Object Pascal }
  4. { }
  5. { Portions created by Microsoft are Copyright (C) 1995-2001 Microsoft }
  6. { Corporation. All Rights Reserved. }
  7. { }
  8. { The original file is: traffic.h, released June 2000. The original Pascal }
  9. { code is: Traffic.pas, released December 2000. The initial developer of the }
  10. { Pascal code is Marcel van Brakel (brakelm att chello dott nl). }
  11. { }
  12. { Portions created by Marcel van Brakel are Copyright (C) 1999-2001 }
  13. { Marcel van Brakel. All Rights Reserved. }
  14. { }
  15. { Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) }
  16. { }
  17. { You may retrieve the latest version of this file at the Project JEDI }
  18. { APILIB home page, located at http://jedi-apilib.sourceforge.net }
  19. { }
  20. { The contents of this file are used with permission, subject to the Mozilla }
  21. { Public License Version 1.1 (the "License"); you may not use this file except }
  22. { in compliance with the License. You may obtain a copy of the License at }
  23. { http://www.mozilla.org/MPL/MPL-1.1.html }
  24. { }
  25. { Software distributed under the License is distributed on an "AS IS" basis, }
  26. { WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for }
  27. { the specific language governing rights and limitations under the License. }
  28. { }
  29. { Alternatively, the contents of this file may be used under the terms of the }
  30. { GNU Lesser General Public License (the "LGPL License"), in which case the }
  31. { provisions of the LGPL License are applicable instead of those above. }
  32. { If you wish to allow use of your version of this file only under the terms }
  33. { of the LGPL License and not to allow others to use your version of this file }
  34. { under the MPL, indicate your decision by deleting the provisions above and }
  35. { replace them with the notice and other provisions required by the LGPL }
  36. { License. If you do not delete the provisions above, a recipient may use }
  37. { your version of this file under either the MPL or the LGPL License. }
  38. { }
  39. { For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html }
  40. { }
  41. {******************************************************************************}
  42. unit JwaTraffic;
  43. {$WEAKPACKAGEUNIT}
  44. {$HPPEMIT ''}
  45. {$HPPEMIT '#include "traffic.h"'}
  46. {$HPPEMIT ''}
  47. {$I jediapilib.inc}
  48. interface
  49. uses
  50. JwaWinType, JwaQos;
  51. //---------------------------------------------------------------------------
  52. //
  53. // Define's
  54. //
  55. const
  56. CURRENT_TCI_VERSION = $0002;
  57. {$EXTERNALSYM CURRENT_TCI_VERSION}
  58. //
  59. // Definitions of notification events. These may be passed
  60. // to the client's notification handler, to identify the
  61. // notification type
  62. //
  63. //
  64. // A TC interface has come up
  65. //
  66. TC_NOTIFY_IFC_UP = 1;
  67. {$EXTERNALSYM TC_NOTIFY_IFC_UP}
  68. //
  69. // A TC interface has come down
  70. //
  71. TC_NOTIFY_IFC_CLOSE = 2;
  72. {$EXTERNALSYM TC_NOTIFY_IFC_CLOSE}
  73. //
  74. // A change on a TC interface, typically a change in the
  75. // list of supported network addresses
  76. //
  77. TC_NOTIFY_IFC_CHANGE = 3;
  78. {$EXTERNALSYM TC_NOTIFY_IFC_CHANGE}
  79. //
  80. // A TC parameter has changed
  81. //
  82. TC_NOTIFY_PARAM_CHANGED = 4;
  83. {$EXTERNALSYM TC_NOTIFY_PARAM_CHANGED}
  84. //
  85. // A flow has been closed by the TC interface
  86. // for example: after a remote call close, or the whole interface
  87. // is going down
  88. //
  89. TC_NOTIFY_FLOW_CLOSE = 5;
  90. {$EXTERNALSYM TC_NOTIFY_FLOW_CLOSE}
  91. TC_INVALID_HANDLE = HANDLE(0);
  92. {$EXTERNALSYM TC_INVALID_HANDLE}
  93. MAX_STRING_LENGTH = 256;
  94. {$EXTERNALSYM MAX_STRING_LENGTH}
  95. //---------------------------------------------------------------------------
  96. //
  97. // Typedef's and structures
  98. //
  99. //
  100. // Handlers registered by the TCI client
  101. //
  102. type
  103. TCI_NOTIFY_HANDLER = procedure(ClRegCtx, ClIfcCtx: HANDLE; Event: ULONG;
  104. SubCode: HANDLE; BufSize: ULONG; Buffer: PVOID); stdcall;
  105. {$EXTERNALSYM TCI_NOTIFY_HANDLER}
  106. TTciNotifyHandler = TCI_NOTIFY_HANDLER;
  107. TCI_ADD_FLOW_COMPLETE_HANDLER = procedure(ClFlowCtx: HANDLE; Status: ULONG); stdcall;
  108. {$EXTERNALSYM TCI_ADD_FLOW_COMPLETE_HANDLER}
  109. TTciAddFlowCompleteHandler = TCI_ADD_FLOW_COMPLETE_HANDLER;
  110. TCI_MOD_FLOW_COMPLETE_HANDLER = procedure(ClFlowCtx: HANDLE; Status: ULONG); stdcall;
  111. {$EXTERNALSYM TCI_MOD_FLOW_COMPLETE_HANDLER}
  112. TTciModFlowCompleteHandler = TCI_MOD_FLOW_COMPLETE_HANDLER;
  113. TCI_DEL_FLOW_COMPLETE_HANDLER = procedure(ClFlowCtx: HANDLE; Status: ULONG); stdcall;
  114. {$EXTERNALSYM TCI_DEL_FLOW_COMPLETE_HANDLER}
  115. TTciDelFlowComlpeteHandler = TCI_DEL_FLOW_COMPLETE_HANDLER;
  116. type
  117. PTCI_CLIENT_FUNC_LIST = ^TCI_CLIENT_FUNC_LIST;
  118. {$EXTERNALSYM PTCI_CLIENT_FUNC_LIST}
  119. _TCI_CLIENT_FUNC_LIST = record
  120. ClNotifyHandler: TCI_NOTIFY_HANDLER;
  121. ClAddFlowCompleteHandler: TCI_ADD_FLOW_COMPLETE_HANDLER;
  122. ClModifyFlowCompleteHandler: TCI_MOD_FLOW_COMPLETE_HANDLER;
  123. ClDeleteFlowCompleteHandler: TCI_DEL_FLOW_COMPLETE_HANDLER;
  124. end;
  125. {$EXTERNALSYM _TCI_CLIENT_FUNC_LIST}
  126. TCI_CLIENT_FUNC_LIST = _TCI_CLIENT_FUNC_LIST;
  127. {$EXTERNALSYM TCI_CLIENT_FUNC_LIST}
  128. TTciClientFuncList = TCI_CLIENT_FUNC_LIST;
  129. PTciClientFuncList = PTCI_CLIENT_FUNC_LIST;
  130. // TODO NETWORD_ADDRESS and NETWORK_ADDRESS_LIST are from NtDDNdis.h
  131. _NETWORK_ADDRESS = record
  132. AddressLength: USHORT; // length in bytes of Address[] in this
  133. AddressType: USHORT; // type of this address (NDIS_PROTOCOL_ID_XXX above)
  134. Address: array [0..0] of UCHAR; // actually AddressLength bytes long
  135. end;
  136. NETWORK_ADDRESS = _NETWORK_ADDRESS;
  137. PNETWORK_ADDRESS = ^NETWORK_ADDRESS;
  138. _NETWORK_ADDRESS_LIST = record
  139. AddressCount: LONG; // number of addresses following
  140. AddressType: USHORT; // type of this address (NDIS_PROTOCOL_ID_XXX above)
  141. Address: array [0..0] of NETWORK_ADDRESS; // actually AddressCount elements long
  142. end;
  143. NETWORK_ADDRESS_LIST = _NETWORK_ADDRESS_LIST;
  144. PNETWORK_ADDRESS_LIST = ^NETWORK_ADDRESS_LIST;
  145. //
  146. // Network address descriptor
  147. //
  148. PADDRESS_LIST_DESCRIPTOR = ^ADDRESS_LIST_DESCRIPTOR;
  149. {$EXTERNALSYM PADDRESS_LIST_DESCRIPTOR}
  150. _ADDRESS_LIST_DESCRIPTOR = record
  151. MediaType: ULONG;
  152. AddressList: NETWORK_ADDRESS_LIST;
  153. end;
  154. {$EXTERNALSYM _ADDRESS_LIST_DESCRIPTOR}
  155. ADDRESS_LIST_DESCRIPTOR = _ADDRESS_LIST_DESCRIPTOR;
  156. {$EXTERNALSYM ADDRESS_LIST_DESCRIPTOR}
  157. TAddressListDescriptor = ADDRESS_LIST_DESCRIPTOR;
  158. PAddressListDescriptor = PADDRESS_LIST_DESCRIPTOR;
  159. //
  160. // An interface ID that is returned by the enumerator
  161. //
  162. PTC_IFC_DESCRIPTOR = ^TC_IFC_DESCRIPTOR;
  163. {$EXTERNALSYM PTC_IFC_DESCRIPTOR}
  164. _TC_IFC_DESCRIPTOR = record
  165. Length: ULONG;
  166. pInterfaceName: LPWSTR;
  167. pInterfaceID: LPWSTR;
  168. AddressListDesc: ADDRESS_LIST_DESCRIPTOR;
  169. end;
  170. {$EXTERNALSYM _TC_IFC_DESCRIPTOR}
  171. TC_IFC_DESCRIPTOR = _TC_IFC_DESCRIPTOR;
  172. {$EXTERNALSYM TC_IFC_DESCRIPTOR}
  173. TTcIfcDescriptor = TC_IFC_DESCRIPTOR;
  174. PTcIfcDescriptor = PTC_IFC_DESCRIPTOR;
  175. //
  176. // This structure is returned by a QoS data provider in reply to
  177. // GUID_QOS_SUPPORTED query or with an interface UP notification
  178. //
  179. PTC_SUPPORTED_INFO_BUFFER = ^TC_SUPPORTED_INFO_BUFFER;
  180. {$EXTERNALSYM PTC_SUPPORTED_INFO_BUFFER}
  181. _TC_SUPPORTED_INFO_BUFFER = record
  182. InstanceIDLength: USHORT;
  183. // device or interface ID
  184. InstanceID: array [0..MAX_STRING_LENGTH - 1] of WCHAR;
  185. // address list
  186. AddrListDesc: ADDRESS_LIST_DESCRIPTOR;
  187. end;
  188. {$EXTERNALSYM _TC_SUPPORTED_INFO_BUFFER}
  189. TC_SUPPORTED_INFO_BUFFER = _TC_SUPPORTED_INFO_BUFFER;
  190. {$EXTERNALSYM TC_SUPPORTED_INFO_BUFFER}
  191. TTcSupportedInfoBuffer = TC_SUPPORTED_INFO_BUFFER;
  192. PTcSupportedInfoBuffer = PTC_SUPPORTED_INFO_BUFFER;
  193. //
  194. // Filters are used to match packets. The Pattern field
  195. // indicates the values to which bits in corresponding
  196. // positions in candidate packets should be compared. The
  197. // Mask field indicates which bits are to be compared and
  198. // which bits are don't cares.
  199. //
  200. // Different filters can be submitted on the TCI interface.
  201. // The generic filter structure is defined to include an
  202. // AddressType, which indicates the specific type of filter to
  203. // follow.
  204. //
  205. PTC_GEN_FILTER = ^TC_GEN_FILTER;
  206. {$EXTERNALSYM PTC_GEN_FILTER}
  207. _TC_GEN_FILTER = record
  208. AddressType: USHORT; // IP, IPX, etc.
  209. PatternSize: ULONG; // byte count of the pattern
  210. Pattern: PVOID; // specific format, e.g. IP_PATTERN
  211. Mask: PVOID; // same type as Pattern
  212. end;
  213. {$EXTERNALSYM _TC_GEN_FILTER}
  214. TC_GEN_FILTER = _TC_GEN_FILTER;
  215. {$EXTERNALSYM TC_GEN_FILTER}
  216. TTcGenFilter = TC_GEN_FILTER;
  217. PTcGenFilter = PTC_GEN_FILTER;
  218. //
  219. // A generic flow includes two flowspecs and a freeform
  220. // buffer which contains flow specific TC objects.
  221. //
  222. PTC_GEN_FLOW = ^TC_GEN_FLOW;
  223. {$EXTERNALSYM PTC_GEN_FLOW}
  224. _TC_GEN_FLOW = record
  225. SendingFlowspec: FLOWSPEC;
  226. ReceivingFlowspec: FLOWSPEC;
  227. TcObjectsLength: ULONG; // number of optional bytes
  228. TcObjects: array [0..0] of QOS_OBJECT_HDR;
  229. end;
  230. {$EXTERNALSYM _TC_GEN_FLOW}
  231. TC_GEN_FLOW = _TC_GEN_FLOW;
  232. {$EXTERNALSYM TC_GEN_FLOW}
  233. TTcGenFlow = TC_GEN_FLOW;
  234. PTcGenFlow = PTC_GEN_FLOW;
  235. //
  236. // Format of specific pattern or mask used by GPC for the IP protocol
  237. //
  238. PIP_PATTERN = ^IP_PATTERN;
  239. {$EXTERNALSYM PIP_PATTERN}
  240. _IP_PATTERN = record
  241. Reserved1: ULONG;
  242. Reserved2: ULONG;
  243. SrcAddr: ULONG;
  244. DstAddr: ULONG;
  245. S_un: record
  246. case Integer of
  247. 0: (
  248. s_srcport: USHORT;
  249. s_dstport: USHORT);
  250. 1: (
  251. s_type: UCHAR;
  252. s_code: UCHAR;
  253. filler: USHORT);
  254. 2: (
  255. S_Spi: ULONG);
  256. end;
  257. ProtocolId: UCHAR;
  258. Reserved3: array [0..3 - 1] of UCHAR;
  259. end;
  260. {$EXTERNALSYM _IP_PATTERN}
  261. IP_PATTERN = _IP_PATTERN;
  262. {$EXTERNALSYM IP_PATTERN}
  263. TIpPattern = IP_PATTERN;
  264. PIpPattern = PIP_PATTERN;
  265. //
  266. // Format of specific pattern or mask used by GPC for the IPX protocol
  267. //
  268. TIpxPatternAddress = record
  269. NetworkAddress: ULONG;
  270. NodeAddress: array [0..5] of UCHAR;
  271. Socket: USHORT;
  272. end;
  273. PIPX_PATTERN = ^IPX_PATTERN;
  274. {$EXTERNALSYM PIPX_PATTERN}
  275. _IPX_PATTERN = record
  276. Src: TIpxPatternAddress;
  277. Dest: TIpxPatternAddress;
  278. end;
  279. {$EXTERNALSYM _IPX_PATTERN}
  280. IPX_PATTERN = _IPX_PATTERN;
  281. {$EXTERNALSYM IPX_PATTERN}
  282. TIpxPattern = IPX_PATTERN;
  283. PIpxPattern = PIPX_PATTERN;
  284. //
  285. // The enumeration buffer is the flow parameters + a list of filters
  286. //
  287. PENUMERATION_BUFFER = ^ENUMERATION_BUFFER;
  288. {$EXTERNALSYM PENUMERATION_BUFFER}
  289. _ENUMERATION_BUFFER = record
  290. Length: ULONG;
  291. OwnerProcessId: ULONG;
  292. FlowNameLength: USHORT;
  293. FlowName: array [0..MAX_STRING_LENGTH - 1] of WCHAR;
  294. pFlow: PTC_GEN_FLOW;
  295. NumberOfFilters: ULONG;
  296. GenericFilter: array [0..0] of TC_GEN_FILTER; // one for each filter
  297. end;
  298. {$EXTERNALSYM _ENUMERATION_BUFFER}
  299. ENUMERATION_BUFFER = _ENUMERATION_BUFFER;
  300. {$EXTERNALSYM ENUMERATION_BUFFER}
  301. TEnumerationBuffer = ENUMERATION_BUFFER;
  302. PEnumerationBuffer = PENUMERATION_BUFFER;
  303. //
  304. // QoS objects supported by traffic
  305. //
  306. const
  307. QOS_TRAFFIC_GENERAL_ID_BASE = 4000;
  308. {$EXTERNALSYM QOS_TRAFFIC_GENERAL_ID_BASE}
  309. QOS_OBJECT_DS_CLASS = $00000001 + QOS_TRAFFIC_GENERAL_ID_BASE;
  310. {$EXTERNALSYM QOS_OBJECT_DS_CLASS}
  311. QOS_OBJECT_TRAFFIC_CLASS = $00000002 + QOS_TRAFFIC_GENERAL_ID_BASE;
  312. {$EXTERNALSYM QOS_OBJECT_TRAFFIC_CLASS}
  313. QOS_OBJECT_DIFFSERV = $00000003 + QOS_TRAFFIC_GENERAL_ID_BASE;
  314. {$EXTERNALSYM QOS_OBJECT_DIFFSERV}
  315. QOS_OBJECT_TCP_TRAFFIC = $00000004 + QOS_TRAFFIC_GENERAL_ID_BASE;
  316. {$EXTERNALSYM QOS_OBJECT_TCP_TRAFFIC}
  317. QOS_OBJECT_FRIENDLY_NAME = $00000005 + QOS_TRAFFIC_GENERAL_ID_BASE;
  318. {$EXTERNALSYM QOS_OBJECT_FRIENDLY_NAME}
  319. //
  320. // This structure is used to associate a friendly name with the flow
  321. //
  322. type
  323. LPQOS_FRIENDLY_NAME = ^QOS_FRIENDLY_NAME;
  324. {$EXTERNALSYM LPQOS_FRIENDLY_NAME}
  325. _QOS_FRIENDLY_NAME = record
  326. ObjectHdr: QOS_OBJECT_HDR;
  327. FriendlyName: array [0..MAX_STRING_LENGTH - 1] of WCHAR;
  328. end;
  329. {$EXTERNALSYM _QOS_FRIENDLY_NAME}
  330. QOS_FRIENDLY_NAME = _QOS_FRIENDLY_NAME;
  331. {$EXTERNALSYM QOS_FRIENDLY_NAME}
  332. TQosFriendlyName = QOS_FRIENDLY_NAME;
  333. PQosFriendlyName = LPQOS_FRIENDLY_NAME;
  334. //
  335. // This structure may carry an 802.1 TrafficClass parameter which
  336. // has been provided to the host by a layer 2 network, for example,
  337. // in an 802.1 extended RSVP RESV message. If this object is obtained
  338. // from the network, hosts will stamp the MAC headers of corresponding
  339. // transmitted packets, with the value in the object. Otherwise, hosts
  340. // may select a value based on the standard Intserv mapping of
  341. // ServiceType to 802.1 TrafficClass.
  342. //
  343. //
  344. LPQOS_TRAFFIC_CLASS = ^QOS_TRAFFIC_CLASS;
  345. {$EXTERNALSYM LPQOS_TRAFFIC_CLASS}
  346. _QOS_TRAFFIC_CLASS = record
  347. ObjectHdr: QOS_OBJECT_HDR;
  348. TrafficClass: ULONG;
  349. end;
  350. {$EXTERNALSYM _QOS_TRAFFIC_CLASS}
  351. QOS_TRAFFIC_CLASS = _QOS_TRAFFIC_CLASS;
  352. {$EXTERNALSYM QOS_TRAFFIC_CLASS}
  353. TQosTrafficClass = QOS_TRAFFIC_CLASS;
  354. PQosTrafficClass = LPQOS_TRAFFIC_CLASS;
  355. //
  356. // This structure may carry an DSField parameter which has been provided to
  357. // the host by a layer 3 network, for example, in an extended RSVP RESV message.
  358. // If this object is obtained from the network, hosts will stamp the DS Field on the
  359. // IP header of transmitted packets, with the value in the object. Otherwise, hosts
  360. // may select a value based on the standard Intserv mapping of ServiceType to DS Field
  361. //
  362. LPQOS_DS_CLASS = ^QOS_DS_CLASS;
  363. {$EXTERNALSYM LPQOS_DS_CLASS}
  364. _QOS_DS_CLASS = record
  365. ObjectHdr: QOS_OBJECT_HDR;
  366. DSField: ULONG;
  367. end;
  368. {$EXTERNALSYM _QOS_DS_CLASS}
  369. QOS_DS_CLASS = _QOS_DS_CLASS;
  370. {$EXTERNALSYM QOS_DS_CLASS}
  371. TQosDsClass = QOS_DS_CLASS;
  372. PQosDsClass = LPQOS_DS_CLASS;
  373. //
  374. // This structure is used to create DiffServ Flows. This creates flows in the packet scheduler
  375. // and allows it to classify to packets based on a particular DS field. This structure takes
  376. // a variable length array of QOS_DIFFSERV_RULE, where each DS field is specified by a
  377. // QOS_DIFFSERV_RULE
  378. //
  379. LPQOS_DIFFSERV = ^QOS_DIFFSERV;
  380. {$EXTERNALSYM LPQOS_DIFFSERV}
  381. _QOS_DIFFSERV = record
  382. ObjectHdr: QOS_OBJECT_HDR;
  383. DSFieldCount: ULONG;
  384. DiffservRule: array [0..0] of UCHAR;
  385. end;
  386. {$EXTERNALSYM _QOS_DIFFSERV}
  387. QOS_DIFFSERV = _QOS_DIFFSERV;
  388. {$EXTERNALSYM QOS_DIFFSERV}
  389. TQosDiffserv = QOS_DIFFSERV;
  390. PQosDiffserv = LPQOS_DIFFSERV;
  391. //
  392. // The rule for a Diffserv DS codepoint.
  393. //
  394. LPQOS_DIFFSERV_RULE = ^QOS_DIFFSERV_RULE;
  395. {$EXTERNALSYM LPQOS_DIFFSERV_RULE}
  396. _QOS_DIFFSERV_RULE = record
  397. InboundDSField: UCHAR;
  398. ConformingOutboundDSField: UCHAR;
  399. NonConformingOutboundDSField: UCHAR;
  400. ConformingUserPriority: UCHAR;
  401. NonConformingUserPriority: UCHAR;
  402. end;
  403. {$EXTERNALSYM _QOS_DIFFSERV_RULE}
  404. QOS_DIFFSERV_RULE = _QOS_DIFFSERV_RULE;
  405. {$EXTERNALSYM QOS_DIFFSERV_RULE}
  406. TQosDiffservRule = QOS_DIFFSERV_RULE;
  407. PQosDiffservRule = LPQOS_DIFFSERV_RULE;
  408. //
  409. // This structure is passed to indicate that the IP Precedence and UserPriority mappings for the flow
  410. // have to be set to the system defaults for TCP traffic. If this object is passed,
  411. // the ServiceType ==> DSField mapping, ServiceType ==> UserPriorityMapping, QOS_OBJECT_DS_CLASS
  412. // and QOS_OBJECT_TRAFFIC_CLASS will be ignored.
  413. //
  414. LPQOS_TCP_TRAFFIC = ^QOS_TCP_TRAFFIC;
  415. {$EXTERNALSYM LPQOS_TCP_TRAFFIC}
  416. _QOS_TCP_TRAFFIC = record
  417. ObjectHdr: QOS_OBJECT_HDR;
  418. end;
  419. {$EXTERNALSYM _QOS_TCP_TRAFFIC}
  420. QOS_TCP_TRAFFIC = _QOS_TCP_TRAFFIC;
  421. {$EXTERNALSYM QOS_TCP_TRAFFIC}
  422. TQosTcpTraffic = QOS_TCP_TRAFFIC;
  423. PQosTcpTraffic = LPQOS_TCP_TRAFFIC;
  424. //---------------------------------------------------------------------------
  425. //
  426. // Interface Function Definitions
  427. //
  428. function TcRegisterClient(TciVersion: ULONG; ClRegCtx: HANDLE; const ClientHandlerList: TCI_CLIENT_FUNC_LIST; var pClientHandle: HANDLE): ULONG; stdcall;
  429. {$EXTERNALSYM TcRegisterClient}
  430. function TcEnumerateInterfaces(ClientHandle: HANDLE; var pBufferSize: ULONG; var InterfaceBuffer: TC_IFC_DESCRIPTOR): ULONG; stdcall;
  431. {$EXTERNALSYM TcEnumerateInterfaces}
  432. function TcOpenInterfaceA(pInterfaceName: LPSTR; ClientHandle, ClIfcCtx: HANDLE; var pIfcHandle: HANDLE): ULONG; stdcall;
  433. {$EXTERNALSYM TcOpenInterfaceA}
  434. function TcOpenInterfaceW(pInterfaceName: LPWSTR; ClientHandle, ClIfcCtx: HANDLE; var pIfcHandle: HANDLE): ULONG; stdcall;
  435. {$EXTERNALSYM TcOpenInterfaceW}
  436. function TcCloseInterface(IfcHandle: HANDLE): ULONG; stdcall;
  437. {$EXTERNALSYM TcCloseInterface}
  438. function TcQueryInterface(IfcHandle: HANDLE; const pGuidParam: GUID; NotifyChange: Longbool; var pBufferSize: ULONG; Buffer: PVOID): ULONG; stdcall;
  439. {$EXTERNALSYM TcQueryInterface}
  440. function TcSetInterface(IfcHandle: HANDLE; const pGuidParam: GUID; BufferSize: ULONG; Buffer: PVOID): ULONG; stdcall;
  441. {$EXTERNALSYM TcSetInterface}
  442. function TcQueryFlowA(pFlowName: LPSTR; const pGuidParam: GUID; var pBufferSize: ULONG; Buffer: PVOID): ULONG; stdcall;
  443. {$EXTERNALSYM TcQueryFlowA}
  444. function TcQueryFlowW(pFlowName: LPWSTR; const pGuidParam: GUID; var pBufferSize: ULONG; Buffer: PVOID): ULONG; stdcall;
  445. {$EXTERNALSYM TcQueryFlowW}
  446. function TcSetFlowA(pFlowName: LPSTR; const pGuidParam: GUID; BufferSize: GUID; Buffer: PVOID): ULONG; stdcall;
  447. {$EXTERNALSYM TcSetFlowA}
  448. function TcSetFlowW(pFlowName: LPWSTR; const pGuidParam: GUID; BufferSize: GUID; Buffer: PVOID): ULONG; stdcall;
  449. {$EXTERNALSYM TcSetFlowW}
  450. function TcAddFlow(IfcHandle, ClFlowCtx: HANDLE; Flags: ULONG; const pGenericFlow: TC_GEN_FLOW; var pFlowHandle: HANDLE): ULONG; stdcall;
  451. {$EXTERNALSYM TcAddFlow}
  452. function TcGetFlowNameA(FlowHandle: HANDLE; StrSize: ULONG; pFlowName: LPSTR): ULONG; stdcall;
  453. {$EXTERNALSYM TcGetFlowNameA}
  454. function TcGetFlowNameW(FlowHandle: HANDLE; StrSize: ULONG; pFlowName: LPWSTR): ULONG; stdcall;
  455. {$EXTERNALSYM TcGetFlowNameW}
  456. function TcModifyFlow(FlowHandle: HANDLE; const pGenericFlow: TC_GEN_FLOW): ULONG; stdcall;
  457. {$EXTERNALSYM TcModifyFlow}
  458. function TcAddFilter(FlowHandle: HANDLE; const pGenericFilter: TC_GEN_FILTER; var pFilterHandle: HANDLE): ULONG; stdcall;
  459. {$EXTERNALSYM TcAddFilter}
  460. function TcDeregisterClient(ClientHandle: HANDLE): ULONG; stdcall;
  461. {$EXTERNALSYM TcDeregisterClient}
  462. function TcDeleteFlow(FlowHandle: HANDLE): ULONG; stdcall;
  463. {$EXTERNALSYM TcDeleteFlow}
  464. function TcDeleteFilter(FilterHandle: HANDLE): ULONG; stdcall;
  465. {$EXTERNALSYM TcDeleteFilter}
  466. function TcEnumerateFlows(IfcHandle: HANDLE; var pEnumHandle: HANDLE; var pFlowCount, pBufSize: ULONG; var Buffer: ENUMERATION_BUFFER): ULONG; stdcall;
  467. {$EXTERNALSYM TcEnumerateFlows}
  468. function TcOpenInterface(pInterfaceName: LPTSTR; ClientHandle, ClIfcCtx: HANDLE; var pIfcHandle: HANDLE): ULONG; stdcall;
  469. {$EXTERNALSYM TcOpenInterface}
  470. function TcQueryFlow(pFlowName: LPTSTR; const pGuidParam: GUID; var pBufferSize: ULONG; Buffer: PVOID): ULONG; stdcall;
  471. {$EXTERNALSYM TcQueryFlow}
  472. function TcSetFlow(pFlowName: LPTSTR; const pGuidParam: GUID; BufferSize: GUID; Buffer: PVOID): ULONG; stdcall;
  473. {$EXTERNALSYM TcSetFlow}
  474. function TcGetFlowName(FlowHandle: HANDLE; StrSize: ULONG; pFlowName: LPTSTR): ULONG; stdcall;
  475. {$EXTERNALSYM TcGetFlowName}
  476. implementation
  477. const
  478. trafficlib = 'traffic.dll';
  479. {$IFDEF UNICODE}
  480. AWSuffix = 'W';
  481. {$ELSE}
  482. AWSuffix = 'A';
  483. {$ENDIF UNICODE}
  484. {$IFDEF DYNAMIC_LINK}
  485. var
  486. _TcRegisterClient: Pointer;
  487. function TcRegisterClient;
  488. begin
  489. GetProcedureAddress(_TcRegisterClient, trafficlib, 'TcRegisterClient');
  490. asm
  491. MOV ESP, EBP
  492. POP EBP
  493. JMP [_TcRegisterClient]
  494. end;
  495. end;
  496. var
  497. _TcEnumerateInterfaces: Pointer;
  498. function TcEnumerateInterfaces;
  499. begin
  500. GetProcedureAddress(_TcEnumerateInterfaces, trafficlib, 'TcEnumerateInterfaces');
  501. asm
  502. MOV ESP, EBP
  503. POP EBP
  504. JMP [_TcEnumerateInterfaces]
  505. end;
  506. end;
  507. var
  508. _TcOpenInterfaceA: Pointer;
  509. function TcOpenInterfaceA;
  510. begin
  511. GetProcedureAddress(_TcOpenInterfaceA, trafficlib, 'TcOpenInterfaceA');
  512. asm
  513. MOV ESP, EBP
  514. POP EBP
  515. JMP [_TcOpenInterfaceA]
  516. end;
  517. end;
  518. var
  519. _TcOpenInterfaceW: Pointer;
  520. function TcOpenInterfaceW;
  521. begin
  522. GetProcedureAddress(_TcOpenInterfaceW, trafficlib, 'TcOpenInterfaceW');
  523. asm
  524. MOV ESP, EBP
  525. POP EBP
  526. JMP [_TcOpenInterfaceW]
  527. end;
  528. end;
  529. var
  530. _TcCloseInterface: Pointer;
  531. function TcCloseInterface;
  532. begin
  533. GetProcedureAddress(_TcCloseInterface, trafficlib, 'TcCloseInterface');
  534. asm
  535. MOV ESP, EBP
  536. POP EBP
  537. JMP [_TcCloseInterface]
  538. end;
  539. end;
  540. var
  541. _TcQueryInterface: Pointer;
  542. function TcQueryInterface;
  543. begin
  544. GetProcedureAddress(_TcQueryInterface, trafficlib, 'TcQueryInterface');
  545. asm
  546. MOV ESP, EBP
  547. POP EBP
  548. JMP [_TcQueryInterface]
  549. end;
  550. end;
  551. var
  552. _TcSetInterface: Pointer;
  553. function TcSetInterface;
  554. begin
  555. GetProcedureAddress(_TcSetInterface, trafficlib, 'TcSetInterface');
  556. asm
  557. MOV ESP, EBP
  558. POP EBP
  559. JMP [_TcSetInterface]
  560. end;
  561. end;
  562. var
  563. _TcQueryFlowA: Pointer;
  564. function TcQueryFlowA;
  565. begin
  566. GetProcedureAddress(_TcQueryFlowA, trafficlib, 'TcQueryFlowA');
  567. asm
  568. MOV ESP, EBP
  569. POP EBP
  570. JMP [_TcQueryFlowA]
  571. end;
  572. end;
  573. var
  574. _TcQueryFlowW: Pointer;
  575. function TcQueryFlowW;
  576. begin
  577. GetProcedureAddress(_TcQueryFlowW, trafficlib, 'TcQueryFlowW');
  578. asm
  579. MOV ESP, EBP
  580. POP EBP
  581. JMP [_TcQueryFlowW]
  582. end;
  583. end;
  584. var
  585. _TcSetFlowA: Pointer;
  586. function TcSetFlowA;
  587. begin
  588. GetProcedureAddress(_TcSetFlowA, trafficlib, 'TcSetFlowA');
  589. asm
  590. MOV ESP, EBP
  591. POP EBP
  592. JMP [_TcSetFlowA]
  593. end;
  594. end;
  595. var
  596. _TcSetFlowW: Pointer;
  597. function TcSetFlowW;
  598. begin
  599. GetProcedureAddress(_TcSetFlowW, trafficlib, 'TcSetFlowW');
  600. asm
  601. MOV ESP, EBP
  602. POP EBP
  603. JMP [_TcSetFlowW]
  604. end;
  605. end;
  606. var
  607. _TcAddFlow: Pointer;
  608. function TcAddFlow;
  609. begin
  610. GetProcedureAddress(_TcAddFlow, trafficlib, 'TcAddFlow');
  611. asm
  612. MOV ESP, EBP
  613. POP EBP
  614. JMP [_TcAddFlow]
  615. end;
  616. end;
  617. var
  618. _TcGetFlowNameA: Pointer;
  619. function TcGetFlowNameA;
  620. begin
  621. GetProcedureAddress(_TcGetFlowNameA, trafficlib, 'TcGetFlowNameA');
  622. asm
  623. MOV ESP, EBP
  624. POP EBP
  625. JMP [_TcGetFlowNameA]
  626. end;
  627. end;
  628. var
  629. _TcGetFlowNameW: Pointer;
  630. function TcGetFlowNameW;
  631. begin
  632. GetProcedureAddress(_TcGetFlowNameW, trafficlib, 'TcGetFlowNameW');
  633. asm
  634. MOV ESP, EBP
  635. POP EBP
  636. JMP [_TcGetFlowNameW]
  637. end;
  638. end;
  639. var
  640. _TcModifyFlow: Pointer;
  641. function TcModifyFlow;
  642. begin
  643. GetProcedureAddress(_TcModifyFlow, trafficlib, 'TcModifyFlow');
  644. asm
  645. MOV ESP, EBP
  646. POP EBP
  647. JMP [_TcModifyFlow]
  648. end;
  649. end;
  650. var
  651. _TcAddFilter: Pointer;
  652. function TcAddFilter;
  653. begin
  654. GetProcedureAddress(_TcAddFilter, trafficlib, 'TcAddFilter');
  655. asm
  656. MOV ESP, EBP
  657. POP EBP
  658. JMP [_TcAddFilter]
  659. end;
  660. end;
  661. var
  662. _TcDeregisterClient: Pointer;
  663. function TcDeregisterClient;
  664. begin
  665. GetProcedureAddress(_TcDeregisterClient, trafficlib, 'TcDeregisterClient');
  666. asm
  667. MOV ESP, EBP
  668. POP EBP
  669. JMP [_TcDeregisterClient]
  670. end;
  671. end;
  672. var
  673. _TcDeleteFlow: Pointer;
  674. function TcDeleteFlow;
  675. begin
  676. GetProcedureAddress(_TcDeleteFlow, trafficlib, 'TcDeleteFlow');
  677. asm
  678. MOV ESP, EBP
  679. POP EBP
  680. JMP [_TcDeleteFlow]
  681. end;
  682. end;
  683. var
  684. _TcDeleteFilter: Pointer;
  685. function TcDeleteFilter;
  686. begin
  687. GetProcedureAddress(_TcDeleteFilter, trafficlib, 'TcDeleteFilter');
  688. asm
  689. MOV ESP, EBP
  690. POP EBP
  691. JMP [_TcDeleteFilter]
  692. end;
  693. end;
  694. var
  695. _TcEnumerateFlows: Pointer;
  696. function TcEnumerateFlows;
  697. begin
  698. GetProcedureAddress(_TcEnumerateFlows, trafficlib, 'TcEnumerateFlows');
  699. asm
  700. MOV ESP, EBP
  701. POP EBP
  702. JMP [_TcEnumerateFlows]
  703. end;
  704. end;
  705. var
  706. _TcOpenInterface: Pointer;
  707. function TcOpenInterface;
  708. begin
  709. GetProcedureAddress(_TcOpenInterface, trafficlib, 'TcOpenInterface' + AWSuffix);
  710. asm
  711. MOV ESP, EBP
  712. POP EBP
  713. JMP [_TcOpenInterface]
  714. end;
  715. end;
  716. var
  717. _TcQueryFlow: Pointer;
  718. function TcQueryFlow;
  719. begin
  720. GetProcedureAddress(_TcQueryFlow, trafficlib, 'TcQueryFlow' + AWSuffix);
  721. asm
  722. MOV ESP, EBP
  723. POP EBP
  724. JMP [_TcQueryFlow]
  725. end;
  726. end;
  727. var
  728. _TcSetFlow: Pointer;
  729. function TcSetFlow;
  730. begin
  731. GetProcedureAddress(_TcSetFlow, trafficlib, 'TcSetFlow' + AWSuffix);
  732. asm
  733. MOV ESP, EBP
  734. POP EBP
  735. JMP [_TcSetFlow]
  736. end;
  737. end;
  738. var
  739. _TcGetFlowName: Pointer;
  740. function TcGetFlowName;
  741. begin
  742. GetProcedureAddress(_TcGetFlowName, trafficlib, 'TcGetFlowName' + AWSuffix);
  743. asm
  744. MOV ESP, EBP
  745. POP EBP
  746. JMP [_TcGetFlowName]
  747. end;
  748. end;
  749. {$ELSE}
  750. function TcRegisterClient; external trafficlib name 'TcRegisterClient';
  751. function TcEnumerateInterfaces; external trafficlib name 'TcEnumerateInterfaces';
  752. function TcOpenInterfaceA; external trafficlib name 'TcOpenInterfaceA';
  753. function TcOpenInterfaceW; external trafficlib name 'TcOpenInterfaceW';
  754. function TcCloseInterface; external trafficlib name 'TcCloseInterface';
  755. function TcQueryInterface; external trafficlib name 'TcQueryInterface';
  756. function TcSetInterface; external trafficlib name 'TcSetInterface';
  757. function TcQueryFlowA; external trafficlib name 'TcQueryFlowA';
  758. function TcQueryFlowW; external trafficlib name 'TcQueryFlowW';
  759. function TcSetFlowA; external trafficlib name 'TcSetFlowA';
  760. function TcSetFlowW; external trafficlib name 'TcSetFlowW';
  761. function TcAddFlow; external trafficlib name 'TcAddFlow';
  762. function TcGetFlowNameA; external trafficlib name 'TcGetFlowNameA';
  763. function TcGetFlowNameW; external trafficlib name 'TcGetFlowNameW';
  764. function TcModifyFlow; external trafficlib name 'TcModifyFlow';
  765. function TcAddFilter; external trafficlib name 'TcAddFilter';
  766. function TcDeregisterClient; external trafficlib name 'TcDeregisterClient';
  767. function TcDeleteFlow; external trafficlib name 'TcDeleteFlow';
  768. function TcDeleteFilter; external trafficlib name 'TcDeleteFilter';
  769. function TcEnumerateFlows; external trafficlib name 'TcEnumerateFlows';
  770. function TcOpenInterface; external trafficlib name 'TcOpenInterface' + AWSuffix;
  771. function TcQueryFlow; external trafficlib name 'TcQueryFlow' + AWSuffix;
  772. function TcSetFlow; external trafficlib name 'TcSetFlow' + AWSuffix;
  773. function TcGetFlowName; external trafficlib name 'TcGetFlowName' + AWSuffix;
  774. {$ENDIF DYNAMIC_LINK}
  775. end.