2013-08-12 16:38:05 -05:00
|
|
|
/**
|
2013-08-15 11:33:05 -05:00
|
|
|
*
|
2014-01-28 08:22:46 -06:00
|
|
|
* /file
|
|
|
|
* /brief getdns context management functions
|
2013-08-15 11:33:05 -05:00
|
|
|
*
|
|
|
|
* Originally taken from the getdns API description pseudo implementation.
|
|
|
|
*
|
|
|
|
*/
|
2014-01-28 08:22:46 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2013, Versign, Inc.
|
|
|
|
* All rights reserved.
|
2013-08-15 11:33:05 -05:00
|
|
|
*
|
2014-01-28 08:22:46 -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.
|
|
|
|
* * Neither the name of the <organization> nor the
|
|
|
|
* 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
|
|
|
*
|
2014-01-28 08:22:46 -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-12 16:38:05 -05:00
|
|
|
*/
|
2014-01-28 08:22:46 -06:00
|
|
|
|
2013-08-12 16:38:05 -05:00
|
|
|
#ifndef _GETDNS_CONTEXT_H_
|
|
|
|
#define _GETDNS_CONTEXT_H_
|
|
|
|
|
2013-08-15 09:16:15 -05:00
|
|
|
#include <getdns/getdns.h>
|
2013-12-08 15:56:34 -06:00
|
|
|
#include "types-internal.h"
|
2013-08-12 16:38:05 -05:00
|
|
|
|
2013-10-16 17:33:12 -05:00
|
|
|
struct getdns_dns_req;
|
2013-11-06 12:32:05 -06:00
|
|
|
struct ldns_rbtree_t;
|
|
|
|
struct ub_ctx;
|
2013-10-15 16:28:23 -05:00
|
|
|
|
2013-08-12 16:38:05 -05:00
|
|
|
/** function pointer typedefs */
|
2014-02-09 10:46:12 -06:00
|
|
|
typedef void (*getdns_update_callback) (struct getdns_context *,
|
|
|
|
getdns_context_code_t);
|
2013-08-12 16:38:05 -05:00
|
|
|
|
2013-12-06 08:54:06 -06:00
|
|
|
struct getdns_context {
|
2013-08-12 16:38:05 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* Context values */
|
2014-02-09 10:46:12 -06:00
|
|
|
getdns_resolution_t resolution_type;
|
|
|
|
getdns_namespace_t *namespaces;
|
|
|
|
uint64_t timeout;
|
|
|
|
getdns_redirects_t follow_redirects;
|
|
|
|
struct getdns_list *dns_root_servers;
|
|
|
|
getdns_append_name_t append_name;
|
2013-11-05 14:03:44 -06:00
|
|
|
struct getdns_list *suffix;
|
|
|
|
struct getdns_list *dnssec_trust_anchors;
|
|
|
|
struct getdns_list *upstream_list;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
uint8_t edns_extended_rcode;
|
|
|
|
uint8_t edns_version;
|
|
|
|
uint8_t edns_do_bit;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_update_callback update_callback;
|
2013-08-12 16:38:05 -05:00
|
|
|
|
2013-12-08 17:05:18 -06:00
|
|
|
struct mem_funcs mf;
|
|
|
|
struct mem_funcs my_mf;
|
2013-12-08 16:15:57 -06:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* The underlying unbound contexts that do
|
|
|
|
* the real work */
|
2014-01-21 14:31:22 -06:00
|
|
|
struct ub_ctx *unbound_ctx;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* which resolution type the contexts are configured for
|
|
|
|
* 0 means nothing set
|
|
|
|
*/
|
|
|
|
uint8_t resolution_type_set;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/*
|
|
|
|
* outbound requests -> transaction to getdns_dns_req
|
|
|
|
*/
|
|
|
|
struct ldns_rbtree_t *outbound_requests;
|
2014-01-22 18:55:04 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Event loop extension functions
|
|
|
|
* These structs are static and should never be freed
|
|
|
|
* since they are just a collection of function pointers
|
|
|
|
*/
|
|
|
|
getdns_eventloop_extension* extension;
|
|
|
|
/*
|
|
|
|
* Extension data that will be freed by the functions
|
|
|
|
* in the extension struct
|
|
|
|
*/
|
|
|
|
void* extension_data;
|
2014-01-27 16:05:25 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Timeout info one tree to manage timeout data
|
|
|
|
* keyed by transaction id. Second to manage by
|
2014-01-31 13:43:02 -06:00
|
|
|
* timeout time (ascending)
|
2014-01-27 16:05:25 -06:00
|
|
|
*/
|
|
|
|
struct ldns_rbtree_t *timeouts_by_id;
|
|
|
|
struct ldns_rbtree_t *timeouts_by_time;
|
2013-11-05 14:03:44 -06:00
|
|
|
};
|
2013-08-12 16:38:05 -05:00
|
|
|
|
2013-10-16 13:45:43 -05:00
|
|
|
/** internal functions **/
|
|
|
|
/**
|
|
|
|
* Sets up the unbound contexts with stub or recursive behavior
|
|
|
|
* if needed.
|
|
|
|
*/
|
2013-12-06 08:54:06 -06:00
|
|
|
getdns_return_t getdns_context_prepare_for_resolution(struct getdns_context *context);
|
2013-10-16 13:45:43 -05:00
|
|
|
|
2013-10-16 17:33:12 -05:00
|
|
|
/* track an outbound request */
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_return_t getdns_context_track_outbound_request(struct getdns_dns_req
|
|
|
|
*req);
|
2013-10-16 17:33:12 -05:00
|
|
|
/* clear the outbound request from being tracked - does not cancel it */
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_return_t getdns_context_clear_outbound_request(struct getdns_dns_req
|
|
|
|
*req);
|
2013-10-18 12:55:31 -05:00
|
|
|
/* cancel callback internal - flag to indicate if req should be freed and callback fired */
|
2013-12-06 08:54:06 -06:00
|
|
|
getdns_return_t getdns_context_cancel_request(struct getdns_context *context,
|
2013-11-05 14:03:44 -06:00
|
|
|
getdns_transaction_t transaction_id, int fire_callback);
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2014-01-14 10:25:23 -06:00
|
|
|
char *getdns_strdup(const struct mem_funcs *mfs, const char *str);
|
2013-11-11 16:10:22 -06:00
|
|
|
|
2013-11-12 10:00:19 -06:00
|
|
|
struct getdns_bindata *getdns_bindata_copy(
|
2013-12-08 17:05:18 -06:00
|
|
|
struct mem_funcs *mfs,
|
2013-11-11 16:10:22 -06:00
|
|
|
const struct getdns_bindata *src);
|
|
|
|
|
2013-12-08 17:05:18 -06:00
|
|
|
void getdns_bindata_destroy(
|
|
|
|
struct mem_funcs *mfs,
|
2013-11-11 16:10:22 -06:00
|
|
|
struct getdns_bindata *bindata);
|
|
|
|
|
2014-01-22 18:55:04 -06:00
|
|
|
/* extension stuff */
|
|
|
|
getdns_return_t getdns_extension_set_eventloop(struct getdns_context* context,
|
|
|
|
getdns_eventloop_extension* extension, void* extension_data);
|
|
|
|
|
2014-01-31 14:48:00 -06:00
|
|
|
getdns_return_t
|
|
|
|
getdns_extension_detach_eventloop(struct getdns_context* context);
|
|
|
|
|
|
|
|
|
2014-01-27 16:05:25 -06:00
|
|
|
/* timeout scheduling */
|
|
|
|
getdns_return_t getdns_context_schedule_timeout(struct getdns_context* context,
|
|
|
|
getdns_transaction_t id, uint16_t timeout, getdns_timeout_callback callback,
|
2014-01-31 13:43:02 -06:00
|
|
|
void* userarg);
|
2014-01-27 16:05:25 -06:00
|
|
|
|
|
|
|
getdns_return_t getdns_context_clear_timeout(struct getdns_context* context,
|
|
|
|
getdns_transaction_t id);
|
|
|
|
|
2013-11-06 12:32:05 -06:00
|
|
|
#endif /* _GETDNS_CONTEXT_H_ */
|