aboutsummaryrefslogtreecommitdiffstats
path: root/ui/cli
diff options
context:
space:
mode:
Diffstat (limited to 'ui/cli')
-rw-r--r--ui/cli/Makefile.common2
-rw-r--r--ui/cli/tap-ansi_astat.c182
-rw-r--r--ui/cli/tap-simple_stattable.c170
-rw-r--r--ui/cli/tshark-tap.h1
4 files changed, 172 insertions, 183 deletions
diff --git a/ui/cli/Makefile.common b/ui/cli/Makefile.common
index ff0636d4da..8cec7b13ab 100644
--- a/ui/cli/Makefile.common
+++ b/ui/cli/Makefile.common
@@ -38,7 +38,6 @@ GENERATOR_FILES =
# sources for TShark taps
TSHARK_TAP_SRC = \
- tap-ansi_astat.c \
tap-bootpstat.c \
tap-camelcounter.c \
tap-camelsrt.c \
@@ -65,6 +64,7 @@ TSHARK_TAP_SRC = \
tap-rtp.c \
tap-rtspstat.c \
tap-sctpchunkstat.c \
+ tap-simple_stattable.c \
tap-sipstat.c \
tap-smbsids.c \
tap-srt.c \
diff --git a/ui/cli/tap-ansi_astat.c b/ui/cli/tap-ansi_astat.c
deleted file mode 100644
index 4e9553403c..0000000000
--- a/ui/cli/tap-ansi_astat.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/* tap-ansi_astat.c
- *
- * Copyright 2003, Michael Lum <mlum [AT] telostech.com>
- * In association with Telos Technology Inc.
- *
- * 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 TAP provides statistics for the ANSI A Interface:
- */
-
-#include "config.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "epan/packet_info.h"
-#include "epan/value_string.h"
-#include <epan/tap.h>
-#include <epan/stat_tap_ui.h>
-#include <epan/dissectors/packet-bssap.h>
-#include <epan/dissectors/packet-ansi_a.h>
-
-void register_tap_listener_ansi_astat(void);
-
-typedef struct _ansi_a_stat_t {
- int bsmap_message_type[0xff];
- int dtap_message_type[0xff];
-} ansi_a_stat_t;
-
-
-static int
-ansi_a_stat_packet(
- void *tapdata,
- packet_info *pinfo _U_,
- epan_dissect_t *edt _U_,
- const void *data)
-{
- ansi_a_stat_t *stat_p = (ansi_a_stat_t *)tapdata;
- const ansi_a_tap_rec_t *tap_p = (const ansi_a_tap_rec_t *)data;
-
-
- switch (tap_p->pdu_type)
- {
- case BSSAP_PDU_TYPE_BSMAP:
- stat_p->bsmap_message_type[tap_p->message_type]++;
- break;
-
- case BSSAP_PDU_TYPE_DTAP:
- stat_p->dtap_message_type[tap_p->message_type]++;
- break;
-
- default:
- /*
- * unknown PDU type !!!
- */
- return(0);
- }
-
- return(1);
-}
-
-
-static void
-ansi_a_stat_draw(
- void *tapdata)
-{
- ansi_a_stat_t *stat_p = (ansi_a_stat_t *)tapdata;
- guint8 i;
-
-
- printf("\n");
- printf("=========== ANSI A-i/f Statistics ============================\n");
- printf("BSMAP\n");
- printf("Message (ID)Type Number\n");
-
- i = 0;
- while (ansi_a_ios401_bsmap_strings[i].strptr)
- {
- if (stat_p->bsmap_message_type[ansi_a_ios401_bsmap_strings[i].value] > 0)
- {
- printf("0x%02x %-50s%d\n",
- ansi_a_ios401_bsmap_strings[i].value,
- ansi_a_ios401_bsmap_strings[i].strptr,
- stat_p->bsmap_message_type[ansi_a_ios401_bsmap_strings[i].value]);
- }
-
- i++;
- }
-
- printf("\nDTAP\n");
- printf("Message (ID)Type Number\n");
-
- i = 0;
- while (ansi_a_ios401_dtap_strings[i].strptr)
- {
- if (stat_p->dtap_message_type[ansi_a_ios401_dtap_strings[i].value] > 0)
- {
- printf("0x%02x %-50s%d\n",
- ansi_a_ios401_dtap_strings[i].value,
- ansi_a_ios401_dtap_strings[i].strptr,
- stat_p->dtap_message_type[ansi_a_ios401_dtap_strings[i].value]);
- }
-
- i++;
- }
-
- printf("==============================================================\n");
-}
-
-
-static void
-ansi_a_stat_init(const char *opt_arg _U_, void *userdata _U_)
-{
- ansi_a_stat_t *stat_p;
- GString *err_p;
-
- stat_p = (ansi_a_stat_t *)g_malloc(sizeof(ansi_a_stat_t));
-
- memset(stat_p, 0, sizeof(ansi_a_stat_t));
-
- err_p =
- register_tap_listener("ansi_a", stat_p, NULL, 0,
- NULL,
- ansi_a_stat_packet,
- ansi_a_stat_draw);
-
- if (err_p != NULL)
- {
- g_free(stat_p);
- g_string_free(err_p, TRUE);
-
- exit(1);
- }
-}
-
-
-static stat_tap_ui ansi_a_stat_ui = {
- REGISTER_STAT_GROUP_GENERIC,
- NULL,
- "ansi_a",
- ansi_a_stat_init,
- 0,
- NULL
-};
-
-void
-register_tap_listener_ansi_astat(void)
-{
- register_stat_tap_ui(&ansi_a_stat_ui, NULL);
-}
-
-/*
- * 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/cli/tap-simple_stattable.c b/ui/cli/tap-simple_stattable.c
new file mode 100644
index 0000000000..29ffc73880
--- /dev/null
+++ b/ui/cli/tap-simple_stattable.c
@@ -0,0 +1,170 @@
+/* tap-simpletable.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>
+
+typedef struct _table_stat_t {
+ const char *filter;
+ new_stat_data_t stats;
+} table_stat_t;
+
+static void
+simple_draw(void *arg)
+{
+ new_stat_data_t* stat_data = (new_stat_data_t*)arg;
+ table_stat_t* stats = (table_stat_t*)stat_data->user_data;
+ size_t i;
+ guint table_index, element, field_index;
+ stat_tap_table_item* field;
+ new_stat_tap_table* table;
+ stat_tap_table_item_type* field_data;
+ gchar fmt_string[250];
+
+ /* printing results */
+ printf("\n");
+ printf("=====================================================================================================\n");
+ printf("%s:\n", stat_data->new_stat_tap_data->title);
+ printf("Filter for statistics: %s\n", stats->filter ? stats->filter : "");
+
+ for (i = 0, field = stat_data->new_stat_tap_data->fields; i < stat_data->new_stat_tap_data->nfields; i++, field++)
+ {
+ printf("%s |", field->column_name);
+ }
+ printf("\n");
+
+ /* To iterate is human, and to recurse is divine. I am human */
+ for (table_index = 0; table_index < stat_data->new_stat_tap_data->tables->len; table_index++)
+ {
+ table = g_array_index(stat_data->new_stat_tap_data->tables, new_stat_tap_table*, table_index);
+ printf("%s\n", table->title);
+ for (element = 0; element < table->num_elements; element++)
+ {
+ for (field_index = 0, field = stat_data->new_stat_tap_data->fields; field_index < table->num_fields; field_index++, field++)
+ {
+ field_data = new_stat_tap_get_field_data(table, element, field_index);
+ if (field_data->type == TABLE_ITEM_NONE) /* Nothing for us here */
+ break;
+
+ g_snprintf(fmt_string, sizeof(fmt_string), "%s |", field->field_format);
+ switch(field->type)
+ {
+ case TABLE_ITEM_UINT:
+ printf(fmt_string, field_data->value.uint_value);
+ break;
+ case TABLE_ITEM_INT:
+ printf(fmt_string, field_data->value.int_value);
+ break;
+ case TABLE_ITEM_STRING:
+ printf(fmt_string, field_data->value.string_value);
+ break;
+ case TABLE_ITEM_FLOAT:
+ printf(fmt_string, field_data->value.float_value);
+ break;
+ case TABLE_ITEM_ENUM:
+ printf(fmt_string, field_data->value.enum_value);
+ break;
+ case TABLE_ITEM_NONE:
+ break;
+ }
+ }
+ printf("\n");
+ }
+ }
+ printf("=====================================================================================================\n");
+}
+
+static void
+init_stat_table(new_stat_tap_ui *new_stat_tap, const char *filter)
+{
+ GString *error_string;
+ table_stat_t* ui;
+
+ ui = g_new0(table_stat_t, 1);
+ ui->filter = g_strdup(filter);
+ ui->stats.new_stat_tap_data = new_stat_tap;
+ ui->stats.user_data = ui;
+
+ new_stat_tap->stat_tap_init_cb(new_stat_tap, NULL, NULL);
+
+ error_string = register_tap_listener(new_stat_tap->tap_name, &ui->stats, filter, 0, NULL, new_stat_tap->packet_func, simple_draw);
+ if (error_string) {
+/* free_rtd_table(rtd, &ui->rtd.stat_table, NULL, NULL); */
+ fprintf(stderr, "tshark: Couldn't register tap: %s\n", error_string->str);
+ g_string_free(error_string, TRUE);
+ exit(1);
+ }
+}
+
+static void
+simple_stat_init(const char *opt_arg, void* userdata)
+{
+ new_stat_tap_ui *new_stat_tap = (new_stat_tap_ui*)userdata;
+ const char *filter=NULL;
+ char* err = NULL;
+
+ new_stat_tap_get_filter(new_stat_tap, opt_arg, &filter, &err);
+ if (err != NULL)
+ {
+ fprintf(stderr, "tshark: %s\n", err);
+ g_free(err);
+ exit(1);
+ }
+
+ init_stat_table(new_stat_tap, filter);
+}
+
+void
+register_simple_stat_tables(gpointer data, gpointer user_data _U_)
+{
+ new_stat_tap_ui *new_stat_tap = (new_stat_tap_ui*)data;
+ stat_tap_ui ui_info;
+
+ ui_info.group = new_stat_tap->group;
+ ui_info.title = new_stat_tap->title; /* construct this from the protocol info? */
+ ui_info.cli_string = new_stat_tap->cli_string;
+ ui_info.tap_init_cb = simple_stat_init;
+ ui_info.nparams = new_stat_tap->nparams;
+ ui_info.params = new_stat_tap->params;
+
+ register_stat_tap_ui(&ui_info, new_stat_tap);
+}
+
+/*
+ * 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 792424b17a..d3f8d0179c 100644
--- a/ui/cli/tshark-tap.h
+++ b/ui/cli/tshark-tap.h
@@ -28,5 +28,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);
+extern void register_simple_stat_tables(gpointer data, gpointer user_data);
#endif /* __TSHARK_TAP_H__ */