Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

QoS_Session_Impl.cpp

Go to the documentation of this file.
00001 // QoS_Session_Impl.cpp
00002 // $Id: QoS_Session_Impl.cpp,v 1.1.1.2 2003/02/21 18:36:32 chad Exp $
00003 
00004 #include "ace/SOCK.h"
00005 #include "QoS_Manager.h"
00006 #include "QoS_Session_Impl.h"
00007 #include "ace/Log_Msg.h"
00008 
00009 #if !defined (__ACE_INLINE__)
00010 #include "QoS_Session_Impl.i"
00011 #endif /* __ACE_INLINE__ */
00012 
00013 ACE_RCSID(ace, QoS_Session_Impl, "$Id: QoS_Session_Impl.cpp,v 1.1.1.2 2003/02/21 18:36:32 chad Exp $")
00014 
00015 ACE_ALLOC_HOOK_DEFINE(ACE_QoS_Session_Impl)
00016 
00017 #if defined (ACE_HAS_RAPI)
00018 #include "rapi_err.h"
00019 
00020 int ACE_RAPI_Session::rsvp_error = 0;
00021 
00022 // Call back function used by RAPI to report RSVP events. This
00023 // function translates the RAPI QoS parameters into the more generic
00024 // ACE_QoS parameters for the underlying RAPI session.
00025 int
00026 rsvp_callback (rapi_sid_t sid,
00027                rapi_eventinfo_t eventype,
00028                int style_id,
00029                int errcode,
00030                int errvalue,
00031                sockaddr * errnode,
00032                u_char errflags,
00033                int filter_spec_no,
00034                rapi_filter_t *filter_spec_list,
00035                int flow_spec_no,
00036                rapi_flowspec_t *flow_spec_list,
00037                int ad_spec_no,
00038                rapi_adspec_t *ad_spec_list,
00039                void *args
00040                )
00041 {
00042   ACE_UNUSED_ARG (sid);
00043   ACE_UNUSED_ARG (style_id);
00044   ACE_UNUSED_ARG (filter_spec_no);
00045   ACE_UNUSED_ARG (filter_spec_list);
00046   ACE_UNUSED_ARG (ad_spec_no);
00047   ACE_UNUSED_ARG (ad_spec_list);
00048   ACE_UNUSED_ARG (errflags);
00049 
00050   if (args == 0)
00051     ACE_DEBUG ((LM_DEBUG,
00052                 "Argument in the call back function is null\n\n"));
00053 
00054   ACE_QoS_Session *qos_session = (ACE_QoS_Session *) args;
00055 
00056   qos_flowspecx_t *csxp = 0;
00057   
00058   if(!flow_spec_list)
00059     {
00060       ACE_DEBUG ((LM_DEBUG,
00061                   "(%N|%l) Null flow_spec_list\n"));
00062     }
00063   else
00064     {
00065       // Extended Legacy format.
00066       csxp = &flow_spec_list->specbody_qosx;
00067       if(!csxp)
00068         {
00069           ACE_ERROR_RETURN ((LM_ERROR,
00070                              "(%N|%l) Null csxp\n"),
00071                             -1);
00072         }
00073     }
00074   
00075   ACE_QoS ace_qos = qos_session->qos ();
00076 
00077   switch(eventype)
00078     {
00079     case RAPI_PATH_EVENT:
00080       {
00081         ACE_DEBUG ((LM_DEBUG,
00082                     "RSVP PATH Event received\n"
00083                     "No. of TSpecs received : %d %d\n",
00084                     flow_spec_no, &flow_spec_list->len));
00085 
00086         ACE_Flow_Spec *receiving_fs = 0;
00087                     
00088         if (flow_spec_no != 0)
00089           {
00090 
00091             ACE_NEW_RETURN (receiving_fs,
00092                             ACE_Flow_Spec,
00093                             -1);
00094 
00095             ACE_NEW_RETURN (receiving_fs,
00096                             ACE_Flow_Spec ((u_long)csxp->xspec_r,
00097                                            (u_long)csxp->xspec_b,
00098                                            (u_long)csxp->xspec_p,
00099                                            0,
00100                                            csxp->xspec_S,
00101                                            1,
00102                                            csxp->xspec_M,
00103                                            csxp->xspec_m,
00104                                            25,
00105                                            0),
00106                             -1);
00107         
00108             
00109             ACE_DEBUG ((LM_DEBUG,
00110                         "\nTSpec :\n"
00111                         "\t Spec Type = %d\n"
00112                         "\t Rate = %f\n"
00113                         "\t Bucket = %f\n"
00114                         "\t Peak = %f\n"
00115                         "\t MPU = %d\n"
00116                         "\t MDU = %d\n"
00117                         "\t TTL = %d\n",
00118                         csxp->spec_type,
00119                         csxp->xspec_r,
00120                         csxp->xspec_b,
00121                         csxp->xspec_p,
00122                         csxp->xspec_m,
00123                         csxp->xspec_M,
00124                         25));
00125            
00126           } 
00127         // Set the sending flowspec QoS of the given session.
00128         ace_qos.receiving_flowspec (receiving_fs);
00129 
00130         qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_PATH_EVENT);
00131 
00132       }
00133       
00134     break;
00135 
00136     case RAPI_RESV_EVENT:
00137       {       
00138         ACE_DEBUG ((LM_DEBUG,
00139                     "RSVP RESV Event received\n"
00140                     "No. of FlowSpecs received : %d\n",
00141                     flow_spec_no));
00142       
00143         ACE_Flow_Spec *sending_flow = 0;
00144         
00145         if (flow_spec_no != 0)
00146           {
00147             ACE_NEW_RETURN (sending_flow,
00148                             ACE_Flow_Spec,
00149                             -1);
00150             
00151             // Choose based on the service type : [QOS_GUARANTEEDX/QOS_CNTR_LOAD].
00152             switch (csxp->spec_type)
00153               {
00154               case QOS_GUARANTEEDX:
00155                 // Slack term in MICROSECONDS
00156                 sending_flow->delay_variation (csxp->xspec_S);
00157 
00158                 // @@How does the guaranteed rate parameter map to the ACE_Flow_Spec.
00159                 // Note there is no break !!
00160 
00161               case QOS_CNTR_LOAD:
00162 
00163                 // qos_service_type.
00164                 sending_flow->service_type (csxp->spec_type);
00165                 // Token Bucket Average Rate (B/s)
00166                 sending_flow->token_rate ((u_long)csxp->xspec_r);
00167                 // Token Bucket Rate (B)
00168                 sending_flow->token_bucket_size ((u_long)csxp->xspec_b);
00169                 // Peak Data Rate (B/s)
00170                 sending_flow->peak_bandwidth ((u_long)csxp->xspec_p);
00171                 // Minimum Policed Unit (B)
00172                 sending_flow->minimum_policed_size (csxp->xspec_m);
00173                 // Max Packet Size (B)
00174                 sending_flow->max_sdu_size (csxp->xspec_M);
00175 
00176                 break;
00177 
00178               default:
00179                 ACE_ERROR_RETURN ((LM_ERROR,
00180                                    "(%N|%l) Unknown flowspec type: %u.\n", csxp->spec_type),
00181                                   -1);
00182               };
00183           }
00184         ace_qos.sending_flowspec (sending_flow);
00185         
00186         qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_RESV_EVENT);
00187       }
00188       break;
00189       
00190     case RAPI_PATH_ERROR:
00191       {
00192         ACE_DEBUG ((LM_DEBUG,
00193                     "PATH ERROR Event received\n"
00194                     "Code=%d  Val=%d  Node= %s\n",
00195                     errcode,
00196                     errvalue,
00197                     ACE_OS::inet_ntoa(((sockaddr_in *)errnode)->sin_addr)));
00198         qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_PATH_ERROR);
00199       }
00200       break;
00201 
00202     case RAPI_RESV_ERROR:
00203       {
00204         ACE_DEBUG ((LM_DEBUG,
00205                     "RESV ERROR Event received\n"
00206                     "Code=%d  Val=%d  Node= %s\n",
00207                     errcode,
00208                     errvalue,
00209                     ACE_OS::inet_ntoa(((sockaddr_in *)errnode)->sin_addr)));
00210         qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_RESV_ERROR);
00211       }
00212       break;
00213       
00214     case RAPI_RESV_CONFIRM:
00215       {
00216         ACE_DEBUG ((LM_DEBUG,
00217                     "RESV CONFIRM Event received\n"));
00218         qos_session->rsvp_event_type (ACE_QoS_Session::RSVP_RESV_CONFIRM);
00219       }
00220       break;
00221       
00222     default:
00223       ACE_DEBUG ((LM_DEBUG,
00224                   "Unknown RSVP Event Received\n"));
00225       break;
00226 
00227     }
00228 
00229   // Set the updated ACE_QoS for the RSVP callback argument(QoS session).
00230   qos_session->qos (ace_qos);
00231 
00232   // @@ what is the meaning of the return value. RAPI docs don't say anything!
00233   return 0;
00234 }
00235 
00236 // Constructor.
00237 ACE_RAPI_Session::ACE_RAPI_Session (void)
00238 {
00239   ACE_TRACE ("ACE_RAPI_Session::ACE_RAPI_Session");
00240   this->source_port (DEFAULT_SOURCE_SENDER_PORT);
00241 }
00242 
00243 // Open a RAPI QoS session [dest IP, dest port, Protocol ID].
00244 int
00245 ACE_RAPI_Session::open (ACE_INET_Addr dest_addr,
00246                         ACE_Protocol_ID protocol_id)
00247 {
00248   ACE_DEBUG ((LM_DEBUG,
00249               "In RAPI SESSION OPEN\n"));
00250 
00251   this->dest_addr_ = dest_addr;
00252   this->protocol_id_ = protocol_id;
00253 
00254   // Open a RAPI session. Note "this" is being passed as an argument to
00255   // the callback function. The callback function uses this argument to
00256   // update the QoS of this session based on the RSVP event it receives.
00257 
00258   if ((this->session_id_ = rapi_session((struct sockaddr *) dest_addr.get_addr (),
00259                                         protocol_id,
00260                                         0,
00261                                         rsvp_callback,
00262                                         (void *) this,
00263                                         &rsvp_error)) == NULL_SID)
00264     ACE_ERROR_RETURN ((LM_ERROR,
00265                        "rapi_session () call fails. Error\n"),
00266                       -1);
00267   else
00268     ACE_DEBUG ((LM_DEBUG,
00269                 "rapi_session () call succeeds. "
00270                 "Session ID = %d\n",
00271                 this->session_id_));
00272 
00273   return 0;
00274 }
00275 
00276 // Close the RAPI QoS Session.
00277 int
00278 ACE_RAPI_Session::close (void)
00279 {
00280   this->rsvp_error = rapi_release(this->session_id_);
00281 
00282   if (rsvp_error == 0)
00283     ACE_ERROR_RETURN ((LM_ERROR,
00284                        "Can't release RSVP session:\n\t%s\n",
00285                        rapi_errlist[rsvp_error]),
00286                       -1);
00287   else
00288     ACE_DEBUG ((LM_DEBUG,
00289                 "rapi session with id %d released successfully.\n",
00290                 this->session_id_));
00291   return 0;
00292 }
00293 
00294 //Get the most recent RSVP event that occured
00295 ACE_QoS_Session::RSVP_Event_Type
00296 ACE_RAPI_Session::rsvp_event_type (void)
00297 {
00298   return this->rsvp_event_type_;
00299 }
00300 
00301 //Set the most recent RSVP event that occured
00302 void
00303 ACE_RAPI_Session::rsvp_event_type (ACE_QoS_Session::RSVP_Event_Type event_type)
00304 {
00305   this->rsvp_event_type_ = event_type;
00306 }
00307 
00308 int
00309 ACE_RAPI_Session::qos (ACE_SOCK *socket,
00310                        ACE_QoS_Manager *qos_manager,
00311                        const ACE_QoS &ace_qos)
00312 {
00313   ACE_UNUSED_ARG (socket);
00314   ACE_UNUSED_ARG (qos_manager);
00315 
00316   // If sender : call sending_qos ()
00317   // If receiver : call receiving_qos ()
00318   // If both : call sending_qos () and receiving_qos ()
00319 
00320   if (this->flags_ != ACE_QOS_RECEIVER)
00321     return this->sending_qos (ace_qos);
00322 
00323   if (this->flags_ != ACE_QOS_SENDER)
00324     return this->receiving_qos (ace_qos);
00325 
00326   return 0;
00327 }
00328 
00329 // Set sending QoS for this RAPI session.
00330 int
00331 ACE_RAPI_Session::sending_qos (const ACE_QoS &ace_qos)
00332 {
00333   ACE_Flow_Spec *sending_flowspec = ace_qos.sending_flowspec ();
00334   
00335   if (sending_flowspec == 0)
00336     {
00337       int result = rapi_sender (this->session_id_,
00338                                 0,
00339                                 0,
00340                                 NULL,
00341                                 0,
00342                                 NULL,
00343                                 NULL,
00344                                 25) ;
00345       if (result != 0)
00346         ACE_ERROR_RETURN ((LM_ERROR,
00347                            "(%N|%l) rapi_sender error %d:\n\tPATH Generation can't be started\n",
00348                            result),
00349                           -1);
00350       else
00351         ACE_DEBUG ((LM_DEBUG,
00352                     "rapi_sender () call succeeds with PATH Tear! \n"));
00353       
00354       return 0;
00355     }
00356 
00357   rapi_tspec_t *t_spec = this->init_tspec_simplified (*sending_flowspec);
00358   if (t_spec == 0)
00359     ACE_ERROR_RETURN ((LM_ERROR,
00360                        "(%N|%l) Error in translating from ACE Flow Spec to"
00361                        " RAPI TSpec\n"),
00362                       -1);
00363 
00364   char buffer[BUFSIZ];
00365 
00366   // This formats the t_spec in a visually intuitive char * that can
00367   // be printed.
00368 
00369   (void) rapi_fmt_tspec(t_spec, buffer, sizeof(buffer));
00370   ACE_DEBUG ((LM_DEBUG,
00371               "\nSender TSpec : %s\n",
00372               buffer));
00373 
00374   // Print out all the fields separately.
00375   ACE_DEBUG ((LM_DEBUG,
00376               "\nTSpec :\n"
00377               "\t Spec Type = %d\n"
00378               "\t Rate = %f\n"
00379               "\t Bucket = %f\n"
00380               "\t Peak = %f\n"
00381               "\t MPU = %d\n"
00382               "\t MDU = %d\n"
00383               "\t TTL = %d\n",
00384               t_spec->tspecbody_qosx.spec_type,
00385               t_spec->tspecbody_qosx.xtspec_r,
00386               t_spec->tspecbody_qosx.xtspec_b,
00387               t_spec->tspecbody_qosx.xtspec_p,
00388               t_spec->tspecbody_qosx.xtspec_m,
00389               t_spec->tspecbody_qosx.xtspec_M,
00390               sending_flowspec->ttl ()));
00391   
00392   // This the source sender port.
00393   ACE_INET_Addr sender_addr (this->source_port ());
00394 
00395   ACE_DEBUG ((LM_DEBUG,
00396               "Making the rapi_sender () call\n"));
00397 
00398   // Set the Sender TSpec for this QoS session.
00399 
00400   int result = rapi_sender(this->session_id_,
00401                            0,
00402                            (sockaddr *) sender_addr.get_addr (),
00403                            NULL,
00404                            t_spec,
00405                            NULL,
00406                            NULL,
00407                            sending_flowspec->ttl ()) ;
00408   
00409   if(result!= 0)
00410     ACE_ERROR_RETURN ((LM_ERROR,
00411                        "(%N|%l) rapi_sender error %d:\n\tPATH Generation can't be started\n",
00412                        result),
00413                       -1);
00414   else
00415     ACE_DEBUG ((LM_DEBUG,
00416                 "rapi_sender () call succeeds ! \n"));
00417   return 0;
00418 }
00419 
00420 // Set receiving QoS for this RAPI session.
00421 int
00422 ACE_RAPI_Session::receiving_qos (const ACE_QoS &ace_qos)
00423 {
00424 
00425   ACE_Flow_Spec *receiving_flowspec = ace_qos.receiving_flowspec ();
00426   if (receiving_flowspec == 0)
00427     {
00428       if (rapi_reserve(this->session_id_,
00429                        0,
00430                        // Setting the RAPI_REQ_CONFIRM flag requests confirmation
00431                        // of the resevation, by means of a confirmation upcall of
00432                        // type RAPI_RESV_CONFIRM.
00433                        //                   (sockaddr *)receiver_addr.get_addr (),
00434                        0,
00435                        RAPI_RSTYLE_WILDCARD,
00436                        // This applies the flowspec to all the senders. Given this,
00437                        // @@I am passing the filter_spec to be null, hoping this will work.
00438                        NULL,
00439                        NULL,
00440                        0,
00441                        NULL,
00442                        // The filter spec is NULL. This should work since the RSTYLE is
00443                        // WILDCARD.
00444                        0,
00445                        0) == -1)
00446         ACE_ERROR_RETURN ((LM_ERROR,
00447                            "(%N|%l)rapi_reserve () error:\n\tRESV Generation can't be started\n"),
00448                           -1);
00449       else
00450         ACE_DEBUG ((LM_DEBUG,
00451                     "rapi_reserve () for RESV Tear call succeeds \n"));
00452       
00453       return 0;
00454     }
00455   
00456 
00457   rapi_flowspec_t *flow_spec = init_flowspec_simplified (*receiving_flowspec);
00458 
00459   if (flow_spec == 0)
00460     ACE_ERROR_RETURN ((LM_ERROR,
00461                        "(%N|%l) Error in translating from ACE Flow Spec to"
00462                        " RAPI FlowSpec\n"),
00463                       -1);
00464 
00465   char buffer[BUFSIZ];
00466 
00467   // This formats the flow_spec in a visually intuitive char * that can
00468   // be printed.
00469   (void)rapi_fmt_flowspec(flow_spec, buffer, sizeof(buffer));
00470   ACE_DEBUG ((LM_DEBUG,
00471               "\nReceiver FlowSpec : %s\n",
00472               buffer));
00473 
00474   // Print out all the fields separately.
00475   ACE_DEBUG ((LM_DEBUG,
00476               "\nFlowSpec :\n"
00477               "\t Spec Type = %d\n"
00478               "\t Rate = %f\n"
00479               "\t Bucket = %f\n"
00480               "\t Peak = %f\n"
00481               "\t MPU = %d\n"
00482               "\t MDU = %d\n",
00483               flow_spec->specbody_qosx.spec_type,
00484               flow_spec->specbody_qosx.xspec_r,
00485               flow_spec->specbody_qosx.xspec_b,
00486               flow_spec->specbody_qosx.xspec_p,
00487               flow_spec->specbody_qosx.xspec_m,
00488               flow_spec->specbody_qosx.xspec_M));
00489 
00490   sockaddr_in Receiver_host;
00491 
00492   Receiver_host.sin_addr.s_addr = INADDR_ANY;
00493 
00494   // Set the Receiver FlowSpec for this QoS session.
00495   // @@The filter style is hardcoded to WildCard. This can be changed later.
00496   if (rapi_reserve(this->session_id_,
00497                    RAPI_REQ_CONFIRM,
00498                    // Setting the RAPI_REQ_CONFIRM flag requests confirmation
00499                    // of the resevation, by means of a confirmation upcall of
00500                    // type RAPI_RESV_CONFIRM.
00501                    //                   (sockaddr *)receiver_addr.get_addr (),
00502                    (sockaddr *)&Receiver_host,
00503                    RAPI_RSTYLE_WILDCARD,
00504                    // This applies the flowspec to all the senders. Given this,
00505                    // @@I am passing the filter_spec to be null, hoping this will work.
00506                    NULL,
00507                    NULL,
00508                    0,
00509                    NULL,
00510                    // The filter spec is NULL. This should work since the RSTYLE is
00511                    // WILDCARD.
00512                    1,
00513                    flow_spec) == -1)
00514     ACE_ERROR_RETURN ((LM_ERROR,
00515                        "rapi_reserve () error:\n\tRESV Generation can't be started\n"),
00516                       -1);
00517   else
00518     ACE_DEBUG ((LM_DEBUG,
00519                 "rapi_reserve () call succeeds \n"));
00520 
00521   return 0;
00522 }
00523 
00524 int
00525 ACE_RAPI_Session::update_qos (void)
00526 {
00527   // Update the session QoS Parameters based on the RSVP Event Received.
00528   if ((rsvp_error = rapi_dispatch ()) != 0)
00529     ACE_ERROR_RETURN ((LM_ERROR,
00530                        "Error in rapi_dispatch () : %s\n",
00531                        rapi_errlist[rsvp_error]),
00532                       -1);
00533   return 0;
00534 }
00535 
00536 // Construct a simplified RAPI Sender TSpec object
00537 // from an ACE_Flow_Spec. Note the form of the TSpec is
00538 // simplified as against the full bodied IntServ version.
00539 
00540 rapi_tspec_t *
00541 ACE_RAPI_Session::init_tspec_simplified (const ACE_Flow_Spec &flow_spec)
00542 {
00543   rapi_tspec_t *t_spec;
00544 
00545   ACE_NEW_RETURN (t_spec,
00546                   rapi_tspec_t,
00547                   0);
00548 
00549   qos_tspecx_t *ctxp = &(t_spec->tspecbody_qosx);
00550 
00551   // There may be some type incompatibility here.
00552   // Note the types of the LHS are float32_t, uint32_t etc.
00553 
00554   ctxp->spec_type = flow_spec.service_type ();//QOS_TSPEC;
00555   ctxp->xtspec_r  = flow_spec.token_rate ();           // Token Rate (B/s)
00556   ctxp->xtspec_b  = flow_spec.token_bucket_size ();    // Token Bucket Depth (B)
00557   ctxp->xtspec_p  = flow_spec.peak_bandwidth ();       // Peak Data Rate (B/s)
00558   ctxp->xtspec_m  = flow_spec.minimum_policed_size (); // Minimum policed unit.
00559   ctxp->xtspec_M  = flow_spec.max_sdu_size();          // Maximum SDU size.
00560   t_spec->len = sizeof(rapi_hdr_t) + sizeof(qos_tspecx_t);
00561   t_spec->form = RAPI_TSPECTYPE_Simplified;
00562 
00563   return (t_spec);
00564 }
00565 
00566 
00567 // Construct a simplified RAPI flowspec object from ACE_Flow_Spec.
00568 // Note the form of the FlowSpec is simplified as against the
00569 // full bodied IntServ version.
00570 
00571 rapi_flowspec_t *
00572 ACE_RAPI_Session::init_flowspec_simplified(const ACE_Flow_Spec &flow_spec)
00573 {
00574   rapi_flowspec_t *flowsp;
00575   ACE_NEW_RETURN (flowsp,
00576                   rapi_flowspec_t,
00577                   0);
00578 
00579   // Extended Legacy format.
00580   qos_flowspecx_t *csxp = &flowsp->specbody_qosx;
00581 
00582   // Choose based on the service type : [QOS_GUARANTEEDX/QOS_CNTR_LOAD].
00583 
00584   switch (flow_spec.service_type ())
00585     {
00586     case QOS_GUARANTEEDX:
00587       csxp->xspec_R = 0 ; // Guaranteed Rate B/s. @@How does this map to the
00588                           // ACE Flow Spec Parameters.
00589 
00590       csxp->xspec_S = flow_spec.delay_variation () ; // Slack term in MICROSECONDS
00591 
00592       // Note there is no break !!
00593 
00594     case QOS_CNTR_LOAD:
00595       csxp->spec_type = flow_spec.service_type ();        // qos_service_type
00596       csxp->xspec_r = flow_spec.token_rate ();            // Token Bucket Average Rate (B/s)
00597       csxp->xspec_b = flow_spec.token_bucket_size ();     // Token Bucket Rate (B)
00598       csxp->xspec_p = flow_spec.peak_bandwidth ();        // Peak Data Rate (B/s)
00599       csxp->xspec_m = flow_spec.minimum_policed_size ();  // Minimum Policed Unit (B)
00600 
00601       csxp->xspec_M = flow_spec.max_sdu_size();          // Max Packet Size (B)
00602 
00603       flowsp->form = RAPI_FLOWSTYPE_Simplified;
00604       break;
00605 
00606     default:
00607       ACE_ERROR_RETURN ((LM_ERROR,
00608                          "(%N|%l) Unknown flowspec type: %u\n",flow_spec.service_type () ),
00609                         0);
00610     }
00611 
00612   flowsp->len = sizeof(rapi_flowspec_t);
00613   return flowsp;
00614 }
00615 
00616 #endif /* ACE_HAS_RAPI */
00617 
00618 // This is a GQoS session ID generator.
00619 int ACE_GQoS_Session::GQoS_session_id = 0;
00620 
00621 // Constructor.
00622 ACE_GQoS_Session::ACE_GQoS_Session (void)
00623 {
00624   ACE_TRACE ("ACE_GQoS_Session::ACE_GQoS_Session");
00625 }
00626 
00627 // Open a GQoS session [dest IP, dest port, Protocol ID].
00628 int
00629 ACE_GQoS_Session::open (ACE_INET_Addr dest_addr,
00630                         ACE_Protocol_ID protocol_id)
00631 {
00632   this->dest_addr_ = dest_addr;
00633   this->protocol_id_ = protocol_id;
00634 
00635   this->session_id_ = GQoS_session_id++;
00636 
00637   return 0;
00638 }
00639 
00640 // Close the GQoS Session.
00641 int
00642 ACE_GQoS_Session::close (void)
00643 {
00644   // TBD.
00645   return 0;
00646 }
00647 
00648 // Set the QoS for this GQoS session.
00649 int
00650 ACE_GQoS_Session::qos (ACE_SOCK *socket,
00651                        ACE_QoS_Manager *qos_manager,
00652                        const ACE_QoS &ace_qos)
00653 {
00654 
00655   // Confirm if the current session is one of the QoS sessions
00656   // subscribed to by the given socket.
00657 
00658   if (qos_manager->qos_session_set ().find (this) == -1)
00659     ACE_ERROR_RETURN ((LM_ERROR,
00660                        ACE_LIB_TEXT ("This QoS session was not subscribed to")
00661                        ACE_LIB_TEXT (" by the socket\n")),
00662                       -1);
00663 
00664   // Set the QOS according to the supplied ACE_QoS. The I/O control
00665   // code used under the hood is SIO_SET_QOS.
00666 
00667   u_long ret_bytes = 0;
00668 
00669   ACE_QoS qos = ace_qos;
00670   if (ACE_OS::ioctl (socket->get_handle (),
00671                      ACE_SIO_SET_QOS,
00672                      qos,
00673                      &ret_bytes) == -1)
00674     ACE_ERROR_RETURN ((LM_ERROR,
00675                        ACE_LIB_TEXT ("Error in Qos set ACE_OS::ioctl() %d\n"),
00676                        ret_bytes),
00677                       -1);
00678   else
00679     ACE_DEBUG ((LM_DEBUG,
00680                 ACE_LIB_TEXT ("Setting QoS with ACE_OS::ioctl () succeeds \n")));
00681 
00682   return 0;
00683 }
00684 
00685 int
00686 ACE_GQoS_Session::update_qos (void)
00687 {
00688   // WSAIoctl (GET_QOS) call goes here...
00689   return 0;
00690 }
00691 
00692 //Get the most recent RSVP event that occured
00693 ACE_QoS_Session::RSVP_Event_Type
00694 ACE_GQoS_Session::rsvp_event_type (void)
00695 {
00696   return this->rsvp_event_type_;
00697 }
00698 
00699 //Set the most recent RSVP event that occured
00700 void
00701 ACE_GQoS_Session::rsvp_event_type (ACE_QoS_Session::RSVP_Event_Type event_type)
00702 {
00703   this->rsvp_event_type_ = event_type;
00704 }

Generated on Mon Jun 16 13:17:26 2003 for ACE_QoS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002