diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-08-04 17:42:53 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-08-06 01:59:10 +0000 |
commit | b7f5eaa5243ab8f0f2912e406a7d0cb94ff0c9fb (patch) | |
tree | db50f364dccf576a4e48f8e14dce339903c12519 /asn1/gsm_map | |
parent | 05eb9b69b8011a581ecd2ca92e4abfa1af7bde6f (diff) |
Convert the GSM MAP stats to new "generic stat API".
Convert both the MAP statistics and summary. As with the GSM A stats
this are mostly untested.
Change-Id: Ibd3a7346b09d1401e78724c0197ec2a38deb97a3
Reviewed-on: https://code.wireshark.org/review/9883
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'asn1/gsm_map')
-rw-r--r-- | asn1/gsm_map/packet-gsm_map-template.c | 160 | ||||
-rw-r--r-- | asn1/gsm_map/packet-gsm_map-template.h | 2 |
2 files changed, 159 insertions, 3 deletions
diff --git a/asn1/gsm_map/packet-gsm_map-template.c b/asn1/gsm_map/packet-gsm_map-template.c index 1bdeb7f9e3..54ba888c47 100644 --- a/asn1/gsm_map/packet-gsm_map-template.c +++ b/asn1/gsm_map/packet-gsm_map-template.c @@ -48,6 +48,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/stat_tap_ui.h> #include <epan/tap.h> #include <epan/oids.h> #include <epan/expert.h> @@ -2143,7 +2144,7 @@ dissect_gsm_map(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void if (op_idx != -1) { tap_rec.invoke = (gsmmap_pdu_type == 1) ? TRUE : FALSE; - tap_rec.opr_code_idx = op_idx; + tap_rec.opcode = opcode; tap_rec.size = gsm_map_pdu_size; tap_queue_packet(gsm_map_tap, pinfo, &tap_rec); @@ -2181,7 +2182,7 @@ dissect_gsm_map_sccp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, if (op_idx != -1) { tap_rec.invoke = (gsmmap_pdu_type == 1) ? TRUE : FALSE; - tap_rec.opr_code_idx = op_idx; + tap_rec.opcode = opcode; tap_rec.size = gsm_map_pdu_size; tap_queue_packet(gsm_map_tap, pinfo, &tap_rec); @@ -2456,6 +2457,141 @@ static const value_string chargingcharacteristics_values[] = { { 0, NULL } }; +/* TAP STAT INFO */ +typedef enum +{ + ID_COLUMN, + OP_CODE_COLUMN, + INVOKES_COLUMN, + NUM_BYTES_FWD_COLUMN, + AVG_BYTES_FWD_COLUMN, + RET_RES_COLUMN, + NUM_BYTES_REV_COLUMN, + AVG_BYTES_REV_COLUMN, + TOT_BYTES_COLUMN, + AVG_BYTES_COLUMN +} gsm_a_stat_columns; + +static stat_tap_table_item gsm_map_stat_fields[] = { + {TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "ID", "%d"}, + {TABLE_ITEM_STRING, TAP_ALIGN_LEFT, "Operation Code", "%-25s"}, + {TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Invokes", "%d"}, + {TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Num Bytes", "%d"}, + {TABLE_ITEM_FLOAT, TAP_ALIGN_RIGHT, "Avg Bytes", "%d"}, + {TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Return Result", "%d"}, + {TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Num Bytes", "%d"}, + {TABLE_ITEM_FLOAT, TAP_ALIGN_RIGHT, "Avg Bytes", "%d"}, + {TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Total Bytes", "%d"}, + {TABLE_ITEM_FLOAT, TAP_ALIGN_RIGHT, "Avg Bytes", "%d"}, +}; + +void gsm_map_stat_init(new_stat_tap_ui* new_stat, new_stat_tap_gui_init_cb gui_callback, void* gui_data) +{ + int num_fields = sizeof(gsm_map_stat_fields)/sizeof(stat_tap_table_item); + new_stat_tap_table* table; + guint i; + stat_tap_table_item_type items[sizeof(gsm_map_stat_fields)/sizeof(stat_tap_table_item)]; + + memset(items, 0, sizeof(items)); + + items[ID_COLUMN].type = TABLE_ITEM_UINT; + items[OP_CODE_COLUMN].type = TABLE_ITEM_STRING; + items[INVOKES_COLUMN].type = TABLE_ITEM_UINT; + items[NUM_BYTES_FWD_COLUMN].type = TABLE_ITEM_UINT; + items[AVG_BYTES_FWD_COLUMN].type = TABLE_ITEM_FLOAT; + items[RET_RES_COLUMN].type = TABLE_ITEM_UINT; + items[NUM_BYTES_REV_COLUMN].type = TABLE_ITEM_UINT; + items[AVG_BYTES_REV_COLUMN].type = TABLE_ITEM_FLOAT; + items[TOT_BYTES_COLUMN].type = TABLE_ITEM_UINT; + items[AVG_BYTES_COLUMN].type = TABLE_ITEM_FLOAT; + + table = new_stat_tap_init_table("GSM MAP Operation Statistics", num_fields, 0, NULL, gui_callback, gui_data); + new_stat_tap_add_table(new_stat, table); + + /* Add a row for each value type */ + for (i = 0; i < GSM_MAP_MAX_NUM_OPR_CODES; i++) + { + const char *ocs = try_val_to_str(i, gsm_map_opr_code_strings); + if (!ocs) ocs = g_strdup_printf("Unknown op code %d", i); + + items[ID_COLUMN].value.uint_value = i; + items[OP_CODE_COLUMN].value.string_value = ocs; + new_stat_tap_init_table_row(table, i, num_fields, items); + } +} + +static gboolean +gsm_map_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *gmtr_ptr) +{ + new_stat_data_t* stat_data = (new_stat_data_t*)tapdata; + const gsm_map_tap_rec_t *gmtr = (const gsm_map_tap_rec_t *)gmtr_ptr; + new_stat_tap_table* table; + stat_tap_table_item_type *invoke_data, *fwd_bytes_data, *result_data, *rev_bytes_data, *avg_data; + guint invokes, fwd_bytes, results, rev_bytes; + guint i = 0; + + table = g_array_index(stat_data->new_stat_tap_data->tables, new_stat_tap_table*, i); + + invoke_data = new_stat_tap_get_field_data(table, gmtr->opcode, INVOKES_COLUMN); + fwd_bytes_data = new_stat_tap_get_field_data(table, gmtr->opcode, NUM_BYTES_FWD_COLUMN); + result_data = new_stat_tap_get_field_data(table, gmtr->opcode, RET_RES_COLUMN); + rev_bytes_data = new_stat_tap_get_field_data(table, gmtr->opcode, NUM_BYTES_REV_COLUMN); + + if (gmtr->invoke) + { + invoke_data->value.uint_value++; + new_stat_tap_set_field_data(table, gmtr->opcode, INVOKES_COLUMN, invoke_data); + + fwd_bytes_data->value.uint_value += gmtr->size; + new_stat_tap_set_field_data(table, gmtr->opcode, NUM_BYTES_FWD_COLUMN, fwd_bytes_data); + } + else + { + result_data->value.uint_value++; + new_stat_tap_set_field_data(table, gmtr->opcode, RET_RES_COLUMN, result_data); + + rev_bytes_data->value.uint_value += gmtr->size; + new_stat_tap_set_field_data(table, gmtr->opcode, NUM_BYTES_REV_COLUMN, rev_bytes_data); + } + + invokes = invoke_data->value.uint_value; + fwd_bytes = fwd_bytes_data->value.uint_value; + results = result_data->value.uint_value; + rev_bytes = rev_bytes_data->value.uint_value; + + if (gmtr->invoke) + { + avg_data = new_stat_tap_get_field_data(table, gmtr->opcode, AVG_BYTES_FWD_COLUMN); + avg_data->value.float_value += (float) fwd_bytes / invokes; + new_stat_tap_set_field_data(table, gmtr->opcode, AVG_BYTES_FWD_COLUMN, avg_data); + } + else + { + avg_data = new_stat_tap_get_field_data(table, gmtr->opcode, AVG_BYTES_REV_COLUMN); + avg_data->value.float_value += (float) rev_bytes / results; + new_stat_tap_set_field_data(table, gmtr->opcode, AVG_BYTES_REV_COLUMN, avg_data); + } + + avg_data = new_stat_tap_get_field_data(table, gmtr->opcode, AVG_BYTES_COLUMN); + avg_data->value.float_value += (float) (fwd_bytes + rev_bytes) / (invokes + results); + new_stat_tap_set_field_data(table, gmtr->opcode, AVG_BYTES_COLUMN, avg_data); + return TRUE; +} + +static void +gsm_map_stat_reset(new_stat_tap_table* table) +{ + guint element; + stat_tap_table_item_type* item_data; + + for (element = 0; element < table->num_elements; element++) + { + item_data = new_stat_tap_get_field_data(table, element, INVOKES_COLUMN); + item_data->value.uint_value = 0; + new_stat_tap_set_field_data(table, element, INVOKES_COLUMN, item_data); + } +} + /*--- proto_reg_handoff_gsm_map ---------------------------------------*/ static void range_delete_callback(guint32 ssn) { @@ -2952,6 +3088,24 @@ void proto_register_gsm_map(void) { {NULL, NULL, -1} }; + static tap_param gsm_map_stat_params[] = { + { PARAM_FILTER, "filter", "Filter", NULL, TRUE } + }; + + static new_stat_tap_ui gsm_map_stat_table = { + REGISTER_STAT_GROUP_TELEPHONY_GSM, + "MAP Operation", + "gsm_map", + "gsm_map,operation", + gsm_map_stat_init, + gsm_map_stat_packet, + gsm_map_stat_reset, + NULL, + NULL, + sizeof(gsm_map_stat_fields)/sizeof(stat_tap_table_item), gsm_map_stat_fields, + sizeof(gsm_map_stat_params)/sizeof(tap_param), gsm_map_stat_params, + NULL + }; /* Register protocol */ proto_gsm_map_dialogue =proto_gsm_map = proto_register_protocol(PNAME, PSNAME, PFNAME); @@ -2996,4 +3150,6 @@ void proto_register_gsm_map(void) { "Dissect Ericsson proprietary extensions", "When enabled, dissector will use the non 3GPP standard extensions from Ericsson (that can override the standard ones)", &pref_ericsson_proprietary_ext); + + register_new_stat_tap_ui(&gsm_map_stat_table); } diff --git a/asn1/gsm_map/packet-gsm_map-template.h b/asn1/gsm_map/packet-gsm_map-template.h index 9f7ccd1324..3b1386ea69 100644 --- a/asn1/gsm_map/packet-gsm_map-template.h +++ b/asn1/gsm_map/packet-gsm_map-template.h @@ -31,7 +31,7 @@ typedef struct _gsm_map_tap_rec_t { gboolean invoke; - guint8 opr_code_idx; + guint32 opcode; guint16 size; } gsm_map_tap_rec_t; |