Home | History | Annotate | Download | only in include
      1 /**
      2  * This file has no copyright assigned and is placed in the Public Domain.
      3  * This file is part of the mingw-w64 runtime package.
      4  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
      5  */
      6 #ifndef __TRAFFIC_H
      7 #define __TRAFFIC_H
      8 
      9 #include <_mingw_unicode.h>
     10 #include <ntddndis.h>
     11 
     12 #ifdef __cplusplus
     13 extern "C" {
     14 #endif
     15 
     16 #define CURRENT_TCI_VERSION 0x0002
     17 
     18 #define TC_NOTIFY_IFC_UP 1
     19 #define TC_NOTIFY_IFC_CLOSE 2
     20 #define TC_NOTIFY_IFC_CHANGE 3
     21 #define TC_NOTIFY_PARAM_CHANGED 4
     22 #define TC_NOTIFY_FLOW_CLOSE 5
     23 #define TC_INVALID_HANDLE ((HANDLE)0)
     24 
     25 #define MAX_STRING_LENGTH 256
     26 
     27 #ifndef CALLBACK
     28 #define CALLBACK __stdcall
     29 #endif
     30 
     31 #ifndef WINAPI
     32 #define WINAPI __stdcall
     33 #endif
     34 
     35 #ifndef APIENTRY
     36 #define APIENTRY WINAPI
     37 #endif
     38 
     39   typedef VOID (CALLBACK *TCI_NOTIFY_HANDLER)(HANDLE ClRegCtx,HANDLE ClIfcCtx,ULONG Event,HANDLE SubCode,ULONG BufSize,PVOID Buffer);
     40   typedef VOID (CALLBACK *TCI_ADD_FLOW_COMPLETE_HANDLER)(HANDLE ClFlowCtx,ULONG Status);
     41   typedef VOID (CALLBACK *TCI_MOD_FLOW_COMPLETE_HANDLER)(HANDLE ClFlowCtx,ULONG Status);
     42   typedef VOID (CALLBACK *TCI_DEL_FLOW_COMPLETE_HANDLER)(HANDLE ClFlowCtx,ULONG Status);
     43 
     44   typedef struct _TCI_CLIENT_FUNC_LIST {
     45     TCI_NOTIFY_HANDLER ClNotifyHandler;
     46     TCI_ADD_FLOW_COMPLETE_HANDLER ClAddFlowCompleteHandler;
     47     TCI_MOD_FLOW_COMPLETE_HANDLER ClModifyFlowCompleteHandler;
     48     TCI_DEL_FLOW_COMPLETE_HANDLER ClDeleteFlowCompleteHandler;
     49   } TCI_CLIENT_FUNC_LIST,*PTCI_CLIENT_FUNC_LIST;
     50 
     51   typedef struct _ADDRESS_LIST_DESCRIPTOR {
     52     ULONG MediaType;
     53     NETWORK_ADDRESS_LIST AddressList;
     54   } ADDRESS_LIST_DESCRIPTOR,*PADDRESS_LIST_DESCRIPTOR;
     55 
     56   typedef struct _TC_IFC_DESCRIPTOR {
     57     ULONG Length;
     58     LPWSTR pInterfaceName;
     59     LPWSTR pInterfaceID;
     60     ADDRESS_LIST_DESCRIPTOR AddressListDesc;
     61   } TC_IFC_DESCRIPTOR,*PTC_IFC_DESCRIPTOR;
     62 
     63   typedef struct _TC_SUPPORTED_INFO_BUFFER {
     64     USHORT InstanceIDLength;
     65     WCHAR InstanceID[MAX_STRING_LENGTH];
     66     ADDRESS_LIST_DESCRIPTOR AddrListDesc;
     67   } TC_SUPPORTED_INFO_BUFFER,*PTC_SUPPORTED_INFO_BUFFER;
     68 
     69   typedef struct _TC_GEN_FILTER {
     70     USHORT AddressType;
     71     ULONG PatternSize;
     72     PVOID Pattern;
     73     PVOID Mask;
     74   } TC_GEN_FILTER,*PTC_GEN_FILTER;
     75 
     76   typedef struct _TC_GEN_FLOW {
     77     FLOWSPEC SendingFlowspec;
     78     FLOWSPEC ReceivingFlowspec;
     79     ULONG TcObjectsLength;
     80     QOS_OBJECT_HDR TcObjects[1];
     81   } TC_GEN_FLOW,*PTC_GEN_FLOW;
     82 
     83   typedef struct _IP_PATTERN {
     84     ULONG Reserved1;
     85     ULONG Reserved2;
     86     ULONG SrcAddr;
     87     ULONG DstAddr;
     88     union {
     89       struct { USHORT s_srcport,s_dstport; } S_un_ports;
     90       struct { UCHAR s_type,s_code; USHORT filler; } S_un_icmp;
     91       ULONG S_Spi;
     92     } S_un;
     93     UCHAR ProtocolId;
     94     UCHAR Reserved3[3];
     95   } IP_PATTERN,*PIP_PATTERN;
     96 
     97 #define tcSrcPort S_un.S_un_ports.s_srcport
     98 #define tcDstPort S_un.S_un_ports.s_dstport
     99 #define tcIcmpType S_un.S_un_icmp.s_type
    100 #define tcIcmpCode S_un.S_un_icmp.s_code
    101 #define tcSpi S_un.S_Spi
    102 
    103   typedef struct _IPX_PATTERN {
    104     struct {
    105       ULONG NetworkAddress;
    106       UCHAR NodeAddress[6];
    107       USHORT Socket;
    108     } Src,Dest;
    109   } IPX_PATTERN,*PIPX_PATTERN;
    110 
    111   typedef struct _ENUMERATION_BUFFER {
    112     ULONG Length;
    113     ULONG OwnerProcessId;
    114     USHORT FlowNameLength;
    115     WCHAR FlowName[MAX_STRING_LENGTH];
    116     PTC_GEN_FLOW pFlow;
    117     ULONG NumberOfFilters;
    118     TC_GEN_FILTER GenericFilter[1];
    119   } ENUMERATION_BUFFER,*PENUMERATION_BUFFER;
    120 
    121 #define QOS_TRAFFIC_GENERAL_ID_BASE 4000
    122 #define QOS_OBJECT_DS_CLASS (0x00000001 + QOS_TRAFFIC_GENERAL_ID_BASE)
    123 #define QOS_OBJECT_TRAFFIC_CLASS (0x00000002 + QOS_TRAFFIC_GENERAL_ID_BASE)
    124 #define QOS_OBJECT_DIFFSERV (0x00000003 + QOS_TRAFFIC_GENERAL_ID_BASE)
    125 #define QOS_OBJECT_TCP_TRAFFIC (0x00000004 + QOS_TRAFFIC_GENERAL_ID_BASE)
    126 #define QOS_OBJECT_FRIENDLY_NAME (0x00000005 + QOS_TRAFFIC_GENERAL_ID_BASE)
    127 
    128   typedef struct _QOS_FRIENDLY_NAME {
    129     QOS_OBJECT_HDR ObjectHdr;
    130     WCHAR FriendlyName[MAX_STRING_LENGTH];
    131   } QOS_FRIENDLY_NAME,*LPQOS_FRIENDLY_NAME;
    132 
    133   typedef struct _QOS_TRAFFIC_CLASS {
    134     QOS_OBJECT_HDR ObjectHdr;
    135     ULONG TrafficClass;
    136   } QOS_TRAFFIC_CLASS,*LPQOS_TRAFFIC_CLASS;
    137 
    138   typedef struct _QOS_DS_CLASS {
    139     QOS_OBJECT_HDR ObjectHdr;
    140     ULONG DSField;
    141   } QOS_DS_CLASS,*LPQOS_DS_CLASS;
    142 
    143   typedef struct _QOS_DIFFSERV {
    144     QOS_OBJECT_HDR ObjectHdr;
    145     ULONG DSFieldCount;
    146     UCHAR DiffservRule[1];
    147   } QOS_DIFFSERV,*LPQOS_DIFFSERV;
    148 
    149   typedef struct _QOS_DIFFSERV_RULE {
    150     UCHAR InboundDSField;
    151     UCHAR ConformingOutboundDSField;
    152     UCHAR NonConformingOutboundDSField;
    153     UCHAR ConformingUserPriority;
    154     UCHAR NonConformingUserPriority;
    155   } QOS_DIFFSERV_RULE,*LPQOS_DIFFSERV_RULE;
    156 
    157   typedef struct _QOS_TCP_TRAFFIC {
    158     QOS_OBJECT_HDR ObjectHdr;
    159   } QOS_TCP_TRAFFIC,*LPQOS_TCP_TRAFFIC;
    160 
    161 #define TcOpenInterface __MINGW_NAME_AW(TcOpenInterface)
    162 #define TcQueryFlow __MINGW_NAME_AW(TcQueryFlow)
    163 #define TcSetFlow __MINGW_NAME_AW(TcSetFlow)
    164 #define TcGetFlowName __MINGW_NAME_AW(TcGetFlowName)
    165 
    166   ULONG WINAPI TcRegisterClient(ULONG TciVersion,HANDLE ClRegCtx,PTCI_CLIENT_FUNC_LIST ClientHandlerList,PHANDLE pClientHandle);
    167   ULONG WINAPI TcEnumerateInterfaces(HANDLE ClientHandle,PULONG pBufferSize,PTC_IFC_DESCRIPTOR InterfaceBuffer);
    168   ULONG WINAPI TcOpenInterfaceA(LPSTR pInterfaceName,HANDLE ClientHandle,HANDLE ClIfcCtx,PHANDLE pIfcHandle);
    169   ULONG WINAPI TcOpenInterfaceW(LPWSTR pInterfaceName,HANDLE ClientHandle,HANDLE ClIfcCtx,PHANDLE pIfcHandle);
    170   ULONG WINAPI TcCloseInterface(HANDLE IfcHandle);
    171   ULONG WINAPI TcQueryInterface(HANDLE IfcHandle,LPGUID pGuidParam,BOOLEAN NotifyChange,PULONG pBufferSize,PVOID Buffer);
    172   ULONG WINAPI TcSetInterface(HANDLE IfcHandle,LPGUID pGuidParam,ULONG BufferSize,PVOID Buffer);
    173   ULONG WINAPI TcQueryFlowA(LPSTR pFlowName,LPGUID pGuidParam,PULONG pBufferSize,PVOID Buffer);
    174   ULONG WINAPI TcQueryFlowW(LPWSTR pFlowName,LPGUID pGuidParam,PULONG pBufferSize,PVOID Buffer);
    175   ULONG WINAPI TcSetFlowA(LPSTR pFlowName,LPGUID pGuidParam,ULONG BufferSize,PVOID Buffer);
    176   ULONG WINAPI TcSetFlowW(LPWSTR pFlowName,LPGUID pGuidParam,ULONG BufferSize,PVOID Buffer);
    177   ULONG WINAPI TcAddFlow(HANDLE IfcHandle,HANDLE ClFlowCtx,ULONG Flags,PTC_GEN_FLOW pGenericFlow,PHANDLE pFlowHandle);
    178   ULONG WINAPI TcGetFlowNameA(HANDLE FlowHandle,ULONG StrSize,LPSTR pFlowName);
    179   ULONG WINAPI TcGetFlowNameW(HANDLE FlowHandle,ULONG StrSize,LPWSTR pFlowName);
    180   ULONG WINAPI TcModifyFlow(HANDLE FlowHandle,PTC_GEN_FLOW pGenericFlow);
    181   ULONG WINAPI TcAddFilter(HANDLE FlowHandle,PTC_GEN_FILTER pGenericFilter,PHANDLE pFilterHandle);
    182   ULONG WINAPI TcDeregisterClient(HANDLE ClientHandle);
    183   ULONG WINAPI TcDeleteFlow(HANDLE FlowHandle);
    184   ULONG WINAPI TcDeleteFilter(HANDLE FilterHandle);
    185   ULONG WINAPI TcEnumerateFlows(HANDLE IfcHandle,PHANDLE pEnumHandle,PULONG pFlowCount,PULONG pBufSize,PENUMERATION_BUFFER Buffer);
    186 
    187 #ifdef __cplusplus
    188 }
    189 #endif
    190 #endif
    191