QoS_UDP.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   QoS_UDP.h
00006  *
00007  *  $Id: QoS_UDP.h 77047 2007-02-12 15:52:44Z johnnyw $
00008  *
00009  *  @author Yamuna Krishnamurthy <yamuna@cs.wustl.edu>
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef TAO_AV_QOS_UDP_H
00015 #define TAO_AV_QOS_UDP_H
00016 #include /**/ "ace/pre.h"
00017 
00018 
00019 #include "ace/config-all.h"
00020 
00021 #if defined (ACE_HAS_RAPI) || defined (ACE_HAS_WINSOCK2_GQOS)
00022 
00023 #include "orbsvcs/AV/Protocol_Factory.h"
00024 
00025 #include "ace/OS.h"
00026 #include "ace/Service_Config.h"
00027 #include "ace/QoS/QoS_Session_Factory.h"
00028 #include "ace/QoS/QoS_Decorator.h"
00029 #include "ace/QoS/SOCK_Dgram_Mcast_QoS.h"
00030 
00031 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00032 
00033 class TAO_AV_Export TAO_AV_UDP_QoS_Factory : public TAO_AV_Transport_Factory
00034 {
00035 public:
00036   TAO_AV_UDP_QoS_Factory (void);
00037   virtual ~TAO_AV_UDP_QoS_Factory (void);
00038   virtual int init (int argc, char *argv[]);
00039   /// Initialization hook.
00040   virtual int match_protocol (const char *protocol_string);
00041   virtual TAO_AV_Acceptor *make_acceptor (void);
00042   virtual TAO_AV_Connector *make_connector (void);
00043 };
00044 
00045 class TAO_AV_UDP_QoS_Flow_Handler;
00046 
00047 /**
00048  * @class TAO_AV_UDP_QoS_Transport
00049  *
00050  * @brief A transport abstraction for udp sockets.
00051  *
00052  * Uses the ACE_SOCK_Dgram to send the data.
00053  */
00054 class TAO_AV_UDP_QoS_Transport
00055   :public TAO_AV_Transport
00056 {
00057 public:
00058   TAO_AV_UDP_QoS_Transport (void);
00059 
00060   TAO_AV_UDP_QoS_Transport (TAO_AV_UDP_QoS_Flow_Handler *handler);
00061 
00062   virtual  ~TAO_AV_UDP_QoS_Transport (void);
00063 
00064   virtual int open (ACE_Addr *addr);
00065 
00066   virtual int close (void);
00067 
00068   virtual int mtu (void);
00069 
00070   virtual ACE_Addr *get_peer_addr (void);
00071 
00072   virtual int set_remote_address (const ACE_INET_Addr &address);
00073 
00074   /// Write the complete Message_Block chain to the connection.
00075   virtual ssize_t send (const ACE_Message_Block *mblk,
00076                         ACE_Time_Value *s = 0);
00077 
00078   /// Write the contents of the buffer of length len to the connection.
00079   virtual ssize_t send (const char *buf,
00080                         size_t len,
00081                         ACE_Time_Value *s = 0);
00082 
00083   /// Write the contents of iovcnt iovec's to the connection.
00084   virtual ssize_t send (const iovec *iov,
00085                         int iovcnt,
00086                         ACE_Time_Value *s = 0);
00087 
00088   /// Read len bytes from into buf.
00089   virtual ssize_t recv (char *buf,
00090                         size_t len,
00091                         ACE_Time_Value *s = 0);
00092 
00093   /// Read len bytes from into buf using flags.
00094   virtual ssize_t recv (char *buf,
00095                         size_t len,
00096                         int flags,
00097                         ACE_Time_Value *s = 0);
00098 
00099   /// Read received data into the iovec buffers.
00100   virtual ssize_t recv (iovec *iov,
00101                         int iovcnt,
00102                         ACE_Time_Value *s = 0);
00103 protected:
00104   TAO_AV_UDP_QoS_Flow_Handler *handler_;
00105   ACE_Addr *addr_;
00106   ACE_INET_Addr peer_addr_;
00107 };
00108 
00109 class TAO_AV_UDP_QoS_Flow_Handler
00110   :public virtual TAO_AV_Flow_Handler,
00111    public virtual ACE_Event_Handler
00112 {
00113 public:
00114   /// Constructor.
00115   /**
00116    * Destructor
00117    */
00118   TAO_AV_UDP_QoS_Flow_Handler (void);
00119   ~TAO_AV_UDP_QoS_Flow_Handler (void);
00120   int open (ACE_Addr &address);
00121   virtual TAO_AV_Transport *transport (void);
00122   virtual int set_remote_address (ACE_Addr *address);
00123   virtual ACE_HANDLE get_handle (void) const;
00124   virtual int handle_input (ACE_HANDLE fd);
00125   virtual int handle_timeout (const ACE_Time_Value &tv, const void *arg = 0);
00126   virtual int change_qos (AVStreams::QoS);
00127   /// Handles a QoS event. Right now, just
00128   /// prints a message.
00129   virtual int handle_qos (ACE_HANDLE fd);
00130   ACE_SOCK_Dgram_Mcast_QoS *get_socket (void);
00131   virtual ACE_Event_Handler* event_handler (void){ return this; }
00132   virtual ACE_QoS_Session* qos_session (void);
00133   virtual void qos_session (ACE_QoS_Session *qos_session);
00134 
00135   int translate (ACE_Flow_Spec *ace_flow_spec,
00136          CosPropertyService::Properties &qos_params);
00137   int translate (CosPropertyService::Properties &qos_params,
00138          ACE_Flow_Spec *ace_flow_spec);
00139 
00140   void negotiator (AVStreams::Negotiator_ptr);
00141 
00142   void endpoint (TAO_Base_StreamEndPoint *endpoint);
00143   TAO_Base_StreamEndPoint* endpoint (void);
00144 
00145   void flowspec_entry (TAO_FlowSpec_Entry *entry);
00146   TAO_FlowSpec_Entry* flowspec_entry (void);
00147 
00148   void av_core (TAO_AV_Core *avcore);
00149   TAO_AV_Core* av_core (void);
00150 
00151 protected:
00152   TAO_AV_Core *av_core_;
00153   ACE_INET_Addr peer_addr_;
00154   ACE_SOCK_Dgram_Mcast_QoS qos_sock_dgram_;
00155   ACE_QoS_Session *qos_session_;
00156   TAO_FlowSpec_Entry *entry_;
00157   TAO_Base_StreamEndPoint *endpoint_;
00158   AVStreams::Negotiator_ptr negotiator_;
00159 };
00160 
00161 class TAO_AV_UDP_QoS_Acceptor
00162   :public TAO_AV_Acceptor
00163 {
00164 public:
00165   TAO_AV_UDP_QoS_Acceptor (void);
00166   virtual ~TAO_AV_UDP_QoS_Acceptor (void);
00167   virtual int open (TAO_Base_StreamEndPoint *endpoint,
00168                     TAO_AV_Core *av_core,
00169                     TAO_FlowSpec_Entry *entry,
00170                     TAO_AV_Flow_Protocol_Factory *factory,
00171                     TAO_AV_Core::Flow_Component flow_comp =
00172                         TAO_AV_Core::TAO_AV_DATA);
00173 
00174   virtual int open_default (TAO_Base_StreamEndPoint *endpoint,
00175                             TAO_AV_Core *av_core,
00176                             TAO_FlowSpec_Entry *entry,
00177                             TAO_AV_Flow_Protocol_Factory *factory,
00178                             TAO_AV_Core::Flow_Component flow_comp =
00179                                 TAO_AV_Core::TAO_AV_DATA);
00180 
00181   virtual int open_i (ACE_INET_Addr *address);
00182 
00183   virtual int close (void);
00184 
00185   virtual int activate_svc_handler (TAO_AV_UDP_QoS_Flow_Handler *handler);
00186 
00187 
00188 protected:
00189   TAO_Base_StreamEndPoint *endpoint_;
00190   TAO_FlowSpec_Entry *entry_;
00191   TAO_AV_Flow_Protocol_Factory *flow_protocol_factory_;
00192   ACE_QoS_Session *qos_session_;
00193   ACE_QoS_Manager qos_manager_;
00194   ACE_INET_Addr qos_acceptor_addr_;
00195 };
00196 
00197 class TAO_AV_UDP_QoS_Connector
00198   :public TAO_AV_Connector
00199 {
00200 public:
00201   TAO_AV_UDP_QoS_Connector (void);
00202   ~TAO_AV_UDP_QoS_Connector (void);
00203   virtual int open (TAO_Base_StreamEndPoint *endpoint,
00204                     TAO_AV_Core *av_core,
00205                     TAO_AV_Flow_Protocol_Factory *factory);
00206 
00207   virtual int connect (TAO_FlowSpec_Entry *entry,
00208                        TAO_AV_Transport *&transport,
00209                        TAO_AV_Core::Flow_Component flow_comp =
00210                            TAO_AV_Core::TAO_AV_DATA);
00211   virtual int activate_svc_handler (TAO_AV_UDP_QoS_Flow_Handler *handler);
00212   virtual int close (void);
00213 
00214   int translate (CosPropertyService::Properties &qos_params,
00215          ACE_Flow_Spec *ace_flow_spec);
00216 
00217 protected:
00218   TAO_Base_StreamEndPoint *endpoint_;
00219   TAO_AV_Core *av_core_;
00220   TAO_FlowSpec_Entry *entry_;
00221   TAO_AV_Flow_Protocol_Factory *flow_protocol_factory_;
00222   ACE_QoS_Session *qos_session_;
00223   ACE_QoS_Manager qos_manager_;
00224 };
00225 
00226 // class TAO_AV_Export TAO_AV_UDP_Object  : public TAO_AV_Protocol_Object
00227 // {
00228 // public:
00229 //   TAO_AV_UDP_Object (TAO_AV_Callback *callback,
00230 //                      TAO_AV_Transport *transport = 0);
00231 
00232 //   virtual ~TAO_AV_UDP_Object (void);
00233 //   // Dtor
00234 
00235 //   virtual int handle_input (void);
00236 
00237 //   virtual int send_frame (ACE_Message_Block *frame,
00238 //                           TAO_AV_frame_info *frame_info = 0);
00239 //   // send a data frame.
00240 
00241 //   virtual int send_frame (const iovec *iov,
00242 //                           int iovcnt,
00243 //                           TAO_AV_frame_info *frame_info = 0);
00244 
00245 //   virtual int destroy (void);
00246 //   // end the stream.
00247 
00248 // private:
00249 //   ACE_Message_Block frame_;
00250 //   // Pre-allocated memory to receive the data...
00251 // };
00252 
00253 class TAO_AV_UDP_QoS_Flow_Factory : public TAO_AV_Flow_Protocol_Factory
00254 {
00255 public:
00256   TAO_AV_UDP_QoS_Flow_Factory (void);
00257   virtual ~TAO_AV_UDP_QoS_Flow_Factory (void);
00258   virtual int init (int argc, char *argv[]);
00259   /// Initialization hook.
00260   virtual int match_protocol (const char *flow_string);
00261   TAO_AV_Protocol_Object* make_protocol_object (TAO_FlowSpec_Entry *entry,
00262                                                 TAO_Base_StreamEndPoint *endpoint,
00263                                                 TAO_AV_Flow_Handler *handler,
00264                                                 TAO_AV_Transport *transport);
00265 };
00266 
00267 /// Helper class to create qos sessions,
00268 /// activate qos handlers and set qos
00269 /// (For separation of concerns)
00270 class TAO_AV_UDP_QoS_Session_Helper
00271 {
00272 public:
00273   TAO_AV_UDP_QoS_Session_Helper (void);
00274   ~TAO_AV_UDP_QoS_Session_Helper (void);
00275 
00276   /// Open a QoS Session with the specified address
00277   ACE_QoS_Session* open_qos_session (TAO_AV_UDP_QoS_Flow_Handler *handler,
00278                      ACE_INET_Addr &addr);
00279 
00280   /// Activate the QoS handler to receive QoS events
00281   int activate_qos_handler (ACE_QoS_Session *qos_session,
00282                 TAO_AV_UDP_QoS_Flow_Handler *handler);
00283 
00284   /// Set the required QoS for the session
00285   int set_qos (ACE_Flow_Spec& ace_flow_spec,
00286            TAO_AV_UDP_QoS_Flow_Handler *handler);
00287 };
00288 
00289 TAO_END_VERSIONED_NAMESPACE_DECL
00290 
00291 ACE_STATIC_SVC_DECLARE (TAO_AV_UDP_QoS_Flow_Factory)
00292 ACE_FACTORY_DECLARE (TAO_AV, TAO_AV_UDP_QoS_Flow_Factory)
00293 
00294 ACE_STATIC_SVC_DECLARE (TAO_AV_UDP_QoS_Factory)
00295 ACE_FACTORY_DECLARE (TAO_AV, TAO_AV_UDP_QoS_Factory)
00296 
00297 
00298 #if defined(__ACE_INLINE__)
00299 #include "orbsvcs/AV/QoS_UDP.inl"
00300 #endif /* __ACE_INLINE__ */
00301 
00302 #endif /* ACE_HAS_RAPI || ACE_HAS_WINSOCK2_GQOS */
00303 
00304 #include /**/ "ace/post.h"
00305 #endif /* TAO_AV_QOS_UDP_H */

Generated on Tue Feb 2 17:47:49 2010 for TAO_AV by  doxygen 1.4.7