Spdp.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef OPENDDS_RTPS_SPDP_H
00009 #define OPENDDS_RTPS_SPDP_H
00010
00011 #include "dds/DdsDcpsInfrastructureC.h"
00012 #include "dds/DdsDcpsInfoUtilsC.h"
00013 #include "dds/DdsDcpsCoreTypeSupportImpl.h"
00014
00015 #include "dds/DCPS/RcObject.h"
00016 #include "dds/DCPS/GuidUtils.h"
00017 #include "dds/DCPS/Definitions.h"
00018 #include "dds/DCPS/RcEventHandler.h"
00019
00020 #include "RtpsCoreC.h"
00021 #include "Sedp.h"
00022 #include "rtps_export.h"
00023
00024 #include "ace/Atomic_Op.h"
00025 #include "ace/SOCK_Dgram.h"
00026 #include "ace/SOCK_Dgram_Mcast.h"
00027 #include "ace/Condition_Thread_Mutex.h"
00028
00029 #include "dds/DCPS/PoolAllocator.h"
00030 #include "dds/DCPS/PoolAllocationBase.h"
00031
00032 #include "dds/DCPS/security/framework/SecurityConfig_rch.h"
00033
00034 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00035 #pragma once
00036 #endif
00037
00038 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00039
00040 namespace OpenDDS {
00041 namespace RTPS {
00042
00043 class RtpsDiscovery;
00044
00045
00046
00047 class OpenDDS_Rtps_Export Spdp : public DCPS::LocalParticipant<Sedp> {
00048 public:
00049
00050 Spdp(DDS::DomainId_t domain,
00051 DCPS::RepoId& guid,
00052 const DDS::DomainParticipantQos& qos,
00053 RtpsDiscovery* disco);
00054
00055 #if defined(OPENDDS_SECURITY)
00056 Spdp(DDS::DomainId_t domain,
00057 const DCPS::RepoId& guid,
00058 const DDS::DomainParticipantQos& qos,
00059 RtpsDiscovery* disco,
00060 DDS::Security::IdentityHandle id_handle,
00061 DDS::Security::PermissionsHandle perm_handle,
00062 DDS::Security::ParticipantCryptoHandle crypto_handle);
00063 #endif
00064
00065 ~Spdp();
00066
00067
00068 const DCPS::RepoId& guid() const { return guid_; }
00069 void init_bit(const DDS::Subscriber_var& bit_subscriber);
00070 void fini_bit();
00071
00072 bool get_default_locators(const DCPS::RepoId& part_id,
00073 DCPS::LocatorSeq& target,
00074 bool& inlineQos);
00075
00076
00077 void signal_liveliness(DDS::LivelinessQosPolicyKind kind);
00078
00079
00080 bool shutting_down() { return shutdown_flag_.value(); }
00081
00082 bool associated() const;
00083 bool has_discovered_participant(const DCPS::RepoId& guid);
00084
00085 WaitForAcks& wait_for_acks();
00086
00087 #if defined(OPENDDS_SECURITY)
00088 Security::SecurityConfig_rch get_security_config() const { return security_config_; }
00089 DDS::Security::ParticipantCryptoHandle crypto_handle() const { return crypto_handle_; }
00090
00091 void handle_auth_request(const DDS::Security::ParticipantStatelessMessage& msg);
00092 void handle_handshake_message(const DDS::Security::ParticipantStatelessMessage& msg);
00093 void handle_participant_crypto_tokens(const DDS::Security::ParticipantVolatileMessageSecure& msg);
00094 #endif
00095
00096 void handle_participant_data(DCPS::MessageId id, const Security::SPDPdiscoveredParticipantData& pdata);
00097
00098 #if defined(OPENDDS_SECURITY)
00099 void check_auth_states(const ACE_Time_Value& tv);
00100 void write_secure_updates();
00101 void write_secure_disposes();
00102 bool is_security_enabled() const { return security_enabled_; }
00103 #endif
00104
00105 bool is_opendds(const GUID_t& participant) const;
00106
00107 #if defined(OPENDDS_SECURITY)
00108 typedef std::pair<DDS::Security::ParticipantCryptoHandle, DDS::Security::SharedSecretHandle_var> ParticipantCryptoInfoPair;
00109 ParticipantCryptoInfoPair lookup_participant_crypto_info(const DCPS::RepoId& id) const;
00110 void send_participant_crypto_tokens(const DCPS::RepoId& id);
00111
00112 DDS::DomainId_t get_domain_id() const { return domain_; }
00113 DDS::Security::PermissionsHandle lookup_participant_permissions(const DCPS::RepoId& id) const;
00114
00115 DCPS::AuthState lookup_participant_auth_state(const DCPS::RepoId& id) const;
00116 #endif
00117
00118 protected:
00119 Sedp& endpoint_manager() { return sedp_; }
00120 Security::SPDPdiscoveredParticipantData build_local_pdata(Security::DiscoveredParticipantDataKind);
00121 bool announce_domain_participant_qos();
00122
00123 private:
00124
00125 void init(DDS::DomainId_t domain,
00126 DCPS::RepoId& guid,
00127 const DDS::DomainParticipantQos& qos,
00128 RtpsDiscovery* disco);
00129
00130 ACE_Reactor* reactor() const;
00131
00132 RtpsDiscovery* disco_;
00133
00134
00135 const DDS::DomainId_t domain_;
00136 DCPS::RepoId guid_;
00137 DCPS::LocatorSeq sedp_unicast_, sedp_multicast_;
00138
00139 void data_received(const DataSubmessage& data, const ParameterList& plist);
00140
00141 void match_unauthenticated(const DCPS::RepoId& guid, DiscoveredParticipant& dp);
00142
00143 #if defined(OPENDDS_SECURITY)
00144 bool match_authenticated(const DCPS::RepoId& guid, DiscoveredParticipant& dp);
00145 void attempt_authentication(const DCPS::RepoId& guid, DiscoveredParticipant& dp);
00146 #endif
00147
00148 #ifndef DDS_HAS_MINIMUM_BIT
00149 DCPS::ParticipantBuiltinTopicDataDataReaderImpl* part_bit();
00150 #endif
00151
00152 struct SpdpTransport : public DCPS::RcEventHandler {
00153 SpdpTransport(Spdp* outer, bool securityGuids);
00154 ~SpdpTransport();
00155
00156 virtual int handle_timeout(const ACE_Time_Value&, const void*);
00157 virtual int handle_input(ACE_HANDLE h);
00158 virtual int handle_exception(ACE_HANDLE fd = ACE_INVALID_HANDLE);
00159
00160 void open();
00161 void write();
00162 void write_i();
00163 void close();
00164 void dispose_unregister();
00165 bool open_unicast_socket(u_short port_common, u_short participant_id);
00166 void acknowledge();
00167
00168 Spdp* outer_;
00169 Header hdr_;
00170 DataSubmessage data_;
00171 DCPS::SequenceNumber seq_;
00172 ACE_Time_Value lease_duration_;
00173 ACE_SOCK_Dgram unicast_socket_;
00174 ACE_SOCK_Dgram_Mcast multicast_socket_;
00175 OPENDDS_SET(ACE_INET_Addr) send_addrs_;
00176 ACE_Message_Block buff_, wbuff_;
00177 ACE_Time_Value disco_resend_period_;
00178 ACE_Time_Value last_disco_resend_;
00179 } *tport_;
00180
00181 ACE_Event_Handler_var eh_;
00182 bool eh_shutdown_;
00183 ACE_Condition_Thread_Mutex shutdown_cond_;
00184 ACE_Atomic_Op<ACE_Thread_Mutex, bool> shutdown_flag_;
00185
00186 void remove_expired_participants();
00187 void get_discovered_participant_ids(DCPS::RepoIdSet& results) const;
00188
00189 Sedp sedp_;
00190
00191
00192 WaitForAcks wait_for_acks_;
00193
00194 #if defined(OPENDDS_SECURITY)
00195 Security::SecurityConfig_rch security_config_;
00196 bool security_enabled_;
00197
00198 DDS::Security::IdentityHandle identity_handle_;
00199 DDS::Security::PermissionsHandle permissions_handle_;
00200 DDS::Security::ParticipantCryptoHandle crypto_handle_;
00201
00202 DDS::Security::IdentityToken identity_token_;
00203 DDS::Security::IdentityStatusToken identity_status_token_;
00204 DDS::Security::PermissionsToken permissions_token_;
00205 DDS::Security::PermissionsCredentialToken permissions_credential_token_;
00206 DDS::Security::ParticipantCryptoTokenSeq crypto_tokens_;
00207
00208 DDS::Security::ParticipantSecurityAttributes participant_sec_attr_;
00209 #endif
00210 };
00211
00212 }
00213 }
00214
00215 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00216
00217 #endif // OPENDDS_RTPS_SPDP_H