Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
ftypes-int.h
Go to the documentation of this file.
1
10#ifndef FTYPES_INT_H
11#define FTYPES_INT_H
12
13#include "ftypes.h"
14#include <epan/proto.h>
15#include <epan/packet.h>
16
17struct _fvalue_t {
18 const ftype_t *ftype;
19 union {
20 /* Put a few basic types in here */
21 uint64_t uinteger64;
22 int64_t sinteger64;
23 double floating;
24 wmem_strbuf_t *strbuf;
25 GBytes *bytes;
28 e_guid_t guid;
29 nstime_t time;
30 protocol_value_t protocol;
31 uint16_t sfloat_ieee_11073;
32 uint32_t float_ieee_11073;
33 } value;
34};
35
36extern const ftype_t* type_list[FT_ENUM_SIZE + 1];
37
38/* Given an ftenum number, return an ftype_t* */
39#define FTYPE_LOOKUP(ftype, result) \
40 /* Check input */ \
41 ws_assert(ftype < FT_NUM_TYPES); \
42 result = type_list[ftype];
43
44typedef void (*FvalueNewFunc)(fvalue_t*);
45typedef void (*FvalueCopyFunc)(fvalue_t*, const fvalue_t*);
46typedef void (*FvalueFreeFunc)(fvalue_t*);
47
48typedef bool (*FvalueFromLiteral)(fvalue_t*, const char*, bool, char **);
49typedef bool (*FvalueFromString)(fvalue_t*, const char*, size_t, char **);
50typedef bool (*FvalueFromCharConst)(fvalue_t*, unsigned long, char **);
51typedef bool (*FvalueFromUnsignedInt64)(fvalue_t*, const char *, uint64_t, char **);
52typedef bool (*FvalueFromSignedInt64)(fvalue_t*, const char *, int64_t, char **);
53typedef bool (*FvalueFromDouble)(fvalue_t*, const char *, double, char **);
54
55typedef char *(*FvalueToStringRepr)(wmem_allocator_t *, const fvalue_t*, ftrepr_t, int field_display);
56
57typedef enum ft_result (*FvalueToUnsignedInt64)(const fvalue_t*, uint64_t *);
58typedef enum ft_result (*FvalueToSignedInt64)(const fvalue_t*, int64_t *);
59typedef enum ft_result (*FvalueToDouble)(const fvalue_t*, double *);
60
61typedef void (*FvalueSetBytesFunc)(fvalue_t*, GBytes *);
62typedef void (*FvalueSetGuidFunc)(fvalue_t*, const e_guid_t *);
63typedef void (*FvalueSetTimeFunc)(fvalue_t*, const nstime_t *);
64typedef void (*FvalueSetStrbufFunc)(fvalue_t*, wmem_strbuf_t *);
65typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const char *name, int length);
66typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, uint32_t);
67typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, int32_t);
68typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, uint64_t);
69typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, int64_t);
70typedef void (*FvalueSetFloatingFunc)(fvalue_t*, double);
71typedef void (*FvalueSetIpv4Func)(fvalue_t*, const ipv4_addr_and_mask *);
72typedef void (*FvalueSetIpv6Func)(fvalue_t*, const ipv6_addr_and_prefix *);
73
74typedef GBytes *(*FvalueGetBytesFunc)(fvalue_t*);
75typedef const e_guid_t *(*FvalueGetGuidFunc)(fvalue_t*);
76typedef const nstime_t *(*FvalueGetTimeFunc)(fvalue_t*);
77typedef const wmem_strbuf_t *(*FvalueGetStrbufFunc)(fvalue_t*);
78typedef tvbuff_t *(*FvalueGetProtocolFunc)(fvalue_t*);
79typedef uint32_t (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
80typedef int32_t (*FvalueGetSignedIntegerFunc)(fvalue_t*);
81typedef uint64_t (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
82typedef int64_t (*FvalueGetSignedInteger64Func)(fvalue_t*);
83typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
84typedef const ipv4_addr_and_mask *(*FvalueGetIpv4Func)(fvalue_t*);
85typedef const ipv6_addr_and_prefix *(*FvalueGetIpv6Func)(fvalue_t*);
86
87typedef enum ft_result (*FvalueCompare)(const fvalue_t*, const fvalue_t*, int*);
88typedef enum ft_result (*FvalueContains)(const fvalue_t*, const fvalue_t*, bool*);
89typedef enum ft_result (*FvalueMatches)(const fvalue_t*, const ws_regex_t*, bool*);
90
91typedef bool (*FvalueIs)(const fvalue_t*);
92typedef unsigned (*FvalueLen)(fvalue_t*);
93typedef unsigned (*FvalueHashFunc)(const fvalue_t *);
94typedef void (*FvalueSlice)(fvalue_t*, void *, unsigned offset, unsigned length);
95typedef enum ft_result (*FvalueUnaryOp)(fvalue_t *, const fvalue_t*, char **);
96typedef enum ft_result (*FvalueBinaryOp)(fvalue_t *, const fvalue_t*, const fvalue_t*, char **);
97
98struct _ftype_t {
99 ftenum_t ftype;
100 int wire_size;
101 FvalueNewFunc new_value;
102 FvalueCopyFunc copy_value;
103 FvalueFreeFunc free_value;
104
105 FvalueFromLiteral val_from_literal;
106 FvalueFromString val_from_string;
107 FvalueFromCharConst val_from_charconst;
108 FvalueFromUnsignedInt64 val_from_uinteger64;
109 FvalueFromSignedInt64 val_from_sinteger64;
110 FvalueFromDouble val_from_double;
111
112 FvalueToStringRepr val_to_string_repr;
113
114 FvalueToUnsignedInt64 val_to_uinteger64;
115 FvalueToSignedInt64 val_to_sinteger64;
116 FvalueToDouble val_to_double;
117
118 union {
119 FvalueSetBytesFunc set_value_bytes;
120 FvalueSetGuidFunc set_value_guid;
121 FvalueSetTimeFunc set_value_time;
122 FvalueSetStrbufFunc set_value_strbuf;
123 FvalueSetProtocolFunc set_value_protocol;
124 FvalueSetUnsignedIntegerFunc set_value_uinteger;
125 FvalueSetSignedIntegerFunc set_value_sinteger;
126 FvalueSetUnsignedInteger64Func set_value_uinteger64;
127 FvalueSetSignedInteger64Func set_value_sinteger64;
128 FvalueSetFloatingFunc set_value_floating;
129 FvalueSetIpv4Func set_value_ipv4;
130 FvalueSetIpv6Func set_value_ipv6;
131 } set_value;
132
133 union {
134 FvalueGetBytesFunc get_value_bytes;
135 FvalueGetGuidFunc get_value_guid;
136 FvalueGetTimeFunc get_value_time;
137 FvalueGetStrbufFunc get_value_strbuf;
138 FvalueGetProtocolFunc get_value_protocol;
139 FvalueGetUnsignedIntegerFunc get_value_uinteger;
140 FvalueGetSignedIntegerFunc get_value_sinteger;
141 FvalueGetUnsignedInteger64Func get_value_uinteger64;
142 FvalueGetSignedInteger64Func get_value_sinteger64;
143 FvalueGetFloatingFunc get_value_floating;
144 FvalueGetIpv4Func get_value_ipv4;
145 FvalueGetIpv6Func get_value_ipv6;
146 } get_value;
147
148 FvalueCompare compare;
149 FvalueContains contains;
150 FvalueMatches matches;
151
152 FvalueHashFunc hash;
153 FvalueIs is_zero;
154 FvalueIs is_negative;
155 FvalueLen len;
156 FvalueSlice slice;
157 FvalueBinaryOp bitwise_and;
158 FvalueUnaryOp unary_minus;
159 FvalueBinaryOp add;
160 FvalueBinaryOp subtract;
161 FvalueBinaryOp multiply;
162 FvalueBinaryOp divide;
163 FvalueBinaryOp modulo;
164};
165
166void ftype_register(enum ftenum ftype, const ftype_t *ft);
167
168void ftype_register_bytes(void);
169void ftype_register_double(void);
170void ftype_register_ieee_11073_float(void);
171void ftype_register_integers(void);
172void ftype_register_ipv4(void);
173void ftype_register_ipv6(void);
174void ftype_register_guid(void);
175void ftype_register_none(void);
176void ftype_register_string(void);
177void ftype_register_time(void);
178void ftype_register_tvbuff(void);
179
180/* For debugging. */
181void ftype_register_pseudofields_bytes(int proto);
182void ftype_register_pseudofields_double(int proto);
183void ftype_register_pseudofields_ieee_11073_float(int proto);
184void ftype_register_pseudofields_integer(int proto);
185void ftype_register_pseudofields_ipv4(int proto);
186void ftype_register_pseudofields_ipv6(int proto);
187void ftype_register_pseudofields_guid(int proto);
188void ftype_register_pseudofields_none(int proto);
189void ftype_register_pseudofields_string(int proto);
190void ftype_register_pseudofields_time(int proto);
191void ftype_register_pseudofields_tvbuff(int proto);
192
193GByteArray *
194byte_array_from_literal(const char *s, char **err_msg);
195
196GByteArray *
197byte_array_from_charconst(unsigned long num, char **err_msg);
198
199char *
200bytes_to_dfilter_repr(wmem_allocator_t *scope,
201 const uint8_t *src, size_t src_size);
202
203#endif /* FTYPES_INT_H */
204
205/*
206 * Editor modelines - https://www.wireshark.org/tools/modelines.html
207 *
208 * Local variables:
209 * c-basic-offset: 8
210 * tab-width: 8
211 * indent-tabs-mode: t
212 * End:
213 *
214 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
215 * :indentSize=8:tabSize=8:noTabs=false:
216 */
Definition guid-utils.h:23
Definition ftypes-int.h:98
Definition ftypes-int.h:17
Definition ftypes.h:299
Definition wmem_allocator.h:27
Definition wmem_strbuf.h:42
Definition regex.c:17
Definition inet_cidr.h:22
Definition inet_cidr.h:27
Definition nstime.h:26
Definition tvbuff-int.h:35