summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjha <jha@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-02-08 19:31:36 +0000
committerjha <jha@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-02-08 19:31:36 +0000
commit59996bbaa86d8ffa68a04b0ad23b6ef7ef0d1eb6 (patch)
tree1d5416df5b576a7bc8bdc6a3ebce3d26efd12e06
parentff4c83f81006c16aa0ebecb3a6f6f1237adf7dc9 (diff)
downloadATCD-59996bbaa86d8ffa68a04b0ad23b6ef7ef0d1eb6.tar.gz
Fixed up get_host_addr. This is another checkpoint checkin to test on
other platforms.
-rw-r--r--ace/INET_Addr.cpp20
-rw-r--r--ace/INET_Addr.h59
2 files changed, 40 insertions, 39 deletions
diff --git a/ace/INET_Addr.cpp b/ace/INET_Addr.cpp
index 9d53fd22ac9..54141ac9522 100644
--- a/ace/INET_Addr.cpp
+++ b/ace/INET_Addr.cpp
@@ -280,7 +280,6 @@ ACE_INET_Addr::set (u_short port_number,
this->ACE_Addr::base_set (ACE_AF_INET, sizeof this->inet_addr_);
(void) ACE_OS::memset ((void *) &this->inet_addr_, 0, sizeof
this->inet_addr_);
- printf("in set(port,hostname)\n");
// Yow, someone gave us a NULL host_name!
if (host_name == 0)
{
@@ -369,6 +368,7 @@ ACE_INET_Addr::set (const char port_name[],
// Initializes a ACE_INET_Addr from a <port_name> and an Internet
// address.
+#if 0
int
ACE_INET_Addr::set (const char port_name[],
ace_in_addr_t inet_address,
@@ -395,6 +395,7 @@ ACE_INET_Addr::set (const char port_name[],
return this->set (sp->s_port, inet_address, 0);
#endif /* VXWORKS */
}
+#endif
// Creates a ACE_INET_Addr from a PORT_NUMBER and the remote
// HOST_NAME.
@@ -690,11 +691,13 @@ ACE_INET_Addr::set_port_number (u_short port_number,
}
const char *
-ACE_INET_Addr::get_host_addr (char *, int) const
+ACE_INET_Addr::get_host_addr (char *dst, int size) const
{
- // XXXXX
- printf("Error: get_host_addr not defined yet for IPv6 addresses\n");
- return 0;
+#if defined (ACE_HAS_IPV6)
+ return ACE_OS::inet_ntop (AF_INET6, (const void*)&this->inet_addr_.sin6_addr,dst,size);
+#else
+ return ACE_OS::inet_ntop (AF_INET, (const void*)&this->inet_addr_.sin_addr,dst,size);
+#endif
}
// Return the dotted Internet address.
@@ -702,10 +705,9 @@ const char *
ACE_INET_Addr::get_host_addr (void) const
{
ACE_TRACE ("ACE_INET_Addr::get_host_addr");
-#if defined ACE_HAS_IPV6
- // XXXXXXXXXXX
- ACE_ERROR ((LM_ERROR,"ACE_INET_Addr::get_host_name needs to be written for IPv6\n"));
- return 0;
+#if defined (ACE_HAS_IPV6)
+ static char buf[INET6_ADDRSTRLEN];
+ return this->get_host_addr(buf,INET6_ADDRSTRLEN);
#else
return ACE_OS::inet_ntoa (this->inet_addr_.sin_addr);
#endif
diff --git a/ace/INET_Addr.h b/ace/INET_Addr.h
index f392f3c6080..36f7c9b7731 100644
--- a/ace/INET_Addr.h
+++ b/ace/INET_Addr.h
@@ -7,6 +7,7 @@
* $Id$
*
* @author Doug Schmidt
+ * Revised to support IPv6 by John Aughey
*/
//=============================================================================
@@ -23,6 +24,7 @@
#include "ace/Addr.h"
+// To simplify the code, the ANY address is defined here.
#if defined (ACE_HAS_IPV6)
#define ACE_INADDR_ANY in6addr_any
#define ACE_AF_INET AF_INET6
@@ -40,6 +42,8 @@
class ACE_Export ACE_INET_Addr : public ACE_Addr
{
public:
+ /* These typedefs simplify the set methods in the protected
+ section. */
#if defined (ACE_HAS_IPV6)
typedef sockaddr_in6 ace_sockaddr_in_t;
typedef in6_addr ace_in_addr_t;
@@ -55,13 +59,34 @@ public:
/// Copy constructor.
ACE_INET_Addr (const ACE_INET_Addr &);
+ // BEGIN IPv4 backwards compatible definitions
+
/// Creates an <ACE_INET_Addr> from a ace_sockaddr_in structure.
+ /// This method may be depreciated in the future.
ACE_INET_Addr (const sockaddr_in *, int len);
+ // Initializes an <ACE_INET_Addr> from a <port_number> and the
+ // remote <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 already and are passed straight through.
+ // Note: if ACE_HAS_IPV6 is defined, this will create a IPv4 address
+ // inside the IPv6 structure. This interface is likely to be depreciated
+ // very soon.
+ int set (u_short port_number,
+ ACE_UINT32 ip_addr = INADDR_ANY,
+ int encode = 1);
+
/// Creates an <ACE_INET_Addr> from a sockaddr_in structure.
int set (const sockaddr_in *,
int len);
+ /// Return the 4-byte IP address, converting it into host byte
+ /// order.
+ // XXXXXXXXXXX This needs to have something done with it for IPv6 addressing
+ // Multicast depends on this. We need to figure out what to do with this.
+ ACE_UINT32 get_ip_address (void) const;
+
+ // END IPv4 backwards compatible definitions
/// Creates an <ACE_INET_Addr> from a <port_number> and the remote
/// <host_name>.
@@ -112,11 +137,6 @@ public:
const wchar_t host_name[],
const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));
-#if !defined (ACE_HAS_IPV6)
- ACE_INET_Addr (const wchar_t port_name[],
- ace_in_addr_t ip_addr,
- const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));
-#endif /* ! ACE_HAS_IPV6 */
#endif /* ACE_HAS_WCHAR */
/// Default dtor.
@@ -139,17 +159,6 @@ public:
const char 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
- // converted into network byte order, otherwise it is assumed to be
- // in network byte order already and are passed straight through.
- // Note: if ACE_HAS_IPV6 is defined, this will create a IPv4 address
- // inside the IPv6 structure. This interface is likely to be depreciated
- // very soon.
- int set (u_short port_number,
- ACE_UINT32 ip_addr = INADDR_ANY,
- int encode = 1);
-
/// Uses <getservbyname> to initialize an <ACE_INET_Addr> from a
/// <port_name>, the remote <host_name>, and the <protocol>.
int set (const char port_name[],
@@ -174,13 +183,7 @@ public:
const wchar_t host_name[],
const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));
-#if !defined (ACE_HAS_IPV6)
- int set (const wchar_t port_name[],
- ace_in_addr_t ip_addr,
- const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp"));
-
int set (const wchar_t addr[]);
-#endif /* ! ACE_HAS_IPV6 */
#endif /* ACE_HAS_WCHAR */
/// Return a pointer to the underlying network address.
@@ -213,9 +216,9 @@ public:
virtual int string_to_addr (const char address[]);
#if defined (ACE_HAS_WCHAR)
- /*
+
virtual int string_to_addr (const char address[]);
- */
+
#endif /* ACE_HAS_WCHAR */
@@ -257,12 +260,6 @@ public:
/// Return the "dotted decimal" Internet address into the string provided.
const char *get_host_addr (char *dst, int size) const;
- /// Return the 4-byte IP address, converting it into host byte
- /// order.
- // XXXXXXXXXXX This needs to have something done with it for IPv6 addressing
- // Multicast depends on this. We need to figure out what to do with this.
- ACE_UINT32 get_ip_address (void) const;
-
/**
* Returns true if <this> is less than <rhs>. In this context,
* "less than" is defined in terms of IP address and TCP port
@@ -307,6 +304,7 @@ public:
int len);
#endif
+#if 0
/**
* Uses <getservbyname> to initialize an <ACE_INET_Addr> from a
* <port_name>, an <ip_addr>, and the <protocol>. This assumes that
@@ -315,6 +313,7 @@ public:
int set (const char port_name[],
ace_in_addr_t ip_addr,
const char protocol[] = "tcp");
+#endif
private:
/// Underlying representation.