OpenDDS  Snapshot(2023/04/28-20:55)
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
OpenDDS::ICE::Checklist Struct Reference

#include <Checklist.h>

Inheritance diagram for OpenDDS::ICE::Checklist:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::ICE::Checklist:
Collaboration graph
[legend]

Public Member Functions

 Checklist (EndpointManager *a_endpoint, const AgentInfo &a_local, const AgentInfo &a_remote, ACE_UINT64 a_ice_tie_breaker)
 
void compute_active_foundations (ActiveFoundationSet &a_active_foundations) const
 
void check_invariants () const
 
bool has_transaction_id (const STUN::TransactionId &a_tid) const
 
bool has_guid_pair (const GuidPair &a_guid_pair) const
 
void unfreeze ()
 
void unfreeze (const FoundationType &a_foundation)
 
void generate_triggered_check (const ACE_INET_Addr &a_local_address, const ACE_INET_Addr &a_remote_address, ACE_UINT32 a_priority, bool a_use_candidate)
 
void success_response (const ACE_INET_Addr &a_local_address, const ACE_INET_Addr &a_remote_address, const STUN::Message &a_message)
 
void error_response (const ACE_INET_Addr &a_local_address, const ACE_INET_Addr &a_remote_address, const STUN::Message &a_message)
 
void add_guid (const GuidPair &a_guid_pair)
 
void remove_guid (const GuidPair &a_guid_pair)
 
void add_guids (const GuidSetType &a_guids)
 
void remove_guids ()
 
GuidSetType guids () const
 
ACE_INET_Addr selected_address () const
 
const AgentInfooriginal_remote_agent_info () const
 
void set_remote_password (const std::string &a_password)
 
void indication ()
 
- Public Member Functions inherited from OpenDDS::ICE::Task
 Task (AgentImpl *a_agent_impl)
 
virtual ~Task ()
 
void enqueue (const DCPS::MonotonicTimePoint &release_time)
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Private Types

typedef std::list< CandidatePairCandidatePairsType
 
typedef std::list< ConnectivityCheckConnectivityChecksType
 

Private Member Functions

 ~Checklist ()
 
void generate_candidate_pairs ()
 
void fix_foundations ()
 
void add_valid_pair (const CandidatePair &a_valid_pair)
 
bool get_local_candidate (const ACE_INET_Addr &a_address, Candidate &a_candidate)
 
bool get_remote_candidate (const ACE_INET_Addr &a_address, Candidate &a_candidate)
 
bool is_succeeded (const CandidatePair &a_candidate_pair) const
 
bool is_in_progress (const CandidatePair &a_candidate_pair) const
 
void add_triggered_check (const CandidatePair &a_candidate_pair)
 
void remove_from_in_progress (const CandidatePair &a_candidate_pair)
 
void succeeded (const ConnectivityCheck &a_connectivity_check)
 
void failed (const ConnectivityCheck &a_connectivity_check)
 
size_t size () const
 
void do_next_check (const DCPS::MonotonicTimePoint &a_now)
 
void execute (const DCPS::MonotonicTimePoint &a_now)
 

Private Attributes

EndpointManager *const endpoint_manager_
 
GuidSetType guids_
 
AgentInfo local_agent_info_
 
AgentInfo remote_agent_info_
 
AgentInfo original_remote_agent_info_
 
bool const local_is_controlling_
 
ACE_UINT64 const ice_tie_breaker_
 
CandidatePairsType frozen_
 
CandidatePairsType waiting_
 
CandidatePairsType in_progress_
 
CandidatePairsType succeeded_
 
CandidatePairsType failed_
 
CandidatePairsType triggered_check_queue_
 
CandidatePairsType valid_list_
 
CandidatePairsType::const_iterator nominating_
 
CandidatePairsType::const_iterator nominated_
 
bool nominated_is_live_
 
DCPS::MonotonicTimePoint last_indication_
 
DCPS::TimeDuration check_interval_
 
DCPS::TimeDuration max_check_interval_
 
ConnectivityChecksType connectivity_checks_
 

Additional Inherited Members

- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Detailed Description

Definition at line 155 of file Checklist.h.

Member Typedef Documentation

◆ CandidatePairsType

Definition at line 227 of file Checklist.h.

◆ ConnectivityChecksType

Definition at line 244 of file Checklist.h.

Constructor & Destructor Documentation

◆ Checklist()

OpenDDS::ICE::Checklist::Checklist ( EndpointManager a_endpoint,
const AgentInfo a_local,
const AgentInfo a_remote,
ACE_UINT64  a_ice_tie_breaker 
)

Definition at line 87 of file Checklist.cpp.

References endpoint_manager_, generate_candidate_pairs(), OpenDDS::DCPS::rchandle_from(), remote_agent_info_, OpenDDS::ICE::EndpointManager::set_responsible_checklist(), and OpenDDS::ICE::AgentInfo::username.

89  : Task(a_endpoint_manager->agent_impl)
90  , endpoint_manager_(a_endpoint_manager)
91  , local_agent_info_(local)
92  , remote_agent_info_(remote)
94  , local_is_controlling_(local.username < remote.username)
95  , ice_tie_breaker_(a_ice_tie_breaker)
96  , nominating_(valid_list_.end())
97  , nominated_(valid_list_.end())
98  , nominated_is_live_(false)
99 {
101 
103 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
AgentInfo remote_agent_info_
Definition: Checklist.h:222
Task(AgentImpl *a_agent_impl)
Definition: Task.h:29
bool const local_is_controlling_
Definition: Checklist.h:224
std::string username
Definition: Ice.h:77
CandidatePairsType::const_iterator nominated_
Definition: Checklist.h:239
CandidatePairsType::const_iterator nominating_
Definition: Checklist.h:238
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
AgentInfo local_agent_info_
Definition: Checklist.h:221
ACE_UINT64 const ice_tie_breaker_
Definition: Checklist.h:225
CandidatePairsType valid_list_
Definition: Checklist.h:236
AgentInfo original_remote_agent_info_
Definition: Checklist.h:223
void set_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)

◆ ~Checklist()

OpenDDS::ICE::Checklist::~Checklist ( )
private

Definition at line 105 of file Checklist.cpp.

106 {
107 }

Member Function Documentation

◆ add_guid()

void OpenDDS::ICE::Checklist::add_guid ( const GuidPair a_guid_pair)

Definition at line 757 of file Checklist.cpp.

References endpoint_manager_, guids_, OpenDDS::DCPS::rchandle_from(), and OpenDDS::ICE::EndpointManager::set_responsible_checklist().

Referenced by add_guids().

758 {
759  guids_.insert(a_guid_pair);
761 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
void set_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)

◆ add_guids()

void OpenDDS::ICE::Checklist::add_guids ( const GuidSetType a_guids)

Definition at line 782 of file Checklist.cpp.

References add_guid().

783 {
784  for (GuidSetType::const_iterator pos = a_guids.begin(), limit = a_guids.end(); pos != limit; ++pos) {
785  add_guid(*pos);
786  }
787 }
void add_guid(const GuidPair &a_guid_pair)
Definition: Checklist.cpp:757

◆ add_triggered_check()

void OpenDDS::ICE::Checklist::add_triggered_check ( const CandidatePair a_candidate_pair)
private

Definition at line 269 of file Checklist.cpp.

References OpenDDS::ICE::AgentImpl::add(), OpenDDS::ICE::EndpointManager::agent_impl, endpoint_manager_, failed_, OpenDDS::ICE::CandidatePair::foundation, frozen_, in_progress_, nominated_, nominating_, OpenDDS::ICE::CandidatePair::priority_sorted(), succeeded_, triggered_check_queue_, valid_list_, and waiting_.

Referenced by execute(), and generate_triggered_check().

270 {
271  if (nominating_ != valid_list_.end() || nominated_ != valid_list_.end()) {
272  // Don't generate a check when we are done.
273  return;
274  }
275 
276  CandidatePairsType::iterator pos;
277 
278  pos = std::find(frozen_.begin(), frozen_.end(), a_candidate_pair);
279 
280  if (pos != frozen_.end()) {
281  frozen_.erase(pos);
282  endpoint_manager_->agent_impl->add(a_candidate_pair.foundation);
283  waiting_.push_back(a_candidate_pair);
285  triggered_check_queue_.push_back(a_candidate_pair);
286  return;
287  }
288 
289  pos = std::find(waiting_.begin(), waiting_.end(), a_candidate_pair);
290 
291  if (pos != waiting_.end()) {
292  // Done.
293  return;
294  }
295 
296  pos = std::find(in_progress_.begin(), in_progress_.end(), a_candidate_pair);
297 
298  if (pos != in_progress_.end()) {
299  // Duplicating to waiting.
300  endpoint_manager_->agent_impl->add(a_candidate_pair.foundation);
301  waiting_.push_back(a_candidate_pair);
303  triggered_check_queue_.push_back(a_candidate_pair);
304  return;
305  }
306 
307  pos = std::find(succeeded_.begin(), succeeded_.end(), a_candidate_pair);
308 
309  if (pos != succeeded_.end()) {
310  // Done.
311  return;
312  }
313 
314  pos = std::find(failed_.begin(), failed_.end(), a_candidate_pair);
315 
316  if (pos != failed_.end()) {
317  failed_.erase(pos);
318  endpoint_manager_->agent_impl->add(a_candidate_pair.foundation);
319  waiting_.push_back(a_candidate_pair);
321  triggered_check_queue_.push_back(a_candidate_pair);
322  return;
323  }
324 
325  // Not in checklist.
326  endpoint_manager_->agent_impl->add(a_candidate_pair.foundation);
327  waiting_.push_back(a_candidate_pair);
329  triggered_check_queue_.push_back(a_candidate_pair);
330 }
CandidatePairsType in_progress_
Definition: Checklist.h:230
CandidatePairsType waiting_
Definition: Checklist.h:229
CandidatePairsType frozen_
Definition: Checklist.h:228
CandidatePairsType succeeded_
Definition: Checklist.h:231
CandidatePairsType::const_iterator nominated_
Definition: Checklist.h:239
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
CandidatePairsType::const_iterator nominating_
Definition: Checklist.h:238
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
CandidatePairsType valid_list_
Definition: Checklist.h:236
CandidatePairsType failed_
Definition: Checklist.h:232
void add(const FoundationType &a_foundation)
Definition: AgentImpl.h:91
CandidatePairsType triggered_check_queue_
Definition: Checklist.h:234

◆ add_valid_pair()

void OpenDDS::ICE::Checklist::add_valid_pair ( const CandidatePair a_valid_pair)
private

Definition at line 227 of file Checklist.cpp.

References OPENDDS_ASSERT, OpenDDS::ICE::CandidatePair::priority_sorted(), OpenDDS::ICE::CandidatePair::use_candidate, and valid_list_.

Referenced by success_response().

228 {
229  OPENDDS_ASSERT(valid_pair.use_candidate);
230  valid_list_.push_back(valid_pair);
232 }
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
CandidatePairsType valid_list_
Definition: Checklist.h:236

◆ check_invariants()

void OpenDDS::ICE::Checklist::check_invariants ( ) const

Definition at line 166 of file Checklist.cpp.

References OPENDDS_ASSERT, and valid_list_.

167 {
168  for (CandidatePairsType::const_iterator pos = valid_list_.begin(), limit = valid_list_.end(); pos != limit; ++pos) {
169  OPENDDS_ASSERT(pos->use_candidate);
170  }
171 }
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
CandidatePairsType valid_list_
Definition: Checklist.h:236

◆ compute_active_foundations()

void OpenDDS::ICE::Checklist::compute_active_foundations ( ActiveFoundationSet a_active_foundations) const

Definition at line 155 of file Checklist.cpp.

References OpenDDS::ICE::ActiveFoundationSet::add(), in_progress_, and waiting_.

156 {
157  for (CandidatePairsType::const_iterator pos = waiting_.begin(), limit = waiting_.end(); pos != limit; ++pos) {
158  active_foundations.add(pos->foundation);
159  }
160 
161  for (CandidatePairsType::const_iterator pos = in_progress_.begin(), limit = in_progress_.end(); pos != limit; ++pos) {
162  active_foundations.add(pos->foundation);
163  }
164 }
CandidatePairsType in_progress_
Definition: Checklist.h:230
CandidatePairsType waiting_
Definition: Checklist.h:229

◆ do_next_check()

void OpenDDS::ICE::Checklist::do_next_check ( const DCPS::MonotonicTimePoint a_now)
private

Definition at line 627 of file Checklist.cpp.

References OpenDDS::ICE::Candidate::address, OpenDDS::ICE::ConnectivityCheck::cancelled(), OpenDDS::ICE::ConnectivityCheck::candidate_pair(), check_interval_, OpenDDS::ICE::Configuration::checklist_period(), connectivity_checks_, endpoint_manager_, OpenDDS::ICE::ConnectivityCheck::expiration_date(), failed(), ice_tie_breaker_, in_progress_, OpenDDS::ICE::Configuration::instance(), local_agent_info_, max_check_interval_, OpenDDS::ICE::AgentInfo::password, OpenDDS::ICE::ConnectivityCheck::password(), OpenDDS::ICE::CandidatePair::priority_sorted(), OpenDDS::DCPS::rchandle_from(), OpenDDS::ICE::CandidatePair::remote, remote_agent_info_, remove_from_in_progress(), OpenDDS::ICE::ConnectivityCheck::request(), OpenDDS::ICE::EndpointManager::send(), OpenDDS::ICE::EndpointManager::set_responsible_checklist(), OpenDDS::ICE::Configuration::T_a(), OpenDDS::STUN::Message::transaction_id, triggered_check_queue_, OpenDDS::ICE::EndpointManager::unset_responsible_checklist(), and waiting_.

Referenced by execute().

628 {
629  // Triggered checks.
630  if (!triggered_check_queue_.empty()) {
631  CandidatePair cp = triggered_check_queue_.front();
632  triggered_check_queue_.pop_front();
633 
634  ConnectivityCheck cc(cp, local_agent_info_, remote_agent_info_, ice_tie_breaker_, a_now + ICE::Configuration::instance()->connectivity_check_ttl());
635 
636  waiting_.remove(cp);
637  in_progress_.push_back(cp);
639 
640  endpoint_manager_->send(cc.candidate_pair().remote.address, cc.request());
641  connectivity_checks_.push_back(cc);
642  endpoint_manager_->set_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
644  return;
645  }
646 
647  // Ordinary check.
648  if (!waiting_.empty()) {
649  CandidatePair cp = waiting_.front();
650  waiting_.pop_front();
651 
652  ConnectivityCheck cc(cp, local_agent_info_, remote_agent_info_, ice_tie_breaker_, a_now + ICE::Configuration::instance()->connectivity_check_ttl());
653 
654  in_progress_.push_back(cp);
656 
657  endpoint_manager_->send(cc.candidate_pair().remote.address, cc.request());
658  connectivity_checks_.push_back(cc);
659  endpoint_manager_->set_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
661  return;
662  }
663 
664  // Retry.
665  while (!connectivity_checks_.empty()) {
666  ConnectivityCheck cc = connectivity_checks_.front();
667  connectivity_checks_.pop_front();
668 
669  if (cc.expiration_date() < a_now) {
670  if (!cc.cancelled()) {
671  // Failing can allow nomination to proceed.
672  failed(cc);
673  } else {
674  remove_from_in_progress(cc.candidate_pair());
675  }
676 
677  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
678  continue;
679  }
680 
681  // We leave the cancelled checks in case we get a response.
682  if (!cc.cancelled()) {
683  // Reset the password in the event that it changed.
684  cc.password(remote_agent_info_.password);
685  endpoint_manager_->send(cc.candidate_pair().remote.address, cc.request());
686  }
687 
688  connectivity_checks_.push_back(cc);
689 
690  // Backoff.
692  break;
693  }
694 
695  // Waiting for the remote or frozen.
697 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
DCPS::TimeDuration check_interval_
Definition: Checklist.h:242
AgentInfo remote_agent_info_
Definition: Checklist.h:222
void remove_from_in_progress(const CandidatePair &a_candidate_pair)
Definition: Checklist.cpp:332
CandidatePairsType in_progress_
Definition: Checklist.h:230
void checklist_period(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:91
CandidatePairsType waiting_
Definition: Checklist.h:229
void T_a(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:73
void failed(const ConnectivityCheck &a_connectivity_check)
Definition: Checklist.cpp:455
void send(const ACE_INET_Addr &address, const STUN::Message &message)
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245
DCPS::TimeDuration max_check_interval_
Definition: Checklist.h:243
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
static Configuration * instance()
Definition: Ice.cpp:109
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
AgentInfo local_agent_info_
Definition: Checklist.h:221
std::string password
Definition: Ice.h:78
ACE_UINT64 const ice_tie_breaker_
Definition: Checklist.h:225
void unset_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)
void set_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)
CandidatePairsType triggered_check_queue_
Definition: Checklist.h:234

◆ error_response()

void OpenDDS::ICE::Checklist::error_response ( const ACE_INET_Addr a_local_address,
const ACE_INET_Addr a_remote_address,
const STUN::Message a_message 
)

Definition at line 560 of file Checklist.cpp.

References ACE_ERROR, ACE_TEXT(), OpenDDS::STUN::BAD_REQUEST, connectivity_checks_, endpoint_manager_, failed(), OpenDDS::STUN::Message::get_error_code(), OpenDDS::STUN::Message::get_error_reason(), OpenDDS::STUN::Message::get_unknown_attributes(), OpenDDS::STUN::Message::has_error_code(), OpenDDS::STUN::Message::has_fingerprint(), OpenDDS::STUN::Message::has_message_integrity(), OpenDDS::STUN::Message::has_unknown_attributes(), LM_WARNING, OPENDDS_ASSERT, OpenDDS::DCPS::rchandle_from(), OpenDDS::STUN::Message::transaction_id, OpenDDS::STUN::UNKNOWN_ATTRIBUTE, OpenDDS::STUN::Message::unknown_comprehension_required_attributes(), OpenDDS::ICE::EndpointManager::unset_responsible_checklist(), and OpenDDS::STUN::Message::verify_message_integrity().

563 {
564  ConnectivityChecksType::iterator pos = std::find(connectivity_checks_.begin(), connectivity_checks_.end(), a_message.transaction_id);
565  OPENDDS_ASSERT(pos != connectivity_checks_.end());
566 
567  ConnectivityCheck const cc = *pos;
568 
569  if (!a_message.has_message_integrity()) {
570  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING No MESSAGE_INTEGRITY attribute\n")));
571  // Retry.
572  return;
573  }
574 
575  if (!a_message.verify_message_integrity(cc.request().password)) {
576  // Retry.
577  return;
578  }
579 
580  // We have a verified error response.
581  std::vector<STUN::AttributeType> unknown_attributes = a_message.unknown_comprehension_required_attributes();
582 
583  if (!unknown_attributes.empty()) {
584  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING Unknown comprehension required attributes\n")));
585  failed(cc);
586  connectivity_checks_.erase(pos);
587  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
588  return;
589  }
590 
591  if (!a_message.has_fingerprint()) {
592  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING No FINGERPRINT attribute\n")));
593  failed(cc);
594  connectivity_checks_.erase(pos);
595  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
596  return;
597  }
598 
599  if (a_message.has_error_code()) {
600  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING ")
601  ACE_TEXT("STUN error response code=%d reason=%s\n"),
602  a_message.get_error_code(),
603  a_message.get_error_reason().c_str()));
604 
605  if (a_message.get_error_code() == STUN::UNKNOWN_ATTRIBUTE && a_message.has_unknown_attributes()) {
606  std::vector<STUN::AttributeType> unknown_attributes = a_message.get_unknown_attributes();
607 
608  for (std::vector<STUN::AttributeType>::const_iterator pos = unknown_attributes.begin(),
609  limit = unknown_attributes.end(); pos != limit; ++pos) {
610  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING Unknown STUN attribute %d\n"), *pos));
611  }
612  }
613 
614  if (a_message.get_error_code() == STUN::BAD_REQUEST || a_message.get_error_code() == STUN::UNKNOWN_ATTRIBUTE) {
615  // Waiting and/or resending won't fix these errors.
616  failed(cc);
617  connectivity_checks_.erase(pos);
618  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
619  }
620  }
621 
622  else {
623  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::error_response: WARNING STUN error response (no code)\n")));
624  }
625 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
#define ACE_ERROR(X)
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
const ACE_UINT16 UNKNOWN_ATTRIBUTE
Definition: Stun.h:53
void failed(const ConnectivityCheck &a_connectivity_check)
Definition: Checklist.cpp:455
const ACE_UINT16 BAD_REQUEST
Definition: Stun.h:51
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245
ACE_TEXT("TCP_Factory")
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
void unset_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)

◆ execute()

void OpenDDS::ICE::Checklist::execute ( const DCPS::MonotonicTimePoint a_now)
privatevirtual

Implements OpenDDS::ICE::Task.

Definition at line 699 of file Checklist.cpp.

References add_triggered_check(), OpenDDS::STUN::Message::append_attribute(), OpenDDS::STUN::BINDING, check_interval_, OpenDDS::STUN::Message::class_, connectivity_checks_, do_next_check(), endpoint_manager_, OpenDDS::ICE::Task::enqueue(), frozen_, OpenDDS::STUN::Message::generate_transaction_id(), guids_, OpenDDS::ICE::EndpointManager::ice_connect(), OpenDDS::ICE::EndpointManager::ice_disconnect(), OpenDDS::STUN::INDICATION, OpenDDS::ICE::Configuration::instance(), last_indication_, local_agent_info_, local_is_controlling_, OpenDDS::STUN::make_fingerprint(), OpenDDS::STUN::make_message_integrity(), OpenDDS::STUN::make_username(), OpenDDS::STUN::Message::method, nominated_, nominated_is_live_, OpenDDS::ICE::Configuration::nominated_ttl(), nominating_, OpenDDS::ICE::AgentInfo::password, OpenDDS::STUN::Message::password, remote_agent_info_, OpenDDS::ICE::EndpointManager::send(), triggered_check_queue_, OpenDDS::ICE::AgentInfo::username, valid_list_, and waiting_.

700 {
701  // Nominating check.
702  if (frozen_.empty() &&
703  waiting_.empty() &&
704  // in_progress_.empty() &&
706  !valid_list_.empty() &&
707  nominating_ == valid_list_.end() &&
708  nominated_ == valid_list_.end()) {
709  triggered_check_queue_.clear();
711  nominating_ = valid_list_.begin();
712  }
713 
714  bool flag = false;
715  TimeDuration interval = std::max(check_interval_, ICE::Configuration::instance()->indication_period());
716 
717  if (!triggered_check_queue_.empty() ||
718  !frozen_.empty() ||
719  !waiting_.empty() ||
720  !connectivity_checks_.empty()) {
721  do_next_check(a_now);
722  flag = true;
723  interval = std::min(interval, check_interval_);
724  }
725 
726  if (nominated_ != valid_list_.end()) {
727  // Send an indication.
728  STUN::Message message;
729  message.class_ = STUN::INDICATION;
730  message.method = STUN::BINDING;
731  message.generate_transaction_id();
732  message.append_attribute(STUN::make_username(remote_agent_info_.username + ":" + local_agent_info_.username));
733  message.password = remote_agent_info_.password;
734  message.append_attribute(STUN::make_message_integrity());
735  message.append_attribute(STUN::make_fingerprint());
736  endpoint_manager_->send(nominated_->remote.address, message);
737  flag = true;
738  interval = std::min(interval, ICE::Configuration::instance()->indication_period());
739 
740  // Check that we are receiving indications.
741  const bool before = nominated_is_live_;
743  if (before && !nominated_is_live_) {
745  } else if (!before && nominated_is_live_) {
746  endpoint_manager_->ice_connect(guids_, nominated_->remote.address);
747  }
748  }
749 
750  if (flag) {
751  enqueue(MonotonicTimePoint::now() + interval);
752  }
753 
754  // The checklist has failed. Don't schedule.
755 }
void add_triggered_check(const CandidatePair &a_candidate_pair)
Definition: Checklist.cpp:269
DCPS::TimeDuration check_interval_
Definition: Checklist.h:242
AgentInfo remote_agent_info_
Definition: Checklist.h:222
Attribute make_username(const std::string &username)
Definition: Stun.cpp:84
void ice_disconnect(const GuidSetType &guids, const ACE_INET_Addr &addr)
void enqueue(const DCPS::MonotonicTimePoint &release_time)
Definition: Task.cpp:19
void ice_connect(const GuidSetType &guids, const ACE_INET_Addr &addr)
CandidatePairsType waiting_
Definition: Checklist.h:229
void nominated_ttl(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:109
void send(const ACE_INET_Addr &address, const STUN::Message &message)
CandidatePairsType frozen_
Definition: Checklist.h:228
bool const local_is_controlling_
Definition: Checklist.h:224
DCPS::MonotonicTimePoint last_indication_
Definition: Checklist.h:241
void do_next_check(const DCPS::MonotonicTimePoint &a_now)
Definition: Checklist.cpp:627
std::string username
Definition: Ice.h:77
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245
CandidatePairsType::const_iterator nominated_
Definition: Checklist.h:239
Attribute make_message_integrity()
Definition: Stun.cpp:92
Attribute make_fingerprint()
Definition: Stun.cpp:139
static Configuration * instance()
Definition: Ice.cpp:109
CandidatePairsType::const_iterator nominating_
Definition: Checklist.h:238
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
AgentInfo local_agent_info_
Definition: Checklist.h:221
std::string password
Definition: Ice.h:78
CandidatePairsType valid_list_
Definition: Checklist.h:236
CandidatePairsType triggered_check_queue_
Definition: Checklist.h:234

◆ failed()

void OpenDDS::ICE::Checklist::failed ( const ConnectivityCheck a_connectivity_check)
private

Definition at line 455 of file Checklist.cpp.

References OpenDDS::ICE::ConnectivityCheck::candidate_pair(), failed_, local_is_controlling_, nominating_, OpenDDS::ICE::CandidatePair::priority_sorted(), remove_from_in_progress(), OpenDDS::ICE::CandidatePair::use_candidate, and valid_list_.

Referenced by do_next_check(), error_response(), succeeded(), and success_response().

456 {
457  const CandidatePair& cp = cc.candidate_pair();
458  // 7.2.5.4
460  failed_.push_back(cp);
462 
463  if (cp.use_candidate && local_is_controlling_) {
464  valid_list_.pop_front();
465  nominating_ = valid_list_.end();
466  }
467 }
void remove_from_in_progress(const CandidatePair &a_candidate_pair)
Definition: Checklist.cpp:332
bool const local_is_controlling_
Definition: Checklist.h:224
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
CandidatePairsType::const_iterator nominating_
Definition: Checklist.h:238
CandidatePairsType valid_list_
Definition: Checklist.h:236
CandidatePairsType failed_
Definition: Checklist.h:232

◆ fix_foundations()

void OpenDDS::ICE::Checklist::fix_foundations ( )
private

Definition at line 234 of file Checklist.cpp.

References OpenDDS::ICE::EndpointManager::agent_impl, endpoint_manager_, in_progress_, OpenDDS::ICE::AgentImpl::remove(), and waiting_.

Referenced by remove_guid().

235 {
236  for (CandidatePairsType::const_iterator pos = waiting_.begin(), limit = waiting_.end(); pos != limit; ++pos) {
237  endpoint_manager_->agent_impl->remove(pos->foundation);
238  }
239 
240  for (CandidatePairsType::const_iterator pos = in_progress_.begin(), limit = in_progress_.end(); pos != limit; ++pos) {
241  endpoint_manager_->agent_impl->remove(pos->foundation);
242  }
243 }
CandidatePairsType in_progress_
Definition: Checklist.h:230
CandidatePairsType waiting_
Definition: Checklist.h:229
void remove(const FoundationType &a_foundation)
Definition: AgentImpl.cpp:228
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219

◆ generate_candidate_pairs()

void OpenDDS::ICE::Checklist::generate_candidate_pairs ( )
private

Definition at line 109 of file Checklist.cpp.

References OpenDDS::ICE::AgentInfo::candidates, check_interval_, OpenDDS::ICE::Configuration::checklist_period(), frozen_, OpenDDS::ICE::Configuration::instance(), local_agent_info_, local_is_controlling_, max_check_interval_, OpenDDS::ICE::CandidatePair::priority_sorted(), remote_agent_info_, and OpenDDS::ICE::Configuration::T_a().

Referenced by Checklist().

110 {
111  // Add the candidate pairs.
112  AgentInfo::CandidatesType::const_iterator local_pos = local_agent_info_.candidates.begin();
113  AgentInfo::CandidatesType::const_iterator local_limit = local_agent_info_.candidates.end();
114  for (; local_pos != local_limit; ++local_pos) {
115  AgentInfo::CandidatesType::const_iterator remote_pos = remote_agent_info_.candidates.begin();
116  AgentInfo::CandidatesType::const_iterator remote_limit = remote_agent_info_.candidates.end();
117  for (; remote_pos != remote_limit; ++remote_pos) {
118 #if ACE_HAS_IPV6
119  if ((local_pos->address.is_linklocal() && remote_pos->address.is_linklocal()) ||
120  (!local_pos->address.is_linklocal() && !remote_pos->address.is_linklocal())) {
121  frozen_.push_back(CandidatePair(*local_pos, *remote_pos, local_is_controlling_));
122  }
123 #else
124  frozen_.push_back(CandidatePair(*local_pos, *remote_pos, local_is_controlling_));
125 #endif
126  }
127  }
128 
129  // Sort by priority.
131 
132  // Eliminate duplicates.
133  for (CandidatePairsType::iterator pos = frozen_.begin(), limit = frozen_.end(); pos != limit; ++pos) {
134  CandidatePairsType::iterator test_pos = pos;
135  ++test_pos;
136 
137  while (test_pos != limit) {
138  if (pos->local.base == test_pos->local.base && pos->remote == test_pos->remote) {
139  frozen_.erase(test_pos++);
140  }
141 
142  else {
143  ++test_pos;
144  }
145  }
146  }
147 
148  if (frozen_.size() != 0) {
150  double s = static_cast<double>(frozen_.size());
152  }
153 }
DCPS::TimeDuration check_interval_
Definition: Checklist.h:242
AgentInfo remote_agent_info_
Definition: Checklist.h:222
void checklist_period(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:91
void T_a(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:73
CandidatePairsType frozen_
Definition: Checklist.h:228
bool const local_is_controlling_
Definition: Checklist.h:224
CandidatesType candidates
Definition: Ice.h:74
DCPS::TimeDuration max_check_interval_
Definition: Checklist.h:243
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
static Configuration * instance()
Definition: Ice.cpp:109
AgentInfo local_agent_info_
Definition: Checklist.h:221

◆ generate_triggered_check()

void OpenDDS::ICE::Checklist::generate_triggered_check ( const ACE_INET_Addr a_local_address,
const ACE_INET_Addr a_remote_address,
ACE_UINT32  a_priority,
bool  a_use_candidate 
)

Definition at line 340 of file Checklist.cpp.

References ACE_ERROR, ACE_TEXT(), add_triggered_check(), OpenDDS::ICE::EndpointManager::agent_impl, OpenDDS::ICE::AgentInfo::candidates, OpenDDS::ICE::candidates_sorted(), check_interval_, connectivity_checks_, endpoint_manager_, OpenDDS::ICE::Task::enqueue(), get_local_candidate(), get_remote_candidate(), OpenDDS::ICE::Configuration::instance(), is_in_progress(), is_succeeded(), LM_WARNING, local_is_controlling_, OpenDDS::ICE::make_peer_reflexive_candidate(), remote_agent_info_, OpenDDS::ICE::AgentImpl::remote_peer_reflexive_counter(), and OpenDDS::ICE::Configuration::T_a().

344 {
345  Candidate remote;
346 
347  if (!get_remote_candidate(remote_address, remote)) {
348  // 7.3.1.3
350  remote_agent_info_.candidates.push_back(remote);
352  }
353 
354  // 7.3.1.4
355  Candidate local;
356  bool flag = get_local_candidate(local_address, local);
357  if (!flag) {
358  // Network addresses may have changed so that local_address is not valid.
359  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::generate_triggered_check: WARNING local_address %C is no longer a local candidate\n"),
360  DCPS::LogAddr(local_address).c_str()));
361  return;
362  }
363 
364  CandidatePair cp(local, remote, local_is_controlling_, use_candidate);
365 
366  if (is_succeeded(cp)) {
367  return;
368  }
369 
370  if (is_in_progress(cp)) {
371  ConnectivityChecksType::iterator pos = std::find(connectivity_checks_.begin(), connectivity_checks_.end(), cp);
372  pos->cancel();
373  }
374 
376  // This can move something from failed to in progress.
377  // In that case, we need to schedule.
379  enqueue(MonotonicTimePoint::now());
380 }
void add_triggered_check(const CandidatePair &a_candidate_pair)
Definition: Checklist.cpp:269
#define ACE_ERROR(X)
DCPS::TimeDuration check_interval_
Definition: Checklist.h:242
AgentInfo remote_agent_info_
Definition: Checklist.h:222
bool is_succeeded(const CandidatePair &a_candidate_pair) const
Definition: Checklist.h:259
void enqueue(const DCPS::MonotonicTimePoint &release_time)
Definition: Task.cpp:19
Candidate make_peer_reflexive_candidate(const ACE_INET_Addr &address, const ACE_INET_Addr &base, const ACE_INET_Addr &server_address, ACE_UINT32 priority)
Definition: Ice.cpp:88
void T_a(const DCPS::TimeDuration &x)
Definition: RTPS/ICE/Ice.h:73
bool const local_is_controlling_
Definition: Checklist.h:224
bool get_local_candidate(const ACE_INET_Addr &a_address, Candidate &a_candidate)
Definition: Checklist.cpp:245
CandidatesType candidates
Definition: Ice.h:74
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245
ACE_TEXT("TCP_Factory")
bool get_remote_candidate(const ACE_INET_Addr &a_address, Candidate &a_candidate)
Definition: Checklist.cpp:257
static Configuration * instance()
Definition: Ice.cpp:109
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
bool is_in_progress(const CandidatePair &a_candidate_pair) const
Definition: Checklist.h:264
bool candidates_sorted(const Candidate &x, const Candidate &y)
Definition: Ice.cpp:21
size_t remote_peer_reflexive_counter()
Definition: AgentImpl.h:81

◆ get_local_candidate()

bool OpenDDS::ICE::Checklist::get_local_candidate ( const ACE_INET_Addr a_address,
Candidate a_candidate 
)
private

Definition at line 245 of file Checklist.cpp.

References OpenDDS::ICE::AgentInfo::begin(), OpenDDS::ICE::AgentInfo::end(), and local_agent_info_.

Referenced by generate_triggered_check(), and success_response().

246 {
247  for (AgentInfo::const_iterator pos = local_agent_info_.begin(), limit = local_agent_info_.end(); pos != limit; ++pos) {
248  if (pos->address == address) {
249  candidate = *pos;
250  return true;
251  }
252  }
253 
254  return false;
255 }
CandidatesType::const_iterator const_iterator
Definition: Ice.h:72
const_iterator end() const
Definition: Ice.h:85
const_iterator begin() const
Definition: Ice.h:81
AgentInfo local_agent_info_
Definition: Checklist.h:221

◆ get_remote_candidate()

bool OpenDDS::ICE::Checklist::get_remote_candidate ( const ACE_INET_Addr a_address,
Candidate a_candidate 
)
private

Definition at line 257 of file Checklist.cpp.

References OpenDDS::ICE::AgentInfo::begin(), OpenDDS::ICE::AgentInfo::end(), and remote_agent_info_.

Referenced by generate_triggered_check().

258 {
259  for (AgentInfo::const_iterator pos = remote_agent_info_.begin(), limit = remote_agent_info_.end(); pos != limit; ++pos) {
260  if (pos->address == address) {
261  candidate = *pos;
262  return true;
263  }
264  }
265 
266  return false;
267 }
AgentInfo remote_agent_info_
Definition: Checklist.h:222
CandidatesType::const_iterator const_iterator
Definition: Ice.h:72
const_iterator end() const
Definition: Ice.h:85
const_iterator begin() const
Definition: Ice.h:81

◆ guids()

GuidSetType OpenDDS::ICE::Checklist::guids ( ) const
inline

Definition at line 198 of file Checklist.h.

Referenced by remove_guids().

199  {
200  return guids_;
201  }

◆ has_guid_pair()

bool OpenDDS::ICE::Checklist::has_guid_pair ( const GuidPair a_guid_pair) const
inline

Definition at line 169 of file Checklist.h.

170  {
171  return guids_.find(a_guid_pair) != guids_.end();
172  }

◆ has_transaction_id()

bool OpenDDS::ICE::Checklist::has_transaction_id ( const STUN::TransactionId a_tid) const
inline

Definition at line 164 of file Checklist.h.

165  {
166  return std::find(connectivity_checks_.begin(), connectivity_checks_.end(), a_tid) != connectivity_checks_.end();
167  }
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245

◆ indication()

void OpenDDS::ICE::Checklist::indication ( )

◆ is_in_progress()

bool OpenDDS::ICE::Checklist::is_in_progress ( const CandidatePair a_candidate_pair) const
inlineprivate

Definition at line 264 of file Checklist.h.

Referenced by generate_triggered_check().

265  {
266  return std::find(in_progress_.begin(), in_progress_.end(), a_candidate_pair) != in_progress_.end();
267  }
CandidatePairsType in_progress_
Definition: Checklist.h:230

◆ is_succeeded()

bool OpenDDS::ICE::Checklist::is_succeeded ( const CandidatePair a_candidate_pair) const
inlineprivate

Definition at line 259 of file Checklist.h.

Referenced by generate_triggered_check().

260  {
261  return std::find(succeeded_.begin(), succeeded_.end(), a_candidate_pair) != succeeded_.end();
262  }
CandidatePairsType succeeded_
Definition: Checklist.h:231

◆ original_remote_agent_info()

const AgentInfo& OpenDDS::ICE::Checklist::original_remote_agent_info ( ) const
inline

Definition at line 205 of file Checklist.h.

206  {
208  }
AgentInfo original_remote_agent_info_
Definition: Checklist.h:223

◆ remove_from_in_progress()

void OpenDDS::ICE::Checklist::remove_from_in_progress ( const CandidatePair a_candidate_pair)
private

Definition at line 332 of file Checklist.cpp.

References OpenDDS::ICE::EndpointManager::agent_impl, endpoint_manager_, OpenDDS::ICE::CandidatePair::foundation, in_progress_, and OpenDDS::ICE::AgentImpl::remove().

Referenced by do_next_check(), failed(), and succeeded().

333 {
334  endpoint_manager_->agent_impl->remove(a_candidate_pair.foundation);
335  // Candidates can be in progress multiple times.
336  CandidatePairsType::iterator pos = std::find(in_progress_.begin(), in_progress_.end(), a_candidate_pair);
337  in_progress_.erase(pos);
338 }
CandidatePairsType in_progress_
Definition: Checklist.h:230
void remove(const FoundationType &a_foundation)
Definition: AgentImpl.cpp:228
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219

◆ remove_guid()

void OpenDDS::ICE::Checklist::remove_guid ( const GuidPair a_guid_pair)

Definition at line 763 of file Checklist.cpp.

References connectivity_checks_, endpoint_manager_, fix_foundations(), guids_, OpenDDS::DCPS::rchandle_from(), remote_agent_info_, OpenDDS::ICE::EndpointManager::unset_responsible_checklist(), and OpenDDS::ICE::AgentInfo::username.

Referenced by remove_guids().

764 {
765  guids_.erase(a_guid_pair);
767 
768  if (guids_.empty()) {
769  // Cleanup this checklist.
770  fix_foundations();
771 
772  for (ConnectivityChecksType::const_iterator pos = connectivity_checks_.begin(),
773  limit = connectivity_checks_.end(); pos != limit; ++pos) {
774  endpoint_manager_->unset_responsible_checklist(pos->request().transaction_id, rchandle_from(this));
775  }
776 
777  // This should drop our ref-count to zero.
779  }
780 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
AgentInfo remote_agent_info_
Definition: Checklist.h:222
std::string username
Definition: Ice.h:77
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
void unset_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)

◆ remove_guids()

void OpenDDS::ICE::Checklist::remove_guids ( )

Definition at line 789 of file Checklist.cpp.

References guids(), guids_, and remove_guid().

790 {
792 
793  for (GuidSetType::const_iterator pos = guids.begin(), limit = guids.end(); pos != limit; ++pos) {
794  remove_guid(*pos);
795  }
796 }
GuidSetType guids() const
Definition: Checklist.h:198
void remove_guid(const GuidPair &a_guid_pair)
Definition: Checklist.cpp:763
std::set< GuidPair > GuidSetType
Definition: RTPS/ICE/Ice.h:39

◆ selected_address()

ACE_INET_Addr OpenDDS::ICE::Checklist::selected_address ( ) const

Definition at line 798 of file Checklist.cpp.

References nominated_, nominated_is_live_, and valid_list_.

799 {
800  if (nominated_is_live_ && nominated_ != valid_list_.end()) {
801  return nominated_->remote.address;
802  }
803 
804  return ACE_INET_Addr();
805 }
CandidatePairsType::const_iterator nominated_
Definition: Checklist.h:239
CandidatePairsType valid_list_
Definition: Checklist.h:236

◆ set_remote_password()

void OpenDDS::ICE::Checklist::set_remote_password ( const std::string &  a_password)
inline

Definition at line 210 of file Checklist.h.

211  {
212  remote_agent_info_.password = a_password;
214  }
AgentInfo remote_agent_info_
Definition: Checklist.h:222
std::string password
Definition: Ice.h:78
AgentInfo original_remote_agent_info_
Definition: Checklist.h:223

◆ size()

size_t OpenDDS::ICE::Checklist::size ( void  ) const
inlineprivate

Definition at line 278 of file Checklist.h.

279  {
280  return frozen_.size() + waiting_.size() + in_progress_.size();
281  }
CandidatePairsType in_progress_
Definition: Checklist.h:230
CandidatePairsType waiting_
Definition: Checklist.h:229
CandidatePairsType frozen_
Definition: Checklist.h:228

◆ succeeded()

void OpenDDS::ICE::Checklist::succeeded ( const ConnectivityCheck a_connectivity_check)
private

Definition at line 382 of file Checklist.cpp.

References OpenDDS::ICE::EndpointManager::agent_impl, OpenDDS::ICE::ConnectivityCheck::cancelled(), OpenDDS::ICE::ConnectivityCheck::candidate_pair(), connectivity_checks_, endpoint_manager_, failed(), failed_, OpenDDS::ICE::CandidatePair::foundation, frozen_, guids_, OpenDDS::ICE::EndpointManager::ice_connect(), in_progress_, last_indication_, local_is_controlling_, nominated_, nominated_is_live_, nominating_, OPENDDS_ASSERT, OpenDDS::ICE::CandidatePair::priority_sorted(), OpenDDS::DCPS::rchandle_from(), OpenDDS::ICE::AgentImpl::remove(), remove_from_in_progress(), OpenDDS::ICE::ConnectivityCheck::request(), OpenDDS::DCPS::TimePoint_T< AceClock >::set_to_now(), succeeded_, OpenDDS::STUN::Message::transaction_id, triggered_check_queue_, OpenDDS::ICE::AgentImpl::unfreeze(), OpenDDS::ICE::EndpointManager::unset_responsible_checklist(), OpenDDS::ICE::CandidatePair::use_candidate, valid_list_, and waiting_.

Referenced by success_response().

383 {
384  const CandidatePair& cp = cc.candidate_pair();
385 
386  // 7.2.5.3.3
387  // 7.2.5.4
388 
390  succeeded_.push_back(cp);
392 
393  if (cp.use_candidate) {
394  if (local_is_controlling_) {
396  nominating_ = valid_list_.end();
397  OPENDDS_ASSERT(frozen_.empty());
398  OPENDDS_ASSERT(waiting_.empty());
399  }
400 
401  else {
402  nominated_ = std::find(valid_list_.begin(), valid_list_.end(), cp);
403 
404  // This is the case where the use_candidate check succeeded before the normal check.
405  if (nominated_ == valid_list_.end()) {
406  valid_list_.push_front(cp);
407  nominated_ = valid_list_.begin();
408  }
409 
410  while (!frozen_.empty()) {
411  CandidatePair cp = frozen_.front();
412  frozen_.pop_front();
413  failed_.push_back(cp);
414  }
415 
416  while (!waiting_.empty()) {
417  CandidatePair cp = waiting_.front();
418  waiting_.pop_front();
419  endpoint_manager_->agent_impl->remove(cp.foundation);
420  failed_.push_back(cp);
421  }
422 
423  triggered_check_queue_.clear();
424  }
425 
426  nominated_is_live_ = true;
427  endpoint_manager_->ice_connect(guids_, nominated_->remote.address);
429 
430  while (!connectivity_checks_.empty()) {
431  ConnectivityCheck cc = connectivity_checks_.front();
432  connectivity_checks_.pop_front();
433 
434  if (!cc.cancelled()) {
435  failed(cc);
436  }
437 
438  else {
439  remove_from_in_progress(cc.candidate_pair());
440  }
441 
442  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
443  }
444 
445  OPENDDS_ASSERT(frozen_.empty());
446  OPENDDS_ASSERT(waiting_.empty());
448  OPENDDS_ASSERT(in_progress_.empty());
450  }
451 
452  endpoint_manager_->agent_impl->unfreeze(cp.foundation);
453 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
void remove_from_in_progress(const CandidatePair &a_candidate_pair)
Definition: Checklist.cpp:332
void unfreeze(const FoundationType &a_foundation)
Definition: AgentImpl.cpp:234
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
void ice_connect(const GuidSetType &guids, const ACE_INET_Addr &addr)
CandidatePairsType in_progress_
Definition: Checklist.h:230
CandidatePairsType waiting_
Definition: Checklist.h:229
void failed(const ConnectivityCheck &a_connectivity_check)
Definition: Checklist.cpp:455
CandidatePairsType frozen_
Definition: Checklist.h:228
bool const local_is_controlling_
Definition: Checklist.h:224
DCPS::MonotonicTimePoint last_indication_
Definition: Checklist.h:241
CandidatePairsType succeeded_
Definition: Checklist.h:231
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245
CandidatePairsType::const_iterator nominated_
Definition: Checklist.h:239
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
void remove(const FoundationType &a_foundation)
Definition: AgentImpl.cpp:228
CandidatePairsType::const_iterator nominating_
Definition: Checklist.h:238
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
CandidatePairsType valid_list_
Definition: Checklist.h:236
void unset_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)
CandidatePairsType failed_
Definition: Checklist.h:232
CandidatePairsType triggered_check_queue_
Definition: Checklist.h:234

◆ success_response()

void OpenDDS::ICE::Checklist::success_response ( const ACE_INET_Addr a_local_address,
const ACE_INET_Addr a_remote_address,
const STUN::Message a_message 
)

Definition at line 469 of file Checklist.cpp.

References ACE_ERROR, ACE_TEXT(), add_valid_pair(), OpenDDS::ICE::Candidate::address, OpenDDS::ICE::Candidate::base, OpenDDS::ICE::AgentInfo::candidates, OpenDDS::ICE::candidates_sorted(), connectivity_checks_, endpoint_manager_, failed(), get_local_candidate(), OpenDDS::STUN::Message::get_mapped_address(), OpenDDS::STUN::Message::has_fingerprint(), OpenDDS::STUN::Message::has_message_integrity(), LM_WARNING, OpenDDS::ICE::CandidatePair::local, local_agent_info_, local_is_controlling_, OpenDDS::ICE::make_peer_reflexive_candidate(), OPENDDS_ASSERT, OpenDDS::DCPS::rchandle_from(), OpenDDS::ICE::CandidatePair::remote, succeeded(), OpenDDS::STUN::Message::transaction_id, OpenDDS::STUN::Message::unknown_comprehension_required_attributes(), OpenDDS::ICE::EndpointManager::unset_responsible_checklist(), OpenDDS::ICE::CandidatePair::use_candidate, and OpenDDS::STUN::Message::verify_message_integrity().

472 {
473  ConnectivityChecksType::iterator pos = std::find(connectivity_checks_.begin(), connectivity_checks_.end(), a_message.transaction_id);
474  OPENDDS_ASSERT(pos != connectivity_checks_.end());
475 
476  ConnectivityCheck const cc = *pos;
477 
478  std::vector<STUN::AttributeType> unknown_attributes = a_message.unknown_comprehension_required_attributes();
479 
480  if (!unknown_attributes.empty()) {
481  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::success_response: WARNING Unknown comprehension required attributes\n")));
482  failed(cc);
483  connectivity_checks_.erase(pos);
484  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
485  return;
486  }
487 
488  if (!a_message.has_fingerprint()) {
489  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::success_response: WARNING No FINGERPRINT attribute\n")));
490  failed(cc);
491  connectivity_checks_.erase(pos);
492  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
493  return;
494  }
495 
496  ACE_INET_Addr mapped_address;
497 
498  if (!a_message.get_mapped_address(mapped_address)) {
499  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::success_response: WARNING No (XOR_)MAPPED_ADDRESS attribute\n")));
500  failed(cc);
501  connectivity_checks_.erase(pos);
502  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
503  return;
504  }
505 
506  if (!a_message.has_message_integrity()) {
507  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::success_response: WARNING No MESSAGE_INTEGRITY attribute\n")));
508  failed(cc);
509  connectivity_checks_.erase(pos);
510  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
511  return;
512  }
513 
514  // Require integrity for checks.
515  if (!a_message.verify_message_integrity(cc.request().password)) {
516  ACE_ERROR((LM_WARNING, ACE_TEXT("(%P|%t) Checklist::success_response: WARNING MESSAGE_INTEGRITY check failed\n")));
517  failed(cc);
518  connectivity_checks_.erase(pos);
519  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
520  return;
521  }
522 
523  // At this point the check will either succeed or fail so remove from the list.
524  connectivity_checks_.erase(pos);
525  endpoint_manager_->unset_responsible_checklist(cc.request().transaction_id, rchandle_from(this));
526 
527  const CandidatePair& cp = cc.candidate_pair();
528 
529  if (remote_address != cp.remote.address || local_address != cp.local.base) {
530  // 7.2.5.2.1 Non-Symmetric Transport Addresses
531  failed(cc);
532  return;
533  }
534 
535  succeeded(cc);
536 
537  if (cp.use_candidate) {
538  return;
539  }
540 
541  // 7.2.5.3.2 Constructing a Valid Pair
542  Candidate local;
543 
544  if (!get_local_candidate(mapped_address, local)) {
545  // 7.2.5.3.1 Discovering Peer-Reflexive Candidates
546  ACE_UINT32 priority;
547  // Our message, no need to check.
548  cc.request().get_priority(priority);
549  local = make_peer_reflexive_candidate(mapped_address, cp.local.base, cp.remote.address, priority);
550  local_agent_info_.candidates.push_back(local);
552  }
553 
554  // The valid pair
555  CandidatePair vp(local, cp.remote, local_is_controlling_, true);
556 
557  add_valid_pair(vp);
558 }
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310
#define ACE_ERROR(X)
void add_valid_pair(const CandidatePair &a_valid_pair)
Definition: Checklist.cpp:227
#define OPENDDS_ASSERT(C)
Definition: Definitions.h:72
Candidate make_peer_reflexive_candidate(const ACE_INET_Addr &address, const ACE_INET_Addr &base, const ACE_INET_Addr &server_address, ACE_UINT32 priority)
Definition: Ice.cpp:88
void failed(const ConnectivityCheck &a_connectivity_check)
Definition: Checklist.cpp:455
bool const local_is_controlling_
Definition: Checklist.h:224
bool get_local_candidate(const ACE_INET_Addr &a_address, Candidate &a_candidate)
Definition: Checklist.cpp:245
CandidatesType candidates
Definition: Ice.h:74
ConnectivityChecksType connectivity_checks_
Definition: Checklist.h:245
void succeeded(const ConnectivityCheck &a_connectivity_check)
Definition: Checklist.cpp:382
ACE_TEXT("TCP_Factory")
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
AgentInfo local_agent_info_
Definition: Checklist.h:221
void unset_responsible_checklist(const STUN::TransactionId &a_transaction_id, ChecklistPtr a_checklist)
bool candidates_sorted(const Candidate &x, const Candidate &y)
Definition: Ice.cpp:21

◆ unfreeze() [1/2]

void OpenDDS::ICE::Checklist::unfreeze ( )

Definition at line 173 of file Checklist.cpp.

References OpenDDS::ICE::AgentImpl::add(), OpenDDS::ICE::EndpointManager::agent_impl, OpenDDS::ICE::AgentImpl::contains(), endpoint_manager_, OpenDDS::ICE::Task::enqueue(), OpenDDS::ICE::CandidatePair::foundation, OpenDDS::ICE::EndpointManager::foundations(), frozen_, OpenDDS::ICE::CandidatePair::priority_sorted(), and waiting_.

174 {
175  bool flag = false;
176 
177  for (CandidatePairsType::iterator pos = frozen_.begin(), limit = frozen_.end(); pos != limit;) {
178  const CandidatePair& cp = *pos;
179 
180  // The second check allows the Checklist to start work on remote
181  // foundations that also belong to its local agent meaning that the
182  // remote agent is probably another EndpointManager in this
183  // process. They will share an AgentImpl and therefore the same
184  // set of active foundations. This will cause deadlock since both
185  // cannot be the first to use the foundation unless we explicitly
186  // allow it.
187  if (!endpoint_manager_->agent_impl->contains(cp.foundation) ||
188  endpoint_manager_->foundations().count(cp.foundation.second)) {
189  endpoint_manager_->agent_impl->add(cp.foundation);
190  waiting_.push_back(cp);
192  frozen_.erase(pos++);
193  flag = true;
194  } else {
195  ++pos;
196  }
197  }
198 
199  if (flag) {
200  enqueue(MonotonicTimePoint::now());
201  }
202 }
bool contains(const FoundationType &a_foundation) const
Definition: AgentImpl.h:86
void enqueue(const DCPS::MonotonicTimePoint &release_time)
Definition: Task.cpp:19
CandidatePairsType waiting_
Definition: Checklist.h:229
CandidatePairsType frozen_
Definition: Checklist.h:228
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
const FoundationSet & foundations() const
void add(const FoundationType &a_foundation)
Definition: AgentImpl.h:91

◆ unfreeze() [2/2]

void OpenDDS::ICE::Checklist::unfreeze ( const FoundationType a_foundation)

Definition at line 204 of file Checklist.cpp.

References OpenDDS::ICE::AgentImpl::add(), OpenDDS::ICE::EndpointManager::agent_impl, endpoint_manager_, OpenDDS::ICE::Task::enqueue(), OpenDDS::ICE::CandidatePair::foundation, frozen_, OpenDDS::ICE::CandidatePair::priority_sorted(), and waiting_.

205 {
206  bool flag = false;
207 
208  for (CandidatePairsType::iterator pos = frozen_.begin(), limit = frozen_.end(); pos != limit;) {
209  const CandidatePair& cp = *pos;
210 
211  if (cp.foundation == a_foundation) {
212  endpoint_manager_->agent_impl->add(cp.foundation);
213  waiting_.push_back(cp);
215  frozen_.erase(pos++);
216  flag = true;
217  } else {
218  ++pos;
219  }
220  }
221 
222  if (flag) {
223  enqueue(MonotonicTimePoint::now());
224  }
225 }
void enqueue(const DCPS::MonotonicTimePoint &release_time)
Definition: Task.cpp:19
CandidatePairsType waiting_
Definition: Checklist.h:229
CandidatePairsType frozen_
Definition: Checklist.h:228
static bool priority_sorted(const CandidatePair &x, const CandidatePair &y)
Definition: Checklist.h:90
EndpointManager *const endpoint_manager_
Definition: Checklist.h:219
void add(const FoundationType &a_foundation)
Definition: AgentImpl.h:91

Member Data Documentation

◆ check_interval_

DCPS::TimeDuration OpenDDS::ICE::Checklist::check_interval_
private

◆ connectivity_checks_

ConnectivityChecksType OpenDDS::ICE::Checklist::connectivity_checks_
private

◆ endpoint_manager_

EndpointManager* const OpenDDS::ICE::Checklist::endpoint_manager_
private

◆ failed_

CandidatePairsType OpenDDS::ICE::Checklist::failed_
private

Definition at line 232 of file Checklist.h.

Referenced by add_triggered_check(), failed(), and succeeded().

◆ frozen_

CandidatePairsType OpenDDS::ICE::Checklist::frozen_
private

◆ guids_

GuidSetType OpenDDS::ICE::Checklist::guids_
private

Definition at line 220 of file Checklist.h.

Referenced by add_guid(), execute(), remove_guid(), remove_guids(), and succeeded().

◆ ice_tie_breaker_

ACE_UINT64 const OpenDDS::ICE::Checklist::ice_tie_breaker_
private

Definition at line 225 of file Checklist.h.

Referenced by do_next_check().

◆ in_progress_

CandidatePairsType OpenDDS::ICE::Checklist::in_progress_
private

◆ last_indication_

DCPS::MonotonicTimePoint OpenDDS::ICE::Checklist::last_indication_
private

Definition at line 241 of file Checklist.h.

Referenced by execute(), indication(), and succeeded().

◆ local_agent_info_

AgentInfo OpenDDS::ICE::Checklist::local_agent_info_
private

◆ local_is_controlling_

bool const OpenDDS::ICE::Checklist::local_is_controlling_
private

◆ max_check_interval_

DCPS::TimeDuration OpenDDS::ICE::Checklist::max_check_interval_
private

Definition at line 243 of file Checklist.h.

Referenced by do_next_check(), and generate_candidate_pairs().

◆ nominated_

CandidatePairsType::const_iterator OpenDDS::ICE::Checklist::nominated_
private

Definition at line 239 of file Checklist.h.

Referenced by add_triggered_check(), execute(), selected_address(), and succeeded().

◆ nominated_is_live_

bool OpenDDS::ICE::Checklist::nominated_is_live_
private

Definition at line 240 of file Checklist.h.

Referenced by execute(), selected_address(), and succeeded().

◆ nominating_

CandidatePairsType::const_iterator OpenDDS::ICE::Checklist::nominating_
private

Definition at line 238 of file Checklist.h.

Referenced by add_triggered_check(), execute(), failed(), and succeeded().

◆ original_remote_agent_info_

AgentInfo OpenDDS::ICE::Checklist::original_remote_agent_info_
private

Definition at line 223 of file Checklist.h.

◆ remote_agent_info_

AgentInfo OpenDDS::ICE::Checklist::remote_agent_info_
private

◆ succeeded_

CandidatePairsType OpenDDS::ICE::Checklist::succeeded_
private

Definition at line 231 of file Checklist.h.

Referenced by add_triggered_check(), and succeeded().

◆ triggered_check_queue_

CandidatePairsType OpenDDS::ICE::Checklist::triggered_check_queue_
private

Definition at line 234 of file Checklist.h.

Referenced by add_triggered_check(), do_next_check(), execute(), and succeeded().

◆ valid_list_

CandidatePairsType OpenDDS::ICE::Checklist::valid_list_
private

◆ waiting_

CandidatePairsType OpenDDS::ICE::Checklist::waiting_
private

The documentation for this struct was generated from the following files: