Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
ftypes-int.h
1 /*
2  * Wireshark - Network traffic analyzer
3  * By Gerald Combs <gerald@wireshark.org>
4  * Copyright 2001 Gerald Combs
5  *
6  * SPDX-License-Identifier: GPL-2.0-or-later
7  */
8 
9 #ifndef FTYPES_INT_H
10 #define FTYPES_INT_H
11 
12 #include <epan/proto.h>
13 #include "ftypes.h"
14 
15 
16 void
17 ftype_register(enum ftenum ftype, ftype_t *ft);
18 
19 /* These are the ftype registration functions that need to be called.
20  * This list and the initialization function could be produced
21  * via a script, like the dissector registration, but there's so few
22  * that I don't mind doing it by hand for now. */
23 void ftype_register_bytes(void);
24 void ftype_register_double(void);
25 void ftype_register_ieee_11073_float(void);
26 void ftype_register_fc(void);
27 void ftype_register_integers(void);
28 void ftype_register_ipv4(void);
29 void ftype_register_ipv6(void);
30 void ftype_register_guid(void);
31 void ftype_register_none(void);
32 void ftype_register_string(void);
33 void ftype_register_time(void);
34 void ftype_register_tvbuff(void);
35 void ftype_register_pcre(void);
36 
37 typedef void (*FvalueNewFunc)(fvalue_t*);
38 typedef void (*FvalueFreeFunc)(fvalue_t*);
39 
40 typedef gboolean (*FvalueFromUnparsed)(fvalue_t*, const char*, gboolean, gchar **);
41 typedef gboolean (*FvalueFromString)(fvalue_t*, const char*, gchar **);
42 typedef void (*FvalueToStringRepr)(fvalue_t*, ftrepr_t, int field_display, char*volatile, unsigned int);
43 typedef int (*FvalueStringReprLen)(fvalue_t*, ftrepr_t, int field_display);
44 
45 typedef void (*FvalueSetByteArrayFunc)(fvalue_t*, GByteArray *);
46 typedef void (*FvalueSetBytesFunc)(fvalue_t*, const guint8 *);
47 typedef void (*FvalueSetGuidFunc)(fvalue_t*, const e_guid_t *);
48 typedef void (*FvalueSetTimeFunc)(fvalue_t*, const nstime_t *);
49 typedef void (*FvalueSetStringFunc)(fvalue_t*, const gchar *value);
50 typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const gchar *name);
51 typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, guint32);
52 typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, gint32);
53 typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, guint64);
54 typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, gint64);
55 typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble);
56 
57 typedef gpointer (*FvalueGetFunc)(fvalue_t*);
58 typedef guint32 (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
59 typedef gint32 (*FvalueGetSignedIntegerFunc)(fvalue_t*);
60 typedef guint64 (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
61 typedef gint64 (*FvalueGetSignedInteger64Func)(fvalue_t*);
62 typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
63 
64 typedef gboolean (*FvalueCmp)(const fvalue_t*, const fvalue_t*);
65 
66 typedef guint (*FvalueLen)(fvalue_t*);
67 typedef void (*FvalueSlice)(fvalue_t*, GByteArray *, guint offset, guint length);
68 
69 struct _ftype_t {
70  ftenum_t ftype;
71  const char *name;
72  const char *pretty_name;
73  int wire_size;
74  FvalueNewFunc new_value;
75  FvalueFreeFunc free_value;
76  FvalueFromUnparsed val_from_unparsed;
77  FvalueFromString val_from_string;
78  FvalueToStringRepr val_to_string_repr;
79  FvalueStringReprLen len_string_repr;
80 
81  union {
82  FvalueSetByteArrayFunc set_value_byte_array;
83  FvalueSetBytesFunc set_value_bytes;
84  FvalueSetGuidFunc set_value_guid;
85  FvalueSetTimeFunc set_value_time;
86  FvalueSetStringFunc set_value_string;
87  FvalueSetProtocolFunc set_value_protocol;
88  FvalueSetUnsignedIntegerFunc set_value_uinteger;
89  FvalueSetSignedIntegerFunc set_value_sinteger;
90  FvalueSetUnsignedInteger64Func set_value_uinteger64;
91  FvalueSetSignedInteger64Func set_value_sinteger64;
92  FvalueSetFloatingFunc set_value_floating;
93  } set_value;
94 
95  union {
96  FvalueGetFunc get_value_ptr;
97  FvalueGetUnsignedIntegerFunc get_value_uinteger;
98  FvalueGetSignedIntegerFunc get_value_sinteger;
99  FvalueGetUnsignedInteger64Func get_value_uinteger64;
100  FvalueGetSignedInteger64Func get_value_sinteger64;
101  FvalueGetFloatingFunc get_value_floating;
102  } get_value;
103 
104  FvalueCmp cmp_eq;
105  FvalueCmp cmp_ne;
106  FvalueCmp cmp_gt;
107  FvalueCmp cmp_ge;
108  FvalueCmp cmp_lt;
109  FvalueCmp cmp_le;
110  FvalueCmp cmp_bitwise_and;
111  FvalueCmp cmp_contains;
112  FvalueCmp cmp_matches;
113 
114  FvalueLen len;
115  FvalueSlice slice;
116 };
117 
118 /* Free all memory used by an fvalue_t. With MSVC and a
119  * libwireshark.dll, we need a special declaration.
120  */
121 
122 #define FVALUE_CLEANUP(fv) \
123  { \
124  register FvalueFreeFunc free_value; \
125  free_value = (fv)->ftype->free_value; \
126  if (free_value) { \
127  free_value((fv)); \
128  } \
129  }
130 
131 #define FVALUE_FREE(fv) \
132  { \
133  FVALUE_CLEANUP(fv) \
134  g_slice_free(fvalue_t, fv); \
135  }
136 
137 #endif
138 
139 /*
140  * Editor modelines - http://www.wireshark.org/tools/modelines.html
141  *
142  * Local variables:
143  * c-basic-offset: 8
144  * tab-width: 8
145  * indent-tabs-mode: t
146  * End:
147  *
148  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
149  * :indentSize=8:tabSize=8:noTabs=false:
150  */
Definition: ftypes-int.h:69
Definition: tvbuff-int.h:35
Definition: nstime.h:27
Definition: guid-utils.h:21
Definition: ftypes.h:200