2002-09-07 10:02:36 +00:00
|
|
|
/* rpc_stat.c
|
|
|
|
* rpc_stat 2002 Ronnie Sahlberg
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2002-09-07 10:02:36 +00:00
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2002-09-07 10:02:36 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
2010-07-13 14:12:06 +00:00
|
|
|
*
|
2002-09-07 10:02:36 +00:00
|
|
|
* 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.
|
2010-07-13 14:12:06 +00:00
|
|
|
*
|
2002-09-07 10:02:36 +00:00
|
|
|
* 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.
|
2010-07-13 14:12:06 +00:00
|
|
|
*
|
2002-09-07 10:02:36 +00:00
|
|
|
* 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.
|
2002-09-07 10:02:36 +00:00
|
|
|
*/
|
|
|
|
|
2010-07-13 14:12:06 +00:00
|
|
|
/* This module provides rpc call/reply SRT (Server Response Time) statistics
|
2006-05-22 07:29:40 +00:00
|
|
|
* to Wireshark.
|
2002-09-07 10:02:36 +00:00
|
|
|
*
|
|
|
|
* It serves as an example on how to use the tap api.
|
|
|
|
*/
|
|
|
|
|
2012-09-20 01:48:30 +00:00
|
|
|
#include "config.h"
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2009-08-27 04:47:28 +00:00
|
|
|
#include <stdio.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
#include <stdlib.h>
|
2009-08-27 04:47:28 +00:00
|
|
|
|
2002-09-07 10:02:36 +00:00
|
|
|
#include <gtk/gtk.h>
|
2003-12-13 22:23:18 +00:00
|
|
|
|
2004-02-13 00:53:37 +00:00
|
|
|
#include <epan/packet_info.h>
|
|
|
|
#include <epan/epan.h>
|
2005-08-20 20:06:05 +00:00
|
|
|
#include <epan/stat_cmd_args.h>
|
2004-09-29 00:06:36 +00:00
|
|
|
#include <epan/tap.h>
|
2004-07-18 18:06:47 +00:00
|
|
|
#include <epan/dissectors/packet-rpc.h>
|
2008-04-13 03:32:24 +00:00
|
|
|
|
|
|
|
#include "../stat_menu.h"
|
2012-01-16 01:07:52 +00:00
|
|
|
#include "ui/simple_dialog.h"
|
2008-04-13 03:32:24 +00:00
|
|
|
|
2012-01-15 21:59:11 +00:00
|
|
|
#include "ui/gtk/gui_stat_menu.h"
|
|
|
|
#include "ui/gtk/gui_utils.h"
|
|
|
|
#include "ui/gtk/dlg_utils.h"
|
|
|
|
#include "ui/gtk/main.h"
|
|
|
|
#include "ui/gtk/filter_dlg.h"
|
|
|
|
#include "ui/gtk/stock_icons.h"
|
|
|
|
#include "ui/gtk/service_response_time_table.h"
|
|
|
|
#include "ui/gtk/gtkglobals.h"
|
|
|
|
#include "ui/gtk/filter_autocomplete.h"
|
|
|
|
|
|
|
|
#include "ui/gtk/old-gtk-compat.h"
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
/* used to keep track of the statistics for an entire program interface */
|
|
|
|
typedef struct _rpcstat_t {
|
|
|
|
GtkWidget *win;
|
2003-06-21 03:24:06 +00:00
|
|
|
srt_stat_table srt_table;
|
2005-07-24 19:01:28 +00:00
|
|
|
const char *prog;
|
2002-09-07 10:02:36 +00:00
|
|
|
guint32 program;
|
|
|
|
guint32 version;
|
|
|
|
guint32 num_procedures;
|
|
|
|
} rpcstat_t;
|
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
static char *
|
|
|
|
rpcstat_gen_title(rpcstat_t *rs)
|
|
|
|
{
|
2012-06-03 22:03:05 +00:00
|
|
|
char *display_name;
|
2003-09-26 02:09:44 +00:00
|
|
|
char *title;
|
|
|
|
|
2012-06-03 22:03:05 +00:00
|
|
|
display_name = cf_get_display_name(&cfile);
|
2003-09-26 02:09:44 +00:00
|
|
|
title = g_strdup_printf("ONC-RPC Service Response Time statistics for %s version %d: %s",
|
2012-06-03 22:03:05 +00:00
|
|
|
rs->prog, rs->version, display_name);
|
|
|
|
g_free(display_name);
|
2003-09-26 02:09:44 +00:00
|
|
|
return title;
|
|
|
|
}
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
static void
|
|
|
|
rpcstat_set_title(rpcstat_t *rs)
|
|
|
|
{
|
|
|
|
char *title;
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
title = rpcstat_gen_title(rs);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(rs->win), title);
|
|
|
|
g_free(title);
|
|
|
|
}
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
static void
|
2005-01-01 12:49:54 +00:00
|
|
|
rpcstat_reset(void *arg)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
2013-03-21 02:58:59 +00:00
|
|
|
rpcstat_t *rs = (rpcstat_t *)arg;
|
2005-01-01 12:49:54 +00:00
|
|
|
|
2003-06-21 03:24:06 +00:00
|
|
|
reset_srt_table_data(&rs->srt_table);
|
2003-09-26 02:09:44 +00:00
|
|
|
rpcstat_set_title(rs);
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-07-13 14:12:06 +00:00
|
|
|
static gboolean
|
2005-01-01 12:49:54 +00:00
|
|
|
rpcstat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
2013-03-21 02:58:59 +00:00
|
|
|
rpcstat_t *rs = (rpcstat_t *)arg;
|
|
|
|
const rpc_call_info_value *ri = (rpc_call_info_value *)arg2;
|
2005-01-01 12:49:54 +00:00
|
|
|
|
2002-09-07 10:02:36 +00:00
|
|
|
/* we are only interested in reply packets */
|
|
|
|
if(ri->request){
|
2010-07-13 14:12:06 +00:00
|
|
|
return FALSE;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
/* we are only interested in certain program/versions */
|
|
|
|
if( (ri->prog!=rs->program) || (ri->vers!=rs->version) ){
|
2010-07-13 14:12:06 +00:00
|
|
|
return FALSE;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
2010-07-13 14:12:06 +00:00
|
|
|
/* maybe we have discovered a new procedure?
|
|
|
|
* then we might need to extend our tables
|
2004-04-07 04:31:32 +00:00
|
|
|
*/
|
|
|
|
if(ri->proc>=rs->num_procedures){
|
|
|
|
guint32 i;
|
|
|
|
if(ri->proc>256){
|
2010-07-13 14:12:06 +00:00
|
|
|
/* no program have probably ever more than this many
|
|
|
|
* procedures anyway and it prevents us from allocating
|
|
|
|
* infinite memory if passed a garbage procedure id
|
2004-04-07 04:31:32 +00:00
|
|
|
*/
|
2010-07-13 14:12:06 +00:00
|
|
|
return FALSE;
|
2004-04-07 04:31:32 +00:00
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
2003-06-21 03:24:06 +00:00
|
|
|
add_srt_table_data(&rs->srt_table, ri->proc, &ri->req_time, pinfo);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2010-07-13 14:12:06 +00:00
|
|
|
return TRUE;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-01-01 12:49:54 +00:00
|
|
|
rpcstat_draw(void *arg)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
2013-03-21 02:58:59 +00:00
|
|
|
rpcstat_t *rs = (rpcstat_t *)arg;
|
2005-01-01 12:49:54 +00:00
|
|
|
|
2003-06-21 03:24:06 +00:00
|
|
|
draw_srt_table_data(&rs->srt_table);
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static guint32 rpc_program=0;
|
|
|
|
static guint32 rpc_version=0;
|
|
|
|
static gint32 rpc_min_vers=-1;
|
|
|
|
static gint32 rpc_max_vers=-1;
|
|
|
|
static gint32 rpc_min_proc=-1;
|
|
|
|
static gint32 rpc_max_proc=-1;
|
|
|
|
|
2010-07-13 14:12:06 +00:00
|
|
|
static void
|
2002-09-07 10:02:36 +00:00
|
|
|
rpcstat_find_procs(gpointer *key, gpointer *value _U_, gpointer *user_data _U_)
|
|
|
|
{
|
|
|
|
rpc_proc_info_key *k=(rpc_proc_info_key *)key;
|
|
|
|
|
|
|
|
if(k->prog!=rpc_program){
|
2010-07-13 14:12:06 +00:00
|
|
|
return;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
if(k->vers!=rpc_version){
|
2010-07-13 14:12:06 +00:00
|
|
|
return;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
if(rpc_min_proc==-1){
|
|
|
|
rpc_min_proc=k->proc;
|
|
|
|
rpc_max_proc=k->proc;
|
|
|
|
}
|
|
|
|
if((gint32)k->proc<rpc_min_proc){
|
|
|
|
rpc_min_proc=k->proc;
|
|
|
|
}
|
|
|
|
if((gint32)k->proc>rpc_max_proc){
|
|
|
|
rpc_max_proc=k->proc;
|
|
|
|
}
|
|
|
|
|
2010-07-13 14:12:06 +00:00
|
|
|
return;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
static void
|
2002-09-07 10:02:36 +00:00
|
|
|
rpcstat_find_vers(gpointer *key, gpointer *value _U_, gpointer *user_data _U_)
|
|
|
|
{
|
|
|
|
rpc_proc_info_key *k=(rpc_proc_info_key *)key;
|
|
|
|
|
|
|
|
if(k->prog!=rpc_program){
|
2010-02-24 01:22:07 +00:00
|
|
|
return;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
if(rpc_min_vers==-1){
|
|
|
|
rpc_min_vers=k->vers;
|
|
|
|
rpc_max_vers=k->vers;
|
|
|
|
}
|
|
|
|
if((gint32)k->vers<rpc_min_vers){
|
|
|
|
rpc_min_vers=k->vers;
|
|
|
|
}
|
|
|
|
if((gint32)k->vers>rpc_max_vers){
|
|
|
|
rpc_max_vers=k->vers;
|
|
|
|
}
|
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
return;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
win_destroy_cb(GtkWindow *win _U_, gpointer data)
|
|
|
|
{
|
|
|
|
rpcstat_t *rs=(rpcstat_t *)data;
|
|
|
|
|
|
|
|
remove_tap_listener(rs);
|
|
|
|
|
2003-06-21 03:24:06 +00:00
|
|
|
free_srt_table_data(&rs->srt_table);
|
2002-09-07 10:02:36 +00:00
|
|
|
g_free(rs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When called, this function will create a new instance of gtk2-rpcstat.
|
|
|
|
*/
|
2002-11-06 10:53:36 +00:00
|
|
|
static void
|
2012-12-06 20:59:53 +00:00
|
|
|
gtk_rpcstat_init(const char *opt_arg, void* userdata _U_)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
|
|
|
rpcstat_t *rs;
|
|
|
|
guint32 i;
|
2003-09-26 02:09:44 +00:00
|
|
|
char *title_string;
|
2007-11-28 03:04:09 +00:00
|
|
|
char *filter_string;
|
2002-09-07 10:02:36 +00:00
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *stat_label;
|
2002-09-27 11:07:16 +00:00
|
|
|
GtkWidget *filter_label;
|
2005-07-24 19:01:28 +00:00
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *close_bt;
|
2002-11-06 10:53:36 +00:00
|
|
|
int program, version, pos;
|
2005-08-06 03:44:55 +00:00
|
|
|
const char *filter=NULL;
|
2003-04-23 08:20:06 +00:00
|
|
|
GString *error_string;
|
2003-09-05 10:26:44 +00:00
|
|
|
int hf_index;
|
|
|
|
header_field_info *hfi;
|
2002-11-06 10:53:36 +00:00
|
|
|
|
|
|
|
pos=0;
|
2012-12-06 20:59:53 +00:00
|
|
|
if(sscanf(opt_arg,"rpc,srt,%d,%d,%n",&program,&version,&pos)==2){
|
2002-11-06 10:53:36 +00:00
|
|
|
if(pos){
|
2012-12-06 20:59:53 +00:00
|
|
|
filter=opt_arg+pos;
|
2002-11-06 10:53:36 +00:00
|
|
|
} else {
|
|
|
|
filter=NULL;
|
|
|
|
}
|
|
|
|
} else {
|
2006-05-28 17:19:08 +00:00
|
|
|
fprintf(stderr, "wireshark: invalid \"-z rpc,srt,<program>,<version>[,<filter>]\" argument\n");
|
2002-11-06 10:53:36 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
rpc_program=program;
|
|
|
|
rpc_version=version;
|
2013-03-21 02:58:59 +00:00
|
|
|
rs=(rpcstat_t *)g_malloc(sizeof(rpcstat_t));
|
2002-09-07 10:02:36 +00:00
|
|
|
rs->prog=rpc_prog_name(rpc_program);
|
|
|
|
rs->program=rpc_program;
|
|
|
|
rs->version=rpc_version;
|
2003-09-05 10:26:44 +00:00
|
|
|
hf_index=rpc_prog_hf(rpc_program, rpc_version);
|
|
|
|
hfi=proto_registrar_get_nth(hf_index);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2009-06-22 15:22:37 +00:00
|
|
|
rs->win = dlg_window_new("rpc-stat"); /* transient_for top_level */
|
|
|
|
gtk_window_set_destroy_with_parent (GTK_WINDOW(rs->win), TRUE);
|
2003-06-21 09:50:19 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(rs->win), 550, 400);
|
2003-09-26 02:09:44 +00:00
|
|
|
rpcstat_set_title(rs);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2012-04-21 16:40:14 +00:00
|
|
|
vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE);
|
2002-09-07 10:02:36 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(rs->win), vbox);
|
2004-04-12 08:53:02 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
|
2010-07-13 14:12:06 +00:00
|
|
|
|
2005-01-01 12:49:54 +00:00
|
|
|
title_string = rpcstat_gen_title(rs);
|
2002-09-07 10:02:36 +00:00
|
|
|
stat_label=gtk_label_new(title_string);
|
2003-09-26 02:09:44 +00:00
|
|
|
g_free(title_string);
|
2002-09-07 10:02:36 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0);
|
|
|
|
|
2007-11-28 03:04:09 +00:00
|
|
|
filter_string = g_strdup_printf("Filter: %s", filter ? filter : "");
|
2002-09-27 11:07:16 +00:00
|
|
|
filter_label=gtk_label_new(filter_string);
|
2007-11-28 03:04:09 +00:00
|
|
|
g_free(filter_string);
|
|
|
|
gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE);
|
2002-09-27 11:07:16 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0);
|
|
|
|
|
2002-09-07 10:02:36 +00:00
|
|
|
rpc_min_proc=-1;
|
|
|
|
rpc_max_proc=-1;
|
|
|
|
g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL);
|
|
|
|
rs->num_procedures=rpc_max_proc+1;
|
|
|
|
|
2003-06-22 04:00:21 +00:00
|
|
|
/* We must display TOP LEVEL Widget before calling init_srt_table() */
|
2004-04-12 08:53:02 +00:00
|
|
|
gtk_widget_show_all(rs->win);
|
2003-06-22 04:00:21 +00:00
|
|
|
|
2003-09-05 10:26:44 +00:00
|
|
|
init_srt_table(&rs->srt_table, rpc_max_proc+1, vbox, hfi->abbrev);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
for(i=0;i<rs->num_procedures;i++){
|
2003-06-21 03:24:06 +00:00
|
|
|
init_srt_table_row(&rs->srt_table, i, rpc_proc_name(rpc_program, rpc_version, i));
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-05 22:42:47 +00:00
|
|
|
error_string=register_tap_listener("rpc", rs, filter, 0, rpcstat_reset, rpcstat_packet, rpcstat_draw);
|
2003-04-23 08:20:06 +00:00
|
|
|
if(error_string){
|
2008-10-31 10:33:20 +00:00
|
|
|
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str);
|
2003-04-23 08:20:06 +00:00
|
|
|
g_string_free(error_string, TRUE);
|
2003-06-21 03:24:06 +00:00
|
|
|
free_srt_table_data(&rs->srt_table);
|
2002-09-07 10:02:36 +00:00
|
|
|
g_free(rs);
|
2002-09-27 11:07:16 +00:00
|
|
|
return;
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
2004-04-12 08:53:02 +00:00
|
|
|
/* 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:58:59 +00:00
|
|
|
close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE);
|
2005-01-01 12:49:54 +00:00
|
|
|
window_set_cancel_button(rs->win, close_bt, window_cancel_button_cb);
|
2004-05-23 23:24:07 +00:00
|
|
|
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(rs->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
|
|
|
g_signal_connect(rs->win, "destroy", G_CALLBACK(win_destroy_cb), rs);
|
2004-04-12 08:53:02 +00:00
|
|
|
|
2005-01-01 12:49:54 +00:00
|
|
|
gtk_widget_show_all(rs->win);
|
|
|
|
window_present(rs->win);
|
2002-09-07 10:02:36 +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(rs->win));
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
static GtkWidget *dlg=NULL;
|
|
|
|
static GtkWidget *filter_entry;
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2002-09-27 11:07:16 +00:00
|
|
|
static void
|
|
|
|
rpcstat_start_button_clicked(GtkWidget *item _U_, gpointer data _U_)
|
|
|
|
{
|
2003-09-26 02:09:44 +00:00
|
|
|
GString *str;
|
"gtk_entry_get_text()" returns a "const char *" - assign the result to
one.
"get_basename()" doesn't modify its argument, and its callers don't
modify the substring pointed to by the result, so make it take a "const
char *" as an argument and return a "const char *".
"find_last_pathname_separator()" doesn't modify its argument, so make it
a "const char *" - but some of its callers pass a non-"const" "char *"
and modify the result, so don't make its return value a "const char *".
And, as none of its callers are outside "filesystem.c", make it static.
In "about_folders_page_new()", have separate variables for pathnames
returned as "const char *" (which are cached by the routine that returns
them, so you can't modify them - and can't free them, so get rid of the
commented-out "g_free()" calls for them) and pathnames returned as "char
*" (which are allocated anew for each call, and can be modified, but
have to be freed).
Clean up white space.
svn path=/trunk/; revision=12881
2004-12-31 00:26:36 +00:00
|
|
|
const char *filter;
|
2002-09-27 11:07:16 +00:00
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
str = g_string_new("rpc,srt");
|
2008-05-06 05:50:31 +00:00
|
|
|
g_string_append_printf(str, ",%d,%d", rpc_program, rpc_version);
|
"gtk_entry_get_text()" returns a "const char *" - assign the result to
one.
"get_basename()" doesn't modify its argument, and its callers don't
modify the substring pointed to by the result, so make it take a "const
char *" as an argument and return a "const char *".
"find_last_pathname_separator()" doesn't modify its argument, so make it
a "const char *" - but some of its callers pass a non-"const" "char *"
and modify the result, so don't make its return value a "const char *".
And, as none of its callers are outside "filesystem.c", make it static.
In "about_folders_page_new()", have separate variables for pathnames
returned as "const char *" (which are cached by the routine that returns
them, so you can't modify them - and can't free them, so get rid of the
commented-out "g_free()" calls for them) and pathnames returned as "char
*" (which are allocated anew for each call, and can be modified, but
have to be freed).
Clean up white space.
svn path=/trunk/; revision=12881
2004-12-31 00:26:36 +00:00
|
|
|
filter=gtk_entry_get_text(GTK_ENTRY(filter_entry));
|
2003-09-26 02:09:44 +00:00
|
|
|
if(filter[0]!=0){
|
2008-05-06 05:50:31 +00:00
|
|
|
g_string_append_printf(str, ",%s", filter);
|
2002-09-27 11:07:16 +00:00
|
|
|
}
|
2003-09-26 02:09:44 +00:00
|
|
|
|
2006-02-11 13:05:24 +00:00
|
|
|
gtk_rpcstat_init(str->str,NULL);
|
2003-09-26 02:09:44 +00:00
|
|
|
g_string_free(str, TRUE);
|
2002-09-27 11:07:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-07 10:02:36 +00:00
|
|
|
static void
|
2010-02-24 01:22:07 +00:00
|
|
|
rpcstat_version_select(GtkWidget *vers_combo_box, gpointer user_data _U_)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
2010-02-24 01:22:07 +00:00
|
|
|
gpointer ptr;
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
if (! ws_combo_box_get_active_pointer(GTK_COMBO_BOX(vers_combo_box), &ptr)) {
|
|
|
|
g_assert_not_reached(); /* Programming error: somehow no active item */
|
|
|
|
}
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
rpc_version=GPOINTER_TO_INT(ptr);
|
|
|
|
}
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
2010-02-24 01:22:07 +00:00
|
|
|
rpcstat_program_select(GtkWidget *prog_combo_box, gpointer user_data)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
2010-02-24 01:22:07 +00:00
|
|
|
rpc_prog_info_key *k;
|
|
|
|
GtkWidget *vers_combo_box;
|
2002-09-07 10:02:36 +00:00
|
|
|
int i;
|
|
|
|
|
2013-03-21 02:58:59 +00:00
|
|
|
vers_combo_box = (GtkWidget *)user_data;
|
2010-02-24 01:22:07 +00:00
|
|
|
|
2013-03-21 02:58:59 +00:00
|
|
|
if (! ws_combo_box_get_active_pointer(GTK_COMBO_BOX(prog_combo_box), (gpointer *)&k)) {
|
2010-02-24 01:22:07 +00:00
|
|
|
g_assert_not_reached(); /* Programming error: somehow no active item */
|
|
|
|
}
|
2002-09-07 10:02:36 +00:00
|
|
|
rpc_program=k->prog;
|
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
/* re-create version menu */
|
2002-09-07 10:02:36 +00:00
|
|
|
rpc_version=0;
|
2010-02-24 01:22:07 +00:00
|
|
|
g_signal_handlers_disconnect_by_func(vers_combo_box, G_CALLBACK(rpcstat_version_select), NULL );
|
|
|
|
ws_combo_box_clear_text_and_pointer(GTK_COMBO_BOX(vers_combo_box));
|
2002-09-07 10:02:36 +00:00
|
|
|
rpc_min_vers=-1;
|
|
|
|
rpc_max_vers=-1;
|
|
|
|
g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_vers, NULL);
|
|
|
|
for(i=rpc_min_vers;i<=rpc_max_vers;i++){
|
|
|
|
char vs[5];
|
2009-03-19 17:49:11 +00:00
|
|
|
g_snprintf(vs, sizeof(vs), "%d",i);
|
2010-07-13 14:12:06 +00:00
|
|
|
ws_combo_box_append_text_and_pointer(GTK_COMBO_BOX(vers_combo_box),
|
2010-02-24 01:22:07 +00:00
|
|
|
vs, GINT_TO_POINTER(i));
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
2010-02-24 01:22:07 +00:00
|
|
|
g_signal_connect(vers_combo_box, "changed", G_CALLBACK(rpcstat_version_select), NULL);
|
|
|
|
ws_combo_box_set_active(GTK_COMBO_BOX(vers_combo_box), 0); /* default: will trigger rpcstat_version_select callback */
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
rpcstat_list_programs(gpointer *key, gpointer *value, gpointer user_data)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
|
|
|
rpc_prog_info_key *k=(rpc_prog_info_key *)key;
|
|
|
|
rpc_prog_info_value *v=(rpc_prog_info_value *)value;
|
2013-03-21 02:58:59 +00:00
|
|
|
GtkComboBox *prog_combo_box = (GtkComboBox *)user_data;
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
ws_combo_box_append_text_and_pointer(prog_combo_box, v->progname, k);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
if(!rpc_program){
|
|
|
|
rpc_program=k->prog;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2010-08-23 15:58:48 +00:00
|
|
|
dlg_destroy_cb(GtkWidget *w _U_, gpointer user_data _U_)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
|
|
|
dlg=NULL;
|
|
|
|
}
|
|
|
|
|
2011-09-25 21:19:45 +00:00
|
|
|
void
|
2011-06-19 09:26:13 +00:00
|
|
|
gtk_rpcstat_cb(GtkAction *action _U_, gpointer user_data _U_)
|
2002-09-07 10:02:36 +00:00
|
|
|
{
|
2003-09-26 02:09:44 +00:00
|
|
|
GtkWidget *dlg_box;
|
2010-02-24 01:22:07 +00:00
|
|
|
GtkWidget *prog_box, *prog_label;
|
2003-09-26 02:09:44 +00:00
|
|
|
GtkWidget *vers_label;
|
2010-02-24 01:22:07 +00:00
|
|
|
GtkWidget *prog_combo_box, *vers_combo_box;
|
2003-10-27 01:20:16 +00:00
|
|
|
GtkWidget *filter_box, *filter_bt;
|
2003-09-26 02:09:44 +00:00
|
|
|
GtkWidget *bbox, *start_button, *cancel_button;
|
2003-12-04 00:45:39 +00:00
|
|
|
const char *filter;
|
2003-10-27 01:20:16 +00:00
|
|
|
static construct_args_t args = {
|
|
|
|
"Service Response Time Statistics Filter",
|
|
|
|
TRUE,
|
2005-12-31 17:09:27 +00:00
|
|
|
FALSE,
|
2010-02-24 01:22:07 +00:00
|
|
|
FALSE
|
2003-10-27 01:20:16 +00:00
|
|
|
};
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
/* if the window is already open, bring it to front */
|
|
|
|
if(dlg){
|
2011-07-21 20:12:08 +00:00
|
|
|
gdk_window_raise(gtk_widget_get_window(dlg));
|
2002-09-07 10:02:36 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-05-22 07:29:40 +00:00
|
|
|
dlg=dlg_window_new("Wireshark: Compute ONC-RPC SRT statistics");
|
2004-05-27 19:59:50 +00:00
|
|
|
gtk_window_set_default_size(GTK_WINDOW(dlg), 300, -1);
|
2003-09-26 02:09:44 +00:00
|
|
|
|
2012-04-21 16:40:14 +00:00
|
|
|
dlg_box=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 10, FALSE);
|
2008-06-29 15:51:43 +00:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(dlg_box), 10);
|
2002-09-07 10:02:36 +00:00
|
|
|
gtk_container_add(GTK_CONTAINER(dlg), dlg_box);
|
|
|
|
gtk_widget_show(dlg_box);
|
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
/* Program box */
|
2012-04-21 16:40:14 +00:00
|
|
|
prog_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10, FALSE);
|
2003-09-26 02:09:44 +00:00
|
|
|
|
2002-09-07 10:02:36 +00:00
|
|
|
/* Program label */
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(prog_box), 10);
|
|
|
|
prog_label=gtk_label_new("Program:");
|
|
|
|
gtk_box_pack_start(GTK_BOX(prog_box), prog_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(prog_label);
|
|
|
|
|
|
|
|
/* Program menu */
|
2010-02-24 01:22:07 +00:00
|
|
|
prog_combo_box=ws_combo_box_new_text_and_pointer();
|
|
|
|
g_hash_table_foreach(rpc_progs, (GHFunc)rpcstat_list_programs, prog_combo_box);
|
|
|
|
gtk_box_pack_start(GTK_BOX(prog_box), prog_combo_box, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(prog_combo_box);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
/* Version label */
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(prog_box), 10);
|
|
|
|
vers_label=gtk_label_new("Version:");
|
|
|
|
gtk_box_pack_start(GTK_BOX(prog_box), vers_label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(vers_label);
|
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
/* Note: version combo box rows set when rpcstat_program_select callback invoked below */
|
|
|
|
vers_combo_box=ws_combo_box_new_text_and_pointer();
|
|
|
|
gtk_box_pack_start(GTK_BOX(prog_box), vers_combo_box, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(vers_combo_box);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
|
|
|
gtk_box_pack_start(GTK_BOX(dlg_box), prog_box, TRUE, TRUE, 0);
|
2010-02-24 01:22:07 +00:00
|
|
|
|
|
|
|
g_signal_connect(prog_combo_box, "changed", G_CALLBACK(rpcstat_program_select), vers_combo_box);
|
|
|
|
ws_combo_box_set_active(GTK_COMBO_BOX(prog_combo_box), 0); /* invokes rpcstat_program_select callback */
|
|
|
|
|
2002-09-07 10:02:36 +00:00
|
|
|
gtk_widget_show(prog_box);
|
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
/* Filter box */
|
2012-04-21 16:40:14 +00:00
|
|
|
filter_box=ws_gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 3, FALSE);
|
2002-09-07 10:02:36 +00:00
|
|
|
|
2002-09-27 11:07:16 +00:00
|
|
|
/* Filter label */
|
2008-04-11 18:58:19 +00:00
|
|
|
filter_bt=gtk_button_new_from_stock(WIRESHARK_STOCK_DISPLAY_FILTER_ENTRY);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(filter_bt, "clicked", G_CALLBACK(display_filter_construct_cb), &args);
|
2003-10-27 01:20:16 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(filter_box), filter_bt, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show(filter_bt);
|
2002-09-27 11:07:16 +00:00
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
/* Filter entry */
|
|
|
|
filter_entry=gtk_entry_new();
|
2010-02-24 01:22:07 +00:00
|
|
|
g_signal_connect(filter_entry, "changed", G_CALLBACK(filter_te_syntax_check_cb), NULL);
|
2008-10-19 13:40:52 +00:00
|
|
|
g_object_set_data(G_OBJECT(filter_box), E_FILT_AUTOCOMP_PTR_KEY, NULL);
|
|
|
|
g_signal_connect(filter_entry, "key-press-event", G_CALLBACK (filter_string_te_key_pressed_cb), NULL);
|
|
|
|
g_signal_connect(dlg, "key-press-event", G_CALLBACK (filter_parent_dlg_key_pressed_cb), NULL);
|
2003-10-27 01:20:16 +00:00
|
|
|
|
|
|
|
/* filter prefs dialog */
|
2010-02-24 01:22:07 +00:00
|
|
|
g_object_set_data(G_OBJECT(filter_bt), E_FILT_TE_PTR_KEY, filter_entry);
|
2003-10-27 01:20:16 +00:00
|
|
|
/* filter prefs dialog */
|
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(filter_box), filter_entry, TRUE, TRUE, 0);
|
2003-08-19 10:09:20 +00:00
|
|
|
filter=gtk_entry_get_text(GTK_ENTRY(main_display_filter_widget));
|
|
|
|
if(filter){
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(filter_entry), filter);
|
2008-10-11 14:32:46 +00:00
|
|
|
} else {
|
|
|
|
colorize_filter_te_as_empty(filter_entry);
|
2003-08-19 10:09:20 +00:00
|
|
|
}
|
2002-09-27 11:07:16 +00:00
|
|
|
gtk_widget_show(filter_entry);
|
2003-06-22 04:00:21 +00:00
|
|
|
|
2002-09-27 11:07:16 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(dlg_box), filter_box, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_show(filter_box);
|
|
|
|
|
2003-09-26 02:09:44 +00:00
|
|
|
/* button box */
|
2010-02-24 01:22:07 +00:00
|
|
|
bbox = dlg_button_row_new(WIRESHARK_STOCK_CREATE_STAT, GTK_STOCK_CANCEL, NULL);
|
2003-09-26 02:09:44 +00:00
|
|
|
gtk_box_pack_start(GTK_BOX(dlg_box), bbox, FALSE, FALSE, 0);
|
2010-02-24 01:22:07 +00:00
|
|
|
gtk_widget_show(bbox);
|
2002-09-27 11:07:16 +00:00
|
|
|
|
2013-03-21 02:58:59 +00:00
|
|
|
start_button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), WIRESHARK_STOCK_CREATE_STAT);
|
2010-02-24 01:22:07 +00:00
|
|
|
g_signal_connect_swapped(start_button, "clicked",
|
|
|
|
G_CALLBACK(rpcstat_start_button_clicked), NULL);
|
2004-01-21 21:19:34 +00:00
|
|
|
|
2013-03-21 02:58:59 +00:00
|
|
|
cancel_button = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CANCEL);
|
2010-02-24 01:22:07 +00:00
|
|
|
window_set_cancel_button(dlg, cancel_button, window_cancel_button_cb);
|
2003-09-26 02:09:44 +00:00
|
|
|
|
|
|
|
/* Give the initial focus to the "Filter" entry box. */
|
|
|
|
gtk_widget_grab_focus(filter_entry);
|
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
gtk_widget_grab_default(start_button );
|
2004-05-23 23:24:07 +00:00
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
g_signal_connect(dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
|
2008-04-11 23:16:06 +00:00
|
|
|
g_signal_connect(dlg, "destroy", G_CALLBACK(dlg_destroy_cb), NULL);
|
2004-05-23 23:24:07 +00:00
|
|
|
|
2010-02-24 01:22:07 +00:00
|
|
|
gtk_widget_show_all(dlg);
|
|
|
|
window_present(dlg);
|
2002-09-07 10:02:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-11-06 10:53:36 +00:00
|
|
|
void
|
|
|
|
register_tap_listener_gtkrpcstat(void)
|
|
|
|
{
|
2006-02-11 13:05:24 +00:00
|
|
|
register_stat_cmd_arg("rpc,srt,", gtk_rpcstat_init, NULL);
|
2003-04-23 05:37:23 +00:00
|
|
|
}
|
2011-09-25 21:19:45 +00:00
|
|
|
|