summaryrefslogtreecommitdiff
path: root/lib/irs/include/irs/context.h
blob: c49cfcfa49741bc9ae1722339e07bfe4e3ef63fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
 * Copyright (C) 2009  Internet Systems Consortium, Inc. ("ISC")
 *
 * Permission to use, copy, modify, and/or distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 * PERFORMANCE OF THIS SOFTWARE.
 */

/* $Id: context.h,v 1.3 2009-09-02 23:48:02 tbox Exp $ */

#ifndef IRS_CONTEXT_H
#define IRS_CONTEXT_H 1

/*! \file
 *
 * \brief
 * The IRS context module provides an abstract interface to the DNS library
 * with an application.  An IRS context object initializes and holds various
 * resources used in the DNS library.
 */

#include <dns/types.h>
#include <irs/types.h>

ISC_LANG_BEGINDECLS

isc_result_t
irs_context_create(irs_context_t **contextp);
/*%<
 * Create an IRS context.  It internally initializes the ISC and DNS libraries
 * (if not yet), creates a DNS client object and initializes the client using
 * the configuration files parsed via the 'resconf' and 'dnsconf' IRS modules.
 * Some of the internally initialized objects can be used by the application
 * via irs_context_getxxx() functions (see below).
 *
 * Requires:
 *
 *\li	contextp != NULL && *contextp == NULL.
 */

isc_result_t
irs_context_get(irs_context_t **contextp);
/*%<
 * Return an IRS context for the calling thread.  If no IRS context is
 * associated to the thread, this function creates a new one by calling
 * irs_context_create(), and associates it with the thread as a thread specific
 * data value.  This function is provided for standard libraries that are
 * expected to be thread-safe but do not accept an appropriate IRS context
 * as a library parameter, e.g., getaddrinfo().
 *
 * Requires:
 *
 *\li	contextp != NULL && *contextp == NULL.
 */

void
irs_context_destroy(irs_context_t **contextp);
/*%<
 * Destroy an IRS context.
 *
 * Requires:
 *
 *\li	'*contextp' is a valid IRS context.
 *
 * Ensures:
 *\li	'*contextp' == NULL.
 */

isc_mem_t *
irs_context_getmctx(irs_context_t *context);
/*%<
 * Return the memory context held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

isc_appctx_t *
irs_context_getappctx(irs_context_t *context);
/*%<
 * Return the application context held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

isc_taskmgr_t *
irs_context_gettaskmgr(irs_context_t *context);
/*%<
 * Return the task manager held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

isc_timermgr_t *
irs_context_gettimermgr(irs_context_t *context);
/*%<
 * Return the timer manager held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

isc_task_t *
irs_context_gettask(irs_context_t *context);
/*%<
 * Return the task object held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

dns_client_t *
irs_context_getdnsclient(irs_context_t *context);
/*%<
 * Return the DNS client object held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

irs_resconf_t *
irs_context_getresconf(irs_context_t *context);
/*%<
 * Return the resolver configuration object held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

irs_dnsconf_t *
irs_context_getdnsconf(irs_context_t *context);
/*%<
 * Return the advanced DNS configuration object held in the context.
 *
 * Requires:
 *
 *\li	'context' is a valid IRS context.
 */

ISC_LANG_ENDDECLS

#endif /* IRS_CONTEXT_H */