jwatraffic.pas 27 KB

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