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"
31 #include <epan/wmem/wmem.h>
35 #endif /* __cplusplus */
38 * Range strings a variant of value_strings
41 /**@todo where's the best place for these? */
42 #define MAX_SCTP_PORT 65535
43 #define MAX_TCP_PORT 65535
44 #define MAX_UDP_PORT 65535
45 #define MAX_DCCP_PORT 65535
47 typedef struct range_admin_tag {
52 /** user specified range(s) */
53 typedef struct epan_range {
54 guint nranges; /**< number of entries in ranges */
55 range_admin_t ranges[1]; /**< variable-length array */
59 * Return value from range_convert_str().
67 WS_DLL_PUBLIC range_t *range_empty(void);
70 /*** Converts a range string to a fast comparable array of ranges.
71 * This function allocates a range_t large enough to hold the number
72 * of ranges specified, and fills the array range->ranges containing
73 * low and high values with the number of ranges being range->nranges.
74 * After having called this function, the function value_is_in_range()
75 * determines whether a given number is within the range or not.<BR>
76 * In case of a single number, we make a range where low is equal to high.
77 * We take care on wrongly entered ranges; opposite order will be taken
80 * The following syntax is accepted :
82 * 1-20,30-40 Range from 1 to 20, and packets 30 to 40
83 * -20,30 Range from 1 to 20, and packet 30
84 * 20,30,40- 20, 30, and the range from 40 to the end
85 * 20-10,30-25 Range from 10 to 20, and from 25 to 30
87 * @param range the range
88 * @param es points to the string to be converted.
89 * @param max_value specifies the maximum value in a range.
90 * @return convert_ret_t
92 WS_DLL_PUBLIC convert_ret_t range_convert_str(range_t **range, const gchar *es,
95 convert_ret_t range_convert_str_work(range_t **range, const gchar *es,
96 guint32 max_value, gboolean err_on_max);
98 /** This function returns TRUE if a given value is within one of the ranges
99 * stored in the ranges array.
100 * @param range the range
101 * @param val the value to check
102 * @return TRUE if the value is in range
104 WS_DLL_PUBLIC gboolean value_is_in_range(range_t *range, guint32 val);
106 /** This function returns TRUE if the two given range_t's are equal.
107 * @param a first range
108 * @param b second range
109 * @return TRUE if the value is in range
111 WS_DLL_PUBLIC gboolean ranges_are_equal(range_t *a, range_t *b);
113 /** This function calls the provided callback function for each value in
115 * @param range the range
116 * @param callback the callback function
118 WS_DLL_PUBLIC void range_foreach(range_t *range, void (*callback)(guint32 val));
121 * This function converts a range_t to a (wmem_alloc()-allocated) string.
123 WS_DLL_PUBLIC char *range_convert_range(wmem_allocator_t *scope, const range_t *range);
126 * Create a copy of a range.
127 * @param src the range to copy
128 * @return ep allocated copy of the range
130 WS_DLL_PUBLIC range_t *range_copy(range_t *src);
134 #endif /* __cplusplus */
136 #endif /* __RANGE_H__ */