OpenDDS  Snapshot(2023/04/28-20:55)
UdpTransport.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 #ifndef OPENDDS_DCPS_TRANSPORT_UDP_UDPTRANSPORT_H
9 #define OPENDDS_DCPS_TRANSPORT_UDP_UDPTRANSPORT_H
10 
11 #include "Udp_Export.h"
12 #include "UdpDataLink_rch.h"
13 #include "UdpDataLink.h"
14 
15 #include <dds/DCPS/PoolAllocator.h>
17 #include <dds/DCPS/TimeTypes.h>
21 
23 
24 namespace OpenDDS {
25 namespace DCPS {
26 
27 class UdpInst;
28 
30 public:
31  explicit UdpTransport(const UdpInst_rch& inst);
32 
33  void passive_connection(const ACE_INET_Addr& remote_address,
34  const ReceivedDataSample& data);
35  UdpInst_rch config() const;
36 protected:
37  virtual AcceptConnectResult connect_datalink(const RemoteTransport& remote,
38  const ConnectionAttribs& attribs,
39  const TransportClient_rch& client);
40 
41  virtual AcceptConnectResult accept_datalink(const RemoteTransport& remote,
42  const ConnectionAttribs& attribs,
43  const TransportClient_rch& client);
44 
45  virtual void stop_accepting_or_connecting(const TransportClient_wrch& client,
46  const GUID_t& remote_id,
47  bool disassociate,
48  bool association_failed);
49 
50  bool configure_i(const UdpInst_rch& config);
51 
52  virtual void shutdown_i();
53 
54  virtual bool connection_info_i(TransportLocator& info, ConnectionInfoFlags flags) const;
55  ACE_INET_Addr get_connection_addr(const TransportBLOB& data) const;
56 
57  virtual void release_datalink(DataLink* link);
58 
59  virtual std::string transport_type() const { return "udp"; }
60 
61 private:
62  UdpDataLink_rch make_datalink(const ACE_INET_Addr& remote_address,
63  Priority priority, bool active);
64 
65  PriorityKey blob_to_key(const TransportBLOB& remote,
66  Priority priority, ACE_INET_Addr local_addr, bool active);
67 
71 
72  /// This lock is used to protect the client_links_ data member.
74 
75  /// Map of fully associated DataLinks for this transport. Protected
76  // by client_links_lock_.
77  typedef OPENDDS_MAP(PriorityKey, UdpDataLink_rch) UdpDataLinkMap;
78  UdpDataLinkMap client_links_;
79 
80  /// The single datalink for the passive side. No locking required.
82 
83  /// This protects the pending_connections_, pending_server_link_keys_,
84  /// and server_link_keys_ data members.
85  //LockType connections_lock_;
87 
88  /// Locked by connections_lock_.
89  /// These are passive-side PriorityKeys that have been fully associated
90  /// (processed by accept_datalink() and finished handshaking). They are
91  /// ready for use and reuse via server_link_.
92  std::set<PriorityKey> server_link_keys_;
93 
94  typedef std::vector<DataLink::OnStartCallback> Callbacks;
95  typedef OPENDDS_MAP(PriorityKey, Callbacks) PendConnMap;
96  /// Locked by connections_lock_. Tracks expected connections
97  /// that we have learned about in accept_datalink() but have
98  /// not yet performed the handshake.
99  PendConnMap pending_connections_;
100 
101  /// Locked by connections_lock_.
102  /// These are passive-side PriorityKeys that have finished handshaking,
103  /// but have not been processed by accept_datalink()
104  std::set<PriorityKey> pending_server_link_keys_;
105 };
106 
107 } // namespace DCPS
108 } // namespace OpenDDS
109 
111 
112 #endif /* DCPS_UDPTRANSPORT_H */
#define ACE_SYNCH_MUTEX
ACE_Guard< LockType > GuardType
Definition: UdpTransport.h:69
Encapsulate a priority value and internet address as a key.
Definition: PriorityKey.h:52
ConditionVariable< LockType > ConditionVariableType
Definition: UdpTransport.h:70
std::vector< DataLink::OnStartCallback > Callbacks
Definition: UdpTransport.h:94
Holds a data sample received by the transport.
std::set< PriorityKey > pending_server_link_keys_
Definition: UdpTransport.h:104
virtual std::string transport_type() const
Definition: UdpTransport.h:59
UdpDataLink_rch server_link_
The single datalink for the passive side. No locking required.
Definition: UdpTransport.h:81
PendConnMap pending_connections_
Definition: UdpTransport.h:99
ACE_Recursive_Thread_Mutex connections_lock_
Definition: UdpTransport.h:86
std::set< PriorityKey > server_link_keys_
Definition: UdpTransport.h:92
ACE_SYNCH_MUTEX LockType
Definition: UdpTransport.h:68
ACE_CDR::Long Priority
LockType client_links_lock_
This lock is used to protect the client_links_ data member.
Definition: UdpTransport.h:73
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
UdpDataLinkMap client_links_
Definition: UdpTransport.h:78
#define OpenDDS_Udp_Export
Definition: Udp_Export.h:24
DDS::OctetSeq TransportBLOB
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
typedef OPENDDS_MAP(OPENDDS_STRING, OPENDDS_STRING) ValueMap
Helper types and functions for config file parsing.
size_t ConnectionInfoFlags