#include "util/log.h"
Defines | |
#define | BIT_CD 0x0010 |
DNS constants for uint16_t style flag manipulation. | |
#define | BIT_AD 0x0020 |
AD flag. | |
#define | BIT_Z 0x0040 |
Z flag. | |
#define | BIT_RA 0x0080 |
RA flag. | |
#define | BIT_RD 0x0100 |
RD flag. | |
#define | BIT_TC 0x0200 |
TC flag. | |
#define | BIT_AA 0x0400 |
AA flag. | |
#define | BIT_QR 0x8000 |
QR flag. | |
#define | FLAGS_GET_RCODE(f) ((f) & 0xf) |
get RCODE bits from uint16 flags | |
#define | FLAGS_SET_RCODE(f, r) (f = (((f) & 0xfff0) | (r))) |
set RCODE bits in uint16 flags | |
#define | UDP_AUTH_QUERY_TIMEOUT 4 |
timeout in seconds for UDP queries to auth servers. | |
#define | TCP_AUTH_QUERY_TIMEOUT 30 |
timeout in seconds for TCP queries to auth servers. | |
#define | EDNS_ADVERTISED_VERSION 0 |
Advertised version of EDNS capabilities. | |
#define | EDNS_ADVERTISED_SIZE 4096 |
Advertised size of EDNS capabilities. | |
#define | EDNS_DO 0x8000 |
bits for EDNS bitfield | |
#define | INET_SIZE 4 |
byte size of ip4 address | |
#define | INET6_SIZE 16 |
byte size of ip6 address | |
#define | DNSKEY_BIT_ZSK 0x0100 |
DNSKEY zone sign key flag. | |
#define | DNSKEY_BIT_SEP 0x0001 |
DNSKEY secure entry point, KSK flag. | |
Functions | |
int | str_is_ip6 (const char *str) |
See if string is ip4 or ip6. | |
int | write_socket (int s, const void *buf, size_t size) |
Write (blocking) to a nonblocking socket. | |
int | fd_set_nonblock (int s) |
Set fd nonblocking. | |
int | fd_set_block (int s) |
Set fd (back to) blocking. | |
int | is_pow2 (size_t num) |
See if number is a power of 2. | |
void * | memdup (void *data, size_t len) |
Allocate memory and copy over contents. | |
void | log_addr (enum verbosity_value v, const char *str, struct sockaddr_storage *addr, socklen_t addrlen) |
Prints the sockaddr in readable format with log_info. | |
void | log_name_addr (enum verbosity_value v, const char *str, uint8_t *zone, struct sockaddr_storage *addr, socklen_t addrlen) |
Prints zone name and sockaddr in readable format with log_info. | |
int | extstrtoaddr (const char *str, struct sockaddr_storage *addr, socklen_t *addrlen) |
Convert address string, with "@port" appendix, to sockaddr. | |
int | ipstrtoaddr (const char *ip, int port, struct sockaddr_storage *addr, socklen_t *addrlen) |
Convert ip address string and port to sockaddr. | |
int | netblockstrtoaddr (const char *ip, int port, struct sockaddr_storage *addr, socklen_t *addrlen, int *net) |
Convert ip netblock (ip/netsize) string and port to sockaddr. | |
void | log_nametypeclass (enum verbosity_value v, const char *str, uint8_t *name, uint16_t type, uint16_t dclass) |
Print string with neat domain name, type and class. | |
int | sockaddr_cmp (struct sockaddr_storage *addr1, socklen_t len1, struct sockaddr_storage *addr2, socklen_t len2) |
Compare two sockaddrs. | |
int | sockaddr_cmp_addr (struct sockaddr_storage *addr1, socklen_t len1, struct sockaddr_storage *addr2, socklen_t len2) |
Compare two sockaddrs. | |
int | addr_is_ip6 (struct sockaddr_storage *addr, socklen_t len) |
Checkout address family. | |
void | addr_mask (struct sockaddr_storage *addr, socklen_t len, int net) |
Make sure the sockaddr ends in zeroes. | |
int | addr_in_common (struct sockaddr_storage *addr1, int net1, struct sockaddr_storage *addr2, int net2, socklen_t addrlen) |
See how many bits are shared, equal, between two addrs. |
#define BIT_CD 0x0010 |
DNS constants for uint16_t style flag manipulation.
host byteorder. 1 1 1 1 1 1 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ |QR| Opcode |AA|TC|RD|RA| Z|AD|CD| RCODE | +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ CD flag
Referenced by answer_from_cache(), answer_norec_from_cache(), causes_cycle(), dns_cache_store(), error_encode(), generate_a_aaaa_check(), generate_ns_check(), generate_sub_request(), mesh_log_list(), mesh_send_reply(), mesh_state_compare(), mesh_state_create(), needs_validation(), outnet_serviced_query(), prime_trust_anchor(), process_response(), processDLVLookup(), processFindKey(), processQueryResponse(), processQueryTargets(), reply_info_answer_encode(), server_stats_insquery(), serviced_encode(), and val_new().
#define UDP_AUTH_QUERY_TIMEOUT 4 |
#define TCP_AUTH_QUERY_TIMEOUT 30 |
int str_is_ip6 | ( | const char * | str | ) |
See if string is ip4 or ip6.
str,: | IP specification. |
Referenced by calc_num46(), ipstrtoaddr(), listening_ports_open(), net_test(), netblockstrtoaddr(), outside_network_create(), service(), and ub_ctx_hosts().
int write_socket | ( | int | s, | |
const void * | buf, | |||
size_t | size | |||
) |
Write (blocking) to a nonblocking socket.
s,: | fd. Is set to be nonblocking at exit. | |
buf,: | data buffer. | |
size,: | length of data to send. |
References fd_set_block(), and fd_set_nonblock().
int fd_set_nonblock | ( | int | s | ) |
Set fd nonblocking.
s,: | file descriptor. |
References log_err().
Referenced by comm_point_perform_accept(), create_tcp_accept_sock(), create_udp_sock(), find_create_proxy(), outnet_tcp_take_into_use(), service(), service_tcp_listen(), tube_create(), tube_read_msg(), tube_write_msg(), and write_socket().
int fd_set_block | ( | int | s | ) |
Set fd (back to) blocking.
s,: | file descriptor. |
References log_err().
Referenced by handle_req(), tube_read_msg(), tube_write_msg(), and write_socket().
int is_pow2 | ( | size_t | num | ) |
See if number is a power of 2.
num,: | the value. |
Referenced by net_test().
void* memdup | ( | void * | data, | |
size_t | len | |||
) |
Allocate memory and copy over contents.
data,: | what to copy over. | |
len,: | length of data. |
Referenced by add_bg_result(), context_deserialize_answer(), dns_cache_store(), fill_res(), get_rr_content(), get_rr_nameclass(), infra_set_lame(), key_entry_copy(), libworker_fillup_fg(), lz_setup_implicit(), move_into_cache(), neg_insert_data(), neg_setup_data_node(), neg_setup_zone_node(), parse_arg_name(), parse_dname(), pending_udp_query(), qlist_add_line(), repinfo_copy_rrsets(), serviced_callbacks(), serviced_create(), setup_if(), tcp_relay_read(), worker_create(), and write_q().
void log_addr | ( | enum verbosity_value | v, | |
const char * | str, | |||
struct sockaddr_storage * | addr, | |||
socklen_t | addrlen | |||
) |
Prints the sockaddr in readable format with log_info.
Debug helper.
v,: | at what verbosity level to print this. | |
str,: | descriptive string printed with it. | |
addr,: | the sockaddr to print. Can be ip4 or ip6. | |
addrlen,: | length of addr. |
References verbose(), and verbosity.
Referenced by comm_point_perform_accept(), comm_point_send_udp_msg(), comm_point_send_udp_msg_if(), comm_point_tcp_handle_read(), comm_point_tcp_handle_write(), contact_server(), delegpt_log(), do_proxy(), iter_filter_unsuitable(), outnet_tcp_cb(), outnet_tcp_take_into_use(), outnet_udp_cb(), pending_find_match(), processQueryTargets(), remote_accept_callback(), run_scenario(), service_recv(), service_send(), service_tcp_listen(), service_tcp_relay(), serviced_callbacks(), serviced_tcp_callback(), serviced_udp_callback(), tcp_proxy_delete(), and worker_handle_request().
void log_name_addr | ( | enum verbosity_value | v, | |
const char * | str, | |||
uint8_t * | zone, | |||
struct sockaddr_storage * | addr, | |||
socklen_t | addrlen | |||
) |
Prints zone name and sockaddr in readable format with log_info.
Debug.
v,: | at what verbosity level to print this. | |
str,: | descriptive string printed with it. | |
zone,: | DNS domain name, uncompressed wireformat. | |
addr,: | the sockaddr to print. Can be ip4 or ip6. | |
addrlen,: | length of addr. |
References dname_str(), verbose(), and verbosity.
Referenced by process_response(), processQueryTargets(), and serviced_udp_callback().
int extstrtoaddr | ( | const char * | str, | |
struct sockaddr_storage * | addr, | |||
socklen_t * | addrlen | |||
) |
Convert address string, with "@port" appendix, to sockaddr.
Uses DNS port by default.
str,: | the string | |
addr,: | where to store sockaddr. | |
addrlen,: | length of stored sockaddr is returned. |
References ipstrtoaddr(), and MAX_ADDR_STRLEN.
Referenced by ah(), contact_server(), main(), open_svr(), read_fwds_addr(), read_stubs_addr(), replay_moment_read(), replay_range_read(), service(), ub_ctx_set_fwd(), and warn_hosts().
int ipstrtoaddr | ( | const char * | ip, | |
int | port, | |||
struct sockaddr_storage * | addr, | |||
socklen_t * | addrlen | |||
) |
Convert ip address string and port to sockaddr.
ip,: | ip4 or ip6 address string. | |
port,: | port number, host format. | |
addr,: | where to store sockaddr. | |
addrlen,: | length of stored sockaddr is returned. |
References str_is_ip6().
Referenced by cfg_ptr_reverse(), contact_server(), extstrtoaddr(), infra_test(), interfacechecks(), netblockstrtoaddr(), service(), and setup_if().
int netblockstrtoaddr | ( | const char * | ip, | |
int | port, | |||
struct sockaddr_storage * | addr, | |||
socklen_t * | addrlen, | |||
int * | net | |||
) |
Convert ip netblock (ip/netsize) string and port to sockaddr.
*SLOW*, does a malloc internally to avoid writing over 'ip' string.
ip,: | ip4 or ip6 address string. | |
port,: | port number, host format. | |
addr,: | where to store sockaddr. | |
addrlen,: | length of stored sockaddr is returned. | |
net,: | netblock size is returned. |
References addr_mask(), ipstrtoaddr(), log_err(), and str_is_ip6().
Referenced by acl_list_str_cfg(), aclchecks(), donotq_str_cfg(), and read_addrs().
void log_nametypeclass | ( | enum verbosity_value | v, | |
const char * | str, | |||
uint8_t * | name, | |||
uint16_t | type, | |||
uint16_t | dclass | |||
) |
Print string with neat domain name, type and class.
v,: | at what verbosity level to print this. | |
str,: | string of message. | |
name,: | domain name uncompressed wireformat. | |
type,: | host format RR type. | |
dclass,: | host format RR class. |
References dname_str(), log_info(), and verbosity.
Referenced by add_item(), anchor_store_new_rr(), cache_fill_missing(), check_zone_invariants(), dnskey_verify_rrset_sig(), generate_a_aaaa_check(), generate_ns_check(), generate_target_query(), get_random_data(), iter_mark_cycle_targets(), local_zone_out(), local_zones_print(), log_query_info(), lz_setup_implicit(), mesh_make_new_space(), neg_insert_data(), nsec3_do_prove_nameerror(), nsec3_prove_closest_encloser(), nsec3_prove_nameerror(), outnet_serviced_query(), prime_stub(), primeResponseToKE(), processDLVLookup(), processFindKey(), processInit(), processPrimeResponse(), processValidate(), remove_item(), remove_rrset(), scrub_message(), val_check_nonsecure(), val_dlv_init(), val_neg_addreferral(), val_neg_addreply(), val_neg_dlvlookup(), val_nsec_check_dlv(), val_verify_rrset(), validate_any_response(), validate_cname_response(), validate_msg_signatures(), validate_positive_response(), verifytest_file(), and verifytest_rrset().
int sockaddr_cmp | ( | struct sockaddr_storage * | addr1, | |
socklen_t | len1, | |||
struct sockaddr_storage * | addr2, | |||
socklen_t | len2 | |||
) |
Compare two sockaddrs.
Imposes an ordering on the addresses. Compares address and port.
addr1,: | address 1. | |
len1,: | lengths of addr1. | |
addr2,: | address 2. | |
len2,: | lengths of addr2. |
References INET6_SIZE, INET_SIZE, and log_assert.
Referenced by answer_check_it(), find_create_proxy(), infra_host_compfunc(), outnet_serviced_query(), pending_cmp(), pending_find_match(), pending_matches_current(), pending_tcp_query(), pending_udp_query(), and serviced_cmp().
int sockaddr_cmp_addr | ( | struct sockaddr_storage * | addr1, | |
socklen_t | len1, | |||
struct sockaddr_storage * | addr2, | |||
socklen_t | len2 | |||
) |
Compare two sockaddrs.
Compares address, not the port.
addr1,: | address 1. | |
len1,: | lengths of addr1. | |
addr2,: | address 2. | |
len2,: | lengths of addr2. |
References INET6_SIZE, INET_SIZE, and log_assert.
Referenced by addr_tree_compare(), and delegpt_find_addr().
int addr_is_ip6 | ( | struct sockaddr_storage * | addr, | |
socklen_t | len | |||
) |
Checkout address family.
addr,: | the sockaddr to examine. | |
len,: | the length of addr. return: true if sockaddr is ip6. |
Referenced by addr_in_common(), addr_mask(), addr_tree_lookup(), cfg_ptr_reverse(), contact_server(), delegpt_add_target(), hash_addr(), iter_filter_unsuitable(), open_svr(), outnet_tcp_take_into_use(), perfsetup(), proxy_list_clear(), randomize_and_send_udp(), server_stats_insquery(), service_recv(), service_tcp_listen(), udp_sockport(), and warn_hosts().
void addr_mask | ( | struct sockaddr_storage * | addr, | |
socklen_t | len, | |||
int | net | |||
) |
Make sure the sockaddr ends in zeroes.
For tree insertion and subsequent comparison.
addr,: | the ip4 or ip6 addr. | |
len,: | length of addr. | |
net,: | number of bits to leave untouched, the rest of the netblock address is zeroed. |
References addr_is_ip6().
Referenced by net_test(), and netblockstrtoaddr().
int addr_in_common | ( | struct sockaddr_storage * | addr1, | |
int | net1, | |||
struct sockaddr_storage * | addr2, | |||
int | net2, | |||
socklen_t | addrlen | |||
) |
See how many bits are shared, equal, between two addrs.
addr1,: | first addr. | |
net1,: | netblock size of first addr. | |
addr2,: | second addr. | |
net2,: | netblock size of second addr. | |
addrlen,: | length of first addr and of second addr. They must be of the same length (i.e. same type IP4, IP6). |
References addr_is_ip6(), log_assert, and match().
Referenced by addr_tree_init_parents(), addr_tree_lookup(), and net_test().