Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

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 Methods

 ACE_SOCK_Dgram_Mcast_QoS (options opts=DEFOPTS)
 Ctor, has same defaults as ACE_SOCK_Dgram_Mcast. More...

 ~ACE_SOCK_Dgram_Mcast_QoS (void)
 Default dtor. More...

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
 Send <buffer_count> worth of <buffers> to <addr> using overlapped I/O (uses <WSASentTo>). Returns 0 on success. More...

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>). More...

ACE_QoS_Manager qos_manager (void)
 Returns the QoS manager for this socket. More...

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. More...


Private Methods

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. More...


Private Attributes

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


Detailed Description

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

Definition at line 31 of file SOCK_Dgram_Mcast_QoS.h.


Constructor & Destructor Documentation

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 26 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_TRACE.

00027   : ACE_SOCK_Dgram_Mcast (opts)
00028 {
00029   ACE_TRACE ("ACE_SOCK_Dgram_Mcast_QoS::ACE_SOCK_Dgram_Mcast_QoS");
00030 }

ASYS_INLINE ACE_SOCK_Dgram_Mcast_QoS::~ACE_SOCK_Dgram_Mcast_QoS void   
 

Default dtor.

Definition at line 5 of file SOCK_Dgram_Mcast_QoS.i.

00006 {
00007 }


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 33 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_DEBUG, ACE_SOCK_GROUP, ACE_TRACE, ACE_IPC_SAP::get_handle, LM_DEBUG, ACE_SOCK::open, and ACE_SOCK_Dgram_Mcast::open_i.

Referenced by subscribe.

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

ASYS_INLINE ACE_QoS_Manager ACE_SOCK_Dgram_Mcast_QoS::qos_manager void   
 

Returns the QoS manager for this socket.

Definition at line 49 of file SOCK_Dgram_Mcast_QoS.i.

References qos_manager_.

00050 {
00051   return this->qos_manager_;
00052 }

ASYS_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 31 of file SOCK_Dgram_Mcast_QoS.i.

References ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, ACE_TRACE, and ACE_SOCK_Dgram::send.

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

ASYS_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 10 of file SOCK_Dgram_Mcast_QoS.i.

References ACE_OVERLAPPED, ACE_OVERLAPPED_COMPLETION_FUNC, ACE_TRACE, and ACE_SOCK_Dgram::send.

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

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 173 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_SOCK_GROUP, ACE_TCHAR, ACE_TRACE, ACE_SOCK::close, ACE_QoS_Session::dest_addr, ENOTSUP, ACE_OS::join_leaf, ACE_QoS_Manager::join_qos_session, LM_ERROR, ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr, open, ACE_QoS_Session::qos, qos_manager_, ACE_QoS_Params::socket_qos, and subscribe_ifs.

Referenced by subscribe_ifs.

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

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 68 of file SOCK_Dgram_Mcast_QoS.cpp.

References ACE_LIB_TEXT, ACE_TCHAR, ACE_TEXT_CHAR_TO_TCHAR, ACE_TRACE, ACE_INET_Addr::get_ip_address, ACE_Sock_Connect::get_ip_interfaces, INADDR_LOOPBACK, ACE_SOCK_Dgram_Mcast::make_multicast_ifaddr, and subscribe.

Referenced by subscribe.

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


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 104 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 129 of file SOCK_Dgram_Mcast_QoS.h.

Referenced by qos_manager, and subscribe.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 13:17:51 2003 for ACE_QoS by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002