1 /* 2 * Copyright (C) Internet Systems Consortium, Inc. ("ISC") 3 * 4 * SPDX-License-Identifier: MPL-2.0 5 * 6 * This Source Code Form is subject to the terms of the Mozilla Public 7 * License, v. 2.0. If a copy of the MPL was not distributed with this 8 * file, you can obtain one at https://mozilla.org/MPL/2.0/. 9 * 10 * See the COPYRIGHT file distributed with this work for additional 11 * information regarding copyright ownership. 12 */ 13 14 #ifndef NS_LISTENLIST_H 15 #define NS_LISTENLIST_H 1 16 17 /***** 18 ***** Module Info 19 *****/ 20 21 /*! \file 22 * \brief 23 * "Listen lists", as in the "listen-on" configuration statement. 24 */ 25 26 /*** 27 *** Imports 28 ***/ 29 30 #include <stdbool.h> 31 32 #include <isc/net.h> 33 34 #include <dns/types.h> 35 36 /*** 37 *** Types 38 ***/ 39 40 typedef struct ns_listenelt ns_listenelt_t; 41 typedef struct ns_listenlist ns_listenlist_t; 42 43 struct ns_listenelt { 44 isc_mem_t *mctx; 45 in_port_t port; 46 isc_dscp_t dscp; /* -1 = not set, 0..63 */ 47 dns_acl_t *acl; 48 ISC_LINK(ns_listenelt_t) link; 49 }; 50 51 struct ns_listenlist { 52 isc_mem_t *mctx; 53 int refcount; 54 ISC_LIST(ns_listenelt_t) elts; 55 }; 56 57 /*** 58 *** Functions 59 ***/ 60 61 isc_result_t 62 ns_listenelt_create(isc_mem_t *mctx, in_port_t port, isc_dscp_t dscp, 63 dns_acl_t *acl, ns_listenelt_t **target); 64 /*%< 65 * Create a listen-on list element. 66 */ 67 68 void 69 ns_listenelt_destroy(ns_listenelt_t *elt); 70 /*%< 71 * Destroy a listen-on list element. 72 */ 73 74 isc_result_t 75 ns_listenlist_create(isc_mem_t *mctx, ns_listenlist_t **target); 76 /*%< 77 * Create a new, empty listen-on list. 78 */ 79 80 void 81 ns_listenlist_attach(ns_listenlist_t *source, ns_listenlist_t **target); 82 /*%< 83 * Attach '*target' to '*source'. 84 */ 85 86 void 87 ns_listenlist_detach(ns_listenlist_t **listp); 88 /*%< 89 * Detach 'listp'. 90 */ 91 92 isc_result_t 93 ns_listenlist_default(isc_mem_t *mctx, in_port_t port, isc_dscp_t dscp, 94 bool enabled, ns_listenlist_t **target); 95 /*%< 96 * Create a listen-on list with default contents, matching 97 * all addresses with port 'port' (if 'enabled' is true), 98 * or no addresses (if 'enabled' is false). 99 */ 100 101 #endif /* NS_LISTENLIST_H */ 102