1 /*	$NetBSD: context.h,v 1.4 2014/12/10 04:37:59 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2009  Internet Systems Consortium, Inc. ("ISC")
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
11  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
12  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
13  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
14  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /* Id: context.h,v 1.3 2009/09/02 23:48:02 tbox Exp  */
20 
21 #ifndef IRS_CONTEXT_H
22 #define IRS_CONTEXT_H 1
23 
24 /*! \file
25  *
26  * \brief
27  * The IRS context module provides an abstract interface to the DNS library
28  * with an application.  An IRS context object initializes and holds various
29  * resources used in the DNS library.
30  */
31 
32 #include <dns/types.h>
33 #include <irs/types.h>
34 
35 ISC_LANG_BEGINDECLS
36 
37 isc_result_t
38 irs_context_create(irs_context_t **contextp);
39 /*%<
40  * Create an IRS context.  It internally initializes the ISC and DNS libraries
41  * (if not yet), creates a DNS client object and initializes the client using
42  * the configuration files parsed via the 'resconf' and 'dnsconf' IRS modules.
43  * Some of the internally initialized objects can be used by the application
44  * via irs_context_getxxx() functions (see below).
45  *
46  * Requires:
47  *
48  *\li	contextp != NULL && *contextp == NULL.
49  */
50 
51 isc_result_t
52 irs_context_get(irs_context_t **contextp);
53 /*%<
54  * Return an IRS context for the calling thread.  If no IRS context is
55  * associated to the thread, this function creates a new one by calling
56  * irs_context_create(), and associates it with the thread as a thread specific
57  * data value.  This function is provided for standard libraries that are
58  * expected to be thread-safe but do not accept an appropriate IRS context
59  * as a library parameter, e.g., getaddrinfo().
60  *
61  * Requires:
62  *
63  *\li	contextp != NULL && *contextp == NULL.
64  */
65 
66 void
67 irs_context_destroy(irs_context_t **contextp);
68 /*%<
69  * Destroy an IRS context.
70  *
71  * Requires:
72  *
73  *\li	'*contextp' is a valid IRS context.
74  *
75  * Ensures:
76  *\li	'*contextp' == NULL.
77  */
78 
79 isc_mem_t *
80 irs_context_getmctx(irs_context_t *context);
81 /*%<
82  * Return the memory context held in the context.
83  *
84  * Requires:
85  *
86  *\li	'context' is a valid IRS context.
87  */
88 
89 isc_appctx_t *
90 irs_context_getappctx(irs_context_t *context);
91 /*%<
92  * Return the application context held in the context.
93  *
94  * Requires:
95  *
96  *\li	'context' is a valid IRS context.
97  */
98 
99 isc_taskmgr_t *
100 irs_context_gettaskmgr(irs_context_t *context);
101 /*%<
102  * Return the task manager held in the context.
103  *
104  * Requires:
105  *
106  *\li	'context' is a valid IRS context.
107  */
108 
109 isc_timermgr_t *
110 irs_context_gettimermgr(irs_context_t *context);
111 /*%<
112  * Return the timer manager held in the context.
113  *
114  * Requires:
115  *
116  *\li	'context' is a valid IRS context.
117  */
118 
119 isc_task_t *
120 irs_context_gettask(irs_context_t *context);
121 /*%<
122  * Return the task object held in the context.
123  *
124  * Requires:
125  *
126  *\li	'context' is a valid IRS context.
127  */
128 
129 dns_client_t *
130 irs_context_getdnsclient(irs_context_t *context);
131 /*%<
132  * Return the DNS client object held in the context.
133  *
134  * Requires:
135  *
136  *\li	'context' is a valid IRS context.
137  */
138 
139 irs_resconf_t *
140 irs_context_getresconf(irs_context_t *context);
141 /*%<
142  * Return the resolver configuration object held in the context.
143  *
144  * Requires:
145  *
146  *\li	'context' is a valid IRS context.
147  */
148 
149 irs_dnsconf_t *
150 irs_context_getdnsconf(irs_context_t *context);
151 /*%<
152  * Return the advanced DNS configuration object held in the context.
153  *
154  * Requires:
155  *
156  *\li	'context' is a valid IRS context.
157  */
158 
159 ISC_LANG_ENDDECLS
160 
161 #endif /* IRS_CONTEXT_H */
162