Home | History | Annotate | Download | only in channel_transport
      1 /*
      2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
      3  *
      4  *  Use of this source code is governed by a BSD-style license
      5  *  that can be found in the LICENSE file in the root of the source
      6  *  tree. An additional intellectual property rights grant can be found
      7  *  in the file PATENTS.  All contributing project authors may
      8  *  be found in the AUTHORS file in the root of the source tree.
      9  */
     10 
     11 #ifndef WEBRTC_TEST_CHANNEL_TRANSPORT_TRAFFIC_CONTROL_WINDOWS_H_
     12 #define WEBRTC_TEST_CHANNEL_TRANSPORT_TRAFFIC_CONTROL_WINDOWS_H_
     13 
     14 #ifndef WIN32_LEAN_AND_MEAN
     15 #define WIN32_LEAN_AND_MEAN
     16 #endif
     17 
     18 // Disable deprication warning from traffic.h
     19 #pragma warning(disable : 4995)
     20 
     21 #include <windows.h>
     22 #include <qos.h>
     23 #include <ntddndis.h>
     24 #include <traffic.h>
     25 
     26 #include "webrtc/system_wrappers/include/trace.h"
     27 
     28 namespace webrtc {
     29 namespace test {
     30 void MyClNotifyHandler(HANDLE ClRegCtx, HANDLE ClIfcCtx, ULONG Event,
     31                        HANDLE SubCode, ULONG BufSize, PVOID Buffer);
     32 
     33 
     34 typedef ULONG (WINAPI *registerFn)(ULONG, HANDLE, PTCI_CLIENT_FUNC_LIST,
     35                                    PHANDLE);
     36 typedef ULONG (WINAPI *deregisterFn)(HANDLE);
     37 typedef ULONG (WINAPI *enumerateFn)(HANDLE, PULONG, PTC_IFC_DESCRIPTOR);
     38 typedef ULONG (WINAPI *openInterfaceFn)(LPWSTR, HANDLE, HANDLE, PHANDLE);
     39 typedef ULONG (WINAPI *closeInterfaceFn)(HANDLE);
     40 typedef ULONG (WINAPI *flowAddFn)(HANDLE, HANDLE, ULONG, PTC_GEN_FLOW, PHANDLE);
     41 typedef ULONG (WINAPI *filterAddFn)(HANDLE, PTC_GEN_FILTER, PHANDLE);
     42 typedef ULONG (WINAPI *flowDeleteFn)(HANDLE);
     43 typedef ULONG (WINAPI *filterDeleteFn)(HANDLE);
     44 
     45 class TrafficControlWindows
     46 {
     47  public:
     48     // Factory method. Constructor disabled.
     49     static TrafficControlWindows* GetInstance(const int32_t id);
     50     static void Release(TrafficControlWindows* gtc);
     51 
     52     ULONG TcRegisterClient(ULONG TciVersion, HANDLE ClRegCtx,
     53                            PTCI_CLIENT_FUNC_LIST ClientHandlerList,
     54                            PHANDLE pClientHandle);
     55 
     56     ULONG TcDeregisterClient(HANDLE clientHandle);
     57 
     58     ULONG TcEnumerateInterfaces(HANDLE ClientHandle, PULONG pBufferSize,
     59                                 PTC_IFC_DESCRIPTOR interfaceBuffer);
     60 
     61     ULONG TcOpenInterfaceW(LPWSTR pInterfaceName, HANDLE ClientHandle,
     62                            HANDLE ClIfcCtx, PHANDLE pIfcHandle);
     63 
     64     ULONG TcCloseInterface(HANDLE IfcHandle);
     65 
     66     ULONG TcAddFlow(HANDLE IfcHandle, HANDLE ClFlowCtx, ULONG Flags,
     67                     PTC_GEN_FLOW pGenericFlow, PHANDLE pFlowHandle);
     68 
     69     ULONG TcAddFilter(HANDLE FlowHandle, PTC_GEN_FILTER pGenericFilter,
     70                       PHANDLE pFilterHandle);
     71 
     72     ULONG TcDeleteFlow(HANDLE FlowHandle);
     73     ULONG TcDeleteFilter(HANDLE FilterHandle);
     74 private:
     75     TrafficControlWindows(const int32_t id);
     76     TCI_CLIENT_FUNC_LIST QoSFunctions;
     77 
     78     static TrafficControlWindows* instance;
     79 
     80     registerFn tcRegister;
     81     deregisterFn tcDeregister;
     82 
     83     enumerateFn tcEnumerate;
     84     openInterfaceFn tcOpenInterface;
     85     closeInterfaceFn tcCloseInterface;
     86 
     87     flowAddFn tcAddFlow;
     88     flowDeleteFn tcDeleteFlow;
     89 
     90     filterAddFn tcAddFilter;
     91     filterDeleteFn tcDeleteFilter;
     92 
     93     static uint32_t refCounter;
     94 };
     95 
     96 }  // namespace test
     97 }  // namespace webrtc
     98 
     99 #endif  // WEBRTC_TEST_CHANNEL_TRANSPORT_TRAFFIC_CONTROL_WINDOWS_H_
    100