/* rpc_stat.c
* rpc_stat 2002 Ronnie Sahlberg
*
- * $Id: rpc_stat.c,v 1.39 2004/02/22 18:44:03 ulfl Exp $
+ * $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
#include "simple_dialog.h"
#include "ui_util.h"
#include "dlg_utils.h"
-#include "tap.h"
+#include <epan/tap.h>
#include "../register.h"
-#include "packet-rpc.h"
+#include <epan/dissectors/packet-rpc.h>
#include "../globals.h"
-#include "filter_prefs.h"
+#include "filter_dlg.h"
#include "compat_macros.h"
#include "service_response_time_table.h"
+#include "gtkglobals.h"
-extern GtkWidget *main_display_filter_widget;
/* used to keep track of the statistics for an entire program interface */
typedef struct _rpcstat_t {
static int
rpcstat_packet(rpcstat_t *rs, packet_info *pinfo, epan_dissect_t *edt _U_, rpc_call_info_value *ri)
{
- if(ri->proc>=rs->num_procedures){
- /* dont handle this since its outside of known table */
- return 0;
- }
/* we are only interested in reply packets */
if(ri->request){
return 0;
if( (ri->prog!=rs->program) || (ri->vers!=rs->version) ){
return 0;
}
-
+ /* maybe we have discovered a new procedure?
+ * then we might need to extend our tables
+ */
+ if(ri->proc>=rs->num_procedures){
+ guint32 i;
+ if(ri->proc>256){
+ /* no program have probably ever more than this many
+ * procedures anyway and it prevent us from allocating
+ * infinite memory if passed a garbage procedure id
+ */
+ return 0;
+ }
+ for(i=rs->num_procedures;i<=ri->proc;i++){
+ init_srt_table_row(&rs->srt_table, i, rpc_proc_name(rs->program, rs->version, i));
+ }
+ rs->num_procedures=ri->proc+1;
+ }
add_srt_table_data(&rs->srt_table, ri->proc, &ri->req_time, pinfo);
return 1;
GtkWidget *vbox;
GtkWidget *stat_label;
GtkWidget *filter_label;
+ GtkWidget *bbox;
+ GtkWidget *close_bt;
int program, version, pos;
char *filter=NULL;
GString *error_string;
hf_index=rpc_prog_hf(rpc_program, rpc_version);
hfi=proto_registrar_get_nth(hf_index);
- rs->win=window_new(GTK_WINDOW_TOPLEVEL, NULL);
+ rs->win=window_new(GTK_WINDOW_TOPLEVEL, "rpc-stat");
gtk_window_set_default_size(GTK_WINDOW(rs->win), 550, 400);
rpcstat_set_title(rs);
- SIGNAL_CONNECT(rs->win, "destroy", win_destroy_cb, rs);
- vbox=gtk_vbox_new(FALSE, 0);
+ vbox=gtk_vbox_new(FALSE, 3);
gtk_container_add(GTK_CONTAINER(rs->win), vbox);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 10);
- gtk_widget_show(vbox);
-
- title_string = rpcstat_gen_title(rs);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
+
+ title_string = rpcstat_gen_title(rs);
stat_label=gtk_label_new(title_string);
g_free(title_string);
gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0);
- gtk_widget_show(stat_label);
- snprintf(filter_string,255,"Filter:%s",filter?filter:"");
+ g_snprintf(filter_string,255,"Filter:%s",filter?filter:"");
filter_label=gtk_label_new(filter_string);
gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0);
- gtk_widget_show(filter_label);
rpc_min_proc=-1;
rpc_max_proc=-1;
rs->num_procedures=rpc_max_proc+1;
/* We must display TOP LEVEL Widget before calling init_srt_table() */
- gtk_widget_show(rs->win);
+ gtk_widget_show_all(rs->win);
init_srt_table(&rs->srt_table, rpc_max_proc+1, vbox, hfi->abbrev);
return;
}
+ /* Button row. */
+ bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL);
+ gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
- gtk_widget_show_all(rs->win);
- retap_packets(&cfile);
+ close_bt = OBJECT_GET_DATA(bbox, GTK_STOCK_CLOSE);
+ window_set_cancel_button(rs->win, close_bt, window_cancel_button_cb);
+
+ SIGNAL_CONNECT(rs->win, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(rs->win, "destroy", win_destroy_cb, rs);
+
+ gtk_widget_show_all(rs->win);
+ window_present(rs->win);
+
+ retap_packets(&cfile);
}
for(i=rpc_min_vers;i<=rpc_max_vers;i++){
GtkWidget *menu_item;
char vs[5];
- sprintf(vs,"%d",i);
+ g_snprintf(vs, 5, "%d",i);
menu_item=gtk_menu_item_new_with_label(vs);
SIGNAL_CONNECT(menu_item, "activate", rpcstat_version_select,
i);
dlg=NULL;
}
-static void
-dlg_cancel_cb(GtkWidget *cancel_bt _U_, gpointer parent_w)
-{
- gtk_widget_destroy(GTK_WIDGET(parent_w));
-}
-
static void
gtk_rpcstat_cb(GtkWidget *w _U_, gpointer d _U_)
{
}
dlg=dlg_window_new("Ethereal: Compute ONC-RPC SRT statistics");
- SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
+ gtk_window_set_default_size(GTK_WINDOW(dlg), 300, -1);
dlg_box=gtk_vbox_new(FALSE, 10);
gtk_container_border_width(GTK_CONTAINER(dlg_box), 10);
for(i=rpc_min_vers;i<=rpc_max_vers;i++){
GtkWidget *menu_item;
char vs[5];
- sprintf(vs,"%d",i);
+ g_snprintf(vs, 5, "%d",i);
menu_item=gtk_menu_item_new_with_label(vs);
SIGNAL_CONNECT(menu_item, "activate", rpcstat_version_select,
i);
/* Filter entry */
filter_entry=gtk_entry_new();
- WIDGET_SET_SIZE(filter_entry, 300, -2);
+ SIGNAL_CONNECT(filter_entry, "changed", filter_te_syntax_check_cb, NULL);
/* filter prefs dialog */
OBJECT_SET_DATA(filter_bt, E_FILT_TE_PTR_KEY, filter_entry);
gtk_widget_show(bbox);
start_button = OBJECT_GET_DATA(bbox, ETHEREAL_STOCK_CREATE_STAT);
- gtk_widget_grab_default(start_button );
SIGNAL_CONNECT_OBJECT(start_button, "clicked",
rpcstat_start_button_clicked, NULL);
cancel_button = OBJECT_GET_DATA(bbox, GTK_STOCK_CANCEL);
- SIGNAL_CONNECT(cancel_button, "clicked", dlg_cancel_cb, dlg);
-
- /* Catch the "activate" signal on the filter text entry, so that
- if the user types Return there, we act as if the "Create Stat"
- button had been selected, as happens if Return is typed if some
- widget that *doesn't* handle the Return key has the input
- focus. */
- dlg_set_activate(filter_entry, start_button);
-
- /* Catch the "key_press_event" signal in the window, so that we can
- catch the ESC key being pressed and act as if the "Cancel" button
- had been selected. */
- dlg_set_cancel(dlg, cancel_button);
+ window_set_cancel_button(dlg, cancel_button, window_cancel_button_cb);
/* Give the initial focus to the "Filter" entry box. */
gtk_widget_grab_focus(filter_entry);
- gtk_widget_show_all(dlg);
+ gtk_widget_grab_default(start_button );
+
+ SIGNAL_CONNECT(dlg, "delete_event", window_delete_event_cb, NULL);
+ SIGNAL_CONNECT(dlg, "destroy", dlg_destroy_cb, NULL);
+
+ gtk_widget_show_all(dlg);
+ window_present(dlg);
}
{
register_ethereal_tap("rpc,srt,", gtk_rpcstat_init);
- register_tap_menu_item("ONC-RPC/Service Response Time...", REGISTER_TAP_LAYER_APPLICATION,
+ register_tap_menu_item("ONC-RPC...", REGISTER_TAP_GROUP_RESPONSE_TIME,
gtk_rpcstat_cb, NULL, NULL, NULL);
}