diff options
54 files changed, 2542 insertions, 5212 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 2dec9a570e..03040fb4e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1140,14 +1140,11 @@ if(ENABLE_EXTCAP) endif() set(TSHARK_TAP_SRC - ui/cli/cli_service_response_time_table.c - ui/cli/tap-afpstat.c ui/cli/tap-ansi_astat.c ui/cli/tap-bootpstat.c ui/cli/tap-camelcounter.c ui/cli/tap-camelsrt.c ui/cli/tap-comparestat.c - ui/cli/tap-dcerpcstat.c ui/cli/tap-diameter-avp.c ui/cli/tap-expert.c ui/cli/tap-endpoints.c @@ -1162,25 +1159,20 @@ set(TSHARK_TAP_SRC ui/cli/tap-icmpv6stat.c ui/cli/tap-iostat.c ui/cli/tap-iousers.c - ui/cli/tap-ldapstat.c ui/cli/tap-macltestat.c ui/cli/tap-mgcpstat.c ui/cli/tap-megacostat.c - ui/cli/tap-ncpstat.c ui/cli/tap-protocolinfo.c ui/cli/tap-protohierstat.c ui/cli/tap-radiusstat.c ui/cli/tap-rlcltestat.c - ui/cli/tap-rpcstat.c ui/cli/tap-rpcprogs.c ui/cli/tap-rtp.c ui/cli/tap-rtspstat.c - ui/cli/tap-scsistat.c ui/cli/tap-sctpchunkstat.c ui/cli/tap-sipstat.c ui/cli/tap-smbsids.c - ui/cli/tap-smb2stat.c - ui/cli/tap-smbstat.c + ui/cli/tap-srt.c ui/cli/tap-stats_tree.c ui/cli/tap-sv.c ui/cli/tap-wspstat.c diff --git a/asn1/camel/packet-camel-template.c b/asn1/camel/packet-camel-template.c index 4488eee513..2c11b5a219 100644 --- a/asn1/camel/packet-camel-template.c +++ b/asn1/camel/packet-camel-template.c @@ -39,6 +39,7 @@ #include <epan/prefs.h> #include <epan/oids.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/asn1.h> #include <epan/expert.h> @@ -325,6 +326,45 @@ static void dbg(guint level, char *fmt, ...) { } #endif +static void +camelstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *camel_srt_table; + gchar* tmp_str; + guint32 i; + + camel_srt_table = init_srt_table("CAMEL Commands", NULL, srt_array, NB_CAMELSRT_CATEGORY, NULL, NULL, gui_callback, gui_data, NULL); + for (i = 0; i < NB_CAMELSRT_CATEGORY; i++) + { + tmp_str = val_to_str_wmem(NULL,i,camelSRTtype_naming,"Unknown (%d)"); + init_srt_table_row(camel_srt_table, i, tmp_str); + wmem_free(NULL, tmp_str); + } +} + +static int +camelstat_packet(void *pcamel, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) +{ + guint idx = 0; + srt_stat_table *camel_srt_table; + const struct camelsrt_info_t * pi=(const struct camelsrt_info_t *)psi; + srt_data_t *data = (srt_data_t *)pcamel; + int i; + + for (i=1; i<NB_CAMELSRT_CATEGORY; i++) { + if ( pi->bool_msginfo[i] && + pi->msginfo[i].is_delta_time + && pi->msginfo[i].request_available + && !pi->msginfo[i].is_duplicate ) + { + camel_srt_table = g_array_index(data->srt_array, srt_stat_table*, idx); + add_srt_table_data(camel_srt_table, i, &pi->msginfo[i].req_time, pinfo); + } + } /* category */ + return 1; +} + + static char camel_number_to_char(int number) { if (number < 10) @@ -1471,5 +1511,7 @@ void proto_register_camel(void) { /* Routine for statistic */ register_init_routine(&camelsrt_init_routine); camel_tap=register_tap(PSNAME); + + register_srt_table(proto_camel, "CAMEL", 1, camelstat_packet, camelstat_init, NULL); } diff --git a/asn1/ldap/packet-ldap-template.c b/asn1/ldap/packet-ldap-template.c index d8eebe8d70..21bd8cfdcd 100644 --- a/asn1/ldap/packet-ldap-template.c +++ b/asn1/ldap/packet-ldap-template.c @@ -87,6 +87,7 @@ #include <epan/conversation.h> #include <epan/prefs.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/oids.h> #include <epan/strutil.h> #include <epan/show_exception.h> @@ -299,6 +300,59 @@ static const value_string netlogon_opcode_vals[] = { { 0, NULL } }; +#define LDAP_NUM_PROCEDURES 24 + +static void +ldapstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *ldap_srt_table; + guint32 i; + + ldap_srt_table = init_srt_table("LDAP Commands", NULL, srt_array, LDAP_NUM_PROCEDURES, NULL, "ldap.protocolOp", gui_callback, gui_data, NULL); + for (i = 0; i < LDAP_NUM_PROCEDURES; i++) + { + init_srt_table_row(ldap_srt_table, i, val_to_str_const(i, ldap_procedure_names, "<unknown>")); + } +} + +static int +ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) +{ + guint i = 0; + srt_stat_table *ldap_srt_table; + const ldap_call_response_t *ldap=(const ldap_call_response_t *)psi; + srt_data_t *data = (srt_data_t *)pldap; + + /* we are only interested in reply packets */ + if(ldap->is_request){ + return 0; + } + /* if we havnt seen the request, just ignore it */ + if(!ldap->req_frame){ + return 0; + } + + /* only use the commands we know how to handle */ + switch(ldap->protocolOpTag){ + case LDAP_REQ_BIND: + case LDAP_REQ_SEARCH: + case LDAP_REQ_MODIFY: + case LDAP_REQ_ADD: + case LDAP_REQ_DELETE: + case LDAP_REQ_MODRDN: + case LDAP_REQ_COMPARE: + case LDAP_REQ_EXTENDED: + break; + default: + return 0; + } + + ldap_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + + add_srt_table_data(ldap_srt_table, ldap->protocolOpTag, &ldap->req_time, pinfo); + return 1; +} + /* * Data structure attached to a conversation, giving authentication * information from a bind request. @@ -2248,6 +2302,7 @@ void proto_register_ldap(void) { ldap_name_dissector_table = register_dissector_table("ldap.name", "LDAP Attribute Type Dissectors", FT_STRING, BASE_NONE); + register_srt_table(proto_ldap, NULL, 1, ldapstat_packet, ldapstat_init, NULL); } diff --git a/epan/CMakeLists.txt b/epan/CMakeLists.txt index c972107b08..87b2d298f9 100644 --- a/epan/CMakeLists.txt +++ b/epan/CMakeLists.txt @@ -1631,6 +1631,7 @@ set(LIBWIRESHARK_FILES req_resp_hdrs.c show_exception.c sminmpec.c + srt_table.c stat_tap_ui.c stats_tree.c strutil.c diff --git a/epan/Makefile.common b/epan/Makefile.common index 52b772ebd1..ec2ee1926e 100644 --- a/epan/Makefile.common +++ b/epan/Makefile.common @@ -81,6 +81,7 @@ LIBWIRESHARK_SRC = \ req_resp_hdrs.c \ show_exception.c \ sminmpec.c \ + srt_table.c \ stat_tap_ui.c \ stats_tree.c \ strutil.c \ @@ -236,6 +237,7 @@ LIBWIRESHARK_INCLUDES = \ show_exception.h \ slow_protocol_subtypes.h \ sminmpec.h \ + srt_table.h \ stat_tap_ui.h \ stat_groups.h \ stats_tree.h \ diff --git a/epan/conversation_table.c b/epan/conversation_table.c index b02d6e558b..f1f397780d 100644 --- a/epan/conversation_table.c +++ b/epan/conversation_table.c @@ -32,8 +32,6 @@ #include "stat_tap_ui.h" -GList *cmd_string_list_ = NULL; - struct register_ct { gboolean hide_ports; /* hide TCP / UDP port columns */ int proto_id; /* protocol id (0-indexed) */ @@ -164,7 +162,6 @@ set_conv_gui_data(gpointer data, gpointer user_data) table->conv_gui_init = (conv_gui_init_cb)user_data; g_string_append(conv_cmd_str, proto_get_protocol_filter_name(table->proto_id)); - cmd_string_list_ = g_list_append(cmd_string_list_, conv_cmd_str->str); ui_info.group = REGISTER_STAT_GROUP_CONVERSATION_LIST; ui_info.title = NULL; /* construct this from the protocol info? */ ui_info.cli_string = g_string_free(conv_cmd_str, FALSE); diff --git a/epan/dissectors/packet-afp.c b/epan/dissectors/packet-afp.c index 2f89b82f20..e317af7b10 100644 --- a/epan/dissectors/packet-afp.c +++ b/epan/dissectors/packet-afp.c @@ -32,6 +32,7 @@ #include <epan/to_str.h> #include <epan/conversation.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/expert.h> #include "packet-afp.h" @@ -1094,6 +1095,45 @@ static const value_string afp_server_addr_type_vals[] = { {0, NULL } }; value_string_ext afp_server_addr_type_vals_ext = VALUE_STRING_EXT_INIT(afp_server_addr_type_vals); +#define AFP_NUM_PROCEDURES 256 + +static void +afpstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *afp_srt_table; + guint32 i; + + afp_srt_table = init_srt_table("AFP Commands", NULL, srt_array, AFP_NUM_PROCEDURES, NULL, "afp.command", gui_callback, gui_data, NULL); + for (i = 0; i < AFP_NUM_PROCEDURES; i++) + { + gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &CommandCode_vals_ext, "Unknown(%u)"); + init_srt_table_row(afp_srt_table, i, tmp_str); + wmem_free(NULL, tmp_str); + } +} + +static int +afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *afp_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const afp_request_val *request_val = (const afp_request_val *)prv; + + /* if we haven't seen the request, just ignore it */ + if (!request_val) { + return 0; + } + + afp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + + add_srt_table_data(afp_srt_table, request_val->command, &request_val->req_time, pinfo); + + return 1; +} + + + #define hash_init_count 20 /* Forward declarations */ @@ -7232,6 +7272,8 @@ proto_register_afp(void) new_register_dissector("afp_spotlight", dissect_spotlight, proto_afp); afp_tap = register_tap("afp"); + + register_srt_table(proto_afp, NULL, 1, afpstat_packet, afpstat_init, NULL); } void diff --git a/epan/dissectors/packet-camel.c b/epan/dissectors/packet-camel.c index 74f917ddf8..80fbdcbde6 100644 --- a/epan/dissectors/packet-camel.c +++ b/epan/dissectors/packet-camel.c @@ -47,6 +47,7 @@ #include <epan/prefs.h> #include <epan/oids.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/asn1.h> #include <epan/expert.h> @@ -605,7 +606,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 112 "../../asn1/camel/packet-camel-template.c" +#line 113 "../../asn1/camel/packet-camel-template.c" static struct camelsrt_info_t * gp_camelsrt_info; @@ -835,7 +836,7 @@ static gint ett_camel_T_problem = -1; static gint ett_camel_InvokeId = -1; /*--- End of included file: packet-camel-ett.c ---*/ -#line 143 "../../asn1/camel/packet-camel-template.c" +#line 144 "../../asn1/camel/packet-camel-template.c" static expert_field ei_camel_unknown_invokeData = EI_INIT; static expert_field ei_camel_unknown_returnResultData = EI_INIT; @@ -1180,7 +1181,7 @@ static const value_string camel_ectTreatmentIndicator_values[] = { #define noInvokeId NULL /*--- End of included file: packet-camel-val.h ---*/ -#line 303 "../../asn1/camel/packet-camel-template.c" +#line 304 "../../asn1/camel/packet-camel-template.c" /*--- Included file: packet-camel-table.c ---*/ @@ -1270,7 +1271,7 @@ static const value_string camel_err_code_string_vals[] = { /*--- End of included file: packet-camel-table.c ---*/ -#line 305 "../../asn1/camel/packet-camel-template.c" +#line 306 "../../asn1/camel/packet-camel-template.c" /* * DEBUG fonctions @@ -1294,6 +1295,45 @@ static void dbg(guint level, char *fmt, ...) { } #endif +static void +camelstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *camel_srt_table; + gchar* tmp_str; + guint32 i; + + camel_srt_table = init_srt_table("CAMEL Commands", NULL, srt_array, NB_CAMELSRT_CATEGORY, NULL, NULL, gui_callback, gui_data, NULL); + for (i = 0; i < NB_CAMELSRT_CATEGORY; i++) + { + tmp_str = val_to_str_wmem(NULL,i,camelSRTtype_naming,"Unknown (%d)"); + init_srt_table_row(camel_srt_table, i, tmp_str); + wmem_free(NULL, tmp_str); + } +} + +static int +camelstat_packet(void *pcamel, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) +{ + guint idx = 0; + srt_stat_table *camel_srt_table; + const struct camelsrt_info_t * pi=(const struct camelsrt_info_t *)psi; + srt_data_t *data = (srt_data_t *)pcamel; + int i; + + for (i=1; i<NB_CAMELSRT_CATEGORY; i++) { + if ( pi->bool_msginfo[i] && + pi->msginfo[i].is_delta_time + && pi->msginfo[i].request_available + && !pi->msginfo[i].is_duplicate ) + { + camel_srt_table = g_array_index(data->srt_array, srt_stat_table*, idx); + add_srt_table_data(camel_srt_table, i, &pi->msginfo[i].req_time, pinfo); + } + } /* category */ + return 1; +} + + static char camel_number_to_char(int number) { if (number < 10) @@ -7071,7 +7111,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 374 "../../asn1/camel/packet-camel-template.c" +#line 414 "../../asn1/camel/packet-camel-template.c" /*--- Included file: packet-camel-table2.c ---*/ @@ -7278,7 +7318,7 @@ static int dissect_returnErrorData(proto_tree *tree, tvbuff_t *tvb, int offset,a /*--- End of included file: packet-camel-table2.c ---*/ -#line 376 "../../asn1/camel/packet-camel-template.c" +#line 416 "../../asn1/camel/packet-camel-template.c" /* * Functions needed for Hash-Table @@ -8130,7 +8170,7 @@ void proto_reg_handoff_camel(void) { /*--- End of included file: packet-camel-dis-tab.c ---*/ -#line 1220 "../../asn1/camel/packet-camel-template.c" +#line 1260 "../../asn1/camel/packet-camel-template.c" } else { range_foreach(ssn_range, range_delete_callback); g_free(ssn_range); @@ -10244,7 +10284,7 @@ void proto_register_camel(void) { "InvokeId_present", HFILL }}, /*--- End of included file: packet-camel-hfarr.c ---*/ -#line 1393 "../../asn1/camel/packet-camel-template.c" +#line 1433 "../../asn1/camel/packet-camel-template.c" }; /* List of subtrees */ @@ -10460,7 +10500,7 @@ void proto_register_camel(void) { &ett_camel_InvokeId, /*--- End of included file: packet-camel-ettarr.c ---*/ -#line 1410 "../../asn1/camel/packet-camel-template.c" +#line 1450 "../../asn1/camel/packet-camel-template.c" }; static ei_register_info ei[] = { @@ -10525,5 +10565,7 @@ void proto_register_camel(void) { /* Routine for statistic */ register_init_routine(&camelsrt_init_routine); camel_tap=register_tap(PSNAME); + + register_srt_table(proto_camel, "CAMEL", 1, camelstat_packet, camelstat_init, NULL); } diff --git a/epan/dissectors/packet-dcerpc.c b/epan/dissectors/packet-dcerpc.c index 72acdedb37..8c64e46984 100644 --- a/epan/dissectors/packet-dcerpc.c +++ b/epan/dissectors/packet-dcerpc.c @@ -29,12 +29,13 @@ #include "config.h" - +#include <stdio.h> #include <epan/packet.h> #include <epan/exceptions.h> #include <epan/prefs.h> #include <epan/reassemble.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/expert.h> #include <epan/addr_resolv.h> #include <epan/show_exception.h> @@ -1479,6 +1480,161 @@ dcerpc_matched_hash(gconstpointer k) return key->frame; } +static gboolean +uuid_equal(e_guid_t *uuid1, e_guid_t *uuid2) +{ + if( (uuid1->data1 != uuid2->data1) + ||(uuid1->data2 != uuid2->data2) + ||(uuid1->data3 != uuid2->data3) + ||(uuid1->data4[0] != uuid2->data4[0]) + ||(uuid1->data4[1] != uuid2->data4[1]) + ||(uuid1->data4[2] != uuid2->data4[2]) + ||(uuid1->data4[3] != uuid2->data4[3]) + ||(uuid1->data4[4] != uuid2->data4[4]) + ||(uuid1->data4[5] != uuid2->data4[5]) + ||(uuid1->data4[6] != uuid2->data4[6]) + ||(uuid1->data4[7] != uuid2->data4[7]) ){ + return FALSE; + } + return TRUE; +} + +static void +dcerpcstat_init(struct register_srt* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + dcerpcstat_tap_data_t* tap_data = (dcerpcstat_tap_data_t*)get_srt_table_param_data(srt); + srt_stat_table *dcerpc_srt_table; + int i, hf_opnum; + dcerpc_sub_dissector *procs; + + DISSECTOR_ASSERT(tap_data); + + hf_opnum = dcerpc_get_proto_hf_opnum(&tap_data->uuid, tap_data->ver); + procs = dcerpc_get_proto_sub_dissector(&tap_data->uuid, tap_data->ver); + + if(hf_opnum != -1){ + dcerpc_srt_table = init_srt_table(tap_data->prog, NULL, srt_array, tap_data->num_procedures, NULL, proto_registrar_get_nth(hf_opnum)->abbrev, gui_callback, gui_data, tap_data); + } else { + dcerpc_srt_table = init_srt_table(tap_data->prog, NULL, srt_array, tap_data->num_procedures, NULL, NULL, gui_callback, gui_data, tap_data); + } + + for(i=0;i<tap_data->num_procedures;i++){ + int j; + const char *proc_name; + + proc_name = "unknown"; + for(j=0;procs[j].name;j++) + { + if (procs[j].num == i) + { + proc_name = procs[j].name; + } + } + + init_srt_table_row(dcerpc_srt_table, i, proc_name); + } +} + +static int +dcerpcstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *dcerpc_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const dcerpc_info *ri = (dcerpc_info *)prv; + dcerpcstat_tap_data_t* tap_data; + + dcerpc_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + tap_data = (dcerpcstat_tap_data_t*)dcerpc_srt_table->table_specific_data; + + if(!ri->call_data){ + return 0; + } + if(!ri->call_data->req_frame){ + /* we have not seen the request so we don't know the delta*/ + return 0; + } + if(ri->call_data->opnum >= tap_data->num_procedures){ + /* don't handle this since it's outside of known table */ + return 0; + } + + /* we are only interested in reply packets */ + if(ri->ptype != PDU_RESP){ + return 0; + } + + /* we are only interested in certain program/versions */ + if( (!uuid_equal( (&ri->call_data->uuid), (&tap_data->uuid))) + ||(ri->call_data->ver != tap_data->ver)){ + return 0; + } + + add_srt_table_data(dcerpc_srt_table, ri->call_data->opnum, &ri->call_data->req_time, pinfo); + + return 1; +} + +static guint +dcerpcstat_param(register_srt_t* srt, const char* opt_arg, char** err) +{ + guint pos = 0; + guint32 i, max_procs; + dcerpcstat_tap_data_t* tap_data; + guint d1,d2,d3,d40,d41,d42,d43,d44,d45,d46,d47; + int major, minor; + guint16 ver; + dcerpc_sub_dissector *procs; + + if (sscanf(opt_arg, ",%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d,%n", + &d1,&d2,&d3,&d40,&d41,&d42,&d43,&d44,&d45,&d46,&d47,&major,&minor,&pos) == 13) + { + if ((major < 0) || (major > 65535)) { + *err = g_strdup_printf("dcerpcstat_init() Major version number %d is invalid - must be positive and <= 65535", major); + return pos; + } + if ((minor < 0) || (minor > 65535)) { + *err = g_strdup_printf("dcerpcstat_init() Minor version number %d is invalid - must be positive and <= 65535", minor); + return pos; + } + ver = major; + + tap_data = g_new0(dcerpcstat_tap_data_t, 1); + + tap_data->uuid.data1 = d1; + tap_data->uuid.data2 = d2; + tap_data->uuid.data3 = d3; + tap_data->uuid.data4[0] = d40; + tap_data->uuid.data4[1] = d41; + tap_data->uuid.data4[2] = d42; + tap_data->uuid.data4[3] = d43; + tap_data->uuid.data4[4] = d44; + tap_data->uuid.data4[5] = d45; + tap_data->uuid.data4[6] = d46; + tap_data->uuid.data4[7] = d47; + + procs = dcerpc_get_proto_sub_dissector(&tap_data->uuid, ver); + tap_data->prog = dcerpc_get_proto_name(&tap_data->uuid, ver); + tap_data->ver = ver; + + for(i=0,max_procs=0;procs[i].name;i++) + { + if(procs[i].num>max_procs) + { + max_procs = procs[i].num; + } + } + tap_data->num_procedures = max_procs+1; + + set_srt_table_param_data(srt, tap_data); + } + else + { + *err = g_strdup_printf("<uuid>,<major version>.<minor version>[,<filter>]"); + } + + return pos; +} /* @@ -6384,6 +6540,8 @@ proto_register_dcerpc(void) dcerpc_tap = register_tap("dcerpc"); register_decode_as(&dcerpc_da); + + register_srt_table(proto_dcerpc, NULL, 1, dcerpcstat_packet, dcerpcstat_init, dcerpcstat_param); } void diff --git a/epan/dissectors/packet-dcerpc.h b/epan/dissectors/packet-dcerpc.h index 2db4d8e5ab..c9222bfb9c 100644 --- a/epan/dissectors/packet-dcerpc.h +++ b/epan/dissectors/packet-dcerpc.h @@ -108,6 +108,14 @@ typedef struct _dcerpc_auth_info { tvbuff_t *auth_data; } dcerpc_auth_info; +typedef struct dcerpcstat_tap_data +{ + const char *prog; + e_guid_t uuid; + guint16 ver; + int num_procedures; +} dcerpcstat_tap_data_t; + /* Private data passed to subdissectors from the main DCERPC dissector. * One unique instance of this structure is created for each * DCERPC request/response transaction when we see the initial request 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 diff --git a/epan/dissectors/packet-fc.c b/epan/dissectors/packet-fc.c index 900a19ac47..a4c3ef2307 100644 --- a/epan/dissectors/packet-fc.c +++ b/epan/dissectors/packet-fc.c @@ -33,6 +33,7 @@ #include <epan/reassemble.h> #include <epan/conversation_table.h> #include <epan/etypes.h> +#include <epan/srt_table.h> #include "packet-fc.h" #include "packet-fclctl.h" #include "packet-fcbls.h" @@ -253,6 +254,47 @@ fc_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const return 1; } +#define FC_NUM_PROCEDURES 256 + +static void +fcstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *fc_srt_table; + guint32 i; + + fc_srt_table = init_srt_table("Fibre Channel Types", NULL, srt_array, FC_NUM_PROCEDURES, NULL, NULL, gui_callback, gui_data, NULL); + for (i = 0; i < FC_NUM_PROCEDURES; i++) + { + gchar* tmp_str = val_to_str_wmem(NULL, i, fc_fc4_val, "Unknown(0x%02x)"); + init_srt_table_row(fc_srt_table, i, tmp_str); + wmem_free(NULL, tmp_str); + } +} + +static int +fcstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *fc_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const fc_hdr *fc=(const fc_hdr *)prv; + + /* we are only interested in reply packets */ + if(!(fc->fctl&FC_FCTL_EXCHANGE_RESPONDER)){ + return 0; + } + /* if we havnt seen the request, just ignore it */ + if ( (!fc->fc_ex) || (fc->fc_ex->first_exchange_frame==0) ){ + return 0; + } + + fc_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + add_srt_table_data(fc_srt_table, fc->type, &fc->fc_ex->fc_time, pinfo); + + return 1; +} + + const value_string fc_fc4_val[] = { {FC_TYPE_BLS, "Basic Link Svc"}, {FC_TYPE_ELS, "Ext Link Svc"}, @@ -1544,6 +1586,7 @@ proto_register_fc(void) fcsof_handle = register_dissector("fcsof", dissect_fcsof, proto_fcsof); register_conversation_table(proto_fc, TRUE, fc_conversation_packet, fc_hostlist_packet); + register_srt_table(proto_fc, NULL, 1, fcstat_packet, fcstat_init, NULL); } diff --git a/epan/dissectors/packet-gtp.c b/epan/dissectors/packet-gtp.c index 5270cf93bf..37de190955 100644 --- a/epan/dissectors/packet-gtp.c +++ b/epan/dissectors/packet-gtp.c @@ -59,6 +59,7 @@ #include <epan/sminmpec.h> #include <epan/asn1.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/to_str.h> #include "packet-ppp.h" #include "packet-radius.h" @@ -1767,6 +1768,61 @@ static const value_string tft_code_type[] = { {0, NULL} }; +static void +gtpstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *gtp_srt_table; + + gtp_srt_table = init_srt_table("GTP Requests", NULL, srt_array, 4, NULL, NULL, gui_callback, gui_data, NULL); + init_srt_table_row(gtp_srt_table, 0, "Echo"); + init_srt_table_row(gtp_srt_table, 1, "Create PDP context"); + init_srt_table_row(gtp_srt_table, 2, "Update PDP context"); + init_srt_table_row(gtp_srt_table, 3, "Delete PDP context"); +} + +static int +gtpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *gtp_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const gtp_msg_hash_t *gtp=(const gtp_msg_hash_t *)prv; + int idx=0; + + /* we are only interested in reply packets */ + if(gtp->is_request){ + return 0; + } + /* if we have not seen the request, just ignore it */ + if(!gtp->req_frame){ + return 0; + } + + /* Only use the commands we know how to handle, this is not a comprehensive list */ + /* Redoing the message indexing is bit reduntant, */ + /* but using message type as such would yield a long gtp_srt_table. */ + /* Only a fraction of the messages are matchable req/resp pairs, */ + /* it just doesn't feel feasible. */ + + switch(gtp->msgtype){ + case GTP_MSG_ECHO_REQ: idx=0; + break; + case GTP_MSG_CREATE_PDP_REQ: idx=1; + break; + case GTP_MSG_UPDATE_PDP_REQ: idx=2; + break; + case GTP_MSG_DELETE_PDP_REQ: idx=3; + break; + default: + return 0; + } + + gtp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + add_srt_table_data(gtp_srt_table, idx, >p->req_time, pinfo); + + return 1; +} + static dissector_handle_t ip_handle; static dissector_handle_t ipv6_handle; @@ -9734,6 +9790,8 @@ proto_register_gtp(void) register_init_routine(gtp_reinit); gtp_tap = register_tap("gtp"); gtpv1_tap = register_tap("gtpv1"); + + register_srt_table(proto_gtp, NULL, 1, gtpstat_packet, gtpstat_init, NULL); } /* TS 132 295 V9.0.0 (2010-02) * 5.1.3 Port usage diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c index 1533178f25..7366cb31d3 100644 --- a/epan/dissectors/packet-ldap.c +++ b/epan/dissectors/packet-ldap.c @@ -95,6 +95,7 @@ #include <epan/conversation.h> #include <epan/prefs.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/oids.h> #include <epan/strutil.h> #include <epan/show_exception.h> @@ -342,7 +343,7 @@ static int hf_ldap_graceAuthNsRemaining = -1; /* INTEGER_0_maxInt */ static int hf_ldap_error = -1; /* T_error */ /*--- End of included file: packet-ldap-hf.c ---*/ -#line 192 "../../asn1/ldap/packet-ldap-template.c" +#line 193 "../../asn1/ldap/packet-ldap-template.c" /* Initialize the subtree pointers */ static gint ett_ldap = -1; @@ -414,7 +415,7 @@ static gint ett_ldap_PasswordPolicyResponseValue = -1; static gint ett_ldap_T_warning = -1; /*--- End of included file: packet-ldap-ett.c ---*/ -#line 204 "../../asn1/ldap/packet-ldap-template.c" +#line 205 "../../asn1/ldap/packet-ldap-template.c" static expert_field ei_ldap_exceeded_filter_length = EI_INIT; static expert_field ei_ldap_too_many_filter_elements = EI_INIT; @@ -513,6 +514,59 @@ static const value_string netlogon_opcode_vals[] = { { 0, NULL } }; +#define LDAP_NUM_PROCEDURES 24 + +static void +ldapstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *ldap_srt_table; + guint32 i; + + ldap_srt_table = init_srt_table("LDAP Commands", NULL, srt_array, LDAP_NUM_PROCEDURES, NULL, "ldap.protocolOp", gui_callback, gui_data, NULL); + for (i = 0; i < LDAP_NUM_PROCEDURES; i++) + { + init_srt_table_row(ldap_srt_table, i, val_to_str_const(i, ldap_procedure_names, "<unknown>")); + } +} + +static int +ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) +{ + guint i = 0; + srt_stat_table *ldap_srt_table; + const ldap_call_response_t *ldap=(const ldap_call_response_t *)psi; + srt_data_t *data = (srt_data_t *)pldap; + + /* we are only interested in reply packets */ + if(ldap->is_request){ + return 0; + } + /* if we havnt seen the request, just ignore it */ + if(!ldap->req_frame){ + return 0; + } + + /* only use the commands we know how to handle */ + switch(ldap->protocolOpTag){ + case LDAP_REQ_BIND: + case LDAP_REQ_SEARCH: + case LDAP_REQ_MODIFY: + case LDAP_REQ_ADD: + case LDAP_REQ_DELETE: + case LDAP_REQ_MODRDN: + case LDAP_REQ_COMPARE: + case LDAP_REQ_EXTENDED: + break; + default: + return 0; + } + + ldap_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + + add_srt_table_data(ldap_srt_table, ldap->protocolOpTag, &ldap->req_time, pinfo); + return 1; +} + /* * Data structure attached to a conversation, giving authentication * information from a bind request. @@ -3781,7 +3835,7 @@ static int dissect_PasswordPolicyResponseValue_PDU(tvbuff_t *tvb _U_, packet_inf /*--- End of included file: packet-ldap-fn.c ---*/ -#line 866 "../../asn1/ldap/packet-ldap-template.c" +#line 920 "../../asn1/ldap/packet-ldap-template.c" static int dissect_LDAPMessage_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ldap_conv_info_t *ldap_info) { int offset = 0; @@ -5647,7 +5701,7 @@ void proto_register_ldap(void) { NULL, HFILL }}, /*--- End of included file: packet-ldap-hfarr.c ---*/ -#line 2163 "../../asn1/ldap/packet-ldap-template.c" +#line 2217 "../../asn1/ldap/packet-ldap-template.c" }; /* List of subtrees */ @@ -5721,7 +5775,7 @@ void proto_register_ldap(void) { &ett_ldap_T_warning, /*--- End of included file: packet-ldap-ettarr.c ---*/ -#line 2177 "../../asn1/ldap/packet-ldap-template.c" +#line 2231 "../../asn1/ldap/packet-ldap-template.c" }; /* UAT for header fields */ static uat_field_t custom_attribute_types_uat_fields[] = { @@ -5796,6 +5850,7 @@ void proto_register_ldap(void) { ldap_name_dissector_table = register_dissector_table("ldap.name", "LDAP Attribute Type Dissectors", FT_STRING, BASE_NONE); + register_srt_table(proto_ldap, NULL, 1, ldapstat_packet, ldapstat_init, NULL); } @@ -5887,7 +5942,7 @@ proto_reg_handoff_ldap(void) /*--- End of included file: packet-ldap-dis-tab.c ---*/ -#line 2326 "../../asn1/ldap/packet-ldap-template.c" +#line 2381 "../../asn1/ldap/packet-ldap-template.c" } diff --git a/epan/dissectors/packet-ncp.c b/epan/dissectors/packet-ncp.c index 85ebe0b3a8..3caabaedea 100644 --- a/epan/dissectors/packet-ncp.c +++ b/epan/dissectors/packet-ncp.c @@ -45,6 +45,7 @@ #include <epan/packet.h> #include <epan/prefs.h> +#include <epan/srt_table.h> #include "packet-ipx.h" #include "packet-tcp.h" #include "packet-ncp-int.h" @@ -190,6 +191,253 @@ static const value_string ncp_oplock_vals[] = { { 0, NULL } }; +enum ncp_table_values +{ + NCP_NCP_SRT_TABLE_INDEX = 0, + NCP_NDS_SRT_TABLE_INDEX, + NCP_FUNC_SRT_TABLE_INDEX, + NCP_SSS_SRT_TABLE_INDEX, + NCP_NMAS_SRT_TABLE_INDEX, + NCP_SUB17_SRT_TABLE_INDEX, + NCP_SUB21_SRT_TABLE_INDEX, + NCP_SUB22_SRT_TABLE_INDEX, + NCP_SUB23_SRT_TABLE_INDEX, + NCP_SUB32_SRT_TABLE_INDEX, + NCP_SUB34_SRT_TABLE_INDEX, + NCP_SUB35_SRT_TABLE_INDEX, + NCP_SUB36_SRT_TABLE_INDEX, + NCP_SUB86_SRT_TABLE_INDEX, + NCP_SUB87_SRT_TABLE_INDEX, + NCP_SUB89_SRT_TABLE_INDEX, + NCP_SUB90_SRT_TABLE_INDEX, + NCP_SUB92_SRT_TABLE_INDEX, + NCP_SUB94_SRT_TABLE_INDEX, + NCP_SUB104_SRT_TABLE_INDEX, + NCP_SUB111_SRT_TABLE_INDEX, + NCP_SUB114_SRT_TABLE_INDEX, + NCP_SUB123_SRT_TABLE_INDEX, + NCP_SUB131_SRT_TABLE_INDEX, + +}; + +#define NCP_NUM_PROCEDURES 0 + +static void +ncpstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + /* Initialize all of the SRT tables with 0 rows. That way we can "filter" the drawing + function to only output tables with rows > 0 */ + + init_srt_table("NCP", "Groups", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.group", gui_callback, gui_data, NULL); + + /* NDS Verbs */ + init_srt_table("NDS Verbs", "NDS", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.ndsverb", gui_callback, gui_data, NULL); + + /* NCP Functions */ + init_srt_table("NCP Functions without Subfunctions", "Functions", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func", gui_callback, gui_data, NULL); + + /* Secret Store Verbs */ + init_srt_table("Secret Store Verbs", "SSS", srt_array, NCP_NUM_PROCEDURES, NULL, "sss.subverb", gui_callback, gui_data, NULL); + + /* NMAS Verbs */ + init_srt_table("NMAS Verbs", "NMAS", srt_array, NCP_NUM_PROCEDURES, NULL, "nmas.subverb", gui_callback, gui_data, NULL); + + /* NCP Subfunctions */ + init_srt_table("Subfunctions for NCP 17", "17", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==17 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 21", "21", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==21 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 22", "22", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==22 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 23", "23", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==23 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 32", "32", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==32 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 34", "34", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==34 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 35", "35", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==35 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 36", "36", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==36 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 86", "86", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==86 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 87", "87", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==87 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 89 (Extended NCP's with UTF8 Support)", "89", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==89 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 90", "90", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==90 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 92 (Secret Store Services)", "92", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==92 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 94 (Novell Modular Authentication Services)", "94", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==94 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 104", "104", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==104 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 111", "111", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==111 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 114", "114", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==114 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 123", "123", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==123 && ncp.subfunc", gui_callback, gui_data, NULL); + init_srt_table("Subfunctions for NCP 131", "131", srt_array, NCP_NUM_PROCEDURES, NULL, "ncp.func==131 && ncp.subfunc", gui_callback, gui_data, NULL); +} + +static int +ncpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *ncp_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const ncp_req_hash_value *request_val=(const ncp_req_hash_value *)prv; + gchar* tmp_str; + + /* if we haven't seen the request, just ignore it */ + if(!request_val || request_val->ncp_rec==0){ + return 0; + } + + /* By Group */ + tmp_str = val_to_str_wmem(NULL, request_val->ncp_rec->group, ncp_group_vals, "Unknown(%u)"); + i = NCP_NCP_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, request_val->ncp_rec->group, tmp_str); + wmem_free(NULL, tmp_str); + add_srt_table_data(ncp_srt_table, request_val->ncp_rec->group, &request_val->req_frame_time, pinfo); + /* By NCP number without subfunction*/ + if (request_val->ncp_rec->subfunc==0) { + i = NCP_FUNC_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, request_val->ncp_rec->func, request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, request_val->ncp_rec->func, &request_val->req_frame_time, pinfo); + } + /* By Subfunction number */ + if(request_val->ncp_rec->subfunc!=0){ + if (request_val->ncp_rec->func==17) { + i = NCP_SUB17_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==21) { + i = NCP_SUB21_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==22) { + i = NCP_SUB22_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==23) { + i = NCP_SUB23_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==32) { + i = NCP_SUB32_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==34) { + i = NCP_SUB34_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==35) { + i = NCP_SUB35_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==36) { + i = NCP_SUB36_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==86) { + i = NCP_SUB86_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==87) { + i = NCP_SUB87_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==89) { + i = NCP_SUB89_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==90) { + i = NCP_SUB90_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==92) { + i = NCP_SUB92_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==94) { + i = NCP_SUB94_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==104) { + i = NCP_SUB104_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==111) { + i = NCP_SUB111_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==114) { + i = NCP_SUB114_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==123) { + i = NCP_SUB123_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + if (request_val->ncp_rec->func==131) { + i = NCP_SUB131_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); + add_srt_table_data(ncp_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); + } + } + /* By NDS verb */ + if (request_val->ncp_rec->func==0x68) { + tmp_str = val_to_str_wmem(NULL, request_val->nds_request_verb, ncp_nds_verb_vals, "Unknown(%u)"); + i = NCP_NDS_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->nds_request_verb), tmp_str); + add_srt_table_data(ncp_srt_table, (request_val->nds_request_verb), &request_val->req_frame_time, pinfo); + wmem_free(NULL, tmp_str); + } + if (request_val->ncp_rec->func==0x5c) { + tmp_str = val_to_str_wmem(NULL, request_val->req_nds_flags, sss_verb_enum, "Unknown(%u)"); + i = NCP_SSS_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->req_nds_flags), tmp_str); + add_srt_table_data(ncp_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo); + wmem_free(NULL, tmp_str); + } + if (request_val->ncp_rec->func==0x5e) { + tmp_str = val_to_str_wmem(NULL, request_val->req_nds_flags, nmas_subverb_enum, "Unknown(%u)"); + i = NCP_NMAS_SRT_TABLE_INDEX; + ncp_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + init_srt_table_row(ncp_srt_table, (request_val->req_nds_flags), tmp_str); + add_srt_table_data(ncp_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo); + wmem_free(NULL, tmp_str); + } + return 1; +} + + /* Conversation Struct so we can detect NCP server sessions */ typedef struct { @@ -1091,6 +1339,7 @@ proto_register_ncp(void) expert_module_t* expert_ncp; proto_ncp = proto_register_protocol("NetWare Core Protocol", "NCP", "ncp"); + proto_register_field_array(proto_ncp, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); expert_ncp = expert_register_protocol(proto_ncp); @@ -1137,6 +1386,7 @@ proto_register_ncp(void) register_postseq_cleanup_routine(&mncp_postseq_cleanup); register_conversation_table(proto_ncp, FALSE, ncp_conversation_packet, ncp_hostlist_packet); + register_srt_table(proto_ncp, "ncp_srt", 24, ncpstat_packet, ncpstat_init, NULL); } void diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c index e8004870e4..5df6cb0d8a 100644 --- a/epan/dissectors/packet-rpc.c +++ b/epan/dissectors/packet-rpc.c @@ -25,7 +25,7 @@ #include "config.h" - +#include <stdio.h> #include <epan/packet.h> #include <epan/expert.h> #include <epan/exceptions.h> @@ -33,6 +33,7 @@ #include <epan/prefs.h> #include <epan/reassemble.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/strutil.h> #include <epan/show_exception.h> @@ -312,6 +313,129 @@ static void dissect_rpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree); static void show_rpc_fraginfo(tvbuff_t *tvb, tvbuff_t *frag_tvb, proto_tree *tree, guint32 rpc_rm, fragment_head *ipfd_head, packet_info *pinfo); + +static guint32 rpc_program = 0; +static guint32 rpc_version = 0; +static gint32 rpc_min_proc = -1; +static gint32 rpc_max_proc = -1; + +static void * +rpcstat_find_procs(gpointer *key, gpointer *value _U_, gpointer *user_data _U_) +{ + rpc_proc_info_key *k = (rpc_proc_info_key *)key; + + if (k->prog != rpc_program) { + return NULL; + } + if (k->vers != rpc_version) { + return NULL; + } + if (rpc_min_proc == -1) { + rpc_min_proc = k->proc; + rpc_max_proc = k->proc; + } + if ((gint32)k->proc < rpc_min_proc) { + rpc_min_proc = k->proc; + } + if ((gint32)k->proc > rpc_max_proc) { + rpc_max_proc = k->proc; + } + + return NULL; +} + +static void +rpcstat_init(struct register_srt* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + rpcstat_tap_data_t* tap_data = (rpcstat_tap_data_t*)get_srt_table_param_data(srt); + srt_stat_table *rpc_srt_table; + int i, hf_index; + header_field_info *hfi; + static char table_name[100]; + + DISSECTOR_ASSERT(tap_data); + + hf_index=rpc_prog_hf(tap_data->program, tap_data->version); + hfi=proto_registrar_get_nth(hf_index); + + g_snprintf(table_name, sizeof(table_name), "%s Version %u", tap_data->prog, tap_data->version); + rpc_srt_table = init_srt_table(table_name, NULL, srt_array, tap_data->num_procedures, NULL, hfi->abbrev, gui_callback, gui_data, tap_data); + for (i = 0; i < rpc_srt_table->num_procs; i++) + { + init_srt_table_row(rpc_srt_table, i, rpc_proc_name(tap_data->program, tap_data->version, i)); + } +} + +static int +rpcstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *rpc_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const rpc_call_info_value *ri = (const rpc_call_info_value *)prv; + rpcstat_tap_data_t* tap_data; + + rpc_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + tap_data = (rpcstat_tap_data_t*)rpc_srt_table->table_specific_data; + + if ((int)ri->proc >= rpc_srt_table->num_procs) { + /* don't handle this since its outside of known table */ + return 0; + } + /* we are only interested in reply packets */ + if (ri->request) { + return 0; + } + /* we are only interested in certain program/versions */ + if ( (ri->prog != tap_data->program) || (ri->vers != tap_data->version) ) { + return 0; + } + + add_srt_table_data(rpc_srt_table, ri->proc, &ri->req_time, pinfo); + return 1; + +} + +static guint +rpcstat_param(register_srt_t* srt, const char* opt_arg, char** err) +{ + guint pos = 0; + int program, version; + rpcstat_tap_data_t* tap_data; + + if (sscanf(opt_arg, ",%d,%d,%n", &program, &version, &pos) == 2) + { + tap_data = g_new0(rpcstat_tap_data_t, 1); + + tap_data->prog = rpc_prog_name(program); + tap_data->program = program; + tap_data->version = version; + + set_srt_table_param_data(srt, tap_data); + + rpc_program = tap_data->program; + rpc_version = tap_data->version; + rpc_min_proc = -1; + rpc_max_proc = -1; + g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL); + + tap_data->num_procedures = rpc_max_proc+1; + if (rpc_min_proc == -1) { + *err = g_strdup_printf("Program:%u version:%u isn't supported", rpc_program, rpc_version); + } + } + else + { + *err = g_strdup_printf("<program>,<version>[,<filter>]"); + } + + return pos; +} + + + + + /***********************************/ /* Hash array with procedure names */ /***********************************/ @@ -4030,6 +4154,8 @@ proto_register_rpc(void) new_register_dissector("rpc-tcp", dissect_rpc_tcp, proto_rpc); rpc_tap = register_tap("rpc"); + register_srt_table(proto_rpc, NULL, 1, rpcstat_packet, rpcstat_init, rpcstat_param); + /* * Init the hash tables. Dissectors for RPC protocols must * have a "handoff registration" routine that registers the diff --git a/epan/dissectors/packet-rpc.h b/epan/dissectors/packet-rpc.h index ffe41686cb..187445fe32 100644 --- a/epan/dissectors/packet-rpc.h +++ b/epan/dissectors/packet-rpc.h @@ -222,5 +222,13 @@ typedef struct _rpc_proc_info_value { */ WS_DLL_PUBLIC GHashTable *rpc_procs; +typedef struct rpcstat_tap_data +{ + const char *prog; + guint32 program; + guint32 version; + int num_procedures; +} rpcstat_tap_data_t; + #endif /* packet-rpc.h */ diff --git a/epan/dissectors/packet-scsi.c b/epan/dissectors/packet-scsi.c index de1ce6f09e..137d39644f 100644 --- a/epan/dissectors/packet-scsi.c +++ b/epan/dissectors/packet-scsi.c @@ -79,11 +79,13 @@ */ #include "config.h" +#include <stdio.h> #include <epan/packet.h> #include <epan/to_str.h> #include <epan/prefs.h> #include <epan/conversation.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/reassemble.h> #include <epan/expert.h> #include "packet-scsi.h" @@ -936,6 +938,110 @@ static const value_string scsi_log_pc_val[] = { {0, NULL}, }; +#define SCSI_NUM_PROCEDURES 256 +typedef struct scsistat_tap_data +{ + guint8 cmdset; + const char *prog; + value_string_ext *cdbnames_ext; + const char *hf_name; +} scsistat_tap_data_t; + +static void +scsistat_init(struct register_srt* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + scsistat_tap_data_t* tap_data = (scsistat_tap_data_t*)get_srt_table_param_data(srt); + srt_stat_table *scsi_srt_table; + guint32 i; + + DISSECTOR_ASSERT(tap_data); + + scsi_srt_table = init_srt_table(tap_data->prog, NULL, srt_array, SCSI_NUM_PROCEDURES, NULL, tap_data->hf_name, gui_callback, gui_data, tap_data); + for (i = 0; i < SCSI_NUM_PROCEDURES; i++) + { + init_srt_table_row(scsi_srt_table, i, val_to_str_ext_const(i, tap_data->cdbnames_ext, "Unknown-0x%02x")); + } +} + +static int +scsistat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *scsi_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const scsi_task_data_t *ri = (const scsi_task_data_t *)prv; + scsistat_tap_data_t* tap_data; + + scsi_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + tap_data = (scsistat_tap_data_t*)scsi_srt_table->table_specific_data; + + /* we are only interested in response packets */ + if (ri->type != SCSI_PDU_TYPE_RSP) { + return 0; + } + /* we are only interested in a specific commandset */ + if ( (!ri->itl) || ((ri->itl->cmdset&SCSI_CMDSET_MASK) != tap_data->cmdset) ) { + return 0; + } + /* check that the opcode looks sane */ + if ( (!ri->itlq) || (ri->itlq->scsi_opcode > 255) ) { + return 0; + } + + add_srt_table_data(scsi_srt_table, ri->itlq->scsi_opcode, &ri->itlq->fc_time, pinfo); + return 1; +} + +static guint +scsistat_param(register_srt_t* srt, const char* opt_arg, char** err) +{ + guint pos = 0; + int program; + scsistat_tap_data_t* tap_data; + + if (sscanf(opt_arg, ",%d,%n", &program, &pos) == 1) + { + tap_data = g_new0(scsistat_tap_data_t, 1); + tap_data->cmdset = (guint8)program; + + switch(program){ + case SCSI_DEV_SBC: + tap_data->prog = "SBC (disk)"; + tap_data->cdbnames_ext = &scsi_sbc_vals_ext; + tap_data->hf_name = "scsi_sbc.opcode"; + break; + case SCSI_DEV_SSC: + tap_data->prog = "SSC (tape)"; + tap_data->cdbnames_ext = &scsi_ssc_vals_ext; + tap_data->hf_name = "scsi_ssc.opcode"; + break; + case SCSI_DEV_CDROM: + tap_data->prog = "MMC (cd/dvd)"; + tap_data->cdbnames_ext = &scsi_mmc_vals_ext; + tap_data->hf_name = "scsi_mmc.opcode"; + break; + case SCSI_DEV_SMC: + tap_data->prog = "SMC (tape robot)"; + tap_data->cdbnames_ext = &scsi_smc_vals_ext; + tap_data->hf_name = "scsi_smc.opcode"; + break; + case SCSI_DEV_OSD: + tap_data->prog = "OSD (object based)"; + tap_data->cdbnames_ext = &scsi_osd_vals_ext; + tap_data->hf_name = "scsi_osd.opcode"; + break; + } + + set_srt_table_param_data(srt, tap_data); + } + else + { + *err = g_strdup_printf("<cmdset>[,<filter>]"); + } + + return pos; +} + /* TapeAlert page : read warning flag */ static void log_parameter_2e_0001(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree) @@ -7567,6 +7673,8 @@ proto_register_scsi(void) "Whether fragmented SCSI DATA IN/OUT transfers should be reassembled", &scsi_defragment); register_init_routine(scsi_defragment_init); + + register_srt_table(proto_scsi, NULL, 1, scsistat_packet, scsistat_init, scsistat_param); } void diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c index 614cf0900b..1f1286a1a4 100644 --- a/epan/dissectors/packet-smb.c +++ b/epan/dissectors/packet-smb.c @@ -32,6 +32,7 @@ #include <epan/prefs.h> #include <epan/reassemble.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/expert.h> #include <epan/to_str.h> @@ -883,6 +884,75 @@ static proto_tree *top_tree_global = NULL; /* ugly */ static int dissect_smb_command(tvbuff_t *tvb, packet_info *pinfo, int offset, proto_tree *smb_tree, guint8 cmd, gboolean first_pdu, smb_info_t *si); +#define SMB_NUM_PROCEDURES 256 +#define SMB_SRT_TABLE_INDEX 0 +#define TRANS2_SRT_TABLE_INDEX 1 +#define NT_SRT_TABLE_INDEX 2 + +static void +smbstat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *smb_srt_table; + srt_stat_table *trans2_srt_table; + srt_stat_table *nt_srt_table; + guint32 i; + + smb_srt_table = init_srt_table("SMB Commands", NULL, srt_array, SMB_NUM_PROCEDURES, "Commands", "smb.cmd", gui_callback, gui_data, NULL); + trans2_srt_table = init_srt_table("Transaction2 Sub-Commands", NULL, srt_array, SMB_NUM_PROCEDURES, "Transaction2 Commands", "smb.trans2.cmd", gui_callback, gui_data, NULL); + nt_srt_table = init_srt_table("NT Transaction Sub-Commands", NULL, srt_array, SMB_NUM_PROCEDURES, "NT Transaction Sub-Commands", "smb.nt.function", gui_callback, gui_data, NULL); + for (i = 0; i < SMB_NUM_PROCEDURES; i++) + { + init_srt_table_row(smb_srt_table, i, val_to_str_ext_const(i, &smb_cmd_vals_ext, "<unknown>")); + init_srt_table_row(trans2_srt_table, i, val_to_str_ext_const(i, &trans2_cmd_vals_ext, "<unknown>")); + init_srt_table_row(nt_srt_table, i, val_to_str_ext_const(i, &nt_cmd_vals_ext, "<unknown>")); + } +} + +static int +smbstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *smb_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const smb_info_t *si = (const smb_info_t *)prv; + + /* we are only interested in reply packets */ + if (si->request) { + return 0; + } + /* if we havnt seen the request, just ignore it */ + if (!si->sip) { + return 0; + } + + if (si->cmd == 0xA0 && si->sip->extra_info_type == SMB_EI_NTI) { + smb_nt_transact_info_t *sti = (smb_nt_transact_info_t *)si->sip->extra_info; + + /*nt transaction*/ + if (sti) { + i = NT_SRT_TABLE_INDEX; + smb_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + add_srt_table_data(smb_srt_table, sti->subcmd, &si->sip->req_time, pinfo); + } + } else if (si->cmd == 0x32 && si->sip->extra_info_type == SMB_EI_T2I) { + smb_transact2_info_t *st2i = (smb_transact2_info_t *)si->sip->extra_info; + + /*transaction2*/ + if (st2i) { + i = TRANS2_SRT_TABLE_INDEX; + smb_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + add_srt_table_data(smb_srt_table, st2i->subcmd, &si->sip->req_time, pinfo); + } + } else { + i = SMB_SRT_TABLE_INDEX; + smb_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + add_srt_table_data(smb_srt_table, si->cmd, &si->sip->req_time, pinfo); + } + + return 1; + +} + /* * Macros for use in the main dissector routines for an SMB. */ @@ -20463,6 +20533,8 @@ proto_register_smb(void) smb_eo_tap = register_tap("smb_eo"); /* SMB Export Object tap */ register_dissector("smb", dissect_smb, proto_smb); + + register_srt_table(proto_smb, NULL, 3, smbstat_packet, smbstat_init, NULL); } void diff --git a/epan/dissectors/packet-smb2.c b/epan/dissectors/packet-smb2.c index 0d8c749b08..c5afb95ce0 100644 --- a/epan/dissectors/packet-smb2.c +++ b/epan/dissectors/packet-smb2.c @@ -35,6 +35,7 @@ #include <epan/prefs.h> #include <epan/expert.h> #include <epan/tap.h> +#include <epan/srt_table.h> #include <epan/aftypes.h> #include <epan/to_str.h> #include <epan/asn1.h> @@ -578,6 +579,53 @@ static const value_string smb2_negotiate_context_types[] = { { 0, NULL } }; +#define SMB2_NUM_PROCEDURES 256 + +static void +smb2stat_init(struct register_srt* srt _U_, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data) +{ + srt_stat_table *smb2_srt_table; + guint32 i; + + smb2_srt_table = init_srt_table("SMB2", NULL, srt_array, SMB2_NUM_PROCEDURES, "Commands", "smb2.cmd", gui_callback, gui_data, NULL); + for (i = 0; i < SMB2_NUM_PROCEDURES; i++) + { + init_srt_table_row(smb2_srt_table, i, val_to_str_ext_const(i, &smb2_cmd_vals_ext, "<unknown>")); + } +} + +static int +smb2stat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) +{ + guint i = 0; + srt_stat_table *smb2_srt_table; + srt_data_t *data = (srt_data_t *)pss; + const smb2_info_t *si=(const smb2_info_t *)prv; + + /* we are only interested in response packets */ + if(!(si->flags&SMB2_FLAGS_RESPONSE)){ + return 0; + } + /* if we haven't seen the request, just ignore it */ + if(!si->saved){ + return 0; + } + + /* SMB2 SRT can be very inaccurate in the presence of retransmissions. Retransmitted responses + * not only add additional (bogus) transactions but also the latency associated with them. + * This can greatly inflate the maximum and average SRT stats especially in the case of + * retransmissions triggered by the expiry of the rexmit timer (RTOs). Only calculating SRT + * for the last received response accomplishes this goal without requiring the TCP pref + * "Do not call subdissectors for error packets" to be set. */ + if ((si->saved->frame_req == 0) || (si->saved->frame_res != pinfo->fd->num)) + return 0; + + smb2_srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + add_srt_table_data(smb2_srt_table, si->opcode, &si->saved->req_time, pinfo); + return 1; +} + + static const gint8 zeros[NTLMSSP_KEY_LEN] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* ExportObject preferences variable */ @@ -8724,6 +8772,7 @@ proto_register_smb2(void) smb2_tap = register_tap("smb2"); smb2_eo_tap = register_tap("smb_eo"); /* SMB Export Object tap */ + register_srt_table(proto_smb2, NULL, 1, smb2stat_packet, smb2stat_init, NULL); } void diff --git a/epan/srt_table.c b/epan/srt_table.c new file mode 100644 index 0000000000..2fe4bafb35 --- /dev/null +++ b/epan/srt_table.c @@ -0,0 +1,322 @@ +/* srt_table.c + * Helper routines common to all SRT taps. + * + * 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 + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include <string.h> + +#include "packet_info.h" +#include "proto.h" +#include "srt_table.h" + +struct register_srt { + int proto_id; /* protocol id (0-indexed) */ + const char* tap_listen_str; /* string used in register_tap_listener (NULL to use protocol name) */ + int max_tables; /* Maximum number of tables expected (used by GUI to determine how to display tables) */ + tap_packet_cb srt_func; /* function to be called for new incoming packets for SRT */ + srt_init_cb srt_init; /* function to create dissector SRT tables */ + srt_param_handler_cb param_cb; /* function to parse parameters of optional arguments of tap string */ + void* param_data; /* Storage for tap parameter data */ +}; + +int get_srt_proto_id(register_srt_t* srt) +{ + if (!srt) { + return -1; + } + return srt->proto_id; +} + +const char* get_srt_tap_listener_name(register_srt_t* srt) +{ + return srt->tap_listen_str; +} + +int get_srt_max_tables(register_srt_t* srt) +{ + return srt->max_tables; +} + +tap_packet_cb get_srt_packet_func(register_srt_t* srt) +{ + return srt->srt_func; +} + +void set_srt_table_param_data(register_srt_t* srt, void* data) +{ + srt->param_data = data; +} + +void* get_srt_table_param_data(register_srt_t* srt) +{ + return srt->param_data; +} + +void +free_srt_table_data(srt_stat_table *rst) +{ + int i; + + for(i=0;i<rst->num_procs;i++){ + g_free(rst->procedures[i].procedure); + rst->procedures[i].procedure=NULL; + } + g_free(rst->filter_string); + rst->filter_string=NULL; + g_free(rst->procedures); + rst->procedures=NULL; + rst->num_procs=0; +} + +void free_srt_table(register_srt_t *srt, GArray* srt_array, srt_gui_free_cb gui_callback, void *callback_data) +{ + guint i = 0; + srt_stat_table *srt_table; + + for (i = 0; i < srt_array->len; i++) + { + srt_table = g_array_index(srt_array, srt_stat_table*, i); + + /* Give GUI the first crack at it before we clean up */ + if (gui_callback) + gui_callback(srt_table, callback_data); + + free_srt_table_data(srt_table); + } + + /* Clear the tables */ + g_array_set_size(srt_array, 0); + + /* Clear out any possible parameter data */ + g_free(srt->param_data); + srt->param_data = NULL; +} + +static void reset_srt_table_data(srt_stat_table *rst) +{ + int i; + + for(i=0;i<rst->num_procs;i++){ + time_stat_init(&rst->procedures[i].stats); + } +} + +void reset_srt_table(GArray* srt_array, srt_gui_reset_cb gui_callback, void *callback_data) +{ + guint i = 0; + srt_stat_table *srt_table; + + for (i = 0; i < srt_array->len; i++) + { + srt_table = g_array_index(srt_array, srt_stat_table*, i); + + /* Give GUI the first crack at it before we clean up */ + if (gui_callback) + gui_callback(srt_table, callback_data); + + reset_srt_table_data(srt_table); + } +} + +static GSList *registered_srt_tables = NULL; + +register_srt_t* get_srt_table_by_name(const char* name) +{ + guint i, size = g_slist_length(registered_srt_tables); + register_srt_t* srt; + GSList *slist; + + for (i = 0; i < size; i++) { + slist = g_slist_nth(registered_srt_tables, i); + srt = (register_srt_t*)slist->data; + + if (strcmp(name, proto_get_protocol_filter_name(srt->proto_id)) == 0) + return srt; + } + + return NULL; +} + +gchar* srt_table_get_tap_string(register_srt_t* srt) +{ + GString *cmd_str = g_string_new(proto_get_protocol_filter_name(srt->proto_id)); + g_string_append(cmd_str, ",srt"); + return g_string_free(cmd_str, FALSE); +} + +void srt_table_get_filter(register_srt_t* srt, const char *opt_arg, const char **filter, char** err) +{ + gchar* cmd_str = srt_table_get_tap_string(srt); + guint len = strlen(cmd_str); + guint pos = len; + *filter=NULL; + *err = NULL; + + if(!strncmp(opt_arg, cmd_str, len)) + { + if (srt->param_cb != NULL) + { + pos = srt->param_cb(srt, opt_arg + len, err); + if (*err != NULL) + return; + + if (pos > 0) + pos += len; + } + else + { + pos++; /* Adjust for comma */ + } + + if (opt_arg[pos] == ',') + { + *filter = opt_arg + pos; + } + } + + g_free(cmd_str); +} + +void srt_table_dissector_init(register_srt_t* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void *callback_data) +{ + srt->srt_init(srt, srt_array, gui_callback, callback_data); +} + +static gint +insert_sorted_by_table_name(gconstpointer aparam, gconstpointer bparam) +{ + const register_srt_t *a = (register_srt_t *)aparam; + const register_srt_t *b = (register_srt_t *)bparam; + + return g_ascii_strcasecmp(proto_get_protocol_short_name(find_protocol_by_id(a->proto_id)), proto_get_protocol_short_name(find_protocol_by_id(b->proto_id))); +} + +void +register_srt_table(const int proto_id, const char* tap_listener, int max_tables, tap_packet_cb srt_packet_func, srt_init_cb init_cb, srt_param_handler_cb param_cb) +{ + register_srt_t *table; + DISSECTOR_ASSERT(init_cb); + DISSECTOR_ASSERT(srt_packet_func); + + table = g_new(register_srt_t,1); + + table->proto_id = proto_id; + if (tap_listener != NULL) + table->tap_listen_str = tap_listener; + else + table->tap_listen_str = proto_get_protocol_filter_name(proto_id); + table->max_tables = max_tables; + table->srt_func = srt_packet_func; + table->srt_init = init_cb; + table->param_cb = param_cb; + table->param_data = NULL; + + registered_srt_tables = g_slist_insert_sorted(registered_srt_tables, table, insert_sorted_by_table_name); +} + +void srt_table_iterate_tables(GFunc func, gpointer user_data) +{ + g_slist_foreach(registered_srt_tables, func, user_data); +} + +srt_stat_table* +init_srt_table(const char *name, const char *short_name, GArray *srt_array, int num_procs, const char* proc_column_name, + const char *filter_string, srt_gui_init_cb gui_callback, void* gui_data, void* table_specific_data) +{ + int i; + srt_stat_table *table = g_new(srt_stat_table, 1); + + if(filter_string){ + table->filter_string=g_strdup(filter_string); + } else { + table->filter_string=NULL; + } + + table->name = name; + table->short_name = short_name; + table->proc_column_name = proc_column_name; + table->num_procs=num_procs; + table->procedures=(srt_procedure_t *)g_malloc(sizeof(srt_procedure_t)*num_procs); + for(i=0;i<num_procs;i++){ + time_stat_init(&table->procedures[i].stats); + table->procedures[i].index = 0; + table->procedures[i].procedure = NULL; + } + + g_array_insert_val(srt_array, srt_array->len, table); + + table->table_specific_data = table_specific_data; + + if (gui_callback) + gui_callback(table, gui_data); + + return table; +} + +void +init_srt_table_row(srt_stat_table *rst, int indx, const char *procedure) +{ + /* we have discovered a new procedure. Extend the table accordingly */ + if(indx>=rst->num_procs){ + int old_num_procs=rst->num_procs; + int i; + + rst->num_procs=indx+1; + rst->procedures=(srt_procedure_t *)g_realloc(rst->procedures, sizeof(srt_procedure_t)*(rst->num_procs)); + for(i=old_num_procs;i<rst->num_procs;i++){ + time_stat_init(&rst->procedures[i].stats); + rst->procedures[i].index = i; + rst->procedures[i].procedure=NULL; + } + } + rst->procedures[indx].index = indx; + rst->procedures[indx].procedure=g_strdup(procedure); +} + +void +add_srt_table_data(srt_stat_table *rst, int indx, const nstime_t *req_time, packet_info *pinfo) +{ + srt_procedure_t *rp; + nstime_t t, delta; + + g_assert(indx >= 0 && indx < rst->num_procs); + rp=&rst->procedures[indx]; + + /* calculate time delta between request and reply */ + t=pinfo->fd->abs_ts; + nstime_delta(&delta, &t, req_time); + + time_stat_update(&rp->stats, &delta, pinfo); +} + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/srt_table.h b/epan/srt_table.h new file mode 100644 index 0000000000..f2f9278f51 --- /dev/null +++ b/epan/srt_table.h @@ -0,0 +1,240 @@ +/* srt_table.h + * GUI independent helper routines common to all service response time (SRT) taps. + * + * 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 + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __SRT_TABLE_H__ +#define __SRT_TABLE_H__ + +#include "tap.h" +#include "timestats.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Procedure data */ +typedef struct _srt_procedure_t { + int index; + timestat_t stats; /**< stats */ + char *procedure; /**< column entries */ +} srt_procedure_t; + +/** Statistics table */ +typedef struct _srt_stat_table { + const char *name; /**< table name */ + const char *short_name; /**< tab name */ + char *filter_string; /**< append procedure number (%d) to this string + to create a display filter */ + int num_procs; /**< number of elements on procedures array */ + const char *proc_column_name; /**< procedure column name (if different from default) */ + srt_procedure_t *procedures;/**< the procedures array */ + void* table_specific_data; /** any dissector/table specific data needed for packet filtering */ +} srt_stat_table; + + +struct register_srt; +struct _srt_data_t; +typedef void (*srt_gui_init_cb)(srt_stat_table* rst, void* gui_data); +typedef void (*srt_gui_reset_cb)(srt_stat_table* rst, void* gui_data); +typedef void (*srt_gui_free_cb)(srt_stat_table* rst, void* gui_data); +typedef void (*srt_proc_table_cb)(srt_stat_table* rst, int indx, struct _srt_data_t* gui_data); +typedef void (*srt_init_cb)(struct register_srt* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void* gui_data); +typedef guint (*srt_param_handler_cb)(struct register_srt* srt, const char* opt_arg, char** err); + +/** tap data + */ +typedef struct _srt_data_t { + GArray *srt_array; /**< array of srt_stat_table */ + void *user_data; /**< "GUI" specifics (if necessary) */ +} srt_data_t; + +/** Structure for information about a registered service response table */ +typedef struct register_srt register_srt_t; + +/** Register the service response time table for the srt windows. + * + * @param proto_id is the protocol with conversation + * @param tap_listener string for register_tap_listener (NULL to just use protocol name) + * @param srt_packet_func the tap processing function + * @param init_cb initialize dissector SRT function + * @param param_cb handles dissection of parameters to optional arguments of tap string + */ +WS_DLL_PUBLIC void register_srt_table(const int proto_id, const char* tap_listener, int max_tables, + tap_packet_cb srt_packet_func, srt_init_cb init_cb, srt_param_handler_cb param_cb); + +/** Get protocol ID from SRT + * + * @param srt Registered SRT + * @return protocol id of SRT + */ +WS_DLL_PUBLIC int get_srt_proto_id(register_srt_t* srt); + +/** Get string for register_tap_listener call. Typically just dissector name + * + * @param srt Registered SRT + * @return string for register_tap_listener call + */ +WS_DLL_PUBLIC const char* get_srt_tap_listener_name(register_srt_t* srt); + +/** Get maximum number of tables from SRT + * + * @param srt Registered SRT + * @return maximum number of tables of SRT + */ +WS_DLL_PUBLIC int get_srt_max_tables(register_srt_t* srt); + +/** Get tap function handler from SRT + * + * @param srt Registered SRT + * @return tap function handler of SRT + */ +WS_DLL_PUBLIC tap_packet_cb get_srt_packet_func(register_srt_t* srt); + +/** Set parameter data from SRT parsed from tap string. Data will be + * freed on tap reset + * + * @param srt Registered SRT + * @param data Parameter data + */ +WS_DLL_PUBLIC void set_srt_table_param_data(register_srt_t* srt, void* data); + +/** Get parameter data from SRT + * + * @param srt Registered SRT + * @return Parameter data + */ +WS_DLL_PUBLIC void* get_srt_table_param_data(register_srt_t* srt); + +/** Get SRT table by its dissector name + * + * @param name dissector name to fetch. + * @return SRT table pointer or NULL. + */ +WS_DLL_PUBLIC register_srt_t* get_srt_table_by_name(const char* name); + +/** Free the srt table data. + * + * @param rst the srt table + */ +WS_DLL_PUBLIC void free_srt_table_data(srt_stat_table *rst); + +/** Free the srt table data. + * + * @param srt Registered SRT + * @param srt_array SRT table array + * @param gui_callback optional callback from GUI + * @param callback_data callback data needed for GUI + */ +WS_DLL_PUBLIC void free_srt_table(register_srt_t *srt, GArray* srt_array, srt_gui_free_cb gui_callback, void *callback_data); + +/** Reset ALL tables in the srt. + * + * @param srt_array SRT table array + * @param gui_callback optional callback from GUI + * @param callback_data callback data needed for GUI + */ +WS_DLL_PUBLIC void reset_srt_table(GArray* srt_array, srt_gui_reset_cb gui_callback, void *callback_data); + +/** Interator to walk srt tables and execute func + * Used for initialization + * + * @param func action to be performed on all converation tables + * @param user_data any data needed to help perform function + */ +WS_DLL_PUBLIC void srt_table_iterate_tables(GFunc func, gpointer user_data); + +/** Return filter used for register_tap_listener + * + * @param srt Registered SRT + * @param opt_arg passed in opt_arg from GUI + * @param filter returned filter string to be used for registering tap + * @param err returned error if opt_arg string can't be successfully parsed. Caller must free memory + */ +WS_DLL_PUBLIC void srt_table_get_filter(register_srt_t* srt, const char *opt_arg, const char **filter, char** err); + +/** "Common" initialization function for all GUIs + * + * @param srt Registered SRT + * @param srt_array SRT table array + * @param opt_arg passed in opt_arg from GUI + * @param filter returned filter string to be used for registering tap + */ +WS_DLL_PUBLIC void srt_table_dissector_init(register_srt_t* srt, GArray* srt_array, srt_gui_init_cb gui_callback, void *callback_data); + +/** Helper function to get tap string name + * Caller is responsible for freeing returned string + * + * @param srt Registered SRT + * @return SRT tap string + */ +WS_DLL_PUBLIC gchar* srt_table_get_tap_string(register_srt_t* srt); + +/** Init an srt table data structure. + * + * @param name the table name + * @param short_name the name used in a tab display + * @param srt_array the srt table array to add to + * @param num_procs number of procedures + * @param proc_column_name procedure column name (if different from "Procedure") + * @param filter_string table filter string or NULL + * @param gui_callback optional GUI callback + * @param gui_data GUI content data + * @return newly created srt_stat_table + */ +WS_DLL_PUBLIC srt_stat_table* init_srt_table(const char *name, const char *short_name, GArray *srt_array, int num_procs, const char* proc_column_name, + const char *filter_string, srt_gui_init_cb gui_callback, void* gui_data, void* table_specific_data); + +/** Init an srt table row data structure. + * + * @param rst the srt table + * @param index number of procedure + * @param procedure the procedures name + */ +WS_DLL_PUBLIC void init_srt_table_row(srt_stat_table *rst, int index, const char *procedure); + +/** Add srt response to table row data. + * + * @param rst the srt table + * @param index number of procedure + * @param req_time the time of the corresponding request + * @param pinfo current packet info + */ +WS_DLL_PUBLIC void add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, packet_info *pinfo); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __SRT_TABLE_H__ */ + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * ex: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ @@ -104,6 +104,7 @@ #include <epan/tap.h> #include <epan/stat_tap_ui.h> #include <epan/conversation_table.h> +#include <epan/srt_table.h> #include <epan/ex-opt.h> #if defined(HAVE_HEIMDAL_KERBEROS) || defined(HAVE_MIT_KERBEROS) @@ -1215,6 +1216,7 @@ DIAG_ON(cast-qual) register_all_tap_listeners(); conversation_table_set_gui_info(init_iousers); hostlist_table_set_gui_info(init_hostlists); + srt_table_iterate_tables(register_srt_tables, NULL); /* If invoked with the "-G" flag, we dump out information based on the argument to the "-G" flag; if no argument is specified, diff --git a/ui/cli/Makefile.common b/ui/cli/Makefile.common index 0d5ee86976..60d9fcbf40 100644 --- a/ui/cli/Makefile.common +++ b/ui/cli/Makefile.common @@ -38,14 +38,11 @@ GENERATOR_FILES = # sources for TShark taps TSHARK_TAP_SRC = \ - cli_service_response_time_table.c \ - tap-afpstat.c \ tap-ansi_astat.c \ tap-bootpstat.c \ tap-camelcounter.c \ tap-camelsrt.c \ tap-comparestat.c \ - tap-dcerpcstat.c \ tap-diameter-avp.c \ tap-endpoints.c \ tap-expert.c \ @@ -60,29 +57,24 @@ TSHARK_TAP_SRC = \ tap-icmpv6stat.c \ tap-iostat.c \ tap-iousers.c \ - tap-ldapstat.c \ tap-macltestat.c \ tap-megacostat.c \ tap-mgcpstat.c \ - tap-ncpstat.c \ tap-protocolinfo.c \ tap-protohierstat.c \ tap-radiusstat.c \ tap-rlcltestat.c \ tap-rpcprogs.c \ - tap-rpcstat.c \ tap-rtp.c \ tap-rtspstat.c \ - tap-scsistat.c \ tap-sctpchunkstat.c \ tap-sipstat.c \ tap-smbsids.c \ - tap-smb2stat.c \ - tap-smbstat.c \ + tap-srt.c \ tap-stats_tree.c \ tap-sv.c \ tap-wspstat.c noinst_HEADERS = \ tshark-tap.h \ - cli_service_response_time_table.h + tap-srt.h diff --git a/ui/cli/cli_service_response_time_table.c b/ui/cli/cli_service_response_time_table.c deleted file mode 100644 index d061069c88..0000000000 --- a/ui/cli/cli_service_response_time_table.c +++ /dev/null @@ -1,166 +0,0 @@ -/* cli_service_response_time_table.c - * TShark service_response_time_table based on GTK version by Ronnie Sahlberg - * Helper routines common to all service response time statistics - * tap. - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> - -#include "epan/packet_info.h" -#include "epan/value_string.h" - -#include "ui/cli/cli_service_response_time_table.h" - -#define NANOSECS_PER_SEC 1000000000 - - -void -init_srt_table(const char *name, srt_stat_table *rst, int num_procs, const char* proc_column_name, const char *filter_string) -{ - int i; - - if(filter_string){ - rst->filter_string=g_strdup(filter_string); - } else { - rst->filter_string=NULL; - } - - rst->name = name; - rst->proc_column_name = proc_column_name; - rst->num_procs=num_procs; - rst->procedures=(srt_procedure_t *)g_malloc(sizeof(srt_procedure_t)*num_procs); - for(i=0;i<num_procs;i++){ - time_stat_init(&rst->procedures[i].stats); - rst->procedures[i].index = 0; - rst->procedures[i].procedure = NULL; - } -} - -void -init_srt_table_row(srt_stat_table *rst, int indx, const char *procedure) -{ - /* we have discovered a new procedure. Extend the table accordingly */ - if(indx>=rst->num_procs){ - int old_num_procs=rst->num_procs; - int i; - - rst->num_procs=indx+1; - rst->procedures=(srt_procedure_t *)g_realloc(rst->procedures, sizeof(srt_procedure_t)*(rst->num_procs)); - for(i=old_num_procs;i<rst->num_procs;i++){ - time_stat_init(&rst->procedures[i].stats); - rst->procedures[i].index = i; - rst->procedures[i].procedure=NULL; - } - } - rst->procedures[indx].index = indx; - rst->procedures[indx].procedure=g_strdup(procedure); -} - -void -add_srt_table_data(srt_stat_table *rst, int indx, const nstime_t *req_time, packet_info *pinfo) -{ - srt_procedure_t *rp; - nstime_t t, delta; - - g_assert(indx >= 0 && indx < rst->num_procs); - rp=&rst->procedures[indx]; - - /* calculate time delta between request and reply */ - t=pinfo->fd->abs_ts; - nstime_delta(&delta, &t, req_time); - - time_stat_update(&rp->stats, &delta, pinfo); -} - -void -draw_srt_table_data(srt_stat_table *rst, gboolean draw_header, gboolean draw_footer) -{ - int i; - guint64 td; - guint64 sum; - - if (draw_header) { - printf("\n"); - printf("===================================================================\n"); - printf("%s SRT Statistics:\n", rst->name); - printf("Filter: %s\n", rst->filter_string ? rst->filter_string : ""); - } - - printf("Index %-22s Calls Min SRT Max SRT Avg SRT Sum SRT\n", (rst->proc_column_name != NULL) ? rst->proc_column_name : "Procedure"); - for(i=0;i<rst->num_procs;i++){ - /* ignore procedures with no calls (they don't have rows) */ - if(rst->procedures[i].stats.num==0){ - continue; - } - /* Scale the average SRT in units of 1us and round to the nearest us. - tot.secs is a time_t which may be 32 or 64 bits (or even floating) - depending uon the platform. After casting tot.secs to 64 bits, it - would take a capture with a duration of over 136 *years* to - overflow the secs portion of td. */ - td = ((guint64)(rst->procedures[i].stats.tot.secs))*NANOSECS_PER_SEC + rst->procedures[i].stats.tot.nsecs; - sum = (td + 500) / 1000; - td = ((td / rst->procedures[i].stats.num) + 500) / 1000; - - printf("%5u %-22s %6u %3d.%06d %3d.%06d %3d.%06d %3d.%06d\n", - i, rst->procedures[i].procedure, - rst->procedures[i].stats.num, - (int)rst->procedures[i].stats.min.secs, (rst->procedures[i].stats.min.nsecs+500)/1000, - (int)rst->procedures[i].stats.max.secs, (rst->procedures[i].stats.max.nsecs+500)/1000, - (int)(td/1000000), (int)(td%1000000), - (int)(sum/1000000), (int)(sum%1000000) - ); - } - - if (draw_footer) - printf("==================================================================\n"); -} - -void -free_srt_table_data(srt_stat_table *rst) -{ - int i; - - for(i=0;i<rst->num_procs;i++){ - g_free(rst->procedures[i].procedure); - rst->procedures[i].procedure=NULL; - } - g_free(rst->filter_string); - rst->filter_string=NULL; - g_free(rst->procedures); - rst->procedures=NULL; - rst->num_procs=0; -} - - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/cli_service_response_time_table.h b/ui/cli/cli_service_response_time_table.h deleted file mode 100644 index 4f6afe402f..0000000000 --- a/ui/cli/cli_service_response_time_table.h +++ /dev/null @@ -1,99 +0,0 @@ -/* cli_service_response_time_table.h - * TShark service_response_time_table based on GTK version by Ronnie Sahlberg - * Helper routines common to all service response time statistics - * tap. - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __CLI_SERVICE_RESPONSE_TIME_TABLE_H__ -#define __CLI_SERVICE_RESPONSE_TIME_TABLE_H__ - -#include "wsutil/nstime.h" -#include "epan/timestats.h" - -/** @file - * Helper routines common to all service response time statistics tap. - */ - -/** Procedure data */ -typedef struct _srt_procedure_t { - int index; - timestat_t stats; /**< stats */ - char *procedure; /**< column entries */ -} srt_procedure_t; - -/** Statistics table */ -typedef struct _srt_stat_table { - const char *name; /**< table name */ - char *filter_string; /**< append procedure number (%d) to this string - to create a display filter */ - int num_procs; /**< number of elements on procedures array */ - const char *proc_column_name; /**< procedure column name (if different from default) */ - srt_procedure_t *procedures;/**< the procedures array */ -} srt_stat_table; - -/** Init an srt table data structure. - * - * @param name the table name - * @param rst the srt table to init - * @param num_procs number of procedures - * @param proc_column_name procedure column name (if different from "Procedure") - * @param filter_string filter string or NULL - */ -void init_srt_table(const char *name, srt_stat_table *rst, int num_procs, const char* proc_column_name, const char *filter_string); - -/** Init an srt table row data structure. - * - * @param rst the srt table - * @param index number of procedure - * @param procedure the procedures name - */ -void init_srt_table_row(srt_stat_table *rst, int index, const char *procedure); - -/** Add srt response to table row data. This will not draw the data! - * - * @param rst the srt table - * @param index number of procedure - * @param req_time the time of the corresponding request - * @param pinfo current packet info - */ -void add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, packet_info *pinfo); - -/** Draw the srt table data. - * - * @param rst the srt table - * @param draw_header draw the header - * @param draw_footer draw the footer - */ -void draw_srt_table_data(srt_stat_table *rst, gboolean draw_header, gboolean draw_footer); - -/** Reset the srt table data. - * - * @param rst the srt table - */ -void reset_srt_table_data(srt_stat_table *rst); - -/** Free the srt table data. - * - * @param rst the srt table - */ -void free_srt_table_data(srt_stat_table *rst); - -#endif /* __CLI_SERVICE_RESPONSE_TIME_TABLE_H__ */ diff --git a/ui/cli/tap-afpstat.c b/ui/cli/tap-afpstat.c deleted file mode 100644 index afb8b12e47..0000000000 --- a/ui/cli/tap-afpstat.c +++ /dev/null @@ -1,133 +0,0 @@ -/* tap-afpstat.c - * Based on - * smbstat 2003 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <epan/packet_info.h> -#include <epan/tap.h> -#include <epan/stat_tap_ui.h> -#include <ui/cli/cli_service_response_time_table.h> -#include <epan/value_string.h> -#include <epan/dissectors/packet-afp.h> -#include "epan/timestats.h" - -void register_tap_listener_afpstat(void); - -#define AFP_NUM_PROCEDURES 256 - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _afpstat_t { - srt_stat_table afp_srt_table; -} afpstat_t; - -static int -afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) -{ - afpstat_t *ss = (afpstat_t *)pss; - const afp_request_val *request_val = (const afp_request_val *)prv; - - /* if we havnt seen the request, just ignore it */ - if (!request_val) { - return 0; - } - - add_srt_table_data(&ss->afp_srt_table, request_val->command, &request_val->req_time, pinfo); - - return 1; -} - -static void -afpstat_draw(void *pss) -{ - afpstat_t *ss = (afpstat_t *)pss; - - draw_srt_table_data(&ss->afp_srt_table, TRUE, TRUE); -} - - -static void -afpstat_init(const char *opt_arg, void *userdata _U_) -{ - afpstat_t *ss; - guint32 i; - const char *filter = NULL; - GString *error_string; - - if (!strncmp(opt_arg, "afp,srt,", 8)) { - filter = opt_arg+8; - } - - ss = g_new(afpstat_t, 1); - - init_srt_table("AFP", &ss->afp_srt_table, AFP_NUM_PROCEDURES, NULL, filter ? g_strdup(filter) : NULL); - for (i = 0; i < AFP_NUM_PROCEDURES; i++) - { - gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &CommandCode_vals_ext, "Unknown(%u)"); - init_srt_table_row(&ss->afp_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - error_string = register_tap_listener("afp", ss, filter, 0, NULL, afpstat_packet, afpstat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - free_srt_table_data(&ss->afp_srt_table); - g_free(ss); - - fprintf(stderr, "tshark: Couldn't register afp,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui afpstat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "afp,srt", - afpstat_init, - 0, - NULL -}; - -void -register_tap_listener_afpstat(void) -{ - register_stat_tap_ui(&afpstat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/tap-dcerpcstat.c b/ui/cli/tap-dcerpcstat.c deleted file mode 100644 index 0c1319d2b4..0000000000 --- a/ui/cli/tap-dcerpcstat.c +++ /dev/null @@ -1,317 +0,0 @@ -/* tap-dcerpcstat.c - * dcerpcstat 2002 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "epan/packet_info.h" -#include <epan/tap.h> -#include <epan/stat_tap_ui.h> -#include <epan/dissectors/packet-dcerpc.h> - -#define MICROSECS_PER_SEC 1000000 -#define NANOSECS_PER_SEC 1000000000 - -void register_tap_listener_dcerpcstat(void); - -/* used to keep track of statistics for a specific procedure */ -typedef struct _rpc_procedure_t { - const char *proc; - int num; - nstime_t min; - nstime_t max; - nstime_t tot; -} rpc_procedure_t; - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _rpcstat_t { - const char *prog; - char *filter; - e_guid_t uuid; - guint16 ver; - guint32 num_procedures; - rpc_procedure_t *procedures; -} rpcstat_t; - - - -static int -dcerpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri) -{ - const dcerpc_info *ri = (const dcerpc_info *)pri; - rpcstat_t *rs = (rpcstat_t *)prs; - nstime_t delta; - rpc_procedure_t *rp; - - if (!ri->call_data) { - return 0; - } - if (!ri->call_data->req_frame) { - /* we have not seen the request so we don't know the delta*/ - return 0; - } - if (ri->call_data->opnum >= rs->num_procedures) { - /* don't handle this since its outside of known table */ - return 0; - } - - /* we are only interested in reply packets */ - if (ri->ptype != PDU_RESP) { - return 0; - } - - /* we are only interested in certain program/versions */ - if ( (ri->call_data->uuid.data1 != rs->uuid.data1) - || (ri->call_data->uuid.data2 != rs->uuid.data2) - || (ri->call_data->uuid.data3 != rs->uuid.data3) - || (ri->call_data->uuid.data4[0] != rs->uuid.data4[0]) - || (ri->call_data->uuid.data4[1] != rs->uuid.data4[1]) - || (ri->call_data->uuid.data4[2] != rs->uuid.data4[2]) - || (ri->call_data->uuid.data4[3] != rs->uuid.data4[3]) - || (ri->call_data->uuid.data4[4] != rs->uuid.data4[4]) - || (ri->call_data->uuid.data4[5] != rs->uuid.data4[5]) - || (ri->call_data->uuid.data4[6] != rs->uuid.data4[6]) - || (ri->call_data->uuid.data4[7] != rs->uuid.data4[7]) - || (ri->call_data->ver != rs->ver)) { - return 0; - } - - rp = &(rs->procedures[ri->call_data->opnum]); - - /* calculate time delta between request and reply */ - nstime_delta(&delta, &pinfo->fd->abs_ts, &ri->call_data->req_time); - - if (rp->num == 0) { - rp->max.secs = delta.secs; - rp->max.nsecs = delta.nsecs; - } - - if (rp->num == 0) { - rp->min.secs = delta.secs; - rp->min.nsecs = delta.nsecs; - } - - if ( (delta.secs < rp->min.secs) - || ( (delta.secs == rp->min.secs) - && (delta.nsecs < rp->min.nsecs) ) ) { - rp->min.secs = delta.secs; - rp->min.nsecs = delta.nsecs; - } - - if ( (delta.secs > rp->max.secs) - || ( (delta.secs == rp->max.secs) - && (delta.nsecs > rp->max.nsecs) ) ) { - rp->max.secs = delta.secs; - rp->max.nsecs = delta.nsecs; - } - - rp->tot.secs += delta.secs; - rp->tot.nsecs += delta.nsecs; - if (rp->tot.nsecs > NANOSECS_PER_SEC) { - rp->tot.nsecs -= NANOSECS_PER_SEC; - rp->tot.secs++; - } - - rp->num++; - - return 1; -} - -static void -dcerpcstat_draw(void *prs) -{ - rpcstat_t *rs = (rpcstat_t *)prs; - guint32 i; - guint64 td; - printf("\n"); - printf("=======================================================================\n"); - printf("%s Major Version %u SRT Statistics:\n", rs->prog, rs->ver); - printf("Filter: %s\n",rs->filter ? rs->filter : ""); - printf("Procedure Calls Min SRT Max SRT Avg SRT\n"); - - for (i=0; i<rs->num_procedures; i++) { - /* Only display procs with non-zero calls */ - if (rs->procedures[i].num == 0) { - continue; - } - /* Scale the average SRT in units of 1us and round to the nearest us. */ - td = ((guint64)(rs->procedures[i].tot.secs)) * NANOSECS_PER_SEC + rs->procedures[i].tot.nsecs; - td = ((td / rs->procedures[i].num) + 500) / 1000; - - printf("%-31s %6d %3d.%06d %3d.%06d %3" G_GINT64_MODIFIER "u.%06" G_GINT64_MODIFIER "u\n", - rs->procedures[i].proc, - rs->procedures[i].num, - (int)(rs->procedures[i].min.secs), (rs->procedures[i].min.nsecs+500)/1000, - (int)(rs->procedures[i].max.secs), (rs->procedures[i].max.nsecs+500)/1000, - td/MICROSECS_PER_SEC, td%MICROSECS_PER_SEC - ); - } - printf("=======================================================================\n"); -} - - - -static void -dcerpcstat_init(const char *opt_arg, void *userdata _U_) -{ - rpcstat_t *rs; - guint32 i, max_procs; - dcerpc_sub_dissector *procs; - e_guid_t uuid; - guint d1, d2, d3, d40, d41, d42, d43, d44, d45, d46, d47; - int major, minor; - guint16 ver; - int pos = 0; - const char *filter = NULL; - GString *error_string; - - /* - * XXX - DCE RPC statistics are maintained only by major version, - * not by major and minor version, so the minor version number is - * ignored. - * - * Should we just stop supporting minor version numbers here? - * Or should we allow it to be omitted? Or should we keep - * separate statistics for different minor version numbers, - * and allow the minor version number to be omitted, and - * report aggregate statistics for all minor version numbers - * if it's omitted? - */ - if (sscanf(opt_arg, - "dcerpc,srt,%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x,%d.%d%n", - &d1, &d2, &d3, &d40, &d41, &d42, &d43, &d44, &d45, &d46, &d47, - &major, &minor, &pos) == 13) { - uuid.data1 = d1; - uuid.data2 = d2; - uuid.data3 = d3; - uuid.data4[0] = d40; - uuid.data4[1] = d41; - uuid.data4[2] = d42; - uuid.data4[3] = d43; - uuid.data4[4] = d44; - uuid.data4[5] = d45; - uuid.data4[6] = d46; - uuid.data4[7] = d47; - if (pos) { - filter = opt_arg+pos; - } else { - filter = NULL; - } - } else { - fprintf(stderr, "tshark: invalid \"-z dcerpc,srt,<uuid>,<major version>.<minor version>[,<filter>]\" argument\n"); - exit(1); - } - if (major < 0 || major > 65535) { - fprintf(stderr, "tshark: dcerpcstat_init() Major version number %d is invalid - must be positive and <= 65535\n", major); - exit(1); - } - if (minor < 0 || minor > 65535) { - fprintf(stderr, "tshark: dcerpcstat_init() Minor version number %d is invalid - must be positive and <= 65535\n", minor); - exit(1); - } - ver = major; - - rs = g_new(rpcstat_t, 1); - rs->prog = dcerpc_get_proto_name(&uuid, ver); - if (!rs->prog) { - g_free(rs); - fprintf(stderr, "tshark: dcerpcstat_init() Protocol with uuid:%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x v%u not supported\n", uuid.data1, uuid.data2, uuid.data3, uuid.data4[0], uuid.data4[1], uuid.data4[2], uuid.data4[3], uuid.data4[4], uuid.data4[5], uuid.data4[6], uuid.data4[7], ver); - exit(1); - } - procs = dcerpc_get_proto_sub_dissector(&uuid, ver); - rs->uuid = uuid; - rs->ver = ver; - - if (filter) { - rs->filter = g_strdup(filter); - } else { - rs->filter = NULL; - } - - for (i=0,max_procs=0; procs[i].name; i++) { - if (procs[i].num > max_procs) { - max_procs = procs[i].num; - } - } - rs->num_procedures = max_procs+1; - rs->procedures = (rpc_procedure_t *)g_malloc(sizeof(rpc_procedure_t)*(rs->num_procedures+1)); - for (i=0; i<rs->num_procedures; i++) { - int j; - rs->procedures[i].proc = "unknown"; - for (j=0; procs[j].name; j++) { - if (procs[j].num == i) { - rs->procedures[i].proc = procs[j].name; - } - } - rs->procedures[i].num = 0; - rs->procedures[i].min.secs = 0; - rs->procedures[i].min.nsecs = 0; - rs->procedures[i].max.secs = 0; - rs->procedures[i].max.nsecs = 0; - rs->procedures[i].tot.secs = 0; - rs->procedures[i].tot.nsecs = 0; - } - - error_string = register_tap_listener("dcerpc", rs, filter, 0, NULL, dcerpcstat_packet, dcerpcstat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - g_free(rs->procedures); - g_free(rs->filter); - g_free(rs); - - fprintf(stderr, "tshark: Couldn't register dcerpc,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui dcerpcstat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "dcerpc,srt", - dcerpcstat_init, - 0, - NULL -}; - -void -register_tap_listener_dcerpcstat(void) -{ - register_stat_tap_ui(&dcerpcstat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/tap-ldapstat.c b/ui/cli/tap-ldapstat.c deleted file mode 100644 index e0021059fc..0000000000 --- a/ui/cli/tap-ldapstat.c +++ /dev/null @@ -1,149 +0,0 @@ -/* tap-ldapstat.c - * - * Based on afpstat - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include <epan/packet_info.h> -#include <epan/tap.h> -#include <epan/stat_tap_ui.h> -#include <ui/cli/cli_service_response_time_table.h> -#include <epan/value_string.h> -#include <epan/dissectors/packet-ldap.h> -#include "epan/timestats.h" - -void register_tap_listener_ldapstat(void); - -#define LDAP_NUM_PROCEDURES 24 - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _ldapstat_t { - srt_stat_table ldap_srt_table; -} ldapstat_t; - -static int -ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - const ldap_call_response_t *ldap=(const ldap_call_response_t *)psi; - ldapstat_t *fs=(ldapstat_t *)pldap; - - /* we are only interested in reply packets */ - if(ldap->is_request){ - return 0; - } - /* if we havnt seen the request, just ignore it */ - if(!ldap->req_frame){ - return 0; - } - - /* only use the commands we know how to handle */ - switch(ldap->protocolOpTag){ - case LDAP_REQ_BIND: - case LDAP_REQ_SEARCH: - case LDAP_REQ_MODIFY: - case LDAP_REQ_ADD: - case LDAP_REQ_DELETE: - case LDAP_REQ_MODRDN: - case LDAP_REQ_COMPARE: - case LDAP_REQ_EXTENDED: - break; - default: - return 0; - } - - add_srt_table_data(&fs->ldap_srt_table, ldap->protocolOpTag, &ldap->req_time, pinfo); - return 1; -} - -static void -ldapstat_draw(void *pss) -{ - ldapstat_t *ss = (ldapstat_t *)pss; - - draw_srt_table_data(&ss->ldap_srt_table, TRUE, TRUE); -} - - -static void -ldapstat_init(const char *opt_arg, void *userdata _U_) -{ - ldapstat_t *ldap; - const char *filter = NULL; - GString *error_string; - int i; - - if (!strncmp(opt_arg, "ldap,srt,", 9)) { - filter = opt_arg+8; - } - - ldap = g_new(ldapstat_t,1); - - init_srt_table("LDAP", &ldap->ldap_srt_table, LDAP_NUM_PROCEDURES, NULL, filter ? g_strdup(filter) : NULL); - for (i = 0; i < LDAP_NUM_PROCEDURES; i++) - { - init_srt_table_row(&ldap->ldap_srt_table, i, val_to_str_const(i, ldap_procedure_names, "<unknown>")); - } - - error_string = register_tap_listener("ldap", ldap, filter, 0, NULL, ldapstat_packet, ldapstat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - free_srt_table_data(&ldap->ldap_srt_table); - g_free(ldap); - - fprintf(stderr, "tshark: Couldn't register ldap,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui ldapstat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "ldap,srt", - ldapstat_init, - 0, - NULL -}; - -void -register_tap_listener_ldapstat(void) -{ - register_stat_tap_ui(&ldapstat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/tap-ncpstat.c b/ui/cli/tap-ncpstat.c deleted file mode 100644 index 7455d3fadf..0000000000 --- a/ui/cli/tap-ncpstat.c +++ /dev/null @@ -1,440 +0,0 @@ -/* tap-ncpstat.c - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "epan/packet_info.h" -#include <epan/tap.h> -#include <epan/stat_tap_ui.h> -#include "epan/value_string.h" -#include <ui/cli/cli_service_response_time_table.h> -#include <epan/dissectors/packet-ncp-int.h> -#include "epan/timestats.h" - -void register_tap_listener_ncpstat(void); - -#define NCP_NUM_PROCEDURES 0 - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _ncpstat_t { - srt_stat_table ncp_srt_table; - srt_stat_table nds_srt_table; - srt_stat_table func_srt_table; - srt_stat_table sss_srt_table; - srt_stat_table nmas_srt_table; - srt_stat_table sub_17_srt_table; - srt_stat_table sub_21_srt_table; - srt_stat_table sub_22_srt_table; - srt_stat_table sub_23_srt_table; - srt_stat_table sub_32_srt_table; - srt_stat_table sub_34_srt_table; - srt_stat_table sub_35_srt_table; - srt_stat_table sub_36_srt_table; - srt_stat_table sub_86_srt_table; - srt_stat_table sub_87_srt_table; - srt_stat_table sub_89_srt_table; - srt_stat_table sub_90_srt_table; - srt_stat_table sub_92_srt_table; - srt_stat_table sub_94_srt_table; - srt_stat_table sub_104_srt_table; - srt_stat_table sub_111_srt_table; - srt_stat_table sub_114_srt_table; - srt_stat_table sub_123_srt_table; - srt_stat_table sub_131_srt_table; -} ncpstat_t; - -static int -ncpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) -{ - ncpstat_t *ss=(ncpstat_t *)pss; - const ncp_req_hash_value *request_val=(const ncp_req_hash_value *)prv; - gchar* tmp_str; - - /* if we haven't seen the request, just ignore it */ - if(!request_val || request_val->ncp_rec==0){ - return 0; - } - /* By Group */ - tmp_str = val_to_str_wmem(NULL, request_val->ncp_rec->group, ncp_group_vals, "Unknown(%u)"); - init_srt_table_row(&ss->ncp_srt_table, request_val->ncp_rec->group, tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->ncp_srt_table, request_val->ncp_rec->group, &request_val->req_frame_time, pinfo); - /* By NCP number without subfunction*/ - if (request_val->ncp_rec->subfunc==0) { - init_srt_table_row(&ss->func_srt_table, request_val->ncp_rec->func, request_val->ncp_rec->name); - add_srt_table_data(&ss->func_srt_table, request_val->ncp_rec->func, &request_val->req_frame_time, pinfo); - } - /* By Subfunction number */ - if(request_val->ncp_rec->subfunc!=0){ - if (request_val->ncp_rec->func==17) { - init_srt_table_row(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==21) { - init_srt_table_row(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==22) { - init_srt_table_row(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==23) { - init_srt_table_row(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==32) { - init_srt_table_row(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==34) { - init_srt_table_row(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==35) { - init_srt_table_row(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==36) { - init_srt_table_row(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==86) { - init_srt_table_row(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==87) { - init_srt_table_row(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==89) { - init_srt_table_row(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==90) { - init_srt_table_row(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==92) { - init_srt_table_row(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==94) { - init_srt_table_row(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==104) { - init_srt_table_row(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==111) { - init_srt_table_row(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==114) { - init_srt_table_row(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==123) { - init_srt_table_row(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==131) { - init_srt_table_row(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - } - /* By NDS verb */ - if (request_val->ncp_rec->func==0x68) { - tmp_str = val_to_str_wmem(NULL, request_val->nds_request_verb, ncp_nds_verb_vals, "Unknown(%u)"); - init_srt_table_row(&ss->nds_srt_table, (request_val->nds_request_verb), tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->nds_srt_table, (request_val->nds_request_verb), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==0x5c) { - tmp_str = val_to_str_wmem(NULL, request_val->req_nds_flags, sss_verb_enum, "Unknown(%u)"); - init_srt_table_row(&ss->sss_srt_table, (request_val->req_nds_flags), tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->sss_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==0x5e) { - tmp_str = val_to_str_wmem(NULL, request_val->req_nds_flags, nmas_subverb_enum, "Unknown(%u)"); - init_srt_table_row(&ss->nmas_srt_table, (request_val->req_nds_flags), tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->nmas_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo); - } - return 1; -} - -static void -ncpstat_draw_header(srt_stat_table *rst) -{ - printf("%s SRT Statistics:\n", rst->name); - printf("Filter: %s\n", rst->filter_string ? rst->filter_string : ""); -} - -static void -ncpstat_draw(void *pss) -{ - ncpstat_t *ss = (ncpstat_t *)pss; - - printf("\n"); - printf("===================================================================\n"); - - /* Tables were intentionally initialized to 0 rows, so only output tables with rows > 0 */ - if (ss->ncp_srt_table.num_procs > 0) { - ncpstat_draw_header(&ss->ncp_srt_table); - draw_srt_table_data(&ss->ncp_srt_table, FALSE, FALSE); - } - if (ss->func_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->func_srt_table); - draw_srt_table_data(&ss->func_srt_table, FALSE, FALSE); - } - if (ss->nds_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->nds_srt_table); - draw_srt_table_data(&ss->nds_srt_table, FALSE, FALSE); - } - if (ss->sss_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sss_srt_table); - draw_srt_table_data(&ss->sss_srt_table, FALSE, FALSE); - } - if (ss->nmas_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->nmas_srt_table); - draw_srt_table_data(&ss->nmas_srt_table, FALSE, FALSE); - } - if (ss->sub_17_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_17_srt_table); - draw_srt_table_data(&ss->sub_17_srt_table, FALSE, FALSE); - } - if (ss->sub_21_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_21_srt_table); - draw_srt_table_data(&ss->sub_21_srt_table, FALSE, FALSE); - } - if (ss->sub_22_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_22_srt_table); - draw_srt_table_data(&ss->sub_22_srt_table, FALSE, FALSE); - } - if (ss->sub_23_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_23_srt_table); - draw_srt_table_data(&ss->sub_23_srt_table, FALSE, FALSE); - } - if (ss->sub_32_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_32_srt_table); - draw_srt_table_data(&ss->sub_32_srt_table, FALSE, FALSE); - } - if (ss->sub_34_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_34_srt_table); - draw_srt_table_data(&ss->sub_34_srt_table, FALSE, FALSE); - } - if (ss->sub_35_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_35_srt_table); - draw_srt_table_data(&ss->sub_35_srt_table, FALSE, FALSE); - } - if (ss->sub_36_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_36_srt_table); - draw_srt_table_data(&ss->sub_36_srt_table, FALSE, FALSE); - } - if (ss->sub_86_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_86_srt_table); - draw_srt_table_data(&ss->sub_86_srt_table, FALSE, FALSE); - } - if (ss->sub_87_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_87_srt_table); - draw_srt_table_data(&ss->sub_87_srt_table, FALSE, FALSE); - } - if (ss->sub_89_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_89_srt_table); - draw_srt_table_data(&ss->sub_89_srt_table, FALSE, FALSE); - } - if (ss->sub_90_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_90_srt_table); - draw_srt_table_data(&ss->sub_90_srt_table, FALSE, FALSE); - } - if (ss->sub_92_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_92_srt_table); - draw_srt_table_data(&ss->sub_92_srt_table, FALSE, FALSE); - } - if (ss->sub_94_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_94_srt_table); - draw_srt_table_data(&ss->sub_94_srt_table, FALSE, FALSE); - } - if (ss->sub_104_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_104_srt_table); - draw_srt_table_data(&ss->sub_104_srt_table, FALSE, FALSE); - } - if (ss->sub_111_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_111_srt_table); - draw_srt_table_data(&ss->sub_111_srt_table, FALSE, FALSE); - } - if (ss->sub_114_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_114_srt_table); - draw_srt_table_data(&ss->sub_114_srt_table, FALSE, FALSE); - } - if (ss->sub_123_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_123_srt_table); - draw_srt_table_data(&ss->sub_123_srt_table, FALSE, FALSE); - } - if (ss->sub_131_srt_table.num_procs > 0) { - printf("\n"); - ncpstat_draw_header(&ss->sub_131_srt_table); - draw_srt_table_data(&ss->sub_131_srt_table, FALSE, FALSE); - } - - printf("===================================================================\n"); -} - - -static void -ncpstat_init(const char *opt_arg, void *userdata _U_) -{ - ncpstat_t *ss; - const char *filter = NULL; - GString *error_string; - - if (!strncmp(opt_arg, "ncp,srt,", 8)) { - filter = opt_arg + 8; - } - - ss = g_new(ncpstat_t, 1); - - /* Initialize all of the SRT tables with 0 rows. That way we can "filter" the drawing - function to only output tables with rows > 0 */ - init_srt_table("NCP", &ss->ncp_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.group"); - - /* NCP Functions */ - init_srt_table("NCP Functions without Subfunctions", &ss->func_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func"); - - /* NCP Subfunctions */ - init_srt_table("Subfunctions for NCP 17", &ss->sub_17_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==17 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 21", &ss->sub_21_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==21 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 22", &ss->sub_22_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==22 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 23", &ss->sub_23_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==23 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 32", &ss->sub_32_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==32 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 34", &ss->sub_34_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==34 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 35", &ss->sub_35_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==35 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 36", &ss->sub_36_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==36 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 86", &ss->sub_86_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==86 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 87", &ss->sub_87_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==87 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 89 (Extended NCP's with UTF8 Support)", &ss->sub_89_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==89 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 90", &ss->sub_90_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==90 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 92 (Secret Store Services)", &ss->sub_92_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==92 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 94 (Novell Modular Authentication Services)", &ss->sub_94_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==94 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 104", &ss->sub_104_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==104 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 111", &ss->sub_111_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==111 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 114", &ss->sub_114_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==114 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 123", &ss->sub_123_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==123 && ncp.subfunc"); - init_srt_table("Subfunctions for NCP 131", &ss->sub_131_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.func==131 && ncp.subfunc"); - - /* NDS Verbs */ - init_srt_table("NDS Verbs", &ss->nds_srt_table, NCP_NUM_PROCEDURES, NULL, "ncp.ndsverb"); - /* Secret Store Verbs */ - init_srt_table("Secret Store Verbs", &ss->sss_srt_table, NCP_NUM_PROCEDURES, NULL, "sss.subverb"); - /* NMAS Verbs */ - init_srt_table("NMAS Verbs", &ss->nmas_srt_table, NCP_NUM_PROCEDURES, NULL, "nmas.subverb"); - - error_string = register_tap_listener("ncp_srt", ss, filter, 0, NULL, ncpstat_packet, ncpstat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - free_srt_table_data(&ss->ncp_srt_table); - free_srt_table_data(&ss->nds_srt_table); - free_srt_table_data(&ss->func_srt_table); - free_srt_table_data(&ss->sss_srt_table); - free_srt_table_data(&ss->nmas_srt_table); - free_srt_table_data(&ss->sub_17_srt_table); - free_srt_table_data(&ss->sub_21_srt_table); - free_srt_table_data(&ss->sub_22_srt_table); - free_srt_table_data(&ss->sub_23_srt_table); - free_srt_table_data(&ss->sub_32_srt_table); - free_srt_table_data(&ss->sub_34_srt_table); - free_srt_table_data(&ss->sub_35_srt_table); - free_srt_table_data(&ss->sub_36_srt_table); - free_srt_table_data(&ss->sub_86_srt_table); - free_srt_table_data(&ss->sub_87_srt_table); - free_srt_table_data(&ss->sub_89_srt_table); - free_srt_table_data(&ss->sub_90_srt_table); - free_srt_table_data(&ss->sub_92_srt_table); - free_srt_table_data(&ss->sub_94_srt_table); - free_srt_table_data(&ss->sub_104_srt_table); - free_srt_table_data(&ss->sub_111_srt_table); - free_srt_table_data(&ss->sub_114_srt_table); - free_srt_table_data(&ss->sub_123_srt_table); - free_srt_table_data(&ss->sub_131_srt_table); - g_free(ss); - - fprintf(stderr, "tshark: Couldn't register ncp,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui ncpstat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "ncp,srt", - ncpstat_init, - 0, - NULL -}; - -void -register_tap_listener_ncpstat(void) -{ - register_stat_tap_ui(&ncpstat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 4 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=4 tabstop=4 noexpandtab: - * :indentSize=4:tabSize=4:noTabs=false: - */ diff --git a/ui/cli/tap-rpcstat.c b/ui/cli/tap-rpcstat.c deleted file mode 100644 index 61dbaadb4f..0000000000 --- a/ui/cli/tap-rpcstat.c +++ /dev/null @@ -1,257 +0,0 @@ -/* tap-rpcstat.c - * rpcstat 2002 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* This module provides rpc call/reply SRT statistics to tshark. - * It is only used by tshark and not wireshark. - * - * It serves as an example on how to use the tap api. - */ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "epan/packet_info.h" -#include <epan/tap.h> -#include <epan/stat_tap_ui.h> -#include <epan/dissectors/packet-rpc.h> -#include <ui/cli/cli_service_response_time_table.h> - - -void register_tap_listener_rpcstat(void); - - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _rpcstat_t { - const char *prog; - guint32 program; - guint32 version; - srt_stat_table rpc_srt_table; -} rpcstat_t; - - - - -/* This callback is invoked whenever the tap system has seen a packet we might - * be interested in. The function is to be used to only update internal state - * information in the *tapdata structure, and if there were state changes which - * requires the window to be redrawn, return 1 and (*draw) will be called - * sometime later. - * - * This function should be as lightweight as possible since it executes - * together with the normal wireshark dissectors. Try to push as much - * processing as possible into (*draw) instead since that function executes - * asynchronously and does not affect the main thread's performance. - * - * If it is possible, try to do all "filtering" explicitly as we do below in - * this example since you will get MUCH better performance than applying - * a similar display-filter in the register call. - * - * The third parameter is tap dependent. Since we register this one to the - * "rpc" tap, the third parameter type is rpc_call_info_value. - * - * The filtering we do is just to check the rpc_call_info_value struct that we - * were called for the proper program and version. We didn't apply a filter - * when we registered so we will be called for ALL rpc packets and not just - * the ones we are collecting stats for. - * - * function returns : - * 0: no updates, no need to call (*draw) later - * !0: state has changed, call (*draw) sometime later - */ -static int -rpcstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri) -{ - rpcstat_t *rs = (rpcstat_t *)prs; - const rpc_call_info_value *ri = (const rpc_call_info_value *)pri; - - if ((int)ri->proc >= rs->rpc_srt_table.num_procs) { - /* don't handle this since its outside of known table */ - return 0; - } - /* we are only interested in reply packets */ - if (ri->request) { - return 0; - } - /* we are only interested in certain program/versions */ - if ( (ri->prog != rs->program) || (ri->vers != rs->version) ) { - return 0; - } - - add_srt_table_data(&rs->rpc_srt_table, ri->proc, &ri->req_time, pinfo); - return 1; -} - -/* This callback is used when tshark wants us to draw/update our data to the - * output device. Since this is tshark, the only output is stdout. - * TShark will only call this callback once, which is when tshark has finished - * reading all packets and exits. - * If used with wireshark this may be called any time, perhaps once every 3 - * seconds or so. - * This function may even be called in parallel with (*reset) or (*draw), so - * make sure there are no races. The data in the rpcstat_t can thus change - * beneath us. Beware! - */ -static void -rpcstat_draw(void *prs) -{ - rpcstat_t *rs = (rpcstat_t *)prs; - - draw_srt_table_data(&rs->rpc_srt_table, TRUE, TRUE); -} - -static guint32 rpc_program = 0; -static guint32 rpc_version = 0; -static gint32 rpc_min_proc = -1; -static gint32 rpc_max_proc = -1; - -static void * -rpcstat_find_procs(gpointer *key, gpointer *value _U_, gpointer *user_data _U_) -{ - rpc_proc_info_key *k = (rpc_proc_info_key *)key; - - if (k->prog != rpc_program) { - return NULL; - } - if (k->vers != rpc_version) { - return NULL; - } - if (rpc_min_proc == -1) { - rpc_min_proc = k->proc; - rpc_max_proc = k->proc; - } - if ((gint32)k->proc < rpc_min_proc) { - rpc_min_proc = k->proc; - } - if ((gint32)k->proc > rpc_max_proc) { - rpc_max_proc = k->proc; - } - - return NULL; -} - - -/* When called, this function will create a new instance of rpcstat. - * - * program and version are which onc-rpc program/version we want to collect - * statistics for. - * - * This function is called from tshark when it parses the -z rpc, arguments and - * it creates a new instance to store statistics in and registers this new - * instance for the rpc tap. - */ -static void -rpcstat_init(const char *opt_arg, void *userdata _U_) -{ - rpcstat_t *rs; - int i; - int program, version; - int pos = 0; - const char *filter = NULL; - GString *error_string; - static char table_name[100]; - - if (sscanf(opt_arg, "rpc,srt,%d,%d,%n", &program, &version, &pos) == 2) { - if (pos) { - filter = opt_arg+pos; - } - } else { - fprintf(stderr, "tshark: invalid \"-z rpc,srt,<program>,<version>[,<filter>]\" argument\n"); - exit(1); - } - - rs = g_new(rpcstat_t, 1); - rs->prog = rpc_prog_name(program); - rs->program = program; - rs->version = version; - - rpc_program = program; - rpc_version = version; - rpc_min_proc = -1; - rpc_max_proc = -1; - g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL); - if (rpc_min_proc == -1) { - fprintf(stderr, "tshark: Invalid -z rpc,srt,%u,%u\n", rpc_program, rpc_version); - fprintf(stderr, " Program:%u version:%u isn't supported by tshark.\n", rpc_program, rpc_version); - exit(1); - } - - g_snprintf(table_name, sizeof(table_name), "%s Version %u", rs->prog, rs->version); - init_srt_table(table_name, &rs->rpc_srt_table, rpc_max_proc+1, NULL, filter ? g_strdup(filter) : NULL); - for (i = 0; i < rs->rpc_srt_table.num_procs; i++) - { - init_srt_table_row(&rs->rpc_srt_table, i, rpc_proc_name(program, version, i)); - } - -/* It is possible to create a filter and attach it to the callbacks. Then the - * callbacks would only be invoked if the filter matched. - * - * Evaluating filters is expensive and if we can avoid it and not use them, - * then we gain performance. - * - * In this case, we do the filtering for protocol and version inside the - * callback itself but use whatever filter the user provided. - * (Perhaps the user only wants the stats for nis+ traffic for certain objects?) - */ - - error_string = register_tap_listener("rpc", rs, filter, 0, NULL, rpcstat_packet, rpcstat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - free_srt_table_data(&rs->rpc_srt_table); - g_free(rs); - - fprintf(stderr, "tshark: Couldn't register rpc,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui rpcstat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "rpc,srt", - rpcstat_init, - 0, - NULL -}; - -void -register_tap_listener_rpcstat(void) -{ - register_stat_tap_ui(&rpcstat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/tap-scsistat.c b/ui/cli/tap-scsistat.c deleted file mode 100644 index 4465919793..0000000000 --- a/ui/cli/tap-scsistat.c +++ /dev/null @@ -1,185 +0,0 @@ -/* tap-scsistat.c 2010 Chris Costa and Cal Turney - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> - -#include <string.h> -#include <epan/packet_info.h> -#include <epan/stat_tap_ui.h> -#include <ui/cli/cli_service_response_time_table.h> -#include <epan/tap.h> -#include <epan/conversation.h> -#include <epan/dissectors/packet-scsi.h> -#include <epan/dissectors/packet-scsi-sbc.h> -#include <epan/dissectors/packet-scsi-ssc.h> -#include <epan/dissectors/packet-scsi-smc.h> -#include <epan/dissectors/packet-scsi-osd.h> -#include <epan/dissectors/packet-scsi-mmc.h> - -void register_tap_listener_scsistat(void); - -#define SCSI_NUM_PROCEDURES 256 - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _scsistat_t { - guint8 cmdset; - const char *prog; - srt_stat_table scsi_srt_table; -} scsistat_t; - -static int -scsistat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri) -{ - scsistat_t *rs = (scsistat_t *)prs; - const scsi_task_data_t *ri = (const scsi_task_data_t *)pri; - - /* we are only interested in response packets */ - if (ri->type != SCSI_PDU_TYPE_RSP) { - return 0; - } - /* we are only interested in a specific commandset */ - if ( (!ri->itl) || ((ri->itl->cmdset&SCSI_CMDSET_MASK) != rs->cmdset) ) { - return 0; - } - /* check that the opcode looks sane */ - if ( (!ri->itlq) || (ri->itlq->scsi_opcode > 255) ) { - return 0; - } - - add_srt_table_data(&rs->scsi_srt_table, ri->itlq->scsi_opcode, &ri->itlq->fc_time, pinfo); - return 1; -} - -static void -scsistat_draw(void *prs) -{ - scsistat_t *rs = (scsistat_t *)prs; - - draw_srt_table_data(&rs->scsi_srt_table, TRUE, TRUE); -} - -static void -scsistat_init(const char *opt_arg, void* userdata _U_) -{ - scsistat_t *rs; - guint32 i; - int program, pos; - const char *filter = NULL; - value_string_ext *cdbnames_ext; - GString *error_string; - const char *table_name; - - pos = 0; - if (sscanf(opt_arg, "scsi,srt,%d,%n", &program, &pos) == 1) { - if (pos) { - filter = opt_arg+pos; - } - } else { - fprintf(stderr, "tshark: invalid \"-z scsi,srt,<cmdset>[,<filter>]\" argument\n"); - exit(1); - } - - rs = g_new(scsistat_t,1); - rs->cmdset = program; - - switch(program) { - case SCSI_DEV_SBC: - rs->prog = "SBC (disk)"; - table_name = "SCSI SBC (disk)"; - cdbnames_ext = &scsi_sbc_vals_ext; - break; - case SCSI_DEV_SSC: - rs->prog = "SSC (tape)"; - table_name = "SCSI SSC (tape)"; - cdbnames_ext = &scsi_ssc_vals_ext; - break; - case SCSI_DEV_CDROM: - rs->prog = "MMC (cd/dvd)"; - table_name = "SCSI MMC (cd/dvd)"; - cdbnames_ext = &scsi_mmc_vals_ext; - break; - case SCSI_DEV_SMC: - rs->prog = "SMC (tape robot)"; - table_name = "SCSI SMC (tape robot)"; - cdbnames_ext = &scsi_smc_vals_ext; - break; - case SCSI_DEV_OSD: - rs->prog = "OSD (object based)"; - table_name = "SCSI OSD (object based)"; - cdbnames_ext = &scsi_osd_vals_ext; - break; - default: - /* Default to the SBC (disk), since this is what EMC SCSI seem to always be */ - rs->cmdset = 0; - rs->prog = "SBC (disk)"; - table_name = "SCSI SBC (disk)"; - cdbnames_ext = &scsi_sbc_vals_ext; - break; - } - - init_srt_table(table_name, &rs->scsi_srt_table, SCSI_NUM_PROCEDURES, NULL, filter ? g_strdup(filter) : NULL); - for (i = 0; i < SCSI_NUM_PROCEDURES; i++) - { - init_srt_table_row(&rs->scsi_srt_table, i, val_to_str_ext_const(i, cdbnames_ext, "<unknown>")); - } - - error_string = register_tap_listener("scsi", rs, filter, 0, NULL, scsistat_packet, scsistat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - free_srt_table_data(&rs->scsi_srt_table); - g_free(rs); - - fprintf(stderr, "tshark: Couldn't register scsi,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui scsistat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "scsi,srt", - scsistat_init, - 0, - NULL -}; - -void -register_tap_listener_scsistat(void) -{ - register_stat_tap_ui(&scsistat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/tap-smb2stat.c b/ui/cli/tap-smb2stat.c deleted file mode 100644 index fef21505c8..0000000000 --- a/ui/cli/tap-smb2stat.c +++ /dev/null @@ -1,144 +0,0 @@ -/* tap-smb2stat.c - * Based off if smbstat by Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "epan/packet_info.h" -#include <epan/tap.h> -#include <epan/stat_tap_ui.h> -#include "epan/value_string.h" -#include <ui/cli/cli_service_response_time_table.h> -#include <epan/dissectors/packet-smb2.h> -#include "epan/timestats.h" - -void register_tap_listener_smbstat(void); - -#define SMB2_NUM_PROCEDURES 256 - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _smb2stat_t { - srt_stat_table smb2_srt_table; -} smb2stat_t; - -static int -smb2stat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - smb2stat_t *ss=(smb2stat_t *)pss; - const smb2_info_t *si=(const smb2_info_t *)psi; - - /* we are only interested in response packets */ - if(!(si->flags&SMB2_FLAGS_RESPONSE)){ - return 0; - } - /* if we haven't seen the request, just ignore it */ - if(!si->saved){ - return 0; - } - /* SMB2 SRT can be very inaccurate in the presence of retransmissions. Retransmitted responses - * not only add additional (bogus) transactions but also the latency associated with them. - * This can greatly inflate the maximum and average SRT stats especially in the case of - * retransmissions triggered by the expiry of the rexmit timer (RTOs). Only calculating SRT - * for the last received response accomplishes this goal without requiring the TCP pref - * "Do not call subdissectors for error packets" to be set. */ - if(si->saved->frame_req - && si->saved->frame_res==pinfo->fd->num) - add_srt_table_data(&ss->smb2_srt_table, si->opcode, &si->saved->req_time, pinfo); - else - return 0; - - return 1; - -} - -static void -smb2stat_draw(void *pss) -{ - smb2stat_t *ss = (smb2stat_t *)pss; - - draw_srt_table_data(&ss->smb2_srt_table, TRUE, TRUE); -} - - -static void -smb2stat_init(const char *opt_arg, void *userdata _U_) -{ - smb2stat_t *ss; - guint32 i; - const char *filter = NULL; - GString *error_string; - - if (!strncmp(opt_arg, "smb2,srt,", 8)) { - filter = opt_arg + 8; - } - - ss = g_new(smb2stat_t, 1); - - init_srt_table("SMB2", &ss->smb2_srt_table, SMB2_NUM_PROCEDURES, "Commands", filter ? g_strdup(filter) : NULL); - for (i = 0; i < SMB2_NUM_PROCEDURES; i++) - { - init_srt_table_row(&ss->smb2_srt_table, i, val_to_str_ext_const(i, &smb2_cmd_vals_ext, "<unknown>")); - } - - error_string = register_tap_listener("smb2", ss, filter, 0, NULL, smb2stat_packet, smb2stat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - free_srt_table_data(&ss->smb2_srt_table); - g_free(ss); - - fprintf(stderr, "tshark: Couldn't register smb2,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui smb2stat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "smb2,srt", - smb2stat_init, - 0, - NULL -}; - -void -register_tap_listener_smb2stat(void) -{ - register_stat_tap_ui(&smb2stat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/tap-smbstat.c b/ui/cli/tap-smbstat.c deleted file mode 100644 index d5f9150c2d..0000000000 --- a/ui/cli/tap-smbstat.c +++ /dev/null @@ -1,162 +0,0 @@ -/* tap-smbstat.c - * smbstat 2003 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "epan/packet_info.h" -#include <epan/tap.h> -#include <epan/stat_tap_ui.h> -#include "epan/value_string.h" -#include <ui/cli/cli_service_response_time_table.h> -#include <epan/dissectors/packet-smb.h> -#include "epan/timestats.h" - -void register_tap_listener_smbstat(void); - -#define SMB_NUM_PROCEDURES 256 - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _smbstat_t { - srt_stat_table smb_srt_table; - srt_stat_table trans2_srt_table; - srt_stat_table nt_srt_table; -} smbstat_t; - -static int -smbstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - smbstat_t *ss = (smbstat_t *)pss; - const smb_info_t *si = (const smb_info_t *)psi; - - /* we are only interested in reply packets */ - if (si->request) { - return 0; - } - /* if we havnt seen the request, just ignore it */ - if (!si->sip) { - return 0; - } - - if (si->cmd == 0xA0 && si->sip->extra_info_type == SMB_EI_NTI) { - smb_nt_transact_info_t *sti = (smb_nt_transact_info_t *)si->sip->extra_info; - - /*nt transaction*/ - if (sti) { - add_srt_table_data(&ss->nt_srt_table, sti->subcmd, &si->sip->req_time, pinfo); - } - } else if (si->cmd == 0x32 && si->sip->extra_info_type == SMB_EI_T2I) { - smb_transact2_info_t *st2i = (smb_transact2_info_t *)si->sip->extra_info; - - /*transaction2*/ - if (st2i) { - add_srt_table_data(&ss->trans2_srt_table, st2i->subcmd, &si->sip->req_time, pinfo); - } - } else { - add_srt_table_data(&ss->smb_srt_table,si->cmd, &si->sip->req_time, pinfo); - } - - return 1; -} - -static void -smbstat_draw(void *pss) -{ - smbstat_t *ss = (smbstat_t *)pss; - - draw_srt_table_data(&ss->smb_srt_table, TRUE, FALSE); - printf("\n"); - draw_srt_table_data(&ss->trans2_srt_table, FALSE, FALSE); - printf("\n"); - draw_srt_table_data(&ss->nt_srt_table, FALSE, TRUE); -} - - -static void -smbstat_init(const char *opt_arg, void *userdata _U_) -{ - smbstat_t *ss; - guint32 i; - const char *filter = NULL; - GString *error_string; - - if (!strncmp(opt_arg, "smb,srt,", 8)) { - filter = opt_arg + 8; - } - - ss = g_new(smbstat_t, 1); - - init_srt_table("SMB", &ss->smb_srt_table, SMB_NUM_PROCEDURES, "Commands", filter ? g_strdup(filter) : NULL); - init_srt_table("SMB", &ss->trans2_srt_table, SMB_NUM_PROCEDURES, "Transaction2 Commands", filter ? g_strdup(filter) : NULL); - init_srt_table("SMB", &ss->nt_srt_table, SMB_NUM_PROCEDURES, "NT Transaction Commands", filter ? g_strdup(filter) : NULL); - for (i = 0; i < SMB_NUM_PROCEDURES; i++) - { - init_srt_table_row(&ss->smb_srt_table, i, val_to_str_ext_const(i, &smb_cmd_vals_ext, "<unknown>")); - init_srt_table_row(&ss->trans2_srt_table, i, val_to_str_ext_const(i, &trans2_cmd_vals_ext, "<unknown>")); - init_srt_table_row(&ss->nt_srt_table, i, val_to_str_ext_const(i, &nt_cmd_vals_ext, "<unknown>")); - } - - error_string = register_tap_listener("smb", ss, filter, 0, NULL, smbstat_packet, smbstat_draw); - if (error_string) { - /* error, we failed to attach to the tap. clean up */ - free_srt_table_data(&ss->smb_srt_table); - free_srt_table_data(&ss->trans2_srt_table); - free_srt_table_data(&ss->nt_srt_table); - g_free(ss); - - fprintf(stderr, "tshark: Couldn't register smb,srt tap: %s\n", - error_string->str); - g_string_free(error_string, TRUE); - exit(1); - } -} - -static stat_tap_ui smbstat_ui = { - REGISTER_STAT_GROUP_GENERIC, - NULL, - "smb,srt", - smbstat_init, - 0, - NULL -}; - -void -register_tap_listener_smbstat(void) -{ - register_stat_tap_ui(&smbstat_ui, NULL); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/cli/tap-srt.c b/ui/cli/tap-srt.c new file mode 100644 index 0000000000..ec9084021d --- /dev/null +++ b/ui/cli/tap-srt.c @@ -0,0 +1,196 @@ +/* tap-srt.c + * + * 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 + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" + +#include <stdio.h> +#include <stdlib.h> + +#include <string.h> +#include <epan/packet.h> +#include <epan/timestamp.h> +#include <epan/stat_tap_ui.h> +#include <ui/cli/tshark-tap.h> +#include <ui/cli/tap-srt.h> + +#define NANOSECS_PER_SEC 1000000000 + +typedef struct _srt_t { + const char *type; + const char *filter; + srt_data_t data; +} srt_t; + +void +draw_srt_table_data(srt_stat_table *rst, gboolean draw_footer) +{ + int i; + guint64 td; + guint64 sum; + + if (rst->num_procs > 0) { + printf("Filter: %s\n", rst->filter_string ? rst->filter_string : ""); + printf("Index %-22s Calls Min SRT Max SRT Avg SRT Sum SRT\n", (rst->proc_column_name != NULL) ? rst->proc_column_name : "Procedure"); + } + for(i=0;i<rst->num_procs;i++){ + /* ignore procedures with no calls (they don't have rows) */ + if(rst->procedures[i].stats.num==0){ + continue; + } + /* Scale the average SRT in units of 1us and round to the nearest us. + tot.secs is a time_t which may be 32 or 64 bits (or even floating) + depending uon the platform. After casting tot.secs to 64 bits, it + would take a capture with a duration of over 136 *years* to + overflow the secs portion of td. */ + td = ((guint64)(rst->procedures[i].stats.tot.secs))*NANOSECS_PER_SEC + rst->procedures[i].stats.tot.nsecs; + sum = (td + 500) / 1000; + td = ((td / rst->procedures[i].stats.num) + 500) / 1000; + + printf("%5u %-22s %6u %3d.%06d %3d.%06d %3d.%06d %3d.%06d\n", + i, rst->procedures[i].procedure, + rst->procedures[i].stats.num, + (int)rst->procedures[i].stats.min.secs, (rst->procedures[i].stats.min.nsecs+500)/1000, + (int)rst->procedures[i].stats.max.secs, (rst->procedures[i].stats.max.nsecs+500)/1000, + (int)(td/1000000), (int)(td%1000000), + (int)(sum/1000000), (int)(sum%1000000) + ); + } + + if (draw_footer) + printf("==================================================================\n"); +} + +static void +srt_draw(void *arg) +{ + guint i = 0; + srt_data_t* data = (srt_data_t*)arg; + srt_t *ui = (srt_t *)data->user_data; + srt_stat_table *srt_table; + gboolean need_newline = FALSE; + + printf("\n"); + printf("===================================================================\n"); + printf("%s SRT Statistics:\n", ui->type); + + srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + draw_srt_table_data(srt_table, data->srt_array->len == 1); + if (srt_table->num_procs > 0) { + need_newline = TRUE; + } + + for (i = 1; i < data->srt_array->len; i++) + { + if (need_newline) + { + printf("\n"); + need_newline = FALSE; + } + srt_table = g_array_index(data->srt_array, srt_stat_table*, i); + draw_srt_table_data(srt_table, i == data->srt_array->len-1); + if (srt_table->num_procs > 0) { + need_newline = TRUE; + } + } +} + +static GArray* global_srt_array; + +static void +init_srt_tables(register_srt_t* srt, const char *filter) +{ + srt_t *ui; + GString *error_string; + + ui = g_new0(srt_t, 1); + ui->type = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))); + ui->filter = g_strdup(filter); + ui->data.srt_array = global_srt_array; + ui->data.user_data = ui; + + error_string = register_tap_listener(get_srt_tap_listener_name(srt), &ui->data, filter, 0, NULL, get_srt_packet_func(srt), srt_draw); + if (error_string) { + free_srt_table(srt, global_srt_array, NULL, NULL); + g_free(ui); + fprintf(stderr, "tshark: Couldn't register srt tap: %s\n", error_string->str); + g_string_free(error_string, TRUE); + exit(1); + } +} + +static void +dissector_srt_init(const char *opt_arg, void* userdata) +{ + register_srt_t *srt = (register_srt_t*)userdata; + const char *filter=NULL; + char* err; + + srt_table_get_filter(srt, opt_arg, &filter, &err); + if (err != NULL) + { + gchar* cmd_str = srt_table_get_tap_string(srt); + fprintf(stderr, "tshark: invalid \"-z %s,%s\" argument\n", cmd_str, err); + g_free(cmd_str); + g_free(err); + exit(1); + } + + /* Need to create the SRT array now */ + global_srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*)); + + srt_table_dissector_init(srt, global_srt_array, NULL, NULL); + init_srt_tables(srt, filter); +} + +/* Set GUI fields for register_srt list */ +void +register_srt_tables(gpointer data, gpointer user_data _U_) +{ + register_srt_t *srt = (register_srt_t*)data; + const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))); + stat_tap_ui ui_info; + + /* XXX - CAMEL dissector hasn't been converted over due seemingly different tap packet + handling functions. So let the existing TShark CAMEL tap keep its registration */ + if (strcmp(short_name, "CAMEL") == 0) + return; + + ui_info.group = REGISTER_STAT_GROUP_RESPONSE_TIME; + ui_info.title = NULL; /* construct this from the protocol info? */ + ui_info.cli_string = srt_table_get_tap_string(srt); + ui_info.tap_init_cb = dissector_srt_init; + ui_info.nparams = 0; + ui_info.params = NULL; + register_stat_tap_ui(&ui_info, srt); +} + +/* + * Editor modelines - http://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: t + * End: + * + * vi: set shiftwidth=8 tabstop=8 noexpandtab: + * :indentSize=8:tabSize=8:noTabs=false: + */ diff --git a/ui/cli/tap-srt.h b/ui/cli/tap-srt.h new file mode 100644 index 0000000000..95f271ed55 --- /dev/null +++ b/ui/cli/tap-srt.h @@ -0,0 +1,43 @@ +/* tap-srt.h + * TShark service_response_time_table based on GTK version by Ronnie Sahlberg + * Helper routines common to all service response time statistics + * tap. + * + * 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 + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __TAP_SRT_H__ +#define __TAP_SRT_H__ + +#include "wsutil/nstime.h" +#include "epan/srt_table.h" + +/** @file + * Helper routines common to all service response time statistics tap. + */ + +/** Draw the srt table data. + * + * @param rst the srt table + * @param draw_header draw the header + * @param draw_footer draw the footer + */ +void draw_srt_table_data(srt_stat_table *rst, gboolean draw_footer); + +#endif /* __TAP_SRT_H__ */ diff --git a/ui/cli/tshark-tap.h b/ui/cli/tshark-tap.h index 2c96cfbd75..3de71ddb18 100644 --- a/ui/cli/tshark-tap.h +++ b/ui/cli/tshark-tap.h @@ -26,5 +26,6 @@ extern void init_iousers(struct register_ct* ct, const char *filter); extern void init_hostlists(struct register_ct* ct, const char *filter); +extern void register_srt_tables(gpointer data, gpointer user_data); #endif /* __TSHARK_TAP_H__ */ diff --git a/ui/gtk/CMakeLists.txt b/ui/gtk/CMakeLists.txt index 6a02968a8e..147bad3271 100644 --- a/ui/gtk/CMakeLists.txt +++ b/ui/gtk/CMakeLists.txt @@ -195,37 +195,30 @@ if(ENABLE_EXTCAP) endif() set(WIRESHARK_TAP_SRC - afp_stat.c ansi_a_stat.c ansi_map_stat.c bootp_stat.c camel_counter.c - camel_srt.c compare_stat.c dcerpc_stat.c - diameter_stat.c expert_comp_dlg.c - fc_stat.c flow_graph.c funnel_stat.c gsm_a_stat.c gsm_map_stat.c gsm_map_summary.c - gtp_stat.c h225_counter.c h225_ras_srt.c iax2_analysis.c io_stat.c lbm_stream_dlg.c lbm_uimflow_dlg.c - ldap_stat.c mac_lte_stat_dlg.c mcast_stream_dlg.c megaco_stat.c mgcp_stat.c mtp3_stat.c mtp3_summary.c - ncp_stat.c radius_stat.c rlc_lte_graph.c rlc_lte_stat_dlg.c @@ -233,14 +226,11 @@ set(WIRESHARK_TAP_SRC rpc_stat.c rtp_analysis.c rtp_stream_dlg.c - scsi_stat.c sctp_assoc_analyse.c sctp_chunk_stat.c sctp_chunk_stat_dlg.c sctp_stat_dlg.c sip_stat.c - smb_stat.c - smb2_stat.c stats_tree_stat.c tcp_graph.c voip_calls_dlg.c diff --git a/ui/gtk/Makefile.common b/ui/gtk/Makefile.common index 51434af4f9..b401155b0e 100644 --- a/ui/gtk/Makefile.common +++ b/ui/gtk/Makefile.common @@ -145,38 +145,31 @@ prefs_layout.c: layouts.h stock_icons.c: stock_icons.h toolbar_icons.h wsicon.h WIRESHARK_TAP_SRC = \ - afp_stat.c \ ansi_a_stat.c \ ansi_map_stat.c \ bootp_stat.c \ camel_counter.c \ - camel_srt.c \ compare_stat.c \ dcerpc_stat.c \ - diameter_stat.c \ expert_comp_dlg.c \ export_pdu_dlg.c \ - fc_stat.c \ flow_graph.c \ funnel_stat.c \ gsm_a_stat.c \ gsm_map_stat.c \ gsm_map_summary.c \ - gtp_stat.c \ h225_counter.c \ h225_ras_srt.c \ iax2_analysis.c \ io_stat.c \ lbm_stream_dlg.c \ lbm_uimflow_dlg.c \ - ldap_stat.c \ mac_lte_stat_dlg.c \ mcast_stream_dlg.c \ megaco_stat.c \ mgcp_stat.c \ mtp3_stat.c \ mtp3_summary.c \ - ncp_stat.c \ radius_stat.c \ rlc_lte_graph.c \ rlc_lte_stat_dlg.c \ @@ -184,14 +177,11 @@ WIRESHARK_TAP_SRC = \ rpc_stat.c \ rtp_analysis.c \ rtp_stream_dlg.c \ - scsi_stat.c \ sctp_assoc_analyse.c \ sctp_chunk_stat.c \ sctp_chunk_stat_dlg.c \ sctp_stat_dlg.c \ sip_stat.c \ - smb_stat.c \ - smb2_stat.c \ stats_tree_stat.c \ tcp_graph.c \ voip_calls_dlg.c \ diff --git a/ui/gtk/afp_stat.c b/ui/gtk/afp_stat.c deleted file mode 100644 index f58122a4c9..0000000000 --- a/ui/gtk/afp_stat.c +++ /dev/null @@ -1,216 +0,0 @@ -/* afp_stat.c - * Based on - * smb_stat 2003 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-afp.h> - - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - - -void register_tap_listener_gtkafpstat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _afpstat_t { - GtkWidget *win; - srt_stat_table afp_srt_table; -} afpstat_t; - -static void -afpstat_set_title(afpstat_t *ss) -{ - set_window_title(ss->win, "AFP Service Response Time statistics"); -} - -static void -afpstat_reset(void *pss) -{ - afpstat_t *ss=(afpstat_t *)pss; - - reset_srt_table_data(&ss->afp_srt_table); - afpstat_set_title(ss); -} - -static int -afpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) -{ - afpstat_t *ss=(afpstat_t *)pss; - const afp_request_val *request_val=(const afp_request_val *)prv; - - /* if we havnt seen the request, just ignore it */ - if(!request_val){ - return 0; - } - - add_srt_table_data(&ss->afp_srt_table, request_val->command, &request_val->req_time, pinfo); - - return 1; -} - - - -static void -afpstat_draw(void *pss) -{ - afpstat_t *ss=(afpstat_t *)pss; - - draw_srt_table_data(&ss->afp_srt_table); -} - - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - afpstat_t *ss=(afpstat_t *)data; - - remove_tap_listener(ss); - - free_srt_table_data(&ss->afp_srt_table); - g_free(ss); -} - - -static void -gtk_afpstat_init(const char *opt_arg, void *userdata _U_) -{ - afpstat_t *ss; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - int i; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - - if(!strncmp(opt_arg,"afp,srt,",8)){ - filter=opt_arg+8; - } else { - filter=NULL; - } - - ss=(afpstat_t *)g_malloc(sizeof(afpstat_t)); - - ss->win=dlg_window_new("afp-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(ss->win), SRT_PREFERRED_WIDTH, 600); - afpstat_set_title(ss); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(ss->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("AFP Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - label=gtk_label_new(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - g_free(filter_string); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - label=gtk_label_new("AFP Commands"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(ss->win); - - init_srt_table(&ss->afp_srt_table, 256, vbox, "afp.command"); - for(i=0;i<256;i++){ - gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &CommandCode_vals_ext, "Unknown(%u)"); - init_srt_table_row(&ss->afp_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - - error_string=register_tap_listener("afp", ss, filter, 0, afpstat_reset, afpstat_packet, afpstat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(ss); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb); - - g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss); - - gtk_widget_show_all(ss->win); - window_present(ss->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(ss->win)); -} - -static tap_param afp_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg afp_stat_dlg = { - "AFP SRT Statistics", - "afp,srt", - gtk_afpstat_init, - -1, - G_N_ELEMENTS(afp_stat_params), - afp_stat_params -}; - -void -register_tap_listener_gtkafpstat(void) -{ - register_param_stat(&afp_stat_dlg, "AFP", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/gtk/camel_srt.c b/ui/gtk/camel_srt.c deleted file mode 100644 index 2b027d424f..0000000000 --- a/ui/gtk/camel_srt.c +++ /dev/null @@ -1,247 +0,0 @@ -/* camel_srt.c - * camel Service Response Time statistics for Wireshark - * Copyright 2006 Florent Drouin (based on h225_ras_srt.c from Lars Roland) - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/packet.h> -#include <epan/dissectors/packet-camel.h> - - -#include "ui/simple_dialog.h" - -#include "ui/gtk/main.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/service_response_time_table.h" - - -/* used to keep track of the statistics for an entire program interface */ -struct camelsrt_t { - GtkWidget *win; - srt_stat_table camel_srt_table; -}; - -static void camelsrt_set_title(struct camelsrt_t * p_camelsrt); -static void camelsrt_reset(void *phs); -static int camelsrt_packet(void *phs, - packet_info *pinfo _U_, - epan_dissect_t *edt _U_, - const void *phi); - -static void camelsrt_draw(void *phs); -static void win_destroy_cb(GtkWindow *win _U_, gpointer data); -static void gtk_camelsrt_init(const char *opt_arg, void *userdata _U_); -void register_tap_listener_gtk_camelsrt(void); - -/* - * - */ -static void camelsrt_set_title(struct camelsrt_t * p_camelsrt) -{ - set_window_title(p_camelsrt->win, "CAMEL Service Response Time statistics"); -} - -static void camelsrt_reset(void *phs) -{ - struct camelsrt_t *hs=(struct camelsrt_t *)phs; - reset_srt_table_data(&hs->camel_srt_table); - camelsrt_set_title(hs); -} - -/* - * Count the delta time between Request and Response - * As we can make several measurement per message, we use a boolean array for the category - * Then, if the measurement is provided, check if it is valid, and update the table - */ -static int camelsrt_packet(void *phs, - packet_info *pinfo _U_, - epan_dissect_t *edt _U_, - const void *phi) -{ - struct camelsrt_t *hs=(struct camelsrt_t *)phs; - const struct camelsrt_info_t * pi=(const struct camelsrt_info_t *)phi; - int i; - - for (i=1; i<NB_CAMELSRT_CATEGORY; i++) { - if ( pi->bool_msginfo[i] && - pi->msginfo[i].is_delta_time - && pi->msginfo[i].request_available - && !pi->msginfo[i].is_duplicate ) { - - add_srt_table_data(&hs->camel_srt_table, i, &pi->msginfo[i].req_time, pinfo); - - } - } /* category */ - return 1; -} - - -static void camelsrt_draw(void *phs) -{ - struct camelsrt_t *hs=(struct camelsrt_t *)phs; - draw_srt_table_data(&hs->camel_srt_table); -} - -/* - * Routine for Display - */ -static void win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - struct camelsrt_t *hs=(struct camelsrt_t *)data; - - remove_tap_listener(hs); - - free_srt_table_data(&hs->camel_srt_table); - g_free(hs); -} - -static void gtk_camelsrt_init(const char *opt_arg, void *userdata _U_) -{ - struct camelsrt_t * p_camelsrt; - const char *filter=NULL; - - GtkWidget *cmd_label; - GtkWidget *main_label; - GtkWidget *filter_label; - char *filter_string; - GString *error_string; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - gchar* tmp_str; - int i; - - if(strncmp(opt_arg,"camel,srt,",10) == 0){ - filter=opt_arg+10; - } else { - filter=NULL; - } - - p_camelsrt=(struct camelsrt_t *)g_malloc(sizeof(struct camelsrt_t)); - - p_camelsrt->win= dlg_window_new("camel-srt"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(p_camelsrt->win), TRUE); - - gtk_window_set_default_size(GTK_WINDOW(p_camelsrt->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - camelsrt_set_title(p_camelsrt); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(p_camelsrt->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - main_label=gtk_label_new("CAMEL Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), main_label, FALSE, FALSE, 0); - gtk_widget_show(main_label); - - filter_string = g_strdup_printf("Filter: %s",filter ? filter : ""); - filter_label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0); - gtk_widget_show(filter_label); - - cmd_label=gtk_label_new("CAMEL Commands"); - gtk_box_pack_start(GTK_BOX(vbox), cmd_label, FALSE, FALSE, 0); - gtk_widget_show(cmd_label); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(p_camelsrt->win); - - init_srt_table(&p_camelsrt->camel_srt_table, NB_CAMELSRT_CATEGORY, vbox, NULL); - for(i=0 ;i<NB_CAMELSRT_CATEGORY; i++) { - tmp_str = val_to_str_wmem(NULL,i,camelSRTtype_naming,"Unknown (%d)"); - init_srt_table_row(&p_camelsrt->camel_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - error_string=register_tap_listener("CAMEL", - p_camelsrt, - filter, - 0, - camelsrt_reset, - camelsrt_packet, - camelsrt_draw); - - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(p_camelsrt); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(p_camelsrt->win, close_bt, window_cancel_button_cb); - - g_signal_connect(p_camelsrt->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(p_camelsrt->win, "destroy", G_CALLBACK(win_destroy_cb), p_camelsrt); - - gtk_widget_show_all(p_camelsrt->win); - window_present(p_camelsrt->win); - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(p_camelsrt->win)); - -} - -static tap_param camel_srt_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg camel_srt_dlg = { - "CAMEL Service Response Time", - "camel,srt", - gtk_camelsrt_init, - -1, - G_N_ELEMENTS(camel_srt_params), - camel_srt_params -}; - -void /* Next line mandatory */ -register_tap_listener_gtk_camelsrt(void) -{ - register_param_stat(&camel_srt_dlg, "CAMEL", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local Variables: - * c-basic-offset: 2 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=2 tabstop=8 expandtab: - * :indentSize=2:tabSize=8:noTabs=true: - */ diff --git a/ui/gtk/dcerpc_stat.c b/ui/gtk/dcerpc_stat.c index b65279503f..c8b2bda843 100644 --- a/ui/gtk/dcerpc_stat.c +++ b/ui/gtk/dcerpc_stat.c @@ -57,12 +57,11 @@ void register_tap_listener_gtkdcerpcstat(void); /* used to keep track of the statistics for an entire program interface */ typedef struct _dcerpcstat_t { - GtkWidget *win; - srt_stat_table srt_table; const char *prog; - e_guid_t uuid; guint16 ver; - int num_procedures; + gtk_srt_t gtk_data; + register_srt_t* srt; + srt_data_t data; } dcerpcstat_t; @@ -103,62 +102,35 @@ dcerpcstat_set_title(dcerpcstat_t *rs) char *title; title = dcerpcstat_gen_title(rs); - gtk_window_set_title(GTK_WINDOW(rs->win), title); + gtk_window_set_title(GTK_WINDOW(rs->gtk_data.win), title); g_free(title); } static void dcerpcstat_reset(void *rs_arg) { - dcerpcstat_t *rs = (dcerpcstat_t *)rs_arg; - - reset_srt_table_data(&rs->srt_table); - dcerpcstat_set_title(rs); -} - + srt_data_t *srt = (srt_data_t*)rs_arg; + dcerpcstat_t *rs = (dcerpcstat_t *)srt->user_data; -static gboolean -dcerpcstat_packet(void *rs_arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *ri_arg) -{ - dcerpcstat_t *rs = (dcerpcstat_t *)rs_arg; - const dcerpc_info *ri = (dcerpc_info *)ri_arg; + reset_srt_table(rs->data.srt_array, reset_table_data, &rs->gtk_data); - if(!ri->call_data){ - return FALSE; - } - if(!ri->call_data->req_frame){ - /* we have not seen the request so we don't know the delta*/ - return FALSE; - } - if(ri->call_data->opnum >= rs->num_procedures){ - /* don't handle this since it's outside of known table */ - return FALSE; - } - - /* we are only interested in reply packets */ - if(ri->ptype != PDU_RESP){ - return FALSE; - } - - /* we are only interested in certain program/versions */ - if( (!uuid_equal( (&ri->call_data->uuid), (&rs->uuid))) - ||(ri->call_data->ver != rs->ver)){ - return FALSE; - } - - - add_srt_table_data(&rs->srt_table, ri->call_data->opnum, &ri->call_data->req_time, pinfo); - - - return TRUE; + dcerpcstat_set_title(rs); } static void dcerpcstat_draw(void *rs_arg) { - dcerpcstat_t *rs = (dcerpcstat_t *)rs_arg; + guint i = 0; + srt_stat_table *srt_table; + srt_data_t *srt = (srt_data_t*)rs_arg; + dcerpcstat_t *rs = (dcerpcstat_t *)srt->user_data; + + for (i = 0; i < srt->srt_array->len; i++) + { + srt_table = g_array_index(srt->srt_array, srt_stat_table*, i); + draw_srt_table_data(srt_table, &rs->gtk_data); + } - draw_srt_table_data(&rs->srt_table); } static void @@ -166,9 +138,9 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data) { dcerpcstat_t *rs = (dcerpcstat_t *)data; - remove_tap_listener(rs); + remove_tap_listener(&rs->data); - free_srt_table_data(&rs->srt_table); + free_srt_table(rs->srt, rs->data.srt_array, free_table_data, &rs->gtk_data); g_free(rs); } @@ -181,7 +153,6 @@ gtk_dcerpcstat_init(const char *opt_arg, void* userdata _U_) guint32 i, max_procs; char *title_string; char *filter_string; - GtkWidget *vbox; GtkWidget *stat_label; GtkWidget *filter_label; GtkWidget *bbox; @@ -193,8 +164,8 @@ gtk_dcerpcstat_init(const char *opt_arg, void* userdata _U_) guint16 ver; int pos = 0; const char *filter = NULL; + dcerpcstat_tap_data_t* tap_data; GString *error_string; - int hf_opnum; /* * XXX - DCE RPC statistics are maintained only by major version, @@ -243,7 +214,7 @@ gtk_dcerpcstat_init(const char *opt_arg, void* userdata _U_) } ver = major; - rs = (dcerpcstat_t *)g_malloc(sizeof(dcerpcstat_t)); + rs = (dcerpcstat_t *)g_malloc0(sizeof(dcerpcstat_t)); rs->prog = dcerpc_get_proto_name(&uuid, ver); if(!rs->prog){ g_free(rs); @@ -252,88 +223,84 @@ gtk_dcerpcstat_init(const char *opt_arg, void* userdata _U_) uuid.data1,uuid.data2,uuid.data3,uuid.data4[0],uuid.data4[1],uuid.data4[2],uuid.data4[3],uuid.data4[4],uuid.data4[5],uuid.data4[6],uuid.data4[7],ver); exit(1); } - hf_opnum = dcerpc_get_proto_hf_opnum(&uuid, ver); + procs = dcerpc_get_proto_sub_dissector(&uuid, ver); - rs->uuid = uuid; rs->ver = ver; - rs->win = dlg_window_new("dcerpc-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent(GTK_WINDOW(rs->win), TRUE); + rs->gtk_data.win = dlg_window_new("dcerpc-stat"); /* transient_for top_level */ + gtk_window_set_destroy_with_parent(GTK_WINDOW(rs->gtk_data.win), TRUE); dcerpcstat_set_title(rs); - gtk_window_set_default_size(GTK_WINDOW(rs->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); + gtk_window_set_default_size(GTK_WINDOW(rs->gtk_data.win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - vbox =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(rs->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); + rs->gtk_data.vbox =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); + gtk_container_add(GTK_CONTAINER(rs->gtk_data.win), rs->gtk_data.vbox); + gtk_container_set_border_width(GTK_CONTAINER(rs->gtk_data.vbox), 12); title_string = dcerpcstat_gen_title(rs); stat_label = gtk_label_new(title_string); g_free(title_string); - gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(rs->gtk_data.vbox), stat_label, FALSE, FALSE, 0); filter_string = g_strdup_printf("Filter: %s",filter ? filter : ""); filter_label = gtk_label_new(filter_string); g_free(filter_string); gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(rs->gtk_data.vbox), filter_label, FALSE, FALSE, 0); + + /* We must display TOP LEVEL Widget before calling init_gtk_srt_table() */ + gtk_widget_show_all(rs->gtk_data.win); + + rs->srt = get_srt_table_by_name("dcerpc"); + for(i=0,max_procs=0;procs[i].name;i++){ if(procs[i].num>max_procs){ max_procs = procs[i].num; } } - rs->num_procedures = max_procs+1; - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(rs->win); + /* Setup the tap data */ + tap_data = g_new0(dcerpcstat_tap_data_t, 1); - if(hf_opnum != -1){ - init_srt_table(&rs->srt_table, max_procs+1, vbox, proto_registrar_get_nth(hf_opnum)->abbrev); - } else { - init_srt_table(&rs->srt_table, max_procs+1, vbox, NULL); - } - - for(i=0;i<(max_procs+1);i++){ - int j; - const char *proc_name; + tap_data->uuid = uuid; + tap_data->prog = dcerpc_get_proto_name(&tap_data->uuid, ver); + tap_data->ver = ver; + tap_data->num_procedures = max_procs+1; - proc_name = "unknown"; - for(j=0;procs[j].name;j++){ - if (procs[j].num == i){ - proc_name = procs[j].name; - } - } + set_srt_table_param_data(rs->srt, tap_data); - init_srt_table_row(&rs->srt_table, i, proc_name); - } + rs->gtk_data.gtk_srt_array = g_array_new(FALSE, TRUE, sizeof(gtk_srt_table_t*)); + rs->data.srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*)); + rs->data.user_data = rs; + srt_table_dissector_init(rs->srt, rs->data.srt_array, init_gtk_srt_table, &rs->gtk_data); - error_string = register_tap_listener("dcerpc", rs, filter, 0, dcerpcstat_reset, dcerpcstat_packet, dcerpcstat_draw); + error_string = register_tap_listener("dcerpc", &rs->data, filter, 0, dcerpcstat_reset, get_srt_packet_func(rs->srt), dcerpcstat_draw); if(error_string){ /* error, we failed to attach to the tap. clean up */ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); g_string_free(error_string, TRUE); - free_srt_table_data(&rs->srt_table); + free_srt_table(rs->srt, rs->data.srt_array, NULL, NULL); g_free(rs); return; } /* Button row. */ bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(rs->gtk_data.vbox), bbox, FALSE, FALSE, 0); close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(rs->win, close_bt, window_cancel_button_cb); + window_set_cancel_button(rs->gtk_data.win, close_bt, window_cancel_button_cb); - g_signal_connect(rs->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(rs->win, "destroy", G_CALLBACK(win_destroy_cb), rs); + g_signal_connect(rs->gtk_data.win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); + g_signal_connect(rs->gtk_data.win, "destroy", G_CALLBACK(win_destroy_cb), rs); - gtk_widget_show_all(rs->win); - window_present(rs->win); + gtk_widget_show_all(rs->gtk_data.win); + window_present(rs->gtk_data.win); cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(rs->win)); + gdk_window_raise(gtk_widget_get_window(rs->gtk_data.win)); } @@ -711,7 +678,7 @@ void gtk_dcerpcstat_cb(GtkAction *action _U_, gpointer user_data _U_) } static stat_tap_ui dcerpcstat_ui = { - REGISTER_STAT_GROUP_GENERIC, + REGISTER_STAT_GROUP_RESPONSE_TIME, NULL, "dcerpc,srt", gtk_dcerpcstat_init, diff --git a/ui/gtk/diameter_stat.c b/ui/gtk/diameter_stat.c deleted file mode 100644 index 44dc3e90a1..0000000000 --- a/ui/gtk/diameter_stat.c +++ /dev/null @@ -1,242 +0,0 @@ -/* diameter_stat.c - * Diameter Service Response Time Statistics - * (c) 2008 Abhik Sarkar - * - * Based almost completely on gtp_stat by Kari Tiirikainen - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-diameter.h> - - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - - -void register_tap_listener_gtkdiameterstat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _diameterstat_t { - GtkWidget *win; - srt_stat_table diameter_srt_table; -} diameterstat_t; - -static GHashTable* cmd_str_hash; - -static void -diameterstat_set_title(diameterstat_t *diameter) -{ - set_window_title(diameter->win, "Diameter Service Response Time statistics"); -} - -static void -diameterstat_reset(void *pdiameter) -{ - diameterstat_t *diameter=(diameterstat_t *)pdiameter; - - reset_srt_table_data(&diameter->diameter_srt_table); - diameterstat_set_title(diameter); -} - - -static int -diameterstat_packet(void *pdiameter, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pdi) -{ - const diameter_req_ans_pair_t *diameter=(const diameter_req_ans_pair_t *)pdi; - diameterstat_t *fs=(diameterstat_t *)pdiameter; - 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; - - idx = (int*) g_hash_table_lookup(cmd_str_hash, diameter->cmd_str); - if (idx == NULL) { - idx = (int *)g_malloc(sizeof(int)); - *idx = (int) g_hash_table_size(cmd_str_hash); - g_hash_table_insert(cmd_str_hash, (gchar*) diameter->cmd_str, idx); - init_srt_table_row(&fs->diameter_srt_table, *idx, (const char*) diameter->cmd_str); - } - - add_srt_table_data(&fs->diameter_srt_table, *idx, &diameter->req_time, pinfo); - - return 1; -} - - - -static void -diameterstat_draw(void *pdiameter) -{ - diameterstat_t *diameter=(diameterstat_t *)pdiameter; - - draw_srt_table_data(&diameter->diameter_srt_table); -} - - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - diameterstat_t *diameter=(diameterstat_t *)data; - - remove_tap_listener(diameter); - - free_srt_table_data(&diameter->diameter_srt_table); - g_free(diameter); - g_hash_table_destroy(cmd_str_hash); -} - - -static void -gtk_diameterstat_init(const char *opt_arg, void *userdata _U_) -{ - diameterstat_t *diameter; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - int* idx; - - if(!strncmp(opt_arg,"diameter,",9)){ - filter=opt_arg+9; - } else { - filter="diameter"; /*NULL doesn't work here like in LDAP. Too little time/lazy to find out why ?*/ - } - - diameter=(diameterstat_t *)g_malloc(sizeof(diameterstat_t)); - idx = (int *)g_malloc(sizeof(int)); - *idx = 0; - cmd_str_hash = g_hash_table_new(g_str_hash,g_str_equal); - g_hash_table_insert(cmd_str_hash, (gchar *)"Unknown", idx); - - diameter->win = dlg_window_new("diameter-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(diameter->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(diameter->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - diameterstat_set_title(diameter); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(diameter->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("Diameter Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - label=gtk_label_new("Diameter Requests"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(diameter->win); - - /** @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. - */ - init_srt_table(&diameter->diameter_srt_table, 1, vbox, NULL); - init_srt_table_row(&diameter->diameter_srt_table, 0, "Unknown"); - - error_string=register_tap_listener( - "diameter", - diameter, filter, - TL_REQUIRES_PROTO_TREE, - diameterstat_reset, - diameterstat_packet, - diameterstat_draw); - - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(diameter); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(diameter->win, close_bt, window_cancel_button_cb); - - g_signal_connect(diameter->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(diameter->win, "destroy", G_CALLBACK(win_destroy_cb), diameter); - - gtk_widget_show_all(diameter->win); - window_present(diameter->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(diameter->win)); -} - -static tap_param diameter_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg diameter_stat_dlg = { - "Diameter Service Response Time Statistics", - "diameter", - gtk_diameterstat_init, - -1, - G_N_ELEMENTS(diameter_stat_params), - diameter_stat_params -}; - -void -register_tap_listener_gtkdiameterstat(void) -{ - register_param_stat(&diameter_stat_dlg, "Diameter", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/gtk/fc_stat.c b/ui/gtk/fc_stat.c deleted file mode 100644 index 0be421ef48..0000000000 --- a/ui/gtk/fc_stat.c +++ /dev/null @@ -1,220 +0,0 @@ -/* fc_stat.c - * fc_stat 2003 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-fc.h> - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - - -void register_tap_listener_gtkfcstat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _fcstat_t { - GtkWidget *win; - srt_stat_table fc_srt_table; -} fcstat_t; - -static void -fcstat_set_title(fcstat_t *fc) -{ - set_window_title(fc->win, "Fibre Channel Service Response Time statistics"); -} - -static void -fcstat_reset(void *pfc) -{ - fcstat_t *fc=(fcstat_t *)pfc; - - reset_srt_table_data(&fc->fc_srt_table); - fcstat_set_title(fc); -} - -static int -fcstat_packet(void *pfc, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - const fc_hdr *fc=(const fc_hdr *)psi; - fcstat_t *fs=(fcstat_t *)pfc; - - /* we are only interested in reply packets */ - if(!(fc->fctl&FC_FCTL_EXCHANGE_RESPONDER)){ - return 0; - } - /* if we havnt seen the request, just ignore it */ - if ( (!fc->fc_ex) || (fc->fc_ex->first_exchange_frame==0) ){ - return 0; - } - - add_srt_table_data(&fs->fc_srt_table, fc->type, &fc->fc_ex->fc_time, pinfo); - - return 1; -} - - - -static void -fcstat_draw(void *pfc) -{ - fcstat_t *fc=(fcstat_t *)pfc; - - draw_srt_table_data(&fc->fc_srt_table); -} - - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - fcstat_t *fc=(fcstat_t *)data; - - remove_tap_listener(fc); - - free_srt_table_data(&fc->fc_srt_table); - g_free(fc); -} - - -static void -gtk_fcstat_init(const char *opt_arg, void *userdata _U_) -{ - fcstat_t *fc; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - int i; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - gchar* tmp_str; - - if(!strncmp(opt_arg,"fc,srt,",7)){ - filter=opt_arg+7; - } else { - filter=NULL; - } - - fc=(fcstat_t *)g_malloc(sizeof(fcstat_t)); - - fc->win = dlg_window_new("fc-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(fc->win), TRUE); - - gtk_window_set_default_size(GTK_WINDOW(fc->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - fcstat_set_title(fc); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(fc->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("Fibre Channel Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - label=gtk_label_new("Fibre Channel Types"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(fc->win); - - init_srt_table(&fc->fc_srt_table, 256, vbox, NULL); - for(i=0;i<256;i++){ - tmp_str = val_to_str_wmem(NULL, i, fc_fc4_val, "Unknown(0x%02x)"); - init_srt_table_row(&fc->fc_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - - error_string=register_tap_listener("fc", fc, filter, 0, fcstat_reset, fcstat_packet, fcstat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(fc); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(fc->win, close_bt, window_cancel_button_cb); - - g_signal_connect(fc->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(fc->win, "destroy", G_CALLBACK(win_destroy_cb), fc); - - gtk_widget_show_all(fc->win); - window_present(fc->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(fc->win)); -} - -static tap_param fc_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg fc_stat_dlg = { - "Fibre Channel Service Response Time statistics", - "fc,srt", - gtk_fcstat_init, - -1, - G_N_ELEMENTS(fc_stat_params), - fc_stat_params -}; - -void -register_tap_listener_gtkfcstat(void) -{ - register_param_stat(&fc_stat_dlg, "Fibre Channel", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/gtk/gtp_stat.c b/ui/gtk/gtp_stat.c deleted file mode 100644 index 2634cf7262..0000000000 --- a/ui/gtk/gtp_stat.c +++ /dev/null @@ -1,237 +0,0 @@ -/* gtp_stat.c - * gtp_stat 2008 Kari Tiirikainen - * Largely based on ldap_stat by Ronnie Sahlberg, all mistakes added by KTi - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-gtp.h> - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - - -void register_tap_listener_gtkgtpstat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _gtpstat_t { - GtkWidget *win; - srt_stat_table gtp_srt_table; -} gtpstat_t; - -static void -gtpstat_set_title(gtpstat_t *gtp) -{ - set_window_title(gtp->win, "GTP Control Plane Response Time statistics"); -} - -static void -gtpstat_reset(void *pgtp) -{ - gtpstat_t *gtp=(gtpstat_t *)pgtp; - - reset_srt_table_data(>p->gtp_srt_table); - gtpstat_set_title(gtp); -} - -static int -gtpstat_packet(void *pgtp, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - const gtp_msg_hash_t *gtp=(const gtp_msg_hash_t *)psi; - gtpstat_t *fs=(gtpstat_t *)pgtp; - int idx=0; - - /* we are only interested in reply packets */ - if(gtp->is_request){ - return 0; - } - /* if we have not seen the request, just ignore it */ - if(!gtp->req_frame){ - return 0; - } - - /* Only use the commands we know how to handle, this is not a comprehensive list */ - /* Redoing the message indexing is bit reduntant, */ - /* but using message type as such would yield a long gtp_srt_table. */ - /* Only a fraction of the messages are matchable req/resp pairs, */ - /* it just doesn't feel feasible. */ - - switch(gtp->msgtype){ - case GTP_MSG_ECHO_REQ: idx=0; - break; - case GTP_MSG_CREATE_PDP_REQ: idx=1; - break; - case GTP_MSG_UPDATE_PDP_REQ: idx=2; - break; - case GTP_MSG_DELETE_PDP_REQ: idx=3; - break; - default: - return 0; - } - - add_srt_table_data(&fs->gtp_srt_table, idx, >p->req_time, pinfo); - - return 1; -} - - - -static void -gtpstat_draw(void *pgtp) -{ - gtpstat_t *gtp=(gtpstat_t *)pgtp; - - draw_srt_table_data(>p->gtp_srt_table); -} - - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - gtpstat_t *gtp=(gtpstat_t *)data; - - remove_tap_listener(gtp); - - free_srt_table_data(>p->gtp_srt_table); - g_free(gtp); -} - - -static void -gtk_gtpstat_init(const char *opt_arg, void *userdata _U_) -{ - gtpstat_t *gtp; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - - if(!strncmp(opt_arg,"gtp,",4)){ - filter=opt_arg+4; - } else { - filter="gtp"; /*NULL doesn't work here like in LDAP. Too little time/lazy to find out why ?*/ - } - - gtp=(gtpstat_t *)g_malloc(sizeof(gtpstat_t)); - - gtp->win = dlg_window_new("gtp-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(gtp->win), TRUE); - - gtk_window_set_default_size(GTK_WINDOW(gtp->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - gtpstat_set_title(gtp); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(gtp->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("GTP Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - label=gtk_label_new("GTP Requests"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(gtp->win); - - init_srt_table(>p->gtp_srt_table, 4, vbox, NULL); - init_srt_table_row(>p->gtp_srt_table, 0, "Echo"); - init_srt_table_row(>p->gtp_srt_table, 1, "Create PDP context"); - init_srt_table_row(>p->gtp_srt_table, 2, "Update PDP context"); - init_srt_table_row(>p->gtp_srt_table, 3, "Delete PDP context"); - - error_string=register_tap_listener("gtp", gtp, filter, 0, gtpstat_reset, gtpstat_packet, gtpstat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(gtp); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(gtp->win, close_bt, window_cancel_button_cb); - - g_signal_connect(gtp->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(gtp->win, "destroy", G_CALLBACK(win_destroy_cb), gtp); - - gtk_widget_show_all(gtp->win); - window_present(gtp->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(gtp->win)); -} - -static tap_param gtp_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg gtp_stat_dlg = { - "GTP Control Plane Response Time Statistics", - "gtp", - gtk_gtpstat_init, - -1, - G_N_ELEMENTS(gtp_stat_params), - gtp_stat_params -}; - -void -register_tap_listener_gtkgtpstat(void) -{ - register_param_stat(>p_stat_dlg, "GTP", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/gtk/ldap_stat.c b/ui/gtk/ldap_stat.c deleted file mode 100644 index c7c3cbfe61..0000000000 --- a/ui/gtk/ldap_stat.c +++ /dev/null @@ -1,231 +0,0 @@ -/* ldap_stat.c - * ldap_stat 2003 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ldap.h> - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - - -void register_tap_listener_gtkldapstat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _ldapstat_t { - GtkWidget *win; - srt_stat_table ldap_srt_table; -} ldapstat_t; - -static void -ldapstat_set_title(ldapstat_t *ldap) -{ - set_window_title(ldap->win, "LDAP Service Response Time statistics"); -} - -static void -ldapstat_reset(void *pldap) -{ - ldapstat_t *ldap=(ldapstat_t *)pldap; - - reset_srt_table_data(&ldap->ldap_srt_table); - ldapstat_set_title(ldap); -} - -static int -ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - const ldap_call_response_t *ldap=(const ldap_call_response_t *)psi; - ldapstat_t *fs=(ldapstat_t *)pldap; - - /* we are only interested in reply packets */ - if(ldap->is_request){ - return 0; - } - /* if we havnt seen the request, just ignore it */ - if(!ldap->req_frame){ - return 0; - } - - /* only use the commands we know how to handle */ - switch(ldap->protocolOpTag){ - case LDAP_REQ_BIND: - case LDAP_REQ_SEARCH: - case LDAP_REQ_MODIFY: - case LDAP_REQ_ADD: - case LDAP_REQ_DELETE: - case LDAP_REQ_MODRDN: - case LDAP_REQ_COMPARE: - case LDAP_REQ_EXTENDED: - break; - default: - return 0; - } - - add_srt_table_data(&fs->ldap_srt_table, ldap->protocolOpTag, &ldap->req_time, pinfo); - - return 1; -} - - - -static void -ldapstat_draw(void *pldap) -{ - ldapstat_t *ldap=(ldapstat_t *)pldap; - - draw_srt_table_data(&ldap->ldap_srt_table); -} - - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - ldapstat_t *ldap=(ldapstat_t *)data; - - remove_tap_listener(ldap); - - free_srt_table_data(&ldap->ldap_srt_table); - g_free(ldap); -} - - -static void -gtk_ldapstat_init(const char *opt_arg, void *userdata _U_) -{ - ldapstat_t *ldap; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - int i; - - if(!strncmp(opt_arg,"ldap,srt,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - ldap=(ldapstat_t *)g_malloc(sizeof(ldapstat_t)); - - ldap->win = dlg_window_new("ldap-stat"); - gtk_window_set_destroy_with_parent (GTK_WINDOW(ldap->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(ldap->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - ldapstat_set_title(ldap); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(ldap->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("LDAP Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - label=gtk_label_new("LDAP Commands"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(ldap->win); - - init_srt_table(&ldap->ldap_srt_table, 24, vbox, NULL); - for (i = 0; i < 24; i++) - { - init_srt_table_row(&ldap->ldap_srt_table, i, val_to_str_const(i, ldap_procedure_names, "<unknown>")); - } - - error_string=register_tap_listener("ldap", ldap, filter, 0, ldapstat_reset, ldapstat_packet, ldapstat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(ldap); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(ldap->win, close_bt, window_cancel_button_cb); - - g_signal_connect(ldap->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(ldap->win, "destroy", G_CALLBACK(win_destroy_cb), ldap); - - gtk_widget_show_all(ldap->win); - window_present(ldap->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(ldap->win)); -} - -static tap_param ldap_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg ldap_stat_dlg = { - "LDAP Service Response Time Statistics", - "ldap,srt", - gtk_ldapstat_init, - -1, - G_N_ELEMENTS(ldap_stat_params), - ldap_stat_params -}; - -void -register_tap_listener_gtkldapstat(void) -{ - register_param_stat(&ldap_stat_dlg, "LDAP", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/gtk/main.c b/ui/gtk/main.c index 265f1048ce..6d757b1c7e 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -193,6 +193,7 @@ #include "ui/gtk/filter_expression_save_dlg.h" #include "ui/gtk/conversations_table.h" #include "ui/gtk/hostlist_table.h" +#include "ui/gtk/service_response_time_table.h" #include "simple_dialog.h" #include "ui/gtk/old-gtk-compat.h" @@ -2533,6 +2534,7 @@ DIAG_ON(cast-qual) register_all_tap_listeners(); conversation_table_set_gui_info(init_conversation_table); hostlist_table_set_gui_info(init_hostlist_table); + srt_table_iterate_tables(register_service_response_tables, NULL); splash_update(RA_PREFERENCES, NULL, (gpointer)splash_win); diff --git a/ui/gtk/ncp_stat.c b/ui/gtk/ncp_stat.c deleted file mode 100644 index 77aa0b06aa..0000000000 --- a/ui/gtk/ncp_stat.c +++ /dev/null @@ -1,558 +0,0 @@ -/* ncp_stat.c - * ncp_stat 2005 Greg Morris - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-ncp-int.h> - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - -void register_tap_listener_gtkncpstat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _ncpstat_t { - GtkWidget *win; - srt_stat_table ncp_srt_table; - srt_stat_table nds_srt_table; - srt_stat_table func_srt_table; - srt_stat_table sss_srt_table; - srt_stat_table nmas_srt_table; - srt_stat_table sub_17_srt_table; - srt_stat_table sub_21_srt_table; - srt_stat_table sub_22_srt_table; - srt_stat_table sub_23_srt_table; - srt_stat_table sub_32_srt_table; - srt_stat_table sub_34_srt_table; - srt_stat_table sub_35_srt_table; - srt_stat_table sub_36_srt_table; - srt_stat_table sub_86_srt_table; - srt_stat_table sub_87_srt_table; - srt_stat_table sub_89_srt_table; - srt_stat_table sub_90_srt_table; - srt_stat_table sub_92_srt_table; - srt_stat_table sub_94_srt_table; - srt_stat_table sub_104_srt_table; - srt_stat_table sub_111_srt_table; - srt_stat_table sub_114_srt_table; - srt_stat_table sub_123_srt_table; - srt_stat_table sub_131_srt_table; -} ncpstat_t; - -static void -ncpstat_set_title(ncpstat_t *ss) -{ - set_window_title(ss->win, "NCP Service Response Time statistics"); -} - -static void -ncpstat_reset(void *pss) -{ - ncpstat_t *ss=(ncpstat_t *)pss; - - reset_srt_table_data(&ss->ncp_srt_table); - reset_srt_table_data(&ss->func_srt_table); - reset_srt_table_data(&ss->nds_srt_table); - reset_srt_table_data(&ss->sss_srt_table); - reset_srt_table_data(&ss->nmas_srt_table); - reset_srt_table_data(&ss->sub_17_srt_table); - reset_srt_table_data(&ss->sub_21_srt_table); - reset_srt_table_data(&ss->sub_22_srt_table); - reset_srt_table_data(&ss->sub_23_srt_table); - reset_srt_table_data(&ss->sub_32_srt_table); - reset_srt_table_data(&ss->sub_34_srt_table); - reset_srt_table_data(&ss->sub_35_srt_table); - reset_srt_table_data(&ss->sub_36_srt_table); - reset_srt_table_data(&ss->sub_86_srt_table); - reset_srt_table_data(&ss->sub_87_srt_table); - reset_srt_table_data(&ss->sub_89_srt_table); - reset_srt_table_data(&ss->sub_90_srt_table); - reset_srt_table_data(&ss->sub_92_srt_table); - reset_srt_table_data(&ss->sub_94_srt_table); - reset_srt_table_data(&ss->sub_104_srt_table); - reset_srt_table_data(&ss->sub_111_srt_table); - reset_srt_table_data(&ss->sub_114_srt_table); - reset_srt_table_data(&ss->sub_123_srt_table); - reset_srt_table_data(&ss->sub_131_srt_table); - ncpstat_set_title(ss); -} - -static int -ncpstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *prv) -{ - ncpstat_t *ss=(ncpstat_t *)pss; - const ncp_req_hash_value *request_val=(const ncp_req_hash_value *)prv; - gchar* tmp_str; - - /* if we haven't seen the request, just ignore it */ - if(!request_val || request_val->ncp_rec==0){ - return 0; - } - /* By Group */ - tmp_str = val_to_str_wmem(NULL, request_val->ncp_rec->group, ncp_group_vals, "Unknown(%u)"); - init_srt_table_row(&ss->ncp_srt_table, request_val->ncp_rec->group, tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->ncp_srt_table, request_val->ncp_rec->group, &request_val->req_frame_time, pinfo); - /* By NCP number without subfunction*/ - if (request_val->ncp_rec->subfunc==0) { - init_srt_table_row(&ss->func_srt_table, request_val->ncp_rec->func, request_val->ncp_rec->name); - add_srt_table_data(&ss->func_srt_table, request_val->ncp_rec->func, &request_val->req_frame_time, pinfo); - } - /* By Subfunction number */ - if(request_val->ncp_rec->subfunc!=0){ - if (request_val->ncp_rec->func==17) { - init_srt_table_row(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_17_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==21) { - init_srt_table_row(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_21_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==22) { - init_srt_table_row(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_22_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==23) { - init_srt_table_row(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_23_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==32) { - init_srt_table_row(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_32_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==34) { - init_srt_table_row(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_34_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==35) { - init_srt_table_row(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_35_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==36) { - init_srt_table_row(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_36_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==86) { - init_srt_table_row(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_86_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==87) { - init_srt_table_row(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_87_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==89) { - init_srt_table_row(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_89_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==90) { - init_srt_table_row(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_90_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==92) { - init_srt_table_row(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_92_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==94) { - init_srt_table_row(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_94_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==104) { - init_srt_table_row(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_104_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==111) { - init_srt_table_row(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_111_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==114) { - init_srt_table_row(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_114_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==123) { - init_srt_table_row(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_123_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==131) { - init_srt_table_row(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), request_val->ncp_rec->name); - add_srt_table_data(&ss->sub_131_srt_table, (request_val->ncp_rec->subfunc), &request_val->req_frame_time, pinfo); - } - } - /* By NDS verb */ - if (request_val->ncp_rec->func==0x68) { - tmp_str = val_to_str_wmem(NULL, request_val->nds_request_verb, ncp_nds_verb_vals, "Unknown(%u)"); - init_srt_table_row(&ss->nds_srt_table, (request_val->nds_request_verb), tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->nds_srt_table, (request_val->nds_request_verb), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==0x5c) { - tmp_str = val_to_str_wmem(NULL, request_val->req_nds_flags, sss_verb_enum, "Unknown(%u)"); - init_srt_table_row(&ss->sss_srt_table, (request_val->req_nds_flags), tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->sss_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo); - } - if (request_val->ncp_rec->func==0x5e) { - tmp_str = val_to_str_wmem(NULL, request_val->req_nds_flags, nmas_subverb_enum, "Unknown(%u)"); - init_srt_table_row(&ss->nmas_srt_table, (request_val->req_nds_flags), tmp_str); - wmem_free(NULL, tmp_str); - add_srt_table_data(&ss->nmas_srt_table, (request_val->req_nds_flags), &request_val->req_frame_time, pinfo); - } - return 1; -} - - - -static void -ncpstat_draw(void *pss) -{ - ncpstat_t *ss=(ncpstat_t *)pss; - - draw_srt_table_data(&ss->ncp_srt_table); - draw_srt_table_data(&ss->func_srt_table); - draw_srt_table_data(&ss->nds_srt_table); - draw_srt_table_data(&ss->sss_srt_table); - draw_srt_table_data(&ss->nmas_srt_table); - draw_srt_table_data(&ss->sub_17_srt_table); - draw_srt_table_data(&ss->sub_21_srt_table); - draw_srt_table_data(&ss->sub_22_srt_table); - draw_srt_table_data(&ss->sub_23_srt_table); - draw_srt_table_data(&ss->sub_32_srt_table); - draw_srt_table_data(&ss->sub_34_srt_table); - draw_srt_table_data(&ss->sub_35_srt_table); - draw_srt_table_data(&ss->sub_36_srt_table); - draw_srt_table_data(&ss->sub_86_srt_table); - draw_srt_table_data(&ss->sub_87_srt_table); - draw_srt_table_data(&ss->sub_89_srt_table); - draw_srt_table_data(&ss->sub_90_srt_table); - draw_srt_table_data(&ss->sub_92_srt_table); - draw_srt_table_data(&ss->sub_94_srt_table); - draw_srt_table_data(&ss->sub_104_srt_table); - draw_srt_table_data(&ss->sub_111_srt_table); - draw_srt_table_data(&ss->sub_114_srt_table); - draw_srt_table_data(&ss->sub_123_srt_table); - draw_srt_table_data(&ss->sub_131_srt_table); -} - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - ncpstat_t *ss=(ncpstat_t *)data; - - remove_tap_listener(ss); - - free_srt_table_data(&ss->ncp_srt_table); - free_srt_table_data(&ss->func_srt_table); - free_srt_table_data(&ss->nds_srt_table); - free_srt_table_data(&ss->sss_srt_table); - free_srt_table_data(&ss->nmas_srt_table); - free_srt_table_data(&ss->sub_17_srt_table); - free_srt_table_data(&ss->sub_21_srt_table); - free_srt_table_data(&ss->sub_22_srt_table); - free_srt_table_data(&ss->sub_23_srt_table); - free_srt_table_data(&ss->sub_32_srt_table); - free_srt_table_data(&ss->sub_34_srt_table); - free_srt_table_data(&ss->sub_35_srt_table); - free_srt_table_data(&ss->sub_36_srt_table); - free_srt_table_data(&ss->sub_86_srt_table); - free_srt_table_data(&ss->sub_87_srt_table); - free_srt_table_data(&ss->sub_89_srt_table); - free_srt_table_data(&ss->sub_90_srt_table); - free_srt_table_data(&ss->sub_92_srt_table); - free_srt_table_data(&ss->sub_94_srt_table); - free_srt_table_data(&ss->sub_104_srt_table); - free_srt_table_data(&ss->sub_111_srt_table); - free_srt_table_data(&ss->sub_114_srt_table); - free_srt_table_data(&ss->sub_123_srt_table); - free_srt_table_data(&ss->sub_131_srt_table); - g_free(ss); -} - - -static void -gtk_ncpstat_init(const char *opt_arg, void *userdata _U_) -{ - ncpstat_t *ss; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - GtkWidget *temp_page; - GtkWidget *main_nb; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - - if(!strncmp(opt_arg,"ncp,srt,",8)){ - filter=opt_arg+8; - } else { - filter=NULL; - } - - ss=(ncpstat_t *)g_malloc(sizeof(ncpstat_t)); - - ss->win = dlg_window_new("ncp-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(ss->win), 300, 400); - - ncpstat_set_title(ss); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(ss->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("NCP Service Response Time Statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, TRUE, TRUE, 0); - - filter_string = g_strdup_printf("Filter: %s",filter ? filter : ""); - label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - main_nb = gtk_notebook_new(); - gtk_box_pack_start(GTK_BOX(vbox), main_nb, TRUE, TRUE, 0); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label = gtk_label_new("Groups"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - - /* NCP Groups */ - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(ss->win); - label=gtk_label_new("NCP by Group Type"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->ncp_srt_table, 256, temp_page, "ncp.group"); - - /* NCP Functions */ - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label = gtk_label_new("Functions"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("NCP Functions without Subfunctions"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->func_srt_table, 256, temp_page, "ncp.func"); - - /* NCP Subfunctions */ - - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label = gtk_label_new("17"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 17"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_17_srt_table, 256, temp_page, "ncp.func==17 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("21"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 21"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_21_srt_table, 256, temp_page, "ncp.func==21 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("22"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 22"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_22_srt_table, 256, temp_page, "ncp.func==22 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("23"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 23"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_23_srt_table, 256, temp_page, "ncp.func==23 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("32"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 32"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_32_srt_table, 256, temp_page, "ncp.func==32 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("34"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 34"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_34_srt_table, 256, temp_page, "ncp.func==34 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("35"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 35"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_35_srt_table, 256, temp_page, "ncp.func==35 && ncp.subfunc"); - temp_page =ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("36"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 36"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_36_srt_table, 256, temp_page, "ncp.func==36 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("86"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 86"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_86_srt_table, 256, temp_page, "ncp.func==86 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("87"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 87"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_87_srt_table, 256, temp_page, "ncp.func==87 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("89"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 89 (Extended NCP's with UTF8 Support)"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_89_srt_table, 256, temp_page, "ncp.func==89 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("90"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 90"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_90_srt_table, 256, temp_page, "ncp.func==90 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("92"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 92 (Secret Store Services)"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_92_srt_table, 256, temp_page, "ncp.func==92 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("94"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 94 (Novell Modular Authentication Services)"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_94_srt_table, 256, temp_page, "ncp.func==94 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("104"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 104"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_104_srt_table, 256, temp_page, "ncp.func==104 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("111"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 111"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_111_srt_table, 256, temp_page, "ncp.func==111 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("114"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 114"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_114_srt_table, 256, temp_page, "ncp.func==114 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("123"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 123"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_123_srt_table, 256, temp_page, "ncp.func==123 && ncp.subfunc"); - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("131"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Subfunctions for NCP 131"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sub_131_srt_table, 256, temp_page, "ncp.func==131 && ncp.subfunc"); - - /* NDS Verbs */ - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("NDS"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("NDS Verbs"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->nds_srt_table, 256, temp_page, "ncp.ndsverb"); - /* Secret Store Verbs */ - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("SSS"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("Secret Store Verbs"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->sss_srt_table, 256, temp_page, "sss.subverb"); - /* NMAS Verbs */ - temp_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); - label=gtk_label_new("NMAS"); - gtk_notebook_append_page(GTK_NOTEBOOK(main_nb), temp_page, label); - label=gtk_label_new("NMAS Verbs"); - gtk_box_pack_start(GTK_BOX(temp_page), label, FALSE, FALSE, 0); - init_srt_table(&ss->nmas_srt_table, 256, temp_page, "nmas.subverb"); - - /* Register the tap listener */ - error_string=register_tap_listener("ncp_srt", ss, filter, 0, ncpstat_reset, ncpstat_packet, ncpstat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(ss); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb); - - g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss); - - gtk_widget_show_all(ss->win); - window_present(ss->win); - - cf_redissect_packets(&cfile); -} - -static tap_param ncp_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg ncp_stat_dlg = { - "NCP SRT Statistics", - "ncp,srt", - gtk_ncpstat_init, - -1, - G_N_ELEMENTS(ncp_stat_params), - ncp_stat_params -}; - -void -register_tap_listener_gtkncpstat(void) -{ - register_param_stat(&ncp_stat_dlg, "NCP", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 4 - * tab-width: 8 - * indent-tabs-mode: nil - * End: - * - * vi: set shiftwidth=4 tabstop=8 expandtab: - * :indentSize=4:tabSize=8:noTabs=true: - */ diff --git a/ui/gtk/rpc_stat.c b/ui/gtk/rpc_stat.c index 42987d0617..bb2843735c 100644 --- a/ui/gtk/rpc_stat.c +++ b/ui/gtk/rpc_stat.c @@ -54,12 +54,11 @@ void register_tap_listener_gtkrpcstat(void); /* used to keep track of the statistics for an entire program interface */ typedef struct _rpcstat_t { - GtkWidget *win; - srt_stat_table srt_table; const char *prog; - guint32 program; guint32 version; - guint32 num_procedures; + gtk_srt_t gtk_data; + register_srt_t* srt; + srt_data_t data; } rpcstat_t; static char * @@ -81,62 +80,34 @@ rpcstat_set_title(rpcstat_t *rs) char *title; title = rpcstat_gen_title(rs); - gtk_window_set_title(GTK_WINDOW(rs->win), title); + gtk_window_set_title(GTK_WINDOW(rs->gtk_data.win), title); g_free(title); } static void rpcstat_reset(void *arg) { - rpcstat_t *rs = (rpcstat_t *)arg; + srt_data_t *srt = (srt_data_t*)arg; + rpcstat_t *rs = (rpcstat_t *)srt->user_data; - reset_srt_table_data(&rs->srt_table); - rpcstat_set_title(rs); -} - - -static gboolean -rpcstat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2) -{ - rpcstat_t *rs = (rpcstat_t *)arg; - const rpc_call_info_value *ri = (const rpc_call_info_value *)arg2; - - /* we are only interested in reply packets */ - if(ri->request){ - return FALSE; - } - /* we are only interested in certain program/versions */ - if( (ri->prog!=rs->program) || (ri->vers!=rs->version) ){ - return FALSE; - } - /* maybe we have discovered a new procedure? - * then we might need to extend our tables - */ - if(ri->proc>=rs->num_procedures){ - guint32 i; - if(ri->proc>256){ - /* no program have probably ever more than this many - * procedures anyway and it prevents us from allocating - * infinite memory if passed a garbage procedure id - */ - return FALSE; - } - for(i=rs->num_procedures;i<=ri->proc;i++){ - init_srt_table_row(&rs->srt_table, i, rpc_proc_name(rs->program, rs->version, i)); - } - rs->num_procedures=ri->proc+1; - } - add_srt_table_data(&rs->srt_table, ri->proc, &ri->req_time, pinfo); + reset_srt_table(rs->data.srt_array, reset_table_data, &rs->gtk_data); - return TRUE; + rpcstat_set_title(rs); } static void rpcstat_draw(void *arg) { - rpcstat_t *rs = (rpcstat_t *)arg; - - draw_srt_table_data(&rs->srt_table); + guint i = 0; + srt_stat_table *srt_table; + srt_data_t *srt = (srt_data_t*)arg; + rpcstat_t *rs = (rpcstat_t *)srt->user_data; + + for (i = 0; i < srt->srt_array->len; i++) + { + srt_table = g_array_index(srt->srt_array, srt_stat_table*, i); + draw_srt_table_data(srt_table, &rs->gtk_data); + } } @@ -200,9 +171,9 @@ win_destroy_cb(GtkWindow *win _U_, gpointer data) { rpcstat_t *rs=(rpcstat_t *)data; - remove_tap_listener(rs); + remove_tap_listener(&rs->data); - free_srt_table_data(&rs->srt_table); + free_srt_table(rs->srt, rs->data.srt_array, free_table_data, &rs->gtk_data); g_free(rs); } @@ -212,10 +183,8 @@ static void gtk_rpcstat_init(const char *opt_arg, void* userdata _U_) { rpcstat_t *rs; - guint32 i; char *title_string; char *filter_string; - GtkWidget *vbox; GtkWidget *stat_label; GtkWidget *filter_label; GtkWidget *bbox; @@ -223,8 +192,7 @@ gtk_rpcstat_init(const char *opt_arg, void* userdata _U_) int program, version, pos; const char *filter=NULL; GString *error_string; - int hf_index; - header_field_info *hfi; + rpcstat_tap_data_t* tap_data; pos=0; if(sscanf(opt_arg,"rpc,srt,%d,%d,%n",&program,&version,&pos)==2){ @@ -240,72 +208,80 @@ gtk_rpcstat_init(const char *opt_arg, void* userdata _U_) rpc_program=program; rpc_version=version; - rs=(rpcstat_t *)g_malloc(sizeof(rpcstat_t)); - rs->prog=rpc_prog_name(rpc_program); - rs->program=rpc_program; - rs->version=rpc_version; - hf_index=rpc_prog_hf(rpc_program, rpc_version); - hfi=proto_registrar_get_nth(hf_index); - - rs->win = dlg_window_new("rpc-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(rs->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(rs->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); + + rs=(rpcstat_t *)g_malloc0(sizeof(rpcstat_t)); + rs->prog = rpc_prog_name(program); + rs->version = version; + + rs->gtk_data.win = dlg_window_new("rpc-stat"); /* transient_for top_level */ + gtk_window_set_destroy_with_parent (GTK_WINDOW(rs->gtk_data.win), TRUE); + gtk_window_set_default_size(GTK_WINDOW(rs->gtk_data.win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); rpcstat_set_title(rs); - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(rs->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); + rs->gtk_data.vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); + gtk_container_add(GTK_CONTAINER(rs->gtk_data.win), rs->gtk_data.vbox); + gtk_container_set_border_width(GTK_CONTAINER(rs->gtk_data.vbox), 12); title_string = rpcstat_gen_title(rs); stat_label=gtk_label_new(title_string); g_free(title_string); - gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(rs->gtk_data.vbox), stat_label, FALSE, FALSE, 0); filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); filter_label=gtk_label_new(filter_string); g_free(filter_string); gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(rs->gtk_data.vbox), filter_label, FALSE, FALSE, 0); rpc_min_proc=-1; rpc_max_proc=-1; g_hash_table_foreach(rpc_procs, (GHFunc)rpcstat_find_procs, NULL); - rs->num_procedures=rpc_max_proc+1; - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(rs->win); + /* We must display TOP LEVEL Widget before calling init_gtk_srt_table() */ + gtk_widget_show_all(rs->gtk_data.win); - init_srt_table(&rs->srt_table, rpc_max_proc+1, vbox, hfi->abbrev); + rs->srt = get_srt_table_by_name("rpc"); - for(i=0;i<rs->num_procedures;i++){ - init_srt_table_row(&rs->srt_table, i, rpc_proc_name(rpc_program, rpc_version, i)); - } + /* Setup the tap data */ + tap_data = g_new0(rpcstat_tap_data_t, 1); + + tap_data->prog = rpc_prog_name(program); + tap_data->program = program; + tap_data->version = version; + tap_data->num_procedures = rpc_max_proc+1; + + set_srt_table_param_data(rs->srt, tap_data); + + rs->gtk_data.gtk_srt_array = g_array_new(FALSE, TRUE, sizeof(gtk_srt_table_t*)); + rs->data.srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*)); + rs->data.user_data = rs; + srt_table_dissector_init(rs->srt, rs->data.srt_array, init_gtk_srt_table, &rs->gtk_data); - error_string=register_tap_listener("rpc", rs, filter, 0, rpcstat_reset, rpcstat_packet, rpcstat_draw); + error_string=register_tap_listener("rpc", &rs->data, filter, 0, rpcstat_reset, get_srt_packet_func(rs->srt), rpcstat_draw); if(error_string){ simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); g_string_free(error_string, TRUE); - free_srt_table_data(&rs->srt_table); + free_srt_table(rs->srt, rs->data.srt_array, NULL, NULL); g_free(rs); return; } /* Button row. */ bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(rs->gtk_data.vbox), bbox, FALSE, FALSE, 0); close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(rs->win, close_bt, window_cancel_button_cb); + window_set_cancel_button(rs->gtk_data.win, close_bt, window_cancel_button_cb); - g_signal_connect(rs->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(rs->win, "destroy", G_CALLBACK(win_destroy_cb), rs); + g_signal_connect(rs->gtk_data.win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); + g_signal_connect(rs->gtk_data.win, "destroy", G_CALLBACK(win_destroy_cb), rs); - gtk_widget_show_all(rs->win); - window_present(rs->win); + gtk_widget_show_all(rs->gtk_data.win); + window_present(rs->gtk_data.win); cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(rs->win)); + gdk_window_raise(gtk_widget_get_window(rs->gtk_data.win)); } @@ -520,7 +496,7 @@ gtk_rpcstat_cb(GtkAction *action _U_, gpointer user_data _U_) static stat_tap_ui rpcstat_ui = { - REGISTER_STAT_GROUP_GENERIC, + REGISTER_STAT_GROUP_RESPONSE_TIME, NULL, "rpc,srt", gtk_rpcstat_init, diff --git a/ui/gtk/scsi_stat.c b/ui/gtk/scsi_stat.c deleted file mode 100644 index 23a50e2651..0000000000 --- a/ui/gtk/scsi_stat.c +++ /dev/null @@ -1,312 +0,0 @@ -/* scsi_stat.c - * scsi_stat 2006 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/* This module provides rpc call/reply SRT (Server Response Time) statistics - * to Wireshark. - */ - -#include "config.h" - - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/tap.h> -#include <epan/conversation.h> -#include <epan/dissectors/packet-scsi.h> -#include <epan/dissectors/packet-scsi-sbc.h> -#include <epan/dissectors/packet-scsi-ssc.h> -#include <epan/dissectors/packet-scsi-smc.h> -#include <epan/dissectors/packet-scsi-osd.h> -#include <epan/dissectors/packet-scsi-mmc.h> - -#include "ui/simple_dialog.h" -#include <epan/stat_groups.h> - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/main.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" - - -void register_tap_listener_gtkscsistat(void); - -/* used to keep track of the statistics for an entire scsi command set */ -typedef struct _scsistat_t { - GtkWidget *win; - srt_stat_table srt_table; - guint8 cmdset; - value_string_ext *cdbnames_ext; - const char *prog; -} scsistat_t; - -static guint8 scsi_program = 0; - -enum -{ - SCSI_STAT_PROG_LABEL_SBC, - SCSI_STAT_PROG_LABEL_SSC, - SCSI_STAT_PROG_LABEL_MMC -}; - - -static char * -scsistat_gen_title(scsistat_t *rs) -{ - char *display_name; - char *title; - - display_name = cf_get_display_name(&cfile); - title = g_strdup_printf("SCSI Service Response Time statistics for %s: %s", - rs->prog, display_name); - g_free(display_name); - return title; -} - -static void -scsistat_set_title(scsistat_t *rs) -{ - char *title; - - title = scsistat_gen_title(rs); - gtk_window_set_title(GTK_WINDOW(rs->win), title); - g_free(title); -} - -static void -scsistat_reset(void *arg) -{ - scsistat_t *rs = (scsistat_t *)arg; - - reset_srt_table_data(&rs->srt_table); - scsistat_set_title(rs); -} - - -static int -scsistat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const void *arg2) -{ - scsistat_t *rs = (scsistat_t *)arg; - const scsi_task_data_t *ri = (const scsi_task_data_t *)arg2; - - /* we are only interested in response packets */ - if(ri->type!=SCSI_PDU_TYPE_RSP){ - return 0; - } - /* we are only interested in a specific commandset */ - if( (!ri->itl) || ((ri->itl->cmdset&SCSI_CMDSET_MASK)!=rs->cmdset) ){ - return 0; - } - /* check that the opcode looks sane */ - if( (!ri->itlq) || (ri->itlq->scsi_opcode>255) ){ - return 0; - } - - add_srt_table_data(&rs->srt_table, ri->itlq->scsi_opcode, &ri->itlq->fc_time, pinfo); - - return 1; -} - -static void -scsistat_draw(void *arg) -{ - scsistat_t *rs = (scsistat_t *)arg; - - draw_srt_table_data(&rs->srt_table); -} - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - scsistat_t *rs = (scsistat_t *)data; - - remove_tap_listener(rs); - - free_srt_table_data(&rs->srt_table); - g_free(rs); -} - - -/* When called, this function will create a new instance of gtk2-scsistat. - */ -static void -gtk_scsistat_init(const char *opt_arg, void* userdata _U_) -{ - scsistat_t *rs; - guint32 i; - char *title_string; - char *filter_string; - GtkWidget *vbox; - GtkWidget *stat_label; - GtkWidget *filter_label; - GtkWidget *bbox; - GtkWidget *close_bt; - int program, pos; - const char *filter = NULL; - GString *error_string; - const char *hf_name = NULL; - - pos = 0; - if(sscanf(opt_arg,"scsi,srt,%d,%n",&program,&pos) == 1){ - if(pos){ - filter = opt_arg+pos; - } else { - filter = NULL; - } - } else { - fprintf(stderr, "wireshark: invalid \"-z scsi,srt,<cmdset>[,<filter>]\" argument\n"); - exit(1); - } - - scsi_program = program; - rs = (scsistat_t *)g_malloc(sizeof(scsistat_t)); - rs->cmdset = program; - switch(program){ - case SCSI_DEV_SBC: - rs->prog = "SBC (disk)"; - rs->cdbnames_ext = &scsi_sbc_vals_ext; - hf_name = "scsi_sbc.opcode"; - break; - case SCSI_DEV_SSC: - rs->prog = "SSC (tape)"; - rs->cdbnames_ext = &scsi_ssc_vals_ext; - hf_name = "scsi_ssc.opcode"; - break; - case SCSI_DEV_CDROM: - rs->prog = "MMC (cd/dvd)"; - rs->cdbnames_ext = &scsi_mmc_vals_ext; - hf_name = "scsi_mmc.opcode"; - break; - case SCSI_DEV_SMC: - rs->prog = "SMC (tape robot)"; - rs->cdbnames_ext = &scsi_smc_vals_ext; - hf_name = "scsi_smc.opcode"; - break; - case SCSI_DEV_OSD: - rs->prog = "OSD (object based)"; - rs->cdbnames_ext = &scsi_osd_vals_ext; - hf_name = "scsi_osd.opcode"; - break; - } - - rs->win = dlg_window_new("scsi-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(rs->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(rs->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - scsistat_set_title(rs); - - vbox = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(rs->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - title_string = scsistat_gen_title(rs); - stat_label = gtk_label_new(title_string); - g_free(title_string); - gtk_box_pack_start(GTK_BOX(vbox), stat_label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - filter_label = gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(filter_label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), filter_label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(rs->win); - - init_srt_table(&rs->srt_table, 256, vbox, hf_name); - - for(i=0; i<256; i++){ - gchar* tmp_str = val_to_str_ext_wmem(NULL, i, rs->cdbnames_ext, "Unknown-0x%02x"); - init_srt_table_row(&rs->srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - - error_string = register_tap_listener("scsi", rs, filter, 0, scsistat_reset, scsistat_packet, scsistat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - free_srt_table_data(&rs->srt_table); - g_free(rs); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(rs->win, close_bt, window_cancel_button_cb); - - g_signal_connect(rs->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(rs->win, "destroy", G_CALLBACK(win_destroy_cb), rs); - - gtk_widget_show_all(rs->win); - window_present(rs->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(rs->win)); -} - -static const enum_val_t scsi_command_sets[] = { - { "sbc", "SBC (disk)", SCSI_DEV_SBC }, - { "ssc", "SSC (tape)", SCSI_DEV_SSC }, - { "mmc", "MMC (cd/dvd)", SCSI_DEV_CDROM }, - { "smc", "SMC (tape robot)", SCSI_DEV_SMC }, - { "osd", "OSD (object based)", SCSI_DEV_OSD }, - { NULL, NULL, 0 } -}; - -static tap_param scsi_stat_params[] = { - { PARAM_ENUM, "cmdset", "Command set", scsi_command_sets, FALSE }, - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg scsi_stat_dlg = { - "SCSI SRT Statistics", - "scsi,srt", - gtk_scsistat_init, - -1, - G_N_ELEMENTS(scsi_stat_params), - scsi_stat_params -}; - -void -register_tap_listener_gtkscsistat(void) -{ - register_param_stat(&scsi_stat_dlg, "SCSI", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/gtk/service_response_time_table.c b/ui/gtk/service_response_time_table.c index 0915707c4d..efc3869246 100644 --- a/ui/gtk/service_response_time_table.c +++ b/ui/gtk/service_response_time_table.c @@ -24,15 +24,24 @@ #include "config.h" +#include <gtk/gtk.h> #include "epan/packet_info.h" +#include "epan/proto.h" #include "ui/simple_dialog.h" #include "ui/utf8_entities.h" -#include "ui/gtk/service_response_time_table.h" #include "ui/gtk/filter_utils.h" #include "ui/gtk/gui_utils.h" +#include "ui/gtk/dlg_utils.h" +#include "ui/gtk/service_response_time_table.h" +#include "ui/gtk/tap_param_dlg.h" +#include "ui/gtk/main.h" + +/* XXX - Part of temporary hack */ +#include "epan/conversation.h" +#include "epan/dissectors/packet-scsi.h" #define NANOSECS_PER_SEC 1000000000 @@ -48,11 +57,20 @@ enum N_COLUMNS }; +typedef struct _srt_t { + const char *type; + const char *filter; + gtk_srt_t gtk_data; + register_srt_t* srt; + srt_data_t data; +} srt_t; + static void srt_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callback_action) { - srt_stat_table *rst = (srt_stat_table *)callback_data; + gtk_srt_table_t *rst_table = (gtk_srt_table_t*)callback_data; + srt_stat_table* rst = rst_table->rst; char *str = NULL; GtkTreeIter iter; GtkTreeModel *model; @@ -63,7 +81,7 @@ srt_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callba return; } - sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(rst->table)); + sel = gtk_tree_view_get_selection (GTK_TREE_VIEW(rst_table->table)); if (!gtk_tree_selection_get_selected(sel, &model, &iter)) return; @@ -82,7 +100,7 @@ srt_select_filter_cb(GtkWidget *widget _U_, gpointer callback_data, guint callba } static gboolean -srt_show_popup_menu_cb(void *widg _U_, GdkEvent *event, srt_stat_table *rst) +srt_show_popup_menu_cb(void *widg _U_, GdkEvent *event, gtk_srt_table_t *rst) { GdkEventButton *bevent = (GdkEventButton *)event; @@ -291,7 +309,7 @@ static const GtkActionEntry service_resp_t__popup_entries[] = { }; static void -srt_create_popup_menu(srt_stat_table *rst) +srt_create_popup_menu(gtk_srt_table_t* rst_table) { GtkUIManager *ui_manager; GtkActionGroup *action_group; @@ -301,7 +319,7 @@ srt_create_popup_menu(srt_stat_table *rst) gtk_action_group_add_actions (action_group, /* the action group */ (GtkActionEntry *)service_resp_t__popup_entries, /* an array of action descriptions */ G_N_ELEMENTS(service_resp_t__popup_entries), /* the number of entries */ - rst); /* data to pass to the action callbacks */ + rst_table); /* data to pass to the action callbacks */ ui_manager = gtk_ui_manager_new (); gtk_ui_manager_insert_action_group (ui_manager, @@ -315,9 +333,9 @@ srt_create_popup_menu(srt_stat_table *rst) g_error_free (error); error = NULL; } - rst->menu = gtk_ui_manager_get_widget(ui_manager, "/ServiceRespTFilterPopup"); - g_signal_connect(rst->table, "button_press_event", G_CALLBACK(srt_show_popup_menu_cb), rst); + rst_table->menu = gtk_ui_manager_get_widget(ui_manager, "/ServiceRespTFilterPopup"); + g_signal_connect(rst_table->table, "button_press_event", G_CALLBACK(srt_show_popup_menu_cb), rst_table); } /* ---------------- */ @@ -388,11 +406,57 @@ srt_time_sort_func(GtkTreeModel *model, return ret; } -/* -XXX Resizable columns are ugly when there's more than on table cf. SMB -*/ +static void +srt_set_title(srt_t *ss) +{ + gchar *str; + + str = g_strdup_printf("%s Service Response Time statistics", proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(ss->srt)))); + set_window_title(ss->gtk_data.win, str); + g_free(str); +} + + +static gtk_srt_table_t* +get_gtk_table_from_srt(srt_stat_table* rst, gtk_srt_t* gtk) +{ + guint i; + gtk_srt_table_t* srt; + + for (i = 0; i < gtk->gtk_srt_array->len; i++) { + srt = g_array_index(gtk->gtk_srt_array, gtk_srt_table_t*, i); + + if (srt->rst == rst) + return srt; + } + + return NULL; +} + void -init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, const char *filter_string) +free_table_data(srt_stat_table* rst, void* gui_data) +{ + gtk_srt_t* gtk_data = (gtk_srt_t*)gui_data; + gtk_srt_table_t* gtk_table = get_gtk_table_from_srt(rst, gtk_data); + g_assert(gtk_table); + + g_free(gtk_table); +} + +static void +win_destroy_cb(GtkWindow *win _U_, gpointer data) +{ + srt_t *ss=(srt_t *)data; + + remove_tap_listener(&ss->data); + + free_srt_table(ss->srt, ss->data.srt_array, free_table_data, &ss->gtk_data); + + g_free(ss); +} + +void +init_gtk_srt_table(srt_stat_table* rst, void* gui_data) { int i; GtkListStore *store; @@ -400,10 +464,34 @@ init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, const char * GtkTreeViewColumn *column; GtkCellRenderer *renderer; GtkTreeSortable *sortable; + GtkWidget *label; + GtkWidget *tab_page; + gtk_srt_t *ss = (gtk_srt_t*)gui_data; + GtkWidget *parent_box = ss->vbox; GtkTreeSelection *sel; + gtk_srt_table_t *gtk_table_data = g_new0(gtk_srt_table_t, 1); static const char *default_titles[] = { "Index", "Procedure", "Calls", "Min SRT (s)", "Max SRT (s)", "Avg SRT (s)", "Sum SRT (s)" }; + /* Create GTK data for the table here */ + gtk_table_data->rst = rst; + g_array_insert_val(ss->gtk_srt_array, ss->gtk_srt_array->len, gtk_table_data); + + /* Create the label for the table here */ + label=gtk_label_new(rst->name); + if (ss->main_nb == NULL) + { + gtk_box_pack_start(GTK_BOX(ss->vbox), label, FALSE, FALSE, 0); + } + else + { + GtkWidget *tab_label=gtk_label_new(rst->short_name); + tab_page = ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 6, FALSE); + gtk_notebook_append_page(GTK_NOTEBOOK(ss->main_nb), tab_page, tab_label); + gtk_box_pack_start(GTK_BOX(tab_page), label, FALSE, FALSE, 0); + parent_box = tab_page; + } + /* Create the store */ store = gtk_list_store_new (N_COLUMNS, /* Total number of columns */ G_TYPE_INT, /* Index */ @@ -416,17 +504,12 @@ init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, const char * /* Create a view */ tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); - rst->table = GTK_TREE_VIEW(tree); + gtk_table_data->table = GTK_TREE_VIEW(tree); sortable = GTK_TREE_SORTABLE(store); /* The view now holds a reference. We can get rid of our own reference */ g_object_unref (G_OBJECT (store)); - if(filter_string){ - rst->filter_string=g_strdup(filter_string); - } else { - rst->filter_string=NULL; - } for (i = 0; i < N_COLUMNS; i++) { renderer = gtk_cell_renderer_text_new (); if (i != PROCEDURE_COLUMN) { @@ -446,15 +529,18 @@ init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, const char * column = gtk_tree_view_column_new_with_attributes (default_titles[i], renderer, NULL); gtk_tree_view_column_set_cell_data_func(column, renderer, srt_avg_func, GINT_TO_POINTER(i), NULL); break; - default: - column = gtk_tree_view_column_new_with_attributes (default_titles[i], renderer, "text", + case PROCEDURE_COLUMN: + column = gtk_tree_view_column_new_with_attributes (((rst->proc_column_name != NULL) ? rst->proc_column_name : default_titles[i]), renderer, "text", i, NULL); break; + default: + column = gtk_tree_view_column_new_with_attributes (default_titles[i], renderer, "text", i, NULL); + break; } gtk_tree_view_column_set_sort_column_id(column, i); gtk_tree_view_column_set_resizable(column, TRUE); - gtk_tree_view_append_column (rst->table, column); + gtk_tree_view_append_column (gtk_table_data->table, column); if (i == CALLS_COLUMN) { /* XXX revert order sort */ gtk_tree_view_column_clicked(column); @@ -462,156 +548,315 @@ init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, const char * } } - rst->scrolled_window=scrolled_window_new(NULL, NULL); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(rst->scrolled_window), + gtk_table_data->scrolled_window=scrolled_window_new(NULL, NULL); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtk_table_data->scrolled_window), GTK_SHADOW_IN); - gtk_container_add(GTK_CONTAINER(rst->scrolled_window), GTK_WIDGET (rst->table)); - gtk_box_pack_start(GTK_BOX(vbox), rst->scrolled_window, TRUE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(gtk_table_data->scrolled_window), GTK_WIDGET (gtk_table_data->table)); + gtk_box_pack_start(GTK_BOX(parent_box), gtk_table_data->scrolled_window, TRUE, TRUE, 0); - gtk_tree_view_set_reorderable (rst->table, FALSE); + gtk_tree_view_set_reorderable (gtk_table_data->table, FALSE); /* Now enable the sorting of each column */ - gtk_tree_view_set_rules_hint(rst->table, TRUE); - gtk_tree_view_set_headers_clickable(rst->table, TRUE); + gtk_tree_view_set_rules_hint(gtk_table_data->table, TRUE); + gtk_tree_view_set_headers_clickable(gtk_table_data->table, TRUE); - gtk_widget_show(rst->scrolled_window); - - rst->num_procs=num_procs; - rst->procedures=(srt_procedure_t *)g_malloc(sizeof(srt_procedure_t)*num_procs); - for(i=0;i<num_procs;i++){ - time_stat_init(&rst->procedures[i].stats); - rst->procedures[i].index = 0; - rst->procedures[i].procedure = NULL; - } + gtk_widget_show(gtk_table_data->scrolled_window); - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(rst->table)); + sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtk_table_data->table)); gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); + /* create popup menu for this table */ if(rst->filter_string){ - srt_create_popup_menu(rst); + srt_create_popup_menu(gtk_table_data); } } void -init_srt_table_row(srt_stat_table *rst, int indx, const char *procedure) -{ - /* we have discovered a new procedure. Extend the table accordingly */ - if(indx>=rst->num_procs){ - int old_num_procs=rst->num_procs; - int i; - - rst->num_procs=indx+1; - rst->procedures=(srt_procedure_t *)g_realloc(rst->procedures, sizeof(srt_procedure_t)*(rst->num_procs)); - for(i=old_num_procs;i<rst->num_procs;i++){ - time_stat_init(&rst->procedures[i].stats); - rst->procedures[i].index = i; - rst->procedures[i].procedure=NULL; - } - } - rst->procedures[indx].index = indx; - rst->procedures[indx].procedure=g_strdup(procedure); -} +draw_srt_table_data(srt_stat_table *rst, gtk_srt_t* gtk_data) +{ + int idx, new_idx; + GtkTreeIter iter; + gboolean first = TRUE; + gtk_srt_table_t* gtk_table; + GtkListStore *store; + gboolean iter_valid; -void -add_srt_table_data(srt_stat_table *rst, int indx, const nstime_t *req_time, packet_info *pinfo) -{ - srt_procedure_t *rp; - nstime_t t, delta; - - g_assert(indx >= 0 && indx < rst->num_procs); - rp=&rst->procedures[indx]; - - /* - * If the count of calls for this procedure is currently zero, it's - * going to become non-zero, so add a row for it (we don't want - * rows for procedures that have no calls - especially if the - * procedure has no calls because the index doesn't correspond - * to a procedure, but is an unused/reserved value). - * - * (Yes, this means that the rows aren't in order by anything - * interesting. That's why we have the table sorted by a column.) - */ + gtk_table = get_gtk_table_from_srt(rst, gtk_data); + g_assert(gtk_table); - if (rp->stats.num==0){ - GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(rst->table)); - gtk_list_store_append(store, &rp->iter); - gtk_list_store_set(store, &rp->iter, - INDEX_COLUMN, rp->index, - PROCEDURE_COLUMN, rp->procedure, - CALLS_COLUMN, rp->stats.num, - MIN_SRT_COLUMN, NULL, - MAX_SRT_COLUMN, NULL, - AVG_SRT_COLUMN, (guint64)0, - SUM_SRT_COLUMN, (guint64)0, - -1); - } + store = GTK_LIST_STORE(gtk_tree_view_get_model(gtk_table->table)); + iter_valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); - /* calculate time delta between request and reply */ - t=pinfo->fd->abs_ts; - nstime_delta(&delta, &t, req_time); + new_idx = gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL); - time_stat_update(&rp->stats, &delta, pinfo); -} + /* Update list items (which may not be in "idx" order), then add new items */ + while (iter_valid || (new_idx < rst->num_procs)) { + srt_procedure_t* procedure; + guint64 td; + guint64 sum; -void -draw_srt_table_data(srt_stat_table *rst) -{ - int i; - guint64 td; - guint64 sum; - GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(rst->table)); + if (iter_valid) { + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, INDEX_COLUMN, &idx, -1); + } else { + idx = new_idx; + new_idx++; + } - for(i=0;i<rst->num_procs;i++){ - /* ignore procedures with no calls (they don't have rows) */ - if(rst->procedures[i].stats.num==0){ + procedure = &rst->procedures[idx]; + if ((procedure->procedure == NULL) || (procedure->stats.num == 0)) { + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); continue; } + + if (first) { + g_object_ref(store); + gtk_tree_view_set_model(GTK_TREE_VIEW(gtk_table->table), NULL); + + first = FALSE; + } + /* Scale the average SRT in units of 1us and round to the nearest us. - tot.secs is a time_t which may be 32 or 64 bits (or even floating) - depending uon the platform. After casting tot.secs to 64 bits, it - would take a capture with a duration of over 136 *years* to - overflow the secs portion of td. */ - td = ((guint64)(rst->procedures[i].stats.tot.secs))*NANOSECS_PER_SEC + rst->procedures[i].stats.tot.nsecs; + tot.secs is a time_t which may be 32 or 64 bits (or even floating) + depending uon the platform. After casting tot.secs to 64 bits, it + would take a capture with a duration of over 136 *years* to + overflow the secs portion of td. */ + td = ((guint64)(procedure->stats.tot.secs))*NANOSECS_PER_SEC + procedure->stats.tot.nsecs; sum = (td + 500) / 1000; - td = ((td / rst->procedures[i].stats.num) + 500) / 1000; - - gtk_list_store_set(store, &rst->procedures[i].iter, - CALLS_COLUMN, rst->procedures[i].stats.num, - MIN_SRT_COLUMN, &rst->procedures[i].stats.min, - MAX_SRT_COLUMN, &rst->procedures[i].stats.max, - AVG_SRT_COLUMN, td, - SUM_SRT_COLUMN, sum, - -1); + td = ((td / procedure->stats.num) + 500) / 1000; + + if (iter_valid) { + /* Existing row. Only changeable entries */ + + gtk_list_store_set(store, &iter, + PROCEDURE_COLUMN, procedure->procedure, + CALLS_COLUMN, procedure->stats.num, + MIN_SRT_COLUMN, &procedure->stats.min, + MAX_SRT_COLUMN, &procedure->stats.max, + AVG_SRT_COLUMN, td, + SUM_SRT_COLUMN, sum, + -1); + } else { + /* New row. All entries, including fixed ones */ + gtk_list_store_insert_with_values(store, &iter, G_MAXINT, + PROCEDURE_COLUMN, procedure->procedure, + CALLS_COLUMN, procedure->stats.num, + MIN_SRT_COLUMN, &procedure->stats.min, + MAX_SRT_COLUMN, &procedure->stats.max, + AVG_SRT_COLUMN, td, + SUM_SRT_COLUMN, sum, + INDEX_COLUMN, idx, + -1); + } + + iter_valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter); + } + + if (!first) { + gtk_tree_view_set_model(GTK_TREE_VIEW(gtk_table->table), GTK_TREE_MODEL(store)); + g_object_unref(store); } } +static void +srt_draw(void *arg) +{ + guint i = 0; + srt_stat_table *srt_table; + srt_data_t *srt = (srt_data_t*)arg; + srt_t *ss = (srt_t*)srt->user_data; + + for (i = 0; i < srt->srt_array->len; i++) + { + srt_table = g_array_index(srt->srt_array, srt_stat_table*, i); + draw_srt_table_data(srt_table, &ss->gtk_data); + } +} void -reset_srt_table_data(srt_stat_table *rst) +reset_table_data(srt_stat_table* rst, void* gui_data) { - int i; GtkListStore *store; + gtk_srt_t* gtk_data = (gtk_srt_t*)gui_data; + gtk_srt_table_t* gtk_table = get_gtk_table_from_srt(rst, gtk_data); + g_assert(gtk_table); - for(i=0;i<rst->num_procs;i++){ - time_stat_init(&rst->procedures[i].stats); - } - store = GTK_LIST_STORE(gtk_tree_view_get_model(rst->table)); + store = GTK_LIST_STORE(gtk_tree_view_get_model(gtk_table->table)); gtk_list_store_clear(store); } -void -free_srt_table_data(srt_stat_table *rst) +static void +srt_reset(void *arg) { - int i; + srt_data_t *srt = (srt_data_t*)arg; + srt_t *ss = (srt_t *)srt->user_data; + + reset_srt_table(ss->data.srt_array, reset_table_data, &ss->gtk_data); + + srt_set_title(ss); +} + +static void +init_srt_tables(register_srt_t* srt, const char *filter) +{ + srt_t *ss; + gchar *str; + GtkWidget *label; + char *filter_string; + GString *error_string; + GtkWidget *bbox; + GtkWidget *close_bt; + + ss = g_new0(srt_t, 1); - for(i=0;i<rst->num_procs;i++){ - g_free(rst->procedures[i].procedure); - rst->procedures[i].procedure=NULL; + str = g_strdup_printf("%s-stat", proto_get_protocol_filter_name(get_srt_proto_id(srt))); + ss->gtk_data.win=dlg_window_new(str); /* transient_for top_level */ + g_free(str); + gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->gtk_data.win), TRUE); + gtk_window_set_default_size(GTK_WINDOW(ss->gtk_data.win), SRT_PREFERRED_WIDTH, 600); + + str = g_strdup_printf("%s Service Response Time statistics", proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt)))); + set_window_title(ss->gtk_data.win, str); + + ss->gtk_data.vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); + gtk_container_add(GTK_CONTAINER(ss->gtk_data.win), ss->gtk_data.vbox); + gtk_container_set_border_width(GTK_CONTAINER(ss->gtk_data.vbox), 12); + + label=gtk_label_new(str); + gtk_box_pack_start(GTK_BOX(ss->gtk_data.vbox), label, FALSE, FALSE, 0); + g_free(str); + + filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); + label=gtk_label_new(filter_string); + gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); + g_free(filter_string); + gtk_box_pack_start(GTK_BOX(ss->gtk_data.vbox), label, FALSE, FALSE, 0); + + /* up to 3 tables is reasonable real estate to display tables. Any more than + * that and we need to switch to a tab view + */ + if (get_srt_max_tables(srt) > 3) + { + ss->gtk_data.main_nb = gtk_notebook_new(); + gtk_box_pack_start(GTK_BOX(ss->gtk_data.vbox), ss->gtk_data.main_nb, TRUE, TRUE, 0); } - g_free(rst->filter_string); - rst->filter_string=NULL; - g_free(rst->procedures); - rst->procedures=NULL; - rst->num_procs=0; + + /* We must display TOP LEVEL Widget before calling srt_table_dissector_init() */ + gtk_widget_show_all(ss->gtk_data.win); + + ss->type = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))); + ss->filter = g_strdup(filter); + ss->srt = srt; + ss->gtk_data.gtk_srt_array = g_array_new(FALSE, TRUE, sizeof(gtk_srt_table_t*)); + ss->data.srt_array = g_array_new(FALSE, TRUE, sizeof(srt_stat_table*)); + ss->data.user_data = ss; + + srt_table_dissector_init(srt, ss->data.srt_array, init_gtk_srt_table, &ss->gtk_data); + + error_string = register_tap_listener(get_srt_tap_listener_name(srt), &ss->data, filter, 0, srt_reset, get_srt_packet_func(srt), srt_draw); + if(error_string){ + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); + g_string_free(error_string, TRUE); + free_srt_table(ss->srt, ss->data.srt_array, NULL, NULL); + g_free(ss); + return; + } + + /* Button row. */ + bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); + gtk_box_pack_end(GTK_BOX(ss->gtk_data.vbox), bbox, FALSE, FALSE, 0); + + close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); + window_set_cancel_button(ss->gtk_data.win, close_bt, window_cancel_button_cb); + + g_signal_connect(ss->gtk_data.win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); + g_signal_connect(ss->gtk_data.win, "destroy", G_CALLBACK(win_destroy_cb), ss); + + gtk_widget_show_all(ss->gtk_data.win); + window_present(ss->gtk_data.win); + + cf_retap_packets(&cfile); + gdk_window_raise(gtk_widget_get_window(ss->gtk_data.win)); +} + +static void +gtk_srtstat_init(const char *opt_arg, void *userdata _U_) +{ + gchar** dissector_name; + register_srt_t *srt; + const char *filter=NULL; + char* err; + + /* Use first comma to find dissector name */ + dissector_name = g_strsplit(opt_arg, ",", -1); + g_assert(dissector_name[0]); + + /* Use dissector name to find SRT table */ + srt = get_srt_table_by_name(dissector_name[0]); + g_assert(srt); + + srt_table_get_filter(srt, opt_arg, &filter, &err); + + if (err != NULL) + { + gchar* cmd_str = srt_table_get_tap_string(srt); + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "invalid \"-z %s,%s\" argument", cmd_str, err); + g_free(cmd_str); + g_free(err); + return; + } + + init_srt_tables(srt, filter); +} + +static tap_param srt_stat_params[] = { + { PARAM_FILTER, "filter", "Filter", NULL, TRUE } +}; + +/* XXX - Temporary hack/workaround until a more generic approach can be implemented */ +static const enum_val_t scsi_command_sets[] = { + { "sbc", "SBC (disk)", SCSI_DEV_SBC }, + { "ssc", "SSC (tape)", SCSI_DEV_SSC }, + { "mmc", "MMC (cd/dvd)", SCSI_DEV_CDROM }, + { "smc", "SMC (tape robot)", SCSI_DEV_SMC }, + { "osd", "OSD (object based)", SCSI_DEV_OSD }, + { NULL, NULL, 0 } +}; + +static tap_param scsi_stat_params[] = { + { PARAM_ENUM, "cmdset", "Command set", scsi_command_sets, FALSE }, + { PARAM_FILTER, "filter", "Filter", NULL, TRUE } +}; + + +void register_service_response_tables(gpointer data, gpointer user_data _U_) +{ + register_srt_t *srt = (register_srt_t*)data; + const char* short_name = proto_get_protocol_short_name(find_protocol_by_id(get_srt_proto_id(srt))); + tap_param_dlg* srt_dlg; + + /* XXX - These dissectors haven't been converted over to due to an "interactive input dialog" for their + tap data. Let those specific dialogs register for themselves */ + if ((strcmp(short_name, "RPC") == 0) || + (strcmp(short_name, "DCERPC") == 0)) + return; + + srt_dlg = g_new(tap_param_dlg, 1); + + srt_dlg->win_title = g_strdup_printf("%s SRT Statistics", short_name); + srt_dlg->init_string = srt_table_get_tap_string(srt); + srt_dlg->tap_init_cb = gtk_srtstat_init; + srt_dlg->index = -1; + if (get_srt_proto_id(srt) == proto_get_id_by_filter_name("scsi")) + { + srt_dlg->nparams = G_N_ELEMENTS(scsi_stat_params); + srt_dlg->params = scsi_stat_params; + } + else + { + srt_dlg->nparams = G_N_ELEMENTS(srt_stat_params); + srt_dlg->params = srt_stat_params; + } + + register_param_stat(srt_dlg, short_name, REGISTER_STAT_GROUP_RESPONSE_TIME); } diff --git a/ui/gtk/service_response_time_table.h b/ui/gtk/service_response_time_table.h index f5a6d14589..e4b1fae979 100644 --- a/ui/gtk/service_response_time_table.h +++ b/ui/gtk/service_response_time_table.h @@ -27,7 +27,7 @@ #include <gtk/gtk.h> #include "wsutil/nstime.h" -#include "epan/timestats.h" +#include "epan/srt_table.h" /** Suggested width of SRT window */ #define SRT_PREFERRED_WIDTH 650 @@ -39,68 +39,62 @@ * Helper routines common to all service response time statistics tap. */ -/** Procedure data */ -typedef struct _srt_procedure_t { - int index; - timestat_t stats; /**< stats */ - char *procedure; /**< column entries */ - GtkTreeIter iter; -} srt_procedure_t; - /** Statistics table */ -typedef struct _srt_stat_table { +typedef struct _gtk_srt_stat_table { GtkWidget *scrolled_window; /**< window widget */ GtkTreeView *table; /**< Tree view */ GtkWidget *menu; /**< context menu */ - char *filter_string; /**< append procedure number (%d) to this string - to create a display filter */ - int num_procs; /**< number of elements on procedures array */ - srt_procedure_t *procedures;/**< the procedures array */ -} srt_stat_table; + srt_stat_table stat_table; +} gtk_srt_stat_table; + +typedef struct _gtk_srt_table_t { + GtkTreeView *table; /**< Tree view */ + GtkWidget *scrolled_window; /**< window widget */ + GtkWidget *menu; /**< context menu */ + srt_stat_table* rst; /**< Used to match tables with its GUI data */ +} gtk_srt_table_t; + +typedef struct _gtk_srt_t { + GtkWidget *vbox; + GtkWidget *win; + GtkWidget *main_nb; /** Used for tab displays */ + GArray *gtk_srt_array; /**< array of gtk_srt_table_t */ +} gtk_srt_t; /** Init an srt table data structure. * * @param rst the srt table to init - * @param num_procs number of procedures - * @param vbox the corresponding GtkVBox to fill in - * @param filter_string filter string or NULL + * @param gui_data contains GTK specific data */ -void init_srt_table(srt_stat_table *rst, int num_procs, GtkWidget *vbox, - const char *filter_string); +void init_gtk_srt_table(srt_stat_table* rst, void* gui_data); -/** Init an srt table row data structure. - * - * @param rst the srt table - * @param index number of procedure - * @param procedure the procedures name - */ -void init_srt_table_row(srt_stat_table *rst, int index, const char *procedure); - -/** Add srt response to table row data. This will not draw the data! +/** Draw the srt table data. * * @param rst the srt table - * @param index number of procedure - * @param req_time the time of the corresponding request - * @param pinfo current packet info + * @param gui_data contains GTK specific data */ -void add_srt_table_data(srt_stat_table *rst, int index, const nstime_t *req_time, packet_info *pinfo); +void draw_srt_table_data(srt_stat_table *rst, gtk_srt_t* gtk_data); -/** Draw the srt table data. +/** Clean up memory of the srt table. * * @param rst the srt table + * @param gui_data contains GTK specific data */ -void draw_srt_table_data(srt_stat_table *rst); +void free_table_data(srt_stat_table* rst, void* gui_data); -/** Reset the srt table data. +/** Reset srt table data. + * Called when a tap listener is reset * * @param rst the srt table + * @param gui_data contains GTK specific data */ -void reset_srt_table_data(srt_stat_table *rst); +void reset_table_data(srt_stat_table* rst, void* gui_data); -/** Free the srt table data. +/** Register function to register dissectors that support SRT for GTK. * - * @param rst the srt table + * @param data register_srt_t* representing dissetor SRT table + * @param user_data is unused */ -void free_srt_table_data(srt_stat_table *rst); +void register_service_response_tables(gpointer data, gpointer user_data); #endif /* __SERVICE_RESPONSE_TIME_TABLE_H__ */ diff --git a/ui/gtk/smb2_stat.c b/ui/gtk/smb2_stat.c deleted file mode 100644 index a774121eb8..0000000000 --- a/ui/gtk/smb2_stat.c +++ /dev/null @@ -1,227 +0,0 @@ -/* smb2_stat.c - * smb2_stat 2005 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-smb2.h> - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - - -void register_tap_listener_gtksmb2stat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _smb2stat_t { - GtkWidget *win; - srt_stat_table smb2_srt_table; -} smb2stat_t; - -static void -smb2stat_set_title(smb2stat_t *ss) -{ - set_window_title(ss->win, "SMB2 Service Response Time statistics"); -} - -static void -smb2stat_reset(void *pss) -{ - smb2stat_t *ss=(smb2stat_t *)pss; - - reset_srt_table_data(&ss->smb2_srt_table); - smb2stat_set_title(ss); -} - -static int -smb2stat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - smb2stat_t *ss=(smb2stat_t *)pss; - const smb2_info_t *si=(const smb2_info_t *)psi; - - /* we are only interested in response packets */ - if(!(si->flags&SMB2_FLAGS_RESPONSE)){ - return 0; - } - /* if we haven't seen the request, just ignore it */ - if(!si->saved){ - return 0; - } - /* SMB2 SRT can be very inaccurate in the presence of retransmissions. Retransmitted responses - * not only add additional (bogus) transactions but also the latency associated with them. - * This can greatly inflate the maximum and average SRT stats especially in the case of - * retransmissions triggered by the expiry of the rexmit timer (RTOs). Only calculating SRT - * for the last received response accomplishes this goal without requiring the TCP pref - * "Do not call subdissectors for error packets" to be set. */ - if(si->saved->frame_req - && si->saved->frame_res==pinfo->fd->num) - add_srt_table_data(&ss->smb2_srt_table, si->opcode, &si->saved->req_time, pinfo); - else - return 0; - - return 1; -} - - - -static void -smb2stat_draw(void *pss) -{ - smb2stat_t *ss=(smb2stat_t *)pss; - - draw_srt_table_data(&ss->smb2_srt_table); -} - - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - smb2stat_t *ss=(smb2stat_t *)data; - - remove_tap_listener(ss); - - free_srt_table_data(&ss->smb2_srt_table); - g_free(ss); -} - - -static void -gtk_smb2stat_init(const char *opt_arg, void *userdata _U_) -{ - smb2stat_t *ss; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - int i; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - - if(!strncmp(opt_arg,"smb2,srt,",9)){ - filter=opt_arg+9; - } else { - filter=NULL; - } - - ss=(smb2stat_t *)g_malloc(sizeof(smb2stat_t)); - - ss->win = dlg_window_new("smb2-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(ss->win), SRT_PREFERRED_WIDTH, SRT_PREFERRED_HEIGHT); - smb2stat_set_title(ss); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(ss->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("SMB2 Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - label=gtk_label_new("SMB2 Commands"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(ss->win); - - init_srt_table(&ss->smb2_srt_table, 256, vbox, "smb2.cmd"); - for(i=0;i<256;i++){ - gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &smb2_cmd_vals_ext, "Unknown(0x%02x)"); - init_srt_table_row(&ss->smb2_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - - error_string=register_tap_listener("smb2", ss, filter, 0, smb2stat_reset, smb2stat_packet, smb2stat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(ss); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb); - - g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss); - - gtk_widget_show_all(ss->win); - window_present(ss->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(ss->win)); -} - -static tap_param smb2_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg smb2_stat_dlg = { - "SMB2 SRT Statistics", - "smb2,srt", - gtk_smb2stat_init, - -1, - G_N_ELEMENTS(smb2_stat_params), - smb2_stat_params -}; - -void -register_tap_listener_gtksmb2stat(void) -{ - register_param_stat(&smb2_stat_dlg, "SMB2", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ diff --git a/ui/gtk/smb_stat.c b/ui/gtk/smb_stat.c deleted file mode 100644 index 9724119b64..0000000000 --- a/ui/gtk/smb_stat.c +++ /dev/null @@ -1,260 +0,0 @@ -/* smb_stat.c - * smb_stat 2003 Ronnie Sahlberg - * - * 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 - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "config.h" - -#include <string.h> - -#include <gtk/gtk.h> - -#include <epan/packet_info.h> -#include <epan/value_string.h> -#include <epan/tap.h> -#include <epan/dissectors/packet-smb.h> - -#include "ui/simple_dialog.h" - -#include "ui/gtk/gui_utils.h" -#include "ui/gtk/dlg_utils.h" -#include "ui/gtk/service_response_time_table.h" -#include "ui/gtk/tap_param_dlg.h" -#include "ui/gtk/main.h" - - -void register_tap_listener_gtksmbstat(void); - -/* used to keep track of the statistics for an entire program interface */ -typedef struct _smbstat_t { - GtkWidget *win; - srt_stat_table smb_srt_table; - srt_stat_table trans2_srt_table; - srt_stat_table nt_trans_srt_table; -} smbstat_t; - -static void -smbstat_set_title(smbstat_t *ss) -{ - set_window_title(ss->win, "SMB Service Response Time statistics"); -} - -static void -smbstat_reset(void *pss) -{ - smbstat_t *ss=(smbstat_t *)pss; - - reset_srt_table_data(&ss->smb_srt_table); - reset_srt_table_data(&ss->trans2_srt_table); - reset_srt_table_data(&ss->nt_trans_srt_table); - smbstat_set_title(ss); -} - -static int -smbstat_packet(void *pss, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi) -{ - smbstat_t *ss=(smbstat_t *)pss; - const smb_info_t *si=(const smb_info_t *)psi; - - /* we are only interested in reply packets */ - if(si->request){ - return 0; - } - /* if we havnt seen the request, just ignore it */ - if(!si->sip){ - return 0; - } - - add_srt_table_data(&ss->smb_srt_table, si->cmd, &si->sip->req_time, pinfo); - - if(si->cmd==0xA0 && si->sip->extra_info_type == SMB_EI_NTI){ - smb_nt_transact_info_t *sti=(smb_nt_transact_info_t *)si->sip->extra_info; - - if(sti){ - add_srt_table_data(&ss->nt_trans_srt_table, sti->subcmd, &si->sip->req_time, pinfo); - } - } else if(si->cmd==0x32 && si->sip->extra_info_type == SMB_EI_T2I){ - smb_transact2_info_t *st2i=(smb_transact2_info_t *)si->sip->extra_info; - - if(st2i){ - add_srt_table_data(&ss->trans2_srt_table, st2i->subcmd, &si->sip->req_time, pinfo); - } - } - - return 1; -} - - - -static void -smbstat_draw(void *pss) -{ - smbstat_t *ss=(smbstat_t *)pss; - - draw_srt_table_data(&ss->smb_srt_table); - draw_srt_table_data(&ss->trans2_srt_table); - draw_srt_table_data(&ss->nt_trans_srt_table); -} - - -static void -win_destroy_cb(GtkWindow *win _U_, gpointer data) -{ - smbstat_t *ss=(smbstat_t *)data; - - remove_tap_listener(ss); - - free_srt_table_data(&ss->smb_srt_table); - free_srt_table_data(&ss->trans2_srt_table); - free_srt_table_data(&ss->nt_trans_srt_table); - g_free(ss); -} - - -static void -gtk_smbstat_init(const char *opt_arg, void *userdata _U_) -{ - smbstat_t *ss; - const char *filter=NULL; - GtkWidget *label; - char *filter_string; - GString *error_string; - int i; - GtkWidget *vbox; - GtkWidget *bbox; - GtkWidget *close_bt; - - if(!strncmp(opt_arg,"smb,srt,",8)){ - filter=opt_arg+8; - } else { - filter=NULL; - } - - ss=(smbstat_t *)g_malloc(sizeof(smbstat_t)); - - ss->win = dlg_window_new("smb-stat"); /* transient_for top_level */ - gtk_window_set_destroy_with_parent (GTK_WINDOW(ss->win), TRUE); - gtk_window_set_default_size(GTK_WINDOW(ss->win), SRT_PREFERRED_WIDTH, 600); - smbstat_set_title(ss); - - vbox=ws_gtk_box_new(GTK_ORIENTATION_VERTICAL, 3, FALSE); - gtk_container_add(GTK_CONTAINER(ss->win), vbox); - gtk_container_set_border_width(GTK_CONTAINER(vbox), 12); - - label=gtk_label_new("SMB Service Response Time statistics"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - filter_string = g_strdup_printf("Filter: %s", filter ? filter : ""); - label=gtk_label_new(filter_string); - g_free(filter_string); - gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - label=gtk_label_new("SMB Commands"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - - /* We must display TOP LEVEL Widget before calling init_srt_table() */ - gtk_widget_show_all(ss->win); - - init_srt_table(&ss->smb_srt_table, 256, vbox, "smb.cmd"); - for(i=0;i<256;i++){ - gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &smb_cmd_vals_ext, "Unknown(0x%02x)"); - init_srt_table_row(&ss->smb_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - - label=gtk_label_new("Transaction2 Sub-Commands"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - init_srt_table(&ss->trans2_srt_table, 256, vbox, "smb.trans2.cmd"); - for(i=0;i<256;i++){ - gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &trans2_cmd_vals_ext, "Unknown(0x%02x)"); - init_srt_table_row(&ss->trans2_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - - label=gtk_label_new("NT Transaction Sub-Commands"); - gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); - init_srt_table(&ss->nt_trans_srt_table, 256, vbox, "smb.nt.function"); - for(i=0;i<256;i++){ - gchar* tmp_str = val_to_str_ext_wmem(NULL, i, &nt_cmd_vals_ext, "Unknown(0x%02x)"); - init_srt_table_row(&ss->nt_trans_srt_table, i, tmp_str); - wmem_free(NULL, tmp_str); - } - - - error_string=register_tap_listener("smb", ss, filter, 0, smbstat_reset, smbstat_packet, smbstat_draw); - if(error_string){ - simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", error_string->str); - g_string_free(error_string, TRUE); - g_free(ss); - return; - } - - /* Button row. */ - bbox = dlg_button_row_new(GTK_STOCK_CLOSE, NULL); - gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); - - close_bt = (GtkWidget *)g_object_get_data(G_OBJECT(bbox), GTK_STOCK_CLOSE); - window_set_cancel_button(ss->win, close_bt, window_cancel_button_cb); - - g_signal_connect(ss->win, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); - g_signal_connect(ss->win, "destroy", G_CALLBACK(win_destroy_cb), ss); - - gtk_widget_show_all(ss->win); - window_present(ss->win); - - cf_retap_packets(&cfile); - gdk_window_raise(gtk_widget_get_window(ss->win)); -} - -static tap_param smb_stat_params[] = { - { PARAM_FILTER, "filter", "Filter", NULL, TRUE } -}; - -static tap_param_dlg smb_stat_dlg = { - "SMB SRT Statistics", - "smb,srt", - gtk_smbstat_init, - -1, - G_N_ELEMENTS(smb_stat_params), - smb_stat_params -}; - -void -register_tap_listener_gtksmbstat(void) -{ - register_param_stat(&smb_stat_dlg, "SMB", - REGISTER_STAT_GROUP_RESPONSE_TIME); -} - -/* - * Editor modelines - http://www.wireshark.org/tools/modelines.html - * - * Local variables: - * c-basic-offset: 8 - * tab-width: 8 - * indent-tabs-mode: t - * End: - * - * vi: set shiftwidth=8 tabstop=8 noexpandtab: - * :indentSize=8:tabSize=8:noTabs=false: - */ |