FlowSpec_Entry.cpp

Go to the documentation of this file.
00001 // $Id: FlowSpec_Entry.cpp 81499 2008-04-28 17:58:17Z johnnyw $
00002 
00003 //------------------------------------------------------------
00004 // TAO_FlowSpec_Entry
00005 //------------------------------------------------------------
00006 
00007 #include "orbsvcs/AV/FlowSpec_Entry.h"
00008 #include "orbsvcs/AV/Protocol_Factory.h"
00009 
00010 #include "tao/debug.h"
00011 
00012 #include "ace/OS_NS_strings.h"
00013 
00014 #if !defined (__ACE_INLINE__)
00015 #include "orbsvcs/AV/FlowSpec_Entry.inl"
00016 #endif /* __ACE_INLINE__ */
00017 
00018 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00019 
00020 // constructor.
00021 TAO_FlowSpec_Entry::TAO_FlowSpec_Entry (void)
00022   :address_ (0),
00023    clean_up_address_ (0),
00024    control_address_ (0),
00025    clean_up_control_address_ (0),
00026    address_str_ (),
00027    format_ (),
00028    direction_ (TAO_AV_INVALID),
00029    direction_str_ (),
00030    flowname_ (),
00031    protocol_ (TAO_AV_Core::TAO_AV_NOPROTOCOL),
00032    carrier_protocol_ (),
00033    flow_protocol_ (),
00034    use_flow_protocol_ (0),
00035    entry_ (),
00036    is_multicast_ (0),
00037    delete_peer_addr_ (false),
00038    peer_addr_ (0),
00039    local_sec_addr_ (0),
00040    num_local_sec_addrs_ (0),
00041    peer_sec_addr_ (0),
00042    num_peer_sec_addrs_ (0),
00043    peer_control_addr_ (0),
00044    local_addr_ (0),
00045    local_control_addr_ (0),
00046    transport_ (0),
00047    control_transport_ (0),
00048    handler_ (0),
00049    control_handler_ (0),
00050    protocol_object_ (0),
00051    control_protocol_object_ (0),
00052    role_ (TAO_AV_INVALID_ROLE)
00053 {
00054 }
00055 
00056 // constructor.
00057 TAO_FlowSpec_Entry::TAO_FlowSpec_Entry (const char *flowname,
00058                                         const char *direction,
00059                                         const char *format_name,
00060                                         const char *flow_protocol,
00061                                         const char *carrier_protocol,
00062                                         ACE_Addr *fwd_address,
00063                                         //ACE_Addr *peer_address,
00064                                         ACE_Addr *control_address)
00065   :address_ (fwd_address),
00066    clean_up_address_ (0),
00067    control_address_ (control_address),
00068    clean_up_control_address_ (0),
00069    address_str_ (),
00070    format_ (format_name),
00071    direction_str_ (), // This is initialized in the call to set_direction()
00072    flowname_ ( flowname ),
00073    carrier_protocol_ ( carrier_protocol ),
00074    flow_protocol_ ( flow_protocol ),
00075    use_flow_protocol_ (0),
00076    entry_ (),
00077    is_multicast_ (0),
00078    delete_peer_addr_ (false),
00079    peer_addr_ (0),
00080    local_sec_addr_ (0),
00081    num_local_sec_addrs_ (0),
00082    peer_sec_addr_ (0),
00083    num_peer_sec_addrs_ (0),
00084    peer_control_addr_ (0),
00085    local_addr_ (0),
00086    local_control_addr_ (0),
00087    transport_ (0),
00088    control_transport_ (0),
00089    handler_ (0),
00090    control_handler_ (0),
00091    protocol_object_ (0),
00092    control_protocol_object_ (0),
00093    role_ (TAO_AV_INVALID_ROLE)
00094 {
00095   this->set_protocol ();
00096   this->set_direction (direction);
00097   this->parse_flow_protocol_string (this->flow_protocol_.c_str());
00098 }
00099 
00100 TAO_FlowSpec_Entry::TAO_FlowSpec_Entry (const char *flowname,
00101                                         const char *direction,
00102                                         const char *format_name,
00103                                         const char *flow_protocol,
00104                                         const char *address)
00105   :address_ (0),
00106    clean_up_address_ (0),
00107    control_address_ (0),
00108    clean_up_control_address_ (0),
00109    address_str_ ( address ),
00110    format_ ( format_name ),
00111    direction_str_ (), // This is initialized in the call to set_direction()
00112    flowname_ ( flowname ),
00113    carrier_protocol_ (),
00114    flow_protocol_ ( flow_protocol ),
00115    use_flow_protocol_ (0),
00116    entry_ (),
00117    is_multicast_ (0),
00118    peer_addr_ (0),
00119    local_sec_addr_ (0),
00120    num_local_sec_addrs_ (0),
00121    peer_sec_addr_ (0),
00122    num_peer_sec_addrs_ (0),
00123    peer_control_addr_ (0),
00124    local_addr_ (0),
00125    local_control_addr_ (0),
00126    transport_ (0),
00127    control_transport_ (0),
00128    handler_ (0),
00129    control_handler_ (0),
00130    protocol_object_ (0),
00131    control_protocol_object_ (0),
00132    role_ (TAO_AV_INVALID_ROLE)
00133 {
00134   this->parse_flow_protocol_string (this->flow_protocol_.c_str() );
00135   this->parse_address (this->address_str_.c_str(), TAO_AV_Core::TAO_AV_DATA);
00136   this->set_direction (direction);
00137 }
00138 
00139 // Destructor.
00140 TAO_FlowSpec_Entry::~TAO_FlowSpec_Entry (void)
00141 {
00142   if (this->delete_peer_addr_)
00143     delete this->peer_addr_;
00144 
00145   if (this->clean_up_address_)
00146     delete address_;
00147   if (this->clean_up_control_address_)
00148     delete control_address_;
00149   if (local_control_addr_ != 0)
00150     delete local_control_addr_;
00151 }
00152 
00153 int
00154 TAO_FlowSpec_Entry::set_protocol (void)
00155 {
00156   if (!this->use_flow_protocol_)
00157     {
00158       if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"TCP") == 0)
00159         this->protocol_ = TAO_AV_Core::TAO_AV_TCP;
00160       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"SCTP_SEQ") == 0)
00161           this->protocol_ = TAO_AV_Core::TAO_AV_SCTP_SEQ;
00162       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"UDP") == 0)
00163           this->protocol_ = TAO_AV_Core::TAO_AV_UDP;
00164       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"QoS_UDP") == 0)
00165         this->protocol_ = TAO_AV_Core::TAO_AV_QOS_UDP;
00166       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"AAL5") == 0)
00167         this->protocol_ = TAO_AV_Core::TAO_AV_AAL5;
00168       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"AAL3_4") == 0)
00169         this->protocol_ = TAO_AV_Core::TAO_AV_AAL3_4;
00170       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"AAL1") == 0)
00171         this->protocol_ = TAO_AV_Core::TAO_AV_AAL1;
00172       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"RTP/UDP") == 0){
00173         this->protocol_ = TAO_AV_Core::TAO_AV_UDP;
00174         flow_protocol_ = "RTP";
00175       }
00176       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"RTP/AAL5") == 0)
00177         this->protocol_ = TAO_AV_Core::TAO_AV_RTP_AAL5;
00178       else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"IPX") == 0)
00179         this->protocol_ = TAO_AV_Core::TAO_AV_IPX;
00180       else
00181         {
00182           this->protocol_ = TAO_AV_Core::TAO_AV_NOPROTOCOL;
00183           return -1;
00184         }
00185     }
00186   else
00187     {
00188       if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"UDP") == 0)
00189         {
00190           if (ACE_OS::strncasecmp (this->flow_protocol_.c_str (),"sfp",3) == 0)
00191             {
00192               this->protocol_ = TAO_AV_Core::TAO_AV_SFP_UDP;
00193             }
00194           else this->protocol_ = TAO_AV_Core::TAO_AV_USERDEFINED_UDP;
00195         }
00196       else
00197         {
00198           this->protocol_ = TAO_AV_Core::TAO_AV_NOPROTOCOL;
00199           return -1;
00200         }
00201     }
00202 
00203   if (this->address_ != 0)
00204     {
00205       if (TAO_debug_level > 0)
00206         ACE_DEBUG ((LM_DEBUG, "TAO_FlowSpec_Entry::set_protocol address is not 0\n"));
00207       ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (this->address_);
00208       char buf[BUFSIZ];
00209       inet_addr->addr_to_string (buf,BUFSIZ);
00210       if (TAO_debug_level > 0)
00211         ACE_DEBUG ((LM_DEBUG,"TAO_FlowSpec_Entry::set_protocol:%s %x\n",buf, inet_addr->get_ip_address ()));
00212       if (IN_CLASSD (inet_addr->get_ip_address ()))
00213         {
00214           this->is_multicast_ = 1;
00215           switch (this->protocol_)
00216             {
00217             case TAO_AV_Core::TAO_AV_UDP:
00218               this->protocol_ = TAO_AV_Core::TAO_AV_UDP_MCAST;
00219               break;
00220             case TAO_AV_Core::TAO_AV_RTP_UDP:
00221               this->protocol_ = TAO_AV_Core::TAO_AV_RTP_UDP_MCAST;
00222               break;
00223             case TAO_AV_Core::TAO_AV_SFP_UDP:
00224               this->protocol_ = TAO_AV_Core::TAO_AV_SFP_UDP_MCAST;
00225               break;
00226             case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00227               this->protocol_ = TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST;
00228               break;
00229             default:
00230               break;
00231             }
00232         }
00233     }
00234   return 0;
00235 }
00236 
00237 int
00238 TAO_FlowSpec_Entry::parse_address (const char *address,
00239                                    TAO_AV_Core::Flow_Component flow_comp)
00240 {
00241   if (TAO_debug_level > 0)
00242     ACE_DEBUG ((LM_DEBUG, "TAO_FlowSpec_Entry::parse_address [%s]\n", address));
00243 
00244   if (address == 0)
00245     return 0;
00246   if (ACE_OS::strcmp (address,"") == 0)
00247     return 0;
00248   TAO_Tokenizer protocol_tokenizer (address,'=');
00249 
00250   this->carrier_protocol_ = protocol_tokenizer[0];
00251 
00252   int result = this->set_protocol ();
00253   if (result < 0)
00254     return result;
00255 
00256   if (protocol_tokenizer [1] != 0)
00257     {
00258       ACE_DEBUG ((LM_DEBUG,
00259                   "Protocol tokenixer is not null\n"));
00260       if ((flow_comp == TAO_AV_Core::TAO_AV_DATA) ||
00261           //(flow_comp == TAO_AV_Core::TAO_AV_BOTH) ||
00262           (flow_comp == TAO_AV_Core::TAO_AV_CONTROL) )
00263         {
00264           ACE_CString addr;
00265           if (this->protocol_ == TAO_AV_Core::TAO_AV_SCTP_SEQ)
00266             {
00267               TAO_Tokenizer addr_token (protocol_tokenizer [1], ';');
00268 
00269               ACE_DEBUG ((LM_DEBUG,
00270                           "Number of local sec addresses = %d\n",
00271                           addr_token.num_tokens () - 1));
00272 
00273               if (addr_token.num_tokens () != 0)
00274                 {
00275                   addr += addr_token [0];
00276                   ACE_NEW_RETURN (local_sec_addr_, char* [addr_token.num_tokens () - 1],-1);
00277                   for (int j = 1; j <= addr_token.num_tokens () - 1; j++)
00278                     {
00279                       ACE_DEBUG ((LM_DEBUG,
00280                                   "adding addresses to sequence %s\n",
00281                                   addr_token [j]));
00282 
00283                       local_sec_addr_ [j-1] =  CORBA::string_dup (addr_token [j]);
00284                     }
00285                   num_local_sec_addrs_ = addr_token.num_tokens () - 1;
00286                 }
00287             }
00288           else addr += protocol_tokenizer[1];
00289 
00290 
00291           switch (this->protocol_)
00292             {
00293             case TAO_AV_Core::TAO_AV_SFP_UDP:
00294             case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00295             case TAO_AV_Core::TAO_AV_RTP_UDP:
00296             case TAO_AV_Core::TAO_AV_TCP:
00297             case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00298             case TAO_AV_Core::TAO_AV_UDP:
00299             case TAO_AV_Core::TAO_AV_QOS_UDP:
00300               {
00301                 if (flow_comp == TAO_AV_Core::TAO_AV_DATA)
00302                   this->address_str_ = addr;
00303                 ACE_INET_Addr *inet_addr;
00304                 ACE_NEW_RETURN (inet_addr,
00305                                 ACE_INET_Addr (addr.c_str() ),
00306                                 -1);
00307                 if (flow_comp == TAO_AV_Core::TAO_AV_DATA)
00308                   {
00309                     this->clean_up_address_ = 1;
00310                     this->address_ = inet_addr;
00311                   }
00312                 else
00313                   {
00314                     this->clean_up_control_address_ = 1;
00315                     this->control_address_ = inet_addr;
00316                   }
00317 
00318                 if (IN_CLASSD (inet_addr->get_ip_address ()))
00319                   {
00320                     if (TAO_debug_level > 0)
00321                       ACE_DEBUG ((LM_DEBUG, "TAO_FlowSpec_Entry::parse_address is multicast\n"));
00322 
00323                     this->is_multicast_ = 1;
00324                     switch (this->protocol_)
00325                       {
00326                       case TAO_AV_Core::TAO_AV_UDP:
00327                         this->protocol_ = TAO_AV_Core::TAO_AV_UDP_MCAST;
00328                         break;
00329                       case TAO_AV_Core::TAO_AV_RTP_UDP:
00330                         this->protocol_ = TAO_AV_Core::TAO_AV_RTP_UDP_MCAST;
00331                         break;
00332                       case TAO_AV_Core::TAO_AV_SFP_UDP:
00333                         this->protocol_ = TAO_AV_Core::TAO_AV_SFP_UDP_MCAST;
00334                         break;
00335                       case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00336                         this->protocol_ = TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST;
00337                         break;
00338                       default:
00339                         break;
00340                       }
00341                   }
00342               }
00343               break;
00344             default:
00345               if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"ATM support not added yet\n"));
00346             }
00347         }
00348       else
00349         {
00350           ACE_DEBUG ((LM_DEBUG,
00351                       "AV BOTH %s \n",
00352                       protocol_tokenizer[1]));
00353 
00354           TAO_Tokenizer address_tokenizer (protocol_tokenizer[1], ':');
00355           TAO_Tokenizer port_tokenizer (address_tokenizer[1], ';');
00356           ACE_CString addr;
00357           addr += address_tokenizer[0];
00358           addr += ":";
00359           addr += port_tokenizer[0];
00360 
00361           if (this->protocol_ == TAO_AV_Core::TAO_AV_SCTP_SEQ)
00362             {
00363               ACE_DEBUG ((LM_DEBUG,
00364                           "Number of local sec addresses = %d\n",
00365                           port_tokenizer.num_tokens () - 1));
00366 
00367               if (port_tokenizer.num_tokens () - 1 != 0)
00368                 {
00369                   ACE_NEW_RETURN (local_sec_addr_, char* [port_tokenizer.num_tokens () - 1],-1);
00370                   for (int j = 1; j <= port_tokenizer.num_tokens () - 1; j++)
00371                     {
00372                       ACE_DEBUG ((LM_DEBUG,
00373                                   "adding addresses to sequence %s\n",
00374                                   port_tokenizer [j]));
00375 
00376                       local_sec_addr_ [j-1] =  CORBA::string_dup (port_tokenizer [j]);
00377                     }
00378                   num_local_sec_addrs_ = port_tokenizer.num_tokens () - 1;
00379                 }
00380             }
00381 
00382           short control_port = static_cast<short> (ACE_OS::atoi(port_tokenizer[0])) + 1;
00383           char control_port_str[6];
00384           ACE_OS::sprintf (control_port_str, "%d", control_port);
00385 
00386           ACE_CString control_addr = "";
00387           if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"RTP/UDP") == 0)
00388             {
00389               control_addr += address_tokenizer[0];
00390               control_addr += ":";
00391               if (port_tokenizer[1] != 0)
00392                 control_addr += port_tokenizer[1];
00393               else
00394                 control_addr += control_port_str;
00395             }
00396 
00397           switch (this->protocol_)
00398             {
00399             case TAO_AV_Core::TAO_AV_SFP_UDP:
00400             case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00401             case TAO_AV_Core::TAO_AV_RTP_UDP:
00402             case TAO_AV_Core::TAO_AV_TCP:
00403             case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00404             case TAO_AV_Core::TAO_AV_UDP:
00405             case TAO_AV_Core::TAO_AV_QOS_UDP:
00406               {
00407                 this->address_str_ = addr;
00408                 ACE_INET_Addr *inet_addr;
00409                 ACE_NEW_RETURN (inet_addr,
00410                                 ACE_INET_Addr (addr.c_str() ),
00411                                 -1);
00412                 this->clean_up_address_ = 1;
00413                 this->address_ = inet_addr;
00414 
00415                 if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"RTP/UDP") == 0)
00416                   {
00417                     ACE_INET_Addr *control_inet_addr;
00418                     ACE_NEW_RETURN (control_inet_addr,
00419                                     ACE_INET_Addr (control_addr.c_str() ),
00420                                     -1);
00421                     this->clean_up_control_address_ = 1;
00422                     this->control_address_ = control_inet_addr;
00423                   }
00424 
00425                 if (IN_CLASSD (inet_addr->get_ip_address ()))
00426                   {
00427                     if (TAO_debug_level > 0)
00428                       ACE_DEBUG ((LM_DEBUG, "TAO_FlowSpec_Entry::parse_address is multicast\n"));
00429 
00430                     this->is_multicast_ = 1;
00431                     switch (this->protocol_)
00432                       {
00433                       case TAO_AV_Core::TAO_AV_UDP:
00434                         this->protocol_ = TAO_AV_Core::TAO_AV_UDP_MCAST;
00435                         break;
00436                       case TAO_AV_Core::TAO_AV_RTP_UDP:
00437                         this->protocol_ = TAO_AV_Core::TAO_AV_RTP_UDP_MCAST;
00438                         break;
00439                       case TAO_AV_Core::TAO_AV_SFP_UDP:
00440                         this->protocol_ = TAO_AV_Core::TAO_AV_SFP_UDP_MCAST;
00441                         break;
00442                       case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00443                         this->protocol_ = TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST;
00444                         break;
00445                       default:
00446                         break;
00447                       }
00448                   }
00449               }
00450               break;
00451             default:
00452               if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"ATM support not added yet\n"));
00453             }
00454         }
00455     }
00456   ACE_DEBUG ((LM_DEBUG,
00457               "Return from parse address\n"));
00458   return 0;
00459 }
00460 
00461 char *
00462 TAO_FlowSpec_Entry::get_local_addr_str (void)
00463 {
00464   if (this->local_addr_ == 0)
00465     return 0;
00466 
00467   switch (this->local_addr_->get_type ())
00468     {
00469     case AF_INET:
00470       {
00471         char *buf;
00472         ACE_NEW_RETURN (buf,
00473                         char [BUFSIZ],
00474                         0);
00475 
00476         ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr *> (this->local_addr_);
00477         inet_addr->addr_to_string (buf,BUFSIZ);
00478         ACE_CString cstring (buf, 0, false);
00479 
00480         return cstring.rep ();
00481       }
00482     default:
00483       ACE_ERROR_RETURN ((LM_ERROR,"Address family not supported"),0);
00484     }
00485 }
00486 
00487 //------------------------------------------------------------
00488 // TAO_Forward_FlowSpec_Entry
00489 //------------------------------------------------------------
00490 
00491 // default constructor.
00492 TAO_Forward_FlowSpec_Entry::TAO_Forward_FlowSpec_Entry (void)
00493 {
00494   // no-op.
00495 }
00496 
00497 // constructor to construct the entry from the arguments.
00498 TAO_Forward_FlowSpec_Entry::TAO_Forward_FlowSpec_Entry (const char *flowname,
00499                                                         const char *direction,
00500                                                         const char *format_name ,
00501                                                         const char *flow_protocol ,
00502                                                         const char *carrier_protocol ,
00503                                                         ACE_Addr *address,
00504                                                         ACE_Addr *control_address )
00505   :TAO_FlowSpec_Entry (flowname,
00506                        direction,
00507                        format_name,
00508                        flow_protocol,
00509                        carrier_protocol,
00510                        address,
00511                        control_address)
00512 {
00513   // no-op.
00514 }
00515 
00516 // constructor to construct the entry from the arguments.
00517 TAO_Forward_FlowSpec_Entry::TAO_Forward_FlowSpec_Entry (const char *flowname,
00518                                                         const char *direction,
00519                                                         const char *format_name ,
00520                                                         const char *flow_protocol ,
00521                                                         const char *address )
00522   :TAO_FlowSpec_Entry (flowname,
00523                        direction,
00524                        format_name,
00525                        flow_protocol,
00526                        address)
00527 {
00528   // no-op.
00529 }
00530 
00531 TAO_Forward_FlowSpec_Entry::~TAO_Forward_FlowSpec_Entry (void)
00532 {
00533   // no-op.
00534 }
00535 
00536 int
00537 TAO_Forward_FlowSpec_Entry::parse (const char *flowSpec_entry)
00538 {
00539   TAO_Tokenizer tokenizer (flowSpec_entry,'\\');
00540 
00541   this->flowname_ = tokenizer [TAO_AV_FLOWNAME];
00542 
00543   if (TAO_debug_level > 0)
00544       ACE_DEBUG ((LM_DEBUG,
00545                   "TAO_Forward_FlowSpec_Entry::parse [%s]\n",
00546                   flowSpec_entry));
00547 
00548   if (tokenizer [TAO_AV_DIRECTION] != 0)
00549     this->set_direction (tokenizer [TAO_AV_DIRECTION]);
00550 
00551   if (tokenizer [TAO_AV_FORMAT] != 0)
00552     this->format_ = tokenizer [TAO_AV_FORMAT];
00553 
00554   if (tokenizer [TAO_AV_ADDRESS] != 0)
00555     if (this->parse_address (tokenizer [TAO_AV_ADDRESS], TAO_AV_Core::TAO_AV_BOTH) < 0)
00556       return -1;
00557 
00558   if (tokenizer [TAO_AV_PEER_ADDR] != 0)
00559     {
00560       ACE_INET_Addr *addr = 0;
00561 
00562 
00563       if (this->protocol_ == TAO_AV_Core::TAO_AV_SCTP_SEQ)
00564         {
00565           TAO_Tokenizer addr_token (tokenizer [TAO_AV_PEER_ADDR], ';');
00566 
00567           ACE_DEBUG ((LM_DEBUG,
00568                       "Number of peer sec addresses = %d\n",
00569                       addr_token.num_tokens () - 1));
00570 
00571           if (addr_token.num_tokens () != 0)
00572             {
00573               ACE_NEW_RETURN (addr,
00574                               ACE_INET_Addr (addr_token [0]),
00575                               0);
00576 
00577               ACE_NEW_RETURN (peer_sec_addr_, char* [addr_token.num_tokens () - 1],-1);
00578               for (int j = 1; j <= addr_token.num_tokens () - 1; j++)
00579                 {
00580                   ACE_DEBUG ((LM_DEBUG,
00581                               "adding addresses to sequence %s\n",
00582                               addr_token [j]));
00583 
00584                   peer_sec_addr_ [j-1] =  CORBA::string_dup (addr_token [j]);
00585                 }
00586               num_peer_sec_addrs_ = addr_token.num_tokens () - 1;
00587             }
00588         }
00589       else
00590         {
00591           ACE_NEW_RETURN (addr,
00592                           ACE_INET_Addr (tokenizer [TAO_AV_PEER_ADDR]),
00593                           0);
00594         }
00595       this->delete_peer_addr_ = true;
00596       this->peer_addr_ = addr;
00597 
00598       char buf [BUFSIZ];
00599       addr->addr_to_string (buf, BUFSIZ);
00600       ACE_DEBUG ((LM_DEBUG,
00601                   "Peer Address %s \n",
00602                   buf));
00603 
00604     }
00605 
00606   if (tokenizer [TAO_AV_FLOW_PROTOCOL] != 0)
00607     if (this->parse_flow_protocol_string (tokenizer [TAO_AV_FLOW_PROTOCOL]) < 0)
00608       return -1;
00609 
00610   return 0;
00611 }
00612 
00613 TAO_FlowSpec_Entry::Role
00614 TAO_Forward_FlowSpec_Entry::role (void)
00615 {
00616   if (this->role_ != TAO_AV_INVALID_ROLE)
00617     return this->role_;
00618 
00619   switch (this->direction_)
00620     {
00621     case TAO_AV_DIR_IN:
00622       // Forward IN means we're the Source.
00623       return TAO_AV_PRODUCER;
00624     case TAO_AV_DIR_OUT:
00625       // Forward out means we're the sink.
00626       return TAO_AV_CONSUMER;
00627     default:
00628       return TAO_AV_INVALID_ROLE;
00629     }
00630 }
00631 
00632 const char *
00633 TAO_Forward_FlowSpec_Entry::entry_to_string (void)
00634 {
00635   if (this->flowname_.length() == 0)
00636     return "";
00637 
00638   char address [BUFSIZ];
00639   ACE_CString address_str;
00640   ACE_CString peer_address_str;
00641 
00642   if (this->address_ != 0)
00643     {
00644       switch (this->protocol_)
00645         {
00646         case TAO_AV_Core::TAO_AV_SFP_UDP:
00647         case TAO_AV_Core::TAO_AV_SFP_UDP_MCAST:
00648         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00649         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST:
00650         case TAO_AV_Core::TAO_AV_RTP_UDP:
00651         case TAO_AV_Core::TAO_AV_RTP_UDP_MCAST:
00652         case TAO_AV_Core::TAO_AV_UDP:
00653         case TAO_AV_Core::TAO_AV_QOS_UDP:
00654         case TAO_AV_Core::TAO_AV_UDP_MCAST:
00655         case TAO_AV_Core::TAO_AV_TCP:
00656         case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00657           {
00658             ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (this->address_);
00659             inet_addr->addr_to_string (address,BUFSIZ);
00660           }
00661           break;
00662         default:
00663           break;
00664         }
00665       ACE_CString cstring (address);
00666 
00667       address_str = this->carrier_protocol_;
00668       address_str += "=";
00669       address_str += cstring;
00670 
00671       if (this->protocol_ == TAO_AV_Core::TAO_AV_SCTP_SEQ)
00672         {
00673           for (int i = 0; i < this->num_local_sec_addrs_; i++)
00674             {
00675               address_str += ";";
00676               address_str += this->local_sec_addr_ [i];
00677             }
00678         }
00679 
00680     }
00681   else
00682     {
00683       address_str = this->carrier_protocol_;
00684     }
00685 
00686 
00687   if ( (this->address_ != 0) &&
00688        (this->control_address_ == 0) &&
00689        (ACE_OS::strncasecmp (this->flow_protocol_.c_str(), "RTP", 3) == 0))
00690     {
00691       u_short control_port;
00692 
00693       switch (this->protocol_)
00694         {
00695         case TAO_AV_Core::TAO_AV_SFP_UDP:
00696         case TAO_AV_Core::TAO_AV_SFP_UDP_MCAST:
00697         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00698         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST:
00699         case TAO_AV_Core::TAO_AV_RTP_UDP:
00700         case TAO_AV_Core::TAO_AV_RTP_UDP_MCAST:
00701         case TAO_AV_Core::TAO_AV_UDP:
00702         case TAO_AV_Core::TAO_AV_QOS_UDP:
00703         case TAO_AV_Core::TAO_AV_UDP_MCAST:
00704         case TAO_AV_Core::TAO_AV_TCP:
00705         case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00706           {
00707             ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (this->address_);
00708             control_port = inet_addr->get_port_number() + 1;
00709             ACE_INET_Addr *inet_control_addr;
00710             ACE_NEW_RETURN (inet_control_addr,
00711                             ACE_INET_Addr (control_port, inet_addr->get_host_addr ()),
00712                             "");
00713             this->control_address_ = inet_control_addr;
00714           }
00715           break;
00716         default:
00717           break;
00718         }
00719     }
00720 
00721 
00722   if (this->peer_addr_ != 0)
00723     {
00724       switch (this->protocol_)
00725         {
00726         case TAO_AV_Core::TAO_AV_SFP_UDP:
00727         case TAO_AV_Core::TAO_AV_SFP_UDP_MCAST:
00728         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00729         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST:
00730         case TAO_AV_Core::TAO_AV_RTP_UDP:
00731         case TAO_AV_Core::TAO_AV_RTP_UDP_MCAST:
00732         case TAO_AV_Core::TAO_AV_UDP:
00733         case TAO_AV_Core::TAO_AV_QOS_UDP:
00734         case TAO_AV_Core::TAO_AV_UDP_MCAST:
00735         case TAO_AV_Core::TAO_AV_TCP:
00736         case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00737           {
00738             ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (this->peer_addr_);
00739             inet_addr->addr_to_string (address,BUFSIZ);
00740             //inet_addr->get_host_name (address, BUFSIZ);
00741 
00742             //cstring += ACE_OS::itoa (address, BUFSIZ, inet_addr->get_port_number ());
00743 
00744           }
00745           break;
00746         default:
00747           break;
00748         }
00749 
00750           ACE_CString cstring (address);
00751 
00752           //peer_address_str = this->carrier_protocol_;
00753           //peer_address_str += "=";
00754           peer_address_str += cstring;
00755 
00756           if (this->protocol_ == TAO_AV_Core::TAO_AV_SCTP_SEQ)
00757             {
00758               for (int i = 0; i < this->num_peer_sec_addrs_; i++)
00759                 {
00760                   peer_address_str += ";";
00761                   peer_address_str += this->peer_sec_addr_ [i];
00762                 }
00763             }
00764 
00765     }
00766 
00767   if (this->control_address_ != 0)
00768     {
00769       u_short control_port = 0;
00770 
00771       switch (this->protocol_)
00772         {
00773         case TAO_AV_Core::TAO_AV_SFP_UDP:
00774         case TAO_AV_Core::TAO_AV_SFP_UDP_MCAST:
00775         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00776         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST:
00777         case TAO_AV_Core::TAO_AV_RTP_UDP:
00778         case TAO_AV_Core::TAO_AV_RTP_UDP_MCAST:
00779         case TAO_AV_Core::TAO_AV_UDP:
00780         case TAO_AV_Core::TAO_AV_QOS_UDP:
00781         case TAO_AV_Core::TAO_AV_UDP_MCAST:
00782         case TAO_AV_Core::TAO_AV_TCP:
00783         case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00784           {
00785             ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (this->control_address_);
00786             control_port = inet_addr->get_port_number();
00787           }
00788           break;
00789         default:
00790           break;
00791         }
00792 
00793       address_str += ";";
00794       char port_str[10];
00795       ACE_OS::sprintf(port_str, "%u", control_port);
00796       address_str += port_str;
00797     }
00798 
00799   this->entry_  = this->flowname_;
00800   this->entry_ += "\\";
00801   this->entry_ += this->direction_str_;
00802   this->entry_ += "\\";
00803   this->entry_ += this->format_;
00804   this->entry_ += "\\";
00805   this->entry_ += this->flow_protocol_;
00806   this->entry_ += "\\";
00807   this->entry_ += address_str;
00808 
00809   if (this->peer_addr_ != 0)
00810     {
00811       this->entry_ += "\\";
00812       this->entry_ += peer_address_str;
00813     }
00814   else ACE_DEBUG ((LM_DEBUG,
00815                    "No peer address specified\n"));
00816 
00817   if (TAO_debug_level > 0)
00818     ACE_DEBUG ((LM_DEBUG,"Forward entry_to_string: entry = %s\n",this->entry_.c_str()));
00819 
00820   return this->entry_.c_str();
00821 }
00822 
00823 //------------------------------------------------------------
00824 // TAO_Reverse_FlowSpec_Entry
00825 //------------------------------------------------------------
00826 
00827 //default constructor.
00828 TAO_Reverse_FlowSpec_Entry::TAO_Reverse_FlowSpec_Entry (void)
00829 {
00830   // no-op
00831 }
00832 
00833 // constructor to construct an entry from the arguments.
00834 TAO_Reverse_FlowSpec_Entry::TAO_Reverse_FlowSpec_Entry (const char *flowname,
00835                                                         const char *direction,
00836                                                         const char *format_name ,
00837                                                         const char *flow_protocol ,
00838                                                         const char *carrier_protocol,
00839                                                         ACE_Addr *address,
00840                                                         ACE_Addr *control_address )
00841   :TAO_FlowSpec_Entry (flowname,
00842                        direction,
00843                        format_name,
00844                        flow_protocol,
00845                        carrier_protocol,
00846                        address,
00847                        control_address)
00848 {
00849   // no-op
00850 }
00851 
00852 // constructor to construct an entry from the arguments.
00853 TAO_Reverse_FlowSpec_Entry::TAO_Reverse_FlowSpec_Entry (const char *flowname,
00854                                                         const char *direction,
00855                                                         const char *format_name ,
00856                                                         const char *flow_protocol ,
00857                                                         const char *address)
00858   :TAO_FlowSpec_Entry (flowname,
00859                        direction,
00860                        format_name,
00861                        flow_protocol,
00862                        address)
00863 {
00864   // no-op.
00865 }
00866 
00867 TAO_Reverse_FlowSpec_Entry::~TAO_Reverse_FlowSpec_Entry (void)
00868 {
00869   // no-op.
00870 }
00871 
00872 TAO_FlowSpec_Entry::Role
00873 TAO_Reverse_FlowSpec_Entry::role (void)
00874 {
00875   if (this->role_ != TAO_AV_INVALID_ROLE)
00876     return this->role_;
00877   switch (this->direction_)
00878     {
00879     case TAO_AV_DIR_IN:
00880       // Forward IN means we're the Source.
00881       return TAO_AV_CONSUMER;
00882     case TAO_AV_DIR_OUT:
00883       // Forward out means we're the sink.
00884       return TAO_AV_PRODUCER;
00885     default:
00886       return TAO_AV_INVALID_ROLE;
00887     }
00888 }
00889 
00890 int
00891 TAO_Reverse_FlowSpec_Entry::parse (const char *flowSpec_entry)
00892 {
00893   TAO_Tokenizer tokenizer (flowSpec_entry,'\\');
00894   this->flowname_ = tokenizer [TAO_AV_FLOWNAME];
00895 
00896   if (TAO_debug_level > 0)
00897     ACE_DEBUG ((LM_DEBUG,
00898                 "TAO_Reverse_FlowSpec_Entry::parse [%s]\n",
00899                 flowSpec_entry));
00900 
00901   if (tokenizer [TAO_AV_ADDRESS] != 0)
00902     if (this->parse_address (tokenizer [TAO_AV_ADDRESS], TAO_AV_Core::TAO_AV_BOTH) < 0)
00903       return -1;
00904 
00905   if (tokenizer [TAO_AV_FLOW_PROTOCOL] != 0)
00906     if (this->parse_flow_protocol_string (tokenizer [TAO_AV_FLOW_PROTOCOL]) < 0)
00907       return -1;
00908 
00909 //  if (tokenizer [TAO_AV_DIRECTION] != 0)
00910 //    this->set_direction (tokenizer [TAO_AV_DIRECTION]);
00911 
00912 //  if (tokenizer [TAO_AV_FORMAT] != 0)
00913 //    this->format_ = tokenizer [TAO_AV_FORMAT];
00914 
00915   return 0;
00916 }
00917 
00918 
00919 const char *
00920 TAO_Reverse_FlowSpec_Entry::entry_to_string (void)
00921 {
00922   if (this->flowname_.length() == 0)
00923     return "";
00924 
00925   char address [BUFSIZ];
00926   ACE_CString address_str;
00927   if (this->address_ != 0)
00928     {
00929       switch (this->protocol_)
00930         {
00931         case TAO_AV_Core::TAO_AV_RTP_UDP:
00932         case TAO_AV_Core::TAO_AV_UDP:
00933         case TAO_AV_Core::TAO_AV_QOS_UDP:
00934         case TAO_AV_Core::TAO_AV_UDP_MCAST:
00935         case TAO_AV_Core::TAO_AV_TCP:
00936         case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00937         case TAO_AV_Core::TAO_AV_SFP_UDP:
00938         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00939           {
00940             ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (this->address_);
00941             inet_addr->addr_to_string (address,BUFSIZ);
00942           }
00943           break;
00944         default:
00945           break;
00946         }
00947       ACE_CString cstring (address);
00948 
00949       address_str = this->carrier_protocol_;
00950       address_str += "=";
00951       address_str += cstring;
00952 
00953       if (this->protocol_ == TAO_AV_Core::TAO_AV_SCTP_SEQ)
00954         {
00955           for (int i = 0; i < this->num_local_sec_addrs_; i++)
00956             {
00957               address_str += ";";
00958               address_str += this->local_sec_addr_ [i];
00959             }
00960         }
00961 
00962     }
00963   else
00964     {
00965       address_str = "";
00966     }
00967 
00968   if (this->control_address_ != 0)
00969     {
00970       u_short control_port = 0;
00971 
00972 
00973       switch (this->protocol_)
00974         {
00975         case TAO_AV_Core::TAO_AV_SFP_UDP:
00976         case TAO_AV_Core::TAO_AV_SFP_UDP_MCAST:
00977         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
00978         case TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST:
00979         case TAO_AV_Core::TAO_AV_RTP_UDP:
00980         case TAO_AV_Core::TAO_AV_RTP_UDP_MCAST:
00981         case TAO_AV_Core::TAO_AV_UDP:
00982         case TAO_AV_Core::TAO_AV_QOS_UDP:
00983         case TAO_AV_Core::TAO_AV_UDP_MCAST:
00984         case TAO_AV_Core::TAO_AV_TCP:
00985         case TAO_AV_Core::TAO_AV_SCTP_SEQ:
00986           {
00987             ACE_INET_Addr *inet_addr = dynamic_cast<ACE_INET_Addr*> (this->control_address_);
00988             control_port = inet_addr->get_port_number();
00989           }
00990           break;
00991         default:
00992           break;
00993         }
00994 
00995       address_str += ";";
00996       char port_str[10];
00997       ACE_OS::sprintf(port_str, "%u", control_port);
00998       address_str += port_str;
00999 
01000     }
01001 
01002   this->entry_ = this->flowname_;
01003   this->entry_ += "\\";
01004   this->entry_ += address_str;
01005   this->entry_ += "\\";
01006   this->entry_ += this->flow_protocol_;
01007 //  this->entry_ += "\\";
01008 //  this->entry_ += this->direction_str_;
01009 //  this->entry_ += "\\";
01010 //  this->entry_ += format_;
01011 
01012   if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG,"Reverse entry_to_string: entry = %s\n",this->entry_.c_str() ));
01013   return this->entry_.c_str();
01014 }
01015 
01016 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Tue Feb 2 17:47:49 2010 for TAO_AV by  doxygen 1.4.7