24 #ifdef OPENDDS_SECURITY 29 agent_impl(a_agent_impl),
60 GuidPair guidp(a_local_guid, a_remote_guid);
68 guid_checklist = pos->second;
78 username_checklist = pos->second;
86 if (guid_checklist != username_checklist) {
87 if (guid_checklist != 0) {
88 guid_checklist->remove_guid(guidp);
91 username_checklist->add_guid(guidp);
94 AgentInfo old_remote_agent_info = username_checklist->original_remote_agent_info();
96 if (old_remote_agent_info == a_remote_agent_info) {
103 if (old_remote_agent_info == a_remote_agent_info) {
105 username_checklist->set_remote_password(a_remote_agent_info.
password);
110 GuidSetType const guids = username_checklist->guids();
111 username_checklist->remove_guids();
113 username_checklist->add_guids(guids);
119 GuidPair guidp(a_local_guid, a_remote_guid);
125 guid_checklist->remove_guid(guidp);
132 GuidPair guidp(a_local_guid, a_remote_guid);
136 return pos->second->selected_address();
146 switch (a_message.
class_) {
148 request(a_local_address, a_remote_address, a_message);
152 indication(a_local_address, a_remote_address, a_message);
170 unsigned char username[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
171 TheSecurityRegistry->builtin_config()->get_utility()->generate_random_bytes(username,
sizeof(username));
182 unsigned char password[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
183 TheSecurityRegistry->builtin_config()->get_utility()->generate_random_bytes(password,
sizeof(password));
191 AddressListType host_addresses;
193 for (AddressListType::const_iterator pos = a_host_addresses.begin(), limit = a_host_addresses.end();
194 pos != limit; ++pos) {
197 if (pos->is_loopback()) {
202 if (pos->is_ipv4_compat_ipv6()) {
212 if (pos->is_ipv4_mapped_ipv6()) {
218 host_addresses.push_back(*pos);
240 if (!password_only) {
266 for (UsernameToChecklistType::const_iterator pos = old_checklists.begin(),
267 limit = old_checklists.end();
268 pos != limit; ++pos) {
270 AgentInfo const remote_agent_info = old_checklist->original_remote_agent_info();
272 old_checklist->remove_guids();
274 new_checklist->add_guids(guids);
289 for (AgentInfoListenersType::const_iterator pos = agent_info_listeners.begin(),
290 limit = agent_info_listeners.end(); pos != limit; ++pos) {
293 ail->update_agent_info(pos->first, agent_info);
332 while (!list.empty() && list.front().expiration_date < a_now) {
357 if (!unknown_attributes.empty()) {
358 ACE_ERROR((
LM_WARNING,
ACE_TEXT(
"(%P|%t) EndpointManager::success_response: WARNING Unknown comprehension required attributes\n")));
392 for (std::vector<STUN::AttributeType>::const_iterator pos = unknown_attributes.begin(),
393 limit = unknown_attributes.end(); pos != limit; ++pos) {
415 for (DeferredTriggeredCheckListType::const_iterator pos2 = list.begin(), limit2 = list.end(); pos2 != limit2; ++pos2) {
416 checklist->generate_triggered_check(pos2->local_address, pos2->remote_address, pos2->priority, pos2->use_candidate);
422 checklist->unfreeze();
428 const std::vector<STUN::AttributeType>& a_unknown_attributes)
443 const std::string& a_reason)
474 std::string username;
478 send(a_remote_address,
485 send(a_remote_address,
490 size_t idx = username.find(
':');
492 if (idx == std::string::npos) {
494 send(a_remote_address,
501 send(a_remote_address,
506 const std::string remote_username = username.substr(++idx);
511 send(a_remote_address,
518 if (!unknown_attributes.empty()) {
520 send(a_remote_address,
527 send(a_remote_address,
534 send(a_remote_address,
543 send(a_remote_address,
552 send(a_remote_address,
557 switch (a_message.
method) {
569 send(a_remote_address, response);
577 checklist->generate_triggered_check(a_local_address, a_remote_address, priority, use_candidate);
581 std::pair<DeferredTriggeredChecksType::iterator, bool> x =
584 a_local_address, a_remote_address, priority, use_candidate,
593 send(a_remote_address,
603 std::string username;
615 size_t idx = username.find(
':');
617 if (idx == std::string::npos) {
627 const std::string remote_username = username.substr(++idx);
637 if (!unknown_attributes.empty()) {
647 switch (a_message.
method) {
654 pos->second->indication();
670 switch (a_message.
method) {
685 pos->second->success_response(a_local_address, a_remote_address, a_message);
700 switch (a_message.
method) {
715 pos->second->error_response(a_local_address, a_remote_address, a_message);
731 checklist->compute_active_foundations(a_active_foundations);
741 ACE_UNUSED_ARG(list);
749 OPENDDS_ASSERT(checklist->original_remote_agent_info().username == pos->first);
750 checklist->check_invariants();
756 ACE_UNUSED_ARG(checklist);
763 ACE_UNUSED_ARG(checklist);
772 pos->second->unfreeze();
780 pos->second->unfreeze(a_foundation);
786 endpoint_manager(a_endpoint_manager)
788 enqueue(MonotonicTimePoint::now());
795 em->server_reflexive_task(a_now);
811 em->change_password(
true);
828 e->send(address, message);
835 for (UsernameToChecklistType::const_iterator pos = checklists.begin(), limit = checklists.end(); pos != limit; ++pos) {
836 pos->second->remove_guids();
842 ail->remove_agent_info(pos->first);
RcHandle< T > rchandle_from(T *pointer)
#define ACE_GUARD(MUTEX, OBJ, LOCK)
bool has_ice_controlled() const
GuidPairToChecklistType guid_pair_to_checklist_
void server_reflexive_address_period(const DCPS::TimeDuration &x)
bool get_mapped_address(ACE_INET_Addr &address) const
ChangePasswordTask(DCPS::RcHandle< EndpointManager > a_endpoint_manager)
void stop_ice(const DCPS::GUID_t &local_guid, const DCPS::GUID_t &remote_guid)
void start_ice(const DCPS::GUID_t &a_local_guid, const DCPS::GUID_t &a_remote_guid, const AgentInfo &a_remote_agent_info)
void server_reflexive_indication_count(size_t x)
void * memcpy(void *t, const void *s, size_t len)
bool has_message_integrity() const
std::pair< std::string, std::string > FoundationType
bool get_priority(ACE_UINT32 &priority) const
#define OPENDDS_ASSERT(C)
DCPS::WeakRcHandle< Endpoint > const endpoint
const ACE_UINT16 UNAUTHORIZED
TransactionIdToChecklistType transaction_id_to_checklist_
void enqueue(const DCPS::MonotonicTimePoint &release_time)
reference_wrapper< T > ref(T &r)
FoundationSet foundations_
Attribute make_xor_mapped_address(const ACE_INET_Addr &addr)
ChecklistPtr create_checklist(const AgentInfo &a_remote_agent_info)
void generate_transaction_id()
std::vector< AttributeType > get_unknown_attributes() const
const ACE_UINT16 UNKNOWN_ATTRIBUTE
void receive(const ACE_INET_Addr &a_local_address, const ACE_INET_Addr &a_remote_address, const STUN::Message &a_message)
Candidate make_host_candidate(const ACE_INET_Addr &address)
std::map< std::string, ChecklistPtr > UsernameToChecklistType
ACE_INET_Addr get_address(const DCPS::GUID_t &a_local_guid, const DCPS::GUID_t &a_remote_guid) const
void compute_active_foundations(ActiveFoundationSet &a_active_foundations) const
STUN::Message make_bad_request_error_response(const STUN::Message &a_message, const std::string &a_reason)
AgentImpl *const agent_impl
bool has_unknown_attributes() const
void execute(const DCPS::MonotonicTimePoint &a_now)
void send(const ACE_INET_Addr &address, const STUN::Message &message)
String to_hex_dds_string(const unsigned char *data, const size_t size, const char delim, const size_t delim_every)
const AgentInfo & agent_info() const
DCPS::WeakRcHandle< EndpointManager > endpoint_manager
const ACE_UINT16 BAD_REQUEST
bool candidates_equal(const Candidate &x, const Candidate &y)
EndpointManager(AgentImpl *a_agent_impl, DCPS::WeakRcHandle< Endpoint > a_endpoint)
ACE_UINT16 get_error_code() const
AgentInfoListenersType agent_info_listeners_
AddressListType host_addresses_
CandidatesType candidates
#define TheSecurityRegistry
TimePoint_T< MonotonicClock > MonotonicTimePoint
bool get_username(std::string &username) const
void request(const ACE_INET_Addr &a_local_address, const ACE_INET_Addr &a_remote_address, const STUN::Message &a_message)
Attribute make_error_code(ACE_UINT16 code, const std::string &reason)
ACE_INET_Addr next_stun_server_address_
Attribute make_message_integrity()
void indication(const ACE_INET_Addr &a_local_address, const ACE_INET_Addr &a_remote_address, const STUN::Message &a_message)
bool has_error_code() const
bool error_response(const STUN::Message &a_message)
Attribute make_fingerprint()
ACE_INET_Addr stun_server_address_
void server_reflexive_task(const DCPS::MonotonicTimePoint &a_now)
DeferredTriggeredChecksType deferred_triggered_checks_
void append_attribute(const Attribute &attribute)
void regenerate_agent_info(bool password_only)
void execute(const DCPS::MonotonicTimePoint &a_now)
std::string get_error_reason() const
UsernameToChecklistType username_to_checklist_
DCPS::WeakRcHandle< EndpointManager > endpoint_manager
ServerReflexiveTask(DCPS::RcHandle< EndpointManager > a_endpoint_manager)
Attribute make_unknown_attributes(const std::vector< AttributeType > &unknown_attributes)
static Configuration * instance()
bool success_response(const STUN::Message &a_message)
STUN::Message make_unauthorized_error_response(const STUN::Message &a_message)
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
ACE_Recursive_Thread_Mutex mutex
bool verify_message_integrity(const std::string &password) const
void set_server_reflexive_address(const ACE_INET_Addr &a_server_reflexive_address, const ACE_INET_Addr &a_stun_server_address)
STUN::Message binding_request_
RcHandle< T > lock() const
Attribute make_mapped_address(const ACE_INET_Addr &addr)
Candidate make_server_reflexive_candidate(const ACE_INET_Addr &address, const ACE_INET_Addr &base, const ACE_INET_Addr &server_address)
bool has_use_candidate() const
void check_invariants() const
void change_password(bool password_only)
bool has_ice_controlling() const
std::vector< AttributeType > unknown_comprehension_required_attributes() const
ACE_INET_Addr server_reflexive_address_
TransactionId transaction_id
The Internal API and Implementation of OpenDDS.
void set_host_addresses(const AddressListType &a_host_addresses)
std::deque< DeferredTriggeredCheck > DeferredTriggeredCheckListType
std::map< DCPS::GUID_t, DCPS::WeakRcHandle< AgentInfoListener >, DCPS::GUID_tKeyLessThan > AgentInfoListenersType
std::set< GuidPair > GuidSetType
bool candidates_sorted(const Candidate &x, const Candidate &y)
STUN::Message make_unknown_attributes_error_response(const STUN::Message &a_message, const std::vector< STUN::AttributeType > &a_unknown_attributes)
ACE_UINT64 ice_tie_breaker_
void clear_transaction_id()
bool has_fingerprint() const