summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2018-02-02 18:46:26 -0500
committerSteve Huston <shuston@riverace.com>2018-02-02 18:46:26 -0500
commit03442547cad74d926f92dccbc3cc031bdc6b44ec (patch)
treea8b5af9076b0b52110bbadf0a28649c9a0c29cce
parent4018771ea5d21d85fd3dcb62a44202b90f6990ec (diff)
downloadATCD-03442547cad74d926f92dccbc3cc031bdc6b44ec.tar.gz
Add ipv6_only support to ACE_SOCK_Dgram
-rw-r--r--ACE/ace/SOCK_Dgram.cpp41
-rw-r--r--ACE/ace/SOCK_Dgram.h16
2 files changed, 43 insertions, 14 deletions
diff --git a/ACE/ace/SOCK_Dgram.cpp b/ACE/ace/SOCK_Dgram.cpp
index 04889eb8c3d..db332165be8 100644
--- a/ACE/ace/SOCK_Dgram.cpp
+++ b/ACE/ace/SOCK_Dgram.cpp
@@ -104,13 +104,28 @@ ACE_SOCK_Dgram::recv (iovec *io_vec,
int
ACE_SOCK_Dgram::shared_open (const ACE_Addr &local,
- int protocol_family)
+ int protocol_family,
+ int ipv6_only)
{
ACE_TRACE ("ACE_SOCK_Dgram::shared_open");
bool error = false;
+#if !defined (ACE_HAS_IPV6) || (!defined (IPPROTO_IPV6) || !defined (IPV6_V6ONLY))
+ ACE_UNUSED_ARG (ipv6_only);
+#endif /* !defined (ACE_HAS_IPV6) || (!defined (IPPROTO_IPV6) || !defined (IPV6_V6ONLY)) */
if (local == ACE_Addr::sap_any)
{
+#if defined (ACE_HAS_IPV6) && defined (IPPROTO_IPV6) && defined (IPV6_V6ONLY)
+ int setting = !!ipv6_only;
+ if (-1 == ACE_OS::setsockopt (this->get_handle (),
+ IPPROTO_IPV6,
+ IPV6_V6ONLY,
+ (char *)&setting,
+ sizeof (setting)))
+ error = true;
+ else
+#endif /* ACE_HAS_IPV6 && IPPROTO_IPV6 && IPV6_V6ONLY */
+
if (protocol_family == PF_INET
#if defined (ACE_HAS_IPV6)
|| protocol_family == PF_INET6
@@ -141,7 +156,8 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local,
ACE_Protocol_Info *protocolinfo,
ACE_SOCK_GROUP g,
u_long flags,
- int reuse_addr)
+ int reuse_addr,
+ int ipv6_only)
{
if (ACE_SOCK::open (SOCK_DGRAM,
protocol_family,
@@ -152,7 +168,8 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local,
reuse_addr) == -1)
return -1;
else if (this->shared_open (local,
- protocol_family) == -1)
+ protocol_family,
+ ipv6_only) == -1)
return -1;
else
return 0;
@@ -164,7 +181,8 @@ int
ACE_SOCK_Dgram::open (const ACE_Addr &local,
int protocol_family,
int protocol,
- int reuse_addr)
+ int reuse_addr,
+ int ipv6_only)
{
ACE_TRACE ("ACE_SOCK_Dgram::open");
@@ -186,7 +204,8 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local,
return -1;
else
return this->shared_open (local,
- protocol_family);
+ protocol_family,
+ ipv6_only);
}
// Here's the general-purpose constructor used by a connectionless
@@ -195,14 +214,16 @@ ACE_SOCK_Dgram::open (const ACE_Addr &local,
ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local,
int protocol_family,
int protocol,
- int reuse_addr)
+ int reuse_addr,
+ int ipv6_only)
{
ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
if (this->open (local,
protocol_family,
protocol,
- reuse_addr) == -1)
+ reuse_addr,
+ ipv6_only) == -1)
ACELIB_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_SOCK_Dgram")));
@@ -214,7 +235,8 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local,
ACE_Protocol_Info *protocolinfo,
ACE_SOCK_GROUP g,
u_long flags,
- int reuse_addr)
+ int reuse_addr,
+ int ipv6_only)
{
ACE_TRACE ("ACE_SOCK_Dgram::ACE_SOCK_Dgram");
if (this->open (local,
@@ -223,7 +245,8 @@ ACE_SOCK_Dgram::ACE_SOCK_Dgram (const ACE_Addr &local,
protocolinfo,
g,
flags,
- reuse_addr) == -1)
+ reuse_addr,
+ ipv6_only) == -1)
ACELIB_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_SOCK_Dgram")));
diff --git a/ACE/ace/SOCK_Dgram.h b/ACE/ace/SOCK_Dgram.h
index b48f748d92a..ad8e2cbcb61 100644
--- a/ACE/ace/SOCK_Dgram.h
+++ b/ACE/ace/SOCK_Dgram.h
@@ -45,7 +45,8 @@ public:
ACE_SOCK_Dgram (const ACE_Addr &local,
int protocol_family = ACE_PROTOCOL_FAMILY_INET,
int protocol = 0,
- int reuse_addr = 0);
+ int reuse_addr = 0,
+ int ipv6_only = 0);
/**
* This is a QoS-enabed method for initiating a socket dgram that
@@ -58,14 +59,16 @@ public:
ACE_Protocol_Info *protocolinfo,
ACE_SOCK_GROUP g = 0,
u_long flags = 0,
- int reuse_addr = 0);
+ int reuse_addr = 0,
+ int ipv6_only = 0);
/// This is a BSD-style method (i.e., no QoS) for initiating a socket
/// dgram that will accept datagrams at the <local> address.
int open (const ACE_Addr &local,
int protocol_family = ACE_PROTOCOL_FAMILY_INET,
int protocol = 0,
- int reuse_addr = 0);
+ int reuse_addr = 0,
+ int ipv6_only = 0);
/**
* This is a QoS-enabed method for initiating a socket dgram that
@@ -78,7 +81,8 @@ public:
ACE_Protocol_Info *protocolinfo,
ACE_SOCK_GROUP g = 0,
u_long flags = 0,
- int reuse_addr = 0);
+ int reuse_addr = 0,
+ int ipv6_only = 0);
/// Default dtor.
~ACE_SOCK_Dgram (void);
@@ -206,7 +210,9 @@ public:
protected:
/// Open is shared by this and by <LSOCK_Dgram>.
- int shared_open (const ACE_Addr &local, int protocol_family);
+ int shared_open (const ACE_Addr &local,
+ int protocol_family,
+ int ipv6_only = 0);
/// Create a multicast addr/if pair, in format useful for system calls.
/// If mreq param is NULL, just verify the passed addr/interface specs.