aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-diameter.c
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-06-16 17:07:04 -0400
committerMichael Mann <mmann78@netscape.net>2015-06-21 03:35:13 +0000
commit6de6f7f0f8f8b79c4fc7473c7e54dad433c7b61b (patch)
tree20b4b81b49467f5685f51c6b75e240c41ca6cb32 /epan/dissectors/packet-diameter.c
parent2895d58dc38321a72c82e1bf77d165ef4acbc73a (diff)
Further refactor SRT stats.
Create "common" SRT tap data collection intended for all GUIs. Refactor/merge functionality of existing dissectors that have SRT support (AFP, DCERPC, Diameter, FC, GTP, LDAP, NCP, RPC, SCIS, SMB, and SMB2) for both TShark and GTK. SMB and DCERPC "tap packet filtering" were different between TShark and GTK, so I went with GTK filter logic. CAMEL "tap packet filtering" was different between TShark and GTK, so GTK filtering logic was pushed to the dissector and the TShark tap was left alone. Change-Id: I7d6eaad0673fe628ef337f9165d7ed94f4a5e1cc Reviewed-on: https://code.wireshark.org/review/8894 Petri-Dish: Michael Mann <mmann78@netscape.net> Reviewed-by: Gerald Combs <gerald@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-diameter.c')
-rw-r--r--epan/dissectors/packet-diameter.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/epan/dissectors/packet-diameter.c b/epan/dissectors/packet-diameter.c
index 8f2045170c..b4e3e4a4ae 100644
--- a/epan/dissectors/packet-diameter.c
+++ b/epan/dissectors/packet-diameter.c
@@ -48,6 +48,7 @@
#include <epan/sminmpec.h>
#include <epan/expert.h>
#include <epan/tap.h>
+#include <epan/srt_table.h>
#include <epan/exported_pdu.h>
#include <epan/diam_dict.h>
#include <epan/sctpppids.h>
@@ -365,6 +366,67 @@ compare_avps(const void *a, const void *b)
return 0;
}
+static GHashTable* diameterstat_cmd_str_hash = NULL;
+#define DIAMETER_NUM_PROCEDURES 1
+
+static void
+diameterstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data)
+{
+ srt_stat_table *diameter_srt_table;
+ int* idx;
+
+ /* XXX - This is a hack/workaround support so reseting/freeing parameters at the dissector
+ level doesn't need to be supported. */
+ if (diameterstat_cmd_str_hash != NULL)
+ {
+ g_hash_table_destroy(diameterstat_cmd_str_hash);
+ }
+
+ idx = (int *)g_malloc(sizeof(int));
+ *idx = 0;
+ diameterstat_cmd_str_hash = g_hash_table_new(g_str_hash,g_str_equal);
+ g_hash_table_insert(diameterstat_cmd_str_hash, (gchar *)"Unknown", idx);
+
+ /** @todo the filter to use in stead of NULL is "diameter.cmd.code"
+ * to enable the filter popup in the service response time dalouge
+ * Note to make it work the command code must be stored rather than the
+ * index.
+ */
+ diameter_srt_table = init_srt_table("Diameter Requests", NULL, srt_array, DIAMETER_NUM_PROCEDURES, NULL, NULL, gui_callback, gui_data, NULL);
+ init_srt_table_row(diameter_srt_table, 0, "Unknown");
+}
+
+static int
+diameterstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv)
+{
+ guint i = 0;
+ srt_stat_table *diameter_srt_table;
+ srt_data_t *data = (srt_data_t *)pss;
+ const diameter_req_ans_pair_t *diameter=(const diameter_req_ans_pair_t *)prv;
+ int* idx = NULL;
+
+ /* Process only answers where corresponding request is found.
+ * Unpaired daimeter messages are currently not supported by statistics.
+ * Return 0, since redraw is not needed. */
+ if(!diameter || diameter->processing_request || !diameter->req_frame)
+ return 0;
+
+ diameter_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
+
+ idx = (int*) g_hash_table_lookup(diameterstat_cmd_str_hash, diameter->cmd_str);
+ if (idx == NULL) {
+ idx = (int *)g_malloc(sizeof(int));
+ *idx = (int) g_hash_table_size(diameterstat_cmd_str_hash);
+ g_hash_table_insert(diameterstat_cmd_str_hash, (gchar*) diameter->cmd_str, idx);
+ init_srt_table_row(diameter_srt_table, *idx, (const char*) diameter->cmd_str);
+ }
+
+ add_srt_table_data(diameter_srt_table, *idx, &diameter->req_time, pinfo);
+
+ return 1;
+}
+
+
/* Special decoding of some AVPs */
static int
@@ -2200,6 +2262,8 @@ real_proto_register_diameter(void)
/* Register tap */
diameter_tap = register_tap("diameter");
+
+ register_srt_table(proto_diameter, NULL, 1, diameterstat_packet, diameterstat_init, NULL);
}
void