portset.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2008, 2009  Internet Systems Consortium, Inc. ("ISC")
00003  *
00004  * Permission to use, copy, modify, and/or distribute this software for any
00005  * purpose with or without fee is hereby granted, provided that the above
00006  * copyright notice and this permission notice appear in all copies.
00007  *
00008  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00009  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00010  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00011  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00012  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00013  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00014  * PERFORMANCE OF THIS SOFTWARE.
00015  */
00016 
00017 /* $Id: portset.h,v 1.6 2009/06/25 05:28:34 marka Exp $ */
00018 
00019 /*! \file isc/portset.h
00020  * \brief Transport Protocol Port Manipulation Module
00021  *
00022  * This module provides simple utilities to handle a set of transport protocol
00023  * (UDP or TCP) port numbers, e.g., for creating an ACL list.  An isc_portset_t
00024  * object is an opaque instance of a port set, for which the user can add or
00025  * remove a specific port or a range of consecutive ports.  This object is
00026  * expected to be used as a temporary work space only, and does not protect
00027  * simultaneous access from multiple threads.  Therefore it must not be stored
00028  * in a place that can be accessed from multiple threads.
00029  */
00030 
00031 #ifndef ISC_PORTSET_H
00032 #define ISC_PORTSET_H 1
00033 
00034 /***
00035  ***    Imports
00036  ***/
00037 
00038 #include <isc/net.h>
00039 
00040 /***
00041  *** Functions
00042  ***/
00043 
00044 ISC_LANG_BEGINDECLS
00045 
00046 isc_result_t
00047 isc_portset_create(isc_mem_t *mctx, isc_portset_t **portsetp);
00048 /*%<
00049  * Create a port set and initialize it as an empty set.
00050  *
00051  * Requires:
00052  *\li   'mctx' to be valid.
00053  *\li   'portsetp' to be non NULL and '*portsetp' to be NULL;
00054  *
00055  * Returns:
00056  *\li   #ISC_R_SUCCESS
00057  *\li   #ISC_R_NOMEMORY
00058  */
00059 
00060 void
00061 isc_portset_destroy(isc_mem_t *mctx, isc_portset_t **portsetp);
00062 /*%<
00063  * Destroy a port set.
00064  *
00065  * Requires:
00066  *\li   'mctx' to be valid and must be the same context given when the port set
00067  *       was created.
00068  *\li   '*portsetp' to be a valid set.
00069  */
00070 
00071 isc_boolean_t
00072 isc_portset_isset(isc_portset_t *portset, in_port_t port);
00073 /*%<
00074  * Test whether the given port is stored in the portset.
00075  *
00076  * Requires:
00077  *\li   'portset' to be a valid set.
00078  *
00079  * Returns
00080  * \li  #ISC_TRUE if the port is found, ISC_FALSE otherwise.
00081  */
00082 
00083 unsigned int
00084 isc_portset_nports(isc_portset_t *portset);
00085 /*%<
00086  * Provides the number of ports stored in the given portset.
00087  *
00088  * Requires:
00089  *\li   'portset' to be a valid set.
00090  *
00091  * Returns
00092  * \li  the number of ports stored in portset.
00093  */
00094 
00095 void
00096 isc_portset_add(isc_portset_t *portset, in_port_t port);
00097 /*%<
00098  * Add the given port to the portset.  The port may or may not be stored in
00099  * the portset.
00100  *
00101  * Requires:
00102  *\li   'portlist' to be valid.
00103  */
00104 
00105 void
00106 isc_portset_remove(isc_portset_t *portset, in_port_t port);
00107 /*%<
00108  * Remove the given port to the portset.  The port may or may not be stored in
00109  * the portset.
00110  *
00111  * Requires:
00112  *\li   'portlist' to be valid.
00113  */
00114 
00115 void
00116 isc_portset_addrange(isc_portset_t *portset, in_port_t port_lo,
00117                      in_port_t port_hi);
00118 /*%<
00119  * Add a subset of [port_lo, port_hi] (inclusive) to the portset.  Ports in the
00120  * subset may or may not be stored in portset.
00121  *
00122  * Requires:
00123  *\li   'portlist' to be valid.
00124  *\li   port_lo <= port_hi
00125  */
00126 
00127 void
00128 isc_portset_removerange(isc_portset_t *portset, in_port_t port_lo,
00129                         in_port_t port_hi);
00130 /*%<
00131  * Subtract a subset of [port_lo, port_hi] (inclusive) from the portset.  Ports
00132  * in the subset may or may not be stored in portset.
00133  *
00134  * Requires:
00135  *\li   'portlist' to be valid.
00136  *\li   port_lo <= port_hi
00137  */
00138 
00139 ISC_LANG_ENDDECLS
00140 
00141 #endif  /* ISC_PORTSET_H */

Generated on Tue Apr 28 17:41:04 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha