2 * Collecting of Expert information.
4 * For further info, see:
5 * https://gitlab.com/wireshark/wireshark/-/wikis/Development/ExpertInfo
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
17 #include <epan/proto.h>
18 #include <epan/packet_info.h>
19 #include "value_string.h"
20 #include "ws_symbol_export.h"
24 #endif /* __cplusplus */
26 /** only for internal and display use. */
27 typedef struct expert_info_s
{
31 int hf_index
; /* hf_index of the expert item. Might be -1. */
37 /* Expert Info and Display hf data */
38 typedef struct expert_field
46 #define EI_INIT {EI_INIT_EI, EI_INIT_HF}
48 typedef struct expert_field_info
{
49 /* ---------- set by dissector --------- */
55 /* ------- set by register routines (prefilled by EXPFILL macro, see below) ------ */
58 int orig_severity
; /* Matches severity when registered, used to restore original severity
59 * if UAT severity entry is removed */
60 hf_register_info hf_info
;
64 #define EXPFILL 0, NULL, 0, \
65 {0, {NULL, NULL, FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL}}
67 typedef struct ei_register_info
{
68 expert_field
*ids
; /**< written to by register() function */
69 expert_field_info eiinfo
; /**< the field info to be registered */
72 typedef struct expert_module expert_module_t
;
74 #define PRE_ALLOC_EXPERT_FIELDS_MEM 5000
76 /* "proto_expert" is exported from libwireshark.dll.
77 * Thus we need a special declaration.
79 WS_DLL_PUBLIC
int proto_expert
;
85 expert_packet_init(void);
91 expert_packet_cleanup(void);
94 expert_get_highest_severity(void);
97 expert_update_comment_count(uint64_t count
);
99 /** Add an expert info.
100 Add an expert info tree to a protocol item using registered expert info item
101 @param pinfo Packet info of the currently processed packet. May be NULL if
103 @param pi Current protocol item (or NULL)
104 @param eiindex The registered expert info item
105 @return the newly created expert info tree
107 WS_DLL_PUBLIC proto_item
*
108 expert_add_info(packet_info
*pinfo
, proto_item
*pi
, expert_field
*eiindex
);
110 /** Add an expert info.
111 Add an expert info tree to a protocol item using registered expert info item,
112 but with a formatted message.
113 @param pinfo Packet info of the currently processed packet. May be NULL if
115 @param pi Current protocol item (or NULL)
116 @param eiindex The registered expert info item
117 @param format Printf-style format string for additional arguments
118 @return the newly created expert info tree
120 WS_DLL_PUBLIC proto_item
*
121 expert_add_info_format(packet_info
*pinfo
, proto_item
*pi
, expert_field
*eiindex
,
122 const char *format
, ...) G_GNUC_PRINTF(4, 5);
124 /** Add an expert info associated with some byte data
125 Add an expert info tree to a protocol item using registered expert info item.
126 This function is intended to replace places where a "text only" proto_tree_add_xxx
127 API + expert_add_info would be used.
128 @param tree Current protocol tree (or NULL)
129 @param pinfo Packet info of the currently processed packet. May be NULL if tree is supplied
130 @param eiindex The registered expert info item
131 @param tvb the tv buffer of the current data
132 @param start start of data in tvb
133 @param length length of data in tvb
134 @return the newly created item above expert info tree
136 WS_DLL_PUBLIC proto_item
*
137 proto_tree_add_expert(proto_tree
*tree
, packet_info
*pinfo
, expert_field
*eiindex
,
138 tvbuff_t
*tvb
, int start
, int length
);
140 /** Add an expert info associated with some byte data
141 Add an expert info tree to a protocol item, using registered expert info item,
142 but with a formatted message.
143 Add an expert info tree to a protocol item using registered expert info item.
144 This function is intended to replace places where a "text only" proto_tree_add_xxx
145 API + expert_add_info_format
147 @param tree Current protocol tree (or NULL)
148 @param pinfo Packet info of the currently processed packet. May be NULL if tree is supplied
149 @param eiindex The registered expert info item
150 @param tvb the tv buffer of the current data
151 @param start start of data in tvb
152 @param length length of data in tvb
153 @param format Printf-style format string for additional arguments
154 @return the newly created item above expert info tree
156 WS_DLL_PUBLIC proto_item
*
157 proto_tree_add_expert_format(proto_tree
*tree
, packet_info
*pinfo
, expert_field
*eiindex
,
158 tvbuff_t
*tvb
, int start
, int length
, const char *format
, ...) G_GNUC_PRINTF(7, 8);
161 * Register that a protocol has expert info.
163 WS_DLL_PUBLIC expert_module_t
*expert_register_protocol(int id
);
166 * Deregister a expert info.
168 void expert_deregister_expertinfo (const char *abbrev
);
171 * Deregister expert info from a protocol.
173 void expert_deregister_protocol (expert_module_t
*module
);
176 * Free deregistered expert infos.
178 void expert_free_deregistered_expertinfos (void);
181 * Get summary text of an expert_info field.
182 * This is intended for use in expert_add_info_format or proto_tree_add_expert_format
183 * to get the "base" string to then append additional information
185 WS_DLL_PUBLIC
const char* expert_get_summary(expert_field
*eiindex
);
187 /** Register a expert field array.
188 @param module the protocol handle from expert_register_protocol()
189 @param ei the ei_register_info array
190 @param num_records the number of records in exp */
192 expert_register_field_array(expert_module_t
*module
, ei_register_info
*ei
, const int num_records
);
194 #define EXPERT_CHECKSUM_DISABLED -2
195 #define EXPERT_CHECKSUM_UNKNOWN -1
196 #define EXPERT_CHECKSUM_GOOD 0
197 #define EXPERT_CHECKSUM_BAD 1
199 WS_DLL_PUBLIC
const value_string expert_group_vals
[];
201 WS_DLL_PUBLIC
const value_string expert_severity_vals
[];
203 WS_DLL_PUBLIC
const value_string expert_checksum_vals
[];
207 #endif /* __cplusplus */
209 #endif /* __EXPERT_H__ */
212 * Editor modelines - https://www.wireshark.org/tools/modelines.html
217 * indent-tabs-mode: t
220 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
221 * :indentSize=8:tabSize=8:noTabs=false: