diff options
author | Gerald Combs <gerald@wireshark.org> | 2015-08-04 08:56:28 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2015-08-04 19:12:00 +0000 |
commit | 4d673b24cd6bb7a8b8c1150b65f1f94d464af91b (patch) | |
tree | 17767a71d3d2ae889f96171ebd3372972524e30d /epan/dissectors/packet-camel.c | |
parent | 3e6b52711468ff61d662f15083ab44e2d0b6c4e7 (diff) |
Convert Camel tap stats to new "generic stat API".
Migrate the Camel stats similar to the recent BOOTP and H.225
migrations.
Change-Id: If82617068ff4b8fa186899f66dc34a08585f66cb
Reviewed-on: https://code.wireshark.org/review/9865
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'epan/dissectors/packet-camel.c')
-rw-r--r-- | epan/dissectors/packet-camel.c | 137 |
1 files changed, 115 insertions, 22 deletions
diff --git a/epan/dissectors/packet-camel.c b/epan/dissectors/packet-camel.c index 634bbc90f6..1f3000429e 100644 --- a/epan/dissectors/packet-camel.c +++ b/epan/dissectors/packet-camel.c @@ -48,6 +48,7 @@ #include <epan/oids.h> #include <epan/tap.h> #include <epan/srt_table.h> +#include <epan/stat_tap_ui.h> #include <epan/asn1.h> #include <epan/expert.h> @@ -606,7 +607,7 @@ static int hf_camel_present = -1; /* INTEGER */ static int hf_camel_InvokeId_present = -1; /* InvokeId_present */ /*--- End of included file: packet-camel-hf.c ---*/ -#line 113 "../../asn1/camel/packet-camel-template.c" +#line 114 "../../asn1/camel/packet-camel-template.c" static struct camelsrt_info_t * gp_camelsrt_info; @@ -836,7 +837,7 @@ static gint ett_camel_T_problem = -1; static gint ett_camel_InvokeId = -1; /*--- End of included file: packet-camel-ett.c ---*/ -#line 144 "../../asn1/camel/packet-camel-template.c" +#line 145 "../../asn1/camel/packet-camel-template.c" static expert_field ei_camel_unknown_invokeData = EI_INIT; static expert_field ei_camel_unknown_returnResultData = EI_INIT; @@ -1181,7 +1182,7 @@ static const value_string camel_ectTreatmentIndicator_values[] = { #define noInvokeId NULL /*--- End of included file: packet-camel-val.h ---*/ -#line 304 "../../asn1/camel/packet-camel-template.c" +#line 305 "../../asn1/camel/packet-camel-template.c" /*--- Included file: packet-camel-table.c ---*/ @@ -1271,7 +1272,7 @@ static const value_string camel_err_code_string_vals[] = { /*--- End of included file: packet-camel-table.c ---*/ -#line 306 "../../asn1/camel/packet-camel-template.c" +#line 307 "../../asn1/camel/packet-camel-template.c" /* * DEBUG fonctions @@ -1311,7 +1312,7 @@ camelstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb } } -static int +static gboolean camelstat_packet(void *pcamel, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) { guint idx = 0; @@ -1330,16 +1331,16 @@ camelstat_packet(void *pcamel, packet_info *pinfo, epan_dissect_t *edt _U_, cons add_srt_table_data(camel_srt_table, i, &pi->msginfo[i].req_time, pinfo); } } /* category */ - return 1; + return TRUE; } static char camel_number_to_char(int number) { - if (number < 10) - return (char) (number + 48 ); /* this is ASCII specific */ - else - return (char) (number + 55 ); + if (number < 10) + return (char) (number + 48 ); /* this is ASCII specific */ + else + return (char) (number + 55 ); } /* @@ -7111,7 +7112,7 @@ static int dissect_CAP_U_ABORT_REASON_PDU(tvbuff_t *tvb _U_, packet_info *pinfo /*--- End of included file: packet-camel-fn.c ---*/ -#line 414 "../../asn1/camel/packet-camel-template.c" +#line 415 "../../asn1/camel/packet-camel-template.c" /*--- Included file: packet-camel-table2.c ---*/ @@ -7318,7 +7319,7 @@ static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset,a /*--- End of included file: packet-camel-table2.c ---*/ -#line 416 "../../asn1/camel/packet-camel-template.c" +#line 417 "../../asn1/camel/packet-camel-template.c" /* * Functions needed for Hash-Table @@ -8119,6 +8120,78 @@ dissect_camel(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* return tvb_captured_length(tvb); } +/* TAP STAT INFO */ +typedef enum +{ + MESSAGE_TYPE_COLUMN = 0, + COUNT_COLUMN +} camel_stat_columns; + +static stat_tap_table_item camel_stat_fields[] = {{TABLE_ITEM_STRING, TAP_ALIGN_LEFT, "Message Type or Reason", "%-25s"}, {TABLE_ITEM_UINT, TAP_ALIGN_RIGHT, "Count", "%d"}}; + +void camel_stat_init(new_stat_tap_ui* new_stat, new_stat_tap_gui_init_cb gui_callback, void* gui_data) +{ + int num_fields = sizeof(camel_stat_fields)/sizeof(stat_tap_table_item); + new_stat_tap_table* table = new_stat_tap_init_table("CAMEL Message Counters", num_fields, 0, NULL, gui_callback, gui_data); + int i; + stat_tap_table_item_type items[sizeof(camel_stat_fields)/sizeof(stat_tap_table_item)]; + + new_stat_tap_add_table(new_stat, table); + + items[MESSAGE_TYPE_COLUMN].type = TABLE_ITEM_STRING; + items[COUNT_COLUMN].type = TABLE_ITEM_UINT; + items[COUNT_COLUMN].value.uint_value = 0; + + /* Add a row for each value type */ + for (i = 0; i < camel_MAX_NUM_OPR_CODES; i++) + { + const char *ocs = try_val_to_str(i, camel_opr_code_strings); + char *col_str; + if (ocs) { + col_str = g_strdup_printf("Request %s", ocs); + } else { + col_str = g_strdup_printf("Unknown op code %d", i); + } + + items[MESSAGE_TYPE_COLUMN].value.string_value = col_str; + new_stat_tap_init_table_row(table, i, num_fields, items); + } +} + +static gboolean +camel_stat_packet(void *tapdata, packet_info *pinfo _U_, epan_dissect_t *edt _U_, const void *csi_ptr) +{ + new_stat_data_t* stat_data = (new_stat_data_t*)tapdata; + const struct camelsrt_info_t *csi = (const struct camelsrt_info_t *) csi_ptr; + new_stat_tap_table* table; + stat_tap_table_item_type* msg_data; + guint i = 0; + + table = g_array_index(stat_data->new_stat_tap_data->tables, new_stat_tap_table*, i); + if (csi->opcode >= table->num_elements) + return FALSE; + msg_data = new_stat_tap_get_field_data(table, csi->opcode, COUNT_COLUMN); + msg_data->value.uint_value++; + new_stat_tap_set_field_data(table, csi->opcode, COUNT_COLUMN, msg_data); + + return TRUE; +} + +static void +camel_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, COUNT_COLUMN); + item_data->value.uint_value = 0; + new_stat_tap_set_field_data(table, element, COUNT_COLUMN, item_data); + } +} + + /*--- proto_reg_handoff_camel ---------------------------------------*/ static void range_delete_callback(guint32 ssn) { @@ -8165,7 +8238,7 @@ void proto_reg_handoff_camel(void) { /*--- End of included file: packet-camel-dis-tab.c ---*/ -#line 1255 "../../asn1/camel/packet-camel-template.c" +#line 1328 "../../asn1/camel/packet-camel-template.c" } else { range_foreach(ssn_range, range_delete_callback); g_free(ssn_range); @@ -10279,7 +10352,7 @@ void proto_register_camel(void) { "InvokeId_present", HFILL }}, /*--- End of included file: packet-camel-hfarr.c ---*/ -#line 1428 "../../asn1/camel/packet-camel-template.c" +#line 1501 "../../asn1/camel/packet-camel-template.c" }; /* List of subtrees */ @@ -10291,10 +10364,10 @@ void proto_register_camel(void) { &ett_camel_cause, &ett_camel_RPcause, &ett_camel_stat, - &ett_camel_calledpartybcdnumber, - &ett_camel_callingpartynumber, - &ett_camel_locationnumber, - &ett_camel_additionalcallingpartynumber, + &ett_camel_calledpartybcdnumber, + &ett_camel_callingpartynumber, + &ett_camel_locationnumber, + &ett_camel_additionalcallingpartynumber, /*--- Included file: packet-camel-ettarr.c ---*/ @@ -10495,7 +10568,7 @@ void proto_register_camel(void) { &ett_camel_InvokeId, /*--- End of included file: packet-camel-ettarr.c ---*/ -#line 1445 "../../asn1/camel/packet-camel-template.c" +#line 1518 "../../asn1/camel/packet-camel-template.c" }; static ei_register_info ei[] = { @@ -10506,6 +10579,25 @@ void proto_register_camel(void) { expert_module_t* expert_camel; + static tap_param camel_stat_params[] = { + { PARAM_FILTER, "filter", "Filter", NULL, TRUE } + }; + + static new_stat_tap_ui camel_stat_table = { + REGISTER_STAT_GROUP_TELEPHONY_GSM, + "CAMEL Messages and Response Status", + PSNAME, + "camel,counter", + camel_stat_init, + camel_stat_packet, + camel_stat_reset, + NULL, + NULL, + sizeof(camel_stat_fields)/sizeof(stat_tap_table_item), camel_stat_fields, + sizeof(camel_stat_params)/sizeof(tap_param), camel_stat_params, + NULL + }; + /* Register protocol */ proto_camel = proto_register_protocol(PNAME, PSNAME, PFNAME); @@ -10548,8 +10640,8 @@ void proto_register_camel(void) { &global_ssn_range, MAX_SSN); prefs_register_bool_preference(camel_module, "srt", - "Service Response Time Analyse", - "Activate the analyse for Response Time", + "Analyze Service Response Time", + "Enable response time analysis", &gcamel_HandleSRT); prefs_register_bool_preference(camel_module, "persistentsrt", @@ -10562,6 +10654,7 @@ void proto_register_camel(void) { register_cleanup_routine(&camelsrt_cleanup_routine); camel_tap=register_tap(PSNAME); - register_srt_table(proto_camel, "CAMEL", 1, camelstat_packet, camelstat_init, NULL); + register_srt_table(proto_camel, PSNAME, 1, camelstat_packet, camelstat_init, NULL); + register_new_stat_tap_ui(&camel_stat_table); } |