2 * Definitions for field types
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 2001 Gerald Combs
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include "ws_symbol_export.h"
32 #endif /* __cplusplus */
36 FT_NONE, /* used for text labels with no value */
38 FT_BOOLEAN, /* TRUE and FALSE come from <glib.h> */
41 FT_UINT24, /* really a UINT32, but displayed as 3 hex-digits if FD_HEX*/
43 FT_UINT40, /* really a UINT64, but displayed as 10 hex-digits if FD_HEX*/
44 FT_UINT48, /* really a UINT64, but displayed as 12 hex-digits if FD_HEX*/
45 FT_UINT56, /* really a UINT64, but displayed as 14 hex-digits if FD_HEX*/
49 FT_INT24, /* same as for UINT24 */
51 FT_INT40, /* same as for UINT40 */
52 FT_INT48, /* same as for UINT48 */
53 FT_INT56, /* same as for UINT56 */
62 FT_STRINGZ, /* for use with proto_tree_add_item() */
63 FT_UINT_STRING, /* for use with proto_tree_add_item() */
70 FT_FRAMENUM, /* a UINT32, but if selected lets you go to frame with that number */
71 FT_PCRE, /* a compiled Perl-Compatible Regular Expression object */
72 FT_GUID, /* GUID, UUID */
73 FT_OID, /* OBJECT IDENTIFIER */
77 FT_REL_OID, /* RELATIVE-OID */
79 FT_STRINGZPAD, /* for use with proto_tree_add_item() */
81 FT_NUM_TYPES /* last item number plus one */
84 #define IS_FT_INT(ft) ((ft)==FT_INT8||(ft)==FT_INT16||(ft)==FT_INT24||(ft)==FT_INT32||(ft)==FT_INT40||(ft)==FT_INT48||(ft)==FT_INT56||(ft)==FT_INT64)
85 #define IS_FT_UINT(ft) ((ft)==FT_UINT8||(ft)==FT_UINT16||(ft)==FT_UINT24||(ft)==FT_UINT32||(ft)==FT_UINT40||(ft)==FT_UINT48||(ft)==FT_UINT56||(ft)==FT_UINT64||(ft)==FT_FRAMENUM)
86 #define IS_FT_TIME(ft) ((ft)==FT_ABSOLUTE_TIME||(ft)==FT_RELATIVE_TIME)
87 #define IS_FT_STRING(ft) ((ft)==FT_STRING||(ft)==FT_STRINGZ||(ft)==FT_STRINGZPAD)
89 /* field types lengths */
90 #define FT_ETHER_LEN 6
91 #define FT_GUID_LEN 16
93 #define FT_IPv6_LEN 16
94 #define FT_IPXNET_LEN 4
95 #define FT_EUI64_LEN 8
96 #define FT_AX25_ADDR_LEN 7
97 #define FT_VINES_ADDR_LEN 6
98 #define FT_FCWWN_LEN 8
100 typedef enum ftenum ftenum_t;
102 enum ft_framenum_type {
105 FT_FRAMENUM_RESPONSE,
108 FT_FRAMENUM_NUM_TYPES /* last item number plus one */
111 typedef enum ft_framenum_type ft_framenum_type_t;
114 typedef struct _ftype_t ftype_t;
116 /* String representation types. */
122 typedef enum ftrepr ftrepr_t;
124 /* Initialize the ftypes subsytem. Called once. */
126 ftypes_initialize(void);
128 /* ---------------- FTYPE ----------------- */
130 /* given two types, are they similar - for example can two
131 * duplicate fields be registered of these two types. */
133 ftype_similar_types(const enum ftenum ftype_a, const enum ftenum ftype_b);
135 /* Return a string representing the name of the type */
138 ftype_name(ftenum_t ftype);
140 /* Return a string presenting a "pretty" representation of the
141 * name of the type. The pretty name means more to the user than
142 * that "FT_*" name. */
145 ftype_pretty_name(ftenum_t ftype);
147 /* Returns length of field in packet, or 0 if not determinable/defined. */
149 ftype_length(ftenum_t ftype);
153 ftype_can_slice(enum ftenum ftype);
157 ftype_can_eq(enum ftenum ftype);
161 ftype_can_ne(enum ftenum ftype);
165 ftype_can_gt(enum ftenum ftype);
169 ftype_can_ge(enum ftenum ftype);
173 ftype_can_lt(enum ftenum ftype);
177 ftype_can_le(enum ftenum ftype);
180 ftype_can_bitwise_and(enum ftenum ftype);
184 ftype_can_contains(enum ftenum ftype);
188 ftype_can_matches(enum ftenum ftype);
190 /* ---------------- FVALUE ----------------- */
192 #include <epan/ipv4.h>
193 #include <epan/ipv6.h>
194 #include <epan/guid-utils.h>
196 #include <epan/tvbuff.h>
197 #include <wsutil/nstime.h>
198 #include <epan/dfilter/drange.h>
200 typedef struct _fvalue_t {
203 /* Put a few basic types in here */
219 guint16 sfloat_ieee_11073;
220 guint32 float_ieee_11073;
223 /* The following is provided for private use
225 gboolean fvalue_gboolean1;
230 fvalue_new(ftenum_t ftype);
233 fvalue_init(fvalue_t *fv, ftenum_t ftype);
237 fvalue_from_unparsed(ftenum_t ftype, const char *s, gboolean allow_partial_value, gchar **err_msg);
240 fvalue_from_string(ftenum_t ftype, const char *s, gchar **err_msg);
242 /* Returns the length of the string required to hold the
243 * string representation of the the field value.
245 * Returns -1 if the string cannot be represented in the given rtype.
247 * The length DOES NOT include the terminating NUL. */
250 fvalue_string_repr_len(fvalue_t *fv, ftrepr_t rtype, int field_display);
252 /* Creates the string representation of the field value.
253 * If given non-NULL 'buf', the string is written at the memory
254 * location pointed to by 'buf'. If 'buf' is NULL, new memory
255 * is malloc'ed and the string representation is written there.
256 * The pointer to the beginning of the string representation is
257 * returned. If 'buf' was NULL, this points to the newly-allocated
258 * memory. if 'buf' was non-NULL, then the return value will be
261 * field_display parameter should be a BASE_ value (enum field_display_e)
262 * BASE_NONE should be used if field information isn't available.
264 * Returns NULL if the string cannot be represented in the given rtype.*/
266 fvalue_to_string_repr(fvalue_t *fv, ftrepr_t rtype, int field_display, char *buf);
268 WS_DLL_PUBLIC ftenum_t
269 fvalue_type_ftenum(fvalue_t *fv);
272 fvalue_type_name(fvalue_t *fv);
275 fvalue_set_byte_array(fvalue_t *fv, GByteArray *value);
278 fvalue_set_bytes(fvalue_t *fv, const guint8 *value);
281 fvalue_set_guid(fvalue_t *fv, const e_guid_t *value);
284 fvalue_set_time(fvalue_t *fv, const nstime_t *value);
287 fvalue_set_string(fvalue_t *fv, const gchar *value);
290 fvalue_set_tvbuff(fvalue_t *fv, tvbuff_t *value);
293 fvalue_set_uinteger(fvalue_t *fv, guint32 value);
296 fvalue_set_sinteger(fvalue_t *fv, gint32 value);
299 fvalue_set_uinteger64(fvalue_t *fv, guint64 value);
302 fvalue_set_sinteger64(fvalue_t *fv, gint64 value);
305 fvalue_set_floating(fvalue_t *fv, gdouble value);
309 fvalue_get(fvalue_t *fv);
311 WS_DLL_PUBLIC guint32
312 fvalue_get_uinteger(fvalue_t *fv);
315 fvalue_get_sinteger(fvalue_t *fv);
319 fvalue_get_uinteger64(fvalue_t *fv);
323 fvalue_get_sinteger64(fvalue_t *fv);
326 fvalue_get_floating(fvalue_t *fv);
329 fvalue_eq(const fvalue_t *a, const fvalue_t *b);
332 fvalue_ne(const fvalue_t *a, const fvalue_t *b);
335 fvalue_gt(const fvalue_t *a, const fvalue_t *b);
338 fvalue_ge(const fvalue_t *a, const fvalue_t *b);
341 fvalue_lt(const fvalue_t *a, const fvalue_t *b);
344 fvalue_le(const fvalue_t *a, const fvalue_t *b);
347 fvalue_bitwise_and(const fvalue_t *a, const fvalue_t *b);
350 fvalue_contains(const fvalue_t *a, const fvalue_t *b);
353 fvalue_matches(const fvalue_t *a, const fvalue_t *b);
356 fvalue_length(fvalue_t *fv);
359 fvalue_slice(fvalue_t *fv, drange_t *dr);
363 #endif /* __cplusplus */
365 #endif /* __FTYPES_H__ */
368 * Editor modelines - http://www.wireshark.org/tools/modelines.html
373 * indent-tabs-mode: t
376 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
377 * :indentSize=8:tabSize=8:noTabs=false: