1/*
2 * Copyright (C) 2009, 2014  Internet Systems Consortium, Inc. ("ISC")
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
13 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 * PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/* $Id: resconf.h,v 1.3 2009/09/02 23:48:02 tbox Exp $ */
18
19#ifndef IRS_RESCONF_H
20#define IRS_RESCONF_H 1
21
22/*! \file
23 *
24 * \brief
25 * The IRS resconf module parses the legacy "/etc/resolv.conf" file and
26 * creates the corresponding configuration objects for the DNS library
27 * modules.
28 */
29
30#include <irs/types.h>
31
32/*%
33 * A DNS search list specified in the 'domain' or 'search' statements
34 * in the "resolv.conf" file.
35 */
36typedef struct irs_resconf_search {
37	char					*domain;
38	ISC_LINK(struct irs_resconf_search)	link;
39} irs_resconf_search_t;
40
41typedef ISC_LIST(irs_resconf_search_t) irs_resconf_searchlist_t;
42
43ISC_LANG_BEGINDECLS
44
45isc_result_t
46irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp);
47/*%<
48 * Load the resolver configuration file 'filename' in the "resolv.conf" format,
49 * and create a new irs_resconf_t object from the configuration.  If the file
50 * is not found ISC_R_FILENOTFOUND is returned with the structure initialized
51 * as if file contained only:
52 *
53 *	nameserver ::1
54 *	nameserver 127.0.0.1
55 *
56 * Notes:
57 *
58 *\li	Currently, only the following options are supported:
59 *	nameserver, domain, search, sortlist, ndots, and options.
60 *	In addition, 'sortlist' is not actually effective; it's parsed, but
61 *	the application cannot use the configuration.
62 *
63 * Returns:
64 * \li	ISC_R_SUCCESS on success
65 * \li  ISC_R_FILENOTFOUND if the file was not found. *confp will be valid.
66 * \li  other on error.
67 *
68 * Requires:
69 *
70 *\li	'mctx' is a valid memory context.
71 *
72 *\li	'filename' != NULL
73 *
74 *\li	'confp' != NULL && '*confp' == NULL
75 */
76
77void
78irs_resconf_destroy(irs_resconf_t **confp);
79/*%<
80 * Destroy the resconf object.
81 *
82 * Requires:
83 *
84 *\li	'*confp' is a valid resconf object.
85 *
86 * Ensures:
87 *
88 *\li	*confp == NULL
89 */
90
91isc_sockaddrlist_t *
92irs_resconf_getnameservers(irs_resconf_t *conf);
93/*%<
94 * Return a list of name server addresses stored in 'conf'.
95 *
96 * Requires:
97 *
98 *\li	'conf' is a valid resconf object.
99 */
100
101irs_resconf_searchlist_t *
102irs_resconf_getsearchlist(irs_resconf_t *conf);
103/*%<
104 * Return the search list stored in 'conf'.
105 *
106 * Requires:
107 *
108 *\li	'conf' is a valid resconf object.
109 */
110
111unsigned int
112irs_resconf_getndots(irs_resconf_t *conf);
113/*%<
114 * Return the 'ndots' value stored in 'conf'.
115 *
116 * Requires:
117 *
118 *\li	'conf' is a valid resconf object.
119 */
120
121ISC_LANG_ENDDECLS
122
123#endif /* IRS_RESCONF_H */
124