You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2012/02/22 17:16:11 UTC
[6/8] TS-995 changes.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/records/I_RecHttp.h
----------------------------------------------------------------------
diff --git a/lib/records/I_RecHttp.h b/lib/records/I_RecHttp.h
index 18ea20b..41da219 100644
--- a/lib/records/I_RecHttp.h
+++ b/lib/records/I_RecHttp.h
@@ -30,8 +30,8 @@
/// Load default inbound IP addresses from the configuration file.
void RecHttpLoadIp(
char const* name, ///< Name of value in configuration file.
- InkInetAddr& ip4, ///< [out] IPv4 address.
- InkInetAddr& ip6 ///< [out] Ipv6 address.
+ IpAddr& ip4, ///< [out] IPv4 address.
+ IpAddr& ip6 ///< [out] Ipv6 address.
);
/** Description of an proxy port.
@@ -104,11 +104,11 @@ public:
/// True if outbound connections (to origin servers) are transparent.
bool m_outbound_transparent_p;
/// Local address for inbound connections (listen address).
- InkInetAddr m_inbound_ip;
+ IpAddr m_inbound_ip;
/// Local address for outbound connections (to origin server).
- InkInetAddr m_outbound_ip4;
+ IpAddr m_outbound_ip4;
/// Local address for outbound connections (to origin server).
- InkInetAddr m_outbound_ip6;
+ IpAddr m_outbound_ip6;
/// Default constructor.
HttpProxyPort();
@@ -117,7 +117,7 @@ public:
@return The IP address for @a family
*/
- InkInetAddr& outboundIp(
+ IpAddr& outboundIp(
uint16_t family ///< IP address family.
);
@@ -260,9 +260,9 @@ public:
inline bool HttpProxyPort::isSSL() const { return TRANSPORT_SSL == m_type; }
-inline InkInetAddr&
+inline IpAddr&
HttpProxyPort::outboundIp(uint16_t family) {
- static InkInetAddr invalid; // dummy to make compiler happy about return.
+ static IpAddr invalid; // dummy to make compiler happy about return.
if (AF_INET == family) return m_outbound_ip4;
else if (AF_INET6 == family) return m_outbound_ip6;
ink_release_assert(!"Invalid family for outbound address on proxy port.");
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/records/RecHttp.cc
----------------------------------------------------------------------
diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc
index 6bbd6ed..628d4fb 100644
--- a/lib/records/RecHttp.cc
+++ b/lib/records/RecHttp.cc
@@ -27,7 +27,7 @@
# include <ts/Tokenizer.h>
# include <strings.h>
-void RecHttpLoadIp(char const* value_name, InkInetAddr& ip4, InkInetAddr& ip6)
+void RecHttpLoadIp(char const* value_name, IpAddr& ip4, IpAddr& ip6)
{
char value[1024];
ip4.invalidate();
@@ -37,15 +37,15 @@ void RecHttpLoadIp(char const* value_name, InkInetAddr& ip4, InkInetAddr& ip6)
int n_addrs = tokens.Initialize(value);
for (int i = 0 ; i < n_addrs ; ++i ) {
char const* host = tokens[i];
- ts_ip_endpoint tmp4, tmp6;
+ IpEndpoint tmp4, tmp6;
// For backwards compatibility we need to support the use of host names
// for the address to bind.
- if (0 == ink_inet_getbestaddrinfo(host, &tmp4, &tmp6)) {
- if (ink_inet_is_ip4(&tmp4)) {
+ if (0 == ats_ip_getbestaddrinfo(host, &tmp4, &tmp6)) {
+ if (ats_is_ip4(&tmp4)) {
if (!ip4.isValid()) ip4 = tmp4;
else Warning("'%s' specifies more than one IPv4 address, ignoring %s.", value_name, host);
}
- if (ink_inet_is_ip6(&tmp6)) {
+ if (ats_is_ip6(&tmp6)) {
if (!ip6.isValid()) ip6 = tmp6;
else Warning("'%s' specifies more than one IPv6 address, ignoring %s.", value_name, host);
}
@@ -114,7 +114,7 @@ bool HttpProxyPort::hasSSL(Group const& ports) {
}
HttpProxyPort* HttpProxyPort::findHttp(Group const& ports, uint16_t family) {
- bool check_family_p = ink_inet_is_ip(family);
+ bool check_family_p = ats_is_ip(family);
self* zret = 0;
for ( int i = 0 , n = ports.length() ; i < n && !zret ; ++i ) {
HttpProxyPort& p = ports[i];
@@ -282,17 +282,17 @@ HttpProxyPort::processOptions(char const* opts) {
zret = true;
}
} else if (0 == strncasecmp(OPT_INBOUND_IP_PREFIX, item, OPT_INBOUND_IP_PREFIX_LEN)) {
- ts_ip_endpoint ip;
+ IpEndpoint ip;
item += OPT_INBOUND_IP_PREFIX_LEN; // skip prefix
if ('-' == *item || '=' == *item) ++item; // permit optional '-' or '='
- if (0 == ink_inet_pton(item, &ip))
+ if (0 == ats_ip_pton(item, &ip))
m_inbound_ip = ip;
else
Warning("Invalid IP address value '%s' in port descriptor '%s'",
item, opts
);
} else if (0 == strncasecmp(OPT_OUTBOUND_IP_PREFIX, item, OPT_OUTBOUND_IP_PREFIX_LEN)) {
- InkInetAddr ip;
+ IpAddr ip;
item += OPT_OUTBOUND_IP_PREFIX_LEN; // skip prefix
if ('-' == *item || '=' == *item) ++item; // permit optional '-' or '='
if (0 == ip.load(item))
@@ -349,7 +349,7 @@ HttpProxyPort::processOptions(char const* opts) {
if (af_set_p) {
if (in_ip_set_p && m_family != m_inbound_ip.family()) {
Warning("Invalid port descriptor '%s' - the inbound adddress family [%s] is not the same type as the explict family value [%s]",
- opts, ink_inet_family_name(m_inbound_ip.family()), ink_inet_family_name(m_family));
+ opts, ats_ip_family_name(m_inbound_ip.family()), ats_ip_family_name(m_family));
zret = false;
}
} else if (in_ip_set_p) {
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/IpMap.cc
----------------------------------------------------------------------
diff --git a/lib/ts/IpMap.cc b/lib/ts/IpMap.cc
index e1ec0c4..1c9ccc5 100644
--- a/lib/ts/IpMap.cc
+++ b/lib/ts/IpMap.cc
@@ -910,16 +910,16 @@ public:
ArgType max, ///< Maximum address (host order).
void* data ///< Client data.
) : Node(data), Ip4Span(min, max) {
- ink_inet_ip4_set(ink_inet_sa_cast(&_sa._min), htonl(min));
- ink_inet_ip4_set(ink_inet_sa_cast(&_sa._max), htonl(max));
+ ats_ip4_set(ats_ip_sa_cast(&_sa._min), htonl(min));
+ ats_ip4_set(ats_ip_sa_cast(&_sa._max), htonl(max));
}
/// @return The minimum value of the interval.
virtual sockaddr const* min() {
- return ink_inet_sa_cast(&_sa._min);
+ return ats_ip_sa_cast(&_sa._min);
}
/// @return The maximum value of the interval.
virtual sockaddr const* max() {
- return ink_inet_sa_cast(&_sa._max);
+ return ats_ip_sa_cast(&_sa._max);
}
/// Set the client data.
self& setData(
@@ -1043,11 +1043,11 @@ public:
}
/// @return The minimum value of the interval.
virtual sockaddr const* min() {
- return ink_inet_sa_cast(&_min);
+ return ats_ip_sa_cast(&_min);
}
/// @return The maximum value of the interval.
virtual sockaddr const* max() {
- return ink_inet_sa_cast(&_max);
+ return ats_ip_sa_cast(&_max);
}
/// Set the client data.
self& setData(
@@ -1063,7 +1063,7 @@ protected:
self& setMin(
ArgType min ///< Minimum value (host order).
) {
- ink_inet_copy(ink_inet_sa_cast(&_min), ink_inet_sa_cast(min));
+ ats_ip_copy(ats_ip_sa_cast(&_min), ats_ip_sa_cast(min));
return *this;
}
@@ -1081,7 +1081,7 @@ protected:
self& setMax(
ArgType max ///< Maximum value (host order).
) {
- ink_inet_copy(ink_inet_sa_cast(&_max), ink_inet_sa_cast(max));
+ ats_ip_copy(ats_ip_sa_cast(&_max), ats_ip_sa_cast(max));
return *this;
}
/// Set the maximum value of the interval.
@@ -1231,9 +1231,9 @@ bool
IpMap::contains(sockaddr const* target, void** ptr) const {
bool zret = false;
if (AF_INET == target->sa_family) {
- zret = _m4 && _m4->contains(ntohl(ink_inet_ip4_addr_cast(target)), ptr);
+ zret = _m4 && _m4->contains(ntohl(ats_ip4_addr_cast(target)), ptr);
} else if (AF_INET6 == target->sa_family) {
- zret = _m6 && _m6->contains(ink_inet_ip6_cast(target), ptr);
+ zret = _m6 && _m6->contains(ats_ip6_cast(target), ptr);
}
return zret;
}
@@ -1252,12 +1252,12 @@ IpMap::mark(
ink_assert(min->sa_family == max->sa_family);
if (AF_INET == min->sa_family) {
this->force4()->mark(
- ntohl(ink_inet_ip4_addr_cast(min)),
- ntohl(ink_inet_ip4_addr_cast(max)),
+ ntohl(ats_ip4_addr_cast(min)),
+ ntohl(ats_ip4_addr_cast(max)),
data
);
} else if (AF_INET6 == min->sa_family) {
- this->force6()->mark(ink_inet_ip6_cast(min), ink_inet_ip6_cast(max), data);
+ this->force6()->mark(ats_ip6_cast(min), ats_ip6_cast(max), data);
}
return *this;
}
@@ -1277,11 +1277,11 @@ IpMap::unmark(
if (AF_INET == min->sa_family) {
if (_m4)
_m4->unmark(
- ntohl(ink_inet_ip4_addr_cast(min)),
- ntohl(ink_inet_ip4_addr_cast(max))
+ ntohl(ats_ip4_addr_cast(min)),
+ ntohl(ats_ip4_addr_cast(max))
);
} else if (AF_INET6 == min->sa_family) {
- if (_m6) _m6->unmark(ink_inet_ip6_cast(min), ink_inet_ip6_cast(max));
+ if (_m6) _m6->unmark(ats_ip6_cast(min), ats_ip6_cast(max));
}
return *this;
}
@@ -1301,12 +1301,12 @@ IpMap::fill(
ink_assert(min->sa_family == max->sa_family);
if (AF_INET == min->sa_family) {
this->force4()->fill(
- ntohl(ink_inet_ip4_addr_cast(min)),
- ntohl(ink_inet_ip4_addr_cast(max)),
+ ntohl(ats_ip4_addr_cast(min)),
+ ntohl(ats_ip4_addr_cast(max)),
data
);
} else if (AF_INET6 == min->sa_family) {
- this->force6()->fill(ink_inet_ip6_cast(min), ink_inet_ip6_cast(max), data);
+ this->force6()->fill(ats_ip6_cast(min), ats_ip6_cast(max), data);
}
return *this;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/IpMap.h
----------------------------------------------------------------------
diff --git a/lib/ts/IpMap.h b/lib/ts/IpMap.h
index 24f4201..9357512 100644
--- a/lib/ts/IpMap.h
+++ b/lib/ts/IpMap.h
@@ -367,8 +367,8 @@ public:
@return This object.
*/
self& mark(
- ts_ip_endpoint const* min, ///< Minimum address (network order).
- ts_ip_endpoint const* max, ///< Maximum address (network order).
+ IpEndpoint const* min, ///< Minimum address (network order).
+ IpEndpoint const* max, ///< Maximum address (network order).
void* data = 0 ///< Client data.
);
@@ -378,7 +378,7 @@ public:
@return This object.
*/
self& mark(
- ts_ip_endpoint const* addr, ///< Address (network order).
+ IpEndpoint const* addr, ///< Address (network order).
void* data = 0 ///< Client data.
);
@@ -416,8 +416,8 @@ public:
);
/// Fill addresses (overload).
self& fill(
- ts_ip_endpoint const* min,
- ts_ip_endpoint const* max,
+ IpEndpoint const* min,
+ IpEndpoint const* max,
void* data = 0
);
/// Fill addresses (overload).
@@ -452,7 +452,7 @@ public:
) const;
bool contains(
- ts_ip_endpoint const* target, ///< Search target (network order).
+ IpEndpoint const* target, ///< Search target (network order).
void **ptr = 0 ///< Client data return.
) const;
@@ -496,19 +496,19 @@ inline IpMap& IpMap::mark(in_addr_t addr, void* data) {
return this->mark(addr, addr, data);
}
-inline IpMap& IpMap::mark(ts_ip_endpoint const* addr, void* data) {
+inline IpMap& IpMap::mark(IpEndpoint const* addr, void* data) {
return this->mark(&addr->sa, &addr->sa, data);
}
-inline IpMap& IpMap::mark(ts_ip_endpoint const* min, ts_ip_endpoint const* max, void* data) {
+inline IpMap& IpMap::mark(IpEndpoint const* min, IpEndpoint const* max, void* data) {
return this->mark(&min->sa, &max->sa, data);
}
-inline IpMap& IpMap::fill(ts_ip_endpoint const* min, ts_ip_endpoint const* max, void* data) {
+inline IpMap& IpMap::fill(IpEndpoint const* min, IpEndpoint const* max, void* data) {
return this->fill(&min->sa, &max->sa, data);
}
-inline bool IpMap::contains(ts_ip_endpoint const* target, void** ptr) const {
+inline bool IpMap::contains(IpEndpoint const* target, void** ptr) const {
return this->contains(&target->sa, ptr);
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/IpMapConf.cc
----------------------------------------------------------------------
diff --git a/lib/ts/IpMapConf.cc b/lib/ts/IpMapConf.cc
index da98d2d..9baf181 100644
--- a/lib/ts/IpMapConf.cc
+++ b/lib/ts/IpMapConf.cc
@@ -68,7 +68,7 @@ read_addr(
}
dst[k] = '\0';
- if (0 != ink_inet_pton(dst, addr)) {
+ if (0 != ats_ip_pton(dst, addr)) {
snprintf(err, ERR_STRING_LEN,
"IP address '%s' improperly formatted", dst
);
@@ -106,7 +106,7 @@ Load_IpMap_From_File(IpMap* map, FILE* f, const char *key_str)
{
int i, n, line_no;
int key_len = strlen(key_str);
- ts_ip_endpoint laddr, raddr;
+ IpEndpoint laddr, raddr;
char line[MAX_LINE_SIZE];
char err_buff[ERR_STRING_LEN];
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/IpMapTest.cc
----------------------------------------------------------------------
diff --git a/lib/ts/IpMapTest.cc b/lib/ts/IpMapTest.cc
index c5ba8ce..7a8d385 100644
--- a/lib/ts/IpMapTest.cc
+++ b/lib/ts/IpMapTest.cc
@@ -95,22 +95,22 @@ REGRESSION_TEST(IpMap_Test_Sample)(RegressionTest* t, int atype, int* pstatus) {
void* const deny = reinterpret_cast<void*>(2);
void* mark; // for retrieval
- ts_ip_endpoint a1,a2,a3,a4,a5,a6, a7, a8;
- ts_ip_endpoint target;
- ts_ip_endpoint t6;
+ IpEndpoint a1,a2,a3,a4,a5,a6, a7, a8;
+ IpEndpoint target;
+ IpEndpoint t6;
*pstatus = REGRESSION_TEST_PASSED;
- ink_inet_pton("10.28.56.0", &a1);
- ink_inet_pton("10.28.56.255", &a2);
- ink_inet_pton("0.0.0.0", &a3);
- ink_inet_pton("255.255.255.255", &a4);
- ink_inet_pton("::", &a5);
- ink_inet_pton("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", &a6);
- ink_inet_pton("fe80::221:9bff:fe10:9d90", &a7);
- ink_inet_pton("fe80::221:9bff:fe10:9d9d", &a8);
- ink_inet_pton("10.28.56.4", &target);
- ink_inet_pton("fe80::221:9bff:fe10:9d95", &t6);
+ ats_ip_pton("10.28.56.0", &a1);
+ ats_ip_pton("10.28.56.255", &a2);
+ ats_ip_pton("0.0.0.0", &a3);
+ ats_ip_pton("255.255.255.255", &a4);
+ ats_ip_pton("::", &a5);
+ ats_ip_pton("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", &a6);
+ ats_ip_pton("fe80::221:9bff:fe10:9d90", &a7);
+ ats_ip_pton("fe80::221:9bff:fe10:9d9d", &a8);
+ ats_ip_pton("10.28.56.4", &target);
+ ats_ip_pton("fe80::221:9bff:fe10:9d95", &t6);
map.fill(&a1,&a2,deny);
map.fill(&a3,&a4,allow);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/MatcherUtils.cc
----------------------------------------------------------------------
diff --git a/lib/ts/MatcherUtils.cc b/lib/ts/MatcherUtils.cc
index cec5f22..1cab191 100644
--- a/lib/ts/MatcherUtils.cc
+++ b/lib/ts/MatcherUtils.cc
@@ -138,12 +138,12 @@ unescapifyStr(char *buffer)
char const*
ExtractIpRange(char* match_str, in_addr_t* min, in_addr_t* max) {
- ts_ip_endpoint ip_min, ip_max;
+ IpEndpoint ip_min, ip_max;
char const* zret = ExtractIpRange(match_str, &ip_min.sa, &ip_max.sa);
if (0 == zret) { // success
- if (ink_inet_is_ip4(&ip_min) && ink_inet_is_ip4(&ip_max)) {
- if (min) *min = ntohl(ink_inet_ip4_addr_cast(&ip_min));
- if (max) *max = ntohl(ink_inet_ip4_addr_cast(&ip_max));
+ if (ats_is_ip4(&ip_min) && ats_is_ip4(&ip_max)) {
+ if (min) *min = ntohl(ats_ip4_addr_cast(&ip_min));
+ if (max) *max = ntohl(ats_ip4_addr_cast(&ip_max));
} else {
zret = "The addresses were not IPv4 addresses.";
}
@@ -173,7 +173,7 @@ ExtractIpRange(char *match_str, sockaddr* addr1, sockaddr* addr2)
int mask_bits;
int mask_val;
int numToks;
- ts_ip_endpoint la1, la2;
+ IpEndpoint la1, la2;
// Extract the IP addresses from match data
numToks = rangeTok.Initialize(match_str, SHARE_TOKS);
@@ -184,7 +184,7 @@ ExtractIpRange(char *match_str, sockaddr* addr1, sockaddr* addr2)
return "malformed IP range";
}
- if (0 != ink_inet_pton(rangeTok[0], &la1.sa)) {
+ if (0 != ats_ip_pton(rangeTok[0], &la1.sa)) {
return "malformed IP address";
}
@@ -192,7 +192,7 @@ ExtractIpRange(char *match_str, sockaddr* addr1, sockaddr* addr2)
if (numToks == 2) {
if (mask) {
- if (!ink_inet_is_ip4(&la1)) {
+ if (!ats_is_ip4(&la1)) {
return "Masks supported only for IPv4";
}
// coverity[secure_coding]
@@ -209,26 +209,26 @@ ExtractIpRange(char *match_str, sockaddr* addr1, sockaddr* addr2)
} else {
mask_val = htonl(0xffffffff >> mask_bits);
}
- in_addr_t a = ink_inet_ip4_addr_cast(&la1);
- ink_inet_ip4_set(&la2, a | mask_val);
- ink_inet_ip4_set(&la1, a & (mask_val ^ 0xffffffff));
+ in_addr_t a = ats_ip4_addr_cast(&la1);
+ ats_ip4_set(&la2, a | mask_val);
+ ats_ip4_set(&la1, a & (mask_val ^ 0xffffffff));
} else {
- if (0 != ink_inet_pton(rangeTok[1], &la2)) {
+ if (0 != ats_ip_pton(rangeTok[1], &la2)) {
return "malformed ip address at range end";
}
}
- if (1 == ink_inet_cmp(&la1.sa, &la2.sa)) {
+ if (1 == ats_ip_addr_cmp(&la1.sa, &la2.sa)) {
return "range start greater than range end";
}
- ink_inet_copy(addr2, &la2);
+ ats_ip_copy(addr2, &la2);
} else {
- ink_inet_copy(addr2, &la1);
+ ats_ip_copy(addr2, &la1);
}
- ink_inet_copy(addr1, &la1);
+ ats_ip_copy(addr1, &la1);
return NULL;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/MatcherUtils.h
----------------------------------------------------------------------
diff --git a/lib/ts/MatcherUtils.h b/lib/ts/MatcherUtils.h
index 3bc5385..94fd2b7 100644
--- a/lib/ts/MatcherUtils.h
+++ b/lib/ts/MatcherUtils.h
@@ -61,7 +61,7 @@ inline char const* ExtractIpRange(
sockaddr_in6* addr1, ///< [in,out] Returned address in network order.
sockaddr_in6* addr2 ///< [in,out] Returned address in network order.
) {
- return ExtractIpRange(match_str, ink_inet_sa_cast(addr1), ink_inet_sa_cast(addr2));
+ return ExtractIpRange(match_str, ats_ip_sa_cast(addr1), ats_ip_sa_cast(addr2));
}
char *tokLine(char *buf, char **last);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/ink_inet.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_inet.cc b/lib/ts/ink_inet.cc
index a42eb22..8a67fdb 100644
--- a/lib/ts/ink_inet.cc
+++ b/lib/ts/ink_inet.cc
@@ -32,7 +32,7 @@ extern "C"
}
#endif
-InkInetAddr const InkInetAddr::INVALID;
+IpAddr const IpAddr::INVALID;
struct hostent *
ink_gethostbyname_r(char *hostname, ink_gethostbyname_r_data * data)
@@ -88,18 +88,6 @@ ink_gethostbyaddr_r(char *ip, int len, int type, ink_gethostbyaddr_r_data * data
return r;
}
-unsigned int
-host_to_ip(char *hostname)
-{
- struct hostent *he;
-
- he = gethostbyname(hostname);
- if (he == NULL)
- return INADDR_ANY;
-
- return *(unsigned int *) he->h_addr;
-}
-
uint32_t
ink_inet_addr(const char *s)
{
@@ -164,16 +152,16 @@ ink_inet_addr(const char *s)
return htonl((uint32_t) - 1);
}
-const char *ink_inet_ntop(const struct sockaddr *addr, char *dst, size_t size)
+const char *ats_ip_ntop(const struct sockaddr *addr, char *dst, size_t size)
{
char const* zret = 0;
switch (addr->sa_family) {
case AF_INET:
- zret = inet_ntop(AF_INET, &ink_inet_ip4_addr_cast(addr), dst, size);
+ zret = inet_ntop(AF_INET, &ats_ip4_addr_cast(addr), dst, size);
break;
case AF_INET6:
- zret = inet_ntop(AF_INET6, &ink_inet_ip6_addr_cast(addr), dst, size);
+ zret = inet_ntop(AF_INET6, &ats_ip6_addr_cast(addr), dst, size);
break;
default:
zret = dst;
@@ -184,7 +172,7 @@ const char *ink_inet_ntop(const struct sockaddr *addr, char *dst, size_t size)
}
char const*
-ink_inet_family_name(int family) {
+ats_ip_family_name(int family) {
return AF_INET == family ? "IPv4"
: AF_INET6 == family ? "IPv6"
: "Unspec"
@@ -207,14 +195,14 @@ uint16_t ink_inet_port(const struct sockaddr *addr)
return port;
}
-char const* ink_inet_nptop(
+char const* ats_ip_nptop(
sockaddr const* addr,
char* dst, size_t size
) {
char buff[INET6_ADDRSTRLEN];
snprintf(dst, size, "%s:%u",
- ink_inet_ntop(addr, buff, sizeof(buff)),
- ink_inet_get_port(addr)
+ ats_ip_ntop(addr, buff, sizeof(buff)),
+ ats_ip_port_host_order(addr)
);
return dst;
}
@@ -269,12 +257,12 @@ ink_inet_parse(ts::ConstBuffer src, ts::ConstBuffer* addr, ts::ConstBuffer* port
}
int
-ink_inet_pton(char const* text, sockaddr* ip) {
+ats_ip_pton(char const* text, sockaddr* ip) {
int zret = -1;
ts::ConstBuffer addr, port;
ts::ConstBuffer src(text, strlen(text)+1);
- ink_inet_invalidate(ip);
+ ats_ip_invalidate(ip);
if (0 == ink_inet_parse(src, &addr, &port)) {
// Copy if not terminated.
if (0 != addr[addr.size()-1]) {
@@ -287,46 +275,46 @@ ink_inet_pton(char const* text, sockaddr* ip) {
in6_addr addr6;
if (inet_pton(AF_INET6, addr.data(), &addr6)) {
zret = 0;
- ink_inet_ip6_set(ip, addr6);
+ ats_ip6_set(ip, addr6);
}
} else { // no colon -> must be IPv4
in_addr addr4;
if (inet_aton(addr.data(), &addr4)) {
zret = 0;
- ink_inet_ip4_set(ip, addr4.s_addr);
+ ats_ip4_set(ip, addr4.s_addr);
}
}
// If we had a successful conversion, set the port.
- if (ink_inet_is_ip(ip))
- ink_inet_port_cast(ip) = port ? htons(atoi(port.data())) : 0;
+ if (ats_is_ip(ip))
+ ats_ip_port_cast(ip) = port ? htons(atoi(port.data())) : 0;
}
return zret;
}
-uint32_t ink_inet_hash(sockaddr const* addr) {
+uint32_t ats_ip_hash(sockaddr const* addr) {
union md5sum {
unsigned char c[16];
uint32_t i;
} zret;
zret.i = 0;
- if (ink_inet_is_ip4(addr)) {
- zret.i = ink_inet_ip4_addr_cast(addr);
- } else if (ink_inet_is_ip6(addr)) {
- ink_code_md5(const_cast<uint8_t*>(ink_inet_addr8_cast(addr)), INK_IP6_SIZE, zret.c);
+ if (ats_is_ip4(addr)) {
+ zret.i = ats_ip4_addr_cast(addr);
+ } else if (ats_is_ip6(addr)) {
+ ink_code_md5(const_cast<uint8_t*>(ats_ip_addr8_cast(addr)), INK_IP6_SIZE, zret.c);
}
return zret.i;
}
int
-ink_inet_to_hex(sockaddr const* src, char* dst, size_t len) {
+ats_ip_to_hex(sockaddr const* src, char* dst, size_t len) {
int zret = 0;
ink_assert(len);
char const* dst_limit = dst + len - 1; // reserve null space.
- if (ink_inet_is_ip(src)) {
- uint8_t const* data = ink_inet_addr8_cast(src);
- for ( uint8_t const* src_limit = data + ink_inet_addr_size(src)
+ if (ats_is_ip(src)) {
+ uint8_t const* data = ats_ip_addr8_cast(src);
+ for ( uint8_t const* src_limit = data + ats_ip_addr_size(src)
; data < src_limit && dst+1 < dst_limit
; ++data, zret += 2
) {
@@ -341,48 +329,48 @@ ink_inet_to_hex(sockaddr const* src, char* dst, size_t len) {
return zret;
}
-sockaddr* ink_inet_ip_set(
+sockaddr* ats_ip_set(
sockaddr* dst,
- InkInetAddr const& addr,
+ IpAddr const& addr,
uint16_t port
) {
- if (AF_INET == addr._family) ink_inet_ip4_set(dst, addr._addr._ip4, port);
- else if (AF_INET6 == addr._family) ink_inet_ip6_set(dst, addr._addr._ip6, port);
- else ink_inet_invalidate(dst);
+ if (AF_INET == addr._family) ats_ip4_set(dst, addr._addr._ip4, port);
+ else if (AF_INET6 == addr._family) ats_ip6_set(dst, addr._addr._ip6, port);
+ else ats_ip_invalidate(dst);
return dst;
}
int
-InkInetAddr::load(char const* text) {
- ts_ip_endpoint ip;
- int zret = ink_inet_pton(text, &ip);
+IpAddr::load(char const* text) {
+ IpEndpoint ip;
+ int zret = ats_ip_pton(text, &ip);
*this = ip;
return zret;
}
char*
-InkInetAddr::toString(char* dest, size_t len) const {
- ts_ip_endpoint ip;
+IpAddr::toString(char* dest, size_t len) const {
+ IpEndpoint ip;
ip.assign(*this);
- ink_inet_ntop(&ip, dest, len);
+ ats_ip_ntop(&ip, dest, len);
return dest;
}
bool
-InkInetAddr::isMulticast() const {
+IpAddr::isMulticast() const {
return (AF_INET == _family && 0xe == _addr._byte[0]) ||
(AF_INET6 == _family && IN6_IS_ADDR_MULTICAST(&_addr._ip6))
;
}
bool
-operator == (InkInetAddr const& lhs, sockaddr const* rhs) {
+operator == (IpAddr const& lhs, sockaddr const* rhs) {
bool zret = false;
if (lhs._family == rhs->sa_family) {
if (AF_INET == lhs._family) {
- zret = lhs._addr._ip4 == ink_inet_ip4_addr_cast(rhs);
+ zret = lhs._addr._ip4 == ats_ip4_addr_cast(rhs);
} else if (AF_INET6 == lhs._family) {
- zret = 0 == memcmp(&lhs._addr._ip6, &ink_inet_ip6_addr_cast(rhs), sizeof(in6_addr));
+ zret = 0 == memcmp(&lhs._addr._ip6, &ats_ip6_addr_cast(rhs), sizeof(in6_addr));
} else { // map all non-IP to the same thing.
zret = true;
}
@@ -391,9 +379,9 @@ operator == (InkInetAddr const& lhs, sockaddr const* rhs) {
}
int
-ink_inet_getbestaddrinfo(char const* host,
- ts_ip_endpoint* ip4,
- ts_ip_endpoint* ip6
+ats_ip_getbestaddrinfo(char const* host,
+ IpEndpoint* ip4,
+ IpEndpoint* ip6
) {
int zret = -1;
int port = 0; // port value to assign if we find an address.
@@ -402,8 +390,8 @@ ink_inet_getbestaddrinfo(char const* host,
ts::ConstBuffer addr_text, port_text;
ts::ConstBuffer src(host, strlen(host)+1);
- if (ip4) ink_inet_invalidate(ip4);
- if (ip6) ink_inet_invalidate(ip6);
+ if (ip4) ats_ip_invalidate(ip4);
+ if (ip6) ats_ip_invalidate(ip6);
if (0 == ink_inet_parse(src, &addr_text, &port_text)) {
// Copy if not terminated.
@@ -435,28 +423,28 @@ ink_inet_getbestaddrinfo(char const* host,
; ai_spot = ai_spot->ai_next
) {
sockaddr const* ai_ip = ai_spot->ai_addr;
- if (!ink_inet_is_ip(ai_ip)) spot_type = NA;
- else if (ink_inet_is_loopback(ai_ip)) spot_type = LO;
- else if (ink_inet_is_nonroutable(ai_ip)) spot_type = NR;
- else if (ink_inet_is_multicast(ai_ip)) spot_type = MC;
+ if (!ats_is_ip(ai_ip)) spot_type = NA;
+ else if (ats_is_ip_loopback(ai_ip)) spot_type = LO;
+ else if (ats_is_ip_nonroutable(ai_ip)) spot_type = NR;
+ else if (ats_is_ip_multicast(ai_ip)) spot_type = MC;
else spot_type = GA;
if (spot_type == NA) continue; // Next!
- if (ink_inet_is_ip4(ai_ip)) {
+ if (ats_is_ip4(ai_ip)) {
if (spot_type > ip4_type) {
ip4_src = ai_ip;
ip4_type = spot_type;
}
- } else if (ink_inet_is_ip6(ai_ip)) {
+ } else if (ats_is_ip6(ai_ip)) {
if (spot_type > ip6_type) {
ip6_src = ai_ip;
ip6_type = spot_type;
}
}
}
- if (ip4_type > NA) ink_inet_copy(ip4, ip4_src);
- if (ip6_type > NA) ink_inet_copy(ip6, ip6_src);
+ if (ip4_type > NA) ats_ip_copy(ip4, ip4_src);
+ if (ip6_type > NA) ats_ip_copy(ip6, ip6_src);
freeaddrinfo(ai_result); // free *after* the copy.
}
@@ -466,10 +454,10 @@ ink_inet_getbestaddrinfo(char const* host,
// would get all the digits so the next character is a non-digit (null or
// not) and atoi will do the right thing in either case.
if (port_text.size()) port = htons(atoi(port_text.data()));
- if (ink_inet_is_ip(ip4)) ink_inet_port_cast(ip4) = port;
- if (ink_inet_is_ip(ip6)) ink_inet_port_cast(ip6) = port;
+ if (ats_is_ip(ip4)) ats_ip_port_cast(ip4) = port;
+ if (ats_is_ip(ip6)) ats_ip_port_cast(ip6) = port;
- if (!ink_inet_is_ip(ip4) && !ink_inet_is_ip(ip6)) zret = -1;
+ if (!ats_is_ip(ip4) && !ats_is_ip(ip6)) zret = -1;
return zret;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/ink_inet.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_inet.h b/lib/ts/ink_inet.h
index 759594b..6998c38 100644
--- a/lib/ts/ink_inet.h
+++ b/lib/ts/ink_inet.h
@@ -45,7 +45,7 @@ static inline bool IN6_IS_ADDR_UNSPECIFIED(in6_addr const* addr) {
}
#endif
-class InkInetAddr; // forward declare.
+class IpAddr; // forward declare.
/** A union to hold the standard IP address structures.
By standard we mean @c sockaddr compliant.
@@ -62,8 +62,8 @@ class InkInetAddr; // forward declare.
structure will make it easy to add if that becomes necessary.
*/
-union ts_ip_endpoint {
- typedef ts_ip_endpoint self; ///< Self reference type.
+union IpEndpoint {
+ typedef IpEndpoint self; ///< Self reference type.
struct sockaddr sa; ///< Generic address.
struct sockaddr_in sin; ///< IPv4
@@ -74,7 +74,7 @@ union ts_ip_endpoint {
);
/// Construct from an @a addr and @a port.
self& assign(
- InkInetAddr const& addr, ///< Address and address family.
+ IpAddr const& addr, ///< Address and address family.
uint16_t port = 0 ///< Port (network order).
);
@@ -117,16 +117,6 @@ struct ink_gethostbyaddr_r_data
};
/**
- returns the IP address of the hostname. If the hostname has
- multiple IP addresses, the first IP address in the list returned
- by 'gethostbyname' is returned.
-
- @note Not thread-safe
-
-*/
-unsigned int host_to_ip(char *hostname);
-
-/**
Wrapper for gethostbyname_r(). If successful, returns a pointer
to the hostent structure. Returns NULL and sets data->herrno to
the appropriate error code on failure.
@@ -158,7 +148,7 @@ struct hostent *ink_gethostbyaddr_r(char *ip, int len, int type, ink_gethostbyad
*/
inkcoreapi uint32_t ink_inet_addr(const char *s);
-const char *ink_inet_ntop(const struct sockaddr *addr, char *dst, size_t size);
+const char *ats_ip_ntop(const struct sockaddr *addr, char *dst, size_t size);
uint16_t ink_inet_port(const struct sockaddr *addr);
// --
@@ -167,13 +157,13 @@ static size_t const INK_IP6_SIZE = sizeof(in6_addr);
/// Reset an address to invalid.
/// @note Useful for marking a member as not yet set.
-inline void ink_inet_invalidate(sockaddr* addr) {
+inline void ats_ip_invalidate(sockaddr* addr) {
addr->sa_family = AF_UNSPEC;
}
-inline void ink_inet_invalidate(sockaddr_in6* addr) {
+inline void ats_ip_invalidate(sockaddr_in6* addr) {
addr->sin6_family = AF_UNSPEC;
}
-inline void ink_inet_invalidate(ts_ip_endpoint* ip) {
+inline void ats_ip_invalidate(IpEndpoint* ip) {
ip->sa.sa_family = AF_UNSPEC;
}
@@ -181,70 +171,70 @@ inline void ink_inet_invalidate(ts_ip_endpoint* ip) {
@return The string name (never @c NULL).
*/
char const*
-ink_inet_family_name(int family);
+ats_ip_family_name(int family);
/// Test for IP protocol.
/// @return @c true if the address is IP, @c false otherwise.
-inline bool ink_inet_is_ip(sockaddr const* addr) {
+inline bool ats_is_ip(sockaddr const* addr) {
return addr
&& (AF_INET == addr->sa_family || AF_INET6 == addr->sa_family);
}
/// @return @c true if the address is IP, @c false otherwise.
-inline bool ink_inet_is_ip(ts_ip_endpoint const* addr) {
+inline bool ats_is_ip(IpEndpoint const* addr) {
return addr
&& (AF_INET == addr->sa.sa_family || AF_INET6 == addr->sa.sa_family);
}
/// Test for IP protocol.
/// @return @c true if the value is an IP address family, @c false otherwise.
-inline bool ink_inet_is_ip(int family) {
+inline bool ats_is_ip(int family) {
return AF_INET == family || AF_INET6 == family;
}
/// Test for IPv4 protocol.
/// @return @c true if the address is IPv4, @c false otherwise.
-inline bool ink_inet_is_ip4(sockaddr const* addr) {
+inline bool ats_is_ip4(sockaddr const* addr) {
return addr && AF_INET == addr->sa_family;
}
/// Test for IPv4 protocol.
/// @note Convenience overload.
/// @return @c true if the address is IPv4, @c false otherwise.
-inline bool ink_inet_is_ip4(ts_ip_endpoint const* addr) {
+inline bool ats_is_ip4(IpEndpoint const* addr) {
return addr && AF_INET == addr->sa.sa_family;
}
/// Test for IPv6 protocol.
/// @return @c true if the address is IPv6, @c false otherwise.
-inline bool ink_inet_is_ip6(sockaddr const* addr) {
+inline bool ats_is_ip6(sockaddr const* addr) {
return addr && AF_INET6 == addr->sa_family;
}
/// Test for IPv6 protocol.
/// @note Convenience overload.
/// @return @c true if the address is IPv6, @c false otherwise.
-inline bool ink_inet_is_ip6(ts_ip_endpoint const* addr) {
+inline bool ats_is_ip6(IpEndpoint const* addr) {
return addr && AF_INET6 == addr->sa.sa_family;
}
/// @return @c true if the address families are compatible.
-inline bool ink_inet_are_compatible(
+inline bool ats_ip_are_compatible(
sockaddr const* lhs, ///< Address to test.
sockaddr const* rhs ///< Address to test.
) {
return lhs->sa_family == rhs->sa_family;
}
/// @return @c true if the address families are compatible.
-inline bool ink_inet_are_compatible(
- ts_ip_endpoint const* lhs, ///< Address to test.
- ts_ip_endpoint const* rhs ///< Address to test.
+inline bool ats_ip_are_compatible(
+ IpEndpoint const* lhs, ///< Address to test.
+ IpEndpoint const* rhs ///< Address to test.
) {
- return ink_inet_are_compatible(&lhs->sa, &rhs->sa);
+ return ats_ip_are_compatible(&lhs->sa, &rhs->sa);
}
/// @return @c true if the address families are compatible.
-inline bool ink_inet_are_compatible(
+inline bool ats_ip_are_compatible(
int lhs, ///< Address family to test.
sockaddr const* rhs ///< Address to test.
) {
return lhs == rhs->sa_family;
}
/// @return @c true if the address families are compatible.
-inline bool ink_inet_are_compatible(
+inline bool ats_ip_are_compatible(
sockaddr const* lhs, ///< Address to test.
int rhs ///< Family to test.
) {
@@ -257,77 +247,77 @@ inline bool ink_inet_are_compatible(
// ip4_cast converts to sockaddr_in (because that's effectively an IPv4 addr).
// ip6_cast converts to sockaddr_in6
-inline sockaddr* ink_inet_sa_cast(sockaddr_storage* a) {
+inline sockaddr* ats_ip_sa_cast(sockaddr_storage* a) {
return static_cast<sockaddr*>(static_cast<void*>(a));
}
-inline sockaddr const* ink_inet_sa_cast(sockaddr_storage const* a) {
+inline sockaddr const* ats_ip_sa_cast(sockaddr_storage const* a) {
return static_cast<sockaddr const*>(static_cast<void const*>(a));
}
-inline sockaddr* ink_inet_sa_cast(sockaddr_in* a) {
+inline sockaddr* ats_ip_sa_cast(sockaddr_in* a) {
return static_cast<sockaddr*>(static_cast<void*>(a));
}
-inline sockaddr_storage const* ink_inet_sa_cast(sockaddr_in const* a) {
+inline sockaddr_storage const* ats_ip_sa_cast(sockaddr_in const* a) {
return static_cast<sockaddr_storage const*>(static_cast<void const*>(a));
}
-inline sockaddr* ink_inet_sa_cast(sockaddr_in6* a) {
+inline sockaddr* ats_ip_sa_cast(sockaddr_in6* a) {
return static_cast<sockaddr*>(static_cast<void*>(a));
}
-inline sockaddr const* ink_inet_sa_cast(sockaddr_in6 const* a) {
+inline sockaddr const* ats_ip_sa_cast(sockaddr_in6 const* a) {
return static_cast<sockaddr const*>(static_cast<void const*>(a));
}
-inline sockaddr_storage* ink_inet_ss_cast(sockaddr* a) {
+inline sockaddr_storage* ats_ip_ss_cast(sockaddr* a) {
return static_cast<sockaddr_storage*>(static_cast<void*>(a));
}
-inline sockaddr_storage const* ink_inet_ss_cast(sockaddr const* a) {
+inline sockaddr_storage const* ats_ip_ss_cast(sockaddr const* a) {
return static_cast<sockaddr_storage const*>(static_cast<void const*>(a));
}
-inline sockaddr_in* ink_inet_ip4_cast(sockaddr* a) {
+inline sockaddr_in* ats_ip4_cast(sockaddr* a) {
return static_cast<sockaddr_in*>(static_cast<void*>(a));
}
-inline sockaddr_in const* ink_inet_ip4_cast(sockaddr const* a) {
+inline sockaddr_in const* ats_ip4_cast(sockaddr const* a) {
return static_cast<sockaddr_in const*>(static_cast<void const*>(a));
}
-inline sockaddr_in& ink_inet_ip4_cast(sockaddr& a) {
+inline sockaddr_in& ats_ip4_cast(sockaddr& a) {
return *static_cast<sockaddr_in*>(static_cast<void*>(&a));
}
-inline sockaddr_in const& ink_inet_ip4_cast(sockaddr const& a) {
+inline sockaddr_in const& ats_ip4_cast(sockaddr const& a) {
return *static_cast<sockaddr_in const*>(static_cast<void const*>(&a));
}
-inline sockaddr_in* ink_inet_ip4_cast(sockaddr_in6* a) {
+inline sockaddr_in* ats_ip4_cast(sockaddr_in6* a) {
return static_cast<sockaddr_in*>(static_cast<void*>(a));
}
-inline sockaddr_in const* ink_inet_ip4_cast(sockaddr_in6 const* a) {
+inline sockaddr_in const* ats_ip4_cast(sockaddr_in6 const* a) {
return static_cast<sockaddr_in const*>(static_cast<void const*>(a));
}
-inline sockaddr_in& ink_inet_ip4_cast(sockaddr_in6& a) {
+inline sockaddr_in& ats_ip4_cast(sockaddr_in6& a) {
return *static_cast<sockaddr_in*>(static_cast<void*>(&a));
}
-inline sockaddr_in const& ink_inet_ip4_cast(sockaddr_in6 const& a) {
+inline sockaddr_in const& ats_ip4_cast(sockaddr_in6 const& a) {
return *static_cast<sockaddr_in const*>(static_cast<void const*>(&a));
}
-inline sockaddr_in6* ink_inet_ip6_cast(sockaddr* a) {
+inline sockaddr_in6* ats_ip6_cast(sockaddr* a) {
return static_cast<sockaddr_in6*>(static_cast<void*>(a));
}
-inline sockaddr_in6 const* ink_inet_ip6_cast(sockaddr const* a) {
+inline sockaddr_in6 const* ats_ip6_cast(sockaddr const* a) {
return static_cast<sockaddr_in6 const*>(static_cast<void const*>(a));
}
-inline sockaddr_in6& ink_inet_ip6_cast(sockaddr& a) {
+inline sockaddr_in6& ats_ip6_cast(sockaddr& a) {
return *static_cast<sockaddr_in6*>(static_cast<void*>(&a));
}
-inline sockaddr_in6 const& ink_inet_ip6_cast(sockaddr const& a) {
+inline sockaddr_in6 const& ats_ip6_cast(sockaddr const& a) {
return *static_cast<sockaddr_in6 const*>(static_cast<void const*>(&a));
}
/// @return The @c sockaddr size for the family of @a addr.
-inline size_t ink_inet_ip_size(
+inline size_t ats_ip_size(
sockaddr const* addr ///< Address object.
) {
return AF_INET == addr->sa_family ? sizeof(sockaddr_in)
@@ -335,8 +325,8 @@ inline size_t ink_inet_ip_size(
: 0
;
}
-inline size_t ink_inet_ip_size(
- ts_ip_endpoint const* addr ///< Address object.
+inline size_t ats_ip_size(
+ IpEndpoint const* addr ///< Address object.
) {
return AF_INET == addr->sa.sa_family ? sizeof(sockaddr_in)
: AF_INET6 == addr->sa.sa_family ? sizeof(sockaddr_in6)
@@ -344,7 +334,7 @@ inline size_t ink_inet_ip_size(
;
}
/// @return The size of the IP address only.
-inline size_t ink_inet_addr_size(
+inline size_t ats_ip_addr_size(
sockaddr const* addr ///< Address object.
) {
return AF_INET == addr->sa_family ? sizeof(in_addr_t)
@@ -352,8 +342,8 @@ inline size_t ink_inet_addr_size(
: 0
;
}
-inline size_t ink_inet_addr_size(
- ts_ip_endpoint const* addr ///< Address object.
+inline size_t ats_ip_addr_size(
+ IpEndpoint const* addr ///< Address object.
) {
return AF_INET == addr->sa.sa_family ? sizeof(in_addr_t)
: AF_INET6 == addr->sa.sa_family ? sizeof(in6_addr)
@@ -363,28 +353,28 @@ inline size_t ink_inet_addr_size(
/** Get a reference to the port in an address.
@note Because this is direct access, the port value is in network order.
- @see ink_inet_get_port.
+ @see ats_ip_port_host_order.
@return A reference to the port value in an IPv4 or IPv6 address.
@internal This is primarily for internal use but it might be handy for
clients so it is exposed.
*/
-inline uint16_t& ink_inet_port_cast(sockaddr* sa) {
+inline uint16_t& ats_ip_port_cast(sockaddr* sa) {
static uint16_t dummy = 0;
- return ink_inet_is_ip4(sa)
- ? ink_inet_ip4_cast(sa)->sin_port
- : ink_inet_is_ip6(sa)
- ? ink_inet_ip6_cast(sa)->sin6_port
+ return ats_is_ip4(sa)
+ ? ats_ip4_cast(sa)->sin_port
+ : ats_is_ip6(sa)
+ ? ats_ip6_cast(sa)->sin6_port
: (dummy = 0)
;
}
-inline uint16_t const& ink_inet_port_cast(sockaddr const* sa) {
- return ink_inet_port_cast(const_cast<sockaddr*>(sa));
+inline uint16_t const& ats_ip_port_cast(sockaddr const* sa) {
+ return ats_ip_port_cast(const_cast<sockaddr*>(sa));
}
-inline uint16_t const& ink_inet_port_cast(ts_ip_endpoint const* ip) {
- return ink_inet_port_cast(const_cast<sockaddr*>(&ip->sa));
+inline uint16_t const& ats_ip_port_cast(IpEndpoint const* ip) {
+ return ats_ip_port_cast(const_cast<sockaddr*>(&ip->sa));
}
-inline uint16_t& ink_inet_port_cast(ts_ip_endpoint* ip) {
- return ink_inet_port_cast(&ip->sa);
+inline uint16_t& ats_ip_port_cast(IpEndpoint* ip) {
+ return ats_ip_port_cast(&ip->sa);
}
/** Access the IPv4 address.
@@ -395,10 +385,10 @@ inline uint16_t& ink_inet_port_cast(ts_ip_endpoint* ip) {
@return A reference to the IPv4 address in @a addr.
*/
-inline in_addr_t& ink_inet_ip4_addr_cast(sockaddr* addr) {
+inline in_addr_t& ats_ip4_addr_cast(sockaddr* addr) {
static in_addr_t dummy = 0;
- return ink_inet_is_ip4(addr)
- ? ink_inet_ip4_cast(addr)->sin_addr.s_addr
+ return ats_is_ip4(addr)
+ ? ats_ip4_cast(addr)->sin_addr.s_addr
: (dummy = 0)
;
}
@@ -411,10 +401,10 @@ inline in_addr_t& ink_inet_ip4_addr_cast(sockaddr* addr) {
@return A reference to the IPv4 address in @a addr.
*/
-inline in_addr_t const& ink_inet_ip4_addr_cast(sockaddr const* addr) {
+inline in_addr_t const& ats_ip4_addr_cast(sockaddr const* addr) {
static in_addr_t dummy = 0;
- return ink_inet_is_ip4(addr)
- ? ink_inet_ip4_cast(addr)->sin_addr.s_addr
+ return ats_is_ip4(addr)
+ ? ats_ip4_cast(addr)->sin_addr.s_addr
: static_cast<in_addr_t const&>(dummy = 0)
;
}
@@ -428,8 +418,8 @@ inline in_addr_t const& ink_inet_ip4_addr_cast(sockaddr const* addr) {
@return A reference to the IPv4 address in @a addr.
*/
-inline in_addr_t& ink_inet_ip4_addr_cast(ts_ip_endpoint* ip) {
- return ink_inet_ip4_addr_cast(&ip->sa);
+inline in_addr_t& ats_ip4_addr_cast(IpEndpoint* ip) {
+ return ats_ip4_addr_cast(&ip->sa);
}
/** Access the IPv4 address.
@@ -441,8 +431,8 @@ inline in_addr_t& ink_inet_ip4_addr_cast(ts_ip_endpoint* ip) {
@return A reference to the IPv4 address in @a addr.
*/
-inline in_addr_t const& ink_inet_ip4_addr_cast(ts_ip_endpoint const* ip) {
- return ink_inet_ip4_addr_cast(&ip->sa);
+inline in_addr_t const& ats_ip4_addr_cast(IpEndpoint const* ip) {
+ return ats_ip4_addr_cast(&ip->sa);
}
/** Access the IPv6 address.
@@ -453,16 +443,16 @@ inline in_addr_t const& ink_inet_ip4_addr_cast(ts_ip_endpoint const* ip) {
@return A reference to the IPv6 address in @a addr.
*/
-inline in6_addr& ink_inet_ip6_addr_cast(sockaddr* addr) {
- return ink_inet_ip6_cast(addr)->sin6_addr;
+inline in6_addr& ats_ip6_addr_cast(sockaddr* addr) {
+ return ats_ip6_cast(addr)->sin6_addr;
}
-inline in6_addr const& ink_inet_ip6_addr_cast(sockaddr const* addr) {
- return ink_inet_ip6_cast(addr)->sin6_addr;
+inline in6_addr const& ats_ip6_addr_cast(sockaddr const* addr) {
+ return ats_ip6_cast(addr)->sin6_addr;
}
-inline in6_addr& ink_inet_ip6_addr_cast(ts_ip_endpoint* ip) {
+inline in6_addr& ats_ip6_addr_cast(IpEndpoint* ip) {
return ip->sin6.sin6_addr;
}
-inline in6_addr const& ink_inet_ip6_addr_cast(ts_ip_endpoint const* ip) {
+inline in6_addr const& ats_ip6_addr_cast(IpEndpoint const* ip) {
return ip->sin6.sin6_addr;
}
@@ -472,16 +462,16 @@ inline in6_addr const& ink_inet_ip6_addr_cast(ts_ip_endpoint const* ip) {
@return A pointer to the address information in @a addr or @c NULL
if @a addr is not an IP address.
*/
-inline uint32_t* ink_inet_addr32_cast(sockaddr* addr) {
+inline uint32_t* ats_ip_addr32_cast(sockaddr* addr) {
uint32_t* zret = 0;
switch(addr->sa_family) {
- case AF_INET: zret = reinterpret_cast<uint32_t*>(&ink_inet_ip4_addr_cast(addr)); break;
- case AF_INET6: zret = reinterpret_cast<uint32_t*>(&ink_inet_ip6_addr_cast(addr)); break;
+ case AF_INET: zret = reinterpret_cast<uint32_t*>(&ats_ip4_addr_cast(addr)); break;
+ case AF_INET6: zret = reinterpret_cast<uint32_t*>(&ats_ip6_addr_cast(addr)); break;
}
return zret;
}
-inline uint32_t const* ink_inet_addr32_cast(sockaddr const* addr) {
- return ink_inet_addr32_cast(const_cast<sockaddr*>(addr));
+inline uint32_t const* ats_ip_addr32_cast(sockaddr const* addr) {
+ return ats_ip_addr32_cast(const_cast<sockaddr*>(addr));
}
/** Cast an IP address to an array of @c uint8_t.
@@ -489,65 +479,65 @@ inline uint32_t const* ink_inet_addr32_cast(sockaddr const* addr) {
must be checked independently of this function.
@return A pointer to the address information in @a addr or @c NULL
if @a addr is not an IP address.
- @see ink_inet_addr_size
+ @see ats_ip_addr_size
*/
-inline uint8_t* ink_inet_addr8_cast(sockaddr* addr) {
+inline uint8_t* ats_ip_addr8_cast(sockaddr* addr) {
uint8_t* zret = 0;
switch(addr->sa_family) {
- case AF_INET: zret = reinterpret_cast<uint8_t*>(&ink_inet_ip4_addr_cast(addr)); break;
- case AF_INET6: zret = reinterpret_cast<uint8_t*>(&ink_inet_ip6_addr_cast(addr)); break;
+ case AF_INET: zret = reinterpret_cast<uint8_t*>(&ats_ip4_addr_cast(addr)); break;
+ case AF_INET6: zret = reinterpret_cast<uint8_t*>(&ats_ip6_addr_cast(addr)); break;
}
return zret;
}
-inline uint8_t const* ink_inet_addr8_cast(sockaddr const* addr) {
- return ink_inet_addr8_cast(const_cast<sockaddr*>(addr));
+inline uint8_t const* ats_ip_addr8_cast(sockaddr const* addr) {
+ return ats_ip_addr8_cast(const_cast<sockaddr*>(addr));
}
-inline uint8_t* ink_inet_addr8_cast(ts_ip_endpoint* ip) {
- return ink_inet_addr8_cast(&ip->sa);
+inline uint8_t* ats_ip_addr8_cast(IpEndpoint* ip) {
+ return ats_ip_addr8_cast(&ip->sa);
}
-inline uint8_t const* ink_inet_addr8_cast(ts_ip_endpoint const* ip) {
- return ink_inet_addr8_cast(&ip->sa);
+inline uint8_t const* ats_ip_addr8_cast(IpEndpoint const* ip) {
+ return ats_ip_addr8_cast(&ip->sa);
}
/// Check for loopback.
/// @return @c true if this is an IP loopback address, @c false otherwise.
-inline bool ink_inet_is_loopback(sockaddr const* ip) {
+inline bool ats_is_ip_loopback(sockaddr const* ip) {
return ip
&& (
- (AF_INET == ip->sa_family && 0x7F == ink_inet_addr8_cast(ip)[0])
+ (AF_INET == ip->sa_family && 0x7F == ats_ip_addr8_cast(ip)[0])
||
- (AF_INET6 == ip->sa_family && IN6_IS_ADDR_LOOPBACK(&ink_inet_ip6_addr_cast(ip)))
+ (AF_INET6 == ip->sa_family && IN6_IS_ADDR_LOOPBACK(&ats_ip6_addr_cast(ip)))
);
}
/// Check for loopback.
/// @return @c true if this is an IP loopback address, @c false otherwise.
-inline bool ink_inet_is_loopback(ts_ip_endpoint const* ip) {
- return ink_inet_is_loopback(&ip->sa);
+inline bool ats_is_ip_loopback(IpEndpoint const* ip) {
+ return ats_is_ip_loopback(&ip->sa);
}
/// Check for multicast.
/// @return @true if @a ip is multicast.
-inline bool ink_inet_is_multicast(sockaddr const* ip) {
+inline bool ats_is_ip_multicast(sockaddr const* ip) {
return ip
&& (
- (AF_INET == ip->sa_family && 0xe == *ink_inet_addr8_cast(ip))
+ (AF_INET == ip->sa_family && 0xe == *ats_ip_addr8_cast(ip))
||
- (AF_INET6 == ip->sa_family && IN6_IS_ADDR_MULTICAST(&ink_inet_ip6_addr_cast(ip)))
+ (AF_INET6 == ip->sa_family && IN6_IS_ADDR_MULTICAST(&ats_ip6_addr_cast(ip)))
);
}
/// Check for multicast.
/// @return @true if @a ip is multicast.
-inline bool ink_inet_is_multicast(ts_ip_endpoint const* ip) {
- return ink_inet_is_multicast(&ip->sa);
+inline bool ats_is_ip_multicast(IpEndpoint const* ip) {
+ return ats_is_ip_multicast(&ip->sa);
}
/// Check for non-routable address.
/// @return @c true if @a ip is a non-routable.
-inline bool ink_inet_is_nonroutable(sockaddr const* ip) {
+inline bool ats_is_ip_nonroutable(sockaddr const* ip) {
bool zret = false;
- if (ink_inet_is_ip4(ip)) {
- in_addr_t a = ink_inet_ip4_addr_cast(ip);
+ if (ats_is_ip4(ip)) {
+ in_addr_t a = ats_ip4_addr_cast(ip);
zret = ((a & htonl(0xFF000000)) == htonl(0x0A000000)) ||
((a & htonl(0xFFFF0000)) == htonl(0xC0A80000)) ||
((a & htonl(0xFFF00000)) == htonl(0xAC100000))
@@ -558,15 +548,15 @@ inline bool ink_inet_is_nonroutable(sockaddr const* ip) {
/// Check for non-routable address.
/// @return @c true if @a ip is a non-routable.
-inline bool ink_inet_is_nonroutable(ts_ip_endpoint const* ip) {
- return ink_inet_is_nonroutable(&ip->sa);
+inline bool ats_is_ip_nonroutable(IpEndpoint const* ip) {
+ return ats_is_ip_nonroutable(&ip->sa);
}
/// Check for being "any" address.
/// @return @c true if @a ip is the any / unspecified address.
-inline bool ink_inet_is_any(sockaddr const* ip) {
- return (ink_inet_is_ip4(ip) && INADDR_ANY == ink_inet_ip4_addr_cast(ip)) ||
- (ink_inet_is_ip6(ip) && IN6_IS_ADDR_UNSPECIFIED(&ink_inet_ip6_addr_cast(ip)))
+inline bool ats_is_ip_any(sockaddr const* ip) {
+ return (ats_is_ip4(ip) && INADDR_ANY == ats_ip4_addr_cast(ip)) ||
+ (ats_is_ip6(ip) && IN6_IS_ADDR_UNSPECIFIED(&ats_ip6_addr_cast(ip)))
;
}
@@ -579,7 +569,7 @@ inline bool ink_inet_is_any(sockaddr const* ip) {
@a dst is marked as invalid.
@return @c true if @a src was an IP address, @c false otherwise.
*/
-inline bool ink_inet_copy(
+inline bool ats_ip_copy(
sockaddr* dst, ///< Destination object.
sockaddr const* src ///< Source object.
) {
@@ -596,28 +586,28 @@ inline bool ink_inet_copy(
dst->sa_len = n;
#endif
} else {
- ink_inet_invalidate(dst);
+ ats_ip_invalidate(dst);
}
return n != 0;
}
-inline bool ink_inet_copy(
- ts_ip_endpoint* dst, ///< Destination object.
+inline bool ats_ip_copy(
+ IpEndpoint* dst, ///< Destination object.
sockaddr const* src ///< Source object.
) {
- return ink_inet_copy(&dst->sa, src);
+ return ats_ip_copy(&dst->sa, src);
}
-inline bool ink_inet_copy(
- ts_ip_endpoint* dst, ///< Destination object.
- ts_ip_endpoint const* src ///< Source object.
+inline bool ats_ip_copy(
+ IpEndpoint* dst, ///< Destination object.
+ IpEndpoint const* src ///< Source object.
) {
- return ink_inet_copy(&dst->sa, &src->sa);
+ return ats_ip_copy(&dst->sa, &src->sa);
}
-inline bool ink_inet_copy(
+inline bool ats_ip_copy(
sockaddr* dst,
- ts_ip_endpoint const* src
+ IpEndpoint const* src
) {
- return ink_inet_copy(dst, &src->sa);
+ return ats_ip_copy(dst, &src->sa);
}
/** Compare two addresses.
@@ -638,7 +628,7 @@ inline bool ink_inet_copy(
@internal This looks like a lot of code for an inline but I think it
should compile down to something reasonable.
*/
-inline int ink_inet_cmp(
+inline int ats_ip_addr_cmp(
sockaddr const* lhs, ///< Left hand operand.
sockaddr const* rhs ///< Right hand operand.
) {
@@ -650,8 +640,8 @@ inline int ink_inet_cmp(
// that is less than an IP address. This includes AF_UNSPEC.
if (AF_INET == ltype) {
if (AF_INET == rtype) {
- in_addr_t la = ntohl(ink_inet_ip4_cast(lhs)->sin_addr.s_addr);
- in_addr_t ra = ntohl(ink_inet_ip4_cast(rhs)->sin_addr.s_addr);
+ in_addr_t la = ntohl(ats_ip4_cast(lhs)->sin_addr.s_addr);
+ in_addr_t ra = ntohl(ats_ip4_cast(rhs)->sin_addr.s_addr);
if (la < ra) zret = -1;
else if (la > ra) zret = 1;
else zret = 0;
@@ -662,10 +652,10 @@ inline int ink_inet_cmp(
}
} else if (AF_INET6 == ltype) {
if (AF_INET6 == rtype) {
- sockaddr_in6 const* lhs_in6 = ink_inet_ip6_cast(lhs);
+ sockaddr_in6 const* lhs_in6 = ats_ip6_cast(lhs);
zret = memcmp(
&lhs_in6->sin6_addr,
- &ink_inet_ip6_cast(rhs)->sin6_addr,
+ &ats_ip6_cast(rhs)->sin6_addr,
sizeof(lhs_in6->sin6_addr)
);
} else {
@@ -684,28 +674,28 @@ inline int ink_inet_cmp(
/** Compare two addresses.
@note Convenience overload.
- @see ink_inet_cmp(sockaddr const* lhs, sockaddr const* rhs)
+ @see ats_ip_addr_cmp(sockaddr const* lhs, sockaddr const* rhs)
*/
-inline int ink_inet_cmp(ts_ip_endpoint const* lhs, ts_ip_endpoint const* rhs) {
- return ink_inet_cmp(&lhs->sa, &rhs->sa);
+inline int ats_ip_addr_cmp(IpEndpoint const* lhs, IpEndpoint const* rhs) {
+ return ats_ip_addr_cmp(&lhs->sa, &rhs->sa);
}
/** Check if two addresses are equal.
@return @c true if @a lhs and @a rhs point to equal addresses,
@c false otherwise.
*/
-inline bool ink_inet_eq(sockaddr const* lhs, sockaddr const* rhs) {
- return 0 == ink_inet_cmp(lhs, rhs);
+inline bool ats_ip_addr_eq(sockaddr const* lhs, sockaddr const* rhs) {
+ return 0 == ats_ip_addr_cmp(lhs, rhs);
}
-inline bool ink_inet_eq(ts_ip_endpoint const* lhs, ts_ip_endpoint const* rhs) {
- return 0 == ink_inet_cmp(&lhs->sa, &rhs->sa);
+inline bool ats_ip_addr_eq(IpEndpoint const* lhs, IpEndpoint const* rhs) {
+ return 0 == ats_ip_addr_cmp(&lhs->sa, &rhs->sa);
}
-inline bool operator == (ts_ip_endpoint const& lhs, ts_ip_endpoint const& rhs) {
- return 0 == ink_inet_cmp(&lhs.sa, &rhs.sa);
+inline bool operator == (IpEndpoint const& lhs, IpEndpoint const& rhs) {
+ return 0 == ats_ip_addr_cmp(&lhs.sa, &rhs.sa);
}
-inline bool operator != (ts_ip_endpoint const& lhs, ts_ip_endpoint const& rhs) {
- return 0 != ink_inet_cmp(&lhs.sa, &rhs.sa);
+inline bool operator != (IpEndpoint const& lhs, IpEndpoint const& rhs) {
+ return 0 != ats_ip_addr_cmp(&lhs.sa, &rhs.sa);
}
//@}
@@ -713,37 +703,37 @@ inline bool operator != (ts_ip_endpoint const& lhs, ts_ip_endpoint const& rhs) {
/// Get IP TCP/UDP port.
/// @return The port in host order for an IPv4 or IPv6 address,
/// or zero if neither.
-inline uint16_t ink_inet_get_port(
+inline uint16_t ats_ip_port_host_order(
sockaddr const* addr ///< Address with port.
) {
// We can discard the const because this function returns
// by value.
- return ntohs(ink_inet_port_cast(const_cast<sockaddr*>(addr)));
+ return ntohs(ats_ip_port_cast(const_cast<sockaddr*>(addr)));
}
/// Get IP TCP/UDP port.
/// @return The port in host order for an IPv4 or IPv6 address,
/// or zero if neither.
-inline uint16_t ink_inet_get_port(
- ts_ip_endpoint const* ip ///< Address with port.
+inline uint16_t ats_ip_port_host_order(
+ IpEndpoint const* ip ///< Address with port.
) {
// We can discard the const because this function returns
// by value.
- return ntohs(ink_inet_port_cast(const_cast<sockaddr*>(&ip->sa)));
+ return ntohs(ats_ip_port_cast(const_cast<sockaddr*>(&ip->sa)));
}
/** Extract the IPv4 address.
@return Host order IPv4 address.
*/
-inline in_addr_t ink_inet_get_ip4_addr(
+inline in_addr_t ats_ip4_addr_host_order(
sockaddr const* addr ///< Address object.
) {
- return ntohl(ink_inet_ip4_addr_cast(const_cast<sockaddr*>(addr)));
+ return ntohl(ats_ip4_addr_cast(const_cast<sockaddr*>(addr)));
}
/// Write IPv4 data to storage @a dst.
-inline sockaddr* ink_inet_ip4_set(
+inline sockaddr* ats_ip4_set(
sockaddr_in* dst, ///< Destination storage.
in_addr_t addr, ///< address, IPv4 network order.
uint16_t port = 0 ///< port, network order.
@@ -755,18 +745,18 @@ inline sockaddr* ink_inet_ip4_set(
dst->sin_family = AF_INET;
dst->sin_addr.s_addr = addr;
dst->sin_port = port;
- return ink_inet_sa_cast(dst);
+ return ats_ip_sa_cast(dst);
}
/** Write IPv4 data to @a dst.
@note Convenience overload.
*/
-inline sockaddr* ink_inet_ip4_set(
- ts_ip_endpoint* dst, ///< Destination storage.
+inline sockaddr* ats_ip4_set(
+ IpEndpoint* dst, ///< Destination storage.
in_addr_t ip4, ///< address, IPv4 network order.
uint16_t port = 0 ///< port, network order.
) {
- return ink_inet_ip4_set(&dst->sin, ip4, port);
+ return ats_ip4_set(&dst->sin, ip4, port);
}
/** Write IPv4 data to storage @a dst.
@@ -774,17 +764,17 @@ inline sockaddr* ink_inet_ip4_set(
This is the generic overload. Caller must verify that @a dst is at
least @c sizeof(sockaddr_in) bytes.
*/
-inline sockaddr* ink_inet_ip4_set(
+inline sockaddr* ats_ip4_set(
sockaddr* dst, ///< Destination storage.
in_addr_t ip4, ///< address, IPv4 network order.
uint16_t port = 0 ///< port, network order.
) {
- return ink_inet_ip4_set(ink_inet_ip4_cast(dst), ip4, port);
+ return ats_ip4_set(ats_ip4_cast(dst), ip4, port);
}
/** Write IPv6 data to storage @a dst.
@return @a dst cast to @c sockaddr*.
*/
-inline sockaddr* ink_inet_ip6_set(
+inline sockaddr* ats_ip6_set(
sockaddr_in6* dst, ///< Destination storage.
in6_addr const& addr, ///< address in network order.
uint16_t port = 0 ///< Port, network order.
@@ -796,33 +786,33 @@ inline sockaddr* ink_inet_ip6_set(
dst->sin6_family = AF_INET6;
memcpy(&dst->sin6_addr, &addr, sizeof addr);
dst->sin6_port = port;
- return ink_inet_sa_cast(dst);
+ return ats_ip_sa_cast(dst);
}
/** Write IPv6 data to storage @a dst.
@return @a dst cast to @c sockaddr*.
*/
-inline sockaddr* ink_inet_ip6_set(
+inline sockaddr* ats_ip6_set(
sockaddr* dst, ///< Destination storage.
in6_addr const& addr, ///< address in network order.
uint16_t port = 0 ///< Port, network order.
) {
- return ink_inet_ip6_set(ink_inet_ip6_cast(dst), addr, port);
+ return ats_ip6_set(ats_ip6_cast(dst), addr, port);
}
/** Write IPv6 data to storage @a dst.
@return @a dst cast to @c sockaddr*.
*/
-inline sockaddr* ink_inet_ip6_set(
- ts_ip_endpoint* dst, ///< Destination storage.
+inline sockaddr* ats_ip6_set(
+ IpEndpoint* dst, ///< Destination storage.
in6_addr const& addr, ///< address in network order.
uint16_t port = 0 ///< Port, network order.
) {
- return ink_inet_ip6_set(&dst->sin6, addr, port);
+ return ats_ip6_set(&dst->sin6, addr, port);
}
/** Write a null terminated string for @a addr to @a dst.
A buffer of size INET6_ADDRSTRLEN suffices, including a terminating nul.
*/
-char const* ink_inet_ntop(
+char const* ats_ip_ntop(
const sockaddr *addr, ///< Address.
char *dst, ///< Output buffer.
size_t size ///< Length of buffer.
@@ -831,12 +821,12 @@ char const* ink_inet_ntop(
/** Write a null terminated string for @a addr to @a dst.
A buffer of size INET6_ADDRSTRLEN suffices, including a terminating nul.
*/
-inline char const* ink_inet_ntop(
- ts_ip_endpoint const* addr, ///< Address.
+inline char const* ats_ip_ntop(
+ IpEndpoint const* addr, ///< Address.
char *dst, ///< Output buffer.
size_t size ///< Length of buffer.
) {
- return ink_inet_ntop(&addr->sa, dst, size);
+ return ats_ip_ntop(&addr->sa, dst, size);
}
/// Buffer size sufficient for IPv6 address and port.
@@ -849,7 +839,7 @@ typedef char ip_port_text_buffer[INET6_ADDRPORTSTRLEN];
/** Write a null terminated string for @a addr to @a dst with port.
A buffer of size INET6_ADDRPORTSTRLEN suffices, including a terminating nul.
*/
-char const* ink_inet_nptop(
+char const* ats_ip_nptop(
const sockaddr *addr, ///< Address.
char *dst, ///< Output buffer.
size_t size ///< Length of buffer.
@@ -858,12 +848,12 @@ char const* ink_inet_nptop(
/** Write a null terminated string for @a addr to @a dst with port.
A buffer of size INET6_ADDRPORTSTRLEN suffices, including a terminating nul.
*/
-inline char const* ink_inet_nptop(
- ts_ip_endpoint const*addr, ///< Address.
+inline char const* ats_ip_nptop(
+ IpEndpoint const*addr, ///< Address.
char *dst, ///< Output buffer.
size_t size ///< Length of buffer.
) {
- return ink_inet_nptop(&addr->sa, dst, size);
+ return ats_ip_nptop(&addr->sa, dst, size);
}
@@ -877,7 +867,7 @@ inline char const* ink_inet_nptop(
@return 0 on success, non-zero on failure.
*/
-int ink_inet_pton(
+int ats_ip_pton(
char const* text, ///< [in] text.
sockaddr* addr ///< [out] address
);
@@ -893,18 +883,18 @@ int ink_inet_pton(
@return 0 on success, non-zero on failure.
*/
-inline int ink_inet_pton(
+inline int ats_ip_pton(
char const* text, ///< [in] text.
sockaddr_in6* addr ///< [out] address
) {
- return ink_inet_pton(text, ink_inet_sa_cast(addr));
+ return ats_ip_pton(text, ats_ip_sa_cast(addr));
}
-inline int ink_inet_pton(
+inline int ats_ip_pton(
char const* text, ///< [in] text.
- ts_ip_endpoint* addr ///< [out] address
+ IpEndpoint* addr ///< [out] address
) {
- return ink_inet_pton(text, &addr->sa);
+ return ats_ip_pton(text, &addr->sa);
}
/** Get the best address info for @a name.
@@ -917,7 +907,7 @@ inline int ink_inet_pton(
IPv4 and IPv4 results are handled independently and stored in @a
ip4 and @a ip6 respectively. If @a name is known to be a numeric
- IP address @c ink_inet_pton is a better choice. Use this function
+ IP address @c ats_ip_pton is a better choice. Use this function
if the type of @a name is not known. If you want to look at the
addresses and not just get the "best", use @c getaddrinfo
directly.
@@ -928,20 +918,20 @@ inline int ink_inet_pton(
@return 0 if an address was found, non-zero otherwise.
- @see ink_inet_pton
+ @see ats_ip_pton
@see getaddrinfo
*/
int
-ink_inet_getbestaddrinfo(
+ats_ip_getbestaddrinfo(
char const* name, ///< [in] Address name (IPv4, IPv6, or host name)
- ts_ip_endpoint* ip4, ///< [out] Storage for IPv4 address.
- ts_ip_endpoint* ip6 ///< [out] Storage for IPv6 address
+ IpEndpoint* ip4, ///< [out] Storage for IPv4 address.
+ IpEndpoint* ip6 ///< [out] Storage for IPv6 address
);
/** Generic IP address hash function.
*/
-uint32_t ink_inet_hash(sockaddr const* addr);
+uint32_t ats_ip_hash(sockaddr const* addr);
/** Convert address to string as a hexidecimal value.
The string is always nul terminated, the output string is clipped
@@ -949,7 +939,7 @@ uint32_t ink_inet_hash(sockaddr const* addr);
@return The length of the resulting string (not including nul).
*/
int
-ink_inet_to_hex(
+ats_ip_to_hex(
sockaddr const* addr, ///< Address to convert. Must be IP.
char* dst, ///< Destination buffer.
size_t len ///< Length of @a dst.
@@ -960,48 +950,48 @@ ink_inet_to_hex(
ancillary information (such as port, or flow data).
@note This is not easily used as an address for system calls.
*/
-struct InkInetAddr {
- typedef InkInetAddr self; ///< Self reference type.
+struct IpAddr {
+ typedef IpAddr self; ///< Self reference type.
/// Default construct (invalid address).
- InkInetAddr() : _family(AF_UNSPEC) {}
+ IpAddr() : _family(AF_UNSPEC) {}
/// Construct as IPv4 @a addr.
- explicit InkInetAddr(
+ explicit IpAddr(
in_addr_t addr ///< Address to assign.
) : _family(AF_INET) {
_addr._ip4 = addr;
}
/// Construct as IPv6 @a addr.
- explicit InkInetAddr(
+ explicit IpAddr(
in6_addr const& addr ///< Address to assign.
) : _family(AF_INET6) {
_addr._ip6 = addr;
}
/// Construct from @c sockaddr.
- explicit InkInetAddr(sockaddr const* addr) { this->assign(addr); }
+ explicit IpAddr(sockaddr const* addr) { this->assign(addr); }
/// Construct from @c sockaddr_in6.
- explicit InkInetAddr(sockaddr_in6 const& addr) { this->assign(ink_inet_sa_cast(&addr)); }
+ explicit IpAddr(sockaddr_in6 const& addr) { this->assign(ats_ip_sa_cast(&addr)); }
/// Construct from @c sockaddr_in6.
- explicit InkInetAddr(sockaddr_in6 const* addr) { this->assign(ink_inet_sa_cast(addr)); }
- /// Construct from @c ts_ip_endpoint.
- explicit InkInetAddr(ts_ip_endpoint const& addr) { this->assign(&addr.sa); }
- /// Construct from @c ts_ip_endpoint.
- explicit InkInetAddr(ts_ip_endpoint const* addr) { this->assign(&addr->sa); }
+ explicit IpAddr(sockaddr_in6 const* addr) { this->assign(ats_ip_sa_cast(addr)); }
+ /// Construct from @c IpEndpoint.
+ explicit IpAddr(IpEndpoint const& addr) { this->assign(&addr.sa); }
+ /// Construct from @c IpEndpoint.
+ explicit IpAddr(IpEndpoint const* addr) { this->assign(&addr->sa); }
/// Assign from sockaddr storage.
self& assign(sockaddr const* addr) {
_family = addr->sa_family;
- if (ink_inet_is_ip4(addr)) {
- _addr._ip4 = ink_inet_ip4_addr_cast(addr);
- } else if (ink_inet_is_ip6(addr)) {
- _addr._ip6 = ink_inet_ip6_addr_cast(addr);
+ if (ats_is_ip4(addr)) {
+ _addr._ip4 = ats_ip4_addr_cast(addr);
+ } else if (ats_is_ip6(addr)) {
+ _addr._ip6 = ats_ip6_addr_cast(addr);
} else {
_family = AF_UNSPEC;
}
return *this;
}
/// Assign from end point.
- self& operator = (ts_ip_endpoint const& ip) {
+ self& operator = (IpEndpoint const& ip) {
return this->assign(&ip.sa);
}
/// Assign from IPv4 raw address.
@@ -1074,52 +1064,52 @@ struct InkInetAddr {
static self const INVALID;
};
-inline InkInetAddr&
-InkInetAddr::operator = (in_addr_t ip) {
+inline IpAddr&
+IpAddr::operator = (in_addr_t ip) {
_family = AF_INET;
_addr._ip4 = ip;
return *this;
}
-inline uint16_t InkInetAddr::family() const { return _family; }
+inline uint16_t IpAddr::family() const { return _family; }
inline bool
-InkInetAddr::isCompatibleWith(self const& that) {
+IpAddr::isCompatibleWith(self const& that) {
return this->isValid() && _family == that._family;
}
-inline bool InkInetAddr::isIp4() const { return AF_INET == _family; }
-inline bool InkInetAddr::isIp6() const { return AF_INET6 == _family; }
+inline bool IpAddr::isIp4() const { return AF_INET == _family; }
+inline bool IpAddr::isIp6() const { return AF_INET6 == _family; }
// Associated operators.
-bool operator == (InkInetAddr const& lhs, sockaddr const* rhs);
-inline bool operator == (sockaddr const* lhs, InkInetAddr const& rhs) {
+bool operator == (IpAddr const& lhs, sockaddr const* rhs);
+inline bool operator == (sockaddr const* lhs, IpAddr const& rhs) {
return rhs == lhs;
}
-inline bool operator != (InkInetAddr const& lhs, sockaddr const* rhs) {
+inline bool operator != (IpAddr const& lhs, sockaddr const* rhs) {
return ! (lhs == rhs);
}
-inline bool operator != (sockaddr const* lhs, InkInetAddr const& rhs) {
+inline bool operator != (sockaddr const* lhs, IpAddr const& rhs) {
return ! (rhs == lhs);
}
-inline bool operator == (InkInetAddr const& lhs, ts_ip_endpoint const& rhs) {
+inline bool operator == (IpAddr const& lhs, IpEndpoint const& rhs) {
return lhs == &rhs.sa;
}
-inline bool operator == (ts_ip_endpoint const& lhs, InkInetAddr const& rhs) {
+inline bool operator == (IpEndpoint const& lhs, IpAddr const& rhs) {
return &lhs.sa == rhs;
}
-inline bool operator != (InkInetAddr const& lhs, ts_ip_endpoint const& rhs) {
+inline bool operator != (IpAddr const& lhs, IpEndpoint const& rhs) {
return ! (lhs == &rhs.sa);
}
-inline bool operator != (ts_ip_endpoint const& lhs, InkInetAddr const& rhs) {
+inline bool operator != (IpEndpoint const& lhs, IpAddr const& rhs) {
return ! (rhs == &lhs.sa);
}
/// Write IP @a addr to storage @a dst.
/// @return @s dst.
-sockaddr* ink_inet_ip_set(
+sockaddr* ats_ip_set(
sockaddr* dst, ///< Destination storage.
- InkInetAddr const& addr, ///< source address.
+ IpAddr const& addr, ///< source address.
uint16_t port = 0 ///< port, network order.
);
@@ -1127,51 +1117,51 @@ sockaddr* ink_inet_ip_set(
Convenience overload.
@return 0 on success, non-zero on failure.
*/
-inline int ink_inet_pton(
+inline int ats_ip_pton(
char const* text, ///< [in] text.
- InkInetAddr& addr ///< [out] address
+ IpAddr& addr ///< [out] address
) {
return addr.load(text) ? 0 : -1;
}
-inline ts_ip_endpoint&
-ts_ip_endpoint::assign(InkInetAddr const& addr, uint16_t port) {
- ink_inet_ip_set(&sa, addr, port);
+inline IpEndpoint&
+IpEndpoint::assign(IpAddr const& addr, uint16_t port) {
+ ats_ip_set(&sa, addr, port);
return *this;
}
-inline ts_ip_endpoint&
-ts_ip_endpoint::assign(sockaddr const* ip) {
- ink_inet_copy(&sa, ip);
+inline IpEndpoint&
+IpEndpoint::assign(sockaddr const* ip) {
+ ats_ip_copy(&sa, ip);
return *this;
}
inline uint16_t&
-ts_ip_endpoint::port() {
- return ink_inet_port_cast(&sa);
+IpEndpoint::port() {
+ return ats_ip_port_cast(&sa);
}
inline bool
-ts_ip_endpoint::isValid() const {
- return ink_inet_is_ip(this);
+IpEndpoint::isValid() const {
+ return ats_is_ip(this);
}
-inline bool ts_ip_endpoint::isIp4() const { return AF_INET == sa.sa_family; }
-inline bool ts_ip_endpoint::isIp6() const { return AF_INET6 == sa.sa_family; }
+inline bool IpEndpoint::isIp4() const { return AF_INET == sa.sa_family; }
+inline bool IpEndpoint::isIp6() const { return AF_INET6 == sa.sa_family; }
-inline ts_ip_endpoint&
-ts_ip_endpoint::setToAnyAddr(int family) {
+inline IpEndpoint&
+IpEndpoint::setToAnyAddr(int family) {
sa.sa_family = family;
- if (AF_INET == family) ink_inet_ip4_addr_cast(this) = INADDR_ANY;
- else if (AF_INET6 == family) ink_inet_ip6_addr_cast(this) = in6addr_any;
+ if (AF_INET == family) ats_ip4_addr_cast(this) = INADDR_ANY;
+ else if (AF_INET6 == family) ats_ip6_addr_cast(this) = in6addr_any;
return *this;
}
-inline ts_ip_endpoint&
-ts_ip_endpoint::setToLoopback(int family) {
+inline IpEndpoint&
+IpEndpoint::setToLoopback(int family) {
sa.sa_family = family;
- if (AF_INET == family) ink_inet_ip4_addr_cast(this) = htonl(INADDR_LOOPBACK);
- else if (AF_INET6 == family) ink_inet_ip6_addr_cast(this) = in6addr_loopback;
+ if (AF_INET == family) ats_ip4_addr_cast(this) = htonl(INADDR_LOOPBACK);
+ else if (AF_INET6 == family) ats_ip6_addr_cast(this) = in6addr_loopback;
return *this;
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/ink_res_init.cc
----------------------------------------------------------------------
diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc
index e4ee6ee..498c5e9 100644
--- a/lib/ts/ink_res_init.cc
+++ b/lib/ts/ink_res_init.cc
@@ -111,7 +111,7 @@ ink_res_nclose(ink_res_state statp) {
}
static void
-ink_res_setservers(ink_res_state statp, ts_ip_endpoint const* set, int cnt) {
+ink_res_setservers(ink_res_state statp, IpEndpoint const* set, int cnt) {
/* close open servers */
ink_res_nclose(statp);
@@ -123,13 +123,13 @@ ink_res_setservers(ink_res_state statp, ts_ip_endpoint const* set, int cnt) {
the destination and sourcea are the same.
*/
int nserv = 0;
- for ( ts_ip_endpoint const* limit = set + cnt ; nserv < INK_MAXNS && set < limit ; ++set ) {
- ts_ip_endpoint* dst = &statp->nsaddr_list[nserv];
+ for ( IpEndpoint const* limit = set + cnt ; nserv < INK_MAXNS && set < limit ; ++set ) {
+ IpEndpoint* dst = &statp->nsaddr_list[nserv];
if (dst == set) {
- if (ink_inet_is_ip(&set->sa))
+ if (ats_is_ip(&set->sa))
++nserv;
- } else if (ink_inet_copy(&dst->sa, &set->sa)) {
+ } else if (ats_ip_copy(&dst->sa, &set->sa)) {
++nserv;
}
}
@@ -139,10 +139,10 @@ ink_res_setservers(ink_res_state statp, ts_ip_endpoint const* set, int cnt) {
int
ink_res_getservers(ink_res_state statp, sockaddr *set, int cnt) {
int zret = 0; // return count.
- ts_ip_endpoint const* src = statp->nsaddr_list;
+ IpEndpoint const* src = statp->nsaddr_list;
for (int i = 0; i < statp->nscount && i < cnt; ++i, ++src) {
- if (ink_inet_copy(set, &src->sa)) {
+ if (ats_ip_copy(set, &src->sa)) {
++set;
++zret;
}
@@ -281,7 +281,7 @@ ink_res_randomid(void) {
int
ink_res_init(
ink_res_state statp, ///< State object to update.
- ts_ip_endpoint const* pHostList, ///< Additional servers.
+ IpEndpoint const* pHostList, ///< Additional servers.
size_t pHostListSize, ///< # of entries in @a pHostList.
const char *pDefDomain, ///< Default domain (may be NULL).
const char *pSearchList, ///< Unknown
@@ -416,10 +416,10 @@ ink_res_init(
if (pHostListSize > INK_MAXNS) pHostListSize = INK_MAXNS;
for (
; nserv < pHostListSize
- && ink_inet_is_ip(&pHostList[nserv].sa)
+ && ats_is_ip(&pHostList[nserv].sa)
; ++nserv
) {
- ink_inet_copy(&statp->nsaddr_list[nserv].sa, &pHostList[nserv].sa);
+ ats_ip_copy(&statp->nsaddr_list[nserv].sa, &pHostList[nserv].sa);
}
}
@@ -501,7 +501,7 @@ ink_res_init(
hints.ai_flags = AI_NUMERICHOST;
sprintf(sbuf, "%d", NAMESERVER_PORT);
if (getaddrinfo(cp, sbuf, &hints, &ai) == 0) {
- if (ink_inet_copy(
+ if (ats_ip_copy(
&statp->nsaddr_list[nserv].sa,
ai->ai_addr
))
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/lib/ts/ink_resolver.h
----------------------------------------------------------------------
diff --git a/lib/ts/ink_resolver.h b/lib/ts/ink_resolver.h
index 2a23fa2..3ebcd9f 100644
--- a/lib/ts/ink_resolver.h
+++ b/lib/ts/ink_resolver.h
@@ -201,7 +201,7 @@ struct ts_imp_res_state {
u_long options; /*%< option flags - see below. */
#endif
int nscount; /*%< number of name servers */
- ts_ip_endpoint nsaddr_list[INK_MAXNS]; /*%< address of name server */
+ IpEndpoint nsaddr_list[INK_MAXNS]; /*%< address of name server */
u_short id; /*%< current message id */
char *dnsrch[MAXDNSRCH+1]; /*%< components of domain to search */
char defdname[256]; /*%< default domain (deprecated) */
@@ -225,7 +225,7 @@ typedef ts_imp_res_state *ink_res_state;
int ink_res_init(
ink_res_state,
- ts_ip_endpoint const* pHostList,
+ IpEndpoint const* pHostList,
size_t pHostListSize,
const char *pDefDomain = NULL,
const char *pSearchList = NULL,
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/mgmt/LocalManager.cc
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index efce1cb..f39fa71 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -327,7 +327,7 @@ void
LocalManager::initCCom(int port, char *addr, int sport)
{
bool found;
- ts_ip_endpoint cluster_ip; // ip addr of the cluster interface
+ IpEndpoint cluster_ip; // ip addr of the cluster interface
ip_text_buffer clusterAddrStr; // cluster ip addr as a String
char *intrName; // Name of the interface we are to use
char hostname[1024]; // hostname of this machine
@@ -344,11 +344,11 @@ LocalManager::initCCom(int port, char *addr, int sport)
found = mgmt_getAddrForIntr(intrName, &cluster_ip.sa);
if (found == false) {
mgmt_fatal(stderr, "[LocalManager::initCCom] Unable to find network interface %s. Exiting...\n", intrName);
- } else if (!ink_inet_is_ip4(&cluster_ip)) {
+ } else if (!ats_is_ip4(&cluster_ip)) {
mgmt_fatal(stderr, "[LocalManager::initCCom] Unable to find IPv4 network interface %s. Exiting...\n", intrName);
}
- ink_inet_ntop(&cluster_ip, clusterAddrStr, sizeof(clusterAddrStr));
+ ats_ip_ntop(&cluster_ip, clusterAddrStr, sizeof(clusterAddrStr));
Debug("ccom", "Cluster Interconnect is %s : %s\n", intrName, clusterAddrStr);
// This an awful hack but I could not come up with a better way to
@@ -371,8 +371,8 @@ LocalManager::initCCom(int port, char *addr, int sport)
ink_strlcat(envBuf, clusterAddrStr, envBuf_size);
ink_release_assert(putenv(envBuf) == 0);
- ccom = new ClusterCom(ink_inet_ip4_addr_cast(&cluster_ip), hostname, port, addr, sport, pserver_path);
- virt_map = new VMap(intrName, ink_inet_ip4_addr_cast(&cluster_ip), &lmgmt->ccom->mutex);
+ ccom = new ClusterCom(ats_ip4_addr_cast(&cluster_ip), hostname, port, addr, sport, pserver_path);
+ virt_map = new VMap(intrName, ats_ip4_addr_cast(&cluster_ip), &lmgmt->ccom->mutex);
virt_map->downAddrs(); // Just to be safe
ccom->establishChannels();
ats_free(intrName);
@@ -1209,7 +1209,7 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
#endif
}
- ts_ip_endpoint ip;
+ IpEndpoint ip;
if (port.m_inbound_ip.isValid()) {
ip.assign(port.m_inbound_ip);
} else if (AF_INET6 == port.m_family) {
@@ -1223,7 +1223,7 @@ LocalManager::bindProxyPort(HttpProxyPort& port)
_exit(1);
}
ip.port() = htons(port.m_port);
- if (bind(port.m_fd, &ip.sa, ink_inet_ip_size(&ip)) < 0) {
+ if (bind(port.m_fd, &ip.sa, ats_ip_size(&ip)) < 0) {
mgmt_elog(stderr, "[bindProxyPort] Unable to bind socket: %d : %s\n", port.m_port, strerror(errno));
_exit(1);
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/mgmt/LocalManager.h
----------------------------------------------------------------------
diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h
index 74edfeb..e808336 100644
--- a/mgmt/LocalManager.h
+++ b/mgmt/LocalManager.h
@@ -120,8 +120,8 @@ public:
volatile int proxy_running;
HttpProxyPort::Group m_proxy_ports;
// Local inbound addresses to bind, if set.
- InkInetAddr m_inbound_ip4;
- InkInetAddr m_inbound_ip6;
+ IpAddr m_inbound_ip4;
+ IpAddr m_inbound_ip6;
int process_server_timeout_secs;
int process_server_timeout_msecs;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/mgmt/utils/MgmtUtils.cc
----------------------------------------------------------------------
diff --git a/mgmt/utils/MgmtUtils.cc b/mgmt/utils/MgmtUtils.cc
index 21c987f..8c85e3b 100644
--- a/mgmt/utils/MgmtUtils.cc
+++ b/mgmt/utils/MgmtUtils.cc
@@ -643,7 +643,7 @@ mgmt_getAddrForIntr(char *intrName, sockaddr* addr, int *mtu)
} else {
// Only look at the address if it an internet address
if (ifr->ifr_ifru.ifru_addr.sa_family == AF_INET) {
- ink_inet_copy(addr, &ifr->ifr_ifru.ifru_addr);
+ ats_ip_copy(addr, &ifr->ifr_ifru.ifru_addr);
found = true;
if (mtu)
@@ -748,26 +748,6 @@ mgmt_sortipaddrs(int num, struct in_addr **list)
return entry;
} /* End mgmt_sortipaddrs */
-char *
-mgmt_localhost_ip()
-{
-#if defined(LOCAL_MANAGER)
- bool found;
- char *hostname;
- in_addr ip;
- int rec_err = RecGetRecordString_Xmalloc("proxy.node.hostname_FQ", &hostname);
-
- found = (rec_err == REC_ERR_OKAY);
- if (found && hostname) {
- ip.s_addr = host_to_ip(hostname);
- if (ip.s_addr != INADDR_ANY) {
- return inet_ntoa(ip);
- }
- }
-#endif
- return NULL;
-}
-
#ifndef _WIN32
void
mgmt_sleep_sec(int seconds)
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/mgmt/utils/MgmtUtils.h
----------------------------------------------------------------------
diff --git a/mgmt/utils/MgmtUtils.h b/mgmt/utils/MgmtUtils.h
index c5629e2..400d313 100644
--- a/mgmt/utils/MgmtUtils.h
+++ b/mgmt/utils/MgmtUtils.h
@@ -57,7 +57,6 @@ void mgmt_use_syslog();
void mgmt_cleanup();
struct in_addr *mgmt_sortipaddrs(int num, struct in_addr **list);
-char *mgmt_localhost_ip();
bool mgmt_getAddrForIntr(char *intrName, sockaddr* addr, int *mtu = 0);
/* the following functions are all DEPRECATED. The Diags
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/proxy/ControlBase.cc
----------------------------------------------------------------------
diff --git a/proxy/ControlBase.cc b/proxy/ControlBase.cc
index 27c7e84..d74768d 100644
--- a/proxy/ControlBase.cc
+++ b/proxy/ControlBase.cc
@@ -250,8 +250,8 @@ IPortMod::make(char* value, char const ** error) {
// ----------
struct SrcIPMod : public ControlBase::Modifier {
// Stored in host order because that's how they are compared.
- ts_ip_endpoint start_addr; ///< Start address in HOST order.
- ts_ip_endpoint end_addr; ///< End address in HOST order.
+ IpEndpoint start_addr; ///< Start address in HOST order.
+ IpEndpoint end_addr; ///< End address in HOST order.
static char const * const NAME;
@@ -270,14 +270,14 @@ void SrcIPMod::print(FILE* f) const {
ip_text_buffer b1, b2;
fprintf(f, "%s=%s-%s "
,this->name()
- , ink_inet_ntop(&start_addr.sa, b1, sizeof(b1))
- , ink_inet_ntop(&end_addr.sa, b2, sizeof(b2))
+ , ats_ip_ntop(&start_addr.sa, b1, sizeof(b1))
+ , ats_ip_ntop(&end_addr.sa, b2, sizeof(b2))
);
}
bool SrcIPMod::check(HttpRequestData* req) const {
// Compare in host order
- return ink_inet_cmp(&start_addr, &req->src_ip) <= 0
- && ink_inet_cmp(&req->src_ip, &end_addr) <= 0
+ return ats_ip_addr_cmp(&start_addr, &req->src_ip) <= 0
+ && ats_ip_addr_cmp(&req->src_ip, &end_addr) <= 0
;
}
SrcIPMod*
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/proxy/ControlMatcher.cc
----------------------------------------------------------------------
diff --git a/proxy/ControlMatcher.cc b/proxy/ControlMatcher.cc
index 0d68911..db0329e 100644
--- a/proxy/ControlMatcher.cc
+++ b/proxy/ControlMatcher.cc
@@ -483,7 +483,7 @@ template<class Data, class Result> char *IpMatcher<Data, Result>::NewEntry(match
const char *errPtr;
char *errBuf;
char *match_data;
- ts_ip_endpoint addr1, addr2;
+ IpEndpoint addr1, addr2;
// Make sure space has been allocated
ink_assert(num_el >= 0);
@@ -545,8 +545,8 @@ template<class Data, class Result> void IpMatcher<Data, Result>::Print()
for ( IpMap::iterator spot(ip_map.begin()), limit(ip_map.end()) ; spot != limit ; ++spot) {
char b1[INET6_ADDRSTRLEN], b2[INET6_ADDRSTRLEN];
printf("\tRange %s - %s ",
- ink_inet_ntop(spot->min(), b1, sizeof b1),
- ink_inet_ntop(spot->max(), b2, sizeof b2)
+ ats_ip_ntop(spot->min(), b1, sizeof b1),
+ ats_ip_ntop(spot->max(), b2, sizeof b2)
);
static_cast<Data*>(spot->data())->Print();
}
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/proxy/ControlMatcher.h
----------------------------------------------------------------------
diff --git a/proxy/ControlMatcher.h b/proxy/ControlMatcher.h
index c6a2562..1200f89 100644
--- a/proxy/ControlMatcher.h
+++ b/proxy/ControlMatcher.h
@@ -153,8 +153,8 @@ public:
char *hostname_str;
_HttpApiInfo *api_info;
time_t xact_start;
- ts_ip_endpoint src_ip;
- ts_ip_endpoint dest_ip;
+ IpEndpoint src_ip;
+ IpEndpoint dest_ip;
uint16_t incoming_port;
char *tag;
};
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/proxy/CoreUtils.cc
----------------------------------------------------------------------
diff --git a/proxy/CoreUtils.cc b/proxy/CoreUtils.cc
index 4663758..9c0abca 100644
--- a/proxy/CoreUtils.cc
+++ b/proxy/CoreUtils.cc
@@ -1011,8 +1011,8 @@ CoreUtils::process_NetVC(UnixNetVConnection * nvc_test)
char addrbuf[INET6_ADDRSTRLEN];
printf("----------- UnixNetVConnection @ 0x%p ----------\n", nvc_test);
printf(" ip: %s port: %d\n",
- ink_inet_ntop(&loaded_nvc->server_addr.sa, addrbuf, sizeof(addrbuf)),
- ink_inet_get_port(&loaded_nvc->server_addr));
+ ats_ip_ntop(&loaded_nvc->server_addr.sa, addrbuf, sizeof(addrbuf)),
+ ats_ip_port_host_order(&loaded_nvc->server_addr));
printf(" closed: %d\n\n", loaded_nvc->closed);
printf(" read state: \n");
print_netstate(&loaded_nvc->read);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/47d1f8ec/proxy/FetchSM.cc
----------------------------------------------------------------------
diff --git a/proxy/FetchSM.cc b/proxy/FetchSM.cc
index 821ae09..9caf516 100644
--- a/proxy/FetchSM.cc
+++ b/proxy/FetchSM.cc
@@ -53,8 +53,8 @@ FetchSM::httpConnect()
{
Debug(DEBUG_TAG, "[%s] calling httpconnect write", __FUNCTION__);
sockaddr_in addr;
- ink_inet_ip4_set(&addr, _ip, _port);
- http_vc = TSHttpConnect(ink_inet_sa_cast(&addr));
+ ats_ip4_set(&addr, _ip, _port);
+ http_vc = TSHttpConnect(ats_ip_sa_cast(&addr));
PluginVC *vc = (PluginVC *) http_vc;