1135446Strhodes/*
2193149Sdougb * Copyright (C) 2004, 2005, 2007, 2008  Internet Systems Consortium, Inc. ("ISC")
3135446Strhodes * Copyright (C) 2000, 2001  Internet Software Consortium.
4135446Strhodes *
5193149Sdougb * Permission to use, copy, modify, and/or distribute this software for any
6135446Strhodes * purpose with or without fee is hereby granted, provided that the above
7135446Strhodes * copyright notice and this permission notice appear in all copies.
8135446Strhodes *
9135446Strhodes * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10135446Strhodes * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11135446Strhodes * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12135446Strhodes * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13135446Strhodes * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14135446Strhodes * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15135446Strhodes * PERFORMANCE OF THIS SOFTWARE.
16135446Strhodes */
17135446Strhodes
18234010Sdougb/* $Id: context_p.h,v 1.19 2008/12/17 23:47:58 tbox Exp $ */
19135446Strhodes
20135446Strhodes#ifndef LWRES_CONTEXT_P_H
21135446Strhodes#define LWRES_CONTEXT_P_H 1
22135446Strhodes
23170222Sdougb/*! \file */
24170222Sdougb
25170222Sdougb/*@{*/
26170222Sdougb/**
27135446Strhodes * Helper functions, assuming the context is always called "ctx" in
28135446Strhodes * the scope these functions are called from.
29135446Strhodes */
30135446Strhodes#define CTXMALLOC(len)		ctx->malloc(ctx->arg, (len))
31135446Strhodes#define CTXFREE(addr, len)	ctx->free(ctx->arg, (addr), (len))
32170222Sdougb/*@}*/
33135446Strhodes
34135446Strhodes#define LWRES_DEFAULT_TIMEOUT	120	/* 120 seconds for a reply */
35135446Strhodes
36170222Sdougb/**
37135446Strhodes * Not all the attributes here are actually settable by the application at
38135446Strhodes * this time.
39135446Strhodes */
40135446Strhodesstruct lwres_context {
41170222Sdougb	unsigned int		timeout;	/*%< time to wait for reply */
42170222Sdougb	lwres_uint32_t		serial;		/*%< serial number state */
43135446Strhodes
44135446Strhodes	/*
45135446Strhodes	 * For network I/O.
46135446Strhodes	 */
47170222Sdougb	int			sock;		/*%< socket to send on */
48170222Sdougb	lwres_addr_t		address;	/*%< address to send to */
49193149Sdougb	int			use_ipv4;	/*%< use IPv4 transaction */
50193149Sdougb	int			use_ipv6;	/*%< use IPv6 transaction */
51135446Strhodes
52170222Sdougb	/*@{*/
53135446Strhodes	/*
54135446Strhodes	 * Function pointers for allocating memory.
55135446Strhodes	 */
56135446Strhodes	lwres_malloc_t		malloc;
57135446Strhodes	lwres_free_t		free;
58135446Strhodes	void		       *arg;
59170222Sdougb	/*@}*/
60135446Strhodes
61170222Sdougb	/*%
62135446Strhodes	 * resolv.conf-like data
63135446Strhodes	 */
64135446Strhodes	lwres_conf_t		confdata;
65135446Strhodes};
66135446Strhodes
67135446Strhodes#endif /* LWRES_CONTEXT_P_H */
68