To ease troubleshooting of bug #2017 and for code clarity in the future, use
[obnox/wireshark/wip.git] / gtk / voip_calls.h
1 /* voip_calls.h
2  * VoIP calls summary addition for Wireshark
3  *
4  * $Id$
5  *
6  * Copyright 2004, Ericsson , Spain
7  * By Francisco Alcoba <francisco.alcoba@ericsson.com>
8  *
9  * based on h323_calls.h
10  * Copyright 2004, Iskratel, Ltd, Kranj
11  * By Miha Jemec <m.jemec@iskratel.si>
12  *
13  * H323, RTP and Graph Support
14  * By Alejandro Vaquero, alejandro.vaquero@verso.com
15  * Copyright 2005, Verso Technologies Inc.
16  *
17  * Wireshark - Network traffic analyzer
18  * By Gerald Combs <gerald@wireshark.org>
19  * Copyright 1998 Gerald Combs
20  *
21  * This program is free software; you can redistribute it and/or
22  * modify it under the terms of the GNU General Public License
23  * as published by the Free Software Foundation; either version 2
24  * of the License, or (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  * GNU General Public License for more details.
30  *
31  * You should have received a copy of the GNU General Public License
32  * along with this program; if not, write to the Free Software
33  * Foundation,  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
34  */
35
36 #ifndef VOIP_CALLS_H_INCLUDED
37 #define VOIP_CALLS_H_INCLUDED
38
39 #include <glib.h>
40 #include <stdio.h>
41 #include <epan/address.h>
42 #include <epan/guid-utils.h>
43 #include <epan/tap-voip.h>
44
45 /****************************************************************************/
46 extern const char *voip_call_state_name[8];
47
48 typedef enum _voip_protocol {
49                 VOIP_SIP,
50                 VOIP_ISUP,
51                 VOIP_H323,
52                 VOIP_MGCP,
53                 VOIP_AC_ISDN,
54                 VOIP_AC_CAS,
55                 MEDIA_T38,
56                 TEL_H248,
57                 TEL_SCCP,
58                 TEL_BSSMAP,
59                 TEL_RANAP,
60                 VOIP_UNISTIM,
61                 VOIP_COMMON
62 } voip_protocol;
63
64 extern const char *voip_protocol_name[];
65
66 /* defines specific SIP data */
67
68 typedef enum _sip_call_state {
69         SIP_INVITE_SENT,
70         SIP_200_REC,
71         SIP_CANCEL_SENT
72 } sip_call_state;
73
74 typedef struct _sip_calls_info {
75         gchar *call_identifier;
76         guint32 invite_cseq;
77         sip_call_state sip_state;
78 } sip_calls_info_t;
79
80 /* defines specific ISUP data */
81 typedef struct _isup_calls_info {
82         guint16                 cic;
83         guint32                 opc, dpc;
84         guint8                  ni;
85 } isup_calls_info_t;
86
87 /* defines specific H245 data */
88 typedef struct _h245_address {
89         address h245_address;
90         guint16 h245_port;
91 } h245_address_t;
92
93 /* defines specific H323 data */
94 typedef struct _h323_calls_info {
95         e_guid_t *guid; /* Call ID to identify a H225 */
96         GList*  h245_list;   /* list of H245 Address and ports for tunneling off calls*/
97         address h225SetupAddr; /* we use the SETUP H225 IP to determine if packets are forward or reverse */                                    
98         gboolean is_h245;
99         gboolean is_faststart_Setup;    /* if faststart field is included in Setup*/
100         gboolean is_faststart_Proc;             /* if faststart field is included in Proce, Alerting, Progress or Connect*/
101         gboolean is_h245Tunneling;
102         gint32 q931_crv;
103         gint32 q931_crv2;
104         guint requestSeqNum;
105 } h323_calls_info_t;
106
107 /* defines specific MGCP data */
108 typedef struct _mgcp_calls_info {
109         gchar *endpointId;
110         gboolean fromEndpoint; /* true if the call was originated from the Endpoint, false for calls from MGC */
111 } mgcp_calls_info_t;
112
113 /* defines specific ACTRACE ISDN data */
114 typedef struct _actrace_isdn_calls_info {
115         gint32 crv;
116         int trunk;
117 } actrace_isdn_calls_info_t;
118
119 /* defines specific ACTRACE CAS data */
120 typedef struct _actrace_cas_calls_info {
121         gint32 bchannel;
122         int trunk;
123 } actrace_cas_calls_info_t;
124
125 /* defines a voip call */
126 typedef struct _voip_calls_info {
127         voip_call_state call_state;
128         voip_call_active_state call_active_state;
129         gchar *call_id;
130         gchar *from_identity;
131         gchar *to_identity;
132         gpointer prot_info;
133         void(*free_prot_info)(gpointer);
134         address initial_speaker;
135         guint32 npackets;
136         guint32 first_frame_num; /* frame number of first frame */
137         guint32 last_frame_num; 
138         voip_protocol protocol;
139         gchar *protocol_name;
140         gchar *call_comment;
141         guint16 call_num;
142         gint32 start_sec, start_usec, stop_sec, stop_usec;
143         gboolean selected;
144
145 } voip_calls_info_t;
146
147 /* structure that holds the information about all detected calls */
148 /* struct holding all information of the tap */
149
150 typedef struct _voip_calls_tapinfo {
151         int     ncalls;       /* number of call */
152         GList*  callsinfo_list;   /* list with all calls */
153         int     npackets;       /* total number of packets of all calls */
154         voip_calls_info_t* filter_calls_fwd;  /* used as filter in some tap modes */
155         guint32 launch_count;   /* number of times the tap has been run */
156         int start_packets;
157         int completed_calls;
158         int rejected_calls;
159         graph_analysis_info_t* graph_analysis;
160         gboolean redraw;
161         /* 
162          * Now add dummy variables, one for each tap listener.
163          * Their address will be used to distinguish between them.
164          */
165         int sip_dummy;
166         int sdp_dummy;
167         int h225_dummy;
168         int h245dg_dummy;
169         int mtp3_dummy;
170         int m3ua_dummy;
171         int isup_dummy;
172         int q931_dummy;
173         int mgcp_dummy;
174         int actrace_dummy;
175         int t38_dummy;
176         int h248_dummy;
177         int sccp_dummy;
178         int sua_dummy;
179         int megaco_dummy;
180         int unistim_dummy;
181         int voip_dummy;
182 } voip_calls_tapinfo_t;
183
184
185 /* defines a RTP stream */
186 typedef struct _voip_rtp_stream_info {
187         address src_addr;
188         guint16 src_port;
189         address dest_addr;
190         guint16 dest_port;
191         guint32 ssrc;
192         guint32  pt;
193         gchar *pt_str;
194         gboolean is_srtp;  
195         guint32 npackets;
196         gboolean end_stream;
197
198         guint32 first_frame_num; /* frame number of first frame */
199         guint32 setup_frame_number; /* frame number of setup message */
200         /* start of recording (GMT) of this stream */
201         guint32 start_rel_sec;         /* start stream rel seconds */
202         guint32 start_rel_usec;        /* start stream rel microseconds */
203         guint32 stop_rel_sec;         /* stop stream rel seconds */
204         guint32 stop_rel_usec;        /* stop stream rel microseconds */
205         gint32 rtp_event;
206 } voip_rtp_stream_info_t;
207
208 /* structure that holds the information about all RTP streams associated with the calls */
209 /* struct holding all information of the RTP tap */
210 typedef struct _voip_rtp_tapinfo {
211         int     nstreams;       /* number of rtp streams */
212         GList*  list;                   /* list with the rtp streams */
213         int rtp_dummy;
214         int rtp_event_dummy;
215 } voip_rtp_tapinfo_t;
216
217 /****************************************************************************/
218 /* INTERFACE */
219
220 /*
221 * Registers the voip_calls tap listeners (if not already done).
222 * From that point on, the calls list will be updated with every redissection.
223 * This function is also the entry point for the initialization routine of the tap system.
224 * So whenever voip_calls.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
225 * If not, it will be registered on demand by the voip_calls functions that need it.
226 */
227 void sip_calls_init_tap(void);
228 void isup_calls_init_tap(void);
229 void mtp3_calls_init_tap(void);
230 void h225_calls_init_tap(void);
231 void h245dg_calls_init_tap(void);
232 void q931_calls_init_tap(void);
233 void sdp_calls_init_tap(void);
234 void rtp_init_tap(void);
235 void rtp_event_init_tap(void);
236 void mgcp_calls_init_tap(void);
237 void actrace_calls_init_tap(void);
238 void t38_init_tap(void);
239 void h248_calls_init_tap(void);
240 void sccp_calls_init_tap(void);
241 void unistim_calls_init_tap(void);
242 void VoIPcalls_init_tap(void);
243
244 /*
245 * Removes the voip_calls tap listener (if not already done)
246 * From that point on, the voip calls list won't be updated any more.
247 */
248 void remove_tap_listener_sip_calls(void);
249 void remove_tap_listener_isup_calls(void);
250 void remove_tap_listener_mtp3_calls(void);
251 void remove_tap_listener_h225_calls(void);
252 void remove_tap_listener_h245dg_calls(void);
253 void remove_tap_listener_q931_calls(void);
254 void remove_tap_listener_sdp_calls(void);
255 void remove_tap_listener_rtp(void);
256 void remove_tap_listener_rtp_event(void);
257 void remove_tap_listener_mgcp_calls(void);
258 void remove_tap_listener_actrace_calls(void);
259 void remove_tap_listener_t38(void);
260 void remove_tap_listener_h248_calls(void);
261 void remove_tap_listener_sccp_calls(void);
262 void remove_tap_listener_unistim_calls(void);
263 void remove_tap_listener_voip_calls(void);
264
265 /*
266 * Retrieves a constant reference to the unique info structure of the voip_calls tap listener.
267 * The user should not modify the data pointed to.
268 */
269 voip_calls_tapinfo_t* voip_calls_get_info(void);
270
271 /*
272 * Cleans up memory of voip calls tap.
273 */
274 void voip_calls_reset(voip_calls_tapinfo_t *tapinfo);
275 void isup_calls_reset(voip_calls_tapinfo_t *tapinfo);
276 void mtp3_calls_reset(voip_calls_tapinfo_t *tapinfo);
277 void q931_calls_reset(voip_calls_tapinfo_t *tapinfo);
278
279 void graph_analysis_data_init(void);
280
281 #endif /*VOIP_CALLS_H_INCLUDED*/