2005-08-20 02:19:37 +00:00
|
|
|
/* afp_stat.c
|
|
|
|
* Based on
|
|
|
|
* smb_stat 2003 Ronnie Sahlberg
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2005-08-20 02:19:37 +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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2005-08-20 02:19:37 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 01:48:30 +00:00
|
|
|
#include "config.h"
|
2005-08-20 02:19:37 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include <epan/packet_info.h>
|
|
|
|
#include <epan/value_string.h>
|
|
|
|
#include <epan/tap.h>
|
|
|
|
#include <epan/dissectors/packet-afp.h>
|
2008-04-13 00:55:59 +00:00
|
|
|
|
|
|
|
|
2012-01-16 01:07:52 +00:00
|
|
|
#include "ui/simple_dialog.h"
|
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/service_response_time_table.h"
|
|
|
|
#include "ui/gtk/tap_param_dlg.h"
|
|
|
|
#include "ui/gtk/main.h"
|
2005-08-20 02:19:37 +00:00
|
|
|
|
|
|
|
|
2014-01-17 19:35:57 +00:00
|
|
|
void register_tap_listener_gtkafpstat(void);
|
|
|
|
|
2005-08-20 02:19:37 +00:00
|
|
|
/* used to keep track of the statistics for an entire program interface */
|
|
|
|
typedef struct _afpstat_t {
|
|
|
|
GtkWidget *win;
|
|
|
|
srt_stat_table afp_srt_table;
|
|
|
|
} afpstat_t;
|
|
|
|
|
|
|
|
static void
|
|
|
|
afpstat_set_title(afpstat_t *ss)
|
|
|
|
{
|
2012-06-03 22:03:05 +00:00
|
|
|
set_window_title(ss->win, "AFP Service Response Time statistics");
|
2005-08-20 02:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
afpstat_reset(void *pss)
|
|
|
|
{
|
|
|
|
afpstat_t *ss=(afpstat_t *)pss;
|
|
|
|
|
|
|
|
reset_srt_table_data(&ss->afp_srt_table);
|
|
|
|
afpstat_set_title(ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
|
|
|
|
{
|
|
|
|
afpstat_t *ss=(afpstat_t *)pss;
|
2013-03-21 02:29:09 +00:00
|
|
|
const afp_request_val *request_val=(const afp_request_val *)prv;
|
2005-08-20 02:19:37 +00:00
|
|
|
|
|
|
|
/* if we havnt seen the request, just ignore it */
|
|
|
|
if(!request_val){
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_srt_table_data(&ss->afp_srt_table, request_val->command, &request_val->req_time, pinfo);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
afpstat_draw(void *pss)
|
|
|
|
{
|
|
|
|
afpstat_t *ss=(afpstat_t *)pss;
|
|
|
|
|
|
|
|
draw_srt_table_data(&ss->afp_srt_table);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|
|
|
{
|
|
|
|
afpstat_t *ss=(afpstat_t *)data;
|
|
|
|
|
|
|
|
remove_tap_listener(ss);
|
|
|
|
|
|
|
|
free_srt_table_data(&ss->afp_srt_table);
|
|
|
|
g_free(ss);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2012-12-05 15:56:36 +00:00
|
|
|
gtk_afpstat_init(const char *opt_arg, void *userdata _U_)
|
2005-08-20 02:19:37 +00:00
|
|
|
{
|
|
|
|
afpstat_t *ss;
|
|
|
|
const char *filter=NULL;
|
|
|
|
GtkWidget *label;
|
2007-11-28 03:04:09 +00:00
|
|
|
char *filter_string;
|
2005-08-20 02:19:37 +00:00
|
|
|
GString *error_string;
|
|
|
|
int i;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *close_bt;
|
|
|
|
|
2012-12-05 15:56:36 +00:00
|
|
|
if(!strncmp(opt_arg,"afp,srt,",8)){
|
|
|
|
filter=opt_arg+8;
|
2005-08-20 02:19:37 +00:00
|
|
|
} else {
|
|
|
|
filter=NULL;
|
|
|
|
}
|
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
ss=(afpstat_t *)g_malloc(sizeof(afpstat_t));
|
2005-08-20 02:19:37 +00:00
|
|
|
|
2009-06-21 20:42:07 +00:00
|
|
|
ss->win=dlg_window_new("afp-stat"); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE);
|
Add a "Sum" column to the Service Response Time (SRT) window.
The Service Response Time (SRT) window currently provides the
columns: Index, Procedure, Calls, Min SRT, Max SRT, and Avg SRT.
A Sum column has been found useful in some customer situations
to understand the total time spent doing a set of procedures.
For example, in one case we were trying to isolate whether most
time was being spent on a client thread or in the act of making
outbound calls. We knew the start and end time of the client call,
so with the "Sum" of time spent in that period, we could isolate
a particular set of procedures driving the slow down.
Additional changes made in this patch:
* Add " (s)" to Min, Max, Avg, and Sum columns to make it clear
that times are in seconds.
* Refactor out width and height constants used in calls to
gtk_window_set_default_size in most of the SRT users into
#define SRT_PREFERRED_WIDTH and SRT_PREFERRED_HEIGHT. Also
increase the common width of 550 to 650 to account for the
additional column.
Change-Id: I20f152eecbcd0bbf69f71c6c6b9f9463e8867e23
Reviewed-on: https://code.wireshark.org/review/7047
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2015-02-10 01:20:38 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(ss->win), SRT_PREFERRED_WIDTH, 600);
|
2005-08-20 02:19:37 +00:00
|
|
|
afpstat_set_title(ss);
|
|
|
|
|
2012-04-21 17:06:30 +00:00
|
|
|
vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
2005-08-20 02:19:37 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(ss->win), vbox);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
|
|
|
|
|
|
|
label=gtk_label_new("AFP Service Response Time statistics");
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
2007-11-28 03:04:09 +00:00
|
|
|
filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
|
2005-08-20 02:19:37 +00:00
|
|
|
label=gtk_label_new(filter_string);
|
2007-11-28 03:04:09 +00:00
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
|
|
|
|
g_free(filter_string);
|
2005-08-20 02:19:37 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
label=gtk_label_new("AFP Commands");
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
/* We must display TOP LEVEL Widget before calling init_srt_table() */
|
|
|
|
gtk_widget_show_all(ss->win);
|
|
|
|
|
2008-09-03 10:24:38 +00:00
|
|
|
init_srt_table(&ss->afp_srt_table, 256, vbox, "afp.command");
|
2005-08-20 02:19:37 +00:00
|
|
|
for(i=0;i<256;i++){
|
2015-02-03 00:58:29 +00:00
|
|
|
gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &CommandCode_vals_ext, "Unknown(%u)");
|
|
|
|
init_srt_table_row(&ss->afp_srt_table, i, tmp_str);
|
|
|
|
wmem_free(NULL, tmp_str);
|
2005-08-20 02:19:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-05 22:42:47 +00:00
|
|
|
error_string=register_tap_listener("afp", ss, filter, 0, afpstat_reset, afpstat_packet, afpstat_draw);
|
2005-08-20 02:19:37 +00:00
|
|
|
if(error_string){
|
2008-10-31 09:53:56 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
2005-08-20 02:19:37 +00:00
|
|
|
g_string_free(error_string, TRUE);
|
|
|
|
g_free(ss);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Button row. */
|
|
|
|
bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
|
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
|
|
|
|
|
2013-03-21 02:29:09 +00:00
|
|
|
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2005-08-20 02:19:37 +00:00
|
|
|
window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb);
|
|
|
|
|
2008-04-09 05:37:53 +00:00
|
|
|
g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss);
|
2005-08-20 02:19:37 +00:00
|
|
|
|
|
|
|
gtk_widget_show_all(ss->win);
|
|
|
|
window_present(ss->win);
|
2008-08-05 17:33:14 +00:00
|
|
|
|
2009-06-05 22:42:47 +00:00
|
|
|
cf_retap_packets(&cfile);
|
2011-07-21 20:12:08 +00:00
|
|
|
gdk_window_raise(gtk_widget_get_window(ss->win));
|
2005-08-20 02:19:37 +00:00
|
|
|
}
|
|
|
|
|
2011-06-05 22:39:23 +00:00
|
|
|
static tap_param afp_stat_params[] = {
|
2014-11-14 20:21:12 +00:00
|
|
|
{ PARAM_FILTER, "filter", "Filter", NULL, TRUE }
|
2011-06-05 22:39:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static tap_param_dlg afp_stat_dlg = {
|
2005-08-21 11:09:36 +00:00
|
|
|
"AFP SRT Statistics",
|
|
|
|
"afp,srt",
|
|
|
|
gtk_afpstat_init,
|
2011-06-05 22:39:23 +00:00
|
|
|
-1,
|
|
|
|
G_N_ELEMENTS(afp_stat_params),
|
|
|
|
afp_stat_params
|
2005-08-21 11:09:36 +00:00
|
|
|
};
|
2005-08-20 02:19:37 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
register_tap_listener_gtkafpstat(void)
|
|
|
|
{
|
2013-05-24 01:10:16 +00:00
|
|
|
register_param_stat(&afp_stat_dlg, "AFP",
|
2005-08-21 11:09:36 +00:00
|
|
|
REGISTER_STAT_GROUP_RESPONSE_TIME);
|
2005-08-20 02:19:37 +00:00
|
|
|
}
|
2015-02-15 18:58:39 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|