A brief file description. More...
#include "libts.h"
#include "ts/TestBox.h"
Go to the source code of this file.
Data Structures | |
struct | ip_parse_spec |
Functions | |
struct hostent * | ink_gethostbyname_r (char *hostname, ink_gethostbyname_r_data *data) |
Wrapper for gethostbyname_r(). | |
struct hostent * | ink_gethostbyaddr_r (char *ip, int len, int type, ink_gethostbyaddr_r_data *data) |
Wrapper for gethostbyaddr_r(). | |
uint32_t | ink_inet_addr (const char *s) |
const char * | ats_ip_ntop (const struct sockaddr *addr, char *dst, size_t size) |
char const * | ats_ip_family_name (int family) |
Get a string name for an IP address family. | |
char const * | ats_ip_nptop (sockaddr const *addr, char *dst, size_t size) |
Write a null terminated string for addr to dst with port. | |
int | ats_ip_parse (ts::ConstBuffer src, ts::ConstBuffer *addr, ts::ConstBuffer *port) |
Parse a string for pieces of an IP address. | |
int | ats_ip_pton (const ts::ConstBuffer &src, sockaddr *ip) |
Convert text to an IP address and write it to addr. | |
uint32_t | ats_ip_hash (sockaddr const *addr) |
Generic IP address hash function. | |
int | ats_ip_to_hex (sockaddr const *src, char *dst, size_t len) |
Convert address to string as a hexidecimal value. | |
sockaddr * | ats_ip_set (sockaddr *dst, IpAddr const &addr, uint16_t port) |
bool | operator== (IpAddr const &lhs, sockaddr const *rhs) |
int | ats_ip_getbestaddrinfo (char const *host, IpEndpoint *ip4, IpEndpoint *ip6) |
int | ats_ip_check_characters (ts::ConstBuffer text) |
Check to see if a buffer contains only IP address characters. | |
REGRESSION_TEST() | Ink_Inet (RegressionTest *t, int, int *pstatus) |
A brief file description.
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Definition in file ink_inet.cc.
int ats_ip_check_characters | ( | ts::ConstBuffer | text | ) |
Check to see if a buffer contains only IP address characters.
Definition at line 458 of file ink_inet.cc.
References ts::ConstBuffer::data(), and ts::ConstBuffer::size().
Referenced by LogHost::set_name_or_ipstr().
char const* ats_ip_family_name | ( | int | family | ) |
Get a string name for an IP address family.
NULL
). Definition at line 176 of file ink_inet.cc.
Referenced by HttpSM::do_http_server_open(), and HttpProxyPort::processOptions().
int ats_ip_getbestaddrinfo | ( | char const * | host, | |
IpEndpoint * | ip4, | |||
IpEndpoint * | ip6 | |||
) |
[in] | host | Address name (IPv4, IPv6, or host name) |
[out] | ip4 | Storage for IPv4 address. |
[out] | ip6 | Storage for IPv6 address |
Definition at line 372 of file ink_inet.cc.
References ats_ip_copy(), ats_ip_invalidate(), ats_ip_parse(), ats_ip_port_cast(), ats_is_ip(), ats_is_ip4(), ats_is_ip6(), ats_is_ip_linklocal(), ats_is_ip_loopback(), ats_is_ip_multicast(), ats_is_ip_private(), ts::ConstBuffer::data(), memcpy, ts::ConstBuffer::set(), and ts::ConstBuffer::size().
Referenced by RecHttpLoadIp(), and setup_socks_servers().
uint32_t ats_ip_hash | ( | sockaddr const * | addr | ) |
Generic IP address hash function.
Definition at line 285 of file ink_inet.cc.
References ats_ip4_addr_cast(), ats_ip_addr8_cast(), ats_is_ip4(), ats_is_ip6(), ink_code_md5(), and TS_IP6_SIZE.
Referenced by ParentRecord::FindParent(), ServerSessionPool::IPHashing::hash(), ConnectionCount::ConnAddrHashFns::hash(), and KeepAliveConnTable::ip_hash().
char const* ats_ip_nptop | ( | const sockaddr * | addr, | |
char * | dst, | |||
size_t | size | |||
) |
Write a null terminated string for addr to dst with port.
A buffer of size INET6_ADDRPORTSTRLEN suffices, including a terminating nul.
addr | Address. | |
dst | Output buffer. | |
size | Length of buffer. |
Definition at line 183 of file ink_inet.cc.
References ats_ip_ntop(), and ats_ip_port_host_order().
Referenced by HttpSessionAccept::accept(), Http2SessionAccept::accept(), Server::accept(), ats_ip_nptop(), LogSock::connect(), LogHost::connect(), DNSConnection::connect(), UnixNetProcessor::connect_re_internal(), UDPNetProcessor::CreateUDPSocket(), DNSProcessor::dns_init(), HttpSM::do_hostdb_update_if_necessary(), HttpSM::do_http_server_open(), ParentSiblingPeer::ExpectedReplies(), ICPPeerReadCont::ICPPeerQueryCont(), ICPPeerReadCont::ICPPeerQueryEvent(), Peer::LogRecvMsg(), HttpSM::mark_host_failure(), DNSHandler::open_con(), ICPPeerReadCont::PeerReadStateMachine(), ICPPeerReadCont::StaleCheck(), SocksEntry::startEvent(), DNSHandler::startEvent(), and HttpSM::state_http_server_open().
const char* ats_ip_ntop | ( | const struct sockaddr * | addr, | |
char * | dst, | |||
size_t | size | |||
) |
Definition at line 156 of file ink_inet.cc.
References ats_ip4_addr_cast(), and ats_ip6_addr_cast().
Referenced by HttpSessionAccept::accept(), HttpTransact::add_client_ip_to_outgoing_request(), MultiCastPeer::AddMultiCastChild(), ats_ip_nptop(), ats_ip_ntop(), HttpTransact::build_error_response(), check_n_attach_prefetch_transform(), client_handler(), config_read_proto(), DNSConnection::connect(), HttpTransact::delete_server_rr_entry(), HttpSM::do_http_server_open(), HttpServerSession::do_io_close(), DNSHandler::failover(), SocksEntry::findServer(), CCCongestionDBTestCont::gen_CongestionEntry(), HttpTransact::handle_response_from_parent(), HttpTransact::HandleBlindTunnel(), KeepAliveConn::handleEvent(), IpMap_Fill(), IpMapTestPrint(), Machine::Machine(), HttpSM::mark_host_failure(), HttpServerSession::new_connection(), HttpTransact::OSDNSLookup(), ICPPeerReadCont::PeerReadStateMachine(), HttpTransact::PPDNSLookup(), IpAllow::Print(), IpMatcher< Data, Result >::Print(), acl_filter_rule::print(), CoreUtils::process_NetVC(), HttpTransact::process_quick_http_filter(), DNSHandler::recover(), DNSHandler::recv_dns(), HttpTransact::ReDNSRoundRobin(), remap_parse_config_bti(), remove_round_robin(), reply_to_cont(), HttpTransact::retry_server_connection_not_open(), DNSHandler::rr_failure(), HttpSM::set_next_state(), setup_socks_servers(), ShowNet::showConnectionsOnThread(), ShowHostDB::showLookupDone(), ShowHostDB::showOne(), CongestionEntry::sprint(), SSLDiagnostic(), IpAddr::toString(), LogAccess::unmarshal_ip_to_str(), and HttpSM::update_stats().
int ats_ip_parse | ( | ts::ConstBuffer | src, | |
ts::ConstBuffer * | addr, | |||
ts::ConstBuffer * | port | |||
) |
Parse a string for pieces of an IP address.
This doesn't parse the actual IP address, but picks it out from src. It is intended to deal with the brackets that can optionally surround an IP address (usually IPv6) which in turn are used to differentiate between an address and an attached port. E.g.
[FE80:9312::192:168:1:1]:80
addr or port can be NULL
in which case that value isn't returned.
[in] | src | String to search. |
[out] | addr | Range containing IP address. |
[out] | port | Range containing port. |
Definition at line 196 of file ink_inet.cc.
References ts::ConstBuffer::after(), ts::ConstBuffer::clip(), ts::ConstBuffer::data(), ts::ConstBuffer::find(), ts::ConstBuffer::reset(), and ts::ConstBuffer::splitOn().
Referenced by ats_ip_getbestaddrinfo(), ats_ip_pton(), Ink_Inet(), and LogHost::set_name_or_ipstr().
int ats_ip_pton | ( | const ts::ConstBuffer & | text, | |
sockaddr * | addr | |||
) |
Convert text to an IP address and write it to addr.
text is expected to be an explicit address, not a hostname. No hostname resolution is done. The call must provide an ip large enough to hold the address value.
This attempts to recognize and process a port value if present. The port in ip is set appropriately, or to zero if no port was found or it was malformed.
inet_pton
. getaddrinfo
internally and so involves memory allocation.[in] | src | text. |
[out] | ip | address |
Definition at line 249 of file ink_inet.cc.
References ats_ip4_set(), ats_ip6_set(), ats_ip_invalidate(), ats_ip_parse(), ats_ip_port_cast(), ats_is_ip(), ts::ConstBuffer::data(), ts::ConstBuffer::find(), memcpy, ts::ConstBuffer::set(), and ts::ConstBuffer::size().
Referenced by ats_ip_pton(), config_read_proto(), DNSProcessor::dns_init(), HttpSM::do_hostdb_reverse_lookup(), ExtractIpRange(), SocksEntry::findServer(), HttpTransact::HandleRequest(), PrefetchBlaster::init(), Ink_Inet(), IpMap_Fill(), IpMap_Unmark(), IpAddr::load(), PARENTSELECTION(), read_addr(), register_ShowHostDB(), register_ShowNet(), remove_congested_entry(), NetVCOptions::set_sni_servername(), and ssl_store_ssl_context().
sockaddr* ats_ip_set | ( | sockaddr * | dst, | |
IpAddr const & | addr, | |||
uint16_t | port | |||
) |
Definition at line 322 of file ink_inet.cc.
References IpAddr::_addr, IpAddr::_family, IpAddr::_ip4, IpAddr::_ip6, ats_ip4_set(), ats_ip6_set(), and ats_ip_invalidate().
Referenced by IpEndpoint::assign(), HostDBContinuation::lookup_done(), HostDBContinuation::make_get_message(), MultiCastPeer::MultiCastPeer(), and ParentSiblingPeer::ParentSiblingPeer().
int ats_ip_to_hex | ( | sockaddr const * | addr, | |
char * | dst, | |||
size_t | len | |||
) |
Convert address to string as a hexidecimal value.
The string is always nul terminated, the output string is clipped if dst is insufficient.
src | Address to convert. Must be IP. | |
dst | Destination buffer. | |
len | Length of dst. |
Definition at line 301 of file ink_inet.cc.
References ats_ip_addr8_cast(), ats_ip_addr_size(), ats_is_ip(), and ink_assert.
Referenced by Machine::Machine(), SSLAddressLookupKey::SSLAddressLookupKey(), and LogAccess::unmarshal_ip_to_hex().
struct hostent* ink_gethostbyaddr_r | ( | char * | ip, | |
int | len, | |||
int | type, | |||
ink_gethostbyaddr_r_data * | data | |||
) | [read] |
Wrapper for gethostbyaddr_r().
If successful, returns a pointer to the hostent structure. Returns NULL and sets data->herrno to the appropriate error code on failure.
ip | IP address of the host | |
len | length of the buffer indicated by ip | |
type | family of the address | |
data | pointer to ink_gethostbyname_r_data allocated by the caller |
Definition at line 68 of file ink_inet.cc.
References ink_gethostbyaddr_r_data::buf, ink_gethostbyaddr_r_data::ent, ink_gethostbyaddr_r_data::herrno, and INK_GETHOSTBYNAME_R_DATA_SIZE.
Referenced by ClusterMachine::ClusterMachine().
struct hostent* ink_gethostbyname_r | ( | char * | hostname, | |
ink_gethostbyname_r_data * | data | |||
) | [read] |
Wrapper for gethostbyname_r().
If successful, returns a pointer to the hostent structure. Returns NULL and sets data->herrno to the appropriate error code on failure.
hostname | null-terminated host name string | |
data | pointer to ink_gethostbyname_r_data allocated by the caller |
Definition at line 39 of file ink_inet.cc.
References ink_gethostbyname_r_data::buf, ink_gethostbyname_r_data::ent, ink_gethostbyname_r_data::herrno, and INK_GETHOSTBYNAME_R_DATA_SIZE.
Referenced by ClusterMachine::ClusterMachine().
REGRESSION_TEST() Ink_Inet | ( | RegressionTest * | t, | |
int | , | |||
int * | pstatus | |||
) |
Definition at line 479 of file ink_inet.cc.
References IpAddr::_addr, IpAddr::_ip4, IpAddr::_ip6, ats_ip_parse(), ats_ip_pton(), countof, ts::ConstBuffer::data(), IpEndpoint::family(), IpAddr::family(), ip_parse_spec::host, ip_parse_spec::hostspec, IpAddr::load(), ip_parse_spec::port, IpEndpoint::sa, IpEndpoint::sin, IpEndpoint::sin6, and ts::ConstBuffer::size().
uint32_t ink_inet_addr | ( | const char * | s | ) |
Definition at line 93 of file ink_inet.cc.
References ParseRules::ink_tolower(), ParseRules::is_digit(), ParseRules::is_hex(), and ParseRules::is_wslfcr().
Referenced by is_dotted_form_hostname().
bool operator== | ( | IpAddr const & | lhs, | |
sockaddr const * | rhs | |||
) |
Definition at line 357 of file ink_inet.cc.
References IpAddr::_addr, IpAddr::_family, IpAddr::_ip4, IpAddr::_ip6, ats_ip4_addr_cast(), and ats_ip6_addr_cast().