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/PoolAllocator.h"
00019 
00020 namespace OpenDDS {
00021 namespace DCPS {
00022 
00023 class UdpInst;
00024 
00025 class OpenDDS_Udp_Export UdpTransport : public TransportImpl {
00026 public:
00027   explicit UdpTransport(const TransportInst_rch& inst);
00028 
00029   void passive_connection(const ACE_INET_Addr& remote_address,
00030                           ACE_Message_Block* data);
00031 
00032 protected:
00033   virtual AcceptConnectResult connect_datalink(const RemoteTransport& remote,
00034                                                const ConnectionAttribs& attribs,
00035                                                TransportClient* client);
00036 
00037   virtual AcceptConnectResult accept_datalink(const RemoteTransport& remote,
00038                                               const ConnectionAttribs& attribs,
00039                                               TransportClient* client);
00040 
00041   virtual void stop_accepting_or_connecting(TransportClient* client,
00042                                             const RepoId& remote_id);
00043 
00044   virtual bool configure_i(TransportInst* config);
00045 
00046   virtual void shutdown_i();
00047 
00048   virtual bool connection_info_i(TransportLocator& info) const;
00049   ACE_INET_Addr get_connection_addr(const TransportBLOB& data) const;
00050 
00051   virtual void release_datalink(DataLink* link);
00052 
00053   virtual std::string transport_type() const { return "udp"; }
00054 
00055 private:
00056   UdpDataLink* make_datalink(const ACE_INET_Addr& remote_address,
00057                              Priority priority, bool active);
00058 
00059   PriorityKey blob_to_key(const TransportBLOB& remote,
00060                           Priority priority, ACE_INET_Addr local_addr, bool active);
00061 
00062   RcHandle<UdpInst> config_i_;
00063 
00064   typedef ACE_SYNCH_MUTEX         LockType;
00065   typedef ACE_Guard<LockType>     GuardType;
00066   typedef ACE_Condition<LockType> ConditionType;
00067 
00068   /// This lock is used to protect the client_links_ data member.
00069   LockType client_links_lock_;
00070 
00071   /// Map of fully associated DataLinks for this transport.  Protected
00072   // by client_links_lock_.
00073   typedef OPENDDS_MAP(PriorityKey, UdpDataLink_rch) UdpDataLinkMap;
00074   UdpDataLinkMap client_links_;
00075 
00076   /// The single datalink for the passive side.  No locking required.
00077   UdpDataLink_rch server_link_;
00078 
00079   /// This protects the pending_connections_, pending_server_link_keys_,
00080   /// and server_link_keys_ data members.
00081   //LockType connections_lock_;
00082   ACE_Recursive_Thread_Mutex connections_lock_;
00083 
00084   /// Locked by connections_lock_.
00085   /// These are passive-side PriorityKeys that have been fully associated
00086   /// (processed by accept_datalink() and finished handshaking).  They are
00087   /// ready for use and reuse via server_link_.
00088   std::set<PriorityKey> server_link_keys_;
00089 
00090   typedef std::vector<DataLink::OnStartCallback> Callbacks;
00091   typedef OPENDDS_MAP(PriorityKey, Callbacks) PendConnMap;
00092   /// Locked by connections_lock_.  Tracks expected connections
00093   /// that we have learned about in accept_datalink() but have
00094   /// not yet performed the handshake.
00095   PendConnMap pending_connections_;
00096 
00097   /// Locked by connections_lock_.
00098   /// These are passive-side PriorityKeys that have finished handshaking,
00099   /// but have not been processed by accept_datalink()
00100   std::set<PriorityKey> pending_server_link_keys_;
00101 };
00102 
00103 } // namespace DCPS
00104 } // namespace OpenDDS
00105 
00106 #endif  /* DCPS_UDPTRANSPORT_H */

Generated on Fri Feb 12 20:05:29 2016 for OpenDDS by  doxygen 1.4.7