summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-99b36
-rw-r--r--ace/INET_Addr.h33
-rw-r--r--ace/OS.h31
-rw-r--r--ace/OS.i41
-rw-r--r--ace/SOCK_Dgram_Mcast.cpp303
-rw-r--r--ace/SOCK_Dgram_Mcast.h153
6 files changed, 377 insertions, 220 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index 4ce84f9bd29..81b0e2629e2 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,3 +1,28 @@
+Tue Jun 15 17:41:38 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * ace/OS: Added a new wrapper for WSASocket(), which is needed for
+ all the new GQoS stuff.
+
+ * ace/SOCK_Dgram_Mcast: The API for many of the methods in this
+ class was broken since it was different for pSoS and for
+ non-pSoS platforms, which violates "The ACE Way." The fix is to
+ make the API the same, i.e., use ASYS_TCHAR * consistently, and
+ then handle this by converting these into numbers via
+ ACE_OS::atoi() where necessary, e.g., for pSoS.
+
+ * ace/INET_Addr: For some strange reason there were several
+ ACE_INET_Addr constructors that weren't consistent with their
+ corresponding set() method, i.e., they didn't have the "encode"
+ argument to allow the caller to select whether network encoding
+ should be performed or not. This has been fixed to make the
+ interfaces consistent. However, no existing code should be
+ affected since the API extensions are done using default values.
+
+ * ACE-INSTALL.html: Updated the documentation to recommend
+ building gperf so that TAO's IDL compiler will work optimally.
+ Thanks to Jim Penny <jpenny@universal-fasteners.com> for
+ suggesting this.
+
Tue Jun 15 22:26:43 1999 Matthew J Braun <mjb2@cs.wustl.edu>
* tests/DLL_Test.cpp
@@ -5,8 +30,8 @@ Tue Jun 15 22:26:43 1999 Matthew J Braun <mjb2@cs.wustl.edu>
* ace/Thread_Manager.h,cpp
* ace/Template_Instantiations.cpp
* ace/Containers_T.h,cpp,i
- * ace/Containers.h,cpp
- Added new classes ACE_Double_Linked_List_Iterator_Base,
+ * ace/Containers.h,cpp: Added new classes
+ ACE_Double_Linked_List_Iterator_Base,
ACE_Double_Linked_List_Reverse_Iterator and
ACE_DLList_Reverse_Iterator. I also had to adjust friend
declarations accordingly (as the iterator base and reverse
@@ -26,13 +51,6 @@ Tue Jun 15 17:55:04 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
defined because we couldn't figure out a way to automagically
determine the OS version.
-Tue Jun 15 17:41:38 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
-
- * ACE-INSTALL.html: Updated the documentation to recommend
- building gperf so that TAO's IDL compiler will work optimally.
- Thanks to Jim Penny <jpenny@universal-fasteners.com> for
- suggesting this.
-
Tue Jun 15 15:22:53 1999 Steve Huston <shuston@riverace.com>
* ace/config-aix-4.x.h: Added ACE_HAS_BROKEN_T_ERROR.
diff --git a/ace/INET_Addr.h b/ace/INET_Addr.h
index 1d62735b875..4958e08e0ed 100644
--- a/ace/INET_Addr.h
+++ b/ace/INET_Addr.h
@@ -28,7 +28,8 @@
class ACE_Export ACE_INET_Addr : public ACE_Addr
{
// = TITLE
- // Defines the Internet domain address family address format.
+ // Defines a C++ wrapper facade for the Internet domain address
+ // family format.
public:
// = Initialization methods.
ACE_INET_Addr (void);
@@ -51,16 +52,19 @@ public:
// is assumed to be a port number, with the IP address being
// INADDR_ANY.
- ACE_INET_Addr (u_short port_number, ACE_UINT32 ip_addr = INADDR_ANY);
+ ACE_INET_Addr (u_short port_number,
+ ACE_UINT32 ip_addr = INADDR_ANY);
// Creates an <ACE_INET_Addr> from a <port_number> and an Internet
// <ip_addr>. This method assumes that <port_number> and <ip_addr>
// are in host byte order.
- ACE_INET_Addr (const ASYS_TCHAR port_name[], const ASYS_TCHAR host_name[]);
+ ACE_INET_Addr (const ASYS_TCHAR port_name[],
+ const ASYS_TCHAR host_name[]);
// Uses <getservbyname> to create an <ACE_INET_Addr> from a
// <port_name> and the remote <host_name>.
- ACE_INET_Addr (const ASYS_TCHAR port_name[], ACE_UINT32 ip_addr);
+ ACE_INET_Addr (const ASYS_TCHAR port_name[],
+ ACE_UINT32 ip_addr);
// Uses <getservbyname> to create an <ACE_INET_Addr> from a
// <port_name> and an Internet <ip_addr>. This method assumes that
// <ip_addr> is in host byte order.
@@ -68,12 +72,15 @@ public:
~ACE_INET_Addr (void);
// Default dtor.
- // = Direct initialization methods (useful after the object has been
- // constructed).
+ // = Direct initialization methods.
+
+ // These methods are useful after the object has been constructed.
+
int set (const ACE_INET_Addr &);
// Initializes from another <ACE_INET_Addr>.
- int set (u_short port_number, const ASYS_TCHAR host_name[],
+ int set (u_short port_number,
+ const ASYS_TCHAR host_name[],
int encode = 1);
// Initializes an <ACE_INET_Addr> from a <port_number> and the
// remote <host_name>. If <encode> is enabled then <port_number> is
@@ -89,11 +96,13 @@ public:
// they are assumed to be in network byte order already and are
// passed straight through.
- int set (const ASYS_TCHAR port_name[], const ASYS_TCHAR host_name[]);
+ int set (const ASYS_TCHAR port_name[],
+ const ASYS_TCHAR host_name[]);
// Uses <getservbyname> to initialize an <ACE_INET_Addr> from a
// <port_name> and the remote <host_name>.
- int set (const ASYS_TCHAR port_name[], ACE_UINT32 ip_addr);
+ int set (const ASYS_TCHAR port_name[],
+ ACE_UINT32 ip_addr);
// Uses <getservbyname> to initialize an <ACE_INET_Addr> from a
// <port_name> and an Internet address. This assumes that <ip_addr>
// is already in network byte order.
@@ -105,7 +114,8 @@ public:
// is assumed to be a port number, with the IP address being
// INADDR_ANY.
- int set (const sockaddr_in *, int len);
+ int set (const sockaddr_in *,
+ int len);
// Creates an <ACE_INET_Addr> from a sockaddr_in structure.
virtual void *get_addr (void) const;
@@ -133,7 +143,8 @@ public:
// is no ':' in the <address> it is assumed to be a port number,
// with the IP address being INADDR_ANY.
- void set_port_number (u_short, int encode = 1);
+ void set_port_number (u_short,
+ int encode = 1);
// Sets the port number without affecting the host name. If
// <encode> is enabled then <port_number> is converted into network
// byte order, otherwise it is assumed to be in network byte order
diff --git a/ace/OS.h b/ace/OS.h
index c2a4e45a98b..7ae0babeda5 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -4762,11 +4762,14 @@ private:
int error_;
};
-// @@ We might want a smarter way to do this...
-#if !defined (SERVICETYPE)
-typedef u_long ACE_SERVICE_TYPE;
-#else
+#if defined (ACE_HAS_WINNT5)
typedef SERVICETYPE ACE_SERVICE_TYPE;
+typedef GROUP ACE_SOCK_GROUP;
+typedef WSAPROTOCOL_INFO ACE_Protocol_Info;
+#else
+typedef u_long ACE_SOCK_GROUP;
+typedef u_long ACE_SERVICE_TYPE;
+typedef u_long ACE_Protocol_Info;
#endif /* SERVICETYPE */
class ACE_Export ACE_Flow_Spec
@@ -4903,7 +4906,7 @@ typedef int (*ACE_QOS_CONDITION_FUNC) (iovec *caller_id,
ACE_QoS *group_socket_qos,
iovec *callee_id,
iovec *callee_data,
- u_long *g, /* unused */
+ ACE_SOCK_GROUP *g,
u_long callbackdata);
// Callback function that's used by the QoS-enabled <ACE_OS::ioctl>
@@ -5706,7 +5709,9 @@ public:
struct sockaddr *addr,
int *addrlen,
ACE_Accept_QoS_Params qos_params);
- // QoS-enabled <accept>.
+ // QoS-enabled <accept>, which passes <qos_params> to <accept>. If
+ // the OS platform doesn't support QoS-enabled <accept> then the
+ // <qos_params> are ignored and the BSD-style <accept> is called.
static int bind (ACE_HANDLE s,
struct sockaddr *name,
int namelen);
@@ -5718,7 +5723,9 @@ public:
const sockaddr *addr,
int addrlen,
ACE_Connect_QoS_Params qos_params);
- // QoS-enabled <connect>.
+ // QoS-enabled <connect>, which passes <qos_params> to <connect>.
+ // If the OS platform doesn't support QoS-enabled <connect> then the
+ // <qos_params> are ignored and the BSD-style <connect> is called.
static int closesocket (ACE_HANDLE s);
static struct hostent *gethostbyaddr (const char *addr,
@@ -5813,6 +5820,16 @@ public:
static ACE_HANDLE socket (int domain,
int type,
int proto);
+ // Create a BSD-style socket (no QoS).
+ static ACE_HANDLE socket (int domain,
+ int type,
+ int proto,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags);
+ // Create a QoS-enabled socket. If the OS platform doesn't support
+ // QoS-enabled <socket> then the BSD-style <socket> is called.
+
static int socketpair (int domain,
int type,
int protocol,
diff --git a/ace/OS.i b/ace/OS.i
index 519dee08188..b0b21b70792 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -5109,11 +5109,46 @@ ACE_OS::shutdown (ACE_HANDLE handle, int how)
}
ACE_INLINE ACE_HANDLE
-ACE_OS::socket (int domain, int type, int proto)
+ACE_OS::socket (int domain,
+ int type,
+ int proto)
{
ACE_TRACE ("ACE_OS::socket");
- ACE_SOCKCALL_RETURN (::socket (domain, type, proto),
- ACE_HANDLE, ACE_INVALID_HANDLE);
+ ACE_SOCKCALL_RETURN (::socket (domain,
+ type,
+ proto),
+ ACE_HANDLE,
+ ACE_INVALID_HANDLE);
+}
+
+ACE_INLINE ACE_HANDLE
+ACE_OS::socket (int domain,
+ int type,
+ int proto,
+ ACE_Protocol_Info *protocolinfo,
+ ACE_SOCK_GROUP g,
+ u_long flags)
+{
+ ACE_TRACE ("ACE_OS::socket");
+
+#if defined (ACE_HAS_WINSOCK2)
+ ACE_SOCKCALL_RETURN (::WSASocket (domain,
+ type,
+ proto,
+ protocolinfo,
+ g,
+ flags),
+ ACE_HANDLE,
+ ACE_INVALID_HANDLE);
+#else
+ ACE_UNUSED_ARG (protocolinfo);
+ ACE_UNUSED_ARG (g);
+ ACE_UNUSED_ARG (flags);
+
+ return ACE_OS::socket (domain,
+ type,
+ proto),
+#endif /* ACE_HAS_WINSOCK2 */
}
ACE_INLINE int
diff --git a/ace/SOCK_Dgram_Mcast.cpp b/ace/SOCK_Dgram_Mcast.cpp
index 1a30f757e43..060aab333da 100644
--- a/ace/SOCK_Dgram_Mcast.cpp
+++ b/ace/SOCK_Dgram_Mcast.cpp
@@ -26,29 +26,25 @@ ACE_SOCK_Dgram_Mcast::ACE_SOCK_Dgram_Mcast (void)
}
int
-ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr,
- int reuse_addr,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not
- // names for network interfaces
- long net_if,
-#else
- const ASYS_TCHAR *net_if,
-#endif /* defined (ACE_PSOS) */
- int protocol_family,
- int protocol)
+ACE_SOCK_Dgram_Mcast::subscribe_i (const ACE_INET_Addr &mcast_addr,
+ int reuse_addr,
+ const ASYS_TCHAR *net_if,
+ int protocol_family,
+ int protocol)
{
- ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe");
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::subscribe_i");
- // Make a local copy of address to use in sends.
+ // Make a copy of address to use in the <send> methods.
this->mcast_addr_.set (mcast_addr);
- // Only perform the open() initialization if we haven't been opened
- // previously.
+ // Only perform the <open> initialization if we haven't been opened
+ // earlier.
if (this->get_handle () == ACE_INVALID_HANDLE)
{
- if (ACE_SOCK::open (SOCK_DGRAM, protocol_family,
- protocol, reuse_addr) == -1)
+ if (ACE_SOCK::open (SOCK_DGRAM,
+ protocol_family,
+ protocol,
+ reuse_addr) == -1)
return -1;
int one = 1;
@@ -67,61 +63,67 @@ ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr,
#endif /* SO_REUSEPORT */
// Create an address to bind the socket to.
-
ACE_INET_Addr local;
if (local.set (this->mcast_addr_.get_port_number ()) == -1)
return -1;
- else if (ACE_SOCK_Dgram::shared_open (local, protocol_family) == -1)
+ else if (ACE_SOCK_Dgram::shared_open (local,
+ protocol_family) == -1)
return -1;
}
#if defined (ACE_WIN32)
- // Windows NT's winsock has trouble with multicast subscribes in the presence
- // of multiple network interfaces when the IP address is given as INADDR_ANY.
- // It will pick the first interface and only accept mcast there. So, to work
- // around this, cycle through all of the interfaces known and subscribe to
- // all the non-loopback ones.
- // Note that this only needs to be done on NT, but there's no way to tell
- // at this point if the code will be running on NT - only if it is compiled
- // for NT-only or for NT/95, and that doesn't really help us. It doesn't
- // hurt to do this on Win95, it's just a little slower than it normally
- // would be.
+ // Windows NT's winsock has trouble with multicast subscribes in the
+ // presence of multiple network interfaces when the IP address is
+ // given as INADDR_ANY. It will pick the first interface and only
+ // accept mcast there. So, to work around this, cycle through all
+ // of the interfaces known and subscribe to all the non-loopback
+ // ones.
+ //
+ // Note that this only needs to be done on NT, but there's no way to
+ // tell at this point if the code will be running on NT - only if it
+ // is compiled for NT-only or for NT/95, and that doesn't really
+ // help us. It doesn't hurt to do this on Win95, it's just a little
+ // slower than it normally would be.
//
- // NOTE - get_ip_interfaces doesn't always get all of the interfaces. In
- // particular, it may not get a PPP interface. This is a limitation of the
- // way get_ip_interfaces works with MSVC. The reliable way of getting the
- // interface list is available only with MSVC 5.
+ // NOTE - <ACE::get_ip_interfaces> doesn't always get all of the
+ // interfaces. In particular, it may not get a PPP interface. This
+ // is a limitation of the way <ACE::get_ip_interfaces> works with
+ // MSVC. The reliable way of getting the interface list is
+ // available only with MSVC 5.
if (net_if == 0)
{
ACE_INET_Addr *if_addrs = 0;
- size_t if_cnt, nr_subscribed;
+ size_t if_cnt;
- if (ACE::get_ip_interfaces(if_cnt, if_addrs) != 0)
+ if (ACE::get_ip_interfaces (if_cnt,
+ if_addrs) != 0)
return -1;
- nr_subscribed = 0;
+ size_t nr_subscribed = 0;
if (if_cnt < 2)
{
- if (this->subscribe(mcast_addr,
- reuse_addr,
- ASYS_WIDE_STRING ("0.0.0.0"),
- protocol_family,
- protocol) == 0)
+ if (this->subscribe (mcast_addr,
+ reuse_addr,
+ ASYS_WIDE_STRING ("0.0.0.0"),
+ protocol_family,
+ protocol) == 0)
++nr_subscribed;
}
else
while (if_cnt > 0)
{
- --if_cnt; // Convert to 0-based for indexing, next loop check
+ --if_cnt;
+
+ // Convert to 0-based for indexing, next loop check.
if (if_addrs[if_cnt].get_ip_address() == INADDR_LOOPBACK)
continue;
- if (this->subscribe(mcast_addr,
- reuse_addr,
- ASYS_WIDE_STRING (if_addrs[if_cnt].get_host_addr()),
- protocol_family,
- protocol) == 0)
+ if (this->subscribe (mcast_addr,
+ reuse_addr,
+ ASYS_WIDE_STRING (if_addrs[if_cnt].get_host_addr()),
+ protocol_family,
+ protocol) == 0)
++nr_subscribed;
}
@@ -138,56 +140,99 @@ ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr,
#endif /* ACE_WIN32 */
// Create multicast request.
- if (this->make_multicast_address (this->mcast_addr_, net_if) == -1)
+ if (this->make_multicast_address (this->mcast_addr_,
+ net_if) == -1)
return -1;
+ else
+ return 0;
+}
+int
+ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr,
+ int reuse_addr,
+ const ASYS_TCHAR *net_if,
+ int protocol_family,
+ int protocol)
+{
+ if (this->subscribe_i (mcast_addr,
+ reuse_addr,
+ net_if,
+ protocol_family,
+ protocol) == -1)
+ return -1;
+
// Tell network device driver to read datagrams with a
- // multicast_address address.
+ // multicast_address IP interface.
else if (this->ACE_SOCK::set_option (IPPROTO_IP,
IP_ADD_MEMBERSHIP,
- &multicast_address_,
- sizeof multicast_address_) == -1)
+ &this->mcast_request_if_,
+ sizeof this->mcast_request_if_) == -1)
return -1;
- return 0;
+ else
+ return 0;
}
int
-ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not
- // names for network interfaces
- long net_if,
-#else
- const ASYS_TCHAR *net_if,
-#endif /* defined (ACE_PSOS) */
- int protocol_family,
- int protocol)
+ACE_SOCK_Dgram_Mcast::subscribe (const ACE_INET_Addr &mcast_addr,
+ ACE_Connect_QoS_Params qos_params,
+ int reuse_addr,
+ const ASYS_TCHAR *net_if,
+ int protocol_family,
+ int protocol)
{
- ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe");
+ if (this->subscribe_i (mcast_addr,
+ reuse_addr,
+ net_if,
+ protocol_family,
+ protocol) == -1)
+ return -1;
+
+ // Tell network device driver to read datagrams with a
+ // <mcast_request_if_> IP interface.
+ else if (ACE_OS::join_leaf (this->get_handle (),
+ ACE_reinterpret_cast (const sockaddr *,
+ &this->mcast_request_if_.imr_multiaddr),
+ sizeof this->mcast_request_if_.imr_multiaddr,
+ qos_params) == -1)
+ return -1;
+ else
+ return 0;
+}
+int
+ACE_SOCK_Dgram_Mcast::unsubscribe_i (const ACE_INET_Addr &mcast_addr,
+ const ASYS_TCHAR *net_if,
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe_i");
#if defined (ACE_WIN32)
- // Windows NT's winsock has trouble with multicast subscribes in the presence
- // of multiple network interfaces when the IP address is given as INADDR_ANY.
- // It will pick the first interface and only accept mcast there. So, to work
- // around this, cycle through all of the interfaces known and subscribe to
- // all the non-loopback ones.
- // Note that this only needs to be done on NT, but there's no way to tell
- // at this point if the code will be running on NT - only if it is compiled
- // for NT-only or for NT/95, and that doesn't really help us. It doesn't
- // hurt to do this on Win95, it's just a little slower than it normally
- // would be.
+ // Windows NT's winsock has trouble with multicast subscribes in the
+ // presence of multiple network interfaces when the IP address is
+ // given as INADDR_ANY. It will pick the first interface and only
+ // accept mcast there. So, to work around this, cycle through all
+ // of the interfaces known and subscribe to all the non-loopback
+ // ones.
+ //
+ // Note that this only needs to be done on NT, but there's no way to
+ // tell at this point if the code will be running on NT - only if it
+ // is compiled for NT-only or for NT/95, and that doesn't really
+ // help us. It doesn't hurt to do this on Win95, it's just a little
+ // slower than it normally would be.
//
- // NOTE - get_ip_interfaces doesn't always get all of the interfaces. In
- // particular, it may not get a PPP interface. This is a limitation of the
- // way get_ip_interfaces works with MSVC. The reliable way of getting the
- // interface list is available only with MSVC 5.
+ // NOTE - <ACE::get_ip_interfaces> doesn't always get all of the
+ // interfaces. In particular, it may not get a PPP interface. This
+ // is a limitation of the way <ACE::get_ip_interfaces> works with
+ // MSVC. The reliable way of getting the interface list is
+ // available only with MSVC 5.
if (net_if == 0)
{
ACE_INET_Addr *if_addrs = 0;
- size_t if_cnt;
+ size_t if_cnt;
- if (ACE::get_ip_interfaces(if_cnt, if_addrs) != 0)
+ if (ACE::get_ip_interfaces (if_cnt,
+ if_addrs) != 0)
return -1;
size_t nr_unsubscribed = 0;
@@ -203,7 +248,8 @@ ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr,
else
while (if_cnt > 0)
{
- --if_cnt; // Convert to 0-based for indexing, next loop check
+ --if_cnt;
+ // Convert to 0-based for indexing, next loop check
if (if_addrs[if_cnt].get_ip_address() == INADDR_LOOPBACK)
continue;
if (this->unsubscribe (mcast_addr,
@@ -230,15 +276,32 @@ ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr,
ip_mreq multicast_address;
// Create multicast request.
- if (this->make_multicast_address_i (mcast_addr, multicast_address, net_if) == -1)
+ if (this->make_multicast_address_i (mcast_addr,
+ multicast_address,
+ net_if) == -1)
return -1;
+ else
+ return 0;
+}
+int
+ACE_SOCK_Dgram_Mcast::unsubscribe (const ACE_INET_Addr &mcast_addr,
+ const ASYS_TCHAR *net_if,
+ int protocol_family,
+ int protocol)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe");
+ if (this->unsubscribe_i (mcast_addr,
+ net_if,
+ protocol_family,
+ protocol) == -1)
+ return -1;
// Tell network device driver to read datagrams with a
// multicast_address address.
- else if (this->ACE_SOCK::set_option (IPPROTO_IP,
- IP_DROP_MEMBERSHIP,
- &multicast_address,
- sizeof multicast_address) == -1)
+ else if (ACE_SOCK::set_option (IPPROTO_IP,
+ IP_DROP_MEMBERSHIP,
+ &this->mcast_request_if_,
+ sizeof this->mcast_request_if_) == -1)
return -1;
return 0;
}
@@ -249,76 +312,64 @@ ACE_SOCK_Dgram_Mcast::unsubscribe (void)
ACE_TRACE ("ACE_SOCK_Dgram_Mcast::unsubscribe");
return this->ACE_SOCK::set_option (IPPROTO_IP,
IP_DROP_MEMBERSHIP,
- &multicast_address_,
- sizeof multicast_address_);
-}
-
-int
-ACE_SOCK_Dgram_Mcast::make_multicast_address (const ACE_INET_Addr &mcast_addr,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not
- // names for network interfaces
- long net_if
-#else
- const ASYS_TCHAR *net_if
-#endif /* defined (ACE_PSOS) */
- )
-{
- ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_address");
-
- return this->make_multicast_address_i (mcast_addr,
- this->multicast_address_,
- net_if );
+ &this->mcast_request_if_,
+ sizeof this->mcast_request_if_);
}
int
ACE_SOCK_Dgram_Mcast::make_multicast_address_i (const ACE_INET_Addr &mcast_addr,
ip_mreq &multicast_address ,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not
- // names for network interfaces
- long net_if
-#else
- const ASYS_TCHAR *net_if
-#endif /* defined (ACE_PSOS) */
- )
+ const ASYS_TCHAR *net_if)
{
if (net_if != 0)
{
-#if !defined (ACE_WIN32)
+#if defined (ACE_WIN32)
+ // This port number is not necessary, just convenient
+ ACE_INET_Addr interface_addr;
+ if (interface_addr.set (mcast_addr.get_port_number (),
+ net_if) == -1)
+ return -1;
+ multicast_address.imr_interface.s_addr =
+ htonl (interface_addr.get_ip_address ());
+#else
struct ifreq if_address;
#if defined (ACE_PSOS)
- // look up the interface by number, not name
- if_address.ifr_ifno = net_if;
+ // Look up the interface by number, not name.
+ if_address.ifr_ifno = ACE_OS::atoi (net_if);
#else
ACE_OS::strcpy (if_address.ifr_name, net_if);
#endif /* defined (ACE_PSOS) */
- if (ACE_OS::ioctl (this->get_handle (), SIOCGIFADDR, &if_address) == -1)
+ if (ACE_OS::ioctl (this->get_handle (),
+ SIOCGIFADDR,
+ &if_address) == -1)
return -1;
struct sockaddr_in *socket_address;
socket_address = ACE_reinterpret_cast(sockaddr_in *,
&if_address.ifr_addr);
multicast_address.imr_interface.s_addr = socket_address->sin_addr.s_addr;
-#else
- // This port number is not necessary, just convenient
- ACE_INET_Addr interface_addr;
- if (interface_addr.set (mcast_addr.get_port_number (),
- net_if) == -1)
- return -1;
- multicast_address.imr_interface.s_addr =
- htonl (interface_addr.get_ip_address ());
#endif /* ACE_WIN32 */
}
else
multicast_address.imr_interface.s_addr = INADDR_ANY;
#if defined (ACE_PSOS) && !defined (ACE_PSOS_TM) && !defined (ACE_PSOS_DIAB_MIPS)
- multicast_address.imr_mcastaddr.s_addr = htonl(mcast_addr.get_ip_address());
+ multicast_address.imr_mcastaddr.s_addr = htonl (mcast_addr.get_ip_address());
#else
multicast_address.imr_multiaddr.s_addr = htonl (mcast_addr.get_ip_address ());
#endif /* defined (ACE_PSOS) */
return 0;
}
+
+int
+ACE_SOCK_Dgram_Mcast::make_multicast_address (const ACE_INET_Addr &mcast_addr,
+ const ASYS_TCHAR *net_if)
+{
+ ACE_TRACE ("ACE_SOCK_Dgram_Mcast::make_multicast_address");
+
+ return this->make_multicast_address_i (mcast_addr,
+ this->mcast_request_if_,
+ net_if );
+}
diff --git a/ace/SOCK_Dgram_Mcast.h b/ace/SOCK_Dgram_Mcast.h
index 55d3ba832dd..2bd48d05d82 100644
--- a/ace/SOCK_Dgram_Mcast.h
+++ b/ace/SOCK_Dgram_Mcast.h
@@ -10,8 +10,9 @@
// SOCK_Dgram_Mcast.h
//
// = AUTHORS
-// Irfan Pyrali (ip1@cs.wustl.edu)
-// Tim Harrison (harrison@cs.wustl.edu)
+// Irfan Pyrali <irfan@cs.wustl.edu>,
+// Tim Harrison <harrison@cs.wustl.edu>, and
+// Douglas C. Schmidt <schmidt@cs.wustl.edu>
//
// ============================================================================
@@ -29,15 +30,15 @@
class ACE_Export ACE_SOCK_Dgram_Mcast : public ACE_SOCK_Dgram
{
// = TITLE
- // Defines the member functions for the ACE SOCK wrapper
- // multicast abstraction.
+ // Defines the member functions for the ACE socket wrapper
+ // for UDP/IP multicast.
public:
// = Initialization routine.
ACE_SOCK_Dgram_Mcast (void);
- // Note that there is no <open>. This cannot be used unless you
- // subscribe to the multicast group. If you just want to send (and
- // not listen) to the multicast group, use ACE_SOCK_Dgram or
- // ACE_SOCK_CODgram.
+ // Note that there is no public <open> method. Therefore, this
+ // class cannot be used unless you <subscribe> to a multicast group.
+ // If you just want to send (and not listen) to a multicast group,
+ // use <ACE_SOCK_Dgram> or <ACE_SOCK_CODgram> instead.
~ACE_SOCK_Dgram_Mcast (void);
// Default dtor.
@@ -46,41 +47,62 @@ public:
int subscribe (const ACE_INET_Addr &mcast_addr,
int reuse_addr = 1,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not names for network interfaces
- long net_if = 0,
-#else
const ASYS_TCHAR *net_if = 0,
-#endif /* defined (ACE_PSOS) */
int protocol_family = PF_INET,
int protocol = 0);
- // Join a multicast group by telling the network interface device
- // driver to accept datagrams with ACE_INET_Addr &mcast_addr
- // multicast addresses.
+ // This is a BSD-style method for joining a multicast group (i.e.,
+ // no QoS). 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>.
//
- // If you have called open already, subscribe closes the socket and
- // opens a new socket bound to the mcast_addr.
+ // 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 on error, else 0.
+ //
+ // 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>.
+
+ int subscribe (const ACE_INET_Addr &mcast_addr,
+ ACE_Connect_QoS_Params qos_params,
+ int reuse_addr = 1,
+ const ASYS_TCHAR *net_if = 0,
+ int protocol_family = PF_INET,
+ int protocol = 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>.
//
- // Interface is hardware specific. use netstat -i to find whether
- // your interface is, say, le0 or something else. If net_if == 0,
- // subscribe uses the default mcast interface.
- // Returns: -1 on error, else 0.
+ // 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 on error, else 0.
+ //
+ // 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>.
int unsubscribe (const ACE_INET_Addr &mcast_addr,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not names for network interfaces
- long net_if = 0,
-#else
const ASYS_TCHAR *net_if = 0,
-#endif /* defined (ACE_PSOS) */
int protocol_family = PF_INET,
int protocol = 0);
- // Leave a multicast group.
- //
- // Interface is hardware specific. use netstat -i to find whether
- // your interface is, say, le0 or something else. If net_if == 0,
- // subscribe uses the default mcast interface.
- // Returns: -1 on error, else 0.
+ // Leave a multicast group identified by <mcast_addr>. The <net_if>
+ // interface is hardware specific. Use something like "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 on error, else 0.
+ //
+ // 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>.
int unsubscribe (void);
// Unsubscribe from a multicast group. Returns 0 on success, -1 on
@@ -98,11 +120,12 @@ public:
// Send <n> <iovecs>.
// = Options.
- int set_option (int option, char optval);
- // Set an ip option that takes a char as input.
- // e.g. IP_MULTICAST_LOOP. This is just a nice interface to a
- // subset of possible setsockopt/ACE_SOCK::set_option calls Returns
- // 0 on success, -1 on failure.
+ int set_option (int option,
+ char optval);
+ // Set an ip option that takes a char as input, such as
+ // <IP_MULTICAST_LOOP>. This is just a more concise nice interface
+ // to a subset of possible <ACE_SOCK::set_option> calls. Returns 0
+ // on success, -1 on failure.
void dump (void) const;
// Dump the state of an object.
@@ -114,10 +137,24 @@ private:
ACE_HANDLE open (const ACE_Addr &local,
int protocol_family = PF_INET,
int protocol = 0);
- // disable public use of ACE_SOCK_Dgram::open ()
-
- // = Disable public use of ACE_SOCK_Dgram::sends and force
- // ACE_SOCK_Dgram_Mcast::sends inline
+ // Disable public use of <ACE_SOCK_Dgram::open> to ensure the class
+ // is used properly.
+
+ int subscribe_i (const ACE_INET_Addr &mcast_addr,
+ int reuse_addr = 1,
+ const ASYS_TCHAR *net_if = 0,
+ int protocol_family = PF_INET,
+ int protocol = 0);
+ // Implementation method of <subscribe>.
+
+ int unsubscribe_i (const ACE_INET_Addr &mcast_addr,
+ const ASYS_TCHAR *net_if = 0,
+ int protocol_family = PF_INET,
+ int protocol = 0);
+ // Implementation method of <unsubscribe>.
+
+ // = Disable public use of <ACE_SOCK_Dgram::send>s and force
+ // <ACE_SOCK_Dgram_Mcast::send>s inline.
ssize_t send (const void *buf,
size_t n,
const ACE_Addr &addr,
@@ -128,37 +165,25 @@ private:
int flags = 0) const;
int make_multicast_address (const ACE_INET_Addr &mcast_addr,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not
- // names for network interfaces
- long net_if = 0
-#else
- const ASYS_TCHAR *net_if = ASYS_TEXT ("le0")
-#endif /* defined (ACE_PSOS) */
- );
- // Initialize the <multicast_addres_ field>
+ const ASYS_TCHAR *net_if = ASYS_TEXT ("le0"));
+ // Initialize the <multicast_address_> IP address.
int make_multicast_address_i (const ACE_INET_Addr &mcast_addr,
ip_mreq& multicast_address,
-#if defined (ACE_PSOS)
- // pSOS supports numbers, not
- // names for network interfaces
- long net_if = 0
-#else
- const ASYS_TCHAR *net_if = ASYS_TEXT ("le0")
-#endif /* defined (ACE_PSOS) */
- );
- // Initialize a multicast address.
+ const ASYS_TCHAR *net_if = ASYS_TEXT ("le0"));
+ // Initialize a multicast address. This method factors out common
+ // code called by <make_multicast_address> and <subscribe>.
ACE_INET_Addr mcast_addr_;
- // Multicast group address.
+ // A copy of the address that we use to <send> multicasts.
- ip_mreq multicast_address_;
- // IP address.
+ ip_mreq mcast_request_if_;
+ // IP address of the interface upon which we're receiving
+ // multicasts.
};
#if !defined (ACE_LACKS_INLINE_FUNCTIONS)
#include "ace/SOCK_Dgram_Mcast.i"
-#endif
+#endif /* ACE_LACKS_INLINE_FUNCTIONS */
#endif /* ACE_SOCK_DGRAM_MCAST_H */