Wireshark  2.9.0-477-g68ec514b
The Wireshark network protocol analyzer
decode_as.h
Go to the documentation of this file.
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  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 
11 #ifndef __DECODE_AS_H__
12 #define __DECODE_AS_H__
13 
14 #include "ws_symbol_export.h"
15 
16 #include "ftypes/ftypes.h"
17 #include "packet_info.h"
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif /* __cplusplus */
22 
26 #define MAX_DECODE_AS_PROMPT_LEN 200
27 #define DECODE_AS_ENTRY "decode_as_entry"
28 #define DECODE_AS_NONE "(none)"
29 
30 /*
31  * Filename of the "decode as" entry preferences
32  */
33 #define DECODE_AS_ENTRIES_FILE_NAME "decode_as_entries"
34 
35 
37 typedef void (*build_label_func)(packet_info *pinfo, gchar* result);
38 
40 typedef gpointer (*build_valid_func)(packet_info *pinfo);
41 
42 typedef void (*decode_as_add_to_list_func)(const gchar *table_name, const gchar *proto_name, gpointer value, gpointer user_data);
43 typedef void (*decode_as_populate_list_func)(const gchar *table_name, decode_as_add_to_list_func add_to_list, gpointer ui_element);
44 typedef void (*decode_as_free_func)(gpointer value);
45 
47 typedef gboolean (*decode_as_reset_func)(const gchar *name, gconstpointer pattern);
49 typedef gboolean (*decode_as_change_func)(const gchar *name, gconstpointer pattern, gpointer handle, gchar *list_name);
50 
51 typedef struct decode_as_value_s {
52  build_label_func label_func;
53  guint num_values;
54  build_valid_func* build_values;
56 
57 typedef struct decode_as_s {
58  const char *name;
59  const gchar *title;
60  const gchar *table_name;
61  guint num_items;
62  guint default_index_value;
63  decode_as_value_t* values;
64  const char* pre_value_str;
65  const char* post_value_str;
66  decode_as_populate_list_func populate_list;
67  decode_as_reset_func reset_value;
68  decode_as_change_func change_value;
69  decode_as_free_func free_func;
70 
71 } decode_as_t;
72 
74 WS_DLL_PUBLIC void register_decode_as(decode_as_t* reg);
75 
76 /* Forward declaration to prevent requiring packet.h */
77 struct dissector_table;
78 
94 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);
95 
96 /* Walk though the dissector table and provide dissector_handle_t for each item in the table */
97 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);
98 /* Clear a FT_UINT32 value from dissector table list */
99 WS_DLL_PUBLIC gboolean decode_as_default_reset(const gchar *name, gconstpointer pattern);
100 /* Add a FT_UINT32 value to dissector table list */
101 WS_DLL_PUBLIC gboolean decode_as_default_change(const gchar *name, gconstpointer pattern, gpointer handle, gchar *list_name);
102 
106 WS_DLL_PUBLIC GList *decode_as_list;
107 
108 /* Some useful utilities for Decode As */
109 
114 extern void load_decode_as_entries(void);
115 
118 WS_DLL_PUBLIC int save_decode_as_entries(gchar** err);
119 
122 WS_DLL_PUBLIC void decode_clear_all(void);
123 
146 WS_DLL_PUBLIC void decode_build_reset_list (const gchar *table_name, ftenum_t selector_type,
147  gpointer key, gpointer value _U_,
148  gpointer user_data _U_);
149 
150 
151 #ifdef __cplusplus
152 }
153 #endif /* __cplusplus */
154 
155 #endif /* decode_as.h */
void load_decode_as_entries(void)
Definition: decode_as.c:286
WS_DLL_PUBLIC void register_decode_as(decode_as_t *reg)
Definition: decode_as.c:28
WS_DLL_PUBLIC int save_decode_as_entries(gchar **err)
Definition: decode_as.c:375
gpointer(* build_valid_func)(packet_info *pinfo)
Definition: decode_as.h:40
Definition: packet_info.h:44
WS_DLL_PUBLIC void decode_clear_all(void)
Definition: decode_as.c:464
Definition: decode_as.h:57
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)
Definition: decode_as.c:60
WS_DLL_PUBLIC GList * decode_as_list
Definition: decode_as.h:106
gboolean(* decode_as_change_func)(const gchar *name, gconstpointer pattern, gpointer handle, gchar *list_name)
Definition: decode_as.h:49
void(* build_label_func)(packet_info *pinfo, gchar *result)
Definition: decode_as.h:37
Definition: packet.c:83
WS_DLL_PUBLIC void decode_build_reset_list(const gchar *table_name, ftenum_t selector_type, gpointer key, gpointer value _U_, gpointer user_data _U_)
Definition: decode_as.c:426
gboolean(* decode_as_reset_func)(const gchar *name, gconstpointer pattern)
Definition: decode_as.h:47
Definition: decode_as.h:51