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