From 47d1f8ec485db09892715ef5f6a4638fd006319b Mon Sep 17 00:00:00 2001 From: "Alan M. Carroll" Date: Tue, 21 Feb 2012 09:55:03 -0600 Subject: [PATCH] TS-995 changes. --- iocore/dns/DNS.cc | 84 ++--- iocore/dns/DNSConnection.cc | 26 +- iocore/dns/I_DNSProcessor.h | 6 +- iocore/dns/P_DNSConnection.h | 2 +- iocore/dns/P_DNSProcessor.h | 8 +- iocore/dns/P_SplitDNSProcessor.h | 2 +- iocore/dns/SplitDNS.cc | 12 +- iocore/hostdb/HostDB.cc | 110 +++--- iocore/hostdb/I_HostDBProcessor.h | 20 +- iocore/hostdb/P_HostDBProcessor.h | 18 +- iocore/net/Connection.cc | 16 +- iocore/net/I_NetProcessor.h | 10 +- iocore/net/I_NetVConnection.h | 8 +- iocore/net/I_UDPNet.h | 2 +- iocore/net/I_UDPPacket.h | 4 +- iocore/net/P_Connection.h | 20 +- iocore/net/P_NetVConnection.h | 18 +- iocore/net/P_Socks.h | 6 +- iocore/net/P_UDPConnection.h | 8 +- iocore/net/P_UDPNet.h | 6 +- iocore/net/P_UDPPacket.h | 8 +- iocore/net/P_UnixNetVConnection.h | 4 +- iocore/net/SSLNetVConnection.cc | 4 +- iocore/net/Socks.cc | 34 +- iocore/net/UnixConnection.cc | 20 +- iocore/net/UnixNetAccept.cc | 10 +- iocore/net/UnixNetPages.cc | 16 +- iocore/net/UnixNetProcessor.cc | 16 +- iocore/net/UnixUDPNet.cc | 44 +-- iocore/utils/I_Machine.h | 6 +- iocore/utils/Machine.cc | 36 +- lib/records/I_RecHttp.h | 16 +- lib/records/RecHttp.cc | 20 +- lib/ts/IpMap.cc | 38 +- lib/ts/IpMap.h | 20 +- lib/ts/IpMapConf.cc | 4 +- lib/ts/IpMapTest.cc | 26 +- lib/ts/MatcherUtils.cc | 30 +- lib/ts/MatcherUtils.h | 2 +- lib/ts/ink_inet.cc | 120 +++---- lib/ts/ink_inet.h | 480 +++++++++++++------------- lib/ts/ink_res_init.cc | 22 +- lib/ts/ink_resolver.h | 4 +- mgmt/LocalManager.cc | 14 +- mgmt/LocalManager.h | 4 +- mgmt/utils/MgmtUtils.cc | 22 +- mgmt/utils/MgmtUtils.h | 1 - proxy/ControlBase.cc | 12 +- proxy/ControlMatcher.cc | 6 +- proxy/ControlMatcher.h | 4 +- proxy/CoreUtils.cc | 4 +- proxy/FetchSM.cc | 4 +- proxy/ICP.cc | 78 ++--- proxy/ICP.h | 48 +-- proxy/ICPConfig.cc | 50 +-- proxy/IPAllow.cc | 10 +- proxy/IPAllow.h | 4 +- proxy/InkAPI.cc | 50 +-- proxy/InkAPITest.cc | 34 +- proxy/InkAPITestTool.cc | 4 +- proxy/InkIOCoreAPI.cc | 10 +- proxy/Main.cc | 2 +- proxy/ParentSelection.cc | 16 +- proxy/PluginVC.cc | 12 +- proxy/PluginVC.h | 4 +- proxy/Prefetch.cc | 50 +-- proxy/Prefetch.h | 22 +- proxy/SimpleHttp.cc | 4 +- proxy/Update.cc | 2 +- proxy/api/ts/InkAPIHughes.h | 4 +- proxy/congest/Congestion.cc | 12 +- proxy/congest/Congestion.h | 2 +- proxy/congest/CongestionDB.cc | 10 +- proxy/congest/CongestionTest.cc | 14 +- proxy/http/HttpAccept.cc | 4 +- proxy/http/HttpAccept.h | 12 +- proxy/http/HttpClientSession.h | 4 +- proxy/http/HttpConfig.h | 4 +- proxy/http/HttpConnectionCount.h | 14 +- proxy/http/HttpSM.cc | 46 +-- proxy/http/HttpServerSession.cc | 4 +- proxy/http/HttpServerSession.h | 2 +- proxy/http/HttpSessionManager.cc | 12 +- proxy/http/HttpTransact.cc | 74 ++-- proxy/http/HttpTransact.h | 2 +- proxy/http/HttpUpdateSM.cc | 2 +- proxy/http/remap/AclFiltering.cc | 4 +- proxy/http/remap/AclFiltering.h | 8 +- proxy/http/remap/RemapProcessor.cc | 4 +- proxy/http/remap/UrlRewrite.cc | 2 +- proxy/logging/LogAccess.cc | 24 +- proxy/logging/LogAccess.h | 2 +- proxy/logging/LogAccessHttp.cc | 4 +- proxy/logging/LogAccessTest.cc | 8 +- proxy/logging/LogCollationClientSM.cc | 4 +- 95 files changed, 1038 insertions(+), 1081 deletions(-) diff --git a/iocore/dns/DNS.cc b/iocore/dns/DNS.cc index e84825bc63d..0611fab8b24 100644 --- a/iocore/dns/DNS.cc +++ b/iocore/dns/DNS.cc @@ -65,11 +65,11 @@ namespace { } inline void set_loopback(sockaddr* addr) { if (prefer_ipv6_p()) - ink_inet_ip6_set(addr, in6addr_loopback, htons(DOMAIN_SERVICE_PORT)); + ats_ip6_set(addr, in6addr_loopback, htons(DOMAIN_SERVICE_PORT)); else - ink_inet_ip4_set(addr, htonl(INADDR_LOOPBACK), htons(DOMAIN_SERVICE_PORT)); + ats_ip4_set(addr, htonl(INADDR_LOOPBACK), htons(DOMAIN_SERVICE_PORT)); } - inline void set_loopback(ts_ip_endpoint* ip) { + inline void set_loopback(IpEndpoint* ip) { set_loopback(&ip->sa); } } @@ -226,13 +226,13 @@ DNSProcessor::open(sockaddr const* target, int aoptions) h->options = aoptions; h->mutex = thread->mutex; h->m_res = &l_res; - ink_inet_copy(&h->local_ipv4.sa, &local_ipv4.sa); - ink_inet_copy(&h->local_ipv6.sa, &local_ipv6.sa); + ats_ip_copy(&h->local_ipv4.sa, &local_ipv4.sa); + ats_ip_copy(&h->local_ipv6.sa, &local_ipv6.sa); if (target) - ink_inet_copy(&h->ip, target); + ats_ip_copy(&h->ip, target); else - ink_inet_invalidate(&h->ip); // marked to use default. + ats_ip_invalidate(&h->ip); // marked to use default. if (!dns_handler_initialized) handler = h; @@ -251,7 +251,7 @@ DNSProcessor::dns_init() Debug("dns", "localhost=%s\n", try_server_names[0]); Debug("dns", "Round-robin nameservers = %d\n", dns_ns_rr); - ts_ip_endpoint nameserver[MAX_NAMED]; + IpEndpoint nameserver[MAX_NAMED]; size_t nserv = 0; if (dns_ns_list) { @@ -287,7 +287,7 @@ DNSProcessor::dns_init() } } - if (!err && 0 != ink_inet_pton(ns, &nameserver[nserv].sa)) { + if (!err && 0 != ats_ip_pton(ns, &nameserver[nserv].sa)) { Debug("dns", "Invalid IP address given for nameserver '%s', discarding", ns); Warning("Invalid IP address given for nameserver '%s', discarding", ns); err = true; @@ -296,10 +296,10 @@ DNSProcessor::dns_init() if (!err) { ip_port_text_buffer buff; - ink_inet_port_cast(&nameserver[nserv].sa) = htons(prt); + ats_ip_port_cast(&nameserver[nserv].sa) = htons(prt); Debug("dns", "Adding nameserver %s to nameserver list", - ink_inet_nptop(&nameserver[nserv].sa, buff, sizeof(buff)) + ats_ip_nptop(&nameserver[nserv].sa, buff, sizeof(buff)) ); ++nserv; } @@ -316,21 +316,21 @@ DNSProcessor::dns_init() // Check for local forced bindings. if (dns_local_ipv6) { - if (0 != ink_inet_pton(dns_local_ipv6, &local_ipv6)) { - ink_inet_invalidate(&local_ipv6); + if (0 != ats_ip_pton(dns_local_ipv6, &local_ipv6)) { + ats_ip_invalidate(&local_ipv6); Warning("Invalid IP address '%s' for dns.local_ipv6 value, discarding.", dns_local_ipv6); - } else if (!ink_inet_is_ip6(&local_ipv6.sa)) { - ink_inet_invalidate(&local_ipv6); + } else if (!ats_is_ip6(&local_ipv6.sa)) { + ats_ip_invalidate(&local_ipv6); Warning("IP address '%s' for dns.local_ipv6 value was not IPv6, discarding.", dns_local_ipv6); } } if (dns_local_ipv4) { - if (0 != ink_inet_pton(dns_local_ipv4, &local_ipv4)) { - ink_inet_invalidate(&local_ipv4); + if (0 != ats_ip_pton(dns_local_ipv4, &local_ipv4)) { + ats_ip_invalidate(&local_ipv4); Warning("Invalid IP address '%s' for dns.local_ipv4 value, discarding.", dns_local_ipv4); - } else if (!ink_inet_is_ip4(&local_ipv4.sa)) { - ink_inet_invalidate(&local_ipv4); + } else if (!ats_is_ip4(&local_ipv4.sa)) { + ats_ip_invalidate(&local_ipv4); Warning("IP address '%s' for dns.local_ipv4 value was not IPv4, discarding.", dns_local_ipv4); } } @@ -394,10 +394,10 @@ DNSEntry::init(const char *x, int len, int qtype_arg, } } else { //T_PTR sockaddr const* ip = reinterpret_cast(x); - if (ink_inet_is_ip6(ip)) - make_ipv6_ptr(&ink_inet_ip6_addr_cast(ip), qname); - else if (ink_inet_is_ip4(ip)) - make_ipv4_ptr(ink_inet_ip4_addr_cast(ip), qname); + if (ats_is_ip6(ip)) + make_ipv6_ptr(&ats_ip6_addr_cast(ip), qname); + else if (ats_is_ip4(ip)) + make_ipv4_ptr(ats_ip4_addr_cast(ip), qname); else ink_assert(!"T_PTR query to DNS must be IP address."); } @@ -417,12 +417,12 @@ DNSHandler::open_con(sockaddr const* target, bool failed, int icon) PollDescriptor *pd = get_PollDescriptor(dnsProcessor.thread); if (!icon && target) { - ink_inet_copy(&ip, target); + ats_ip_copy(&ip, target); } else if (!target) { target = &ip.sa; } - Debug("dns", "open_con: opening connection %s", ink_inet_nptop(target, ip_text, sizeof ip_text)); + Debug("dns", "open_con: opening connection %s", ats_ip_nptop(target, ip_text, sizeof ip_text)); if (con[icon].fd != NO_FD) { // Remove old FD from epoll fd con[icon].eio.stop(); @@ -459,10 +459,10 @@ DNSHandler::open_con(sockaddr const* target, bool failed, int icon) void DNSHandler::validate_ip() { - if (!ink_inet_is_ip(&ip.sa)) { + if (!ats_is_ip(&ip.sa)) { // Invalid, switch to default. // seems that res_init always sets m_res.nscount to at least 1! - if (!m_res->nscount || !ink_inet_copy(&ip.sa, &m_res->nsaddr_list[0].sa)) { + if (!m_res->nscount || !ats_ip_copy(&ip.sa, &m_res->nsaddr_list[0].sa)) { Warning("bad nameserver config, fallback to %s loopback", prefer_ipv6_p() ? "IPv6" : "IPv4" ); @@ -500,11 +500,11 @@ DNSHandler::startEvent(int event, Event *e) for (int i = 0; i < max_nscount; i++) { ip_port_text_buffer buff; sockaddr *sa = &m_res->nsaddr_list[i].sa; - if (ink_inet_is_ip(sa)) { + if (ats_is_ip(sa)) { open_con(sa, false, n_con); ++n_con; Debug("dns_pas", "opened connection to %s, n_con = %d", - ink_inet_nptop(sa, buff, sizeof(buff)), + ats_ip_nptop(sa, buff, sizeof(buff)), n_con ); } @@ -555,7 +555,7 @@ void DNSHandler::recover() { ip_text_buffer buff; - Warning("connection to DNS server %s restored", ink_inet_ntop(&ip.sa, buff, sizeof(buff))); + Warning("connection to DNS server %s restored", ats_ip_ntop(&ip.sa, buff, sizeof(buff))); name_server = 0; switch_named(name_server); } @@ -639,15 +639,15 @@ DNSHandler::failover() name_server = (name_server + 1) % max_nscount; Debug("dns", "failover: failing over to name_server=%d", name_server); - ts_ip_endpoint target; - ink_inet_copy(&target.sa, &m_res->nsaddr_list[name_server].sa); + IpEndpoint target; + ats_ip_copy(&target.sa, &m_res->nsaddr_list[name_server].sa); Warning("failover: connection to DNS server %s lost, move to %s", - ink_inet_ntop(old_addr, buff1, sizeof(buff1)), - ink_inet_ntop(&target.sa, buff2, sizeof(buff2)) + ats_ip_ntop(old_addr, buff1, sizeof(buff1)), + ats_ip_ntop(&target.sa, buff2, sizeof(buff2)) ); - if (!ink_inet_is_ip(&target.sa)) set_loopback(&target.sa); + if (!ats_is_ip(&target.sa)) set_loopback(&target.sa); open_con(&target.sa, true, name_server); if (n_con <= name_server) @@ -656,7 +656,7 @@ DNSHandler::failover() } else { ip_text_buffer buff; Warning("failover: connection to DNS server %s lost, retrying", - ink_inet_ntop(&ip.sa, buff, sizeof(buff)) + ats_ip_ntop(&ip.sa, buff, sizeof(buff)) ); } } @@ -672,7 +672,7 @@ DNSHandler::rr_failure(int ndx) Debug("dns", "rr_failure: Marking nameserver %d as down", ndx); ns_down[ndx] = 1; Warning("connection to DNS server %s lost, marking as down", - ink_inet_ntop(&m_res->nsaddr_list[ndx].sa, buff, sizeof(buff)) + ats_ip_ntop(&m_res->nsaddr_list[ndx].sa, buff, sizeof(buff)) ); } @@ -740,7 +740,7 @@ DNSHandler::recv_dns(int event, Event *e) while ((dnsc = (DNSConnection *) triggered.dequeue())) { while (1) { - ts_ip_endpoint from_ip; + IpEndpoint from_ip; socklen_t from_length = sizeof(from_ip); if (!hostent_cache) @@ -761,10 +761,10 @@ DNSHandler::recv_dns(int event, Event *e) } // verify that this response came from the correct server - if (!ink_inet_eq(&dnsc->ip.sa, &from_ip.sa)) { + if (!ats_ip_addr_eq(&dnsc->ip.sa, &from_ip.sa)) { Warning("unexpected DNS response from %s (expected %s)", - ink_inet_ntop(&from_ip.sa, ipbuff1, sizeof ipbuff1), - ink_inet_ntop(&dnsc->ip.sa, ipbuff2, sizeof ipbuff2) + ats_ip_ntop(&from_ip.sa, ipbuff1, sizeof ipbuff1), + ats_ip_ntop(&dnsc->ip.sa, ipbuff2, sizeof ipbuff2) ); continue; } @@ -777,7 +777,7 @@ DNSHandler::recv_dns(int event, Event *e) received_one(dnsc->num); if (ns_down[dnsc->num]) { Warning("connection to DNS server %s restored", - ink_inet_ntop(&m_res->nsaddr_list[dnsc->num].sa, ipbuff1, sizeof ipbuff1) + ats_ip_ntop(&m_res->nsaddr_list[dnsc->num].sa, ipbuff1, sizeof ipbuff1) ); ns_down[dnsc->num] = 0; } diff --git a/iocore/dns/DNSConnection.cc b/iocore/dns/DNSConnection.cc index 92132e575ca..3003a6e8dba 100644 --- a/iocore/dns/DNSConnection.cc +++ b/iocore/dns/DNSConnection.cc @@ -85,12 +85,12 @@ DNSConnection::connect(sockaddr const* addr, Options const& opt) // bool non_blocking_connect, bool use_tcp, bool non_blocking, bool bind_random_port) { ink_assert(fd == NO_FD); - ink_assert(ink_inet_is_ip(addr)); + ink_assert(ats_is_ip(addr)); int res = 0; short Proto; uint8_t af = addr->sa_family; - ts_ip_endpoint bind_addr; + IpEndpoint bind_addr; size_t bind_size = 0; if (opt._use_tcp) { @@ -109,15 +109,15 @@ DNSConnection::connect(sockaddr const* addr, Options const& opt) bind_addr.sa.sa_family = af; if (AF_INET6 == af) { - if (ink_inet_is_ip6(opt._local_ipv6)) { - ink_inet_copy(&bind_addr.sa, opt._local_ipv6); + if (ats_is_ip6(opt._local_ipv6)) { + ats_ip_copy(&bind_addr.sa, opt._local_ipv6); } else { bind_addr.sin6.sin6_addr = in6addr_any; } bind_size = sizeof(sockaddr_in6); } else if (AF_INET == af) { - if (ink_inet_is_ip4(opt._local_ipv4)) - ink_inet_copy(&bind_addr.sa, opt._local_ipv4); + if (ats_is_ip4(opt._local_ipv4)) + ats_ip_copy(&bind_addr.sa, opt._local_ipv4); else bind_addr.sin.sin_addr.s_addr = INADDR_ANY; bind_size = sizeof(sockaddr_in); @@ -127,7 +127,7 @@ DNSConnection::connect(sockaddr const* addr, Options const& opt) if (opt._bind_random_port) { int retries = 0; - ts_ip_endpoint bind_addr; + IpEndpoint bind_addr; size_t bind_size = 0; memset(&bind_addr, 0, sizeof bind_addr); bind_addr.sa.sa_family = af; @@ -142,8 +142,8 @@ DNSConnection::connect(sockaddr const* addr, Options const& opt) ip_port_text_buffer b; uint32_t p = generator.random(); p = static_cast((p % (LAST_RANDOM_PORT - FIRST_RANDOM_PORT)) + FIRST_RANDOM_PORT); - ink_inet_port_cast(&bind_addr.sa) = htons(p); // stuff port in sockaddr. - Debug("dns", "random port = %s\n", ink_inet_nptop(&bind_addr.sa, b, sizeof b)); + ats_ip_port_cast(&bind_addr.sa) = htons(p); // stuff port in sockaddr. + Debug("dns", "random port = %s\n", ats_ip_nptop(&bind_addr.sa, b, sizeof b)); if ((res = socketManager.ink_bind(fd, &bind_addr.sa, bind_size, Proto)) < 0) { continue; } @@ -151,11 +151,11 @@ DNSConnection::connect(sockaddr const* addr, Options const& opt) } Warning("unable to bind random DNS port"); Lok:; - } else if (ink_inet_is_ip(&bind_addr.sa)) { + } else if (ats_is_ip(&bind_addr.sa)) { ip_text_buffer b; res = socketManager.ink_bind(fd, &bind_addr.sa, bind_size, Proto); if (res < 0) Warning("Unable to bind local address to %s.", - ink_inet_ntop(&bind_addr.sa, b, sizeof b)); + ats_ip_ntop(&bind_addr.sa, b, sizeof b)); } if (opt._non_blocking_connect) @@ -177,8 +177,8 @@ DNSConnection::connect(sockaddr const* addr, Options const& opt) goto Lerror; #endif - ink_inet_copy(&ip.sa, addr); - res =::connect(fd, addr, ink_inet_ip_size(addr)); + ats_ip_copy(&ip.sa, addr); + res =::connect(fd, addr, ats_ip_size(addr)); if (!res || ((res < 0) && (errno == EINPROGRESS || errno == EWOULDBLOCK))) { if (!opt._non_blocking_connect && opt._non_blocking_io) diff --git a/iocore/dns/I_DNSProcessor.h b/iocore/dns/I_DNSProcessor.h index 51e7e47385a..2375178277e 100644 --- a/iocore/dns/I_DNSProcessor.h +++ b/iocore/dns/I_DNSProcessor.h @@ -98,8 +98,8 @@ struct DNSProcessor: public Processor EThread *thread; DNSHandler *handler; ts_imp_res_state l_res; - ts_ip_endpoint local_ipv6; - ts_ip_endpoint local_ipv4; + IpEndpoint local_ipv6; + IpEndpoint local_ipv4; Action *getby(const char *x, int len, int type, Continuation *cont, DNSHandler *adnsH = NULL, int timeout = 0); void dns_init(); }; @@ -136,7 +136,7 @@ inline Action * DNSProcessor::gethostbyaddr(Continuation *cont, in_addr_t addr, int timeout) { sockaddr_in ip; - ink_inet_ip4_set(&ip, addr); + ats_ip4_set(&ip, addr); return getby(reinterpret_cast(&ip), 0, T_PTR, cont, NULL, timeout); } diff --git a/iocore/dns/P_DNSConnection.h b/iocore/dns/P_DNSConnection.h index 285e6481974..48f699e44cd 100644 --- a/iocore/dns/P_DNSConnection.h +++ b/iocore/dns/P_DNSConnection.h @@ -92,7 +92,7 @@ struct DNSConnection { }; int fd; - ts_ip_endpoint ip; + IpEndpoint ip; int num; LINK(DNSConnection, link); EventIO eio; diff --git a/iocore/dns/P_DNSProcessor.h b/iocore/dns/P_DNSProcessor.h index d4a584b5cac..3f74082115c 100644 --- a/iocore/dns/P_DNSProcessor.h +++ b/iocore/dns/P_DNSProcessor.h @@ -199,9 +199,9 @@ struct DNSEntry; struct DNSHandler: public Continuation { /// This is used as the target if round robin isn't set. - ts_ip_endpoint ip; - ts_ip_endpoint local_ipv6; ///< Local V6 address if set. - ts_ip_endpoint local_ipv4; ///< Local V4 address if set. + IpEndpoint ip; + IpEndpoint local_ipv6; ///< Local V6 address if set. + IpEndpoint local_ipv4; ///< Local V4 address if set. int ifd[MAX_NAMED]; int n_con; DNSConnection con[MAX_NAMED]; @@ -296,7 +296,7 @@ TS_INLINE DNSHandler::DNSHandler() hostent_cache(0), last_primary_retry(0), last_primary_reopen(0), m_res(0), txn_lookup_timeout(0), generator((uint32_t)((uintptr_t)time(NULL) ^ (uintptr_t)this)) { - ink_inet_invalidate(&ip); + ats_ip_invalidate(&ip); for (int i = 0; i < MAX_NAMED; i++) { ifd[i] = -1; failover_number[i] = 0; diff --git a/iocore/dns/P_SplitDNSProcessor.h b/iocore/dns/P_SplitDNSProcessor.h index ce23a94d0ca..38ce322ce3b 100644 --- a/iocore/dns/P_SplitDNSProcessor.h +++ b/iocore/dns/P_SplitDNSProcessor.h @@ -162,7 +162,7 @@ TS_INLINE bool SplitDNSConfig::isSplitDNSEnabled() -------------------------------------------------------------- */ struct DNSServer { - ts_ip_endpoint x_server_ip[MAXNS]; + IpEndpoint x_server_ip[MAXNS]; char x_dns_ip_line[MAXDNAME * 2]; char x_def_domain[MAXDNAME]; diff --git a/iocore/dns/SplitDNS.cc b/iocore/dns/SplitDNS.cc index 9609adb4e8d..871e898f62d 100644 --- a/iocore/dns/SplitDNS.cc +++ b/iocore/dns/SplitDNS.cc @@ -364,11 +364,11 @@ SplitDNSRecord::ProcessDNSHosts(char *val) *tmp = 0; } - if (0 != ink_inet_pton(current, &m_servers.x_server_ip[i].sa)) { + if (0 != ats_ip_pton(current, &m_servers.x_server_ip[i].sa)) { return "invalid IP address given for a DNS server"; } - ink_inet_port_cast(&m_servers.x_server_ip[i].sa) = htons(port ? port : NAMESERVER_PORT); + ats_ip_port_cast(&m_servers.x_server_ip[i].sa) = htons(port ? port : NAMESERVER_PORT); if ((MAXDNAME * 2 - 1) > totsz) { sz = strlen(current); @@ -503,7 +503,7 @@ SplitDNSRecord::Init(matcher_line * line_info) } } - if (!ink_inet_is_ip(&m_servers.x_server_ip[0].sa)) { + if (!ats_is_ip(&m_servers.x_server_ip[0].sa)) { snprintf(errBuf, errBufLen, "%s No server specified in splitdns.config at line %d", modulePrefix, line_num); return errBuf; } @@ -517,7 +517,7 @@ SplitDNSRecord::Init(matcher_line * line_info) char ab[INET6_ADDRPORTSTRLEN]; snprintf(errBuf, errBufLen, "Failed to build res record for the servers %s ...", - ink_inet_ntop(&m_servers.x_server_ip[0].sa, ab, sizeof ab) + ats_ip_ntop(&m_servers.x_server_ip[0].sa, ab, sizeof ab) ); return errBuf; } @@ -525,7 +525,7 @@ SplitDNSRecord::Init(matcher_line * line_info) dnsH->m_res = res; dnsH->mutex = SplitDNSConfig::dnsHandler_mutex; dnsH->options = res->options; - ink_inet_invalidate(&dnsH->ip.sa); // Mark to use default DNS. + ats_ip_invalidate(&dnsH->ip.sa); // Mark to use default DNS. m_servers.x_dnsH = dnsH; @@ -576,7 +576,7 @@ SplitDNSRecord::Print() { for (int i = 0; i < m_dnsSrvr_cnt; i++) { char ab[INET6_ADDRPORTSTRLEN]; - Debug("splitdns_config", " %s ", ink_inet_ntop(&m_servers.x_server_ip[i].sa, ab, sizeof ab)); + Debug("splitdns_config", " %s ", ats_ip_ntop(&m_servers.x_server_ip[i].sa, ab, sizeof ab)); } } diff --git a/iocore/hostdb/HostDB.cc b/iocore/hostdb/HostDB.cc index 22e5616d243..2ed6e40e98e 100644 --- a/iocore/hostdb/HostDB.cc +++ b/iocore/hostdb/HostDB.cc @@ -103,10 +103,10 @@ ip_addr_set( void* ptr ///< Raw address data ) { if (AF_INET6 == af) - ink_inet_ip6_set(ip, *static_cast(ptr)); + ats_ip6_set(ip, *static_cast(ptr)); else if (AF_INET == af) - ink_inet_ip4_set(ip, *static_cast(ptr)); - else ink_inet_invalidate(ip); + ats_ip4_set(ip, *static_cast(ptr)); + else ats_ip_invalidate(ip); } inline void @@ -176,7 +176,7 @@ HostDBCache::rebuild_callout(HostDBInfo * e, RebuildMC & r) for (int i = 0; i < rr->good; i++) { if (!valid_heap_pointer(((char *) &rr->info[i + 1]) - 1)) return -1; - if (!ink_inet_is_ip(rr->info[i].ip())) + if (!ats_is_ip(rr->info[i].ip())) return corrupt_debugging_callout(e, r); if (rr->info[i].md5_high != e->md5_high || rr->info[i].md5_low != e->md5_low || rr->info[i].md5_low_low != e->md5_low_low) @@ -462,7 +462,7 @@ HostDBContinuation::init( dns_lookup_timeout = timeout; namelen = len; is_srv_lookup = is_srv; - ink_inet_copy(&ip.sa, aip); + ats_ip_copy(&ip.sa, aip); md5 = amd5; mutex = hostDB.lock_for_bucket((int) (fold_md5(md5) % hostDB.buckets)); m_pDS = pDS; @@ -538,7 +538,7 @@ reply_to_cont(Continuation * cont, HostDBInfo * ar) goto Lerror; } ip_text_buffer ipb; - Debug("hostdb", "RR of %d with %d good, 1st IP = %s", r->rr()->n, r->rr()->good, ink_inet_ntop(r->ip(), ipb, sizeof ipb)); + Debug("hostdb", "RR of %d with %d good, 1st IP = %s", r->rr()->n, r->rr()->good, ats_ip_ntop(r->ip(), ipb, sizeof ipb)); } if (r->is_srv && r->srv_count) { cont->handleEvent(EVENT_SRV_LOOKUP, r); @@ -671,7 +671,7 @@ HostDBProcessor::getby(Continuation * cont, void *pDS = 0; EThread *thread = this_ethread(); ProxyMutex *mutex = thread->mutex; - unsigned short port = ink_inet_get_port(ip); + unsigned short port = ats_ip_port_host_order(ip); ip_text_buffer ipb; HOSTDB_INCREMENT_DYN_STAT(hostdb_total_lookups_stat); @@ -713,10 +713,10 @@ HostDBProcessor::getby(Continuation * cont, // uint8_t buff[INK_IP6_SIZE+4]; memset(buff, 0, sizeof(buff)); - if (ink_inet_is_ip4(ip)) - memcpy(buff+2, &ink_inet_ip4_addr_cast(ip), sizeof(in_addr_t)); - else if (ink_inet_is_ip6(ip)) - memcpy(buff+2, &ink_inet_ip6_addr_cast(ip), sizeof(in6_addr)); + if (ats_is_ip4(ip)) + memcpy(buff+2, &ats_ip4_addr_cast(ip), sizeof(in_addr_t)); + else if (ats_is_ip6(ip)) + memcpy(buff+2, &ats_ip6_addr_cast(ip), sizeof(in6_addr)); md5.encodeBuffer(buff, sizeof buff); } @@ -737,7 +737,7 @@ HostDBProcessor::getby(Continuation * cont, if (r) { Debug("hostdb", "immediate answer for %s", hostname ? hostname - : ink_inet_is_ip(ip) ? ink_inet_ntop(ip, ipb, sizeof ipb) + : ats_is_ip(ip) ? ats_ip_ntop(ip, ipb, sizeof ipb) : "" ); HOSTDB_INCREMENT_DYN_STAT(hostdb_total_hits_stat); @@ -748,7 +748,7 @@ HostDBProcessor::getby(Continuation * cont, } Debug("hostdb", "delaying force %d answer for %s", aforce_dns, hostname ? hostname - : ink_inet_is_ip(ip) ? ink_inet_ntop(ip, ipb, sizeof ipb) + : ats_is_ip(ip) ? ats_ip_ntop(ip, ipb, sizeof ipb) : "" ); @@ -784,7 +784,7 @@ HostDBProcessor::getbyname_re(Continuation * cont, const char *ahostname, int le ProxyMutex *mutex = thread->mutex; sockaddr_in ip; - ink_inet_ip4_set(&ip, INADDR_ANY, htons(port)); + ats_ip4_set(&ip, INADDR_ANY, htons(port)); if (flags & HOSTDB_FORCE_DNS_ALWAYS) force_dns = true; @@ -793,7 +793,7 @@ HostDBProcessor::getbyname_re(Continuation * cont, const char *ahostname, int le if (force_dns) HOSTDB_INCREMENT_DYN_STAT(hostdb_re_dns_on_reload_stat); } - return getby(cont, ahostname, len, ink_inet_sa_cast(&ip), force_dns); + return getby(cont, ahostname, len, ats_ip_sa_cast(&ip), force_dns); } @@ -826,7 +826,7 @@ HostDBProcessor::getSRVbyname_imm(Continuation * cont, process_srv_info_pfn proc } sockaddr_in ip; - ink_inet_ip4_set(&ip, INADDR_ANY, htons(port)); + ats_ip4_set(&ip, INADDR_ANY, htons(port)); if (!len) len = strlen(hostname); @@ -841,7 +841,7 @@ HostDBProcessor::getSRVbyname_imm(Continuation * cont, process_srv_info_pfn proc // If we can get the lock and a level 1 probe succeeds, return if (lock) { - HostDBInfo *r = probe(bucket_mutex, md5, hostname, len, ink_inet_sa_cast(&ip), pDS, false, true); + HostDBInfo *r = probe(bucket_mutex, md5, hostname, len, ats_ip_sa_cast(&ip), pDS, false, true); if (r) { Debug("hostdb", "immediate SRV answer for %s from hostdb", hostname); Debug("dns_srv", "immediate SRV answer for %s from hostdb", hostname); @@ -856,7 +856,7 @@ HostDBProcessor::getSRVbyname_imm(Continuation * cont, process_srv_info_pfn proc // Otherwise, create a continuation to do a deeper probe in the background HostDBContinuation *c = hostDBContAllocator.alloc(); - c->init(hostname, len, ink_inet_sa_cast(&ip), md5, cont, pDS, true, dns_lookup_timeout); + c->init(hostname, len, ats_ip_sa_cast(&ip), md5, cont, pDS, true, dns_lookup_timeout); c->force_dns = force_dns; SET_CONTINUATION_HANDLER(c, (HostDBContHandler) & HostDBContinuation::probeEvent); @@ -881,8 +881,8 @@ HostDBProcessor::getbyname_imm(Continuation * cont, process_hostdb_info_pfn proc EThread *thread = cont->mutex->thread_holding; ProxyMutex *mutex = thread->mutex; sockaddr_in ip_store; - sockaddr* ip = ink_inet_sa_cast(&ip_store); - ink_inet_ip4_set(ip, INADDR_ANY, htons(port)); + sockaddr* ip = ats_ip_sa_cast(&ip_store); + ats_ip4_set(ip, INADDR_ANY, htons(port)); if (flags & HOSTDB_FORCE_DNS_ALWAYS) force_dns = true; @@ -965,7 +965,7 @@ do_setby(HostDBInfo * r, HostDBApplicationInfo * app, const char *hostname, sock if (rr) { ink_assert(hostname); for (int i = 0; i < rr->n; i++) { - if (0 == ink_inet_cmp(rr->info[i].ip(), ip)) { + if (0 == ats_ip_addr_cmp(rr->info[i].ip(), ip)) { Debug("hostdb", "immediate setby for %s", hostname ? hostname : ""); rr->info[i].app.allotment.application1 = app->allotment.application1; rr->info[i].app.allotment.application2 = app->allotment.application2; @@ -973,7 +973,7 @@ do_setby(HostDBInfo * r, HostDBApplicationInfo * app, const char *hostname, sock } } } else { - if (r->reverse_dns || (!r->round_robin && ink_inet_eq(r->ip(), ip))) { + if (r->reverse_dns || (!r->round_robin && ats_ip_addr_eq(r->ip(), ip))) { Debug("hostdb", "immediate setby for %s", hostname ? hostname : ""); r->app.allotment.application1 = app->allotment.application1; r->app.allotment.application2 = app->allotment.application2; @@ -989,7 +989,7 @@ HostDBProcessor::setby(const char *hostname, int len, sockaddr const* ip, HostDB return; INK_MD5 md5; - unsigned short port = ink_inet_get_port(ip); + unsigned short port = ats_ip_port_host_order(ip); // if it is by name, INK_MD5 the name // @@ -1003,10 +1003,10 @@ HostDBProcessor::setby(const char *hostname, int len, sockaddr const* ip, HostDB // uint8_t buff[INK_IP6_SIZE+4]; memset(buff, 0, sizeof(buff)); - if (ink_inet_is_ip4(ip)) - memcpy(buff+2, &ink_inet_ip4_addr_cast(ip), sizeof(in_addr_t)); - else if (ink_inet_is_ip6(ip)) - memcpy(buff+2, &ink_inet_ip6_addr_cast(ip), sizeof(in6_addr)); + if (ats_is_ip4(ip)) + memcpy(buff+2, &ats_ip4_addr_cast(ip), sizeof(in_addr_t)); + else if (ats_is_ip6(ip)) + memcpy(buff+2, &ats_ip6_addr_cast(ip), sizeof(in6_addr)); md5.encodeBuffer(buff, sizeof buff); } @@ -1057,10 +1057,10 @@ remove_round_robin(HostDBInfo * r, const char *hostname, sockaddr const* ip) if (!rr) return false; for (int i = 0; i < rr->good; i++) { - if (0 == ink_inet_cmp(rr->info[i].ip(), ip)) { + if (0 == ats_ip_addr_cmp(rr->info[i].ip(), ip)) { ip_text_buffer b; Debug("hostdb", "Deleting %s from '%s' round robin DNS entry", - ink_inet_ntop(ip, b, sizeof b), + ats_ip_ntop(ip, b, sizeof b), hostname ); HostDBInfo tmp = rr->info[i]; @@ -1076,7 +1076,7 @@ remove_round_robin(HostDBInfo * r, const char *hostname, sockaddr const* ip) char *rr_ip_list = (char *) alloca(bufsize); char *p = rr_ip_list; for (int n = 0; n < rr->good; ++n) { - ink_inet_ntop(rr->info[n].ip(), p, bufsize); + ats_ip_ntop(rr->info[n].ip(), p, bufsize); int nbytes = strlen(p); p += nbytes; bufsize -= nbytes; @@ -1098,7 +1098,7 @@ HostDBProcessor::failed_connect_on_ip_for_name(Continuation * cont, sockaddr con INK_MD5 md5; char *pServerLine = 0; void *pDS = 0; - unsigned short port = ink_inet_get_port(ip); + unsigned short port = ats_ip_port_host_order(ip); #ifdef SPLIT_DNS SplitDNS *pSD = 0; @@ -1180,14 +1180,14 @@ HostDBContinuation::lookup_done(sockaddr const* aip, char *aname, bool around_ro HostDBInfo *i = NULL; ink_debug_assert(this_ethread() == hostDB.lock_for_bucket((int) (fold_md5(md5) % hostDB.buckets))->thread_holding); - if (!aip || !ink_inet_is_ip(aip) || !aname || !aname[0]) { + if (!aip || !ats_is_ip(aip) || !aname || !aname[0]) { if (is_byname()) { Debug("hostdb", "lookup_done() failed for '%s'", name); } else if (is_srv()) { Debug("dns_srv", "SRV failed for '%s'", name); } else { ip_text_buffer b; - Debug("hostdb", "failed for %s", ink_inet_ntop(&ip.sa, b, sizeof b)); + Debug("hostdb", "failed for %s", ats_ip_ntop(&ip.sa, b, sizeof b)); } i = insert(hostdb_ip_fail_timeout_interval); // currently ... 0 i->round_robin = false; @@ -1216,8 +1216,8 @@ HostDBContinuation::lookup_done(sockaddr const* aip, char *aname, bool around_ro i = insert(ttl_seconds); if (is_byname()) { ip_text_buffer b; - Debug("hostdb", "done %s TTL %d", ink_inet_ntop(aip, b, sizeof b), ttl_seconds); - ink_inet_copy(i->ip(), aip); + Debug("hostdb", "done %s TTL %d", ats_ip_ntop(aip, b, sizeof b), ttl_seconds); + ats_ip_copy(i->ip(), aip); i->round_robin = around_robin; i->reverse_dns = false; if (name != aname) { @@ -1226,7 +1226,7 @@ HostDBContinuation::lookup_done(sockaddr const* aip, char *aname, bool around_ro i->is_srv = false; } else if (is_srv()) { - ink_inet_copy(i->ip(), aip); /* this doesnt matter w. srv records -- setting to 1 so Md5 works */ + ats_ip_copy(i->ip(), aip); /* this doesnt matter w. srv records -- setting to 1 so Md5 works */ i->reverse_dns = false; @@ -1305,12 +1305,12 @@ restore_info(HostDBInfo * r, HostDBInfo * old_r, HostDBInfo & old_info, HostDBRo { if (old_rr_data) { for (int j = 0; j < old_rr_data->n; j++) - if (ink_inet_eq(old_rr_data->info[j].ip(), r->ip())) { + if (ats_ip_addr_eq(old_rr_data->info[j].ip(), r->ip())) { r->app = old_rr_data->info[j].app; return true; } } else if (old_r) - if (ink_inet_eq(old_info.ip(), r->ip())) { + if (ats_ip_addr_eq(old_info.ip(), r->ip())) { r->app = old_info.app; return true; } @@ -1402,8 +1402,8 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e) HostDBInfo *r = NULL; sockaddr_storage tip; // temporary IP data. - sockaddr* tip_ptr = ink_inet_sa_cast(&tip); - ink_inet_invalidate(tip_ptr); + sockaddr* tip_ptr = ats_ip_sa_cast(&tip); + ats_ip_invalidate(tip_ptr); if (first) ip_addr_set(tip_ptr, af, first); if (is_byname()) @@ -1430,7 +1430,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e) SRV *t = q->dequeue(); HostDBInfo& item = rr_data->info[i]; - ink_inet_invalidate(item.ip()); + ats_ip_invalidate(item.ip()); item.round_robin = 0; item.reverse_dns = 0; @@ -1522,7 +1522,7 @@ HostDBContinuation::dnsEvent(int event, HostEnt * e) // struct HostDB_get_message { INK_MD5 md5; - ts_ip_endpoint ip; + IpEndpoint ip; Continuation *cont; int namelen; char name[MAXDNAME]; @@ -1539,7 +1539,7 @@ HostDBContinuation::make_get_message(char *buf, int size) HostDB_get_message *msg = reinterpret_cast(buf); msg->md5 = md5; - ink_inet_copy(&msg->ip.sa, &ip.sa); + ats_ip_copy(&msg->ip.sa, &ip.sa); msg->cont = this; // name @@ -1607,7 +1607,7 @@ bool HostDBContinuation::do_get_response(Event * e) // struct HostDB_put_message { INK_MD5 md5; - ts_ip_endpoint ip; + IpEndpoint ip; unsigned int ttl; unsigned int missing:1; unsigned int round_robin:1; @@ -1633,7 +1633,7 @@ HostDBContinuation::make_put_message(HostDBInfo * r, Continuation * c, char *buf msg->md5 = md5; msg->cont = c; if (r) { - ink_inet_copy(&msg->ip.sa, r->ip()); + ats_ip_copy(&msg->ip.sa, r->ip()); msg->application1 = r->app.allotment.application1; msg->application2 = r->app.allotment.application2; msg->missing = false; @@ -1694,7 +1694,7 @@ HostDBContinuation::probeEvent(int event, Event * e) return EVENT_DONE; } - if (!hostdb_enable || (!*name && !ink_inet_is_ip(&ip.sa))) { + if (!hostdb_enable || (!*name && !ats_is_ip(&ip.sa))) { if (action.continuation) action.continuation->handleEvent(EVENT_HOST_DB_LOOKUP, NULL); #ifdef NON_MODULAR @@ -1791,8 +1791,8 @@ HostDBContinuation::do_dns() ink_assert(!action.cancelled); if (is_byname()) { Debug("hostdb", "DNS %s", name); - ts_ip_endpoint tip; - if (0 == ink_inet_pton(name, &tip.sa)) { + IpEndpoint tip; + if (0 == ats_ip_pton(name, &tip.sa)) { // check 127.0.0.1 format // What the heck does that mean? - AMC if (action.continuation) { HostDBInfo *r = lookup_done(&tip.sa, name, false, HOST_DB_MAX_TTL, NULL); @@ -1821,7 +1821,7 @@ HostDBContinuation::do_dns() pending_action = dnsProcessor.getSRVbyname(this, name, dnsH, dns_lookup_timeout); } else { ip_text_buffer ipb; - Debug("hostdb", "DNS IP %s", ink_inet_ntop(&ip.sa, ipb, sizeof ipb)); + Debug("hostdb", "DNS IP %s", ats_ip_ntop(&ip.sa, ipb, sizeof ipb)); pending_action = dnsProcessor.gethostbyaddr(this, &ip.sa, dns_lookup_timeout); } } else { @@ -2124,7 +2124,7 @@ typedef int (ShowHostDB::*ShowHostDBEventHandler) (int event, Event * data); struct ShowHostDB: public ShowCont { char *name; - ts_ip_endpoint ip; + IpEndpoint ip; bool force; int showMain(int event, Event * e) @@ -2174,7 +2174,7 @@ struct ShowHostDB: public ShowCont if (r->reverse_dns) { CHECK_SHOW(show("%s%s\n", "Hostname", r->hostname()? r->hostname() : "")); } else { - CHECK_SHOW(show("%s%s\n", "IP", ink_inet_ntop(r->ip(), b, sizeof b))); + CHECK_SHOW(show("%s%s\n", "IP", ats_ip_ntop(r->ip(), b, sizeof b))); } CHECK_SHOW(show("\n")); return EVENT_CONT; @@ -2209,7 +2209,7 @@ struct ShowHostDB: public ShowCont } else { if (name) { ip_text_buffer b; - CHECK_SHOW(show("

%s Not Found

\n", ink_inet_ntop(&ip.sa, b, sizeof b))); + CHECK_SHOW(show("

%s Not Found

\n", ats_ip_ntop(&ip.sa, b, sizeof b))); } else { CHECK_SHOW(show("

%s Not Found

\n", name)); } @@ -2221,7 +2221,7 @@ struct ShowHostDB: public ShowCont ShowHostDB(Continuation * c, HTTPHdr * h) : ShowCont(c, h), name(0), force(0) { - ink_inet_invalidate(&ip); + ats_ip_invalidate(&ip); SET_HANDLER(&ShowHostDB::showMain); } @@ -2247,7 +2247,7 @@ register_ShowHostDB(Continuation * c, HTTPHdr * h) if (s->sarg) gn = (char *)memchr(s->sarg, '=', strlen(s->sarg)); if (gn) { - ink_inet_pton(gn+1, &s->ip); // hope that's null terminated. + ats_ip_pton(gn+1, &s->ip); // hope that's null terminated. } SET_CONTINUATION_HANDLER(s, &ShowHostDB::showLookup); } else if (STR_LEN_EQ_PREFIX(path, path_len, "name")) { @@ -2297,7 +2297,7 @@ struct HostDBTestReverse: public Continuation #else l = lrand48(); #endif - ts_ip_endpoint ip; + IpEndpoint ip; ip.sin.sin_addr.s_addr = static_cast(l); outstanding++; total++; diff --git a/iocore/hostdb/I_HostDBProcessor.h b/iocore/hostdb/I_HostDBProcessor.h index c697e2504ac..34b3ab6a9a2 100644 --- a/iocore/hostdb/I_HostDBProcessor.h +++ b/iocore/hostdb/I_HostDBProcessor.h @@ -141,7 +141,7 @@ struct HostDBInfo } else if (byname) { if (reverse_dns) goto Lbad; - if (!ink_inet_is_ip(ip())) + if (!ats_is_ip(ip())) goto Lbad; } else { if (!reverse_dns) @@ -233,7 +233,7 @@ struct HostDBInfo // union { - ts_ip_endpoint ip; ///< IP address / port data. + IpEndpoint ip; ///< IP address / port data. int hostname_offset; ///< Some hostname thing. } data; @@ -260,8 +260,8 @@ struct HostDBInfo uint64_t md5_high; - bool failed() { return !ink_inet_is_ip(ip()); } - void set_failed() { ink_inet_invalidate(ip()); } + bool failed() { return !ats_is_ip(ip()); } + void set_failed() { ats_ip_invalidate(ip()); } void set_deleted() { deleted = 1; } bool is_deleted() const { return deleted; } @@ -294,7 +294,7 @@ struct HostDBInfo void reset() { - ink_inet_invalidate(ip()); + ats_ip_invalidate(ip()); app.allotment.application1 = 0; app.allotment.application2 = 0; backed = 0; @@ -335,7 +335,7 @@ HostDBInfo() app.allotment.application1 = 0; app.allotment.application2 = 0; #endif - ink_inet_invalidate(ip()); + ats_ip_invalidate(ip()); return; } @@ -470,8 +470,8 @@ struct HostDBProcessor: public Processor void setbyname_appinfo(char *hostname, int len, int port, HostDBApplicationInfo * app) { sockaddr_in addr; - ink_inet_ip4_set(&addr, INADDR_ANY, port); - setby(hostname, len, ink_inet_sa_cast(&addr), app); + ats_ip4_set(&addr, INADDR_ANY, port); + setby(hostname, len, ats_ip_sa_cast(&addr), app); } void setbyaddr_appinfo(sockaddr const* addr, HostDBApplicationInfo * app) { @@ -481,8 +481,8 @@ struct HostDBProcessor: public Processor void setbyaddr_appinfo(in_addr_t ip, HostDBApplicationInfo * app) { sockaddr_in addr; - ink_inet_ip4_set(&addr, ip); - this->setby(0, 0, ink_inet_sa_cast(&addr), app); + ats_ip4_set(&addr, ip); + this->setby(0, 0, ats_ip_sa_cast(&addr), app); } /** Configuration. */ diff --git a/iocore/hostdb/P_HostDBProcessor.h b/iocore/hostdb/P_HostDBProcessor.h index 48a2ff96818..b7961ea68c1 100644 --- a/iocore/hostdb/P_HostDBProcessor.h +++ b/iocore/hostdb/P_HostDBProcessor.h @@ -35,14 +35,14 @@ inline unsigned int HOSTDB_CLIENT_IP_HASH( sockaddr const* rhs ) { unsigned int zret = ~static_cast(0); - if (ink_inet_are_compatible(lhs,rhs)) { - if (ink_inet_is_ip4(lhs)) { - in_addr_t ip1 = ink_inet_ip4_addr_cast(lhs); - in_addr_t ip2 = ink_inet_ip4_addr_cast(rhs); + if (ats_ip_are_compatible(lhs,rhs)) { + if (ats_is_ip4(lhs)) { + in_addr_t ip1 = ats_ip4_addr_cast(lhs); + in_addr_t ip2 = ats_ip4_addr_cast(rhs); zret = (ip1 >> 16) ^ ip1 ^ ip2 ^ (ip2 >> 16); - } else if (ink_inet_is_ip6(lhs)) { - uint32_t const* ip1 = ink_inet_addr32_cast(lhs); - uint32_t const* ip2 = ink_inet_addr32_cast(rhs); + } else if (ats_is_ip6(lhs)) { + uint32_t const* ip1 = ats_ip_addr32_cast(lhs); + uint32_t const* ip2 = ats_ip_addr32_cast(rhs); for ( int i = 0 ; i < 4 ; ++i, ++ip1, ++ip2 ) { zret ^= (*ip1 >> 16) ^ *ip1 ^ *ip2 ^ (*ip2 >> 16); } @@ -174,7 +174,7 @@ HostDBRoundRobin::find_ip(sockaddr const* ip) { } for (int i = 0; i < good; i++) { - if (ink_inet_eq(ip, info[i].ip())) { + if (ats_ip_addr_eq(ip, info[i].ip())) { return &info[i]; } } @@ -299,7 +299,7 @@ typedef int (HostDBContinuation::*HostDBContHandler) (int, void *); struct HostDBContinuation: public Continuation { Action action; - ts_ip_endpoint ip; + IpEndpoint ip; unsigned int ttl; bool is_srv_lookup; int dns_lookup_timeout; diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc index 192b9e5bc5e..1dbbe123b49 100644 --- a/iocore/net/Connection.cc +++ b/iocore/net/Connection.cc @@ -92,8 +92,8 @@ Server::accept(Connection * c) if (is_debug_tag_set("iocore_net_server")) { ip_port_text_buffer ipb1, ipb2; Debug("iocore_net_server", "Connection accepted [Server]. %s -> %s\n" - , ink_inet_nptop(&c->addr, ipb2, sizeof(ipb2)) - , ink_inet_nptop(&addr, ipb1, sizeof(ipb1)) + , ats_ip_nptop(&c->addr, ipb2, sizeof(ipb2)) + , ats_ip_nptop(&addr, ipb1, sizeof(ipb1)) ); } @@ -268,10 +268,10 @@ Server::listen(bool non_blocking, int recv_bufsize, int send_bufsize, bool trans int res = 0; int namelen; - if (!ink_inet_is_ip(&accept_addr)) { - ink_inet_ip4_set(&addr, INADDR_ANY,0); + if (!ats_is_ip(&accept_addr)) { + ats_ip4_set(&addr, INADDR_ANY,0); } else { - ink_inet_copy(&addr, &accept_addr); + ats_ip_copy(&addr, &accept_addr); } res = socketManager.socket(addr.sa.sa_family, SOCK_STREAM, IPPROTO_TCP); @@ -339,13 +339,13 @@ Server::listen(bool non_blocking, int recv_bufsize, int send_bufsize, bool trans } #endif - if (ink_inet_is_ip6(&addr) && (res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int))) < 0) + if (ats_is_ip6(&addr) && (res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int))) < 0) goto Lerror; if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, SOCKOPT_ON, sizeof(int))) < 0) goto Lerror; - if ((res = socketManager.ink_bind(fd, &addr.sa, ink_inet_ip_size(&addr.sa), IPPROTO_TCP)) < 0) { + if ((res = socketManager.ink_bind(fd, &addr.sa, ats_ip_size(&addr.sa), IPPROTO_TCP)) < 0) { goto Lerror; } #ifdef SET_TCP_NO_DELAY @@ -391,6 +391,6 @@ Server::listen(bool non_blocking, int recv_bufsize, int send_bufsize, bool trans Lerror: if (fd != NO_FD) close(); - Error("Could not bind or listen to port %d (error: %d)", ink_inet_get_port(&addr), res); + Error("Could not bind or listen to port %d (error: %d)", ats_ip_port_host_order(&addr), res); return res; } diff --git a/iocore/net/I_NetProcessor.h b/iocore/net/I_NetProcessor.h index 847a664fbb5..bea906af475 100644 --- a/iocore/net/I_NetProcessor.h +++ b/iocore/net/I_NetProcessor.h @@ -51,7 +51,7 @@ class NetProcessor:public Processor int local_port; /// Local address to bind for accept. /// If not set -> any address. - InkInetAddr local_ip; + IpAddr local_ip; /// IP address family. /// @note Ignored if an explicit incoming address is set in the /// the configuration (@c local_ip). If neither is set IPv4 is used. @@ -233,8 +233,8 @@ class NetProcessor:public Processor ) { struct sockaddr_in addr; - ink_inet_ip4_set(&addr, ip, htons(port)); - return connect_re(cont, ink_inet_sa_cast(&addr), options); + ats_ip4_set(&addr, ip, htons(port)); + return connect_re(cont, ats_ip_sa_cast(&addr), options); } /** @@ -276,8 +276,8 @@ class NetProcessor:public Processor ) { struct sockaddr_in addr; - ink_inet_ip4_set(&addr, ip, htons(port)); - return connect_s(cont, ink_inet_sa_cast(&addr), timeout, opts); + ats_ip4_set(&addr, ip, htons(port)); + return connect_s(cont, ats_ip_sa_cast(&addr), timeout, opts); } /** diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h index 2297830ca7c..0c55580fe5d 100644 --- a/iocore/net/I_NetVConnection.h +++ b/iocore/net/I_NetVConnection.h @@ -101,7 +101,7 @@ struct NetVCOptions { causes the value in @a local_addr to be ignored. The IP address and port are separate because most clients treat - these independently. For the same reason @c InkInetAddr is used + these independently. For the same reason @c IpAddr is used to be clear that it contains no port data. @see local_addr @@ -124,7 +124,7 @@ struct NetVCOptions { @see addr_binding @see ip_family */ - InkInetAddr local_ip; + IpAddr local_ip; /** Local port for connection. Set to 0 for "don't care" (default). */ @@ -569,8 +569,8 @@ class NetVConnection:public VConnection NetVConnection & operator =(const NetVConnection &); protected: - ts_ip_endpoint local_addr; - ts_ip_endpoint remote_addr; + IpEndpoint local_addr; + IpEndpoint remote_addr; bool got_local_addr; bool got_remote_addr; diff --git a/iocore/net/I_UDPNet.h b/iocore/net/I_UDPNet.h index ec9c8566216..5e558ec86d0 100644 --- a/iocore/net/I_UDPNet.h +++ b/iocore/net/I_UDPNet.h @@ -82,7 +82,7 @@ class UDPNetProcessor:public Processor inkcoreapi Action *UDPBind(Continuation * c, sockaddr const* addr, int send_bufsize = 0, int recv_bufsize = 0); // The mess again: the complier won't let me stick UDPConnection here. - void UDPClassifyConnection(Continuation * udpConn, InkInetAddr const& addr); + void UDPClassifyConnection(Continuation * udpConn, IpAddr const& addr); // create pairs of UDPConnections in which the first connection is // on a even-#'ed port and the second connection is on the next diff --git a/iocore/net/I_UDPPacket.h b/iocore/net/I_UDPPacket.h index 378d5cfe88e..f248e7aba38 100644 --- a/iocore/net/I_UDPPacket.h +++ b/iocore/net/I_UDPPacket.h @@ -65,8 +65,8 @@ class UDPPacket inkcoreapi void append_block(IOBufferBlock * block); virtual void UDPPacket_is_abstract() = 0; - ts_ip_endpoint from; // what address came from - ts_ip_endpoint to; // what address to send to + IpEndpoint from; // what address came from + IpEndpoint to; // what address to send to int from_size; diff --git a/iocore/net/P_Connection.h b/iocore/net/P_Connection.h index f16f78ea1c8..1630ee30c09 100644 --- a/iocore/net/P_Connection.h +++ b/iocore/net/P_Connection.h @@ -81,7 +81,7 @@ struct NetVCOptions; struct Connection { SOCKET fd; ///< Socket for connection. - ts_ip_endpoint addr; ///< Associated address. + IpEndpoint addr; ///< Associated address. bool is_bound; ///< Flag for already bound to a local address. bool is_connected; ///< Flag for already connected. @@ -121,7 +121,7 @@ struct Connection void setRemote( sockaddr const* remote_addr ///< Address and port. ) { - ink_inet_copy(&addr, remote_addr); + ats_ip_copy(&addr, remote_addr); } /** @@ -131,7 +131,7 @@ struct Connection in_addr_t ip, int port ) { - ink_inet_ip4_set(&addr.sin, ip, htons(port)); + ats_ip4_set(&addr.sin, ip, htons(port)); } @@ -152,12 +152,12 @@ struct Connection struct sockaddr_in mc_addr; struct sockaddr_in my_addr; - ink_inet_ip4_set(&mc_addr, mc_ip, htons(mc_port)); - ink_inet_ip4_set(&my_addr, my_ip, htons(my_port)); + ats_ip4_set(&mc_addr, mc_ip, htons(mc_port)); + ats_ip4_set(&my_addr, my_ip, htons(my_port)); return setup_mc_send( - ink_inet_sa_cast(&mc_addr), - ink_inet_sa_cast(&my_addr), + ats_ip_sa_cast(&mc_addr), + ats_ip_sa_cast(&my_addr), non_blocking, mc_ttl, mc_loopback, c); } @@ -173,9 +173,9 @@ struct Connection bool non_blocking = NON_BLOCKING, Connection * sendchan = NULL, Continuation * c = NULL) { struct sockaddr_in mc_addr; - ink_inet_ip4_set(&mc_addr, mc_ip, port); + ats_ip4_set(&mc_addr, mc_ip, port); - return setup_mc_receive(ink_inet_sa_cast(&mc_addr), non_blocking, sendchan, c); + return setup_mc_receive(ats_ip_sa_cast(&mc_addr), non_blocking, sendchan, c); } @@ -199,7 +199,7 @@ struct Connection struct Server: public Connection { /// Client side (inbound) local IP address. - ts_ip_endpoint accept_addr; + IpEndpoint accept_addr; /// If set, the related incoming connect was transparent. bool f_inbound_transparent; diff --git a/iocore/net/P_NetVConnection.h b/iocore/net/P_NetVConnection.h index e5d05c514f6..b62ed54b726 100644 --- a/iocore/net/P_NetVConnection.h +++ b/iocore/net/P_NetVConnection.h @@ -37,8 +37,8 @@ TS_INLINE in_addr_t NetVConnection::get_remote_ip() { sockaddr const* addr = this->get_remote_addr(); - return ink_inet_is_ip4(addr) - ? ink_inet_ip4_addr_cast(addr) + return ats_is_ip4(addr) + ? ats_ip4_addr_cast(addr) : 0; } @@ -47,7 +47,7 @@ NetVConnection::get_remote_ip() TS_INLINE uint16_t NetVConnection::get_remote_port() { - return ink_inet_get_port(this->get_remote_addr()); + return ats_ip_port_host_order(this->get_remote_addr()); } TS_INLINE sockaddr const* @@ -56,9 +56,9 @@ NetVConnection::get_local_addr() if (!got_local_addr) { set_local_addr(); if ( - (ink_inet_is_ip(&local_addr) && ink_inet_port_cast(&local_addr)) // IP and has a port. - || (ink_inet_is_ip4(&local_addr) && INADDR_ANY != ink_inet_ip4_addr_cast(&local_addr)) // IPv4 - || (ink_inet_is_ip6(&local_addr) && !IN6_IS_ADDR_UNSPECIFIED(&local_addr.sin6.sin6_addr)) + (ats_is_ip(&local_addr) && ats_ip_port_cast(&local_addr)) // IP and has a port. + || (ats_is_ip4(&local_addr) && INADDR_ANY != ats_ip4_addr_cast(&local_addr)) // IPv4 + || (ats_is_ip6(&local_addr) && !IN6_IS_ADDR_UNSPECIFIED(&local_addr.sin6.sin6_addr)) ) { got_local_addr = 1; } @@ -70,8 +70,8 @@ TS_INLINE in_addr_t NetVConnection::get_local_ip() { sockaddr const* addr = this->get_local_addr(); - return ink_inet_is_ip4(addr) - ? ink_inet_ip4_addr_cast(addr) + return ats_is_ip4(addr) + ? ats_ip4_addr_cast(addr) : 0; } @@ -79,5 +79,5 @@ NetVConnection::get_local_ip() TS_INLINE uint16_t NetVConnection::get_local_port() { - return ink_inet_get_port(this->get_local_addr()); + return ats_ip_port_host_order(this->get_local_addr()); } diff --git a/iocore/net/P_Socks.h b/iocore/net/P_Socks.h index 8a98a0cad5d..d03eacd8c78 100644 --- a/iocore/net/P_Socks.h +++ b/iocore/net/P_Socks.h @@ -62,7 +62,7 @@ struct socks_conf_struct #endif #ifndef SOCKS_WITH_TS - ts_ip_endpoint server_addr; + IpEndpoint server_addr; #endif socks_conf_struct():socks_needed(0), server_connect_timeout(0), socks_timeout(100), default_version(5), @@ -115,9 +115,9 @@ struct SocksEntry:public Continuation SocksNetVC *netVConnection; // Changed from @a ip and @a port. - ts_ip_endpoint target_addr; ///< Original target address. + IpEndpoint target_addr; ///< Original target address. // Changed from @a server_ip, @a server_port. - ts_ip_endpoint server_addr; ///< Origin server address. + IpEndpoint server_addr; ///< Origin server address. int nattempts; diff --git a/iocore/net/P_UDPConnection.h b/iocore/net/P_UDPConnection.h index 94360735f3f..724bb9e3e00 100644 --- a/iocore/net/P_UDPConnection.h +++ b/iocore/net/P_UDPConnection.h @@ -46,7 +46,7 @@ class UDPConnectionInternal:public UDPConnection int refcount; // public for assertion SOCKET fd; - ts_ip_endpoint binding; + IpEndpoint binding; int binding_valid; int tobedestroyed; int sendGenerationNum; @@ -113,7 +113,7 @@ TS_INLINE void UDPConnection::setBinding(struct sockaddr const* s) { UDPConnectionInternal *p = (UDPConnectionInternal *) this; - ink_inet_copy(&p->binding, s); + ats_ip_copy(&p->binding, s); p->binding_valid = 1; } @@ -121,7 +121,7 @@ TS_INLINE int UDPConnection::getBinding(struct sockaddr *s) { UDPConnectionInternal *p = (UDPConnectionInternal *) this; - ink_inet_copy(s, &p->binding); + ats_ip_copy(s, &p->binding); return p->binding_valid; } @@ -165,7 +165,7 @@ UDPConnection::GetSendGenerationNumber() TS_INLINE int UDPConnection::getPortNum(void) { - return ink_inet_get_port(&static_cast(this)->binding); + return ats_ip_port_host_order(&static_cast(this)->binding); } TS_INLINE int64_t diff --git a/iocore/net/P_UDPNet.h b/iocore/net/P_UDPNet.h index 91f677c4f4b..37d01514c23 100644 --- a/iocore/net/P_UDPNet.h +++ b/iocore/net/P_UDPNet.h @@ -416,7 +416,7 @@ struct InkSinglePipeInfo int64_t bwAlloc; // this is in Mbps double bwUsed; - InkInetAddr destIP; + IpAddr destIP; uint32_t count; uint64_t bytesSent; uint64_t pktsSent; @@ -456,8 +456,8 @@ class UDPWorkContinuation:public Continuation private: Continuation * cont; int numPairs; - ts_ip_endpoint local_ip; ///< replaces myIP. - ts_ip_endpoint remote_ip; ///< replaces destIP. + IpEndpoint local_ip; ///< replaces myIP. + IpEndpoint remote_ip; ///< replaces destIP. int sendbufsize, recvbufsize; UnixUDPConnection **udpConns; int resultCode; diff --git a/iocore/net/P_UDPPacket.h b/iocore/net/P_UDPPacket.h index 87dcb234464..5ad953e5059 100644 --- a/iocore/net/P_UDPPacket.h +++ b/iocore/net/P_UDPPacket.h @@ -219,7 +219,7 @@ new_UDPPacket(struct sockaddr const* to, ink_hrtime when, char *buf, int len) p->in_heap = 0; #endif p->delivery_time = when; - ink_inet_copy(&p->to, to); + ats_ip_copy(&p->to, to); if (buf) { IOBufferBlock *body = new_IOBufferBlock(); @@ -244,7 +244,7 @@ new_UDPPacket(struct sockaddr const* to, ink_hrtime when, IOBufferBlock * buf, i p->in_heap = 0; #endif p->delivery_time = when; - ink_inet_copy(&p->to, to); + ats_ip_copy(&p->to, to); while (buf) { body = buf->clone(); @@ -265,7 +265,7 @@ new_UDPPacket(struct sockaddr const* to, ink_hrtime when, Ptr buf #endif p->delivery_time = when; if (to) - ink_inet_copy(&p->to, to); + ats_ip_copy(&p->to, to); p->chain = buf; return p; } @@ -286,7 +286,7 @@ new_incoming_UDPPacket(struct sockaddr * from, char *buf, int len) p->in_heap = 0; #endif p->delivery_time = 0; - ink_inet_copy(&p->from, from); + ats_ip_copy(&p->from, from); IOBufferBlock *body = new_IOBufferBlock(); body->alloc(iobuffer_size_to_index(len)); diff --git a/iocore/net/P_UnixNetVConnection.h b/iocore/net/P_UnixNetVConnection.h index 387b1d27dbd..9a9d07bf94d 100644 --- a/iocore/net/P_UnixNetVConnection.h +++ b/iocore/net/P_UnixNetVConnection.h @@ -208,7 +208,7 @@ class UnixNetVConnection:public NetVConnection NetHandler *nh; unsigned int id; // amc - what is this for? Why not use remote_addr or con.addr? - ts_ip_endpoint server_addr; /// Server address and port. + IpEndpoint server_addr; /// Server address and port. union { @@ -250,7 +250,7 @@ typedef int (UnixNetVConnection::*NetVConnHandler) (int, void *); TS_INLINE void UnixNetVConnection::set_remote_addr() { - ink_inet_copy(&remote_addr, &con.addr); + ats_ip_copy(&remote_addr, &con.addr); } TS_INLINE void diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc index 60a67cd6d96..f5383596c0d 100644 --- a/iocore/net/SSLNetVConnection.cc +++ b/iocore/net/SSLNetVConnection.cc @@ -469,7 +469,7 @@ int SSLNetVConnection::sslStartHandShake(int event, int &err) { SSL_CTX *ctx = NULL; - ts_ip_endpoint ip; + IpEndpoint ip; int namelen = sizeof(ip); if (event == SSL_EVENT_SERVER) { @@ -477,7 +477,7 @@ SSLNetVConnection::sslStartHandShake(int event, int &err) if (sslCertLookup.multipleCerts) { char buff[INET6_ADDRSTRLEN]; safe_getsockname(get_socket(), &ip.sa, &namelen); - ink_inet_ntop(&ip.sa, buff, sizeof(buff)); + ats_ip_ntop(&ip.sa, buff, sizeof(buff)); ctx = sslCertLookup.findInfoInHash(buff); if (ctx == NULL) ctx = ssl_NetProcessor.ctx; diff --git a/iocore/net/Socks.cc b/iocore/net/Socks.cc index 21c68d6437e..36dd678ae36 100644 --- a/iocore/net/Socks.cc +++ b/iocore/net/Socks.cc @@ -54,7 +54,7 @@ SocksEntry::init(ProxyMutex * m, SocksNetVC * vc, unsigned char socks_support, u SET_HANDLER(&SocksEntry::startEvent); - ink_inet_copy(&target_addr, vc->get_local_addr()); + ats_ip_copy(&target_addr, vc->get_local_addr()); #ifdef SOCKS_WITH_TS req_data.hdr = 0; @@ -62,11 +62,11 @@ SocksEntry::init(ProxyMutex * m, SocksNetVC * vc, unsigned char socks_support, u req_data.api_info = 0; req_data.xact_start = time(0); - assert(ink_inet_is_ip4(&target_addr)); - ink_inet_copy(&req_data.dest_ip, &target_addr); + assert(ats_is_ip4(&target_addr)); + ats_ip_copy(&req_data.dest_ip, &target_addr); //we dont have information about the source. set to destination's - ink_inet_copy(&req_data.src_ip, &target_addr); + ats_ip_copy(&req_data.src_ip, &target_addr); server_params = SocksServerConfig::acquire(); #endif @@ -104,10 +104,10 @@ SocksEntry::findServer() switch (server_result.r) { case PARENT_SPECIFIED: // Original was inet_addr, but should hostnames work? - // ink_inet_pton only supports numeric (because other clients + // ats_ip_pton only supports numeric (because other clients // explicitly want to avoid hostname lookups). - if (0 == ink_inet_pton(server_result.hostname, &server_addr)) { - ink_inet_port_cast(&server_addr) = htons(server_result.port); + if (0 == ats_ip_pton(server_result.hostname, &server_addr)) { + ats_ip_port_cast(&server_addr) = htons(server_result.port); } else { Debug("SocksParent", "Invalid parent server specified %s", server_result.hostname); } @@ -122,13 +122,13 @@ SocksEntry::findServer() #else if (nattempts > netProcessor.socks_conf_stuff->connection_attempts) memset(&server_addr, 0, sizeof(server_addr)); - else ink_inet_copy(server_addr, g_socks_conf_stuff->socks_server); + else ats_ip_copy(server_addr, g_socks_conf_stuff->socks_server); #endif // SOCKS_WITH_TS char buff[INET6_ADDRSTRLEN]; Debug("SocksParents", "findServer result: %s:%d", - ink_inet_ntop(&server_addr.sa, buff, sizeof(buff)), - ink_inet_get_port(&server_addr) + ats_ip_ntop(&server_addr.sa, buff, sizeof(buff)), + ats_ip_port_host_order(&server_addr) ); } @@ -163,7 +163,7 @@ SocksEntry::free() netVConnection->do_io_read(this, 0, 0); netVConnection->do_io_write(this, 0, 0); netVConnection->action_ = action_; //assign the original continuation - ink_inet_copy(&netVConnection->server_addr, &server_addr); + ats_ip_copy(&netVConnection->server_addr, &server_addr); Debug("Socks", "Sent success to HTTP"); NET_INCREMENT_DYN_STAT(socks_connections_successful_stat); action_.continuation->handleEvent(NET_EVENT_OPEN, netVConnection); @@ -197,11 +197,11 @@ SocksEntry::startEvent(int event, void *data) } char buff[INET6_ADDRPORTSTRLEN]; - Debug("Socks", "Failed to connect to %s", ink_inet_nptop(&server_addr.sa, buff, sizeof(buff))); + Debug("Socks", "Failed to connect to %s", ats_ip_nptop(&server_addr.sa, buff, sizeof(buff))); findServer(); - if (!ink_inet_is_ip(&server_addr)) { + if (!ats_is_ip(&server_addr)) { Debug("Socks", "Unable to open connection to the SOCKS server"); lerrno = ESOCK_NO_SOCK_SERVER_CONN; free(); @@ -253,18 +253,18 @@ SocksEntry::mainEvent(int event, void *data) p[n_bytes++] = version; p[n_bytes++] = (socks_cmd == NORMAL_SOCKS) ? SOCKS_CONNECT : socks_cmd; - ts = ntohs(ink_inet_port_cast(&server_addr)); + ts = ntohs(ats_ip_port_cast(&server_addr)); if (version == SOCKS5_VERSION) { p[n_bytes++] = 0; //Reserved - if (ink_inet_is_ip4(&server_addr)) { + if (ats_is_ip4(&server_addr)) { p[n_bytes++] = 1; //IPv4 addr memcpy(p + n_bytes, &server_addr.sin.sin_addr, 4 ); n_bytes += 4; - } else if (ink_inet_is_ip6(&server_addr)) { + } else if (ats_is_ip6(&server_addr)) { p[n_bytes++] = 4; //IPv6 addr memcpy(p + n_bytes, &server_addr.sin6.sin6_addr, @@ -280,7 +280,7 @@ SocksEntry::mainEvent(int event, void *data) n_bytes += 2; if (version == SOCKS4_VERSION) { - if (ink_inet_is_ip4(&server_addr)) { + if (ats_is_ip4(&server_addr)) { //for socks4, ip addr is after the port memcpy(p + n_bytes, &server_addr.sin.sin_addr, diff --git a/iocore/net/UnixConnection.cc b/iocore/net/UnixConnection.cc index dadb3484fdd..3be09f550fd 100644 --- a/iocore/net/UnixConnection.cc +++ b/iocore/net/UnixConnection.cc @@ -64,11 +64,11 @@ Connection::setup_mc_send( goto Lerror; } - if ((res = socketManager.ink_bind(fd, my_addr, ink_inet_ip_size(my_addr), IPPROTO_UDP)) < 0) { + if ((res = socketManager.ink_bind(fd, my_addr, ats_ip_size(my_addr), IPPROTO_UDP)) < 0) { goto Lerror; } - ink_inet_copy(&addr, mc_addr); + ats_ip_copy(&addr, mc_addr); #ifdef SET_CLOSE_ON_EXEC if ((res = safe_fcntl(fd, F_SETFD, 1)) < 0) @@ -124,19 +124,19 @@ Connection::setup_mc_receive( if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &enable_reuseaddr, sizeof(enable_reuseaddr)) < 0)) goto Lerror; - ink_inet_copy(&addr, mc_addr); + ats_ip_copy(&addr, mc_addr); - if ((res = socketManager.ink_bind(fd, &addr.sa, ink_inet_ip_size(&addr.sa), IPPROTO_TCP)) < 0) + if ((res = socketManager.ink_bind(fd, &addr.sa, ats_ip_size(&addr.sa), IPPROTO_TCP)) < 0) goto Lerror; if (non_blocking) if ((res = safe_nonblocking(fd)) < 0) goto Lerror; - if (ink_inet_is_ip4(&addr)) { + if (ats_is_ip4(&addr)) { struct ip_mreq mc_request; // Add ourselves to the MultiCast group - mc_request.imr_multiaddr.s_addr = ink_inet_ip4_addr_cast(mc_addr); + mc_request.imr_multiaddr.s_addr = ats_ip4_addr_cast(mc_addr); mc_request.imr_interface.s_addr = INADDR_ANY; if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (char *) &mc_request, sizeof(mc_request)) < 0)) @@ -213,7 +213,7 @@ Connection::open(NetVCOptions const& opt) ink_assert(fd == NO_FD); int enable_reuseaddr = 1; // used for sockopt setting int res = 0; // temp result - ts_ip_endpoint local_addr; + IpEndpoint local_addr; int sock_type = NetVCOptions::USE_UDP == opt.ip_proto ? SOCK_DGRAM : SOCK_STREAM; @@ -234,7 +234,7 @@ Connection::open(NetVCOptions const& opt) family = opt.local_ip.family(); } else { // No local address specified, so use family option if possible. - family = ink_inet_is_ip(opt.ip_family) ? opt.ip_family : AF_INET; + family = ats_is_ip(opt.ip_family) ? opt.ip_family : AF_INET; local_addr.setToAnyAddr(family); local_addr.port() = htons(opt.local_port); } @@ -305,7 +305,7 @@ Connection::open(NetVCOptions const& opt) } } - if (-1 == socketManager.ink_bind(fd, &local_addr.sa, ink_inet_ip_size(&local_addr.sa))) + if (-1 == socketManager.ink_bind(fd, &local_addr.sa, ats_ip_size(&local_addr.sa))) return -errno; cleanup.reset(); @@ -325,7 +325,7 @@ Connection::connect(sockaddr const* target, NetVCOptions const& opt) { cleaner cleanup(this, &Connection::_cleanup); // mark for close until we succeed. - res = ::connect(fd, target, ink_inet_ip_size(target)); + res = ::connect(fd, target, ats_ip_size(target)); // It's only really an error if either the connect was blocking // or it wasn't blocking and the error was other than EINPROGRESS. diff --git a/iocore/net/UnixNetAccept.cc b/iocore/net/UnixNetAccept.cc index a3d981798d7..1e11eac9a49 100644 --- a/iocore/net/UnixNetAccept.cc +++ b/iocore/net/UnixNetAccept.cc @@ -118,7 +118,7 @@ net_accept(NetAccept * na, void *ep, bool blockable) na->alloc_cache = NULL; vc->submit_time = ink_get_hrtime(); - ink_inet_copy(&vc->server_addr, &vc->con.addr); + ats_ip_copy(&vc->server_addr, &vc->con.addr); vc->mutex = new_ProxyMutex(); vc->action_ = *na->action_; vc->set_is_transparent(na->server.f_inbound_transparent); @@ -314,7 +314,7 @@ NetAccept::do_blocking_accept(EThread * t) NET_SUM_GLOBAL_DYN_STAT(net_connections_currently_open_stat, 1); vc->submit_time = now; - ink_inet_copy(&vc->server_addr, &vc->con.addr); + ats_ip_copy(&vc->server_addr, &vc->con.addr); vc->set_is_transparent(server.f_inbound_transparent); vc->mutex = new_ProxyMutex(); vc->action_ = *action_; @@ -356,10 +356,10 @@ NetAccept::acceptEvent(int event, void *ep) NET_DECREMENT_DYN_STAT(net_accepts_currently_open_stat); /* INKqa11179 */ Warning("Accept on port %d failed with error no %d", - ink_inet_get_port(&server.addr), res + ats_ip_port_host_order(&server.addr), res ); Warning("Traffic Server may be unable to accept more network" "connections on %d", - ink_inet_get_port(&server.addr) + ats_ip_port_host_order(&server.addr) ); e->cancel(); delete this; @@ -455,7 +455,7 @@ NetAccept::acceptFastEvent(int event, void *ep) vc->id = net_next_connection_number(); vc->submit_time = ink_get_hrtime(); - ink_inet_copy(&vc->server_addr, &vc->con.addr); + ats_ip_copy(&vc->server_addr, &vc->con.addr); vc->set_is_transparent(server.f_inbound_transparent); vc->mutex = new_ProxyMutex(); vc->thread = e->ethread; diff --git a/iocore/net/UnixNetPages.cc b/iocore/net/UnixNetPages.cc index f68ef6c4526..dfcc28f5dc1 100644 --- a/iocore/net/UnixNetPages.cc +++ b/iocore/net/UnixNetPages.cc @@ -34,7 +34,7 @@ typedef int (ShowNet::*ShowNetEventHandler) (int event, Event * data); struct ShowNet: public ShowCont { int ithread; - ts_ip_endpoint addr; + IpEndpoint addr; int showMain(int event, Event * e) { @@ -63,13 +63,13 @@ struct ShowNet: public ShowCont ink_hrtime now = ink_get_hrtime(); forl_LL(UnixNetVConnection, vc, nh->open_list) { -// uint16_t port = ink_inet_get_port(&addr.sa); - if (ink_inet_is_ip(&addr) && addr != vc->server_addr) +// uint16_t port = ats_ip_port_host_order(&addr.sa); + if (ats_is_ip(&addr) && addr != vc->server_addr) continue; -// if (port && port != ink_inet_get_port(&vc->server_addr.sa) && port != vc->accept_port) +// if (port && port != ats_ip_port_host_order(&vc->server_addr.sa) && port != vc->accept_port) // continue; char ipbuf[INET6_ADDRSTRLEN]; - ink_inet_ntop(&vc->server_addr.sa, ipbuf, sizeof(ipbuf)); + ats_ip_ntop(&vc->server_addr.sa, ipbuf, sizeof(ipbuf)); char opt_ipbuf[INET6_ADDRSTRLEN]; char interbuf[80]; snprintf(interbuf, sizeof(interbuf), "[%s] %s:%d", @@ -100,7 +100,7 @@ struct ShowNet: public ShowCont "\n", vc->id, ipbuf, - ink_inet_get_port(&vc->server_addr), + ats_ip_port_host_order(&vc->server_addr), vc->con.fd, interbuf, // vc->accept_port, @@ -233,7 +233,7 @@ register_ShowNet(Continuation * c, HTTPHdr * h) if (s->sarg) gn = (char *)memchr(s->sarg, '=', strlen(s->sarg)); if (gn) - ink_inet_pton(gn + 1, &s->addr); + ats_ip_pton(gn + 1, &s->addr); SET_CONTINUATION_HANDLER(s, &ShowNet::showConnections); } else if (STREQ_PREFIX(path, path_len, "ports")) { int query_len; @@ -243,7 +243,7 @@ register_ShowNet(Continuation * c, HTTPHdr * h) if (s->sarg) gn = (char *)memchr(s->sarg, '=', strlen(s->sarg)); if (gn) - ink_inet_port_cast(&s->addr.sa) = htons(atoi(gn+1)); + ats_ip_port_cast(&s->addr.sa) = htons(atoi(gn+1)); SET_CONTINUATION_HANDLER(s, &ShowNet::showConnections); } eventProcessor.schedule_imm(s, ET_TASK); diff --git a/iocore/net/UnixNetProcessor.cc b/iocore/net/UnixNetProcessor.cc index 1b49745023f..512a68a08c0 100644 --- a/iocore/net/UnixNetProcessor.cc +++ b/iocore/net/UnixNetProcessor.cc @@ -94,7 +94,7 @@ UnixNetProcessor::accept_internal( EThread *thread = this_ethread(); ProxyMutex *mutex = thread->mutex; int accept_threads = opt.accept_threads; // might be changed. - ts_ip_endpoint accept_ip; // local binding address. + IpEndpoint accept_ip; // local binding address. // Potentially upgrade to SSL. upgradeEtype(et); @@ -118,7 +118,7 @@ UnixNetProcessor::accept_internal( na->accept_fn = net_accept; // All callers used this. na->server.fd = fd; - ink_inet_copy(&na->server.accept_addr, &accept_ip); + ats_ip_copy(&na->server.accept_addr, &accept_ip); na->server.f_inbound_transparent = opt.f_inbound_transparent; if (opt.f_inbound_transparent) { Debug( @@ -153,10 +153,10 @@ UnixNetProcessor::accept_internal( a = createNetAccept(); *a = *na; a->init_accept_loop(); - Debug("iocore_net_accept", "Created accept thread #%d for port %d", i, ink_inet_get_port(&accept_ip)); + Debug("iocore_net_accept", "Created accept thread #%d for port %d", i, ats_ip_port_host_order(&accept_ip)); } // Start the "template" accept thread last. - Debug("iocore_net_accept", "Created accept thread #%d for port %d", accept_threads, ink_inet_get_port(&accept_ip)); + Debug("iocore_net_accept", "Created accept thread #%d for port %d", accept_threads, ats_ip_port_host_order(&accept_ip)); na->init_accept_loop(); } } else { @@ -220,23 +220,23 @@ UnixNetProcessor::connect_re_internal( vc->id = net_next_connection_number(); vc->submit_time = ink_get_hrtime(); vc->setSSLClientConnection(true); - ink_inet_copy(&vc->server_addr, target); + ats_ip_copy(&vc->server_addr, target); vc->mutex = cont->mutex; Action *result = &vc->action_; #ifndef INK_NO_SOCKS if (using_socks) { char buff[INET6_ADDRPORTSTRLEN]; - Debug("Socks", "Using Socks ip: %s\n", ink_inet_nptop(target, buff, sizeof(buff))); + Debug("Socks", "Using Socks ip: %s\n", ats_ip_nptop(target, buff, sizeof(buff))); socksEntry = socksAllocator.alloc(); socksEntry->init(cont->mutex, vc, opt->socks_support, opt->socks_version); /*XXXX remove last two args */ socksEntry->action_ = cont; cont = socksEntry; - if (!ink_inet_is_ip(&socksEntry->server_addr)) { + if (!ats_is_ip(&socksEntry->server_addr)) { socksEntry->lerrno = ESOCK_NO_SOCK_SERVER_CONN; socksEntry->free(); return ACTION_RESULT_DONE; } - ink_inet_copy(&vc->server_addr, &socksEntry->server_addr); + ats_ip_copy(&vc->server_addr, &socksEntry->server_addr); result = &socksEntry->action_; vc->action_ = socksEntry; } else { diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc index c472bbe089d..d61311cf1d7 100644 --- a/iocore/net/UnixUDPNet.cc +++ b/iocore/net/UnixUDPNet.cc @@ -146,7 +146,7 @@ UDPNetProcessorInternal::udp_read_from_net(UDPNetHandler * nh, break; } // create packet - UDPPacket *p = new_incoming_UDPPacket(ink_inet_sa_cast(&fromaddr), buf, r); + UDPPacket *p = new_incoming_UDPPacket(ats_ip_sa_cast(&fromaddr), buf, r); p->setConnection(uc); // XXX: is this expensive? I] really want to know this information p->setArrivalTime(ink_get_hrtime_internal()); @@ -285,7 +285,7 @@ UDPReadContinuation::init_read(int rfd, IOBufferBlock * buf, int len, struct soc fd = rfd; readbuf = buf; readlen = len; - fromaddr = ink_inet_ip6_cast(fromaddr_); + fromaddr = ats_ip6_cast(fromaddr_); fromaddrlen = fromaddrlen_; SET_HANDLER(&UDPReadContinuation::readPollEvent); period = NET_PERIOD; @@ -362,7 +362,7 @@ UDPReadContinuation::readPollEvent(int event_, Event * e) socklen_t tmp_fromlen = *fromaddrlen; int rlen = socketManager.recvfrom(fd, readbuf->end(), readlen, 0, // default flags - ink_inet_sa_cast(fromaddr), &tmp_fromlen); + ats_ip_sa_cast(fromaddr), &tmp_fromlen); completionUtil::setThread(event, e->ethread); // call back user with their event if (rlen > 0) { @@ -548,7 +548,7 @@ UDPNetProcessor::CreateUDPSocket( ) { int res = 0, fd = -1; - ink_assert(ink_inet_are_compatible(remote_addr, local_addr)); + ink_assert(ats_ip_are_compatible(remote_addr, local_addr)); *resfd = -1; if ((res = socketManager.socket(remote_addr->sa_family, SOCK_DGRAM, 0)) < 0) @@ -556,9 +556,9 @@ UDPNetProcessor::CreateUDPSocket( fd = res; if ((res = safe_fcntl(fd, F_SETFL, O_NONBLOCK)) < 0) goto HardError; - if ((res = socketManager.ink_bind(fd, remote_addr, ink_inet_ip_size(remote_addr), IPPROTO_UDP)) < 0) { + if ((res = socketManager.ink_bind(fd, remote_addr, ats_ip_size(remote_addr), IPPROTO_UDP)) < 0) { char buff[INET6_ADDRPORTSTRLEN]; - Debug("udpnet", "ink bind failed on %s", ink_inet_nptop(remote_addr, buff, sizeof(buff))); + Debug("udpnet", "ink bind failed on %s", ats_ip_nptop(remote_addr, buff, sizeof(buff))); goto SoftError; } @@ -577,12 +577,12 @@ UDPNetProcessor::CreateUDPSocket( *resfd = fd; *status = NULL; Debug("udpnet", "creating a udp socket port = %d, %d---success", - ink_inet_get_port(remote_addr), ink_inet_get_port(local_addr) + ats_ip_port_host_order(remote_addr), ats_ip_port_host_order(local_addr) ); return true; SoftError: Debug("udpnet", "creating a udp socket port = %d---soft failure", - ink_inet_get_port(local_addr) + ats_ip_port_host_order(local_addr) ); if (fd != -1) socketManager.close(fd); @@ -591,7 +591,7 @@ UDPNetProcessor::CreateUDPSocket( return false; HardError: Debug("udpnet", "creating a udp socket port = %d---hard failure", - ink_inet_get_port(local_addr) + ats_ip_port_host_order(local_addr) ); if (fd != -1) socketManager.close(fd); @@ -603,7 +603,7 @@ UDPNetProcessor::CreateUDPSocket( void UDPNetProcessor::UDPClassifyConnection( Continuation * udpConn, - InkInetAddr const& destIP + IpAddr const& destIP ) { int i; UDPConnectionInternal *p = static_cast(udpConn); @@ -619,7 +619,7 @@ UDPNetProcessor::UDPClassifyConnection( p->pipe_class = i; // no match; set it to the null class if (p->pipe_class == -1) { - InkInetAddr null; // default constructed -> invalid value. + IpAddr null; // default constructed -> invalid value. for (i = 0; i < G_inkPipeInfo.numPipes + 1; ++i) if (G_inkPipeInfo.perPipeInfo[i].destIP == null) { p->pipe_class = i; @@ -639,7 +639,7 @@ UDPNetProcessor::UDPBind(Continuation * cont, sockaddr const* addr, int send_buf int res = 0; int fd = -1; UnixUDPConnection *n = NULL; - ts_ip_endpoint myaddr; + IpEndpoint myaddr; int myaddr_len = sizeof(myaddr); if ((res = socketManager.socket(addr->sa_family, SOCK_DGRAM, 0)) < 0) @@ -649,7 +649,7 @@ UDPNetProcessor::UDPBind(Continuation * cont, sockaddr const* addr, int send_buf goto Lerror; // If this is a class D address (i.e. multicast address), use REUSEADDR. - if (ink_inet_is_multicast(addr)) { + if (ats_is_ip_multicast(addr)) { int enable_reuseaddr = 1; if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &enable_reuseaddr, sizeof(enable_reuseaddr)) < 0)) { @@ -657,7 +657,7 @@ UDPNetProcessor::UDPBind(Continuation * cont, sockaddr const* addr, int send_buf } } - if ((res = socketManager.ink_bind(fd, addr, ink_inet_ip_size(addr))) < 0) { + if ((res = socketManager.ink_bind(fd, addr, ats_ip_size(addr))) < 0) { goto Lerror; } @@ -1260,8 +1260,8 @@ UDPWorkContinuation::init(Continuation * c, int num_pairs, cont = c; action = c; numPairs = num_pairs; - ink_inet_copy(&local_ip, local_addr); - ink_inet_copy(&remote_ip, remote_addr); + ats_ip_copy(&local_ip, local_addr); + ats_ip_copy(&remote_ip, remote_addr); sendbufsize = s_bufsize; recvbufsize = r_bufsize; udpConns = NULL; @@ -1276,8 +1276,8 @@ UDPWorkContinuation::StateCreatePortPairs(int event, void *data) // int res = 0; int numUdpPorts = 2 * numPairs; int fd1 = -1, fd2 = -1; - ts_ip_endpoint target; - ts_ip_endpoint myaddr1, myaddr2; + IpEndpoint target; + IpEndpoint myaddr1, myaddr2; int portNum, i; // int myaddr_len = sizeof(myaddr1); static int lastAllocPort = 10000; @@ -1297,7 +1297,7 @@ UDPWorkContinuation::StateCreatePortPairs(int event, void *data) } startTime = ink_get_hrtime_internal(); - ink_inet_copy(&target, &remote_ip); + ats_ip_copy(&target, &remote_ip); udpConns = NEW(new UnixUDPConnection *[numUdpPorts]); for (i = 0; i < numUdpPorts; i++) @@ -1312,13 +1312,13 @@ UDPWorkContinuation::StateCreatePortPairs(int event, void *data) int myaddr1_len = sizeof(myaddr1); int myaddr2_len = sizeof(myaddr2); - ink_inet_port_cast(&target) = htons(portNum); + ats_ip_port_cast(&target) = htons(portNum); if (udpNet.CreateUDPSocket(&fd1, &target.sa, &myaddr1.sa, &myaddr1_len, &status, sendbufsize, recvbufsize)) { - ink_inet_port_cast(&target) = htons(portNum + 1); + ats_ip_port_cast(&target) = htons(portNum + 1); if (udpNet.CreateUDPSocket(&fd2, &target.sa, &myaddr2.sa, @@ -1357,7 +1357,7 @@ UDPWorkContinuation::StateCreatePortPairs(int event, void *data) } for (i = 0; i < numUdpPorts; i++) { - udpNet.UDPClassifyConnection(udpConns[i], InkInetAddr(target)); + udpNet.UDPClassifyConnection(udpConns[i], IpAddr(target)); Debug("udpnet-pipe", "Adding (port = %d) to Pipe class: %d", udpConns[i]->getPortNum(), udpConns[i]->pipe_class); } diff --git a/iocore/utils/I_Machine.h b/iocore/utils/I_Machine.h index 91cfa853d43..dc9385035f3 100644 --- a/iocore/utils/I_Machine.h +++ b/iocore/utils/I_Machine.h @@ -52,9 +52,9 @@ struct Machine { char *hostname; // name of the internet host int hostname_len; // size of the string pointed to by hostname - ts_ip_endpoint ip; ///< Prefered IP address of the host (network order) - ts_ip_endpoint ip4; ///< IPv4 address if present. - ts_ip_endpoint ip6; ///< IPv6 address if present. + IpEndpoint ip; ///< Prefered IP address of the host (network order) + IpEndpoint ip4; ///< IPv4 address if present. + IpEndpoint ip6; ///< IPv6 address if present. ip_text_buffer ip_string; // IP address of the host as a string. int ip_string_len; diff --git a/iocore/utils/Machine.cc b/iocore/utils/Machine.cc index c13506bf9ee..64ab53cd82b 100644 --- a/iocore/utils/Machine.cc +++ b/iocore/utils/Machine.cc @@ -61,7 +61,7 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr) localhost[sizeof(localhost)-1] = 0; // ensure termination. - if (!ink_inet_is_ip(addr)) { + if (!ats_is_ip(addr)) { if (!the_hostname) { ink_release_assert(!gethostname(localhost, sizeof(localhost)-1)); the_hostname = localhost; @@ -118,22 +118,22 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr) ifip = &spot->ifr_addr; # endif - if (!ink_inet_is_ip(ifip)) spot_type = NA; - else if (ink_inet_is_loopback(ifip)) spot_type = LO; - else if (ink_inet_is_nonroutable(ifip)) spot_type = NR; - else if (ink_inet_is_multicast(ifip)) spot_type = MC; + if (!ats_is_ip(ifip)) spot_type = NA; + else if (ats_is_ip_loopback(ifip)) spot_type = LO; + else if (ats_is_ip_nonroutable(ifip)) spot_type = NR; + else if (ats_is_ip_multicast(ifip)) spot_type = MC; else spot_type = GA; if (spot_type == NA) continue; // Next! - if (ink_inet_is_ip4(ifip)) { + if (ats_is_ip4(ifip)) { if (spot_type > ip4_type) { - ink_inet_copy(&ip4, ifip); + ats_ip_copy(&ip4, ifip); ip4_type = spot_type; } - } else if (ink_inet_is_ip6(ifip)) { + } else if (ats_is_ip6(ifip)) { if (spot_type > ip6_type) { - ink_inet_copy(&ip6, ifip); + ats_ip_copy(&ip6, ifip); ip6_type = spot_type; } } @@ -145,17 +145,17 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr) // What about the general address? Prefer IPv4? if (ip4_type >= ip6_type) - ink_inet_copy(&ip.sa, &ip4.sa); + ats_ip_copy(&ip.sa, &ip4.sa); else - ink_inet_copy(&ip.sa, &ip6.sa); + ats_ip_copy(&ip.sa, &ip6.sa); } } else { // address provided. - ink_inet_copy(&ip, addr); - if (ink_inet_is_ip4(addr)) ink_inet_copy(&ip4, addr); - else if (ink_inet_is_ip6(addr)) ink_inet_copy(&ip6, addr); + ats_ip_copy(&ip, addr); + if (ats_is_ip4(addr)) ats_ip_copy(&ip4, addr); + else if (ats_is_ip6(addr)) ats_ip_copy(&ip6, addr); status = getnameinfo( - addr, ink_inet_ip_size(addr), + addr, ats_ip_size(addr), localhost, sizeof(localhost) - 1, 0, 0, // do not request service info 0 // no flags. @@ -164,7 +164,7 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr) if (0 != status) { ip_text_buffer ipbuff; Warning("Failed to find hostname for address '%s' - %s" - , ink_inet_ntop(addr, ipbuff, sizeof(ipbuff)) + , ats_ip_ntop(addr, ipbuff, sizeof(ipbuff)) , gai_strerror(status) ); } else @@ -173,9 +173,9 @@ Machine::Machine(char const* the_hostname, sockaddr const* addr) hostname_len = hostname ? strlen(hostname) : 0; - ink_inet_ntop(&ip.sa, ip_string, sizeof(ip_string)); + ats_ip_ntop(&ip.sa, ip_string, sizeof(ip_string)); ip_string_len = strlen(ip_string); - ip_hex_string_len = ink_inet_to_hex(&ip.sa, ip_hex_string, sizeof(ip_hex_string)); + ip_hex_string_len = ats_ip_to_hex(&ip.sa, ip_hex_string, sizeof(ip_hex_string)); } Machine::~Machine() diff --git a/lib/records/I_RecHttp.h b/lib/records/I_RecHttp.h index 18ea20bd0ae..41da2195a25 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 @@ struct HttpProxyPort { /// 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 @@ struct HttpProxyPort { @return The IP address for @a family */ - InkInetAddr& outboundIp( + IpAddr& outboundIp( uint16_t family ///< IP address family. ); @@ -260,9 +260,9 @@ struct HttpProxyPort { 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."); diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc index 6bbd6ede4b7..628d4fbefb7 100644 --- a/lib/records/RecHttp.cc +++ b/lib/records/RecHttp.cc @@ -27,7 +27,7 @@ # include # include -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) { diff --git a/lib/ts/IpMap.cc b/lib/ts/IpMap.cc index e1ec0c408dc..1c9ccc5b34e 100644 --- a/lib/ts/IpMap.cc +++ b/lib/ts/IpMap.cc @@ -910,16 +910,16 @@ class Ip4Node : public IpMap::Node, protected Ip4Span { 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 @@ class Ip6Node : public IpMap::Node, protected Ip6Span { } /// @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 @@ class Ip6Node : public IpMap::Node, protected Ip6Span { 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 @@ class Ip6Node : public IpMap::Node, protected Ip6Span { 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; } diff --git a/lib/ts/IpMap.h b/lib/ts/IpMap.h index 24f4201be52..9357512f4b5 100644 --- a/lib/ts/IpMap.h +++ b/lib/ts/IpMap.h @@ -367,8 +367,8 @@ class IpMap { @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 @@ class IpMap { @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 @@ class IpMap { ); /// 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 @@ class IpMap { ) 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); } diff --git a/lib/ts/IpMapConf.cc b/lib/ts/IpMapConf.cc index da98d2d495b..9baf1813404 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]; diff --git a/lib/ts/IpMapTest.cc b/lib/ts/IpMapTest.cc index c5ba8ce79c0..7a8d3853fb8 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(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); diff --git a/lib/ts/MatcherUtils.cc b/lib/ts/MatcherUtils.cc index cec5f2295d8..1cab19110ed 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; } diff --git a/lib/ts/MatcherUtils.h b/lib/ts/MatcherUtils.h index 3bc5385069f..94fd2b7b7b1 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); diff --git a/lib/ts/ink_inet.cc b/lib/ts/ink_inet.cc index a42eb220826..8a67fdbca57 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(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(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; } diff --git a/lib/ts/ink_inet.h b/lib/ts/ink_inet.h index 759594b2c82..6998c389a09 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). ); @@ -116,16 +116,6 @@ struct ink_gethostbyaddr_r_data char buf[INK_GETHOSTBYADDR_R_DATA_SIZE]; }; -/** - 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 @@ -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(static_cast(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(static_cast(a)); } -inline sockaddr* ink_inet_sa_cast(sockaddr_in* a) { +inline sockaddr* ats_ip_sa_cast(sockaddr_in* a) { return static_cast(static_cast(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(static_cast(a)); } -inline sockaddr* ink_inet_sa_cast(sockaddr_in6* a) { +inline sockaddr* ats_ip_sa_cast(sockaddr_in6* a) { return static_cast(static_cast(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(static_cast(a)); } -inline sockaddr_storage* ink_inet_ss_cast(sockaddr* a) { +inline sockaddr_storage* ats_ip_ss_cast(sockaddr* a) { return static_cast(static_cast(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(static_cast(a)); } -inline sockaddr_in* ink_inet_ip4_cast(sockaddr* a) { +inline sockaddr_in* ats_ip4_cast(sockaddr* a) { return static_cast(static_cast(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(static_cast(a)); } -inline sockaddr_in& ink_inet_ip4_cast(sockaddr& a) { +inline sockaddr_in& ats_ip4_cast(sockaddr& a) { return *static_cast(static_cast(&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(static_cast(&a)); } -inline sockaddr_in* ink_inet_ip4_cast(sockaddr_in6* a) { +inline sockaddr_in* ats_ip4_cast(sockaddr_in6* a) { return static_cast(static_cast(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(static_cast(a)); } -inline sockaddr_in& ink_inet_ip4_cast(sockaddr_in6& a) { +inline sockaddr_in& ats_ip4_cast(sockaddr_in6& a) { return *static_cast(static_cast(&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(static_cast(&a)); } -inline sockaddr_in6* ink_inet_ip6_cast(sockaddr* a) { +inline sockaddr_in6* ats_ip6_cast(sockaddr* a) { return static_cast(static_cast(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(static_cast(a)); } -inline sockaddr_in6& ink_inet_ip6_cast(sockaddr& a) { +inline sockaddr_in6& ats_ip6_cast(sockaddr& a) { return *static_cast(static_cast(&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(static_cast(&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(sa)); +inline uint16_t const& ats_ip_port_cast(sockaddr const* sa) { + return ats_ip_port_cast(const_cast(sa)); } -inline uint16_t const& ink_inet_port_cast(ts_ip_endpoint const* ip) { - return ink_inet_port_cast(const_cast(&ip->sa)); +inline uint16_t const& ats_ip_port_cast(IpEndpoint const* ip) { + return ats_ip_port_cast(const_cast(&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(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(&ink_inet_ip4_addr_cast(addr)); break; - case AF_INET6: zret = reinterpret_cast(&ink_inet_ip6_addr_cast(addr)); break; + case AF_INET: zret = reinterpret_cast(&ats_ip4_addr_cast(addr)); break; + case AF_INET6: zret = reinterpret_cast(&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(addr)); +inline uint32_t const* ats_ip_addr32_cast(sockaddr const* addr) { + return ats_ip_addr32_cast(const_cast(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(&ink_inet_ip4_addr_cast(addr)); break; - case AF_INET6: zret = reinterpret_cast(&ink_inet_ip6_addr_cast(addr)); break; + case AF_INET: zret = reinterpret_cast(&ats_ip4_addr_cast(addr)); break; + case AF_INET6: zret = reinterpret_cast(&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(addr)); +inline uint8_t const* ats_ip_addr8_cast(sockaddr const* addr) { + return ats_ip_addr8_cast(const_cast(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(addr))); + return ntohs(ats_ip_port_cast(const_cast(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(&ip->sa))); + return ntohs(ats_ip_port_cast(const_cast(&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(addr))); + return ntohl(ats_ip4_addr_cast(const_cast(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; } diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc index e4ee6ee030a..498c5e9cc66 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 )) diff --git a/lib/ts/ink_resolver.h b/lib/ts/ink_resolver.h index 2a23fa2de21..3ebcd9f2c46 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, diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc index efce1cbc1b9..f39fa71f70c 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); } diff --git a/mgmt/LocalManager.h b/mgmt/LocalManager.h index 74edfeb2bc7..e8083360267 100644 --- a/mgmt/LocalManager.h +++ b/mgmt/LocalManager.h @@ -120,8 +120,8 @@ class LocalManager: public BaseManager 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; diff --git a/mgmt/utils/MgmtUtils.cc b/mgmt/utils/MgmtUtils.cc index 21c987f87f8..8c85e3b6474 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) diff --git a/mgmt/utils/MgmtUtils.h b/mgmt/utils/MgmtUtils.h index c5629e2b018..400d31324a1 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 diff --git a/proxy/ControlBase.cc b/proxy/ControlBase.cc index 27c7e84eadb..d74768d7ac6 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* diff --git a/proxy/ControlMatcher.cc b/proxy/ControlMatcher.cc index 0d68911e9f0..db0329e5ad1 100644 --- a/proxy/ControlMatcher.cc +++ b/proxy/ControlMatcher.cc @@ -483,7 +483,7 @@ template char *IpMatcher::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 void IpMatcher::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(spot->data())->Print(); } diff --git a/proxy/ControlMatcher.h b/proxy/ControlMatcher.h index c6a25623aea..1200f89f14b 100644 --- a/proxy/ControlMatcher.h +++ b/proxy/ControlMatcher.h @@ -153,8 +153,8 @@ class HttpRequestData:public RequestData 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; }; diff --git a/proxy/CoreUtils.cc b/proxy/CoreUtils.cc index 46637584be3..9c0abca7716 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); diff --git a/proxy/FetchSM.cc b/proxy/FetchSM.cc index 821ae09927e..9caf516f4ed 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; diff --git a/proxy/ICP.cc b/proxy/ICP.cc index 56e35c57e80..4a92ed61baa 100644 --- a/proxy/ICP.cc +++ b/proxy/ICP.cc @@ -405,7 +405,7 @@ ICPPeerReadCont::StaleCheck(int event, Event * e) Debug("icp-stale", "Stale check res=%d for id=%d, [%s] from [%s]", event, _state->_rICPmsg->h.requestno, - _state->_rICPmsg->un.query.URL, ink_inet_nptop(&_state->_sender, ipb, sizeof(ipb))); + _state->_rICPmsg->un.query.URL, ats_ip_nptop(&_state->_sender, ipb, sizeof(ipb))); switch (event) { case ICP_STALE_OBJECT: @@ -438,7 +438,7 @@ ICPPeerReadCont::ICPPeerQueryEvent(int event, Event * e) NOWARN_UNUSED(e); Debug("icp", "Remote Query lookup res=%d for id=%d, [%s] from [%s]", event, _state->_rICPmsg->h.requestno, - _state->_rICPmsg->un.query.URL, ink_inet_nptop(&_state->_sender, ipb, sizeof(ipb))); + _state->_rICPmsg->un.query.URL, ats_ip_nptop(&_state->_sender, ipb, sizeof(ipb))); if (pluginFreshnessCalcFunc) { switch (event) { case CACHE_EVENT_OPEN_READ: @@ -482,7 +482,7 @@ ICPPeerReadCont::ICPPeerQueryCont(int event, Event * e) Debug("icp", "Remote Query for id=%d, [%s] from [%s]", _state->_rICPmsg->h.requestno, _state->_rICPmsg->un.query.URL, - ink_inet_nptop(&_state->_sender, ipb, sizeof(ipb)) + ats_ip_nptop(&_state->_sender, ipb, sizeof(ipb)) ); SET_HANDLER((ICPPeerReadContHandler) & ICPPeerReadCont::ICPPeerQueryEvent); @@ -693,7 +693,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) } // Validate receiver and convert the received sockaddr // to internal sockaddr format. - ts_ip_endpoint from; + IpEndpoint from; if (!s->_peer->ExtToIntRecvSockAddr(&s->_peer->fromaddr.sa, &from.sa)) { int status; ICPConfigData *cfg = _ICPpr->GetConfig()->globalConfig(); @@ -722,11 +722,11 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) int icp_reply_port = cfg->ICPDefaultReplyPort(); if (!icp_reply_port) { - icp_reply_port = ntohs(ink_inet_port_cast(&s->_peer->fromaddr)); + icp_reply_port = ntohs(ats_ip_port_cast(&s->_peer->fromaddr)); } PeerConfigData *Pcfg = NEW(new PeerConfigData( PeerConfigData::CTYPE_SIBLING, - InkInetAddr(s->_peer->fromaddr), + IpAddr(s->_peer->fromaddr), 0, icp_reply_port )); @@ -739,7 +739,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) P->GetChan()->setRemote(P->GetIP()); // coverity[uninit_use_in_call] - Note("ICP Peer added ip=%s", ink_inet_nptop(P->GetIP(), ipb, sizeof(ipb))); + Note("ICP Peer added ip=%s", ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb))); from = s->_peer->fromaddr; } else { invalid_message: @@ -748,7 +748,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) // ICP_INCREMENT_DYN_STAT(invalid_sender_stat); Debug("icp", "Received msg from invalid sender [%s]", - ink_inet_nptop(&s->_peer->fromaddr, ipb, sizeof(ipb))); + ats_ip_nptop(&s->_peer->fromaddr, ipb, sizeof(ipb))); s->_peer->buf = NULL; s->_next_state = READ_NOT_ACTIVE; @@ -771,7 +771,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) && (s->_rICPmsg->h.version != ICP_VERSION_3)) { ICP_INCREMENT_DYN_STAT(read_not_v2_icp_stat); Debug("icp", "Received (v=%d) !v2 && !v3 msg from sender [%s]", - (uint32_t) s->_rICPmsg->h.version, ink_inet_nptop(&from, ipb, sizeof(ipb))); + (uint32_t) s->_rICPmsg->h.version, ats_ip_nptop(&from, ipb, sizeof(ipb))); s->_rICPmsg = NULL; s->_buf = NULL; @@ -797,7 +797,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) } else { // We have a response message for an ICP query. Debug("icp", "Response for Id=%d, from [%s]", - s->_rICPmsg->h.requestno, ink_inet_nptop(&s->_sender, ipb, sizeof(ipb))); + s->_rICPmsg->h.requestno, ats_ip_nptop(&s->_sender, ipb, sizeof(ipb))); ICP_INCREMENT_DYN_STAT(icp_remote_responses_stat); s->_next_state = GET_ICP_REQUEST; RECORD_ICP_STATE_CHANGE(s, 0, GET_ICP_REQUEST); @@ -818,7 +818,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) if (s->_queryResult == CACHE_EVENT_LOOKUP) { // Use the received ICP data buffer for the response message Debug("icp", "Sending ICP_OP_HIT for id=%d, [%.*s] to [%s]", - s->_rICPmsg->h.requestno, datalen, (const char *)data, ink_inet_nptop(&s->_sender, ipb, sizeof(ipb))); + s->_rICPmsg->h.requestno, datalen, (const char *)data, ats_ip_nptop(&s->_sender, ipb, sizeof(ipb))); ICP_INCREMENT_DYN_STAT(icp_cache_lookup_success_stat); status = ICPRequestCont::BuildICPMsg(ICP_OP_HIT, s->_rICPmsg->h.requestno, 0 /* optflags */ , 0 /* optdata */ , @@ -827,7 +827,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) } else if (s->_queryResult == CACHE_EVENT_LOOKUP_FAILED) { // Use the received ICP data buffer for response message Debug("icp", "Sending ICP_OP_MISS for id=%d, [%.*s] to [%s]", - s->_rICPmsg->h.requestno, datalen, (const char *)data, ink_inet_nptop(&s->_sender, ipb, sizeof(ipb))); + s->_rICPmsg->h.requestno, datalen, (const char *)data, ats_ip_nptop(&s->_sender, ipb, sizeof(ipb))); ICP_INCREMENT_DYN_STAT(icp_cache_lookup_fail_stat); status = ICPRequestCont::BuildICPMsg(ICP_OP_MISS, s->_rICPmsg->h.requestno, 0 /* optflags */ , 0 /* optdata */ , @@ -882,7 +882,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) ICP_INCREMENT_DYN_STAT(query_response_partial_write_stat); // coverity[uninit_use_in_call] Debug("icp_warn", "ICP response send, sent=%d res=%d, ip=%s", - ntohs(s->_rICPmsg->h.msglen), -1, ink_inet_ntop(&s->_sender, ipb, sizeof(ipb))); + ntohs(s->_rICPmsg->h.msglen), -1, ats_ip_ntop(&s->_sender, ipb, sizeof(ipb))); s->_next_state = READ_NOT_ACTIVE; RECORD_ICP_STATE_CHANGE(s, 0, READ_NOT_ACTIVE); break; @@ -909,7 +909,7 @@ ICPPeerReadCont::PeerReadStateMachine(PeerReadData * s, Event * e) ICP_INCREMENT_DYN_STAT(query_response_partial_write_stat); // coverity[uninit_use_in_call] Debug("icp_warn", "ICP response send, sent=%d res=%d, ip=%s", - ntohs(s->_rICPmsg->h.msglen), len, ink_inet_ntop(&s->_sender, ipb, sizeof(ipb))); + ntohs(s->_rICPmsg->h.msglen), len, ats_ip_ntop(&s->_sender, ipb, sizeof(ipb))); } // Processing complete, perform completion actions s->_next_state = READ_NOT_ACTIVE; @@ -1338,7 +1338,7 @@ ICPRequestCont::ICPStateMachine(int event, void *d) } P->LogSendMsg(&_ICPmsg, NULL); // log as send query Debug("icp", "[ICP_QUEUE_REQUEST] Id=%d send query to [%s]", - _sequence_number, ink_inet_nptop(P->GetIP(), ipb, sizeof(ipb))); + _sequence_number, ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb))); } else { _expected_replies_list.ClearBit(P->GetPeerID()); _expected_replies -= was_expected; @@ -1347,7 +1347,7 @@ ICPRequestCont::ICPStateMachine(int event, void *d) // coverity[uninit_use_in_call] Debug("icp_warn", "ICP query send, res=%d, ip=%s", ntohs(_ICPmsg.h.msglen), - ink_inet_ntop(P->GetIP(), ipb, sizeof(ipb))); + ats_ip_ntop(P->GetIP(), ipb, sizeof(ipb))); } SendPeers--; } @@ -1511,15 +1511,15 @@ ICPRequestCont::ICPResponseMessage(int event, ICPMsg_t * m, int ICPMsg_len, Peer pp = _ICPpr->GetNthParentPeer(0, _ICPpr->GetStartingParentPeerBias()); if (pp && !_expected_replies_list.IsBitSet(pp->GetPeerID()) && pp->isUp()) { - ink_inet_copy(&_ret_sockaddr.sa, pp->GetIP()); + ats_ip_copy(&_ret_sockaddr.sa, pp->GetIP()); _ret_sockaddr.port() = htons(static_cast(pp)->GetProxyPort()); _ret_status = ICP_LOOKUP_FOUND; Debug("icp", "ICP timeout using parent Id=%d from [%s] return [%s]", _sequence_number, - ink_inet_nptop(pp->GetIP(), ipb, sizeof(ipb)), - ink_inet_nptop(&_ret_sockaddr, ipb2, sizeof(ipb2)) + ats_ip_nptop(pp->GetIP(), ipb, sizeof(ipb)), + ats_ip_nptop(&_ret_sockaddr, ipb2, sizeof(ipb2)) ); return EVENT_DONE; } @@ -1546,15 +1546,15 @@ ICPRequestCont::ICPResponseMessage(int event, ICPMsg_t * m, int ICPMsg_len, Peer ICP_INCREMENT_DYN_STAT(icp_query_hits_stat); ++_received_replies; - ink_inet_copy(&_ret_sockaddr, peer->GetIP()); + ats_ip_copy(&_ret_sockaddr, peer->GetIP()); _ret_sockaddr.port() = htons(static_cast(peer)->GetProxyPort()); _ret_status = ICP_LOOKUP_FOUND; Debug("icp", "ICP Response HIT for Id=%d from [%s] return [%s]", _sequence_number, - ink_inet_nptop(peer->GetIP(), ipb, sizeof(ipb)), - ink_inet_nptop(&_ret_sockaddr, ipb2, sizeof(ipb2)) + ats_ip_nptop(peer->GetIP(), ipb, sizeof(ipb)), + ats_ip_nptop(&_ret_sockaddr, ipb2, sizeof(ipb2)) ); return EVENT_DONE; } @@ -1564,7 +1564,7 @@ ICPRequestCont::ICPResponseMessage(int event, ICPMsg_t * m, int ICPMsg_len, Peer case ICP_OP_DENIED: { Debug("icp", "ICP MISS response for Id=%d from [%s]", - _sequence_number, ink_inet_nptop(peer->GetIP(), ipb, sizeof(ipb))); + _sequence_number, ats_ip_nptop(peer->GetIP(), ipb, sizeof(ipb))); // "received_replies" is only for Peers who we expect a reply // from (Peers which are in the expected_replies_list). int Id = peer->GetPeerID(); @@ -1606,17 +1606,17 @@ ICPRequestCont::ICPResponseMessage(int event, ICPMsg_t * m, int ICPMsg_len, Peer } } if (p) { - ink_inet_copy(&_ret_sockaddr, p->GetIP()); + ats_ip_copy(&_ret_sockaddr, p->GetIP()); _ret_sockaddr.port() = htons(static_cast(p)->GetProxyPort()); _ret_status = ICP_LOOKUP_FOUND; Debug("icp", "ICP ALL MISS(1) for Id=%d return [%s]", - _sequence_number, ink_inet_nptop(&_ret_sockaddr, ipb, sizeof(ipb))); + _sequence_number, ats_ip_nptop(&_ret_sockaddr, ipb, sizeof(ipb))); return EVENT_DONE; } } Debug("icp", "ICP ALL MISS(2) for Id=%d return [%s]", - _sequence_number, ink_inet_nptop(&_ret_sockaddr, ipb, sizeof(ipb))); + _sequence_number, ats_ip_nptop(&_ret_sockaddr, ipb, sizeof(ipb))); return EVENT_DONE; } default: @@ -1624,7 +1624,7 @@ ICPRequestCont::ICPResponseMessage(int event, ICPMsg_t * m, int ICPMsg_len, Peer ICP_INCREMENT_DYN_STAT(invalid_icp_query_response_stat); // coverity[uninit_use_in_call] Warning("Invalid ICP response, op=%d reqno=%d ip=%s", - m->h.opcode, m->h.requestno, ink_inet_ntop(peer->GetIP(), ipb, sizeof(ipb))); + m->h.opcode, m->h.requestno, ats_ip_ntop(peer->GetIP(), ipb, sizeof(ipb))); return EVENT_CONT; // wait for more responses } @@ -2030,7 +2030,7 @@ ICPProcessor::BuildPeerList() Pcfg->_ctype = PeerConfigData::CTYPE_LOCAL; // Get IP address for given interface - ts_ip_endpoint tmp_ip; + IpEndpoint tmp_ip; if (!mgmt_getAddrForIntr(GetConfig()->globalConfig()->ICPinterface(), &tmp_ip.sa)) { Pcfg->_ip_addr._family = AF_UNSPEC; // No IP address for given interface @@ -2214,8 +2214,8 @@ ICPProcessor::SetupListenSockets() // coverity[uninit_use_in_call] Warning("ICP MC send setup failed, res=%d, ip=%s bind_ip=%s", status, - ink_inet_nptop(pMC->GetIP(), ipb, sizeof(ipb)), - ink_inet_nptop(_LocalPeer->GetIP(), ipb2, sizeof(ipb2)) + ats_ip_nptop(pMC->GetIP(), ipb, sizeof(ipb)), + ats_ip_nptop(_LocalPeer->GetIP(), ipb2, sizeof(ipb2)) ); REC_SignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP MC send setup failed"); return 1; // Failed @@ -2226,7 +2226,7 @@ ICPProcessor::SetupListenSockets() if (status) { // coverity[uninit_use_in_call] Warning("ICP MC recv setup failed, res=%d, ip=%s", - status, ink_inet_nptop(pMC->GetIP(), ipb, sizeof(ipb))); + status, ats_ip_nptop(pMC->GetIP(), ipb, sizeof(ipb))); REC_SignalWarning(REC_SIGNAL_CONFIG_ERROR, "ICP MC recv setup failed"); return 1; // Failed } @@ -2406,14 +2406,14 @@ ICPProcessor::CancelPendingReads() } Peer * -ICPProcessor::GenericFindListPeer(InkInetAddr const& ip, uint16_t port, int validListItems, Ptr *List) +ICPProcessor::GenericFindListPeer(IpAddr const& ip, uint16_t port, int validListItems, Ptr *List) { Peer *P; port = htons(port); for (int n = 0; n < validListItems; ++n) { if ((P = List[n])) { if ((P->GetIP() == ip) - && ((port == 0) || (ink_inet_port_cast(P->GetIP()) == port))) + && ((port == 0) || (ats_ip_port_cast(P->GetIP()) == port))) return P; } } @@ -2421,14 +2421,14 @@ ICPProcessor::GenericFindListPeer(InkInetAddr const& ip, uint16_t port, int vali } Peer * -ICPProcessor::FindPeer(InkInetAddr const& ip, uint16_t port) +ICPProcessor::FindPeer(IpAddr const& ip, uint16_t port) { // Find (Peer *) with the given (ip,port) on the global list (PeerList) return GenericFindListPeer(ip, port, (_nPeerList + 1), _PeerList); } Peer * -ICPProcessor::FindSendListPeer(InkInetAddr const& ip, uint16_t port) +ICPProcessor::FindSendListPeer(IpAddr const& ip, uint16_t port) { // Find (Peer *) with the given (ip,port) on the // scheduler list (SendPeerList) @@ -2436,7 +2436,7 @@ ICPProcessor::FindSendListPeer(InkInetAddr const& ip, uint16_t port) } Peer * -ICPProcessor::FindRecvListPeer(InkInetAddr const& ip, uint16_t port) +ICPProcessor::FindRecvListPeer(IpAddr const& ip, uint16_t port) { // Find (Peer *) with the given (ip,port) on the // receive list (RecvPeerList) @@ -2456,7 +2456,7 @@ ICPProcessor::AddPeer(Peer * P) if (FindPeer(P->GetIP())) { ip_port_text_buffer x; // coverity[uninit_use_in_call] - Warning("bad icp.config, multiple peer definitions for ip=%s", ink_inet_nptop(P->GetIP(), x, sizeof(x))); + Warning("bad icp.config, multiple peer definitions for ip=%s", ats_ip_nptop(P->GetIP(), x, sizeof(x))); REC_SignalWarning(REC_SIGNAL_CONFIG_ERROR, "bad icp.config, multiple peer definitions"); return 0; // Not added @@ -2481,7 +2481,7 @@ ICPProcessor::AddPeerToRecvList(Peer * P) // Returns 1 - added; 0 - Not added // Assert that no duplicate exists - ink_assert(FindRecvListPeer(InkInetAddr(P->GetIP()), ink_inet_get_port(P->GetIP())) == 0); + ink_assert(FindRecvListPeer(IpAddr(P->GetIP()), ats_ip_port_host_order(P->GetIP())) == 0); if (_nRecvPeerList + 1 < RECV_PEER_LIST_SIZE) { _nRecvPeerList++; @@ -2500,7 +2500,7 @@ ICPProcessor::AddPeerToSendList(Peer * P) // Returns 1 - added; 0 - Not added // Assert that no duplicate exists - ink_assert(FindSendListPeer(InkInetAddr(P->GetIP()), ink_inet_get_port(P->GetIP())) == 0); + ink_assert(FindSendListPeer(IpAddr(P->GetIP()), ats_ip_port_host_order(P->GetIP())) == 0); if (_nSendPeerList + 1 < SEND_PEER_LIST_SIZE) { _nSendPeerList++; diff --git a/proxy/ICP.h b/proxy/ICP.h index d7ecba00d89..492dfb70cd9 100644 --- a/proxy/ICP.h +++ b/proxy/ICP.h @@ -315,7 +315,7 @@ class PeerConfigData public: PeerConfigData(); - PeerConfigData(int ctype, InkInetAddr const& ip_addr, int proxy_port, int icp_port) + PeerConfigData(int ctype, IpAddr const& ip_addr, int proxy_port, int icp_port) : _ctype(ctype), _ip_addr(ip_addr), _proxy_port(proxy_port), _icp_port(icp_port), _mc_member(0), _mc_ttl(0), _my_ip_addr(ip_addr) @@ -334,7 +334,7 @@ class PeerConfigData { return _ctype; } - inline InkInetAddr const& GetIPAddr() + inline IpAddr const& GetIPAddr() { return _my_ip_addr; } @@ -350,7 +350,7 @@ class PeerConfigData { return _mc_member; } - inline InkInetAddr const& GetMultiCastIPAddr() + inline IpAddr const& GetMultiCastIPAddr() { return _mc_ip_addr; } @@ -361,7 +361,7 @@ class PeerConfigData // Static member functions static PeerType_t CTypeToPeerType_t(int); - static int GetHostIPByName(char *, InkInetAddr&); + static int GetHostIPByName(char *, IpAddr&); enum { HOSTNAME_SIZE = 256 }; @@ -378,20 +378,20 @@ class PeerConfigData //--------------------------------------------------------- char _hostname[HOSTNAME_SIZE]; int _ctype; - InkInetAddr _ip_addr; + IpAddr _ip_addr; int _proxy_port; int _icp_port; //------------------- // MultiCast data //------------------- int _mc_member; - InkInetAddr _mc_ip_addr; + IpAddr _mc_ip_addr; int _mc_ttl; //---------------------------------------------- // Computed data not subject to "==" test //---------------------------------------------- - InkInetAddr _my_ip_addr; + IpAddr _my_ip_addr; }; //--------------------------------------------------------------- @@ -568,7 +568,7 @@ class Peer:public RefCountObj // these shouldn't be public // this is for delayed I/O Ptr buf; - ts_ip_endpoint fromaddr; + IpEndpoint fromaddr; socklen_t fromaddrlen; int notFirstRead; // priming the reads Action *readAction; // outstanding read @@ -646,7 +646,7 @@ class ParentSiblingPeer:public Peer private: // Class data declarations PeerConfigData * _pconfig; // associated config data - ts_ip_endpoint _ip; ///< Cache for GetIP(). + IpEndpoint _ip; ///< Cache for GetIP(). Connection _chan; }; @@ -656,7 +656,7 @@ class ParentSiblingPeer:public Peer class MultiCastPeer:public Peer { public: - MultiCastPeer(InkInetAddr const&, uint16_t, int, ICPProcessor *); + MultiCastPeer(IpAddr const&, uint16_t, int, ICPProcessor *); ~MultiCastPeer() { } @@ -666,7 +666,7 @@ class MultiCastPeer:public Peer If @a port is 0 the port is not checked. */ Peer *FindMultiCastChild( - InkInetAddr const& ip, ///< IP address. + IpAddr const& ip, ///< IP address. uint16_t port = 0 ///< Port (host order). ); @@ -689,10 +689,10 @@ class MultiCastPeer:public Peer } inline virtual int ExtToIntRecvSockAddr(sockaddr const* in, sockaddr* out) { - Peer *P = FindMultiCastChild(InkInetAddr(in)); + Peer *P = FindMultiCastChild(IpAddr(in)); if (P) { - ink_inet_copy(out, in); - ink_inet_port_cast(out) = ink_inet_port_cast(P->GetIP()); + ats_ip_copy(out, in); + ats_ip_port_cast(out) = ats_ip_port_cast(P->GetIP()); return 1; } else { return 0; @@ -706,7 +706,7 @@ class MultiCastPeer:public Peer //--------------------------- // Multicast specific data //--------------------------- - ts_ip_endpoint _mc_ip; + IpEndpoint _mc_ip; int _mc_ttl; struct multicast_data { @@ -767,12 +767,12 @@ class ICPProcessor } ReconfigState_t; ReconfigState_t ReconfigureStateMachine(ReconfigState_t, int, int); - Peer *FindPeer(InkInetAddr const& ip, uint16_t port = 0); - Peer *FindPeer(ts_ip_endpoint const& ip) { - return this->FindPeer(InkInetAddr(&ip), ink_inet_get_port(&ip)); + Peer *FindPeer(IpAddr const& ip, uint16_t port = 0); + Peer *FindPeer(IpEndpoint const& ip) { + return this->FindPeer(IpAddr(&ip), ats_ip_port_host_order(&ip)); } Peer *FindPeer(sockaddr const* ip) { - return this->FindPeer(InkInetAddr(ip), ink_inet_get_port(ip)); + return this->FindPeer(IpAddr(ip), ats_ip_port_host_order(ip)); } inline Peer *GetLocalPeer() @@ -847,9 +847,9 @@ class ICPProcessor _PendingIcpQueries--; } - Peer *GenericFindListPeer(InkInetAddr const&, uint16_t, int, Ptr *); - Peer *FindSendListPeer(InkInetAddr const&, uint16_t); - Peer *FindRecvListPeer(InkInetAddr const&, uint16_t); + Peer *GenericFindListPeer(IpAddr const&, uint16_t, int, Ptr *); + Peer *FindSendListPeer(IpAddr const&, uint16_t); + Peer *FindRecvListPeer(IpAddr const&, uint16_t); int AddPeer(Peer *); int AddPeerToSendList(Peer *); int AddPeerToRecvList(Peer *); @@ -1077,7 +1077,7 @@ class ICPPeerReadCont:public Continuation Ptr _buf; // the buffer with the ICP message in it ICPMsg_t *_rICPmsg; int _rICPmsg_len; - ts_ip_endpoint _sender; // sender of rICPmsg + IpEndpoint _sender; // sender of rICPmsg URL _cachelookupURL; int _queryResult; ICPRequestCont *_ICPReqCont; @@ -1199,7 +1199,7 @@ class ICPRequestCont:public Continuation URL *_url; // Return data - ts_ip_endpoint _ret_sockaddr; + IpEndpoint _ret_sockaddr; ICPreturn_t _ret_status; class Action _act; diff --git a/proxy/ICPConfig.cc b/proxy/ICPConfig.cc index a1082aec619..0d8eb7adf64 100644 --- a/proxy/ICPConfig.cc +++ b/proxy/ICPConfig.cc @@ -302,7 +302,7 @@ PeerType_t PeerConfigData::CTypeToPeerType_t(int ctype) } int -PeerConfigData::GetHostIPByName(char *hostname, InkInetAddr& rip) +PeerConfigData::GetHostIPByName(char *hostname, IpAddr& rip) { // Short circuit NULL hostname case if (0 == hostname || 0 == *hostname) @@ -319,8 +319,8 @@ PeerConfigData::GetHostIPByName(char *hostname, InkInetAddr& rip) for ( addrinfo *spot = ai ; spot ; spot = spot->ai_next) { // If current address is valid, and either we don't have one yet // or this address is less than our current, set it as current. - if (ink_inet_is_ip(spot->ai_addr) && - (!best || -1 == ink_inet_cmp(spot->ai_addr, best)) + if (ats_is_ip(spot->ai_addr) && + (!best || -1 == ats_ip_addr_cmp(spot->ai_addr, best)) ) { best = spot->ai_addr; } @@ -843,7 +843,7 @@ Peer::LogRecvMsg(ICPMsg_t * m, int valid) _state |= PEER_UP; _stats.total_received = _stats.total_sent; // restart timeout count - Debug("icp", "Peer [%s] now back online", ink_inet_nptop(this->GetIP(), ipb, sizeof(ipb))); + Debug("icp", "Peer [%s] now back online", ats_ip_nptop(this->GetIP(), ipb, sizeof(ipb))); } } @@ -854,7 +854,7 @@ Peer::LogRecvMsg(ICPMsg_t * m, int valid) ParentSiblingPeer::ParentSiblingPeer(PeerType_t t, PeerConfigData * p, ICPProcessor * icpPr, bool dynamic_peer) :Peer(t, icpPr, dynamic_peer), _pconfig(p) { - ink_inet_ip_set(&_ip.sa, _pconfig->GetIPAddr(), htons(_pconfig->GetICPPort())); + ats_ip_set(&_ip.sa, _pconfig->GetIPAddr(), htons(_pconfig->GetICPPort())); } int @@ -880,17 +880,17 @@ ParentSiblingPeer::SendMsg_re(Continuation * cont, void *token, struct msghdr * if (to) { // Send to specified host - Peer *p = _ICPpr->FindPeer(InkInetAddr(to), ntohs(ink_inet_port_cast(to))); + Peer *p = _ICPpr->FindPeer(IpAddr(to), ntohs(ats_ip_port_cast(to))); ink_assert(p); msg->msg_name = &p->GetSendChan()->addr; - msg->msg_namelen = ink_inet_ip_size(&p->GetSendChan()->addr); + msg->msg_namelen = ats_ip_size(&p->GetSendChan()->addr); Action *a = udpNet.sendmsg_re(cont, token, lp->GetSendFD(), msg); return a; } else { // Send to default host msg->msg_name = & _chan.addr; - msg->msg_namelen = ink_inet_ip_size(&_chan.addr.sa); + msg->msg_namelen = ats_ip_size(&_chan.addr.sa); Action *a = udpNet.sendmsg_re(cont, token, lp->GetSendFD(), msg); return a; } @@ -928,7 +928,7 @@ ParentSiblingPeer::ExpectedReplies(BitMap * expected_replies_list) if (_state & PEER_UP) { ip_port_text_buffer ipb; _state &= ~PEER_UP; - Debug("icp", "Peer [%s] marked offline", ink_inet_nptop(this->GetIP(), ipb, sizeof(ipb))); + Debug("icp", "Peer [%s] marked offline", ats_ip_nptop(this->GetIP(), ipb, sizeof(ipb))); } // // We will continue to send messages, but will not wait for a reply @@ -962,8 +962,8 @@ ParentSiblingPeer::ValidSender(sockaddr* fr) // Make sure the sockaddr_in corresponds to this peer // Need to update once we have support for comparing address // and port in a socakddr. - if (ink_inet_eq(this->GetIP(), fr) && - (ink_inet_port_cast(this->GetIP()) == ink_inet_port_cast(fr)) + if (ats_ip_addr_eq(this->GetIP(), fr) && + (ats_ip_port_cast(this->GetIP()) == ats_ip_port_cast(fr)) ) { return 1; // Sender is this peer } else { @@ -987,10 +987,10 @@ ParentSiblingPeer::LogSendMsg(ICPMsg_t * m, sockaddr const* sa) int ParentSiblingPeer::ExtToIntRecvSockAddr(sockaddr const* in, sockaddr *out) { - Peer *p = _ICPpr->FindPeer(InkInetAddr(in)); + Peer *p = _ICPpr->FindPeer(IpAddr(in)); if (p && (p->GetType() != PEER_LOCAL)) { // Map from received (ip, port) to defined (ip, port). - ink_inet_copy(out, p->GetIP()); + ats_ip_copy(out, p->GetIP()); return 1; } else { return 0; @@ -1001,10 +1001,10 @@ ParentSiblingPeer::ExtToIntRecvSockAddr(sockaddr const* in, sockaddr *out) // Class MultiCastPeer (derived from Peer) member functions // ICP object describing MultiCast Peers. //----------------------------------------------------------- -MultiCastPeer::MultiCastPeer(InkInetAddr const& addr, uint16_t mc_port, int ttl, ICPProcessor * icpPr) +MultiCastPeer::MultiCastPeer(IpAddr const& addr, uint16_t mc_port, int ttl, ICPProcessor * icpPr) :Peer(PEER_MULTICAST, icpPr), _mc_ttl(ttl) { - ink_inet_ip_set(&_mc_ip.sa, addr, htons(mc_port)); + ats_ip_set(&_mc_ip.sa, addr, htons(mc_port)); memset(&this->_mc, 0, sizeof(this->_mc)); } @@ -1027,7 +1027,7 @@ MultiCastPeer::SendMsg_re(Continuation * cont, void *token, struct msghdr * msg, if (to) { // Send to MultiCast group member (UniCast) - Peer *p = FindMultiCastChild(InkInetAddr(to), ink_inet_get_port(to)); + Peer *p = FindMultiCastChild(IpAddr(to), ats_ip_port_host_order(to)); ink_assert(p); a = ((ParentSiblingPeer *) p)->SendMsg_re(cont, token, msg, 0); } else { @@ -1085,8 +1085,8 @@ MultiCastPeer::ValidSender(sockaddr* sa) // MultiCast group. Peer *P = _next; while (P) { - if (ink_inet_eq(P->GetIP(), sa) && - (ink_inet_port_cast(P->GetIP()) == ink_inet_port_cast(sa)) + if (ats_ip_addr_eq(P->GetIP(), sa) && + (ats_ip_port_cast(P->GetIP()) == ats_ip_port_cast(sa)) ) { return 1; } else { @@ -1105,7 +1105,7 @@ MultiCastPeer::LogSendMsg(ICPMsg_t * m, sockaddr const* sa) // target Peer. // Peer *p; - p = FindMultiCastChild(InkInetAddr(sa), ink_inet_get_port(sa)); + p = FindMultiCastChild(IpAddr(sa), ats_ip_port_host_order(sa)); if (p) ((ParentSiblingPeer *) p)->LogSendMsg(m, sa); @@ -1135,9 +1135,9 @@ MultiCastPeer::AddMultiCastChild(Peer * P) // Add (Peer *) to the given MultiCast structure. // Make sure child (ip,port) is unique. sockaddr const* ip = P->GetIP(); - if (FindMultiCastChild(InkInetAddr(ip), ink_inet_get_port(ip))) { + if (FindMultiCastChild(IpAddr(ip), ats_ip_port_host_order(ip))) { ip_text_buffer x; - Warning("bad icp.config, multiple multicast child definitions for ip=%s", ink_inet_ntop(ip, x, sizeof(x))); + Warning("bad icp.config, multiple multicast child definitions for ip=%s", ats_ip_ntop(ip, x, sizeof(x))); return 0; // Not added, already exists } else { P->SetNext(this->_next); @@ -1148,7 +1148,7 @@ MultiCastPeer::AddMultiCastChild(Peer * P) } Peer * -MultiCastPeer::FindMultiCastChild(InkInetAddr const& addr, uint16_t port) +MultiCastPeer::FindMultiCastChild(IpAddr const& addr, uint16_t port) { // Locate child (Peer *) with the given (ip,port). This is split out // rather than using a sockaddr so we can indicate the port is to not @@ -1157,7 +1157,7 @@ MultiCastPeer::FindMultiCastChild(InkInetAddr const& addr, uint16_t port) while (curP) { sockaddr const* peer_ip = curP->GetIP(); if (addr == peer_ip && - (!port || port == ink_inet_get_port(peer_ip)) + (!port || port == ats_ip_port_host_order(peer_ip)) ) { return curP; } else { @@ -1490,12 +1490,12 @@ ICPProcessor::DumpICPConfig() } // End of switch if (*str_type == 'M') { - Debug("icp", "[%d]: Type=%s IP=%s", id, str_type, ink_inet_nptop(P->GetIP(), ipb, sizeof(ipb))); + Debug("icp", "[%d]: Type=%s IP=%s", id, str_type, ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb))); } else { ParentSiblingPeer *Pps = static_cast(P); Debug("icp", "[%d]: Type=%s IP=%s PPort=%d Host=%s", - id, str_type, ink_inet_nptop(P->GetIP(), ipb, sizeof(ipb)), + id, str_type, ats_ip_nptop(P->GetIP(), ipb, sizeof(ipb)), Pps->GetConfig()->GetProxyPort(), Pps->GetConfig()->GetHostname()); Debug("icp", diff --git a/proxy/IPAllow.cc b/proxy/IPAllow.cc index c9585d62098..315a8e5e400 100644 --- a/proxy/IPAllow.cc +++ b/proxy/IPAllow.cc @@ -178,10 +178,10 @@ IpAllow::Print() { s << std::endl << " Line " << ar->_src_line << ": " << (ACL_OP_ALLOW == ar->_op ? "allow " : "deny ") - << ink_inet_ntop(spot->min(), text, sizeof text) + << ats_ip_ntop(spot->min(), text, sizeof text) ; - if (0 != ink_inet_cmp(spot->min(), spot->max())) { - s << " - " << ink_inet_ntop(spot->max(), text, sizeof text); + if (0 != ats_ip_addr_cmp(spot->min(), spot->max())) { + s << " - " << ats_ip_ntop(spot->max(), text, sizeof text); } } Debug("ip-allow", "%s", s.str().c_str()); @@ -196,8 +196,8 @@ IpAllow::BuildTable() char errBuf[1024]; char *file_buf = NULL; int line_num = 0; - ts_ip_endpoint addr1; - ts_ip_endpoint addr2; + IpEndpoint addr1; + IpEndpoint addr2; matcher_line line_info; bool alarmAlready = false; diff --git a/proxy/IPAllow.h b/proxy/IPAllow.h index a3a00aaec49..753289a39a7 100644 --- a/proxy/IPAllow.h +++ b/proxy/IPAllow.h @@ -68,7 +68,7 @@ class IpAllow { int BuildTable(); void Print(); bool match(in_addr_t addr) const; - bool match(ts_ip_endpoint const* ip) const; + bool match(IpEndpoint const* ip) const; bool match(sockaddr const* ip) const; /// @return The global instance. @@ -106,7 +106,7 @@ IpAllow::match(in_addr_t addr) const { } inline bool -IpAllow::match(ts_ip_endpoint const* ip) const { +IpAllow::match(IpEndpoint const* ip) const { return this->match(&ip->sa); } diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc index 210ffbaa8be..20e8fbbbf22 100644 --- a/proxy/InkAPI.cc +++ b/proxy/InkAPI.cc @@ -5271,7 +5271,7 @@ TSHttpTxnClientIPGet(TSHttpTxn txnp) sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); HttpSM *sm = (HttpSM *) txnp; - return ink_inet_ip4_addr_cast(&sm->t_state.client_info.addr); + return ats_ip4_addr_cast(&sm->t_state.client_info.addr); } sockaddr const* @@ -5299,7 +5299,7 @@ TSHttpTxnClientIncomingPortGet(TSHttpTxn txnp) sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); HttpSM *sm = (HttpSM *) txnp; - return ink_inet_get_port(&sm->t_state.client_info.addr); + return ats_ip_port_host_order(&sm->t_state.client_info.addr); } sockaddr const* @@ -5317,7 +5317,7 @@ TSHttpTxnServerIPGet(TSHttpTxn txnp) sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); HttpSM *sm = (HttpSM *) txnp; - return ink_inet_ip4_addr_cast(&sm->t_state.server_info.addr.sa); + return ats_ip4_addr_cast(&sm->t_state.server_info.addr.sa); } // [amc] This might use the port. The code path should do that but it @@ -5328,11 +5328,11 @@ TSHttpTxnOutgoingAddrSet(TSHttpTxn txnp, const struct sockaddr *addr, socklen_t sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS); HttpSM *sm = (HttpSM *) txnp; - sm->ua_session->outbound_port = ink_inet_get_port(addr); + sm->ua_session->outbound_port = ats_ip_port_host_order(addr); - if (ink_inet_is_ip4(addr)) { + if (ats_is_ip4(addr)) { sm->ua_session->outbound_ip4.assign(addr); - } else if (ink_inet_is_ip6(addr)) { + } else if (ats_is_ip6(addr)) { sm->ua_session->outbound_ip6.assign(addr); } else { sm->ua_session->outbound_ip4.invalidate(); @@ -5368,7 +5368,7 @@ TSHttpTxnNextHopIPGet(TSHttpTxn txnp) */ if (sm->t_state.current.server == NULL) return 0; - return ink_inet_ip4_addr_cast(&sm->t_state.current.server->addr.sa); + return ats_ip4_addr_cast(&sm->t_state.current.server->addr.sa); } int @@ -5380,7 +5380,7 @@ TSHttpTxnNextHopPortGet(TSHttpTxn txnp) int port = 0; if (sm && sm->t_state.current.server) - port = ink_inet_get_port(&sm->t_state.current.server->addr); + port = ats_ip_port_host_order(&sm->t_state.current.server->addr); return port; } @@ -5995,8 +5995,8 @@ TSHttpConnect(sockaddr const* addr) { sdk_assert(addr); - sdk_assert(ink_inet_is_ip(addr)); - sdk_assert(ink_inet_port_cast(addr)); + sdk_assert(ats_is_ip(addr)); + sdk_assert(ats_ip_port_cast(addr)); if (plugin_http_accept) { PluginVCCore *new_pvc = PluginVCCore::alloc(); @@ -6023,12 +6023,12 @@ TSHttpConnect(sockaddr const* addr) TSVConn TSHttpConnectTransparent(sockaddr const* client_addr, sockaddr const* server_addr) { - sdk_assert(ink_inet_is_ip(client_addr)); - sdk_assert(ink_inet_is_ip(server_addr)); - sdk_assert(!ink_inet_is_any(client_addr)); - sdk_assert(ink_inet_port_cast(client_addr)); - sdk_assert(!ink_inet_is_any(server_addr)); - sdk_assert(ink_inet_port_cast(server_addr)); + sdk_assert(ats_is_ip(client_addr)); + sdk_assert(ats_is_ip(server_addr)); + sdk_assert(!ats_is_ip_any(client_addr)); + sdk_assert(ats_ip_port_cast(client_addr)); + sdk_assert(!ats_is_ip_any(server_addr)); + sdk_assert(ats_ip_port_cast(server_addr)); if (plugin_http_transparent_accept) { PluginVCCore *new_pvc = PluginVCCore::alloc(); @@ -6377,7 +6377,7 @@ TSAction TSNetConnect(TSCont contp, sockaddr const* addr) { sdk_assert(sdk_sanity_check_continuation(contp) == TS_SUCCESS); - sdk_assert(ink_inet_is_ip(addr)); + sdk_assert(ats_is_ip(addr)); FORCE_PLUGIN_MUTEX(contp); @@ -6435,7 +6435,7 @@ in_addr_t TSHostLookupResultIpGet(TSHostLookupResult lookup_result) { sdk_assert(sdk_sanity_check_hostlookup_structure(lookup_result) == TS_SUCCESS); - return ink_inet_ip4_addr_cast(((HostDBInfo *)lookup_result)->ip()); + return ats_ip4_addr_cast(((HostDBInfo *)lookup_result)->ip()); } void @@ -6446,7 +6446,7 @@ TSOSIpSet(TSHttpTxn txnp, unsigned int ip) HttpTransact::State *s = &(sm->t_state); s->dns_info.lookup_success = true; - ink_inet_ip4_set(s->host_db_info.ip(), ip); + ats_ip4_set(s->host_db_info.ip(), ip); } /* @@ -7282,9 +7282,9 @@ TSFetchPages(TSFetchUrlParams_t *params) while (myparams != NULL) { FetchSM *fetch_sm = FetchSMAllocator.alloc(); - sockaddr* addr = ink_inet_sa_cast(&myparams->ip); - in_addr_t ip = ink_inet_ip4_addr_cast(addr); - uint16_t port = ink_inet_get_port(addr); + sockaddr* addr = ats_ip_sa_cast(&myparams->ip); + in_addr_t ip = ats_ip4_addr_cast(addr); + uint16_t port = ats_ip_port_host_order(addr); fetch_sm->init((Continuation*)myparams->contp, myparams->options,myparams->events, myparams->request, myparams->request_len, ip, port); fetch_sm->httpConnect(); @@ -7298,11 +7298,11 @@ TSFetchUrl(const char* headers, int request_len, sockaddr const* ip , TSCont con if (callback_options != NO_CALLBACK) { sdk_assert(sdk_sanity_check_continuation(contp) == TS_SUCCESS); } - sdk_assert(ink_inet_is_ip4(ip)); + sdk_assert(ats_is_ip4(ip)); FetchSM *fetch_sm = FetchSMAllocator.alloc(); - in_addr_t addr = ink_inet_ip4_addr_cast(ip); - unsigned short port = ink_inet_port_cast(ip); + in_addr_t addr = ats_ip4_addr_cast(ip); + unsigned short port = ats_ip_port_cast(ip); fetch_sm->init((Continuation*)contp, callback_options, events, headers, request_len, addr, port); fetch_sm->httpConnect(); diff --git a/proxy/InkAPITest.cc b/proxy/InkAPITest.cc index bdfa0b8e415..dca65c8398e 100644 --- a/proxy/InkAPITest.cc +++ b/proxy/InkAPITest.cc @@ -281,15 +281,15 @@ client_handler(TSCont contp, TSEvent event, void *data) SDK_RPRINT(SDK_NetVConn_test, "TSNetConnect", "TestCase1", TC_PASS, "ok"); sockaddr const* addr = TSNetVConnRemoteAddrGet(static_cast(data)); - uint16_t input_server_port = ink_inet_get_port(addr); + uint16_t input_server_port = ats_ip_port_host_order(addr); - if (!ink_inet_is_loopback(addr)) { + if (!ats_is_ip_loopback(addr)) { ip_text_buffer s, ipb; - ts_ip_endpoint loopback; - ink_inet_ip4_set(&loopback, htonl(INADDR_LOOPBACK)); + IpEndpoint loopback; + ats_ip4_set(&loopback, htonl(INADDR_LOOPBACK)); SDK_RPRINT(SDK_NetVConn_test, "TSNetVConnRemoteIPGet", "TestCase1", TC_FAIL, "server ip [%s] is incorrect - expected [%s]", - ink_inet_ntop(addr, s, sizeof s), - ink_inet_ntop(&loopback.sa, ipb, sizeof ipb) + ats_ip_ntop(addr, s, sizeof s), + ats_ip_ntop(&loopback.sa, ipb, sizeof ipb) ); TSContDestroy(contp); @@ -333,8 +333,8 @@ REGRESSION_TEST(SDK_API_TSNetVConn) (RegressionTest * test, int atype, int *psta TSNetAccept(server_cont, server_port, -1, 0); - ts_ip_endpoint addr; - ink_inet_ip4_set(&addr, htonl(INADDR_LOOPBACK), htons(server_port)); + IpEndpoint addr; + ats_ip4_set(&addr, htonl(INADDR_LOOPBACK), htons(server_port)); TSNetConnect(client_cont, &addr.sa); } @@ -2163,7 +2163,7 @@ checkHttpTxnClientIPGet(SocketTest * test, void *data) in_addr_t actual_ip = htonl(INADDR_LOOPBACK); /* 127.0.0.1 is expected because the client is on the same machine */ ptr = TSHttpTxnClientAddrGet(txnp); - if (ptr == 0 || INADDR_ANY == (ip = ink_inet_ip4_addr_cast(ptr))) { + if (ptr == 0 || INADDR_ANY == (ip = ats_ip4_addr_cast(ptr))) { test->test_client_ip_get = false; SDK_RPRINT(test->regtest, "TSHttpTxnClientIPGet", "TestCase1", TC_FAIL, "TSHttpTxnClientIPGet returns 0 %s", ptr ? "address" : "pointer"); return TS_EVENT_CONTINUE; @@ -2190,7 +2190,7 @@ checkHttpTxnNextHopIPGet(SocketTest * test, void *data) in_addr_t nexthopip; ptr = TSHttpTxnNextHopAddrGet(txnp); - if (ptr == 0 || (nexthopip = ink_inet_ip4_addr_cast(ptr)) == 0) { + if (ptr == 0 || (nexthopip = ats_ip4_addr_cast(ptr)) == 0) { test->test_next_hop_ip_get = false; SDK_RPRINT(test->regtest, "TSHttpTxnNextHopIPGet", "TestCase1", TC_FAIL, "TSHttpTxnNextHopIPGet returns 0 %s", ptr ? "address" : "pointer" ); return TS_EVENT_CONTINUE; @@ -2219,7 +2219,7 @@ checkHttpTxnServerIPGet(SocketTest * test, void *data) in_addr_t actual_ip = htonl(INADDR_LOOPBACK); /* 127.0.0.1 is expected because the client is on the same machine */ ptr = TSHttpTxnServerAddrGet(txnp); - if (0 == ptr || 0 == (ip = ink_inet_ip4_addr_cast(ptr))) { + if (0 == ptr || 0 == (ip = ats_ip4_addr_cast(ptr))) { test->test_server_ip_get = false; SDK_RPRINT(test->regtest, "TSHttpTxnServerIPGet", "TestCase1", TC_FAIL, "TSHttpTxnServerIPGet returns 0 %s", ptr ? "address" : "pointer"); return TS_EVENT_CONTINUE; @@ -2259,7 +2259,7 @@ checkHttpTxnClientIncomingPortGet(SocketTest * test, void *data) test->test_client_incoming_port_get = false; return TS_EVENT_CONTINUE; } - port = ink_inet_get_port(ptr); + port = ats_ip_port_host_order(ptr); TSDebug(UTDBG_TAG, "TS HTTP port = %x, Txn incoming client port %x", proxy_port->m_port, port); @@ -2293,7 +2293,7 @@ checkHttpTxnClientRemotePortGet(SocketTest * test, void *data) return TS_EVENT_CONTINUE; } - port = ink_inet_get_port(ptr); + port = ats_ip_port_host_order(ptr); TSDebug(UTDBG_TAG, "Browser port = %x, Txn remote port = %x", browser_port, port); if (port == browser_port) { @@ -7451,8 +7451,8 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_TSHttpConnectIntercept) (RegressionTest * test /* ip and log do not matter as it is used for logging only */ sockaddr_in addr; - ink_inet_ip4_set(&addr, 1, 1); - data->vc = TSHttpConnect(ink_inet_sa_cast(&addr)); + ats_ip4_set(&addr, 1, 1); + data->vc = TSHttpConnect(ats_ip_sa_cast(&addr)); synclient_txn_send_request_to_vc(data->browser, data->request, data->vc); /* Wait until transaction is done */ @@ -7492,8 +7492,8 @@ EXCLUSIVE_REGRESSION_TEST(SDK_API_TSHttpConnectServerIntercept) (RegressionTest /* ip and log do not matter as it is used for logging only */ sockaddr_in addr; - ink_inet_ip4_set(&addr, 2, 2); - data->vc = TSHttpConnect(ink_inet_sa_cast(&addr)); + ats_ip4_set(&addr, 2, 2); + data->vc = TSHttpConnect(ats_ip_sa_cast(&addr)); synclient_txn_send_request_to_vc(data->browser, data->request, data->vc); diff --git a/proxy/InkAPITestTool.cc b/proxy/InkAPITestTool.cc index 666efaf2e4a..0dcc08764e2 100644 --- a/proxy/InkAPITestTool.cc +++ b/proxy/InkAPITestTool.cc @@ -503,8 +503,8 @@ synclient_txn_send_request(ClientTxn * txn, char *request) cont = TSContCreate(synclient_txn_main_handler, TSMutexCreate()); TSContDataSet(cont, txn); - ink_inet_ip4_set(&addr, txn->connect_ip, htons(txn->connect_port)); - TSNetConnect(cont, ink_inet_sa_cast(&addr)); + ats_ip4_set(&addr, txn->connect_ip, htons(txn->connect_port)); + TSNetConnect(cont, ats_ip_sa_cast(&addr)); return 1; } diff --git a/proxy/InkIOCoreAPI.cc b/proxy/InkIOCoreAPI.cc index 10e93a96998..35b55bea2ba 100644 --- a/proxy/InkIOCoreAPI.cc +++ b/proxy/InkIOCoreAPI.cc @@ -364,9 +364,9 @@ INKUDPBind(TSCont contp, unsigned int ip, int port) FORCE_PLUGIN_MUTEX(contp); struct sockaddr_in addr; - ink_inet_ip4_set(&addr, ip, htons(port)); + ats_ip4_set(&addr, ip, htons(port)); - return reinterpret_cast(udpNet.UDPBind((Continuation *)contp, ink_inet_sa_cast(&addr), INK_ETHERNET_MTU_SIZE, INK_ETHERNET_MTU_SIZE)); + return reinterpret_cast(udpNet.UDPBind((Continuation *)contp, ats_ip_sa_cast(&addr), INK_ETHERNET_MTU_SIZE, INK_ETHERNET_MTU_SIZE)); } TSAction @@ -378,7 +378,7 @@ INKUDPSendTo(TSCont contp, INKUDPConn udp, unsigned int ip, int port, char *data UDPPacket *packet = new_UDPPacket(); UDPConnection *conn = (UDPConnection *)udp; - ink_inet_ip4_set(&packet->to, ip, htons(port)); + ats_ip4_set(&packet->to, ip, htons(port)); IOBufferBlock *blockp = new_IOBufferBlock(); blockp->alloc(BUFFER_SIZE_INDEX_32K); @@ -440,7 +440,7 @@ INKUDPPacketFromAddressGet(INKUDPPacket packet) sdk_assert(sdk_sanity_check_null_ptr((void*)packet) == TS_SUCCESS); UDPPacket *p = (UDPPacket *)packet; - return ink_inet_ip4_addr_cast(&p->from); + return ats_ip4_addr_cast(&p->from); } int @@ -449,7 +449,7 @@ INKUDPPacketFromPortGet(INKUDPPacket packet) sdk_assert(sdk_sanity_check_null_ptr((void*)packet) == TS_SUCCESS); UDPPacket *p = (UDPPacket *)packet; - return ink_inet_get_port(&p->from); + return ats_ip_port_host_order(&p->from); } INKUDPConn diff --git a/proxy/Main.cc b/proxy/Main.cc index 73f259885f3..3161a98c629 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -1551,7 +1551,7 @@ main(int argc, char **argv) /* Set up the machine with the outbound address if that's set, or the inbound address if set, otherwise let it default. */ - ts_ip_endpoint machine_addr; + IpEndpoint machine_addr; ink_zero(machine_addr); if (HttpConfig::m_master.outbound_ip4.isValid()) machine_addr.assign(HttpConfig::m_master.outbound_ip4); diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc index 978a8cf8c0b..09a936ab2e2 100644 --- a/proxy/ParentSelection.cc +++ b/proxy/ParentSelection.cc @@ -511,10 +511,10 @@ ParentRecord::FindParent(bool first_call, ParentResult * result, RD * rdata, Par // INKqa12817 - make sure to convert to host byte order // Why was it important to do host order here? And does this have any // impact with the transition to IPv6? The IPv4 functionality is - // preserved for now anyway as ink_inet_hash returns the 32-bit address in + // preserved for now anyway as ats_ip_hash returns the 32-bit address in // that case. if (rdata->get_client_ip() != NULL) { - cur_index = ntohl(ink_inet_hash(rdata->get_client_ip())) % num_parents; + cur_index = ntohl(ats_ip_hash(rdata->get_client_ip())) % num_parents; } else { cur_index = 0; } @@ -1056,9 +1056,9 @@ request_to_data(HttpRequestData * req, sockaddr const* srcip, sockaddr const* ds HTTPParser parser; ink_zero(req->src_ip); - ink_inet_copy(&req->src_ip.sa, srcip); + ats_ip_copy(&req->src_ip.sa, srcip); ink_zero(req->dest_ip); - ink_inet_copy(&req->dest_ip.sa, dstip); + ats_ip_copy(&req->dest_ip.sa, dstip); req->hdr = NEW(new HTTPHdr); @@ -1146,11 +1146,11 @@ EXCLUSIVE_REGRESSION_TEST(PARENTSELECTION) (RegressionTest * t, int intensity_le T("dest_host=pluto scheme=HTTP parent=strategy:80\n") /* L16 */ REBUILD // Test 3 - ts_ip_endpoint ip; - ink_inet_pton(TEST_IP4_ADDR, &ip.sa); + IpEndpoint ip; + ats_ip_pton(TEST_IP4_ADDR, &ip.sa); ST(3) REINIT br(request, "numeric_host", &ip.sa); FP RE(verify(result, PARENT_SPECIFIED, "cat", 37) + verify(result, PARENT_SPECIFIED, "dog", 24), 3) - ink_inet_pton(TEST_IP6_ADDR, &ip.sa); + ats_ip_pton(TEST_IP6_ADDR, &ip.sa); ST(4) REINIT br(request, "numeric_host", &ip.sa); FP RE(verify(result, PARENT_SPECIFIED, "zwoop", 37) + verify(result, PARENT_SPECIFIED, "jMCg", 24), 4) // Test 5 @@ -1309,7 +1309,7 @@ br(HttpRequestData * h, const char *os_hostname, sockaddr const* dest_ip) h->xact_start = time(NULL); ink_zero(h->src_ip); ink_zero(h->dest_ip); - ink_inet_copy(&h->dest_ip.sa, dest_ip); + ats_ip_copy(&h->dest_ip.sa, dest_ip); h->incoming_port = 80; h->api_info = new _HttpApiInfo(); } diff --git a/proxy/PluginVC.cc b/proxy/PluginVC.cc index 2907fd0f653..1346c669519 100644 --- a/proxy/PluginVC.cc +++ b/proxy/PluginVC.cc @@ -879,10 +879,10 @@ void PluginVC::set_local_addr() { if (vc_type == PLUGIN_VC_ACTIVE) { - ink_inet_copy(&local_addr, &core_obj->active_addr_struct); + ats_ip_copy(&local_addr, &core_obj->active_addr_struct); // local_addr = core_obj->active_addr_struct; } else { - ink_inet_copy(&local_addr, &core_obj->passive_addr_struct); + ats_ip_copy(&local_addr, &core_obj->passive_addr_struct); // local_addr = core_obj->passive_addr_struct; } } @@ -891,9 +891,9 @@ void PluginVC::set_remote_addr() { if (vc_type == PLUGIN_VC_ACTIVE) { - ink_inet_copy(&remote_addr, &core_obj->passive_addr_struct); + ats_ip_copy(&remote_addr, &core_obj->passive_addr_struct); } else { - ink_inet_copy(&remote_addr, &core_obj->active_addr_struct); + ats_ip_copy(&remote_addr, &core_obj->active_addr_struct); } } @@ -1147,7 +1147,7 @@ PluginVCCore::kill_no_connect() void PluginVCCore::set_passive_addr(in_addr_t ip, int port) { - ink_inet_ip4_set(&passive_addr_struct, htonl(ip), htons(port)); + ats_ip4_set(&passive_addr_struct, htonl(ip), htons(port)); } void @@ -1159,7 +1159,7 @@ PluginVCCore::set_passive_addr(sockaddr const* ip) void PluginVCCore::set_active_addr(in_addr_t ip, int port) { - ink_inet_ip4_set(&active_addr_struct, htonl(ip), htons(port)); + ats_ip4_set(&active_addr_struct, htonl(ip), htons(port)); } void diff --git a/proxy/PluginVC.h b/proxy/PluginVC.h index f58e5d2bc21..7a6245e0315 100644 --- a/proxy/PluginVC.h +++ b/proxy/PluginVC.h @@ -219,8 +219,8 @@ class PluginVCCore:public Continuation MIOBuffer *a_to_p_buffer; IOBufferReader *a_to_p_reader; - ts_ip_endpoint passive_addr_struct; - ts_ip_endpoint active_addr_struct; + IpEndpoint passive_addr_struct; + IpEndpoint active_addr_struct; void *passive_data; void *active_data; diff --git a/proxy/Prefetch.cc b/proxy/Prefetch.cc index 73264960963..a088955a19c 100644 --- a/proxy/Prefetch.cc +++ b/proxy/Prefetch.cc @@ -547,7 +547,7 @@ PrefetchTransform::parse_data(IOBufferReader *reader) continue; } //Debug("PrefetchParserURLs", "Found embedded URL: %s", url_start); - ink_inet_copy(&entry->req_ip, &m_sm->t_state.client_info.addr); + ats_ip_copy(&entry->req_ip, &m_sm->t_state.client_info.addr); PrefetchBlaster *blaster = prefetchBlasterAllocator.alloc(); blaster->init(entry, &m_sm->t_state.hdr_info.client_request, this); @@ -583,7 +583,7 @@ PrefetchTransform::hash_add(char *s) #define IS_RECURSIVE_PREFETCH(req_ip) \ - (prefetch_config.max_recursion > 0 && ink_inet_is_loopback(&req_ip)) + (prefetch_config.max_recursion > 0 && ats_is_ip_loopback(&req_ip)) static void check_n_attach_prefetch_transform(HttpSM *sm, HTTPHdr *resp, bool from_cache) @@ -591,11 +591,11 @@ check_n_attach_prefetch_transform(HttpSM *sm, HTTPHdr *resp, bool from_cache) INKVConnInternal *prefetch_trans; ip_text_buffer client_ipb; - ts_ip_endpoint client_ip = sm->t_state.client_info.addr; + IpEndpoint client_ip = sm->t_state.client_info.addr; // we depend on this to setup @a client_ipb for all subsequent Debug(). Debug("PrefetchParser", "Checking response for request from %s\n", - ink_inet_ntop(&client_ip, client_ipb, sizeof(client_ipb)) + ats_ip_ntop(&client_ip, client_ipb, sizeof(client_ipb)) ); unsigned int rec_depth = 0; @@ -892,10 +892,10 @@ PrefetchUrlBlaster::udpUrlBlaster(int event, void *data) setup_udp_header(block->start(), get_udp_seq_no(), 0, true); setup_object_header(block->start() + PRELOAD_UDP_HEADER_LEN, block->read_avail() - PRELOAD_UDP_HEADER_LEN, true); - ts_ip_endpoint saddr; - ink_inet_copy(&saddr, &url_head->url_multicast_ip) || - ink_inet_copy(&saddr, &url_head->child_ip); - ink_inet_port_cast(&saddr.sa) = htons(prefetch_config.stuffer_port); + IpEndpoint saddr; + ats_ip_copy(&saddr, &url_head->url_multicast_ip) || + ats_ip_copy(&saddr, &url_head->child_ip); + ats_ip_port_cast(&saddr.sa) = htons(prefetch_config.stuffer_port); udpNet.sendto_re(this, NULL, prefetch_udp_fd, &saddr.sa, sizeof(saddr), block, block->read_avail()); } @@ -1000,7 +1000,7 @@ PrefetchBlaster::init(PrefetchUrlEntry *entry, HTTPHdr *req_hdr, PrefetchTransfo //this is a recursive prefetch. get child ip address from //Client-IP header ink_strlcpy(b, ip_str, sizeof(b)); - ink_inet_pton(b, &entry->child_ip.sa); + ats_ip_pton(b, &entry->child_ip.sa); } else entry->child_ip = entry->req_ip; @@ -1500,7 +1500,7 @@ PrefetchBlaster::httpClient(int event, void *data) switch (event) { case EVENT_IMMEDIATE:{ - ts_ip_endpoint target; + IpEndpoint target; target.setToLoopback(AF_INET); target.port() = prefetch_config.local_http_server_port; netProcessor.connect_re(this, &target.sa); @@ -1676,13 +1676,13 @@ PrefetchBlaster::blastObject(int event, void *data) setup_udp_header(io_block->start(), seq_no, n_pkts_sent++, (towrite >= nread_avail)); - ts_ip_endpoint saddr; - ink_inet_copy(&saddr.sa, - ink_inet_is_ip(&url_ent->data_multicast_ip) + IpEndpoint saddr; + ats_ip_copy(&saddr.sa, + ats_is_ip(&url_ent->data_multicast_ip) ? &url_ent->data_multicast_ip.sa : &url_ent->child_ip.sa ); - ink_inet_port_cast(&saddr) = htons(prefetch_config.stuffer_port); + ats_ip_port_cast(&saddr) = htons(prefetch_config.stuffer_port); //saddr.sin_addr.s_addr = htonl((209<<24)|(131<<16)|(60<<8)|243); //saddr.sin_addr.s_addr = htonl((209<<24)|(131<<16)|(48<<8)|52); @@ -1740,9 +1740,9 @@ PrefetchBlaster::invokeBlaster() if (ret == TS_PREFETCH_CONTINUE) { if (MULTICAST_BLAST == url_blast.type) - ink_inet_copy(&url_ent->url_multicast_ip.sa, &url_blast.ip.sa); + ats_ip_copy(&url_ent->url_multicast_ip.sa, &url_blast.ip.sa); if (MULTICAST_BLAST == data_blast.type) - ink_inet_copy(&url_ent->data_multicast_ip.sa, &data_blast.ip.sa); + ats_ip_copy(&url_ent->data_multicast_ip.sa, &data_blast.ip.sa); if (url_ent->object_buf_status != TS_PREFETCH_OBJ_BUF_NEEDED) { if (url_blast.type == TCP_BLAST) @@ -1795,14 +1795,14 @@ config_read_proto(PrefetchBlastData &blast, const char *str) blast.type = TCP_BLAST; else { // this is a multicast address: if (strncasecmp("multicast:", str, 10) == 0) { - if (0 != ink_inet_pton(str, &blast.ip.sa)) { + if (0 != ats_ip_pton(str, &blast.ip.sa)) { Error("PrefetchProcessor: Address specified for multicast does not seem to " "be of the form multicast:ip_addr (eg: multicast:224.0.0.1)"); return 1; } else { ip_text_buffer ipb; blast.type = MULTICAST_BLAST; - Debug("Prefetch", "Setting multicast address: %s\n", ink_inet_ntop(&blast.ip.sa, ipb, sizeof(ipb))); + Debug("Prefetch", "Setting multicast address: %s\n", ats_ip_ntop(&blast.ip.sa, ipb, sizeof(ipb))); } } else { Error("PrefetchProcessor: The protocol for Prefetch should of the form: " "tcp or udp or multicast:ip_address"); @@ -1961,9 +1961,9 @@ PrefetchConfiguration::readHtmlTags(int fd, html_tag ** ptags, html_tag ** pattr #define CONN_ARR_SIZE 256 inline int -KeepAliveConnTable::ip_hash(ts_ip_endpoint const& ip) +KeepAliveConnTable::ip_hash(IpEndpoint const& ip) { - return ink_inet_hash(&ip.sa) & (CONN_ARR_SIZE - 1); + return ats_ip_hash(&ip.sa) & (CONN_ARR_SIZE - 1); } inline int @@ -2005,7 +2005,7 @@ KeepAliveConnTable::free() ClassAllocator prefetchLockHandlerAllocator("prefetchLockHandlerAllocator"); int -KeepAliveConnTable::append(ts_ip_endpoint const& ip, MIOBuffer *buf, IOBufferReader *reader) +KeepAliveConnTable::append(IpEndpoint const& ip, MIOBuffer *buf, IOBufferReader *reader) { int index = ip_hash(ip); @@ -2025,7 +2025,7 @@ KeepAliveConnTable::append(ts_ip_endpoint const& ip, MIOBuffer *buf, IOBufferRea KeepAliveConn **conn = &arr[index].conn; - while (*conn && ! ink_inet_eq(&(*conn)->ip, &ip)) + while (*conn && ! ats_ip_addr_eq(&(*conn)->ip, &ip)) conn = &(*conn)->next; if (*conn) { @@ -2040,7 +2040,7 @@ KeepAliveConnTable::append(ts_ip_endpoint const& ip, MIOBuffer *buf, IOBufferRea } int -KeepAliveConn::init(ts_ip_endpoint const& xip, MIOBuffer *xbuf, IOBufferReader *xreader) +KeepAliveConn::init(IpEndpoint const& xip, MIOBuffer *xbuf, IOBufferReader *xreader) { mutex = g_conn_table->arr[KeepAliveConnTable::ip_hash(xip)].mutex; @@ -2114,7 +2114,7 @@ KeepAliveConn::handleEvent(int event, void *data) break; case NET_EVENT_OPEN_FAILED: - Debug("PrefetchKeepAlive", "Connection to child %s failed\n", ink_inet_ntop(&ip.sa, ipb, sizeof(ipb))); + Debug("PrefetchKeepAlive", "Connection to child %s failed\n", ats_ip_ntop(&ip.sa, ipb, sizeof(ipb))); free(); break; @@ -2143,7 +2143,7 @@ KeepAliveConn::handleEvent(int event, void *data) break; case VC_EVENT_ERROR: - Debug("PrefetchKeepAlive", "got VC_ERROR.. connection problem? " "(ip: %s)", ink_inet_ntop(&ip.sa, ipb, sizeof(ipb))); + Debug("PrefetchKeepAlive", "got VC_ERROR.. connection problem? " "(ip: %s)", ats_ip_ntop(&ip.sa, ipb, sizeof(ipb))); free(); break; diff --git a/proxy/Prefetch.h b/proxy/Prefetch.h index ccaebd62dbe..ff58d0e2f5e 100644 --- a/proxy/Prefetch.h +++ b/proxy/Prefetch.h @@ -107,10 +107,10 @@ class PrefetchUrlEntry: public RefCountObj int object_buf_status; - ts_ip_endpoint req_ip; /*ip address where request is coming from */ - ts_ip_endpoint child_ip; - ts_ip_endpoint url_multicast_ip; - ts_ip_endpoint data_multicast_ip; + IpEndpoint req_ip; /*ip address where request is coming from */ + IpEndpoint child_ip; + IpEndpoint url_multicast_ip; + IpEndpoint data_multicast_ip; PrefetchUrlEntry *blaster_link; PrefetchUrlEntry *hash_link; @@ -349,13 +349,13 @@ class KeepAliveConn: public Continuation : Continuation(), nbytes_added(0) { ink_zero(ip); } - int init(ts_ip_endpoint const& ip, MIOBuffer * buf, IOBufferReader * reader); + int init(IpEndpoint const& ip, MIOBuffer * buf, IOBufferReader * reader); void free(); int append(IOBufferReader * reader); int handleEvent(int event, void *data); - ts_ip_endpoint ip; + IpEndpoint ip; MIOBuffer *buf; IOBufferReader *reader; @@ -380,8 +380,8 @@ class KeepAliveConnTable int init(); void free(); - static int ip_hash(ts_ip_endpoint const& ip); - int append(ts_ip_endpoint const& ip, MIOBuffer * buf, IOBufferReader * reader); + static int ip_hash(IpEndpoint const& ip); + int append(IpEndpoint const& ip, MIOBuffer * buf, IOBufferReader * reader); typedef struct { @@ -403,11 +403,11 @@ class KeepAliveLockHandler: public Continuation ink_zero(ip); }; - void init(ts_ip_endpoint const& xip, MIOBuffer * xbuf, IOBufferReader * xreader) + void init(IpEndpoint const& xip, MIOBuffer * xbuf, IOBufferReader * xreader) { mutex = g_conn_table->arr[KeepAliveConnTable::ip_hash(xip)].mutex; - ink_inet_copy(&ip, &xip); + ats_ip_copy(&ip, &xip); buf = xbuf; reader = xreader; @@ -421,7 +421,7 @@ class KeepAliveLockHandler: public Continuation int handleEvent(int event, void *data); - ts_ip_endpoint ip; + IpEndpoint ip; MIOBuffer *buf; IOBufferReader *reader; }; diff --git a/proxy/SimpleHttp.cc b/proxy/SimpleHttp.cc index 7d77627b4c8..bd043d892e5 100644 --- a/proxy/SimpleHttp.cc +++ b/proxy/SimpleHttp.cc @@ -657,10 +657,10 @@ SimpleCont::dns_event(int event, void *edata) if (r->round_robin) { // TODO: IPv6 sockaddr_in ip4; - ink_inet_ip4_set(&ip4, 0); + ats_ip4_set(&ip4, 0); Debug("simple_http", "dns round robin"); - rr = r->rr()->select_best(ink_inet_sa_cast(&ip4)); + rr = r->rr()->select_best(ats_ip_sa_cast(&ip4)); } else { rr = r; } diff --git a/proxy/Update.cc b/proxy/Update.cc index 0be5d0dca02..cf6cbe7c536 100644 --- a/proxy/Update.cc +++ b/proxy/Update.cc @@ -2563,7 +2563,7 @@ ObjectReloadCont::ObjectReloadEvent(int event, void *d) switch (_state) { case START: { - ts_ip_endpoint target; + IpEndpoint target; // Schedule connect to localhost: Debug("update-reload", "Connect start id=%d", _request_id); _state = ObjectReloadCont::ATTEMPT_CONNECT; diff --git a/proxy/api/ts/InkAPIHughes.h b/proxy/api/ts/InkAPIHughes.h index 1a3556975ae..32bf883640e 100644 --- a/proxy/api/ts/InkAPIHughes.h +++ b/proxy/api/ts/InkAPIHughes.h @@ -36,7 +36,7 @@ typedef enum typedef struct { PrefetchBlastType type; - ts_ip_endpoint ip; + IpEndpoint ip; } PrefetchBlastData; typedef struct @@ -51,7 +51,7 @@ typedef struct TSMLoc response_loc; /*child ip addr in network order */ - ts_ip_endpoint client_ip; + IpEndpoint client_ip; /*the embedded url parsed by the parser */ const char *embedded_url; diff --git a/proxy/congest/Congestion.cc b/proxy/congest/Congestion.cc index 95f75672f6f..3cb2ed8d5fe 100644 --- a/proxy/congest/Congestion.cc +++ b/proxy/congest/Congestion.cc @@ -474,7 +474,7 @@ make_key(char *hostname, int len, sockaddr const* ip, CongestionControlRecord * if (record->congestion_scheme == PER_HOST && len > 0) ink_code_incr_MMH_update(&ctx, hostname, len); else - ink_code_incr_MMH_update(&ctx, reinterpret_cast(ink_inet_addr8_cast(ip)), ink_inet_addr_size(ip)); + ink_code_incr_MMH_update(&ctx, reinterpret_cast(ats_ip_addr8_cast(ip)), ats_ip_addr_size(ip)); if (record->port != 0) { unsigned short p = port; p = htons(p); @@ -490,7 +490,7 @@ make_key(char *hostname, int len, sockaddr const* ip, CongestionControlRecord * if (record->congestion_scheme == PER_HOST && len > 0) ink_code_incr_md5_update(&ctx, hostname, len); else - ink_code_incr_md5_update(&ctx, reinterpret_cast(ink_inet_addr8_cast(ip)), ink_inet_addr_size(ip)); + ink_code_incr_md5_update(&ctx, reinterpret_cast(ats_ip_addr8_cast(ip)), ats_ip_addr_size(ip)); if (record->port != 0) { unsigned short p = record->port; p = htons(p); @@ -515,7 +515,7 @@ make_key(char *hostname, int len, sockaddr const* ip, char *prefix, int prelen, if (hostname && len > 0) ink_code_incr_MMH_update(&ctx, hostname, len); else - ink_code_incr_MMH_update(&ctx, reinterpret_cast(ink_inet_addr8_cast(ip)), ink_inet_addr_size(ip)); + ink_code_incr_MMH_update(&ctx, reinterpret_cast(ats_ip_addr8_cast(ip)), ats_ip_addr_size(ip)); if (port != 0) { unsigned short p = port; p = htons(p); @@ -531,7 +531,7 @@ make_key(char *hostname, int len, sockaddr const* ip, char *prefix, int prelen, if (hostname && len > 0) ink_code_incr_md5_update(&ctx, hostname, len); else - ink_code_incr_md5_update(&ctx, reinterpret_cast(ink_inet_addr8_cast(ip)), ink_inet_addr_size(ip)); + ink_code_incr_md5_update(&ctx, reinterpret_cast(ats_ip_addr8_cast(ip)), ats_ip_addr_size(ip)); if (port != 0) { unsigned short p = port; p = htons(p); @@ -617,7 +617,7 @@ m_M_congested(0), m_last_M_congested(0), m_num_connections(0), m_stat_congested_ { memset(&m_ip, 0, sizeof(m_ip)); if (ip != NULL) { - ink_inet_copy(&m_ip.sa, ip); + ats_ip_copy(&m_ip.sa, ip); } m_hostname = ats_strdup(hostname); rule->get(); @@ -714,7 +714,7 @@ CongestionEntry::sprint(char *buf, int buflen, int format) len += snprintf(buf + len, buflen - len, "%" PRId64 "|%d|%s|%s", timestamp, pRecord->line_num, - (m_hostname ? m_hostname : " "), (ink_inet_is_ip(&m_ip) ? ink_inet_ntop(&m_ip.sa, addrbuf, sizeof(addrbuf)) : " ")); + (m_hostname ? m_hostname : " "), (ats_is_ip(&m_ip) ? ats_ip_ntop(&m_ip.sa, addrbuf, sizeof(addrbuf)) : " ")); len += snprintf(buf + len, buflen - len, "|%s|%s|%c", (pRecord->congestion_scheme == PER_IP ? "per_ip" : "per_host"), diff --git a/proxy/congest/Congestion.h b/proxy/congest/Congestion.h index 8924da7fcdd..3746f8e8ec0 100644 --- a/proxy/congest/Congestion.h +++ b/proxy/congest/Congestion.h @@ -202,7 +202,7 @@ struct CongestionEntry: public RequestData // key in the hash table; uint64_t m_key; // host info - ts_ip_endpoint m_ip; + IpEndpoint m_ip; char *m_hostname; // Pointer to the congestion.config entry diff --git a/proxy/congest/CongestionDB.cc b/proxy/congest/CongestionDB.cc index 6486fcab1b4..f2d3eafb531 100644 --- a/proxy/congest/CongestionDB.cc +++ b/proxy/congest/CongestionDB.cc @@ -75,7 +75,7 @@ class CongestionDBCont:public Continuation { uint64_t m_key; char *m_hostname; - ts_ip_endpoint m_ip; + IpEndpoint m_ip; CongestionControlRecord *m_rule; CongestionEntry **m_ppEntry; } entry_info; @@ -515,7 +515,7 @@ get_congest_entry(Continuation * cont, HttpRequestData * data, CongestionEntry * Ccont->mutex = cont->mutex; Ccont->CDBC_key = key; Ccont->CDBC_host = (char *) data->get_host(); - ink_inet_copy(&Ccont->CDBC_ip.sa, data->get_ip()); + ats_ip_copy(&Ccont->CDBC_ip.sa, data->get_ip()); p->get(); Ccont->CDBC_rule = p; Ccont->CDBC_ppE = ppEntry; @@ -623,7 +623,7 @@ remove_congested_entry(char *buf, MIOBuffer * out_buffer) remove_congested_entry(key); len = snprintf(msg, MSG_LEN, "host=%s prefix=%s removed\n", p, prefix ? prefix : "(nil)"); } else if (strncasecmp(buf, "ip=", 3) == 0) { - ts_ip_endpoint ip; + IpEndpoint ip; memset(&ip, 0, sizeof(ip)); char *p = buf + 3; @@ -634,8 +634,8 @@ remove_congested_entry(char *buf, MIOBuffer * out_buffer) prefix++; prelen = strlen(prefix); } - ink_inet_pton(p, &ip); - if (!ink_inet_is_ip(&ip)) { + ats_ip_pton(p, &ip); + if (!ats_is_ip(&ip)) { len = snprintf(msg, MSG_LEN, "invalid ip: %s\n", buf); } else { key = make_key(NULL, 0, &ip.sa, prefix, prelen); diff --git a/proxy/congest/CongestionTest.cc b/proxy/congest/CongestionTest.cc index a4fc821dbbd..e93f4ad2d23 100644 --- a/proxy/congest/CongestionTest.cc +++ b/proxy/congest/CongestionTest.cc @@ -407,7 +407,7 @@ CCCongestionDBTestCont::gen_CongestionEntry(sockaddr const* ip, int congested) { char hostname[INET6_ADDRSTRLEN]; uint64_t key; - ink_inet_ntop(ip, hostname, sizeof(hostname)); + ats_ip_ntop(ip, hostname, sizeof(hostname)); key = make_key(hostname, strlen(hostname), ip, rule->pRecord); CongestionEntry *ret = new CongestionEntry(hostname, ip, @@ -474,8 +474,8 @@ CCCongestionDBTestCont::mainEvent(int event, Event * e) if (i % (dbsize / 25) == 0) fprintf(stderr, "."); - ts_ip_endpoint ip; - ink_inet_ip4_set(&ip, i + 255); + IpEndpoint ip; + ats_ip4_set(&ip, i + 255); CongestionEntry *tmp = gen_CongestionEntry(&ip.sa); db->addRecord(tmp->m_key, tmp); @@ -494,8 +494,8 @@ CCCongestionDBTestCont::mainEvent(int event, Event * e) if (i % (to_add / 25) == 0) fprintf(stderr, "."); - ts_ip_endpoint ip; - ink_inet_ip4_set(&ip, i + 255); + IpEndpoint ip; + ats_ip4_set(&ip, i + 255); CongestionEntry *tmp = gen_CongestionEntry(&ip.sa); db->addRecord(tmp->m_key, tmp); } @@ -512,8 +512,8 @@ CCCongestionDBTestCont::mainEvent(int event, Event * e) if (i % (to_add / 25) == 0) fprintf(stderr, "."); - ts_ip_endpoint ip; - ink_inet_ip4_set(&ip, i + 255); + IpEndpoint ip; + ats_ip4_set(&ip, i + 255); CongestionEntry *tmp = gen_CongestionEntry(&ip.sa, 1); db->addRecord(tmp->m_key, tmp); diff --git a/proxy/http/HttpAccept.cc b/proxy/http/HttpAccept.cc index a307cf2f0d7..f90b7b0c39c 100644 --- a/proxy/http/HttpAccept.cc +++ b/proxy/http/HttpAccept.cc @@ -45,7 +45,7 @@ HttpAccept::mainEvent(int event, void *data) // The backdoor port is now only bound to "localhost", so reason to // check for if it's incoming from "localhost" or not. if (!backdoor && IpAllow::instance() && (!IpAllow::instance()->match(client_ip))) { - Warning("connect by disallowed client %s, closing", ink_inet_ntop(client_ip, ipb, sizeof(ipb))); + Warning("connect by disallowed client %s, closing", ats_ip_ntop(client_ip, ipb, sizeof(ipb))); netvc->do_io_close(); return VC_EVENT_CONT; @@ -54,7 +54,7 @@ HttpAccept::mainEvent(int event, void *data) netvc->attributes = transport_type; if (is_debug_tag_set("http_seq")) - Debug("http_seq", "[HttpAccept:mainEvent %p] accepted connection from %s transport type = %d", netvc, ink_inet_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes); + Debug("http_seq", "[HttpAccept:mainEvent %p] accepted connection from %s transport type = %d", netvc, ats_ip_nptop(client_ip, ipb, sizeof(ipb)), netvc->attributes); HttpClientSession *new_session = THREAD_ALLOC_INIT(httpClientSessionAllocator, netvc->thread); diff --git a/proxy/http/HttpAccept.h b/proxy/http/HttpAccept.h index af3584b6000..9a2269592df 100644 --- a/proxy/http/HttpAccept.h +++ b/proxy/http/HttpAccept.h @@ -58,12 +58,12 @@ namespace detail { /// Set the transport type. self& setTransportType(int); /// Local address to bind for outbound connections. - InkInetAddr outbound_ip4; + IpAddr outbound_ip4; /// Local address to bind for outbound connections. - InkInetAddr outbound_ip6; + IpAddr outbound_ip6; /// Set the outbound IP address. - self& setOutboundIp(InkInetAddr& ip); - self& setOutboundIp(ts_ip_endpoint* ip); + self& setOutboundIp(IpAddr& ip); + self& setOutboundIp(IpEndpoint* ip); /// Local port for outbound connection. uint16_t outbound_port; /// Set outbound port. @@ -93,14 +93,14 @@ namespace detail { } inline HttpAcceptOptions& - HttpAcceptOptions::setOutboundIp(InkInetAddr& ip) { + HttpAcceptOptions::setOutboundIp(IpAddr& ip) { if (ip.isIp4()) outbound_ip4 = ip; else if (ip.isIp6()) outbound_ip6 = ip; return *this; } inline HttpAcceptOptions& - HttpAcceptOptions::setOutboundIp(ts_ip_endpoint* ip) { + HttpAcceptOptions::setOutboundIp(IpEndpoint* ip) { if (ip->isIp4()) outbound_ip4 = *ip; else if (ip->isIp6()) outbound_ip6 = *ip; return *this; diff --git a/proxy/http/HttpClientSession.h b/proxy/http/HttpClientSession.h index dcef9032597..47d2a3e0191 100644 --- a/proxy/http/HttpClientSession.h +++ b/proxy/http/HttpClientSession.h @@ -144,9 +144,9 @@ class HttpClientSession: public VConnection bool backdoor_connect; int hooks_set; /// Local address for outbound connection. - InkInetAddr outbound_ip4; + IpAddr outbound_ip4; /// Local address for outbound connection. - InkInetAddr outbound_ip6; + IpAddr outbound_ip6; /// Local port for outbound connection. uint16_t outbound_port; /// Set outbound connection to transparent. diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h index 922fb45718d..cdd26082edb 100644 --- a/proxy/http/HttpConfig.h +++ b/proxy/http/HttpConfig.h @@ -594,8 +594,8 @@ struct HttpConfigParams:public ConfigInfo char *proxy_hostname; int proxy_hostname_len; - InkInetAddr inbound_ip4, inbound_ip6; - InkInetAddr outbound_ip4, outbound_ip6; + IpAddr inbound_ip4, inbound_ip6; + IpAddr outbound_ip4, outbound_ip6; MgmtInt server_max_connections; MgmtInt origin_min_keep_alive_connections; // TODO: This one really ought to be overridable, but difficult right now. diff --git a/proxy/http/HttpConnectionCount.h b/proxy/http/HttpConnectionCount.h index d1acf93381e..bbf4b4591c9 100644 --- a/proxy/http/HttpConnectionCount.h +++ b/proxy/http/HttpConnectionCount.h @@ -46,7 +46,7 @@ class ConnectionCount * @param ip IP address of the host * @return Number of connections */ - int getCount(const ts_ip_endpoint& addr) { + int getCount(const IpEndpoint& addr) { ink_mutex_acquire(&_mutex); int count = _hostCount.get(ConnAddr(addr)); ink_mutex_release(&_mutex); @@ -58,7 +58,7 @@ class ConnectionCount * @param ip IP address of the host * @param delta Default is +1, can be set to negative to decrement */ - void incrementCount(const ts_ip_endpoint& addr, const int delta = 1) { + void incrementCount(const IpEndpoint& addr, const int delta = 1) { ConnAddr caddr(addr); ink_mutex_acquire(&_mutex); int count = _hostCount.get(caddr); @@ -67,18 +67,18 @@ class ConnectionCount } struct ConnAddr { - ts_ip_endpoint _addr; + IpEndpoint _addr; ConnAddr() { ink_zero(_addr); } ConnAddr(int x) { ink_release_assert(x == 0); ink_zero(_addr); } - ConnAddr(const ts_ip_endpoint& addr) : _addr(addr) { } - operator bool() { return ink_inet_is_ip(&_addr); } + ConnAddr(const IpEndpoint& addr) : _addr(addr) { } + operator bool() { return ats_is_ip(&_addr); } }; class ConnAddrHashFns { public: - static uintptr_t hash(ConnAddr& addr) { return (uintptr_t) ink_inet_hash(&addr._addr.sa); } - static int equal(ConnAddr& a, ConnAddr& b) { return ink_inet_eq(&a._addr, &b._addr); } + static uintptr_t hash(ConnAddr& addr) { return (uintptr_t) ats_ip_hash(&addr._addr.sa); } + static int equal(ConnAddr& a, ConnAddr& b) { return ats_ip_addr_eq(&a._addr, &b._addr); } }; private: diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc index c2b91dafbee..00d1b769fef 100644 --- a/proxy/http/HttpSM.cc +++ b/proxy/http/HttpSM.cc @@ -599,7 +599,7 @@ HttpSM::attach_client_session(HttpClientSession * client_vc, IOBufferReader * bu NetVConnection* netvc = client_vc->get_netvc(); - ink_inet_copy(&t_state.client_info.addr, netvc->get_remote_addr()); + ats_ip_copy(&t_state.client_info.addr, netvc->get_remote_addr()); t_state.client_info.port = netvc->get_local_port(); t_state.client_info.is_transparent = netvc->get_is_transparent(); t_state.backdoor_request = client_vc->backdoor_connect; @@ -1624,9 +1624,9 @@ HttpSM::state_http_server_open(int event, void *data) UnixNetVConnection *server_vc = (UnixNetVConnection*)data; printf("client fd is :%d , server fd is %d\n",vc->con.fd, server_vc->con.fd); */ - ink_inet_copy(&session->server_ip, &t_state.current.server->addr); + ats_ip_copy(&session->server_ip, &t_state.current.server->addr); session->new_connection((NetVConnection *) data); - ink_inet_port_cast(&session->server_ip) = htons(t_state.current.server->port); + ats_ip_port_cast(&session->server_ip) = htons(t_state.current.server->port); session->state = HSS_ACTIVE; attach_server_session(session); @@ -2013,7 +2013,7 @@ HttpSM::process_hostdb_info(HostDBInfo * r) // m_s.host_db_info = m_updated_host_db_info = *rr; t_state.host_db_info = *rr; ink_release_assert(!t_state.host_db_info.reverse_dns); - ink_release_assert(ink_inet_is_ip(t_state.host_db_info.ip())); + ink_release_assert(ats_is_ip(t_state.host_db_info.ip())); } } else { Debug("http", "[%" PRId64 "] DNS lookup failed for '%s'", sm_id, t_state.dns_info.lookup_name); @@ -2115,7 +2115,7 @@ HttpSM::state_mark_os_down(int event, void *data) } } else { // No longer a round robin, check to see if our address is the same - if (ink_inet_eq(t_state.host_db_info.ip(), r->ip())) { + if (ats_ip_addr_eq(t_state.host_db_info.ip(), r->ip())) { mark_down = r; } } @@ -3763,8 +3763,8 @@ HttpSM::do_hostdb_reverse_lookup() Debug("http_seq", "[HttpSM::do_hostdb_reverse_lookup] Doing reverse DNS Lookup"); - ts_ip_endpoint addr; - ink_inet_pton(t_state.dns_info.lookup_name, &addr.sa); + IpEndpoint addr; + ats_ip_pton(t_state.dns_info.lookup_name, &addr.sa); Action *dns_lookup_action_handle = hostDBProcessor.getbyaddr_re(this, &addr.sa); if (dns_lookup_action_handle != ACTION_RESULT_DONE) { @@ -3786,7 +3786,7 @@ HttpSM::do_hostdb_update_if_necessary() } // If we failed back over to the origin server, we don't have our // hostdb information anymore which means we shouldn't update the hostdb - if (!ink_inet_eq(&t_state.current.server->addr.sa, t_state.host_db_info.ip())) { + if (!ats_ip_addr_eq(&t_state.current.server->addr.sa, t_state.host_db_info.ip())) { Debug("http", "[%" PRId64 "] skipping hostdb update due to server failover", sm_id); return; } @@ -3813,12 +3813,12 @@ HttpSM::do_hostdb_update_if_necessary() } else { if (t_state.host_db_info.app.http_data.last_failure != 0) { t_state.host_db_info.app.http_data.last_failure = 0; - ink_inet_port_cast(&t_state.current.server->addr) = htons(t_state.current.server->port); + ats_ip_port_cast(&t_state.current.server->addr) = htons(t_state.current.server->port); issue_update |= 1; char addrbuf[INET6_ADDRPORTSTRLEN]; Debug("http", "[%" PRId64 "] hostdb update marking IP: %s as up", sm_id, - ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); } } @@ -3831,7 +3831,7 @@ HttpSM::do_hostdb_update_if_necessary() } char addrbuf[INET6_ADDRPORTSTRLEN]; - Debug("http", "server info = %s", ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); + Debug("http", "server info = %s", ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); return; } @@ -4076,7 +4076,7 @@ HttpSM::do_http_server_open(bool raw) opt.local_port = ua_session->outbound_port; opt.ip_family = ip_family; - InkInetAddr& outbound_ip = AF_INET6 == ip_family ? ua_session->outbound_ip6 : ua_session->outbound_ip4; + IpAddr& outbound_ip = AF_INET6 == ip_family ? ua_session->outbound_ip6 : ua_session->outbound_ip4; if (outbound_ip.isValid()) { opt.addr_binding = NetVCOptions::INTF_ADDR; opt.local_ip = outbound_ip; @@ -4090,7 +4090,7 @@ HttpSM::do_http_server_open(bool raw) char addrbuf[INET6_ADDRPORTSTRLEN]; Debug("http", "[%" PRId64 "] open connection to %s: %s", sm_id, t_state.current.server->name, - ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); if (plugin_tunnel) { PluginVCCore *t = plugin_tunnel; @@ -4168,8 +4168,8 @@ HttpSM::do_http_server_open(bool raw) HttpServerSession *existing_ss = ua_session->get_server_session(); if (existing_ss) { - // [amc] Is this OK? Should we compare ports? (not done by ink_inet_cmp) - if (ink_inet_cmp(&existing_ss->server_ip.sa, &t_state.current.server->addr.sa) == 0) { + // [amc] Is this OK? Should we compare ports? (not done by ats_ip_addr_cmp) + if (ats_ip_addr_cmp(&existing_ss->server_ip.sa, &t_state.current.server->addr.sa) == 0) { ua_session->attach_server_session(NULL); existing_ss->state = HSS_ACTIVE; this->attach_server_session(existing_ss); @@ -4221,7 +4221,7 @@ HttpSM::do_http_server_open(bool raw) char addrbuf[INET6_ADDRSTRLEN]; if (connections->getCount((t_state.current.server->addr)) >= t_state.txn_conf->origin_max_connections) { Debug("http", "[%" PRId64 "] over the number of connection for this host: %s", sm_id, - ink_inet_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); ink_debug_assert(pending_action == NULL); pending_action = eventProcessor.schedule_in(this, HRTIME_MSECONDS(100)); return; @@ -4407,7 +4407,7 @@ HttpSM::mark_host_failure(HostDBInfo * info, time_t time_down) char *url_str = t_state.hdr_info.client_request.url_string_get(&t_state.arena, 0); Log::error("CONNECT: could not connect to %s " "for '%s' (setting last failure time)", - ink_inet_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)), + ats_ip_ntop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf)), url_str ? url_str : "" ); if (url_str) @@ -4423,7 +4423,7 @@ HttpSM::mark_host_failure(HostDBInfo * info, time_t time_down) Debug("http", "[%" PRId64 "] hostdb update marking IP: %s as down", sm_id, - ink_inet_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_nptop(&t_state.current.server->addr.sa, addrbuf, sizeof(addrbuf))); } void @@ -6398,7 +6398,7 @@ HttpSM::set_next_state() } else if (t_state.http_config_param->use_client_target_addr && !t_state.url_remap_success && t_state.client_info.is_transparent - && ink_inet_is_ip(addr = t_state.state_machine->ua_session->get_netvc()->get_local_addr()) + && ats_is_ip(addr = t_state.state_machine->ua_session->get_netvc()->get_local_addr()) ) { ip_text_buffer ipb; /* If the connection is client side transparent and the URL @@ -6406,14 +6406,14 @@ HttpSM::set_next_state() address instead of doing a DNS lookup. This is controlled by the 'use_client_target_addr' configuration parameter. */ - Debug("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup for client supplied target %s.\n", ink_inet_ntop(addr, ipb, sizeof(ipb))); - ink_inet_copy(t_state.host_db_info.ip(), addr); + Debug("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup for client supplied target %s.\n", ats_ip_ntop(addr, ipb, sizeof(ipb))); + ats_ip_copy(t_state.host_db_info.ip(), addr); t_state.dns_info.lookup_success = true; call_transact_and_set_next_state(NULL); break; } else if (t_state.parent_result.r == PARENT_UNDEFINED && t_state.dns_info.lookup_success) { // Already set, and we don't have a parent proxy to lookup - ink_assert(ink_inet_is_ip(t_state.host_db_info.ip())); + ink_assert(ats_is_ip(t_state.host_db_info.ip())); Debug("dns", "[HttpTransact::HandleRequest] Skipping DNS lookup, provided by plugin"); call_transact_and_set_next_state(NULL); break; @@ -6421,7 +6421,7 @@ HttpSM::set_next_state() t_state.http_config_param->no_dns_forward_to_parent){ if (t_state.cop_test_page) - ink_inet_copy(t_state.host_db_info.ip(), t_state.state_machine->ua_session->get_netvc()->get_local_addr()); + ats_ip_copy(t_state.host_db_info.ip(), t_state.state_machine->ua_session->get_netvc()->get_local_addr()); t_state.dns_info.lookup_success = true; call_transact_and_set_next_state(NULL); diff --git a/proxy/http/HttpServerSession.cc b/proxy/http/HttpServerSession.cc index 4df4d8a9625..60783eba521 100644 --- a/proxy/http/HttpServerSession.cc +++ b/proxy/http/HttpServerSession.cc @@ -81,7 +81,7 @@ HttpServerSession::new_connection(NetVConnection *new_vc) char addrbuf[INET6_ADDRSTRLEN]; Debug("http_ss", "[%" PRId64 "] new connection, ip: %s, count: %u", con_id, - ink_inet_ntop(&server_ip.sa, addrbuf, sizeof(addrbuf)), connection_count->getCount(server_ip)); + ats_ip_ntop(&server_ip.sa, addrbuf, sizeof(addrbuf)), connection_count->getCount(server_ip)); } #ifdef LAZY_BUF_ALLOC read_buffer = new_empty_MIOBuffer(HTTP_SERVER_RESP_HDR_BUFFER_INDEX); @@ -134,7 +134,7 @@ HttpServerSession::do_io_close(int alerrno) char addrbuf[INET6_ADDRSTRLEN]; Debug("http_ss", "[%" PRId64 "] connection closed, ip: %s, count: %u", con_id, - ink_inet_ntop(&server_ip.sa, addrbuf, sizeof(addrbuf)), + ats_ip_ntop(&server_ip.sa, addrbuf, sizeof(addrbuf)), connection_count->getCount(server_ip)); } else { Error("[%" PRId64 "] number of connections should be greater then zero: %u", diff --git a/proxy/http/HttpServerSession.h b/proxy/http/HttpServerSession.h index 82ddb2feb55..8078158f7e1 100644 --- a/proxy/http/HttpServerSession.h +++ b/proxy/http/HttpServerSession.h @@ -114,7 +114,7 @@ class HttpServerSession : public VConnection }; // Keys for matching hostnames - ts_ip_endpoint server_ip; + IpEndpoint server_ip; INK_MD5 hostname_hash; bool host_hash_computed; diff --git a/proxy/http/HttpSessionManager.cc b/proxy/http/HttpSessionManager.cc index f341e7142c8..c49e0e9c614 100644 --- a/proxy/http/HttpSessionManager.cc +++ b/proxy/http/HttpSessionManager.cc @@ -36,8 +36,8 @@ #include "HttpSM.h" #include "HttpDebugNames.h" -#define FIRST_LEVEL_HASH(x) ink_inet_hash(x) % HSM_LEVEL1_BUCKETS -#define SECOND_LEVEL_HASH(x) ink_inet_hash(x) % HSM_LEVEL2_BUCKETS +#define FIRST_LEVEL_HASH(x) ats_ip_hash(x) % HSM_LEVEL1_BUCKETS +#define SECOND_LEVEL_HASH(x) ats_ip_hash(x) % HSM_LEVEL2_BUCKETS // Initialize a thread to handle HTTP session management void @@ -190,8 +190,8 @@ _acquire_session(SessionBucket *bucket, sockaddr const* ip, INK_MD5 &hostname_ha // the 2nd level bucket b = bucket->l2_hash[l2_index].head; while (b != NULL) { - if (ink_inet_eq(&b->server_ip.sa, ip) && - ink_inet_port_cast(ip) == ink_inet_port_cast(&b->server_ip) + if (ats_ip_addr_eq(&b->server_ip.sa, ip) && + ats_ip_port_cast(ip) == ats_ip_port_cast(&b->server_ip) ) { if (hostname_hash == b->hostname_hash) { bucket->lru_list.remove(b); @@ -236,8 +236,8 @@ HttpSessionManager::acquire_session(Continuation *cont, sockaddr const* ip, if (to_return != NULL) { ua_session->attach_server_session(NULL); - if (ink_inet_eq(&to_return->server_ip.sa, ip) && - ink_inet_port_cast(&to_return->server_ip) == ink_inet_port_cast(ip) + if (ats_ip_addr_eq(&to_return->server_ip.sa, ip) && + ats_ip_port_cast(&to_return->server_ip) == ats_ip_port_cast(ip) ) { if (!hash_computed) { ink_code_MMH((unsigned char *) hostname, strlen(hostname), (unsigned char *) &hostname_hash); diff --git a/proxy/http/HttpTransact.cc b/proxy/http/HttpTransact.cc index bb983b36f1b..5f888e01def 100644 --- a/proxy/http/HttpTransact.cc +++ b/proxy/http/HttpTransact.cc @@ -318,7 +318,7 @@ find_server_and_update_current_info(HttpTransact::State* s) // to go the origin server, we can only obey this if we // dns'ed the origin server if (s->parent_result.r == PARENT_DIRECT && s->http_config_param->no_dns_forward_to_parent != 0) { - ink_assert(!ink_inet_is_ip(&s->server_info.addr)); + ink_assert(!ats_is_ip(&s->server_info.addr)); s->parent_result.r = PARENT_FAIL; } break; @@ -1220,10 +1220,10 @@ HttpTransact::HandleRequest(State* s) // we need to see if the hostname is an // ip address since the parent selection code result // could change as a result of this ip address - ts_ip_endpoint addr; - ink_inet_pton(s->server_info.name, &addr); - if (ink_inet_is_ip(&addr)) { - ink_inet_copy(&s->request_data.dest_ip, &addr); + IpEndpoint addr; + ats_ip_pton(s->server_info.name, &addr); + if (ats_is_ip(&addr)) { + ats_ip_copy(&s->request_data.dest_ip, &addr); } if (s->parent_params->parentExists(&s->request_data)) { @@ -1231,7 +1231,7 @@ HttpTransact::HandleRequest(State* s) // DNS service available, we just want to forward the request // the parent proxy. In this case, we never find out the // origin server's ip. So just skip past OSDNS - ink_inet_invalidate(&s->server_info.addr); + ats_ip_invalidate(&s->server_info.addr); StartAccessControl(s); return; } else if (s->http_config_param->no_origin_server_dns) { @@ -1383,7 +1383,7 @@ HttpTransact::PPDNSLookup(State* s) if (!s->dns_info.lookup_success) { // DNS lookup of parent failed, find next parent or o.s. find_server_and_update_current_info(s); - if (!ink_inet_is_ip(&s->current.server->addr)) { + if (!ats_is_ip(&s->current.server->addr)) { if (s->current.request_to == PARENT_PROXY) { TRANSACT_RETURN(DNS_LOOKUP, PPDNSLookup); } else { @@ -1396,13 +1396,13 @@ HttpTransact::PPDNSLookup(State* s) } } else { // lookup succeeded, open connection to p.p. - ink_inet_copy(&s->parent_info.addr, s->host_db_info.ip()); + ats_ip_copy(&s->parent_info.addr, s->host_db_info.ip()); get_ka_info_from_host_db(s, &s->parent_info, &s->client_info, &s->host_db_info); s->parent_info.dns_round_robin = s->dns_info.round_robin; char addrbuf[INET6_ADDRSTRLEN]; Debug("http_trans", "[PPDNSLookup] DNS lookup for sm_id[%"PRId64"] successful IP: %s", - s->state_machine->sm_id, ink_inet_ntop(&s->parent_info.addr.sa, addrbuf, sizeof(addrbuf))); + s->state_machine->sm_id, ats_ip_ntop(&s->parent_info.addr.sa, addrbuf, sizeof(addrbuf))); } // Since this function can be called serveral times while retrying @@ -1451,14 +1451,14 @@ HttpTransact::ReDNSRoundRobin(State* s) // Our ReDNS of the server succeeeded so update the necessary // information and try again - ink_inet_copy(&s->server_info.addr, s->host_db_info.ip()); - ink_inet_copy(&s->request_data.dest_ip, &s->server_info.addr); + ats_ip_copy(&s->server_info.addr, s->host_db_info.ip()); + ats_ip_copy(&s->request_data.dest_ip, &s->server_info.addr); get_ka_info_from_host_db(s, &s->server_info, &s->client_info, &s->host_db_info); s->server_info.dns_round_robin = s->dns_info.round_robin; char addrbuf[INET6_ADDRSTRLEN]; Debug("http_trans", "[ReDNSRoundRobin] DNS lookup for O.S. successful IP: %s", - ink_inet_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf))); s->next_action = how_to_open_connection(s); } else { @@ -1594,14 +1594,14 @@ HttpTransact::OSDNSLookup(State* s) // Check to see if can fullfill expect requests based on the cached // update some state variables with hostdb information that has // been provided. - ink_inet_copy(&s->server_info.addr, s->host_db_info.ip()); - ink_inet_copy(&s->request_data.dest_ip, &s->server_info.addr); + ats_ip_copy(&s->server_info.addr, s->host_db_info.ip()); + ats_ip_copy(&s->request_data.dest_ip, &s->server_info.addr); get_ka_info_from_host_db(s, &s->server_info, &s->client_info, &s->host_db_info); s->server_info.dns_round_robin = s->dns_info.round_robin; char addrbuf[INET6_ADDRSTRLEN]; Debug("http_trans", "[OSDNSLookup] DNS lookup for O.S. successful " - "IP: %s", ink_inet_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf))); + "IP: %s", ats_ip_ntop(&s->server_info.addr.sa, addrbuf, sizeof(addrbuf))); // so the dns lookup was a success, but the lookup succeeded on // a hostname which was expanded by the traffic server. we should @@ -2550,7 +2550,7 @@ HttpTransact::HandleCacheOpenReadHit(State* s) } if (server_up || s->stale_icp_lookup) { - if (!s->stale_icp_lookup && !ink_inet_is_ip(&s->current.server->addr)) { + if (!s->stale_icp_lookup && !ats_is_ip(&s->current.server->addr)) { // ink_release_assert(s->current.request_to == PARENT_PROXY || // s->http_config_param->no_dns_forward_to_parent != 0); @@ -2938,7 +2938,7 @@ HttpTransact::HandleCacheOpenReadMiss(State* s) if (!h->is_cache_control_set(HTTP_VALUE_ONLY_IF_CACHED)) { find_server_and_update_current_info(s); - if (!ink_inet_is_ip(&s->current.server->addr)) { + if (!ats_is_ip(&s->current.server->addr)) { ink_release_assert(s->current.request_to == PARENT_PROXY || s->http_config_param->no_dns_forward_to_parent != 0); if (s->current.request_to == PARENT_PROXY) { @@ -2983,14 +2983,14 @@ HttpTransact::HandleICPLookup(State* s) if (s->icp_lookup_success == true) { HTTP_INCREMENT_TRANS_STAT(http_icp_suggested_lookups_stat); Debug("http_trans", "[HandleICPLookup] Success, sending request to icp suggested host."); - ink_inet_ip4_set(&s->icp_info.addr, s->icp_ip_result.sin_addr.s_addr); + ats_ip4_set(&s->icp_info.addr, s->icp_ip_result.sin_addr.s_addr); s->icp_info.port = ntohs(s->icp_ip_result.sin_port); // TODO in this case we should go to the miss case // just a little shy about using goto's, that's all. ink_release_assert( (s->icp_info.port != s->client_info.port) || - (ink_inet_cmp(&s->icp_info.addr.sa, &Machine::instance()->ip.sa) != 0) + (ats_ip_addr_cmp(&s->icp_info.addr.sa, &Machine::instance()->ip.sa) != 0) ); // Since the ICPDNSLookup is not called, these two @@ -3016,7 +3016,7 @@ HttpTransact::HandleICPLookup(State* s) ink_zero(s->parent_info.addr); find_server_and_update_current_info(s); - if (!ink_inet_is_ip(&s->current.server->addr)) { + if (!ats_is_ip(&s->current.server->addr)) { if (s->current.request_to == PARENT_PROXY) { TRANSACT_RETURN(DNS_LOOKUP, PPDNSLookup); } else { @@ -3296,7 +3296,7 @@ HttpTransact::handle_response_from_icp_suggested_host(State* s) // send request to parent proxy now if there is // one or else directly to the origin server. find_server_and_update_current_info(s); - if (!ink_inet_is_ip(&s->current.server->addr)) { + if (!ats_is_ip(&s->current.server->addr)) { if (s->current.request_to == PARENT_PROXY) { TRANSACT_RETURN(DNS_LOOKUP, PPDNSLookup); } else { @@ -3362,7 +3362,7 @@ HttpTransact::handle_response_from_parent(State* s) char addrbuf[INET6_ADDRSTRLEN]; Debug("http_trans", "[%d] failed to connect to parent %s", s->current.attempts, - ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); // If the request is not retryable, just give up! if (!is_request_retryable(s)) { @@ -3571,8 +3571,8 @@ HttpTransact::delete_srv_entry(State* s, int max_retries) MUTEX_TRY_LOCK(lock, bucket_mutex, thread); if (lock) { - ts_ip_endpoint ip; - HostDBInfo *r = probe(bucket_mutex, md5, hostname, len, ink_inet_ip4_set(&ip.sa, INADDR_ANY, htons(port)), pDS, false, true); + IpEndpoint ip; + HostDBInfo *r = probe(bucket_mutex, md5, hostname, len, ats_ip4_set(&ip.sa, INADDR_ANY, htons(port)), pDS, false, true); if (r) { if (r->is_srv) { Debug("dns_srv", "Marking SRV records for %s [Origin: %s] as bad", hostname, s->dns_info.lookup_name); @@ -3622,7 +3622,7 @@ HttpTransact::delete_srv_entry(State* s, int max_retries) new_r->ip_timeout_interval = 45; /* good for 45 seconds, then lets re-validate? */ new_r->ip_timestamp = hostdb_current_interval; - ink_inet_invalidate(new_r->ip()); + ats_ip_invalidate(new_r->ip()); /* these go into the RR area */ int n = new_r->srv_count; @@ -3637,7 +3637,7 @@ HttpTransact::delete_srv_entry(State* s, int max_retries) int i = 0; while ((srv_entry = still_ok_hosts.dequeue())) { Debug("dns_srv", "Re-adding %s to HostDB [as a RR] after %s failed", srv_entry->getHost(), s->dns_info.lookup_name); - ink_inet_invalidate(rr_data->info[i].ip()); + ats_ip_invalidate(rr_data->info[i].ip()); rr_data->info[i].round_robin = 0; rr_data->info[i].reverse_dns = 0; @@ -3690,7 +3690,7 @@ HttpTransact::delete_server_rr_entry(State* s, int max_retries) if (diags->on()) { DebugOn("http_trans", "[%d] failed to connect to %s", s->current.attempts, - ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); DebugOn("http_trans", "[delete_server_rr_entry] marking rr entry " "down and finding next one"); } ink_debug_assert(s->current.server->connect_failure); @@ -3726,7 +3726,7 @@ HttpTransact::retry_server_connection_not_open(State* s, ServerState_t conn_stat char *url_string = s->hdr_info.client_request.url_string_get(&s->arena); Debug("http_trans", "[%d] failed to connect [%d] to %s", s->current.attempts, conn_state, - ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); + ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf))); ////////////////////////////////////////// // on the first connect attempt failure // @@ -3736,7 +3736,7 @@ HttpTransact::retry_server_connection_not_open(State* s, ServerState_t conn_stat Log::error("CONNECT:[%d] could not connect [%s] to %s for '%s'", s->current.attempts, HttpDebugNames::get_server_state_name(conn_state), - ink_inet_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)), url_string ? url_string : "" + ats_ip_ntop(&s->current.server->addr.sa, addrbuf, sizeof(addrbuf)), url_string ? url_string : "" ); if (url_string) { @@ -5172,11 +5172,11 @@ HttpTransact::add_client_ip_to_outgoing_request(State* s, HTTPHdr* request) char ip_string[INET6_ADDRSTRLEN + 1] = {'\0'}; size_t ip_string_size = 0; - if (!ink_inet_is_ip(&s->client_info.addr.sa)) + if (!ats_is_ip(&s->client_info.addr.sa)) return; // Always prepare the IP string. - if (ink_inet_ntop(&s->client_info.addr.sa, ip_string, sizeof(ip_string)) != NULL) { + if (ats_ip_ntop(&s->client_info.addr.sa, ip_string, sizeof(ip_string)) != NULL) { ip_string_size += strlen(ip_string); } else { // Failure, omg @@ -5691,7 +5691,7 @@ HttpTransact::initialize_state_variables_from_request(State* s, HTTPHdr* obsolet } s->request_data.hdr = &s->hdr_info.client_request; s->request_data.hostname_str = s->arena.str_store(host_name, host_len); - ink_inet_copy(&s->request_data.src_ip, &s->client_info.addr); + ats_ip_copy(&s->request_data.src_ip, &s->client_info.addr); memset(&s->request_data.dest_ip, 0, sizeof(s->request_data.dest_ip)); if (s->state_machine->ua_session) { s->request_data.incoming_port = s->state_machine->ua_session->get_netvc()->get_local_port(); @@ -6583,7 +6583,7 @@ HttpTransact::process_quick_http_filter(State* s, int method) } // Exempt for "localhost", avoid denying for localhost. - if (ink_inet_is_loopback(&s->client_info.addr)) { + if (ats_is_ip_loopback(&s->client_info.addr)) { return; } @@ -6695,9 +6695,9 @@ HttpTransact::will_this_request_self_loop(State* s) // check if we are about to self loop // //////////////////////////////////////// if (s->dns_info.lookup_success) { - if (ink_inet_eq(s->host_db_info.ip(), &Machine::instance()->ip.sa)) { + if (ats_ip_addr_eq(s->host_db_info.ip(), &Machine::instance()->ip.sa)) { uint16_t host_port = s->hdr_info.client_request.url_get()->port_get(); - uint16_t local_port = ink_inet_get_port(&s->client_info.addr); + uint16_t local_port = ats_ip_port_host_order(&s->client_info.addr); if (host_port == local_port) { switch (s->dns_info.looking_up) { case ORIGIN_SERVER: @@ -6721,7 +6721,7 @@ HttpTransact::will_this_request_self_loop(State* s) // Now check for a loop using the Via string. // Since we insert our ip_address (in hex) into outgoing Via strings, // look for our_ip address in the request's via string. - if (ink_inet_is_ip(&Machine::instance()->ip)) { + if (ats_is_ip(&Machine::instance()->ip)) { MIMEField *via_field = s->hdr_info.client_request.field_find(MIME_FIELD_VIA, MIME_LEN_VIA); while (via_field) { @@ -8227,7 +8227,7 @@ HttpTransact::build_error_response(State *s, HTTPStatus status_code, const char char ip_string[INET6_ADDRSTRLEN]; Log::error("RESPONSE: sent %s status %d (%s) for '%s'", - ink_inet_ntop(&s->client_info.addr.sa, ip_string, sizeof(ip_string)), + ats_ip_ntop(&s->client_info.addr.sa, ip_string, sizeof(ip_string)), status_code, reason_phrase, (url_string ? url_string : "")); diff --git a/proxy/http/HttpTransact.h b/proxy/http/HttpTransact.h index bc0becfe09a..a6593490feb 100644 --- a/proxy/http/HttpTransact.h +++ b/proxy/http/HttpTransact.h @@ -780,7 +780,7 @@ class HttpTransact bool connect_failure; TransferEncoding_t transfer_encoding; - ts_ip_endpoint addr; // replaces 'ip' field + IpEndpoint addr; // replaces 'ip' field // port to connect to, except for client // connection where it is port on proxy diff --git a/proxy/http/HttpUpdateSM.cc b/proxy/http/HttpUpdateSM.cc index 84328cd9546..6f2dd98e556 100644 --- a/proxy/http/HttpUpdateSM.cc +++ b/proxy/http/HttpUpdateSM.cc @@ -75,7 +75,7 @@ HttpUpdateSM::start_scheduled_update(Continuation * cont, HTTPHdr * request) // Fix ME: What should these be set to since there is not a // real client - ink_inet_ip4_set(&t_state.client_info.addr, htonl(INADDR_LOOPBACK), 0); + ats_ip4_set(&t_state.client_info.addr, htonl(INADDR_LOOPBACK), 0); t_state.backdoor_request = 0; t_state.client_info.port_attribute = HttpProxyPort::TRANSPORT_DEFAULT; diff --git a/proxy/http/remap/AclFiltering.cc b/proxy/http/remap/AclFiltering.cc index 14e1843a8d3..105eeffb2c7 100644 --- a/proxy/http/remap/AclFiltering.cc +++ b/proxy/http/remap/AclFiltering.cc @@ -102,8 +102,8 @@ acl_filter_rule::print(void) for (i = 0; i < src_ip_cnt; i++) { ip_text_buffer b1, b2; printf("%s - %s" - , ink_inet_ntop(&src_ip_array[i].start.sa, b1, sizeof(b1)) - , ink_inet_ntop(&src_ip_array[i].end.sa, b2, sizeof(b2)) + , ats_ip_ntop(&src_ip_array[i].start.sa, b1, sizeof(b1)) + , ats_ip_ntop(&src_ip_array[i].end.sa, b2, sizeof(b2)) ); } for (i = 0; i < argc; i++) { diff --git a/proxy/http/remap/AclFiltering.h b/proxy/http/remap/AclFiltering.h index 992411d6f9e..4dd684ab0e1 100644 --- a/proxy/http/remap/AclFiltering.h +++ b/proxy/http/remap/AclFiltering.h @@ -35,8 +35,8 @@ static int const ACL_FILTER_MAX_SRC_IP = 128; static int const ACL_FILTER_MAX_ARGV = 512; struct src_ip_info_t { - ts_ip_endpoint start; ///< Minimum value in range. - ts_ip_endpoint end; ///< Maximum value in range. + IpEndpoint start; ///< Minimum value in range. + IpEndpoint end; ///< Maximum value in range. bool invert; ///< Should we "invert" the meaning of this IP range ("not in range") void reset() { @@ -46,8 +46,8 @@ struct src_ip_info_t { } /// @return @c true if @a ip is inside @a this range. - bool contains(ts_ip_endpoint const& ip) { - return ink_inet_cmp(&start, &ip) <= 0 && ink_inet_cmp(&ip, &end) <= 0; + bool contains(IpEndpoint const& ip) { + return ats_ip_addr_cmp(&start, &ip) <= 0 && ats_ip_addr_cmp(&ip, &end) <= 0; } }; diff --git a/proxy/http/remap/RemapProcessor.cc b/proxy/http/remap/RemapProcessor.cc index 8cf8449cc94..16893bbcd93 100644 --- a/proxy/http/remap/RemapProcessor.cc +++ b/proxy/http/remap/RemapProcessor.cc @@ -90,8 +90,8 @@ RemapProcessor::setup_for_remap(HttpTransact::State *s) if (rewrite_table->num_rules_forward_with_recv_port) { Debug("url_rewrite", "[lookup] forward mappings with recv port found; Using recv port %d", - ink_inet_get_port(&s->client_info.addr)); - if (rewrite_table->forwardMappingWithRecvPortLookup(request_url, ink_inet_get_port(&s->client_info.addr), + ats_ip_port_host_order(&s->client_info.addr)); + if (rewrite_table->forwardMappingWithRecvPortLookup(request_url, ats_ip_port_host_order(&s->client_info.addr), request_host, request_host_len, s->url_map)) { Debug("url_rewrite", "Found forward mapping with recv port"); mapping_found = true; diff --git a/proxy/http/remap/UrlRewrite.cc b/proxy/http/remap/UrlRewrite.cc index dde8b5e0814..eda4bfcb97c 100644 --- a/proxy/http/remap/UrlRewrite.cc +++ b/proxy/http/remap/UrlRewrite.cc @@ -847,7 +847,7 @@ UrlRewrite::PerformACLFiltering(HttpTransact::State *s, url_mapping *map) i = (method = s->hdr_info.client_request.method_get_wksidx()) - HTTP_WKSIDX_CONNECT; if (likely(i >= 0 && i < ACL_FILTER_MAX_METHODS)) { bool client_enabled_flag = true; - ink_release_assert(ink_inet_is_ip(&s->client_info.addr)); + ink_release_assert(ats_is_ip(&s->client_info.addr)); for (acl_filter_rule * rp = map->filter; rp; rp = rp->next) { bool match = true; if (rp->method_valid) { diff --git a/proxy/logging/LogAccess.cc b/proxy/logging/LogAccess.cc index b65cd54a106..64aec919517 100644 --- a/proxy/logging/LogAccess.cc +++ b/proxy/logging/LogAccess.cc @@ -795,16 +795,16 @@ int LogAccess::marshal_ip(char* dest, sockaddr const* ip) { LogFieldIpStorage data; int len = sizeof(data._ip); - if (ink_inet_is_ip4(ip)) { + if (ats_is_ip4(ip)) { if (dest) { data._ip4._family = AF_INET; - data._ip4._addr = ink_inet_ip4_addr_cast(ip); + data._ip4._addr = ats_ip4_addr_cast(ip); } len = sizeof(data._ip4); - } else if (ink_inet_is_ip6(ip)) { + } else if (ats_is_ip6(ip)) { if (dest) { data._ip6._family = AF_INET6; - data._ip6._addr = ink_inet_ip6_addr_cast(ip); + data._ip6._addr = ats_ip6_addr_cast(ip); } len = sizeof(data._ip6); } else { @@ -1139,7 +1139,7 @@ LogAccess::unmarshal_http_status(char **buf, char *dest, int len) Retrieve an IP address directly. -------------------------------------------------------------------------*/ int -LogAccess::unmarshal_ip(char **buf, ts_ip_endpoint* dest) +LogAccess::unmarshal_ip(char **buf, IpEndpoint* dest) { int len = sizeof(LogFieldIp); // of object processed. @@ -1150,14 +1150,14 @@ LogAccess::unmarshal_ip(char **buf, ts_ip_endpoint* dest) LogFieldIp* raw = reinterpret_cast(*buf); if (AF_INET == raw->_family) { LogFieldIp4* ip4 = static_cast(raw); - ink_inet_ip4_set(dest, ip4->_addr); + ats_ip4_set(dest, ip4->_addr); len = sizeof(*ip4); } else if (AF_INET6 == raw->_family) { LogFieldIp6* ip6 = static_cast(raw); - ink_inet_ip6_set(dest, ip6->_addr); + ats_ip6_set(dest, ip6->_addr); len = sizeof(*ip6); } else { - ink_inet_invalidate(dest); + ats_ip_invalidate(dest); } len = INK_ALIGN_DEFAULT(len); *buf += len; @@ -1175,10 +1175,10 @@ LogAccess::unmarshal_ip(char **buf, ts_ip_endpoint* dest) int LogAccess::unmarshal_ip_to_str(char **buf, char *dest, int len) { - ts_ip_endpoint ip; + IpEndpoint ip; unmarshal_ip(buf, &ip); - return ink_inet_ntop(&ip, dest, len) ? ::strlen(dest) : -1; + return ats_ip_ntop(&ip, dest, len) ? ::strlen(dest) : -1; } /*------------------------------------------------------------------------- @@ -1192,9 +1192,9 @@ LogAccess::unmarshal_ip_to_str(char **buf, char *dest, int len) int LogAccess::unmarshal_ip_to_hex(char **buf, char *dest, int len) { - ts_ip_endpoint ip; + IpEndpoint ip; unmarshal_ip(buf, &ip); - return ink_inet_to_hex(&ip.sa, dest, len); + return ats_ip_to_hex(&ip.sa, dest, len); } /*------------------------------------------------------------------------- diff --git a/proxy/logging/LogAccess.h b/proxy/logging/LogAccess.h index bc9e5ef7d8f..5c0102f4fd7 100644 --- a/proxy/logging/LogAccess.h +++ b/proxy/logging/LogAccess.h @@ -278,7 +278,7 @@ class LogAccess static int unmarshal_http_version(char **buf, char *dest, int len); static int unmarshal_http_text(char **buf, char *dest, int len); static int unmarshal_http_status(char **buf, char *dest, int len); - static int unmarshal_ip(char** buf, ts_ip_endpoint* dest); + static int unmarshal_ip(char** buf, IpEndpoint* dest); static int unmarshal_ip_to_str(char **buf, char *dest, int len); static int unmarshal_ip_to_hex(char** buf, char* dest, int len); static int unmarshal_hierarchy(char **buf, char *dest, int len, Ptr map); diff --git a/proxy/logging/LogAccessHttp.cc b/proxy/logging/LogAccessHttp.cc index 60aaa852937..a0e71c6d185 100644 --- a/proxy/logging/LogAccessHttp.cc +++ b/proxy/logging/LogAccessHttp.cc @@ -662,10 +662,10 @@ LogAccessHttp::marshal_server_host_ip(char *buf) { sockaddr const* ip = 0; ip = &m_http_sm->t_state.server_info.addr.sa; - if (! ink_inet_is_ip(ip)) { + if (! ats_is_ip(ip)) { if (m_http_sm->t_state.current.server) { ip = &m_http_sm->t_state.current.server->addr.sa; - if (! ink_inet_is_ip(ip)) ip = 0; + if (! ats_is_ip(ip)) ip = 0; } else { ip = 0; } diff --git a/proxy/logging/LogAccessTest.cc b/proxy/logging/LogAccessTest.cc index 3947c9ac2f1..e24067d2f89 100644 --- a/proxy/logging/LogAccessTest.cc +++ b/proxy/logging/LogAccessTest.cc @@ -67,8 +67,8 @@ LogAccessTest::~LogAccessTest() int LogAccessTest::marshal_client_host_ip(char *buf) { - ts_ip_endpoint lo; - ink_inet_ip4_set(&lo, INADDR_LOOPBACK); + IpEndpoint lo; + ats_ip4_set(&lo, INADDR_LOOPBACK); return marshal_ip(buf, &lo.sa); } @@ -316,8 +316,8 @@ LogAccessTest::marshal_proxy_hierarchy_route(char *buf) int LogAccessTest::marshal_server_host_ip(char *buf) { - ts_ip_endpoint lo; - ink_inet_ip4_set(&lo, INADDR_LOOPBACK); + IpEndpoint lo; + ats_ip4_set(&lo, INADDR_LOOPBACK); return marshal_ip(buf, &lo.sa); } diff --git a/proxy/logging/LogCollationClientSM.cc b/proxy/logging/LogCollationClientSM.cc index f581047d204..ced2c4ce6aa 100644 --- a/proxy/logging/LogCollationClientSM.cc +++ b/proxy/logging/LogCollationClientSM.cc @@ -315,9 +315,9 @@ LogCollationClientSM::client_dns(int event, HostDBInfo * hostdb_info) return client_done(LOG_COLL_EVENT_SWITCH, NULL); } // careful!!! could have problems later!!! - m_log_host->m_ip = ink_inet_ip4_addr_cast(hostdb_info->ip()); + m_log_host->m_ip = ats_ip4_addr_cast(hostdb_info->ip()); m_log_host->m_ipstr = (char *)ats_malloc(INET6_ADDRSTRLEN); - ink_inet_ntop(hostdb_info->ip(), m_log_host->m_ipstr, INET6_ADDRSTRLEN); + ats_ip_ntop(hostdb_info->ip(), m_log_host->m_ipstr, INET6_ADDRSTRLEN); return client_open(LOG_COLL_EVENT_SWITCH, NULL);