summaryrefslogtreecommitdiff
path: root/ui/gtk/mtp3_summary.c
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-08-31 12:24:48 -0700
committerGerald Combs <gerald@wireshark.org>2015-08-31 23:06:09 +0000
commit377d215e0fd1022a093fa44b32f396948e70c119 (patch)
tree4a798c715645ec953e1ae447ddec555c3f509bbb /ui/gtk/mtp3_summary.c
parente9614ad7bad3078876c370a5e2f697fb61664322 (diff)
downloadwireshark-377d215e0fd1022a093fa44b32f396948e70c119.tar.gz
Convert the MTP3 stats to new "generic stat API".
Convert both the MTP3 statistics and summary. As with the GSM stats this is mostly untested. Change-Id: I7af8d5f21c8161dc95f7f2c710f32364b6f6a431 Reviewed-on: https://code.wireshark.org/review/10338 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/gtk/mtp3_summary.c')
-rw-r--r--ui/gtk/mtp3_summary.c125
1 files changed, 116 insertions, 9 deletions
diff --git a/ui/gtk/mtp3_summary.c b/ui/gtk/mtp3_summary.c
index 85b319f8ec..11c8bfeef1 100644
--- a/ui/gtk/mtp3_summary.c
+++ b/ui/gtk/mtp3_summary.c
@@ -27,26 +27,38 @@
#include "config.h"
-#include <string.h>
+#include <stdlib.h>
#include <gtk/gtk.h>
-#include "epan/packet_info.h"
-#include "epan/value_string.h"
+#include <epan/packet_info.h>
+#include <epan/stat_groups.h>
+#include <epan/tap.h>
+#include <epan/value_string.h>
+
#include <epan/dissectors/packet-mtp3.h>
-#include <epan/stat_groups.h>
-#include "../globals.h"
-#include "../summary.h"
+#include "globals.h"
+#include "summary.h"
+
+#include "ui/simple_dialog.h"
#include "ui/gtk/gui_stat_menu.h"
#include "ui/gtk/dlg_utils.h"
#include "ui/gtk/gui_utils.h"
-#include "ui/gtk/mtp3_stat.h"
#define SUM_STR_MAX 1024
-void register_tap_listener_gtkmtp3_summary(void);
+typedef struct _mtp3_stat_si_code_t {
+ int num_msus;
+ int size;
+} mtp3_stat_si_code_t;
+
+typedef struct _mtp3_stat_t {
+ mtp3_addr_pc_t addr_opc;
+ mtp3_addr_pc_t addr_dpc;
+ mtp3_stat_si_code_t mtp3_si_code[MTP3_NUM_SI_CODE];
+} mtp3_stat_t;
typedef struct _my_columns_t {
guint32 value;
@@ -65,6 +77,15 @@ enum
N_COLUMN /* The number of columns */
};
+/*
+ * I don't like it but I don't have time to create
+ * the code for a dynamic size solution
+ */
+#define MTP3_MAX_NUM_OPC_DPC 50
+
+static mtp3_stat_t mtp3_stat[MTP3_MAX_NUM_OPC_DPC];
+static guint8 mtp3_num_used;
+
/* Create list */
static GtkWidget *
create_list(void)
@@ -436,9 +457,95 @@ mtp3_sum_gtk_sum_cb(GtkAction *action _U_, gpointer user_data _U_)
}
+static void
+mtp3_summary_reset(
+ void *tapdata)
+{
+ mtp3_stat_t (*stat_p)[MTP3_MAX_NUM_OPC_DPC] = (mtp3_stat_t(*)[MTP3_MAX_NUM_OPC_DPC])tapdata;
+
+ mtp3_num_used = 0;
+ memset(stat_p, 0, MTP3_MAX_NUM_OPC_DPC * sizeof(mtp3_stat_t));
+}
+
+
+static gboolean
+mtp3_summary_packet(
+ void *tapdata,
+ packet_info *pinfo _U_,
+ epan_dissect_t *edt _U_,
+ const void *data)
+{
+ mtp3_stat_t (*stat_p)[MTP3_MAX_NUM_OPC_DPC] = (mtp3_stat_t(*)[MTP3_MAX_NUM_OPC_DPC])tapdata;
+ const mtp3_tap_rec_t *data_p = (const mtp3_tap_rec_t *)data;
+ int i;
+
+ if (data_p->mtp3_si_code >= MTP3_NUM_SI_CODE)
+ {
+ /*
+ * we thought this si_code was not used ?
+ * is MTP3_NUM_SI_CODE out of date ?
+ */
+ return(FALSE);
+ }
+
+ /*
+ * look for opc/dpc pair
+ */
+ i = 0;
+ while (i < mtp3_num_used)
+ {
+ if (memcmp(&data_p->addr_opc, &(*stat_p)[i].addr_opc, sizeof(mtp3_addr_pc_t)) == 0)
+ {
+ if (memcmp(&data_p->addr_dpc, &(*stat_p)[i].addr_dpc, sizeof(mtp3_addr_pc_t)) == 0)
+ {
+ break;
+ }
+ }
+
+ i++;
+ }
+
+ if (i == mtp3_num_used)
+ {
+ if (mtp3_num_used == MTP3_MAX_NUM_OPC_DPC)
+ {
+ /*
+ * too many
+ */
+ return(FALSE);
+ }
+
+ mtp3_num_used++;
+ }
+
+ (*stat_p)[i].addr_opc = data_p->addr_opc;
+ (*stat_p)[i].addr_dpc = data_p->addr_dpc;
+ (*stat_p)[i].mtp3_si_code[data_p->mtp3_si_code].num_msus++;
+ (*stat_p)[i].mtp3_si_code[data_p->mtp3_si_code].size += data_p->size;
+
+ return(TRUE);
+}
+
void
-register_tap_listener_gtkmtp3_summary(void)
+register_tap_listener_gtk_mtp3_summary(void)
{
+ GString *err_p;
+
+ memset((void *) &mtp3_stat, 0, sizeof(mtp3_stat));
+
+ err_p =
+ register_tap_listener("mtp3", &mtp3_stat, NULL, 0,
+ mtp3_summary_reset,
+ mtp3_summary_packet,
+ NULL);
+
+ if (err_p != NULL)
+ {
+ simple_dialog(ESD_TYPE_WARN, ESD_BTN_OK, "%s", err_p->str);
+ g_string_free(err_p, TRUE);
+
+ exit(1);
+ }
}
/*