Commit ff4ca893 authored by Youness Alaoui's avatar Youness Alaoui Committed by Youness Alaoui

Fix MSN username for peer reflexive candidates

parent 7d187257
......@@ -1488,7 +1488,7 @@ static void priv_check_for_role_conflict (NiceAgent *agent, gboolean control)
*
* @return pointer to a new pair if one was created, otherwise NULL
*/
static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAgent *agent, Stream *stream, Component *component, CandidateCheckPair *p, NiceUDPSocket *sockptr, struct sockaddr *mapped_sockaddr, NiceCandidate *base_candidate)
static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAgent *agent, Stream *stream, Component *component, CandidateCheckPair *p, NiceUDPSocket *sockptr, struct sockaddr *mapped_sockaddr, NiceCandidate *local_candidate, NiceCandidate *remote_candidate)
{
CandidateCheckPair *new_pair = NULL;
NiceAddress mapped;
......@@ -1519,7 +1519,8 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
component->id,
&mapped,
sockptr,
base_candidate);
local_candidate,
remote_candidate);
p->state = NICE_CHECK_FAILED;
/* step: add a new discovered pair (see ICE 7.1.2.2.2
......@@ -1538,7 +1539,7 @@ static CandidateCheckPair *priv_process_response_check_for_peer_reflexive(NiceAg
*
* @return TRUE if a matching transaction is found
*/
static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *stream, Component *component, NiceUDPSocket *sockptr, const NiceAddress *from, NiceCandidate *base_candidate, StunMessage *resp)
static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *stream, Component *component, NiceUDPSocket *sockptr, const NiceAddress *from, NiceCandidate *local_candidate, NiceCandidate *remote_candidate, StunMessage *resp)
{
struct sockaddr sockaddr;
socklen_t socklen = sizeof (sockaddr);
......@@ -1595,7 +1596,7 @@ static gboolean priv_map_reply_to_conn_check_request (NiceAgent *agent, Stream *
* "Discovering Peer Reflexive Candidates" ICE ID-19) */
ok_pair = priv_process_response_check_for_peer_reflexive(agent, stream, component,
p, sockptr, &sockaddr, base_candidate);
p, sockptr, &sockaddr, local_candidate, remote_candidate);
if (!ok_pair)
ok_pair = p;
......@@ -1950,7 +1951,7 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
/* step: let's try to match the response to an existing check context */
if (trans_found != TRUE)
trans_found = priv_map_reply_to_conn_check_request (agent, stream,
component, udp_socket, from, local_candidate, &req);
component, udp_socket, from, local_candidate, remote_candidate, &req);
/* step: let's try to match the response to an existing discovery */
if (trans_found != TRUE)
......
......@@ -387,7 +387,8 @@ discovery_add_peer_reflexive_candidate (
guint component_id,
NiceAddress *address,
NiceUDPSocket *base_socket,
NiceCandidate *base_candidate)
NiceCandidate *local_candidate,
NiceCandidate *remote_candidate)
{
NiceCandidate *candidate;
Component *component;
......@@ -414,13 +415,34 @@ discovery_add_peer_reflexive_candidate (
candidate->addr = *address;
candidate->base_addr = base_socket->addr;
if (base_candidate->username)
candidate->username = g_strdup(base_candidate->username);
if (base_candidate->password)
candidate->password = g_strdup(base_candidate->password);
priv_assign_foundation (agent, candidate);
if (agent->compatibility == NICE_COMPATIBILITY_MSN &&
remote_candidate && local_candidate) {
guchar *new_username = NULL;
guchar *decoded_local = NULL;
guchar *decoded_remote = NULL;
gsize local_size;
gsize remote_size;
g_free(candidate->username);
g_free(candidate->password);
decoded_local = g_base64_decode (local_candidate->username, &local_size);
decoded_remote = g_base64_decode (remote_candidate->username, &remote_size);
new_username = g_new0(guchar, local_size + remote_size);
memcpy(new_username, decoded_local, local_size);
memcpy(new_username + local_size, decoded_remote, remote_size);
candidate->username = g_base64_encode (new_username, local_size + remote_size);
g_free(new_username);
g_free(decoded_local);
g_free(decoded_remote);
candidate->password = g_strdup(local_candidate->password);
}
/* step: link to the base candidate+socket */
candidate->sockptr = base_socket;
candidate->base_addr = base_socket->addr;
......@@ -485,8 +507,31 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate (
candidate->stream_id = stream->id;
candidate->component_id = component->id;
priv_generate_msn_credentials (agent, candidate);
g_snprintf (candidate->foundation, NICE_CANDIDATE_MAX_FOUNDATION, "%u", next_remote_id);
#if 0
if (agent->compatibility == NICE_COMPATIBILITY_MSN &&
remote && local) {
gchar *new_username = NULL;
gchar *decoded_local = NULL;
gchar *decoded_remote = NULL;
gsize local_size;
gsize remote_size;
g_free(candidate->username);
decoded_local = g_base64_decode (local->username, &local_size);
decoded_remote = g_base64_decode (remote->username, &remote_size);
new_username = g_new0(gchar, local_size + remote_size);
memcpy(new_username, decoded_remote, remote_size);
memcpy(new_username + remote_size, decoded_local, local_size);
candidate->username = g_base64_encode (new_username, local_size + remote_size);
g_free(new_username);
g_free(decoded_local);
g_free(decoded_remote);
}
#endif
candidate->sockptr = NULL; /* not stored for remote candidates */
/* note: candidate username and password are left NULL as stream
level ufrag/password are used */
......
......@@ -90,7 +90,8 @@ discovery_add_peer_reflexive_candidate (
guint component_id,
NiceAddress *address,
NiceUDPSocket *base_socket,
NiceCandidate *base_candidate);
NiceCandidate *local_candidate,
NiceCandidate *remote_candidate);
NiceCandidate *
discovery_learn_remote_peer_reflexive_candidate (
......
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