summaryrefslogtreecommitdiff
path: root/ui/cli
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-06-20 12:22:22 -0400
committerAnders Broman <a.broman58@gmail.com>2015-06-22 15:13:39 +0000
commit8f390d497577937dee7311f345b77c840ba42e15 (patch)
treed59679646ab38e4c22d7773cd00003719be028e7 /ui/cli
parent8b230eabddf11becf4ae895fba17f43a3415716e (diff)
downloadwireshark-8f390d497577937dee7311f345b77c840ba42e15.tar.gz
Refactor RTD stats.
Very similar to the refactoring of SRT stats, it provides more commonality of the stats for all GUI interfaces. Currently implemented for TShark and GTK. Affected dissectors: MEGACO, MGCP, Radius Change-Id: Icb73a7e603dc3502b39bf696227fcaae37d4ed21 Reviewed-on: https://code.wireshark.org/review/8998 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'ui/cli')
-rw-r--r--ui/cli/Makefile.common4
-rw-r--r--ui/cli/tap-megacostat.c163
-rw-r--r--ui/cli/tap-mgcpstat.c248
-rw-r--r--ui/cli/tap-radiusstat.c261
-rw-r--r--ui/cli/tap-rtd.c170
-rw-r--r--ui/cli/tshark-tap.h1
6 files changed, 172 insertions, 675 deletions
diff --git a/ui/cli/Makefile.common b/ui/cli/Makefile.common
index fef030038e..d903f38112 100644
--- a/ui/cli/Makefile.common
+++ b/ui/cli/Makefile.common
@@ -58,13 +58,11 @@ TSHARK_TAP_SRC = \
tap-iostat.c \
tap-iousers.c \
tap-macltestat.c \
- tap-megacostat.c \
- tap-mgcpstat.c \
tap-protocolinfo.c \
tap-protohierstat.c \
- tap-radiusstat.c \
tap-rlcltestat.c \
tap-rpcprogs.c \
+ tap-rtd.c \
tap-rtp.c \
tap-rtspstat.c \
tap-sctpchunkstat.c \
diff --git a/ui/cli/tap-megacostat.c b/ui/cli/tap-megacostat.c
deleted file mode 100644
index feae053ffe..0000000000
--- a/ui/cli/tap-megacostat.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/* tap-megacostat.c
- * mgcpstat 2003 Lars Roland
- * Copyright 2008, Ericsson AB
- * By Balint Reczey <balint.reczey@ericsson.com>
- *
- * 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 <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 "epan/gcp.h"
-#include "epan/timestats.h"
-#include <epan/prefs-int.h>
-
-#include "ui/tap-megaco-common.h"
-
-void register_tap_listener_megacostat(void);
-
-static void
-megacostat_draw(void *pms)
-{
- megacostat_t *ms = (megacostat_t *)pms;
- gchar* tmp_str;
- int i;
-
- /* printing results */
- printf("\n");
- printf("=====================================================================================================\n");
- printf("MEGACO Response Time Delay (RTD) Statistics:\n");
- printf("Filter for statistics: %s\n", ms->filter ? ms->filter : "");
- printf("Duplicate requests: %u\n", ms->req_dup_num);
- printf("Duplicate responses: %u\n", ms->rsp_dup_num);
- printf("Open requests: %u\n", ms->open_req_num);
- printf("Discarded responses: %u\n", ms->disc_rsp_num);
- printf(" Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n");
- for (i=0; i<NUM_TIMESTATS; i++) {
- if (ms->rtd[i].num) {
- tmp_str = val_to_str_wmem(NULL, i, megaco_message_type, "Other (%d)");
- printf("%5s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n",
- tmp_str, ms->rtd[i].num,
- nstime_to_msec(&(ms->rtd[i].min)), nstime_to_msec(&(ms->rtd[i].max)),
- get_average(&(ms->rtd[i].tot), ms->rtd[i].num),
- ms->rtd[i].min_num, ms->rtd[i].max_num
- );
- wmem_free(NULL, tmp_str);
- }
- }
- printf("=====================================================================================================\n");
-}
-
-
-static void
-megacostat_init(const char *opt_arg, void *userdata _U_)
-{
- megacostat_t *ms;
- int i;
- GString *error_string;
- pref_t *megaco_ctx_track, *h248_ctx_track;
-
- megaco_ctx_track = prefs_find_preference(prefs_find_module("megaco"), "ctx_info");
- h248_ctx_track = prefs_find_preference(prefs_find_module("h248"), "ctx_info");
-
- if (!megaco_ctx_track || !h248_ctx_track) {
- /* No such preferences */
- return;
- }
-
- if (!*megaco_ctx_track->varp.boolp || !*h248_ctx_track->varp.boolp) {
- printf("Track Context option at Protocols -> MEGACO and Protocols -> H248 preferences\n");
- printf("has to be set to true to enable measurement of service response times.\n");
- exit(1);
- }
-
- ms = g_new(megacostat_t, 1);
- if (!strncmp(opt_arg, "megaco,rtd,", 11)) {
- ms->filter = g_strdup(opt_arg+11);
- } else {
- ms->filter = NULL;
- }
-
- for (i=0; i<NUM_TIMESTATS; i++) {
- ms->rtd[i].num = 0;
- ms->rtd[i].min_num = 0;
- ms->rtd[i].max_num = 0;
- ms->rtd[i].min.secs = 0;
- ms->rtd[i].min.nsecs = 0;
- ms->rtd[i].max.secs = 0;
- ms->rtd[i].max.nsecs = 0;
- ms->rtd[i].tot.secs = 0;
- ms->rtd[i].tot.nsecs = 0;
- }
-
- ms->open_req_num = 0;
- ms->disc_rsp_num = 0;
- ms->req_dup_num = 0;
- ms->rsp_dup_num = 0;
-
- error_string = register_tap_listener("megaco", ms, ms->filter, 0, NULL, megacostat_packet, megacostat_draw);
- if (error_string) {
- /* error, we failed to attach to the tap. clean up */
- g_free(ms->filter);
- g_free(ms);
-
- fprintf(stderr, "tshark: Couldn't register megaco,rtd tap: %s\n",
- error_string->str);
- g_string_free(error_string, TRUE);
- exit(1);
- }
-}
-
-static stat_tap_ui megacostat_ui = {
- REGISTER_STAT_GROUP_GENERIC,
- NULL,
- "megaco,rtd",
- megacostat_init,
- 0,
- NULL
-};
-
-void
-register_tap_listener_megacostat(void)
-{
- /* We don't register this tap, if we don't have the megaco plugin loaded.*/
- if (find_tap_id("megaco")) {
- register_stat_tap_ui(&megacostat_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-mgcpstat.c b/ui/cli/tap-mgcpstat.c
deleted file mode 100644
index ad9455c05e..0000000000
--- a/ui/cli/tap-mgcpstat.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/* tap-mgcpstat.c
- * mgcpstat 2003 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 <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 "epan/dissectors/packet-mgcp.h"
-#include "epan/timestats.h"
-
-#define NUM_TIMESTATS 11
-
-void register_tap_listener_mgcpstat(void);
-
-/* used to keep track of the statistics for an entire program interface */
-typedef struct _mgcpstat_t {
- char *filter;
- timestat_t rtd[NUM_TIMESTATS];
- guint32 open_req_num;
- guint32 disc_rsp_num;
- guint32 req_dup_num;
- guint32 rsp_dup_num;
-} mgcpstat_t;
-
-static const value_string mgcp_mesage_type[] = {
- { 0, "Overall"},
- { 1, "EPCF "},
- { 2, "CRCX "},
- { 3, "MDCX "},
- { 4, "DLCX "},
- { 5, "RQNT "},
- { 6, "NTFY "},
- { 7, "AUEP "},
- { 8, "AUCX "},
- { 9, "RSIP "},
- { 0, NULL}
-};
-
-static int
-mgcpstat_packet(void *pms, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pmi)
-{
- mgcpstat_t *ms = (mgcpstat_t *)pms;
- const mgcp_info_t *mi = (const mgcp_info_t *)pmi;
- nstime_t delta;
- int ret = 0;
-
- switch (mi->mgcp_type) {
-
- case MGCP_REQUEST:
- if (mi->is_duplicate) {
- /* Duplicate is ignored */
- ms->req_dup_num++;
- }
- else {
- ms->open_req_num++;
- }
- break;
-
- case MGCP_RESPONSE:
- if (mi->is_duplicate) {
- /* Duplicate is ignored */
- ms->rsp_dup_num++;
- }
- else if (!mi->request_available) {
- /* no request was seen */
- ms->disc_rsp_num++;
- }
- else {
- ms->open_req_num--;
- /* calculate time delta between request and response */
- nstime_delta(&delta, &pinfo->fd->abs_ts, &mi->req_time);
-
- time_stat_update(&(ms->rtd[0]), &delta, pinfo);
-
- if (g_ascii_strncasecmp(mi->code, "EPCF", 4) == 0 ) {
- time_stat_update(&(ms->rtd[1]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "CRCX", 4) == 0 ) {
- time_stat_update(&(ms->rtd[2]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "MDCX", 4) == 0 ) {
- time_stat_update(&(ms->rtd[3]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "DLCX", 4) == 0 ) {
- time_stat_update(&(ms->rtd[4]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "RQNT", 4) == 0 ) {
- time_stat_update(&(ms->rtd[5]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "NTFY", 4) == 0 ) {
- time_stat_update(&(ms->rtd[6]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "AUEP", 4) == 0 ) {
- time_stat_update(&(ms->rtd[7]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "AUCX", 4) == 0 ) {
- time_stat_update(&(ms->rtd[8]), &delta, pinfo);
- }
- else if (g_ascii_strncasecmp(mi->code, "RSIP", 4) == 0 ) {
- time_stat_update(&(ms->rtd[9]), &delta, pinfo);
- }
- else {
- time_stat_update(&(ms->rtd[10]), &delta, pinfo);
- }
-
- ret = 1;
- }
- break;
-
- default:
- break;
- }
-
- return ret;
-}
-
-static void
-mgcpstat_draw(void *pms)
-{
- mgcpstat_t *ms = (mgcpstat_t *)pms;
- gchar* tmp_str;
- int i;
-
- /* printing results */
- printf("\n");
- printf("=====================================================================================================\n");
- printf("MGCP Response Time Delay (RTD) Statistics:\n");
- printf("Filter for statistics: %s\n", ms->filter ? ms->filter : "");
- printf("Duplicate requests: %u\n", ms->req_dup_num);
- printf("Duplicate responses: %u\n", ms->rsp_dup_num);
- printf("Open requests: %u\n", ms->open_req_num);
- printf("Discarded responses: %u\n", ms->disc_rsp_num);
- printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n");
- for (i=0; i<NUM_TIMESTATS; i++) {
- if (ms->rtd[i].num) {
- tmp_str = val_to_str_wmem(NULL, i, mgcp_mesage_type, "Other (%d)");
- printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n",
- tmp_str, ms->rtd[i].num,
- nstime_to_msec(&(ms->rtd[i].min)), nstime_to_msec(&(ms->rtd[i].max)),
- get_average(&(ms->rtd[i].tot), ms->rtd[i].num),
- ms->rtd[i].min_num, ms->rtd[i].max_num
- );
- wmem_free(NULL, tmp_str);
- }
- }
- printf("=====================================================================================================\n");
-}
-
-
-static void
-mgcpstat_init(const char *opt_arg, void *userdata _U_)
-{
- mgcpstat_t *ms;
- int i;
- GString *error_string;
-
- ms = g_new(mgcpstat_t, 1);
- if (!strncmp(opt_arg, "mgcp,rtd,", 9)) {
- ms->filter = g_strdup(opt_arg+9);
- } else {
- ms->filter = NULL;
- }
-
- for (i=0; i<NUM_TIMESTATS; i++) {
- ms->rtd[i].num = 0;
- ms->rtd[i].min_num = 0;
- ms->rtd[i].max_num = 0;
- ms->rtd[i].min.secs = 0;
- ms->rtd[i].min.nsecs = 0;
- ms->rtd[i].max.secs = 0;
- ms->rtd[i].max.nsecs = 0;
- ms->rtd[i].tot.secs = 0;
- ms->rtd[i].tot.nsecs = 0;
- }
-
- ms->open_req_num = 0;
- ms->disc_rsp_num = 0;
- ms->req_dup_num = 0;
- ms->rsp_dup_num = 0;
-
- error_string = register_tap_listener("mgcp", ms, ms->filter, 0, NULL, mgcpstat_packet, mgcpstat_draw);
- if (error_string) {
- /* error, we failed to attach to the tap. clean up */
- g_free(ms->filter);
- g_free(ms);
-
- fprintf(stderr, "tshark: Couldn't register mgcp,rtd tap: %s\n",
- error_string->str);
- g_string_free(error_string, TRUE);
- exit(1);
- }
-}
-
-static stat_tap_ui mgcpstat_ui = {
- REGISTER_STAT_GROUP_GENERIC,
- NULL,
- "mgcp,rtd",
- mgcpstat_init,
- 0,
- NULL
-};
-
-void
-register_tap_listener_mgcpstat(void)
-{
- /* We don't register this tap, if we don't have the mgcp plugin loaded.*/
- if (find_tap_id("mgcp")) {
- register_stat_tap_ui(&mgcpstat_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-radiusstat.c b/ui/cli/tap-radiusstat.c
deleted file mode 100644
index 2514ef43bd..0000000000
--- a/ui/cli/tap-radiusstat.c
+++ /dev/null
@@ -1,261 +0,0 @@
-/* tap-radiusstat.c
- * Copyright 2006 Alejandro Vaquero <alejandrovaquero@yahoo.com>
- *
- * 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 <epan/dissectors/packet-radius.h>
-#include "epan/timestats.h"
-
-void register_tap_listener_radiusstat(void);
-
-typedef enum _radius_category {
- RADIUS_CAT_OVERALL = 0,
- RADIUS_CAT_ACCESS,
- RADIUS_CAT_ACCOUNTING,
- RADIUS_CAT_PASSWORD,
- RADIUS_CAT_RESOURCE_FREE,
- RADIUS_CAT_RESOURCE_QUERY,
- RADIUS_CAT_NAS_REBOOT,
- RADIUS_CAT_EVENT,
- RADIUS_CAT_DISCONNECT,
- RADIUS_CAT_COA,
- RADIUS_CAT_OTHERS,
- RADIUS_CAT_NUM_TIMESTATS
-} radius_category;
-
-/* used to keep track of the statistics for an entire program interface */
-typedef struct _radiusstat_t {
- char *filter;
- timestat_t rtd[RADIUS_CAT_NUM_TIMESTATS];
- guint32 open_req_num;
- guint32 disc_rsp_num;
- guint32 req_dup_num;
- guint32 rsp_dup_num;
-} radiusstat_t;
-
-
-
-
-static const value_string radius_message_code[] = {
- { RADIUS_CAT_OVERALL, "Overall "},
- { RADIUS_CAT_ACCESS, "Access "},
- { RADIUS_CAT_ACCOUNTING, "Accounting "},
- { RADIUS_CAT_PASSWORD, "Password "},
- { RADIUS_CAT_RESOURCE_FREE, "Resource Free "},
- { RADIUS_CAT_RESOURCE_QUERY, "Resource Query"},
- { RADIUS_CAT_NAS_REBOOT, "NAS Reboot "},
- { RADIUS_CAT_EVENT, "Event "},
- { RADIUS_CAT_DISCONNECT, "Disconnect "},
- { RADIUS_CAT_COA, "CoA "},
- { RADIUS_CAT_OTHERS, "Other "},
- { 0, NULL}
-};
-
-static int
-radiusstat_packet(void *prs, packet_info *pinfo, epan_dissect_t *edt _U_, const void *pri)
-{
- radiusstat_t *rs = (radiusstat_t *)prs;
- const radius_info_t *ri = (const radius_info_t *)pri;
- nstime_t delta;
- int ret = 0;
-
- switch (ri->code) {
-
- case RADIUS_PKT_TYPE_ACCESS_REQUEST:
- case RADIUS_PKT_TYPE_ACCOUNTING_REQUEST:
- case RADIUS_PKT_TYPE_PASSWORD_REQUEST:
- case RADIUS_PKT_TYPE_RESOURCE_FREE_REQUEST:
- case RADIUS_PKT_TYPE_RESOURCE_QUERY_REQUEST:
- case RADIUS_PKT_TYPE_NAS_REBOOT_REQUEST:
- case RADIUS_PKT_TYPE_EVENT_REQUEST:
- case RADIUS_PKT_TYPE_DISCONNECT_REQUEST:
- case RADIUS_PKT_TYPE_COA_REQUEST:
- if (ri->is_duplicate) {
- /* Duplicate is ignored */
- rs->req_dup_num++;
- }
- else {
- rs->open_req_num++;
- }
- break;
-
- case RADIUS_PKT_TYPE_ACCESS_ACCEPT:
- case RADIUS_PKT_TYPE_ACCESS_REJECT:
- case RADIUS_PKT_TYPE_ACCOUNTING_RESPONSE:
- case RADIUS_PKT_TYPE_PASSWORD_ACK:
- case RADIUS_PKT_TYPE_PASSWORD_REJECT:
- case RADIUS_PKT_TYPE_RESOURCE_FREE_RESPONSE:
- case RADIUS_PKT_TYPE_RESOURCE_QUERY_RESPONSE:
- case RADIUS_PKT_TYPE_NAS_REBOOT_RESPONSE:
- case RADIUS_PKT_TYPE_EVENT_RESPONSE:
- case RADIUS_PKT_TYPE_DISCONNECT_ACK:
- case RADIUS_PKT_TYPE_DISCONNECT_NAK:
- case RADIUS_PKT_TYPE_COA_ACK:
- case RADIUS_PKT_TYPE_COA_NAK:
- if (ri->is_duplicate) {
- /* Duplicate is ignored */
- rs->rsp_dup_num++;
- }
- else if (!ri->request_available) {
- /* no request was seen */
- rs->disc_rsp_num++;
- }
- else {
- rs->open_req_num--;
- /* calculate time delta between request and response */
- nstime_delta(&delta, &pinfo->fd->abs_ts, &ri->req_time);
-
- time_stat_update(&(rs->rtd[RADIUS_CAT_OVERALL]), &delta, pinfo);
-
- if (ri->code == RADIUS_PKT_TYPE_ACCESS_ACCEPT || ri->code == RADIUS_PKT_TYPE_ACCESS_REJECT) {
- time_stat_update(&(rs->rtd[RADIUS_CAT_ACCESS]), &delta, pinfo);
- }
- else if (ri->code == RADIUS_PKT_TYPE_ACCOUNTING_RESPONSE) {
- time_stat_update(&(rs->rtd[RADIUS_CAT_ACCOUNTING]), &delta, pinfo);
- }
- else {
- time_stat_update(&(rs->rtd[RADIUS_CAT_OTHERS]), &delta, pinfo);
- }
-
- ret = 1;
- }
- break;
-
- default:
- break;
- }
-
- return ret;
-}
-
-static void
-radiusstat_draw(void *prs)
-{
- radiusstat_t *rs = (radiusstat_t *)prs;
- gchar* tmp_str;
- int i;
-
- /* printing results */
- printf("\n");
- printf("===========================================================================================================\n");
- printf("RADIUS Response Time Delay (RTD) Statistics:\n");
- printf("Filter for statistics: %s\n", rs->filter ? rs->filter : "");
- printf("Duplicate requests: %u\n", rs->req_dup_num);
- printf("Duplicate responses: %u\n", rs->rsp_dup_num);
- printf("Open requests: %u\n", rs->open_req_num);
- printf("Discarded responses: %u\n", rs->disc_rsp_num);
- printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n");
- for (i=0; i<RADIUS_CAT_NUM_TIMESTATS; i++) {
- if (rs->rtd[i].num) {
- tmp_str = val_to_str_wmem(NULL, i, radius_message_code, "Other (%d)");
- printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n",
- tmp_str, rs->rtd[i].num,
- nstime_to_msec(&(rs->rtd[i].min)), nstime_to_msec(&(rs->rtd[i].max)),
- get_average(&(rs->rtd[i].tot), rs->rtd[i].num),
- rs->rtd[i].min_num, rs->rtd[i].max_num
- );
- wmem_free(NULL, tmp_str);
- }
- }
- printf("===========================================================================================================\n");
-}
-
-
-static void
-radiusstat_init(const char *opt_arg, void *userdata _U_)
-{
- radiusstat_t *rs;
- int i;
- GString *error_string;
-
- rs = g_new(radiusstat_t, 1);
- if (!strncmp(opt_arg, "radius,rtd,", 11)) {
- rs->filter = g_strdup(opt_arg+11);
- } else {
- rs->filter = NULL;
- }
-
- for (i=0; i<RADIUS_CAT_NUM_TIMESTATS; i++) {
- rs->rtd[i].num = 0;
- rs->rtd[i].min_num = 0;
- rs->rtd[i].max_num = 0;
- rs->rtd[i].min.secs = 0;
- rs->rtd[i].min.nsecs = 0;
- rs->rtd[i].max.secs = 0;
- rs->rtd[i].max.nsecs = 0;
- rs->rtd[i].tot.secs = 0;
- rs->rtd[i].tot.nsecs = 0;
- }
-
- rs->open_req_num = 0;
- rs->disc_rsp_num = 0;
- rs->req_dup_num = 0;
- rs->rsp_dup_num = 0;
-
- error_string = register_tap_listener("radius", rs, rs->filter, 0, NULL, radiusstat_packet, radiusstat_draw);
- if (error_string) {
- /* error, we failed to attach to the tap. clean up */
- g_free(rs->filter);
- g_free(rs);
-
- fprintf(stderr, "tshark: Couldn't register radius,rtd tap: %s\n",
- error_string->str);
- g_string_free(error_string, TRUE);
- exit(1);
- }
-}
-
-static stat_tap_ui radiusstat_ui = {
- REGISTER_STAT_GROUP_GENERIC,
- NULL,
- "radius,rtd",
- radiusstat_init,
- 0,
- NULL
-};
-
-void
-register_tap_listener_radiusstat(void)
-{
- register_stat_tap_ui(&radiusstat_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-rtd.c b/ui/cli/tap-rtd.c
new file mode 100644
index 0000000000..a939817431
--- /dev/null
+++ b/ui/cli/tap-rtd.c
@@ -0,0 +1,170 @@
+/* tap-rtd.c
+ *
+ * Based on 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/rtd_table.h>
+#include <epan/timestamp.h>
+#include <epan/stat_tap_ui.h>
+#include <ui/cli/tshark-tap.h>
+
+typedef struct _rtd_t {
+ const char *type;
+ const char *filter;
+ const value_string* vs_type;
+ rtd_data_t rtd;
+} rtd_t;
+
+static void
+rtd_draw(void *arg)
+{
+ rtd_data_t* rtd_data = (rtd_data_t*)arg;
+ rtd_t* rtd = (rtd_t*)rtd_data->user_data;
+ gchar* tmp_str;
+ guint i, j;
+
+ /* printing results */
+ printf("\n");
+ printf("=====================================================================================================\n");
+ printf("%s Response Time Delay (RTD) Statistics:\n", rtd->type);
+ printf("Filter for statistics: %s\n", rtd->filter ? rtd->filter : "");
+ if (rtd_data->stat_table.num_rtds == 1)
+ {
+ printf("Duplicate requests: %u\n", rtd_data->stat_table.time_stats[0].req_dup_num);
+ printf("Duplicate responses: %u\n", rtd_data->stat_table.time_stats[0].rsp_dup_num);
+ printf("Open requests: %u\n", rtd_data->stat_table.time_stats[0].open_req_num);
+ printf("Discarded responses: %u\n", rtd_data->stat_table.time_stats[0].disc_rsp_num);
+ printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame |\n");
+ for (i=0; i<rtd_data->stat_table.time_stats[0].num_timestat; i++) {
+ if (rtd_data->stat_table.time_stats[0].rtd[i].num) {
+ tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)");
+ printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u |\n",
+ tmp_str, rtd_data->stat_table.time_stats[0].rtd[i].num,
+ nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[0].rtd[i].max)),
+ get_average(&(rtd_data->stat_table.time_stats[0].rtd[i].tot), rtd_data->stat_table.time_stats[0].rtd[i].num),
+ rtd_data->stat_table.time_stats[0].rtd[i].min_num, rtd_data->stat_table.time_stats[0].rtd[i].max_num
+ );
+ wmem_free(NULL, tmp_str);
+ }
+ }
+ }
+ else
+ {
+ printf("Type | Messages | Min RTD | Max RTD | Avg RTD | Min in Frame | Max in Frame | Open Requests | Discarded responses | Duplicate requests | Duplicate responses\n");
+ for (i=0; i<rtd_data->stat_table.num_rtds; i++) {
+ for (j=0; j<rtd_data->stat_table.time_stats[i].num_timestat; j++) {
+ if (rtd_data->stat_table.time_stats[i].rtd[j].num) {
+ tmp_str = val_to_str_wmem(NULL, i, rtd->vs_type, "Other (%d)");
+ printf("%s | %7u | %8.2f msec | %8.2f msec | %8.2f msec | %10u | %10u | %10u | %10u | %4u (%4.2f%%) | %4u (%4.2f%%) |\n",
+ tmp_str, rtd_data->stat_table.time_stats[i].rtd[j].num,
+ nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].min)), nstime_to_msec(&(rtd_data->stat_table.time_stats[i].rtd[j].max)),
+ get_average(&(rtd_data->stat_table.time_stats[i].rtd[j].tot), rtd_data->stat_table.time_stats[i].rtd[j].num),
+ rtd_data->stat_table.time_stats[i].rtd[j].min_num, rtd_data->stat_table.time_stats[i].rtd[j].max_num,
+ rtd_data->stat_table.time_stats[i].open_req_num, rtd_data->stat_table.time_stats[i].disc_rsp_num,
+ rtd_data->stat_table.time_stats[i].req_dup_num,
+ rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].req_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0,
+ rtd_data->stat_table.time_stats[i].rsp_dup_num,
+ rtd_data->stat_table.time_stats[i].rtd[j].num?((double)rtd_data->stat_table.time_stats[i].rsp_dup_num*100)/(double)rtd_data->stat_table.time_stats[i].rtd[j].num:0
+ );
+ wmem_free(NULL, tmp_str);
+ }
+ }
+ }
+ }
+ printf("=====================================================================================================\n");
+}
+
+static void
+init_rtd_tables(register_rtd_t* rtd, const char *filter)
+{
+ GString *error_string;
+ rtd_t* ui;
+
+ ui = g_new0(rtd_t, 1);
+ ui->type = proto_get_protocol_short_name(find_protocol_by_id(get_rtd_proto_id(rtd)));
+ ui->filter = g_strdup(filter);
+ ui->vs_type = get_rtd_value_string(rtd);
+ ui->rtd.user_data = ui;
+
+ rtd_table_dissector_init(rtd, &ui->rtd.stat_table, NULL, NULL);
+
+ error_string = register_tap_listener(get_rtd_tap_listener_name(rtd), &ui->rtd, filter, 0, NULL, get_rtd_packet_func(rtd), rtd_draw);
+ if (error_string) {
+ free_rtd_table(rtd, &ui->rtd.stat_table, NULL, NULL);
+ fprintf(stderr, "tshark: Couldn't register srt tap: %s\n", error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+}
+
+static void
+dissector_rtd_init(const char *opt_arg, void* userdata)
+{
+ register_rtd_t *rtd = (register_rtd_t*)userdata;
+ const char *filter=NULL;
+ char* err = NULL;
+
+ rtd_table_get_filter(rtd, opt_arg, &filter, &err);
+ if (err != NULL)
+ {
+ fprintf(stderr, "tshark: %s\n", err);
+ g_free(err);
+ exit(1);
+ }
+
+ init_rtd_tables(rtd, filter);
+}
+
+/* Set GUI fields for register_rtd list */
+void
+register_rtd_tables(gpointer data, gpointer user_data _U_)
+{
+ register_rtd_t *rtd = (register_rtd_t*)data;
+ stat_tap_ui ui_info;
+
+ ui_info.group = REGISTER_STAT_GROUP_RESPONSE_TIME;
+ ui_info.title = NULL; /* construct this from the protocol info? */
+ ui_info.cli_string = rtd_table_get_tap_string(rtd);
+ ui_info.tap_init_cb = dissector_rtd_init;
+ ui_info.nparams = 0;
+ ui_info.params = NULL;
+ register_stat_tap_ui(&ui_info, rtd);
+}
+
+/*
+ * 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/tshark-tap.h b/ui/cli/tshark-tap.h
index 3de71ddb18..792424b17a 100644
--- a/ui/cli/tshark-tap.h
+++ b/ui/cli/tshark-tap.h
@@ -27,5 +27,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);
+extern void register_rtd_tables(gpointer data, gpointer user_data);
#endif /* __TSHARK_TAP_H__ */