2 * Collecting Expert information.
4 * Implemented as a tap named "expert".
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
38 static int expert_tap = -1;
44 if(expert_tap == -1) {
45 expert_tap = register_tap("expert");
52 /* memory cleanup will be done by se_... */
56 /* set's the PI_ flags to a protocol item
57 * (and it's parent items till the toplevel) */
59 expert_set_item_flags(proto_item *pi, int group, int severity)
62 if(proto_item_set_expert_flags(pi, group, severity)) {
63 /* propagate till toplevel item */
64 pi = proto_item_get_parent(pi);
65 expert_set_item_flags(pi, group, severity);
71 expert_set_info_vformat(
72 packet_info *pinfo, proto_item *pi, int group, int severity, const char *format, va_list ap)
74 int ret; /*tmp return value */
79 /* if this packet isn't loaded because of a read filter, don't output anything */
80 if(pinfo == NULL || pinfo->fd->num == 0) {
84 /* XXX - use currently nonexistant se_vsnprintf instead */
85 ret = g_vsnprintf(formatted, sizeof(formatted), format, ap);
86 if ((ret == -1) || (ret >= sizeof(formatted)))
87 formatted[sizeof(formatted) - 1] = '\0';
89 ei = ep_alloc(sizeof(expert_info_t));
90 ei->packet_num = pinfo->fd->num;
92 ei->severity = severity;
93 ei->protocol = ep_strdup(pinfo->current_proto);
94 ei->summary = ep_strdup(formatted);
97 /* if we have a proto_item (not a faked item), set expert attributes to it */
98 if(pi != NULL && pi->finfo != NULL) {
100 expert_set_item_flags(pi, group, severity);
103 tap_queue_packet(expert_tap, pinfo, ei);
108 expert_add_info_format(
109 packet_info *pinfo, proto_item *pi, int group, int severity, const char *format, ...)
114 va_start(ap, format);
115 expert_set_info_vformat(pinfo, pi, group, severity, format, ap);