diff options
author | Steve Huston <shuston@riverace.com> | 2001-12-03 21:34:18 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2001-12-03 21:34:18 +0000 |
commit | be1c9f9fbf62c0194c507cd99acb0d11205983d1 (patch) | |
tree | 408f77903765e492a9d40c64440d175f1cf97825 /ace/INET_Addr.h | |
parent | f3e1c2ebad0ad5b741c5c0022dc2a9abeb7d97b6 (diff) | |
download | ATCD-be1c9f9fbf62c0194c507cd99acb0d11205983d1.tar.gz |
ChangeLogTag:Mon Dec 3 15:50:42 2001 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace/INET_Addr.h')
-rw-r--r-- | ace/INET_Addr.h | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/ace/INET_Addr.h b/ace/INET_Addr.h index 9d362ec75d4..3d3b72a369f 100644 --- a/ace/INET_Addr.h +++ b/ace/INET_Addr.h @@ -36,6 +36,7 @@ class ACE_Export ACE_INET_Addr : public ACE_Addr { public: // = Initialization methods. + /// Default constructor. ACE_INET_Addr (void); @@ -48,8 +49,10 @@ public: /// Creates an <ACE_INET_Addr> from a <port_number> and the remote /// <host_name>. The port number is assumed to be in host byte order. /// To set a port already in network byte order, please @see set(). + /// Use address_family to select IPv6 (PF_INET6) vs. IPv4 (PF_INET). ACE_INET_Addr (u_short port_number, - const char host_name[]); + const char host_name[], + int address_family = AF_UNSPEC); /** * Initializes an <ACE_INET_Addr> from the <address>, which can be @@ -67,12 +70,12 @@ public: * network byte order, @see set(). */ ACE_INET_Addr (u_short port_number, - ACE_UINT32 ip_addr = INADDR_ANY); + ACE_UINT32 ip_addr = INADDR_ANY); /// Uses <getservbyname> to create an <ACE_INET_Addr> from a /// <port_name>, the remote <host_name>, and the <protocol>. ACE_INET_Addr (const char port_name[], - const char host_name[], + const char host_name[], const char protocol[] = "tcp"); /** @@ -81,21 +84,22 @@ public: * method assumes that <ip_addr> is in host byte order. */ ACE_INET_Addr (const char port_name[], - ACE_UINT32 ip_addr, + ACE_UINT32 ip_addr, const char protocol[] = "tcp"); #if defined (ACE_HAS_WCHAR) ACE_INET_Addr (u_short port_number, - const wchar_t host_name[]); + const wchar_t host_name[], + int address_family = AF_UNSPEC); ACE_EXPLICIT ACE_INET_Addr (const wchar_t address[]); ACE_INET_Addr (const wchar_t port_name[], - const wchar_t host_name[], + const wchar_t host_name[], const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); ACE_INET_Addr (const wchar_t port_name[], - ACE_UINT32 ip_addr, + ACE_UINT32 ip_addr, const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); #endif /* ACE_HAS_WCHAR */ @@ -114,10 +118,14 @@ public: * remote <host_name>. If <encode> is non-zero 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. + * address_family can be used to select IPv4/IPv6 if the OS has + * IPv6 capability (ACE_HAS_IPV6 is defined). To specify IPv6, use + * the value AF_INET6. To specify IPv4, use AF_INET. */ int set (u_short port_number, - const char host_name[], - int encode = 1); + const char host_name[], + int encode = 1, + int address_family = AF_UNSPEC); /** * Initializes an <ACE_INET_Addr> from a @param port_number and an @@ -133,7 +141,7 @@ public: /// 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[], - const char host_name[], + const char host_name[], const char protocol[] = "tcp"); /** @@ -142,7 +150,7 @@ public: * <ip_addr> is already in network byte order. */ int set (const char port_name[], - ACE_UINT32 ip_addr, + ACE_UINT32 ip_addr, const char protocol[] = "tcp"); /** @@ -156,19 +164,20 @@ public: /// Creates an <ACE_INET_Addr> from a sockaddr_in structure. int set (const sockaddr_in *, - int len); + int len); #if defined (ACE_HAS_WCHAR) int set (u_short port_number, - const wchar_t host_name[], - int encode = 1); + const wchar_t host_name[], + int encode = 1, + int address_family = AF_UNSPEC); int set (const wchar_t port_name[], - const wchar_t host_name[], + const wchar_t host_name[], const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); int set (const wchar_t port_name[], - ACE_UINT32 ip_addr, + ACE_UINT32 ip_addr, const wchar_t protocol[] = ACE_TEXT_WIDE ("tcp")); int set (const wchar_t addr[]); @@ -176,6 +185,7 @@ public: /// Return a pointer to the underlying network address. virtual void *get_addr (void) const; + int get_addr_size(void) const; /// Set a pointer to the address. virtual void set_addr (void *, int len); @@ -217,7 +227,18 @@ public: * already and are passed straight through. */ void set_port_number (u_short, - int encode = 1); + int encode = 1); + + /** + * Sets the address without affecting the port number. If + * <encode> is enabled then <ip_addr> is converted into network + * byte order, otherwise it is assumed to be in network byte order + * already and are passed straight through. The size of the address + * is specified in the <len> parameter. + */ + int set_address (const char *ip_addr, + int len, + int encode = 1); /// Return the port number, converting it into host byte-order. u_short get_port_number (void) const; @@ -246,6 +267,7 @@ public: /// Return the "dotted decimal" Internet address. const char *get_host_addr (void) const; + const char *get_host_addr (char *dst, int size) const; /// Return the 4-byte IP address, converting it into host byte /// order. @@ -279,8 +301,22 @@ private: /// Insure that @arg hostname is properly null-terminated. int get_host_name_i (char hostname[], size_t hostnamelen) const; + // Methods to gain access to the actual address of + // the underlying internet address structure. + void *ip_addr_pointer (void) const; + size_t ip_addr_size (void) const; + int determine_type (void) const; + /// Underlying representation. - sockaddr_in inet_addr_; + /// This union uses the knowledge that the two structures share the + /// first member, sa_family (as all sockaddr structures do). + union + { + sockaddr_in in4_; +#if defined (ACE_HAS_IPV6) + sockaddr_in6 in6_; +#endif /* ACE_HAS_IPV6 */ + } inet_addr_; #if defined (VXWORKS) char buf_[INET_ADDR_LEN]; |