1 /* $NetBSD: resconf.h,v 1.2 2025/01/26 16:25:29 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 #pragma once 17 18 #include <isc/lang.h> 19 #include <isc/list.h> 20 #include <isc/types.h> 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 /*%< resolv.conf configuration information */ 31 typedef struct irs_resconf irs_resconf_t; 32 33 /*% 34 * A DNS search list specified in the 'domain' or 'search' statements 35 * in the "resolv.conf" file. 36 */ 37 typedef struct irs_resconf_search { 38 char *domain; 39 ISC_LINK(struct irs_resconf_search) link; 40 } irs_resconf_search_t; 41 42 typedef ISC_LIST(irs_resconf_search_t) irs_resconf_searchlist_t; 43 44 ISC_LANG_BEGINDECLS 45 46 isc_result_t 47 irs_resconf_load(isc_mem_t *mctx, const char *filename, irs_resconf_t **confp); 48 /*%< 49 * Load the resolver configuration file 'filename' in the "resolv.conf" format, 50 * and create a new irs_resconf_t object from the configuration. If the file 51 * is not found ISC_R_FILENOTFOUND is returned with the structure initialized 52 * as if file contained only: 53 * 54 * nameserver ::1 55 * nameserver 127.0.0.1 56 * 57 * Notes: 58 * 59 *\li Currently, only the following options are supported: 60 * nameserver, domain, search, sortlist, ndots, and options. 61 * In addition, 'sortlist' is not actually effective; it's parsed, but 62 * the application cannot use the configuration. 63 * 64 * Returns: 65 * \li ISC_R_SUCCESS on success 66 * \li ISC_R_FILENOTFOUND if the file was not found. *confp will be valid. 67 * \li other on error. 68 * 69 * Requires: 70 * 71 *\li 'mctx' is a valid memory context. 72 * 73 *\li 'filename' != NULL 74 * 75 *\li 'confp' != NULL && '*confp' == NULL 76 */ 77 78 void 79 irs_resconf_destroy(irs_resconf_t **confp); 80 /*%< 81 * Destroy the resconf object. 82 * 83 * Requires: 84 * 85 *\li '*confp' is a valid resconf object. 86 * 87 * Ensures: 88 * 89 *\li *confp == NULL 90 */ 91 92 isc_sockaddrlist_t * 93 irs_resconf_getnameservers(irs_resconf_t *conf); 94 /*%< 95 * Return a list of name server addresses stored in 'conf'. 96 * 97 * Requires: 98 * 99 *\li 'conf' is a valid resconf object. 100 */ 101 102 irs_resconf_searchlist_t * 103 irs_resconf_getsearchlist(irs_resconf_t *conf); 104 /*%< 105 * Return the search list stored in 'conf'. 106 * 107 * Requires: 108 * 109 *\li 'conf' is a valid resconf object. 110 */ 111 112 unsigned int 113 irs_resconf_getndots(irs_resconf_t *conf); 114 /*%< 115 * Return the 'ndots' value stored in 'conf'. 116 * 117 * Requires: 118 * 119 *\li 'conf' is a valid resconf object. 120 */ 121 122 unsigned int 123 irs_resconf_getattempts(irs_resconf_t *conf); 124 /*%< 125 * Return the 'attempts' value stored in 'conf'. 126 * 127 * Requires: 128 * 129 *\li 'conf' is a valid resconf object. 130 */ 131 132 unsigned int 133 irs_resconf_gettimeout(irs_resconf_t *conf); 134 /*%< 135 * Return the 'timeout' value stored in 'conf'. 136 * 137 * Requires: 138 * 139 *\li 'conf' is a valid resconf object. 140 */ 141 142 ISC_LANG_ENDDECLS 143