Commit 19a64f56 authored by Dafydd Harries's avatar Dafydd Harries
Browse files

fix username checking for inbound connectivity checks to be compatible with libjingle

darcs-hash:20070202183947-c9803-7a6cb9466d550315143b99f38b2ef730c156a000.gz
parent fee8fdfa
......@@ -375,6 +375,7 @@ _handle_stun (
GSList *i;
StunAttribute **attr;
gchar *username = NULL;
NiceCandidate *remote = NULL;
if (msg->type != STUN_MESSAGE_BINDING_REQUEST)
/* XXX: send error response */
......@@ -383,7 +384,7 @@ _handle_stun (
/* msg should have either:
*
* Jingle P2P:
* username = remote candidate username + local candidate username
* username = local candidate username + remote candidate username
* ICE:
* username = local candidate username + ":" + local candidate username
* password = local candidate pwd
......@@ -391,11 +392,10 @@ _handle_stun (
*
* Note that:
*
* - Jingle and ICE differ with respects to which way around the candidate
* usernames are concatenated
* - the remote candidate password is not necessarily unique; Jingle seems
* to always generate a unique password for each candidate, but ICE makes
* no guarantees
* - "local"/"remote" are from the perspective of the receiving side
* - the remote candidate username is not necessarily unique; Jingle seems
* to always generate a unique username/password for each candidate, but
* ICE makes no guarantees
*
* There are three cases we need to deal with:
*
......@@ -427,15 +427,16 @@ _handle_stun (
for (i = agent->remote_candidates; i; i = i->next)
{
NiceCandidate *rtmp = i->data;
guint len;
if (!g_str_has_prefix (username, rtmp->username))
remote = i->data;
if (!g_str_has_prefix (username, local->username))
continue;
len = strlen (rtmp->username);
len = strlen (local->username);
if (0 != strcmp (username + len, local->username))
if (0 != strcmp (username + len, remote->username))
continue;
#if 0
......
......@@ -154,8 +154,8 @@ test_stun_valid_password (
breq = stun_message_new (STUN_MESSAGE_BINDING_REQUEST,
"0123456789abcdef", 1);
username = g_strconcat (
"username",
((NiceCandidate *) agent->local_candidates->data)->username,
"username",
NULL);
breq->attributes[0] = stun_attribute_username_new (username);
g_free (username);
......
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