/* decode_as.h
* Routines for dissector Decode As handlers
*
- * $Id$
- *
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
extern "C" {
#endif /* __cplusplus */
-/** @file
+/** @file
*/
#define MAX_DECODE_AS_PROMPT_LEN 200
#define DECODE_AS_ENTRY "decode_as_entry"
+#define DECODE_AS_NONE "(none)"
+
/*
* Filename of the "decode as" entry preferences
*/
typedef void (*decode_as_free_func)(gpointer value);
/** callback function definition: Clear value from dissector table */
-typedef gboolean (*decode_as_reset_func)(const char *name, const gpointer pattern);
+typedef gboolean (*decode_as_reset_func)(const gchar *name, gconstpointer pattern);
/** callback function definition: Apply value to dissector table */
-typedef gboolean (*decode_as_change_func)(const char *name, const gpointer pattern, gpointer handle, gchar* list_name);
+typedef gboolean (*decode_as_change_func)(const gchar *name, gconstpointer pattern, gpointer handle, gchar *list_name);
typedef struct decode_as_value_s {
build_label_func label_func;
/** register a "Decode As". A copy of the decode_as_t will be maintained by the decode_as module */
WS_DLL_PUBLIC void register_decode_as(decode_as_t* reg);
+/* Forward declaration to prevent requiring packet.h */
+struct dissector_table;
+
+/** Register a "Decode As" entry for the special case where there is no
+ * indication for the next protocol (such as port number etc.).
+ * For now, this will use a uint32 dissector table internally and
+ * assign all registered protocols to 0. The framework to do this can
+ * be kept internal to epan.
+ *
+ * @param proto The protocol ID to create the dissector table.
+ * @param title The table name in which this dissector is found.
+ * @param table_name The table name in which this dissector is found.
+ * @param ui_name UI name for created dissector table.
+ * @param label_func Optional prompt text for dissector. If NULL, "Next level protocol as" is used.
+ *
+ * @return Created dissector table with Decode As support
+*/
+WS_DLL_PUBLIC struct dissector_table* register_decode_as_next_proto(int proto, const gchar *title, const gchar *table_name, const gchar *ui_name, build_label_func* label_func);
+
/* Walk though the dissector table and provide dissector_handle_t for each item in the table */
WS_DLL_PUBLIC void decode_as_default_populate_list(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element);
/* Clear a FT_UINT32 value from dissector table list */
-WS_DLL_PUBLIC gboolean decode_as_default_reset(const char *name, const gpointer pattern);
+WS_DLL_PUBLIC gboolean decode_as_default_reset(const gchar *name, gconstpointer pattern);
/* Add a FT_UINT32 value to dissector table list */
-WS_DLL_PUBLIC gboolean decode_as_default_change(const char *name, const gpointer pattern, gpointer handle, gchar* list_name);
-
-/*** THE FOLLOWING SHOULD NOT BE USED BY ANY DISSECTORS!!! ***/
+WS_DLL_PUBLIC gboolean decode_as_default_change(const gchar *name, gconstpointer pattern, gpointer handle, gchar *list_name);
+/** List of registered decode_as_t structs.
+ * For UI code only. Should not be directly accessed by dissectors.
+ */
WS_DLL_PUBLIC GList *decode_as_list;
+/* Some useful utilities for Decode As */
+
/** Reset the "decode as" entries and reload ones of the current profile.
+ * This is called by epan_load_settings(); programs should call that
+ * rather than individually calling the routines it calls.
*/
-WS_DLL_PUBLIC void load_decode_as_entries(void);
+extern void load_decode_as_entries(void);
-/*
- * This routine creates one entry in the list of protocol dissector
+/** Write out the "decode as" entries of the current profile.
+ */
+WS_DLL_PUBLIC int save_decode_as_entries(gchar** err);
+
+/** Clear all "decode as" settings.
+ */
+WS_DLL_PUBLIC void decode_clear_all(void);
+
+/** This routine creates one entry in the list of protocol dissector
* that need to be reset. It is called by the g_hash_table_foreach
* routine once for each changed entry in a dissector table.
* Unfortunately it cannot delete the entry immediately as this screws
* protocol, i.e. the ethernet type code, IP port number, TCP port
* number, etc.
*
+ * @param selector_type The type of the selector in that dissector table
+ *
* @param value A pointer to the value for this entry in the dissector
* hash table. This is an opaque pointer that can only be handed back
* to routine in the file packet.c - but it's unused.
gpointer key, gpointer value _U_,
gpointer user_data _U_);
-/** Clear all "decode as" settings
- */
-WS_DLL_PUBLIC void decode_clear_all(void);
-
#ifdef __cplusplus
}