2013-08-12 16:38:05 -05:00
|
|
|
/**
|
2013-08-15 11:33:05 -05:00
|
|
|
*
|
|
|
|
* /brief getdns contect management functions
|
|
|
|
*
|
|
|
|
* This is the meat of the API
|
|
|
|
* Originally taken from the getdns API description pseudo implementation.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
/* The MIT License (MIT)
|
|
|
|
* Copyright (c) 2013 Verisign, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
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-15 16:28:23 -05:00
|
|
|
struct event_base;
|
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 */
|
2013-12-06 08:54:06 -06:00
|
|
|
typedef void (*getdns_update_callback) (struct getdns_context *, uint16_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 */
|
|
|
|
uint16_t resolution_type;
|
|
|
|
uint16_t *namespaces;
|
|
|
|
uint16_t timeout;
|
|
|
|
uint16_t follow_redirects;
|
|
|
|
struct getdns_list *dns_root_servers;
|
|
|
|
uint16_t append_name;
|
|
|
|
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
|
|
|
/* Event loop for sync requests */
|
|
|
|
struct event_base *event_base_sync;
|
|
|
|
/* Event loop for async requests */
|
|
|
|
struct event_base *event_base_async;
|
2013-10-16 17:33:12 -05:00
|
|
|
|
2013-11-05 14:03:44 -06:00
|
|
|
/* The underlying unbound contexts that do
|
|
|
|
* the real work */
|
|
|
|
struct ub_ctx *unbound_sync;
|
|
|
|
struct ub_ctx *unbound_async;
|
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;
|
|
|
|
};
|
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);
|
|
|
|
|
2013-11-06 12:32:05 -06:00
|
|
|
#endif /* _GETDNS_CONTEXT_H_ */
|