LCOV - code coverage report
Current view: top level - DCPS/RTPS - DiscoveredEntities.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 120 120 100.0 %
Date: 2023-04-30 01:32:43 Functions: 11 11 100.0 %

          Line data    Source code
       1             : /*
       2             :  * Distributed under the OpenDDS License.
       3             :  * See: http://www.opendds.org/license.html
       4             :  */
       5             : #ifndef OPENDDS_DCPS_RTPS_DISCOVERED_ENTITIES_H
       6             : #define OPENDDS_DCPS_RTPS_DISCOVERED_ENTITIES_H
       7             : 
       8             : #include <dds/Versioned_Namespace.h>
       9             : 
      10             : #include "AssociationRecord.h"
      11             : #include "RtpsCoreC.h"
      12             : #ifdef OPENDDS_SECURITY
      13             : #  include "RtpsSecurityC.h"
      14             : #endif
      15             : #include "ICE/Ice.h"
      16             : 
      17             : #include <dds/DCPS/FibonacciSequence.h>
      18             : #include <dds/DCPS/PoolAllocationBase.h>
      19             : #include <dds/DCPS/SequenceNumber.h>
      20             : 
      21             : #ifndef ACE_LACKS_PRAGMA_ONCE
      22             : #  pragma once
      23             : #endif
      24             : 
      25             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      26             : 
      27             : namespace OpenDDS {
      28             : namespace RTPS {
      29             : 
      30             : #ifdef OPENDDS_SECURITY
      31             : enum AuthState {
      32             :   AUTH_STATE_HANDSHAKE,
      33             :   AUTH_STATE_AUTHENTICATED,
      34             :   AUTH_STATE_UNAUTHENTICATED
      35             : };
      36             : 
      37             : enum HandshakeState {
      38             :   HANDSHAKE_STATE_BEGIN_HANDSHAKE_REQUEST, //!< Requester should call begin_handshake_request
      39             :   HANDSHAKE_STATE_BEGIN_HANDSHAKE_REPLY, //!< Replier should call begin_handshake_reply
      40             :   HANDSHAKE_STATE_PROCESS_HANDSHAKE, //!< Requester and replier should call process handshake
      41             :   HANDSHAKE_STATE_DONE //!< Handshake concluded or timed out
      42             : };
      43             : 
      44             : typedef Security::SPDPdiscoveredParticipantData ParticipantData_t;
      45             : #else
      46             : typedef SPDPdiscoveredParticipantData ParticipantData_t;
      47             : #endif
      48             : 
      49             : struct DiscoveredParticipant {
      50           2 :   DiscoveredParticipant()
      51           4 :     : location_ih_(DDS::HANDLE_NIL)
      52           2 :     , bit_ih_(DDS::HANDLE_NIL)
      53           2 :     , seq_reset_count_(0)
      54             : #ifdef OPENDDS_SECURITY
      55           2 :     , have_spdp_info_(false)
      56           2 :     , have_sedp_info_(false)
      57           2 :     , have_auth_req_msg_(false)
      58           2 :     , have_handshake_msg_(false)
      59           2 :     , handshake_resend_falloff_(DCPS::TimeDuration::zero_value)
      60           2 :     , auth_state_(AUTH_STATE_HANDSHAKE)
      61           2 :     , handshake_state_(HANDSHAKE_STATE_BEGIN_HANDSHAKE_REQUEST)
      62           2 :     , is_requester_(false)
      63           2 :     , auth_req_sequence_number_(0)
      64           2 :     , handshake_sequence_number_(0)
      65           2 :     , identity_handle_(DDS::HANDLE_NIL)
      66           2 :     , handshake_handle_(DDS::HANDLE_NIL)
      67           2 :     , permissions_handle_(DDS::HANDLE_NIL)
      68           2 :     , extended_builtin_endpoints_(0)
      69           4 :     , participant_tokens_sent_(false)
      70             : #endif
      71             :   {
      72             : #ifdef OPENDDS_SECURITY
      73           2 :     pdata_.dataKind = Security::DPDK_NONE;
      74           2 :     security_info_.participant_security_attributes = 0;
      75           2 :     security_info_.plugin_participant_security_attributes = 0;
      76             : #endif
      77           2 :   }
      78             : 
      79           1 :   DiscoveredParticipant(const ParticipantData_t& p,
      80             :                         const DCPS::SequenceNumber& seq,
      81             :                         const DCPS::TimeDuration& resend_period)
      82           1 :     : pdata_(p)
      83           1 :     , location_ih_(DDS::HANDLE_NIL)
      84           1 :     , bit_ih_(DDS::HANDLE_NIL)
      85           1 :     , max_seq_(seq)
      86           1 :     , seq_reset_count_(0)
      87             : #ifdef OPENDDS_SECURITY
      88           1 :     , have_spdp_info_(false)
      89           1 :     , have_sedp_info_(false)
      90           1 :     , have_auth_req_msg_(false)
      91           1 :     , have_handshake_msg_(false)
      92           1 :     , handshake_resend_falloff_(resend_period)
      93           1 :     , auth_state_(AUTH_STATE_HANDSHAKE)
      94           1 :     , handshake_state_(HANDSHAKE_STATE_BEGIN_HANDSHAKE_REQUEST)
      95           1 :     , is_requester_(false)
      96           1 :     , auth_req_sequence_number_(0)
      97           1 :     , handshake_sequence_number_(0)
      98           1 :     , identity_handle_(DDS::HANDLE_NIL)
      99           1 :     , handshake_handle_(DDS::HANDLE_NIL)
     100           1 :     , permissions_handle_(DDS::HANDLE_NIL)
     101           1 :     , extended_builtin_endpoints_(0)
     102           2 :     , participant_tokens_sent_(false)
     103             : #endif
     104             :   {
     105           1 :     const DCPS::GUID_t guid = DCPS::make_part_guid(p.participantProxy.guidPrefix);
     106           1 :     assign(location_data_.guid, guid);
     107           1 :     location_data_.location = 0;
     108           1 :     location_data_.change_mask = 0;
     109           1 :     location_data_.local_timestamp.sec = 0;
     110           1 :     location_data_.local_timestamp.nanosec = 0;
     111           1 :     location_data_.ice_timestamp.sec = 0;
     112           1 :     location_data_.ice_timestamp.nanosec = 0;
     113           1 :     location_data_.relay_timestamp.sec = 0;
     114           1 :     location_data_.relay_timestamp.nanosec = 0;
     115           1 :     location_data_.local6_timestamp.sec = 0;
     116           1 :     location_data_.local6_timestamp.nanosec = 0;
     117           1 :     location_data_.ice6_timestamp.sec = 0;
     118           1 :     location_data_.ice6_timestamp.nanosec = 0;
     119           1 :     location_data_.relay6_timestamp.sec = 0;
     120           1 :     location_data_.relay6_timestamp.nanosec = 0;
     121             : 
     122             : #ifdef OPENDDS_SECURITY
     123           1 :     security_info_.participant_security_attributes = 0;
     124           1 :     security_info_.plugin_participant_security_attributes = 0;
     125             : #else
     126             :     ACE_UNUSED_ARG(resend_period);
     127             : #endif
     128           1 :   }
     129             : 
     130             :   ParticipantData_t pdata_;
     131             : 
     132             :   struct LocationUpdate {
     133             :     DCPS::ParticipantLocation mask_;
     134             :     ACE_INET_Addr from_;
     135             :     DCPS::SystemTimePoint timestamp_;
     136             :     LocationUpdate() {}
     137             :     LocationUpdate(DCPS::ParticipantLocation mask,
     138             :                    const ACE_INET_Addr& from,
     139             :                    const DCPS::SystemTimePoint& timestamp)
     140             :       : mask_(mask), from_(from), timestamp_(timestamp) {}
     141             :   };
     142             :   typedef OPENDDS_VECTOR(LocationUpdate) LocationUpdateList;
     143             :   LocationUpdateList location_updates_;
     144             :   DCPS::ParticipantLocationBuiltinTopicData location_data_;
     145             :   DDS::InstanceHandle_t location_ih_;
     146             : 
     147             :   ACE_INET_Addr last_recv_address_;
     148             :   DCPS::MonotonicTimePoint discovered_at_;
     149             :   DCPS::MonotonicTimePoint lease_expiration_;
     150             :   DDS::InstanceHandle_t bit_ih_;
     151             :   DCPS::SequenceNumber max_seq_;
     152             :   ACE_UINT16 seq_reset_count_;
     153             :   typedef OPENDDS_LIST(BuiltinAssociationRecord) BuiltinAssociationRecords;
     154             :   BuiltinAssociationRecords builtin_pending_records_;
     155             :   BuiltinAssociationRecords builtin_associated_records_;
     156             :   typedef OPENDDS_LIST(WriterAssociationRecord_rch) WriterAssociationRecords;
     157             :   WriterAssociationRecords writer_pending_records_;
     158             :   WriterAssociationRecords writer_associated_records_;
     159             :   typedef OPENDDS_LIST(ReaderAssociationRecord_rch) ReaderAssociationRecords;
     160             :   ReaderAssociationRecords reader_pending_records_;
     161             :   ReaderAssociationRecords reader_associated_records_;
     162             : #ifdef OPENDDS_SECURITY
     163             :   bool have_spdp_info_;
     164             :   ICE::AgentInfo spdp_info_;
     165             :   bool have_sedp_info_;
     166             :   ICE::AgentInfo sedp_info_;
     167             :   bool have_auth_req_msg_;
     168             :   DDS::Security::ParticipantStatelessMessage auth_req_msg_;
     169             :   bool have_handshake_msg_;
     170             :   DDS::Security::ParticipantStatelessMessage handshake_msg_;
     171             :   DCPS::FibonacciSequence<DCPS::TimeDuration> handshake_resend_falloff_;
     172             :   DCPS::MonotonicTimePoint stateless_msg_deadline_;
     173             : 
     174             :   DCPS::MonotonicTimePoint handshake_deadline_;
     175             :   AuthState auth_state_;
     176             :   HandshakeState handshake_state_;
     177             :   bool is_requester_;
     178             :   CORBA::LongLong auth_req_sequence_number_;
     179             :   CORBA::LongLong handshake_sequence_number_;
     180             : 
     181             :   DDS::Security::IdentityToken identity_token_;
     182             :   DDS::Security::PermissionsToken permissions_token_;
     183             :   DDS::Security::PropertyQosPolicy property_qos_;
     184             :   DDS::Security::ParticipantSecurityInfo security_info_;
     185             :   DDS::Security::IdentityStatusToken identity_status_token_;
     186             :   DDS::Security::IdentityHandle identity_handle_;
     187             :   DDS::Security::HandshakeHandle handshake_handle_;
     188             :   DDS::Security::AuthRequestMessageToken local_auth_request_token_;
     189             :   DDS::Security::AuthRequestMessageToken remote_auth_request_token_;
     190             :   DDS::Security::AuthenticatedPeerCredentialToken authenticated_peer_credential_token_;
     191             :   DDS::Security::SharedSecretHandle_var shared_secret_handle_;
     192             :   DDS::Security::PermissionsHandle permissions_handle_;
     193             :   DDS::Security::ParticipantCryptoTokenSeq crypto_tokens_;
     194             :   DDS::Security::ExtendedBuiltinEndpointSet_t extended_builtin_endpoints_;
     195             :   bool participant_tokens_sent_;
     196             : 
     197           3 :   bool has_security_data() const
     198             :   {
     199           3 :     return pdata_.dataKind == Security::DPDK_ENHANCED || pdata_.dataKind == Security::DPDK_SECURE;
     200             :   }
     201             : #endif
     202             : };
     203             : 
     204             : struct DiscoveredSubscription : DCPS::PoolAllocationBase {
     205           1 :   DiscoveredSubscription()
     206           2 :     : bit_ih_(DDS::HANDLE_NIL)
     207           1 :     , participant_discovered_at_(DCPS::monotonic_time_zero())
     208           1 :     , transport_context_(0)
     209             : #ifdef OPENDDS_SECURITY
     210           2 :     , have_ice_agent_info_(false)
     211             : #endif
     212             :   {
     213             : #ifdef OPENDDS_SECURITY
     214           1 :     security_attribs_.base = DDS::Security::TopicSecurityAttributes();
     215           1 :     security_attribs_.is_key_protected = 0;
     216           1 :     security_attribs_.is_payload_protected = 0;
     217           1 :     security_attribs_.is_submessage_protected = 0;
     218           1 :     security_attribs_.plugin_endpoint_attributes = 0;
     219             : #endif
     220           1 :   }
     221             : 
     222           1 :   explicit DiscoveredSubscription(const DCPS::DiscoveredReaderData& r)
     223           1 :     : reader_data_(r)
     224           1 :     , bit_ih_(DDS::HANDLE_NIL)
     225           1 :     , participant_discovered_at_(DCPS::monotonic_time_zero())
     226           1 :     , transport_context_(0)
     227             : #ifdef OPENDDS_SECURITY
     228           1 :     , security_attribs_(DDS::Security::EndpointSecurityAttributes())
     229           3 :     , have_ice_agent_info_(false)
     230             : #endif
     231             :   {
     232             : #ifdef OPENDDS_SECURITY
     233           1 :     security_attribs_.base = DDS::Security::TopicSecurityAttributes();
     234           1 :     security_attribs_.is_key_protected = 0;
     235           1 :     security_attribs_.is_payload_protected = 0;
     236           1 :     security_attribs_.is_submessage_protected = 0;
     237           1 :     security_attribs_.plugin_endpoint_attributes = 0;
     238             : #endif
     239           1 :   }
     240             : 
     241             :   DCPS::RepoIdSet matched_endpoints_;
     242             :   DCPS::DiscoveredReaderData reader_data_;
     243             :   DDS::InstanceHandle_t bit_ih_;
     244             :   DCPS::MonotonicTime_t participant_discovered_at_;
     245             :   ACE_CDR::ULong transport_context_;
     246             :   XTypes::TypeInformation type_info_;
     247             : 
     248             : #ifdef OPENDDS_SECURITY
     249             :   DDS::Security::EndpointSecurityAttributes security_attribs_;
     250             :   bool have_ice_agent_info_;
     251             :   ICE::AgentInfo ice_agent_info_;
     252             : #endif
     253             : 
     254           2 :   const char* get_topic_name() const
     255             :   {
     256           2 :     return reader_data_.ddsSubscriptionData.topic_name;
     257             :   }
     258             : 
     259           2 :   const char* get_type_name() const
     260             :   {
     261           2 :     return reader_data_.ddsSubscriptionData.type_name;
     262             :   }
     263             : };
     264             : 
     265             : struct DiscoveredPublication : DCPS::PoolAllocationBase {
     266           1 :   DiscoveredPublication()
     267           2 :     : bit_ih_(DDS::HANDLE_NIL)
     268           1 :     , participant_discovered_at_(DCPS::monotonic_time_zero())
     269           1 :     , transport_context_(0)
     270             : #ifdef OPENDDS_SECURITY
     271           2 :     , have_ice_agent_info_(false)
     272             : #endif
     273             :   {
     274             : #ifdef OPENDDS_SECURITY
     275           1 :     security_attribs_.base = DDS::Security::TopicSecurityAttributes();
     276           1 :     security_attribs_.is_key_protected = 0;
     277           1 :     security_attribs_.is_payload_protected = 0;
     278           1 :     security_attribs_.is_submessage_protected = 0;
     279           1 :     security_attribs_.plugin_endpoint_attributes = 0;
     280             : #endif
     281           1 :   }
     282             : 
     283           1 :   explicit DiscoveredPublication(const DCPS::DiscoveredWriterData& w)
     284           1 :     : writer_data_(w)
     285           1 :     , bit_ih_(DDS::HANDLE_NIL)
     286           1 :     , participant_discovered_at_(DCPS::monotonic_time_zero())
     287           1 :     , transport_context_(0)
     288             : #ifdef OPENDDS_SECURITY
     289           2 :     , have_ice_agent_info_(false)
     290             : #endif
     291             :   {
     292             : #ifdef OPENDDS_SECURITY
     293           1 :     security_attribs_.base = DDS::Security::TopicSecurityAttributes();
     294           1 :     security_attribs_.is_key_protected = 0;
     295           1 :     security_attribs_.is_payload_protected = 0;
     296           1 :     security_attribs_.is_submessage_protected = 0;
     297           1 :     security_attribs_.plugin_endpoint_attributes = 0;
     298             : #endif
     299           1 :   }
     300             : 
     301             :   DCPS::RepoIdSet matched_endpoints_;
     302             :   DCPS::DiscoveredWriterData writer_data_;
     303             :   DDS::InstanceHandle_t bit_ih_;
     304             :   DCPS::MonotonicTime_t participant_discovered_at_;
     305             :   ACE_CDR::ULong transport_context_;
     306             :   XTypes::TypeInformation type_info_;
     307             : 
     308             : #ifdef OPENDDS_SECURITY
     309             :   DDS::Security::EndpointSecurityAttributes security_attribs_;
     310             :   bool have_ice_agent_info_;
     311             :   ICE::AgentInfo ice_agent_info_;
     312             : #endif
     313             : 
     314           2 :   const char* get_topic_name() const
     315             :   {
     316           2 :     return writer_data_.ddsPublicationData.topic_name;
     317             :   }
     318             : 
     319           2 :   const char* get_type_name() const
     320             :   {
     321           2 :     return writer_data_.ddsPublicationData.type_name;
     322             :   }
     323             : };
     324             : 
     325             : }
     326             : }
     327             : 
     328             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
     329             : 
     330             : #endif // OPENDDS_DCPS_RTPS_DISCOVERED_ENTITIES_H

Generated by: LCOV version 1.16