4 * Dick Gooris <gooris@lucent.com>
5 * Ulf Lamping <ulf.lamping@web.de>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include "ws_symbol_export.h"
33 * Range strings a variant of value_strings
36 /**@todo where's the best place for these? */
37 #define MAX_SCTP_PORT 65535
38 #define MAX_TCP_PORT 65535
39 #define MAX_UDP_PORT 65535
40 #define MAX_DCCP_PORT 65535
42 typedef struct range_admin_tag {
47 /** user specified range(s) */
48 typedef struct epan_range {
49 guint nranges; /**< number of entries in ranges */
50 range_admin_t ranges[1]; /**< variable-length array */
54 * Return value from range_convert_str().
62 WS_DLL_PUBLIC range_t *range_empty(void);
65 /*** Converts a range string to a fast comparable array of ranges.
66 * This function allocates a range_t large enough to hold the number
67 * of ranges specified, and fills the array range->ranges containing
68 * low and high values with the number of ranges being range->nranges.
69 * After having called this function, the function value_is_in_range()
70 * determines whether a given number is within the range or not.<BR>
71 * In case of a single number, we make a range where low is equal to high.
72 * We take care on wrongly entered ranges; opposite order will be taken
75 * The following syntax is accepted :
77 * 1-20,30-40 Range from 1 to 20, and packets 30 to 40
78 * -20,30 Range from 1 to 20, and packet 30
79 * 20,30,40- 20, 30, and the range from 40 to the end
80 * 20-10,30-25 Range from 10 to 20, and from 25 to 30
82 * @param range the range
83 * @param es points to the string to be converted.
84 * @param max_value specifies the maximum value in a range.
85 * @return convert_ret_t
87 WS_DLL_PUBLIC convert_ret_t range_convert_str(range_t **range, const gchar *es,
90 convert_ret_t range_convert_str_work(range_t **range, const gchar *es,
91 guint32 max_value, gboolean err_on_max);
93 /** This function returns TRUE if a given value is within one of the ranges
94 * stored in the ranges array.
95 * @param range the range
96 * @param val the value to check
97 * @return TRUE if the value is in range
99 WS_DLL_PUBLIC gboolean value_is_in_range(range_t *range, guint32 val);
101 /** This function returns TRUE if the two given range_t's are equal.
102 * @param a first range
103 * @param b second range
104 * @return TRUE if the value is in range
106 WS_DLL_PUBLIC gboolean ranges_are_equal(range_t *a, range_t *b);
108 /** This function calls the provided callback function for each value in
110 * @param range the range
111 * @param callback the callback function
113 WS_DLL_PUBLIC void range_foreach(range_t *range, void (*callback)(guint32 val));
116 * This function converts a range_t to a (ep_alloc()-allocated) string.
118 WS_DLL_PUBLIC char *range_convert_range(range_t *range);
121 * Create a copy of a range.
122 * @param src the range to copy
123 * @return ep allocated copy of the range
125 WS_DLL_PUBLIC range_t *range_copy(range_t *src);
127 #endif /* __RANGE_H__ */