FlowSpec_Entry.cpp

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

Generated on Thu Nov 9 13:44:41 2006 for TAO_AV by doxygen 1.3.6