[Automatic update for 2017-06-18]
[metze/wireshark/wip.git] / ui / rtp_stream.h
1 /* rtp_stream.h
2  * RTP streams summary addition for Wireshark
3  *
4  * Copyright 2003, Alcatel Business Systems
5  * By Lars Ruoff <lars.ruoff@gmx.net>
6  *
7  * Wireshark - Network traffic analyzer
8  * By Gerald Combs <gerald@wireshark.org>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation,  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25
26 #ifndef __RTP_STREAM_H__
27 #define __RTP_STREAM_H__
28
29 /** @file
30  *  "RTP Streams" dialog box common routines.
31  *  @ingroup main_ui_group
32  */
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif /* __cplusplus */
37
38 #include "tap-rtp-analysis.h"
39 #include <glib.h>
40 #include <stdio.h>
41
42 #include "cfile.h"
43
44 #include <epan/address.h>
45 #include <epan/tap.h>
46
47 /** Defines an rtp stream */
48 typedef struct _rtp_stream_info {
49     address         src_addr;
50     guint32         src_port;
51     address         dest_addr;
52     guint32         dest_port;
53     guint32         ssrc;
54
55     guint8          payload_type; /**< Numeric payload type */
56     gchar          *payload_type_name; /**< Payload type name */
57     gboolean        is_srtp;
58
59     guint32         packet_count;
60     gboolean        end_stream; /**< Used to track streams across payload types */
61     int             rtp_event;
62
63     int             call_num; /**< Used to match call_num in voip_calls_info_t */
64     guint32         setup_frame_number; /**< frame number of setup message */
65     /* Start and stop packets needed for .num and .abs_ts */
66     frame_data     *start_fd;
67     frame_data     *stop_fd;
68     nstime_t        start_rel_time;     /**< relative start time from pinfo */
69     nstime_t        stop_rel_time;      /**< relative stop time from pinfo */
70     guint16         vlan_id;
71     gboolean        tag_vlan_error;
72     gboolean        tag_diffserv_error;
73
74     gboolean        decode; /**< Decode this stream. GTK+ only? */
75     GList          *rtp_packet_list; /**< List of RTP rtp_packet_t. GTK+ only */
76
77     tap_rtp_stat_t  rtp_stats;  /**< here goes the RTP statistics info */
78     gboolean        problem;    /**< if the streams had wrong sequence numbers or wrong timestamps */
79     gchar          *ed137_info;
80 } rtp_stream_info_t;
81
82 /** tapping modes */
83 typedef enum
84 {
85     TAP_ANALYSE,
86     TAP_SAVE,
87     TAP_MARK
88 } tap_mode_t;
89
90 typedef struct _rtpstream_tapinfo rtpstream_tapinfo_t;
91
92 typedef void (*rtpstream_tap_reset_cb)(rtpstream_tapinfo_t *tapinfo);
93 typedef void (*rtpstream_tap_draw_cb)(rtpstream_tapinfo_t *tapinfo);
94 typedef void (*tap_mark_packet_cb)(rtpstream_tapinfo_t *tapinfo, frame_data *fd);
95
96 /* structure that holds the information about all detected streams */
97 /** struct holding all information of the tap */
98 struct _rtpstream_tapinfo {
99     rtpstream_tap_reset_cb tap_reset;       /**< tap reset callback */
100     rtpstream_tap_draw_cb tap_draw;         /**< tap draw callback */
101     tap_mark_packet_cb tap_mark_packet;     /**< packet marking callback */
102     void *tap_data;                         /**< data for tap callbacks */
103     int                nstreams; /**< number of streams in the list */
104     GList             *strinfo_list; /**< list of rtp_stream_info_t* */
105     int                npackets; /**< total number of rtp packets of all streams */
106     /* used while tapping. user shouldn't modify these */
107     tap_mode_t         mode;
108     rtp_stream_info_t *filter_stream_fwd; /**< used as filter in some tap modes */
109     rtp_stream_info_t *filter_stream_rev; /**< used as filter in some tap modes */
110     FILE              *save_file;
111     gboolean           is_registered; /**< if the tap listener is currently registered or not */
112 };
113
114 #if 0
115 #define RTP_STREAM_DEBUG(...) { \
116     char *RTP_STREAM_DEBUG_MSG = g_strdup_printf(__VA_ARGS__); \
117     g_warning("rtp_stream: %s:%d %s", G_STRFUNC, __LINE__, RTP_STREAM_DEBUG_MSG); \
118     g_free(RTP_STREAM_DEBUG_MSG); \
119 }
120 #else
121 #define RTP_STREAM_DEBUG(...)
122 #endif
123
124 /****************************************************************************/
125 /* INTERFACE */
126
127 /**
128 * Registers the rtp_streams tap listener (if not already done).
129 * From that point on, the RTP streams list will be updated with every redissection.
130 * This function is also the entry point for the initialization routine of the tap system.
131 * So whenever rtp_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
132 * If not, it will be registered on demand by the rtp_streams and rtp_analysis functions that need it.
133 */
134 void register_tap_listener_rtp_stream(rtpstream_tapinfo_t *tapinfo, const char *fstring);
135
136 /**
137 * Removes the rtp_streams tap listener (if not already done)
138 * From that point on, the RTP streams list won't be updated any more.
139 */
140 void remove_tap_listener_rtp_stream(rtpstream_tapinfo_t *tapinfo);
141
142 /**
143 * Cleans up memory of rtp streams tap.
144 */
145 void rtpstream_reset(rtpstream_tapinfo_t *tapinfo);
146
147 /**
148 * Scans all packets for RTP streams and updates the RTP streams list.
149 * (redissects all packets)
150 */
151 void rtpstream_scan(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, const char *fstring);
152
153 /**
154 * Saves an RTP stream as raw data stream with timestamp information for later RTP playback.
155 * (redissects all packets)
156 */
157 gboolean rtpstream_save(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtp_stream_info_t* stream, const gchar *filename);
158
159 /**
160 * Compares the endpoints of two RTP streams.
161 *
162 * @return TRUE if the
163 */
164 gboolean rtp_stream_info_is_reverse(const rtp_stream_info_t *stream_a, rtp_stream_info_t *stream_b);
165
166 /**
167 * Marks all packets belonging to either of stream_fwd or stream_rev.
168 * (both can be NULL)
169 * (redissects all packets)
170 */
171 void rtpstream_mark(rtpstream_tapinfo_t *tapinfo, capture_file *cap_file, rtp_stream_info_t* stream_fwd, rtp_stream_info_t* stream_rev);
172
173 #define MAX_SILENCE_FRAMES 14400000
174
175 #ifdef __cplusplus
176 }
177 #endif /* __cplusplus */
178
179 #endif /* __RTP_STREAM_H__ */
180
181 /*
182  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
183  *
184  * Local variables:
185  * c-basic-offset: 4
186  * tab-width: 8
187  * indent-tabs-mode: nil
188  * End:
189  *
190  * vi: set shiftwidth=4 tabstop=8 expandtab:
191  * :indentSize=4:tabSize=8:noTabs=true:
192  */