diff options
author | Olivier CrĂȘte <olivier.crete@collabora.com> | 2017-04-11 16:42:55 -0400 |
---|---|---|
committer | Olivier CrĂȘte <olivier.crete@collabora.com> | 2017-04-11 18:31:14 -0400 |
commit | f49ab88f957a3a250ef2ada0c0fab4fbbd3e5da8 (patch) | |
tree | 62fc8643c6439373ca5d665b4480fb320ca4e6aa | |
parent | 8fc22b0034d04cbc222e0637152b1cee2879eef3 (diff) | |
download | libnice-f49ab88f957a3a250ef2ada0c0fab4fbbd3e5da8.tar.gz |
conncheck: Check the controlling state when the req was sent
It was checking when the pair was created, but the role may have
already changed when the request is sent.
-rw-r--r-- | agent/conncheck.c | 30 | ||||
-rw-r--r-- | agent/conncheck.h | 1 |
2 files changed, 19 insertions, 12 deletions
diff --git a/agent/conncheck.c b/agent/conncheck.c index 7ffa3db..5501c2b 100644 --- a/agent/conncheck.c +++ b/agent/conncheck.c @@ -1666,7 +1666,6 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent, tmpbuf2, nice_address_get_port (&pair->remote->addr)); } pair->nominated = use_candidate; - pair->controlling = agent->controlling_mode; pair->prflx_priority = ensure_unique_priority (component, peer_reflexive_candidate_priority (agent, local)); @@ -2531,7 +2530,6 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint pair->priority = nice_candidate_pair_priority (pair->remote->priority, pair->local->priority); pair->nominated = FALSE; - pair->controlling = agent->controlling_mode; pair->prflx_priority = ensure_unique_priority (component, peer_reflexive_candidate_priority (agent, local_cand)); nice_debug ("Agent %p : added a new peer-discovered pair with foundation of '%s'.", agent, pair->foundation); @@ -2777,16 +2775,26 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, NiceStre } else if (res == STUN_USAGE_ICE_RETURN_ROLE_CONFLICT) { /* case: role conflict error, need to restart with new role */ nice_debug ("Agent %p : conncheck %p ROLE CONFLICT, restarting", agent, p); - /* note: our role might already have changed due to an - * incoming request, but if not, change role now; - * follows ICE 7.1.2.1 "Failure Cases" (ID-19) */ - priv_check_for_role_conflict (agent, !p->controlling); - p->stun_message.buffer = NULL; - p->stun_message.buffer_len = 0; - p->state = NICE_CHECK_WAITING; - priv_add_pair_to_triggered_check_queue (agent, p); - nice_debug ("Agent %p : pair %p state WAITING", agent, p); + if (p->stun_message.buffer != NULL) { + guint64 tie; + gboolean controlled_mode; + + /* note: our role might already have changed due to an + * incoming request, but if not, change role now; + * follows ICE 7.1.2.1 "Failure Cases" (ID-19) */ + controlled_mode = (stun_message_find64 (&p->stun_message, + STUN_ATTRIBUTE_ICE_CONTROLLED, &tie) == + STUN_MESSAGE_RETURN_SUCCESS); + + priv_check_for_role_conflict (agent, controlled_mode); + + p->stun_message.buffer = NULL; + p->stun_message.buffer_len = 0; + p->state = NICE_CHECK_WAITING; + priv_add_pair_to_triggered_check_queue (agent, p); + nice_debug ("Agent %p : pair %p state WAITING", agent, p); + } trans_found = TRUE; } else { /* case: STUN error, the check STUN context was freed */ diff --git a/agent/conncheck.h b/agent/conncheck.h index 10319cc..c204475 100644 --- a/agent/conncheck.h +++ b/agent/conncheck.h @@ -85,7 +85,6 @@ struct _CandidateCheckPair gchar foundation[NICE_CANDIDATE_PAIR_MAX_FOUNDATION]; NiceCheckState state; gboolean nominated; - gboolean controlling; gboolean timer_restarted; gboolean valid; guint64 priority; |