Commit 1ab9d7c1 authored by Olivier Crête's avatar Olivier Crête

conncheck: Separate valid and succeded states

RFC 5245 specifies that when a mapped-address differs from the address
from the request was sent, the mapped-address is used to select the
valid pair, but the source address of the check is used to select the
pair that succeeded, so they are not the same.
parent 0a6c779f
...@@ -304,7 +304,7 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen ...@@ -304,7 +304,7 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen
{ {
gboolean keep_timer_going = FALSE; gboolean keep_timer_going = FALSE;
guint s_inprogress = 0, s_succeeded = 0, s_discovered = 0, guint s_inprogress = 0, s_succeeded = 0, s_discovered = 0,
s_nominated = 0, s_waiting_for_nomination = 0; s_nominated = 0, s_waiting_for_nomination = 0, s_valid = 0;
guint frozen = 0, waiting = 0; guint frozen = 0, waiting = 0;
GSList *i, *k; GSList *i, *k;
...@@ -380,6 +380,8 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen ...@@ -380,6 +380,8 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen
++s_succeeded; ++s_succeeded;
else if (p->state == NICE_CHECK_DISCOVERED) else if (p->state == NICE_CHECK_DISCOVERED)
++s_discovered; ++s_discovered;
if (p->valid)
++s_valid;
if ((p->state == NICE_CHECK_SUCCEEDED || p->state == NICE_CHECK_DISCOVERED) if ((p->state == NICE_CHECK_SUCCEEDED || p->state == NICE_CHECK_DISCOVERED)
&& p->nominated) && p->nominated)
...@@ -425,9 +427,9 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen ...@@ -425,9 +427,9 @@ static gboolean priv_conn_check_tick_stream (NiceStream *stream, NiceAgent *agen
if (tick_counter++ % 50 == 0 || keep_timer_going != TRUE) if (tick_counter++ % 50 == 0 || keep_timer_going != TRUE)
nice_debug ("Agent %p : stream %u: timer tick #%u: %u frozen, %u in-progress, " nice_debug ("Agent %p : stream %u: timer tick #%u: %u frozen, %u in-progress, "
"%u waiting, %u succeeded, %u discovered, %u nominated, " "%u waiting, %u succeeded, %u discovered, %u nominated, "
"%u waiting-for-nom.", agent, stream->id, "%u waiting-for-nom, %u valid.", agent, stream->id,
tick_counter, frozen, s_inprogress, waiting, s_succeeded, tick_counter, frozen, s_inprogress, waiting, s_succeeded,
s_discovered, s_nominated, s_waiting_for_nomination); s_discovered, s_nominated, s_waiting_for_nomination, s_valid);
} }
return keep_timer_going; return keep_timer_going;
...@@ -1365,7 +1367,7 @@ static void priv_update_check_list_failed_components (NiceAgent *agent, NiceStre ...@@ -1365,7 +1367,7 @@ static void priv_update_check_list_failed_components (NiceAgent *agent, NiceStre
static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream *stream, NiceComponent *component) static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream *stream, NiceComponent *component)
{ {
GSList *i; GSList *i;
guint succeeded = 0, nominated = 0; guint valid = 0, nominated = 0;
g_assert (component); g_assert (component);
...@@ -1373,9 +1375,8 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream ...@@ -1373,9 +1375,8 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream
for (i = stream->conncheck_list; i; i = i->next) { for (i = stream->conncheck_list; i; i = i->next) {
CandidateCheckPair *p = i->data; CandidateCheckPair *p = i->data;
if (p->component_id == component->id) { if (p->component_id == component->id) {
if (p->state == NICE_CHECK_SUCCEEDED || if (p->valid) {
p->state == NICE_CHECK_DISCOVERED) { ++valid;
++succeeded;
if (p->nominated == TRUE) { if (p->nominated == TRUE) {
++nominated; ++nominated;
} }
...@@ -1383,7 +1384,7 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream ...@@ -1383,7 +1384,7 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream
} }
} }
if (nominated > 0) { if (valid > 0) {
/* Only go to READY if no checks are left in progress. If there are /* Only go to READY if no checks are left in progress. If there are
* any that are kept, then this function will be called again when the * any that are kept, then this function will be called again when the
* conncheck tick timer finishes them all */ * conncheck tick timer finishes them all */
...@@ -1402,7 +1403,7 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream ...@@ -1402,7 +1403,7 @@ static void priv_update_check_list_state_for_ready (NiceAgent *agent, NiceStream
component->id, NICE_COMPONENT_STATE_READY); component->id, NICE_COMPONENT_STATE_READY);
} }
} }
nice_debug ("Agent %p : conn.check list status: %u nominated, %u succeeded, c-id %u.", agent, nominated, succeeded, component->id); nice_debug ("Agent %p : conn.check list status: %u nominated, %u valid, c-id %u.", agent, nominated, valid, component->id);
} }
/* /*
...@@ -1422,8 +1423,7 @@ static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, Nice ...@@ -1422,8 +1423,7 @@ static void priv_mark_pair_nominated (NiceAgent *agent, NiceStream *stream, Nice
if (pair->local == localcand && pair->remote == remotecand) { if (pair->local == localcand && pair->remote == remotecand) {
nice_debug ("Agent %p : marking pair %p (%s) as nominated", agent, pair, pair->foundation); nice_debug ("Agent %p : marking pair %p (%s) as nominated", agent, pair, pair->foundation);
pair->nominated = TRUE; pair->nominated = TRUE;
if (pair->state == NICE_CHECK_SUCCEEDED || if (pair->valid) {
pair->state == NICE_CHECK_DISCOVERED) {
priv_update_selected_pair (agent, component, pair); priv_update_selected_pair (agent, component, pair);
/* Do not step down to CONNECTED if we're already at state READY*/ /* Do not step down to CONNECTED if we're already at state READY*/
if (component->state != NICE_COMPONENT_STATE_READY) { if (component->state != NICE_COMPONENT_STATE_READY) {
...@@ -2051,10 +2051,8 @@ static guint priv_prune_pending_checks (NiceStream *stream, guint component_id) ...@@ -2051,10 +2051,8 @@ static guint priv_prune_pending_checks (NiceStream *stream, guint component_id)
for (i = stream->conncheck_list; i; i = i->next) { for (i = stream->conncheck_list; i; i = i->next) {
CandidateCheckPair *p = i->data; CandidateCheckPair *p = i->data;
if (p->component_id == component_id && if (p->component_id == component_id && p->valid == TRUE &&
(p->state == NICE_CHECK_SUCCEEDED || p->nominated == TRUE) {
p->state == NICE_CHECK_DISCOVERED) &&
p->nominated == TRUE){
if (p->priority > highest_nominated_priority) { if (p->priority > highest_nominated_priority) {
highest_nominated_priority = p->priority; highest_nominated_priority = p->priority;
} }
...@@ -2406,8 +2404,6 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent * ...@@ -2406,8 +2404,6 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent *
} }
if (new_pair) { if (new_pair) {
/* note: this is same as "adding to VALID LIST" in the spec
text */
p->state = NICE_CHECK_SUCCEEDED; p->state = NICE_CHECK_SUCCEEDED;
nice_debug ("Agent %p : conncheck %p SUCCEEDED.", agent, p); nice_debug ("Agent %p : conncheck %p SUCCEEDED.", agent, p);
priv_conn_check_unfreeze_related (agent, stream, p); priv_conn_check_unfreeze_related (agent, stream, p);
...@@ -2432,6 +2428,11 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent * ...@@ -2432,6 +2428,11 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent *
nice_debug ("Agent %p : conncheck %p FAILED, %p DISCOVERED.", agent, p, new_pair); nice_debug ("Agent %p : conncheck %p FAILED, %p DISCOVERED.", agent, p, new_pair);
} }
/* note: this is same as "adding to VALID LIST" in the spec
text */
if (new_pair)
new_pair->valid = TRUE;
return new_pair; return new_pair;
} }
...@@ -2511,6 +2512,8 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, NiceStre ...@@ -2511,6 +2512,8 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, NiceStre
/* note: this is same as "adding to VALID LIST" in the spec /* note: this is same as "adding to VALID LIST" in the spec
text */ text */
p->state = NICE_CHECK_SUCCEEDED; p->state = NICE_CHECK_SUCCEEDED;
p->valid = TRUE;
g_assert_not_reached ();
nice_debug ("Agent %p : Mapped address not found." nice_debug ("Agent %p : Mapped address not found."
" conncheck %p SUCCEEDED.", agent, p); " conncheck %p SUCCEEDED.", agent, p);
priv_conn_check_unfreeze_related (agent, stream, p); priv_conn_check_unfreeze_related (agent, stream, p);
......
...@@ -87,6 +87,7 @@ struct _CandidateCheckPair ...@@ -87,6 +87,7 @@ struct _CandidateCheckPair
gboolean nominated; gboolean nominated;
gboolean controlling; gboolean controlling;
gboolean timer_restarted; gboolean timer_restarted;
gboolean valid;
guint64 priority; guint64 priority;
GTimeVal next_tick; /* next tick timestamp */ GTimeVal next_tick; /* next tick timestamp */
StunTimer timer; StunTimer timer;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment