OpenDDS  Snapshot(2023/04/28-20:55)
AgentImpl.h
Go to the documentation of this file.
1 /*
2  *
3  *
4  * Distributed under the OpenDDS License.
5  * See: http://www.opendds.org/license.html
6  */
7 
8 #ifdef OPENDDS_SECURITY
9 #ifndef OPENDDS_DCPS_RTPS_ICE_AGENTIMPL_H
10 #define OPENDDS_DCPS_RTPS_ICE_AGENTIMPL_H
11 
12 #if !defined (ACE_LACKS_PRAGMA_ONCE)
13 #pragma once
14 #endif /* ACE_LACKS_PRAGMA_ONCE */
15 
16 #include "EndpointManager.h"
17 #include "Ice.h"
18 #include "Task.h"
19 
20 #include "dds/DCPS/Definitions.h"
25 
26 #include <ace/Time_Value.h>
27 
29 
30 namespace OpenDDS {
31 namespace ICE {
32 
33 typedef std::vector<FoundationType> FoundationList;
34 
35 class AgentImpl
36  : public virtual Agent
37  , public virtual DCPS::ShutdownListener
38  , public virtual DCPS::InternalDataReaderListener<DCPS::NetworkInterfaceAddress>
40 {
41 public:
42  AgentImpl();
43 
44  void shutdown();
45 
46  void notify_shutdown();
47 
49 
51 
53 
55  const DCPS::GUID_t& a_local_guid,
56  DCPS::WeakRcHandle<AgentInfoListener> a_agent_info_listener);
57 
59  const DCPS::GUID_t& a_local_guid);
60 
62  const DCPS::GUID_t& a_local_guid,
63  const DCPS::GUID_t& a_remote_guid,
64  const AgentInfo& a_remote_agent_info);
65 
66  void stop_ice(DCPS::WeakRcHandle<Endpoint> a_endpoint,
67  const DCPS::GUID_t& a_local_guid,
68  const DCPS::GUID_t& a_remote_guid);
69 
71  const DCPS::GUID_t& a_local_guid,
72  const DCPS::GUID_t& a_remote_guid) const;
73 
74  void receive(DCPS::WeakRcHandle<Endpoint> a_endpoint,
75  const ACE_INET_Addr& a_local_address,
76  const ACE_INET_Addr& a_remote_address,
77  const STUN::Message& a_message);
78 
79  void enqueue(const DCPS::MonotonicTimePoint& a_release_time, WeakTaskPtr a_task);
80 
82  {
84  }
85 
86  bool contains(const FoundationType& a_foundation) const
87  {
88  return active_foundations_.contains(a_foundation);
89  }
90 
91  void add(const FoundationType& a_foundation)
92  {
93  active_foundations_.add(a_foundation);
94  }
95 
96  void remove(const FoundationType& a_foundation);
97 
98  void unfreeze(const FoundationType& a_foundation);
99 
101 
102 private:
104  void process_deferred();
105 
107  FoundationList to_unfreeze_;
108  bool unfreeze_;
112  typedef std::map<DCPS::WeakRcHandle<Endpoint>, EndpointManagerPtr> EndpointManagerMapType;
113  EndpointManagerMapType endpoint_managers_;
114  struct Item {
117  Item(const DCPS::MonotonicTimePoint& release_time,
118  WeakTaskPtr task)
119  : release_time_(release_time)
120  , task_(task)
121  {}
122  bool operator<(const Item& other) const
123  {
124  return release_time_ > other.release_time_;
125  }
126  };
127  std::priority_queue<Item> tasks_;
129 
130  bool reactor_is_shut_down() const;
131  int handle_timeout(const ACE_Time_Value& a_now, const void* /*act*/);
132 
133  void check_invariants() const;
134 };
135 
136 } // namespace ICE
137 } // namespace OpenDDS
138 
140 
141 #endif /* OPENDDS_RTPS_ICE_AGENT_IMPL_H */
142 #endif /* OPENDDS_SECURITY */
void remove_endpoint(DCPS::WeakRcHandle< Endpoint > a_endpoint)
Definition: AgentImpl.cpp:120
void add_local_agent_info_listener(DCPS::WeakRcHandle< Endpoint > a_endpoint, const DCPS::GUID_t &a_local_guid, DCPS::WeakRcHandle< AgentInfoListener > a_agent_info_listener)
Definition: AgentImpl.cpp:149
DCPS::MonotonicTimePoint release_time_
Definition: AgentImpl.h:115
ActiveFoundationSet active_foundations_
Definition: AgentImpl.h:106
AgentInfo get_local_agent_info(DCPS::WeakRcHandle< Endpoint > a_endpoint) const
Definition: AgentImpl.cpp:141
bool contains(const FoundationType &a_foundation) const
Definition: AgentImpl.h:86
void unfreeze(const FoundationType &a_foundation)
Definition: AgentImpl.cpp:234
std::pair< std::string, std::string > FoundationType
Definition: Checklist.h:34
FoundationList to_unfreeze_
Definition: AgentImpl.h:107
void on_data_available(DCPS::RcHandle< DCPS::InternalDataReader< DCPS::NetworkInterfaceAddress > > reader)
Definition: AgentImpl.cpp:262
ACE_INET_Addr get_address(DCPS::WeakRcHandle< Endpoint > a_endpoint, const DCPS::GUID_t &a_local_guid, const DCPS::GUID_t &a_remote_guid) const
Definition: AgentImpl.cpp:193
void add(const FoundationType &a_foundation)
Definition: Checklist.h:38
size_t remote_peer_reflexive_counter_
Definition: AgentImpl.h:111
void add_endpoint(DCPS::WeakRcHandle< Endpoint > a_endpoint)
Definition: AgentImpl.cpp:102
void stop_ice(DCPS::WeakRcHandle< Endpoint > a_endpoint, const DCPS::GUID_t &a_local_guid, const DCPS::GUID_t &a_remote_guid)
Definition: AgentImpl.cpp:181
bool contains(const FoundationType &a_foundation) const
Definition: Checklist.h:58
Item(const DCPS::MonotonicTimePoint &release_time, WeakTaskPtr task)
Definition: AgentImpl.h:117
void remove_local_agent_info_listener(DCPS::WeakRcHandle< Endpoint > a_endpoint, const DCPS::GUID_t &a_local_guid)
Definition: AgentImpl.cpp:159
std::priority_queue< Item > tasks_
Definition: AgentImpl.h:127
std::vector< FoundationType > FoundationList
Definition: AgentImpl.h:33
EndpointManagerMapType endpoint_managers_
Definition: AgentImpl.h:113
std::map< DCPS::WeakRcHandle< Endpoint >, EndpointManagerPtr > EndpointManagerMapType
Definition: AgentImpl.h:112
bool reactor_is_shut_down() const
Definition: AgentImpl.cpp:52
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
bool operator<(const Item &other) const
Definition: AgentImpl.h:122
void receive(DCPS::WeakRcHandle< Endpoint > a_endpoint, const ACE_INET_Addr &a_local_address, const ACE_INET_Addr &a_remote_address, const STUN::Message &a_message)
Definition: AgentImpl.cpp:204
ACE_Recursive_Thread_Mutex mutex
Definition: AgentImpl.h:100
DCPS::MonotonicTimePoint last_execute_
Definition: AgentImpl.h:128
void enqueue(const DCPS::MonotonicTimePoint &a_release_time, WeakTaskPtr a_task)
Definition: AgentImpl.cpp:42
void check_invariants() const
Definition: AgentImpl.cpp:239
void start_ice(DCPS::WeakRcHandle< Endpoint > a_endpoint, const DCPS::GUID_t &a_local_guid, const DCPS::GUID_t &a_remote_guid, const AgentInfo &a_remote_agent_info)
Definition: AgentImpl.cpp:168
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
void add(const FoundationType &a_foundation)
Definition: AgentImpl.h:91
DCPS::RcHandle< DCPS::InternalDataReader< DCPS::NetworkInterfaceAddress > > reader_
Definition: AgentImpl.h:109
int handle_timeout(const ACE_Time_Value &a_now, const void *)
Definition: AgentImpl.cpp:57
size_t remote_peer_reflexive_counter()
Definition: AgentImpl.h:81