Commit 9cf4e79c authored by Jakub Adam's avatar Jakub Adam Committed by Youness Alaoui

Compatibility with MSOC 2007

parent 9eba3b31
......@@ -151,6 +151,8 @@ agent_to_ice_compatibility (NiceAgent *agent)
STUN_USAGE_ICE_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ?
STUN_USAGE_ICE_COMPATIBILITY_WLM2009 :
agent->compatibility == NICE_COMPATIBILITY_OC2007 ?
STUN_USAGE_ICE_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_OC2007R2 ?
STUN_USAGE_ICE_COMPATIBILITY_WLM2009 :
STUN_USAGE_ICE_COMPATIBILITY_RFC5245;
......@@ -165,6 +167,8 @@ agent_to_turn_compatibility (NiceAgent *agent)
agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_TURN_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ?
STUN_USAGE_TURN_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_OC2007 ?
STUN_USAGE_TURN_COMPATIBILITY_MSN : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9;
}
......@@ -177,6 +181,8 @@ agent_to_turn_socket_compatibility (NiceAgent *agent)
NICE_TURN_SOCKET_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ?
NICE_TURN_SOCKET_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_OC2007 ?
NICE_TURN_SOCKET_COMPATIBILITY_MSN :
NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9;
}
......@@ -834,7 +840,8 @@ nice_agent_set_property (
STUN_COMPATIBILITY_RFC3489,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_IGNORE_CREDENTIALS);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC3489,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
......
......@@ -213,6 +213,7 @@ typedef enum
* @NICE_COMPATIBILITY_MSN: Use compatibility for MSN Messenger specs
* @NICE_COMPATIBILITY_WLM2009: Use compatibility with Windows Live Messenger
* 2009
* @NICE_COMPATIBILITY_OC2007: Use compatibility with Microsoft Office Communicator 2007
* @NICE_COMPATIBILITY_OC2007R2: Use compatibility with Microsoft Office Communicator 2007 R2
* @NICE_COMPATIBILITY_DRAFT19: Use compatibility for ICE Draft 19 specs
* @NICE_COMPATIBILITY_LAST: Dummy last compatibility mode
......@@ -230,6 +231,7 @@ typedef enum
NICE_COMPATIBILITY_GOOGLE,
NICE_COMPATIBILITY_MSN,
NICE_COMPATIBILITY_WLM2009,
NICE_COMPATIBILITY_OC2007,
NICE_COMPATIBILITY_OC2007R2,
NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245,
NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_OC2007R2,
......
......@@ -978,7 +978,8 @@ void conn_check_remote_candidates_set(NiceAgent *agent)
NiceCandidate *remote_candidate = NULL;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE ||
agent->compatibility == NICE_COMPATIBILITY_MSN) {
agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
/* We need to find which local candidate was used */
uint8_t uname[NICE_STREAM_MAX_UNAME];
guint uname_len;
......@@ -1455,7 +1456,8 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
len += remote_len;
memcpy (dest + len, local, local_len);
len += local_len;
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
gchar component_str[10];
guchar *local_decoded = NULL;
guchar *remote_decoded = NULL;
......@@ -1611,7 +1613,8 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
size_t buffer_len;
unsigned int timeout;
if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
password = g_base64_decode ((gchar *) password, &password_len);
}
......@@ -1643,7 +1646,8 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer);
if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
g_free (password);
}
......@@ -2512,7 +2516,17 @@ static bool conncheck_stun_validater (StunAgent *agent,
gchar *ufrag = NULL;
gsize ufrag_len;
for (i = data->component->local_candidates; i; i = i->next) {
gboolean msn_msoc_nice_compatibility =
data->agent->compatibility == NICE_COMPATIBILITY_MSN ||
data->agent->compatibility == NICE_COMPATIBILITY_OC2007;
if (data->agent->compatibility == NICE_COMPATIBILITY_OC2007 &&
stun_message_get_class (message) == STUN_RESPONSE)
i = data->component->remote_candidates;
else
i = data->component->local_candidates;
for (; i; i = i->next) {
NiceCandidate *cand = i->data;
ufrag = NULL;
......@@ -2522,7 +2536,7 @@ static bool conncheck_stun_validater (StunAgent *agent,
ufrag = data->stream->local_ufrag;
ufrag_len = ufrag? strlen (ufrag) : 0;
if (ufrag && data->agent->compatibility == NICE_COMPATIBILITY_MSN)
if (ufrag && msn_msoc_nice_compatibility)
ufrag = (gchar *)g_base64_decode (ufrag, &ufrag_len);
if (ufrag == NULL)
......@@ -2547,20 +2561,20 @@ static bool conncheck_stun_validater (StunAgent *agent,
*password = (uint8_t *) pass;
*password_len = strlen (pass);
if (data->agent->compatibility == NICE_COMPATIBILITY_MSN) {
if (msn_msoc_nice_compatibility) {
data->password = g_base64_decode (pass, password_len);
*password = data->password;
}
}
if (data->agent->compatibility == NICE_COMPATIBILITY_MSN)
if (msn_msoc_nice_compatibility)
g_free (ufrag);
stun_debug ("Found valid username, returning password: '%s'\n", *password);
return TRUE;
}
if (data->agent->compatibility == NICE_COMPATIBILITY_MSN)
if (msn_msoc_nice_compatibility)
g_free (ufrag);
}
......@@ -2681,7 +2695,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
if (len == 0)
return FALSE;
if (agent->compatibility != NICE_COMPATIBILITY_MSN) {
if (agent->compatibility != NICE_COMPATIBILITY_MSN &&
agent->compatibility != NICE_COMPATIBILITY_OC2007) {
nice_socket_send (socket, from, rbuf_len, (const gchar*)rbuf);
}
return TRUE;
......@@ -2693,7 +2708,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
if (stun_agent_init_error (&agent->stun_agent, &msg, rbuf, rbuf_len,
&req, STUN_ERROR_UNAUTHORIZED)) {
rbuf_len = stun_agent_finish_message (&agent->stun_agent, &msg, NULL, 0);
if (rbuf_len > 0 && agent->compatibility != NICE_COMPATIBILITY_MSN)
if (rbuf_len > 0 && agent->compatibility != NICE_COMPATIBILITY_MSN &&
agent->compatibility != NICE_COMPATIBILITY_OC2007)
nice_socket_send (socket, from, rbuf_len, (const gchar*)rbuf);
}
return TRUE;
......@@ -2703,7 +2719,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
if (stun_agent_init_error (&agent->stun_agent, &msg, rbuf, rbuf_len,
&req, STUN_ERROR_BAD_REQUEST)) {
rbuf_len = stun_agent_finish_message (&agent->stun_agent, &msg, NULL, 0);
if (rbuf_len > 0 && agent->compatibility != NICE_COMPATIBILITY_MSN)
if (rbuf_len > 0 && agent->compatibility != NICE_COMPATIBILITY_MSN &&
agent->compatibility != NICE_COMPATIBILITY_OC2007)
nice_socket_send (socket, from, rbuf_len, (const gchar*)rbuf);
}
return TRUE;
......@@ -2721,7 +2738,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
}
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE ||
agent->compatibility == NICE_COMPATIBILITY_MSN) {
agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
/* We need to find which local candidate was used */
for (i = component->remote_candidates;
i != NULL && remote_candidate2 == NULL; i = i->next) {
......@@ -2731,7 +2749,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
NiceCandidate *lcand = j->data;
/* If we receive a response, then the username is local:remote */
if (agent->compatibility != NICE_COMPATIBILITY_MSN) {
if (agent->compatibility != NICE_COMPATIBILITY_MSN &&
agent->compatibility != NICE_COMPATIBILITY_OC2007) {
if (stun_message_get_class (&req) == STUN_REQUEST ||
stun_message_get_class (&req) == STUN_INDICATION) {
inbound = TRUE;
......@@ -2783,16 +2802,23 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
if (stun_message_get_class (&req) == STUN_REQUEST) {
if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
if ( agent->compatibility == NICE_COMPATIBILITY_MSN
|| agent->compatibility == NICE_COMPATIBILITY_OC2007) {
if (local_candidate && remote_candidate2) {
username = (uint8_t *) stun_message_find (&req,
STUN_ATTRIBUTE_USERNAME, &username_len);
uname_len = priv_create_username (agent, stream,
component->id, remote_candidate2, local_candidate,
uname, sizeof (uname), FALSE);
memcpy (username, uname, username_len);
req.key = g_base64_decode ((gchar *) remote_candidate2->password,
&req.key_len);
if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
username = (uint8_t *) stun_message_find (&req,
STUN_ATTRIBUTE_USERNAME, &username_len);
uname_len = priv_create_username (agent, stream,
component->id, remote_candidate2, local_candidate,
uname, sizeof (uname), FALSE);
memcpy (username, uname, username_len);
req.key = g_base64_decode ((gchar *) remote_candidate2->password,
&req.key_len);
} else if (agent->compatibility == NICE_COMPATIBILITY_OC2007) {
req.key = g_base64_decode ((gchar *) local_candidate->password,
&req.key_len);
}
} else {
nice_debug ("Agent %p : received MSN incoming check from unknown remote candidate. "
"Ignoring request", agent);
......@@ -2806,7 +2832,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
&control, agent->tie_breaker,
agent_to_ice_compatibility (agent));
if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
if ( agent->compatibility == NICE_COMPATIBILITY_MSN
|| agent->compatibility == NICE_COMPATIBILITY_OC2007) {
g_free (req.key);
}
......@@ -2822,7 +2849,8 @@ gboolean conn_check_handle_inbound_stun (NiceAgent *agent, Stream *stream,
if (agent->controlling_mode ||
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ||
agent->compatibility == NICE_COMPATIBILITY_MSN)
agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007)
use_candidate = TRUE;
if (stream->initial_binding_request_received != TRUE)
......
......@@ -403,7 +403,8 @@ void priv_generate_candidate_credentials (NiceAgent *agent,
NiceCandidate *candidate)
{
if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
guchar username[32];
guchar password[16];
......@@ -458,7 +459,8 @@ NiceCandidate *discovery_add_local_host_candidate (
candidate->base_addr = *address;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority (candidate);
......@@ -523,7 +525,8 @@ discovery_add_server_reflexive_candidate (
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority_full
......@@ -580,7 +583,8 @@ discovery_add_relay_candidate (
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority_full
......@@ -656,7 +660,8 @@ discovery_add_peer_reflexive_candidate (
candidate->transport = NICE_CANDIDATE_TRANSPORT_UDP;
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority_full
......@@ -670,7 +675,8 @@ discovery_add_peer_reflexive_candidate (
priv_assign_foundation (agent, candidate);
if (agent->compatibility == NICE_COMPATIBILITY_MSN &&
if ((agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) &&
remote && local) {
guchar *new_username = NULL;
guchar *decoded_local = NULL;
......@@ -751,7 +757,8 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate (
candidate->priority = priority;
} else if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
candidate->priority = nice_candidate_jingle_priority (candidate);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) {
candidate->priority = nice_candidate_msn_priority (candidate);
} else {
candidate->priority = nice_candidate_ice_priority_full
......@@ -763,7 +770,8 @@ NiceCandidate *discovery_learn_remote_peer_reflexive_candidate (
priv_assign_remote_foundation (agent, candidate);
if (agent->compatibility == NICE_COMPATIBILITY_MSN &&
if ((agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_OC2007) &&
remote && local) {
guchar *new_username = NULL;
guchar *decoded_local = NULL;
......
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