00001
00002
00003
00004
00005
00006
00007 ACE_INLINE
00008 ACE_INET_Addr::~ACE_INET_Addr (void)
00009 {
00010 }
00011
00012 ACE_INLINE void
00013 ACE_INET_Addr::reset (void)
00014 {
00015 ACE_OS::memset(&this->inet_addr_, 0, sizeof(this->inet_addr_));
00016 if (this->get_type() == AF_INET) {
00017 this->inet_addr_.in4_.sin_family = AF_INET;
00018 }
00019 #if defined (ACE_HAS_IPV6)
00020 else if (this->get_type() == AF_INET6) {
00021 this->inet_addr_.in6_.sin6_family = AF_INET6;
00022 }
00023 #endif
00024 }
00025
00026 ACE_INLINE int
00027 ACE_INET_Addr::determine_type (void) const
00028 {
00029 #if defined (ACE_HAS_IPV6)
00030 # if defined (ACE_USES_IPV4_IPV6_MIGRATION)
00031 return ACE_Sock_Connect::ipv6_enabled () ? AF_INET6 : AF_INET;
00032 # else
00033 return AF_INET6;
00034 # endif
00035 #endif
00036 return AF_INET;
00037 }
00038
00039 ACE_INLINE void *
00040 ACE_INET_Addr::ip_addr_pointer (void) const
00041 {
00042 #if defined (ACE_HAS_IPV6)
00043 if (this->get_type () == PF_INET)
00044 return (void*)&this->inet_addr_.in4_.sin_addr;
00045 else
00046 return (void*)&this->inet_addr_.in6_.sin6_addr;
00047 #else
00048 return (void*)&this->inet_addr_.in4_.sin_addr;
00049 #endif
00050 }
00051
00052 ACE_INLINE int
00053 ACE_INET_Addr::ip_addr_size (void) const
00054 {
00055
00056
00057
00058
00059 #if defined (ACE_HAS_IPV6)
00060 if (this->get_type () == PF_INET)
00061 return ACE_static_cast (int, sizeof this->inet_addr_.in4_.sin_addr);
00062 else
00063 return ACE_static_cast (int, sizeof this->inet_addr_.in6_.sin6_addr);
00064 #else
00065
00066
00067
00068 # if !defined(_UNICOS)
00069 return ACE_static_cast (int, sizeof this->inet_addr_.in4_.sin_addr.s_addr);
00070 # else
00071 return ACE_static_cast (int, sizeof this->inet_addr_.in4_.sin_addr);
00072 # endif
00073 #endif
00074 }
00075
00076
00077
00078 ACE_INLINE u_short
00079 ACE_INET_Addr::get_port_number (void) const
00080 {
00081 ACE_TRACE ("ACE_INET_Addr::get_port_number");
00082 #if defined (ACE_HAS_IPV6)
00083 if (this->get_type () == PF_INET)
00084 return ntohs (this->inet_addr_.in4_.sin_port);
00085 else
00086 return ntohs (this->inet_addr_.in6_.sin6_port);
00087 #else
00088 return ntohs (this->inet_addr_.in4_.sin_port);
00089 #endif
00090 }
00091
00092
00093
00094 ACE_INLINE void *
00095 ACE_INET_Addr::get_addr (void) const
00096 {
00097 ACE_TRACE ("ACE_INET_Addr::get_addr");
00098 return (void*)&this->inet_addr_;
00099 }
00100
00101 ACE_INLINE int
00102 ACE_INET_Addr::get_addr_size (void) const
00103 {
00104 ACE_TRACE ("ACE_INET_Addr::get_addr_size");
00105 #if defined (ACE_HAS_IPV6)
00106 if (this->get_type () == PF_INET)
00107 return sizeof this->inet_addr_.in4_;
00108 else
00109 return sizeof this->inet_addr_.in6_;
00110 #else
00111 return sizeof this->inet_addr_.in4_;
00112 #endif
00113 }
00114
00115
00116 ACE_INLINE u_long
00117 ACE_INET_Addr::hash (void) const
00118 {
00119 #if defined (ACE_HAS_IPV6)
00120 if (this->get_type () == PF_INET6)
00121 {
00122 const unsigned int *addr = (const unsigned int*)this->ip_addr_pointer();
00123 return addr[0] + addr[1] + addr[2] + addr[3] + this->get_port_number();
00124 }
00125 else
00126 #endif
00127 return this->get_ip_address () + this->get_port_number ();
00128 }
00129
00130 ACE_INLINE int
00131 ACE_INET_Addr::operator < (const ACE_INET_Addr &rhs) const
00132 {
00133 return this->get_ip_address () < rhs.get_ip_address ()
00134 || (this->get_ip_address () == rhs.get_ip_address ()
00135 && this->get_port_number () < rhs.get_port_number ());
00136 }
00137
00138 #if defined (ACE_HAS_WCHAR)
00139 ACE_INLINE int
00140 ACE_INET_Addr::set (u_short port_number,
00141 const wchar_t host_name[],
00142 int encode,
00143 int address_family)
00144 {
00145 return this->set (port_number,
00146 ACE_Wide_To_Ascii (host_name).char_rep (),
00147 encode,
00148 address_family);
00149 }
00150
00151 ACE_INLINE int
00152 ACE_INET_Addr::set (const wchar_t port_name[],
00153 const wchar_t host_name[],
00154 const wchar_t protocol[])
00155 {
00156 return this->set (ACE_Wide_To_Ascii (port_name).char_rep (),
00157 ACE_Wide_To_Ascii (host_name).char_rep (),
00158 ACE_Wide_To_Ascii (protocol).char_rep ());
00159 }
00160
00161 ACE_INLINE int
00162 ACE_INET_Addr::set (const wchar_t port_name[],
00163 ACE_UINT32 ip_addr,
00164 const wchar_t protocol[])
00165 {
00166 return this->set (ACE_Wide_To_Ascii (port_name).char_rep (),
00167 ip_addr,
00168 ACE_Wide_To_Ascii (protocol).char_rep ());
00169 }
00170
00171 ACE_INLINE int
00172 ACE_INET_Addr::set (const wchar_t addr[])
00173 {
00174 return this->set (ACE_Wide_To_Ascii (addr).char_rep ());
00175 }
00176
00177 #endif