summaryrefslogtreecommitdiff
path: root/examples/QOS/QosEvent.h
blob: fe72f5c90533c51776caeadb41ca86c6c935a9f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
//$Id$

#ifndef QOSEVENT_H
#define QOSEVENT_H

#include <winsock2.h>
#include <ws2tcpip.h>
#include <qos.h>
#include <qossp.h>
#include <stdio.h>


#define MY_DEFPORT (5001)



// Application specific define - there is NO specific invalid send priority.
// This value is simply used to indicate whether or not to even set priority.
#define INVALID_SEND_PRIORITY 255


// application specific define - there is no "default" QOS template in GQoS,
// only for this particular application does "default" have meaning.
#define QOS_DEFAULTNAME "default"       

// Use an arbitrary multicast group if none is specified on the command line
#define DEFAULT_MULTICASTGROUP        "234.5.6.7"

typedef struct _SP_OPTIONS
{
  int  iProtocol;             // protocol to use
  BOOL bQos;                  // enable QOS
  BOOL bMulticast;            // enable multicasting
} SP_OPTIONS;


typedef enum 
{
  QOS_IOCTL_SET_DURING,       // do not use ioctl to set Qos
  QOS_IOCTL_SET_BEFORE,       // set qos with ioctl before connection/accept
  QOS_IOCTL_SET_AFTER,        // set qos with ioctl after connection/accept
  QOS_IOCTL_SET_QOS           // set qos in receiver during FD_QOS, note that 
                                //  qos must be set prior to wsaeventselect in 
                                //  order to ever receive fd_qos
} QOS_IOCTL_SET;


typedef struct _QOS_OPTIONS
{
  BOOL    bReceiver;          // act as receiver if TRUE
  BOOL    bWaitToSend;        // sender must wait for RESV before sending
  BOOL    bConfirmResv;       // have receiver request RESV confirmation
  BOOL    bQueryBufferSize;   // have WSAioctl return size of buffer needed 
                                //      when using SIO_GET_QOS (behaviour not
                                //      avail on Win98).
  BOOL    bMustSetQosInAccept;// Will be set for Win98 only.  Win98 currently
                                //      needs valid qos structure to be set in
                                //      wsaaccept condition func in lpSQos is valid
  BOOL    bDisableSignalling; // If TRUE do not emit RSVP signalling, just use 
                                //      traffic control
  BOOL    bAlternateQos;      // Alternate between enabling and disabling QOS on 
                                //      a socket every N sends
  UCHAR   SendPriority;       // create QOS_OBJECT_PRIORITY structure, and
                                //  set valid priority 0-7
  BOOL    bSetDestaddr;       // TRUE if unconnected UDP and QOS is used (not multicast)
  BOOL    bProviderSpecific;  // TRUE if a provider-specific object must be set
  BOOL    bFineGrainErrorAvail;   // TRUE if Win2000beta3 availability of
  //   fine grain errors on SIO_SET_QOS
  BOOL    bQosabilityIoctls;   // TRUE if Win2000beta3 qosablity ioctls 
  BOOL    bFixTemplate;       // TRUE if Win98 to divide ToeknRate and PeakBandwidth
                                //   by 8 when using WSAGetQOSByName 
  QOS_IOCTL_SET qosIoctlSet;  // when to set QOS
  CHAR    szTemplate[64];     // qos template
} QOS_OPTIONS;



extern FLOWSPEC default_notraffic;
extern FLOWSPEC default_g711;


typedef struct _OPTIONS
{
  CHAR            szHostname[64];
  unsigned short  port;
  int             nRepeat;
  CHAR            fillchar;
  int             nBufSize;
  CHAR *          buf;
  DWORD           dwSleep;
  DWORD           dwTotalClients;
  QOS_OPTIONS     qosOptions;
  SP_OPTIONS      spOptions;
} OPTIONS;
    

#ifdef QOSEVENT_MAIN

OPTIONS default_options = 
{
  "localhost",
  MY_DEFPORT,
  1,
  'c',
  4096,
  NULL,
  0,
  0,
  {TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, INVALID_SEND_PRIORITY, 
   TRUE, TRUE, TRUE, TRUE, FALSE, QOS_IOCTL_SET_BEFORE, QOS_DEFAULTNAME},
  {IPPROTO_TCP, FALSE, FALSE}
};

FLOWSPEC default_notraffic =
{
  QOS_NOT_SPECIFIED,
  QOS_NOT_SPECIFIED,
  QOS_NOT_SPECIFIED,
  QOS_NOT_SPECIFIED,
  QOS_NOT_SPECIFIED,
  SERVICETYPE_NOTRAFFIC,
  QOS_NOT_SPECIFIED,
  QOS_NOT_SPECIFIED
};
    

FLOWSPEC default_g711 =
{
  9200,
  708,
  18400,
  0,
  0,
  SERVICETYPE_CONTROLLEDLOAD,
  368,
  368
};
/*

FLOWSPEC default_g711 =
    {
    8500,
    680,
    17000,
    QOS_NOT_SPECIFIED,
    QOS_NOT_SPECIFIED,
    SERVICETYPE_GUARANTEED,
    340,
    340
    };


FLOWSPEC default_g711 =
    {
    68000,
    6800,
    136000,
    QOS_NOT_SPECIFIED,
    QOS_NOT_SPECIFIED,
    SERVICETYPE_GUARANTEED,
    340,
    340
    };
*/

SOCKADDR_IN g_destaddr;

#else

extern FLOWSPEC default_notraffic;
extern FLOWSPEC default_g711;
extern SOCKADDR_IN g_destaddr;
    
#endif



extern BOOL FindServiceProvider(
                                int iProtocol,
                                BOOL bQos,
                                BOOL bMulticast,
                                WSAPROTOCOL_INFO *pProtocolInfo);

extern VOID Receiver(
                     OPTIONS *pOptions, 
                     WSAPROTOCOL_INFO *pProtocolInfo);

extern VOID Sender(
                   OPTIONS *pOptions, 
                   WSAPROTOCOL_INFO *pProtocolInfo);

extern BOOL SetQos(
                   SOCKET sd, 
                   QOS_OPTIONS *pQosOptions, 
                   BOOL bSetQos, 
                   QOS *pQos, 
                   DWORD *cbQosLen);

extern BOOL GetQos(
                   SOCKET sd, 
                   BOOL bQueryBufferSize,
                   QOS *pQos);

extern void PrintQos(
                     QOS *qos, 
                     CHAR *lpszIndent);

extern BOOL ChkQosSend(
                       SOCKET sd);



#endif