2005-09-11 16:55:34 +00:00
|
|
|
/* expert_dlg.c
|
|
|
|
* Display of Expert information.
|
2008-08-05 17:33:14 +00:00
|
|
|
*
|
2005-09-11 16:55:34 +00:00
|
|
|
* Implemented as a tap listener to the "expert" tap.
|
|
|
|
*
|
|
|
|
* $Id$
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-09-11 16:55:34 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
|
2005-09-11 16:55:34 +00:00
|
|
|
#include <gtk/gtk.h>
|
2008-04-13 01:54:20 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
#include <epan/expert.h>
|
|
|
|
#include <epan/emem.h>
|
|
|
|
#include <epan/tap.h>
|
2005-09-11 16:55:34 +00:00
|
|
|
#include "epan/packet_info.h"
|
2008-04-13 01:54:20 +00:00
|
|
|
#include <epan/stat_cmd_args.h>
|
|
|
|
#include <epan/prefs.h>
|
|
|
|
|
|
|
|
#include "../simple_dialog.h"
|
|
|
|
#include "../globals.h"
|
|
|
|
#include "../color.h"
|
|
|
|
#include "../stat_menu.h"
|
|
|
|
|
2005-09-11 16:55:34 +00:00
|
|
|
#include "gtk/find_dlg.h"
|
|
|
|
#include "gtk/color_dlg.h"
|
2008-04-13 01:54:20 +00:00
|
|
|
#include "gtk/main.h"
|
|
|
|
#include "gtk/gui_utils.h"
|
|
|
|
#include "gtk/gtkglobals.h"
|
|
|
|
#include "gtk/dlg_utils.h"
|
|
|
|
#include "gtk/gui_stat_menu.h"
|
|
|
|
#include "gtk/tap_dfilter_dlg.h"
|
2008-04-13 12:41:22 +00:00
|
|
|
#include "gtk/color_utils.h"
|
2008-04-13 01:54:20 +00:00
|
|
|
#include "gtk/main_proto_draw.h"
|
|
|
|
#include "gtk/help_dlg.h"
|
2009-08-19 18:37:13 +00:00
|
|
|
#include "gtk/expert_dlg.h"
|
2009-08-26 17:26:26 +00:00
|
|
|
#include "gtk/font_utils.h"
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2005-09-13 23:46:42 +00:00
|
|
|
static const value_string expert_severity_om_vals[] = {
|
2009-08-24 18:20:20 +00:00
|
|
|
{ PI_ERROR, "Errors only" },
|
|
|
|
{ PI_WARN, "Error+Warn" },
|
|
|
|
{ PI_NOTE, "Error+Warn+Note" },
|
|
|
|
{ PI_CHAT, "Error+Warn+Note+Chat" },
|
|
|
|
{ 0, NULL }
|
2005-09-11 16:55:34 +00:00
|
|
|
};
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
enum
|
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
NO_COLUMN,
|
|
|
|
SEVERITY_COLUMN,
|
|
|
|
GROUP_COLUMN,
|
|
|
|
PROTOCOL_COLUMN,
|
|
|
|
SUMMARY_COLUMN,
|
|
|
|
FOREGROUND_COLOR_COL,
|
|
|
|
BACKGROUND_COLOR_COL,
|
|
|
|
N_COLUMNS
|
2009-08-24 16:11:00 +00:00
|
|
|
};
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2005-09-13 23:46:42 +00:00
|
|
|
/* reset of display only, e.g. for filtering */
|
|
|
|
static void expert_dlg_display_reset(expert_tapdata_t * etd)
|
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
etd->disp_events = 0;
|
|
|
|
gtk_list_store_clear(GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(etd->tree_view))));
|
2005-09-13 23:46:42 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
gtk_window_set_title(GTK_WINDOW(etd->win), "Wireshark: ? Expert Infos");
|
|
|
|
if(etd->label) {
|
|
|
|
gtk_label_set_text(GTK_LABEL(etd->label), "Please wait ...");
|
|
|
|
}
|
2005-09-13 23:46:42 +00:00
|
|
|
}
|
2005-09-11 16:55:34 +00:00
|
|
|
|
|
|
|
|
2005-09-13 23:46:42 +00:00
|
|
|
/* complete reset, e.g. capture file closed */
|
2005-09-11 16:55:34 +00:00
|
|
|
void expert_dlg_reset(void *tapdata)
|
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
expert_tapdata_t * etd = tapdata;
|
|
|
|
|
|
|
|
etd->chat_events = 0;
|
|
|
|
etd->note_events = 0;
|
|
|
|
etd->warn_events = 0;
|
|
|
|
etd->error_events = 0;
|
|
|
|
etd->last = 0;
|
|
|
|
etd->first = 0;
|
|
|
|
/* g_string_chunk_clear() is introduced in glib 2.14 */
|
|
|
|
g_string_chunk_free(etd->text);
|
|
|
|
etd->text = g_string_chunk_new(100);
|
|
|
|
g_array_set_size(etd->ei_array, 0);
|
|
|
|
|
|
|
|
expert_dlg_display_reset(etd);
|
2005-09-11 16:55:34 +00:00
|
|
|
}
|
|
|
|
|
2005-09-17 00:39:52 +00:00
|
|
|
int expert_dlg_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *pointer)
|
2005-09-11 16:55:34 +00:00
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
expert_info_t *ei;
|
|
|
|
expert_tapdata_t *etd = tapdata;
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2009-08-19 18:37:13 +00:00
|
|
|
g_array_append_val(etd->ei_array, *(expert_info_t *)pointer);
|
|
|
|
etd->last = etd->ei_array->len;
|
|
|
|
ei = &g_array_index(etd->ei_array, expert_info_t, etd->last -1); /* ugly */
|
2009-08-23 18:13:03 +00:00
|
|
|
ei->protocol = g_string_chunk_insert_const(etd->text, ei->protocol);
|
2009-08-19 18:37:13 +00:00
|
|
|
ei->summary = g_string_chunk_insert_const(etd->text, ei->summary);
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
switch(ei->severity) {
|
|
|
|
case(PI_CHAT):
|
|
|
|
etd->chat_events++;
|
|
|
|
break;
|
|
|
|
case(PI_NOTE):
|
|
|
|
etd->note_events++;
|
|
|
|
break;
|
|
|
|
case(PI_WARN):
|
|
|
|
etd->warn_events++;
|
|
|
|
break;
|
|
|
|
case(PI_ERROR):
|
|
|
|
etd->error_events++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
if(ei->severity < etd->severity_report_level) {
|
|
|
|
return 0; /* draw not required */
|
|
|
|
} else {
|
|
|
|
return 1; /* draw required */
|
|
|
|
}
|
2005-09-11 16:55:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-09-11 22:25:33 +00:00
|
|
|
expert_dlg_draw(void *data)
|
2005-09-11 16:55:34 +00:00
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
expert_tapdata_t *etd = data;
|
|
|
|
expert_info_t *ei;
|
|
|
|
gchar *title;
|
2009-08-27 05:34:06 +00:00
|
|
|
const char *entries[2]; /**< column entries */
|
2009-08-24 16:11:00 +00:00
|
|
|
GtkListStore *list_store;
|
2009-08-24 18:20:20 +00:00
|
|
|
GtkTreeIter iter;
|
2009-08-26 17:26:26 +00:00
|
|
|
gchar *color_str;
|
2009-08-24 18:20:20 +00:00
|
|
|
guint packet_no = 0;
|
2009-08-27 05:34:06 +00:00
|
|
|
const gchar *group_str;
|
|
|
|
const gchar *severity_str;
|
2009-08-24 18:20:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
if(etd->label) {
|
|
|
|
if(etd->last - etd->first) {
|
|
|
|
title = g_strdup_printf("Adding: %u new messages",etd->last - etd->first);
|
|
|
|
gtk_label_set_text(GTK_LABEL(etd->label), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* append new events (remove from new list, append to displayed list and clist) */
|
|
|
|
while(etd->first < etd->last){
|
|
|
|
ei = &g_array_index(etd->ei_array, expert_info_t, etd->first);
|
|
|
|
etd->first++;
|
|
|
|
|
|
|
|
if(ei->severity < etd->severity_report_level) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
etd->disp_events++;
|
|
|
|
|
|
|
|
/* packet number */
|
|
|
|
if(ei->packet_num) {
|
2009-08-24 16:11:00 +00:00
|
|
|
packet_no = ei->packet_num;
|
2009-08-24 18:20:20 +00:00
|
|
|
}
|
|
|
|
|
2009-09-02 05:48:38 +00:00
|
|
|
/* match_strval return a static string or NULL
|
|
|
|
severity */
|
2009-08-27 05:34:06 +00:00
|
|
|
severity_str = match_strval(ei->severity, expert_severity_vals);
|
2009-08-24 18:20:20 +00:00
|
|
|
/* group */
|
2009-08-27 05:34:06 +00:00
|
|
|
group_str = match_strval(ei->group, expert_group_vals);
|
2009-08-24 18:20:20 +00:00
|
|
|
|
|
|
|
/* protocol */
|
|
|
|
if(ei->protocol) {
|
2009-08-27 05:34:06 +00:00
|
|
|
entries[0] = ei->protocol;
|
2009-08-24 18:20:20 +00:00
|
|
|
} else {
|
2009-08-27 05:34:06 +00:00
|
|
|
entries[0] = "-";
|
2009-08-24 18:20:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* summary */
|
2009-08-27 05:34:06 +00:00
|
|
|
entries[1] = ei->summary;
|
2009-08-24 18:20:20 +00:00
|
|
|
|
|
|
|
/* set rows background color depending on severity */
|
|
|
|
switch(ei->severity) {
|
|
|
|
case(PI_CHAT):
|
2009-08-26 17:26:26 +00:00
|
|
|
color_str = expert_color_chat_str;
|
2009-08-24 18:20:20 +00:00
|
|
|
break;
|
|
|
|
case(PI_NOTE):
|
2009-08-26 17:26:26 +00:00
|
|
|
color_str = expert_color_note_str;
|
2009-08-24 18:20:20 +00:00
|
|
|
break;
|
|
|
|
case(PI_WARN):
|
2009-08-26 17:26:26 +00:00
|
|
|
color_str = expert_color_warn_str;
|
2009-08-24 18:20:20 +00:00
|
|
|
break;
|
|
|
|
case(PI_ERROR):
|
2009-08-26 17:26:26 +00:00
|
|
|
color_str = expert_color_error_str;
|
2009-08-24 18:20:20 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
g_assert_not_reached();
|
|
|
|
}
|
|
|
|
|
|
|
|
list_store = GTK_LIST_STORE(gtk_tree_view_get_model(etd->tree_view)); /* Get store */
|
2009-08-24 16:11:00 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/* Creates a new row at position. iter will be changed to point to this new row.
|
|
|
|
* If position is larger than the number of rows on the list, then the new row will be appended to the list.
|
|
|
|
* The row will be filled with the values given to this function.
|
|
|
|
* :
|
|
|
|
* should generally be preferred when inserting rows in a sorted list store.
|
|
|
|
*/
|
2009-08-24 16:11:00 +00:00
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2009-08-24 18:20:20 +00:00
|
|
|
gtk_list_store_insert_with_values( list_store , &iter, G_MAXINT,
|
2009-08-24 16:11:00 +00:00
|
|
|
#else
|
2009-08-24 18:20:20 +00:00
|
|
|
gtk_list_store_append (list_store, &iter);
|
|
|
|
gtk_list_store_set (list_store, &iter,
|
2009-08-24 16:11:00 +00:00
|
|
|
#endif
|
2009-08-24 18:20:20 +00:00
|
|
|
NO_COLUMN, packet_no,
|
2009-08-27 05:34:06 +00:00
|
|
|
SEVERITY_COLUMN, severity_str,
|
|
|
|
GROUP_COLUMN, group_str,
|
|
|
|
PROTOCOL_COLUMN, entries[0],
|
|
|
|
SUMMARY_COLUMN, entries[1],
|
2009-08-26 17:26:26 +00:00
|
|
|
FOREGROUND_COLOR_COL, expert_color_foreground_str,
|
2009-08-24 18:20:20 +00:00
|
|
|
BACKGROUND_COLOR_COL, color_str,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(etd->label) {
|
|
|
|
title = g_strdup_printf("Errors: %u Warnings: %u Notes: %u Chats: %u",
|
|
|
|
etd->error_events, etd->warn_events,
|
|
|
|
etd->note_events, etd->chat_events);
|
|
|
|
gtk_label_set_text(GTK_LABEL(etd->label), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
|
|
|
|
|
|
|
title = g_strdup_printf("Wireshark: %u Expert Info%s",
|
|
|
|
etd->disp_events,
|
|
|
|
plurality(etd->disp_events, "", "s"));
|
|
|
|
gtk_window_set_title(GTK_WINDOW(etd->win), title);
|
|
|
|
g_free(title);
|
2005-09-11 16:55:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2009-08-24 16:11:00 +00:00
|
|
|
select_row_cb(GtkTreeSelection *selection, gpointer *user_data _U_)
|
2005-09-11 16:55:34 +00:00
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
/*guint num = GPOINTER_TO_UINT(gtk_clist_get_row_data(clist, row));*/
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/*cf_goto_frame(&cfile, num);*/
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
GtkTreeIter iter;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
guint fnumber;
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
if (selection==NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (gtk_tree_selection_get_selected (selection, &model, &iter)){
|
|
|
|
gtk_tree_model_get (model, &iter, NO_COLUMN, &fnumber, -1);
|
|
|
|
cf_goto_frame(&cfile, fnumber);
|
|
|
|
}
|
2005-09-11 16:55:34 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
void
|
2005-09-11 16:55:34 +00:00
|
|
|
expert_dlg_init_table(expert_tapdata_t * etd, GtkWidget *vbox)
|
|
|
|
{
|
2009-08-24 16:11:00 +00:00
|
|
|
GtkListStore *store;
|
|
|
|
GtkWidget *tree;
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
GtkTreeSortable *sortable;
|
2009-08-24 18:20:20 +00:00
|
|
|
GtkTreeSelection *selection;
|
2009-08-24 16:11:00 +00:00
|
|
|
|
|
|
|
/* Create the store */
|
2009-08-24 18:20:20 +00:00
|
|
|
store = gtk_list_store_new(N_COLUMNS, /* Total number of columns */
|
|
|
|
G_TYPE_UINT, /* No */
|
2009-08-27 05:34:06 +00:00
|
|
|
G_TYPE_POINTER, /* Severity */
|
|
|
|
G_TYPE_POINTER, /* Group */
|
2009-09-02 05:48:38 +00:00
|
|
|
G_TYPE_POINTER, /* Protocol */
|
|
|
|
G_TYPE_POINTER, /* Summary */
|
2009-08-24 16:11:00 +00:00
|
|
|
G_TYPE_STRING, /* forground */
|
|
|
|
G_TYPE_STRING); /* Background */
|
|
|
|
|
|
|
|
/* Create a view */
|
|
|
|
tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
|
|
|
|
etd->tree_view = GTK_TREE_VIEW(tree);
|
|
|
|
sortable = GTK_TREE_SORTABLE(store);
|
|
|
|
|
|
|
|
#if GTK_CHECK_VERSION(2,6,0)
|
2009-08-24 18:20:20 +00:00
|
|
|
/* Speed up the list display */
|
|
|
|
gtk_tree_view_set_fixed_height_mode(etd->tree_view, TRUE);
|
2009-08-24 16:11:00 +00:00
|
|
|
#endif
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
/* Setup the sortable columns */
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW (tree), FALSE);
|
|
|
|
|
|
|
|
/* The view now holds a reference. We can get rid of our own reference */
|
|
|
|
g_object_unref (G_OBJECT (store));
|
|
|
|
|
2009-09-02 05:48:38 +00:00
|
|
|
gtk_widget_modify_font(GTK_WIDGET (etd->tree_view), user_font_get_regular());
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
/* Create a cell renderer */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2009-09-02 05:48:38 +00:00
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
g_object_set(renderer, "xalign", 1.0, NULL);
|
2009-08-24 16:11:00 +00:00
|
|
|
|
|
|
|
/* Create the first column, associating the "text" attribute of the
|
|
|
|
* cell_renderer to the first column of the model */
|
2009-08-24 18:20:20 +00:00
|
|
|
/* No */
|
2009-08-24 16:11:00 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("No", renderer,
|
2009-08-24 18:20:20 +00:00
|
|
|
"text", NO_COLUMN,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, NO_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/* Severity */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2009-09-02 05:48:38 +00:00
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Severity", renderer,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
2009-08-27 05:34:06 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(SEVERITY_COLUMN), NULL);
|
|
|
|
|
2009-08-27 06:57:53 +00:00
|
|
|
gtk_tree_sortable_set_sort_func(sortable, SEVERITY_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(SEVERITY_COLUMN), NULL);
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, SEVERITY_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
/* Add the column to the view. */
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/* Group */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2009-09-02 05:48:38 +00:00
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
2009-08-24 18:20:20 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Group", renderer,
|
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
2009-08-27 05:34:06 +00:00
|
|
|
|
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
2009-08-27 06:57:53 +00:00
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_func(sortable, GROUP_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(GROUP_COLUMN), NULL);
|
2009-08-27 05:34:06 +00:00
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, GROUP_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
/* Add the column to the view. */
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/* Protocol. */
|
2009-08-24 16:11:00 +00:00
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2009-09-02 05:48:38 +00:00
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
2009-08-24 16:11:00 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Protocol", renderer,
|
2009-08-24 18:20:20 +00:00
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
2009-09-02 05:48:38 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_func(sortable, PROTOCOL_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(PROTOCOL_COLUMN), NULL);
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sort_column_id(column, PROTOCOL_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 80);
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
|
|
|
/* Summary. */
|
|
|
|
renderer = gtk_cell_renderer_text_new ();
|
2009-09-02 05:48:38 +00:00
|
|
|
g_object_set(renderer, "ypad", 0, NULL);
|
2009-08-24 16:11:00 +00:00
|
|
|
column = gtk_tree_view_column_new_with_attributes ("Summary", renderer,
|
2009-08-24 18:20:20 +00:00
|
|
|
"foreground", FOREGROUND_COLOR_COL,
|
|
|
|
"background", BACKGROUND_COLOR_COL,
|
|
|
|
NULL);
|
2009-09-02 05:48:38 +00:00
|
|
|
gtk_tree_view_column_set_cell_data_func(column, renderer, str_ptr_data_func,
|
|
|
|
GINT_TO_POINTER(SUMMARY_COLUMN), NULL);
|
|
|
|
|
|
|
|
gtk_tree_sortable_set_sort_func(sortable, SUMMARY_COLUMN, str_ptr_sort_func,
|
|
|
|
GINT_TO_POINTER(SUMMARY_COLUMN), NULL);
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
|
|
|
|
gtk_tree_view_column_set_min_width(column, 90);
|
|
|
|
gtk_tree_view_column_set_sort_column_id(column, SUMMARY_COLUMN);
|
|
|
|
gtk_tree_view_column_set_resizable(column, TRUE);
|
|
|
|
gtk_tree_view_append_column (etd->tree_view, column);
|
|
|
|
|
|
|
|
|
|
|
|
gtk_tree_view_set_search_column (etd->tree_view, SUMMARY_COLUMN); /* Allow searching the summary */
|
|
|
|
gtk_tree_view_set_reorderable (etd->tree_view, TRUE); /* Allow user to reorder data with drag n drop */
|
|
|
|
|
|
|
|
/* Now enable the sorting of each column */
|
|
|
|
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(etd->tree_view), TRUE);
|
|
|
|
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(etd->tree_view), TRUE);
|
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/* Setup the selection handler */
|
|
|
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(etd->tree_view));
|
|
|
|
gtk_tree_selection_set_mode(selection, GTK_SELECTION_SINGLE);
|
2009-08-24 16:11:00 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
g_signal_connect (G_OBJECT (selection), "changed", /* select_row */
|
2009-08-24 16:11:00 +00:00
|
|
|
G_CALLBACK (select_row_cb),
|
|
|
|
NULL);
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
etd->scrolled_window=scrolled_window_new(NULL, NULL);
|
|
|
|
gtk_container_add(GTK_CONTAINER(etd->scrolled_window), GTK_WIDGET (etd->tree_view));
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), etd->scrolled_window, TRUE, TRUE, 0);
|
2005-09-11 16:55:34 +00:00
|
|
|
}
|
|
|
|
|
2009-08-24 16:11:00 +00:00
|
|
|
|
2009-08-19 18:37:13 +00:00
|
|
|
void
|
2005-09-11 16:55:34 +00:00
|
|
|
expert_dlg_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
expert_tapdata_t *etd=(expert_tapdata_t *)data;
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
protect_thread_critical_region();
|
|
|
|
remove_tap_listener(etd);
|
|
|
|
unprotect_thread_critical_region();
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/*free_srt_table_data(&etd->afp_srt_table);*/
|
|
|
|
g_array_free(etd->ei_array, TRUE);
|
|
|
|
g_string_chunk_free(etd->text);
|
|
|
|
g_free(etd);
|
2005-09-11 16:55:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-13 23:46:42 +00:00
|
|
|
static void
|
2009-08-22 16:17:42 +00:00
|
|
|
expert_dlg_severity_cb(GtkWidget *w, gpointer data _U_)
|
2005-09-13 23:46:42 +00:00
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
int i;
|
|
|
|
expert_tapdata_t * etd;
|
2005-09-13 23:46:42 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
i = gtk_combo_box_get_active (GTK_COMBO_BOX(w));
|
|
|
|
etd = g_object_get_data(G_OBJECT(w), "tapdata");
|
2005-09-13 23:46:42 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
etd->severity_report_level = expert_severity_om_vals[i].value;
|
2005-09-13 23:46:42 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/* "move" all events from "all" back to "new" lists */
|
|
|
|
protect_thread_critical_region();
|
|
|
|
etd->first = 0;
|
|
|
|
unprotect_thread_critical_region();
|
2005-09-13 23:46:42 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
/* redraw table */
|
|
|
|
expert_dlg_display_reset(etd);
|
|
|
|
expert_dlg_draw(etd);
|
2005-09-13 23:46:42 +00:00
|
|
|
}
|
|
|
|
|
2009-08-19 18:37:13 +00:00
|
|
|
expert_tapdata_t * expert_dlg_new_table(void)
|
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
expert_tapdata_t * etd;
|
|
|
|
etd=g_malloc0(sizeof(expert_tapdata_t));
|
|
|
|
|
|
|
|
etd->ei_array = g_array_sized_new(FALSE, FALSE, sizeof(expert_info_t), 1000);
|
|
|
|
etd->text = g_string_chunk_new(100);
|
|
|
|
etd->severity_report_level = PI_CHAT;
|
|
|
|
return etd;
|
2009-08-19 18:37:13 +00:00
|
|
|
}
|
2005-09-11 16:55:34 +00:00
|
|
|
|
|
|
|
static void
|
2006-02-11 13:05:24 +00:00
|
|
|
expert_dlg_init(const char *optarg, void* userdata _U_)
|
2005-09-11 16:55:34 +00:00
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
expert_tapdata_t * etd;
|
|
|
|
const char *filter=NULL;
|
|
|
|
GString *error_string;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *close_bt;
|
|
|
|
GtkWidget *help_bt;
|
|
|
|
|
|
|
|
GtkWidget *severity_box;
|
|
|
|
GtkWidget *severity_combo_box;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkTooltips *tooltips = gtk_tooltips_new();
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if(!strncmp(optarg,"afp,srt,",8)){
|
|
|
|
filter=optarg+8;
|
|
|
|
} else {
|
|
|
|
filter=NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
proto_draw_colors_init();
|
|
|
|
|
|
|
|
etd = expert_dlg_new_table();
|
|
|
|
etd->win=dlg_window_new("Wireshark: Expert Info"); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(etd->win), TRUE);
|
|
|
|
|
|
|
|
gtk_window_set_default_size(GTK_WINDOW(etd->win), 650, 600);
|
|
|
|
|
|
|
|
vbox=gtk_vbox_new(FALSE, 3);
|
|
|
|
gtk_container_add(GTK_CONTAINER(etd->win), vbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
|
|
|
|
|
|
|
table = gtk_table_new(1, 2, TRUE /* homogeneous */);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
etd->label=gtk_label_new("Please wait ...");
|
|
|
|
gtk_misc_set_alignment(GTK_MISC(etd->label), 0.0f, 0.5f);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), etd->label, 0, 1, 0, 1);
|
|
|
|
|
|
|
|
severity_box = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_table_attach_defaults(GTK_TABLE(table), severity_box, 1, 2, 0, 1);
|
|
|
|
|
|
|
|
label=gtk_label_new("Severity filter: ");
|
|
|
|
gtk_box_pack_start(GTK_BOX(severity_box), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
severity_combo_box = gtk_combo_box_new_text ();
|
|
|
|
for(i=0; expert_severity_om_vals[i].strptr != NULL;i++){
|
|
|
|
gtk_combo_box_append_text (GTK_COMBO_BOX (severity_combo_box), expert_severity_om_vals[i].strptr);
|
|
|
|
if(expert_severity_om_vals[i].value == (guint) etd->severity_report_level) {
|
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(severity_combo_box), i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
g_object_set_data(G_OBJECT(severity_combo_box), "tapdata", etd);
|
|
|
|
g_signal_connect(severity_combo_box, "changed", G_CALLBACK(expert_dlg_severity_cb), etd->win);
|
|
|
|
gtk_box_pack_start(GTK_BOX(severity_box), severity_combo_box, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
|
|
|
|
/* We must display TOP LEVEL Widget before calling init_srt_table() */
|
|
|
|
gtk_widget_show_all(etd->win);
|
|
|
|
|
|
|
|
expert_dlg_init_table(etd, vbox);
|
|
|
|
/*for(i=0;i<256;i++){
|
|
|
|
init_srt_table_row(&etd->afp_srt_table, i, val_to_str(i, CommandCode_vals, "Unknown(%u)"));
|
|
|
|
}*/
|
|
|
|
|
|
|
|
error_string=register_tap_listener("expert", etd, NULL /* fstring */,
|
|
|
|
TL_REQUIRES_PROTO_TREE,
|
|
|
|
expert_dlg_reset,
|
|
|
|
expert_dlg_packet,
|
|
|
|
expert_dlg_draw);
|
|
|
|
if(error_string){
|
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
|
|
|
g_string_free(error_string, TRUE);
|
|
|
|
g_free(etd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Button row. */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, GTK_STOCK_HELP, NULL);
|
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
close_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
|
|
|
window_set_cancel_button(etd->win, close_bt, window_cancel_button_cb);
|
|
|
|
|
|
|
|
help_bt = g_object_get_data(G_OBJECT(bbox), GTK_STOCK_HELP);
|
|
|
|
g_signal_connect(help_bt, "clicked", G_CALLBACK(topic_cb), (gpointer)HELP_EXPERT_INFO_DIALOG);
|
|
|
|
gtk_tooltips_set_tip (tooltips, help_bt, "Show topic specific help", NULL);
|
|
|
|
|
|
|
|
g_signal_connect(etd->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(etd->win, "destroy", G_CALLBACK(expert_dlg_destroy_cb), etd);
|
|
|
|
|
|
|
|
gtk_widget_show_all(etd->win);
|
|
|
|
window_present(etd->win);
|
|
|
|
|
|
|
|
cf_retap_packets(&cfile);
|
|
|
|
|
|
|
|
/* This will bring up the progress bar
|
|
|
|
* Put our window back in front
|
|
|
|
*/
|
|
|
|
gdk_window_raise(etd->win->window);
|
|
|
|
expert_dlg_draw(etd);
|
2005-09-11 16:55:34 +00:00
|
|
|
}
|
|
|
|
|
2008-08-05 17:33:14 +00:00
|
|
|
static void
|
2005-09-11 16:55:34 +00:00
|
|
|
expert_dlg_cb(GtkWidget *w _U_, gpointer d _U_)
|
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
expert_dlg_init("", NULL);
|
2005-09-11 16:55:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_expert(void)
|
|
|
|
{
|
2009-08-24 18:20:20 +00:00
|
|
|
register_stat_cmd_arg("expert", expert_dlg_init,NULL);
|
2005-09-11 16:55:34 +00:00
|
|
|
|
2009-08-24 18:20:20 +00:00
|
|
|
register_stat_menu_item("E_xpert Info", REGISTER_ANALYZE_GROUP_UNSORTED,
|
2005-09-11 16:55:34 +00:00
|
|
|
expert_dlg_cb, NULL, NULL, NULL);
|
|
|
|
}
|