Commit 966fc22a authored by Youness Alaoui's avatar Youness Alaoui

add WLM2009 compatibility mode to libnice and libstun

parent 64e898cd
......@@ -119,35 +119,34 @@ static void priv_detach_stream_component (Stream *stream, Component *component);
StunUsageIceCompatibility
agent_to_ice_compatibility (NiceAgent *agent)
{
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
return agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
STUN_USAGE_ICE_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_ICE_COMPATIBILITY_MSN : STUN_USAGE_ICE_COMPATIBILITY_DRAFT19;
STUN_USAGE_ICE_COMPATIBILITY_MSN :
STUN_USAGE_ICE_COMPATIBILITY_DRAFT19;
}
StunUsageTurnCompatibility
agent_to_turn_compatibility (NiceAgent *agent)
{
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
STUN_USAGE_TURN_COMPATIBILITY_DRAFT9 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
return agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
STUN_USAGE_TURN_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_TURN_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ?
STUN_USAGE_TURN_COMPATIBILITY_MSN : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9;
}
NiceTurnSocketCompatibility
agent_to_turn_socket_compatibility (NiceAgent *agent)
{
return agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ?
NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9 :
agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
return agent->compatibility == NICE_COMPATIBILITY_GOOGLE ?
NICE_TURN_SOCKET_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ?
NICE_TURN_SOCKET_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ?
NICE_TURN_SOCKET_COMPATIBILITY_MSN :
NICE_TURN_SOCKET_COMPATIBILITY_DRAFT9;
}
......@@ -631,12 +630,7 @@ nice_agent_set_property (
case PROP_COMPATIBILITY:
agent->compatibility = g_value_get_uint (value);
if (agent->compatibility == NICE_COMPATIBILITY_DRAFT19) {
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC5389,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_USE_FINGERPRINT);
} else if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC3489,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
......@@ -646,6 +640,16 @@ nice_agent_set_property (
STUN_COMPATIBILITY_RFC3489,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_FORCE_VALIDATER);
} else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009) {
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_WLM2009,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_USE_FINGERPRINT);
} else {
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC5389,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_USE_FINGERPRINT);
}
break;
......@@ -965,20 +969,21 @@ priv_add_new_candidate_discovery_turn (NiceAgent *agent,
cdisco->component = stream_find_component_by_id (stream, component_id);
cdisco->agent = agent;
if (agent->compatibility == NICE_COMPATIBILITY_DRAFT19) {
if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
stun_agent_init (&cdisco->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC5389,
STUN_AGENT_USAGE_ADD_SOFTWARE |
STUN_AGENT_USAGE_LONG_TERM_CREDENTIALS);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN) {
STUN_COMPATIBILITY_RFC3489,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_IGNORE_CREDENTIALS);
} else if (agent->compatibility == NICE_COMPATIBILITY_MSN ||
agent->compatibility == NICE_COMPATIBILITY_WLM2009) {
stun_agent_init (&cdisco->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC3489,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS);
} else if (agent->compatibility == NICE_COMPATIBILITY_GOOGLE) {
} else {
stun_agent_init (&cdisco->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC3489,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_IGNORE_CREDENTIALS);
STUN_COMPATIBILITY_RFC5389,
STUN_AGENT_USAGE_ADD_SOFTWARE |
STUN_AGENT_USAGE_LONG_TERM_CREDENTIALS);
}
nice_debug ("Agent %p : Adding new relay-rflx candidate discovery %p\n",
......
......@@ -225,7 +225,8 @@ typedef enum
NICE_COMPATIBILITY_DRAFT19 = 0,
NICE_COMPATIBILITY_GOOGLE,
NICE_COMPATIBILITY_MSN,
NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_MSN
NICE_COMPATIBILITY_WLM2009,
NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_WLM2009
} NiceCompatibility;
/**
......
......@@ -1020,7 +1020,8 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *
/* note: do not create pairs where local candidate is
* a srv-reflexive (ICE 5.7.3. "Pruning the Pairs" ID-19) */
if (agent->compatibility == NICE_COMPATIBILITY_DRAFT19 &&
if ((agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ||
agent->compatibility == NICE_COMPATIBILITY_WLM2009) &&
local->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE)
continue;
......@@ -1433,10 +1434,11 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
same state update as for processing responses to our own checks */
priv_update_check_list_state_for_ready (agent, stream, component);
/* note: to take care of the controlling-controlling case in
/* note: to take care of the controlling-controlling case in
* aggressive nomination mode, send a new triggered
* check to nominate the pair */
if (agent->compatibility == NICE_COMPATIBILITY_DRAFT19 &&
if ((agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ||
agent->compatibility == NICE_COMPATIBILITY_WLM2009) &&
agent->controlling_mode)
priv_conn_check_initiate (agent, p);
}
......
......@@ -129,13 +129,15 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
msg->long_term_valid = FALSE;
/* TODO: reject it or not ? */
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 &&
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) &&
!stun_has_cookie (msg)) {
stun_debug ("STUN demux error: no cookie!\n");
return STUN_VALIDATION_BAD_REQUEST;
}
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 &&
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) &&
agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) {
/* Looks for FINGERPRINT */
if (stun_message_find32 (msg, STUN_ATTRIBUTE_FINGERPRINT, &fpr) !=
......@@ -317,7 +319,8 @@ bool stun_agent_init_request (StunAgent *agent, StunMessage *msg,
ret = stun_message_init (msg, STUN_REQUEST, m, id);
if (ret) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) {
uint32_t cookie = htonl (STUN_MAGIC_COOKIE);
memcpy (msg->buffer + STUN_MESSAGE_TRANS_ID_POS, &cookie, sizeof (cookie));
}
......@@ -344,7 +347,8 @@ bool stun_agent_init_indication (StunAgent *agent, StunMessage *msg,
ret = stun_message_init (msg, STUN_INDICATION, m, id);
if (ret) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) {
uint32_t cookie = htonl (STUN_MAGIC_COOKIE);
memcpy (msg->buffer + STUN_MESSAGE_TRANS_ID_POS, &cookie, sizeof (cookie));
}
......@@ -378,7 +382,8 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg,
if (stun_message_init (msg, STUN_RESPONSE,
stun_message_get_method (request), id)) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 &&
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) &&
agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE) {
stun_message_append_software (msg);
}
......@@ -413,7 +418,8 @@ bool stun_agent_init_error (StunAgent *agent, StunMessage *msg,
if (stun_message_init (msg, STUN_ERROR,
stun_message_get_method (request), id)) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 &&
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) &&
agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE) {
stun_message_append_software (msg);
}
......@@ -519,7 +525,8 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
}
}
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 &&
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) &&
agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) {
ptr = stun_message_append (msg, STUN_ATTRIBUTE_FINGERPRINT, 4);
if (ptr == NULL) {
......
......@@ -53,7 +53,8 @@ typedef struct stun_agent_t StunAgent;
typedef enum {
STUN_COMPATIBILITY_RFC3489,
STUN_COMPATIBILITY_RFC5389,
STUN_COMPATIBILITY_LAST = STUN_COMPATIBILITY_RFC5389
STUN_COMPATIBILITY_WLM2009,
STUN_COMPATIBILITY_LAST = STUN_COMPATIBILITY_WLM2009
} StunCompatibility;
......
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