summaryrefslogtreecommitdiff
path: root/epan/decode_as.h
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2013-11-20 19:17:08 +0000
committerMichael Mann <mmann78@netscape.net>2013-11-20 19:17:08 +0000
commit76ab93ea94787605d4c829620b51ff4dee105cb1 (patch)
tree88b6c8e46ab562da0ad5a57c2869046845dabda5 /epan/decode_as.h
parent91b972ae5ef1dbd437778d942901c6d820f399e2 (diff)
downloadwireshark-76ab93ea94787605d4c829620b51ff4dee105cb1.tar.gz
Provide "Decode As" functionality through dissectors themselves instead of the GUI. Bug 9450 (https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9450)
The basic idea behind this design is to have dissectors register with a "decode as list" with their name and dissector table. When "Decode As" dialog is launched, any "registered" dissector found in the packet will cause a tab to be created in the dialog. This patch includes just the dissector portion of the functionality (minus packet-dcerpc.[ch] because it has hooks to the current GUI) svn path=/trunk/; revision=53445
Diffstat (limited to 'epan/decode_as.h')
-rw-r--r--epan/decode_as.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/epan/decode_as.h b/epan/decode_as.h
new file mode 100644
index 0000000000..e25df5d41a
--- /dev/null
+++ b/epan/decode_as.h
@@ -0,0 +1,94 @@
+/* decode_as.h
+ * Routines for dissector Decode As handlers
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 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.
+ */
+
+#ifndef __DECODE_AS_H__
+#define __DECODE_AS_H__
+
+#include "ws_symbol_export.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/** @file
+ */
+
+#define MAX_DECODE_AS_PROMPT_LEN 200
+
+/** callback function definition: return formatted label string */
+typedef void (*build_label_func)(packet_info *pinfo, gchar* result);
+
+/** callback function definition: return value used to pass to dissector table */
+typedef gpointer (*build_valid_func)(packet_info *pinfo);
+
+typedef void (*decode_as_add_to_list_func)(const gchar *table_name, const gchar *proto_name, gpointer value, gpointer user_data);
+typedef void (*decode_as_populate_list_func)(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element);
+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);
+/** 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 struct decode_as_value_s {
+ build_label_func label_func;
+ guint num_values;
+ build_valid_func* build_values;
+} decode_as_value_t;
+
+typedef struct decode_as_s {
+ const char *name;
+ const gchar *title;
+ const gchar *table_name;
+ guint num_items;
+ guint default_index_value;
+ decode_as_value_t* values;
+ const char* pre_value_str;
+ const char* post_value_str;
+ decode_as_populate_list_func populate_list;
+ decode_as_reset_func reset_value;
+ decode_as_change_func change_value;
+ decode_as_free_func free_func;
+
+} decode_as_t;
+
+/** 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);
+
+/* 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);
+/* 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 GList *decode_as_list;
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* decode_as.h */