Commit 47aa0288 authored by Fabrice Bellet's avatar Fabrice Bellet Committed by Olivier Crête

conncheck: factorize pair state debug

Reviewed-by: default avatarOlivier Crête <olivier.crete@collabora.com>
Differential Revision: https://phabricator.freedesktop.org/D1892
parent b5dd5e2a
...@@ -123,22 +123,29 @@ priv_state_to_string (NiceCheckState state) ...@@ -123,22 +123,29 @@ priv_state_to_string (NiceCheckState state)
{ {
switch (state) { switch (state) {
case NICE_CHECK_WAITING: case NICE_CHECK_WAITING:
return "waiting"; return "WAITING";
case NICE_CHECK_IN_PROGRESS: case NICE_CHECK_IN_PROGRESS:
return "in progress"; return "IN_PROGRESS";
case NICE_CHECK_SUCCEEDED: case NICE_CHECK_SUCCEEDED:
return "succeeded"; return "SUCCEEDED";
case NICE_CHECK_FAILED: case NICE_CHECK_FAILED:
return "failed"; return "FAILED";
case NICE_CHECK_FROZEN: case NICE_CHECK_FROZEN:
return "frozen"; return "FROZEN";
case NICE_CHECK_DISCOVERED: case NICE_CHECK_DISCOVERED:
return "discovered"; return "DISCOVERED";
default: default:
g_assert_not_reached (); g_assert_not_reached ();
} }
} }
#define SET_PAIR_STATE( a, p, s ) G_STMT_START{\
g_assert (p); \
p->state = s; \
nice_debug ("Agent %p : pair %p state %s (%s)", \
a, p, priv_state_to_string (s), G_STRFUNC); \
}G_STMT_END
static const gchar * static const gchar *
priv_ice_return_to_string (StunUsageIceReturn ice_return) priv_ice_return_to_string (StunUsageIceReturn ice_return)
{ {
...@@ -251,8 +258,7 @@ priv_add_pair_to_triggered_check_queue (NiceAgent *agent, CandidateCheckPair *pa ...@@ -251,8 +258,7 @@ priv_add_pair_to_triggered_check_queue (NiceAgent *agent, CandidateCheckPair *pa
{ {
g_assert (pair); g_assert (pair);
pair->state = NICE_CHECK_IN_PROGRESS; SET_PAIR_STATE (agent, pair, NICE_CHECK_IN_PROGRESS);
nice_debug ("Agent %p : pair %p state IN_PROGRESS", agent, pair);
if (agent->triggered_check_queue == NULL || if (agent->triggered_check_queue == NULL ||
g_slist_find (agent->triggered_check_queue, pair) == NULL) g_slist_find (agent->triggered_check_queue, pair) == NULL)
agent->triggered_check_queue = g_slist_append (agent->triggered_check_queue, pair); agent->triggered_check_queue = g_slist_append (agent->triggered_check_queue, pair);
...@@ -440,11 +446,9 @@ priv_find_first_frozen_check_list (NiceAgent *agent) ...@@ -440,11 +446,9 @@ priv_find_first_frozen_check_list (NiceAgent *agent)
*/ */
static gboolean priv_conn_check_initiate (NiceAgent *agent, CandidateCheckPair *pair) static gboolean priv_conn_check_initiate (NiceAgent *agent, CandidateCheckPair *pair)
{ {
pair->state = NICE_CHECK_IN_PROGRESS; SET_PAIR_STATE (agent, pair, NICE_CHECK_IN_PROGRESS);
nice_debug ("Agent %p : pair %p state IN_PROGRESS", agent, pair);
if (conn_check_send (agent, pair)) { if (conn_check_send (agent, pair)) {
pair->state = NICE_CHECK_FAILED; SET_PAIR_STATE (agent, pair, NICE_CHECK_FAILED);
nice_debug ("Agent %p : pair %p state FAILED", agent, pair);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
...@@ -495,8 +499,7 @@ static gboolean priv_conn_check_unfreeze_next (NiceAgent *agent, NiceStream *str ...@@ -495,8 +499,7 @@ static gboolean priv_conn_check_unfreeze_next (NiceAgent *agent, NiceStream *str
if (pair) { if (pair) {
nice_debug ("Agent %p : Pair %p with s/c-id %u/%u (%s) unfrozen.", nice_debug ("Agent %p : Pair %p with s/c-id %u/%u (%s) unfrozen.",
agent, pair, pair->stream_id, pair->component_id, pair->foundation); agent, pair, pair->stream_id, pair->component_id, pair->foundation);
pair->state = NICE_CHECK_WAITING; SET_PAIR_STATE (agent, pair, NICE_CHECK_WAITING);
nice_debug ("Agent %p : pair %p state WAITING", agent, pair);
result = TRUE; result = TRUE;
} }
} }
...@@ -535,8 +538,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, NiceStream *stre ...@@ -535,8 +538,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, NiceStream *stre
strncmp (p->foundation, ok_check->foundation, strncmp (p->foundation, ok_check->foundation,
NICE_CANDIDATE_PAIR_MAX_FOUNDATION) == 0) { NICE_CANDIDATE_PAIR_MAX_FOUNDATION) == 0) {
nice_debug ("Agent %p : Unfreezing check %p (after successful check %p).", agent, p, ok_check); nice_debug ("Agent %p : Unfreezing check %p (after successful check %p).", agent, p, ok_check);
p->state = NICE_CHECK_WAITING; SET_PAIR_STATE (agent, p, NICE_CHECK_WAITING);
nice_debug ("Agent %p : pair %p state WAITING", agent, p);
} }
} }
} }
...@@ -559,8 +561,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, NiceStream *stre ...@@ -559,8 +561,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, NiceStream *stre
if (p->state == NICE_CHECK_FROZEN && if (p->state == NICE_CHECK_FROZEN &&
priv_foundation_matches_a_valid_pair (p->foundation, stream)) { priv_foundation_matches_a_valid_pair (p->foundation, stream)) {
nice_debug ("Agent %p : Unfreezing check %p from stream %u (after successful check %p).", agent, p, s->id, ok_check); nice_debug ("Agent %p : Unfreezing check %p from stream %u (after successful check %p).", agent, p, s->id, ok_check);
p->state = NICE_CHECK_WAITING; SET_PAIR_STATE (agent, p, NICE_CHECK_WAITING);
nice_debug ("Agent %p : pair %p state WAITING", agent, p);
} }
} }
} else if (priv_is_checklist_frozen (s)) { } else if (priv_is_checklist_frozen (s)) {
...@@ -576,8 +577,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, NiceStream *stre ...@@ -576,8 +577,7 @@ static void priv_conn_check_unfreeze_related (NiceAgent *agent, NiceStream *stre
if (priv_foundation_matches_a_valid_pair (p->foundation, stream)) { if (priv_foundation_matches_a_valid_pair (p->foundation, stream)) {
match_found = TRUE; match_found = TRUE;
nice_debug ("Agent %p : Unfreezing check %p from stream %u (after successful check %p).", agent, p, s->id, ok_check); nice_debug ("Agent %p : Unfreezing check %p from stream %u (after successful check %p).", agent, p, s->id, ok_check);
p->state = NICE_CHECK_WAITING; SET_PAIR_STATE (agent, p, NICE_CHECK_WAITING);
nice_debug ("Agent %p : pair %p state WAITING", agent, p);
} }
} }
...@@ -675,8 +675,7 @@ candidate_check_pair_fail (NiceStream *stream, NiceAgent *agent, CandidateCheckP ...@@ -675,8 +675,7 @@ candidate_check_pair_fail (NiceStream *stream, NiceAgent *agent, CandidateCheckP
NiceComponent *component; NiceComponent *component;
component = nice_stream_find_component_by_id (stream, p->component_id); component = nice_stream_find_component_by_id (stream, p->component_id);
p->state = NICE_CHECK_FAILED; SET_PAIR_STATE (agent, p, NICE_CHECK_FAILED);
nice_debug ("Agent %p : pair %p state FAILED", agent, p);
priv_free_all_stun_transactions (p, component); priv_free_all_stun_transactions (p, component);
} }
...@@ -841,8 +840,7 @@ timer_return_timeout: ...@@ -841,8 +840,7 @@ timer_return_timeout:
if (pair) { if (pair) {
priv_print_conn_check_lists (agent, G_STRFUNC, priv_print_conn_check_lists (agent, G_STRFUNC,
", got a pair in Frozen state"); ", got a pair in Frozen state");
pair->state = NICE_CHECK_WAITING; SET_PAIR_STATE (agent, pair, NICE_CHECK_WAITING);
nice_debug ("Agent %p : pair %p state WAITING", agent, pair);
priv_conn_check_initiate (agent, pair); priv_conn_check_initiate (agent, pair);
return TRUE; return TRUE;
} }
...@@ -1075,8 +1073,7 @@ static gboolean priv_conn_check_tick_unlocked (NiceAgent *agent) ...@@ -1075,8 +1073,7 @@ static gboolean priv_conn_check_tick_unlocked (NiceAgent *agent)
priv_print_conn_check_lists (agent, G_STRFUNC, priv_print_conn_check_lists (agent, G_STRFUNC,
", got a pair from triggered check list"); ", got a pair from triggered check list");
if (conn_check_send (agent, pair)) { if (conn_check_send (agent, pair)) {
pair->state = NICE_CHECK_FAILED; SET_PAIR_STATE (agent, pair, NICE_CHECK_FAILED);
nice_debug ("Agent %p : pair %p state FAILED", agent, pair);
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
...@@ -2067,8 +2064,8 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent, ...@@ -2067,8 +2064,8 @@ static CandidateCheckPair *priv_add_new_check_pair (NiceAgent *agent,
g_snprintf (pair->foundation, NICE_CANDIDATE_PAIR_MAX_FOUNDATION, "%s:%s", local->foundation, remote->foundation); g_snprintf (pair->foundation, NICE_CANDIDATE_PAIR_MAX_FOUNDATION, "%s:%s", local->foundation, remote->foundation);
pair->priority = agent_candidate_pair_priority (agent, local, remote); pair->priority = agent_candidate_pair_priority (agent, local, remote);
pair->state = initial_state; nice_debug ("Agent %p : creating a new pair", agent);
nice_debug ("Agent %p : creating new pair %p state %d", agent, pair, initial_state); SET_PAIR_STATE (agent, pair, initial_state);
{ {
gchar tmpbuf1[INET6_ADDRSTRLEN]; gchar tmpbuf1[INET6_ADDRSTRLEN];
gchar tmpbuf2[INET6_ADDRSTRLEN]; gchar tmpbuf2[INET6_ADDRSTRLEN];
...@@ -2976,10 +2973,10 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint ...@@ -2976,10 +2973,10 @@ static CandidateCheckPair *priv_add_peer_reflexive_pair (NiceAgent *agent, guint
pair->local = local_cand; pair->local = local_cand;
pair->remote = parent_pair->remote; pair->remote = parent_pair->remote;
pair->sockptr = local_cand->sockptr; pair->sockptr = local_cand->sockptr;
pair->state = NICE_CHECK_DISCOVERED;
parent_pair->discovered_pair = pair; parent_pair->discovered_pair = pair;
pair->succeeded_pair = parent_pair; pair->succeeded_pair = parent_pair;
nice_debug ("Agent %p : new pair %p state DISCOVERED", agent, pair); nice_debug ("Agent %p : creating a new pair", agent);
SET_PAIR_STATE (agent, pair, NICE_CHECK_DISCOVERED);
{ {
gchar tmpbuf1[INET6_ADDRSTRLEN]; gchar tmpbuf1[INET6_ADDRSTRLEN];
gchar tmpbuf2[INET6_ADDRSTRLEN]; gchar tmpbuf2[INET6_ADDRSTRLEN];
...@@ -3099,10 +3096,9 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent * ...@@ -3099,10 +3096,9 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent *
*/ */
if (new_pair == p) if (new_pair == p)
p->valid = TRUE; p->valid = TRUE;
p->state = NICE_CHECK_SUCCEEDED; SET_PAIR_STATE (agent, p, NICE_CHECK_SUCCEEDED);
priv_remove_pair_from_triggered_check_queue (agent, p); priv_remove_pair_from_triggered_check_queue (agent, p);
priv_free_all_stun_transactions (p, component); priv_free_all_stun_transactions (p, component);
nice_debug ("Agent %p : conncheck %p SUCCEEDED.", agent, p);
nice_component_add_valid_candidate (component, remote_candidate); nice_component_add_valid_candidate (component, remote_candidate);
} }
else { else {
...@@ -3135,11 +3131,9 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent * ...@@ -3135,11 +3131,9 @@ static CandidateCheckPair *priv_process_response_check_for_reflexive(NiceAgent *
/* step: The agent sets the state of the pair that *generated* the check to /* step: The agent sets the state of the pair that *generated* the check to
* Succeeded, RFC 5245, 7.1.3.2.3, "Updating Pair States" * Succeeded, RFC 5245, 7.1.3.2.3, "Updating Pair States"
*/ */
p->state = NICE_CHECK_SUCCEEDED; SET_PAIR_STATE (agent, p, NICE_CHECK_SUCCEEDED);
priv_remove_pair_from_triggered_check_queue (agent, p); priv_remove_pair_from_triggered_check_queue (agent, p);
priv_free_all_stun_transactions (p, component); priv_free_all_stun_transactions (p, component);
nice_debug ("Agent %p : conncheck %p SUCCEEDED, %p DISCOVERED.",
agent, p, new_pair);
} }
if (new_pair && new_pair->valid) if (new_pair && new_pair->valid)
...@@ -3226,10 +3220,9 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, NiceStre ...@@ -3226,10 +3220,9 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, NiceStre
* "Discovering Peer Reflexive Candidates" ICE ID-19) */ * "Discovering Peer Reflexive Candidates" ICE ID-19) */
if (res == STUN_USAGE_ICE_RETURN_NO_MAPPED_ADDRESS) { if (res == STUN_USAGE_ICE_RETURN_NO_MAPPED_ADDRESS) {
p->state = NICE_CHECK_SUCCEEDED; nice_debug ("Agent %p : Mapped address not found", agent);
SET_PAIR_STATE (agent, p, NICE_CHECK_SUCCEEDED);
p->valid = TRUE; p->valid = TRUE;
nice_debug ("Agent %p : Mapped address not found."
" conncheck %p SUCCEEDED.", agent, p);
nice_component_add_valid_candidate (component, p->remote); nice_component_add_valid_candidate (component, p->remote);
} else } else
ok_pair = priv_process_response_check_for_reflexive (agent, ok_pair = priv_process_response_check_for_reflexive (agent,
......
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