UdpTransport.h

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #ifndef DCPS_UDPTRANSPORT_H
00009 #define DCPS_UDPTRANSPORT_H
00010 
00011 #include "Udp_Export.h"
00012 
00013 #include "UdpDataLink.h"
00014 #include "UdpDataLink_rch.h"
00015 
00016 #include "dds/DCPS/transport/framework/PriorityKey.h"
00017 #include "dds/DCPS/transport/framework/TransportImpl.h"
00018 #include "dds/DCPS/transport/framework/TransportClient.h"
00019 #include "dds/DCPS/PoolAllocator.h"
00020 
00021 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00022 
00023 namespace OpenDDS {
00024 namespace DCPS {
00025 
00026 class UdpInst;
00027 
00028 class OpenDDS_Udp_Export UdpTransport : public TransportImpl {
00029 public:
00030   explicit UdpTransport(UdpInst& inst);
00031 
00032   void passive_connection(const ACE_INET_Addr& remote_address,
00033                           const Message_Block_Ptr& data);
00034   UdpInst& config() const;
00035 protected:
00036   virtual AcceptConnectResult connect_datalink(const RemoteTransport& remote,
00037                                                const ConnectionAttribs& attribs,
00038                                                const TransportClient_rch& client);
00039 
00040   virtual AcceptConnectResult accept_datalink(const RemoteTransport& remote,
00041                                               const ConnectionAttribs& attribs,
00042                                               const TransportClient_rch& client);
00043 
00044   virtual void stop_accepting_or_connecting(const TransportClient_wrch& client,
00045                                             const RepoId& remote_id);
00046 
00047   bool configure_i(UdpInst& config);
00048 
00049   virtual void shutdown_i();
00050 
00051   virtual bool connection_info_i(TransportLocator& info) const;
00052   ACE_INET_Addr get_connection_addr(const TransportBLOB& data) const;
00053 
00054   virtual void release_datalink(DataLink* link);
00055 
00056   virtual std::string transport_type() const { return "udp"; }
00057 
00058 private:
00059   UdpDataLink_rch make_datalink(const ACE_INET_Addr& remote_address,
00060                              Priority priority, bool active);
00061 
00062   PriorityKey blob_to_key(const TransportBLOB& remote,
00063                           Priority priority, ACE_INET_Addr local_addr, bool active);
00064 
00065   typedef ACE_SYNCH_MUTEX         LockType;
00066   typedef ACE_Guard<LockType>     GuardType;
00067   typedef ACE_Condition<LockType> ConditionType;
00068 
00069   /// This lock is used to protect the client_links_ data member.
00070   LockType client_links_lock_;
00071 
00072   /// Map of fully associated DataLinks for this transport.  Protected
00073   // by client_links_lock_.
00074   typedef OPENDDS_MAP(PriorityKey, UdpDataLink_rch) UdpDataLinkMap;
00075   UdpDataLinkMap client_links_;
00076 
00077   /// The single datalink for the passive side.  No locking required.
00078   UdpDataLink_rch server_link_;
00079 
00080   /// This protects the pending_connections_, pending_server_link_keys_,
00081   /// and server_link_keys_ data members.
00082   //LockType connections_lock_;
00083   ACE_Recursive_Thread_Mutex connections_lock_;
00084 
00085   /// Locked by connections_lock_.
00086   /// These are passive-side PriorityKeys that have been fully associated
00087   /// (processed by accept_datalink() and finished handshaking).  They are
00088   /// ready for use and reuse via server_link_.
00089   std::set<PriorityKey> server_link_keys_;
00090 
00091   typedef std::vector<DataLink::OnStartCallback> Callbacks;
00092   typedef OPENDDS_MAP(PriorityKey, Callbacks) PendConnMap;
00093   /// Locked by connections_lock_.  Tracks expected connections
00094   /// that we have learned about in accept_datalink() but have
00095   /// not yet performed the handshake.
00096   PendConnMap pending_connections_;
00097 
00098   /// Locked by connections_lock_.
00099   /// These are passive-side PriorityKeys that have finished handshaking,
00100   /// but have not been processed by accept_datalink()
00101   std::set<PriorityKey> pending_server_link_keys_;
00102 };
00103 
00104 } // namespace DCPS
00105 } // namespace OpenDDS
00106 
00107 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00108 
00109 #endif  /* DCPS_UDPTRANSPORT_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1