update epan/dissectors/pidl/drsuapi/drsuapi.idl from samba
[wireshark-sm.git] / ui / rtp_stream.c
blob949195cb792c2e00542913a4f3e850fbc53cb5a2
1 /* rtp_stream.c
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
14 #include "config.h"
16 #include <errno.h>
17 #include <stdlib.h>
18 #include <string.h>
20 #include "file.h"
22 #include <epan/epan.h>
23 #include <epan/packet.h>
24 #include <epan/tap.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 */
37 void
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)
48 bool was_registered;
50 if (!tapinfo || !cap_file) {
51 return;
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);
62 if (!was_registered)
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)
71 bool was_registered;
73 if (!tapinfo) {
74 return false;
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);
83 return false;
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);
90 return false;
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;
101 if (!was_registered)
102 remove_tap_listener_rtpstream(tapinfo);
104 if (ferror(tapinfo->save_file)) {
105 write_failure_alert_box(filename, errno);
106 fclose(tapinfo->save_file);
107 return false;
110 if (fclose(tapinfo->save_file) == EOF) {
111 write_failure_alert_box(filename, errno);
112 return false;
114 return true;
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)
121 bool was_registered;
123 if (!tapinfo) {
124 return;
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;
138 if (!was_registered)
139 remove_tap_listener_rtpstream(tapinfo);