1 /*
2  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
3  *
4  * This Source Code Form is subject to the terms of the Mozilla Public
5  * License, v. 2.0. If a copy of the MPL was not distributed with this
6  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
7  *
8  * See the COPYRIGHT file distributed with this work for additional
9  * information regarding copyright ownership.
10  */
11 
12 #ifndef LWRES_CONTEXT_P_H
13 #define LWRES_CONTEXT_P_H 1
14 
15 #include <inttypes.h>
16 
17 /*! \file */
18 
19 /*@{*/
20 /**
21  * Helper functions, assuming the context is always called "ctx" in
22  * the scope these functions are called from.
23  */
24 #define CTXMALLOC(len)		ctx->malloc(ctx->arg, (len))
25 #define CTXFREE(addr, len)	ctx->free(ctx->arg, (addr), (len))
26 /*@}*/
27 
28 #define LWRES_DEFAULT_TIMEOUT	120	/* 120 seconds for a reply */
29 
30 /**
31  * Not all the attributes here are actually settable by the application at
32  * this time.
33  */
34 struct lwres_context {
35 	unsigned int		timeout;	/*%< time to wait for reply */
36 	uint32_t		serial;		/*%< serial number state */
37 
38 	/*
39 	 * For network I/O.
40 	 */
41 	int			sock;		/*%< socket to send on */
42 	lwres_addr_t		address;	/*%< address to send to */
43 	int			use_ipv4;	/*%< use IPv4 transaction */
44 	int			use_ipv6;	/*%< use IPv6 transaction */
45 
46 	/*@{*/
47 	/*
48 	 * Function pointers for allocating memory.
49 	 */
50 	lwres_malloc_t		malloc;
51 	lwres_free_t		free;
52 	void		       *arg;
53 	/*@}*/
54 
55 	/*%
56 	 * resolv.conf-like data
57 	 */
58 	lwres_conf_t		confdata;
59 };
60 
61 #endif /* LWRES_CONTEXT_P_H */
62