Document return values
[ACE_TAO.git] / ACE / ace / OS_QoS.h
blob70ea271eed72071ea91f5aeb2fc547f50f1ba6ec
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file OS_QoS.h
7 * @brief Contains OS specific data structures for QoS networking.
9 * @author Craig Rodrigues <crodrigu@bbn.com>
11 //=============================================================================
13 #ifndef ACE_OS_QOS_H
14 #define ACE_OS_QOS_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/os_include/sys/os_uio.h"
24 #include "ace/OS_NS_stropts.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined (ACE_HAS_WINSOCK2_GQOS)
29 typedef SERVICETYPE ACE_SERVICE_TYPE;
30 #else
31 typedef unsigned long ACE_SERVICE_TYPE;
32 #endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */
34 #if defined (WSA_FLAG_OVERLAPPED)
35 # define ACE_OVERLAPPED_SOCKET_FLAG WSA_FLAG_OVERLAPPED
36 #else
37 # define ACE_OVERLAPPED_SOCKET_FLAG 0
38 #endif
40 #if defined (XP1_QOS_SUPPORTED)
41 # define ACE_XP1_QOS_SUPPORTED XP1_QOS_SUPPORTED
42 #else
43 # define ACE_XP1_QOS_SUPPORTED 0x00002000
44 #endif
46 #if defined (XP1_SUPPORT_MULTIPOINT)
47 # define ACE_XP1_SUPPORT_MULTIPOINT XP1_SUPPORT_MULTIPOINT
48 #else
49 # define ACE_XP1_SUPPORT_MULTIPOINT 0x00000400
50 #endif
52 #if defined (WSABASEERR)
53 # define ACE_BASEERR WSABASEERR
54 #else
55 # define ACE_BASEERR 10000
56 #endif
58 #if defined (WSAENOBUFS)
59 # define ACE_ENOBUFS WSAENOBUFS
60 #else
61 # define ACE_ENOBUFS (ACE_BASEERR+55)
62 #endif
64 #if defined (FROM_PROTOCOL_INFO)
65 # define ACE_FROM_PROTOCOL_INFO FROM_PROTOCOL_INFO
66 #else
67 # define ACE_FROM_PROTOCOL_INFO (-1)
68 #endif
70 #if defined (WSA_FLAG_MULTIPOINT_C_ROOT)
71 # define ACE_FLAG_MULTIPOINT_C_ROOT WSA_FLAG_MULTIPOINT_C_ROOT
72 #else
73 # define ACE_FLAG_MULTIPOINT_C_ROOT 0x02
74 #endif
76 #if defined (WSA_FLAG_MULTIPOINT_C_LEAF)
77 # define ACE_FLAG_MULTIPOINT_C_LEAF WSA_FLAG_MULTIPOINT_C_LEAF
78 #else
79 # define ACE_FLAG_MULTIPOINT_C_LEAF 0x04
80 #endif
82 #if defined (WSA_FLAG_MULTIPOINT_D_ROOT)
83 # define ACE_FLAG_MULTIPOINT_D_ROOT WSA_FLAG_MULTIPOINT_D_ROOT
84 #else
85 # define ACE_FLAG_MULTIPOINT_D_ROOT 0x08
86 #endif
88 #if defined (WSA_FLAG_MULTIPOINT_D_LEAF)
89 # define ACE_FLAG_MULTIPOINT_D_LEAF WSA_FLAG_MULTIPOINT_D_LEAF
90 #else
91 # define ACE_FLAG_MULTIPOINT_D_LEAF 0x10
92 #endif
94 #if defined (QOS_NOT_SPECIFIED)
95 # define ACE_QOS_NOT_SPECIFIED QOS_NOT_SPECIFIED
96 #else
97 # define ACE_QOS_NOT_SPECIFIED 0xFFFFFFFF
98 #endif
100 #if defined (SERVICETYPE_NOTRAFFIC)
101 # define ACE_SERVICETYPE_NOTRAFFIC SERVICETYPE_NOTRAFFIC
102 #else
103 # define ACE_SERVICETYPE_NOTRAFFIC 0x00000000 /* No data in this */
104 /* direction. */
105 #endif
107 #if defined (SERVICETYPE_CONTROLLEDLOAD)
108 # define ACE_SERVICETYPE_CONTROLLEDLOAD SERVICETYPE_CONTROLLEDLOAD
109 #else
110 # define ACE_SERVICETYPE_CONTROLLEDLOAD 0x00000001 /* Controlled Load. */
111 #endif
113 #if defined (SERVICETYPE_GUARANTEED)
114 # define ACE_SERVICETYPE_GUARANTEED SERVICETYPE_GUARANTEED
115 #else
116 # define ACE_SERVICETYPE_GUARANTEED 0x00000003 /* Guaranteed. */
117 #endif
119 #if defined (JL_SENDER_ONLY)
120 # define ACE_JL_SENDER_ONLY JL_SENDER_ONLY
121 #else
122 # define ACE_JL_SENDER_ONLY 0x01
123 #endif
125 #if defined (JL_BOTH)
126 # define ACE_JL_BOTH JL_BOTH
127 #else
128 # define ACE_JL_BOTH 0x04
129 #endif
131 #if defined (SIO_GET_QOS)
132 # define ACE_SIO_GET_QOS SIO_GET_QOS
133 #else
134 # define ACE_SIO_GET_QOS (0x40000000 | 0x08000000 | 7)
135 #endif
137 #if defined (SIO_MULTIPOINT_LOOPBACK)
138 # define ACE_SIO_MULTIPOINT_LOOPBACK SIO_MULTIPOINT_LOOPBACK
139 #else
140 # define ACE_SIO_MULTIPOINT_LOOPBACK (0x08000000 | 9)
141 #endif
143 #if defined (SIO_MULTICAST_SCOPE)
144 # define ACE_SIO_MULTICAST_SCOPE SIO_MULTICAST_SCOPE
145 #else
146 # define ACE_SIO_MULTICAST_SCOPE (0x08000000 | 10)
147 #endif
149 #if defined (SIO_SET_QOS)
150 # define ACE_SIO_SET_QOS SIO_SET_QOS
151 #else
152 # define ACE_SIO_SET_QOS (0x08000000 | 11)
153 #endif
156 * @class ACE_Flow_Spec
158 * @brief Wrapper class that defines the flow spec QoS information,
159 * which is used by IntServ (RSVP) and DiffServ.
161 class ACE_Export ACE_Flow_Spec
162 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
163 : public FLOWSPEC
164 #endif /* ACE_HAS_WINSOCK2 */
166 public:
167 /// Default constructor.
168 ACE_Flow_Spec ();
170 /// Constructor that initializes all the fields.
171 ACE_Flow_Spec (unsigned long token_rate,
172 unsigned long token_bucket_size,
173 unsigned long peak_bandwidth,
174 unsigned long latency,
175 unsigned long delay_variation,
176 ACE_SERVICE_TYPE service_type,
177 unsigned long max_sdu_size,
178 unsigned long minimum_policed_size,
179 int ttl,
180 int priority);
182 /// Get the token rate in bytes/sec.
183 unsigned long token_rate () const;
185 /// Set the token rate in bytes/sec.
186 void token_rate (unsigned long tr);
188 /// Get the token bucket size in bytes.
189 unsigned long token_bucket_size () const;
191 /// Set the token bucket size in bytes.
192 void token_bucket_size (unsigned long tbs);
194 /// Get the PeakBandwidth in bytes/sec.
195 unsigned long peak_bandwidth () const;
197 /// Set the PeakBandwidth in bytes/sec.
198 void peak_bandwidth (unsigned long pb);
200 /// Get the latency in microseconds.
201 unsigned long latency () const;
203 /// Set the latency in microseconds.
204 void latency (unsigned long l);
206 /// Get the delay variation in microseconds.
207 unsigned long delay_variation () const;
209 /// Set the delay variation in microseconds.
210 void delay_variation (unsigned long dv);
212 /// Get the service type.
213 ACE_SERVICE_TYPE service_type () const;
215 /// Set the service type.
216 void service_type (ACE_SERVICE_TYPE st);
218 /// Get the maximum SDU size in bytes.
219 unsigned long max_sdu_size () const;
221 /// Set the maximum SDU size in bytes.
222 void max_sdu_size (unsigned long mss);
224 /// Get the minimum policed size in bytes.
225 unsigned long minimum_policed_size () const;
227 /// Set the minimum policed size in bytes.
228 void minimum_policed_size (unsigned long mps);
230 /// Get the time-to-live.
231 int ttl () const;
233 /// Set the time-to-live.
234 void ttl (int t);
236 /// Get the priority.
237 int priority () const;
239 /// Set the priority.
240 void priority (int p);
242 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
243 defined (ACE_HAS_WINSOCK2_GQOS)
244 #else
245 private:
246 unsigned long token_rate_;
247 unsigned long token_bucket_size_;
248 unsigned long peak_bandwidth_;
249 unsigned long latency_;
250 unsigned long delay_variation_;
251 ACE_SERVICE_TYPE service_type_;
252 unsigned long max_sdu_size_;
253 unsigned long minimum_policed_size_;
254 int ttl_;
255 int priority_;
256 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
257 defined (ACE_HAS_WINSOCK2_GQOS) */
261 * @class ACE_QoS
263 * @brief Wrapper class that holds the sender and receiver flow spec
264 * information, which is used by IntServ (RSVP) and DiffServ.
266 class ACE_Export ACE_QoS
267 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
268 : public QOS
269 #endif /* ACE_HAS_WINSOCK2 */
271 public:
272 /// Constructor
273 ACE_QoS ();
275 /// Get the flow spec for data sending.
276 ACE_Flow_Spec *sending_flowspec () const;
278 /// Set the flow spec for data sending.
279 void sending_flowspec (ACE_Flow_Spec *fs);
281 /// Get the flow spec for data receiving.
282 ACE_Flow_Spec *receiving_flowspec () const;
284 /// Set the flow spec for data receiving.
285 void receiving_flowspec (ACE_Flow_Spec *fs);
287 /// Get the provider specific information.
288 iovec provider_specific () const;
290 /// Set the provider specific information.
291 void provider_specific (const iovec &ps);
293 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
294 #else
295 private:
296 ACE_Flow_Spec *sending_flowspec_;
297 ACE_Flow_Spec *receiving_flowspec_;
298 #endif
302 * @class ACE_QoS_Params
304 * @brief Wrapper class that simplifies the information passed to the QoS
305 * enabled <ACE_OS::connect> and <ACE_OS::join_leaf> methods.
307 class ACE_Export ACE_QoS_Params
309 public:
311 * Initialize the data members. The <caller_data> is a pointer to
312 * the user data that is to be transferred to the peer during
313 * connection establishment. The <callee_data> is a pointer to the
314 * user data that is to be transferred back from the peer during
315 * connection establishment. The_<socket_qos> is a pointer to the
316 * flow specifications for the socket, one for each direction. The
317 * <group_socket_qos> is a pointer to the flow speicfications for
318 * the socket group, if applicable. The_@a flags indicate if we're a
319 * sender, receiver, or both.
321 ACE_QoS_Params (iovec *caller_data = 0,
322 iovec *callee_data = 0,
323 ACE_QoS *socket_qos = 0,
324 ACE_QoS *group_socket_qos = 0,
325 unsigned long flags = 0);
327 /// Get caller data.
328 iovec *caller_data () const;
330 /// Set caller data.
331 void caller_data (iovec *);
333 /// Get callee data.
334 iovec *callee_data () const;
336 /// Set callee data.
337 void callee_data (iovec *);
339 /// Get socket qos.
340 ACE_QoS *socket_qos () const;
342 /// Set socket qos.
343 void socket_qos (ACE_QoS *);
345 /// Get group socket qos.
346 ACE_QoS *group_socket_qos () const;
348 /// Set group socket qos.
349 void group_socket_qos (ACE_QoS *);
351 /// Get flags.
352 unsigned long flags () const;
354 /// Set flags.
355 void flags (unsigned long);
357 private:
358 /// A pointer to the user data that is to be transferred to the peer
359 /// during connection establishment.
360 iovec *caller_data_;
362 /// A pointer to the user data that is to be transferred back from
363 /// the peer during connection establishment.
364 iovec *callee_data_;
366 /// A pointer to the flow speicfications for the socket, one for each
367 /// direction.
368 ACE_QoS *socket_qos_;
370 /// A pointer to the flow speicfications for the socket group, if
371 /// applicable.
372 ACE_QoS *group_socket_qos_;
374 /// Flags that indicate if we're a sender, receiver, or both.
375 unsigned long flags_;
378 // Callback function that's used by the QoS-enabled <ACE_OS::accept>
379 // method.
380 typedef int (*ACE_QOS_CONDITION_FUNC) (iovec *caller_id,
381 iovec *caller_data,
382 ACE_QoS *socket_qos,
383 ACE_QoS *group_socket_qos,
384 iovec *callee_id,
385 iovec *callee_data,
386 ACE_SOCK_GROUP *g,
387 unsigned long callbackdata);
391 * @class ACE_Accept_QoS_Params
393 * @brief Wrapper class that simplifies the information passed to the QoS
394 * enabled <ACE_OS::accept> method.
396 class ACE_Export ACE_Accept_QoS_Params
398 public:
400 * Initialize the data members. The <qos_condition_callback> is the
401 * address of an optional, application-supplied condition function
402 * that will make an accept/reject decision based on the caller
403 * information pass in as parameters, and optionally create or join
404 * a socket group by assinging an appropriate value to the result
405 * parameter <g> of this function. The <callback_data> data is
406 * passed back to the application as a condition function parameter,
407 * i.e., it is an Asynchronous Completion Token (ACT).
409 ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback = 0,
410 unsigned long callback_data = 0);
412 /// Get QoS condition callback.
413 ACE_QOS_CONDITION_FUNC qos_condition_callback () const;
415 /// Set QoS condition callback.
416 void qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc);
418 /// Get callback data.
419 unsigned long callback_data () const;
421 /// Set callback data.
422 void callback_data (unsigned long cd);
424 private:
426 * This is the address of an optional, application-supplied
427 * condition function that will make an accept/reject decision based
428 * on the caller information pass in as parameters, and optionally
429 * create or join a socket group by assinging an appropriate value
430 * to the result parameter <g> of this function.
432 ACE_QOS_CONDITION_FUNC qos_condition_callback_;
435 * This data is passed back to the application as a condition
436 * function parameter, i.e., it is an Asynchronous Completion Token
437 * (ACT).
439 unsigned long callback_data_;
442 ACE_END_VERSIONED_NAMESPACE_DECL
444 #include /**/ "ace/post.h"
445 #endif /* ACE_OS_QOS_H */