TcpInst.cpp

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "Tcp_pch.h"
00009 #include "TcpInst.h"
00010 
00011 #include "dds/DCPS/transport/framework/NetworkAddress.h"
00012 
00013 #include "ace/Configuration.h"
00014 
00015 #include <iostream>
00016 #include <sstream>
00017 
00018 #if !defined (__ACE_INLINE__)
00019 #include "TcpInst.inl"
00020 #endif /* __ACE_INLINE__ */
00021 
00022 OpenDDS::DCPS::TcpInst::~TcpInst()
00023 {
00024   DBG_ENTRY_LVL("TcpInst","~TcpInst",6);
00025 }
00026 
00027 OpenDDS::DCPS::TcpTransport*
00028 OpenDDS::DCPS::TcpInst::new_impl(const TransportInst_rch& inst)
00029 {
00030   return new TcpTransport(inst);
00031 }
00032 
00033 int
00034 OpenDDS::DCPS::TcpInst::load(ACE_Configuration_Heap& cf,
00035                              ACE_Configuration_Section_Key& trans_sect)
00036 {
00037   TransportInst::load(cf, trans_sect);
00038 
00039   std::string local_address;
00040   GET_CONFIG_STRING_VALUE(cf, trans_sect, ACE_TEXT("local_address"), local_address);
00041 
00042   if (local_address != "") {
00043     this->local_address(local_address.c_str());
00044   }
00045 
00046   GET_CONFIG_STRING_VALUE(cf, trans_sect, ACE_TEXT("pub_address"), pub_address_str_);
00047 
00048   GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("enable_nagle_algorithm"),
00049                    this->enable_nagle_algorithm_, bool)
00050 
00051   GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_initial_delay"),
00052                    this->conn_retry_initial_delay_, int)
00053 
00054   GET_CONFIG_DOUBLE_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_backoff_multiplier"),
00055                    this->conn_retry_backoff_multiplier_)
00056 
00057   GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("conn_retry_attempts"),
00058                    this->conn_retry_attempts_, int)
00059 
00060   GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("passive_reconnect_duration"),
00061                    this->passive_reconnect_duration_, int)
00062 
00063   GET_CONFIG_VALUE(cf, trans_sect, ACE_TEXT("max_output_pause_period"),
00064                    this->max_output_pause_period_, int)
00065 
00066   return 0;
00067 }
00068 
00069 OPENDDS_STRING
00070 OpenDDS::DCPS::TcpInst::dump_to_str()
00071 {
00072   std::ostringstream os;
00073   os << TransportInst::dump_to_str() << std::endl;
00074 
00075   os << formatNameForDump("local_address")                 << this->local_address_string() << std::endl;
00076   os << formatNameForDump("pub_address")                   << this->pub_address_str_ << std::endl;
00077   os << formatNameForDump("enable_nagle_algorithm")        << (this->enable_nagle_algorithm_ ? "true" : "false") << std::endl;
00078   os << formatNameForDump("conn_retry_initial_delay")      << this->conn_retry_initial_delay_ << std::endl;
00079   os << formatNameForDump("conn_retry_backoff_multiplier") << this->conn_retry_backoff_multiplier_ << std::endl;
00080   os << formatNameForDump("conn_retry_attempts")           << this->conn_retry_attempts_ << std::endl;
00081   os << formatNameForDump("passive_reconnect_duration")    << this->passive_reconnect_duration_ << std::endl;
00082   os << formatNameForDump("max_output_pause_period")       << this->max_output_pause_period_ << std::endl;
00083   return OPENDDS_STRING(os.str());
00084 }
00085 
00086 size_t
00087 OpenDDS::DCPS::TcpInst::populate_locator(OpenDDS::DCPS::TransportLocator& local_info) const
00088 {
00089   if (this->local_address() != ACE_INET_Addr() || !pub_address_str_.empty()) {
00090     // Get the public address string from the inst (usually the local address)
00091     NetworkAddress network_order_address(this->get_public_address());
00092 
00093     ACE_OutputCDR cdr;
00094     cdr << network_order_address;
00095     const CORBA::ULong len = static_cast<CORBA::ULong>(cdr.total_length());
00096     char* buffer = const_cast<char*>(cdr.buffer()); // safe
00097 
00098     local_info.transport_type = "tcp";
00099     local_info.data = TransportBLOB(len, len,
00100                                     reinterpret_cast<CORBA::Octet*>(buffer));
00101     return 1;
00102   } else {
00103     return 0;
00104   }
00105 }

Generated on Fri Feb 12 20:05:27 2016 for OpenDDS by  doxygen 1.4.7