Wireshark  4.3.0
The Wireshark network protocol analyzer
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 
17 struct _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;
26  ipv4_addr_and_mask ipv4;
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 
36 extern const ftype_t* type_list[FT_NUM_TYPES];
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 
44 typedef void (*FvalueNewFunc)(fvalue_t*);
45 typedef void (*FvalueCopyFunc)(fvalue_t*, const fvalue_t*);
46 typedef void (*FvalueFreeFunc)(fvalue_t*);
47 
48 typedef bool (*FvalueFromLiteral)(fvalue_t*, const char*, bool, char **);
49 typedef bool (*FvalueFromString)(fvalue_t*, const char*, size_t, char **);
50 typedef bool (*FvalueFromCharConst)(fvalue_t*, unsigned long, char **);
51 typedef bool (*FvalueFromUnsignedInt64)(fvalue_t*, const char *, uint64_t, char **);
52 typedef bool (*FvalueFromSignedInt64)(fvalue_t*, const char *, int64_t, char **);
53 typedef bool (*FvalueFromDouble)(fvalue_t*, const char *, double, char **);
54 
55 typedef char *(*FvalueToStringRepr)(wmem_allocator_t *, const fvalue_t*, ftrepr_t, int field_display);
56 
57 typedef enum ft_result (*FvalueToUnsignedInt64)(const fvalue_t*, uint64_t *);
58 typedef enum ft_result (*FvalueToSignedInt64)(const fvalue_t*, int64_t *);
59 typedef enum ft_result (*FvalueToDouble)(const fvalue_t*, double *);
60 
61 typedef void (*FvalueSetBytesFunc)(fvalue_t*, GBytes *);
62 typedef void (*FvalueSetGuidFunc)(fvalue_t*, const e_guid_t *);
63 typedef void (*FvalueSetTimeFunc)(fvalue_t*, const nstime_t *);
64 typedef void (*FvalueSetStrbufFunc)(fvalue_t*, wmem_strbuf_t *);
65 typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const char *name, int length);
66 typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, uint32_t);
67 typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, int32_t);
68 typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, uint64_t);
69 typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, int64_t);
70 typedef void (*FvalueSetFloatingFunc)(fvalue_t*, double);
71 typedef void (*FvalueSetIpv4Func)(fvalue_t*, const ipv4_addr_and_mask *);
72 typedef void (*FvalueSetIpv6Func)(fvalue_t*, const ipv6_addr_and_prefix *);
73 
74 typedef GBytes *(*FvalueGetBytesFunc)(fvalue_t*);
75 typedef const e_guid_t *(*FvalueGetGuidFunc)(fvalue_t*);
76 typedef const nstime_t *(*FvalueGetTimeFunc)(fvalue_t*);
77 typedef const wmem_strbuf_t *(*FvalueGetStrbufFunc)(fvalue_t*);
78 typedef tvbuff_t *(*FvalueGetProtocolFunc)(fvalue_t*);
79 typedef uint32_t (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
80 typedef int32_t (*FvalueGetSignedIntegerFunc)(fvalue_t*);
81 typedef uint64_t (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
82 typedef int64_t (*FvalueGetSignedInteger64Func)(fvalue_t*);
83 typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
84 typedef const ipv4_addr_and_mask *(*FvalueGetIpv4Func)(fvalue_t*);
85 typedef const ipv6_addr_and_prefix *(*FvalueGetIpv6Func)(fvalue_t*);
86 
87 typedef enum ft_result (*FvalueCompare)(const fvalue_t*, const fvalue_t*, int*);
88 typedef enum ft_result (*FvalueContains)(const fvalue_t*, const fvalue_t*, bool*);
89 typedef enum ft_result (*FvalueMatches)(const fvalue_t*, const ws_regex_t*, bool*);
90 
91 typedef bool (*FvalueIs)(const fvalue_t*);
92 typedef unsigned (*FvalueLen)(fvalue_t*);
93 typedef unsigned (*FvalueHashFunc)(const fvalue_t *);
94 typedef void (*FvalueSlice)(fvalue_t*, void *, unsigned offset, unsigned length);
95 typedef enum ft_result (*FvalueUnaryOp)(fvalue_t *, const fvalue_t*, char **);
96 typedef enum ft_result (*FvalueBinaryOp)(fvalue_t *, const fvalue_t*, const fvalue_t*, char **);
97 
98 struct _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 
166 void ftype_register(enum ftenum ftype, const ftype_t *ft);
167 
168 void ftype_register_bytes(void);
169 void ftype_register_double(void);
170 void ftype_register_ieee_11073_float(void);
171 void ftype_register_integers(void);
172 void ftype_register_ipv4(void);
173 void ftype_register_ipv6(void);
174 void ftype_register_guid(void);
175 void ftype_register_none(void);
176 void ftype_register_string(void);
177 void ftype_register_time(void);
178 void ftype_register_tvbuff(void);
179 
180 /* For debugging. */
181 void ftype_register_pseudofields_bytes(int proto);
182 void ftype_register_pseudofields_double(int proto);
183 void ftype_register_pseudofields_ieee_11073_float(int proto);
184 void ftype_register_pseudofields_integer(int proto);
185 void ftype_register_pseudofields_ipv4(int proto);
186 void ftype_register_pseudofields_ipv6(int proto);
187 void ftype_register_pseudofields_guid(int proto);
188 void ftype_register_pseudofields_none(int proto);
189 void ftype_register_pseudofields_string(int proto);
190 void ftype_register_pseudofields_time(int proto);
191 void ftype_register_pseudofields_tvbuff(int proto);
192 
193 GByteArray *
194 byte_array_from_literal(const char *s, char **err_msg);
195 
196 GByteArray *
197 byte_array_from_charconst(unsigned long num, char **err_msg);
198 
199 char *
200 bytes_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:22
Definition: ftypes-int.h:98
Definition: ftypes-int.h:17
Definition: ftypes.h:297
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