SCTP_SEQ.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   SCTP_SEQ.h
00006  *
00007  *  SCTP_SEQ.h,v 1.7 2006/03/14 06:14:24 jtc Exp
00008  *
00009  *  @author Yamuna Krishnamurthy <yamuna@oomworks.com>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef TAO_AV_SCTP_SEQ_H
00014 #define TAO_AV_SCTP_SEQ_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/config-all.h"
00018 
00019 #if defined (ACE_HAS_SCTP)
00020 
00021 #include "ace/Auto_Ptr.h"
00022 #include "ace/Service_Config.h"
00023 #include "orbsvcs/AV/Protocol_Factory.h"
00024 #include "ace/SOCK_SEQPACK_Association.h"
00025 #include "ace/SOCK_SEQPACK_Acceptor.h"
00026 #include "ace/SOCK_SEQPACK_Connector.h"
00027 
00028 extern "C" {
00029 #include <netinet/sctp.h>
00030 };
00031 
00032 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00033 
00034 typedef ACE_Unbounded_Set <ACE_CString> Interface_Seq;
00035 typedef ACE_Unbounded_Set_Iterator <ACE_CString> Interface_Seq_Itor;
00036 
00037 //typedef auto_ptr <Interface_Seq> Interface_Seq_Ptr;
00038 typedef ACE_Hash_Map_Manager <ACE_CString,Interface_Seq,ACE_Null_Mutex>  Secondary_Addr_Map;
00039 typedef ACE_Hash_Map_Entry <ACE_CString,Interface_Seq> Secondary_Addr_Map_Entry;
00040 typedef ACE_Hash_Map_Iterator <ACE_CString,Interface_Seq,ACE_Null_Mutex>  Secondary_Addr_Map_Iterator;
00041 
00042 /**
00043  * @class TAO_AV_SCTP_SEQ_Factory
00044  */
00045 class TAO_AV_Export TAO_AV_SCTP_SEQ_Factory : public TAO_AV_Transport_Factory
00046 {
00047 public:
00048   /// Initialization hook.
00049   TAO_AV_SCTP_SEQ_Factory (void);
00050   virtual ~TAO_AV_SCTP_SEQ_Factory (void);
00051   virtual int init (int argc, char *argv[]);
00052   virtual int match_protocol (const char *protocol_string);
00053   virtual TAO_AV_Acceptor *make_acceptor (void);
00054   virtual TAO_AV_Connector *make_connector (void);
00055 };
00056 
00057 class TAO_AV_SCTP_SEQ_Flow_Handler;
00058 
00059 /**
00060  * @class TAO_AV_SCTP_SEQ_Transport
00061  * @brief A transport abstraction for udp sockets.
00062  *        Uses the ACE_SOCK_Dgram to send the data.
00063  */
00064 class TAO_AV_Export TAO_AV_SCTP_SEQ_Transport
00065   :public TAO_AV_Transport
00066 {
00067 public:
00068   TAO_AV_SCTP_SEQ_Transport (void);
00069 
00070   TAO_AV_SCTP_SEQ_Transport (TAO_AV_SCTP_SEQ_Flow_Handler *handler);
00071 
00072   virtual  ~TAO_AV_SCTP_SEQ_Transport (void);
00073   virtual int open (ACE_Addr *addr);
00074 
00075   virtual int close (void);
00076 
00077   virtual int mtu (void);
00078 
00079   virtual ACE_Addr *get_peer_addr (void);
00080 
00081   /// Write the complete Message_Block chain to the connection.
00082   virtual ssize_t send (const ACE_Message_Block *mblk,
00083                         ACE_Time_Value *s = 0);
00084 
00085   /// Write the contents of the buffer of length len to the connection.
00086   virtual ssize_t send (const char *buf,
00087                         size_t len,
00088                         ACE_Time_Value *s = 0);
00089 
00090   /// Write the contents of iovcnt iovec's to the connection.
00091   virtual ssize_t send (const iovec *iov,
00092                         int iovcnt,
00093                         ACE_Time_Value *s = 0);
00094 
00095   /// Read len bytes from into buf.
00096   virtual ssize_t recv (char *buf,
00097                         size_t len,
00098                         ACE_Time_Value *s = 0);
00099 
00100   /// Read len bytes from into buf using flags.
00101   virtual ssize_t recv (char *buf,
00102                         size_t len,
00103                         int flags,
00104                         ACE_Time_Value *s = 0);
00105 
00106   ///  Read received data into the iovec buffers.
00107   virtual ssize_t recv (iovec *iov,
00108                         int iovcnt,
00109                         ACE_Time_Value *s = 0);
00110 
00111   TAO_AV_SCTP_SEQ_Flow_Handler *handler (void) { return this->handler_; }
00112 
00113 protected:
00114   TAO_AV_SCTP_SEQ_Flow_Handler *handler_;
00115   ACE_Addr *addr_;
00116   ACE_INET_Addr peer_addr_;
00117 };
00118 
00119 /**
00120  * @class TAO_AV_SCTP_SEQ_Flow_Handler
00121  */
00122 class TAO_AV_SCTP_SEQ_Flow_Handler
00123   :public virtual TAO_AV_Flow_Handler,
00124    public ACE_Svc_Handler <ACE_SOCK_SEQPACK_ASSOCIATION, ACE_NULL_SYNCH>
00125 {
00126 public:
00127   TAO_AV_SCTP_SEQ_Flow_Handler (TAO_AV_Callback *callback = 0);
00128   virtual ~TAO_AV_SCTP_SEQ_Flow_Handler (void);
00129   virtual TAO_AV_Transport *transport (void);
00130   virtual int open (void * = 0);
00131   virtual int handle_input (ACE_HANDLE fd);
00132   virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0);
00133   virtual ACE_Event_Handler* event_handler (void){ return this; }
00134   /// Change the QoS
00135   virtual int change_qos (AVStreams::QoS);
00136 
00137 protected:
00138   TAO_AV_Core *av_core_;
00139 };
00140 
00141 class TAO_AV_SCTP_SEQ_Acceptor;
00142 
00143 /**
00144  * @class TAO_AV_SCTP_SEQ_Base_Acceptor
00145  */
00146 class TAO_AV_SCTP_SEQ_Base_Acceptor  :public ACE_Acceptor <TAO_AV_SCTP_SEQ_Flow_Handler,ACE_SOCK_SEQPACK_ACCEPTOR>
00147 {
00148  public:
00149   virtual int acceptor_open (TAO_AV_SCTP_SEQ_Acceptor *acceptor,
00150                              ACE_Reactor *reactor,
00151                              const ACE_INET_Addr &local_addr,
00152                              TAO_FlowSpec_Entry *entry);
00153   virtual int make_svc_handler (TAO_AV_SCTP_SEQ_Flow_Handler *& handler);
00154  protected:
00155   TAO_AV_SCTP_SEQ_Acceptor *acceptor_;
00156   ACE_Reactor *reactor_;
00157   TAO_FlowSpec_Entry *entry_;
00158 };
00159 
00160 /**
00161  * @class TAO_AV_SCTP_SEQ_Acceptor
00162  * @brief
00163  */
00164 class TAO_AV_Export TAO_AV_SCTP_SEQ_Acceptor
00165    :public TAO_AV_Acceptor
00166 {
00167 public:
00168   TAO_AV_SCTP_SEQ_Acceptor (void);
00169   virtual ~TAO_AV_SCTP_SEQ_Acceptor (void);
00170   virtual int open (TAO_Base_StreamEndPoint *endpoint,
00171                     TAO_AV_Core *av_core,
00172                     TAO_FlowSpec_Entry *entry,
00173                     TAO_AV_Flow_Protocol_Factory *factory,
00174                     TAO_AV_Core::Flow_Component flow_comp =
00175                     TAO_AV_Core::TAO_AV_DATA);
00176 
00177   virtual int open_default (TAO_Base_StreamEndPoint *endpoint,
00178                             TAO_AV_Core *av_core,
00179                             TAO_FlowSpec_Entry *entry,
00180                             TAO_AV_Flow_Protocol_Factory *factory,
00181                             TAO_AV_Core::Flow_Component flow_comp =
00182                             TAO_AV_Core::TAO_AV_DATA);
00183 
00184   virtual int close (void);
00185   virtual int make_svc_handler (TAO_AV_SCTP_SEQ_Flow_Handler *&handler);
00186 
00187 protected:
00188   ACE_INET_Addr *address_;
00189   TAO_AV_SCTP_SEQ_Base_Acceptor acceptor_;
00190   TAO_Base_StreamEndPoint *endpoint_;
00191   TAO_FlowSpec_Entry *entry_;
00192   TAO_AV_Flow_Protocol_Factory *flow_protocol_factory_;
00193 };
00194 
00195 class TAO_AV_SCTP_SEQ_Connector;
00196 
00197 /**
00198  * @class TAO_AV_Base_Connector
00199  */
00200 class TAO_AV_SCTP_SEQ_Base_Connector  : public ACE_Connector <TAO_AV_SCTP_SEQ_Flow_Handler,ACE_SOCK_SEQPACK_CONNECTOR>
00201 {
00202 public:
00203   // To avoid warnings of open and connect hiding the base class functions these have to renamed.
00204   int connector_open (TAO_AV_SCTP_SEQ_Connector *connector,
00205                       ACE_Reactor *reactor);
00206   int connector_connect (TAO_AV_SCTP_SEQ_Flow_Handler *&handler,
00207                          const ACE_Multihomed_INET_Addr &remote_addr,
00208                          const ACE_Multihomed_INET_Addr &local_addr);
00209   virtual int make_svc_handler (TAO_AV_SCTP_SEQ_Flow_Handler *& handler);
00210 protected:
00211   TAO_AV_SCTP_SEQ_Connector *connector_;
00212   ACE_Reactor *reactor_;
00213 };
00214 
00215 /**
00216  * @class TAO_AV_SCTP_SEQ_Connector
00217  * @brief
00218  */
00219 class TAO_AV_SCTP_SEQ_Connector  : public TAO_AV_Connector
00220 {
00221 public:
00222   TAO_AV_SCTP_SEQ_Connector (void);
00223   virtual ~TAO_AV_SCTP_SEQ_Connector (void);
00224 
00225   virtual int open (TAO_Base_StreamEndPoint *endpoint,
00226                     TAO_AV_Core *av_core,
00227                     TAO_AV_Flow_Protocol_Factory *factory);
00228 
00229   virtual int connect (TAO_FlowSpec_Entry *entry,
00230                        TAO_AV_Transport *&transport,
00231                        TAO_AV_Core::Flow_Component flow_comp =
00232                        TAO_AV_Core::TAO_AV_DATA);
00233   virtual int close (void);
00234   virtual int make_svc_handler (TAO_AV_SCTP_SEQ_Flow_Handler *&handler);
00235 protected:
00236   TAO_AV_Core *av_core_;
00237   TAO_AV_SCTP_SEQ_Base_Connector connector_;
00238   TAO_Base_StreamEndPoint *endpoint_;
00239   TAO_FlowSpec_Entry *entry_;
00240   TAO_AV_Flow_Protocol_Factory *flow_protocol_factory_;
00241 };
00242 
00243 /**
00244  * @class TAO_AV_SCTP_SEQ_Object
00245  * @brief TAO_AV_Protocol_Object for the User Datagram Protocol (SCTP_SEQ)
00246  */
00247 class TAO_AV_Export TAO_AV_SCTP_SEQ_Object  : public TAO_AV_Protocol_Object
00248 {
00249 public:
00250   TAO_AV_SCTP_SEQ_Object (TAO_AV_Callback *callback,
00251                      TAO_AV_Transport *transport = 0);
00252 
00253   /// Dtor
00254   virtual ~TAO_AV_SCTP_SEQ_Object (void);
00255 
00256   virtual int handle_input (void);
00257 
00258   /// send a data frame.
00259   virtual int send_frame (ACE_Message_Block *frame,
00260                           TAO_AV_frame_info *frame_info = 0);
00261 
00262   virtual int send_frame (const iovec *iov,
00263                           int iovcnt,
00264                           TAO_AV_frame_info *frame_info = 0);
00265 
00266   virtual int send_frame (const char*buf,
00267                           size_t len);
00268 
00269   /// end the stream.
00270   virtual int destroy (void);
00271 
00272 private:
00273   /// Pre-allocated memory to receive the data...
00274   ACE_Message_Block frame_;
00275 };
00276 
00277 /**
00278  * @class TAO_AV_SCTP_SEQ_Flow_Factory
00279  * @brief
00280  */
00281 class TAO_AV_Export TAO_AV_SCTP_SEQ_Flow_Factory : public TAO_AV_Flow_Protocol_Factory
00282 {
00283 public:
00284   /// Initialization hook.
00285   TAO_AV_SCTP_SEQ_Flow_Factory (void);
00286   virtual ~TAO_AV_SCTP_SEQ_Flow_Factory (void);
00287   virtual int init (int argc, char *argv[]);
00288   virtual int match_protocol (const char *flow_string);
00289   TAO_AV_Protocol_Object* make_protocol_object (TAO_FlowSpec_Entry *entry,
00290                                                 TAO_Base_StreamEndPoint *endpoint,
00291                                                 TAO_AV_Flow_Handler *handler,
00292                                                 TAO_AV_Transport *transport);
00293 };
00294 
00295 TAO_END_VERSIONED_NAMESPACE_DECL
00296 
00297 ACE_STATIC_SVC_DECLARE (TAO_AV_SCTP_SEQ_Flow_Factory)
00298 ACE_FACTORY_DECLARE (TAO_AV, TAO_AV_SCTP_SEQ_Flow_Factory)
00299 
00300 ACE_STATIC_SVC_DECLARE (TAO_AV_SCTP_SEQ_Factory)
00301 ACE_FACTORY_DECLARE (TAO_AV, TAO_AV_SCTP_SEQ_Factory)
00302 
00303 
00304 #endif // ACE_HAS_SCTP
00305 
00306 #include /**/ "ace/post.h"
00307 
00308 #endif /* TAO_AV_SCTP_SEQ_H */

Generated on Thu Nov 9 13:44:45 2006 for TAO_AV by doxygen 1.3.6