summaryrefslogtreecommitdiff
path: root/ace/QoS/QoS_Session_Impl.cpp
blob: c516d38e9e0a6dd058cf89e15a0e0b65ac496f12 (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
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
// QoS_Session_Impl.cpp
// $Id$

#include "ace/SOCK.h"
#include "QoS_Manager.h"
#include "QoS_Session_Impl.h"
#include "ace/Log_Msg.h"

#if !defined (__ACE_INLINE__)
#include "QoS_Session_Impl.i"
#endif /* __ACE_INLINE__ */

ACE_RCSID(ace, QoS_Session_Impl, "$Id$")

ACE_ALLOC_HOOK_DEFINE(ACE_QoS_Session_Impl)

#if defined (ACE_HAS_RAPI)
#include "rapi_err.h"

int ACE_RAPI_Session::rsvp_error = 0;

// Call back function used by RAPI to report RSVP events. This
// function translates the RAPI QoS parameters into the more generic
// ACE_QoS parameters for the underlying RAPI session.
int
rsvp_callback (rapi_sid_t sid,
               rapi_eventinfo_t eventype,
               int style_id,
               int errcode,
               int errvalue,
               sockaddr * errnode,
               u_char errflags,
               int filter_spec_no,
               rapi_filter_t *filter_spec_list,
               int flow_spec_no,
               rapi_flowspec_t *flow_spec_list,
               int ad_spec_no,
               rapi_adspec_t *ad_spec_list,
               void *args
               )
{
  ACE_UNUSED_ARG (sid);
  ACE_UNUSED_ARG (style_id);
  ACE_UNUSED_ARG (filter_spec_no);
  ACE_UNUSED_ARG (filter_spec_list);
  ACE_UNUSED_ARG (ad_spec_no);
  ACE_UNUSED_ARG (ad_spec_list);
  ACE_UNUSED_ARG (errflags);

  if (args == 0)
    ACE_DEBUG ((LM_DEBUG,
                "Argument in the call back function is null\n\n"));

  ACE_QoS_Session *qos_session = (ACE_QoS_Session *) args;

  qos_flowspecx_t *csxp = 0;
  
  if(!flow_spec_list)
    {
      ACE_DEBUG ((LM_DEBUG,
		  "(%N|%l) Null flow_spec_list\n"));
    }
  else
    {
      // Extended Legacy format.
      csxp = &flow_spec_list->specbody_qosx;
      if(!csxp)
	{
	  ACE_ERROR_RETURN ((LM_ERROR,
			     "(%N|%l) Null csxp\n"),
			    -1);
	}
    }
  
  ACE_QoS ace_qos = qos_session->qos ();

  switch(eventype)
    {
    case RAPI_PATH_EVENT:
      {
        ACE_DEBUG ((LM_DEBUG,
                    "RSVP PATH Event received\n"
                    "No. of TSpecs received : %d %d\n",
                    flow_spec_no, &flow_spec_list->len));

	ACE_Flow_Spec *receiving_fs = 0;
		    
	if (flow_spec_no != 0)
	  {

	    ACE_NEW_RETURN (receiving_fs,
			    ACE_Flow_Spec,
			    -1);

	    ACE_NEW_RETURN (receiving_fs,
			    ACE_Flow_Spec ((u_long)csxp->xspec_r,
					   (u_long)csxp->xspec_b,
					   (u_long)csxp->xspec_p,
					   0,
					   csxp->xspec_S,
					   1,
					   csxp->xspec_M,
					   csxp->xspec_m,
					   25,
					   0),
			    -1);
	
	    
	    ACE_DEBUG ((LM_DEBUG,
			"\nTSpec :\n"
			"\t Spec Type = %d\n"
			"\t Rate = %f\n"
			"\t Bucket = %f\n"
			"\t Peak = %f\n"
			"\t MPU = %d\n"
			"\t MDU = %d\n"
			"\t TTL = %d\n",
			csxp->spec_type,
			csxp->xspec_r,
			csxp->xspec_b,
			csxp->xspec_p,
			csxp->xspec_m,
			csxp->xspec_M,
			25));
	   
	  } 
	// Set the sending flowspec QoS of the given session.
	ace_qos.receiving_flowspec (receiving_fs);

	qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_PATH_EVENT);

      }
      
    break;

    case RAPI_RESV_EVENT:
      {	      
	ACE_DEBUG ((LM_DEBUG,
		    "RSVP RESV Event received\n"
		    "No. of FlowSpecs received : %d\n",
		    flow_spec_no));
      
	ACE_Flow_Spec *sending_flow = 0;
	
	if (flow_spec_no != 0)
	  {
	    ACE_NEW_RETURN (sending_flow,
			    ACE_Flow_Spec,
			    -1);
	    
	    // Choose based on the service type : [QOS_GUARANTEEDX/QOS_CNTR_LOAD].
	    switch (csxp->spec_type)
	      {
	      case QOS_GUARANTEEDX:
		// Slack term in MICROSECONDS
		sending_flow->delay_variation (csxp->xspec_S);

		// @@How does the guaranteed rate parameter map to the ACE_Flow_Spec.
		// Note there is no break !!

	      case QOS_CNTR_LOAD:

		// qos_service_type.
		sending_flow->service_type (csxp->spec_type);
		// Token Bucket Average Rate (B/s)
		sending_flow->token_rate ((u_long)csxp->xspec_r);
		// Token Bucket Rate (B)
		sending_flow->token_bucket_size ((u_long)csxp->xspec_b);
		// Peak Data Rate (B/s)
		sending_flow->peak_bandwidth ((u_long)csxp->xspec_p);
		// Minimum Policed Unit (B)
		sending_flow->minimum_policed_size (csxp->xspec_m);
		// Max Packet Size (B)
		sending_flow->max_sdu_size (csxp->xspec_M);

		break;

	      default:
		ACE_ERROR_RETURN ((LM_ERROR,
				   "(%N|%l) Unknown flowspec type: %u.\n", csxp->spec_type),
				  -1);
	      };
	  }
	ace_qos.sending_flowspec (sending_flow);
	
	qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_RESV_EVENT);
      }
      break;
      
    case RAPI_PATH_ERROR:
      {
	ACE_DEBUG ((LM_DEBUG,
		    "PATH ERROR Event received\n"
		    "Code=%d  Val=%d  Node= %s\n",
		    errcode,
		    errvalue,
		    ACE_OS::inet_ntoa(((sockaddr_in *)errnode)->sin_addr)));
	qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_PATH_ERROR);
      }
      break;

    case RAPI_RESV_ERROR:
      {
	ACE_DEBUG ((LM_DEBUG,
		    "RESV ERROR Event received\n"
		    "Code=%d  Val=%d  Node= %s\n",
		    errcode,
		    errvalue,
		    ACE_OS::inet_ntoa(((sockaddr_in *)errnode)->sin_addr)));
	qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_RESV_ERROR);
      }
      break;
      
    case RAPI_RESV_CONFIRM:
      {
	ACE_DEBUG ((LM_DEBUG,
		    "RESV CONFIRM Event received\n"));
	qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_RESV_CONFIRM);
      }
      break;
      
    default:
      ACE_DEBUG ((LM_DEBUG,
                  "Unknown RSVP Event Received\n"));
      break;

    }

  // Set the updated ACE_QoS for the RSVP callback argument(QoS session).
  qos_session->qos (ace_qos);

  // @@ what is the meaning of the return value. RAPI docs don't say anything!
  return 0;
}

// Constructor.
ACE_RAPI_Session::ACE_RAPI_Session (void)
{
  ACE_TRACE ("ACE_RAPI_Session::ACE_RAPI_Session");
  //this->source_port (DEFAULT_SOURCE_SENDER_PORT);
  ACE_NEW (this->src_addr_,
	   ACE_INET_Addr ("0")); 
}

// Open a RAPI QoS session [dest IP, dest port, Protocol ID].
int
ACE_RAPI_Session::open (ACE_INET_Addr dest_addr,
                        ACE_Protocol_ID protocol_id)
{
  char buf [BUFSIZ];
  dest_addr.addr_to_string (buf,
			     BUFSIZ);
  ACE_DEBUG ((LM_DEBUG,
	      "In RAPI SESSION OPEN %s\n",
	      buf));

  this->dest_addr_ = dest_addr;
  this->protocol_id_ = protocol_id;

  // Open a RAPI session. Note "this" is being passed as an argument to
  // the callback function. The callback function uses this argument to
  // update the QoS of this session based on the RSVP event it receives.

  if ((this->session_id_ = rapi_session((struct sockaddr *) dest_addr.get_addr (),
                                        protocol_id,
                                        0,
                                        rsvp_callback,
                                        (void *) this,
                                        &rsvp_error)) == NULL_SID)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "rapi_session () call fails. Error\n"),
                      -1);
  else
    ACE_DEBUG ((LM_DEBUG,
                "rapi_session () call succeeds. "
                "Session ID = %d\n",
                this->session_id_));

  return 0;
}

// Close the RAPI QoS Session.
int
ACE_RAPI_Session::close (void)
{
  this->rsvp_error = rapi_release(this->session_id_);

  if (rsvp_error == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Can't release RSVP session:\n\t%s\n",
                       rapi_errlist[rsvp_error]),
                      -1);
  else
    ACE_DEBUG ((LM_DEBUG,
                "rapi session with id %d released successfully.\n",
                this->session_id_));
  return 0;
}

//Get the most recent RSVP event that occured
ACE_QoS_Session::RSVP_Event_Type
ACE_RAPI_Session::rsvp_event_type (void)
{
  return this->rsvp_event_type_;
}

//Set the most recent RSVP event that occured
void
ACE_RAPI_Session::rsvp_event_type (ACE_QoS_Session::RSVP_Event_Type event_type)
{
  this->rsvp_event_type_ = event_type;
}

int
ACE_RAPI_Session::qos (ACE_SOCK *socket,
                       ACE_QoS_Manager *qos_manager,
                       const ACE_QoS &ace_qos)
{
  ACE_UNUSED_ARG (socket);
  ACE_UNUSED_ARG (qos_manager);

  // If sender : call sending_qos ()
  // If receiver : call receiving_qos ()
  // If both : call sending_qos () and receiving_qos ()

  if (this->flags_ != ACE_QOS_RECEIVER)
    return this->sending_qos (ace_qos);

  if (this->flags_ != ACE_QOS_SENDER)
    return this->receiving_qos (ace_qos);

  return 0;
}

// Set sending QoS for this RAPI session.
int
ACE_RAPI_Session::sending_qos (const ACE_QoS &ace_qos)
{
  ACE_Flow_Spec *sending_flowspec = ace_qos.sending_flowspec ();
  
  if (sending_flowspec == 0)
    {
      int result = rapi_sender (this->session_id_,
				0,
				0,
				NULL,
				0,
				NULL,
				NULL,
				25) ;
      if (result != 0)
	ACE_ERROR_RETURN ((LM_ERROR,
			   "(%N|%l) rapi_sender error %d:\n\tPATH Generation can't be started\n",
			   result),
			  -1);
      else
	ACE_DEBUG ((LM_DEBUG,
		    "rapi_sender () call succeeds with PATH Tear! \n"));
      
      return 0;
    }

  rapi_tspec_t *t_spec = this->init_tspec_simplified (*sending_flowspec);
  if (t_spec == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "(%N|%l) Error in translating from ACE Flow Spec to"
                       " RAPI TSpec\n"),
                      -1);

  char buffer[BUFSIZ];

  // This formats the t_spec in a visually intuitive char * that can
  // be printed.

  (void) rapi_fmt_tspec(t_spec, buffer, sizeof(buffer));
  ACE_DEBUG ((LM_DEBUG,
              "\nSender TSpec : %s\n",
              buffer));

  // Print out all the fields separately.
  ACE_DEBUG ((LM_DEBUG,
              "\nTSpec :\n"
              "\t Spec Type = %d\n"
              "\t Rate = %f\n"
              "\t Bucket = %f\n"
              "\t Peak = %f\n"
              "\t MPU = %d\n"
              "\t MDU = %d\n"
              "\t TTL = %d\n",
              t_spec->tspecbody_qosx.spec_type,
              t_spec->tspecbody_qosx.xtspec_r,
              t_spec->tspecbody_qosx.xtspec_b,
              t_spec->tspecbody_qosx.xtspec_p,
              t_spec->tspecbody_qosx.xtspec_m,
              t_spec->tspecbody_qosx.xtspec_M,
              sending_flowspec->ttl ()));
  
  // This the source sender port.
  //  ACE_INET_Addr sender_addr (this->source_port ());

  ACE_DEBUG ((LM_DEBUG,
              "Making the rapi_sender () call\n"));

  // Set the Sender TSpec for this QoS session.


  int result = rapi_sender(this->session_id_,
			   0,
			   (sockaddr *) this->src_addr_->get_addr (),
			   NULL,
			   t_spec,
			   NULL,
			   NULL,
			   sending_flowspec->ttl ()) ;
  
  /*
  int result = rapi_sender(this->session_id_,
			   0,
			   (sockaddr *) sender_addr.get_addr (),
			   NULL,
			   t_spec,
			   NULL,
			   NULL,
			   sending_flowspec->ttl ()) ;
  */
  if(result!= 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "(%N|%l) rapi_sender error %d:\n\tPATH Generation can't be started\n",
		       result),
                      -1);
  else
    ACE_DEBUG ((LM_DEBUG,
                "rapi_sender () call succeeds ! \n"));
  return 0;
}

// Set receiving QoS for this RAPI session.
int
ACE_RAPI_Session::receiving_qos (const ACE_QoS &ace_qos)
{

  ACE_Flow_Spec *receiving_flowspec = ace_qos.receiving_flowspec ();
  if (receiving_flowspec == 0)
    {
      if (rapi_reserve(this->session_id_,
		       0,
		       // Setting the RAPI_REQ_CONFIRM flag requests confirmation
		       // of the resevation, by means of a confirmation upcall of
		       // type RAPI_RESV_CONFIRM.
		       //                   (sockaddr *)receiver_addr.get_addr (),
		       0,
		       RAPI_RSTYLE_WILDCARD,
		       // This applies the flowspec to all the senders. Given this,
		       // @@I am passing the filter_spec to be null, hoping this will work.
		       NULL,
		       NULL,
		       0,
		       NULL,
		       // The filter spec is NULL. This should work since the RSTYLE is
		       // WILDCARD.
		       0,
		       0) == -1)
	ACE_ERROR_RETURN ((LM_ERROR,
			   "(%N|%l)rapi_reserve () error:\n\tRESV Generation can't be started\n"),
			  -1);
      else
	ACE_DEBUG ((LM_DEBUG,
		    "rapi_reserve () for RESV Tear call succeeds \n"));
      
      return 0;
    }
  

  rapi_flowspec_t *flow_spec = init_flowspec_simplified (*receiving_flowspec);

  if (flow_spec == 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "(%N|%l) Error in translating from ACE Flow Spec to"
                       " RAPI FlowSpec\n"),
                      -1);

  char buffer[BUFSIZ];

  // This formats the flow_spec in a visually intuitive char * that can
  // be printed.
  (void)rapi_fmt_flowspec(flow_spec, buffer, sizeof(buffer));
  ACE_DEBUG ((LM_DEBUG,
              "\nReceiver FlowSpec : %s\n",
              buffer));

  // Print out all the fields separately.
  ACE_DEBUG ((LM_DEBUG,
              "\nFlowSpec :\n"
              "\t Spec Type = %d\n"
              "\t Rate = %f\n"
              "\t Bucket = %f\n"
              "\t Peak = %f\n"
              "\t MPU = %d\n"
              "\t MDU = %d\n",
              flow_spec->specbody_qosx.spec_type,
              flow_spec->specbody_qosx.xspec_r,
              flow_spec->specbody_qosx.xspec_b,
              flow_spec->specbody_qosx.xspec_p,
              flow_spec->specbody_qosx.xspec_m,
              flow_spec->specbody_qosx.xspec_M));

  sockaddr_in Receiver_host;

  Receiver_host.sin_addr.s_addr = INADDR_ANY;

  // Set the Receiver FlowSpec for this QoS session.
  // @@The filter style is hardcoded to WildCard. This can be changed later.
  if (rapi_reserve(this->session_id_,
                   RAPI_REQ_CONFIRM,
                   // Setting the RAPI_REQ_CONFIRM flag requests confirmation
                   // of the resevation, by means of a confirmation upcall of
                   // type RAPI_RESV_CONFIRM.
                   //                   (sockaddr *)receiver_addr.get_addr (),
                   (sockaddr *)&Receiver_host,
                   RAPI_RSTYLE_WILDCARD,
                   // This applies the flowspec to all the senders. Given this,
                   // @@I am passing the filter_spec to be null, hoping this will work.
                   NULL,
                   NULL,
                   0,
                   NULL,
                   // The filter spec is NULL. This should work since the RSTYLE is
                   // WILDCARD.
                   1,
                   flow_spec) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "rapi_reserve () error:\n\tRESV Generation can't be started\n"),
                      -1);
  else
    ACE_DEBUG ((LM_DEBUG,
                "rapi_reserve () call succeeds \n"));

  return 0;
}

int
ACE_RAPI_Session::update_qos (void)
{
  // Update the session QoS Parameters based on the RSVP Event Received.
  if ((rsvp_error = rapi_dispatch ()) != 0)
    ACE_ERROR_RETURN ((LM_ERROR,
                       "Error in rapi_dispatch () : %s\n",
                       rapi_errlist[rsvp_error]),
                      -1);
  return 0;
}

// Construct a simplified RAPI Sender TSpec object
// from an ACE_Flow_Spec. Note the form of the TSpec is
// simplified as against the full bodied IntServ version.

rapi_tspec_t *
ACE_RAPI_Session::init_tspec_simplified (const ACE_Flow_Spec &flow_spec)
{
  rapi_tspec_t *t_spec;

  ACE_NEW_RETURN (t_spec,
                  rapi_tspec_t,
                  0);

  qos_tspecx_t *ctxp = &(t_spec->tspecbody_qosx);

  // There may be some type incompatibility here.
  // Note the types of the LHS are float32_t, uint32_t etc.

  ctxp->spec_type = flow_spec.service_type ();//QOS_TSPEC;
  ctxp->xtspec_r  = flow_spec.token_rate ();           // Token Rate (B/s)
  ctxp->xtspec_b  = flow_spec.token_bucket_size ();    // Token Bucket Depth (B)
  ctxp->xtspec_p  = flow_spec.peak_bandwidth ();       // Peak Data Rate (B/s)
  ctxp->xtspec_m  = flow_spec.minimum_policed_size (); // Minimum policed unit.
  ctxp->xtspec_M  = flow_spec.max_sdu_size();          // Maximum SDU size.
  t_spec->len = sizeof(rapi_hdr_t) + sizeof(qos_tspecx_t);
  t_spec->form = RAPI_TSPECTYPE_Simplified;

  return (t_spec);
}


// Construct a simplified RAPI flowspec object from ACE_Flow_Spec.
// Note the form of the FlowSpec is simplified as against the
// full bodied IntServ version.

rapi_flowspec_t *
ACE_RAPI_Session::init_flowspec_simplified(const ACE_Flow_Spec &flow_spec)
{
  rapi_flowspec_t *flowsp;
  ACE_NEW_RETURN (flowsp,
                  rapi_flowspec_t,
                  0);

  // Extended Legacy format.
  qos_flowspecx_t *csxp = &flowsp->specbody_qosx;

  // Choose based on the service type : [QOS_GUARANTEEDX/QOS_CNTR_LOAD].

  switch (flow_spec.service_type ())
    {
    case QOS_GUARANTEEDX:
      csxp->xspec_R = 0 ; // Guaranteed Rate B/s. @@How does this map to the
                          // ACE Flow Spec Parameters.

      csxp->xspec_S = flow_spec.delay_variation () ; // Slack term in MICROSECONDS

      // Note there is no break !!

    case QOS_CNTR_LOAD:
      csxp->spec_type = flow_spec.service_type ();        // qos_service_type
      csxp->xspec_r = flow_spec.token_rate ();            // Token Bucket Average Rate (B/s)
      csxp->xspec_b = flow_spec.token_bucket_size ();     // Token Bucket Rate (B)
      csxp->xspec_p = flow_spec.peak_bandwidth ();        // Peak Data Rate (B/s)
      csxp->xspec_m = flow_spec.minimum_policed_size ();  // Minimum Policed Unit (B)

      csxp->xspec_M = flow_spec.max_sdu_size();          // Max Packet Size (B)

      flowsp->form = RAPI_FLOWSTYPE_Simplified;
      break;

    default:
      ACE_ERROR_RETURN ((LM_ERROR,
                         "(%N|%l) Unknown flowspec type: %u\n",flow_spec.service_type () ),
                        0);
    }

  flowsp->len = sizeof(rapi_flowspec_t);
  return flowsp;
}

#endif /* ACE_HAS_RAPI */

// This is a GQoS session ID generator.
int ACE_GQoS_Session::GQoS_session_id = 0;

// Constructor.
ACE_GQoS_Session::ACE_GQoS_Session (void)
{
  ACE_TRACE ("ACE_GQoS_Session::ACE_GQoS_Session");
}

// Open a GQoS session [dest IP, dest port, Protocol ID].
int
ACE_GQoS_Session::open (ACE_INET_Addr dest_addr,
                        ACE_Protocol_ID protocol_id)
{
  this->dest_addr_ = dest_addr;
  this->protocol_id_ = protocol_id;

  this->session_id_ = GQoS_session_id++;

  return 0;
}

// Close the GQoS Session.
int
ACE_GQoS_Session::close (void)
{
  // TBD.
  return 0;
}

// Set the QoS for this GQoS session.
int
ACE_GQoS_Session::qos (ACE_SOCK *socket,
                       ACE_QoS_Manager *qos_manager,
                       const ACE_QoS &ace_qos)
{

  // Confirm if the current session is one of the QoS sessions
  // subscribed to by the given socket.

  if (qos_manager->qos_session_set ().find (this) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_LIB_TEXT ("This QoS session was not subscribed to")
                       ACE_LIB_TEXT (" by the socket\n")),
                      -1);

  // Set the QOS according to the supplied ACE_QoS. The I/O control
  // code used under the hood is SIO_SET_QOS.

  u_long ret_bytes = 0;

  ACE_QoS qos = ace_qos;
  if (ACE_OS::ioctl (socket->get_handle (),
                     ACE_SIO_SET_QOS,
                     qos,
                     &ret_bytes) == -1)
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_LIB_TEXT ("Error in Qos set ACE_OS::ioctl() %d\n"),
                       ret_bytes),
                      -1);
  else
    ACE_DEBUG ((LM_DEBUG,
                ACE_LIB_TEXT ("Setting QoS with ACE_OS::ioctl () succeeds \n")));

  return 0;
}

int
ACE_GQoS_Session::update_qos (void)
{
  // WSAIoctl (GET_QOS) call goes here...
  return 0;
}

//Get the most recent RSVP event that occured
ACE_QoS_Session::RSVP_Event_Type
ACE_GQoS_Session::rsvp_event_type (void)
{
  return this->rsvp_event_type_;
}

//Set the most recent RSVP event that occured
void
ACE_GQoS_Session::rsvp_event_type (ACE_QoS_Session::RSVP_Event_Type event_type)
{
  this->rsvp_event_type_ = event_type;
}