*Backed out changeset 3be01fb200a5
--HG-- branch : trunk
This commit is contained in:
@@ -2,10 +2,13 @@
|
||||
//
|
||||
// $Id: INET_Addr.inl 80826 2008-03-04 14:51:23Z wotte $
|
||||
|
||||
|
||||
#include "ace/OS_NS_string.h"
|
||||
#include "ace/Global_Macros.h"
|
||||
#include "ace/OS_NS_arpa_inet.h"
|
||||
|
||||
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
ACE_INLINE void
|
||||
ACE_INET_Addr::reset (void)
|
||||
{
|
||||
@@ -27,6 +30,7 @@ ACE_INET_Addr::reset (void)
|
||||
}
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
}
|
||||
|
||||
ACE_INLINE int
|
||||
ACE_INET_Addr::determine_type (void) const
|
||||
{
|
||||
@@ -40,6 +44,7 @@ ACE_INET_Addr::determine_type (void) const
|
||||
return AF_INET;
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
}
|
||||
|
||||
ACE_INLINE void *
|
||||
ACE_INET_Addr::ip_addr_pointer (void) const
|
||||
{
|
||||
@@ -52,6 +57,7 @@ ACE_INET_Addr::ip_addr_pointer (void) const
|
||||
return (void*)&this->inet_addr_.in4_.sin_addr;
|
||||
#endif
|
||||
}
|
||||
|
||||
ACE_INLINE int
|
||||
ACE_INET_Addr::ip_addr_size (void) const
|
||||
{
|
||||
@@ -75,7 +81,9 @@ ACE_INET_Addr::ip_addr_size (void) const
|
||||
# endif /* ! _UNICOS */
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
}
|
||||
|
||||
// Return the port number, converting it into host byte order...
|
||||
|
||||
ACE_INLINE u_short
|
||||
ACE_INET_Addr::get_port_number (void) const
|
||||
{
|
||||
@@ -91,6 +99,7 @@ ACE_INET_Addr::get_port_number (void) const
|
||||
return ntohs (this->inet_addr_.in4_.sin_port);
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
}
|
||||
|
||||
ACE_INLINE int
|
||||
ACE_INET_Addr::get_addr_size (void) const
|
||||
{
|
||||
@@ -104,6 +113,7 @@ ACE_INET_Addr::get_addr_size (void) const
|
||||
return sizeof this->inet_addr_.in4_;
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
}
|
||||
|
||||
ACE_INLINE bool
|
||||
ACE_INET_Addr::operator < (const ACE_INET_Addr &rhs) const
|
||||
{
|
||||
@@ -112,11 +122,13 @@ ACE_INET_Addr::operator < (const ACE_INET_Addr &rhs) const
|
||||
{
|
||||
return this->get_type() < rhs.get_type();
|
||||
}
|
||||
|
||||
if (this->get_type() == PF_INET6)
|
||||
{
|
||||
int memval = ACE_OS::memcmp (this->ip_addr_pointer(),
|
||||
rhs.ip_addr_pointer(),
|
||||
this->ip_addr_size());
|
||||
|
||||
return memval < 0
|
||||
|| (memval == 0
|
||||
&& (this->get_port_number() < rhs.get_port_number()
|
||||
@@ -125,10 +137,12 @@ ACE_INET_Addr::operator < (const ACE_INET_Addr &rhs) const
|
||||
rhs.inet_addr_.in6_.sin6_scope_id)));
|
||||
}
|
||||
#endif
|
||||
|
||||
return this->get_ip_address () < rhs.get_ip_address ()
|
||||
|| (this->get_ip_address () == rhs.get_ip_address ()
|
||||
&& this->get_port_number () < rhs.get_port_number ());
|
||||
}
|
||||
|
||||
#if defined (ACE_HAS_WCHAR)
|
||||
ACE_INLINE int
|
||||
ACE_INET_Addr::set (u_short port_number,
|
||||
@@ -141,6 +155,7 @@ ACE_INET_Addr::set (u_short port_number,
|
||||
encode,
|
||||
address_family);
|
||||
}
|
||||
|
||||
ACE_INLINE int
|
||||
ACE_INET_Addr::set (const wchar_t port_name[],
|
||||
const wchar_t host_name[],
|
||||
@@ -150,6 +165,7 @@ ACE_INET_Addr::set (const wchar_t port_name[],
|
||||
ACE_Wide_To_Ascii (host_name).char_rep (),
|
||||
ACE_Wide_To_Ascii (protocol).char_rep ());
|
||||
}
|
||||
|
||||
ACE_INLINE int
|
||||
ACE_INET_Addr::set (const wchar_t port_name[],
|
||||
ACE_UINT32 ip_addr,
|
||||
@@ -159,12 +175,15 @@ ACE_INET_Addr::set (const wchar_t port_name[],
|
||||
ip_addr,
|
||||
ACE_Wide_To_Ascii (protocol).char_rep ());
|
||||
}
|
||||
|
||||
ACE_INLINE int
|
||||
ACE_INET_Addr::set (const wchar_t addr[], int address_family)
|
||||
{
|
||||
return this->set (ACE_Wide_To_Ascii (addr).char_rep (), address_family);
|
||||
}
|
||||
|
||||
#endif /* ACE_HAS_WCHAR */
|
||||
|
||||
// Return @c true if the IP address is INADDR_ANY or IN6ADDR_ANY.
|
||||
ACE_INLINE bool
|
||||
ACE_INET_Addr::is_any (void) const
|
||||
@@ -173,8 +192,10 @@ ACE_INET_Addr::is_any (void) const
|
||||
if (this->get_type () == AF_INET6)
|
||||
return IN6_IS_ADDR_UNSPECIFIED (&this->inet_addr_.in6_.sin6_addr);
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
|
||||
return (this->inet_addr_.in4_.sin_addr.s_addr == INADDR_ANY);
|
||||
}
|
||||
|
||||
// Return @c true if the IP address is IPv4/IPv6 loopback address.
|
||||
ACE_INLINE bool
|
||||
ACE_INET_Addr::is_loopback (void) const
|
||||
@@ -183,9 +204,11 @@ ACE_INET_Addr::is_loopback (void) const
|
||||
if (this->get_type () == AF_INET6)
|
||||
return IN6_IS_ADDR_LOOPBACK (&this->inet_addr_.in6_.sin6_addr);
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
|
||||
// RFC 3330 defines loopback as any address with 127.x.x.x
|
||||
return ((this->get_ip_address () & 0XFF000000) == (INADDR_LOOPBACK & 0XFF000000));
|
||||
}
|
||||
|
||||
// Return @c true if the IP address is IPv4/IPv6 multicast address.
|
||||
ACE_INLINE bool
|
||||
ACE_INET_Addr::is_multicast (void) const
|
||||
@@ -198,6 +221,7 @@ ACE_INET_Addr::is_multicast (void) const
|
||||
this->inet_addr_.in4_.sin_addr.s_addr >= 0xE0000000 && // 224.0.0.0
|
||||
this->inet_addr_.in4_.sin_addr.s_addr <= 0xEFFFFFFF; // 239.255.255.255
|
||||
}
|
||||
|
||||
#if defined (ACE_HAS_IPV6)
|
||||
// Return @c true if the IP address is IPv6 linklocal address.
|
||||
ACE_INLINE bool
|
||||
@@ -205,23 +229,29 @@ ACE_INET_Addr::is_linklocal (void) const
|
||||
{
|
||||
if (this->get_type () == AF_INET6)
|
||||
return IN6_IS_ADDR_LINKLOCAL (&this->inet_addr_.in6_.sin6_addr);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return @c true if the IP address is IPv4 mapped IPv6 address.
|
||||
ACE_INLINE bool
|
||||
ACE_INET_Addr::is_ipv4_mapped_ipv6 (void) const
|
||||
{
|
||||
if (this->get_type () == AF_INET6)
|
||||
return IN6_IS_ADDR_V4MAPPED (&this->inet_addr_.in6_.sin6_addr);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Return @c true if the IP address is IPv4-compatible IPv6 address.
|
||||
ACE_INLINE bool
|
||||
ACE_INET_Addr::is_ipv4_compat_ipv6 (void) const
|
||||
{
|
||||
if (this->get_type () == AF_INET6)
|
||||
return IN6_IS_ADDR_V4COMPAT (&this->inet_addr_.in6_.sin6_addr);
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif /* ACE_HAS_IPV6 */
|
||||
|
||||
ACE_END_VERSIONED_NAMESPACE_DECL
|
||||
|
||||
Reference in New Issue
Block a user