| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
ftypes-int.h
Go to the documentation of this file.
1
9#pragma once
10
11#include "ftypes.h"
12#include <epan/proto.h>
13#include <epan/packet.h>
14
22 struct _fvalue_t {
23 const ftype_t *ftype;
24
25 union {
26 uint64_t uinteger64;
27 int64_t sinteger64;
28 double floating;
29 wmem_strbuf_t *strbuf;
30 GBytes *bytes;
31 ipv4_addr_and_mask ipv4;
32 ipv6_addr_and_prefix ipv6;
33 e_guid_t guid;
34 nstime_t time;
35 protocol_value_t protocol;
36 uint16_t sfloat_ieee_11073;
37 uint32_t float_ieee_11073;
38 } value;
39};
40
41 extern const ftype_t* type_list[FT_ENUM_SIZE + 1];
42
43/* Given an ftenum number, return an ftype_t* */
44#define FTYPE_LOOKUP(ftype, result) \
45 /* Check input */ \
46 ws_abort_if_fail(ftype < FT_NUM_TYPES); \
47 result = type_list[ftype];
48
49 typedef void (*FvalueNewFunc)(fvalue_t*);
50 typedef void (*FvalueCopyFunc)(fvalue_t*, const fvalue_t*);
51 typedef void (*FvalueFreeFunc)(fvalue_t*);
52
53 typedef bool (*FvalueFromLiteral)(fvalue_t*, const char*, bool, char **);
54 typedef bool (*FvalueFromString)(fvalue_t*, const char*, size_t, char **);
55 typedef bool (*FvalueFromCharConst)(fvalue_t*, unsigned long, char **);
56 typedef bool (*FvalueFromUnsignedInt64)(fvalue_t*, const char *, uint64_t, char **);
57 typedef bool (*FvalueFromSignedInt64)(fvalue_t*, const char *, int64_t, char **);
58 typedef bool (*FvalueFromDouble)(fvalue_t*, const char *, double, char **);
59
60 typedef char *(*FvalueToStringRepr)(wmem_allocator_t *, const fvalue_t*, ftrepr_t, int field_display);
61
62 typedef enum ft_result (*FvalueToUnsignedInt64)(const fvalue_t*, uint64_t *);
63 typedef enum ft_result (*FvalueToSignedInt64)(const fvalue_t*, int64_t *);
64 typedef enum ft_result (*FvalueToDouble)(const fvalue_t*, double *);
65
66 typedef void (*FvalueSetBytesFunc)(fvalue_t*, GBytes *);
67 typedef void (*FvalueSetGuidFunc)(fvalue_t*, const e_guid_t *);
68 typedef void (*FvalueSetTimeFunc)(fvalue_t*, const nstime_t *);
69 typedef void (*FvalueSetStrbufFunc)(fvalue_t*, wmem_strbuf_t *);
70 typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const char *name, unsigned length);
71 typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, uint32_t);
72 typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, int32_t);
73 typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, uint64_t);
74 typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, int64_t);
75 typedef void (*FvalueSetFloatingFunc)(fvalue_t*, double);
76 typedef void (*FvalueSetIpv4Func)(fvalue_t*, const ipv4_addr_and_mask *);
77 typedef void (*FvalueSetIpv6Func)(fvalue_t*, const ipv6_addr_and_prefix *);
78
79 typedef GBytes *(*FvalueGetBytesFunc)(fvalue_t*);
80 typedef const e_guid_t *(*FvalueGetGuidFunc)(fvalue_t*);
81 typedef const nstime_t *(*FvalueGetTimeFunc)(fvalue_t*);
82 typedef const wmem_strbuf_t *(*FvalueGetStrbufFunc)(fvalue_t*);
83 typedef tvbuff_t *(*FvalueGetProtocolFunc)(fvalue_t*);
84 typedef uint32_t (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
85 typedef int32_t (*FvalueGetSignedIntegerFunc)(fvalue_t*);
86 typedef uint64_t (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
87 typedef int64_t (*FvalueGetSignedInteger64Func)(fvalue_t*);
88 typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
89 typedef const ipv4_addr_and_mask *(*FvalueGetIpv4Func)(fvalue_t*);
90 typedef const ipv6_addr_and_prefix *(*FvalueGetIpv6Func)(fvalue_t*);
91
92 typedef enum ft_result (*FvalueCompare)(const fvalue_t*, const fvalue_t*, int*);
93 typedef enum ft_result (*FvalueContains)(const fvalue_t*, const fvalue_t*, bool*);
94 typedef enum ft_result (*FvalueMatches)(const fvalue_t*, const ws_regex_t*, bool*);
95
96 typedef bool (*FvalueIs)(const fvalue_t*);
97 typedef unsigned (*FvalueLen)(fvalue_t*);
98 typedef unsigned (*FvalueHashFunc)(const fvalue_t *);
99 typedef void (*FvalueSlice)(fvalue_t*, void *, unsigned offset, unsigned length);
100 typedef enum ft_result (*FvalueUnaryOp)(fvalue_t *, const fvalue_t*, char **);
101 typedef enum ft_result (*FvalueBinaryOp)(fvalue_t *, const fvalue_t*, const fvalue_t*, char **);
102
110 struct _ftype_t {
111 ftenum_t ftype;
112 int wire_size;
113
114 FvalueNewFunc new_value;
115 FvalueCopyFunc copy_value;
116 FvalueFreeFunc free_value;
117
118 FvalueFromLiteral val_from_literal;
119 FvalueFromString val_from_string;
120 FvalueFromCharConst val_from_charconst;
121 FvalueFromUnsignedInt64 val_from_uinteger64;
122 FvalueFromSignedInt64 val_from_sinteger64;
123 FvalueFromDouble val_from_double;
124
125 FvalueToStringRepr val_to_string_repr;
126
127 FvalueToUnsignedInt64 val_to_uinteger64;
128 FvalueToSignedInt64 val_to_sinteger64;
129 FvalueToDouble val_to_double;
130
136 union {
137 FvalueSetBytesFunc set_value_bytes;
138 FvalueSetGuidFunc set_value_guid;
139 FvalueSetTimeFunc set_value_time;
140 FvalueSetStrbufFunc set_value_strbuf;
141 FvalueSetProtocolFunc set_value_protocol;
142 FvalueSetUnsignedIntegerFunc set_value_uinteger;
143 FvalueSetSignedIntegerFunc set_value_sinteger;
144 FvalueSetUnsignedInteger64Func set_value_uinteger64;
145 FvalueSetSignedInteger64Func set_value_sinteger64;
146 FvalueSetFloatingFunc set_value_floating;
147 FvalueSetIpv4Func set_value_ipv4;
148 FvalueSetIpv6Func set_value_ipv6;
149 } set_value;
150
156 union {
157 FvalueGetBytesFunc get_value_bytes;
158 FvalueGetGuidFunc get_value_guid;
159 FvalueGetTimeFunc get_value_time;
160 FvalueGetStrbufFunc get_value_strbuf;
161 FvalueGetProtocolFunc get_value_protocol;
162 FvalueGetUnsignedIntegerFunc get_value_uinteger;
163 FvalueGetSignedIntegerFunc get_value_sinteger;
164 FvalueGetUnsignedInteger64Func get_value_uinteger64;
165 FvalueGetSignedInteger64Func get_value_sinteger64;
166 FvalueGetFloatingFunc get_value_floating;
167 FvalueGetIpv4Func get_value_ipv4;
168 FvalueGetIpv6Func get_value_ipv6;
169 } get_value;
170
171 FvalueCompare compare;
172 FvalueContains contains;
173 FvalueMatches matches;
174
175 FvalueHashFunc hash;
176 FvalueIs is_zero;
177 FvalueIs is_negative;
178 FvalueIs is_nan;
179 FvalueLen len;
180 FvalueSlice slice;
181
182 FvalueBinaryOp bitwise_and;
183 FvalueUnaryOp unary_minus;
184 FvalueBinaryOp add;
185 FvalueBinaryOp subtract;
186 FvalueBinaryOp multiply;
187 FvalueBinaryOp divide;
188 FvalueBinaryOp modulo;
189};
190
199 void ftype_register(enum ftenum ftype, const ftype_t *ft);
200
204 void ftype_register_bytes(void);
205
209 void ftype_register_double(void);
210
214 void ftype_register_ieee_11073_float(void);
215
219 void ftype_register_integers(void);
220
224 void ftype_register_ipv4(void);
225
229 void ftype_register_ipv6(void);
230
234 void ftype_register_guid(void);
235
239 void ftype_register_none(void);
240
244 void ftype_register_string(void);
245
249 void ftype_register_time(void);
250
254 void ftype_register_tvbuff(void);
255
256/* For debugging. */
257
263 void ftype_register_pseudofields_bytes(int proto);
264
270 void ftype_register_pseudofields_double(int proto);
271
277 void ftype_register_pseudofields_ieee_11073_float(int proto);
278
284 void ftype_register_pseudofields_integer(int proto);
285
291 void ftype_register_pseudofields_ipv4(int proto);
292
298 void ftype_register_pseudofields_ipv6(int proto);
299
305 void ftype_register_pseudofields_guid(int proto);
306
312 void ftype_register_pseudofields_none(int proto);
313
319 void ftype_register_pseudofields_string(int proto);
320
326 void ftype_register_pseudofields_time(int proto);
327
333 void ftype_register_pseudofields_tvbuff(int proto);
334
345GByteArray *
346 byte_array_from_literal(const char *s, char **err_msg);
347
355GByteArray *
356 byte_array_from_charconst(unsigned long num, char **err_msg);
357
369 char *
370 bytes_to_dfilter_repr(wmem_allocator_t *scope,
371 const uint8_t *src, size_t src_size);
372
373/*
374 * Editor modelines - https://www.wireshark.org/tools/modelines.html
375 *
376 * Local variables:
377 * c-basic-offset: 8
378 * tab-width: 8
379 * indent-tabs-mode: t
380 * End:
381 *
382 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
383 * :indentSize=8:tabSize=8:noTabs=false:
384 */
ftype_register_ipv4
void ftype_register_ipv4(void)
Registers IPv4 data type.
Definition ftype-ipv4.c:171
ftype_register_pseudofields_bytes
void ftype_register_pseudofields_bytes(int proto)
Registers pseudofields for byte-related data types.
Definition ftype-bytes.c:983
ftype_register_ipv6
void ftype_register_ipv6(void)
Registers IPv6 data type.
Definition ftype-ipv6.c:202
ftype_register_pseudofields_guid
void ftype_register_pseudofields_guid(int proto)
Registers pseudofields for GUID type.
Definition ftype-guid.c:152
ftype_register
void ftype_register(enum ftenum ftype, const ftype_t *ft)
Registers a field type handler for Wireshark.
Definition ftypes.c:59
ftype_register_pseudofields_string
void ftype_register_pseudofields_string(int proto)
Registers pseudofields for string types.
Definition ftype-string.c:511
byte_array_from_charconst
GByteArray * byte_array_from_charconst(unsigned long num, char **err_msg)
Convert an unsigned long to a byte array.
Definition ftype-bytes.c:223
ftype_register_pseudofields_tvbuff
void ftype_register_pseudofields_tvbuff(int proto)
Registers pseudofields for TVB (Protocol Data Unit) data.
Definition ftype-protocol.c:399
bytes_to_dfilter_repr
char * bytes_to_dfilter_repr(wmem_allocator_t *scope, const uint8_t *src, size_t src_size)
Convert bytes to a string representation suitable for display filters.
Definition ftype-bytes.c:79
ftype_register_guid
void ftype_register_guid(void)
Registers the GUID data type.
Definition ftype-guid.c:105
ftype_register_tvbuff
void ftype_register_tvbuff(void)
Registers a new ftype for TVB (Protocol Data Unit) data.
Definition ftype-protocol.c:351
ftype_register_pseudofields_ipv6
void ftype_register_pseudofields_ipv6(int proto)
Registers pseudofields for IPv6 data types.
Definition ftype-ipv6.c:248
ftype_register_pseudofields_ieee_11073_float
void ftype_register_pseudofields_ieee_11073_float(int proto)
Registers pseudofields for IEEE 11073 float type.
Definition ftype-ieee-11073-float.c:1259
ftype_register_ieee_11073_float
void ftype_register_ieee_11073_float(void)
Registers the IEEE 11073 float data type.
Definition ftype-ieee-11073-float.c:1103
ftype_register_pseudofields_integer
void ftype_register_pseudofields_integer(int proto)
Registers pseudofields for integer types.
Definition ftype-integer.c:1754
ftype_register_bytes
void ftype_register_bytes(void)
Registers the bytes data type handler for Wireshark.
Definition ftype-bytes.c:608
ftype_register_pseudofields_time
void ftype_register_pseudofields_time(int proto)
Registers pseudofields for time-related data types.
Definition ftype-time.c:781
byte_array_from_literal
GByteArray * byte_array_from_literal(const char *s, char **err_msg)
Convert a literal string to a GByteArray.
Definition ftype-bytes.c:157
ftype_register_pseudofields_none
void ftype_register_pseudofields_none(int proto)
Registers pseudofields for a protocol with no specific type.
Definition ftype-none.c:61
ftype_register_double
void ftype_register_double(void)
Registers the double data type handler for Wireshark.
Definition ftype-double.c:186
ftype_register_string
void ftype_register_string(void)
Registers string field types.
Definition ftype-string.c:263
ftype_register_time
void ftype_register_time(void)
Registers time-related field types.
Definition ftype-time.c:694
ftype_register_integers
void ftype_register_integers(void)
Registers all integer-related field types.
Definition ftype-integer.c:946
ftype_register_none
void ftype_register_none(void)
Registers the "none" data type.
Definition ftype-none.c:15
ftype_register_pseudofields_ipv4
void ftype_register_pseudofields_ipv4(int proto)
Registers pseudofields for IPv4 data types.
Definition ftype-ipv4.c:218
ftype_register_pseudofields_double
void ftype_register_pseudofields_double(int proto)
Registers pseudofields for double type.
Definition ftype-double.c:274
ftypes.h
protocol_value_t
struct _protocol_value_t protocol_value_t
Holds a protocol value's buffer and associated metadata for use in display filter evaluation.
ftenum_t
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
ftenum
ftenum
Fundamental field value types used throughout the Wireshark dissector framework.
Definition ftypes.h:26
FT_ENUM_SIZE
@ FT_ENUM_SIZE
Definition ftypes.h:75
ft_result
ft_result
Return codes for ftype operations such as conversion and comparison.
Definition ftypes.h:217
wmem_allocator_t
struct _wmem_allocator_t wmem_allocator_t
Definition wmem_core.h:44
e_guid_t
struct _e_guid_t e_guid_t
Represents a GUID/UUID value; may be larger than GUID_LEN so must not be used to directly overlay pac...
packet.h
proto.h
_ftype_t
Describes a field type and its associated operations for display filtering.
Definition ftypes-int.h:110
_ftype_t::val_to_double
FvalueToDouble val_to_double
Definition ftypes-int.h:129
_ftype_t::set_value_ipv6
FvalueSetIpv6Func set_value_ipv6
Definition ftypes-int.h:148
_ftype_t::val_from_charconst
FvalueFromCharConst val_from_charconst
Definition ftypes-int.h:120
_ftype_t::set_value_floating
FvalueSetFloatingFunc set_value_floating
Definition ftypes-int.h:146
_ftype_t::is_nan
FvalueIs is_nan
Definition ftypes-int.h:178
_ftype_t::get_value_uinteger
FvalueGetUnsignedIntegerFunc get_value_uinteger
Definition ftypes-int.h:162
_ftype_t::set_value_strbuf
FvalueSetStrbufFunc set_value_strbuf
Definition ftypes-int.h:140
_ftype_t::val_from_double
FvalueFromDouble val_from_double
Definition ftypes-int.h:123
_ftype_t::contains
FvalueContains contains
Definition ftypes-int.h:172
_ftype_t::set_value_sinteger64
FvalueSetSignedInteger64Func set_value_sinteger64
Definition ftypes-int.h:145
_ftype_t::subtract
FvalueBinaryOp subtract
Definition ftypes-int.h:185
_ftype_t::set_value
union _ftype_t::@040136201203000301012104120052321254150172251010 set_value
Union of function pointers for setting typed field values.
_ftype_t::compare
FvalueCompare compare
Definition ftypes-int.h:171
_ftype_t::get_value_sinteger
FvalueGetSignedIntegerFunc get_value_sinteger
Definition ftypes-int.h:163
_ftype_t::len
FvalueLen len
Definition ftypes-int.h:179
_ftype_t::is_negative
FvalueIs is_negative
Definition ftypes-int.h:177
_ftype_t::set_value_ipv4
FvalueSetIpv4Func set_value_ipv4
Definition ftypes-int.h:147
_ftype_t::get_value_ipv4
FvalueGetIpv4Func get_value_ipv4
Definition ftypes-int.h:167
_ftype_t::set_value_time
FvalueSetTimeFunc set_value_time
Definition ftypes-int.h:139
_ftype_t::free_value
FvalueFreeFunc free_value
Definition ftypes-int.h:116
_ftype_t::matches
FvalueMatches matches
Definition ftypes-int.h:173
_ftype_t::val_from_sinteger64
FvalueFromSignedInt64 val_from_sinteger64
Definition ftypes-int.h:122
_ftype_t::get_value_sinteger64
FvalueGetSignedInteger64Func get_value_sinteger64
Definition ftypes-int.h:165
_ftype_t::slice
FvalueSlice slice
Definition ftypes-int.h:180
_ftype_t::val_to_sinteger64
FvalueToSignedInt64 val_to_sinteger64
Definition ftypes-int.h:128
_ftype_t::val_from_literal
FvalueFromLiteral val_from_literal
Definition ftypes-int.h:118
_ftype_t::modulo
FvalueBinaryOp modulo
Definition ftypes-int.h:188
_ftype_t::val_from_uinteger64
FvalueFromUnsignedInt64 val_from_uinteger64
Definition ftypes-int.h:121
_ftype_t::get_value_protocol
FvalueGetProtocolFunc get_value_protocol
Definition ftypes-int.h:161
_ftype_t::set_value_guid
FvalueSetGuidFunc set_value_guid
Definition ftypes-int.h:138
_ftype_t::set_value_bytes
FvalueSetBytesFunc set_value_bytes
Definition ftypes-int.h:137
_ftype_t::divide
FvalueBinaryOp divide
Definition ftypes-int.h:187
_ftype_t::set_value_uinteger
FvalueSetUnsignedIntegerFunc set_value_uinteger
Definition ftypes-int.h:142
_ftype_t::val_from_string
FvalueFromString val_from_string
Definition ftypes-int.h:119
_ftype_t::bitwise_and
FvalueBinaryOp bitwise_and
Definition ftypes-int.h:182
_ftype_t::get_value_strbuf
FvalueGetStrbufFunc get_value_strbuf
Definition ftypes-int.h:160
_ftype_t::unary_minus
FvalueUnaryOp unary_minus
Definition ftypes-int.h:183
_ftype_t::set_value_uinteger64
FvalueSetUnsignedInteger64Func set_value_uinteger64
Definition ftypes-int.h:144
_ftype_t::set_value_protocol
FvalueSetProtocolFunc set_value_protocol
Definition ftypes-int.h:141
_ftype_t::wire_size
int wire_size
Definition ftypes-int.h:112
_ftype_t::multiply
FvalueBinaryOp multiply
Definition ftypes-int.h:186
_ftype_t::get_value_bytes
FvalueGetBytesFunc get_value_bytes
Definition ftypes-int.h:157
_ftype_t::val_to_uinteger64
FvalueToUnsignedInt64 val_to_uinteger64
Definition ftypes-int.h:127
_ftype_t::get_value_guid
FvalueGetGuidFunc get_value_guid
Definition ftypes-int.h:158
_ftype_t::ftype
ftenum_t ftype
Definition ftypes-int.h:111
_ftype_t::hash
FvalueHashFunc hash
Definition ftypes-int.h:175
_ftype_t::add
FvalueBinaryOp add
Definition ftypes-int.h:184
_ftype_t::get_value_uinteger64
FvalueGetUnsignedInteger64Func get_value_uinteger64
Definition ftypes-int.h:164
_ftype_t::get_value_ipv6
FvalueGetIpv6Func get_value_ipv6
Definition ftypes-int.h:168
_ftype_t::set_value_sinteger
FvalueSetSignedIntegerFunc set_value_sinteger
Definition ftypes-int.h:143
_ftype_t::val_to_string_repr
FvalueToStringRepr val_to_string_repr
Definition ftypes-int.h:125
_ftype_t::get_value_time
FvalueGetTimeFunc get_value_time
Definition ftypes-int.h:159
_ftype_t::copy_value
FvalueCopyFunc copy_value
Definition ftypes-int.h:115
_ftype_t::new_value
FvalueNewFunc new_value
Definition ftypes-int.h:114
_ftype_t::get_value_floating
FvalueGetFloatingFunc get_value_floating
Definition ftypes-int.h:166
_ftype_t::is_zero
FvalueIs is_zero
Definition ftypes-int.h:176
_fvalue_t
Represents a typed field value used in protocol dissection.
Definition ftypes-int.h:22
_fvalue_t::protocol
protocol_value_t protocol
Definition ftypes-int.h:35
_fvalue_t::floating
double floating
Definition ftypes-int.h:28
_fvalue_t::sinteger64
int64_t sinteger64
Definition ftypes-int.h:27
_fvalue_t::sfloat_ieee_11073
uint16_t sfloat_ieee_11073
Definition ftypes-int.h:36
_fvalue_t::ipv4
ipv4_addr_and_mask ipv4
Definition ftypes-int.h:31
_fvalue_t::uinteger64
uint64_t uinteger64
Definition ftypes-int.h:26
_fvalue_t::bytes
GBytes * bytes
Definition ftypes-int.h:30
_fvalue_t::value
union _fvalue_t::@261174046216355056107116147205130335061271165154 value
_fvalue_t::ipv6
ipv6_addr_and_prefix ipv6
Definition ftypes-int.h:32
_fvalue_t::guid
e_guid_t guid
Definition ftypes-int.h:33
_fvalue_t::ftype
const ftype_t * ftype
Definition ftypes-int.h:23
_fvalue_t::strbuf
wmem_strbuf_t * strbuf
Definition ftypes-int.h:29
_fvalue_t::float_ieee_11073
uint32_t float_ieee_11073
Definition ftypes-int.h:37
_fvalue_t::time
nstime_t time
Definition ftypes-int.h:34
ipv4_addr_and_mask
Holds an IPv4 address paired with its subnet mask, both in host byte order.
Definition inet_cidr.h:25
ipv6_addr_and_prefix
Holds an IPv6 address paired with its prefix length.
Definition inet_cidr.h:33
nstime_t
Definition nstime.h:26