Storage for an IP address. More...
#include <ink_inet.h>
Public Types | |
typedef IpAddr | self |
Self reference type. | |
Public Member Functions | |
IpAddr () | |
Default construct (invalid address). | |
IpAddr (in_addr_t addr) | |
Construct as IPv4 addr. | |
IpAddr (in6_addr const &addr) | |
Construct as IPv6 addr. | |
IpAddr (sockaddr const *addr) | |
Construct from sockaddr . | |
IpAddr (sockaddr_in6 const &addr) | |
Construct from sockaddr_in6 . | |
IpAddr (sockaddr_in6 const *addr) | |
Construct from sockaddr_in6 . | |
IpAddr (IpEndpoint const &addr) | |
Construct from IpEndpoint . | |
IpAddr (IpEndpoint const *addr) | |
Construct from IpEndpoint . | |
self & | operator= (IpEndpoint const &ip) |
Assign from end point. | |
int | load (char const *str) |
Load from string. | |
char * | toString (char *dest, size_t len) const |
Output to a string. | |
bool | operator== (self const &that) const |
Equality. | |
bool | operator!= (self const &that) |
Inequality. | |
bool | isValid () const |
Test for validity. | |
self & | invalidate () |
Make invalid. | |
bool | isMulticast () const |
Test for multicast. | |
is passed to @c getaddrinfo which does a host lookup if @a | |
Get the best address info for name. name is not in IP address format. The results are examined for the "best" addresses. This is only significant for the host name case (for IP address data, there is at most one result). The preference is Global > Non-Routable > Multicast > Loopback. IPv4 and IPv4 results are handled independently and stored in ip4 and ip6 respectively. If name is known to be a numeric IP address ip4 or ip6 can be
| |
self & | assign (sockaddr const *addr) |
Assign sockaddr storage. | |
self & | operator= (in_addr_t ip) |
Assign from IPv4 raw address. | |
self & | operator= (in6_addr const &ip) |
Assign from IPv6 raw address. | |
bool | isCompatibleWith (self const &that) |
Test for same address family. | |
uint16_t | family () const |
Get the address family. | |
bool | isIp4 () const |
Test for IPv4. | |
bool | isIp6 () const |
Test for IPv6. | |
Data Fields | |
uint16_t | _family |
Protocol family. | |
union { | |
in_addr_t _ip4 | |
IPv4 address storage. | |
in6_addr _ip6 | |
IPv6 address storage. | |
uint8_t _byte [TS_IP6_SIZE] | |
As raw bytes. | |
} | _addr |
Address data. | |
Static Public Attributes | |
static self const | INVALID |
Storage for an IP address.
In some cases we want to store just the address and not the ancillary information (such as port, or flow data).
Definition at line 1052 of file ink_inet.h.
typedef IpAddr IpAddr::self |
Self reference type.
Definition at line 1053 of file ink_inet.h.
IpAddr::IpAddr | ( | ) | [inline] |
Default construct (invalid address).
Definition at line 1056 of file ink_inet.h.
IpAddr::IpAddr | ( | in_addr_t | addr | ) | [inline, explicit] |
Construct as IPv4 addr.
addr | Address to assign. |
Definition at line 1058 of file ink_inet.h.
References _addr.
IpAddr::IpAddr | ( | in6_addr const & | addr | ) | [inline, explicit] |
Construct as IPv6 addr.
addr | Address to assign. |
Definition at line 1064 of file ink_inet.h.
References _addr.
IpAddr::IpAddr | ( | sockaddr const * | addr | ) | [inline, explicit] |
IpAddr::IpAddr | ( | sockaddr_in6 const & | addr | ) | [inline, explicit] |
Construct from sockaddr_in6
.
Definition at line 1072 of file ink_inet.h.
References assign(), and ats_ip_sa_cast().
IpAddr::IpAddr | ( | sockaddr_in6 const * | addr | ) | [inline, explicit] |
Construct from sockaddr_in6
.
Definition at line 1074 of file ink_inet.h.
References assign(), and ats_ip_sa_cast().
IpAddr::IpAddr | ( | IpEndpoint const & | addr | ) | [inline, explicit] |
Construct from IpEndpoint
.
Definition at line 1076 of file ink_inet.h.
References assign(), and IpEndpoint::sa.
IpAddr::IpAddr | ( | IpEndpoint const * | addr | ) | [inline, explicit] |
Construct from IpEndpoint
.
Definition at line 1078 of file ink_inet.h.
References assign(), and IpEndpoint::sa.
IpAddr & IpAddr::assign | ( | sockaddr const * | addr | ) | [inline] |
Assign sockaddr storage.
addr | May be NULL |
Definition at line 1187 of file ink_inet.h.
References _addr, _family, ats_ip4_addr_cast(), ats_ip6_addr_cast(), ats_is_ip4(), and ats_is_ip6().
Referenced by get_hostinfo_ClusterFunction(), PeerConfigData::GetHostIPByName(), IpAddr(), operator=(), put_hostinfo_ClusterFunction(), HostDBProcessor::setby(), TSHttpTxnOutgoingAddrSet(), and TSNetConnectTransparent().
uint16_t IpAddr::family | ( | ) | const [inline] |
Get the address family.
Definition at line 1176 of file ink_inet.h.
References _family.
Referenced by Ink_Inet(), Connection::open(), and HttpProxyPort::processOptions().
self& IpAddr::invalidate | ( | ) | [inline] |
Make invalid.
Definition at line 1146 of file ink_inet.h.
References _family.
Referenced by ICPConfiguration::icp_config_change_callback(), ip_addr_set(), RecHttpLoadIp(), NetProcessor::AcceptOptions::reset(), NetVCOptions::reset(), and TSHttpTxnOutgoingAddrSet().
bool IpAddr::isCompatibleWith | ( | self const & | that | ) | [inline] |
Test for same address family.
return
true
if that is the same address family as this.
Definition at line 1179 of file ink_inet.h.
bool IpAddr::isIp4 | ( | ) | const [inline] |
Test for IPv4.
Definition at line 1183 of file ink_inet.h.
References _family.
Referenced by DNSEntry::init(), make_net_accept_options(), and detail::HttpSessionAcceptOptions::setOutboundIp().
bool IpAddr::isIp6 | ( | ) | const [inline] |
Test for IPv6.
Definition at line 1184 of file ink_inet.h.
References _family.
Referenced by DNSEntry::init(), make_net_accept_options(), HostDBMD5::refresh(), and detail::HttpSessionAcceptOptions::setOutboundIp().
bool IpAddr::isMulticast | ( | ) | const |
bool IpAddr::isValid | ( | ) | const [inline] |
Test for validity.
Definition at line 1144 of file ink_inet.h.
References _family.
Referenced by UnixNetProcessor::accept_internal(), LogHost::connect(), UnixNetVConnection::connectUp(), HttpSM::do_http_server_open(), isCompatibleWith(), HostDBContinuation::lookup_done(), make_net_accept_options(), MakeHttpProxyAcceptor(), Connection::open(), LogHostList::operator==(), HttpProxyPort::print(), HostDBContinuation::probeEvent(), HttpProxyPort::processOptions(), and RecHttpLoadIp().
int IpAddr::load | ( | char const * | str | ) |
Load from string.
The address is copied to this object if the conversion is successful, otherwise this object is invalidated.
str | Nul terminated input string. |
Definition at line 334 of file ink_inet.cc.
References ats_ip_pton().
Referenced by ats_ip_pton(), HostDBContinuation::do_dns(), ICPConfiguration::icp_config_change_callback(), Ink_Inet(), LogFilterIP::LogFilterIP(), HttpProxyPort::processOptions(), and LogHost::set_ipstr_port().
bool IpAddr::operator!= | ( | self const & | that | ) | [inline] |
Inequality.
Definition at line 1127 of file ink_inet.h.
IpAddr & IpAddr::operator= | ( | in6_addr const & | ip | ) | [inline] |
Assign from IPv6 raw address.
Definition at line 1170 of file ink_inet.h.
self& IpAddr::operator= | ( | IpEndpoint const & | ip | ) | [inline] |
Assign from end point.
Definition at line 1086 of file ink_inet.h.
References assign(), and IpEndpoint::sa.
IpAddr & IpAddr::operator= | ( | in_addr_t | ip | ) | [inline] |
Assign from IPv4 raw address.
ip | Network order IPv4 address. |
Definition at line 1163 of file ink_inet.h.
bool IpAddr::operator== | ( | self const & | that | ) | const [inline] |
char * IpAddr::toString | ( | char * | dest, | |
size_t | len | |||
) | const |
Output to a string.
[out] | dest | Destination string buffer. |
[in] | len | Size of buffer. |
Definition at line 342 of file ink_inet.cc.
References IpEndpoint::assign(), and ats_ip_ntop().
Referenced by UnixNetVConnection::connectUp(), HostDBContinuation::do_dns(), HostDBContinuation::lookup_done(), HttpProxyPort::print(), remove_round_robin(), and LogCollationClientSM::send().
union { ... } IpAddr::_addr |
Address data.
Pre-constructed invalid instance.
Referenced by assign(), ats_ip_set(), DNSEntry::init(), Ink_Inet(), IpAddr(), isMulticast(), operator=(), operator==(), operator==(), and HostDBMD5::refresh().
uint8_t IpAddr::_byte[TS_IP6_SIZE] |
uint16_t IpAddr::_family |
Protocol family.
Definition at line 1150 of file ink_inet.h.
Referenced by assign(), ats_ip_set(), HostDBContinuation::dnsEvent(), family(), invalidate(), isCompatibleWith(), isIp4(), isIp6(), isMulticast(), isValid(), operator=(), operator==(), and operator==().
in_addr_t IpAddr::_ip4 |
IPv4 address storage.
Definition at line 1153 of file ink_inet.h.
Referenced by ats_ip_set(), DNSEntry::init(), Ink_Inet(), and operator==().
in6_addr IpAddr::_ip6 |
IPv6 address storage.
Definition at line 1154 of file ink_inet.h.
Referenced by ats_ip_set(), DNSEntry::init(), Ink_Inet(), and operator==().
IpAddr const IpAddr::INVALID [static] |
Definition at line 1159 of file ink_inet.h.