3 //=============================================================================
7 * @brief Contains OS specific data structures for QoS networking.
9 * @author Craig Rodrigues <crodrigu@bbn.com>
11 //=============================================================================
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_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
;
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
37 # define ACE_OVERLAPPED_SOCKET_FLAG 0
40 #if defined (XP1_QOS_SUPPORTED)
41 # define ACE_XP1_QOS_SUPPORTED XP1_QOS_SUPPORTED
43 # define ACE_XP1_QOS_SUPPORTED 0x00002000
46 #if defined (XP1_SUPPORT_MULTIPOINT)
47 # define ACE_XP1_SUPPORT_MULTIPOINT XP1_SUPPORT_MULTIPOINT
49 # define ACE_XP1_SUPPORT_MULTIPOINT 0x00000400
52 #if defined (WSABASEERR)
53 # define ACE_BASEERR WSABASEERR
55 # define ACE_BASEERR 10000
58 #if defined (WSAENOBUFS)
59 # define ACE_ENOBUFS WSAENOBUFS
61 # define ACE_ENOBUFS (ACE_BASEERR+55)
64 #if defined (FROM_PROTOCOL_INFO)
65 # define ACE_FROM_PROTOCOL_INFO FROM_PROTOCOL_INFO
67 # define ACE_FROM_PROTOCOL_INFO (-1)
70 #if defined (WSA_FLAG_MULTIPOINT_C_ROOT)
71 # define ACE_FLAG_MULTIPOINT_C_ROOT WSA_FLAG_MULTIPOINT_C_ROOT
73 # define ACE_FLAG_MULTIPOINT_C_ROOT 0x02
76 #if defined (WSA_FLAG_MULTIPOINT_C_LEAF)
77 # define ACE_FLAG_MULTIPOINT_C_LEAF WSA_FLAG_MULTIPOINT_C_LEAF
79 # define ACE_FLAG_MULTIPOINT_C_LEAF 0x04
82 #if defined (WSA_FLAG_MULTIPOINT_D_ROOT)
83 # define ACE_FLAG_MULTIPOINT_D_ROOT WSA_FLAG_MULTIPOINT_D_ROOT
85 # define ACE_FLAG_MULTIPOINT_D_ROOT 0x08
88 #if defined (WSA_FLAG_MULTIPOINT_D_LEAF)
89 # define ACE_FLAG_MULTIPOINT_D_LEAF WSA_FLAG_MULTIPOINT_D_LEAF
91 # define ACE_FLAG_MULTIPOINT_D_LEAF 0x10
94 #if defined (QOS_NOT_SPECIFIED)
95 # define ACE_QOS_NOT_SPECIFIED QOS_NOT_SPECIFIED
97 # define ACE_QOS_NOT_SPECIFIED 0xFFFFFFFF
100 #if defined (SERVICETYPE_NOTRAFFIC)
101 # define ACE_SERVICETYPE_NOTRAFFIC SERVICETYPE_NOTRAFFIC
103 # define ACE_SERVICETYPE_NOTRAFFIC 0x00000000 /* No data in this */
107 #if defined (SERVICETYPE_CONTROLLEDLOAD)
108 # define ACE_SERVICETYPE_CONTROLLEDLOAD SERVICETYPE_CONTROLLEDLOAD
110 # define ACE_SERVICETYPE_CONTROLLEDLOAD 0x00000001 /* Controlled Load. */
113 #if defined (SERVICETYPE_GUARANTEED)
114 # define ACE_SERVICETYPE_GUARANTEED SERVICETYPE_GUARANTEED
116 # define ACE_SERVICETYPE_GUARANTEED 0x00000003 /* Guaranteed. */
119 #if defined (JL_SENDER_ONLY)
120 # define ACE_JL_SENDER_ONLY JL_SENDER_ONLY
122 # define ACE_JL_SENDER_ONLY 0x01
125 #if defined (JL_BOTH)
126 # define ACE_JL_BOTH JL_BOTH
128 # define ACE_JL_BOTH 0x04
131 #if defined (SIO_GET_QOS)
132 # define ACE_SIO_GET_QOS SIO_GET_QOS
134 # define ACE_SIO_GET_QOS (0x40000000 | 0x08000000 | 7)
137 #if defined (SIO_MULTIPOINT_LOOPBACK)
138 # define ACE_SIO_MULTIPOINT_LOOPBACK SIO_MULTIPOINT_LOOPBACK
140 # define ACE_SIO_MULTIPOINT_LOOPBACK (0x08000000 | 9)
143 #if defined (SIO_MULTICAST_SCOPE)
144 # define ACE_SIO_MULTICAST_SCOPE SIO_MULTICAST_SCOPE
146 # define ACE_SIO_MULTICAST_SCOPE (0x08000000 | 10)
149 #if defined (SIO_SET_QOS)
150 # define ACE_SIO_SET_QOS SIO_SET_QOS
152 # define ACE_SIO_SET_QOS (0x08000000 | 11)
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)
164 #endif /* ACE_HAS_WINSOCK2 */
167 /// Default constructor.
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
,
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.
233 /// Set the time-to-live.
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)
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_
;
256 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
257 defined (ACE_HAS_WINSOCK2_GQOS) */
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)
269 #endif /* ACE_HAS_WINSOCK2 */
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)
296 ACE_Flow_Spec
*sending_flowspec_
;
297 ACE_Flow_Spec
*receiving_flowspec_
;
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
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);
328 iovec
*caller_data () const;
331 void caller_data (iovec
*);
334 iovec
*callee_data () const;
337 void callee_data (iovec
*);
340 ACE_QoS
*socket_qos () const;
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
*);
352 unsigned long flags () const;
355 void flags (unsigned long);
358 /// A pointer to the user data that is to be transferred to the peer
359 /// during connection establishment.
362 /// A pointer to the user data that is to be transferred back from
363 /// the peer during connection establishment.
366 /// A pointer to the flow speicfications for the socket, one for each
368 ACE_QoS
*socket_qos_
;
370 /// A pointer to the flow speicfications for the socket group, if
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>
380 typedef int (*ACE_QOS_CONDITION_FUNC
) (iovec
*caller_id
,
383 ACE_QoS
*group_socket_qos
,
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
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
);
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
439 unsigned long callback_data_
;
442 ACE_END_VERSIONED_NAMESPACE_DECL
444 #include /**/ "ace/post.h"
445 #endif /* ACE_OS_QOS_H */