Commit 577aaa5a authored by Youness Alaoui's avatar Youness Alaoui
Browse files

use a dedicated stun agent for stun binding discovery because we'll need to be...

use a dedicated stun agent for stun binding discovery because we'll need to be compatible with rfc 3489
parent 2a9bac88
......@@ -732,6 +732,9 @@ priv_add_new_candidate_discovery_stun (NiceAgent *agent,
cdisco->stream = stream;
cdisco->component = stream_find_component_by_id (stream, component_id);
cdisco->agent = agent;
stun_agent_init (&cdisco->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC3489, 0);
nice_debug ("Agent %p : Adding new srv-rflx candidate discovery %p\n", agent, cdisco);
agent->discovery_list = modified_list;
++agent->discovery_unsched_items;
......
......@@ -2212,7 +2212,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
NiceCandidate *remote_candidate = NULL;
NiceCandidate *remote_candidate2 = NULL;
NiceCandidate *local_candidate = NULL;
gboolean turn_msg = FALSE;
gboolean discovery_msg = FALSE;
nice_address_copy_to_sockaddr (from, &sockaddr);
......@@ -2233,13 +2233,12 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
valid = stun_agent_validate (&agent->stun_agent, &req,
(uint8_t *) buf, len, conncheck_stun_validater, &validater_data);
/* Check for relay candidates stun agents */
/* Check for discovery candidates stun agents */
if (valid == STUN_VALIDATION_BAD_REQUEST ||
valid == STUN_VALIDATION_UNMATCHED_RESPONSE) {
for (i = agent->discovery_list; i; i = i->next) {
CandidateDiscovery *d = i->data;
if (d->type == NICE_CANDIDATE_TYPE_RELAYED &&
d->stream == stream && d->component == component &&
if (d->stream == stream && d->component == component &&
d->nicesock == socket) {
valid = stun_agent_validate (&d->stun_agent, &req,
(uint8_t *) buf, len, conncheck_stun_validater, &validater_data);
......@@ -2247,12 +2246,12 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
if (valid == STUN_VALIDATION_UNMATCHED_RESPONSE)
continue;
turn_msg = TRUE;
discovery_msg = TRUE;
break;
}
}
}
/* Check for relay candidates stun agents */
/* Check for relay refresh stun agents */
if (valid == STUN_VALIDATION_BAD_REQUEST ||
valid == STUN_VALIDATION_UNMATCHED_RESPONSE) {
for (i = agent->refresh_list; i; i = i->next) {
......@@ -2266,7 +2265,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
nice_debug ("Validating gave %d", valid);
if (valid == STUN_VALIDATION_UNMATCHED_RESPONSE)
continue;
turn_msg = TRUE;
discovery_msg = TRUE;
break;
}
}
......@@ -2363,7 +2362,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE &&
local_candidate == NULL &&
turn_msg == FALSE) {
discovery_msg == FALSE) {
/* if we couldn't match the username and the stun agent has
IGNORE_CREDENTIALS then we have an integrity check failing */
nice_debug ("Agent %p : Username check failed.", agent);
......
......@@ -835,7 +835,7 @@ static gboolean priv_discovery_tick_unlocked (gpointer pointer)
NICE_COMPONENT_STATE_GATHERING);
if (cand->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE) {
buffer_len = stun_usage_bind_create (&agent->stun_agent,
buffer_len = stun_usage_bind_create (&cand->stun_agent,
&cand->stun_message, cand->stun_buffer, sizeof(cand->stun_buffer));
} else if (cand->type == NICE_CANDIDATE_TYPE_RELAYED) {
uint8_t *username = (uint8_t *)cand->turn->username;
......
......@@ -175,7 +175,7 @@ StunUsageBindReturn stun_usage_bind_run (const struct sockaddr *srv,
StunUsageBindReturn bind_ret;
stun_agent_init (&agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC5389, STUN_AGENT_USAGE_USE_FINGERPRINT);
STUN_COMPATIBILITY_RFC3489, 0);
len = stun_usage_bind_create (&agent, &req, req_buf, sizeof(req_buf));
......
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