epan: use SPDX indentifiers.
[metze/wireshark/wip.git] / epan / ftypes / ftypes-int.h
index 600792b6984ff71506ebb5914788e3bb42678178..14933bfd7c94d2ad2cec6159f1d93b6ef7131a7f 100644 (file)
@@ -1,29 +1,15 @@
 /*
- * $Id$
- *
  * Wireshark - Network traffic analyzer
  * By Gerald Combs <gerald@wireshark.org>
  * Copyright 2001 Gerald Combs
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #ifndef FTYPES_INT_H
 #define FTYPES_INT_H
 
-#include <epan/packet.h>
+#include <epan/proto.h>
 #include "ftypes.h"
 
 
@@ -36,6 +22,8 @@ ftype_register(enum ftenum ftype, ftype_t *ft);
  * that I don't mind doing it by hand for now. */
 void ftype_register_bytes(void);
 void ftype_register_double(void);
+void ftype_register_ieee_11073_float(void);
+void ftype_register_fc(void);
 void ftype_register_integers(void);
 void ftype_register_ipv4(void);
 void ftype_register_ipv6(void);
@@ -46,4 +34,117 @@ void ftype_register_time(void);
 void ftype_register_tvbuff(void);
 void ftype_register_pcre(void);
 
+typedef void (*FvalueNewFunc)(fvalue_t*);
+typedef void (*FvalueFreeFunc)(fvalue_t*);
+
+typedef gboolean (*FvalueFromUnparsed)(fvalue_t*, const char*, gboolean, gchar **);
+typedef gboolean (*FvalueFromString)(fvalue_t*, const char*, gchar **);
+typedef void (*FvalueToStringRepr)(fvalue_t*, ftrepr_t, int field_display, char*volatile, unsigned int);
+typedef int (*FvalueStringReprLen)(fvalue_t*, ftrepr_t, int field_display);
+
+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 *);
+typedef void (*FvalueSetStringFunc)(fvalue_t*, const gchar *value);
+typedef void (*FvalueSetProtocolFunc)(fvalue_t*, tvbuff_t *value, const gchar *name);
+typedef void (*FvalueSetUnsignedIntegerFunc)(fvalue_t*, guint32);
+typedef void (*FvalueSetSignedIntegerFunc)(fvalue_t*, gint32);
+typedef void (*FvalueSetUnsignedInteger64Func)(fvalue_t*, guint64);
+typedef void (*FvalueSetSignedInteger64Func)(fvalue_t*, gint64);
+typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble);
+
+typedef gpointer (*FvalueGetFunc)(fvalue_t*);
+typedef guint32 (*FvalueGetUnsignedIntegerFunc)(fvalue_t*);
+typedef gint32  (*FvalueGetSignedIntegerFunc)(fvalue_t*);
+typedef guint64 (*FvalueGetUnsignedInteger64Func)(fvalue_t*);
+typedef gint64 (*FvalueGetSignedInteger64Func)(fvalue_t*);
+typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
+
+typedef gboolean (*FvalueCmp)(const fvalue_t*, const fvalue_t*);
+
+typedef guint (*FvalueLen)(fvalue_t*);
+typedef void (*FvalueSlice)(fvalue_t*, GByteArray *, guint offset, guint length);
+
+struct _ftype_t {
+       ftenum_t                ftype;
+       const char              *name;
+       const char              *pretty_name;
+       int                     wire_size;
+       FvalueNewFunc           new_value;
+       FvalueFreeFunc          free_value;
+       FvalueFromUnparsed      val_from_unparsed;
+       FvalueFromString        val_from_string;
+       FvalueToStringRepr      val_to_string_repr;
+       FvalueStringReprLen     len_string_repr;
+
+       union {
+               FvalueSetByteArrayFunc  set_value_byte_array;
+               FvalueSetBytesFunc      set_value_bytes;
+               FvalueSetGuidFunc       set_value_guid;
+               FvalueSetTimeFunc       set_value_time;
+               FvalueSetStringFunc     set_value_string;
+               FvalueSetProtocolFunc   set_value_protocol;
+               FvalueSetUnsignedIntegerFunc    set_value_uinteger;
+               FvalueSetSignedIntegerFunc      set_value_sinteger;
+               FvalueSetUnsignedInteger64Func  set_value_uinteger64;
+               FvalueSetSignedInteger64Func    set_value_sinteger64;
+               FvalueSetFloatingFunc   set_value_floating;
+       } set_value;
+
+       union {
+               FvalueGetFunc           get_value_ptr;
+               FvalueGetUnsignedIntegerFunc    get_value_uinteger;
+               FvalueGetSignedIntegerFunc      get_value_sinteger;
+               FvalueGetUnsignedInteger64Func  get_value_uinteger64;
+               FvalueGetSignedInteger64Func    get_value_sinteger64;
+               FvalueGetFloatingFunc   get_value_floating;
+       } get_value;
+
+       FvalueCmp               cmp_eq;
+       FvalueCmp               cmp_ne;
+       FvalueCmp               cmp_gt;
+       FvalueCmp               cmp_ge;
+       FvalueCmp               cmp_lt;
+       FvalueCmp               cmp_le;
+       FvalueCmp               cmp_bitwise_and;
+       FvalueCmp               cmp_contains;
+       FvalueCmp               cmp_matches;
+
+       FvalueLen               len;
+       FvalueSlice             slice;
+};
+
+/* Free all memory used by an fvalue_t. With MSVC and a
+ * libwireshark.dll, we need a special declaration.
+ */
+
+#define FVALUE_CLEANUP(fv)                                     \
+       {                                                       \
+               register FvalueFreeFunc free_value;             \
+               free_value = (fv)->ftype->free_value;   \
+               if (free_value) {                               \
+                       free_value((fv));                       \
+               }                                               \
+       }
+
+#define FVALUE_FREE(fv)                                                \
+       {                                                       \
+               FVALUE_CLEANUP(fv)                              \
+               g_slice_free(fvalue_t, fv);                     \
+       }
+
 #endif
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * 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:
+ */