19 #include <dds/DdsDcpsInfrastructureC.h> 26 #if !defined (__ACE_INLINE__) 40 #ifdef OPENDDS_SAFETY_PROFILE 41 const char FALLBACK_TYPE[] =
"rtps_udp";
43 const char FALLBACK_TYPE[] =
"tcp";
78 lib_directive_map_[
"tcp"] =
"dynamic OpenDDS_Tcp Service_Object * OpenDDS_Tcp:_make_TcpLoader()";
79 lib_directive_map_[
"udp"] =
"dynamic OpenDDS_Udp Service_Object * OpenDDS_Udp:_make_UdpLoader()";
80 lib_directive_map_[
"multicast"] =
"dynamic OpenDDS_Multicast Service_Object * OpenDDS_Multicast:_make_MulticastLoader()";
81 lib_directive_map_[
"rtps_udp"] =
"dynamic OpenDDS_Rtps_Udp Service_Object * OpenDDS_Rtps_Udp:_make_RtpsUdpLoader()";
82 lib_directive_map_[
"shmem"] =
"dynamic OpenDDS_Shmem Service_Object * OpenDDS_Shmem:_make_ShmemLoader()";
86 lib_directive_map_[
"repository"] =
"dynamic OpenDDS_InfoRepoDiscovery Service_Object * OpenDDS_InfoRepoDiscovery:_make_IRDiscoveryLoader()";
97 typedef std::pair<TransportConfig_rch, OPENDDS_VECTOR(OPENDDS_STRING) > ConfigInfo;
116 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
117 ACE_TEXT(
"failed to open section %C\n"),
126 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
127 ACE_TEXT(
"transport sections must have a section name\n"),
136 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
137 ACE_TEXT(
"too many nesting layers in [%C] section.\n"),
141 for (KeyList::const_iterator it = keys.begin(); it != keys.end(); ++it) {
146 if (
pullValues(cf, it->second, values) != 0) {
149 ValueMap::const_iterator vm_it = values.find(
"transport_type");
150 if (vm_it != values.end()) {
151 transport_type = vm_it->second;
154 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
155 ACE_TEXT(
"missing transport_type in [transport/%C] section.\n"),
156 transport_id.
c_str()),
167 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
168 ACE_TEXT(
"Unable to create transport instance in [transport/%C] section.\n"),
169 transport_id.
c_str()),
173 instances.push_back(inst);
174 inst->load(cf, inst_sect);
180 transports_.push_back(entry);
183 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
184 ACE_TEXT(
"missing transport_type in [transport/%C] section.\n"),
185 transport_id.
c_str()),
195 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
196 ACE_TEXT(
"failed to open section [%C]\n"),
205 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
206 ACE_TEXT(
"config sections must have a section name\n"),
216 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
217 ACE_TEXT(
"too many nesting layers in [%C] section.\n"),
221 for (KeyList::const_iterator it = keys.begin(); it != keys.end(); ++it) {
228 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
229 ACE_TEXT(
"Unable to create transport config in [config/%C] section.\n"),
237 ConfigInfo configInfo;
238 configInfo.first = config;
239 for (ValueMap::const_iterator it = values.begin(); it != values.end(); ++it) {
242 if (name ==
"transports") {
246 while ((pos = value.find(delim)) != OPENDDS_STRING::npos) {
247 token = value.substr(0, pos);
248 configInfo.second.push_back(token);
249 value.erase(0, pos + 1);
254 if (it->transport_template_name == value) {
255 it->config_name = config_id;
268 configInfo.second.push_back(value);
270 configInfoVec.push_back(configInfo);
271 }
else if (name ==
"swap_bytes") {
272 if ((value ==
"1") || (value ==
"true")) {
274 }
else if ((value !=
"0") && (value !=
"false")) {
276 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
277 ACE_TEXT(
"Illegal value for swap_bytes (%C) in [config/%C] section.\n"),
278 value.c_str(), config_id.c_str()),
281 }
else if (name ==
"passive_connect_duration") {
285 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
286 ACE_TEXT(
"Illegal integer value for passive_connect_duration (%C) in [config/%C] section.\n"),
287 value.c_str(), config_id.c_str()),
292 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
293 ACE_TEXT(
"Unexpected entry (%C) in [config/%C] section.\n"),
294 name.c_str(), config_id.c_str()),
298 if (configInfo.second.empty()) {
300 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
301 ACE_TEXT(
"No transport instances listed in [config/%C] section.\n"),
311 for (
unsigned int i = 0; i < configInfoVec.size(); ++i) {
314 for (
unsigned int j = 0; j < insts.size(); ++j) {
318 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
319 ACE_TEXT(
"The inst (%C) in [config/%C] section is undefined.\n"),
320 insts[j].c_str(), config->
name().c_str()),
329 if (!instances.empty()) {
333 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_configuration: ")
334 ACE_TEXT(
"Unable to create default transport config.\n"),
338 instances.sort(predicate);
340 it != instances.end(); ++it) {
359 ACE_TEXT(
"(%P|%t) NOTICE: TransportRegistry::load_transport_templates(): ")
360 ACE_TEXT(
"config does not have a [%s] section.\n"),
369 ACE_TEXT(
"(%P|%t) NOTICE: TransportRegistry::load_transport_templates(): ")
370 ACE_TEXT(
"config has %s sections.\n"),
379 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::load_transport_templates(): ")
380 ACE_TEXT(
"%s sections must have a subsection name\n"),
388 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::load_transport_templates(): ")
389 ACE_TEXT(
"too many nesting layers in the [%s] section.\n"),
395 for (KeyList::const_iterator it = keys.begin(); it != keys.end(); ++it) {
402 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_templates(): ")
412 for (ValueMap::const_iterator it = values.begin(); it != values.end(); ++it) {
414 if (name ==
"instantiation_rule") {
416 if (rule ==
"per_participant") {
422 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_templates(): ")
423 ACE_TEXT(
"[%s/%C]: instantiantion rule == %C\n"),
427 customization = it->second;
430 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_templates(): ")
431 ACE_TEXT(
"[%s/%C]: customization == %C\n"),
441 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::load_transport_templates(): ")
442 ACE_TEXT(
"%s sections must have a subsection name\n"),
451 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_templates(): ")
452 ACE_TEXT(
"too many nesting layers in the [%s] section.\n"),
458 for (KeyList::const_iterator iter = keys.begin(); iter != keys.end(); ++iter) {
459 if (customization == iter->first) {
463 for (ValueMap::const_iterator it = values.begin(); it != values.end(); ++it) {
474 transport_templates_.push_back(element);
487 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_lib: ")
488 ACE_TEXT(
"could not load transport_type=%C.\n"),
489 transport_type.c_str()));
501 #if !defined(ACE_AS_STATIC_LIBS) 506 ACE_TEXT(
"(%P|%t) TransportRegistry::load_transport_lib_i: ")
507 ACE_TEXT(
"no directive for transport_type=%C.\n"),
508 transport_type.c_str()));
536 ACE_TEXT(
"(%P|%t) TransportRegistry::create_inst: ")
537 ACE_TEXT(
"transport_type=%C is not registered.\n"),
538 transport_type.c_str()));
544 ACE_TEXT(
"(%P|%t) TransportRegistry::create_inst: ")
545 ACE_TEXT(
"name=%C is already in use.\n"),
559 InstMap::const_iterator found =
inst_map_.find(name);
561 return found->second;
574 ACE_TEXT(
"(%P|%t) TransportRegistry::create_config: ")
575 ACE_TEXT(
"name=%C is already in use.\n"),
590 ConfigMap::const_iterator found =
config_map_.find(name);
592 return found->second;
617 if (cfg->
name() == i->config_name) {
634 ACE_TEXT(
"(%P|%t) TransportRegistry::bind_config: ")
635 ACE_TEXT(
"GUID_UNKNOWN. Can not bind entity to a domain template instance.\n")));
641 if (cfg_name.
c_str() != 0) {
645 ACE_TEXT(
"(%P|%t) TransportRegistry::bind_config: ")
646 ACE_TEXT(
"Config name is null.\n")));
660 ACE_TEXT(
"(%P|%t) TransportRegistry::bind_config: ")
661 ACE_TEXT(
"Failed to create new transport template instance.\n")));
679 ACE_TEXT(
"(%P|%t) TransportRegistry::remove_transport_template_instance: ")
680 ACE_TEXT(
"%C is not a transport template instance.\n"),
681 config_name.c_str()));
692 ACE_TEXT(
"(%P|%t) DomainParticipantFactoryImpl::delete_participant ")
693 ACE_TEXT(
"deleted TransportRegistry's dynamically created config %C and instance %C\n"),
694 config_name.c_str(), inst_name.c_str()));
730 if (name ==
"rtps_udp") {
745 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::")
746 ACE_TEXT(
"create_new_transport_instance_for_participant: ")
747 ACE_TEXT(
"transport_template missing instantiation_rule=per_participant\n")),
758 transport_config_name = config_name;
759 transport_instance_name = inst_name;
779 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::")
780 ACE_TEXT(
"create_new_transport_instance_for_participant ")
781 ACE_TEXT(
"could not process_customizations\n")),
786 for (ValueMap::const_iterator it = customs.begin(); it != customs.end(); ++it) {
791 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::")
792 ACE_TEXT(
"create_new_transport_instance_for_participant ")
793 ACE_TEXT(
"could not find transport_template for config %C\n"),
794 cfg->
name().c_str()),
801 for (ValueMap::const_iterator it = tr_inst.
transport_info.begin();
806 ACE_TEXT(
"(%P|%t) TransportRegistry::")
807 ACE_TEXT(
"create_new_transport_entry_for_participant adding %C=%C\n"),
808 it->first.c_str(), it->second.c_str()));
813 inst->
load(ach, sect_key);
833 iter->second->shutdown();
837 transport_templates_.clear();
858 return configured_name;
866 return configured_name;
876 ConfigMap::const_iterator i =
config_map_.find(config_inst_name);
906 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::")
907 ACE_TEXT(
"create_transport_template_instance ")
908 ACE_TEXT(
"could not process_customizations\n")),
913 for (ValueMap::const_iterator it = customs.begin(); it != customs.end(); ++it) {
918 ACE_TEXT(
"(%P|%t) TransportRegistry::")
919 ACE_TEXT(
"create_transport_template_instance adding %C=%C\n"),
920 it->first.c_str(), it->second.c_str()));
929 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::create_transport_template_instance ")
930 ACE_TEXT(
"load_transport_configuration() returned %d\n"),
975 ACE_TEXT(
"(%P|%t) TransportRegistry::get_transport_template_info: ")
977 ret ?
"found" :
"did not find", config_name.
c_str()));
985 for (ValueMap::const_iterator it = tr_inst.
transport_info.begin();
988 ValueMap::const_iterator idx = tr_inst.
customizations.find(it->first);
994 bool add_to_ip =
false;
995 bool add_to_port =
false;
1000 size_t comma_pos = custom.find(
',');
1001 if (comma_pos != OPENDDS_STRING::npos) {
1002 val1 = custom.substr(0, comma_pos);
1004 val1.erase(
std::remove(val1.begin(), val1.end(),
' '), val1.end());
1006 val2 = custom.substr(comma_pos + 1);
1007 val2.erase(
std::remove(val2.begin(), val2.end(),
' '), val2.end());
1013 custom.erase(
std::remove(custom.begin(), custom.end(),
' '), custom.end());
1019 if (!add_to_ip && !add_to_port) {
1021 ACE_TEXT(
"(%P|%t) TransportRegistry::process_customizations: ")
1022 ACE_TEXT(
"%C customization is not supported. Supported values are %C and %C\n"),
1029 size_t pos = addr.find_last_of(
".");
1030 if (pos != OPENDDS_STRING::npos) {
1036 size_t cpos = custom.find(
":");
1037 if (cpos != OPENDDS_STRING::npos) {
1038 port = custom.substr(cpos);
1039 last_octet = custom.substr(0, cpos);
1041 last_octet = custom;
1047 ACE_TEXT(
"(%P|%t) ERROR: TransportRegistry::")
1048 ACE_TEXT(
"process_customizations ")
1049 ACE_TEXT(
"could not convert %C to integer\n"),
1055 addr = addr.substr(0, pos);
1062 ACE_TEXT(
"(%P|%t) ERROR: Service_Participant::")
1063 ACE_TEXT(
"process_customizations ")
1064 ACE_TEXT(
"could not add_domain_id_to_ip_addr for address %C\n"),
1065 idx->second.c_str()),
1071 ACE_TEXT(
"(%P|%t) TransportRegistry::")
1072 ACE_TEXT(
"process_customizations processing add_domain_id_to_ip_addr: %C=%C\n"),
1073 it->first.c_str(), addr.c_str()));
1078 size_t pos = addr.find_last_of(
":");
1079 if (pos == OPENDDS_STRING::npos) {
1081 const int PB = 7400;
1084 int rtpsPort = PB + DG *
id + D2;
1091 addr = addr.substr(0, pos);
1096 ACE_TEXT(
"(%P|%t) ERROR: Service_Participant::")
1097 ACE_TEXT(
"process_customizations ")
1098 ACE_TEXT(
"could not add_domain_id_to_port for %C.\n"),
1099 idx->second.c_str()),
1105 ACE_TEXT(
"(%P|%t) TransportRegistry::")
1106 ACE_TEXT(
"process_customizations processing add_domain_id_to_port: %C ==> %C\n"),
1107 it->first.c_str(), addr.c_str()));
1114 ACE_TEXT(
"(%P|%t) TransportRegistry::")
1115 ACE_TEXT(
"process_customizations processing add_domain_id_to_port: %C=%C\n"),
1116 it->first.c_str(), addr.c_str()));
1120 customs[idx->first] = addr.c_str();
1122 customs[it->first] = it->second.c_str();
1125 ACE_TEXT(
"(%P|%t) TransportRegistry::")
1126 ACE_TEXT(
"process_customizations adding %C=%C\n"),
1127 it->first.c_str(), it->second.c_str()));
1137 return !transport_templates_.empty();
1159 ACE_TEXT(
"(%P|%t) TransportRegistry::get_transport_info: ")
1161 ret ?
"found" :
"did not find", config_name.
c_str()));
1169 return !transports_.empty();
TransportInst_rch get_inst(const OPENDDS_STRING &name) const
int create_transport_template_instance(DDS::DomainId_t domain, const ACE_TString &config_name)
Implements the OpenDDS::DCPS::Entity interfaces.
bool create_new_transport_instance_for_participant(DDS::DomainId_t id, OPENDDS_STRING &transport_config_name, OPENDDS_STRING &transport_instance_name)
OPENDDS_STRING get_transport_template_instance_name(DDS::DomainId_t id)
virtual int set_string_value(const ACE_Configuration_Section_Key &key, const ACE_TCHAR *name, const ACE_TString &value)
const char * c_str(void) const
const LogLevel::Value value
void remove_inst(const TransportInst_rch &inst)
void load_transport_lib(const OPENDDS_STRING &transport_type)
void update_config_template_instance_info(const OPENDDS_STRING &config_name, const OPENDDS_STRING &inst_name)
void remove_transport_template_instance(const OPENDDS_STRING &config_name)
const GUID_t GUID_UNKNOWN
Nil value for GUID.
static const ACE_TCHAR CUSTOMIZATION_SECTION_NAME[]
static int process_directive(const ACE_TCHAR directive[])
String to_dds_string(unsigned short to_convert)
static const char DEFAULT_CONFIG_NAME[]
bool has_transport_templates() const
#define ACE_TEXT_ALWAYS_CHAR(STRING)
const OPENDDS_STRING & name() const
virtual const ACE_Configuration_Section_Key & root_section(void) const
RcHandle< TransportConfig > TransportConfig_rch
bool has_transports() const
OPENDDS_STRING get_config_instance_name(DDS::DomainId_t id)
RcHandle< TransportInst > TransportInst_rch
The type definition for the smart-pointer to the underlying type.
bool config_has_transport_template(const ACE_TString &config_name) const
void bind_config(const OPENDDS_STRING &name, DDS::Entity_ptr entity)
Conversion processing and value testing utilities for RTPS GUID_t types.
bool get_transport_template_info(const ACE_TString &config_name, TransportTemplate &inst)
static TYPE * instance(void)
TransportConfig_rch global_config() const
ConfigTemplateToInstanceMap config_template_to_instance_map_
LibDirectiveMap lib_directive_map_
OPENDDS_STRING config_name
virtual void transport_config(const TransportConfig_rch &cfg)
bool get_transport_info(const ACE_TString &config_name, TransportEntry &inst)
DOMAINID_TYPE_NATIVE DomainId_t
TransportType_rch load_transport_lib_i(const OPENDDS_STRING &transport_type)
virtual GUID_t get_id() const
TransportConfig_rch get_config(const OPENDDS_STRING &name) const
static const ACE_TCHAR CONFIG_SECTION_NAME[]
static const ACE_TCHAR TRANSPORT_SECTION_NAME[]
RcHandle< TransportType > TransportType_rch
DomainConfigMap domain_default_config_map_
OPENDDS_STRING transport_template_name
unsigned long passive_connect_duration_
bool instantiate_per_participant
int load_transport_configuration(const OPENDDS_STRING &file_name, ACE_Configuration_Heap &cf)
void remove_config(const TransportConfig_rch &cfg)
static void close()
Close the singleton instance of this class.
TransportInst_rch create_inst(const OPENDDS_STRING &name, const OPENDDS_STRING &transport_type)
#define ACE_TEXT_CHAR_TO_TCHAR(STRING)
TransportConfig_rch create_config(const OPENDDS_STRING &name)
OPENDDS_STRING uniqueParticipantId() const
OPENDDS_STRING name() const
int strcmp(const char *s, const char *t)
int load_transport_templates(ACE_Configuration_Heap &cf)
TransportConfig_rch fix_empty_default()
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
virtual int load(ACE_Configuration_Heap &cf, ACE_Configuration_Section_Key §)
virtual DDS::DomainId_t get_domain_id()
#define DBG_ENTRY_LVL(CNAME, MNAME, DBG_LVL)
virtual int open_section(const ACE_Configuration_Section_Key &base, const ACE_TCHAR *sub_section, bool create, ACE_Configuration_Section_Key &result)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
static const char DEFAULT_INST_PREFIX[]
static TransportRegistry * instance()
Return a singleton instance of this class.
int processSections(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, KeyList &subsections)
int remove(Container &c, const ValueType &v)
int open(const ACE_TCHAR *file_name, void *base_address=ACE_DEFAULT_BASE_ADDR, size_t default_map_size=ACE_DEFAULT_CONFIG_SECTION_SIZE)
OPENDDS_VECTOR(TransportTemplate) transport_templates_
virtual int enumerate_sections(const ACE_Configuration_Section_Key &key, int index, ACE_TString &name)
static const ACE_TCHAR TRANSPORT_TEMPLATE_SECTION_NAME[]
#define ACE_ERROR_RETURN(X, Y)
int pullValues(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, ValueMap &values)
#define TheServiceParticipant
The Internal API and Implementation of OpenDDS.
ACE_TString transport_name
static const OPENDDS_STRING CUSTOM_ADD_DOMAIN_TO_PORT
typedef OPENDDS_LIST(SubsectionPair) KeyList
bool register_type(const TransportType_rch &type)
TransportConfig_rch global_config_
bool convertToInteger(const String &s, T &value)
bool process_customizations(const DDS::DomainId_t id, const TransportTemplate &tr_inst, ValueMap &customs)
static const OPENDDS_STRING CUSTOM_ADD_DOMAIN_TO_IP
int find(Container &c, const Key &key, typename Container::mapped_type *&value)