2013-08-15 11:33:05 -05:00
|
|
|
/**
|
|
|
|
*
|
2013-11-04 17:37:54 -06:00
|
|
|
* /brief type declarations private to the getdns library
|
2013-08-15 11:33:05 -05:00
|
|
|
*
|
2013-11-04 17:37:54 -06:00
|
|
|
* These type declarations are not meant to be used by applications calling
|
|
|
|
* the public library functions.
|
2013-08-15 11:33:05 -05:00
|
|
|
*/
|
2013-11-04 17:37:54 -06:00
|
|
|
|
|
|
|
/*
|
2014-02-25 07:12:33 -06:00
|
|
|
* Copyright (c) 2013, NLnet Labs, Verisign, Inc.
|
2013-11-04 17:37:54 -06:00
|
|
|
* All rights reserved.
|
2014-01-21 14:31:22 -06:00
|
|
|
*
|
2013-11-04 17:37:54 -06:00
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2014-02-25 07:23:19 -06:00
|
|
|
* * Neither the names of the copyright holders nor the
|
2013-11-04 17:37:54 -06:00
|
|
|
* names of its contributors may be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
2013-08-15 11:33:05 -05:00
|
|
|
*
|
2013-11-04 17:37:54 -06:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY
|
|
|
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2013-08-15 11:33:05 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef TYPES_INTERNAL_H_
|
|
|
|
#define TYPES_INTERNAL_H_
|
|
|
|
|
2014-05-19 08:50:34 -05:00
|
|
|
#include "getdns/getdns.h"
|
2014-10-06 16:04:12 -05:00
|
|
|
#include "getdns/getdns_extra.h"
|
2014-10-16 04:28:32 -05:00
|
|
|
#include "util/rbtree.h"
|
|
|
|
|
2014-10-19 15:51:42 -05:00
|
|
|
|
2015-09-30 09:05:19 -05:00
|
|
|
/**
|
|
|
|
* this structure represents a single item in a list or dict
|
|
|
|
*/
|
2015-10-01 08:43:17 -05:00
|
|
|
typedef union getdns_union {
|
|
|
|
void *ptr;
|
|
|
|
getdns_dict *dict;
|
|
|
|
getdns_list *list;
|
|
|
|
getdns_bindata *bindata;
|
|
|
|
uint32_t n;
|
|
|
|
} getdns_union;
|
|
|
|
|
2015-09-30 09:05:19 -05:00
|
|
|
typedef struct getdns_item {
|
|
|
|
getdns_data_type dtype;
|
2015-10-01 08:43:17 -05:00
|
|
|
getdns_union data;
|
2015-09-30 09:05:19 -05:00
|
|
|
} getdns_item;
|
|
|
|
|
|
|
|
|
2013-12-08 15:56:34 -06:00
|
|
|
struct getdns_context;
|
2014-10-15 14:00:57 -05:00
|
|
|
struct getdns_upstreams;
|
2014-10-15 16:57:24 -05:00
|
|
|
struct getdns_upstream;
|
2014-10-15 08:12:16 -05:00
|
|
|
|
2013-12-03 07:13:10 -06:00
|
|
|
/**
|
|
|
|
* \defgroup strings String Constants
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
#define GETDNS_STR_IPV4 "IPv4"
|
|
|
|
#define GETDNS_STR_IPV6 "IPv6"
|
|
|
|
#define GETDNS_STR_ADDRESS_TYPE "address_type"
|
|
|
|
#define GETDNS_STR_ADDRESS_DATA "address_data"
|
|
|
|
#define GETDNS_STR_PORT "port"
|
|
|
|
#define GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6 "return_both_v4_and_v6"
|
|
|
|
|
|
|
|
#define GETDNS_STR_KEY_STATUS "status"
|
|
|
|
#define GETDNS_STR_KEY_REPLIES_TREE "replies_tree"
|
|
|
|
#define GETDNS_STR_KEY_REPLIES_FULL "replies_full"
|
|
|
|
#define GETDNS_STR_KEY_JUST_ADDRS "just_address_answers"
|
|
|
|
#define GETDNS_STR_KEY_CANONICAL_NM "canonical_name"
|
|
|
|
#define GETDNS_STR_KEY_ANSWER_TYPE "answer_type"
|
|
|
|
#define GETDNS_STR_KEY_INTERM_ALIASES "intermediate_aliases"
|
|
|
|
#define GETDNS_STR_KEY_NAME "name"
|
|
|
|
#define GETDNS_STR_KEY_HEADER "header"
|
|
|
|
#define GETDNS_STR_KEY_QUESTION "question"
|
|
|
|
#define GETDNS_STR_KEY_ANSWER "answer"
|
|
|
|
#define GETDNS_STR_KEY_TYPE "type"
|
|
|
|
#define GETDNS_STR_KEY_CLASS "class"
|
|
|
|
#define GETDNS_STR_KEY_TTL "ttl"
|
|
|
|
#define GETDNS_STR_KEY_RDATA "rdata"
|
|
|
|
#define GETDNS_STR_KEY_V4_ADDR "ipv4_address"
|
|
|
|
#define GETDNS_STR_KEY_V6_ADDR "ipv6_address"
|
|
|
|
#define GETDNS_STR_KEY_RDATA_RAW "rdata_raw"
|
|
|
|
#define GETDNS_STR_KEY_AUTHORITY "authority"
|
|
|
|
#define GETDNS_STR_KEY_ADDITIONAL "additional"
|
|
|
|
#define GETDNS_STR_KEY_QTYPE "qtype"
|
|
|
|
#define GETDNS_STR_KEY_QCLASS "qclass"
|
|
|
|
#define GETDNS_STR_KEY_QNAME "qname"
|
2013-12-12 12:59:53 -06:00
|
|
|
#define GETDNS_STR_KEY_QR "qr"
|
|
|
|
/* header flags */
|
|
|
|
#define GETDNS_STR_KEY_ID "id"
|
|
|
|
#define GETDNS_STR_KEY_OPCODE "opcode"
|
|
|
|
#define GETDNS_STR_KEY_RCODE "rcode"
|
|
|
|
#define GETDNS_STR_KEY_AA "aa"
|
|
|
|
#define GETDNS_STR_KEY_TC "tc"
|
|
|
|
#define GETDNS_STR_KEY_RD "rd"
|
|
|
|
#define GETDNS_STR_KEY_RA "ra"
|
|
|
|
#define GETDNS_STR_KEY_AD "ad"
|
|
|
|
#define GETDNS_STR_KEY_CD "cd"
|
|
|
|
#define GETDNS_STR_KEY_Z "z"
|
|
|
|
#define GETDNS_STR_KEY_QDCOUNT "qdcount"
|
|
|
|
#define GETDNS_STR_KEY_ANCOUNT "ancount"
|
|
|
|
#define GETDNS_STR_KEY_NSCOUNT "nscount"
|
|
|
|
#define GETDNS_STR_KEY_ARCOUNT "arcount"
|
|
|
|
|
2014-10-08 08:42:33 -05:00
|
|
|
#define TIMEOUT_FOREVER ((int64_t)-1)
|
|
|
|
#define ASSERT_UNREACHABLE 0
|
2013-12-12 12:59:53 -06:00
|
|
|
|
2015-12-18 08:41:59 -06:00
|
|
|
#define GETDNS_TRANSPORTS_MAX 3
|
|
|
|
#define GETDNS_UPSTREAM_TRANSPORTS 2
|
2015-06-19 12:28:29 -05:00
|
|
|
|
2013-12-03 07:13:10 -06:00
|
|
|
/** @}
|
|
|
|
*/
|
|
|
|
|
2013-08-15 11:33:05 -05:00
|
|
|
/* declarations */
|
|
|
|
struct getdns_dns_req;
|
|
|
|
struct getdns_network_req;
|
|
|
|
|
2015-03-18 17:45:26 -05:00
|
|
|
typedef void (*internal_cb_t)(struct getdns_dns_req *dns_req);
|
2014-02-20 16:35:27 -06:00
|
|
|
|
2015-08-24 07:37:02 -05:00
|
|
|
#define MF_PLAIN ((void *)&plain_mem_funcs_user_arg)
|
|
|
|
extern void *plain_mem_funcs_user_arg;
|
2014-02-20 16:35:27 -06:00
|
|
|
|
|
|
|
typedef union {
|
|
|
|
struct {
|
|
|
|
void *(*malloc)(size_t);
|
|
|
|
void *(*realloc)(void *, size_t);
|
|
|
|
void (*free)(void *);
|
|
|
|
} pln;
|
|
|
|
struct {
|
|
|
|
void *(*malloc)(void *userarg, size_t);
|
|
|
|
void *(*realloc)(void *userarg, void *, size_t);
|
|
|
|
void (*free)(void *userarg, void *);
|
|
|
|
} ext;
|
|
|
|
} mf_union;
|
|
|
|
|
|
|
|
struct mem_funcs {
|
|
|
|
void *mf_arg;
|
|
|
|
mf_union mf;
|
|
|
|
};
|
|
|
|
|
2014-10-08 18:18:53 -05:00
|
|
|
struct mem_funcs *
|
|
|
|
priv_getdns_context_mf(getdns_context *context);
|
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
typedef enum network_req_state_enum
|
|
|
|
{
|
|
|
|
NET_REQ_NOT_SENT,
|
|
|
|
NET_REQ_IN_FLIGHT,
|
|
|
|
NET_REQ_FINISHED,
|
|
|
|
NET_REQ_CANCELED
|
2013-10-16 17:33:12 -05:00
|
|
|
} network_req_state;
|
|
|
|
|
2014-10-17 17:25:41 -05:00
|
|
|
|
|
|
|
/* State for async tcp stub resolving */
|
|
|
|
typedef struct getdns_tcp_state {
|
|
|
|
|
|
|
|
uint8_t *write_buf;
|
|
|
|
size_t write_buf_len;
|
|
|
|
size_t written;
|
2015-06-24 12:49:34 -05:00
|
|
|
int write_error;
|
2014-10-17 17:25:41 -05:00
|
|
|
|
|
|
|
uint8_t *read_buf;
|
|
|
|
size_t read_buf_len;
|
|
|
|
uint8_t *read_pos;
|
|
|
|
size_t to_read;
|
|
|
|
|
|
|
|
} getdns_tcp_state;
|
|
|
|
|
2015-04-24 10:29:08 -05:00
|
|
|
|
2013-10-16 17:33:12 -05:00
|
|
|
/**
|
2014-10-17 17:25:41 -05:00
|
|
|
* Request data
|
2013-10-16 17:33:12 -05:00
|
|
|
**/
|
2013-11-05 14:03:44 -06:00
|
|
|
typedef struct getdns_network_req
|
|
|
|
{
|
2014-10-16 04:28:32 -05:00
|
|
|
/* For storage in upstream->netreq_by_query_id */
|
2015-08-19 09:07:01 -05:00
|
|
|
_getdns_rbnode_t node;
|
2013-10-16 17:33:12 -05:00
|
|
|
/* the async_id from unbound */
|
2013-11-05 14:03:44 -06:00
|
|
|
int unbound_id;
|
|
|
|
/* state var */
|
|
|
|
network_req_state state;
|
|
|
|
/* owner request (contains name) */
|
|
|
|
struct getdns_dns_req *owner;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* request type */
|
|
|
|
uint16_t request_type;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2015-06-29 15:23:01 -05:00
|
|
|
/* dnssec status */
|
|
|
|
int dnssec_status;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2015-12-21 18:03:31 -06:00
|
|
|
/* tsig status:
|
|
|
|
* GETDNS_DNSSEC_INDETERMINATE means "No TSIG processing"
|
|
|
|
* GETDNS_DNSSEC_INSECURE means "TSIG sent, validate reply"
|
|
|
|
* GETDNS_DNSSEC_SECURE means "Validated"
|
|
|
|
* GETDNS_DNSSEC_BOGUS means "Validation failed"
|
|
|
|
*/
|
|
|
|
int tsig_status;
|
|
|
|
|
2016-03-23 05:32:38 -05:00
|
|
|
getdns_redirects_t follow_redirects;
|
|
|
|
|
2014-10-15 08:12:16 -05:00
|
|
|
/* For stub resolving */
|
2014-10-15 16:57:24 -05:00
|
|
|
struct getdns_upstream *upstream;
|
2014-10-17 17:25:41 -05:00
|
|
|
int fd;
|
2015-06-21 10:55:12 -05:00
|
|
|
getdns_transport_list_t transports[GETDNS_TRANSPORTS_MAX];
|
2015-09-25 11:28:45 -05:00
|
|
|
size_t transport_count;
|
|
|
|
size_t transport_current;
|
2015-09-30 08:03:15 -05:00
|
|
|
getdns_tls_authentication_t tls_auth_min;
|
2014-10-17 17:25:41 -05:00
|
|
|
getdns_eventloop_event event;
|
|
|
|
getdns_tcp_state tcp;
|
|
|
|
uint16_t query_id;
|
|
|
|
|
2015-02-03 03:46:44 -06:00
|
|
|
int edns_maximum_udp_payload_size;
|
2014-10-23 08:17:54 -05:00
|
|
|
uint16_t max_udp_payload_size;
|
|
|
|
|
2015-11-24 11:59:01 -06:00
|
|
|
size_t keepalive_sent;
|
|
|
|
|
2014-10-17 17:25:41 -05:00
|
|
|
/* Network requests scheduled to write after me */
|
2014-10-18 07:32:55 -05:00
|
|
|
struct getdns_network_req *write_queue_tail;
|
2014-10-15 08:12:16 -05:00
|
|
|
|
2015-12-16 08:20:35 -06:00
|
|
|
/* Some fields to record info for return_call_reporting */
|
2016-04-11 07:49:44 -05:00
|
|
|
uint64_t debug_start_time;
|
|
|
|
uint64_t debug_end_time;
|
|
|
|
size_t debug_tls_auth_status;
|
|
|
|
size_t debug_udp;
|
2015-10-31 20:24:02 -05:00
|
|
|
|
2015-01-29 05:30:40 -06:00
|
|
|
/* When more space is needed for the wire_data response than is
|
|
|
|
* available in wire_data[], it will be allocated seperately.
|
|
|
|
* response will then not point to wire_data anymore.
|
|
|
|
*/
|
2015-02-03 03:46:44 -06:00
|
|
|
uint8_t *query;
|
|
|
|
uint8_t *opt; /* offset of OPT RR in query */
|
2015-10-31 05:04:56 -05:00
|
|
|
|
|
|
|
/* each network_req has a set of base options that are
|
|
|
|
* specific to the query, which are static and included when
|
|
|
|
* the network_req is created. When the query is sent out to
|
|
|
|
* a given upstream, some additional options are added that
|
|
|
|
* are specific to the upstream. There can be at most
|
|
|
|
* GETDNS_MAXIMUM_UPSTREAM_OPTION_SPACE bytes of
|
|
|
|
* upstream-specific options.
|
|
|
|
|
|
|
|
* use _getdns_network_req_clear_upstream_options() and
|
|
|
|
* _getdns_network_req_add_upstream_option() to fiddle with the
|
|
|
|
*/
|
|
|
|
size_t base_query_option_sz;
|
2015-02-11 07:55:22 -06:00
|
|
|
size_t response_len;
|
2015-01-29 05:30:40 -06:00
|
|
|
uint8_t *response;
|
|
|
|
size_t wire_data_sz;
|
|
|
|
uint8_t wire_data[];
|
|
|
|
|
2015-10-31 20:24:02 -05:00
|
|
|
|
|
|
|
|
2013-08-15 11:33:05 -05:00
|
|
|
} getdns_network_req;
|
|
|
|
|
2013-11-04 17:37:54 -06:00
|
|
|
/**
|
|
|
|
* dns request - manages a number of network requests and
|
2013-10-16 17:33:12 -05:00
|
|
|
* the initial data passed to getdns_general
|
|
|
|
*/
|
2014-10-23 16:00:30 -05:00
|
|
|
typedef struct getdns_dns_req {
|
|
|
|
/* For storage in context->outbound_requests */
|
2015-08-19 09:07:01 -05:00
|
|
|
_getdns_rbnode_t node;
|
2014-10-23 16:00:30 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* name */
|
2015-06-29 16:32:49 -05:00
|
|
|
uint8_t name[256];
|
|
|
|
size_t name_len;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2016-04-18 15:06:12 -05:00
|
|
|
uint16_t request_class;
|
|
|
|
|
|
|
|
/* context that owns the request */
|
|
|
|
struct getdns_context *context;
|
|
|
|
|
2015-12-29 10:34:14 -06:00
|
|
|
getdns_append_name_t append_name;
|
|
|
|
const uint8_t *suffix;
|
|
|
|
size_t suffix_len;
|
2016-04-18 15:06:12 -05:00
|
|
|
int suffix_appended : 1;
|
2015-12-29 10:34:14 -06:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* canceled flag */
|
2016-04-18 15:06:12 -05:00
|
|
|
int canceled : 1;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* request extensions */
|
2016-04-18 15:06:12 -05:00
|
|
|
int dnssec_return_status : 1;
|
|
|
|
int dnssec_return_only_secure : 1;
|
|
|
|
int dnssec_return_all_statuses : 1;
|
|
|
|
int dnssec_return_validation_chain : 1;
|
|
|
|
int dnssec_return_full_validation_chain : 1;
|
2015-10-31 07:04:08 -05:00
|
|
|
#ifdef DNSSEC_ROADBLOCK_AVOIDANCE
|
2016-04-18 15:06:12 -05:00
|
|
|
int dnssec_roadblock_avoidance : 1;
|
|
|
|
int avoid_dnssec_roadblocks : 1;
|
2015-10-31 07:04:08 -05:00
|
|
|
#endif
|
2016-04-18 15:06:12 -05:00
|
|
|
int edns_cookies : 1;
|
|
|
|
int edns_client_subnet_private : 1;
|
|
|
|
int return_call_reporting : 1;
|
|
|
|
int add_warning_for_bad_dns : 1;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2015-03-18 17:45:26 -05:00
|
|
|
/* Internally used by return_validation_chain */
|
2016-04-18 15:06:12 -05:00
|
|
|
int dnssec_ok_checking_disabled : 1;
|
|
|
|
int is_sync_request : 1;
|
|
|
|
|
|
|
|
uint16_t tls_query_padding_blocksize;
|
2015-03-18 17:45:26 -05:00
|
|
|
|
2016-04-22 07:09:18 -05:00
|
|
|
/* The validating and freed variables are used to make sure a single
|
|
|
|
* code path is followed while processing a DNS request, even when
|
|
|
|
* callbacks are already fired whilst the registering/scheduling call
|
|
|
|
* (i.e. ub_resolve_event) has not returned yet.
|
|
|
|
*
|
|
|
|
* validating is touched by _getdns_get_validation_chain only and
|
|
|
|
* freed is touched by _getdns_submit_netreq only
|
2016-04-21 08:16:38 -05:00
|
|
|
*/
|
2016-04-22 07:09:18 -05:00
|
|
|
int validating;
|
2016-04-21 08:16:38 -05:00
|
|
|
int *freed;
|
|
|
|
|
2015-03-18 17:45:26 -05:00
|
|
|
/* internally scheduled request */
|
|
|
|
internal_cb_t internal_cb;
|
|
|
|
|
2014-10-13 17:14:25 -05:00
|
|
|
/* event loop */
|
|
|
|
getdns_eventloop *loop;
|
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* callback data */
|
|
|
|
getdns_callback_t user_callback;
|
|
|
|
void *user_pointer;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* the transaction id */
|
|
|
|
getdns_transaction_t trans_id;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2014-10-13 17:14:25 -05:00
|
|
|
/* for scheduling timeouts when using libunbound */
|
2014-10-08 08:42:33 -05:00
|
|
|
getdns_eventloop_event timeout;
|
2014-02-03 16:23:31 -06:00
|
|
|
|
2014-10-06 16:04:12 -05:00
|
|
|
/* mem funcs */
|
|
|
|
struct mem_funcs my_mf;
|
2013-08-15 11:33:05 -05:00
|
|
|
|
2014-10-15 08:12:16 -05:00
|
|
|
/* Stuff for stub resolving */
|
2014-10-15 14:00:57 -05:00
|
|
|
struct getdns_upstreams *upstreams;
|
2014-10-15 08:12:16 -05:00
|
|
|
|
2016-03-23 16:13:31 -05:00
|
|
|
/* Linked list pointer for dns requests, for which answers are received
|
|
|
|
* from open connections as aside-effect of doing a synchronous call.
|
|
|
|
* See also the type definition of getdns_upstream in context.h for a
|
|
|
|
* more elaborate description.
|
|
|
|
*/
|
|
|
|
struct getdns_dns_req *finished_next;
|
|
|
|
|
2015-01-29 05:30:40 -06:00
|
|
|
/* network requests for this dns request.
|
|
|
|
* The array is terminated with NULL.
|
|
|
|
*
|
|
|
|
* Memory for these netreqs has been allocated by the same malloc
|
|
|
|
* operation that reserved space for this getdns_dns_req.
|
|
|
|
* They will thus be freed as part of the desctruction of this struct,
|
|
|
|
* and do not need to be freed seperately.
|
|
|
|
*/
|
|
|
|
getdns_network_req *netreqs[];
|
|
|
|
|
2014-02-20 16:35:27 -06:00
|
|
|
} getdns_dns_req;
|
2013-12-08 15:56:34 -06:00
|
|
|
|
2013-11-12 10:00:19 -06:00
|
|
|
#define GETDNS_XMALLOC(obj, type, count) \
|
2013-12-08 17:05:18 -06:00
|
|
|
((obj).mf_arg == MF_PLAIN \
|
|
|
|
? ((type *)(*(obj).mf.pln.malloc)( (count)*sizeof(type))) \
|
|
|
|
: ((type *)(*(obj).mf.ext.malloc)((obj).mf_arg, (count)*sizeof(type))) \
|
|
|
|
)
|
2013-11-12 10:00:19 -06:00
|
|
|
|
|
|
|
#define GETDNS_XREALLOC(obj, ptr, type, count) \
|
2013-12-08 17:05:18 -06:00
|
|
|
((obj).mf_arg == MF_PLAIN \
|
|
|
|
? ((type *)(*(obj).mf.pln.realloc)( (ptr), (count)*sizeof(type))) \
|
|
|
|
: ((type *)(*(obj).mf.ext.realloc)( (obj).mf_arg \
|
|
|
|
, (ptr), (count)*sizeof(type))) \
|
|
|
|
)
|
2013-12-08 15:56:34 -06:00
|
|
|
|
|
|
|
#define GETDNS_FREE(obj, ptr) \
|
2013-12-08 17:05:18 -06:00
|
|
|
((obj).mf_arg == MF_PLAIN \
|
|
|
|
? ((*(obj).mf.pln.free)( (ptr))) \
|
|
|
|
: ((*(obj).mf.ext.free)((obj).mf_arg, (ptr))) \
|
|
|
|
)
|
2013-11-12 10:00:19 -06:00
|
|
|
|
2014-10-17 17:25:41 -05:00
|
|
|
#define GETDNS_NULL_FREE(obj, ptr) \
|
|
|
|
do { \
|
|
|
|
if (!(ptr)) \
|
|
|
|
break; \
|
|
|
|
if ((obj).mf_arg == MF_PLAIN) \
|
|
|
|
(*(obj).mf.pln.free)( (ptr)); \
|
|
|
|
else \
|
|
|
|
(*(obj).mf.ext.free)((obj).mf_arg, (ptr)); \
|
|
|
|
(ptr) = NULL; \
|
|
|
|
} while (0);
|
|
|
|
|
2013-11-12 10:00:19 -06:00
|
|
|
#define GETDNS_MALLOC(obj, type) GETDNS_XMALLOC(obj, type, 1)
|
|
|
|
#define GETDNS_REALLOC(obj, ptr, type) GETDNS_XREALLOC(obj, ptr, type, 1);
|
|
|
|
|
|
|
|
|
2013-08-15 11:33:05 -05:00
|
|
|
/* utility methods */
|
|
|
|
|
2015-06-22 17:00:20 -05:00
|
|
|
extern getdns_dict *dnssec_ok_checking_disabled;
|
2015-11-04 16:11:51 -06:00
|
|
|
extern getdns_dict *dnssec_ok_checking_disabled_roadblock_avoidance;
|
|
|
|
extern getdns_dict *dnssec_ok_checking_disabled_avoid_roadblocks;
|
2015-06-22 17:00:20 -05:00
|
|
|
|
2013-08-15 11:33:05 -05:00
|
|
|
/* dns request utils */
|
2015-08-19 09:33:19 -05:00
|
|
|
getdns_dns_req *_getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop,
|
2014-10-13 17:14:25 -05:00
|
|
|
const char *name, uint16_t request_type, getdns_dict *extensions);
|
2013-08-15 11:33:05 -05:00
|
|
|
|
2015-08-19 09:33:19 -05:00
|
|
|
void _getdns_dns_req_free(getdns_dns_req * req);
|
2013-08-15 11:42:35 -05:00
|
|
|
|
2015-10-31 05:04:56 -05:00
|
|
|
/* network request utils */
|
|
|
|
getdns_return_t _getdns_network_req_add_upstream_option(getdns_network_req * req,
|
|
|
|
uint16_t code, uint16_t sz, const void* data);
|
|
|
|
void _getdns_network_req_clear_upstream_options(getdns_network_req * req);
|
|
|
|
|
2015-12-21 15:11:16 -06:00
|
|
|
/* Adds TSIG signature (if needed) and returns query length */
|
|
|
|
size_t _getdns_network_req_add_tsig(getdns_network_req *req);
|
|
|
|
|
2015-12-21 18:03:31 -06:00
|
|
|
void _getdns_network_validate_tsig(getdns_network_req *req);
|
|
|
|
|
2015-12-29 16:06:02 -06:00
|
|
|
void _getdns_netreq_reinit(getdns_network_req *netreq);
|
|
|
|
|
2013-08-15 11:33:05 -05:00
|
|
|
#endif
|
2013-11-04 17:37:54 -06:00
|
|
|
/* types-internal.h */
|