Commit 540a385f authored by Dafydd Harries's avatar Dafydd Harries

include username from request in connectivity check binding responses

darcs-hash:20070203112032-c9803-59fe493bfaa60aaf46e8e836042afcf344054f0e.gz
parent 2231cff7
...@@ -464,11 +464,11 @@ RESPOND: ...@@ -464,11 +464,11 @@ RESPOND:
guint len; guint len;
gchar *packed; gchar *packed;
/* XXX: add username to response */
response = stun_message_new (STUN_MESSAGE_BINDING_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 ( response->attributes[0] = stun_attribute_mapped_address_new (
ntohl (from.sin_addr.s_addr), ntohs (from.sin_port)); ntohl (from.sin_addr.s_addr), ntohs (from.sin_port));
response->attributes[1] = stun_attribute_username_new (username);
len = stun_message_pack (response, &packed); len = stun_message_pack (response, &packed);
nice_udp_socket_send (&local->sock, &from, len, packed); nice_udp_socket_send (&local->sock, &from, len, packed);
......
...@@ -138,27 +138,27 @@ test_stun_valid_password ( ...@@ -138,27 +138,27 @@ test_stun_valid_password (
struct sockaddr_in to = {0,}; struct sockaddr_in to = {0,};
gchar buf[1024]; gchar buf[1024];
gchar *packed; gchar *packed;
gchar *username;
memset (buf, '\0', 1024); memset (buf, '\0', 1024);
candidate = agent->local_candidates->data; candidate = agent->local_candidates->data;
sock = &candidate->sock; sock = &candidate->sock;
username = g_strconcat (
((NiceCandidate *) agent->local_candidates->data)->username,
"username",
NULL);
{ {
StunMessage *breq; StunMessage *breq;
guint packed_len; guint packed_len;
gchar *packed; gchar *packed;
gchar *username;
/* send binding request with correct username */ /* send binding request with correct username */
breq = stun_message_new (STUN_MESSAGE_BINDING_REQUEST, breq = stun_message_new (STUN_MESSAGE_BINDING_REQUEST,
"0123456789abcdef", 1); "0123456789abcdef", 1);
username = g_strconcat (
((NiceCandidate *) agent->local_candidates->data)->username,
"username",
NULL);
breq->attributes[0] = stun_attribute_username_new (username); breq->attributes[0] = stun_attribute_username_new (username);
g_free (username);
packed_len = stun_message_pack (breq, &packed); packed_len = stun_message_pack (breq, &packed);
g_assert (packed_len != 0); g_assert (packed_len != 0);
nice_udp_fake_socket_push_recv (sock, &from, packed_len, packed); nice_udp_fake_socket_push_recv (sock, &from, packed_len, packed);
...@@ -171,20 +171,22 @@ test_stun_valid_password ( ...@@ -171,20 +171,22 @@ test_stun_valid_password (
/* construct expected response packet */ /* construct expected response packet */
bres = stun_message_new (STUN_MESSAGE_BINDING_RESPONSE, bres = stun_message_new (STUN_MESSAGE_BINDING_RESPONSE,
"0123456789abcdef", 1); "0123456789abcdef", 2);
bres->attributes[0] = stun_attribute_mapped_address_new ( bres->attributes[0] = stun_attribute_mapped_address_new (
ntohl (from.sin_addr.s_addr), 5678); ntohl (from.sin_addr.s_addr), 5678);
bres->attributes[1] = stun_attribute_username_new (username);
packed_len = stun_message_pack (bres, &packed); packed_len = stun_message_pack (bres, &packed);
g_assert (packed_len == 32);
stun_message_free (bres); stun_message_free (bres);
} }
g_free (username);
/* tell the agent there's a packet waiting */ /* tell the agent there's a packet waiting */
nice_agent_recv (agent, candidate->id); nice_agent_recv (agent, candidate->id);
/* compare sent packet to expected */ /* compare sent packet to expected */
len = nice_udp_fake_socket_pop_send (sock, &to, sizeof (buf) / sizeof (gchar), len = nice_udp_fake_socket_pop_send (sock, &to,
buf); sizeof (buf) / sizeof (gchar), buf);
g_assert (len == packed_len); g_assert (len == packed_len);
g_assert (0 == memcmp (buf, packed, len)); g_assert (0 == memcmp (buf, packed, len));
g_assert (to.sin_family == from.sin_family); g_assert (to.sin_family == from.sin_family);
......
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