GSM/ANSI/CAMEL...: fix no previous prototype for '*_stat_init' [-Wmissing-prototypes]
[metze/wireshark/wip.git] / epan / decode_as.h
1 /* decode_as.h
2  * Routines for dissector Decode As handlers
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
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.
12  *
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.
17  *
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.
21  */
22
23 #ifndef __DECODE_AS_H__
24 #define __DECODE_AS_H__
25
26 #include "ws_symbol_export.h"
27
28 #include "ftypes/ftypes.h"
29 #include "packet_info.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif /* __cplusplus */
34
35 /** @file
36  */
37
38 #define MAX_DECODE_AS_PROMPT_LEN    200
39 #define DECODE_AS_ENTRY "decode_as_entry"
40 #define DECODE_AS_NONE "(none)"
41
42 /*
43  * Filename of the "decode as" entry preferences
44  */
45 #define DECODE_AS_ENTRIES_FILE_NAME "decode_as_entries"
46
47
48 /** callback function definition: return formatted label string */
49 typedef void (*build_label_func)(packet_info *pinfo, gchar* result);
50
51 /** callback function definition: return value used to pass to dissector table */
52 typedef gpointer (*build_valid_func)(packet_info *pinfo);
53
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);
57
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);
62
63 typedef struct decode_as_value_s {
64     build_label_func label_func;
65     guint num_values;
66     build_valid_func* build_values;
67 } decode_as_value_t;
68
69 typedef struct decode_as_s {
70     const char *name;
71     const gchar *title;
72     const gchar *table_name;
73     guint num_items;
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;
82
83 } decode_as_t;
84
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);
87
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);
94
95 /** List of registered decode_as_t structs.
96  * For UI code only. Should not be directly accessed by dissectors.
97  */
98 WS_DLL_PUBLIC GList *decode_as_list;
99
100 #ifdef __cplusplus
101 }
102 #endif /* __cplusplus */
103
104 #endif /* decode_as.h */