A brief file description. More...
#include "P_DNS.h"
#include <ts/ink_inet.h>
Go to the source code of this file.
Defines | |
#define | SRV_COST (RRFIXEDSZ+0) |
#define | SRV_WEIGHT (RRFIXEDSZ+2) |
#define | SRV_PORT (RRFIXEDSZ+4) |
#define | SRV_SERVER (RRFIXEDSZ+6) |
#define | SRV_FIXEDSZ (RRFIXEDSZ+6) |
Functions | |
static bool | dns_process (DNSHandler *handler, HostEnt *buf, int len) |
Decode the reply from "named". | |
static DNSEntry * | get_dns (DNSHandler *h, uint16_t id) |
Find a DNSEntry by id. | |
static void | dns_result (DNSHandler *h, DNSEntry *e, HostEnt *ent, bool retry) |
We have a result for an entry, return it to the user or retry if it is a retry-able and we have retries left. | |
static void | write_dns (DNSHandler *h) |
Write up to dns_max_dns_in_flight entries. | |
static bool | write_dns_event (DNSHandler *h, DNSEntry *e) |
Construct and Write the request for a single entry (using send(3N)). | |
static char * | strnchr (char *s, char c, int len) |
static uint16_t | ink_get16 (const uint8_t *src) |
void | make_ipv4_ptr (in_addr_t addr, char *buffer) |
void | make_ipv6_ptr (in6_addr const *addr, char *buffer) |
int | ink_dn_expand (const u_char *msg, const u_char *eom, const u_char *comp_dn, u_char *exp_dn, int length) |
Inter-OS portability for dn_expand. | |
static int | _ink_res_mkquery (ink_res_state res, char *qname, int qtype, char *buffer) |
static unsigned int | get_rcode (char *buff) |
static unsigned int | get_rcode (HostEnt *ent) |
static bool | good_rcode (char *buff) |
static DNSEntry * | get_entry (DNSHandler *h, char *qname, int qtype) |
Find a DNSEntry by query name and type. | |
void | ink_dns_init (ModuleVersion v) |
Variables | |
EventType | ET_DNS = ET_CALL |
int | dns_timeout = DEFAULT_DNS_TIMEOUT |
int | dns_retries = DEFAULT_DNS_RETRIES |
int | dns_search = DEFAULT_DNS_SEARCH |
int | dns_failover_number = DEFAULT_FAILOVER_NUMBER |
int | dns_failover_period = DEFAULT_FAILOVER_PERIOD |
int | dns_failover_try_period = DEFAULT_FAILOVER_TRY_PERIOD |
int | dns_max_dns_in_flight = MAX_DNS_IN_FLIGHT |
int | dns_validate_qname = 0 |
unsigned int | dns_handler_initialized = 0 |
int | dns_ns_rr = 0 |
int | dns_ns_rr_init_down = 1 |
char * | dns_ns_list = NULL |
char * | dns_resolv_conf = NULL |
char * | dns_local_ipv6 = NULL |
char * | dns_local_ipv4 = NULL |
int | dns_thread = 0 |
int | dns_prefer_ipv6 = 0 |
DNSProcessor | dnsProcessor |
ClassAllocator< DNSEntry > | dnsEntryAllocator ("dnsEntryAllocator") |
ClassAllocator< HostEnt > | dnsBufAllocator ("dnsBufAllocator", 2) |
static int | try_servers = 0 |
static int | local_num_entries = 1 |
static int | attempt_num_entries = 1 |
char | try_server_names [DEFAULT_NUM_TRY_SERVER][MAXDNAME] |
RecRawStatBlock * | dns_rsb |
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 DNS.cc.
#define SRV_COST (RRFIXEDSZ+0) |
Definition at line 31 of file DNS.cc.
Referenced by dns_process().
#define SRV_PORT (RRFIXEDSZ+4) |
Definition at line 33 of file DNS.cc.
Referenced by dns_process().
#define SRV_SERVER (RRFIXEDSZ+6) |
Definition at line 34 of file DNS.cc.
Referenced by dns_process().
#define SRV_WEIGHT (RRFIXEDSZ+2) |
Definition at line 32 of file DNS.cc.
Referenced by dns_process().
static int _ink_res_mkquery | ( | ink_res_state | res, | |
char * | qname, | |||
int | qtype, | |||
char * | buffer | |||
) | [inline, static] |
Definition at line 540 of file DNS.cc.
References ink_res_mkquery(), and MAX_DNS_PACKET_LEN.
Referenced by DNSHandler::retry_named(), DNSHandler::try_primary_named(), and write_dns_event().
static bool dns_process | ( | DNSHandler * | handler, | |
HostEnt * | buf, | |||
int | len | |||
) | [static] |
Decode the reply from "named".
Definition at line 1281 of file DNS.cc.
References align_pointer_forward(), attempt_num_entries, HostEnt::buf, countof, Debug, DEFAULT_NUM_TRY_SERVER, DNS_DECREMENT_DYN_STAT, DNS_HOSTBUF_SIZE, dns_in_flight_stat, DNS_INCREMENT_DYN_STAT, dns_lookup_fail_stat, DNS_MAX_ALIASES, dns_response_time_stat, dns_result(), DNS_SUM_DYN_STAT, dns_validate_qname, HostEnt::ent, get_dns(), HostEnt::h_addr_ptrs, HFIXEDSZ, SRV::host, HostEnt::host_aliases, HOST_DB_MAX_ROUND_ROBIN_INFO, SRV::host_len, HostEnt::hostbuf, SRVHosts::hosts, DNSHandler::in_flight, ink_assert, ink_dn_expand(), ink_get16(), ink_get_hrtime(), ink_ns_name_ntop(), ink_strlcpy(), SRV::key, local_num_entries, makeHostHash(), memcpy, Continuation::mutex, NS_GET16, NS_GET32, SRV::port, SRV::priority, DNSEntry::qname, DNSEntry::qname_len, DNSEntry::qtype, DNSEntry::send_time, SRV_COST, SRVHosts::srv_host_count, HostEnt::srv_hosts, SRVHosts::srv_hosts_length, SRV_PORT, SRV_SERVER, SRV_WEIGHT, try_server_names, try_servers, HostEnt::ttl, Warning, SRV::weight, and DNSEntry::written_flag.
Referenced by DNSHandler::recv_dns().
static void dns_result | ( | DNSHandler * | h, | |
DNSEntry * | e, | |||
HostEnt * | ent, | |||
bool | retry | |||
) | [static] |
We have a result for an entry, return it to the user or retry if it is a retry-able and we have retries left.
Definition at line 1113 of file DNS.cc.
References DNSEntry::action, BAD_DNS_RESULT, Action::cancel(), Action::cancelled, Debug, dns_fail_time_stat, DNS_INCREMENT_DYN_STAT, dns_lookup_fail_stat, dns_lookup_success_stat, dns_max_retries_exceeded_stat, DNS_PERIOD, dns_retries, dns_retries_stat, dns_success_time_stat, DNS_SUM_DYN_STAT, DNSEntry::domains, HostEnt::ent, DNSHandler::entries, DNSEntry::id, ink_get_hrtime(), ink_strlcpy(), is_debug_tag_set, DNSEntry::last, Action::mutex, Continuation::mutex, MUTEX_TRY_LOCK, DNSEntry::orig_qname_len, DNSEntry::post(), DNSEntry::postEvent(), DNSEntry::qname, DNSEntry::qname_len, DNSEntry::qtype, DNSHandler::release_query_id(), Queue< C, L >::remove(), DNSEntry::result_ent, DNSEntry::retries, EThread::schedule_imm_signal(), SET_CONTINUATION_HANDLER, DNSEntry::submit_thread, DNSEntry::submit_time, DNSEntry::timeout, and write_dns().
Referenced by dns_process(), DNSEntry::mainEvent(), and write_dns_event().
static DNSEntry * get_dns | ( | DNSHandler * | h, | |
uint16_t | id | |||
) | [inline, static] |
Find a DNSEntry by id.
Definition at line 847 of file DNS.cc.
References DNSHandler::entries, and DLL< C, L >::head.
Referenced by dns_process().
static DNSEntry* get_entry | ( | DNSHandler * | h, | |
char * | qname, | |||
int | qtype | |||
) | [inline, static] |
Find a DNSEntry by query name and type.
Definition at line 866 of file DNS.cc.
References DNSHandler::entries, and DLL< C, L >::head.
Referenced by DNSEntry::mainEvent().
static unsigned int get_rcode | ( | HostEnt * | ent | ) | [inline, static] |
Definition at line 716 of file DNS.cc.
References get_rcode().
static unsigned int get_rcode | ( | char * | buff | ) | [inline, static] |
Definition at line 712 of file DNS.cc.
Referenced by get_rcode(), good_rcode(), and DNSHandler::recv_dns().
static bool good_rcode | ( | char * | buff | ) | [static] |
Definition at line 721 of file DNS.cc.
References get_rcode().
Referenced by DNSHandler::recv_dns().
int ink_dn_expand | ( | const u_char * | msg, | |
const u_char * | eom, | |||
const u_char * | comp_dn, | |||
u_char * | exp_dn, | |||
int | length | |||
) | [inline] |
Inter-OS portability for dn_expand.
dn_expand() expands the compressed domain name comp_dn to a full domain name. Expanded names are converted to upper case. msg is a pointer to the beginning of the message, exp_dn is a pointer to a buffer of size length for the result. The size of compressed name is returned or -1 if there was an error.
Definition at line 336 of file DNS.cc.
Referenced by dns_process().
void ink_dns_init | ( | ModuleVersion | v | ) |
Definition at line 1605 of file DNS.cc.
References checkModuleVersion(), Debug, dns_fail_time_stat, dns_in_flight_stat, dns_lookup_fail_stat, dns_lookup_success_stat, dns_max_retries_exceeded_stat, dns_response_time_stat, dns_retries_stat, DNS_Stat_Count, dns_success_time_stat, dns_total_lookups_stat, HOSTDB_MODULE_VERSION, ink_release_assert, RecAllocateRawStatBlock(), RECD_INT, RECP_NON_PERSISTENT, RECP_PERSISTENT, RecRawStatSyncHrTimeAvg(), RecRawStatSyncSum(), RecRegisterRawStat, and RECT_PROCESS.
Referenced by main().
static uint16_t ink_get16 | ( | const uint8_t * | src | ) | [inline, static] |
void make_ipv4_ptr | ( | in_addr_t | addr, | |
char * | buffer | |||
) |
void make_ipv6_ptr | ( | in6_addr const * | addr, | |
char * | buffer | |||
) |
Definition at line 145 of file DNS.cc.
References ink_strlcpy(), and TS_IP6_SIZE.
Referenced by DNSEntry::init().
static char* strnchr | ( | char * | s, | |
char | c, | |||
int | len | |||
) | [inline, static] |
Definition at line 93 of file DNS.cc.
Referenced by DNSEntry::mainEvent().
static void write_dns | ( | DNSHandler * | h | ) | [static] |
Write up to dns_max_dns_in_flight entries.
Definition at line 882 of file DNS.cc.
References DNS_INCREMENT_DYN_STAT, dns_max_dns_in_flight, dns_ns_rr, dns_total_lookups_stat, DNSHandler::entries, DLL< C, L >::head, DNSHandler::in_flight, DNSHandler::in_write_dns, DNSHandler::m_res, MAX_NAMED, Continuation::mutex, DNSHandler::name_server, DNSHandler::ns_down, ts_imp_res_state::nscount, write_dns_event(), and DNSEntry::written_flag.
Referenced by dns_result(), DNSEntry::mainEvent(), and DNSHandler::mainEvent().
static bool write_dns_event | ( | DNSHandler * | h, | |
DNSEntry * | e | |||
) | [static] |
Construct and Write the request for a single entry (using send(3N)).
Definition at line 956 of file DNS.cc.
References _ink_res_mkquery(), Action::cancel(), DNSHandler::con, Debug, dns_in_flight_stat, DNS_INCREMENT_DYN_STAT, dns_ns_rr, dns_result(), dns_retries, dns_timeout, DNSHandler::failover(), DNSConnection::fd, DNSHandler::get_query_id(), HRTIME_MSECONDS, HRTIME_SECONDS, DNSEntry::id, DNSHandler::in_flight, ink_get_hrtime(), DNSHandler::m_res, Continuation::mutex, DNSHandler::name_server, DNSEntry::once_written_flag, DNSEntry::qname, DNSEntry::qtype, DNSHandler::release_query_id(), DNSEntry::retries, DNSHandler::rr_failure(), SocketManager::send(), DNSEntry::send_time, DNSHandler::sent_one(), socketManager, DNSEntry::timeout, DNSHandler::txn_lookup_timeout, DNSEntry::which_ns, and DNSEntry::written_flag.
Referenced by write_dns().
int attempt_num_entries = 1 [static] |
Definition at line 89 of file DNS.cc.
Referenced by dns_process().
int dns_failover_number = DEFAULT_FAILOVER_NUMBER |
Definition at line 45 of file DNS.cc.
Referenced by DNSHandler::sent_one(), and DNSProcessor::start().
int dns_failover_period = DEFAULT_FAILOVER_PERIOD |
Definition at line 46 of file DNS.cc.
Referenced by DNSHandler::failover_now(), and DNSProcessor::start().
int dns_failover_try_period = DEFAULT_FAILOVER_TRY_PERIOD |
Definition at line 47 of file DNS.cc.
Referenced by DNSHandler::failover_soon(), and DNSProcessor::start().
unsigned int dns_handler_initialized = 0 |
Definition at line 50 of file DNS.cc.
Referenced by DNSProcessor::open(), and DNSHandler::startEvent().
char* dns_local_ipv4 = NULL |
Definition at line 56 of file DNS.cc.
Referenced by DNSProcessor::dns_init(), and DNSProcessor::start().
char* dns_local_ipv6 = NULL |
Definition at line 55 of file DNS.cc.
Referenced by DNSProcessor::dns_init(), and DNSProcessor::start().
int dns_max_dns_in_flight = MAX_DNS_IN_FLIGHT |
Definition at line 48 of file DNS.cc.
Referenced by DNSProcessor::start(), and write_dns().
char* dns_ns_list = NULL |
Definition at line 53 of file DNS.cc.
Referenced by DNSProcessor::dns_init(), and DNSProcessor::start().
int dns_ns_rr = 0 |
Definition at line 51 of file DNS.cc.
Referenced by DNSProcessor::dns_init(), DNSHandler::mainEvent(), DNSHandler::open_con(), DNSHandler::recv_dns(), DNSProcessor::start(), DNSHandler::startEvent(), write_dns(), and write_dns_event().
int dns_ns_rr_init_down = 1 |
Definition at line 52 of file DNS.cc.
Referenced by DNSHandler::rr_failure(), and DNSHandler::startEvent().
int dns_prefer_ipv6 = 0 |
char* dns_resolv_conf = NULL |
Definition at line 54 of file DNS.cc.
Referenced by DNSProcessor::dns_init(), and DNSProcessor::start().
int dns_retries = DEFAULT_DNS_RETRIES |
Definition at line 43 of file DNS.cc.
Referenced by dns_result(), DNSProcessor::getby(), DNSHandler::rr_failure(), DNSProcessor::start(), DNSHandler::switch_named(), and write_dns_event().
int dns_search = DEFAULT_DNS_SEARCH |
Definition at line 44 of file DNS.cc.
Referenced by DNSEntry::mainEvent(), and DNSProcessor::start().
int dns_thread = 0 |
Definition at line 57 of file DNS.cc.
Referenced by DNSProcessor::start().
int dns_timeout = DEFAULT_DNS_TIMEOUT |
Definition at line 42 of file DNS.cc.
Referenced by DNSProcessor::start(), and write_dns_event().
int dns_validate_qname = 0 |
Definition at line 49 of file DNS.cc.
Referenced by dns_process(), and DNSProcessor::start().
ClassAllocator<HostEnt> dnsBufAllocator("dnsBufAllocator", 2) |
Referenced by HostEnt::free(), and DNSHandler::recv_dns().
ClassAllocator<DNSEntry> dnsEntryAllocator("dnsEntryAllocator") |
Referenced by DNSProcessor::getby(), and DNSEntry::postEvent().
Definition at line 69 of file DNS.cc.
Referenced by HostDBContinuation::do_dns(), get_hostinfo_ClusterFunction(), HostDBProcessor::getSRVbyname_imm(), main(), TestDnsStateMachine::processEvent(), put_hostinfo_ClusterFunction(), and TestProxy::startEvent().
Definition at line 37 of file DNS.cc.
Referenced by HostDBProcessor::start(), DNSProcessor::start(), and TSContSchedule().
int local_num_entries = 1 [static] |
Definition at line 88 of file DNS.cc.
Referenced by dns_process(), and DNSHandler::try_primary_named().
char try_server_names[DEFAULT_NUM_TRY_SERVER][MAXDNAME] |
Definition at line 90 of file DNS.cc.
Referenced by DNSProcessor::dns_init(), dns_process(), DNSHandler::retry_named(), and DNSHandler::try_primary_named().
int try_servers = 0 [static] |
Definition at line 87 of file DNS.cc.
Referenced by dns_process(), DNSHandler::retry_named(), and DNSHandler::try_primary_named().