From 7123b59bb4f468ef32821126418b76e3341b65d3 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Tue, 7 May 2024 17:04:37 +0200 Subject: [PATCH] MT#56465 Carry `sdp_origin` via flags to ml init func In order to be able to set `sdp_origin` related things while initiating a monologue from flags (so in `__call_monologue_init_from_flags()` ), duplicate `sdp_origin` from `sdp_session` while doing streams parsing in `sdp_streams()`. Change-Id: I17a4400a41623d336590010e9dfc5389460b27be --- daemon/call.c | 13 +++++++++++++ daemon/sdp.c | 18 +----------------- include/call_interfaces.h | 3 +++ include/sdp.h | 16 ++++++++++++++++ 4 files changed, 33 insertions(+), 17 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 200400d12..9b8895f51 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2638,6 +2638,19 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, sdp_ng_f ml->sdp_attributes = flags->session_attributes; t_queue_init(&flags->session_attributes); + /* consume sdp session origin parts (name, version etc.) */ + { + if (!ml->sdp_username && flags->session_sdp_orig.username.len) + ml->sdp_username = call_strdup_len(call, flags->session_sdp_orig.username.s, + flags->session_sdp_orig.username.len); + if (!ml->sdp_session_id && flags->session_sdp_orig.session_id.len) + ml->sdp_session_id = str_to_ui(&flags->session_sdp_orig.session_id, 0); + + ml->sdp_version = flags->session_sdp_orig.version_num; + if (ml->sdp_version == ULLONG_MAX) + ml->sdp_version = (unsigned int)ssl_random(); + } + // reset offer ipv4/ipv6/mixed media stats if (flags->opmode == OP_OFFER) { statistics_update_ip46_inc_dec(call, CMC_DECREMENT); diff --git a/daemon/sdp.c b/daemon/sdp.c index 1a0b99b51..1d9e1bded 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -71,23 +71,6 @@ enum attr_id { // make sure g_int_hash can be used static_assert(sizeof(gint) == sizeof(enum attr_id), "sizeof enum attr_id wrong"); -struct network_address { - str network_type; - str address_type; - str address; - sockaddr_t parsed; -}; - -struct sdp_origin { - str username; - str session_id; - str version_str; - struct network_address address; - unsigned long long version_num; - size_t version_output_pos; - unsigned int parsed:1; -}; - struct sdp_connection { str s; struct network_address address; @@ -1806,6 +1789,7 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f session = l->data; sdp_attr_append_other(&flags->session_attributes, &session->attributes); + flags->session_sdp_orig = session->origin; for (__auto_type k = session->media_streams.head; k; k = k->next) { media = k->data; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 2e8e14d9b..eef21b058 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -68,7 +68,10 @@ struct sdp_ng_flags { str_q sdes_order; /* the order, in which crypto suites are being added to the SDP */ str_q sdes_offerer_pref; /* preferred crypto suites to be selected for the offerer */ str dtls_fingerprint; + + /* keep session level attributes for internal proper parsing */ sdp_attr_q session_attributes; // top-level (not part of an m= section) SDP session attributes + struct sdp_origin session_sdp_orig; /* commands to manipulate attr lines in SDP */ struct sdp_manipulations * sdp_manipulations[__MT_MAX]; diff --git a/include/sdp.h b/include/sdp.h index 8a19d75cf..47249c9ef 100644 --- a/include/sdp.h +++ b/include/sdp.h @@ -44,6 +44,22 @@ struct sdp_attr { enum sdp_attr_type type; }; +struct network_address { + str network_type; + str address_type; + str address; + sockaddr_t parsed; +}; + +struct sdp_origin { + str username; + str session_id; + str version_str; + struct network_address address; + unsigned long long version_num; + size_t version_output_pos; + unsigned int parsed:1; +}; extern const str rtpe_instance_id;