ACE_SOCK_Dgram_Mcast_QoS Class Reference

Defines the member functions for the ACE QoS enabled socket wrapper for UDP/IP multicast. More...

#include <SOCK_Dgram_Mcast_QoS.h>

Inheritance diagram for ACE_SOCK_Dgram_Mcast_QoS:

Inheritance graph
[legend]
Collaboration diagram for ACE_SOCK_Dgram_Mcast_QoS:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_SOCK_Dgram_Mcast_QoS (options opts=DEFOPTS)
 Ctor, has same defaults as ACE_SOCK_Dgram_Mcast.
 ~ACE_SOCK_Dgram_Mcast_QoS (void)
 Default dtor.
int subscribe (const ACE_INET_Addr &mcast_addr, const ACE_QoS_Params &qos_params, int reuse_addr=1, const ACE_TCHAR *net_if=0, int protocol_family=PF_INET, int protocol=0, ACE_Protocol_Info *protocolinfo=0, ACE_SOCK_GROUP g=0, u_long flags=0, ACE_QoS_Session *qos_session=0)
ssize_t send (const iovec buffers[], int buffer_count, size_t &number_of_bytes_sent, int flags, const ACE_Addr &addr, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const
ssize_t send (const void *buf, size_t n, const ACE_Addr &addr, int flags, ACE_OVERLAPPED *overlapped, ACE_OVERLAPPED_COMPLETION_FUNC func) const
 Send an n byte buf to the datagram socket (uses <WSASentTo>).
ACE_QoS_Manager qos_manager (void)
 Returns the QoS manager for this socket.
int open (const ACE_INET_Addr &addr, const ACE_QoS_Params &qos_params, int protocol_family=PF_INET, int protocol=0, ACE_Protocol_Info *protocolinfo=0, ACE_SOCK_GROUP g=0, u_long flags=0, int reuse_addr=0)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Member Functions

int subscribe_ifs (const ACE_INET_Addr &mcast_addr, const ACE_QoS_Params &qos_params, const ACE_TCHAR *net_if, int protocol_family, int protocol, int reuse_addr, ACE_Protocol_Info *protocolinfo)
 Subscribe to the multicast interface using QoS-enabled semantics.

Private Attributes

ACE_QoS_Manager qos_manager_
 Manages the QoS sessions that this socket subscribes to.

Detailed Description

Defines the member functions for the ACE QoS enabled socket wrapper for UDP/IP multicast.

Definition at line 33 of file SOCK_Dgram_Mcast_QoS.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_SOCK_Dgram_Mcast_QoS::ACE_SOCK_Dgram_Mcast_QoS ( options  opts = DEFOPTS  ) 

Ctor, has same defaults as ACE_SOCK_Dgram_Mcast.

Definition at line 32 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_TRACE.

00033   : ACE_SOCK_Dgram_Mcast (opts)
00034 {
00035   ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::ACE_SOCK_Dgram_Mcast_QoS");
00036 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_SOCK_Dgram_Mcast_QoS::~ACE_SOCK_Dgram_Mcast_QoS ( void   ) 

Default dtor.

Definition at line 8 of file SOCK_Dgram_Mcast_QoS.inl.

00009 {
00010 }


Member Function Documentation

int ACE_SOCK_Dgram_Mcast_QoS::open ( const ACE_INET_Addr addr,
const ACE_QoS_Params qos_params,
int  protocol_family = PF_INET,
int  protocol = 0,
ACE_Protocol_Info protocolinfo = 0,
ACE_SOCK_GROUP  g = 0,
u_long  flags = 0,
int  reuse_addr = 0 
)

Definition at line 39 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_DEBUG, ACE_TRACE, LM_DEBUG, ACE_SOCK::open(), ACE_SOCK_Dgram_Mcast::open_i(), and SOCK_DGRAM.

00047 {
00048   ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::open");
00049 
00050   ACE_UNUSED_ARG (qos_params);
00051 
00052   // Only perform the <open> initialization if we haven't been opened
00053   // earlier.
00054   if (this->get_handle () != ACE_INVALID_HANDLE)
00055     return 0;
00056 
00057   ACE_DEBUG ((LM_DEBUG,
00058               "Get Handle Returns Invalid Handle\n"));
00059 
00060   if (ACE_SOCK::open (SOCK_DGRAM,
00061                       protocol_family,
00062                       protocol,
00063                       protocolinfo,
00064                       g,
00065                       flags,
00066                       reuse_addr) == -1)
00067     return -1;
00068 
00069   return this->open_i (addr, 0, reuse_addr);
00070 }

ACE_INLINE ACE_QoS_Manager ACE_SOCK_Dgram_Mcast_QoS::qos_manager ( void   ) 

Returns the QoS manager for this socket.

Definition at line 52 of file SOCK_Dgram_Mcast_QoS.inl.

References qos_manager_.

00053 {
00054   return this->qos_manager_;
00055 }

ACE_INLINE ssize_t ACE_SOCK_Dgram_Mcast_QoS::send ( const void *  buf,
size_t  n,
const ACE_Addr addr,
int  flags,
ACE_OVERLAPPED overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC  func 
) const

Send an n byte buf to the datagram socket (uses <WSASentTo>).

Reimplemented from ACE_SOCK_Dgram.

Definition at line 34 of file SOCK_Dgram_Mcast_QoS.inl.

References ACE_TRACE, and ACE_SOCK_Dgram::send().

00040 {
00041   ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::send");
00042 
00043   return ACE_SOCK_Dgram::send (buf,
00044                                n,
00045                                addr,
00046                                flags,
00047                                overlapped,
00048                                func);
00049 }

ACE_INLINE ssize_t ACE_SOCK_Dgram_Mcast_QoS::send ( const iovec  buffers[],
int  buffer_count,
size_t &  number_of_bytes_sent,
int  flags,
const ACE_Addr addr,
ACE_OVERLAPPED overlapped,
ACE_OVERLAPPED_COMPLETION_FUNC  func 
) const

Send <buffer_count> worth of buffers to addr using overlapped I/O (uses <WSASentTo>). Returns 0 on success.

Reimplemented from ACE_SOCK_Dgram.

Definition at line 13 of file SOCK_Dgram_Mcast_QoS.inl.

References ACE_TRACE, and ACE_SOCK_Dgram::send().

00020 {
00021   ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::send");
00022 
00023   return ACE_SOCK_Dgram::send (buffers,
00024                                buffer_count,
00025                                number_of_bytes_sent,
00026                                flags,
00027                                addr,
00028                                overlapped,
00029                                func);
00030 
00031 }

int ACE_SOCK_Dgram_Mcast_QoS::subscribe ( const ACE_INET_Addr mcast_addr,
const ACE_QoS_Params qos_params,
int  reuse_addr = 1,
const ACE_TCHAR net_if = 0,
int  protocol_family = PF_INET,
int  protocol = 0,
ACE_Protocol_Info protocolinfo = 0,
ACE_SOCK_GROUP  g = 0,
u_long  flags = 0,
ACE_QoS_Session qos_session = 0 
)

This is a QoS-enabled method for joining a multicast group, which passes <qos_params> via <ACE_OS::join_leaf>. The network interface device driver is instructed to accept datagrams with <mcast_addr> multicast addresses. If the socket has already been opened, <subscribe> closes the socket and opens a new socket bound to the <mcast_addr>. The session object specifies the QoS session that the socket wants to subscribe to. A socket may subscribe to multiple QoS sessions by calling this method multiple times with different session objects.

The <net_if> interface is hardware specific, e.g., use "netstat -i" to find whether your interface is, such as "le0" or something else. If net_if == 0, <subscribe> uses the default mcast interface. Returns: -1 if the call fails.

Note that some platforms, such as pSoS, support only number, not names, for network interfaces. For these platforms, just give these numbers in alphanumeric form and <subscribe> will convert them into numbers via <ACE_OS::atoi>.

Definition at line 178 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_TEXT, ACE_TRACE, ACE_QoS_Session::dest_addr(), ENOTSUP, ACE_OS::join_leaf(), LM_ERROR, ACE_SOCK_Dgram::make_multicast_ifaddr(), ACE_QoS_Session::qos(), ACE_QoS_Params::socket_qos(), and subscribe_ifs().

00188 {
00189   ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::subscribe");
00190 
00191   if (this->open (mcast_addr,
00192                   qos_params,
00193                   protocol_family,
00194                   protocol,
00195                   protocolinfo,
00196                   g,
00197                   flags,
00198                   reuse_addr) == -1)
00199     return -1;
00200 
00201   // The following method call only applies to Win32 currently.
00202   int result = this->subscribe_ifs (mcast_addr,
00203                                     qos_params,
00204                                     net_if,
00205                                     protocol_family,
00206                                     protocol,
00207                                     reuse_addr,
00208                                     protocolinfo);
00209   // Check for the "short-circuit" return value of 1 (for NT).
00210   if (result != 0)
00211     return result;
00212 
00213   // Tell network device driver to read datagrams with a
00214   // <mcast_request_if_> IP interface.
00215   else
00216     {
00217       // Check if the mcast_addr passed into this method is the
00218       // same as the QoS session address.
00219       if (qos_session != 0 && mcast_addr == qos_session->dest_addr ())
00220         {
00221           // Subscribe to the QoS session.
00222           if (this->qos_manager_.join_qos_session (qos_session) == -1)
00223             ACE_ERROR_RETURN ((LM_ERROR,
00224                                ACE_TEXT ("Unable to join QoS Session\n")),
00225                               -1);
00226         }
00227       else
00228         {
00229           if (this->close () != 0)
00230             ACE_ERROR ((LM_ERROR,
00231                         ACE_TEXT ("Unable to close socket\n")));
00232             ACE_ERROR_RETURN ((LM_ERROR,
00233                                ACE_TEXT ("Dest Addr in the QoS Session does")
00234                                ACE_TEXT (" not match the address passed into")
00235                                ACE_TEXT (" subscribe\n")),
00236                               -1);
00237         }
00238 
00239       ip_mreq ret_mreq;
00240       this->make_multicast_ifaddr (&ret_mreq, mcast_addr, net_if);
00241 
00242       // XX This is windows stuff only. fredk
00243       if (ACE_OS::join_leaf (this->get_handle (),
00244                              reinterpret_cast<const sockaddr *> (&ret_mreq.IMR_MULTIADDR.s_addr),
00245                              sizeof ret_mreq.IMR_MULTIADDR.s_addr,
00246                              qos_params) == ACE_INVALID_HANDLE
00247           && errno != ENOTSUP)
00248         return -1;
00249 
00250       else
00251         if (qos_params.socket_qos () != 0 && qos_session != 0)
00252           qos_session->qos (*(qos_params.socket_qos ()));
00253 
00254       return 0;
00255     }
00256 }

int ACE_SOCK_Dgram_Mcast_QoS::subscribe_ifs ( const ACE_INET_Addr mcast_addr,
const ACE_QoS_Params qos_params,
const ACE_TCHAR net_if,
int  protocol_family,
int  protocol,
int  reuse_addr,
ACE_Protocol_Info protocolinfo 
) [private]

Subscribe to the multicast interface using QoS-enabled semantics.

Definition at line 74 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, ACE_TRACE, and ACE::get_ip_interfaces().

Referenced by subscribe().

00081 {
00082   ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::subscribe_ifs");
00083 #if defined (ACE_WIN32)
00084   // Windows NT's winsock has trouble with multicast subscribes in the
00085   // presence of multiple network interfaces when the IP address is
00086   // given as INADDR_ANY.  It will pick the first interface and only
00087   // accept mcast there.  So, to work around this, cycle through all
00088   // of the interfaces known and subscribe to all the non-loopback
00089   // ones.
00090   //
00091   // Note that this only needs to be done on NT, but there's no way to
00092   // tell at this point if the code will be running on NT - only if it
00093   // is compiled for NT-only or for NT/95, and that doesn't really
00094   // help us.  It doesn't hurt to do this on Win95, it's just a little
00095   // slower than it normally would be.
00096   //
00097   // NOTE - <ACE_Sock_Connect::get_ip_interfaces> doesn't always get all
00098   // of the interfaces.  In particular, it may not get a PPP interface.  This
00099   // is a limitation of the way <ACE_Sock_Connect::get_ip_interfaces> works
00100   // with MSVC.  The reliable way of getting the interface list is
00101   // available only with MSVC 5.
00102 
00103   if (net_if == 0)
00104     {
00105       ACE_INET_Addr *if_addrs = 0;
00106       size_t if_cnt;
00107 
00108       if (ACE::get_ip_interfaces (if_cnt, if_addrs) != 0)
00109         return -1;
00110 
00111       size_t nr_subscribed = 0;
00112 
00113       if (if_cnt < 2)
00114         {
00115           if (this->subscribe (mcast_addr,
00116                                qos_params,
00117                                reuse_addr,
00118                                ACE_TEXT ("0.0.0.0"),
00119                                protocol_family,
00120                                protocol,
00121                                protocolinfo) == 0)
00122             ++nr_subscribed;
00123         }
00124       else
00125         // Iterate through all the interfaces, figure out which ones
00126         // offer multicast service, and subscribe to them.
00127         while (if_cnt > 0)
00128           {
00129             --if_cnt;
00130 
00131             // Convert to 0-based for indexing, next loop check.
00132             if (if_addrs[if_cnt].is_loopback())
00133               continue;
00134             if (this->subscribe (mcast_addr,
00135                                  qos_params,
00136                                  reuse_addr,
00137                                  ACE_TEXT_CHAR_TO_TCHAR
00138                                    (if_addrs[if_cnt].get_host_addr()),
00139                                  protocol_family,
00140                                  protocol,
00141                                  protocolinfo) == 0)
00142               ++nr_subscribed;
00143           }
00144 
00145       delete [] if_addrs;
00146 
00147       if (nr_subscribed == 0)
00148         {
00149           errno = ENODEV;
00150           return -1;
00151         }
00152       else
00153         // 1 indicates a "short-circuit" return.  This handles the
00154         // rather bizarre semantics of checking all the interfaces on
00155         // NT.
00156         return 1;
00157     }
00158 #else
00159   ACE_UNUSED_ARG (mcast_addr);
00160   ACE_UNUSED_ARG (qos_params);
00161   ACE_UNUSED_ARG (protocol_family);
00162   ACE_UNUSED_ARG (protocol);
00163   ACE_UNUSED_ARG (reuse_addr);
00164   ACE_UNUSED_ARG (protocolinfo);
00165 #endif /* ACE_WIN32 */
00166   // Otherwise, do it like everyone else...
00167 
00168   // Create multicast request.
00169   if (this->make_multicast_ifaddr (0,
00170                                    mcast_addr,
00171                                    net_if) == -1)
00172     return -1;
00173   else
00174     return 0;
00175 }


Member Data Documentation

ACE_SOCK_Dgram_Mcast_QoS::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Reimplemented from ACE_SOCK_Dgram_Mcast.

Definition at line 106 of file SOCK_Dgram_Mcast_QoS.h.

ACE_QoS_Manager ACE_SOCK_Dgram_Mcast_QoS::qos_manager_ [private]

Manages the QoS sessions that this socket subscribes to.

Definition at line 131 of file SOCK_Dgram_Mcast_QoS.h.

Referenced by qos_manager().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:36:41 2010 for ACE_QoS by  doxygen 1.4.7