Replace g_log() calls with ws_log()
[metze/wireshark/wip.git] / ui / voip_calls.h
1 /* voip_calls.h
2  * VoIP calls summary addition for Wireshark
3  *
4  * Copyright 2004, Ericsson , Spain
5  * By Francisco Alcoba <francisco.alcoba@ericsson.com>
6  *
7  * based on h323_calls.h
8  * Copyright 2004, Iskratel, Ltd, Kranj
9  * By Miha Jemec <m.jemec@iskratel.si>
10  *
11  * H323, RTP and Graph Support
12  * By Alejandro Vaquero, alejandro.vaquero@verso.com
13  * Copyright 2005, Verso Technologies Inc.
14  *
15  * Wireshark - Network traffic analyzer
16  * By Gerald Combs <gerald@wireshark.org>
17  * Copyright 1998 Gerald Combs
18  *
19  * SPDX-License-Identifier: GPL-2.0-or-later
20  */
21
22 #ifndef __VOIP_CALLS_H__
23 #define __VOIP_CALLS_H__
24
25 #include <glib.h>
26
27 #include <stdio.h>
28
29 #include "epan/address.h"
30 #include "epan/packet.h"
31 #include "epan/guid-utils.h"
32 #include "epan/tap.h"
33 #include "epan/tap-voip.h"
34 #include "epan/sequence_analysis.h"
35
36 /** @file
37  *  "VoIP Calls" dialog box common routines.
38  *  @ingroup main_ui_group
39  */
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* __cplusplus */
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_SKINNY,
62     VOIP_IAX2,
63     VOIP_COMMON
64 } voip_protocol;
65
66 typedef enum _hash_indexes {
67     SIP_HASH=0
68 } hash_indexes;
69
70 extern const char *voip_protocol_name[];
71
72 typedef enum _flow_show_options
73 {
74     FLOW_ALL,
75     FLOW_ONLY_INVITES
76 } flow_show_options;
77
78 /** defines specific SIP data */
79
80 typedef enum _sip_call_state {
81     SIP_INVITE_SENT,
82     SIP_200_REC,
83     SIP_CANCEL_SENT
84 } sip_call_state;
85
86 typedef struct _sip_calls_info {
87     gchar *call_identifier;
88     guint32 invite_cseq;
89     sip_call_state sip_state;
90 } sip_calls_info_t;
91
92 /** defines specific ISUP data */
93 typedef struct _isup_calls_info {
94     guint16 cic;
95     guint32 opc, dpc;
96     guint8  ni;
97 } isup_calls_info_t;
98
99 /* defines specific H245 data */
100 typedef struct _h245_address {
101     address h245_address;
102     guint16 h245_port;
103 } h245_address_t;
104
105 /** defines specific H323 data */
106 typedef struct _h323_calls_info {
107     e_guid_t *guid;               /* Call ID to identify a H225 */
108     GList*    h245_list;          /**< list of H245 Address and ports for tunneling off calls*/
109     address   h225SetupAddr;      /**< we use the SETUP H225 IP to determine if packets are forward or reverse */
110     gboolean  is_h245;
111     gboolean  is_faststart_Setup; /**< if faststart field is included in Setup*/
112     gboolean  is_faststart_Proc;  /**< if faststart field is included in Proce, Alerting, Progress or Connect*/
113     gboolean  is_h245Tunneling;
114     gint32    q931_crv;
115     gint32    q931_crv2;
116     guint     requestSeqNum;
117 } h323_calls_info_t;
118
119 /**< defines specific MGCP data */
120 typedef struct _mgcp_calls_info {
121     gchar *endpointId;
122     gboolean fromEndpoint; /**< true if the call was originated from the Endpoint, false for calls from MGC */
123 } mgcp_calls_info_t;
124
125 /** defines specific ACTRACE ISDN data */
126 typedef struct _actrace_isdn_calls_info {
127     gint32 crv;
128     int trunk;
129 } actrace_isdn_calls_info_t;
130
131 /** defines specific ACTRACE CAS data */
132 typedef struct _actrace_cas_calls_info {
133     gint32 bchannel;
134     int trunk;
135 } actrace_cas_calls_info_t;
136
137 /** defines specific SKINNY data */
138 typedef struct _skinny_calls_info {
139     guint32 callId;
140 } skinny_calls_info_t;
141
142 /** defines info types for graph analysis additional information */
143 typedef enum _ga_info_type {
144     GA_INFO_TYPE_NONE=0,
145     GA_INFO_TYPE_RTP
146 } ga_info_type;
147
148 /** defines a voip call */
149 typedef struct _voip_calls_info {
150     voip_call_state         call_state;
151     voip_call_active_state  call_active_state;
152     gchar                  *call_id;
153     gchar                  *from_identity;
154     gchar                  *to_identity;
155     gpointer                prot_info;
156     void (*free_prot_info)(gpointer);
157     address                 initial_speaker;
158     guint32                 npackets;
159     voip_protocol           protocol;
160     gchar                  *protocol_name;
161     gchar                  *call_comment;
162     guint16                 call_num;
163     /**> The frame_data struct holds the frame number and timing information needed. */
164     frame_data             *start_fd;
165     nstime_t                start_rel_ts;
166     frame_data             *stop_fd;
167     nstime_t                stop_rel_ts;
168 } voip_calls_info_t;
169
170 /**
171  * structure that holds the information about all detected calls */
172 /* struct holding all information of the tap */
173 /*
174  * XXX Most of these are private to voip_calls.c. We might want to
175  * make them private.
176  */
177 struct _h245_labels;
178 typedef struct _voip_calls_tapinfo {
179     tap_reset_cb          tap_reset; /**< tap reset callback */
180     tap_packet_cb         tap_packet; /**< tap per-packet callback */
181     tap_draw_cb           tap_draw; /**< tap draw callback */
182     void                 *tap_data; /**< data for tap callbacks */
183     int                   ncalls; /**< number of call */
184     GQueue*               callsinfos; /**< queue with all calls (voip_calls_info_t) */
185     GHashTable*           callsinfo_hashtable[1]; /**< array of hashes per voip protocol (voip_calls_info_t); currently only the one for SIP is used */
186     int                   npackets; /**< total number of packets of all calls */
187     voip_calls_info_t    *filter_calls_fwd; /**< used as filter in some tap modes */
188     int                   start_packets;
189     int                   completed_calls;
190     int                   rejected_calls;
191     seq_analysis_info_t  *graph_analysis;
192     epan_t               *session; /**< epan session */
193     int                   nrtpstreams; /**< number of rtp streams */
194     GList*                rtpstream_list; /**< list of rtpstream_info_t */
195     guint32               rtp_evt_frame_num;
196     guint8                rtp_evt;
197     gboolean              rtp_evt_end;
198     gchar                *sdp_summary;
199     guint32               sdp_frame_num;
200     guint32               mtp3_opc;
201     guint32               mtp3_dpc;
202     guint8                mtp3_ni;
203     guint32               mtp3_frame_num;
204     struct _h245_labels  *h245_labels; /**< H.245 labels */
205     gchar                *q931_calling_number;
206     gchar                *q931_called_number;
207     guint8                q931_cause_value;
208     gint32                q931_crv;
209     guint32               q931_frame_num;
210     guint32               h225_frame_num;
211     guint16               h225_call_num;
212     int                   h225_cstype; /* XXX actually an enum */
213     gboolean              h225_is_faststart;
214     guint32               sip_frame_num;
215     guint32               actrace_frame_num;
216     gint32                actrace_trunk;
217     gint32                actrace_direction;
218     flow_show_options     fs_option;
219     guint32               redraw;
220     gboolean              apply_display_filter;
221 } voip_calls_tapinfo_t;
222
223 #if 0
224 #define VOIP_CALLS_DEBUG(...) { \
225     char *VOIP_CALLS_DEBUG_MSG = g_strdup_printf(__VA_ARGS__); \
226     ws_warning("voip_calls: %s:%d %s", G_STRFUNC, __LINE__, VOIP_CALLS_DEBUG_MSG); \
227     g_free(VOIP_CALLS_DEBUG_MSG); \
228 }
229 #else
230 #define VOIP_CALLS_DEBUG(...)
231 #endif
232
233 /****************************************************************************/
234 /* INTERFACE */
235
236 /**
237  * Registers the voip_calls tap listeners (if not already done).
238  * From that point on, the calls list will be updated with every redissection.
239  * This function is also the entry point for the initialization routine of the tap system.
240  * So whenever voip_calls.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
241  * If not, it will be registered on demand by the voip_calls functions that need it.
242  */
243 void voip_calls_init_all_taps(voip_calls_tapinfo_t *tap_id_base);
244
245 /**
246  * Removes the voip_calls tap listener (if not already done)
247  * From that point on, the voip calls list won't be updated any more.
248  */
249 void voip_calls_remove_all_tap_listeners(voip_calls_tapinfo_t *tap_id_base);
250
251 /**
252  * Cleans up memory of voip calls tap.
253  */
254 void voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo);
255
256 /**
257  * Frees one callsinfo
258  */
259 void
260 voip_calls_free_callsinfo(voip_calls_info_t *callsinfo);
261
262 #ifdef __cplusplus
263 }
264 #endif /* __cplusplus */
265
266 #endif /* __VOIP_CALLS_H__ */