Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
range.h
Go to the documentation of this file.
1/* range.h
2 * Range routines
3 *
4 * Dick Gooris <[email protected]>
5 * Ulf Lamping <[email protected]>
6 *
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <[email protected]>
9 * Copyright 1998 Gerald Combs
10 *
11 * SPDX-License-Identifier: GPL-2.0-or-later
12 */
13
14#ifndef __RANGE_H__
15#define __RANGE_H__
16
17#include "ws_symbol_export.h"
18#include <epan/wmem_scopes.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif /* __cplusplus */
23
29#define MAX_SCTP_PORT 65535
30#define MAX_TCP_PORT 65535
31#define MAX_UDP_PORT 65535
32#define MAX_DCCP_PORT 65535
33
34typedef struct range_admin_tag {
35 uint32_t low;
36 uint32_t high;
38#define RANGE_ADMIN_T_INITIALIZER { 0, 0 }
39
41typedef struct epan_range {
42 unsigned nranges;
45
49typedef enum {
50 CVT_NO_ERROR,
51 CVT_SYNTAX_ERROR,
52 CVT_NUMBER_TOO_BIG
54
55WS_DLL_PUBLIC range_t *range_empty(wmem_allocator_t *scope);
56
57
58/*** Converts a range string to a fast comparable array of ranges.
59 * This function allocates a range_t large enough to hold the number
60 * of ranges specified, and fills the array range->ranges containing
61 * low and high values with the number of ranges being range->nranges.
62 * After having called this function, the function value_is_in_range()
63 * determines whether a given number is within the range or not.<BR>
64 * In case of a single number, we make a range where low is equal to high.
65 * We take care on wrongly entered ranges; opposite order will be taken
66 * care of.
67 *
68 * The following syntax is accepted :
69 *
70 * 1-20,30-40 Range from 1 to 20, and packets 30 to 40
71 * -20,30 Range from 1 to 20, and packet 30
72 * 20,30,40- 20, 30, and the range from 40 to the end
73 * 20-10,30-25 Range from 10 to 20, and from 25 to 30
74 * - All values
75 * @param scope memory scope for the range
76 * @param range the range
77 * @param es points to the string to be converted.
78 * @param max_value specifies the maximum value in a range.
79 * @return convert_ret_t
80 */
81WS_DLL_PUBLIC convert_ret_t range_convert_str(wmem_allocator_t *scope, range_t **range, const char *es,
82 uint32_t max_value);
83
84WS_DLL_PUBLIC convert_ret_t range_convert_str_work(wmem_allocator_t *scope, range_t **range, const char *es,
85 uint32_t max_value, bool err_on_max);
86
93WS_DLL_PUBLIC bool value_is_in_range(const range_t *range, uint32_t val);
94
102WS_DLL_PUBLIC bool range_add_value(wmem_allocator_t *scope, range_t **range, uint32_t val);
103
111WS_DLL_PUBLIC bool range_remove_value(wmem_allocator_t *scope, range_t **range, uint32_t val);
112
118WS_DLL_PUBLIC bool ranges_are_equal(const range_t *a, const range_t *b);
119
127WS_DLL_PUBLIC void range_foreach(range_t *range, void (*callback)(uint32_t val, void *ptr), void *ptr);
128
132WS_DLL_PUBLIC char *range_convert_range(wmem_allocator_t *scope, const range_t *range);
133
140WS_DLL_PUBLIC range_t *range_copy(wmem_allocator_t *scope, const range_t *src);
141
142#ifdef __cplusplus
143}
144#endif /* __cplusplus */
145
146#endif /* __RANGE_H__ */
WS_DLL_PUBLIC range_t * range_copy(wmem_allocator_t *scope, const range_t *src)
Definition range.c:432
WS_DLL_PUBLIC char * range_convert_range(wmem_allocator_t *scope, const range_t *range)
Definition range.c:409
struct epan_range range_t
WS_DLL_PUBLIC bool range_add_value(wmem_allocator_t *scope, range_t **range, uint32_t val)
Definition range.c:277
convert_ret_t
Definition range.h:49
WS_DLL_PUBLIC bool ranges_are_equal(const range_t *a, const range_t *b)
Definition range.c:369
WS_DLL_PUBLIC void range_foreach(range_t *range, void(*callback)(uint32_t val, void *ptr), void *ptr)
Definition range.c:395
WS_DLL_PUBLIC bool range_remove_value(wmem_allocator_t *scope, range_t **range, uint32_t val)
Definition range.c:314
WS_DLL_PUBLIC bool value_is_in_range(const range_t *range, uint32_t val)
Definition range.c:260
Definition wmem_allocator.h:27
Definition range.h:41
unsigned nranges
Definition range.h:42
range_admin_t ranges[]
Definition range.h:43
Definition range.h:34