summaryrefslogtreecommitdiff
path: root/ACE/ace/OS_QoS.h
blob: c8df7c58eeca43b9f5da13bd4a92dd7133474fe5 (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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
// -*- C++ -*-

//=============================================================================
/**
 *  @file   OS_QoS.h
 *
 *  $Id$
 *
 *  @brief  Contains OS specific data structures for QoS networking.
 *
 *  @author Craig Rodrigues  <crodrigu@bbn.com>
 */
//=============================================================================

#ifndef ACE_OS_QOS_H
#define ACE_OS_QOS_H
#include /**/ "ace/pre.h"

#include "ace/ACE_export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/os_include/sys/os_uio.h"
#include "ace/OS_NS_stropts.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
#if defined (ACE_HAS_WINSOCK2_GQOS)
typedef SERVICETYPE ACE_SERVICE_TYPE;
#else
typedef unsigned long ACE_SERVICE_TYPE;
#endif /* ACE_HAS_WINSOCK2_GQOS */


#define ACE_OVERLAPPED_SOCKET_FLAG WSA_FLAG_OVERLAPPED

#define ACE_XP1_QOS_SUPPORTED XP1_QOS_SUPPORTED
#define ACE_XP1_SUPPORT_MULTIPOINT XP1_SUPPORT_MULTIPOINT

#define ACE_BASEERR WSABASEERR
#define ACE_ENOBUFS WSAENOBUFS
#define ACE_FROM_PROTOCOL_INFO FROM_PROTOCOL_INFO
#define ACE_FLAG_MULTIPOINT_C_ROOT WSA_FLAG_MULTIPOINT_C_ROOT
#define ACE_FLAG_MULTIPOINT_C_LEAF WSA_FLAG_MULTIPOINT_C_LEAF
#define ACE_FLAG_MULTIPOINT_D_ROOT WSA_FLAG_MULTIPOINT_D_ROOT
#define ACE_FLAG_MULTIPOINT_D_LEAF WSA_FLAG_MULTIPOINT_D_LEAF

#define ACE_QOS_NOT_SPECIFIED QOS_NOT_SPECIFIED
#define ACE_SERVICETYPE_NOTRAFFIC SERVICETYPE_NOTRAFFIC
#define ACE_SERVICETYPE_CONTROLLEDLOAD SERVICETYPE_CONTROLLEDLOAD
#define ACE_SERVICETYPE_GUARANTEED SERVICETYPE_GUARANTEED

#define ACE_JL_SENDER_ONLY JL_SENDER_ONLY
#define ACE_JL_BOTH JL_BOTH

#define ACE_SIO_GET_QOS SIO_GET_QOS
#define ACE_SIO_MULTIPOINT_LOOPBACK SIO_MULTIPOINT_LOOPBACK
#define ACE_SIO_MULTICAST_SCOPE SIO_MULTICAST_SCOPE
#define ACE_SIO_SET_QOS SIO_SET_QOS

#else
typedef unsigned long ACE_SERVICE_TYPE;

#define ACE_OVERLAPPED_SOCKET_FLAG 0
#define ACE_XP1_QOS_SUPPORTED        0x00002000
#define ACE_XP1_SUPPORT_MULTIPOINT   0x00000400

#define ACE_BASEERR   10000
#define ACE_ENOBUFS   (ACE_BASEERR+55)

#define ACE_FROM_PROTOCOL_INFO (-1)

#define ACE_FLAG_MULTIPOINT_C_ROOT    0x02
#define ACE_FLAG_MULTIPOINT_C_LEAF    0x04
#define ACE_FLAG_MULTIPOINT_D_ROOT    0x08
#define ACE_FLAG_MULTIPOINT_D_LEAF    0x10

#define ACE_QOS_NOT_SPECIFIED            0xFFFFFFFF
#define ACE_SERVICETYPE_NOTRAFFIC        0x00000000  /* No data in this */
                                                     /* direction. */
#define ACE_SERVICETYPE_CONTROLLEDLOAD   0x00000001  /* Controlled Load. */
#define ACE_SERVICETYPE_GUARANTEED       0x00000003  /* Guaranteed. */

#define ACE_JL_SENDER_ONLY    0x01
#define ACE_JL_BOTH           0x04

#define ACE_SIO_GET_QOS              (0x40000000 | 0x08000000 | 7)
#define ACE_SIO_MULTIPOINT_LOOPBACK  (0x08000000 | 9)
#define ACE_SIO_MULTICAST_SCOPE      (0x08000000 | 10)
#define ACE_SIO_SET_QOS              (0x08000000 | 11)

#endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */




/**
 * @class ACE_Flow_Spec
 *
 * @brief Wrapper class that defines the flow spec QoS information,
 *    which is used by IntServ (RSVP) and DiffServ.
 */
class ACE_Export ACE_Flow_Spec
#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
  : public FLOWSPEC
#endif /* ACE_HAS_WINSOCK2 */
{
public:
  /// Default constructor.
  ACE_Flow_Spec (void);

  /// Constructor that initializes all the fields.
  ACE_Flow_Spec (unsigned long token_rate,
                 unsigned long token_bucket_size,
                 unsigned long peak_bandwidth,
                 unsigned long latency,
                 unsigned long delay_variation,
                 ACE_SERVICE_TYPE service_type,
                 unsigned long max_sdu_size,
                 unsigned long minimum_policed_size,
                 int ttl,
                 int priority);

  /// Get the token rate in bytes/sec.
  unsigned long token_rate (void) const;

  /// Set the token rate in bytes/sec.
  void token_rate (unsigned long tr);

  /// Get the token bucket size in bytes.
  unsigned long token_bucket_size (void) const;

  /// Set the token bucket size in bytes.
  void token_bucket_size (unsigned long tbs);

  /// Get the PeakBandwidth in bytes/sec.
  unsigned long peak_bandwidth (void) const;

  /// Set the PeakBandwidth in bytes/sec.
  void peak_bandwidth (unsigned long pb);

  /// Get the latency in microseconds.
  unsigned long latency (void) const;

  /// Set the latency in microseconds.
  void latency (unsigned long l);

  /// Get the delay variation in microseconds.
  unsigned long delay_variation (void) const;

  /// Set the delay variation in microseconds.
  void delay_variation (unsigned long dv);

  /// Get the service type.
  ACE_SERVICE_TYPE service_type (void) const;

  /// Set the service type.
  void service_type (ACE_SERVICE_TYPE st);

  /// Get the maximum SDU size in bytes.
  unsigned long max_sdu_size (void) const;

  /// Set the maximum SDU size in bytes.
  void max_sdu_size (unsigned long mss);

  /// Get the minimum policed size in bytes.
  unsigned long minimum_policed_size (void) const;

  /// Set the minimum policed size in bytes.
  void minimum_policed_size (unsigned long mps);

  /// Get the time-to-live.
  int ttl (void) const;

  /// Set the time-to-live.
  void ttl (int t);

  /// Get the priority.
  int priority (void) const;

  /// Set the priority.
  void priority (int p);

#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
    defined (ACE_HAS_WINSOCK2_GQOS)
#else
private:
  unsigned long token_rate_;
  unsigned long token_bucket_size_;
  unsigned long peak_bandwidth_;
  unsigned long latency_;
  unsigned long delay_variation_;
  ACE_SERVICE_TYPE service_type_;
  unsigned long max_sdu_size_;
  unsigned long minimum_policed_size_;
  int ttl_;
  int priority_;
#endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
          defined (ACE_HAS_WINSOCK2_GQOS) */
};

/**
 * @class ACE_QoS
 *
 * @brief Wrapper class that holds the sender and receiver flow spec
 *     information, which is used by IntServ (RSVP) and DiffServ.
 */
class ACE_Export ACE_QoS
#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
  : public QOS
#endif /* ACE_HAS_WINSOCK2 */
{
public:
  /// Constructor
  ACE_QoS (void);

  /// Get the flow spec for data sending.
  ACE_Flow_Spec *sending_flowspec (void) const;

  /// Set the flow spec for data sending.
  void sending_flowspec (ACE_Flow_Spec *fs);

  /// Get the flow spec for data receiving.
  ACE_Flow_Spec *receiving_flowspec (void) const;

  /// Set the flow spec for data receiving.
  void receiving_flowspec (ACE_Flow_Spec *fs);

  /// Get the provider specific information.
  iovec provider_specific (void) const;

  /// Set the provider specific information.
  void provider_specific (const iovec &ps);

#if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
#else
private:

  ACE_Flow_Spec *sending_flowspec_;
  ACE_Flow_Spec *receiving_flowspec_;
#endif

};

/**
 * @class ACE_QoS_Params
 *
 * @brief Wrapper class that simplifies the information passed to the QoS
 * enabled <ACE_OS::connect> and <ACE_OS::join_leaf> methods.
 */
class ACE_Export ACE_QoS_Params
{
public:
  /**
   * Initialize the data members.  The <caller_data> is a pointer to
   * the user data that is to be transferred to the peer during
   * connection establishment.  The <callee_data> is a pointer to the
   * user data that is to be transferred back from the peer during
   * connection establishment.  The_<socket_qos> is a pointer to the
   * flow specifications for the socket, one for each direction.  The
   * <group_socket_qos> is a pointer to the flow speicfications for
   * the socket group, if applicable.  The_<flags> indicate if we're a
   * sender, receiver, or both.
   */
  ACE_QoS_Params (iovec *caller_data = 0,
                  iovec *callee_data = 0,
                  ACE_QoS *socket_qos = 0,
                  ACE_QoS *group_socket_qos = 0,
                  unsigned long flags = 0);

  /// Get caller data.
  iovec *caller_data (void) const;

  /// Set caller data.
  void caller_data (iovec *);

  /// Get callee data.
  iovec *callee_data (void) const;

  /// Set callee data.
  void callee_data (iovec *);

  /// Get socket qos.
  ACE_QoS *socket_qos (void) const;

  /// Set socket qos.
  void socket_qos (ACE_QoS *);

  /// Get group socket qos.
  ACE_QoS *group_socket_qos (void) const;

  /// Set group socket qos.
  void group_socket_qos (ACE_QoS *);

  /// Get flags.
  unsigned long flags (void) const;

  /// Set flags.
  void flags (unsigned long);

private:
  /// A pointer to the user data that is to be transferred to the peer
  /// during connection establishment.
  iovec *caller_data_;

  /// A pointer to the user data that is to be transferred back from
  /// the peer during connection establishment.
  iovec *callee_data_;

  /// A pointer to the flow speicfications for the socket, one for each
  /// direction.
  ACE_QoS *socket_qos_;

  /// A pointer to the flow speicfications for the socket group, if
  /// applicable.
  ACE_QoS *group_socket_qos_;

  /// Flags that indicate if we're a sender, receiver, or both.
  unsigned long flags_;
};

// Callback function that's used by the QoS-enabled <ACE_OS::accept>
// method.
typedef int (*ACE_QOS_CONDITION_FUNC) (iovec *caller_id,
                                       iovec *caller_data,
                                       ACE_QoS *socket_qos,
                                       ACE_QoS *group_socket_qos,
                                       iovec *callee_id,
                                       iovec *callee_data,
                                       ACE_SOCK_GROUP *g,
                                       unsigned long callbackdata);


/**
 * @class ACE_Accept_QoS_Params
 *
 * @brief Wrapper class that simplifies the information passed to the QoS
 * enabled <ACE_OS::accept> method.
 */
class ACE_Export ACE_Accept_QoS_Params
{
public:
  /**
   * Initialize the data members.  The <qos_condition_callback> is the
   * address of an optional, application-supplied condition function
   * that will make an accept/reject decision based on the caller
   * information pass in as parameters, and optionally create or join
   * a socket group by assinging an appropriate value to the result
   * parameter <g> of this function.  The <callback_data> data is
   * passed back to the application as a condition function parameter,
   * i.e., it is an Asynchronous Completion Token (ACT).
   */
  ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback = 0,
                         unsigned long callback_data = 0);

  /// Get QoS condition callback.
  ACE_QOS_CONDITION_FUNC qos_condition_callback (void) const;

  /// Set QoS condition callback.
  void qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc);

  /// Get callback data.
  unsigned long callback_data (void) const;

  /// Set callback data.
  void callback_data (unsigned long cd);

private:
  /**
   * This is the address of an optional, application-supplied
   * condition function that will make an accept/reject decision based
   * on the caller information pass in as parameters, and optionally
   * create or join a socket group by assinging an appropriate value
   * to the result parameter <g> of this function.
   */
  ACE_QOS_CONDITION_FUNC qos_condition_callback_;

  /**
   * This data is passed back to the application as a condition
   * function parameter, i.e., it is an Asynchronous Completion Token
   * (ACT).
   */
  unsigned long callback_data_;
};

ACE_END_VERSIONED_NAMESPACE_DECL

#include /**/ "ace/post.h"
#endif  /* ACE_OS_QOS_H */