📄 flowspec_entry.cpp
字号:
// FlowSpec_Entry.cpp,v 5.19 2003/11/04 05:21:31 dhinton Exp
//------------------------------------------------------------
// TAO_FlowSpec_Entry
//------------------------------------------------------------
#include "FlowSpec_Entry.h"
#include "Protocol_Factory.h"
#include "tao/debug.h"
#include "tao/PortableServer/ORB_Manager.h"
#include "ace/OS_NS_strings.h"
#if !defined (__ACE_INLINE__)
#include "FlowSpec_Entry.i"
#endif /* __ACE_INLINE__ */
// constructor.
TAO_FlowSpec_Entry::TAO_FlowSpec_Entry (void)
:address_ (0),
clean_up_address_ (0),
control_address_ (0),
clean_up_control_address_ (0),
address_str_ (),
format_ (),
direction_ (TAO_AV_INVALID),
direction_str_ (),
flowname_ (),
protocol_ (TAO_AV_Core::TAO_AV_NOPROTOCOL),
carrier_protocol_ (),
flow_protocol_ (),
use_flow_protocol_ (0),
entry_ (),
is_multicast_ (0),
peer_addr_ (0),
local_sec_addr_ (0),
num_local_sec_addrs_ (0),
peer_sec_addr_ (0),
num_peer_sec_addrs_ (0),
peer_control_addr_ (0),
local_addr_ (0),
local_control_addr_ (0),
transport_ (0),
control_transport_ (0),
handler_ (0),
control_handler_ (0),
protocol_object_ (0),
control_protocol_object_ (0),
role_ (TAO_AV_INVALID_ROLE)
{
}
// constructor.
TAO_FlowSpec_Entry::TAO_FlowSpec_Entry (const char *flowname,
const char *direction,
const char *format_name,
const char *flow_protocol,
const char *carrier_protocol,
ACE_Addr *fwd_address,
//ACE_Addr *peer_address,
ACE_Addr *control_address)
:address_ (fwd_address),
clean_up_address_ (0),
control_address_ (control_address),
clean_up_control_address_ (0),
address_str_ (),
format_ (format_name),
direction_str_ (direction ),
flowname_ ( flowname ),
carrier_protocol_ ( carrier_protocol ),
flow_protocol_ ( flow_protocol ),
use_flow_protocol_ (0),
entry_ (),
is_multicast_ (0),
peer_addr_ (0),
local_sec_addr_ (0),
num_local_sec_addrs_ (0),
peer_sec_addr_ (0),
num_peer_sec_addrs_ (0),
peer_control_addr_ (0),
local_addr_ (0),
local_control_addr_ (0),
transport_ (0),
control_transport_ (0),
handler_ (0),
control_handler_ (0),
protocol_object_ (0),
control_protocol_object_ (0),
role_ (TAO_AV_INVALID_ROLE)
{
this->set_protocol ();
this->set_direction (this->direction_str_.c_str());
this->parse_flow_protocol_string (this->flow_protocol_.c_str() );
}
TAO_FlowSpec_Entry::TAO_FlowSpec_Entry (const char *flowname,
const char *direction,
const char *format_name,
const char *flow_protocol,
const char *address)
//const char *peer_address)
:address_ (0),
clean_up_address_ (0),
control_address_ (0),
clean_up_control_address_ (0),
address_str_ ( address ),
format_ ( format_name ),
direction_str_ ( direction ),
flowname_ ( flowname ),
carrier_protocol_ (),
flow_protocol_ ( flow_protocol ),
use_flow_protocol_ (0),
entry_ (),
is_multicast_ (0),
peer_addr_ (0),
local_sec_addr_ (0),
num_local_sec_addrs_ (0),
peer_sec_addr_ (0),
num_peer_sec_addrs_ (0),
peer_control_addr_ (0),
local_addr_ (0),
local_control_addr_ (0),
transport_ (0),
control_transport_ (0),
handler_ (0),
control_handler_ (0),
protocol_object_ (0),
control_protocol_object_ (0),
role_ (TAO_AV_INVALID_ROLE)
{
this->parse_flow_protocol_string (this->flow_protocol_.c_str() );
this->parse_address (this->address_str_.c_str(), TAO_AV_Core::TAO_AV_DATA);
this->set_direction (this->direction_str_.c_str());
}
// Destructor.
TAO_FlowSpec_Entry::~TAO_FlowSpec_Entry (void)
{
if (this->clean_up_address_)
delete address_;
if (this->clean_up_control_address_)
delete control_address_;
if (local_control_addr_ != 0)
delete local_control_addr_;
}
int
TAO_FlowSpec_Entry::set_protocol (void)
{
if (!this->use_flow_protocol_)
{
if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"TCP") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_TCP;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"SCTP_SEQ") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_SCTP_SEQ;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"UDP") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_UDP;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"QoS_UDP") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_QOS_UDP;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"AAL5") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_AAL5;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"AAL3_4") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_AAL3_4;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"AAL1") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_AAL1;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"RTP/UDP") == 0){
this->protocol_ = TAO_AV_Core::TAO_AV_UDP;
flow_protocol_ = "RTP";
}
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"RTP/AAL5") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_RTP_AAL5;
else if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"IPX") == 0)
this->protocol_ = TAO_AV_Core::TAO_AV_IPX;
else
{
this->protocol_ = TAO_AV_Core::TAO_AV_NOPROTOCOL;
return -1;
}
}
else
{
if (ACE_OS::strcasecmp (this->carrier_protocol_.c_str(),"UDP") == 0)
{
if (ACE_OS::strncasecmp (this->flow_protocol_.c_str (),"sfp",3) == 0)
{
this->protocol_ = TAO_AV_Core::TAO_AV_SFP_UDP;
}
else this->protocol_ = TAO_AV_Core::TAO_AV_USERDEFINED_UDP;
}
else
{
this->protocol_ = TAO_AV_Core::TAO_AV_NOPROTOCOL;
return -1;
}
}
if (this->address_ != 0)
{
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "TAO_FlowSpec_Entry::set_protocol address is not 0\n"));
ACE_INET_Addr *inet_addr = ACE_dynamic_cast (ACE_INET_Addr*,this->address_);
char buf[BUFSIZ];
inet_addr->addr_to_string (buf,BUFSIZ);
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG,"TAO_FlowSpec_Entry::set_protocol:%s %x\n",buf, inet_addr->get_ip_address ()));
if (IN_CLASSD (inet_addr->get_ip_address ()))
{
this->is_multicast_ = 1;
switch (this->protocol_)
{
case TAO_AV_Core::TAO_AV_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_UDP_MCAST;
break;
case TAO_AV_Core::TAO_AV_RTP_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_RTP_UDP_MCAST;
break;
case TAO_AV_Core::TAO_AV_SFP_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_SFP_UDP_MCAST;
break;
case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST;
break;
default:
break;
}
}
}
return 0;
}
int
TAO_FlowSpec_Entry::parse_address (const char *address,
TAO_AV_Core::Flow_Component flow_comp)
{
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "TAO_FlowSpec_Entry::parse_address %s\n", address));
if (address == 0)
return 0;
if (ACE_OS::strcmp (address,"") == 0)
return 0;
TAO_Tokenizer protocol_tokenizer (address,'=');
this->carrier_protocol_ = protocol_tokenizer[0];
int result = this->set_protocol ();
if (result < 0)
return result;
if (protocol_tokenizer [1] != 0)
{
ACE_DEBUG ((LM_DEBUG,
"Protocol tokenixer is not null\n"));
if ((flow_comp == TAO_AV_Core::TAO_AV_DATA) ||
//(flow_comp == TAO_AV_Core::TAO_AV_BOTH) ||
(flow_comp == TAO_AV_Core::TAO_AV_CONTROL) )
{
ACE_CString addr;
if (this->protocol_ == TAO_AV_Core::TAO_AV_SCTP_SEQ)
{
TAO_Tokenizer addr_token (protocol_tokenizer [1], ';');
ACE_DEBUG ((LM_DEBUG,
"Number of local sec addresses = %d\n",
addr_token.num_tokens () - 1));
if (addr_token.num_tokens () != 0)
{
addr += addr_token [0];
ACE_NEW_RETURN (local_sec_addr_, char* [addr_token.num_tokens () - 1],-1);
for (int j = 1; j <= addr_token.num_tokens () - 1; j++)
{
ACE_DEBUG ((LM_DEBUG,
"adding addresses to sequence %s\n",
addr_token [j]));
local_sec_addr_ [j-1] = CORBA::string_dup (addr_token [j]);
}
num_local_sec_addrs_ = addr_token.num_tokens () - 1;
}
}
else addr += protocol_tokenizer[1];
switch (this->protocol_)
{
case TAO_AV_Core::TAO_AV_SFP_UDP:
case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
case TAO_AV_Core::TAO_AV_RTP_UDP:
case TAO_AV_Core::TAO_AV_TCP:
case TAO_AV_Core::TAO_AV_SCTP_SEQ:
case TAO_AV_Core::TAO_AV_UDP:
case TAO_AV_Core::TAO_AV_QOS_UDP:
{
if (flow_comp == TAO_AV_Core::TAO_AV_DATA)
this->address_str_ = addr;
ACE_INET_Addr *inet_addr;
ACE_NEW_RETURN (inet_addr,
ACE_INET_Addr (addr.c_str() ),
-1);
if (flow_comp == TAO_AV_Core::TAO_AV_DATA)
{
this->clean_up_address_ = 1;
this->address_ = inet_addr;
}
else
{
this->clean_up_control_address_ = 1;
this->control_address_ = inet_addr;
}
if (IN_CLASSD (inet_addr->get_ip_address ()))
{
if (TAO_debug_level > 0)
ACE_DEBUG ((LM_DEBUG, "TAO_FlowSpec_Entry::parse_address is multicast\n"));
this->is_multicast_ = 1;
switch (this->protocol_)
{
case TAO_AV_Core::TAO_AV_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_UDP_MCAST;
break;
case TAO_AV_Core::TAO_AV_RTP_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_RTP_UDP_MCAST;
break;
case TAO_AV_Core::TAO_AV_SFP_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_SFP_UDP_MCAST;
break;
case TAO_AV_Core::TAO_AV_USERDEFINED_UDP:
this->protocol_ = TAO_AV_Core::TAO_AV_USERDEFINED_UDP_MCAST;
break;
default:
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -