From e59d0f4461cb725b6420e83d51b7e0b717a05b9e Mon Sep 17 00:00:00 2001 From: Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> Date: Tue, 18 Oct 2016 11:23:39 -0400 Subject: [PATCH] ice: fix IceTransport getLocalAddress/getRemoteAddress APIs This patch contains following changes: * getLocalAddress : wasn't return the negotiated IP if available * getRemoteAddress : do not check for negotiation state * some debug added This fixes bugs during call establishement when IPv6 pair is negotiated, but an IPv4 TURN is given as candidate (and not selected, but used as default IP). Change-Id: I89a973c16674b24cce35dc6dd9433554cb3a41bd Tuleap: #891 (cherry picked from commit b1e576a372a208e93b5c9c4ca986fb990d930ff6) --- src/ice_transport.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ice_transport.cpp b/src/ice_transport.cpp index f768cd9225..ffcbdd581a 100644 --- a/src/ice_transport.cpp +++ b/src/ice_transport.cpp @@ -504,18 +504,33 @@ IceTransport::_isFailed() const IpAddr IceTransport::getLocalAddress(unsigned comp_id) const { + // Return the local IP of negotiated connection pair + if (isRunning()) { + if (auto sess = pj_ice_strans_get_valid_pair(icest_.get(), comp_id+1)) { + return sess->lcand->addr; + } + RING_WARN("Non-negotiated transport: try to return default local IP"); + } + + // Return the default IP (could be not nominated and valid after negotiation) if (isInitialized()) return cand_[comp_id].addr; + + RING_ERR("bad call: non-initialized transport"); return {}; } IpAddr IceTransport::getRemoteAddress(unsigned comp_id) const { - if (isInitialized()) { + // Return the remote IP of negotiated connection pair + if (isRunning()) { if (auto sess = pj_ice_strans_get_valid_pair(icest_.get(), comp_id+1)) return sess->rcand->addr; + RING_ERR("runtime error: negotiated transport without valid pair"); } + + RING_ERR("bad call: non-negotiated transport"); return {}; } -- GitLab