2003-06-21 01:42:46 +00:00
|
|
|
/* service_response_time_table.c
|
|
|
|
* service_response_time_table 2003 Ronnie Sahlberg
|
|
|
|
* Helper routines common to all service response time statistics
|
|
|
|
* tap.
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2003-06-21 01:42:46 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2003-06-21 01:42:46 +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
|
|
|
|
|
2003-06-21 05:39:45 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <math.h>
|
2003-06-21 01:42:46 +00:00
|
|
|
#include <gtk/gtk.h>
|
2003-06-21 05:39:45 +00:00
|
|
|
#include "compat_macros.h"
|
2003-06-21 01:42:46 +00:00
|
|
|
#include "epan/packet_info.h"
|
|
|
|
#include "service_response_time_table.h"
|
2003-06-21 05:39:45 +00:00
|
|
|
#include "image/clist_ascend.xpm"
|
|
|
|
#include "image/clist_descend.xpm"
|
2003-09-05 10:26:44 +00:00
|
|
|
#include "simple_dialog.h"
|
|
|
|
#include "globals.h"
|
|
|
|
#include "gtk/find_dlg.h"
|
2003-10-10 08:59:17 +00:00
|
|
|
#include "color.h"
|
|
|
|
#include "gtk/color_dlg.h"
|
2004-01-25 18:51:26 +00:00
|
|
|
#include "main.h"
|
2005-08-20 12:09:48 +00:00
|
|
|
#include "gui_utils.h"
|
2004-06-02 07:12:11 +00:00
|
|
|
#include "gtkglobals.h"
|
|
|
|
|
2003-09-05 10:26:44 +00:00
|
|
|
|
|
|
|
#define GTK_MENU_FUNC(a) ((GtkItemFactoryCallback)(a))
|
2003-06-21 01:42:46 +00:00
|
|
|
|
|
|
|
|
2003-06-21 05:39:45 +00:00
|
|
|
typedef struct column_arrows {
|
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *ascend_pm;
|
|
|
|
GtkWidget *descend_pm;
|
|
|
|
} column_arrows;
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
srt_click_column_cb(GtkCList *clist, gint column, gpointer data)
|
|
|
|
{
|
|
|
|
column_arrows *col_arrows = (column_arrows *) data;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
gtk_clist_freeze(clist);
|
|
|
|
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
gtk_widget_hide(col_arrows[i].ascend_pm);
|
|
|
|
gtk_widget_hide(col_arrows[i].descend_pm);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (column == clist->sort_column) {
|
|
|
|
if (clist->sort_type == GTK_SORT_ASCENDING) {
|
|
|
|
clist->sort_type = GTK_SORT_DESCENDING;
|
|
|
|
gtk_widget_show(col_arrows[column].descend_pm);
|
|
|
|
} else {
|
|
|
|
clist->sort_type = GTK_SORT_ASCENDING;
|
|
|
|
gtk_widget_show(col_arrows[column].ascend_pm);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* Columns 2-5 Count, Min, Max, Avg are sorted in descending
|
|
|
|
order by default.
|
2003-06-22 04:00:21 +00:00
|
|
|
Columns 0 and 1 sort by ascending order by default
|
2003-06-21 05:39:45 +00:00
|
|
|
*/
|
|
|
|
if(column>=2){
|
|
|
|
clist->sort_type = GTK_SORT_DESCENDING;
|
|
|
|
gtk_widget_show(col_arrows[column].descend_pm);
|
|
|
|
} else {
|
|
|
|
clist->sort_type = GTK_SORT_ASCENDING;
|
|
|
|
gtk_widget_show(col_arrows[column].ascend_pm);
|
|
|
|
}
|
|
|
|
gtk_clist_set_sort_column(clist, column);
|
|
|
|
}
|
|
|
|
gtk_clist_thaw(clist);
|
|
|
|
|
|
|
|
gtk_clist_sort(clist);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
srt_sort_column(GtkCList *clist, gconstpointer ptr1, gconstpointer ptr2)
|
|
|
|
{
|
|
|
|
char *text1 = NULL;
|
|
|
|
char *text2 = NULL;
|
|
|
|
int i1, i2;
|
|
|
|
float f1,f2;
|
|
|
|
|
2004-12-31 00:33:54 +00:00
|
|
|
const GtkCListRow *row1 = ptr1;
|
|
|
|
const GtkCListRow *row2 = ptr2;
|
2003-06-21 05:39:45 +00:00
|
|
|
|
|
|
|
text1 = GTK_CELL_TEXT (row1->cell[clist->sort_column])->text;
|
|
|
|
text2 = GTK_CELL_TEXT (row2->cell[clist->sort_column])->text;
|
|
|
|
|
|
|
|
switch(clist->sort_column){
|
|
|
|
case 1:
|
|
|
|
return strcmp (text1, text2);
|
|
|
|
case 0:
|
|
|
|
case 2:
|
2003-06-22 04:00:21 +00:00
|
|
|
i1=atoi(text1);
|
2003-06-21 05:39:45 +00:00
|
|
|
i2=atoi(text2);
|
|
|
|
return i1-i2;
|
|
|
|
case 3:
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
sscanf(text1,"%f",&f1);
|
|
|
|
sscanf(text2,"%f",&f2);
|
|
|
|
if(fabs(f1-f2)<0.000005)
|
|
|
|
return 0;
|
|
|
|
if(f1>f2)
|
|
|
|
return 1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
g_assert_not_reached();
|
2003-06-22 04:00:21 +00:00
|
|
|
return 0;
|
2003-06-21 05:39:45 +00:00
|
|
|
}
|
|
|
|
|
2003-09-05 10:26:44 +00:00
|
|
|
|
|
|
|
|
2007-12-09 09:04:58 +00:00
|
|
|
/* Filter actions */
|
|
|
|
#define ACTION_MATCH 0
|
|
|
|
#define ACTION_PREPARE 1
|
|
|
|
#define ACTION_FIND_FRAME 2
|
|
|
|
#define ACTION_FIND_NEXT 3
|
|
|
|
#define ACTION_FIND_PREVIOUS 4
|
|
|
|
#define ACTION_COLORIZE 5
|
|
|
|
|
|
|
|
/* Action type - says what to do with the filter */
|
|
|
|
#define ACTYPE_SELECTED 0
|
|
|
|
#define ACTYPE_NOT_SELECTED 1
|
|
|
|
#define ACTYPE_AND_SELECTED 2
|
|
|
|
#define ACTYPE_OR_SELECTED 3
|
|
|
|
#define ACTYPE_AND_NOT_SELECTED 4
|
|
|
|
#define ACTYPE_OR_NOT_SELECTED 5
|
|
|
|
|
|
|
|
/* Encoded callback arguments */
|
|
|
|
#define CALLBACK_MATCH(type) ((ACTION_MATCH<<8) | (type))
|
|
|
|
#define CALLBACK_PREPARE(type) ((ACTION_PREPARE<<8) | (type))
|
|
|
|
#define CALLBACK_FIND_FRAME(type) ((ACTION_FIND_FRAME<<8) | (type))
|
|
|
|
#define CALLBACK_FIND_NEXT(type) ((ACTION_FIND_NEXT<<8) | (type))
|
|
|
|
#define CALLBACK_FIND_PREVIOUS(type) ((ACTION_FIND_PREVIOUS<<8) | (type))
|
|
|
|
#define CALLBACK_COLORIZE(type) ((ACTION_COLORIZE<<8) | (type))
|
|
|
|
|
|
|
|
/* Extract components of callback argument */
|
|
|
|
#define FILTER_ACTION(cb_arg) (((cb_arg)>>8) & 0xff)
|
|
|
|
#define FILTER_ACTYPE(cb_arg) ((cb_arg) & 0xff)
|
|
|
|
|
2003-09-05 10:26:44 +00:00
|
|
|
static void
|
|
|
|
srt_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callback_action)
|
|
|
|
{
|
|
|
|
int action, type, selection;
|
|
|
|
srt_stat_table *rst = (srt_stat_table *)callback_data;
|
2007-11-28 03:04:09 +00:00
|
|
|
char *str = NULL;
|
2003-12-04 00:45:39 +00:00
|
|
|
const char *current_filter;
|
2003-09-05 10:26:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
if(rst->filter_string==NULL){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-12-09 09:04:58 +00:00
|
|
|
action = FILTER_ACTION(callback_action);
|
|
|
|
type = FILTER_ACTYPE(callback_action);
|
2003-09-05 10:26:44 +00:00
|
|
|
|
|
|
|
selection=GPOINTER_TO_INT(g_list_nth_data(GTK_CLIST(rst->table)->selection, 0));
|
|
|
|
if(selection>=(int)rst->num_procs){
|
2004-01-31 03:22:42 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "No procedure selected");
|
2003-09-05 10:26:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* translate it back from row index to index in procedures array */
|
|
|
|
selection=GPOINTER_TO_INT(gtk_clist_get_row_data(rst->table, selection));
|
|
|
|
|
|
|
|
current_filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
|
|
|
|
|
|
|
switch(type){
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTYPE_SELECTED:
|
2007-11-28 03:04:09 +00:00
|
|
|
str = g_strdup_printf("%s==%d", rst->filter_string, selection);
|
2003-09-05 10:26:44 +00:00
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTYPE_NOT_SELECTED:
|
2007-11-28 03:04:09 +00:00
|
|
|
str = g_strdup_printf("!(%s==%d)", rst->filter_string,
|
|
|
|
selection);
|
2003-09-05 10:26:44 +00:00
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTYPE_AND_SELECTED:
|
2007-12-04 23:47:30 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
|
|
|
str = g_strdup_printf("%s==%d", rst->filter_string, selection);
|
|
|
|
else
|
|
|
|
str = g_strdup_printf("(%s) && (%s==%d)", current_filter,
|
|
|
|
rst->filter_string, selection);
|
2003-09-05 10:26:44 +00:00
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTYPE_OR_SELECTED:
|
2007-12-04 23:47:30 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
|
|
|
str = g_strdup_printf("%s==%d", rst->filter_string, selection);
|
|
|
|
else
|
|
|
|
str = g_strdup_printf("(%s) || (%s==%d)", current_filter,
|
|
|
|
rst->filter_string, selection);
|
2003-09-05 10:26:44 +00:00
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTYPE_AND_NOT_SELECTED:
|
2007-12-04 23:47:30 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
|
|
|
str = g_strdup_printf("!(%s==%d)", rst->filter_string, selection);
|
|
|
|
else
|
|
|
|
str = g_strdup_printf("(%s) && !(%s==%d)", current_filter,
|
|
|
|
rst->filter_string, selection);
|
2003-09-05 10:26:44 +00:00
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTYPE_OR_NOT_SELECTED:
|
2007-12-04 23:47:30 +00:00
|
|
|
if ((!current_filter) || (0 == strlen(current_filter)))
|
|
|
|
str = g_strdup_printf("!(%s==%d)", rst->filter_string, selection);
|
|
|
|
else
|
|
|
|
str = g_strdup_printf("(%s) || !(%s==%d)", current_filter,
|
|
|
|
rst->filter_string, selection);
|
2003-09-05 10:26:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), str);
|
|
|
|
|
|
|
|
switch(action){
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTION_MATCH:
|
2004-02-23 22:48:52 +00:00
|
|
|
main_filter_packets(&cfile, str, FALSE);
|
2007-12-04 07:50:18 +00:00
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTION_PREPARE:
|
2003-09-05 10:26:44 +00:00
|
|
|
/* do nothing */
|
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTION_FIND_FRAME:
|
2003-09-05 10:26:44 +00:00
|
|
|
find_frame_with_filter(str);
|
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTION_FIND_NEXT:
|
2003-10-10 08:52:19 +00:00
|
|
|
find_previous_next_frame_with_filter(str, FALSE);
|
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTION_FIND_PREVIOUS:
|
2003-10-10 08:52:19 +00:00
|
|
|
find_previous_next_frame_with_filter(str, TRUE);
|
|
|
|
break;
|
2007-12-09 09:04:58 +00:00
|
|
|
case ACTION_COLORIZE:
|
2003-10-10 08:59:17 +00:00
|
|
|
color_display_with_filter(str);
|
|
|
|
break;
|
2003-09-05 10:26:44 +00:00
|
|
|
}
|
|
|
|
|
2007-11-28 03:04:09 +00:00
|
|
|
g_free(str);
|
2003-09-05 10:26:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gint
|
|
|
|
srt_show_popup_menu_cb(void *widg _U_, GdkEvent *event, srt_stat_table *rst)
|
|
|
|
{
|
|
|
|
GdkEventButton *bevent = (GdkEventButton *)event;
|
|
|
|
|
|
|
|
if(event->type==GDK_BUTTON_PRESS && bevent->button==3){
|
|
|
|
gtk_menu_popup(GTK_MENU(rst->menu), NULL, NULL, NULL, NULL,
|
|
|
|
bevent->button, bevent->time);
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkItemFactoryEntry srt_list_menu_items[] =
|
|
|
|
{
|
|
|
|
/* Match */
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Apply as Filter", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Apply as Filter/Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_MATCH(ACTYPE_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Apply as Filter/... not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_MATCH(ACTYPE_NOT_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Apply as Filter/.. and Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_MATCH(ACTYPE_AND_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Apply as Filter/... or Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_MATCH(ACTYPE_OR_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Apply as Filter/... and not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_MATCH(ACTYPE_AND_NOT_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Apply as Filter/... or not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_MATCH(ACTYPE_OR_NOT_SELECTED), NULL, NULL),
|
2003-09-05 10:26:44 +00:00
|
|
|
|
|
|
|
/* Prepare */
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Prepare a Filter", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Prepare a Filter/Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_PREPARE(ACTYPE_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Prepare a Filter/Not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_PREPARE(ACTYPE_NOT_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Prepare a Filter/... and Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_PREPARE(ACTYPE_AND_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Prepare a Filter/... or Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_PREPARE(ACTYPE_OR_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Prepare a Filter/... and not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_PREPARE(ACTYPE_AND_NOT_SELECTED), NULL, NULL),
|
2004-05-07 12:15:24 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Prepare a Filter/... or not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_PREPARE(ACTYPE_OR_NOT_SELECTED), NULL, NULL),
|
2003-09-05 10:26:44 +00:00
|
|
|
|
|
|
|
/* Find Frame */
|
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame", NULL, NULL, 0, "<Branch>", NULL),
|
2003-10-10 08:52:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Frame", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Frame/Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_FIND_FRAME(ACTYPE_SELECTED), NULL, NULL),
|
2003-10-10 08:52:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Frame/Not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_FIND_FRAME(ACTYPE_NOT_SELECTED), NULL, NULL),
|
2003-10-10 08:52:19 +00:00
|
|
|
/* Find Next */
|
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Next", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Next/Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_FIND_NEXT(ACTYPE_SELECTED), NULL, NULL),
|
2003-10-10 08:52:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Next/Not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_FIND_NEXT(ACTYPE_NOT_SELECTED), NULL, NULL),
|
2003-10-10 08:52:19 +00:00
|
|
|
|
2003-10-10 08:59:17 +00:00
|
|
|
/* Find Previous */
|
2003-10-10 08:52:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Previous", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Previous/Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_FIND_PREVIOUS(ACTYPE_SELECTED), NULL, NULL),
|
2003-10-10 08:52:19 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Find Frame/Find Previous/Not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_FIND_PREVIOUS(ACTYPE_NOT_SELECTED), NULL, NULL),
|
2003-09-05 10:26:44 +00:00
|
|
|
|
2003-10-10 08:59:17 +00:00
|
|
|
/* Colorize Procedure */
|
|
|
|
ITEM_FACTORY_ENTRY("/Colorize Procedure", NULL, NULL, 0, "<Branch>", NULL),
|
|
|
|
ITEM_FACTORY_ENTRY("/Colorize Procedure/Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_COLORIZE(ACTYPE_SELECTED), NULL, NULL),
|
2003-10-10 08:59:17 +00:00
|
|
|
ITEM_FACTORY_ENTRY("/Colorize Procedure/Not Selected", NULL,
|
2007-12-09 09:04:58 +00:00
|
|
|
srt_select_filter_cb, CALLBACK_COLORIZE(ACTYPE_NOT_SELECTED), NULL, NULL),
|
2003-10-10 08:59:17 +00:00
|
|
|
|
2003-09-05 10:26:44 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
srt_create_popup_menu(srt_stat_table *rst)
|
|
|
|
{
|
|
|
|
GtkItemFactory *item_factory;
|
|
|
|
|
|
|
|
item_factory = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
|
|
|
|
|
|
|
|
gtk_item_factory_create_items_ac(item_factory, sizeof(srt_list_menu_items)/sizeof(srt_list_menu_items[0]), srt_list_menu_items, rst, 2);
|
|
|
|
|
|
|
|
rst->menu = gtk_item_factory_get_widget(item_factory, "<main>");
|
|
|
|
SIGNAL_CONNECT(rst->table, "button_press_event", srt_show_popup_menu_cb, rst);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-21 01:42:46 +00:00
|
|
|
void
|
2005-06-24 01:32:42 +00:00
|
|
|
init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, const char *filter_string)
|
2003-06-21 01:42:46 +00:00
|
|
|
{
|
|
|
|
int i, j;
|
2003-06-21 05:39:45 +00:00
|
|
|
column_arrows *col_arrows;
|
|
|
|
GdkBitmap *ascend_bm, *descend_bm;
|
|
|
|
GdkPixmap *ascend_pm, *descend_pm;
|
|
|
|
GtkStyle *win_style;
|
|
|
|
GtkWidget *column_lb;
|
2005-08-05 20:59:08 +00:00
|
|
|
const char *default_titles[] = { "Index", "Procedure", "Calls", "Min SRT", "Max SRT", "Avg SRT" };
|
2003-06-21 05:39:45 +00:00
|
|
|
|
2003-06-21 01:42:46 +00:00
|
|
|
|
2003-09-05 10:26:44 +00:00
|
|
|
if(filter_string){
|
|
|
|
rst->filter_string=g_strdup(filter_string);
|
|
|
|
} else {
|
|
|
|
rst->filter_string=NULL;
|
|
|
|
}
|
2004-02-06 19:19:12 +00:00
|
|
|
rst->scrolled_window=scrolled_window_new(NULL, NULL);
|
2003-06-21 01:42:46 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), rst->scrolled_window, TRUE, TRUE, 0);
|
|
|
|
|
2003-06-21 05:39:45 +00:00
|
|
|
rst->table=(GtkCList *)gtk_clist_new(6);
|
|
|
|
|
2003-06-22 04:00:21 +00:00
|
|
|
gtk_widget_show(GTK_WIDGET(rst->table));
|
|
|
|
gtk_widget_show(rst->scrolled_window);
|
|
|
|
|
2003-06-21 05:39:45 +00:00
|
|
|
col_arrows = (column_arrows *) g_malloc(sizeof(column_arrows) * 6);
|
|
|
|
win_style = gtk_widget_get_style(rst->scrolled_window);
|
|
|
|
ascend_pm = gdk_pixmap_create_from_xpm_d(rst->scrolled_window->window,
|
|
|
|
&ascend_bm,
|
|
|
|
&win_style->bg[GTK_STATE_NORMAL],
|
|
|
|
(gchar **)clist_ascend_xpm);
|
|
|
|
descend_pm = gdk_pixmap_create_from_xpm_d(rst->scrolled_window->window,
|
|
|
|
&descend_bm,
|
|
|
|
&win_style->bg[GTK_STATE_NORMAL],
|
|
|
|
(gchar **)clist_descend_xpm);
|
|
|
|
for (i = 0; i < 6; i++) {
|
|
|
|
col_arrows[i].table = gtk_table_new(2, 2, FALSE);
|
|
|
|
gtk_table_set_col_spacings(GTK_TABLE(col_arrows[i].table), 5);
|
|
|
|
column_lb = gtk_label_new(default_titles[i]);
|
|
|
|
gtk_table_attach(GTK_TABLE(col_arrows[i].table), column_lb, 0, 1, 0, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show(column_lb);
|
|
|
|
|
|
|
|
col_arrows[i].ascend_pm = gtk_pixmap_new(ascend_pm, ascend_bm);
|
|
|
|
gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].ascend_pm, 1, 2, 1, 2, GTK_SHRINK, GTK_SHRINK, 0, 0);
|
|
|
|
col_arrows[i].descend_pm = gtk_pixmap_new(descend_pm, descend_bm);
|
2003-06-22 04:00:21 +00:00
|
|
|
gtk_table_attach(GTK_TABLE(col_arrows[i].table), col_arrows[i].descend_pm, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 0, 0);
|
2003-06-21 06:45:49 +00:00
|
|
|
if (i == 2) {
|
|
|
|
gtk_widget_show(col_arrows[i].descend_pm);
|
|
|
|
}
|
2003-06-21 05:39:45 +00:00
|
|
|
gtk_clist_set_column_widget(GTK_CLIST(rst->table), i, col_arrows[i].table);
|
|
|
|
gtk_widget_show(col_arrows[i].table);
|
|
|
|
}
|
|
|
|
gtk_clist_column_titles_show(GTK_CLIST(rst->table));
|
|
|
|
|
|
|
|
gtk_clist_set_compare_func(rst->table, srt_sort_column);
|
2003-06-21 05:57:34 +00:00
|
|
|
gtk_clist_set_sort_column(rst->table, 2);
|
|
|
|
gtk_clist_set_sort_type(rst->table, GTK_SORT_DESCENDING);
|
2003-06-21 05:39:45 +00:00
|
|
|
|
2003-06-21 01:42:46 +00:00
|
|
|
|
|
|
|
/*XXX instead of this we should probably have some code to
|
|
|
|
dynamically adjust the width of the columns */
|
|
|
|
gtk_clist_set_column_width(rst->table, 0, 32);
|
|
|
|
gtk_clist_set_column_width(rst->table, 1, 160);
|
|
|
|
gtk_clist_set_column_width(rst->table, 2, 50);
|
|
|
|
gtk_clist_set_column_width(rst->table, 3, 60);
|
|
|
|
gtk_clist_set_column_width(rst->table, 4, 60);
|
|
|
|
gtk_clist_set_column_width(rst->table, 5, 60);
|
|
|
|
|
|
|
|
gtk_clist_set_shadow_type(rst->table, GTK_SHADOW_IN);
|
|
|
|
gtk_clist_column_titles_show(rst->table);
|
|
|
|
gtk_container_add(GTK_CONTAINER(rst->scrolled_window), (GtkWidget *)rst->table);
|
2003-06-21 05:39:45 +00:00
|
|
|
|
|
|
|
SIGNAL_CONNECT(rst->table, "click-column", srt_click_column_cb, col_arrows);
|
|
|
|
|
2003-06-22 04:00:21 +00:00
|
|
|
gtk_widget_show(GTK_WIDGET(rst->table));
|
2003-06-21 05:39:45 +00:00
|
|
|
gtk_widget_show(rst->scrolled_window);
|
|
|
|
|
2003-06-21 01:42:46 +00:00
|
|
|
|
|
|
|
rst->num_procs=num_procs;
|
|
|
|
rst->procedures=g_malloc(sizeof(srt_procedure_t)*num_procs);
|
|
|
|
for(i=0;i<num_procs;i++){
|
2005-08-22 07:12:20 +00:00
|
|
|
rst->procedures[i].stats.num=0;
|
|
|
|
rst->procedures[i].stats.min.secs=0;
|
|
|
|
rst->procedures[i].stats.min.nsecs=0;
|
|
|
|
rst->procedures[i].stats.max.secs=0;
|
|
|
|
rst->procedures[i].stats.max.nsecs=0;
|
|
|
|
rst->procedures[i].stats.tot.secs=0;
|
|
|
|
rst->procedures[i].stats.tot.nsecs=0;
|
2003-06-21 01:42:46 +00:00
|
|
|
for(j=0;j<6;j++){
|
|
|
|
rst->procedures[i].entries[j]=NULL;
|
|
|
|
}
|
|
|
|
}
|
2003-09-05 10:26:44 +00:00
|
|
|
|
|
|
|
/* create popup menu for this table */
|
|
|
|
if(rst->filter_string){
|
|
|
|
srt_create_popup_menu(rst);
|
|
|
|
}
|
2003-06-21 01:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-06-27 08:13:41 +00:00
|
|
|
init_srt_table_row(srt_stat_table *rst, int index, const char *procedure)
|
2003-06-21 01:42:46 +00:00
|
|
|
{
|
2004-04-07 04:31:32 +00:00
|
|
|
/* we have discovered a new procedure. Extend the table accordingly */
|
|
|
|
if(index>=rst->num_procs){
|
|
|
|
int old_num_procs=rst->num_procs;
|
|
|
|
int i,j;
|
|
|
|
rst->num_procs=index+1;
|
|
|
|
rst->procedures=g_realloc(rst->procedures, sizeof(srt_procedure_t)*(rst->num_procs));
|
|
|
|
for(i=old_num_procs;i<rst->num_procs;i++){
|
2005-08-22 07:12:20 +00:00
|
|
|
rst->procedures[i].stats.num=0;
|
|
|
|
rst->procedures[i].stats.min.secs=0;
|
|
|
|
rst->procedures[i].stats.min.nsecs=0;
|
|
|
|
rst->procedures[i].stats.max.secs=0;
|
|
|
|
rst->procedures[i].stats.max.nsecs=0;
|
|
|
|
rst->procedures[i].stats.tot.secs=0;
|
|
|
|
rst->procedures[i].stats.tot.nsecs=0;
|
2004-04-07 04:31:32 +00:00
|
|
|
for(j=0;j<6;j++){
|
|
|
|
rst->procedures[i].entries[j]=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-08-21 21:50:49 +00:00
|
|
|
rst->procedures[index].entries[0]=g_strdup_printf("%d", index);
|
2003-06-21 01:42:46 +00:00
|
|
|
|
|
|
|
rst->procedures[index].entries[1]=g_strdup(procedure);
|
|
|
|
|
|
|
|
rst->procedures[index].entries[2]=g_strdup("0");
|
|
|
|
rst->procedures[index].entries[3]=g_strdup("0");
|
|
|
|
rst->procedures[index].entries[4]=g_strdup("0");
|
|
|
|
rst->procedures[index].entries[5]=g_strdup("0");
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-01-01 02:57:02 +00:00
|
|
|
add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, packet_info *pinfo)
|
2003-06-21 01:42:46 +00:00
|
|
|
{
|
|
|
|
srt_procedure_t *rp;
|
2005-08-21 21:50:49 +00:00
|
|
|
nstime_t t, delta;
|
|
|
|
gint row;
|
2003-06-21 01:42:46 +00:00
|
|
|
|
|
|
|
rp=&rst->procedures[index];
|
2003-06-22 04:00:21 +00:00
|
|
|
|
2005-08-21 21:50:49 +00:00
|
|
|
/*
|
|
|
|
* If the count of calls for this procedure is currently zero, it's
|
|
|
|
* going to become non-zero, so add a row for it (we don't want
|
|
|
|
* rows for procedures that have no calls - especially if the
|
|
|
|
* procedure has no calls because the index doesn't correspond
|
|
|
|
* to a procedure, but is an unused/reserved value).
|
|
|
|
*
|
|
|
|
* (Yes, this means that the rows aren't in order by anything
|
|
|
|
* interesting. That's why we have the table sorted by a column.)
|
|
|
|
*/
|
2005-08-22 07:12:20 +00:00
|
|
|
if (rp->stats.num==0){
|
2005-08-21 21:50:49 +00:00
|
|
|
row=gtk_clist_append(rst->table, rst->procedures[index].entries);
|
2007-05-29 02:43:18 +00:00
|
|
|
gtk_clist_set_row_data(rst->table, row, (gpointer)(long) index);
|
2003-06-21 01:42:46 +00:00
|
|
|
}
|
2005-08-22 07:12:20 +00:00
|
|
|
|
|
|
|
/* calculate time delta between request and reply */
|
2005-08-24 21:31:56 +00:00
|
|
|
t=pinfo->fd->abs_ts;
|
|
|
|
nstime_delta(&delta, &t, req_time);
|
2005-08-22 07:12:20 +00:00
|
|
|
|
|
|
|
time_stat_update(&rp->stats, &delta, pinfo);
|
2003-06-21 01:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
draw_srt_table_data(srt_stat_table *rst)
|
|
|
|
{
|
2003-06-21 05:57:34 +00:00
|
|
|
int i,j;
|
2003-06-21 01:42:46 +00:00
|
|
|
guint64 td;
|
2005-08-21 21:50:49 +00:00
|
|
|
char *strp;
|
2003-06-21 01:42:46 +00:00
|
|
|
|
|
|
|
for(i=0;i<rst->num_procs;i++){
|
2005-08-21 21:50:49 +00:00
|
|
|
/* ignore procedures with no calls (they don't have CList rows) */
|
2005-08-22 07:12:20 +00:00
|
|
|
if(rst->procedures[i].stats.num==0){
|
2005-08-21 21:50:49 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2003-06-21 01:42:46 +00:00
|
|
|
/* scale it to units of 10us.*/
|
|
|
|
/* for long captures with a large tot time, this can overflow on 32bit */
|
2005-08-22 07:12:20 +00:00
|
|
|
td=(int)rst->procedures[i].stats.tot.secs;
|
|
|
|
td=td*100000+(int)rst->procedures[i].stats.tot.nsecs/10000;
|
|
|
|
td/=rst->procedures[i].stats.num;
|
2003-06-21 01:42:46 +00:00
|
|
|
|
2007-05-29 02:43:18 +00:00
|
|
|
j=gtk_clist_find_row_from_data(rst->table, (gpointer)(long)i);
|
2005-08-22 07:12:20 +00:00
|
|
|
strp=g_strdup_printf("%d", rst->procedures[i].stats.num);
|
2003-06-21 05:57:34 +00:00
|
|
|
gtk_clist_set_text(rst->table, j, 2, strp);
|
2003-06-21 01:42:46 +00:00
|
|
|
g_free(rst->procedures[i].entries[2]);
|
|
|
|
rst->procedures[i].entries[2]=strp;
|
|
|
|
|
|
|
|
|
2005-08-21 21:50:49 +00:00
|
|
|
strp=g_strdup_printf("%3d.%05d",
|
2005-08-22 07:12:20 +00:00
|
|
|
(int)rst->procedures[i].stats.min.secs,
|
|
|
|
rst->procedures[i].stats.min.nsecs/10000);
|
2003-06-21 05:57:34 +00:00
|
|
|
gtk_clist_set_text(rst->table, j, 3, strp);
|
2003-06-21 01:42:46 +00:00
|
|
|
g_free(rst->procedures[i].entries[3]);
|
|
|
|
rst->procedures[i].entries[3]=strp;
|
|
|
|
|
|
|
|
|
2005-08-21 21:50:49 +00:00
|
|
|
strp=g_strdup_printf("%3d.%05d",
|
2005-08-22 07:12:20 +00:00
|
|
|
(int)rst->procedures[i].stats.max.secs,
|
|
|
|
rst->procedures[i].stats.max.nsecs/10000);
|
2003-06-21 05:57:34 +00:00
|
|
|
gtk_clist_set_text(rst->table, j, 4, strp);
|
2003-06-21 01:42:46 +00:00
|
|
|
g_free(rst->procedures[i].entries[4]);
|
|
|
|
rst->procedures[i].entries[4]=strp;
|
|
|
|
|
2007-05-29 18:52:42 +00:00
|
|
|
strp=g_strdup_printf("%3" G_GINT64_MODIFIER "d.%05" G_GINT64_MODIFIER "d",
|
2005-08-21 21:50:49 +00:00
|
|
|
td/100000, td%100000);
|
2003-06-21 05:57:34 +00:00
|
|
|
gtk_clist_set_text(rst->table, j, 5, strp);
|
2003-06-21 01:42:46 +00:00
|
|
|
g_free(rst->procedures[i].entries[5]);
|
|
|
|
rst->procedures[i].entries[5]=strp;
|
|
|
|
}
|
2003-06-21 05:39:45 +00:00
|
|
|
|
|
|
|
gtk_clist_sort(rst->table);
|
2003-06-21 01:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
reset_srt_table_data(srt_stat_table *rst)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i=0;i<rst->num_procs;i++){
|
2005-08-22 07:12:20 +00:00
|
|
|
time_stat_init(&rst->procedures[i].stats);
|
2003-06-21 01:42:46 +00:00
|
|
|
}
|
2006-02-01 06:09:55 +00:00
|
|
|
gtk_clist_clear(rst->table);
|
2003-06-21 01:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
free_srt_table_data(srt_stat_table *rst)
|
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
|
|
|
|
for(i=0;i<rst->num_procs;i++){
|
|
|
|
for(j=0;j<6;j++){
|
|
|
|
if(rst->procedures[i].entries[j]){
|
|
|
|
g_free(rst->procedures[i].entries[j]);
|
|
|
|
rst->procedures[i].entries[j]=NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2003-09-05 10:26:44 +00:00
|
|
|
g_free(rst->filter_string);
|
|
|
|
rst->filter_string=NULL;
|
2003-06-21 01:42:46 +00:00
|
|
|
g_free(rst->procedures);
|
|
|
|
rst->procedures=NULL;
|
|
|
|
rst->num_procs=0;
|
|
|
|
}
|
|
|
|
|