OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | List of all members
OpenDDS::RTPS::RtpsDiscovery::Config Class Reference

#include <RtpsDiscovery.h>

Inheritance diagram for OpenDDS::RTPS::RtpsDiscovery::Config:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::RTPS::RtpsDiscovery::Config:
Collaboration graph
[legend]

Public Member Functions

int discovery_config (ACE_Configuration_Heap &cf)
 

Detailed Description

Definition at line 351 of file RtpsDiscovery.h.

Member Function Documentation

◆ discovery_config()

int OpenDDS::RTPS::RtpsDiscovery::Config::discovery_config ( ACE_Configuration_Heap cf)

FUTURE: handle > 1 group.

Definition at line 49 of file RtpsDiscovery.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_ERROR_RETURN, ACE_TEXT(), OpenDDS::ICE::Configuration::change_password_period(), OpenDDS::ICE::Configuration::checklist_period(), OpenDDS::RTPS::RtpsDiscovery::config(), OpenDDS::ICE::Configuration::connectivity_check_ttl(), OpenDDS::DCPS::convertToDouble(), OpenDDS::DCPS::convertToInteger(), OpenDDS::RTPS::RtpsDiscovery::d0(), OpenDDS::RTPS::RtpsDiscovery::d1(), OpenDDS::DCPS::DCPS_debug_level, OpenDDS::ICE::Configuration::deferred_triggered_check_ttl(), OpenDDS::RTPS::RtpsDiscovery::dg(), OpenDDS::RTPS::RtpsDiscovery::dx(), OpenDDS::DCPS::TimeDuration::from_double(), OpenDDS::DCPS::TimeDuration::from_msec(), OpenDDS::ICE::Configuration::indication_period(), OpenDDS::ICE::Configuration::instance(), OpenDDS::DCPS::LogAddr::ip(), LM_DEBUG, LM_ERROR, name, OpenDDS::ICE::Configuration::nominated_ttl(), ACE_Configuration_Heap::open_section(), OPENDDS_STRING, OpenDDS::RTPS::RtpsDiscovery::pb(), OpenDDS::RTPS::RtpsDiscovery::pg(), OpenDDS::DCPS::processSections(), OpenDDS::DCPS::pullValues(), ACE_Configuration::root_section(), OpenDDS::DCPS::RTPS_SECTION_NAME, OpenDDS::ICE::Configuration::server_reflexive_address_period(), OpenDDS::ICE::Configuration::server_reflexive_indication_count(), ACE_INET_Addr::set(), OpenDDS::RTPS::RtpsDiscovery::spdp_send_addrs(), OpenDDS::ICE::Configuration::T_a(), TheServiceParticipant, and value.

50 {
53 
54  if (cf.open_section(root, RTPS_SECTION_NAME, 0, rtps_sect) == 0) {
55 
56  // Ensure there are no properties in this section
57  DCPS::ValueMap vm;
58  if (DCPS::pullValues(cf, rtps_sect, vm) > 0) {
59  // There are values inside [rtps_discovery]
60  ACE_ERROR_RETURN((LM_ERROR,
61  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
62  ACE_TEXT("rtps_discovery sections must have a subsection name\n")),
63  -1);
64  }
65  // Process the subsections of this section (the individual rtps_discovery/*)
66  DCPS::KeyList keys;
67  if (DCPS::processSections(cf, rtps_sect, keys) != 0) {
68  ACE_ERROR_RETURN((LM_ERROR,
69  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
70  ACE_TEXT("too many nesting layers in the [rtps] section.\n")),
71  -1);
72  }
73 
74  // Loop through the [rtps_discovery/*] sections
75  for (DCPS::KeyList::const_iterator it = keys.begin();
76  it != keys.end(); ++it) {
77  const OPENDDS_STRING& rtps_name = it->first;
78 
79  RtpsDiscovery_rch discovery = OpenDDS::DCPS::make_rch<RtpsDiscovery>(rtps_name);
80  RtpsDiscoveryConfig_rch config = discovery->config();
81 
82  // spdpaddr defaults to DCPSDefaultAddress if set
83  if (TheServiceParticipant->default_address().to_addr() != ACE_INET_Addr()) {
84  config->spdp_local_address(TheServiceParticipant->default_address().to_addr());
85  config->multicast_interface(DCPS::LogAddr::ip(TheServiceParticipant->default_address().to_addr()));
86  }
87 
88  DCPS::ValueMap values;
89  DCPS::pullValues(cf, it->second, values);
90  for (DCPS::ValueMap::const_iterator it = values.begin();
91  it != values.end(); ++it) {
92  const OPENDDS_STRING& name = it->first;
93  if (name == "ResendPeriod") {
94  const OPENDDS_STRING& value = it->second;
95  int resend = 0;
96  if (!DCPS::convertToInteger(value, resend)) {
97  ACE_ERROR_RETURN((LM_ERROR,
98  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
99  ACE_TEXT("Invalid entry (%C) for ResendPeriod in ")
100  ACE_TEXT("[rtps_discovery/%C] section.\n"),
101  value.c_str(), rtps_name.c_str()), -1);
102  }
103  config->resend_period(TimeDuration(resend));
104  } else if (name == "QuickResendRatio") {
105  const OPENDDS_STRING& value = it->second;
106  double ratio = 0.0;
107  if (!DCPS::convertToDouble(value, ratio)) {
108  ACE_ERROR_RETURN((LM_ERROR,
109  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
110  ACE_TEXT("Invalid entry (%C) for QuickResendRatio in ")
111  ACE_TEXT("[rtps_discovery/%C] section.\n"),
112  value.c_str(), rtps_name.c_str()), -1);
113  }
114  config->quick_resend_ratio(ratio);
115  } else if (name == "MinResendDelay") {
116  const OPENDDS_STRING& value = it->second;
117  int delay = 0;
118  if (!DCPS::convertToInteger(value, delay)) {
119  ACE_ERROR_RETURN((LM_ERROR,
120  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
121  ACE_TEXT("Invalid entry (%C) for MinResendDelay in ")
122  ACE_TEXT("[rtps_discovery/%C] section.\n"),
123  value.c_str(), rtps_name.c_str()), -1);
124  }
125  config->min_resend_delay(TimeDuration::from_msec(delay));
126  } else if (name == "LeaseDuration") {
127  const OPENDDS_STRING& value = it->second;
128  int duration = 0;
129  if (!DCPS::convertToInteger(value, duration)) {
130  ACE_ERROR_RETURN((LM_ERROR,
131  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
132  ACE_TEXT("Invalid entry (%C) for LeaseDuration in ")
133  ACE_TEXT("[rtps_discovery/%C] section.\n"),
134  value.c_str(), rtps_name.c_str()), -1);
135  }
136  config->lease_duration(TimeDuration(duration));
137  } else if (name == "MaxLeaseDuration") {
138  const OPENDDS_STRING& value = it->second;
139  int duration = 0;
140  if (!DCPS::convertToInteger(value, duration)) {
141  ACE_ERROR_RETURN((LM_ERROR,
142  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
143  ACE_TEXT("Invalid entry (%C) for MaxLeaseDuration in ")
144  ACE_TEXT("[rtps_discovery/%C] section.\n"),
145  value.c_str(), rtps_name.c_str()), -1);
146  }
147  config->max_lease_duration(TimeDuration(duration));
148 #ifdef OPENDDS_SECURITY
149  } else if (name == "SecurityUnsecureLeaseDuration") {
150  const OPENDDS_STRING& value = it->second;
151  int duration = 0;
152  if (!DCPS::convertToInteger(value, duration)) {
153  ACE_ERROR_RETURN((LM_ERROR,
154  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
155  ACE_TEXT("Invalid entry (%C) for SecurityUnsecureLeaseDuration in ")
156  ACE_TEXT("[rtps_discovery/%C] section.\n"),
157  value.c_str(), rtps_name.c_str()), -1);
158  }
159  config->security_unsecure_lease_duration(TimeDuration(duration));
160  } else if (name == "MaxParticipantsInAuthentication") {
161  const OPENDDS_STRING& value = it->second;
162  unsigned int max_participants = 0;
163  if (!DCPS::convertToInteger(value, max_participants)) {
164  ACE_ERROR_RETURN((LM_ERROR,
165  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
166  ACE_TEXT("Invalid entry (%C) for MaxParticipantsInAuthentication in ")
167  ACE_TEXT("[rtps_discovery/%C] section.\n"),
168  value.c_str(), rtps_name.c_str()), -1);
169  }
170  config->max_participants_in_authentication(max_participants);
171 #endif
172  } else if (name == "LeaseExtension") {
173  const OPENDDS_STRING& value = it->second;
174  int extension = 0;
175  if (!DCPS::convertToInteger(value, extension)) {
176  ACE_ERROR_RETURN((LM_ERROR,
177  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
178  ACE_TEXT("Invalid entry (%C) for LeaseExtension in ")
179  ACE_TEXT("[rtps_discovery/%C] section.\n"),
180  value.c_str(), rtps_name.c_str()), -1);
181  }
182  config->lease_extension(TimeDuration(extension));
183  } else if (name == "PB") {
184  const OPENDDS_STRING& value = it->second;
185  u_short pb = 0;
186  if (!DCPS::convertToInteger(value, pb)) {
187  ACE_ERROR_RETURN((LM_ERROR,
188  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
189  ACE_TEXT("Invalid entry (%C) for PB in ")
190  ACE_TEXT("[rtps_discovery/%C] section.\n"),
191  value.c_str(), rtps_name.c_str()), -1);
192  }
193  config->pb(pb);
194  } else if (name == "DG") {
195  const OPENDDS_STRING& value = it->second;
196  u_short dg = 0;
197  if (!DCPS::convertToInteger(value, dg)) {
198  ACE_ERROR_RETURN((LM_ERROR,
199  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
200  ACE_TEXT("Invalid entry (%C) for DG in ")
201  ACE_TEXT("[rtps_discovery/%C] section.\n"),
202  value.c_str(), rtps_name.c_str()), -1);
203  }
204  config->dg(dg);
205  } else if (name == "PG") {
206  const OPENDDS_STRING& value = it->second;
207  u_short pg = 0;
208  if (!DCPS::convertToInteger(value, pg)) {
209  ACE_ERROR_RETURN((LM_ERROR,
210  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
211  ACE_TEXT("Invalid entry (%C) for PG in ")
212  ACE_TEXT("[rtps_discovery/%C] section.\n"),
213  value.c_str(), rtps_name.c_str()), -1);
214  }
215  config->pg(pg);
216  } else if (name == "D0") {
217  const OPENDDS_STRING& value = it->second;
218  u_short d0 = 0;
219  if (!DCPS::convertToInteger(value, d0)) {
220  ACE_ERROR_RETURN((LM_ERROR,
221  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
222  ACE_TEXT("Invalid entry (%C) for D0 in ")
223  ACE_TEXT("[rtps_discovery/%C] section.\n"),
224  value.c_str(), rtps_name.c_str()), -1);
225  }
226  config->d0(d0);
227  } else if (name == "D1") {
228  const OPENDDS_STRING& value = it->second;
229  u_short d1 = 0;
230  if (!DCPS::convertToInteger(value, d1)) {
231  ACE_ERROR_RETURN((LM_ERROR,
232  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
233  ACE_TEXT("Invalid entry (%C) for D1 in ")
234  ACE_TEXT("[rtps_discovery/%C] section.\n"),
235  value.c_str(), rtps_name.c_str()), -1);
236  }
237  config->d1(d1);
238  } else if (name == "DX") {
239  const OPENDDS_STRING& value = it->second;
240  u_short dx = 0;
241  if (!DCPS::convertToInteger(value, dx)) {
242  ACE_ERROR_RETURN((LM_ERROR,
243  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
244  ACE_TEXT("Invalid entry (%C) for DX in ")
245  ACE_TEXT("[rtps_discovery/%C] section.\n"),
246  value.c_str(), rtps_name.c_str()), -1);
247  }
248  config->dx(dx);
249  } else if (name == "TTL") {
250  const OPENDDS_STRING& value = it->second;
251  unsigned short ttl_us = 0;
252  if (!DCPS::convertToInteger(value, ttl_us) || ttl_us > UCHAR_MAX) {
253  ACE_ERROR_RETURN((LM_ERROR,
254  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
255  ACE_TEXT("Invalid entry (%C) for TTL in ")
256  ACE_TEXT("[rtps_discovery/%C] section.\n"),
257  value.c_str(), rtps_name.c_str()), -1);
258  }
259  config->ttl(static_cast<unsigned char>(ttl_us));
260  } else if (name == "SendBufferSize") {
261  const OPENDDS_STRING& value = it->second;
262  ACE_INT32 send_buffer_size = 0;
263  if (!DCPS::convertToInteger(value, send_buffer_size)) {
264  ACE_ERROR_RETURN((LM_ERROR,
265  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
266  ACE_TEXT("Invalid entry (%C) for SendBufferSize in ")
267  ACE_TEXT("[rtps_discovery/%C] section.\n"),
268  value.c_str(), rtps_name.c_str()), -1);
269  }
270  config->send_buffer_size(send_buffer_size);
271  } else if (name == "RecvBufferSize") {
272  const OPENDDS_STRING& value = it->second;
273  ACE_INT32 recv_buffer_size = 0;
274  if (!DCPS::convertToInteger(value, recv_buffer_size)) {
275  ACE_ERROR_RETURN((LM_ERROR,
276  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
277  ACE_TEXT("Invalid entry (%C) for RecvBufferSize in ")
278  ACE_TEXT("[rtps_discovery/%C] section.\n"),
279  value.c_str(), rtps_name.c_str()), -1);
280  }
281  config->recv_buffer_size(recv_buffer_size);
282  } else if (name == "SedpMulticast") {
283  const OPENDDS_STRING& value = it->second;
284  int smInt = 0;
285  if (!DCPS::convertToInteger(value, smInt)) {
286  ACE_ERROR_RETURN((LM_ERROR,
287  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
288  ACE_TEXT("Invalid entry (%C) for SedpMulticast in ")
289  ACE_TEXT("[rtps_discovery/%C] section.\n"),
290  value.c_str(), rtps_name.c_str()), -1);
291  }
292  config->sedp_multicast(bool(smInt));
293  } else if (name == "MulticastInterface") {
294  config->multicast_interface(it->second);
295  } else if (name == "SedpLocalAddress") {
296  ACE_INET_Addr addr;
297  if (addr.set(it->second.c_str())) {
298  ACE_ERROR_RETURN((LM_ERROR,
299  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
300  ACE_TEXT("failed to parse SedpLocalAddress %C\n"),
301  it->second.c_str()),
302  -1);
303  }
304  config->sedp_local_address(addr);
305  } else if (name == "SedpAdvertisedLocalAddress") {
306  ACE_INET_Addr addr;
307  if (addr.set(it->second.c_str())) {
308  ACE_ERROR_RETURN((LM_ERROR,
309  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
310  ACE_TEXT("failed to parse SedpAdvertisedLocalAddress %C\n"),
311  it->second.c_str()),
312  -1);
313  }
314  config->sedp_advertised_address(addr);
315  } else if (name == "SpdpLocalAddress") {
316  ACE_INET_Addr addr;
317  if (addr.set(u_short(0), it->second.c_str())) {
318  ACE_ERROR_RETURN((LM_ERROR,
319  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
320  ACE_TEXT("failed to parse SpdpLocalAddress %C\n"),
321  it->second.c_str()),
322  -1);
323  }
324  config->spdp_local_address(addr);
325  } else if (name == "SpdpRequestRandomPort") {
326  const OPENDDS_STRING& value = it->second;
327  int smInt = 0;
328  if (!DCPS::convertToInteger(value, smInt)) {
329  ACE_ERROR_RETURN((LM_ERROR,
330  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
331  ACE_TEXT("Invalid entry (%C) for SpdpRequestRandomPort in ")
332  ACE_TEXT("[rtps_discovery/%C] section.\n"),
333  value.c_str(), rtps_name.c_str()), -1);
334  }
335  config->spdp_request_random_port(bool(smInt));
336  } else if (name == "GuidInterface") {
337  config->guid_interface(it->second);
338  } else if (name == "InteropMulticastOverride") {
339  /// FUTURE: handle > 1 group.
340  ACE_INET_Addr addr;
341  if (addr.set(u_short(0), it->second.c_str())) {
342  ACE_ERROR_RETURN((LM_ERROR,
343  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
344  ACE_TEXT("failed to parse InteropMulticastOverride %C\n"),
345  it->second.c_str()),
346  -1);
347  }
348  config->default_multicast_group(addr);
349  } else if (name == "SpdpSendAddrs") {
351  const OPENDDS_STRING& value = it->second;
352  size_t i = 0;
353  do {
354  i = value.find_first_not_of(' ', i); // skip spaces
355  const size_t n = value.find_first_of(", ", i);
356  spdp_send_addrs.push_back(value.substr(i, (n == OPENDDS_STRING::npos) ? n : n - i));
357  i = value.find(',', i);
358  } while (i++ != OPENDDS_STRING::npos); // skip past comma if there is one
359  config->spdp_send_addrs(spdp_send_addrs);
360  } else if (name == "SpdpRtpsRelayAddress") {
361  ACE_INET_Addr addr;
362  if (addr.set(it->second.c_str())) {
363  ACE_ERROR_RETURN((LM_ERROR,
364  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
365  ACE_TEXT("failed to parse SpdpRtpsRelayAddress %C\n"),
366  it->second.c_str()),
367  -1);
368  }
369  config->spdp_rtps_relay_address(addr);
370  } else if (name == "SpdpRtpsRelayBeaconPeriod") {
371  ACE_ERROR((LM_ERROR,
372  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
373  ACE_TEXT("Entry SpdpRtpsRelayBeaconPeriod is deprecated and will be ignored.\n")));
374  } else if (name == "SpdpRtpsRelaySendPeriod") {
375  const OPENDDS_STRING& value = it->second;
376  int period = 0;
377  if (!DCPS::convertToInteger(value, period)) {
378  ACE_ERROR_RETURN((LM_ERROR,
379  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
380  ACE_TEXT("Invalid entry (%C) for SpdpRtpsRelaySendPeriod in ")
381  ACE_TEXT("[rtps_discovery/%C] section.\n"),
382  value.c_str(), rtps_name.c_str()), -1);
383  }
384  config->spdp_rtps_relay_send_period(TimeDuration(period));
385  } else if (name == "SedpRtpsRelayAddress") {
386  ACE_INET_Addr addr;
387  if (addr.set(it->second.c_str())) {
388  ACE_ERROR_RETURN((LM_ERROR,
389  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
390  ACE_TEXT("failed to parse SedpRtpsRelayAddress %C\n"),
391  it->second.c_str()),
392  -1);
393  }
394  config->sedp_rtps_relay_address(addr);
395  } else if (name == "SedpRtpsRelayBeaconPeriod") {
396  ACE_ERROR((LM_ERROR,
397  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
398  ACE_TEXT("Entry SedpRtpsRelayBeaconPeriod is deprecated and will be ignored.\n")));
399  } else if (name == "RtpsRelayOnly") {
400  const OPENDDS_STRING& value = it->second;
401  int smInt = 0;
402  if (!DCPS::convertToInteger(value, smInt)) {
403  ACE_ERROR_RETURN((LM_ERROR,
404  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
405  ACE_TEXT("Invalid entry (%C) for RtpsRelayOnly in ")
406  ACE_TEXT("[rtps_discovery/%C] section.\n"),
407  value.c_str(), rtps_name.c_str()), -1);
408  }
409  config->rtps_relay_only(bool(smInt));
410  } else if (name == "UseRtpsRelay") {
411  const OPENDDS_STRING& value = it->second;
412  int smInt = 0;
413  if (!DCPS::convertToInteger(value, smInt)) {
414  ACE_ERROR_RETURN((LM_ERROR,
415  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
416  ACE_TEXT("Invalid entry (%C) for UseRtpsRelay in ")
417  ACE_TEXT("[rtps_discovery/%C] section.\n"),
418  value.c_str(), rtps_name.c_str()), -1);
419  }
420  config->use_rtps_relay(bool(smInt));
421 #ifdef OPENDDS_SECURITY
422  } else if (name == "SpdpStunServerAddress") {
423  ACE_INET_Addr addr;
424  if (addr.set(it->second.c_str())) {
425  ACE_ERROR_RETURN((LM_ERROR,
426  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
427  ACE_TEXT("failed to parse SpdpStunServerAddress %C\n"),
428  it->second.c_str()),
429  -1);
430  }
431  config->spdp_stun_server_address(addr);
432  } else if (name == "SedpStunServerAddress") {
433  ACE_INET_Addr addr;
434  if (addr.set(it->second.c_str())) {
435  ACE_ERROR_RETURN((LM_ERROR,
436  ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config(): ")
437  ACE_TEXT("failed to parse SedpStunServerAddress %C\n"),
438  it->second.c_str()),
439  -1);
440  }
441  config->sedp_stun_server_address(addr);
442  } else if (name == "UseIce") {
443  const OPENDDS_STRING& value = it->second;
444  int smInt = 0;
445  if (!DCPS::convertToInteger(value, smInt)) {
446  ACE_ERROR_RETURN((LM_ERROR,
447  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
448  ACE_TEXT("Invalid entry (%C) for UseIce in ")
449  ACE_TEXT("[rtps_discovery/%C] section.\n"),
450  value.c_str(), rtps_name.c_str()), -1);
451  }
452  config->use_ice(bool(smInt));
453  if (smInt && !TheServiceParticipant->get_security()) {
454  ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: Security must be enabled (-DCPSSecurity 1) when using ICE (UseIce)\n")), -1);
455  }
456  } else if (name == "IceTa") {
457  // In milliseconds.
458  const OPENDDS_STRING& string_value = it->second;
459  int int_value = 0;
460  if (DCPS::convertToInteger(string_value, int_value)) {
462  } else {
463  ACE_ERROR_RETURN((LM_ERROR,
464  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
465  ACE_TEXT("Invalid entry (%C) for IceTa in ")
466  ACE_TEXT("[rtps_discovery/%C] section.\n"),
467  string_value.c_str(), rtps_name.c_str()), -1);
468  }
469  } else if (name == "IceConnectivityCheckTTL") {
470  // In seconds.
471  const OPENDDS_STRING& string_value = it->second;
472  int int_value = 0;
473  if (DCPS::convertToInteger(string_value, int_value)) {
474  ICE::Configuration::instance()->connectivity_check_ttl(TimeDuration(int_value));
475  } else {
476  ACE_ERROR_RETURN((LM_ERROR,
477  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
478  ACE_TEXT("Invalid entry (%C) for IceConnectivityCheckTTL in ")
479  ACE_TEXT("[rtps_discovery/%C] section.\n"),
480  string_value.c_str(), rtps_name.c_str()), -1);
481  }
482  } else if (name == "IceChecklistPeriod") {
483  // In seconds.
484  const OPENDDS_STRING& string_value = it->second;
485  int int_value = 0;
486  if (DCPS::convertToInteger(string_value, int_value)) {
487  ICE::Configuration::instance()->checklist_period(TimeDuration(int_value));
488  } else {
489  ACE_ERROR_RETURN((LM_ERROR,
490  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
491  ACE_TEXT("Invalid entry (%C) for IceChecklistPeriod in ")
492  ACE_TEXT("[rtps_discovery/%C] section.\n"),
493  string_value.c_str(), rtps_name.c_str()), -1);
494  }
495  } else if (name == "IceIndicationPeriod") {
496  // In seconds.
497  const OPENDDS_STRING& string_value = it->second;
498  int int_value = 0;
499  if (DCPS::convertToInteger(string_value, int_value)) {
500  ICE::Configuration::instance()->indication_period(TimeDuration(int_value));
501  } else {
502  ACE_ERROR_RETURN((LM_ERROR,
503  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
504  ACE_TEXT("Invalid entry (%C) for IceIndicationPeriod in ")
505  ACE_TEXT("[rtps_discovery/%C] section.\n"),
506  string_value.c_str(), rtps_name.c_str()), -1);
507  }
508  } else if (name == "IceNominatedTTL") {
509  // In seconds.
510  const OPENDDS_STRING& string_value = it->second;
511  int int_value = 0;
512  if (DCPS::convertToInteger(string_value, int_value)) {
513  ICE::Configuration::instance()->nominated_ttl(TimeDuration(int_value));
514  } else {
515  ACE_ERROR_RETURN((LM_ERROR,
516  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
517  ACE_TEXT("Invalid entry (%C) for IceNominatedTTL in ")
518  ACE_TEXT("[rtps_discovery/%C] section.\n"),
519  string_value.c_str(), rtps_name.c_str()), -1);
520  }
521  } else if (name == "IceServerReflexiveAddressPeriod") {
522  // In seconds.
523  const OPENDDS_STRING& string_value = it->second;
524  int int_value = 0;
525  if (DCPS::convertToInteger(string_value, int_value)) {
527  } else {
528  ACE_ERROR_RETURN((LM_ERROR,
529  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
530  ACE_TEXT("Invalid entry (%C) for IceServerReflexiveAddressPeriod in ")
531  ACE_TEXT("[rtps_discovery/%C] section.\n"),
532  string_value.c_str(), rtps_name.c_str()), -1);
533  }
534  } else if (name == "IceServerReflexiveIndicationCount") {
535  const OPENDDS_STRING& string_value = it->second;
536  int int_value = 0;
537  if (DCPS::convertToInteger(string_value, int_value)) {
539  } else {
540  ACE_ERROR_RETURN((LM_ERROR,
541  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
542  ACE_TEXT("Invalid entry (%C) for IceServerReflexiveIndicationCount in ")
543  ACE_TEXT("[rtps_discovery/%C] section.\n"),
544  string_value.c_str(), rtps_name.c_str()), -1);
545  }
546  } else if (name == "IceDeferredTriggeredCheckTTL") {
547  // In seconds.
548  const OPENDDS_STRING& string_value = it->second;
549  int int_value = 0;
550  if (DCPS::convertToInteger(string_value, int_value)) {
552  } else {
553  ACE_ERROR_RETURN((LM_ERROR,
554  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
555  ACE_TEXT("Invalid entry (%C) for IceDeferredTriggeredCheckTTL in ")
556  ACE_TEXT("[rtps_discovery/%C] section.\n"),
557  string_value.c_str(), rtps_name.c_str()), -1);
558  }
559  } else if (name == "IceChangePasswordPeriod") {
560  // In seconds.
561  const OPENDDS_STRING& string_value = it->second;
562  int int_value = 0;
563  if (DCPS::convertToInteger(string_value, int_value)) {
564  ICE::Configuration::instance()->change_password_period(TimeDuration(int_value));
565  } else {
566  ACE_ERROR_RETURN((LM_ERROR,
567  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
568  ACE_TEXT("Invalid entry (%C) for IceChangePasswordPeriod in ")
569  ACE_TEXT("[rtps_discovery/%C] section.\n"),
570  string_value.c_str(), rtps_name.c_str()), -1);
571  }
572  } else if (name == "MaxAuthTime") {
573  // In seconds.
574  const OPENDDS_STRING& string_value = it->second;
575  int int_value = 0;
576  if (DCPS::convertToInteger(string_value, int_value)) {
577  config->max_auth_time(TimeDuration(int_value));
578  } else {
579  ACE_ERROR_RETURN((LM_ERROR,
580  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
581  ACE_TEXT("Invalid entry (%C) for MaxAuthTime in ")
582  ACE_TEXT("[rtps_discovery/%C] section.\n"),
583  string_value.c_str(), rtps_name.c_str()), -1);
584  }
585  } else if (name == "AuthResendPeriod") {
586  // In seconds.
587  const OPENDDS_STRING& string_value = it->second;
588  double double_value = 0.0;
589  if (DCPS::convertToDouble(string_value, double_value)) {
590  config->auth_resend_period(TimeDuration::from_double(double_value));
591  } else {
592  ACE_ERROR_RETURN((LM_ERROR,
593  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
594  ACE_TEXT("Invalid entry (%C) for AuthResendPeriod in ")
595  ACE_TEXT("[rtps_discovery/%C] section.\n"),
596  string_value.c_str(), rtps_name.c_str()), -1);
597  }
598 #endif /* OPENDDS_SECURITY */
599  } else if (name == "MaxSpdpSequenceMsgResetChecks") {
600  const OPENDDS_STRING& string_value = it->second;
601  u_short value = 0;
602  if (DCPS::convertToInteger(string_value, value)) {
603  config->max_spdp_sequence_msg_reset_check(value);
604  } else {
605  ACE_ERROR_RETURN((LM_ERROR,
606  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
607  ACE_TEXT("Invalid entry (%C) for MaxSpdpSequenceMsgResetChecks in ")
608  ACE_TEXT("[rtps_discovery/%C] section.\n"),
609  string_value.c_str(), rtps_name.c_str()), -1);
610  }
611  } else if (name == "SedpMaxMessageSize") {
612  const OPENDDS_STRING& string_value = it->second;
613  size_t value = 0;
614  if (DCPS::convertToInteger(string_value, value)) {
615  config->sedp_max_message_size(value);
616  } else {
617  ACE_ERROR_RETURN((LM_ERROR,
618  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
619  ACE_TEXT("Invalid entry (%C) for SedpMaxMessageSize in ")
620  ACE_TEXT("[rtps_discovery/%C] section.\n"),
621  string_value.c_str(), rtps_name.c_str()), -1);
622  }
623  } else if (name == "SedpHeartbeatPeriod") {
624  const OPENDDS_STRING& string_value = it->second;
625  int value = 0;
626  if (DCPS::convertToInteger(string_value, value)) {
627  config->sedp_heartbeat_period(TimeDuration::from_msec(value));
628  } else {
629  ACE_ERROR_RETURN((LM_ERROR,
630  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
631  ACE_TEXT("Invalid entry (%C) for SedpHeartbeatPeriod in ")
632  ACE_TEXT("[rtps_discovery/%C] section.\n"),
633  string_value.c_str(), rtps_name.c_str()), -1);
634  }
635  } else if (name == "SedpNakResponseDelay") {
636  const OPENDDS_STRING& string_value = it->second;
637  int value = 0;
638  if (DCPS::convertToInteger(string_value, value)) {
639  config->sedp_nak_response_delay(TimeDuration::from_msec(value));
640  } else {
641  ACE_ERROR_RETURN((LM_ERROR,
642  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
643  ACE_TEXT("Invalid entry (%C) for SedpNakResponseDelay in ")
644  ACE_TEXT("[rtps_discovery/%C] section.\n"),
645  string_value.c_str(), rtps_name.c_str()), -1);
646  }
647  } else if (name == "SedpSendDelay") {
648  const OPENDDS_STRING& string_value = it->second;
649  int value = 0;
650  if (DCPS::convertToInteger(string_value, value)) {
651  config->sedp_send_delay(TimeDuration::from_msec(value));
652  } else {
653  ACE_ERROR_RETURN((LM_ERROR,
654  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
655  ACE_TEXT("Invalid entry (%C) for SedpSendDelay in ")
656  ACE_TEXT("[rtps_discovery/%C] section.\n"),
657  string_value.c_str(), rtps_name.c_str()), -1);
658  }
659  } else if (name == "SedpFragmentReassemblyTimeout") {
660  const OPENDDS_STRING& string_value = it->second;
661  int value = 0;
662  if (DCPS::convertToInteger(string_value, value)) {
663  config->sedp_fragment_reassembly_timeout(TimeDuration::from_msec(value));
664  } else {
665  ACE_ERROR_RETURN((LM_ERROR,
666  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
667  ACE_TEXT("Invalid entry (%C) for SedpFragmentReassemblyTimeout in ")
668  ACE_TEXT("[rtps_discovery/%C] section.\n"),
669  string_value.c_str(), rtps_name.c_str()), -1);
670  }
671  } else if (name == "SedpPassiveConnectDuration") {
672  const OPENDDS_STRING& string_value = it->second;
673  int value = 0;
674  if (DCPS::convertToInteger(string_value, value)) {
675  config->sedp_passive_connect_duration(TimeDuration::from_msec(value));
676  } else {
677  ACE_ERROR_RETURN((LM_ERROR,
678  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
679  ACE_TEXT("Invalid entry (%C) for SedpPassiveConnectDuration in ")
680  ACE_TEXT("[rtps_discovery/%C] section.\n"),
681  string_value.c_str(), rtps_name.c_str()), -1);
682  }
683  } else if (name == "SecureParticipantUserData") {
684  const OPENDDS_STRING& string_value = it->second;
685  int int_value = 0;
686  if (!DCPS::convertToInteger(string_value, int_value)) {
687  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscovery::Config::discovery_config: ")
688  ACE_TEXT("Invalid entry (%C) for SecureParticipantUserData in ")
689  ACE_TEXT("[rtps_discovery/%C] section.\n"),
690  string_value.c_str(), rtps_name.c_str()));
691  return -1;
692  }
693  config->secure_participant_user_data(int_value);
694  } else if (name == "Customization") {
695  if (DCPS::DCPS_debug_level > 0) {
696  ACE_DEBUG((LM_DEBUG,
697  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
698  ACE_TEXT("%C section has a Customization setting.\n"),
699  rtps_name.c_str()));
700  }
701  } else if (name == "UndirectedSpdp") {
702  const OPENDDS_STRING& value = it->second;
703  int smInt = 0;
704  if (!DCPS::convertToInteger(value, smInt)) {
705  ACE_ERROR_RETURN((LM_ERROR,
706  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
707  ACE_TEXT("Invalid entry (%C) for UndirectedSpdp in ")
708  ACE_TEXT("[rtps_discovery/%C] section.\n"),
709  value.c_str(), rtps_name.c_str()), -1);
710  }
711  config->undirected_spdp(bool(smInt));
712  } else if (name == "PeriodicDirectedSpdp") {
713  const OPENDDS_STRING& value = it->second;
714  int smInt = 0;
715  if (!DCPS::convertToInteger(value, smInt)) {
716  ACE_ERROR_RETURN((LM_ERROR,
717  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
718  ACE_TEXT("Invalid entry (%C) for PeriodicDirectedSpdp in ")
719  ACE_TEXT("[rtps_discovery/%C] section.\n"),
720  value.c_str(), rtps_name.c_str()), -1);
721  }
722  config->periodic_directed_spdp(bool(smInt));
723  } else if (name == "TypeLookupServiceReplyTimeout") {
724  const OPENDDS_STRING& value = it->second;
725  int timeout = 0;
726  if (!DCPS::convertToInteger(value, timeout)) {
727  ACE_ERROR_RETURN((LM_ERROR,
728  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
729  ACE_TEXT("Invalid entry (%C) for TypeLookupServiceReplyTimeout in ")
730  ACE_TEXT("[rtps_discovery/%C] section.\n"),
731  value.c_str(), rtps_name.c_str()), -1);
732  }
733  config->max_type_lookup_service_reply_period(TimeDuration::from_msec(timeout));
734  } else if (name == "UseXTypes") {
735  const OPENDDS_STRING& value = it->second;
736  int smInt = 0;
737  bool valid = value.size() == 1 && DCPS::convertToInteger(value, smInt) &&
738  smInt >= 0 && smInt <= 2;
739  if (valid) {
740  config->use_xtypes(static_cast<RtpsDiscoveryConfig::UseXTypes>(smInt));
741  } else {
742  valid = config->use_xtypes(value.c_str());
743  }
744  if (!valid) {
745  ACE_ERROR((LM_ERROR,
746  "(%P|%t) RtpsDiscovery::Config::discovery_config: "
747  "Invalid entry (%C) for UseXTypes in "
748  "[rtps_discovery/%C] section.\n",
749  value.c_str(), rtps_name.c_str()));
750  return -1;
751  }
752  } else if (name == "SedpResponsiveMode") {
753  const OPENDDS_STRING& value = it->second;
754  int smInt = 0;
755  if (!DCPS::convertToInteger(value, smInt)) {
756  ACE_ERROR_RETURN((LM_ERROR,
757  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
758  ACE_TEXT("Invalid entry (%C) for SedpResponsiveMode in ")
759  ACE_TEXT("[rtps_discovery/%C] section.\n"),
760  value.c_str(), rtps_name.c_str()), -1);
761  }
762  config->sedp_responsive_mode(bool(smInt));
763  } else if (name == "SedpReceivePreallocatedMessageBlocks") {
764  const String& string_value = it->second;
765  size_t value;
766  if (DCPS::convertToInteger(string_value, value)) {
767  config->sedp_receive_preallocated_message_blocks(value);
768  } else {
769  ACE_ERROR_RETURN((LM_ERROR,
770  "(%P|%t) RtpsDiscovery::Config::discovery_config(): "
771  "Invalid entry (%C) for SedpReceivePreallocatedMessageBlocks in "
772  "[rtps_discovery/%C] section.\n",
773  string_value.c_str(), rtps_name.c_str()), -1);
774  }
775  } else if (name == "SedpReceivePreallocatedDataBlocks") {
776  const String& string_value = it->second;
777  size_t value = 0;
778  if (DCPS::convertToInteger(string_value, value)) {
779  config->sedp_receive_preallocated_data_blocks(value);
780  } else {
781  ACE_ERROR_RETURN((LM_ERROR,
782  "(%P|%t) RtpsDiscovery::Config::discovery_config(): "
783  "Invalid entry (%C) for SedpReceivePreallocatedDataBlocks in "
784  "[rtps_discovery/%C] section.\n",
785  string_value.c_str(), rtps_name.c_str()), -1);
786  }
787  } else if (name == "CheckSourceIp") {
788  const OPENDDS_STRING& value = it->second;
789  int smInt = 0;
790  if (!DCPS::convertToInteger(value, smInt)) {
791  ACE_ERROR_RETURN((LM_ERROR,
792  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config ")
793  ACE_TEXT("Invalid entry (%C) for CheckSourceIp in ")
794  ACE_TEXT("[rtps_discovery/%C] section.\n"),
795  value.c_str(), rtps_name.c_str()), -1);
796  }
797  config->check_source_ip(bool(smInt));
798  } else {
799  ACE_ERROR_RETURN((LM_ERROR,
800  ACE_TEXT("(%P|%t) RtpsDiscovery::Config::discovery_config(): ")
801  ACE_TEXT("Unexpected entry (%C) in [rtps_discovery/%C] section.\n"),
802  name.c_str(), rtps_name.c_str()), -1);
803  }
804  }
805 
806  TheServiceParticipant->add_discovery(discovery);
807  }
808  }
809 
810  // If the default RTPS discovery object has not been configured,
811  // instantiate it now.
812  const DCPS::Service_Participant::RepoKeyDiscoveryMap& discoveryMap = TheServiceParticipant->discoveryMap();
813  if (discoveryMap.find(Discovery::DEFAULT_RTPS) == discoveryMap.end()) {
814  TheServiceParticipant->add_discovery(OpenDDS::DCPS::make_rch<RtpsDiscovery>(Discovery::DEFAULT_RTPS));
815  }
816 
817  return 0;
818 }
#define ACE_DEBUG(X)
#define ACE_ERROR(X)
AddrVec spdp_send_addrs() const
const LogLevel::Value value
Definition: debug.cpp:61
std::string String
void server_reflexive_address_period(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:118
RtpsDiscoveryConfig_rch config() const
void server_reflexive_indication_count(size_t x)
Definition: RTPS/ICE/Ice.h:127
void indication_period(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:100
virtual const ACE_Configuration_Section_Key & root_section(void) const
OpenDDS::DCPS::RcHandle< RtpsDiscoveryConfig > RtpsDiscoveryConfig_rch
Definition: RtpsDiscovery.h:38
void deferred_triggered_check_ttl(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:136
void checklist_period(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:91
void T_a(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:73
void nominated_ttl(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:109
#define OPENDDS_STRING
static TimeDuration from_msec(const ACE_UINT64 &ms)
void change_password_period(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:145
RtpsDiscoveryConfig::AddrVec AddrVec
Definition: RtpsDiscovery.h:57
static const ACE_TCHAR RTPS_SECTION_NAME[]
const char *const name
Definition: debug.cpp:60
int set(const ACE_INET_Addr &)
ACE_TEXT("TCP_Factory")
bool convertToDouble(const String &s, T &value)
OpenDDS_Dcps_Export unsigned int DCPS_debug_level
Definition: debug.cpp:30
OpenDDS::DCPS::RcHandle< RtpsDiscovery > RtpsDiscovery_rch
virtual int open_section(const ACE_Configuration_Section_Key &base, const ACE_TCHAR *sub_section, bool create, ACE_Configuration_Section_Key &result)
static Configuration * instance()
Definition: Ice.cpp:109
void connectivity_check_ttl(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:82
static TimeDuration from_double(double duration)
int processSections(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, KeyList &subsections)
Definition: ConfigUtils.cpp:41
#define ACE_ERROR_RETURN(X, Y)
static const String ip(const ACE_INET_Addr &addr)
Definition: LogAddr.cpp:15
int pullValues(ACE_Configuration_Heap &cf, const ACE_Configuration_Section_Key &key, ValueMap &values)
Definition: ConfigUtils.cpp:17
#define TheServiceParticipant
bool convertToInteger(const String &s, T &value)

The documentation for this class was generated from the following files: