summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2010-11-05 14:12:43 +0000
committerSteve Huston <shuston@riverace.com>2010-11-05 14:12:43 +0000
commit150834f17e31a49c560d1ce76960ad7c658ac852 (patch)
tree90edac6a3b58eef030b116cc2f971d09feabfdf6
parent06efde616163509c5336caf2f19739b9715c7fab (diff)
downloadATCD-150834f17e31a49c560d1ce76960ad7c658ac852.tar.gz
ChangeLogTag:Thu Nov 4 15:17:51 UTC 2010 Steve Huston <shuston@riverace.com>
-rw-r--r--ChangeLog4
-rw-r--r--ace/INET_Addr.cpp23
-rw-r--r--tests/INET_Addr_Test.cpp25
3 files changed, 43 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index cfbdd951803..b97f81ef8f4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,4 @@
-Tue Nov 2 00:18:34 UTC 2010 Steve Huston <shuston@riverace.com>
+Thu Nov 4 15:17:51 UTC 2010 Steve Huston <shuston@riverace.com>
* ace/INET_Addr.cpp (set): For platforms that have the GNU-extended
gethostbyname2_r() function, use it instead of getaddrinfo() for
@@ -6,6 +6,8 @@ Tue Nov 2 00:18:34 UTC 2010 Steve Huston <shuston@riverace.com>
hugely slower than gethostbyname2 on large vlans. The alternate
code is used if ACE_HAS_GETHOSTBYNAME2 is set in config.h.
+ * tests/INET_Addr_Test.cpp: Add some IPv6 address and name lookups.
+
Thu Oct 28 17:45:10 UTC 2010 Steve Huston <shuston@riverace.com>
* ace/INET_Addr.cpp (set): Corrected ACE_HAS_IPV6 checks made in
diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp
index 54bc4f74dd9..dd1dc25ea75 100644
--- a/ace/INET_Addr.cpp
+++ b/ace/INET_Addr.cpp
@@ -350,17 +350,26 @@ ACE_INET_Addr::set (u_short port_number,
{
# if defined (ACE_HAS_GETHOSTBYNAME2)
hostent hentry;
+ hostent *hp;
ACE_HOSTENT_DATA buf;
int h_error = 0; // Not the same as errno!
- hostent *hp = ::gethostbyname2_r (host_name, AF_INET6, &hentry,
- buf, &h_error);
- if (hp != 0)
+ if (0 == ::gethostbyname2_r (host_name, AF_INET6, &hentry,
+ buf, sizeof(buf), &hp, &h_error))
{
- this->set_type (hp->h_addrtype);
- this->set_addr (hp->h_addr, hp->h_length);
- this->set_port_number (port_number, encode);
- return 0;
+ if (hp != 0)
+ {
+ struct sockaddr_in6 v6;
+ ACE_OS::memset (&v6, 0, sizeof (v6));
+ v6.sin6_family = AF_INET6;
+ (void) ACE_OS::memcpy ((void *) &v6.sin6_addr,
+ hp->h_addr,
+ hp->h_length);
+ this->set_type (hp->h_addrtype);
+ this->set_addr (&v6, hp->h_length);
+ this->set_port_number (port_number, encode);
+ return 0;
+ }
}
errno = h_error;
if (address_family == AF_INET6)
diff --git a/tests/INET_Addr_Test.cpp b/tests/INET_Addr_Test.cpp
index 3ffd482451e..4a3f1ca6e51 100644
--- a/tests/INET_Addr_Test.cpp
+++ b/tests/INET_Addr_Test.cpp
@@ -220,8 +220,31 @@ int run_main (int argc, ACE_TCHAR *argv[])
status = 1;
}
}
- }
+ const char *ipv6_names[] = {
+ "naboo.dre.vanderbilt.edu",
+ "v6.ipv6-test.com",
+ 0
+ };
+ for (int i=0; ipv6_names[i] != 0; i++)
+ {
+ ACE_INET_Addr addr (80, ipv6_names[i]);
+ status |= check_type_consistency (addr);
+
+ if (0 != ACE_OS::strcmp (addr.get_host_name (), ipv6_names[i]))
+ {
+ ACE_ERROR ((LM_WARNING,
+ ACE_TEXT ("IPv6 name mismatch: %s (%s) != %s\n"),
+ addr.get_host_name (),
+ addr.get_host_addr (),
+ ipv6_names[i]));
+ status = 1;
+ }
+ }
+ }
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("IPv6 tests done\n")));
+#else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_HAS_IPV6 not set; no IPv6 tests run\n")));
#endif
struct Address loopback_addresses[] =