diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/AV/Transport.h')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/AV/Transport.h | 430 |
1 files changed, 54 insertions, 376 deletions
diff --git a/TAO/orbsvcs/orbsvcs/AV/Transport.h b/TAO/orbsvcs/orbsvcs/AV/Transport.h index 82a5c6f674e..c46fa19e51b 100644 --- a/TAO/orbsvcs/orbsvcs/AV/Transport.h +++ b/TAO/orbsvcs/orbsvcs/AV/Transport.h @@ -28,8 +28,53 @@ #include "AV_Core.h" #include "FlowSpec_Entry.h" -// Transports +// Forward declarations. +class TAO_AV_Protocol_Object; +class TAO_AV_Callback; +class TAO_AV_Transport; + +class TAO_AV_Flow_Handler +{ +public: + TAO_AV_Flow_Handler (void); + // Constructor. + + virtual int start (TAO_FlowSpec_Entry::Role role); + virtual int stop (TAO_FlowSpec_Entry::Role role); + // Start/stop the flow handler. + + virtual int schedule_timer (void); + // Schedule timer. Uses the get_timeout method on the callback. + + TAO_AV_Transport *transport (void); + // get the transport. + + TAO_AV_Protocol_Object* protocol_object (void); + void protocol_object (TAO_AV_Protocol_Object *protocol_object); + // set/get protocol_object. + + void callback (TAO_AV_Callback *callback); + // set the callback. + + int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); + // Handle timeout. called from reactor. + + virtual int set_remote_address (ACE_Addr *address); + // set the remote address. + + virtual ACE_Event_Handler* event_handler (void) = 0; + // get the underlying event handler. To be overridden by the derived clases. + +protected: + TAO_AV_Transport *transport_; + TAO_AV_Callback *callback_; + TAO_AV_Protocol_Object *protocol_object_; + long timer_id_; + ACE_Reactor *reactor_; + void *timeout_arg_; +}; +// Transports class TAO_ORBSVCS_Export TAO_AV_Transport { // TITLE @@ -82,130 +127,10 @@ public: }; -class TAO_AV_TCP_Flow_Handler; - -class TAO_AV_TCP_Transport - :public TAO_AV_Transport -{ - // = TITLE - // A transport abstraction for socket streams. - // - // = DESCRIPTION - // Uses the ACE_SOCK_Stream to send the data. -public: - TAO_AV_TCP_Transport (void); - - TAO_AV_TCP_Transport (TAO_AV_TCP_Flow_Handler *handler); - - virtual ~TAO_AV_TCP_Transport (void); - - virtual int open (ACE_Addr *address); - - virtual int close (void); - - virtual int mtu (void); - - virtual ACE_Addr *get_peer_addr (void); - - virtual ssize_t send (const ACE_Message_Block *mblk, - ACE_Time_Value *s = 0); - // Write the complete Message_Block chain to the connection. - - virtual ssize_t send (const char *buf, - size_t len, - ACE_Time_Value *s = 0); - // Write the contents of the buffer of length len to the connection. - - virtual ssize_t send (const iovec *iov, - int iovcnt, - ACE_Time_Value *s = 0); - // Write the contents of iovcnt iovec's to the connection. - - virtual ssize_t recv (char *buf, - size_t len, - ACE_Time_Value *s = 0); - // Read len bytes from into buf. - - virtual ssize_t recv (char *buf, - size_t len, - int flags, - ACE_Time_Value *s = 0); - // Read len bytes from into buf using flags. - - virtual ssize_t recv (iovec *iov, - int iovcnt, - ACE_Time_Value *s = 0); - // Read received data into the iovec buffers. -protected: - TAO_AV_TCP_Flow_Handler *handler_; -}; - -class TAO_AV_UDP_Flow_Handler; - -class TAO_AV_UDP_Transport - :public TAO_AV_Transport -{ - // = TITLE - // A transport abstraction for udp sockets. - // - // = DESCRIPTION - // Uses the ACE_SOCK_Dgram to send the data. -public: - TAO_AV_UDP_Transport (void); - - TAO_AV_UDP_Transport (TAO_AV_UDP_Flow_Handler *handler); - - virtual ~TAO_AV_UDP_Transport (void); - virtual int open (ACE_Addr *addr); - - virtual int close (void); - - virtual int mtu (void); - - virtual ACE_Addr *get_peer_addr (void); - - virtual int set_remote_address (const ACE_INET_Addr &address); - - virtual ssize_t send (const ACE_Message_Block *mblk, - ACE_Time_Value *s = 0); - // Write the complete Message_Block chain to the connection. - - virtual ssize_t send (const char *buf, - size_t len, - ACE_Time_Value *s = 0); - // Write the contents of the buffer of length len to the connection. - - virtual ssize_t send (const iovec *iov, - int iovcnt, - ACE_Time_Value *s = 0); - // Write the contents of iovcnt iovec's to the connection. - - virtual ssize_t recv (char *buf, - size_t len, - ACE_Time_Value *s = 0); - // Read len bytes from into buf. - - virtual ssize_t recv (char *buf, - size_t len, - int flags, - ACE_Time_Value *s = 0); - // Read len bytes from into buf using flags. - - virtual ssize_t recv (iovec *iov, - int iovcnt, - ACE_Time_Value *s = 0); - // Read received data into the iovec buffers. -protected: - TAO_AV_UDP_Flow_Handler *handler_; - ACE_Addr *addr_; - ACE_INET_Addr peer_addr_; -}; - class TAO_Base_StreamEndPoint; class TAO_AV_Core; class TAO_FlowSpec_Entry; -// Acceptors class TAO_AV_Acceptor { public: @@ -213,10 +138,14 @@ public: virtual ~TAO_AV_Acceptor (void); virtual int open (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, - TAO_FlowSpec_Entry *entry) = 0; + TAO_FlowSpec_Entry *entry, + TAO_AV_Flow_Protocol_Factory *factory) = 0; + virtual int open_default (TAO_Base_StreamEndPoint *endpoint, TAO_AV_Core *av_core, - TAO_FlowSpec_Entry *entry) = 0; + TAO_FlowSpec_Entry *entry, + TAO_AV_Flow_Protocol_Factory *factory) = 0; + const char *flowname (); virtual int close (void) = 0; protected: @@ -225,101 +154,6 @@ protected: ACE_Addr *address_; }; -class TAO_AV_TCP_Acceptor; - -class TAO_AV_TCP_Base_Acceptor - :public ACE_Acceptor <TAO_AV_TCP_Flow_Handler,ACE_SOCK_ACCEPTOR> -{ -public: - virtual int open (TAO_AV_TCP_Acceptor *acceptor, - ACE_Reactor *reactor, - const ACE_INET_Addr &local_addr, - TAO_FlowSpec_Entry *entry); - virtual int make_svc_handler (TAO_AV_TCP_Flow_Handler *& handler); -protected: - TAO_AV_TCP_Acceptor *acceptor_; - ACE_Reactor *reactor_; - TAO_FlowSpec_Entry *entry_; -}; - -class TAO_AV_TCP_Acceptor - :public TAO_AV_Acceptor -{ -public: - TAO_AV_TCP_Acceptor (void); - virtual ~TAO_AV_TCP_Acceptor (void); - virtual int open (TAO_Base_StreamEndPoint *endpoint, - TAO_AV_Core *av_core, - TAO_FlowSpec_Entry *entry); - virtual int open_default (TAO_Base_StreamEndPoint *endpoint, - TAO_AV_Core *av_core, - TAO_FlowSpec_Entry *entry); - virtual int close (void); - virtual int make_svc_handler (TAO_AV_TCP_Flow_Handler *&handler); -protected: - TAO_AV_TCP_Base_Acceptor acceptor_; - TAO_FlowSpec_Entry *entry_; - TAO_Base_StreamEndPoint *endpoint_; -}; - -class TAO_AV_Flow_Handler; - -class TAO_AV_UDP_Acceptor; - -class TAO_ORBSVCS_Export TAO_AV_Dgram_Acceptor -{ -public: - virtual int open (TAO_AV_UDP_Acceptor *acceptor, - ACE_Reactor *reactor, - ACE_Addr &address, - TAO_AV_UDP_Flow_Handler *&handler); - virtual int make_svc_handler (TAO_AV_UDP_Flow_Handler *&handler); - virtual int activate_svc_handler (TAO_AV_UDP_Flow_Handler *handler); -protected: - ACE_Reactor *reactor_; - TAO_AV_UDP_Acceptor *acceptor_; -}; - -class TAO_AV_UDP_Connector; - -class TAO_ORBSVCS_Export TAO_AV_Dgram_Connector -{ -public: - virtual int open (TAO_AV_UDP_Connector *connector, - ACE_Reactor *reactor); - - virtual int connect (TAO_AV_UDP_Flow_Handler *&handler, - ACE_Addr &remote_addr, - ACE_Addr &local_addr); - virtual int make_svc_handler (TAO_AV_UDP_Flow_Handler *&handler); - virtual int activate_svc_handler (TAO_AV_UDP_Flow_Handler *handler); -protected: - ACE_Reactor *reactor_; - TAO_AV_UDP_Connector *connector_; -}; - -class TAO_AV_UDP_Acceptor - :public TAO_AV_Acceptor -{ -public: - TAO_AV_UDP_Acceptor (void); - virtual ~TAO_AV_UDP_Acceptor (void); - virtual int open (TAO_Base_StreamEndPoint *endpoint, - TAO_AV_Core *av_core, - TAO_FlowSpec_Entry *entry); - virtual int open_default (TAO_Base_StreamEndPoint *endpoint, - TAO_AV_Core *av_core, - TAO_FlowSpec_Entry *entry); - virtual int close (void); - virtual int make_svc_handler (TAO_AV_UDP_Flow_Handler *&handler); -protected: - TAO_AV_Dgram_Acceptor acceptor_; - TAO_Base_StreamEndPoint *endpoint_; - TAO_FlowSpec_Entry *entry_; - TAO_AV_UDP_Flow_Handler *handler_; -}; - -// Connectors class TAO_AV_Connector { public: @@ -328,7 +162,8 @@ public: const char *flowname (void); virtual int open (TAO_Base_StreamEndPoint *endpoint, - TAO_AV_Core *av_core) = 0; + TAO_AV_Core *av_core, + TAO_AV_Flow_Protocol_Factory *factory) = 0; virtual int connect (TAO_FlowSpec_Entry *entry, TAO_AV_Transport *&transport) = 0; @@ -338,163 +173,6 @@ protected: ACE_CString flowname_; }; -class TAO_AV_TCP_Connector; - -class TAO_AV_TCP_Base_Connector - :public ACE_Connector <TAO_AV_TCP_Flow_Handler,ACE_SOCK_CONNECTOR> -{ -public: - // To avoid warnings of open and connect hiding the base class functions these have to renamed. - int connector_open (TAO_AV_TCP_Connector *connector, - ACE_Reactor *reactor); - int connector_connect (TAO_AV_TCP_Flow_Handler *&handler, - const ACE_INET_Addr &remote_addr); - virtual int make_svc_handler (TAO_AV_TCP_Flow_Handler *& handler); -protected: - TAO_AV_TCP_Connector *connector_; - ACE_Reactor *reactor_; -}; - -class TAO_AV_TCP_Connector - :public TAO_AV_Connector -{ -public: - TAO_AV_TCP_Connector (void); - virtual ~TAO_AV_TCP_Connector (void); - - virtual int open (TAO_Base_StreamEndPoint *endpoint, - TAO_AV_Core *av_core); - - virtual int connect (TAO_FlowSpec_Entry *entry, - TAO_AV_Transport *&transport); - virtual int close (void); - virtual int make_svc_handler (TAO_AV_TCP_Flow_Handler *&handler); -protected: - TAO_AV_Core *av_core_; - TAO_AV_TCP_Base_Connector connector_; - TAO_Base_StreamEndPoint *endpoint_; - TAO_FlowSpec_Entry *entry_; -}; - -class TAO_AV_UDP_Connector - :public TAO_AV_Connector -{ -public: - TAO_AV_UDP_Connector (void); - ~TAO_AV_UDP_Connector (void); - virtual int open (TAO_Base_StreamEndPoint *endpoint, - TAO_AV_Core *av_core); - - virtual int connect (TAO_FlowSpec_Entry *entry, - TAO_AV_Transport *&transport); - virtual int close (void); - virtual int make_svc_handler (TAO_AV_UDP_Flow_Handler *&handler); -protected: - TAO_AV_Dgram_Connector connector_; - TAO_Base_StreamEndPoint *endpoint_; - TAO_AV_Core *av_core_; - TAO_FlowSpec_Entry *entry_; - TAO_AV_UDP_Flow_Handler *handler_; -}; - -// Protocol Factories -class TAO_ORBSVCS_Export TAO_AV_Protocol_Factory -// @@ Derive from Svc config. -{ -public: - TAO_AV_Protocol_Factory (void); - virtual ~TAO_AV_Protocol_Factory (void); - - virtual int match_protocol (TAO_AV_Core::Protocol protocol) = 0; - virtual TAO_AV_Acceptor *make_acceptor (void) = 0; - virtual TAO_AV_Connector *make_connector (void) = 0; -}; - -class TAO_AV_TCP_Protocol_Factory - :public TAO_AV_Protocol_Factory -{ -public: - TAO_AV_TCP_Protocol_Factory (void); - virtual ~TAO_AV_TCP_Protocol_Factory (void); - virtual int match_protocol (TAO_AV_Core::Protocol protocol); - virtual TAO_AV_Acceptor *make_acceptor (void); - virtual TAO_AV_Connector *make_connector (void); - -}; - -class TAO_AV_UDP_Protocol_Factory - :public TAO_AV_Protocol_Factory -{ -public: - TAO_AV_UDP_Protocol_Factory (void); - virtual ~TAO_AV_UDP_Protocol_Factory (void); - virtual int match_protocol (TAO_AV_Core::Protocol protocol); - virtual TAO_AV_Acceptor *make_acceptor (void); - virtual TAO_AV_Connector *make_connector (void); -}; - -// Forward declarations. -class TAO_AV_Protocol_Object; -class TAO_AV_Callback; - -class TAO_AV_Flow_Handler -{ -public: - TAO_AV_Flow_Handler (TAO_AV_Callback *callback); - virtual int start (TAO_FlowSpec_Entry::Role role); - virtual int stop (TAO_FlowSpec_Entry::Role role); - TAO_AV_Transport *transport (void); - TAO_AV_Protocol_Object* protocol_object (void); - void protocol_object (TAO_AV_Protocol_Object *protocol_object); - int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); - virtual int set_remote_address (ACE_Addr *address); - virtual ACE_Event_Handler* event_handler (void) = 0; -protected: - TAO_AV_Transport *transport_; - TAO_AV_Callback *callback_; - TAO_AV_Protocol_Object *protocol_object_; - long timer_id_; - ACE_Reactor *reactor_; - void *timeout_arg_; -}; - -class TAO_AV_TCP_Flow_Handler - :public virtual TAO_AV_Flow_Handler, - public ACE_Svc_Handler <ACE_SOCK_STREAM, ACE_NULL_SYNCH> -{ -public: - TAO_AV_TCP_Flow_Handler (TAO_AV_Callback *callback = 0); - virtual TAO_AV_Transport *transport (void); - virtual int open (void * = 0); - virtual int handle_input (ACE_HANDLE fd); - virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); - virtual ACE_Event_Handler* event_handler (void){ return this; } -protected: - TAO_AV_Core *av_core_; -}; - -class TAO_AV_UDP_Flow_Handler - :public virtual TAO_AV_Flow_Handler, - public virtual ACE_Event_Handler -{ -public: - TAO_AV_UDP_Flow_Handler (TAO_AV_Callback *callback); - //Ctor - ~TAO_AV_UDP_Flow_Handler (void); - // Dtor - int open (ACE_Addr &address); - virtual TAO_AV_Transport *transport (void); - virtual int set_remote_address (ACE_Addr *address); - virtual ACE_HANDLE get_handle (void) const; - virtual int handle_input (ACE_HANDLE fd); - virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0); - const ACE_SOCK_Dgram *get_socket (void) const; - virtual ACE_Event_Handler* event_handler (void){ return this; } -protected: - TAO_AV_Core *av_core_; - ACE_INET_Addr peer_addr_; - ACE_SOCK_Dgram sock_dgram_; -}; typedef ACE_Unbounded_Set<TAO_AV_Connector*> TAO_AV_ConnectorSet; typedef ACE_Unbounded_Set_Iterator<TAO_AV_Connector*> TAO_AV_ConnectorSetItor; |