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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
38 #include <epan/epan.h>
39 #include <epan/packet.h>
41 #include <epan/dissectors/packet-rtp.h>
42 #include <epan/addr_resolv.h>
44 #include "../globals.h"
45 #include "ui/alert_box.h"
46 #include "ui/simple_dialog.h"
47 #include "ui/rtp_stream.h"
48 #include "ui/tap-rtp-common.h"
49 #include <wsutil/file_util.h>
51 #include "ui/rtp_stream.h"
52 #include "ui/gtk/rtp_stream_dlg.h"
53 #include "ui/gtk/main.h"
55 /* The one and only global rtpstream_tapinfo_t structure for tshark and wireshark.
57 static rtpstream_tapinfo_t the_tapinfo_struct
=
58 {0, NULL
, 0, TAP_ANALYSE
, NULL
, NULL
, NULL
, 0, FALSE
};
61 /****************************************************************************/
62 /* redraw the output */
63 static void rtpstream_draw(void *arg _U_
)
65 /* XXX: see rtpstream_on_update in rtp_streams_dlg.c for comments
66 g_signal_emit_by_name(top_level, "signal_rtpstream_update");
68 rtpstream_dlg_update(the_tapinfo_struct
.strinfo_list
);
73 /****************************************************************************/
74 /* scan for RTP streams */
75 void rtpstream_scan(void)
77 gboolean was_registered
= the_tapinfo_struct
.is_registered
;
78 if (!the_tapinfo_struct
.is_registered
)
79 register_tap_listener_rtp_stream();
81 the_tapinfo_struct
.mode
= TAP_ANALYSE
;
82 cf_retap_packets(&cfile
);
85 remove_tap_listener_rtp_stream();
89 /****************************************************************************/
90 /* save rtp dump of stream_fwd */
91 gboolean
rtpstream_save(rtp_stream_info_t
* stream
, const gchar
*filename
)
93 gboolean was_registered
= the_tapinfo_struct
.is_registered
;
94 /* open file for saving */
95 the_tapinfo_struct
.save_file
= ws_fopen(filename
, "wb");
96 if (the_tapinfo_struct
.save_file
==NULL
) {
97 open_failure_alert_box(filename
, errno
, TRUE
);
101 rtp_write_header(stream
, the_tapinfo_struct
.save_file
);
102 if (ferror(the_tapinfo_struct
.save_file
)) {
103 write_failure_alert_box(filename
, errno
);
104 fclose(the_tapinfo_struct
.save_file
);
108 if (!the_tapinfo_struct
.is_registered
)
109 register_tap_listener_rtp_stream();
111 the_tapinfo_struct
.mode
= TAP_SAVE
;
112 the_tapinfo_struct
.filter_stream_fwd
= stream
;
113 cf_retap_packets(&cfile
);
114 the_tapinfo_struct
.mode
= TAP_ANALYSE
;
117 remove_tap_listener_rtp_stream();
119 if (ferror(the_tapinfo_struct
.save_file
)) {
120 write_failure_alert_box(filename
, errno
);
121 fclose(the_tapinfo_struct
.save_file
);
125 if (fclose(the_tapinfo_struct
.save_file
) == EOF
) {
126 write_failure_alert_box(filename
, errno
);
133 /****************************************************************************/
134 /* mark packets in stream_fwd or stream_rev */
135 void rtpstream_mark(rtp_stream_info_t
* stream_fwd
, rtp_stream_info_t
* stream_rev
)
137 gboolean was_registered
= the_tapinfo_struct
.is_registered
;
138 if (!the_tapinfo_struct
.is_registered
)
139 register_tap_listener_rtp_stream();
141 the_tapinfo_struct
.mode
= TAP_MARK
;
142 the_tapinfo_struct
.filter_stream_fwd
= stream_fwd
;
143 the_tapinfo_struct
.filter_stream_rev
= stream_rev
;
144 cf_retap_packets(&cfile
);
145 the_tapinfo_struct
.mode
= TAP_ANALYSE
;
148 remove_tap_listener_rtp_stream();
152 /****************************************************************************/
153 const rtpstream_tapinfo_t
* rtpstream_get_info(void)
155 return &the_tapinfo_struct
;
159 /****************************************************************************/
161 /****************************************************************************/
163 /****************************************************************************/
165 remove_tap_listener_rtp_stream(void)
167 if (the_tapinfo_struct
.is_registered
) {
168 remove_tap_listener(&the_tapinfo_struct
);
170 the_tapinfo_struct
.is_registered
= FALSE
;
175 /****************************************************************************/
177 register_tap_listener_rtp_stream(void)
179 GString
*error_string
;
181 if (!the_tapinfo_struct
.is_registered
) {
182 error_string
= register_tap_listener("rtp", &the_tapinfo_struct
,
183 NULL
, 0, rtpstream_reset_cb
, rtpstream_packet
,
186 if (error_string
!= NULL
) {
187 simple_dialog(ESD_TYPE_ERROR
, ESD_BTN_OK
,
188 "%s", error_string
->str
);
189 g_string_free(error_string
, TRUE
);
193 the_tapinfo_struct
.is_registered
= TRUE
;