2 * Copyright (C) 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
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.
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.
17 /* $Id: portset.h,v 1.3.90.3 2009/06/25 05:31:51 marka Exp $ */
19 /*! \file isc/portset.h
20 * \brief Transport Protocol Port Manipulation Module
22 * This module provides simple utilities to handle a set of transport protocol
23 * (UDP or TCP) port numbers, e.g., for creating an ACL list. An isc_portset_t
24 * object is an opaque instance of a port set, for which the user can add or
25 * remove a specific port or a range of consecutive ports. This object is
26 * expected to be used as a temporary work space only, and does not protect
27 * simultaneous access from multiple threads. Therefore it must not be stored
28 * in a place that can be accessed from multiple threads.
32 #define ISC_PORTSET_H 1
47 isc_portset_create(isc_mem_t *mctx, isc_portset_t **portsetp);
49 * Create a port set and initialize it as an empty set.
52 *\li 'mctx' to be valid.
53 *\li 'portsetp' to be non NULL and '*portsetp' to be NULL;
61 isc_portset_destroy(isc_mem_t *mctx, isc_portset_t **portsetp);
66 *\li 'mctx' to be valid and must be the same context given when the port set
68 *\li '*portsetp' to be a valid set.
72 isc_portset_isset(isc_portset_t *portset, in_port_t port);
74 * Test whether the given port is stored in the portset.
77 *\li 'portset' to be a valid set.
80 * \li #ISC_TRUE if the port is found, ISC_FALSE otherwise.
84 isc_portset_nports(isc_portset_t *portset);
86 * Provides the number of ports stored in the given portset.
89 *\li 'portset' to be a valid set.
92 * \li the number of ports stored in portset.
96 isc_portset_add(isc_portset_t *portset, in_port_t port);
98 * Add the given port to the portset. The port may or may not be stored in
102 *\li 'portlist' to be valid.
106 isc_portset_remove(isc_portset_t *portset, in_port_t port);
108 * Remove the given port to the portset. The port may or may not be stored in
112 *\li 'portlist' to be valid.
116 isc_portset_addrange(isc_portset_t *portset, in_port_t port_lo,
119 * Add a subset of [port_lo, port_hi] (inclusive) to the portset. Ports in the
120 * subset may or may not be stored in portset.
123 *\li 'portlist' to be valid.
124 *\li port_lo <= port_hi
128 isc_portset_removerange(isc_portset_t *portset, in_port_t port_lo,
131 * Subtract a subset of [port_lo, port_hi] (inclusive) from the portset. Ports
132 * in the subset may or may not be stored in portset.
135 *\li 'portlist' to be valid.
136 *\li port_lo <= port_hi
141 #endif /* ISC_PORTSET_H */