OS_QoS.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   OS_QoS.h
00006  *
00007  *  $Id: OS_QoS.h 80826 2008-03-04 14:51:23Z wotte $
00008  *
00009  *  @brief  Contains OS specific data structures for QoS networking.
00010  *
00011  *  @author Craig Rodrigues  <crodrigu@bbn.com>
00012  */
00013 //=============================================================================
00014 
00015 #ifndef ACE_OS_QOS_H
00016 #define ACE_OS_QOS_H
00017 #include /**/ "ace/pre.h"
00018 
00019 #include /**/ "ace/ACE_export.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "ace/os_include/sys/os_uio.h"
00026 #include "ace/OS_NS_stropts.h"
00027 
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029 
00030 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && defined (ACE_HAS_WINSOCK2_GQOS)
00031 typedef SERVICETYPE ACE_SERVICE_TYPE;
00032 #else
00033 typedef unsigned long ACE_SERVICE_TYPE;
00034 #endif /* ACE_HAS_WINSOCK2 && ACE_HAS_WINSOCK2 != 0 */
00035 
00036 #if defined (WSA_FLAG_OVERLAPPED)
00037 # define ACE_OVERLAPPED_SOCKET_FLAG WSA_FLAG_OVERLAPPED
00038 #else
00039 # define ACE_OVERLAPPED_SOCKET_FLAG 0
00040 #endif
00041 
00042 #if defined (XP1_QOS_SUPPORTED)
00043 # define ACE_XP1_QOS_SUPPORTED XP1_QOS_SUPPORTED
00044 #else
00045 # define ACE_XP1_QOS_SUPPORTED        0x00002000
00046 #endif
00047 
00048 #if defined (XP1_SUPPORT_MULTIPOINT)
00049 # define ACE_XP1_SUPPORT_MULTIPOINT XP1_SUPPORT_MULTIPOINT
00050 #else
00051 # define ACE_XP1_SUPPORT_MULTIPOINT   0x00000400
00052 #endif
00053 
00054 #if defined (WSABASEERR)
00055 # define ACE_BASEERR WSABASEERR
00056 #else
00057 # define ACE_BASEERR   10000
00058 #endif
00059 
00060 #if defined (WSAENOBUFS)
00061 # define ACE_ENOBUFS WSAENOBUFS
00062 #else
00063 # define ACE_ENOBUFS   (ACE_BASEERR+55)
00064 #endif
00065 
00066 #if defined (FROM_PROTOCOL_INFO)
00067 # define ACE_FROM_PROTOCOL_INFO FROM_PROTOCOL_INFO
00068 #else
00069 # define ACE_FROM_PROTOCOL_INFO (-1)
00070 #endif
00071 
00072 #if defined (WSA_FLAG_MULTIPOINT_C_ROOT)
00073 # define ACE_FLAG_MULTIPOINT_C_ROOT WSA_FLAG_MULTIPOINT_C_ROOT
00074 #else
00075 # define ACE_FLAG_MULTIPOINT_C_ROOT    0x02
00076 #endif
00077 
00078 #if defined (WSA_FLAG_MULTIPOINT_C_LEAF)
00079 # define ACE_FLAG_MULTIPOINT_C_LEAF WSA_FLAG_MULTIPOINT_C_LEAF
00080 #else
00081 # define ACE_FLAG_MULTIPOINT_C_LEAF    0x04
00082 #endif
00083 
00084 #if defined (WSA_FLAG_MULTIPOINT_D_ROOT)
00085 # define ACE_FLAG_MULTIPOINT_D_ROOT WSA_FLAG_MULTIPOINT_D_ROOT
00086 #else
00087 # define ACE_FLAG_MULTIPOINT_D_ROOT    0x08
00088 #endif
00089 
00090 #if defined (WSA_FLAG_MULTIPOINT_D_LEAF)
00091 # define ACE_FLAG_MULTIPOINT_D_LEAF WSA_FLAG_MULTIPOINT_D_LEAF
00092 #else
00093 # define ACE_FLAG_MULTIPOINT_D_LEAF    0x10
00094 #endif
00095 
00096 #if defined (QOS_NOT_SPECIFIED)
00097 # define ACE_QOS_NOT_SPECIFIED QOS_NOT_SPECIFIED
00098 #else
00099 # define ACE_QOS_NOT_SPECIFIED            0xFFFFFFFF
00100 #endif
00101 
00102 #if defined (SERVICETYPE_NOTRAFFIC)
00103 # define ACE_SERVICETYPE_NOTRAFFIC SERVICETYPE_NOTRAFFIC
00104 #else
00105 # define ACE_SERVICETYPE_NOTRAFFIC        0x00000000  /* No data in this */
00106                                                       /* direction. */
00107 #endif
00108 
00109 #if defined (SERVICETYPE_CONTROLLEDLOAD)
00110 # define ACE_SERVICETYPE_CONTROLLEDLOAD SERVICETYPE_CONTROLLEDLOAD
00111 #else
00112 # define ACE_SERVICETYPE_CONTROLLEDLOAD   0x00000001  /* Controlled Load. */
00113 #endif
00114 
00115 #if defined (SERVICETYPE_GUARANTEED)
00116 # define ACE_SERVICETYPE_GUARANTEED SERVICETYPE_GUARANTEED
00117 #else
00118 # define ACE_SERVICETYPE_GUARANTEED       0x00000003  /* Guaranteed. */
00119 #endif
00120 
00121 #if defined (JL_SENDER_ONLY)
00122 # define ACE_JL_SENDER_ONLY JL_SENDER_ONLY
00123 #else
00124 # define ACE_JL_SENDER_ONLY    0x01
00125 #endif
00126 
00127 #if defined (JL_BOTH)
00128 # define ACE_JL_BOTH JL_BOTH
00129 #else
00130 # define ACE_JL_BOTH           0x04
00131 #endif
00132 
00133 #if defined (SIO_GET_QOS)
00134 # define ACE_SIO_GET_QOS SIO_GET_QOS
00135 #else
00136 # define ACE_SIO_GET_QOS              (0x40000000 | 0x08000000 | 7)
00137 #endif
00138 
00139 #if defined (SIO_MULTIPOINT_LOOPBACK)
00140 # define ACE_SIO_MULTIPOINT_LOOPBACK SIO_MULTIPOINT_LOOPBACK
00141 #else
00142 # define ACE_SIO_MULTIPOINT_LOOPBACK  (0x08000000 | 9)
00143 #endif
00144 
00145 #if defined (SIO_MULTICAST_SCOPE)
00146 # define ACE_SIO_MULTICAST_SCOPE SIO_MULTICAST_SCOPE
00147 #else
00148 # define ACE_SIO_MULTICAST_SCOPE      (0x08000000 | 10)
00149 #endif
00150 
00151 #if defined (SIO_SET_QOS)
00152 # define ACE_SIO_SET_QOS SIO_SET_QOS
00153 #else
00154 # define ACE_SIO_SET_QOS              (0x08000000 | 11)
00155 #endif
00156 
00157 /**
00158  * @class ACE_Flow_Spec
00159  *
00160  * @brief Wrapper class that defines the flow spec QoS information,
00161  *    which is used by IntServ (RSVP) and DiffServ.
00162  */
00163 class ACE_Export ACE_Flow_Spec
00164 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00165   : public FLOWSPEC
00166 #endif /* ACE_HAS_WINSOCK2 */
00167 {
00168 public:
00169   /// Default constructor.
00170   ACE_Flow_Spec (void);
00171 
00172   /// Constructor that initializes all the fields.
00173   ACE_Flow_Spec (unsigned long token_rate,
00174                  unsigned long token_bucket_size,
00175                  unsigned long peak_bandwidth,
00176                  unsigned long latency,
00177                  unsigned long delay_variation,
00178                  ACE_SERVICE_TYPE service_type,
00179                  unsigned long max_sdu_size,
00180                  unsigned long minimum_policed_size,
00181                  int ttl,
00182                  int priority);
00183 
00184   /// Get the token rate in bytes/sec.
00185   unsigned long token_rate (void) const;
00186 
00187   /// Set the token rate in bytes/sec.
00188   void token_rate (unsigned long tr);
00189 
00190   /// Get the token bucket size in bytes.
00191   unsigned long token_bucket_size (void) const;
00192 
00193   /// Set the token bucket size in bytes.
00194   void token_bucket_size (unsigned long tbs);
00195 
00196   /// Get the PeakBandwidth in bytes/sec.
00197   unsigned long peak_bandwidth (void) const;
00198 
00199   /// Set the PeakBandwidth in bytes/sec.
00200   void peak_bandwidth (unsigned long pb);
00201 
00202   /// Get the latency in microseconds.
00203   unsigned long latency (void) const;
00204 
00205   /// Set the latency in microseconds.
00206   void latency (unsigned long l);
00207 
00208   /// Get the delay variation in microseconds.
00209   unsigned long delay_variation (void) const;
00210 
00211   /// Set the delay variation in microseconds.
00212   void delay_variation (unsigned long dv);
00213 
00214   /// Get the service type.
00215   ACE_SERVICE_TYPE service_type (void) const;
00216 
00217   /// Set the service type.
00218   void service_type (ACE_SERVICE_TYPE st);
00219 
00220   /// Get the maximum SDU size in bytes.
00221   unsigned long max_sdu_size (void) const;
00222 
00223   /// Set the maximum SDU size in bytes.
00224   void max_sdu_size (unsigned long mss);
00225 
00226   /// Get the minimum policed size in bytes.
00227   unsigned long minimum_policed_size (void) const;
00228 
00229   /// Set the minimum policed size in bytes.
00230   void minimum_policed_size (unsigned long mps);
00231 
00232   /// Get the time-to-live.
00233   int ttl (void) const;
00234 
00235   /// Set the time-to-live.
00236   void ttl (int t);
00237 
00238   /// Get the priority.
00239   int priority (void) const;
00240 
00241   /// Set the priority.
00242   void priority (int p);
00243 
00244 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
00245     defined (ACE_HAS_WINSOCK2_GQOS)
00246 #else
00247 private:
00248   unsigned long token_rate_;
00249   unsigned long token_bucket_size_;
00250   unsigned long peak_bandwidth_;
00251   unsigned long latency_;
00252   unsigned long delay_variation_;
00253   ACE_SERVICE_TYPE service_type_;
00254   unsigned long max_sdu_size_;
00255   unsigned long minimum_policed_size_;
00256   int ttl_;
00257   int priority_;
00258 #endif /* defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0) && \
00259           defined (ACE_HAS_WINSOCK2_GQOS) */
00260 };
00261 
00262 /**
00263  * @class ACE_QoS
00264  *
00265  * @brief Wrapper class that holds the sender and receiver flow spec
00266  *     information, which is used by IntServ (RSVP) and DiffServ.
00267  */
00268 class ACE_Export ACE_QoS
00269 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00270   : public QOS
00271 #endif /* ACE_HAS_WINSOCK2 */
00272 {
00273 public:
00274   /// Constructor
00275   ACE_QoS (void);
00276 
00277   /// Get the flow spec for data sending.
00278   ACE_Flow_Spec *sending_flowspec (void) const;
00279 
00280   /// Set the flow spec for data sending.
00281   void sending_flowspec (ACE_Flow_Spec *fs);
00282 
00283   /// Get the flow spec for data receiving.
00284   ACE_Flow_Spec *receiving_flowspec (void) const;
00285 
00286   /// Set the flow spec for data receiving.
00287   void receiving_flowspec (ACE_Flow_Spec *fs);
00288 
00289   /// Get the provider specific information.
00290   iovec provider_specific (void) const;
00291 
00292   /// Set the provider specific information.
00293   void provider_specific (const iovec &ps);
00294 
00295 #if defined (ACE_HAS_WINSOCK2) && (ACE_HAS_WINSOCK2 != 0)
00296 #else
00297 private:
00298 
00299   ACE_Flow_Spec *sending_flowspec_;
00300   ACE_Flow_Spec *receiving_flowspec_;
00301 #endif
00302 
00303 };
00304 
00305 /**
00306  * @class ACE_QoS_Params
00307  *
00308  * @brief Wrapper class that simplifies the information passed to the QoS
00309  * enabled <ACE_OS::connect> and <ACE_OS::join_leaf> methods.
00310  */
00311 class ACE_Export ACE_QoS_Params
00312 {
00313 public:
00314   /**
00315    * Initialize the data members.  The <caller_data> is a pointer to
00316    * the user data that is to be transferred to the peer during
00317    * connection establishment.  The <callee_data> is a pointer to the
00318    * user data that is to be transferred back from the peer during
00319    * connection establishment.  The_<socket_qos> is a pointer to the
00320    * flow specifications for the socket, one for each direction.  The
00321    * <group_socket_qos> is a pointer to the flow speicfications for
00322    * the socket group, if applicable.  The_@a flags indicate if we're a
00323    * sender, receiver, or both.
00324    */
00325   ACE_QoS_Params (iovec *caller_data = 0,
00326                   iovec *callee_data = 0,
00327                   ACE_QoS *socket_qos = 0,
00328                   ACE_QoS *group_socket_qos = 0,
00329                   unsigned long flags = 0);
00330 
00331   /// Get caller data.
00332   iovec *caller_data (void) const;
00333 
00334   /// Set caller data.
00335   void caller_data (iovec *);
00336 
00337   /// Get callee data.
00338   iovec *callee_data (void) const;
00339 
00340   /// Set callee data.
00341   void callee_data (iovec *);
00342 
00343   /// Get socket qos.
00344   ACE_QoS *socket_qos (void) const;
00345 
00346   /// Set socket qos.
00347   void socket_qos (ACE_QoS *);
00348 
00349   /// Get group socket qos.
00350   ACE_QoS *group_socket_qos (void) const;
00351 
00352   /// Set group socket qos.
00353   void group_socket_qos (ACE_QoS *);
00354 
00355   /// Get flags.
00356   unsigned long flags (void) const;
00357 
00358   /// Set flags.
00359   void flags (unsigned long);
00360 
00361 private:
00362   /// A pointer to the user data that is to be transferred to the peer
00363   /// during connection establishment.
00364   iovec *caller_data_;
00365 
00366   /// A pointer to the user data that is to be transferred back from
00367   /// the peer during connection establishment.
00368   iovec *callee_data_;
00369 
00370   /// A pointer to the flow speicfications for the socket, one for each
00371   /// direction.
00372   ACE_QoS *socket_qos_;
00373 
00374   /// A pointer to the flow speicfications for the socket group, if
00375   /// applicable.
00376   ACE_QoS *group_socket_qos_;
00377 
00378   /// Flags that indicate if we're a sender, receiver, or both.
00379   unsigned long flags_;
00380 };
00381 
00382 // Callback function that's used by the QoS-enabled <ACE_OS::accept>
00383 // method.
00384 typedef int (*ACE_QOS_CONDITION_FUNC) (iovec *caller_id,
00385                                        iovec *caller_data,
00386                                        ACE_QoS *socket_qos,
00387                                        ACE_QoS *group_socket_qos,
00388                                        iovec *callee_id,
00389                                        iovec *callee_data,
00390                                        ACE_SOCK_GROUP *g,
00391                                        unsigned long callbackdata);
00392 
00393 
00394 /**
00395  * @class ACE_Accept_QoS_Params
00396  *
00397  * @brief Wrapper class that simplifies the information passed to the QoS
00398  * enabled <ACE_OS::accept> method.
00399  */
00400 class ACE_Export ACE_Accept_QoS_Params
00401 {
00402 public:
00403   /**
00404    * Initialize the data members.  The <qos_condition_callback> is the
00405    * address of an optional, application-supplied condition function
00406    * that will make an accept/reject decision based on the caller
00407    * information pass in as parameters, and optionally create or join
00408    * a socket group by assinging an appropriate value to the result
00409    * parameter <g> of this function.  The <callback_data> data is
00410    * passed back to the application as a condition function parameter,
00411    * i.e., it is an Asynchronous Completion Token (ACT).
00412    */
00413   ACE_Accept_QoS_Params (ACE_QOS_CONDITION_FUNC qos_condition_callback = 0,
00414                          unsigned long callback_data = 0);
00415 
00416   /// Get QoS condition callback.
00417   ACE_QOS_CONDITION_FUNC qos_condition_callback (void) const;
00418 
00419   /// Set QoS condition callback.
00420   void qos_condition_callback (ACE_QOS_CONDITION_FUNC qcc);
00421 
00422   /// Get callback data.
00423   unsigned long callback_data (void) const;
00424 
00425   /// Set callback data.
00426   void callback_data (unsigned long cd);
00427 
00428 private:
00429   /**
00430    * This is the address of an optional, application-supplied
00431    * condition function that will make an accept/reject decision based
00432    * on the caller information pass in as parameters, and optionally
00433    * create or join a socket group by assinging an appropriate value
00434    * to the result parameter <g> of this function.
00435    */
00436   ACE_QOS_CONDITION_FUNC qos_condition_callback_;
00437 
00438   /**
00439    * This data is passed back to the application as a condition
00440    * function parameter, i.e., it is an Asynchronous Completion Token
00441    * (ACT).
00442    */
00443   unsigned long callback_data_;
00444 };
00445 
00446 ACE_END_VERSIONED_NAMESPACE_DECL
00447 
00448 #include /**/ "ace/post.h"
00449 #endif  /* ACE_OS_QOS_H */

Generated on Tue Feb 2 17:18:41 2010 for ACE by  doxygen 1.4.7