2003-12-01 23:05:09 +00:00
|
|
|
/* tap-ansi_astat.c
|
|
|
|
*
|
|
|
|
* Copyright 2003, Michael Lum <mlum [AT] telostech.com>
|
|
|
|
* In association with Telos Technology Inc.
|
|
|
|
*
|
2006-05-21 05:12:17 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2003-12-01 23:05:09 +00:00
|
|
|
* 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
|
2012-06-28 22:56:06 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2003-12-01 23:05:09 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This TAP provides statistics for the ANSI A Interface:
|
|
|
|
*/
|
|
|
|
|
2012-09-20 01:29:52 +00:00
|
|
|
#include "config.h"
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
#include <stdlib.h>
|
2003-12-01 23:05:09 +00:00
|
|
|
#include <string.h>
|
2013-11-10 15:59:37 +00:00
|
|
|
|
2003-12-01 23:05:09 +00:00
|
|
|
#include "epan/packet_info.h"
|
|
|
|
#include "epan/value_string.h"
|
2004-09-29 00:06:36 +00:00
|
|
|
#include <epan/tap.h>
|
2014-11-14 18:51:40 +00:00
|
|
|
#include <epan/stat_tap_ui.h>
|
2004-07-18 18:06:47 +00:00
|
|
|
#include <epan/dissectors/packet-bssap.h>
|
|
|
|
#include <epan/dissectors/packet-ansi_a.h>
|
2003-12-01 23:05:09 +00:00
|
|
|
|
2013-11-14 06:21:02 +00:00
|
|
|
void register_tap_listener_ansi_astat(void);
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
typedef struct _ansi_a_stat_t {
|
2014-10-13 19:04:21 +00:00
|
|
|
int bsmap_message_type[0xff];
|
|
|
|
int dtap_message_type[0xff];
|
2003-12-01 23:05:09 +00:00
|
|
|
} ansi_a_stat_t;
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
ansi_a_stat_packet(
|
2014-10-13 19:04:21 +00:00
|
|
|
void *tapdata,
|
|
|
|
packet_info *pinfo _U_,
|
|
|
|
epan_dissect_t *edt _U_,
|
|
|
|
const void *data)
|
2003-12-01 23:05:09 +00:00
|
|
|
{
|
2014-10-13 19:04:21 +00:00
|
|
|
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;
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
switch (tap_p->pdu_type)
|
|
|
|
{
|
|
|
|
case BSSAP_PDU_TYPE_BSMAP:
|
2014-10-13 19:04:21 +00:00
|
|
|
stat_p->bsmap_message_type[tap_p->message_type]++;
|
|
|
|
break;
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
case BSSAP_PDU_TYPE_DTAP:
|
2014-10-13 19:04:21 +00:00
|
|
|
stat_p->dtap_message_type[tap_p->message_type]++;
|
|
|
|
break;
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
default:
|
2014-10-13 19:04:21 +00:00
|
|
|
/*
|
|
|
|
* unknown PDU type !!!
|
|
|
|
*/
|
|
|
|
return(0);
|
2003-12-01 23:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
ansi_a_stat_draw(
|
2014-10-13 19:04:21 +00:00
|
|
|
void *tapdata)
|
2003-12-01 23:05:09 +00:00
|
|
|
{
|
2014-10-13 19:04:21 +00:00
|
|
|
ansi_a_stat_t *stat_p = (ansi_a_stat_t *)tapdata;
|
|
|
|
guint8 i;
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
printf("=========== ANSI A-i/f Statistics ============================\n");
|
|
|
|
printf("BSMAP\n");
|
|
|
|
printf("Message (ID)Type Number\n");
|
|
|
|
|
2003-12-03 23:46:23 +00:00
|
|
|
i = 0;
|
|
|
|
while (ansi_a_ios401_bsmap_strings[i].strptr)
|
2003-12-01 23:05:09 +00:00
|
|
|
{
|
2014-10-13 19:04:21 +00:00
|
|
|
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++;
|
2003-12-01 23:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nDTAP\n");
|
|
|
|
printf("Message (ID)Type Number\n");
|
|
|
|
|
2003-12-03 23:46:23 +00:00
|
|
|
i = 0;
|
|
|
|
while (ansi_a_ios401_dtap_strings[i].strptr)
|
2003-12-01 23:05:09 +00:00
|
|
|
{
|
2014-10-13 19:04:21 +00:00
|
|
|
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++;
|
2003-12-01 23:05:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("==============================================================\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
2014-10-13 19:04:21 +00:00
|
|
|
ansi_a_stat_init(const char *opt_arg _U_, void *userdata _U_)
|
2003-12-01 23:05:09 +00:00
|
|
|
{
|
2014-10-13 19:04:21 +00:00
|
|
|
ansi_a_stat_t *stat_p;
|
|
|
|
GString *err_p;
|
2003-12-01 23:05:09 +00:00
|
|
|
|
2013-03-20 01:18:10 +00:00
|
|
|
stat_p = (ansi_a_stat_t *)g_malloc(sizeof(ansi_a_stat_t));
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
memset(stat_p, 0, sizeof(ansi_a_stat_t));
|
|
|
|
|
|
|
|
err_p =
|
2014-10-13 19:04:21 +00:00
|
|
|
register_tap_listener("ansi_a", stat_p, NULL, 0,
|
|
|
|
NULL,
|
|
|
|
ansi_a_stat_packet,
|
|
|
|
ansi_a_stat_draw);
|
2003-12-01 23:05:09 +00:00
|
|
|
|
|
|
|
if (err_p != NULL)
|
|
|
|
{
|
2014-10-13 19:04:21 +00:00
|
|
|
g_free(stat_p);
|
|
|
|
g_string_free(err_p, TRUE);
|
2003-12-01 23:05:09 +00:00
|
|
|
|
2014-10-13 19:04:21 +00:00
|
|
|
exit(1);
|
2003-12-01 23:05:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-14 18:42:26 +00:00
|
|
|
static stat_tap_ui ansi_a_stat_ui = {
|
2014-11-14 18:31:04 +00:00
|
|
|
REGISTER_STAT_GROUP_GENERIC,
|
|
|
|
NULL,
|
|
|
|
"ansi_a,",
|
|
|
|
ansi_a_stat_init,
|
|
|
|
-1,
|
|
|
|
0,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2003-12-01 23:05:09 +00:00
|
|
|
void
|
|
|
|
register_tap_listener_ansi_astat(void)
|
|
|
|
{
|
2014-11-14 18:42:26 +00:00
|
|
|
register_stat_tap_ui(&ansi_a_stat_ui, NULL);
|
2003-12-01 23:05:09 +00:00
|
|
|
}
|
2014-10-13 19:04:21 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* 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:
|
|
|
|
*/
|