2 * RTP streams summary addition for Wireshark
6 * Copyright 2003, Alcatel Business Systems
7 * By Lars Ruoff <lars.ruoff@gmx.net>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 #include <epan/dissectors/packet-rtp.h>
39 #include "alert_box.h"
40 #include "simple_dialog.h"
41 #include "file_util.h"
47 #ifdef HAVE_SYS_TYPES_H
48 # include <sys/types.h>
52 #include <epan/addr_resolv.h>
54 #include "rtp_stream.h"
55 #include "rtp_stream_dlg.h"
56 #include "tap-rtp-common.h"
58 /****************************************************************************/
59 /* redraw the output */
60 static void rtpstream_draw(void *arg _U_)
62 /* XXX: see rtpstream_on_update in rtp_streams_dlg.c for comments
63 gtk_signal_emit_by_name(top_level, "signal_rtpstream_update");
65 rtpstream_dlg_update(the_tapinfo_struct.strinfo_list);
70 /****************************************************************************/
71 /* scan for RTP streams */
72 void rtpstream_scan(void)
74 gboolean was_registered = the_tapinfo_struct.is_registered;
75 if (!the_tapinfo_struct.is_registered)
76 register_tap_listener_rtp_stream();
78 the_tapinfo_struct.mode = TAP_ANALYSE;
79 cf_retap_packets(&cfile, FALSE);
82 remove_tap_listener_rtp_stream();
86 /****************************************************************************/
87 /* save rtp dump of stream_fwd */
88 gboolean rtpstream_save(rtp_stream_info_t* stream, const gchar *filename)
90 gboolean was_registered = the_tapinfo_struct.is_registered;
91 /* open file for saving */
92 the_tapinfo_struct.save_file = eth_fopen(filename, "wb");
93 if (the_tapinfo_struct.save_file==NULL) {
94 open_failure_alert_box(filename, errno, TRUE);
98 rtp_write_header(stream, the_tapinfo_struct.save_file);
99 if (ferror(the_tapinfo_struct.save_file)) {
100 write_failure_alert_box(filename, errno);
101 fclose(the_tapinfo_struct.save_file);
105 if (!the_tapinfo_struct.is_registered)
106 register_tap_listener_rtp_stream();
108 the_tapinfo_struct.mode = TAP_SAVE;
109 the_tapinfo_struct.filter_stream_fwd = stream;
110 cf_retap_packets(&cfile, FALSE);
111 the_tapinfo_struct.mode = TAP_ANALYSE;
114 remove_tap_listener_rtp_stream();
116 if (ferror(the_tapinfo_struct.save_file)) {
117 write_failure_alert_box(filename, errno);
118 fclose(the_tapinfo_struct.save_file);
122 if (fclose(the_tapinfo_struct.save_file) == EOF) {
123 write_failure_alert_box(filename, errno);
130 /****************************************************************************/
131 /* mark packets in stream_fwd or stream_rev */
132 void rtpstream_mark(rtp_stream_info_t* stream_fwd, rtp_stream_info_t* stream_rev)
134 gboolean was_registered = the_tapinfo_struct.is_registered;
135 if (!the_tapinfo_struct.is_registered)
136 register_tap_listener_rtp_stream();
138 the_tapinfo_struct.mode = TAP_MARK;
139 the_tapinfo_struct.filter_stream_fwd = stream_fwd;
140 the_tapinfo_struct.filter_stream_rev = stream_rev;
141 cf_retap_packets(&cfile, FALSE);
142 the_tapinfo_struct.mode = TAP_ANALYSE;
145 remove_tap_listener_rtp_stream();
149 /****************************************************************************/
150 const rtpstream_tapinfo_t* rtpstream_get_info(void)
152 return &the_tapinfo_struct;
156 /****************************************************************************/
158 /****************************************************************************/
160 /* XXX just copied from gtk/rpc_stat.c */
161 void protect_thread_critical_region(void);
162 void unprotect_thread_critical_region(void);
164 /****************************************************************************/
166 remove_tap_listener_rtp_stream(void)
168 if (the_tapinfo_struct.is_registered) {
169 protect_thread_critical_region();
170 remove_tap_listener(&the_tapinfo_struct);
171 unprotect_thread_critical_region();
173 the_tapinfo_struct.is_registered = FALSE;
178 /****************************************************************************/
180 register_tap_listener_rtp_stream(void)
182 GString *error_string;
184 if (!the_tapinfo_struct.is_registered) {
185 error_string = register_tap_listener("rtp", &the_tapinfo_struct,
186 NULL, rtpstream_reset_cb, rtpstream_packet,
189 if (error_string != NULL) {
190 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
192 g_string_free(error_string, TRUE);
196 the_tapinfo_struct.is_registered = TRUE;