bool RtpsUdpTransport::configure_i(TransportInst* config) { config_i_ = RtpsUdpInst_rch(dynamic_cast<RtpsUdpInst*>(config), false); if (config_i_.is_nil()) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: ") ACE_TEXT("invalid configuration!\n")), false); } // Open the socket here so that any addresses/ports left // unspecified in the RtpsUdpInst are known by the time we get to // connection_info_i(). Opening the sockets here also allows us to // detect and report errors during DataReader/Writer setup instead // of during association. if (unicast_socket_.open(config_i_->local_address_) != 0) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: socket open:") ACE_TEXT("%m\n")), false); } if (config_i_->local_address_.is_any()) { OpenDDS::DCPS::get_fully_qualified_hostname(&config_i_->local_address_); } if (config_i_->local_address_.get_port_number() == 0) { ACE_INET_Addr address; if (unicast_socket_.get_local_addr(address) != 0) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsUdpDataLink::configure_i - %p\n"), ACE_TEXT("cannot get local addr")), false); } config_i_->local_address_.set_port_number(address.get_port_number()); } create_reactor_task(); if (config_i_->opendds_discovery_default_listener_) { RtpsUdpDataLink_rch link = make_datalink(config_i_->opendds_discovery_guid_.guidPrefix); link->default_listener(config_i_->opendds_discovery_default_listener_); default_listener_ = dynamic_cast<TransportClient*>(config_i_->opendds_discovery_default_listener_); } return true; }
bool RtpsUdpTransport::configure_i(TransportInst* config) { config_i_ = RtpsUdpInst_rch(dynamic_cast<RtpsUdpInst*>(config), false); if (config_i_.is_nil()) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: ") ACE_TEXT("invalid configuration!\n")), false); } // Override with DCPSDefaultAddress. if (this->config_i_->local_address() == ACE_INET_Addr () && !TheServiceParticipant->default_address ().empty ()) { this->config_i_->local_address(0, TheServiceParticipant->default_address ().c_str ()); } // Open the socket here so that any addresses/ports left // unspecified in the RtpsUdpInst are known by the time we get to // connection_info_i(). Opening the sockets here also allows us to // detect and report errors during DataReader/Writer setup instead // of during association. if (!open_appropriate_socket_type(unicast_socket_, config_i_->local_address())) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ") ACE_TEXT("RtpsUdpTransport::configure_i: open_appropriate_socket_type:") ACE_TEXT("%m\n")), false); } if (config_i_->local_address().get_port_number() == 0) { ACE_INET_Addr address; if (unicast_socket_.get_local_addr(address) != 0) { ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsUdpDataLink::configure_i - %p\n"), ACE_TEXT("cannot get local addr")), false); } config_i_->local_address_set_port(address.get_port_number()); } create_reactor_task(); if (config_i_->opendds_discovery_default_listener_) { RtpsUdpDataLink_rch link = make_datalink(config_i_->opendds_discovery_guid_.guidPrefix); link->default_listener(config_i_->opendds_discovery_default_listener_); default_listener_ = dynamic_cast<TransportClient*>(config_i_->opendds_discovery_default_listener_); } return true; }
TransportImpl::AcceptConnectResult RtpsUdpTransport::connect_datalink(const RemoteTransport& remote, const ConnectionAttribs& attribs, TransportClient* client ) { GuardThreadType guard_links(this->links_lock_); RtpsUdpDataLink_rch link = link_; if (link_.is_nil()) { link = make_datalink(attribs.local_id_.guidPrefix); if (link.is_nil()) { return AcceptConnectResult(); } } use_datalink(attribs.local_id_, remote.repo_id_, remote.blob_, attribs.local_reliable_, remote.reliable_, attribs.local_durable_, remote.durable_); if (0 == std::memcmp(attribs.local_id_.guidPrefix, remote.repo_id_.guidPrefix, sizeof(GuidPrefix_t))) { return AcceptConnectResult(link._retn()); // "loopback" connection return link right away } if (link->check_handshake_complete(attribs.local_id_, remote.repo_id_)){ return AcceptConnectResult(link._retn()); } if (!link->add_on_start_callback(client, remote.repo_id_)) { // link was started by the reactor thread before we could add a callback VDBG_LVL((LM_DEBUG, "(%P|%t) RtpsUdpTransport::connect_datalink got link.\n"), 2); return AcceptConnectResult(link._retn()); } GuardType guard(connections_lock_); add_pending_connection(client, link.in()); VDBG_LVL((LM_DEBUG, "(%P|%t) RtpsUdpTransport::connect_datalink pending.\n"), 2); return AcceptConnectResult(AcceptConnectResult::ACR_SUCCESS); /* const GuidConverter local_conv(attribs.local_id_), remote_conv(remote.repo_id_); VDBG_LVL((LM_DEBUG, "(%P|%t) RtpsUdpTransport::connect_datalink_i " "waiting for handshake local %C remote %C\n", std::string(local_conv).c_str(), std::string(remote_conv).c_str()), 2); //TODO: fix waiting if (!link->wait_for_handshake(attribs.local_id_, remote.repo_id_)) { VDBG_LVL((LM_ERROR, "(%P|%t) RtpsUdpTransport::connect_datalink_i " "ERROR: wait for handshake failed\n"), 2); return AcceptConnectResult(); } VDBG_LVL((LM_DEBUG, "(%P|%t) RtpsUdpTransport::connect_datalink_i " "wait for handshake completed\n"), 2); return AcceptConnectResult(link._retn()); */ }
TransportImpl::AcceptConnectResult RtpsUdpTransport::accept_datalink(const RemoteTransport& remote, const ConnectionAttribs& attribs, TransportClient* ) { GuardThreadType guard_links(this->links_lock_); RtpsUdpDataLink_rch link = link_; if (link_.is_nil()) { link = make_datalink(attribs.local_id_.guidPrefix); if (link.is_nil()) { return AcceptConnectResult(); } } use_datalink(attribs.local_id_, remote.repo_id_, remote.blob_, attribs.local_reliable_, remote.reliable_, attribs.local_durable_, remote.durable_); return AcceptConnectResult(link._retn()); }