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  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 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 char *(*FvalueToStringRepr)(wmem_allocator_t *, const fvalue_t*, ftrepr_t, int field_display);
52 
53 typedef enum ft_result (*FvalueToUnsignedInteger64Func)(const fvalue_t*, uint64_t *);
54 typedef enum ft_result (*FvalueToSignedInteger64Func)(const fvalue_t*, int64_t *);
55 
56 typedef void (*FvalueSetBytesFunc)(fvalue_t*, GBytes *);
57 typedef void (*FvalueSetGuidFunc)(fvalue_t*, const e_guid_t *);
58 typedef void (*FvalueSetTimeFunc)(fvalue_t*, const nstime_t *);
59 typedef void (*FvalueSetStrbufFunc)(fvalue_t*, wmem_strbuf_t *);
60 typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const char *name, int length);
61 typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, uint32_t);
62 typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, int32_t);
63 typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, uint64_t);
64 typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, int64_t);
65 typedef void (*FvalueSetFloatingFunc)(fvalue_t*, double);
66 typedef void (*FvalueSetIpv6Func)(fvalue_t*, const ipv6_addr_and_prefix *);
67 
68 typedef GBytes *(*FvalueGetBytesFunc)(fvalue_t*);
69 typedef const e_guid_t *(*FvalueGetGuidFunc)(fvalue_t*);
70 typedef const nstime_t *(*FvalueGetTimeFunc)(fvalue_t*);
71 typedef const wmem_strbuf_t *(*FvalueGetStrbufFunc)(fvalue_t*);
72 typedef tvbuff_t *(*FvalueGetProtocolFunc)(fvalue_t*);
73 typedef uint32_t (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
74 typedef int32_t (*FvalueGetSignedIntegerFunc)(fvalue_t*);
75 typedef uint64_t (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
76 typedef int64_t (*FvalueGetSignedInteger64Func)(fvalue_t*);
77 typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
78 typedef const ipv6_addr_and_prefix *(*FvalueGetIpv6Func)(fvalue_t*);
79 
80 typedef enum ft_result (*FvalueCompare)(const fvalue_t*, const fvalue_t*, int*);
81 typedef enum ft_result (*FvalueContains)(const fvalue_t*, const fvalue_t*, bool*);
82 typedef enum ft_result (*FvalueMatches)(const fvalue_t*, const ws_regex_t*, bool*);
83 
84 typedef bool (*FvalueIs)(const fvalue_t*);
85 typedef unsigned (*FvalueLen)(fvalue_t*);
86 typedef unsigned (*FvalueHashFunc)(const fvalue_t *);
87 typedef void (*FvalueSlice)(fvalue_t*, void *, unsigned offset, unsigned length);
88 typedef enum ft_result (*FvalueUnaryOp)(fvalue_t *, const fvalue_t*, char **);
89 typedef enum ft_result (*FvalueBinaryOp)(fvalue_t *, const fvalue_t*, const fvalue_t*, char **);
90 
91 struct _ftype_t {
92  ftenum_t ftype;
93  const char *name;
94  const char *pretty_name;
95  int wire_size;
96  FvalueNewFunc new_value;
97  FvalueCopyFunc copy_value;
98  FvalueFreeFunc free_value;
99  FvalueFromLiteral val_from_literal;
100  FvalueFromString val_from_string;
101  FvalueFromCharConst val_from_charconst;
102  FvalueToStringRepr val_to_string_repr;
103 
104  FvalueToUnsignedInteger64Func val_to_uinteger64;
105  FvalueToSignedInteger64Func val_to_sinteger64;
106 
107  union {
108  FvalueSetBytesFunc set_value_bytes;
109  FvalueSetGuidFunc set_value_guid;
110  FvalueSetTimeFunc set_value_time;
111  FvalueSetStrbufFunc set_value_strbuf;
112  FvalueSetProtocolFunc set_value_protocol;
113  FvalueSetUnsignedIntegerFunc set_value_uinteger;
114  FvalueSetSignedIntegerFunc set_value_sinteger;
115  FvalueSetUnsignedInteger64Func set_value_uinteger64;
116  FvalueSetSignedInteger64Func set_value_sinteger64;
117  FvalueSetFloatingFunc set_value_floating;
118  FvalueSetIpv6Func set_value_ipv6;
119  } set_value;
120 
121  union {
122  FvalueGetBytesFunc get_value_bytes;
123  FvalueGetGuidFunc get_value_guid;
124  FvalueGetTimeFunc get_value_time;
125  FvalueGetStrbufFunc get_value_strbuf;
126  FvalueGetProtocolFunc get_value_protocol;
127  FvalueGetUnsignedIntegerFunc get_value_uinteger;
128  FvalueGetSignedIntegerFunc get_value_sinteger;
129  FvalueGetUnsignedInteger64Func get_value_uinteger64;
130  FvalueGetSignedInteger64Func get_value_sinteger64;
131  FvalueGetFloatingFunc get_value_floating;
132  FvalueGetIpv6Func get_value_ipv6;
133  } get_value;
134 
135  FvalueCompare compare;
136  FvalueContains contains;
137  FvalueMatches matches;
138 
139  FvalueHashFunc hash;
140  FvalueIs is_zero;
141  FvalueIs is_negative;
142  FvalueLen len;
143  FvalueSlice slice;
144  FvalueBinaryOp bitwise_and;
145  FvalueUnaryOp unary_minus;
146  FvalueBinaryOp add;
147  FvalueBinaryOp subtract;
148  FvalueBinaryOp multiply;
149  FvalueBinaryOp divide;
150  FvalueBinaryOp modulo;
151 };
152 
153 void ftype_register(enum ftenum ftype, ftype_t *ft);
154 
155 void ftype_register_bytes(void);
156 void ftype_register_double(void);
157 void ftype_register_ieee_11073_float(void);
158 void ftype_register_integers(void);
159 void ftype_register_ipv4(void);
160 void ftype_register_ipv6(void);
161 void ftype_register_guid(void);
162 void ftype_register_none(void);
163 void ftype_register_string(void);
164 void ftype_register_time(void);
165 void ftype_register_tvbuff(void);
166 
167 /* For debugging. */
168 void ftype_register_pseudofields_bytes(int proto);
169 void ftype_register_pseudofields_double(int proto);
170 void ftype_register_pseudofields_ieee_11073_float(int proto);
171 void ftype_register_pseudofields_integer(int proto);
172 void ftype_register_pseudofields_ipv4(int proto);
173 void ftype_register_pseudofields_ipv6(int proto);
174 void ftype_register_pseudofields_guid(int proto);
175 void ftype_register_pseudofields_none(int proto);
176 void ftype_register_pseudofields_string(int proto);
177 void ftype_register_pseudofields_time(int proto);
178 void ftype_register_pseudofields_tvbuff(int proto);
179 
180 GByteArray *
181 byte_array_from_literal(const char *s, char **err_msg);
182 
183 GByteArray *
184 byte_array_from_charconst(unsigned long num, char **err_msg);
185 
186 char *
187 bytes_to_dfilter_repr(wmem_allocator_t *scope,
188  const uint8_t *src, size_t src_size);
189 
190 #endif /* FTYPES_INT_H */
191 
192 /*
193  * Editor modelines - https://www.wireshark.org/tools/modelines.html
194  *
195  * Local variables:
196  * c-basic-offset: 8
197  * tab-width: 8
198  * indent-tabs-mode: t
199  * End:
200  *
201  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
202  * :indentSize=8:tabSize=8:noTabs=false:
203  */
Definition: guid-utils.h:22
Definition: ftypes-int.h:91
Definition: ftypes-int.h:17
Definition: ftypes.h:283
Definition: wmem_allocator.h:27
Definition: wmem_strbuf.h:42
Definition: regex.c:17
Definition: ipv4.h:21
Definition: ipv6.h:22
Definition: nstime.h:26
Definition: tvbuff-int.h:35