aboutsummaryrefslogtreecommitdiffstats
path: root/tap-rtp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2008-02-03 13:12:43 +0000
committerGuy Harris <guy@alum.mit.edu>2008-02-03 13:12:43 +0000
commit75cd81a45b5cb4d0ebff00edddd483c7f2873552 (patch)
treec1fcb0b1fe06b6b85befc546fb0b9246c8201870 /tap-rtp.c
parent0ed69712733a236c115778593fc89a999ed734ed (diff)
One more missing file from Balint Reczey's patch for bug 2233.
svn path=/trunk/; revision=24254
Diffstat (limited to 'tap-rtp.c')
-rw-r--r--tap-rtp.c158
1 files changed, 158 insertions, 0 deletions
diff --git a/tap-rtp.c b/tap-rtp.c
new file mode 100644
index 0000000000..a911ace7bd
--- /dev/null
+++ b/tap-rtp.c
@@ -0,0 +1,158 @@
+/* tap-rtp.c
+ * RTP TAP for tshark
+ *
+ * Copyright 2008, Ericsson AB
+ * By Balint Reczey <balint.reczey@ericsson.com>
+ *
+ * based on gtk/rtp_stream_dlg.c
+ * Copyright 2003, Alcatel Business Systems
+ * By Lars Ruoff <lars.ruoff@gmx.net>
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+/*
+ * This TAP provides statistics for RTP streams
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <string.h>
+#include <locale.h>
+#include "epan/packet_info.h"
+#include "epan/value_string.h"
+#include <epan/tap.h>
+#include <epan/rtp_pt.h>
+#include <epan/stat_cmd_args.h>
+#include <epan/addr_resolv.h>
+#include "register.h"
+#include "tap-rtp-common.h"
+
+
+
+static void
+rtp_streams_stat_draw(void *arg _U_)
+{
+
+
+ GList *list;
+ rtp_stream_info_t* strinfo;
+ gchar *payload_type;
+ guint32 expected;
+ gint32 lost;
+ double perc;
+ char *savelocale;
+
+ printf("========================= RTP Streams ========================\n");
+ printf("%15s %5s %15s %5s %10s %16s %5s %12s %15s %15s %15s %s\n","Src IP addr", "Port", "Dest IP addr", "Port", "SSRC", "Payload", "Pkts", "Lost", "Max Delta(ms)", "Max Jitter(ms)", "Mean Jitter(ms)", "Problems?");
+
+ /* save the current locale */
+ savelocale = setlocale(LC_NUMERIC, NULL);
+ /* switch to "C" locale to avoid problems with localized decimal separators
+ in g_snprintf("%f") functions */
+ setlocale(LC_NUMERIC, "C");
+
+ list = the_tapinfo_struct.strinfo_list;
+
+ list = g_list_first(list);
+ while (list)
+ {
+ strinfo = (rtp_stream_info_t*)(list->data);
+
+ // payload type
+ if(strinfo->pt>95){
+ if(strinfo->info_payload_type_str != NULL){
+ payload_type = g_strdup(strinfo->info_payload_type_str);
+ }else{
+ payload_type = g_strdup_printf("Unknown(%u)",strinfo->pt);
+ }
+
+ }else{
+ payload_type = g_strdup(val_to_str(strinfo->pt, rtp_payload_type_vals,
+ "Unknown (%u)"));
+ }
+
+ // packet count, lost packets
+ expected = (strinfo->rtp_stats.stop_seq_nr + strinfo->rtp_stats.cycles*65536)
+ - strinfo->rtp_stats.start_seq_nr + 1;
+ lost = expected - strinfo->rtp_stats.total_nr;
+ if (expected){
+ perc = (double)(lost*100)/(double)expected;
+ } else {
+ perc = 0;
+ }
+
+ printf("%15s %5u %15s %5u 0x%08X %16s %5u %5d (%.1f%%) %15.2f %15.2f %15.2f %s\n",
+ get_addr_name(&(strinfo->src_addr)),
+ strinfo->src_port,
+ get_addr_name(&(strinfo->dest_addr)),
+ strinfo->dest_port,
+ strinfo->ssrc,
+ payload_type,
+ strinfo->npackets,
+ lost, perc,
+ strinfo->rtp_stats.max_delta*1000,
+ strinfo->rtp_stats.max_jitter*1000,
+ strinfo->rtp_stats.mean_jitter*1000,
+ (strinfo->problem)?"X":"");
+
+ list = g_list_next(list);
+
+
+ }
+
+ printf("==============================================================\n");
+ /* restore previous locale setting */
+ setlocale(LC_NUMERIC, savelocale);
+}
+
+
+static void
+rtp_streams_stat_init(const char *optarg _U_, void* userdata _U_)
+{
+ GString *err_p;
+
+ err_p =
+ register_tap_listener("rtp", &the_tapinfo_struct, NULL,
+ rtpstream_reset_cb,
+ rtpstream_packet,
+ rtp_streams_stat_draw);
+
+ if (err_p != NULL)
+ {
+ g_string_free(err_p, TRUE);
+
+ exit(1);
+ }
+}
+
+
+void
+register_tap_listener_rtp_streams(void)
+{
+ register_stat_cmd_arg("rtp,streams", rtp_streams_stat_init,NULL);
+}