*
* $Id$
*
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@ethereal.com>
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* This program is free software; you can redistribute it and/or
#include "epan/packet_info.h"
#include "epan/epan.h"
#include "epan/value_string.h"
-#include "tap_menu.h"
+#include <epan/stat_cmd_args.h>
+#include "../stat_menu.h"
+#include "gui_stat_menu.h"
#include "image/clist_ascend.xpm"
#include "image/clist_descend.xpm"
#include "simple_dialog.h"
#include "dlg_utils.h"
-#include "ui_util.h"
+#include "gui_utils.h"
#include <epan/tap.h>
#include "../register.h"
#include "../globals.h"
typedef struct _my_columns_t {
guint32 value;
- gchar *strptr;
+ const gchar *strptr;
GtkJustification just;
} my_columns_t;
gsm_map_stat_reset(
void *tapdata)
{
- tapdata = tapdata;
+ gsm_map_stat_t *stat_p = tapdata;
- memset((void *) &gsm_map_stat, 0, sizeof(gsm_map_stat_t));
+ memset(stat_p, 0, sizeof(gsm_map_stat_t));
}
static int
gsm_map_stat_packet(
void *tapdata,
- packet_info *pinfo,
+ packet_info *pinfo _U_,
epan_dissect_t *edt _U_,
- void *data)
+ const void *data)
{
- gsm_map_tap_rec_t *data_p = data;
-
-
- tapdata = tapdata;
- pinfo = pinfo;
+ gsm_map_stat_t *stat_p = tapdata;
+ const gsm_map_tap_rec_t *data_p = data;
#if 0 /* always false because message_type is 8 bit value */
- if (data_p->opr_code_idx > sizeof(gsm_map_stat.opr_code))
+ if (data_p->opr_code_idx > sizeof(stat_p->opr_code))
{
/*
* unknown message type !!!
if (data_p->invoke)
{
- gsm_map_stat.opr_code[data_p->opr_code_idx]++;
- gsm_map_stat.size[data_p->opr_code_idx] += data_p->size;
+ stat_p->opr_code[data_p->opr_code_idx]++;
+ stat_p->size[data_p->opr_code_idx] += data_p->size;
}
else
{
- gsm_map_stat.opr_code_rr[data_p->opr_code_idx]++;
- gsm_map_stat.size_rr[data_p->opr_code_idx] += data_p->size;
+ stat_p->opr_code_rr[data_p->opr_code_idx]++;
+ stat_p->size_rr[data_p->opr_code_idx] += data_p->size;
}
return(1);
gsm_map_stat_draw(
void *tapdata)
{
+ gsm_map_stat_t *stat_p = tapdata;
int i, j;
char *strp;
-
- tapdata = tapdata;
-
- if (dlg.win != NULL)
+ if (dlg.win && tapdata)
{
i = 0;
{
j = gtk_clist_find_row_from_data(GTK_CLIST(dlg.table), (gpointer) i);
- strp = g_strdup_printf("%d", gsm_map_stat.opr_code[i]);
+ strp = g_strdup_printf("%d", stat_p->opr_code[i]);
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 2, strp);
g_free(strp);
- strp = g_strdup_printf("%.0f", gsm_map_stat.size[i]);
+ strp = g_strdup_printf("%.0f", stat_p->size[i]);
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 3, strp);
g_free(strp);
- strp = g_strdup_printf("%.2f", gsm_map_stat.size[i]/gsm_map_stat.opr_code[i]);
+ if (stat_p->opr_code[i] >0)
+ strp = g_strdup_printf("%.2f",stat_p->size[i]/stat_p->opr_code[i]);
+ else strp=g_strdup_printf("--");
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 4, strp);
g_free(strp);
- strp = g_strdup_printf("%u", gsm_map_stat.opr_code_rr[i]);
+ strp = g_strdup_printf("%u", stat_p->opr_code_rr[i]);
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 5, strp);
g_free(strp);
- strp = g_strdup_printf("%.0f", gsm_map_stat.size_rr[i]);
+ strp = g_strdup_printf("%.0f", stat_p->size_rr[i]);
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 6, strp);
g_free(strp);
- strp = g_strdup_printf("%.2f", gsm_map_stat.size_rr[i]/gsm_map_stat.opr_code_rr[i]);
+ if (stat_p->opr_code_rr[i]>0)
+ strp = g_strdup_printf("%.2f",stat_p->size_rr[i]/stat_p->opr_code_rr[i]);
+ else strp=g_strdup_printf("--");
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 7, strp);
g_free(strp);
- strp = g_strdup_printf("%.0f", gsm_map_stat.size[i] + gsm_map_stat.size_rr[i]);
+ strp = g_strdup_printf("%.0f", stat_p->size[i] + stat_p->size_rr[i]);
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 8, strp);
g_free(strp);
- strp = g_strdup_printf("%.2f",
- (gsm_map_stat.size[i] + gsm_map_stat.size_rr[i])/(gsm_map_stat.opr_code[i] + gsm_map_stat.opr_code_rr[i]));
+ if ((stat_p->opr_code[i] + stat_p->opr_code_rr[i])>0)
+ strp = g_strdup_printf("%.2f",
+ (stat_p->size[i] +stat_p->size_rr[i])/(stat_p->opr_code[i] + stat_p->opr_code_rr[i]));
+ else strp=g_strdup_printf("--");
gtk_clist_set_text(GTK_CLIST(dlg.table), j, 9, strp);
g_free(strp);
static void
gsm_map_stat_gtk_win_create(
gsm_map_stat_dlg_t *dlg_p,
- char *title)
+ const char *title)
{
int i;
column_arrows *col_arrows;
}
-/*
- * Never gets called ?
- */
-static void
-gsm_map_stat_gtk_init(
- char *optarg)
-{
- /* does not appear to be called */
-
- optarg = optarg;
-}
-
-
static void
gsm_map_stat_gtk_cb(
GtkWidget *w _U_,
gpointer d _U_)
{
- int i;
- char str[100];
+ int i,j;
/*
i = 0;
while (gsm_map_opr_code_strings[i].strptr)
{
- g_snprintf(str, 100, "%u", gsm_map_opr_code_strings[i].value);
- dlg.entries[0] = g_strdup(str);
+ dlg.entries[0] = g_strdup_printf("%u",
+ gsm_map_opr_code_strings[i].value);
dlg.entries[1] = g_strdup(gsm_map_opr_code_strings[i].strptr);
- dlg.entries[2] = g_strdup("0");
- dlg.entries[3] = g_strdup("0");
- dlg.entries[4] = g_strdup("0");
- dlg.entries[5] = g_strdup("0");
- dlg.entries[6] = g_strdup("0");
- dlg.entries[7] = g_strdup("0");
- dlg.entries[8] = g_strdup("0");
- dlg.entries[9] = g_strdup("0");
- dlg.entries[10] = g_strdup("0");
+ /*
+ * set the rest of the columns
+ */
+ for (j = 2; j < GSM_MAP_INIT_TABLE_NUM_COLUMNS; j++)
+ {
+ dlg.entries[j] = g_strdup("0");
+ }
gtk_clist_insert(GTK_CLIST(dlg.table), i, dlg.entries);
gtk_clist_set_row_data(GTK_CLIST(dlg.table), i, (gpointer) i);
i++;
}
- gsm_map_stat_draw(NULL);
+ gsm_map_stat_draw(&gsm_map_stat);
+}
+
+
+static void
+gsm_map_stat_gtk_init(const char *optarg _U_,
+ void* userdata _U_)
+{
+ gsm_map_stat_gtk_cb(NULL, NULL);
}
GString *err_p;
- register_ethereal_tap("gsm_map,", gsm_map_stat_gtk_init);
-
memset((void *) &gsm_map_stat, 0, sizeof(gsm_map_stat_t));
err_p =
- register_tap_listener("gsm_map", NULL, NULL,
+ register_tap_listener("gsm_map", &gsm_map_stat, NULL,
gsm_map_stat_reset,
gsm_map_stat_packet,
gsm_map_stat_draw);
exit(1);
}
- register_tap_menu_item("GSM/MAP Operation", REGISTER_TAP_GROUP_NONE,
+ register_stat_menu_item("GSM/MAP Operation", REGISTER_STAT_GROUP_TELEPHONY,
gsm_map_stat_gtk_cb, NULL, NULL, NULL);
+ register_stat_cmd_arg("gsm_map", gsm_map_stat_gtk_init,NULL);
}