gnuace: use list of generated files from GENERATED_DIRTY for ADDITIONAL_IDL_TARGETS
[ACE_TAO.git] / ACE / ace / OS_QoS.cpp
blob47bce4a886c261cbeb32647db7106b08c9e2463b
1 //=============================================================================
2 ///**
3 // * @file OS_QoS.cpp
4 // *
5 // *
6 // *
7 // * @brief Contains OS specific data structures for QoS networking.
8 // *
9 // * @author Craig Rodrigues <crodrigu@bbn.com>
10 // */
11 //=============================================================================
13 #include "ace/OS_QoS.h"
14 #include "ace/OS_NS_errno.h"
16 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
18 ACE_Flow_Spec::ACE_Flow_Spec (unsigned long token_rate,
19 unsigned long token_bucket_size,
20 unsigned long peak_bandwidth,
21 unsigned long latency,
22 unsigned long delay_variation,
23 ACE_SERVICE_TYPE service_type,
24 unsigned long max_sdu_size,
25 unsigned long minimum_policed_size,
26 int ttl,
27 int priority)
29 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
30 this->TokenRate = token_rate;
31 this->TokenBucketSize = token_bucket_size;
32 this->PeakBandwidth = peak_bandwidth;
33 this->Latency = latency;
34 this->DelayVariation = delay_variation;
35 #if defined(ACE_HAS_WINSOCK2_GQOS)
36 this->ServiceType = service_type;
37 this->MaxSduSize = max_sdu_size;
38 this->MinimumPolicedSize = minimum_policed_size;
39 #else
40 ACE_UNUSED_ARG (service_type);
41 ACE_UNUSED_ARG (max_sdu_size);
42 ACE_UNUSED_ARG (minimum_policed_size);
43 #endif /* ACE_HAS_WINSOCK2_GQOS */
44 ACE_UNUSED_ARG (ttl);
45 ACE_UNUSED_ARG (priority);
46 #else
48 this->token_rate_ = token_rate;
49 this->token_bucket_size_ = token_bucket_size;
50 this->peak_bandwidth_ = peak_bandwidth;
51 this->latency_ = latency;
52 this->delay_variation_ = delay_variation;
53 this->service_type_ = service_type;
54 this->max_sdu_size_ = max_sdu_size;
55 this->minimum_policed_size_ = minimum_policed_size;
56 this->ttl_ = ttl;
57 this->priority_ = priority;
59 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
62 ACE_Flow_Spec::ACE_Flow_Spec (void)
64 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
65 defined (ACE_HAS_WINSOCK2_GQOS)
66 this->TokenRate = 0;
67 this->TokenBucketSize = 0;
68 this->PeakBandwidth = 0;
69 this->Latency = 0;
70 this->DelayVariation = 0;
71 #if defined(ACE_HAS_WINSOCK2_GQOS)
72 this->ServiceType = 0;
73 this->MaxSduSize = 0;
74 this->MinimumPolicedSize = 0;
75 #endif /* ACE_HAS_WINSOCK2_GQOS */
76 #else
78 this->token_rate_ = 0;
79 this->token_bucket_size_ = 0;
80 this->peak_bandwidth_ = 0;
81 this->latency_ = 0;
82 this->delay_variation_ = 0;
83 this->service_type_ = 0;
84 this->max_sdu_size_ = 0;
85 this->minimum_policed_size_ = 0;
86 this->ttl_ = 0;
87 this->priority_ = 0;
89 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) */
92 unsigned long
93 ACE_Flow_Spec::token_rate (void) const
95 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
96 return this->TokenRate;
97 #else
98 return this->token_rate_;
99 #endif /* ACE_HAS_WINSOCK2 */
102 void
103 ACE_Flow_Spec::token_rate (unsigned long tr)
105 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
106 this->TokenRate = tr;
107 #else
108 this->token_rate_ = tr;
109 #endif /* ACE_HAS_WINSOCK2 */
112 unsigned long
113 ACE_Flow_Spec::token_bucket_size (void) const
115 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
116 return this->TokenBucketSize;
117 #else
118 return this->token_bucket_size_;
119 #endif /* ACE_HAS_WINSOCK2 */
122 void
123 ACE_Flow_Spec::token_bucket_size (unsigned long tbs)
125 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
126 this->TokenBucketSize = tbs;
127 #else
128 this->token_bucket_size_ = tbs;
129 #endif /* ACE_HAS_WINSOCK2 */
132 unsigned long
133 ACE_Flow_Spec::peak_bandwidth (void) const
135 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
136 return this->PeakBandwidth;
137 #else
138 return this->peak_bandwidth_;
139 #endif /* ACE_HAS_WINSOCK2 */
142 void
143 ACE_Flow_Spec::peak_bandwidth (unsigned long pb)
145 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
146 this->PeakBandwidth = pb;
147 #else
148 this->peak_bandwidth_ = pb;
149 #endif /* ACE_HAS_WINSOCK2 */
152 unsigned long
153 ACE_Flow_Spec::latency (void) const
155 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
156 return this->Latency;
157 #else
158 return this->latency_;
159 #endif /* ACE_HAS_WINSOCK2 */
162 void
163 ACE_Flow_Spec::latency (unsigned long l)
165 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
166 this->Latency = l;
167 #else
168 this->latency_ = l;
169 #endif /* ACE_HAS_WINSOCK2 */
172 unsigned long
173 ACE_Flow_Spec::delay_variation (void) const
175 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
176 return this->DelayVariation;
177 #else
178 return this->delay_variation_;
179 #endif /* ACE_HAS_WINSOCK2 */
181 void
182 ACE_Flow_Spec::delay_variation (unsigned long dv)
184 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
185 this->DelayVariation = dv;
186 #else
187 this->delay_variation_ = dv;
188 #endif /* ACE_HAS_WINSOCK2 */
191 ACE_SERVICE_TYPE
192 ACE_Flow_Spec::service_type (void) const
194 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
195 defined (ACE_HAS_WINSOCK2_GQOS)
196 return this->ServiceType;
197 #else
198 return this->service_type_;
199 #endif /* ACE_HAS_WINSOCK2 */
202 void
203 ACE_Flow_Spec::service_type (ACE_SERVICE_TYPE st)
205 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
206 defined (ACE_HAS_WINSOCK2_GQOS)
207 this->ServiceType = st;
208 #else
209 this->service_type_ = st;
210 #endif /* ACE_HAS_WINSOCK2 */
213 unsigned long
214 ACE_Flow_Spec::max_sdu_size (void) const
216 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
217 defined (ACE_HAS_WINSOCK2_GQOS)
218 return this->MaxSduSize;
219 #else
220 return this->max_sdu_size_;
221 #endif /* ACE_HAS_WINSOCK2 */
224 void
225 ACE_Flow_Spec::max_sdu_size (unsigned long mss)
227 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
228 defined (ACE_HAS_WINSOCK2_GQOS)
229 this->MaxSduSize = mss;
230 #else
231 this->max_sdu_size_ = mss;
232 #endif /* ACE_HAS_WINSOCK2 */
235 unsigned long
236 ACE_Flow_Spec::minimum_policed_size (void) const
238 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
239 defined (ACE_HAS_WINSOCK2_GQOS)
240 return this->MinimumPolicedSize;
241 #else
242 return this->minimum_policed_size_;
243 #endif /* ACE_HAS_WINSOCK2 */
246 void
247 ACE_Flow_Spec::minimum_policed_size (unsigned long mps)
249 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
250 defined (ACE_HAS_WINSOCK2_GQOS)
251 this->MinimumPolicedSize = mps;
252 #else
253 this->minimum_policed_size_ = mps;
254 #endif /* ACE_HAS_WINSOCK2 */
258 ACE_Flow_Spec::ttl (void) const
260 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
261 defined (ACE_HAS_WINSOCK2_GQOS)
262 ACE_NOTSUP_RETURN (-1);
263 #else
264 return this->ttl_;
265 #endif /* ACE_HAS_WINSOCK2 */
268 void
269 ACE_Flow_Spec::ttl (int t)
271 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
272 defined (ACE_HAS_WINSOCK2_GQOS)
273 ACE_UNUSED_ARG (t);
274 // TBD...
275 #else
276 this->ttl_ = t;
277 #endif /* ACE_HAS_WINSOCK2 */
281 ACE_Flow_Spec::priority (void) const
283 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
284 defined (ACE_HAS_WINSOCK2_GQOS)
285 ACE_NOTSUP_RETURN (-1);
286 #else
287 return this->priority_;
288 #endif /* ACE_HAS_WINSOCK2 */
291 void
292 ACE_Flow_Spec::priority (int p)
294 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
295 defined (ACE_HAS_WINSOCK2_GQOS)
296 ACE_UNUSED_ARG (p);
297 // TBD...
298 #else
299 this->priority_ = p;
300 #endif /* ACE_HAS_WINSOCK2 */
303 ACE_QoS::ACE_QoS (void)
304 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
305 #else
306 : sending_flowspec_ (0),
307 receiving_flowspec_ (0)
308 #endif /* ACE_HAS_WINSOCK2 */
312 ACE_Flow_Spec*
313 ACE_QoS::sending_flowspec (void) const
315 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
316 return &((ACE_Flow_Spec &) this->SendingFlowspec);
317 #else
318 return this->sending_flowspec_;
319 #endif /* ACE_HAS_WINSOCK2 */
322 void
323 ACE_QoS::sending_flowspec (ACE_Flow_Spec *fs)
325 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
326 this->SendingFlowspec = (FLOWSPEC) (*fs);
327 #else
328 this->sending_flowspec_ = fs;
329 #endif /* ACE_HAS_WINSOCK2 */
332 ACE_Flow_Spec*
333 ACE_QoS::receiving_flowspec (void) const
335 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
336 return &((ACE_Flow_Spec &) this->ReceivingFlowspec);
337 #else
338 return receiving_flowspec_;
339 #endif /* ACE_HAS_WINSOCK2 */
342 void
343 ACE_QoS::receiving_flowspec (ACE_Flow_Spec *fs)
345 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
346 this->ReceivingFlowspec = (FLOWSPEC) (*fs);
347 #else
348 this->receiving_flowspec_ = fs;
349 #endif /* ACE_HAS_WINSOCK2 */
352 iovec
353 ACE_QoS::provider_specific (void) const
355 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
356 return (iovec&) this->ProviderSpecific;
357 #else
358 ACE_NOTSUP_RETURN (iovec ());
359 #endif /* ACE_HAS_WINSOCK2 */
362 void
363 ACE_QoS::provider_specific (const iovec &ps)
365 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
366 this->ProviderSpecific = (WSABUF) (const_cast <iovec &> (ps));
367 #else
368 ACE_UNUSED_ARG (ps);
369 #endif /* ACE_HAS_WINSOCK2 */
372 ACE_QoS_Params::ACE_QoS_Params (iovec *caller_data,
373 iovec *callee_data,
374 ACE_QoS *socket_qos,
375 ACE_QoS *group_socket_qos,
376 unsigned long flags)
377 : caller_data_ (caller_data),
378 callee_data_ (callee_data),
379 socket_qos_ (socket_qos),
380 group_socket_qos_ (group_socket_qos),
381 flags_ (flags)
385 iovec *
386 ACE_QoS_Params::caller_data (void) const
388 return this->caller_data_;
391 void
392 ACE_QoS_Params::caller_data (iovec *cd)
394 this->caller_data_ = cd;
397 iovec *
398 ACE_QoS_Params::callee_data (void) const
400 return this->callee_data_;
403 void
404 ACE_QoS_Params::callee_data (iovec *cd)
406 this->callee_data_ = cd;
409 ACE_QoS *
410 ACE_QoS_Params::socket_qos (void) const
412 return this->socket_qos_;
415 void
416 ACE_QoS_Params::socket_qos (ACE_QoS *sq)
418 this->socket_qos_ = sq;
421 ACE_QoS *
422 ACE_QoS_Params::group_socket_qos (void) const
424 return this->group_socket_qos_;
427 void
428 ACE_QoS_Params::group_socket_qos (ACE_QoS *gsq)
430 this->group_socket_qos_ = gsq;
433 unsigned long
434 ACE_QoS_Params::flags (void) const
436 return this->flags_;
439 void
440 ACE_QoS_Params::flags (unsigned long f)
442 this->flags_ = f;
445 ACE_Accept_QoS_Params::ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback,
446 unsigned long callback_data)
447 : qos_condition_callback_ (qos_condition_callback),
448 callback_data_ (callback_data)
452 ACE_QOS_CONDITION_FUNC
453 ACE_Accept_QoS_Params::qos_condition_callback (void) const
455 return this->qos_condition_callback_;
458 void
459 ACE_Accept_QoS_Params::qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc)
461 this->qos_condition_callback_ = qcc;
464 unsigned long
465 ACE_Accept_QoS_Params::callback_data (void) const
467 return this->callback_data_;
470 void
471 ACE_Accept_QoS_Params::callback_data (unsigned long cd)
473 this->callback_data_ = cd;
476 ACE_END_VERSIONED_NAMESPACE_DECL