1 /*	$NetBSD: resconf.h,v 1.5 2014/12/10 04:37:59 christos Exp $	*/
2 
3 /*
4  * Copyright (C) 2009, 2014  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: resconf.h,v 1.3 2009/09/02 23:48:02 tbox Exp  */
20 
21 #ifndef IRS_RESCONF_H
22 #define IRS_RESCONF_H 1
23 
24 /*! \file
25  *
26  * \brief
27  * The IRS resconf module parses the legacy "/etc/resolv.conf" file and
28  * creates the corresponding configuration objects for the DNS library
29  * modules.
30  */
31 
32 #include <irs/types.h>
33 
34 /*%
35  * A DNS search list specified in the 'domain' or 'search' statements
36  * in the "resolv.conf" file.
37  */
38 typedef struct irs_resconf_search {
39 	char					*domain;
40 	ISC_LINK(struct irs_resconf_search)	link;
41 } irs_resconf_search_t;
42 
43 typedef ISC_LIST(irs_resconf_search_t) irs_resconf_searchlist_t;
44 
45 ISC_LANG_BEGINDECLS
46 
47 isc_result_t
48 irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp);
49 /*%<
50  * Load the resolver configuration file 'filename' in the "resolv.conf" format,
51  * and create a new irs_resconf_t object from the configuration.  If the file
52  * is not found ISC_R_FILENOTFOUND is returned with the structure initialized
53  * as if file contained only:
54  *
55  *	nameserver ::1
56  *	nameserver 127.0.0.1
57  *
58  * Notes:
59  *
60  *\li	Currently, only the following options are supported:
61  *	nameserver, domain, search, sortlist, ndots, and options.
62  *	In addition, 'sortlist' is not actually effective; it's parsed, but
63  *	the application cannot use the configuration.
64  *
65  * Returns:
66  * \li	ISC_R_SUCCESS on success
67  * \li  ISC_R_FILENOTFOUND if the file was not found. *confp will be valid.
68  * \li  other on error.
69  *
70  * Requires:
71  *
72  *\li	'mctx' is a valid memory context.
73  *
74  *\li	'filename' != NULL
75  *
76  *\li	'confp' != NULL && '*confp' == NULL
77  */
78 
79 void
80 irs_resconf_destroy(irs_resconf_t **confp);
81 /*%<
82  * Destroy the resconf object.
83  *
84  * Requires:
85  *
86  *\li	'*confp' is a valid resconf object.
87  *
88  * Ensures:
89  *
90  *\li	*confp == NULL
91  */
92 
93 isc_sockaddrlist_t *
94 irs_resconf_getnameservers(irs_resconf_t *conf);
95 /*%<
96  * Return a list of name server addresses stored in 'conf'.
97  *
98  * Requires:
99  *
100  *\li	'conf' is a valid resconf object.
101  */
102 
103 irs_resconf_searchlist_t *
104 irs_resconf_getsearchlist(irs_resconf_t *conf);
105 /*%<
106  * Return the search list stored in 'conf'.
107  *
108  * Requires:
109  *
110  *\li	'conf' is a valid resconf object.
111  */
112 
113 unsigned int
114 irs_resconf_getndots(irs_resconf_t *conf);
115 /*%<
116  * Return the 'ndots' value stored in 'conf'.
117  *
118  * Requires:
119  *
120  *\li	'conf' is a valid resconf object.
121  */
122 
123 ISC_LANG_ENDDECLS
124 
125 #endif /* IRS_RESCONF_H */
126