2021-11-30 04:18:35 +00:00
|
|
|
/** @file
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-02-01 20:31:21 +00:00
|
|
|
* Copyright 2001 Gerald Combs
|
2002-08-28 20:41:00 +00:00
|
|
|
*
|
2018-02-08 16:59:17 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2001-02-01 20:31:21 +00:00
|
|
|
*/
|
|
|
|
|
2001-02-01 20:21:25 +00:00
|
|
|
#ifndef FTYPES_INT_H
|
|
|
|
#define FTYPES_INT_H
|
|
|
|
|
|
|
|
#include "ftypes.h"
|
2021-11-11 09:38:50 +00:00
|
|
|
#include <epan/proto.h>
|
2021-12-07 15:02:00 +00:00
|
|
|
#include <epan/packet.h>
|
2005-07-23 06:21:17 +00:00
|
|
|
|
2022-02-27 09:56:41 +00:00
|
|
|
extern ftype_t* type_list[FT_NUM_TYPES];
|
|
|
|
|
|
|
|
/* Given an ftenum number, return an ftype_t* */
|
|
|
|
#define FTYPE_LOOKUP(ftype, result) \
|
|
|
|
/* Check input */ \
|
|
|
|
ws_assert(ftype < FT_NUM_TYPES); \
|
|
|
|
result = type_list[ftype];
|
|
|
|
|
2013-11-10 13:14:09 +00:00
|
|
|
typedef void (*FvalueNewFunc)(fvalue_t*);
|
2022-03-14 20:38:26 +00:00
|
|
|
typedef void (*FvalueCopyFunc)(fvalue_t*, const fvalue_t*);
|
2013-11-10 13:14:09 +00:00
|
|
|
typedef void (*FvalueFreeFunc)(fvalue_t*);
|
|
|
|
|
2022-02-23 00:47:00 +00:00
|
|
|
typedef gboolean (*FvalueFromLiteral)(fvalue_t*, const char*, gboolean, gchar **);
|
2022-06-18 09:43:24 +00:00
|
|
|
typedef gboolean (*FvalueFromString)(fvalue_t*, const char*, size_t, gchar **);
|
2021-11-23 21:20:34 +00:00
|
|
|
typedef gboolean (*FvalueFromCharConst)(fvalue_t*, unsigned long, gchar **);
|
2021-11-08 15:55:03 +00:00
|
|
|
typedef char *(*FvalueToStringRepr)(wmem_allocator_t *, const fvalue_t*, ftrepr_t, int field_display);
|
2013-11-10 13:14:09 +00:00
|
|
|
|
2022-07-05 19:24:30 +00:00
|
|
|
typedef enum ft_result (*FvalueToUnsignedInteger64Func)(const fvalue_t*, guint64 *);
|
|
|
|
typedef enum ft_result (*FvalueToSignedInteger64Func)(const fvalue_t*, gint64 *);
|
|
|
|
|
2014-01-15 01:05:03 +00:00
|
|
|
typedef void (*FvalueSetByteArrayFunc)(fvalue_t*, GByteArray *);
|
|
|
|
typedef void (*FvalueSetBytesFunc)(fvalue_t*, const guint8 *);
|
|
|
|
typedef void (*FvalueSetGuidFunc)(fvalue_t*, const e_guid_t *);
|
|
|
|
typedef void (*FvalueSetTimeFunc)(fvalue_t*, const nstime_t *);
|
2022-06-18 09:43:24 +00:00
|
|
|
typedef void (*FvalueSetStrbufFunc)(fvalue_t*, wmem_strbuf_t *);
|
2022-05-22 20:02:22 +00:00
|
|
|
typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const gchar *name, int length);
|
2013-11-10 13:14:09 +00:00
|
|
|
typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, guint32);
|
|
|
|
typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, gint32);
|
2014-12-17 20:19:20 +00:00
|
|
|
typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, guint64);
|
|
|
|
typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, gint64);
|
2013-11-10 13:14:09 +00:00
|
|
|
typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble);
|
|
|
|
|
2022-06-18 23:31:30 +00:00
|
|
|
typedef const guint8 *(*FvalueGetBytesFunc)(fvalue_t*);
|
|
|
|
typedef const e_guid_t *(*FvalueGetGuidFunc)(fvalue_t*);
|
|
|
|
typedef const nstime_t *(*FvalueGetTimeFunc)(fvalue_t*);
|
2022-06-18 09:43:24 +00:00
|
|
|
typedef const wmem_strbuf_t *(*FvalueGetStrbufFunc)(fvalue_t*);
|
2022-06-18 23:31:30 +00:00
|
|
|
typedef tvbuff_t *(*FvalueGetProtocolFunc)(fvalue_t*);
|
2013-11-10 13:14:09 +00:00
|
|
|
typedef guint32 (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
|
|
|
|
typedef gint32 (*FvalueGetSignedIntegerFunc)(fvalue_t*);
|
2014-12-17 20:19:20 +00:00
|
|
|
typedef guint64 (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
|
|
|
|
typedef gint64 (*FvalueGetSignedInteger64Func)(fvalue_t*);
|
2013-11-10 13:14:09 +00:00
|
|
|
typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
|
|
|
|
|
2022-07-05 19:24:30 +00:00
|
|
|
typedef enum ft_result (*FvalueCmp)(const fvalue_t*, const fvalue_t*, int*);
|
|
|
|
typedef enum ft_result (*FvalueContains)(const fvalue_t*, const fvalue_t*, gboolean*);
|
|
|
|
typedef enum ft_result (*FvalueMatches)(const fvalue_t*, const ws_regex_t*, gboolean*);
|
2013-11-10 13:14:09 +00:00
|
|
|
|
2022-04-13 14:30:36 +00:00
|
|
|
typedef gboolean (*FvalueIs)(const fvalue_t*);
|
2013-11-10 13:14:09 +00:00
|
|
|
typedef guint (*FvalueLen)(fvalue_t*);
|
|
|
|
typedef void (*FvalueSlice)(fvalue_t*, GByteArray *, guint offset, guint length);
|
2022-03-31 13:50:20 +00:00
|
|
|
typedef enum ft_result (*FvalueUnaryOp)(fvalue_t *, const fvalue_t*, gchar **);
|
|
|
|
typedef enum ft_result (*FvalueBinaryOp)(fvalue_t *, const fvalue_t*, const fvalue_t*, gchar **);
|
2013-11-10 13:14:09 +00:00
|
|
|
|
|
|
|
struct _ftype_t {
|
|
|
|
ftenum_t ftype;
|
|
|
|
const char *name;
|
|
|
|
const char *pretty_name;
|
|
|
|
int wire_size;
|
|
|
|
FvalueNewFunc new_value;
|
2022-03-14 20:38:26 +00:00
|
|
|
FvalueCopyFunc copy_value;
|
2013-11-10 13:14:09 +00:00
|
|
|
FvalueFreeFunc free_value;
|
2022-02-23 00:47:00 +00:00
|
|
|
FvalueFromLiteral val_from_literal;
|
2013-11-10 13:14:09 +00:00
|
|
|
FvalueFromString val_from_string;
|
2021-11-23 21:20:34 +00:00
|
|
|
FvalueFromCharConst val_from_charconst;
|
2013-11-10 13:14:09 +00:00
|
|
|
FvalueToStringRepr val_to_string_repr;
|
|
|
|
|
2022-07-05 19:24:30 +00:00
|
|
|
FvalueToUnsignedInteger64Func val_to_uinteger64;
|
|
|
|
FvalueToSignedInteger64Func val_to_sinteger64;
|
|
|
|
|
2017-03-04 15:15:54 +00:00
|
|
|
union {
|
2022-06-18 23:31:30 +00:00
|
|
|
FvalueSetByteArrayFunc set_value_byte_array;
|
|
|
|
FvalueSetBytesFunc set_value_bytes;
|
|
|
|
FvalueSetGuidFunc set_value_guid;
|
|
|
|
FvalueSetTimeFunc set_value_time;
|
2022-06-18 09:43:24 +00:00
|
|
|
FvalueSetStrbufFunc set_value_strbuf;
|
2022-06-18 23:31:30 +00:00
|
|
|
FvalueSetProtocolFunc set_value_protocol;
|
2017-03-12 18:15:19 +00:00
|
|
|
FvalueSetUnsignedIntegerFunc set_value_uinteger;
|
2017-03-12 18:49:42 +00:00
|
|
|
FvalueSetSignedIntegerFunc set_value_sinteger;
|
2017-03-13 17:46:48 +00:00
|
|
|
FvalueSetUnsignedInteger64Func set_value_uinteger64;
|
2017-03-14 22:00:36 +00:00
|
|
|
FvalueSetSignedInteger64Func set_value_sinteger64;
|
2022-06-18 23:31:30 +00:00
|
|
|
FvalueSetFloatingFunc set_value_floating;
|
2017-03-04 15:15:54 +00:00
|
|
|
} set_value;
|
|
|
|
|
2017-03-16 21:34:49 +00:00
|
|
|
union {
|
2022-06-18 23:31:30 +00:00
|
|
|
FvalueGetBytesFunc get_value_bytes;
|
|
|
|
FvalueGetGuidFunc get_value_guid;
|
|
|
|
FvalueGetTimeFunc get_value_time;
|
2022-06-18 09:43:24 +00:00
|
|
|
FvalueGetStrbufFunc get_value_strbuf;
|
2022-06-18 23:31:30 +00:00
|
|
|
FvalueGetProtocolFunc get_value_protocol;
|
2017-03-19 19:57:43 +00:00
|
|
|
FvalueGetUnsignedIntegerFunc get_value_uinteger;
|
2017-03-19 19:32:20 +00:00
|
|
|
FvalueGetSignedIntegerFunc get_value_sinteger;
|
2017-03-19 12:31:53 +00:00
|
|
|
FvalueGetUnsignedInteger64Func get_value_uinteger64;
|
2017-03-19 12:08:06 +00:00
|
|
|
FvalueGetSignedInteger64Func get_value_sinteger64;
|
2022-06-18 23:31:30 +00:00
|
|
|
FvalueGetFloatingFunc get_value_floating;
|
2017-03-16 21:34:49 +00:00
|
|
|
} get_value;
|
|
|
|
|
2021-10-10 15:00:51 +00:00
|
|
|
FvalueCmp cmp_order;
|
|
|
|
FvalueContains cmp_contains;
|
2021-03-21 10:06:17 +00:00
|
|
|
FvalueMatches cmp_matches;
|
2013-11-10 13:14:09 +00:00
|
|
|
|
2022-04-13 14:30:36 +00:00
|
|
|
FvalueIs is_zero;
|
|
|
|
FvalueIs is_negative;
|
2013-11-10 13:14:09 +00:00
|
|
|
FvalueLen len;
|
|
|
|
FvalueSlice slice;
|
2022-03-31 13:50:20 +00:00
|
|
|
FvalueBinaryOp bitwise_and;
|
|
|
|
FvalueUnaryOp unary_minus;
|
|
|
|
FvalueBinaryOp add;
|
|
|
|
FvalueBinaryOp subtract;
|
|
|
|
FvalueBinaryOp multiply;
|
|
|
|
FvalueBinaryOp divide;
|
|
|
|
FvalueBinaryOp modulo;
|
2013-11-10 13:14:09 +00:00
|
|
|
};
|
|
|
|
|
2021-11-11 09:38:50 +00:00
|
|
|
void ftype_register(enum ftenum ftype, ftype_t *ft);
|
|
|
|
|
|
|
|
void ftype_register_bytes(void);
|
|
|
|
void ftype_register_double(void);
|
|
|
|
void ftype_register_ieee_11073_float(void);
|
|
|
|
void ftype_register_integers(void);
|
|
|
|
void ftype_register_ipv4(void);
|
|
|
|
void ftype_register_ipv6(void);
|
|
|
|
void ftype_register_guid(void);
|
|
|
|
void ftype_register_none(void);
|
|
|
|
void ftype_register_string(void);
|
|
|
|
void ftype_register_time(void);
|
|
|
|
void ftype_register_tvbuff(void);
|
|
|
|
|
2022-07-28 16:43:16 +00:00
|
|
|
/* For debugging. */
|
2021-12-07 15:02:00 +00:00
|
|
|
void ftype_register_pseudofields_bytes(int proto);
|
|
|
|
void ftype_register_pseudofields_double(int proto);
|
|
|
|
void ftype_register_pseudofields_ieee_11073_float(int proto);
|
|
|
|
void ftype_register_pseudofields_integer(int proto);
|
|
|
|
void ftype_register_pseudofields_ipv4(int proto);
|
|
|
|
void ftype_register_pseudofields_ipv6(int proto);
|
|
|
|
void ftype_register_pseudofields_guid(int proto);
|
2022-07-28 16:43:16 +00:00
|
|
|
void ftype_register_pseudofields_none(int proto);
|
2021-12-07 15:02:00 +00:00
|
|
|
void ftype_register_pseudofields_string(int proto);
|
|
|
|
void ftype_register_pseudofields_time(int proto);
|
|
|
|
void ftype_register_pseudofields_tvbuff(int proto);
|
|
|
|
|
2021-11-11 00:54:00 +00:00
|
|
|
GByteArray *
|
2022-02-23 00:47:00 +00:00
|
|
|
byte_array_from_literal(const char *s, gchar **err_msg);
|
2021-10-14 13:17:41 +00:00
|
|
|
|
2021-11-23 21:20:34 +00:00
|
|
|
GByteArray *
|
|
|
|
byte_array_from_charconst(unsigned long num, gchar **err_msg);
|
|
|
|
|
2021-10-14 13:17:41 +00:00
|
|
|
#endif /* FTYPES_INT_H */
|
2015-02-15 03:31:53 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2015-02-15 03:31:53 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|