1 /*	$NetBSD: context.h,v 1.5 2022/09/23 12:15:32 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0.  If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 #ifndef IRS_CONTEXT_H
17 #define IRS_CONTEXT_H 1
18 
19 /*! \file
20  *
21  * \brief
22  * The IRS context module provides an abstract interface to the DNS library
23  * with an application.  An IRS context object initializes and holds various
24  * resources used in the DNS library.
25  */
26 
27 #include <dns/types.h>
28 
29 #include <irs/types.h>
30 
31 ISC_LANG_BEGINDECLS
32 
33 isc_result_t
34 irs_context_create(irs_context_t **contextp);
35 /*%<
36  * Create an IRS context.  It internally initializes the ISC and DNS libraries
37  * (if not yet), creates a DNS client object and initializes the client using
38  * the configuration files parsed via the 'resconf' and 'dnsconf' IRS modules.
39  * Some of the internally initialized objects can be used by the application
40  * via irs_context_getxxx() functions (see below).
41  *
42  * Requires:
43  *
44  *\li	contextp != NULL && *contextp == NULL.
45  */
46 
47 isc_result_t
48 irs_context_get(irs_context_t **contextp);
49 /*%<
50  * Return an IRS context for the calling thread.  If no IRS context is
51  * associated to the thread, this function creates a new one by calling
52  * irs_context_create(), and associates it with the thread as a thread specific
53  * data value.  This function is provided for standard libraries that are
54  * expected to be thread-safe but do not accept an appropriate IRS context
55  * as a library parameter, e.g., getaddrinfo().
56  *
57  * Requires:
58  *
59  *\li	contextp != NULL && *contextp == NULL.
60  */
61 
62 void
63 irs_context_destroy(irs_context_t **contextp);
64 /*%<
65  * Destroy an IRS context.
66  *
67  * Requires:
68  *
69  *\li	'*contextp' is a valid IRS context.
70  *
71  * Ensures:
72  *\li	'*contextp' == NULL.
73  */
74 
75 isc_mem_t *
76 irs_context_getmctx(irs_context_t *context);
77 /*%<
78  * Return the memory context held in the context.
79  *
80  * Requires:
81  *
82  *\li	'context' is a valid IRS context.
83  */
84 
85 isc_appctx_t *
86 irs_context_getappctx(irs_context_t *context);
87 /*%<
88  * Return the application context held in the context.
89  *
90  * Requires:
91  *
92  *\li	'context' is a valid IRS context.
93  */
94 
95 isc_taskmgr_t *
96 irs_context_gettaskmgr(irs_context_t *context);
97 /*%<
98  * Return the task manager held in the context.
99  *
100  * Requires:
101  *
102  *\li	'context' is a valid IRS context.
103  */
104 
105 isc_timermgr_t *
106 irs_context_gettimermgr(irs_context_t *context);
107 /*%<
108  * Return the timer manager held in the context.
109  *
110  * Requires:
111  *
112  *\li	'context' is a valid IRS context.
113  */
114 
115 isc_task_t *
116 irs_context_gettask(irs_context_t *context);
117 /*%<
118  * Return the task object held in the context.
119  *
120  * Requires:
121  *
122  *\li	'context' is a valid IRS context.
123  */
124 
125 dns_client_t *
126 irs_context_getdnsclient(irs_context_t *context);
127 /*%<
128  * Return the DNS client object held in the context.
129  *
130  * Requires:
131  *
132  *\li	'context' is a valid IRS context.
133  */
134 
135 irs_resconf_t *
136 irs_context_getresconf(irs_context_t *context);
137 /*%<
138  * Return the resolver configuration object held in the context.
139  *
140  * Requires:
141  *
142  *\li	'context' is a valid IRS context.
143  */
144 
145 irs_dnsconf_t *
146 irs_context_getdnsconf(irs_context_t *context);
147 /*%<
148  * Return the advanced DNS configuration object held in the context.
149  *
150  * Requires:
151  *
152  *\li	'context' is a valid IRS context.
153  */
154 
155 ISC_LANG_ENDDECLS
156 
157 #endif /* IRS_CONTEXT_H */
158