QoS_UDP.h

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

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