home *** CD-ROM | disk | FTP | other *** search
/ PC Format (South-Africa) 2001 June / PCFJune.iso / Xenon / C++ / FreeCommandLineTools.exe / Include / traffic.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-31  |  11.4 KB  |  547 lines

  1. /*++
  2.  
  3. Copyright (c) 1996-1998 Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     traffic.h
  8.  
  9. Abstract:
  10.  
  11.     This module contains API definitions for the traffic control interface.
  12.  
  13. --*/
  14.  
  15. #ifndef __TRAFFIC_H
  16. #pragma option push -b -a8 -pc -A- /*P_O_Push*/
  17. #define __TRAFFIC_H
  18.  
  19. #ifdef __cplusplus
  20. extern  "C" {
  21. #endif
  22.  
  23. //---------------------------------------------------------------------------
  24. //
  25. // Define's
  26. //
  27. #define CURRENT_TCI_VERSION           0x0002
  28.  
  29. //
  30. // Flow flags
  31. //
  32. #define TC_FLAGS_PERSIST            0x00000001
  33. #define TC_FLAGS_SHUTDOWN            0x00000002
  34.  
  35. //
  36. // Definitions of notification events. These may be passed
  37. // to the client's notification handler, to identify the 
  38. // notification type
  39. //
  40.  
  41. //
  42. // A TC interface has come up
  43. //
  44. #define TC_NOTIFY_IFC_UP        1
  45. // 
  46. // A TC interface has come down
  47. //
  48. #define TC_NOTIFY_IFC_CLOSE        2
  49. //
  50. // A change on a TC interface, typically a change in the 
  51. // list of supported network addresses
  52. //
  53. #define TC_NOTIFY_IFC_CHANGE    3
  54. //
  55. // A TC parameter has changed
  56. //
  57. #define TC_NOTIFY_PARAM_CHANGED    4
  58. //
  59. // A flow has been closed by the TC interface
  60. // for example: after a remote call close, or the whole interface
  61. // is going down
  62. //
  63. #define TC_NOTIFY_FLOW_CLOSE        5
  64.  
  65. #define TC_INVALID_HANDLE    ((HANDLE)0)
  66.  
  67. #define MAX_STRING_LENGTH    256
  68.  
  69.  
  70. //---------------------------------------------------------------------------
  71. //
  72. // Typedef's and structures
  73. //
  74.  
  75. #ifndef CALLBACK
  76. #define CALLBACK __stdcall
  77. #endif
  78.  
  79. #ifndef APIENTRY
  80. #define APIENTRY FAR __stdcall
  81. #endif
  82.  
  83. //
  84. // Handlers registered by the TCI client
  85. //
  86.  
  87. typedef
  88. VOID (CALLBACK * TCI_NOTIFY_HANDLER)(
  89.     IN    HANDLE        ClRegCtx,
  90.     IN    HANDLE        ClIfcCtx,
  91.     IN    ULONG        Event,         // See list below
  92.     IN    ULONG        SubCode,
  93.     IN    ULONG        BufSize,
  94.     IN    PVOID        Buffer
  95.     );
  96.  
  97. typedef
  98. VOID (CALLBACK * TCI_ADD_FLOW_COMPLETE_HANDLER)(
  99.     IN HANDLE     ClFlowCtx,
  100.     IN ULONG    Status
  101.     );
  102.  
  103. typedef
  104. VOID (CALLBACK * TCI_MOD_FLOW_COMPLETE_HANDLER)(
  105.     IN HANDLE     ClFlowCtx,
  106.     IN ULONG    Status
  107.     );
  108.  
  109. typedef
  110. VOID (CALLBACK * TCI_DEL_FLOW_COMPLETE_HANDLER)(
  111.     IN HANDLE     ClFlowCtx,
  112.     IN ULONG    Status
  113.     );
  114.  
  115.  
  116. typedef struct _TCI_CLIENT_FUNC_LIST {
  117.  
  118.     TCI_NOTIFY_HANDLER                ClNotifyHandler;
  119.     TCI_ADD_FLOW_COMPLETE_HANDLER    ClAddFlowCompleteHandler;
  120.     TCI_MOD_FLOW_COMPLETE_HANDLER    ClModifyFlowCompleteHandler;
  121.     TCI_DEL_FLOW_COMPLETE_HANDLER    ClDeleteFlowCompleteHandler;
  122.  
  123. } TCI_CLIENT_FUNC_LIST, *PTCI_CLIENT_FUNC_LIST;
  124.  
  125.  
  126. #ifndef _NTDDNDIS_
  127. //
  128. // The structures below need to be consistent with TRANSPORT_ADDRESS structures in TDI.H
  129. //
  130. typedef struct _NETWORK_ADDRESS
  131. {
  132.     USHORT        AddressLength;        // length in bytes of Address[] in this
  133.     USHORT        AddressType;        // type of this address (NDIS_PROTOCOL_ID_XXX above)
  134.     UCHAR        Address[1];            // actually AddressLength bytes long
  135. } NETWORK_ADDRESS, *PNETWORK_ADDRESS;
  136.  
  137. //
  138. // The following is used with OID_GEN_NETWORK_LAYER_ADDRESSES to set network layer addresses on an interface
  139. //
  140. typedef struct _NETWORK_ADDRESS_LIST
  141. {
  142.     LONG        AddressCount;        // number of addresses following
  143.     USHORT        AddressType;        // type of this address (NDIS_PROTOCOL_ID_XXX above)
  144.     NETWORK_ADDRESS Address[1];        // actually AddressCount elements long
  145. } NETWORK_ADDRESS_LIST, *PNETWORK_ADDRESS_LIST;
  146.  
  147. //
  148. // IP address - This must remain consistent with TDI_ADDRESS_IP in tdi.h
  149. //
  150. typedef struct _NETWORK_ADDRESS_IP
  151. {
  152.     USHORT        sin_port;
  153.     ULONG        in_addr;
  154.     UCHAR        sin_zero[8];
  155. } NETWORK_ADDRESS_IP, *PNETWORK_ADDRESS_IP;
  156.  
  157. #define NETWORK_ADDRESS_LENGTH_IP sizeof (NETWORK_ADDRESS_IP)
  158.  
  159. //
  160. // IPX address - This must remain consistent with TDI_ADDRESS_IPX in tdi.h.
  161. //
  162. typedef struct _NETWORK_ADDRESS_IPX
  163. {
  164.     ULONG        NetworkAddress;
  165.     UCHAR        NodeAddress[6];
  166.     USHORT        Socket;
  167. } NETWORK_ADDRESS_IPX, *PNETWORK_ADDRESS_IPX;
  168.  
  169. #endif
  170.  
  171.  
  172. //
  173. // Network address descriptor
  174. //
  175. typedef struct _ADDRESS_LIST_DESCRIPTOR {
  176.  
  177.     ULONG                    MediaType;
  178.     NETWORK_ADDRESS_LIST    AddressList;
  179.  
  180. } ADDRESS_LIST_DESCRIPTOR, *PADDRESS_LIST_DESCRIPTOR;
  181.  
  182.  
  183. //
  184. // An interface ID that is returned by the enumerator
  185. //
  186. typedef struct _TC_IFC_DESCRIPTOR {
  187.  
  188.     ULONG                    Length;
  189.     LPWSTR                    pInterfaceName;
  190.     ADDRESS_LIST_DESCRIPTOR    AddressListDesc;
  191.  
  192. } TC_IFC_DESCRIPTOR, *PTC_IFC_DESCRIPTOR;
  193.  
  194.  
  195. //
  196. // Filters are used to match packets. The Pattern field
  197. // indicates the values to which bits in corresponding
  198. // positions in candidate packets should be compared. The
  199. // Mask field indicates which bits are to be compared and
  200. // which bits are don't cares.
  201. //
  202. // Different filters can be submitted on the TCI interface.
  203. // The generic filter structure is defined to include an
  204. // AddressType, which indicates the specific type of filter to
  205. // follow.
  206. //
  207.  
  208. typedef struct _TC_GEN_FILTER {
  209.  
  210.     USHORT    AddressType;    // IP, IPX, etc.
  211.     ULONG    PatternSize;    // byte count of the pattern
  212.     PVOID      Pattern;        // specific format, e.g. IP_PATTERN
  213.     PVOID      Mask;            // same type as Pattern
  214.  
  215. } TC_GEN_FILTER, *PTC_GEN_FILTER;
  216.  
  217.  
  218. //
  219. // A generic flow includes two flowspecs and a freeform
  220. // buffer which contains flow specific TC objects.
  221. //
  222. typedef struct _TC_GEN_FLOW {
  223.     
  224.     FLOWSPEC        SendingFlowspec;
  225.     FLOWSPEC        ReceivingFlowspec;
  226.     ULONG            TcObjectsLength;        // number of optional bytes
  227.     QOS_OBJECT_HDR    TcObjects[1];
  228.  
  229. } TC_GEN_FLOW, *PTC_GEN_FLOW;
  230.  
  231.  
  232. //
  233. // Format of specific pattern or mask used by GPC for the IP protocol
  234. //
  235. typedef struct _IP_PATTERN {
  236.  
  237.     ULONG        Reserved1;
  238.     ULONG        Reserved2;
  239.  
  240.     ULONG        SrcAddr;
  241.     ULONG        DstAddr;
  242.  
  243.     union {
  244.         struct { USHORT s_srcport,s_dstport; } S_un_ports;
  245.         struct { UCHAR s_type,s_code; USHORT filler; } S_un_icmp;
  246.         ULONG    S_Spi;
  247.     } S_un;
  248.  
  249.     UCHAR        ProtocolId;
  250.     UCHAR        Reserved3[3];
  251.  
  252. #define tcSrcPort S_un.S_un_ports.s_srcport
  253. #define tcDstPort S_un.S_un_ports.s_dstport
  254. #define tcIcmpType        S_un.S_un_icmp.s_type
  255. #define tcIcmpCode        S_un.S_un_icmp.s_code
  256. #define tcSpi             S_un.S_Spi
  257.  
  258. } IP_PATTERN, *PIP_PATTERN;
  259.  
  260. //
  261. // Format of specific pattern or mask used by GPC for the IPX protocol
  262. //
  263. typedef struct _IPX_PATTERN {
  264.  
  265.     struct {
  266.         ULONG     NetworkAddress;
  267.         UCHAR     NodeAddress[6];
  268.         USHORT     Socket;
  269.     } Src, Dest;
  270.  
  271. } IPX_PATTERN, *PIPX_PATTERN;
  272.  
  273.  
  274. //
  275. // The enumeration buffer is the flow parameters + a list of filters
  276. //
  277. typedef struct _ENUMERATION_BUFFER {
  278.  
  279.     ULONG            Length;
  280.     ULONG            OwnerProcessId;
  281.     USHORT            FlowNameLength;
  282.     WCHAR            FlowName[MAX_STRING_LENGTH];
  283.     PTC_GEN_FLOW    pFlow;
  284.     ULONG            NumberOfFilters;
  285.     TC_GEN_FILTER    GenericFilter[1];     // one for each filter
  286.  
  287. } ENUMERATION_BUFFER, *PENUMERATION_BUFFER;
  288.     
  289.  
  290. //
  291. // A class map structure is used by internal TC component
  292. // such as the CBQ.
  293. // This should have been in qos.h but we'll put it here until
  294. // the time is ready
  295. //
  296.  
  297. #define CLSMAP_ID_BASE                5000
  298. #define CLSMAP_OBJECT_SERVICETYPE     (0x00000000 + CLSMAP_ID_BASE)
  299. #define CLSMAP_OBJECT_END_OF_LIST     (0x00000001 + CLSMAP_ID_BASE)
  300.  
  301. //
  302. // The servicetype object can be used to override the default class for // a given service type
  303. //
  304. typedef struct _CLSMAP_SERVICETYPE {
  305.     QOS_OBJECT_HDR    Header;
  306.     ULONG            ServiceType;
  307.     ULONG            ClassId;
  308. } CLSMAP_SERVICETYPE, *PCLSMAP_SERVICETYPE;
  309.  
  310. typedef struct _TC_CLASS_MAP_FLOW {
  311.  
  312.     ULONG           DefaultClass;            // Default Class Id
  313.     ULONG           ObjectsLength;            // Length of Objects
  314.     QOS_OBJECT_HDR    Objects;                // Offset to Objects
  315.  
  316. } TC_CLASS_MAP_FLOW, *PTC_CLASS_MAP_FLOW;
  317.  
  318.  
  319. //
  320. // class hierarchy definitions
  321. //
  322.  
  323. typedef struct _QOS_HIERARCHY_CLASS {
  324.  
  325.     ULONG ClassId;                // Unique nonzero class identifier
  326.     ULONG Allocation;            // Share of link bandwidth
  327.     ULONG BurstLength;            // Maximum burst size
  328.     ULONG Flags;                // See below
  329.     ULONG ParentClassId;        // Id of parent class
  330.     ULONG ObjectsLength;        // For possible future use
  331.     UCHAR Objects[1];
  332.  
  333. } QOS_HIERARCHY_CLASS, *PQOS_HIERARCHY_CLASS;
  334.  
  335. #define HCLASS_FLAG_BOUNDED                1
  336.  
  337.  
  338. //---------------------------------------------------------------------------
  339. //
  340. // Interface Function Definitions
  341. //
  342.  
  343. ULONG
  344. APIENTRY
  345. TcRegisterClient(
  346.     IN        ULONG                    TciVersion,
  347.     IN        HANDLE                    ClRegCtx,
  348.     IN        PTCI_CLIENT_FUNC_LIST    ClientHandlerList,
  349.     OUT        PHANDLE                    pClientHandle
  350.     );
  351.  
  352. ULONG
  353. APIENTRY
  354. TcEnumerateInterfaces(
  355.     IN         HANDLE                ClientHandle,
  356.     IN OUT    PULONG                pBufferSize,
  357.     OUT        PTC_IFC_DESCRIPTOR     InterfaceBuffer
  358.     );
  359.  
  360. ULONG
  361. APIENTRY
  362. TcOpenInterfaceA(
  363.     IN        LPSTR            pInterfaceName,
  364.     IN         HANDLE            ClientHandle,
  365.     IN        HANDLE            ClIfcCtx,
  366.     OUT        PHANDLE            pIfcHandle
  367.     );
  368.  
  369. ULONG
  370. APIENTRY
  371. TcOpenInterfaceW(
  372.     IN        LPWSTR            pInterfaceName,
  373.     IN         HANDLE            ClientHandle,
  374.     IN        HANDLE            ClIfcCtx,
  375.     OUT        PHANDLE            pIfcHandle
  376.     );
  377.  
  378. ULONG
  379. APIENTRY
  380. TcCloseInterface(
  381.     IN         HANDLE       IfcHandle
  382.     );
  383.  
  384. ULONG
  385. APIENTRY
  386. TcQueryInterface(
  387.     IN         HANDLE         IfcHandle,
  388.     IN        LPGUID        pGuidParam,
  389.     IN        BOOLEAN        NotifyChange,
  390.     IN OUT    PULONG        pBufferSize,
  391.     OUT        PVOID        Buffer
  392.     );
  393.  
  394. ULONG
  395. APIENTRY
  396. TcSetInterface(
  397.     IN         HANDLE         IfcHandle,
  398.     IN        LPGUID        pGuidParam,
  399.     IN         ULONG        BufferSize,
  400.     IN        PVOID        Buffer
  401.     );
  402.  
  403. ULONG
  404. APIENTRY
  405. TcQueryFlowA(
  406.     IN         LPSTR        pFlowName,
  407.     IN        LPGUID        pGuidParam,
  408.     IN OUT    PULONG        pBufferSize,
  409.     OUT        PVOID        Buffer
  410.     );
  411.  
  412. ULONG
  413. APIENTRY
  414. TcQueryFlowW(
  415.     IN         LPWSTR        pFlowName,
  416.     IN        LPGUID        pGuidParam,
  417.     IN OUT    PULONG        pBufferSize,
  418.     OUT        PVOID        Buffer
  419.     );
  420.  
  421. ULONG
  422. APIENTRY
  423. TcSetFlowA(
  424.     IN         LPSTR        pFlowName,
  425.     IN        LPGUID        pGuidParam,
  426.     IN         ULONG        BufferSize,
  427.     IN        PVOID        Buffer
  428.     );
  429.  
  430. ULONG
  431. APIENTRY
  432. TcSetFlowW(
  433.     IN         LPWSTR        pFlowName,
  434.     IN        LPGUID        pGuidParam,
  435.     IN         ULONG        BufferSize,
  436.     IN        PVOID        Buffer
  437.     );
  438.  
  439. ULONG
  440. APIENTRY
  441. TcAddFlow(
  442.     IN      HANDLE             IfcHandle,
  443.     IN        HANDLE            ClFlowCtx,
  444.     IN        ULONG            Flags,
  445.     IN        PTC_GEN_FLOW    pGenericFlow,
  446.     OUT        PHANDLE            pFlowHandle
  447. );
  448.  
  449. ULONG
  450. APIENTRY
  451. TcGetFlowNameA(
  452.     IN        HANDLE            FlowHandle,
  453.     IN        ULONG            StrSize,
  454.     OUT        LPSTR            pFlowName
  455. );
  456.  
  457. ULONG
  458. APIENTRY
  459. TcGetFlowNameW(
  460.     IN        HANDLE            FlowHandle,
  461.     IN        ULONG            StrSize,
  462.     OUT        LPWSTR            pFlowName
  463. );
  464.  
  465. ULONG
  466. APIENTRY
  467. TcModifyFlow(    
  468.     IN        HANDLE            FlowHandle,
  469.     IN        PTC_GEN_FLOW    pGenericFlow
  470.     );
  471.  
  472. ULONG
  473. APIENTRY
  474. TcAddFilter(
  475.     IN        HANDLE            FlowHandle,
  476.     IN        PTC_GEN_FILTER    pGenericFilter,
  477.     OUT        PHANDLE            pFilterHandle
  478.     );
  479.  
  480.  
  481. ULONG
  482. APIENTRY
  483. TcDeregisterClient(
  484.     IN         HANDLE             ClientHandle
  485.     );
  486.  
  487.  
  488. ULONG
  489. APIENTRY
  490. TcDeleteFlow(
  491.     IN         HANDLE          FlowHandle
  492.     );
  493.  
  494. ULONG
  495. APIENTRY
  496. TcDeleteFilter(
  497.     IN         HANDLE          FilterHandle
  498.     );
  499.  
  500. ULONG
  501. APIENTRY
  502. TcEnumerateFlows(    
  503.     IN        HANDLE                    IfcHandle,
  504.     IN OUT     PHANDLE                    pEnumHandle,
  505.     IN OUT    PULONG                    pFlowCount,
  506.     IN OUT    PULONG                    pBufSize,
  507.     OUT        PENUMERATION_BUFFER        Buffer
  508.     );
  509.  
  510.  
  511. ULONG
  512. APIENTRY
  513. TcAddClassMapFlow(
  514.     IN      HANDLE                 IfcHandle,
  515.     IN        HANDLE                ClFlowCtx,
  516.     IN        ULONG                Flags,
  517.     IN        PTC_CLASS_MAP_FLOW    pClassMapFlow,
  518.     OUT        PHANDLE                pFlowHandle
  519. );
  520.  
  521.  
  522. #ifdef UNICODE
  523.  
  524. #define TcOpenInterface                    TcOpenInterfaceW
  525. #define TcQueryFlow                        TcQueryFlowW
  526. #define TcSetFlow                        TcSetFlowW
  527. #define TcGetFlowName                    TcGetFlowNameW
  528.  
  529. #else    // UNICODE
  530.  
  531. #define TcOpenInterface        TcOpenInterfaceA
  532. #define TcQueryFlow            TcQueryFlowA
  533. #define TcSetFlow            TcSetFlowA
  534. #define TcGetFlowName        TcGetFlowNameA
  535.  
  536. #endif    // UNICODE
  537.  
  538.  
  539. #ifdef __cplusplus
  540. }
  541. #endif
  542.  
  543.  
  544. #pragma option pop /*P_O_Pop*/
  545. #endif
  546.  
  547.