From b593d57e21ecc20c76df44062ed175799f0c8922 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 3 Jan 2019 16:22:36 -0500 Subject: [PATCH] TT#37400 do not answer with ICE attributes if no ICE was offered fixes #561 Change-Id: Ia660f19109404f8edc1dd5c143e797a82d25276d --- daemon/call.c | 24 +++++++++++++++++------- daemon/sdp.c | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 28381b766..ec8ddb45f 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1232,13 +1232,23 @@ static void __ice_offer(const struct sdp_ng_flags *flags, struct call_media *thi if (flags->ice_remove) MEDIA_CLEAR(this, ICE); - /* special case: if doing ICE on both sides and ice_force is not set, we cannot - * be sure that media will pass through us, so we have to disable certain features */ - if (MEDIA_ISSET(this, ICE) && MEDIA_ISSET(other, ICE) && !flags->ice_force) { - ilog(LOG_DEBUG, "enabling passthrough mode"); - MEDIA_SET(this, PASSTHRU); - MEDIA_SET(other, PASSTHRU); - return; + if (!flags->ice_force) { + /* special case: if doing ICE on both sides and ice_force is not set, we cannot + * be sure that media will pass through us, so we have to disable certain features */ + if (MEDIA_ISSET(this, ICE) && MEDIA_ISSET(other, ICE)) { + ilog(LOG_DEBUG, "enabling passthrough mode"); + MEDIA_SET(this, PASSTHRU); + MEDIA_SET(other, PASSTHRU); + return; + } + // if this is an answer, may see our ICE offer being rejected. if the original offer + // wasn't forcing ICE, then we're only acting as a passthrough and so we must disable + // ICE on the remote side as well. we can use the presence of an ICE agent as a test + // to see whether ICE was originally forced or not. + if (flags->opmode == OP_ANSWER && !MEDIA_ISSET(other, ICE) && !this->ice_agent) { + MEDIA_CLEAR(this, ICE); + return; + } } /* determine roles (even if we don't actually do ICE) */ diff --git a/daemon/sdp.c b/daemon/sdp.c index b70bcd21b..d4414df29 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2151,7 +2151,7 @@ int sdp_replace(struct sdp_chopper *chop, GQueue *sessions, struct call_monologu if (MEDIA_ISSET(call_media, TRICKLE_ICE) && call_media->ice_agent) chopper_append_c(chop, "a=ice-options:trickle\r\n"); - if (!flags->ice_remove) + if (MEDIA_ISSET(call_media, ICE)) insert_candidates(chop, ps, ps_rtcp, flags, sdp_media); next: