Wireshark 4.7.0
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
40
41extern 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_assert(ftype < FT_NUM_TYPES); \
47 result = type_list[ftype];
48
49typedef void (*FvalueNewFunc)(fvalue_t*);
50typedef void (*FvalueCopyFunc)(fvalue_t*, const fvalue_t*);
51typedef void (*FvalueFreeFunc)(fvalue_t*);
52
53typedef bool (*FvalueFromLiteral)(fvalue_t*, const char*, bool, char **);
54typedef bool (*FvalueFromString)(fvalue_t*, const char*, size_t, char **);
55typedef bool (*FvalueFromCharConst)(fvalue_t*, unsigned long, char **);
56typedef bool (*FvalueFromUnsignedInt64)(fvalue_t*, const char *, uint64_t, char **);
57typedef bool (*FvalueFromSignedInt64)(fvalue_t*, const char *, int64_t, char **);
58typedef bool (*FvalueFromDouble)(fvalue_t*, const char *, double, char **);
59
60typedef char *(*FvalueToStringRepr)(wmem_allocator_t *, const fvalue_t*, ftrepr_t, int field_display);
61
62typedef enum ft_result (*FvalueToUnsignedInt64)(const fvalue_t*, uint64_t *);
63typedef enum ft_result (*FvalueToSignedInt64)(const fvalue_t*, int64_t *);
64typedef enum ft_result (*FvalueToDouble)(const fvalue_t*, double *);
65
66typedef void (*FvalueSetBytesFunc)(fvalue_t*, GBytes *);
67typedef void (*FvalueSetGuidFunc)(fvalue_t*, const e_guid_t *);
68typedef void (*FvalueSetTimeFunc)(fvalue_t*, const nstime_t *);
69typedef void (*FvalueSetStrbufFunc)(fvalue_t*, wmem_strbuf_t *);
70typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const char *name, int length);
71typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, uint32_t);
72typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, int32_t);
73typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, uint64_t);
74typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, int64_t);
75typedef void (*FvalueSetFloatingFunc)(fvalue_t*, double);
76typedef void (*FvalueSetIpv4Func)(fvalue_t*, const ipv4_addr_and_mask *);
77typedef void (*FvalueSetIpv6Func)(fvalue_t*, const ipv6_addr_and_prefix *);
78
79typedef GBytes *(*FvalueGetBytesFunc)(fvalue_t*);
80typedef const e_guid_t *(*FvalueGetGuidFunc)(fvalue_t*);
81typedef const nstime_t *(*FvalueGetTimeFunc)(fvalue_t*);
82typedef const wmem_strbuf_t *(*FvalueGetStrbufFunc)(fvalue_t*);
83typedef tvbuff_t *(*FvalueGetProtocolFunc)(fvalue_t*);
84typedef uint32_t (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
85typedef int32_t (*FvalueGetSignedIntegerFunc)(fvalue_t*);
86typedef uint64_t (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
87typedef int64_t (*FvalueGetSignedInteger64Func)(fvalue_t*);
88typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
89typedef const ipv4_addr_and_mask *(*FvalueGetIpv4Func)(fvalue_t*);
90typedef const ipv6_addr_and_prefix *(*FvalueGetIpv6Func)(fvalue_t*);
91
92typedef enum ft_result (*FvalueCompare)(const fvalue_t*, const fvalue_t*, int*);
93typedef enum ft_result (*FvalueContains)(const fvalue_t*, const fvalue_t*, bool*);
94typedef enum ft_result (*FvalueMatches)(const fvalue_t*, const ws_regex_t*, bool*);
95
96typedef bool (*FvalueIs)(const fvalue_t*);
97typedef unsigned (*FvalueLen)(fvalue_t*);
98typedef unsigned (*FvalueHashFunc)(const fvalue_t *);
99typedef void (*FvalueSlice)(fvalue_t*, void *, unsigned offset, unsigned length);
100typedef enum ft_result (*FvalueUnaryOp)(fvalue_t *, const fvalue_t*, char **);
101typedef enum ft_result (*FvalueBinaryOp)(fvalue_t *, const fvalue_t*, const fvalue_t*, char **);
102
110struct _ftype_t {
114 FvalueNewFunc new_value;
115 FvalueCopyFunc copy_value;
116 FvalueFreeFunc free_value;
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;
125 FvalueToStringRepr val_to_string_repr;
127 FvalueToUnsignedInt64 val_to_uinteger64;
128 FvalueToSignedInt64 val_to_sinteger64;
129 FvalueToDouble val_to_double;
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;
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;
170
171 FvalueCompare compare;
172 FvalueContains contains;
173 FvalueMatches matches;
175 FvalueHashFunc hash;
176 FvalueIs is_zero;
177 FvalueIs is_negative;
178 FvalueIs is_nan;
179 FvalueLen len;
180 FvalueSlice slice;
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
199void ftype_register(enum ftenum ftype, const ftype_t *ft);
200
204void ftype_register_bytes(void);
205
209void ftype_register_double(void);
210
215
219void ftype_register_integers(void);
220
224void ftype_register_ipv4(void);
225
229void ftype_register_ipv6(void);
230
234void ftype_register_guid(void);
235
239void ftype_register_none(void);
240
244void ftype_register_string(void);
245
249void ftype_register_time(void);
250
254void ftype_register_tvbuff(void);
255
256/* For debugging. */
257
264
271
278
285
292
299
306
313
320
327
334
345GByteArray *
346byte_array_from_literal(const char *s, char **err_msg);
347
355GByteArray *
356byte_array_from_charconst(unsigned long num, char **err_msg);
357
369char *
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 */
void ftype_register_ipv4(void)
Registers IPv4 data type.
Definition ftype-ipv4.c:171
void ftype_register_pseudofields_bytes(int proto)
Registers pseudofields for byte-related data types.
Definition ftype-bytes.c:983
void ftype_register_ipv6(void)
Registers IPv6 data type.
Definition ftype-ipv6.c:202
void ftype_register_pseudofields_guid(int proto)
Registers pseudofields for GUID type.
Definition ftype-guid.c:152
void ftype_register(enum ftenum ftype, const ftype_t *ft)
Registers a field type handler for Wireshark.
Definition ftypes.c:59
void ftype_register_pseudofields_string(int proto)
Registers pseudofields for string types.
Definition ftype-string.c:511
GByteArray * byte_array_from_charconst(unsigned long num, char **err_msg)
Convert an unsigned long to a byte array.
Definition ftype-bytes.c:223
void ftype_register_pseudofields_tvbuff(int proto)
Registers pseudofields for TVB (Protocol Data Unit) data.
Definition ftype-protocol.c:416
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
void ftype_register_guid(void)
Registers the GUID data type.
Definition ftype-guid.c:105
void ftype_register_tvbuff(void)
Registers a new ftype for TVB (Protocol Data Unit) data.
Definition ftype-protocol.c:368
void ftype_register_pseudofields_ipv6(int proto)
Registers pseudofields for IPv6 data types.
Definition ftype-ipv6.c:248
void ftype_register_pseudofields_ieee_11073_float(int proto)
Registers pseudofields for IEEE 11073 float type.
Definition ftype-ieee-11073-float.c:1259
void ftype_register_ieee_11073_float(void)
Registers the IEEE 11073 float data type.
Definition ftype-ieee-11073-float.c:1103
void ftype_register_pseudofields_integer(int proto)
Registers pseudofields for integer types.
Definition ftype-integer.c:1754
void ftype_register_bytes(void)
Registers the bytes data type handler for Wireshark.
Definition ftype-bytes.c:608
void ftype_register_pseudofields_time(int proto)
Registers pseudofields for time-related data types.
Definition ftype-time.c:776
GByteArray * byte_array_from_literal(const char *s, char **err_msg)
Convert a literal string to a GByteArray.
Definition ftype-bytes.c:157
void ftype_register_pseudofields_none(int proto)
Registers pseudofields for a protocol with no specific type.
Definition ftype-none.c:61
void ftype_register_double(void)
Registers the double data type handler for Wireshark.
Definition ftype-double.c:186
void ftype_register_string(void)
Registers string field types.
Definition ftype-string.c:263
void ftype_register_time(void)
Registers time-related field types.
Definition ftype-time.c:689
void ftype_register_integers(void)
Registers all integer-related field types.
Definition ftype-integer.c:946
void ftype_register_none(void)
Registers the "none" data type.
Definition ftype-none.c:15
void ftype_register_pseudofields_ipv4(int proto)
Registers pseudofields for IPv4 data types.
Definition ftype-ipv4.c:218
void ftype_register_pseudofields_double(int proto)
Registers pseudofields for double type.
Definition ftype-double.c:274
enum ftenum ftenum_t
Convenience typedef for ftenum.
Definition ftypes.h:190
ftenum
Fundamental field value types used throughout the Wireshark dissector framework.
Definition ftypes.h:26
@ FT_ENUM_SIZE
Definition ftypes.h:75
ft_result
Return codes for ftype operations such as conversion and comparison.
Definition ftypes.h:217
Represents a GUID/UUID value; may be larger than GUID_LEN so must not be used to directly overlay pac...
Definition guid-utils.h:21
Describes a field type and its associated operations for display filtering.
Definition ftypes-int.h:110
FvalueToDouble val_to_double
Definition ftypes-int.h:129
FvalueSetIpv6Func set_value_ipv6
Definition ftypes-int.h:148
FvalueFromCharConst val_from_charconst
Definition ftypes-int.h:120
FvalueSetFloatingFunc set_value_floating
Definition ftypes-int.h:146
FvalueIs is_nan
Definition ftypes-int.h:178
FvalueGetUnsignedIntegerFunc get_value_uinteger
Definition ftypes-int.h:162
FvalueSetStrbufFunc set_value_strbuf
Definition ftypes-int.h:140
FvalueFromDouble val_from_double
Definition ftypes-int.h:123
FvalueContains contains
Definition ftypes-int.h:172
union _ftype_t::@481 set_value
Union of function pointers for setting typed field values.
FvalueSetSignedInteger64Func set_value_sinteger64
Definition ftypes-int.h:145
FvalueBinaryOp subtract
Definition ftypes-int.h:185
FvalueCompare compare
Definition ftypes-int.h:171
FvalueGetSignedIntegerFunc get_value_sinteger
Definition ftypes-int.h:163
FvalueLen len
Definition ftypes-int.h:179
FvalueIs is_negative
Definition ftypes-int.h:177
FvalueSetIpv4Func set_value_ipv4
Definition ftypes-int.h:147
FvalueGetIpv4Func get_value_ipv4
Definition ftypes-int.h:167
FvalueSetTimeFunc set_value_time
Definition ftypes-int.h:139
FvalueFreeFunc free_value
Definition ftypes-int.h:116
FvalueMatches matches
Definition ftypes-int.h:173
FvalueFromSignedInt64 val_from_sinteger64
Definition ftypes-int.h:122
FvalueGetSignedInteger64Func get_value_sinteger64
Definition ftypes-int.h:165
FvalueSlice slice
Definition ftypes-int.h:180
FvalueToSignedInt64 val_to_sinteger64
Definition ftypes-int.h:128
FvalueFromLiteral val_from_literal
Definition ftypes-int.h:118
FvalueBinaryOp modulo
Definition ftypes-int.h:188
FvalueFromUnsignedInt64 val_from_uinteger64
Definition ftypes-int.h:121
FvalueGetProtocolFunc get_value_protocol
Definition ftypes-int.h:161
FvalueSetGuidFunc set_value_guid
Definition ftypes-int.h:138
FvalueSetBytesFunc set_value_bytes
Definition ftypes-int.h:137
FvalueBinaryOp divide
Definition ftypes-int.h:187
FvalueSetUnsignedIntegerFunc set_value_uinteger
Definition ftypes-int.h:142
FvalueFromString val_from_string
Definition ftypes-int.h:119
FvalueBinaryOp bitwise_and
Definition ftypes-int.h:182
FvalueGetStrbufFunc get_value_strbuf
Definition ftypes-int.h:160
FvalueUnaryOp unary_minus
Definition ftypes-int.h:183
FvalueSetUnsignedInteger64Func set_value_uinteger64
Definition ftypes-int.h:144
FvalueSetProtocolFunc set_value_protocol
Definition ftypes-int.h:141
int wire_size
Definition ftypes-int.h:112
FvalueBinaryOp multiply
Definition ftypes-int.h:186
FvalueGetBytesFunc get_value_bytes
Definition ftypes-int.h:157
FvalueToUnsignedInt64 val_to_uinteger64
Definition ftypes-int.h:127
FvalueGetGuidFunc get_value_guid
Definition ftypes-int.h:158
ftenum_t ftype
Definition ftypes-int.h:111
FvalueHashFunc hash
Definition ftypes-int.h:175
FvalueBinaryOp add
Definition ftypes-int.h:184
FvalueGetUnsignedInteger64Func get_value_uinteger64
Definition ftypes-int.h:164
FvalueGetIpv6Func get_value_ipv6
Definition ftypes-int.h:168
FvalueSetSignedIntegerFunc set_value_sinteger
Definition ftypes-int.h:143
FvalueToStringRepr val_to_string_repr
Definition ftypes-int.h:125
FvalueGetTimeFunc get_value_time
Definition ftypes-int.h:159
union _ftype_t::@482 get_value
Union of function pointers for retrieving typed field values.
FvalueCopyFunc copy_value
Definition ftypes-int.h:115
FvalueNewFunc new_value
Definition ftypes-int.h:114
FvalueGetFloatingFunc get_value_floating
Definition ftypes-int.h:166
FvalueIs is_zero
Definition ftypes-int.h:176
Represents a typed field value used in protocol dissection.
Definition ftypes-int.h:22
protocol_value_t protocol
Definition ftypes-int.h:35
double floating
Definition ftypes-int.h:28
int64_t sinteger64
Definition ftypes-int.h:27
uint16_t sfloat_ieee_11073
Definition ftypes-int.h:36
ipv4_addr_and_mask ipv4
Definition ftypes-int.h:31
uint64_t uinteger64
Definition ftypes-int.h:26
GBytes * bytes
Definition ftypes-int.h:30
ipv6_addr_and_prefix ipv6
Definition ftypes-int.h:32
e_guid_t guid
Definition ftypes-int.h:33
const ftype_t * ftype
Definition ftypes-int.h:23
wmem_strbuf_t * strbuf
Definition ftypes-int.h:29
union _fvalue_t::@480 value
uint32_t float_ieee_11073
Definition ftypes-int.h:37
nstime_t time
Definition ftypes-int.h:34
Holds a protocol value's buffer and associated metadata for use in display filter evaluation.
Definition ftypes.h:552
Internal memory allocator interface used by the wmem subsystem.
Definition wmem_allocator.h:34
Internal structure representing a wmem-allocated string buffer.
Definition wmem_strbuf.h:38
Definition regex.c:17
Definition inet_cidr.h:22
Definition inet_cidr.h:27
Definition nstime.h:26
Core tvbuff (testy virtual buffer) structure representing a region of packet data,...
Definition tvbuff-int.h:95