QoS_Session_Impl.cpp

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

Generated on Tue Feb 2 17:36:39 2010 for ACE_QoS by  doxygen 1.4.7