3 * RTP streams handler functions used by tshark and wireshark
5 * Copyright 2008, Ericsson AB
6 * By Balint Reczey <balint.reczey@ericsson.com>
8 * most functions are copied from ui/gtk/rtp_stream.c and ui/gtk/rtp_analisys.c
9 * Copyright 2003, Alcatel Business Systems
10 * By Lars Ruoff <lars.ruoff@gmx.net>
12 * Wireshark - Network traffic analyzer
13 * By Gerald Combs <gerald@wireshark.org>
14 * Copyright 1998 Gerald Combs
16 * SPDX-License-Identifier: GPL-2.0-or-later
19 #ifndef __TAP_RTP_COMMON_H__
20 #define __TAP_RTP_COMMON_H__
22 #include "ui/rtp_stream.h"
26 #endif /* __cplusplus */
28 /* type of error when saving voice in a file didn't succeed */
33 TAP_RTP_PADDING_ERROR
,
35 TAP_RTP_FILE_OPEN_ERROR
,
36 TAP_RTP_FILE_WRITE_ERROR
,
38 } tap_rtp_error_type_t
;
40 typedef struct _tap_rtp_save_info_t
{
43 tap_rtp_error_type_t error_type
;
45 } tap_rtp_save_info_t
;
47 typedef struct _rtpstream_info_calc
{
53 char *all_payload_type_names
; /* Name of codec derived from fixed or dynamic codec names */
54 uint32_t packet_count
;
56 uint32_t packet_expected
; /* Count of expected packets, derived from length of RTP stream */
66 bool problem
; /* Indication that RTP stream contains something unusual -GUI should indicate it somehow */
67 double clock_drift_ms
;
69 double freq_drift_perc
;
71 uint32_t sequence_err
;
72 double start_time_ms
; /**< Unit is ms */
73 uint32_t first_packet_num
;
74 uint32_t last_packet_num
;
75 } rtpstream_info_calc_t
;
78 * Functions for init and destroy of rtpstream_info_t and attached structures
80 void rtpstream_info_init(rtpstream_info_t
* info
);
81 rtpstream_info_t
*rtpstream_info_malloc_and_init(void);
82 void rtpstream_info_copy_deep(rtpstream_info_t
*dest
, const rtpstream_info_t
*src
);
83 rtpstream_info_t
*rtpstream_info_malloc_and_copy_deep(const rtpstream_info_t
*src
);
84 void rtpstream_info_free_data(rtpstream_info_t
* info
);
85 void rtpstream_info_free_all(rtpstream_info_t
* info
);
88 * Compares two RTP stream infos (GCompareFunc style comparison function)
92 int rtpstream_info_cmp(const void *aa
, const void *bb
);
95 * Compares the endpoints of two RTP streams.
99 bool rtpstream_info_is_reverse(const rtpstream_info_t
*stream_a
, rtpstream_info_t
*stream_b
);
102 * Checks if payload_type is used in rtpstream.
104 * @returns true if is used
106 bool rtpstream_is_payload_used(const rtpstream_info_t
*stream_info
, const uint8_t payload_type
);
108 /****************************************************************************/
112 * Registers the rtp_streams tap listener (if not already done).
113 * From that point on, the RTP streams list will be updated with every redissection.
114 * This function is also the entry point for the initialization routine of the tap system.
115 * So whenever rtp_stream.c is added to the list of WIRESHARK_TAP_SRCs, the tap will be registered on startup.
116 * If not, it will be registered on demand by the rtp_streams and rtp_analysis functions that need it.
118 void register_tap_listener_rtpstream(rtpstream_tapinfo_t
*tapinfo
, const char *fstring
, rtpstream_tap_error_cb tap_error
);
121 * Removes the rtp_streams tap listener (if not already done)
122 * From that point on, the RTP streams list won't be updated any more.
124 void remove_tap_listener_rtpstream(rtpstream_tapinfo_t
*tapinfo
);
127 * Cleans up memory of rtp streams tap.
129 void rtpstream_reset(rtpstream_tapinfo_t
*tapinfo
);
131 void rtpstream_reset_cb(void*);
132 void rtp_write_header(rtpstream_info_t
*, FILE*);
133 tap_packet_status
rtpstream_packet_cb(void*, packet_info
*, epan_dissect_t
*, const void *, tap_flags_t
);
136 * Evaluate rtpstream_info_t calculations
138 void rtpstream_info_calculate(const rtpstream_info_t
*strinfo
, rtpstream_info_calc_t
*calc
);
141 * Free rtpstream_info_calc_t structure (internal items)
143 void rtpstream_info_calc_free(rtpstream_info_calc_t
*calc
);
146 * Init analyse counters in rtpstream_info_t from pinfo
148 void rtpstream_info_analyse_init(rtpstream_info_t
*stream_info
, const packet_info
*pinfo
, const struct _rtp_info
*rtpinfo
);
151 * Update analyse counters in rtpstream_info_t from pinfo
153 void rtpstream_info_analyse_process(rtpstream_info_t
*stream_info
, const packet_info
*pinfo
, const struct _rtp_info
*rtpinfo
);
156 * Get hash key for rtpstream_info_t
158 unsigned rtpstream_to_hash(const void *key
);
161 * Insert new_stream_info into multihash
163 void rtpstream_info_multihash_insert(GHashTable
*multihash
, rtpstream_info_t
*new_stream_info
);
166 * Lookup stream_info in stream_info multihash
168 rtpstream_info_t
*rtpstream_info_multihash_lookup(GHashTable
*multihash
, rtpstream_id_t
*stream_id
);
171 * GHFunc () for destroying GList in multihash
173 void rtpstream_info_multihash_destroy_value(void *key
, void *value
, void *user_data
);
177 #endif /* __cplusplus */
179 #endif /* __TAP_RTP_COMMON_H__ */