2021-11-30 08:01:36 -05:00
|
|
|
/** @file
|
|
|
|
*
|
2018-06-15 22:47:47 +02:00
|
|
|
* RTP stream id functions for Wireshark
|
|
|
|
*
|
|
|
|
* Copyright 2003, Alcatel Business Systems
|
|
|
|
* By Lars Ruoff <lars.ruoff@gmx.net>
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __RTP_STREAM_ID_H__
|
|
|
|
#define __RTP_STREAM_ID_H__
|
|
|
|
|
|
|
|
/** @file
|
|
|
|
* "RTP Streams" dialog box common routines.
|
|
|
|
* @ingroup main_ui_group
|
|
|
|
*/
|
|
|
|
|
2021-03-16 13:50:13 -07:00
|
|
|
#include <epan/address.h>
|
|
|
|
|
2018-06-15 22:47:47 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
/* forward */
|
|
|
|
struct _rtp_info;
|
|
|
|
|
|
|
|
/** Defines an rtp stream identification */
|
|
|
|
typedef struct _rtpstream_id {
|
|
|
|
address src_addr;
|
2024-03-29 18:08:09 -07:00
|
|
|
uint16_t src_port;
|
2018-06-15 22:47:47 +02:00
|
|
|
address dst_addr;
|
2024-03-29 18:08:09 -07:00
|
|
|
uint16_t dst_port;
|
|
|
|
uint32_t ssrc;
|
2018-06-15 22:47:47 +02:00
|
|
|
} rtpstream_id_t;
|
|
|
|
|
2021-04-13 16:38:13 +02:00
|
|
|
/**
|
|
|
|
* Get hash of rtpstream_id
|
|
|
|
*/
|
2024-03-29 18:08:09 -07:00
|
|
|
unsigned rtpstream_id_to_hash(const rtpstream_id_t *id);
|
2021-04-13 16:38:13 +02:00
|
|
|
|
2018-06-15 22:47:47 +02:00
|
|
|
/**
|
2018-06-21 14:24:17 +02:00
|
|
|
* Copy rtpstream_id_t structure
|
2018-06-15 22:47:47 +02:00
|
|
|
*/
|
|
|
|
void rtpstream_id_copy(const rtpstream_id_t *src, rtpstream_id_t *dest);
|
|
|
|
|
|
|
|
/**
|
2023-02-28 18:28:39 -05:00
|
|
|
* Deep copy addresses and ports from pinfo
|
2018-06-15 22:47:47 +02:00
|
|
|
*/
|
2024-03-29 18:08:09 -07:00
|
|
|
void rtpstream_id_copy_pinfo(const packet_info *pinfo, rtpstream_id_t *dest, bool swap_src_dst);
|
2018-06-15 22:47:47 +02:00
|
|
|
|
2023-02-28 18:28:39 -05:00
|
|
|
/**
|
|
|
|
* Shallow copy addresses and ports from pinfo
|
|
|
|
* Do not call rtpstream_id_free if you use this function.
|
|
|
|
*/
|
2024-03-29 18:08:09 -07:00
|
|
|
void rtpstream_id_copy_pinfo_shallow(const packet_info *pinfo, rtpstream_id_t *dest, bool swap_src_dst);
|
2023-02-28 18:28:39 -05:00
|
|
|
|
2018-06-15 22:47:47 +02:00
|
|
|
/**
|
|
|
|
* Free memory allocated for id
|
|
|
|
* it releases address items only, do not release whole structure!
|
|
|
|
*/
|
|
|
|
void rtpstream_id_free(rtpstream_id_t *id);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if two rtpstream_id_t are equal
|
|
|
|
* - compare src_addr, dest_addr, src_port, dest_port
|
|
|
|
* - compare other items when requested
|
|
|
|
* Note: ssrc is the only other item now, but it is expected it will be extended later
|
|
|
|
*/
|
|
|
|
#define RTPSTREAM_ID_EQUAL_NONE 0x0000
|
|
|
|
#define RTPSTREAM_ID_EQUAL_SSRC 0x0001
|
2024-03-29 18:08:09 -07:00
|
|
|
bool rtpstream_id_equal(const rtpstream_id_t *id1, const rtpstream_id_t *id2, unsigned flags);
|
2018-06-15 22:47:47 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if rtpstream_id_t is equal to pinfo
|
|
|
|
* - compare src_addr, dest_addr, src_port, dest_port with pinfo
|
RTP: Improve selection of streams for RTP Analysis/Player
If we are only trying to find RTP streams that match the current
packet, there's no reason to retap all other packets after
dissecting the current packet. This speeds up selection in that
case.
It is possible for an RTP session to contain multiple SSRCs
(such as with SDP negotiating BUNDLE (RFC 9143) as in WebRTC,
also see RFC 8872 for a general disscussion.)
The existing mechanism for searching for matching RTP streams for
the currently selected packet does not deal well with this.
findRtpStreams adds one copy of the forward stream (however, with the
same SSRC each time) for each stream bundled together on the session.
It also adds one copy for each stream in the reverse direction, only
using the first encountered SSRC.
When processed later, that means that only one reverse direction RTP
stream is added, which might not be the desired pair of the forward
stream (e.g., audio and video are bundled in each direction.)
Worse, if and when the RTP stream IDs are freed, a double-free can occur
and crash.
Don't add an RTP stream more than once.
Change the behavior when the Ctrl key is selected to adding all
RTP streams that share the addresses and ports (in either direction)
regardless of SSRC. Adding everything in the bundle makes more sense,
especially since there's no good way to determine which of the
bundled reverse RTP streams are paired with the selected packet's
RTP stream.
Also try to handle the unusual case of more than one stream in
the current packet (could happen with unusual tunneling.)
2023-07-01 07:51:16 -04:00
|
|
|
* - if swap_src_dst is true, compare src to dst and vice versa
|
|
|
|
*/
|
2024-03-29 18:08:09 -07:00
|
|
|
bool rtpstream_id_equal_pinfo(const rtpstream_id_t *id, const packet_info *pinfo, bool swap_src_dst);
|
RTP: Improve selection of streams for RTP Analysis/Player
If we are only trying to find RTP streams that match the current
packet, there's no reason to retap all other packets after
dissecting the current packet. This speeds up selection in that
case.
It is possible for an RTP session to contain multiple SSRCs
(such as with SDP negotiating BUNDLE (RFC 9143) as in WebRTC,
also see RFC 8872 for a general disscussion.)
The existing mechanism for searching for matching RTP streams for
the currently selected packet does not deal well with this.
findRtpStreams adds one copy of the forward stream (however, with the
same SSRC each time) for each stream bundled together on the session.
It also adds one copy for each stream in the reverse direction, only
using the first encountered SSRC.
When processed later, that means that only one reverse direction RTP
stream is added, which might not be the desired pair of the forward
stream (e.g., audio and video are bundled in each direction.)
Worse, if and when the RTP stream IDs are freed, a double-free can occur
and crash.
Don't add an RTP stream more than once.
Change the behavior when the Ctrl key is selected to adding all
RTP streams that share the addresses and ports (in either direction)
regardless of SSRC. Adding everything in the bundle makes more sense,
especially since there's no good way to determine which of the
bundled reverse RTP streams are paired with the selected packet's
RTP stream.
Also try to handle the unusual case of more than one stream in
the current packet (could happen with unusual tunneling.)
2023-07-01 07:51:16 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check if rtpstream_id_t is equal to pinfo and rtp_info
|
|
|
|
* - compare src_addr, dest_addr, src_port, dest_port with pinfo
|
2018-06-15 22:47:47 +02:00
|
|
|
* - compare ssrc with rtp_info
|
|
|
|
*/
|
2024-03-29 18:08:09 -07:00
|
|
|
bool rtpstream_id_equal_pinfo_rtp_info(const rtpstream_id_t *id, const packet_info *pinfo, const struct _rtp_info *rtp_info);
|
2018-06-15 22:47:47 +02:00
|
|
|
|
2021-04-13 16:38:13 +02:00
|
|
|
/**
|
|
|
|
* Get hash of rtpstream_id extracted from packet_info and _rtp_info
|
|
|
|
*/
|
2024-03-29 18:08:09 -07:00
|
|
|
unsigned pinfo_rtp_info_to_hash(const packet_info *pinfo, const struct _rtp_info *rtp_info);
|
2021-04-13 16:38:13 +02:00
|
|
|
|
2018-06-15 22:47:47 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
#endif /* __RTP_STREAM_ID_H__ */
|