OpenDDS  Snapshot(2023/04/28-20:55)
RtpsDiscovery.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_RTPSDISCOVERY_H
7 #define OPENDDS_DCPS_RTPS_RTPSDISCOVERY_H
8 
9 #include "RtpsDiscoveryConfig.h"
10 #include "GuidGenerator.h"
11 #include "Spdp.h"
12 #include "rtps_export.h"
13 
14 #include <dds/DCPS/PoolAllocator.h>
15 #include <dds/DCPS/debug.h>
16 #include <dds/DCPS/AtomicBool.h>
17 
18 #include <ace/Configuration.h>
19 
20 #ifndef ACE_LACKS_PRAGMA_ONCE
21 # pragma once
22 #endif
23 
24 class DDS_TEST;
25 
27 
28 namespace OpenDDS {
29 namespace RTPS {
30 
31 using DCPS::log_level;
32 using DCPS::LogLevel;
33 using DCPS::AtomicBool;
34 
36 typedef OPENDDS_MAP_CMP(GUID_t, ParticipantHandle, GUID_tKeyLessThan) ParticipantMap;
37 typedef OPENDDS_MAP(DDS::DomainId_t, ParticipantMap) DomainParticipantMap;
39 
40 const char RTPS_DISCOVERY_ENDPOINT_ANNOUNCEMENTS[] = "OpenDDS.RtpsDiscovery.EndpointAnnouncements";
41 const char RTPS_DISCOVERY_TYPE_LOOKUP_SERVICE[] = "OpenDDS.RtpsDiscovery.TypeLookupService";
42 const char RTPS_RELAY_APPLICATION_PARTICIPANT[] = "OpenDDS.Rtps.RelayApplicationParticipant";
43 const char RTPS_REFLECT_HEARTBEAT_COUNT[] = "OpenDDS.Rtps.ReflectHeartbeatCount";
44 
45 
46 /**
47  * @class RtpsDiscovery
48  *
49  * @brief Discovery Strategy class that implements RTPS discovery
50  *
51  * This class implements the Discovery interface for Rtps-based
52  * discovery.
53  *
54  */
56 public:
57  typedef RtpsDiscoveryConfig::AddrVec AddrVec;
58 
59  explicit RtpsDiscovery(const RepoKey& key);
60  ~RtpsDiscovery();
61 
62  virtual OpenDDS::DCPS::GUID_t generate_participant_guid();
63 
64  virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant(
65  DDS::DomainId_t domain,
66  const DDS::DomainParticipantQos& qos,
68 
69 #if defined(OPENDDS_SECURITY)
70 # if defined __GNUC__ && ((__GNUC__ == 5 && __GNUC_MINOR__ < 3) || __GNUC__ < 5) && ! defined __clang__
71 # define OPENDDS_GCC_PRE53_DISABLE_OPTIMIZATION __attribute__((optimize("-O0")))
72 # else
73 # define OPENDDS_GCC_PRE53_DISABLE_OPTIMIZATION
74 # endif
75 
76  virtual OpenDDS::DCPS::AddDomainStatus add_domain_participant_secure(
77  DDS::DomainId_t domain,
78  const DDS::DomainParticipantQos& qos,
80  const OpenDDS::DCPS::GUID_t& guid,
85 #endif
86 
87  virtual bool supports_liveliness() const { return true; }
88 
89  virtual void signal_liveliness(const DDS::DomainId_t domain_id,
90  const OpenDDS::DCPS::GUID_t& part_id,
92 
93  // configuration parameters:
94 
95  DCPS::TimeDuration resend_period() const { return config_->resend_period(); }
96  void resend_period(const DCPS::TimeDuration& period) { config_->resend_period(period); }
97 
98  DCPS::TimeDuration lease_duration() const { return config_->lease_duration(); }
99  void lease_duration(const DCPS::TimeDuration& period) { config_->lease_duration(period); }
100 
101  DCPS::TimeDuration lease_extension() const { return config_->lease_extension(); }
102  void lease_extension(const DCPS::TimeDuration& period) { config_->lease_extension(period); }
103 
104  u_short pb() const { return config_->pb(); }
105  void pb(u_short port_base) { config_->pb(port_base); }
106 
107  u_short dg() const { return config_->dg(); }
108  void dg(u_short domain_gain) { config_->dg(domain_gain); }
109 
110  u_short pg() const { return config_->pg(); }
111  void pg(u_short participant_gain) { config_->pg(participant_gain); }
112 
113  u_short d0() const { return config_->d0(); }
114  void d0(u_short offset_zero) { config_->d0(offset_zero); }
115 
116  u_short d1() const { return config_->d1(); }
117  void d1(u_short offset_one) { config_->d1(offset_one); }
118 
119  u_short dx() const { return config_->dx(); }
120  void dx(u_short offset_two) { config_->dx(offset_two); }
121 
122  unsigned char ttl() const { return config_->ttl(); }
123  void ttl(unsigned char time_to_live) { config_->ttl(time_to_live); }
124 
125  ACE_INET_Addr sedp_local_address() const { return config_->sedp_local_address(); }
126  void sedp_local_address(const ACE_INET_Addr& mi) { config_->sedp_local_address(mi); }
127 
128  ACE_INET_Addr spdp_local_address() const { return config_->spdp_local_address(); }
129  void spdp_local_address(const ACE_INET_Addr& mi) { config_->spdp_local_address(mi); }
130 
131  bool sedp_multicast() const { return config_->sedp_multicast(); }
132  void sedp_multicast(bool sm) { config_->sedp_multicast(sm); }
133 
134  OPENDDS_STRING multicast_interface() const { return config_->multicast_interface(); }
135  void multicast_interface(const OPENDDS_STRING& mi) { config_->multicast_interface(mi); }
136 
137  ACE_INET_Addr default_multicast_group() const { return config_->default_multicast_group(); }
138  void default_multicast_group(const ACE_INET_Addr& group) { config_->default_multicast_group(group); }
139 
140  AddrVec spdp_send_addrs() const { return config_->spdp_send_addrs(); }
141  void spdp_send_addrs(const AddrVec& addrs) { return config_->spdp_send_addrs(addrs); }
142 
143  OPENDDS_STRING guid_interface() const { return config_->guid_interface(); }
144  void guid_interface(const OPENDDS_STRING& gi) { config_->guid_interface(gi); }
145 
146  DCPS::TimeDuration max_auth_time() const { return config_->max_auth_time(); }
147  void max_auth_time(const DCPS::TimeDuration& x) { config_->max_auth_time(x); }
148 
149  DCPS::TimeDuration auth_resend_period() const { return config_->auth_resend_period(); }
150  void auth_resend_period(const DCPS::TimeDuration& x) { config_->auth_resend_period(x); }
151 
152  u_short max_spdp_sequence_msg_reset_check() const { return config_->max_spdp_sequence_msg_reset_check(); }
153  void max_spdp_sequence_msg_reset_check(u_short reset_value) { config_->max_spdp_sequence_msg_reset_check(reset_value); }
154 
155  bool rtps_relay_only() const { return config_->rtps_relay_only(); }
156  void rtps_relay_only_now(bool f);
157 
158  bool use_rtps_relay() const { return config_->use_rtps_relay(); }
159  void use_rtps_relay_now(bool f);
160 
161  bool use_ice() const { return config_->use_ice(); }
162  void use_ice_now(bool f);
163 
165  {
166  return config_->secure_participant_user_data();
167  }
169  {
170  config_->secure_participant_user_data(value);
171  }
172 
173  bool use_xtypes() const { return config_->use_xtypes(); }
174  void use_xtypes(RtpsDiscoveryConfig::UseXTypes val) { return config_->use_xtypes(val); }
175  bool use_xtypes_complete() const { return config_->use_xtypes_complete(); }
176 
177  RtpsDiscoveryConfig_rch config() const { return config_; }
178 
179 #ifdef OPENDDS_SECURITY
181  const DCPS::GUID_t& local_participant,
182  const DCPS::GUID_t& remote_participant = GUID_UNKNOWN) const;
183 #endif
184 
185  u_short get_spdp_port(DDS::DomainId_t domain,
186  const DCPS::GUID_t& local_participant) const;
187  u_short get_sedp_port(DDS::DomainId_t domain,
188  const DCPS::GUID_t& local_participant) const;
189 #ifdef ACE_HAS_IPV6
190  u_short get_ipv6_spdp_port(DDS::DomainId_t domain,
191  const DCPS::GUID_t& local_participant) const;
192  u_short get_ipv6_sedp_port(DDS::DomainId_t domain,
193  const DCPS::GUID_t& local_participant) const;
194 #endif
195  void spdp_rtps_relay_address(const ACE_INET_Addr& address);
196  void sedp_rtps_relay_address(const ACE_INET_Addr& address);
197  void spdp_stun_server_address(const ACE_INET_Addr& address);
198  void sedp_stun_server_address(const ACE_INET_Addr& address);
199 
200  void append_transport_statistics(DDS::DomainId_t domain,
201  const DCPS::GUID_t& local_participant,
203 
205 
206  void fini_bit(DCPS::DomainParticipantImpl* participant);
207 
208  bool attach_participant(DDS::DomainId_t domainId, const GUID_t& participantId);
209 
210  bool remove_domain_participant(DDS::DomainId_t domain_id, const GUID_t& participantId);
211 
212  bool ignore_domain_participant(DDS::DomainId_t domain, const GUID_t& myParticipantId,
213  const GUID_t& ignoreId);
214 
215  bool remove_domain_participant(DDS::DomainId_t domain, const GUID_t& myParticipantId,
216  const GUID_t& removeId);
217 
218  bool update_domain_participant_qos(DDS::DomainId_t domain, const GUID_t& participant,
219  const DDS::DomainParticipantQos& qos);
220 
221  bool has_domain_participant(DDS::DomainId_t domain, const GUID_t& local, const GUID_t& remote) const;
222 
223  DCPS::TopicStatus assert_topic(
224  GUID_t& topicId,
225  DDS::DomainId_t domainId,
226  const GUID_t& participantId,
227  const char* topicName,
228  const char* dataTypeName,
229  const DDS::TopicQos& qos,
230  bool hasDcpsKey,
231  DCPS::TopicCallbacks* topic_callbacks);
232 
233  DCPS::TopicStatus find_topic(
234  DDS::DomainId_t domainId,
235  const GUID_t& participantId,
236  const char* topicName,
237  CORBA::String_out dataTypeName,
238  DDS::TopicQos_out qos,
239  GUID_t& topicId);
240 
241  DCPS::TopicStatus remove_topic(
242  DDS::DomainId_t domainId,
243  const GUID_t& participantId,
244  const GUID_t& topicId);
245 
246  bool ignore_topic(DDS::DomainId_t domainId,
247  const GUID_t& myParticipantId, const GUID_t& ignoreId);
248 
249  bool update_topic_qos(const GUID_t& topicId, DDS::DomainId_t domainId,
250  const GUID_t& participantId, const DDS::TopicQos& qos);
251 
252  GUID_t add_publication(
253  DDS::DomainId_t domainId,
254  const GUID_t& participantId,
255  const GUID_t& topicId,
256  DCPS::DataWriterCallbacks_rch publication,
257  const DDS::DataWriterQos& qos,
258  const DCPS::TransportLocatorSeq& transInfo,
259  const DDS::PublisherQos& publisherQos,
260  const XTypes::TypeInformation& type_info);
261 
262  bool remove_publication(DDS::DomainId_t domainId, const GUID_t& participantId,
263  const GUID_t& publicationId);
264 
265  bool ignore_publication(DDS::DomainId_t domainId, const GUID_t& participantId,
266  const GUID_t& ignoreId);
267 
268  bool update_publication_qos(
269  DDS::DomainId_t domainId,
270  const GUID_t& partId,
271  const GUID_t& dwId,
272  const DDS::DataWriterQos& qos,
273  const DDS::PublisherQos& publisherQos);
274 
275  void update_publication_locators(
276  DDS::DomainId_t domainId,
277  const GUID_t& partId,
278  const GUID_t& dwId,
279  const DCPS::TransportLocatorSeq& transInfo);
280 
281  GUID_t add_subscription(
282  DDS::DomainId_t domainId,
283  const GUID_t& participantId,
284  const GUID_t& topicId,
285  DCPS::DataReaderCallbacks_rch subscription,
286  const DDS::DataReaderQos& qos,
287  const DCPS::TransportLocatorSeq& transInfo,
288  const DDS::SubscriberQos& subscriberQos,
289  const char* filterClassName,
290  const char* filterExpr,
291  const DDS::StringSeq& params,
292  const XTypes::TypeInformation& type_info);
293 
294  bool remove_subscription(DDS::DomainId_t domainId, const GUID_t& participantId,
295  const GUID_t& subscriptionId);
296 
297  bool ignore_subscription(DDS::DomainId_t domainId, const GUID_t& participantId,
298  const GUID_t& ignoreId);
299 
300  bool update_subscription_qos(
301  DDS::DomainId_t domainId,
302  const GUID_t& partId,
303  const GUID_t& drId,
304  const DDS::DataReaderQos& qos,
305  const DDS::SubscriberQos& subQos);
306 
307  bool update_subscription_params(
308  DDS::DomainId_t domainId,
309  const GUID_t& partId,
310  const GUID_t& subId,
311  const DDS::StringSeq& params);
312 
313  void update_subscription_locators(
314  DDS::DomainId_t domainId,
315  const GUID_t& partId,
316  const GUID_t& subId,
317  const DCPS::TransportLocatorSeq& transInfo);
318 
319  RcHandle<DCPS::TransportInst> sedp_transport_inst(DDS::DomainId_t domainId,
320  const GUID_t& partId) const;
321 
322  void request_remote_complete_type_objects(
323  DDS::DomainId_t domain, const GUID_t& local_participant,
324  const GUID_t& remote_entity, const XTypes::TypeInformation& remote_type_info,
325  DCPS::TypeObjReqCond& cond);
326 
327 private:
328 
329  // This mutex only protects the participants map
331 
332  DomainParticipantMap participants_;
333 
334  ParticipantHandle get_part(const DDS::DomainId_t domain_id, const GUID_t& part_id) const;
335 
336  // This mutex protects everything else
338 
339  RtpsDiscoveryConfig_rch config_;
340 
341  RtpsDiscoveryConfig_rch get_config() const;
342 
343  /// Guids will be unique within this RTPS configuration
345 
346  void create_bit_dr(DDS::TopicDescription_ptr topic, const char* type,
348  const DDS::DataReaderQos& qos);
349 
350 public:
351  class Config : public Discovery::Config {
352  public:
353  int discovery_config(ACE_Configuration_Heap& cf);
354  };
355 
357  public:
359  };
360 
361 private:
362  friend class ::DDS_TEST;
363 };
364 
366 
368 
369 } // namespace RTPS
370 } // namespace OpenDDS
371 
373 
374 #endif /* OPENDDS_RTPS_RTPSDISCOVERY_H */
RtpsDiscoveryConfig_rch config_
Implements the OpenDDS::DCPS::DomainParticipant interfaces.
ACE_INET_Addr default_multicast_group() const
OPENDDS_STRING guid_interface() const
void spdp_local_address(const ACE_INET_Addr &mi)
AddrVec spdp_send_addrs() const
const char RTPS_RELAY_APPLICATION_PARTICIPANT[]
Definition: RtpsDiscovery.h:42
const LogLevel::Value value
Definition: debug.cpp:61
void spdp_send_addrs(const AddrVec &addrs)
const char RTPS_DISCOVERY_ENDPOINT_ANNOUNCEMENTS[]
Definition: RtpsDiscovery.h:40
void guid_interface(const OPENDDS_STRING &gi)
RtpsDiscoveryConfig_rch config() const
DCPS::TimeDuration lease_extension() const
ACE_INET_Addr spdp_local_address() const
void max_spdp_sequence_msg_reset_check(u_short reset_value)
const GUID_t GUID_UNKNOWN
Nil value for GUID.
Definition: GuidUtils.h:59
sequence< octet > key
void multicast_interface(const OPENDDS_STRING &mi)
void d1(u_short offset_one)
u_short max_spdp_sequence_msg_reset_check() const
void default_multicast_group(const ACE_INET_Addr &group)
void use_xtypes(RtpsDiscoveryConfig::UseXTypes val)
OpenDDS::DCPS::RcHandle< RtpsDiscoveryConfig > RtpsDiscoveryConfig_rch
Definition: RtpsDiscovery.h:38
sequence< TransportLocator > TransportLocatorSeq
void pb(u_short port_base)
GuidGenerator guid_gen_
Guids will be unique within this RTPS configuration.
DCPS::TimeDuration auth_resend_period() const
virtual bool supports_liveliness() const
Definition: RtpsDiscovery.h:87
const char RTPS_REFLECT_HEARTBEAT_COUNT[]
Definition: RtpsDiscovery.h:43
typedef OPENDDS_MAP_CMP(GUID_t, ParticipantHandle, GUID_tKeyLessThan) ParticipantMap
DomainParticipantMap participants_
const char RTPS_DISCOVERY_TYPE_LOOKUP_SERVICE[]
Definition: RtpsDiscovery.h:41
void resend_period(const DCPS::TimeDuration &period)
Definition: RtpsDiscovery.h:96
#define OPENDDS_STRING
DCPS::TimeDuration resend_period() const
Definition: RtpsDiscovery.h:95
RcHandle< Spdp > ParticipantHandle
Definition: RtpsDiscovery.h:35
DOMAINID_TYPE_NATIVE DomainId_t
ACE_Thread_Mutex participants_lock_
typedef OPENDDS_MAP(DDS::DomainId_t, ParticipantMap) DomainParticipantMap
#define OpenDDS_Rtps_Export
Definition: rtps_export.h:23
sequence< TransportStatistics > TransportStatisticsSequence
bool secure_participant_user_data() const
unsigned char ttl() const
#define OPENDDS_GCC_PRE53_DISABLE_OPTIMIZATION
Definition: RtpsDiscovery.h:73
void ttl(unsigned char time_to_live)
OPENDDS_STRING multicast_interface() const
void max_auth_time(const DCPS::TimeDuration &x)
void secure_participant_user_data(bool value)
RtpsDiscoveryConfig::AddrVec AddrVec
Definition: RtpsDiscovery.h:57
void pg(u_short participant_gain)
void sedp_local_address(const ACE_INET_Addr &mi)
void dg(u_short domain_gain)
void auth_resend_period(const DCPS::TimeDuration &x)
void dx(u_short offset_two)
OpenDDS_Dcps_Export LogLevel log_level
DCPS::TimeDuration lease_duration() const
Definition: RtpsDiscovery.h:98
ACE_INET_Addr sedp_local_address() const
OpenDDS::DCPS::RcHandle< RtpsDiscovery > RtpsDiscovery_rch
void lease_duration(const DCPS::TimeDuration &period)
Definition: RtpsDiscovery.h:99
DCPS::RcHandle< TypeLookupService > TypeLookupService_rch
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
Discovery Strategy interface class.
Definition: Discovery.h:76
static RtpsDiscovery::StaticInitializer initialize_rtps
void lease_extension(const DCPS::TimeDuration &period)
DCPS::TimeDuration max_auth_time() const
void d0(u_short offset_zero)
Defines the interface for Discovery callbacks into the Topic.
OPENDDS_STRING RepoKey
Definition: Discovery.h:80
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
LivelinessQosPolicyKind
sequence< string > StringSeq
Definition: DdsDcpsCore.idl:50
Discovery Strategy class that implements RTPS discovery.
Definition: RtpsDiscovery.h:55