1 /* $NetBSD: portlist.h,v 1.1 2024/02/18 20:57:37 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 /*! \file dns/portlist.h */ 17 18 #include <stdbool.h> 19 20 #include <isc/lang.h> 21 #include <isc/net.h> 22 #include <isc/types.h> 23 24 #include <dns/types.h> 25 26 #ifndef DNS_PORTLIST_H 27 #define DNS_PORTLIST_H 1 28 29 ISC_LANG_BEGINDECLS 30 31 isc_result_t 32 dns_portlist_create(isc_mem_t *mctx, dns_portlist_t **portlistp); 33 /*%< 34 * Create a port list. 35 * 36 * Requires: 37 *\li 'mctx' to be valid. 38 *\li 'portlistp' to be non NULL and '*portlistp' to be NULL; 39 * 40 * Returns: 41 *\li #ISC_R_SUCCESS 42 *\li #ISC_R_NOMEMORY 43 *\li #ISC_R_UNEXPECTED 44 */ 45 46 isc_result_t 47 dns_portlist_add(dns_portlist_t *portlist, int af, in_port_t port); 48 /*%< 49 * Add the given <port,af> tuple to the portlist. 50 * 51 * Requires: 52 *\li 'portlist' to be valid. 53 *\li 'af' to be AF_INET or AF_INET6 54 * 55 * Returns: 56 *\li #ISC_R_SUCCESS 57 *\li #ISC_R_NOMEMORY 58 */ 59 60 void 61 dns_portlist_remove(dns_portlist_t *portlist, int af, in_port_t port); 62 /*%< 63 * Remove the given <port,af> tuple to the portlist. 64 * 65 * Requires: 66 *\li 'portlist' to be valid. 67 *\li 'af' to be AF_INET or AF_INET6 68 */ 69 70 bool 71 dns_portlist_match(dns_portlist_t *portlist, int af, in_port_t port); 72 /*%< 73 * Find the given <port,af> tuple to the portlist. 74 * 75 * Requires: 76 *\li 'portlist' to be valid. 77 *\li 'af' to be AF_INET or AF_INET6 78 * 79 * Returns 80 * \li #true if the tuple is found, false otherwise. 81 */ 82 83 void 84 dns_portlist_attach(dns_portlist_t *portlist, dns_portlist_t **portlistp); 85 /*%< 86 * Attach to a port list. 87 * 88 * Requires: 89 *\li 'portlist' to be valid. 90 *\li 'portlistp' to be non NULL and '*portlistp' to be NULL; 91 */ 92 93 void 94 dns_portlist_detach(dns_portlist_t **portlistp); 95 /*%< 96 * Detach from a port list. 97 * 98 * Requires: 99 *\li '*portlistp' to be valid. 100 */ 101 102 ISC_LANG_ENDDECLS 103 104 #endif /* DNS_PORTLIST_H */ 105