OpenDDS  Snapshot(2023/04/28-20:55)
RtpsDiscoveryConfig.h
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #ifndef OPENDDS_DCPS_RTPS_RTPSDISCOVERYCONFIG_H
7 #define OPENDDS_DCPS_RTPS_RTPSDISCOVERYCONFIG_H
8 
9 #include "Spdp.h"
10 
11 #include <dds/DCPS/debug.h>
12 #include <dds/DCPS/AtomicBool.h>
13 
15 
16 namespace OpenDDS {
17 namespace RTPS {
18 
19 using DCPS::log_level;
20 using DCPS::LogLevel;
21 using DCPS::AtomicBool;
22 
24 public:
25  typedef OPENDDS_VECTOR(OPENDDS_STRING) AddrVec;
26 
27  enum UseXTypes {
28  XTYPES_NONE = 0, ///< Turn off support for XTypes
29  XTYPES_MINIMAL, ///< Only use minimal TypeObjects
30  XTYPES_COMPLETE ///< Use both minimal and complete TypeObjects
31  };
32 
34 
36  {
38  return resend_period_;
39  }
40  void resend_period(const DCPS::TimeDuration& period)
41  {
43  resend_period_ = period;
44  }
45 
46  double quick_resend_ratio() const
47  {
49  return quick_resend_ratio_;
50  }
51  void quick_resend_ratio(double ratio)
52  {
54  quick_resend_ratio_ = ratio;
55  }
57  {
59  return min_resend_delay_;
60  }
62  {
64  min_resend_delay_ = delay;
65  }
66 
68  {
70  return lease_duration_;
71  }
72  void lease_duration(const DCPS::TimeDuration& period)
73  {
75  lease_duration_ = period;
76  }
77 
79  {
81  return max_lease_duration_;
82  }
84  {
86  max_lease_duration_ = period;
87  }
88 
89 #ifdef OPENDDS_SECURITY
91  {
93  return security_unsecure_lease_duration_;
94  }
96  {
98  security_unsecure_lease_duration_ = period;
99  }
100 
102  {
104  return max_participants_in_authentication_;
105  }
107  {
109  max_participants_in_authentication_ = m;
110  }
111 #endif
112 
114  {
116  return lease_extension_;
117  }
119  {
121  lease_extension_ = period;
122  }
123 
124  u_short pb() const
125  {
126  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, u_short());
127  return pb_;
128  }
129  void pb(u_short port_base)
130  {
132  pb_ = port_base;
133  }
134 
135  u_short dg() const
136  {
137  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, u_short());
138  return dg_;
139  }
140  void dg(u_short domain_gain)
141  {
143  dg_ = domain_gain;
144  }
145 
146  u_short pg() const
147  {
148  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, u_short());
149  return pg_;
150  }
151  void pg(u_short participant_gain)
152  {
154  pg_ = participant_gain;
155  }
156 
157  u_short d0() const
158  {
159  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, u_short());
160  return d0_;
161  }
162  void d0(u_short offset_zero)
163  {
165  d0_ = offset_zero;
166  }
167 
168  u_short d1() const
169  {
170  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, u_short());
171  return d1_;
172  }
173  void d1(u_short offset_one)
174  {
176  d1_ = offset_one;
177  }
178 
179  u_short dx() const
180  {
181  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, u_short());
182  return dx_;
183  }
184  void dx(u_short offset_two)
185  {
187  dx_ = offset_two;
188  }
189 
190  unsigned char ttl() const
191  {
193  return ttl_;
194  }
195  void ttl(unsigned char time_to_live)
196  {
198  ttl_ = time_to_live;
199  }
200 
201  ACE_INT32 send_buffer_size() const
202  {
204  return send_buffer_size_;
205  }
206  void send_buffer_size(ACE_INT32 buffer_size)
207  {
209  send_buffer_size_ = buffer_size;
210  }
211 
212  ACE_INT32 recv_buffer_size() const
213  {
215  return recv_buffer_size_;
216  }
217  void recv_buffer_size(ACE_INT32 buffer_size)
218  {
220  recv_buffer_size_ = buffer_size;
221  }
222 
224  {
226  return sedp_local_address_;
227  }
229  {
230  if (mi.get_type() == AF_INET) {
232  sedp_local_address_ = mi;
233  } else {
234  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::sedp_local_address set failed because address family is not AF_INET\n")));
235  }
236  }
237 
239  {
241  return sedp_advertised_address_;
242  }
244  {
245  if (mi.get_type() == AF_INET) {
247  sedp_advertised_address_ = mi;
248  } else {
249  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::sedp_local_address set failed because address family is not AF_INET\n")));
250  }
251  }
252 
254  {
256  return spdp_local_address_;
257  }
259  {
260  if (mi.get_type() == AF_INET) {
262  spdp_local_address_ = mi;
263  } else {
264  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::spdp_local_address set failed because address family is not AF_INET\n")));
265  }
266  }
267 
268  bool sedp_multicast() const
269  {
270  return sedp_multicast_;
271  }
272  void sedp_multicast(bool sm)
273  {
274  sedp_multicast_ = sm;
275  }
276 
278  {
280  return multicast_interface_;
281  }
283  {
285  multicast_interface_ = mi;
286  }
287 
289  {
291  return default_multicast_group_;
292  }
294  {
295  if (group.get_type() == AF_INET) {
297  default_multicast_group_ = group;
298  } else {
299  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::default_multicast_group set failed because address family is not AF_INET\n")));
300  }
301  }
302 
303  u_short port_common(DDS::DomainId_t domain) const
304  {
306  // Ports are set by the formulas in RTPS v2.1 Table 9.8
307  return pb_ + (dg_ * domain);
308  }
309 
310  ACE_INET_Addr multicast_address(u_short port_common) const
311  {
313 
314  ACE_INET_Addr addr = default_multicast_group_;
315  // Ports are set by the formulas in RTPS v2.1 Table 9.8
316  addr.set_port_number(port_common + d0_);
317  return addr;
318  }
319 
320 #ifdef ACE_HAS_IPV6
321  ACE_INET_Addr ipv6_spdp_local_address() const
322  {
324  return ipv6_spdp_local_address_;
325  }
326  void ipv6_spdp_local_address(const ACE_INET_Addr& mi)
327  {
328  if (mi.get_type() == AF_INET6) {
330  ipv6_spdp_local_address_ = mi;
331  } else {
332  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::ipv6_spdp_local_address set failed because address family is not AF_INET6\n")));
333  }
334  }
335 
336  ACE_INET_Addr ipv6_sedp_local_address() const
337  {
339  return ipv6_sedp_local_address_;
340  }
341  void ipv6_sedp_local_address(const ACE_INET_Addr& mi)
342  {
343  if (mi.get_type() == AF_INET6) {
345  ipv6_sedp_local_address_ = mi;
346  } else {
347  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::ipv6_sedp_local_address set failed because address family is not AF_INET6\n")));
348  }
349  }
350 
351  ACE_INET_Addr ipv6_sedp_advertised_address() const
352  {
354  return ipv6_sedp_advertised_address_;
355  }
356  void ipv6_sedp_advertised_address(const ACE_INET_Addr& mi)
357  {
358  if (mi.get_type() == AF_INET6) {
360  ipv6_sedp_advertised_address_ = mi;
361  } else {
362  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::ipv6_sedp_advertised_address set failed because address family is not AF_INET6\n")));
363  }
364  }
365 
366  ACE_INET_Addr ipv6_default_multicast_group() const
367  {
369  return ipv6_default_multicast_group_;
370  }
371  void ipv6_default_multicast_group(const ACE_INET_Addr& group)
372  {
373  if (group.get_type() == AF_INET6) {
375  ipv6_default_multicast_group_ = group;
376  } else {
377  ACE_ERROR((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: RtpsDiscoveryConfig::ipv6_default_multicast_group set failed because address family is not AF_INET6\n")));
378  }
379  }
380 
381  ACE_INET_Addr ipv6_multicast_address(u_short port_common) const
382  {
384 
385  ACE_INET_Addr addr = ipv6_default_multicast_group_;
386  // Ports are set by the formulas in RTPS v2.1 Table 9.8
387  addr.set_port_number(port_common + d0_);
388  return addr;
389  }
390 
391 #endif
392 
394  {
395  return spdp_request_random_port_;
396  }
398  {
399  spdp_request_random_port_ = f;
400  }
401 
403  {
405  return guid_interface_;
406  }
408  {
410  guid_interface_ = gi;
411  }
412 
413  AddrVec spdp_send_addrs() const
414  {
415  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, AddrVec());
416  return spdp_send_addrs_;
417  }
418  void spdp_send_addrs(const AddrVec& addrs)
419  {
421  spdp_send_addrs_ = addrs;
422  }
423 
425  {
427  return max_auth_time_;
428  }
430  {
432  max_auth_time_ = x;
433  }
434 
436  {
438  return auth_resend_period_;
439  }
441  {
443  auth_resend_period_ = x;
444  }
445 
447  {
448  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, u_short());
449  return max_spdp_sequence_msg_reset_check_;
450  }
451  void max_spdp_sequence_msg_reset_check(u_short reset_value)
452  {
454  max_spdp_sequence_msg_reset_check_ = reset_value;
455  }
456 
458  {
460  return spdp_rtps_relay_address_;
461  }
463  {
465  spdp_rtps_relay_address_ = address;
466  }
467 
469  {
471  return spdp_rtps_relay_send_period_;
472  }
474  {
476  spdp_rtps_relay_send_period_ = period;
477  }
478 
480  {
482  return sedp_rtps_relay_address_;
483  }
485  {
487  sedp_rtps_relay_address_ = address;
488  }
489 
490  bool use_rtps_relay() const
491  {
492  return use_rtps_relay_;
493  }
494  void use_rtps_relay(bool f)
495  {
496  use_rtps_relay_ = f;
497  }
498 
499  bool rtps_relay_only() const
500  {
501  return rtps_relay_only_;
502  }
503  void rtps_relay_only(bool f)
504  {
505  rtps_relay_only_ = f;
506  }
507 
509  {
511  return spdp_stun_server_address_;
512  }
514  {
516  spdp_stun_server_address_ = address;
517  }
518 
520  {
522  return sedp_stun_server_address_;
523  }
525  {
527  sedp_stun_server_address_ = address;
528  }
529 
530  bool use_ice() const
531  {
532  return use_ice_;
533  }
534  void use_ice(bool ui)
535  {
536  use_ice_ = ui;
537  }
538 
539  size_t sedp_max_message_size() const
540  {
541  ACE_GUARD_RETURN(ACE_Thread_Mutex, g, lock_, size_t());
542  return sedp_max_message_size_;
543  }
545  {
547  sedp_max_message_size_ = value;
548  }
549 
550  bool undirected_spdp() const
551  {
552  return undirected_spdp_;
553  }
555  {
556  undirected_spdp_ = value;
557  }
558 
560  {
561  return periodic_directed_spdp_;
562  }
564  {
565  periodic_directed_spdp_ = value;
566  }
567 
569  {
570  return secure_participant_user_data_;
571  }
573  {
574  secure_participant_user_data_ = value;
575  }
576 
578  {
580  return max_type_lookup_service_reply_period_;
581  }
583  {
585  max_type_lookup_service_reply_period_ = x;
586  }
587 
588  bool use_xtypes() const
589  {
591  return use_xtypes_ != XTYPES_NONE;
592  }
593  void use_xtypes(UseXTypes use_xtypes)
594  {
596  use_xtypes_ = use_xtypes;
597  }
598  bool use_xtypes(const char* str)
599  {
601  struct NameValue {
602  const char* name;
604  };
605  static const NameValue entries[] = {
606  {"no", XTYPES_NONE},
607  {"minimal", XTYPES_MINIMAL},
608  {"complete", XTYPES_COMPLETE}
609  };
610 
611  for (size_t i = 0; i < sizeof entries / sizeof entries[0]; ++i) {
612  if (0 == std::strcmp(entries[i].name, str)) {
613  use_xtypes_ = entries[i].value;
614  return true;
615  }
616  }
617  if (log_level >= LogLevel::Warning) {
618  ACE_ERROR((LM_WARNING, "(%P|%t) WARNING: RtpsDiscoveryConfig::use_xtypes: "
619  "invalid XTypes configuration: %C\n", str));
620  }
621  return false;
622  }
623  bool use_xtypes_complete() const
624  {
626  return use_xtypes_ == XTYPES_COMPLETE;
627  }
628 
630  {
632  return sedp_heartbeat_period_;
633  }
635  {
637  sedp_heartbeat_period_ = period;
638  }
639 
641  {
643  return sedp_nak_response_delay_;
644  }
646  {
648  sedp_nak_response_delay_ = period;
649  }
650 
652  {
654  return sedp_send_delay_;
655  }
657  {
659  sedp_send_delay_ = period;
660  }
661 
663  {
665  return sedp_passive_connect_duration_;
666  }
668  {
670  sedp_passive_connect_duration_ = period;
671  }
672 
674  {
676  return sedp_fragment_reassembly_timeout_;
677  }
679  {
681  sedp_fragment_reassembly_timeout_ = timeout;
682  }
683 
685  {
687  return participant_flags_;
688  }
689  void participant_flags(CORBA::ULong participant_flags)
690  {
692  participant_flags_ = participant_flags;
693  }
694 
695  bool sedp_responsive_mode() const
696  {
697  return sedp_responsive_mode_;
698  }
699  void sedp_responsive_mode(bool sedp_responsive_mode)
700  {
701  sedp_responsive_mode_ = sedp_responsive_mode;
702  }
703 
705  {
707  return sedp_receive_preallocated_message_blocks_;
708  }
710  {
712  sedp_receive_preallocated_message_blocks_ = n;
713  }
714 
716  {
718  return sedp_receive_preallocated_data_blocks_;
719  }
721  {
723  sedp_receive_preallocated_data_blocks_ = n;
724  }
725 
726  bool check_source_ip() const
727  {
728  return check_source_ip_;
729  }
730  void check_source_ip(bool flag)
731  {
732  check_source_ip_ = flag;
733  }
734 
735 private:
742 #ifdef OPENDDS_SECURITY
745 #endif
747  u_short pb_, dg_, pg_, d0_, d1_, dx_;
748  unsigned char ttl_;
749  ACE_INT32 send_buffer_size_;
750  ACE_INT32 recv_buffer_size_;
753  ACE_INET_Addr sedp_local_address_, sedp_advertised_address_, spdp_local_address_;
754  ACE_INET_Addr default_multicast_group_; /// FUTURE: handle > 1 group.
755 #ifdef ACE_HAS_IPV6
756  ACE_INET_Addr ipv6_sedp_local_address_, ipv6_sedp_advertised_address_, ipv6_spdp_local_address_;
757  ACE_INET_Addr ipv6_default_multicast_group_;
758 #endif
776  /// Should participant user data QoS only be sent when the message is secure?
787  size_t sedp_receive_preallocated_message_blocks_, sedp_receive_preallocated_data_blocks_;
789 };
790 
792 
793 } // namespace RTPS
794 } // namespace OpenDDS
795 
797 
798 #endif /* OPENDDS_DCPS_RTPS_RTPSDISCOVERYCONFIG_H */
DCPS::TimeDuration min_resend_delay() const
#define ACE_ERROR(X)
#define ACE_GUARD(MUTEX, OBJ, LOCK)
const LogLevel::Value value
Definition: debug.cpp:61
DCPS::TimeDuration lease_extension() const
void lease_extension(const DCPS::TimeDuration &period)
ACE_INET_Addr spdp_rtps_relay_address() const
void sedp_passive_connect_duration(const DCPS::TimeDuration &period)
void sedp_heartbeat_period(const DCPS::TimeDuration &period)
void guid_interface(const OPENDDS_STRING &gi)
void max_type_lookup_service_reply_period(const DCPS::TimeDuration &x)
DCPS::TimeDuration sedp_heartbeat_period() const
void resend_period(const DCPS::TimeDuration &period)
void sedp_fragment_reassembly_timeout(const DCPS::TimeDuration &timeout)
void participant_flags(CORBA::ULong participant_flags)
void sedp_stun_server_address(const ACE_INET_Addr &address)
void sedp_nak_response_delay(const DCPS::TimeDuration &period)
OpenDDS::DCPS::RcHandle< RtpsDiscoveryConfig > RtpsDiscoveryConfig_rch
Definition: RtpsDiscovery.h:38
void auth_resend_period(const DCPS::TimeDuration &x)
ACE_INET_Addr default_multicast_group() const
DCPS::TimeDuration security_unsecure_lease_duration_
void send_buffer_size(ACE_INT32 buffer_size)
ACE_Guard< ACE_Thread_Mutex > lock_
int get_type(void) const
void recv_buffer_size(ACE_INT32 buffer_size)
void max_spdp_sequence_msg_reset_check(u_short reset_value)
void sedp_responsive_mode(bool sedp_responsive_mode)
void ttl(unsigned char time_to_live)
void min_resend_delay(const DCPS::TimeDuration &delay)
#define OPENDDS_STRING
void pg(u_short participant_gain)
DCPS::TimeDuration resend_period() const
DCPS::TimeDuration max_auth_time() const
DCPS::TimeDuration sedp_fragment_reassembly_timeout() const
DCPS::TimeDuration sedp_nak_response_delay() const
DOMAINID_TYPE_NATIVE DomainId_t
void spdp_stun_server_address(const ACE_INET_Addr &address)
void max_auth_time(const DCPS::TimeDuration &x)
ACE_CDR::ULong ULong
u_short port_common(DDS::DomainId_t domain) const
ACE_INET_Addr sedp_rtps_relay_address() const
AtomicBool secure_participant_user_data_
Should participant user data QoS only be sent when the message is secure?
#define OpenDDS_Rtps_Export
Definition: rtps_export.h:23
ACE_INET_Addr sedp_stun_server_address() const
void use_xtypes(UseXTypes use_xtypes)
#define ACE_GUARD_RETURN(MUTEX, OBJ, LOCK, RETURN)
void lease_duration(const DCPS::TimeDuration &period)
#define AF_INET
void spdp_rtps_relay_address(const ACE_INET_Addr &address)
void sedp_rtps_relay_address(const ACE_INET_Addr &address)
ACE_INET_Addr sedp_advertised_address() const
ACE_INET_Addr multicast_address(u_short port_common) const
LM_WARNING
DCPS::TimeDuration sedp_fragment_reassembly_timeout_
DCPS::TimeDuration sedp_send_delay() const
DCPS::TimeDuration security_unsecure_lease_duration() const
const char *const name
Definition: debug.cpp:60
ACE_TEXT("TCP_Factory")
void security_unsecure_lease_duration(const DCPS::TimeDuration &period)
void spdp_local_address(const ACE_INET_Addr &mi)
#define OPENDDS_VECTOR(T)
OpenDDS_Dcps_Export LogLevel log_level
void spdp_send_addrs(const AddrVec &addrs)
DCPS::TimeDuration max_type_lookup_service_reply_period_
DCPS::TimeDuration sedp_passive_connect_duration_
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
void default_multicast_group(const ACE_INET_Addr &group)
void set_port_number(u_short, int encode=1)
void multicast_interface(const OPENDDS_STRING &mi)
OPENDDS_STRING multicast_interface() const
void spdp_rtps_relay_send_period(const DCPS::TimeDuration &period)
DCPS::TimeDuration max_type_lookup_service_reply_period() const
void max_lease_duration(const DCPS::TimeDuration &period)
DCPS::TimeDuration max_lease_duration() const
ACE_INET_Addr spdp_stun_server_address() const
DCPS::TimeDuration auth_resend_period() const
AtomicBool spdp_request_random_port_
FUTURE: handle > 1 group.
DCPS::TimeDuration lease_duration() const
void sedp_local_address(const ACE_INET_Addr &mi)
LM_ERROR
void sedp_advertised_address(const ACE_INET_Addr &mi)
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
DCPS::TimeDuration sedp_passive_connect_duration() const
DCPS::TimeDuration spdp_rtps_relay_send_period() const
void sedp_send_delay(const DCPS::TimeDuration &period)