2 * Routines for dissector Decode As handlers
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 #ifndef __DECODE_AS_H__
26 #define __DECODE_AS_H__
28 #include "ws_symbol_export.h"
30 #include "ftypes/ftypes.h"
31 #include "packet_info.h"
35 #endif /* __cplusplus */
40 #define MAX_DECODE_AS_PROMPT_LEN 200
41 #define DECODE_AS_ENTRY "decode_as_entry"
42 #define DECODE_AS_NONE "(none)"
45 * Filename of the "decode as" entry preferences
47 #define DECODE_AS_ENTRIES_FILE_NAME "decode_as_entries"
50 /** callback function definition: return formatted label string */
51 typedef void (*build_label_func)(packet_info *pinfo, gchar* result);
53 /** callback function definition: return value used to pass to dissector table */
54 typedef gpointer (*build_valid_func)(packet_info *pinfo);
56 typedef void (*decode_as_add_to_list_func)(const gchar *table_name, const gchar *proto_name, gpointer value, gpointer user_data);
57 typedef void (*decode_as_populate_list_func)(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element);
58 typedef void (*decode_as_free_func)(gpointer value);
60 /** callback function definition: Clear value from dissector table */
61 typedef gboolean (*decode_as_reset_func)(const char *name, const gpointer pattern);
62 /** callback function definition: Apply value to dissector table */
63 typedef gboolean (*decode_as_change_func)(const char *name, const gpointer pattern, gpointer handle, gchar* list_name);
65 typedef struct decode_as_value_s {
66 build_label_func label_func;
68 build_valid_func* build_values;
71 typedef struct decode_as_s {
74 const gchar *table_name;
76 guint default_index_value;
77 decode_as_value_t* values;
78 const char* pre_value_str;
79 const char* post_value_str;
80 decode_as_populate_list_func populate_list;
81 decode_as_reset_func reset_value;
82 decode_as_change_func change_value;
83 decode_as_free_func free_func;
87 /** register a "Decode As". A copy of the decode_as_t will be maintained by the decode_as module */
88 WS_DLL_PUBLIC void register_decode_as(decode_as_t* reg);
90 /* Walk though the dissector table and provide dissector_handle_t for each item in the table */
91 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);
92 /* Clear a FT_UINT32 value from dissector table list */
93 WS_DLL_PUBLIC gboolean decode_as_default_reset(const char *name, const gpointer pattern);
94 /* Add a FT_UINT32 value to dissector table list */
95 WS_DLL_PUBLIC gboolean decode_as_default_change(const char *name, const gpointer pattern, gpointer handle, gchar* list_name);
97 /** List of registered decode_as_t structs.
98 * For UI code only. Should not be directly accessed by dissectors.
100 WS_DLL_PUBLIC GList *decode_as_list;
104 #endif /* __cplusplus */
106 #endif /* decode_as.h */