[Nice] [nice/master] use a dedicated stun agent for stun binding discovery because we'll need to be compatible with rfc 3489
Youness Alaoui
youness.alaoui at collabora.co.uk
Wed Nov 12 14:59:59 PST 2008
---
agent/agent.c | 3 +++
agent/conncheck.c | 15 +++++++--------
agent/discovery.c | 2 +-
stun/usages/bind.c | 2 +-
4 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/agent/agent.c b/agent/agent.c
index 7004c06..0afe2bc 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -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;
diff --git a/agent/conncheck.c b/agent/conncheck.c
index 40ee829..16f0c4d 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -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);
diff --git a/agent/discovery.c b/agent/discovery.c
index 5ba5048..4cafe67 100644
--- a/agent/discovery.c
+++ b/agent/discovery.c
@@ -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;
diff --git a/stun/usages/bind.c b/stun/usages/bind.c
index d66dddd..93bd288 100644
--- a/stun/usages/bind.c
+++ b/stun/usages/bind.c
@@ -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));
--
1.5.6.5
More information about the Nice
mailing list