summaryrefslogtreecommitdiff
path: root/agent
diff options
context:
space:
mode:
authorDafydd Harries <dafydd.harries@collabora.co.uk>2007-02-03 11:20:00 +0000
committerDafydd Harries <dafydd.harries@collabora.co.uk>2007-02-03 11:20:00 +0000
commit540a385f531642e699e412672fb225e97677271d (patch)
tree4c04a00a58b16e64d05d7b64de85de4a77026b7c /agent
parent2231cff7cb9300f5ad8f124b461dd390f52776d7 (diff)
downloadlibnice-540a385f531642e699e412672fb225e97677271d.tar.gz
include username from request in connectivity check binding responses
darcs-hash:20070203112032-c9803-59fe493bfaa60aaf46e8e836042afcf344054f0e.gz
Diffstat (limited to 'agent')
-rw-r--r--agent/agent.c4
-rw-r--r--agent/test-stun.c22
2 files changed, 14 insertions, 12 deletions
diff --git a/agent/agent.c b/agent/agent.c
index 536fb0e..de37f0d 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -464,11 +464,11 @@ RESPOND:
guint len;
gchar *packed;
- /* XXX: add username to response */
response = stun_message_new (STUN_MESSAGE_BINDING_RESPONSE,
- msg->transaction_id, 1);
+ msg->transaction_id, 2);
response->attributes[0] = stun_attribute_mapped_address_new (
ntohl (from.sin_addr.s_addr), ntohs (from.sin_port));
+ response->attributes[1] = stun_attribute_username_new (username);
len = stun_message_pack (response, &packed);
nice_udp_socket_send (&local->sock, &from, len, packed);
diff --git a/agent/test-stun.c b/agent/test-stun.c
index 7ab26d6..2e8aff5 100644
--- a/agent/test-stun.c
+++ b/agent/test-stun.c
@@ -138,27 +138,27 @@ test_stun_valid_password (
struct sockaddr_in to = {0,};
gchar buf[1024];
gchar *packed;
+ gchar *username;
memset (buf, '\0', 1024);
candidate = agent->local_candidates->data;
sock = &candidate->sock;
+ username = g_strconcat (
+ ((NiceCandidate *) agent->local_candidates->data)->username,
+ "username",
+ NULL);
+
{
StunMessage *breq;
guint packed_len;
gchar *packed;
- gchar *username;
/* send binding request with correct username */
breq = stun_message_new (STUN_MESSAGE_BINDING_REQUEST,
"0123456789abcdef", 1);
- username = g_strconcat (
- ((NiceCandidate *) agent->local_candidates->data)->username,
- "username",
- NULL);
breq->attributes[0] = stun_attribute_username_new (username);
- g_free (username);
packed_len = stun_message_pack (breq, &packed);
g_assert (packed_len != 0);
nice_udp_fake_socket_push_recv (sock, &from, packed_len, packed);
@@ -171,20 +171,22 @@ test_stun_valid_password (
/* construct expected response packet */
bres = stun_message_new (STUN_MESSAGE_BINDING_RESPONSE,
- "0123456789abcdef", 1);
+ "0123456789abcdef", 2);
bres->attributes[0] = stun_attribute_mapped_address_new (
ntohl (from.sin_addr.s_addr), 5678);
+ bres->attributes[1] = stun_attribute_username_new (username);
packed_len = stun_message_pack (bres, &packed);
- g_assert (packed_len == 32);
stun_message_free (bres);
}
+ g_free (username);
+
/* tell the agent there's a packet waiting */
nice_agent_recv (agent, candidate->id);
/* compare sent packet to expected */
- len = nice_udp_fake_socket_pop_send (sock, &to, sizeof (buf) / sizeof (gchar),
- buf);
+ len = nice_udp_fake_socket_pop_send (sock, &to,
+ sizeof (buf) / sizeof (gchar), buf);
g_assert (len == packed_len);
g_assert (0 == memcmp (buf, packed, len));
g_assert (to.sin_family == from.sin_family);