2 * RTP streams summary addition for Wireshark
4 * Copyright 2003, Alcatel Business Systems
5 * By Lars Ruoff <lars.ruoff@gmx.net>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
22 #include <epan/epan.h>
23 #include <epan/packet.h>
25 #include <epan/dissectors/packet-rtp.h>
26 #include <epan/addr_resolv.h>
28 #include "ui/alert_box.h"
29 #include "ui/simple_dialog.h"
30 #include "ui/rtp_stream.h"
31 #include "ui/tap-rtp-common.h"
32 #include <wsutil/file_util.h>
35 /****************************************************************************/
36 /* scan for RTP streams */
38 show_tap_registration_error(GString
*error_string
)
40 simple_dialog(ESD_TYPE_ERROR
, ESD_BTN_OK
,
41 "%s", error_string
->str
);
44 /****************************************************************************/
45 /* scan for RTP streams */
46 void rtpstream_scan(rtpstream_tapinfo_t
*tapinfo
, capture_file
*cap_file
, const char *fstring
)
50 if (!tapinfo
|| !cap_file
) {
54 was_registered
= tapinfo
->is_registered
;
55 if (!tapinfo
->is_registered
)
56 register_tap_listener_rtpstream(tapinfo
, fstring
, show_tap_registration_error
);
58 /* RTP_STREAM_DEBUG("scanning %s, filter: %s", cap_file->filename, fstring); */
59 tapinfo
->mode
= TAP_ANALYSE
;
60 cf_retap_packets(cap_file
);
63 remove_tap_listener_rtpstream(tapinfo
);
67 /****************************************************************************/
68 /* save rtp dump of stream_fwd */
69 bool rtpstream_save(rtpstream_tapinfo_t
*tapinfo
, capture_file
*cap_file
, rtpstream_info_t
* stream
, const char *filename
)
77 was_registered
= tapinfo
->is_registered
;
79 /* open file for saving */
80 tapinfo
->save_file
= ws_fopen(filename
, "wb");
81 if (tapinfo
->save_file
==NULL
) {
82 open_failure_alert_box(filename
, errno
, true);
86 rtp_write_header(stream
, tapinfo
->save_file
);
87 if (ferror(tapinfo
->save_file
)) {
88 write_failure_alert_box(filename
, errno
);
89 fclose(tapinfo
->save_file
);
93 if (!tapinfo
->is_registered
)
94 register_tap_listener_rtpstream(tapinfo
, NULL
, show_tap_registration_error
);
96 tapinfo
->mode
= TAP_SAVE
;
97 tapinfo
->filter_stream_fwd
= stream
;
98 cf_retap_packets(cap_file
);
99 tapinfo
->mode
= TAP_ANALYSE
;
102 remove_tap_listener_rtpstream(tapinfo
);
104 if (ferror(tapinfo
->save_file
)) {
105 write_failure_alert_box(filename
, errno
);
106 fclose(tapinfo
->save_file
);
110 if (fclose(tapinfo
->save_file
) == EOF
) {
111 write_failure_alert_box(filename
, errno
);
117 /****************************************************************************/
118 /* mark packets in stream_fwd or stream_rev */
119 void rtpstream_mark(rtpstream_tapinfo_t
*tapinfo
, capture_file
*cap_file
, rtpstream_info_t
* stream_fwd
, rtpstream_info_t
* stream_rev
)
127 was_registered
= tapinfo
->is_registered
;
129 if (!tapinfo
->is_registered
)
130 register_tap_listener_rtpstream(tapinfo
, NULL
, show_tap_registration_error
);
132 tapinfo
->mode
= TAP_MARK
;
133 tapinfo
->filter_stream_fwd
= stream_fwd
;
134 tapinfo
->filter_stream_rev
= stream_rev
;
135 cf_retap_packets(cap_file
);
136 tapinfo
->mode
= TAP_ANALYSE
;
139 remove_tap_listener_rtpstream(tapinfo
);