attr_dissector_fn_t
[wireshark-sm.git] / epan / expert.h
blobfe4a056e8eeea9f019c3e3208c06142c2e8ef6b2
1 /** @file
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
14 #ifndef __EXPERT_H__
15 #define __EXPERT_H__
17 #include <epan/proto.h>
18 #include <epan/packet_info.h>
19 #include "value_string.h"
20 #include "ws_symbol_export.h"
22 #ifdef __cplusplus
23 extern "C" {
24 #endif /* __cplusplus */
26 /** only for internal and display use. */
27 typedef struct expert_info_s {
28 uint32_t packet_num;
29 int group;
30 int severity;
31 int hf_index; /* hf_index of the expert item. Might be -1. */
32 const char *protocol;
33 char *summary;
34 proto_item *pitem;
35 } expert_info_t;
37 /* Expert Info and Display hf data */
38 typedef struct expert_field
40 int ei;
41 int hf;
42 } expert_field;
44 #define EI_INIT_EI -1
45 #define EI_INIT_HF -1
46 #define EI_INIT {EI_INIT_EI, EI_INIT_HF}
48 typedef struct expert_field_info {
49 /* ---------- set by dissector --------- */
50 const char *name;
51 int group;
52 int severity;
53 const char *summary;
55 /* ------- set by register routines (prefilled by EXPFILL macro, see below) ------ */
56 int id;
57 const char *protocol;
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;
62 } expert_field_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 */
70 } ei_register_info;
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;
81 extern void
82 expert_init(void);
84 extern void
85 expert_packet_init(void);
87 extern void
88 expert_cleanup(void);
90 extern void
91 expert_packet_cleanup(void);
93 WS_DLL_PUBLIC int
94 expert_get_highest_severity(void);
96 WS_DLL_PUBLIC 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
102 pi is supplied
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
114 pi is supplied
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
146 would be used.
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 */
191 WS_DLL_PUBLIC void
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[];
205 #ifdef __cplusplus
207 #endif /* __cplusplus */
209 #endif /* __EXPERT_H__ */
212 * Editor modelines - https://www.wireshark.org/tools/modelines.html
214 * Local variables:
215 * c-basic-offset: 8
216 * tab-width: 8
217 * indent-tabs-mode: t
218 * End:
220 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
221 * :indentSize=8:tabSize=8:noTabs=false: