Add sip_call_id filter to RTP stream.

Change-Id: Ia525fa74457eef03a3a8bc85905036c19693cfbb
Reviewed-on: https://code.wireshark.org/review/30830
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Anders Broman 2018-11-29 10:48:46 +01:00 committed by Anders Broman
parent 0da9763d11
commit d68b7bc505
15 changed files with 95 additions and 30 deletions

View File

@ -340,7 +340,7 @@ static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_cha
if (upcoming_channel_lcl->media_addr.addr.type!=AT_NONE && upcoming_channel_lcl->media_addr.port!=0) {
srtp_add_address(pinfo, PT_UDP, &upcoming_channel_lcl->media_addr.addr,
upcoming_channel_lcl->media_addr.port, 0,
"H245", pinfo->num, upcoming_channel_lcl->is_video , rtp_dyn_payload, dummy_srtp_info);
"H245", pinfo->num, upcoming_channel_lcl->is_video , rtp_dyn_payload, dummy_srtp_info, NULL);
}
if (upcoming_channel_lcl->media_control_addr.addr.type!=AT_NONE && upcoming_channel_lcl->media_control_addr.port!=0 && rtcp_handle) {
srtcp_add_address(pinfo, &upcoming_channel_lcl->media_control_addr.addr,

View File

@ -471,7 +471,7 @@ static void h245_setup_channels(packet_info *pinfo, channel_info_t *upcoming_cha
if (upcoming_channel_lcl->media_addr.addr.type!=AT_NONE && upcoming_channel_lcl->media_addr.port!=0) {
srtp_add_address(pinfo, PT_UDP, &upcoming_channel_lcl->media_addr.addr,
upcoming_channel_lcl->media_addr.port, 0,
"H245", pinfo->num, upcoming_channel_lcl->is_video , rtp_dyn_payload, dummy_srtp_info);
"H245", pinfo->num, upcoming_channel_lcl->is_video , rtp_dyn_payload, dummy_srtp_info, NULL);
}
if (upcoming_channel_lcl->media_control_addr.addr.type!=AT_NONE && upcoming_channel_lcl->media_control_addr.port!=0 && rtcp_handle) {
srtcp_add_address(pinfo, &upcoming_channel_lcl->media_control_addr.addr,

View File

@ -78,13 +78,15 @@ typedef enum _http_type {
HTTP_REQUEST,
HTTP_RESPONSE,
HTTP_NOTIFICATION,
HTTP_OTHERS
HTTP_OTHERS,
SIP_DATA /* If the content is from the SIP dissector*/
} http_type_t;
/** Passed to dissectors called by the HTTP dissector. */
typedef struct _http_message_info_t {
http_type_t type; /* Message type; may be HTTP_OTHERS if not called by HTTP */
const char *media_str; /* Content-Type parameters */
http_type_t type; /**< Message type; may be HTTP_OTHERS if not called by HTTP */
const char *media_str; /**< Content-Type parameters */
void *data; /**< The http_type is used to indicate the data transported */
} http_message_info_t;
#endif /* __PACKET_HTTP_H__ */

View File

@ -1996,7 +1996,7 @@ dissect_body_data(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb,
{
http2_data_stream_body_info_t *body_info = get_data_stream_body_info(pinfo);
gchar *content_type = body_info->content_type;
http_message_info_t metadata_used_for_media_type_handle = { HTTP_OTHERS, body_info->content_type_parameters };
http_message_info_t metadata_used_for_media_type_handle = { HTTP_OTHERS, body_info->content_type_parameters, NULL };
proto_tree_add_item(tree, hf_http2_data_data, tvb, start, length, encoding);

View File

@ -890,6 +890,7 @@ dissect_imf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
message_info.type = HTTP_OTHERS;
message_info.media_str = parameters;
message_info.data = NULL;
dissector_try_string(media_type_dissector_table, content_type_str, next_tvb, pinfo, tree, (void*)&message_info);
} else {

View File

@ -2017,7 +2017,7 @@ static int dissect_media( const gchar* fullmediatype, tvbuff_t * tvb, packet_inf
gchar *mediatype = wmem_strdup(wmem_packet_scope(), fullmediatype);
gchar *parms_at = strchr(mediatype, ';');
const char *save_match_string = pinfo->match_string;
http_message_info_t message_info = { HTTP_OTHERS, NULL };
http_message_info_t message_info = { HTTP_OTHERS, NULL, NULL };
/* Based upon what is done in packet-media.c we set up type and params */
if (NULL != parms_at) {

View File

@ -457,7 +457,7 @@ dissect_msrp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_
int found_match = 0;
gint content_type_len, content_type_parameter_str_len;
gchar *media_type_str_lower_case = NULL;
http_message_info_t message_info = { HTTP_OTHERS, NULL };
http_message_info_t message_info = { HTTP_OTHERS, NULL, NULL };
tvbuff_t *next_tvb;
gint parameter_offset;
gint semi_colon_offset;

View File

@ -545,7 +545,7 @@ process_body_part(proto_tree *tree, tvbuff_t *tvb,
proto_tree *subtree;
proto_item *ti;
gint offset = start, next_offset = 0;
http_message_info_t message_info = { input_message_info->type, NULL };
http_message_info_t message_info = { input_message_info->type, NULL, NULL };
gint body_start, boundary_start, boundary_line_len;
gchar *content_type_str = NULL;

View File

@ -163,6 +163,9 @@ static dissector_table_t rtp_dyn_pt_dissector_table;
static dissector_table_t rtp_hdr_ext_dissector_table;
static dissector_table_t rtp_hdr_ext_rfc5285_dissector_table;
/* Used for storing data to be retreived by the SDP dissector*/
static int proto_sdp = -1;
/* RTP header fields */
static int proto_rtp = -1;
static int hf_rtp_version = -1;
@ -1018,7 +1021,7 @@ void
srtp_add_address(packet_info *pinfo, const port_type ptype, address *addr, int port, int other_port,
const gchar *setup_method, guint32 setup_frame_number,
guint32 media_types _U_, rtp_dyn_payload_t *rtp_dyn_payload,
struct srtp_info *srtp_info)
struct srtp_info *srtp_info, sdp_setup_info_t *setup_info)
{
address null_addr;
conversation_t* p_conv;
@ -1115,6 +1118,9 @@ srtp_add_address(packet_info *pinfo, const port_type ptype, address *addr, int p
p_conv_data->frame_number = setup_frame_number;
p_conv_data->media_types = media_types;
p_conv_data->srtp_info = srtp_info;
if (setup_info) {
p_conv_data->setup_info = setup_info;
}
p_conv_data->bta2dp_info = NULL;
p_conv_data->btvdp_info = NULL;
}
@ -1125,7 +1131,7 @@ rtp_add_address(packet_info *pinfo, const port_type ptype, address *addr, int po
const gchar *setup_method, guint32 setup_frame_number,
guint32 media_types , rtp_dyn_payload_t *rtp_dyn_payload)
{
srtp_add_address(pinfo, ptype, addr, port, other_port, setup_method, setup_frame_number, media_types, rtp_dyn_payload, NULL);
srtp_add_address(pinfo, ptype, addr, port, other_port, setup_method, setup_frame_number, media_types, rtp_dyn_payload, NULL, NULL);
}
static gboolean
@ -2307,6 +2313,7 @@ get_conv_info(packet_info *pinfo, struct _rtp_info *rtp_info)
p_conv_packet_data->rtp_dyn_payload = p_conv_data->rtp_dyn_payload;
p_conv_packet_data->rtp_conv_info = p_conv_data->rtp_conv_info;
p_conv_packet_data->srtp_info = p_conv_data->srtp_info;
p_conv_packet_data->setup_info = p_conv_data->setup_info;
p_conv_packet_data->bta2dp_info = p_conv_data->bta2dp_info;
p_conv_packet_data->btvdp_info = p_conv_data->btvdp_info;
/* XXX: why is this file pool not pinfo->pool? */
@ -2358,6 +2365,14 @@ show_setup_info(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
item = proto_tree_add_string(rtp_setup_tree, hf_rtp_setup_method,
tvb, 0, 0, p_conv_data->method);
PROTO_ITEM_SET_GENERATED(item);
if ((p_conv_data->setup_info) && (p_conv_data->setup_info->hf_id)) {
if (p_conv_data->setup_info->hf_type == SDP_TRACE_ID_HF_TYPE_STR ) {
item = proto_tree_add_string(rtp_setup_tree, p_conv_data->setup_info->hf_id, tvb, 0, 0, p_conv_data->setup_info->trace_id);
PROTO_ITEM_SET_GENERATED(item);
}
}
}
}
@ -3026,6 +3041,7 @@ proto_reg_handoff_rtp(void)
}
dissector_add_uint("rtp.pt", rtp_rfc2198_pt, rtp_rfc2198_handle);
rtp_saved_rfc2198_pt = rtp_rfc2198_pt;
proto_sdp = proto_get_id_by_filter_name("sdp");
}
/*

View File

@ -13,11 +13,14 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_RTP_H__
#define __PACKET_RTP_H__
#include "epan/packet.h"
#include "ws_symbol_export.h"
#include "packet-btavdtp.h"
#include "packet-sdp.h"
#define RTP_MEDIA_AUDIO 1
#define RTP_MEDIA_VIDEO 2
@ -165,7 +168,7 @@ void rtp_dump_dyn_payload(rtp_dyn_payload_t *rtp_dyn_payload);
#endif
/* Info to save in RTP conversation / packet-info */
#define MAX_RTP_SETUP_METHOD_SIZE 7
#define MAX_RTP_SETUP_METHOD_SIZE 11
struct _rtp_conversation_info
{
gchar method[MAX_RTP_SETUP_METHOD_SIZE + 1];
@ -183,6 +186,7 @@ struct _rtp_conversation_info
struct srtp_info *srtp_info; /* SRTP context */
bta2dp_codec_info_t *bta2dp_info;
btvdp_codec_info_t *btvdp_info;
sdp_setup_info_t *setup_info;
};
/* Add an RTP conversation with the given details */
@ -206,10 +210,13 @@ void srtp_add_address(packet_info *pinfo,
guint32 setup_frame_number,
guint32 media_types,
rtp_dyn_payload_t *rtp_dyn_payload,
struct srtp_info *srtp_info);
struct srtp_info *srtp_info,
sdp_setup_info_t *setup_info);
/* Add an Bluetooth conversation with the given details */
void
bluetooth_add_address(packet_info *pinfo, address *addr, guint32 stream_number,
const gchar *setup_method, guint32 setup_frame_number,
guint32 media_types, void *data);
#endif /*__PACKET_RTP_H__*/

View File

@ -27,6 +27,7 @@
#include <wsutil/strtoi.h>
#include "packet-http.h"
#include "packet-sdp.h"
/* un-comment the following as well as this line in conversation.c, to enable debug printing */
@ -2205,7 +2206,7 @@ complete_descriptions(transport_info_t *transport_info, guint answer_offset)
* are not freed, this is the responsibility of the caller.
*/
static void
apply_sdp_transport(packet_info *pinfo, transport_info_t *transport_info, int request_frame)
apply_sdp_transport(packet_info *pinfo, transport_info_t *transport_info, int request_frame, sdp_setup_info_t *setup_info)
{
int establish_frame = 0;
@ -2262,15 +2263,16 @@ apply_sdp_transport(packet_info *pinfo, transport_info_t *transport_info, int re
because that's where the RTP flow started, and thus conversation needs to check against */
srtp_add_address(pinfo, PT_UDP, &media_desc->conn_addr, media_desc->media_port, 0, "SDP", establish_frame,
media_desc->media_types,
media_desc->media.rtp_dyn_payload, srtp_info);
media_desc->media.rtp_dyn_payload, srtp_info,
setup_info);
DENDENT();
} else {
DPRINT(("calling rtp_add_address, channel=%d, media_port=%d",
i, media_desc->media_port));
DINDENT();
rtp_add_address(pinfo, PT_UDP, &media_desc->conn_addr, media_desc->media_port, 0, "SDP", establish_frame,
srtp_add_address(pinfo, PT_UDP, &media_desc->conn_addr, media_desc->media_port, 0, "SDP", establish_frame,
media_desc->media_types,
media_desc->media.rtp_dyn_payload);
media_desc->media.rtp_dyn_payload, NULL, setup_info);
DENDENT();
}
/* SPRT might use the same port... */
@ -2327,7 +2329,7 @@ apply_sdp_transport(packet_info *pinfo, transport_info_t *transport_info, int re
void
setup_sdp_transport(tvbuff_t *tvb, packet_info *pinfo, enum sdp_exchange_type exchange_type,
int request_frame, const gboolean delay)
int request_frame, const gboolean delay, sdp_setup_info_t *setup_info)
{
gint offset = 0, next_offset, n;
int linelen;
@ -2476,7 +2478,7 @@ setup_sdp_transport(tvbuff_t *tvb, packet_info *pinfo, enum sdp_exchange_type ex
if (!delay || ((exchange_type == SDP_EXCHANGE_ANSWER_ACCEPT) &&
(transport_info->sdp_status == SDP_EXCHANGE_OFFER))) {
/* Accepting answer to a previous offer (or delay pref is false). */
apply_sdp_transport(pinfo, transport_info, request_frame);
apply_sdp_transport(pinfo, transport_info, request_frame, setup_info);
/* Free all media hash tables that were not assigned to a conversation
* ('set_rtp' is false) */
@ -2506,7 +2508,7 @@ void setup_sdp_transport_resend(int current_frame, int request_frame)
}
static int
dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
proto_tree *sdp_tree;
proto_item *ti, *sub_ti;
@ -2523,6 +2525,14 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
media_description_t *media_desc = NULL;
session_info_t session_info;
sdp_packet_info *sdp_pi;
sdp_setup_info_t *setup_info = NULL;
if (data) {
http_message_info_t *message_info = (http_message_info_t *)data;
if (message_info->type == SIP_DATA) {
setup_info = (sdp_setup_info_t *)message_info->data;
}
}
DPRINT2(("----------------------- dissect_sdp ------------------------"));
@ -2748,7 +2758,7 @@ dissect_sdp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
* not an earlier request (transport_info == &local_transport_info).
* Use 0 as request_frame since there is no (known) request.
*/
apply_sdp_transport(pinfo, transport_info, 0);
apply_sdp_transport(pinfo, transport_info, 0, setup_info);
}
/* Add information to the VoIP Calls dialog. */

View File

@ -12,8 +12,11 @@
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef __PACKET_SDP_H__
#define __PACKET_SDP_H__
typedef struct _sdp_packet_info {
gchar summary_str[50]; /* SDP summary string for VoIP calls graph analysis */
gchar summary_str[50]; /* SDP summary string for VoIP calls graph analysis */
} sdp_packet_info;
enum sdp_exchange_type
@ -23,8 +26,25 @@ enum sdp_exchange_type
SDP_EXCHANGE_ANSWER_REJECT
};
extern void setup_sdp_transport(tvbuff_t *tvb, packet_info *pinfo, enum sdp_exchange_type type, int request_frame, const gboolean delay);
enum sdp_trace_id_hf_type
{
SDP_TRACE_ID_HF_TYPE_STR = 0 /* */
};
/*
* Information needed to set up a trace id in RTP(t ex SIP CallId )
*/
typedef struct _sdp_setup_info {
gchar *setup_proto;
int hf_id; /* Header field to use */
enum sdp_trace_id_hf_type hf_type; /* Indicates which of the following variables to use( add guint32 etc as needed)*/
gchar *trace_id; /* The trace id if the type is str*/
} sdp_setup_info_t;
extern void setup_sdp_transport(tvbuff_t *tvb, packet_info *pinfo, enum sdp_exchange_type type, int request_frame, const gboolean delay, sdp_setup_info_t *setup_info);
/* Handles duplicate OFFER packets so they don't end up processed by dissect_sdp(). This can probably
* be removed when all higher layer dissectors properly handle SDP themselves with setup_sdp_transport()
*/
extern void setup_sdp_transport_resend(int current_frame, int request_frame);
#endif /* __PACKET_SDP_H__ */

View File

@ -3338,7 +3338,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
char cseq_method[MAX_CSEQ_METHOD_SIZE] = "";
char call_id[MAX_CALL_ID_SIZE] = "";
gchar *media_type_str_lower_case = NULL;
http_message_info_t message_info = { HTTP_OTHERS, NULL };
http_message_info_t message_info = { SIP_DATA, NULL, NULL };
char *content_encoding_parameter_str = NULL;
guint resend_for_packet = 0;
guint request_for_response = 0;
@ -4703,11 +4703,19 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
if (!strcmp(media_type_str_lower_case, "application/sdp")) {
/* Resends don't count */
if (resend_for_packet == 0) {
sdp_setup_info_t *setup_info = wmem_new(wmem_file_scope(), sdp_setup_info_t);
setup_info->setup_proto = g_strdup("SIP");
setup_info->hf_id = hf_header_array[POS_CALL_ID];
setup_info->hf_type = SDP_TRACE_ID_HF_TYPE_STR;
setup_info->trace_id = wmem_strdup(wmem_file_scope(), call_id);
message_info.data = setup_info;
if (line_type == REQUEST_LINE) {
DPRINT(("calling setup_sdp_transport() SDP_EXCHANGE_OFFER frame=%d",
pinfo->num));
DINDENT();
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_OFFER, pinfo->num, sip_delay_sdp_changes);
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_OFFER, pinfo->num, sip_delay_sdp_changes, setup_info);
DENDENT();
} else if (line_type == STATUS_LINE) {
if (stat_info->response_code >= 400) {
@ -4716,7 +4724,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
request_for_response, pinfo->num));
DINDENT();
/* SIP client request failed, so SDP offer should fail */
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_ANSWER_REJECT, request_for_response, sip_delay_sdp_changes);
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_ANSWER_REJECT, request_for_response, sip_delay_sdp_changes, setup_info);
DENDENT();
}
else if ((stat_info->response_code >= 200) && (stat_info->response_code <= 299)) {
@ -4725,7 +4733,7 @@ dissect_sip_common(tvbuff_t *tvb, int offset, int remaining_length, packet_info
request_for_response, pinfo->num));
DINDENT();
/* SIP success request, so SDP offer should be accepted */
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_ANSWER_ACCEPT, request_for_response, sip_delay_sdp_changes);
setup_sdp_transport(next_tvb, pinfo, SDP_EXCHANGE_ANSWER_ACCEPT, request_for_response, sip_delay_sdp_changes, setup_info);
DENDENT();
}
}

View File

@ -906,6 +906,7 @@ static int dissect_spdy_data_payload(tvbuff_t *tvb,
}
message_info.type = si->message_type;
message_info.media_str = media_str;
message_info.data = NULL;
if (handle != NULL) {
/*
* We have a subdissector - call it.

View File

@ -443,10 +443,10 @@ dissect_Conf2ACK(packet_info *pinfo) {
dummy_srtp_info->auth_tag_len = 4;
srtp_add_address(pinfo, PT_UDP, &pinfo->net_src, pinfo->srcport, pinfo->destport,
"ZRTP", pinfo->num, RTP_MEDIA_AUDIO, NULL, dummy_srtp_info);
"ZRTP", pinfo->num, RTP_MEDIA_AUDIO, NULL, dummy_srtp_info, NULL);
srtp_add_address(pinfo, PT_UDP, &pinfo->net_dst, pinfo->destport, pinfo->srcport,
"ZRTP", pinfo->num, RTP_MEDIA_AUDIO, NULL, dummy_srtp_info);
"ZRTP", pinfo->num, RTP_MEDIA_AUDIO, NULL, dummy_srtp_info, NULL);
srtcp_add_address(pinfo, &pinfo->net_src, pinfo->srcport+1, pinfo->destport+1,
"ZRTP", pinfo->num, dummy_srtp_info);