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
This commit is contained in:
Guillaume Roguez
2016-10-18 11:23:39 -04:00
parent 0bc5829b88
commit b1e576a372

View File

@ -545,18 +545,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 {};
}