From e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 10 Apr 2024 22:34:10 +0200 Subject: Adding upstream version 4.2.2. Signed-off-by: Daniel Baumann --- ui/rtp_stream.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 ui/rtp_stream.c (limited to 'ui/rtp_stream.c') diff --git a/ui/rtp_stream.c b/ui/rtp_stream.c new file mode 100644 index 0000000..2dc2393 --- /dev/null +++ b/ui/rtp_stream.c @@ -0,0 +1,140 @@ +/* rtp_stream.c + * RTP streams summary addition for Wireshark + * + * Copyright 2003, Alcatel Business Systems + * By Lars Ruoff + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "config.h" + +#include +#include +#include + +#include "file.h" + +#include +#include +#include +#include +#include + +#include "ui/alert_box.h" +#include "ui/simple_dialog.h" +#include "ui/rtp_stream.h" +#include "ui/tap-rtp-common.h" +#include + + +/****************************************************************************/ +/* scan for RTP streams */ +void +show_tap_registration_error(GString *error_string) +{ + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "%s", error_string->str); +} + +/****************************************************************************/ +/* scan for RTP streams */ +void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const char *fstring) +{ + gboolean was_registered; + + if (!tapinfo || !cap_file) { + return; + } + + was_registered = tapinfo->is_registered; + if (!tapinfo->is_registered) + register_tap_listener_rtpstream(tapinfo, fstring, show_tap_registration_error); + + /* RTP_STREAM_DEBUG("scanning %s, filter: %s", cap_file->filename, fstring); */ + tapinfo->mode = TAP_ANALYSE; + cf_retap_packets(cap_file); + + if (!was_registered) + remove_tap_listener_rtpstream(tapinfo); +} + + +/****************************************************************************/ +/* save rtp dump of stream_fwd */ +gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream, const gchar *filename) +{ + gboolean was_registered; + + if (!tapinfo) { + return FALSE; + } + + was_registered = tapinfo->is_registered; + + /* open file for saving */ + tapinfo->save_file = ws_fopen(filename, "wb"); + if (tapinfo->save_file==NULL) { + open_failure_alert_box(filename, errno, TRUE); + return FALSE; + } + + rtp_write_header(stream, tapinfo->save_file); + if (ferror(tapinfo->save_file)) { + write_failure_alert_box(filename, errno); + fclose(tapinfo->save_file); + return FALSE; + } + + if (!tapinfo->is_registered) + register_tap_listener_rtpstream(tapinfo, NULL, show_tap_registration_error); + + tapinfo->mode = TAP_SAVE; + tapinfo->filter_stream_fwd = stream; + cf_retap_packets(cap_file); + tapinfo->mode = TAP_ANALYSE; + + if (!was_registered) + remove_tap_listener_rtpstream(tapinfo); + + if (ferror(tapinfo->save_file)) { + write_failure_alert_box(filename, errno); + fclose(tapinfo->save_file); + return FALSE; + } + + if (fclose(tapinfo->save_file) == EOF) { + write_failure_alert_box(filename, errno); + return FALSE; + } + return TRUE; +} + +/****************************************************************************/ +/* mark packets in stream_fwd or stream_rev */ +void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtpstream_info_t* stream_fwd, rtpstream_info_t* stream_rev) +{ + gboolean was_registered; + + if (!tapinfo) { + return; + } + + was_registered = tapinfo->is_registered; + + if (!tapinfo->is_registered) + register_tap_listener_rtpstream(tapinfo, NULL, show_tap_registration_error); + + tapinfo->mode = TAP_MARK; + tapinfo->filter_stream_fwd = stream_fwd; + tapinfo->filter_stream_rev = stream_rev; + cf_retap_packets(cap_file); + tapinfo->mode = TAP_ANALYSE; + + if (!was_registered) + remove_tap_listener_rtpstream(tapinfo); +} -- cgit v1.2.3