2 * Collecting of Expert information.
4 * For further info, see: https://wiki.wireshark.org/Development/ExpertInfo
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet_info.h>
17 #include <epan/proto.h>
18 #include "value_string.h"
19 #include "ws_symbol_export.h"
23 #endif /* __cplusplus */
25 /** only for internal and display use. */
26 typedef struct expert_info_s {
30 int hf_index; /* hf_index of the expert item. Might be -1. */
31 const gchar *protocol;
36 /* Expert Info and Display hf data */
37 typedef struct expert_field
45 #define EI_INIT {EI_INIT_EI, EI_INIT_HF}
47 typedef struct expert_field_info {
48 /* ---------- set by dissector --------- */
54 /* ------- set by register routines (prefilled by EXPFILL macro, see below) ------ */
56 const gchar *protocol;
57 int orig_severity; /* Matches severity when registered, used to restore original severity
58 * if UAT severity entry is removed */
59 hf_register_info hf_info;
63 #define EXPFILL 0, NULL, 0, \
64 {0, {NULL, NULL, FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL}}
66 typedef struct ei_register_info {
67 expert_field *ids; /**< written to by register() function */
68 expert_field_info eiinfo; /**< the field info to be registered */
71 typedef struct expert_module expert_module_t;
73 #define PRE_ALLOC_EXPERT_FIELDS_MEM 5000
75 /* "proto_expert" is exported from libwireshark.dll.
76 * Thus we need a special declaration.
78 WS_DLL_PUBLIC int proto_expert;
84 expert_packet_init(void);
90 expert_packet_cleanup(void);
93 expert_get_highest_severity(void);
96 expert_update_comment_count(guint64 count);
98 /** Add an expert info.
99 Add an expert info tree to a protocol item using registered expert info item
100 @param pinfo Packet info of the currently processed packet. May be NULL if
102 @param pi Current protocol item (or NULL)
103 @param eiindex The registered expert info item
106 expert_add_info(packet_info *pinfo, proto_item *pi, expert_field *eiindex);
108 /** Add an expert info.
109 Add an expert info tree to a protocol item using registered expert info item,
110 but with a formatted message.
111 @param pinfo Packet info of the currently processed packet. May be NULL if
113 @param pi Current protocol item (or NULL)
114 @param eiindex The registered expert info item
115 @param format Printf-style format string for additional arguments
118 expert_add_info_format(packet_info *pinfo, proto_item *pi, expert_field *eiindex,
119 const char *format, ...) G_GNUC_PRINTF(4, 5);
121 /** Add an expert info associated with some byte data
122 Add an expert info tree to a protocol item using registered expert info item.
123 This function is intended to replace places where a "text only" proto_tree_add_xxx
124 API + expert_add_info would be used.
125 @param tree Current protocol tree (or NULL)
126 @param pinfo Packet info of the currently processed packet. May be NULL if tree is supplied
127 @param eiindex The registered expert info item
128 @param tvb the tv buffer of the current data
129 @param start start of data in tvb
130 @param length length of data in tvb
131 @return the newly created item above expert info tree
133 WS_DLL_PUBLIC proto_item *
134 proto_tree_add_expert(proto_tree *tree, packet_info *pinfo, expert_field *eiindex,
135 tvbuff_t *tvb, gint start, gint length);
137 /** Add an expert info associated with some byte data
138 Add an expert info tree to a protocol item, using registered expert info item,
139 but with a formatted message.
140 Add an expert info tree to a protocol item using registered expert info item.
141 This function is intended to replace places where a "text only" proto_tree_add_xxx
142 API + expert_add_info_format
144 @param tree Current protocol tree (or NULL)
145 @param pinfo Packet info of the currently processed packet. May be NULL if tree is supplied
146 @param eiindex The registered expert info item
147 @param tvb the tv buffer of the current data
148 @param start start of data in tvb
149 @param length length of data in tvb
150 @param format Printf-style format string for additional arguments
151 @return the newly created item above expert info tree
153 WS_DLL_PUBLIC proto_item *
154 proto_tree_add_expert_format(proto_tree *tree, packet_info *pinfo, expert_field *eiindex,
155 tvbuff_t *tvb, gint start, gint length, const char *format, ...) G_GNUC_PRINTF(7, 8);
158 * Register that a protocol has expert info.
160 WS_DLL_PUBLIC expert_module_t *expert_register_protocol(int id);
163 * Deregister a expert info.
165 void expert_deregister_expertinfo (const char *abbrev);
168 * Deregister expert info from a protocol.
170 void expert_deregister_protocol (expert_module_t *module);
173 * Free deregistered expert infos.
175 void expert_free_deregistered_expertinfos (void);
178 * Get summary text of an expert_info field.
179 * This is intended for use in expert_add_info_format or proto_tree_add_expert_format
180 * to get the "base" string to then append additional information
182 WS_DLL_PUBLIC const gchar* expert_get_summary(expert_field *eiindex);
184 /** Register a expert field array.
185 @param module the protocol handle from expert_register_protocol()
186 @param ei the ei_register_info array
187 @param num_records the number of records in exp */
189 expert_register_field_array(expert_module_t *module, ei_register_info *ei, const int num_records);
191 #define EXPERT_CHECKSUM_DISABLED -2
192 #define EXPERT_CHECKSUM_UNKNOWN -1
193 #define EXPERT_CHECKSUM_GOOD 0
194 #define EXPERT_CHECKSUM_BAD 1
196 WS_DLL_PUBLIC const value_string expert_group_vals[];
198 WS_DLL_PUBLIC const value_string expert_severity_vals[];
200 WS_DLL_PUBLIC const value_string expert_checksum_vals[];
204 #endif /* __cplusplus */
206 #endif /* __EXPERT_H__ */
209 * Editor modelines - https://www.wireshark.org/tools/modelines.html
214 * indent-tabs-mode: t
217 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
218 * :indentSize=8:tabSize=8:noTabs=false: