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

Compatibility with MSOC 2007 R2

parent 67130554
...@@ -149,6 +149,10 @@ agent_to_ice_compatibility (NiceAgent *agent) ...@@ -149,6 +149,10 @@ agent_to_ice_compatibility (NiceAgent *agent)
STUN_USAGE_ICE_COMPATIBILITY_GOOGLE : STUN_USAGE_ICE_COMPATIBILITY_GOOGLE :
agent->compatibility == NICE_COMPATIBILITY_MSN ? agent->compatibility == NICE_COMPATIBILITY_MSN ?
STUN_USAGE_ICE_COMPATIBILITY_MSN : STUN_USAGE_ICE_COMPATIBILITY_MSN :
agent->compatibility == NICE_COMPATIBILITY_WLM2009 ?
STUN_USAGE_ICE_COMPATIBILITY_WLM2009 :
agent->compatibility == NICE_COMPATIBILITY_OC2007R2 ?
STUN_USAGE_ICE_COMPATIBILITY_WLM2009 :
STUN_USAGE_ICE_COMPATIBILITY_RFC5245; STUN_USAGE_ICE_COMPATIBILITY_RFC5245;
} }
...@@ -840,6 +844,11 @@ nice_agent_set_property ( ...@@ -840,6 +844,11 @@ nice_agent_set_property (
STUN_COMPATIBILITY_WLM2009, STUN_COMPATIBILITY_WLM2009,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS | STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_USE_FINGERPRINT); STUN_AGENT_USAGE_USE_FINGERPRINT);
} else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
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 { } else {
stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES, stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_RFC5389, STUN_COMPATIBILITY_RFC5389,
......
...@@ -213,6 +213,7 @@ typedef enum ...@@ -213,6 +213,7 @@ typedef enum
* @NICE_COMPATIBILITY_MSN: Use compatibility for MSN Messenger specs * @NICE_COMPATIBILITY_MSN: Use compatibility for MSN Messenger specs
* @NICE_COMPATIBILITY_WLM2009: Use compatibility with Windows Live Messenger * @NICE_COMPATIBILITY_WLM2009: Use compatibility with Windows Live Messenger
* 2009 * 2009
* @NICE_COMPATIBILITY_OC2007R2: Use compatibility with Microsoft Office Communicator 2007 R2
* @NICE_COMPATIBILITY_DRAFT19: Use compatibility for ICE Draft 19 specs * @NICE_COMPATIBILITY_DRAFT19: Use compatibility for ICE Draft 19 specs
* @NICE_COMPATIBILITY_LAST: Dummy last compatibility mode * @NICE_COMPATIBILITY_LAST: Dummy last compatibility mode
* *
...@@ -229,8 +230,9 @@ typedef enum ...@@ -229,8 +230,9 @@ typedef enum
NICE_COMPATIBILITY_GOOGLE, NICE_COMPATIBILITY_GOOGLE,
NICE_COMPATIBILITY_MSN, NICE_COMPATIBILITY_MSN,
NICE_COMPATIBILITY_WLM2009, NICE_COMPATIBILITY_WLM2009,
NICE_COMPATIBILITY_OC2007R2,
NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245, NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245,
NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_WLM2009, NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_OC2007R2,
} NiceCompatibility; } NiceCompatibility;
/** /**
......
...@@ -599,6 +599,7 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent) ...@@ -599,6 +599,7 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
uname, uname_len, password, password_len, uname, uname_len, password, password_len,
agent->controlling_mode, agent->controlling_mode, priority, agent->controlling_mode, agent->controlling_mode, priority,
agent->tie_breaker, agent->tie_breaker,
NULL,
agent_to_ice_compatibility (agent)); agent_to_ice_compatibility (agent));
nice_debug ("Agent %p: conncheck created %d - %p", nice_debug ("Agent %p: conncheck created %d - %p",
...@@ -1314,7 +1315,8 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component * ...@@ -1314,7 +1315,8 @@ int conn_check_add_for_candidate (NiceAgent *agent, guint stream_id, Component *
/* note: do not create pairs where local candidate is /* note: do not create pairs where local candidate is
* a srv-reflexive (ICE 5.7.3. "Pruning the Pairs" ID-19) */ * a srv-reflexive (ICE 5.7.3. "Pruning the Pairs" ID-19) */
if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 || if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 ||
agent->compatibility == NICE_COMPATIBILITY_WLM2009) && agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
local->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE) local->type == NICE_CANDIDATE_TYPE_SERVER_REFLEXIVE)
continue; continue;
...@@ -1434,7 +1436,8 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id, ...@@ -1434,7 +1436,8 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
len++; len++;
memcpy (dest + len, local, local_len); memcpy (dest + len, local, local_len);
len += local_len; len += local_len;
} else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009 && } else if ((agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
dest_len >= remote_len + local_len + 4 ) { dest_len >= remote_len + local_len + 4 ) {
memcpy (dest, remote, remote_len); memcpy (dest, remote, remote_len);
len += remote_len; len += remote_len;
...@@ -1635,6 +1638,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) ...@@ -1635,6 +1638,7 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
uname, uname_len, password, password_len, uname, uname_len, password, password_len,
cand_use, controlling, priority, cand_use, controlling, priority,
agent->tie_breaker, agent->tie_breaker,
pair->foundation,
agent_to_ice_compatibility (agent)); agent_to_ice_compatibility (agent));
nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer); nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer);
...@@ -1769,8 +1773,9 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream, ...@@ -1769,8 +1773,9 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
* aggressive nomination mode, send a new triggered * aggressive nomination mode, send a new triggered
* check to nominate the pair */ * check to nominate the pair */
if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 || if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 ||
agent->compatibility == NICE_COMPATIBILITY_WLM2009) && agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
agent->controlling_mode) agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
agent->controlling_mode)
priv_conn_check_initiate (agent, p); priv_conn_check_initiate (agent, p);
} }
......
...@@ -218,6 +218,8 @@ typedef enum ...@@ -218,6 +218,8 @@ typedef enum
* defined by ICE draft 19 * defined by ICE draft 19
* @STUN_ATTRIBUTE_ICE_CONTROLLING: The ICE-CONTROLLING optional attribute as * @STUN_ATTRIBUTE_ICE_CONTROLLING: The ICE-CONTROLLING optional attribute as
* defined by ICE draft 19 * defined by ICE draft 19
* @STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER: The CANDIDATE-IDENTIFIER optional
* attribute as defined by [MS-ICE2]
* *
* Known STUN attribute types as defined by various RFCs and drafts * Known STUN attribute types as defined by various RFCs and drafts
*/ */
...@@ -288,7 +290,9 @@ typedef enum ...@@ -288,7 +290,9 @@ typedef enum
STUN_ATTRIBUTE_FINGERPRINT=0x8028, /* RFC5389 */ STUN_ATTRIBUTE_FINGERPRINT=0x8028, /* RFC5389 */
STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */ STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */
STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */ STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */
/* 0x802B-0xFFFF */ /* reserved */ /* 0x802B-0x8053 */ /* reserved */
STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER=0x8054 /* MS-ICE2 */
/* 0x8055-0xFFFF */ /* reserved */
} StunAttribute; } StunAttribute;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <string.h> #include <string.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#ifdef _WIN32 #ifdef _WIN32
#include <winsock2.h> #include <winsock2.h>
...@@ -64,13 +65,15 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg, ...@@ -64,13 +65,15 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
const uint8_t *username, const size_t username_len, const uint8_t *username, const size_t username_len,
const uint8_t *password, const size_t password_len, const uint8_t *password, const size_t password_len,
bool cand_use, bool controlling, uint32_t priority, bool cand_use, bool controlling, uint32_t priority,
uint64_t tie, StunUsageIceCompatibility compatibility) uint64_t tie, const char *candidate_identifier,
StunUsageIceCompatibility compatibility)
{ {
StunMessageReturn val; StunMessageReturn val;
stun_agent_init_request (agent, msg, buffer, buffer_len, STUN_BINDING); stun_agent_init_request (agent, msg, buffer, buffer_len, STUN_BINDING);
if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_RFC5245) { if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_RFC5245 ||
compatibility == STUN_USAGE_ICE_COMPATIBILITY_WLM2009) {
if (cand_use) if (cand_use)
{ {
val = stun_message_append_flag (msg, STUN_ATTRIBUTE_USE_CANDIDATE); val = stun_message_append_flag (msg, STUN_ATTRIBUTE_USE_CANDIDATE);
...@@ -97,6 +100,28 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg, ...@@ -97,6 +100,28 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
return 0; return 0;
} }
if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_WLM2009) {
size_t identifier_len = strlen(candidate_identifier);
size_t buffer_len = identifier_len;
int modulo4 = identifier_len % 4;
uint8_t* buf;
if (modulo4)
buffer_len += 4 - modulo4;
buf = malloc(buffer_len);
memset(buf, 0, buffer_len);
memcpy(buf, candidate_identifier, identifier_len);
val = stun_message_append_bytes (msg, STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER,
buf, buffer_len);
free(buf);
if (val != STUN_MESSAGE_RETURN_SUCCESS)
return 0;
}
return stun_agent_finish_message (agent, msg, password, password_len); return stun_agent_finish_message (agent, msg, password, password_len);
} }
......
...@@ -65,6 +65,8 @@ extern "C" { ...@@ -65,6 +65,8 @@ extern "C" {
* implementation of ICE * implementation of ICE
* @STUN_USAGE_ICE_COMPATIBILITY_MSN: The ICE compatibility with MSN's * @STUN_USAGE_ICE_COMPATIBILITY_MSN: The ICE compatibility with MSN's
* implementation of ICE * implementation of ICE
* @STUN_USAGE_ICE_COMPATIBILITY_WLM2009: The ICE compatibility with Windows
* Live Messenger and Microsoft Office Communicator 2007 R2 implementation of ICE
* @STUN_USAGE_ICE_COMPATIBILITY_DRAFT19: The ICE compatibility with draft 19 * @STUN_USAGE_ICE_COMPATIBILITY_DRAFT19: The ICE compatibility with draft 19
* *
* This enum defines which compatibility modes this ICE usage can use * This enum defines which compatibility modes this ICE usage can use
...@@ -78,6 +80,7 @@ typedef enum { ...@@ -78,6 +80,7 @@ typedef enum {
STUN_USAGE_ICE_COMPATIBILITY_RFC5245, STUN_USAGE_ICE_COMPATIBILITY_RFC5245,
STUN_USAGE_ICE_COMPATIBILITY_GOOGLE, STUN_USAGE_ICE_COMPATIBILITY_GOOGLE,
STUN_USAGE_ICE_COMPATIBILITY_MSN, STUN_USAGE_ICE_COMPATIBILITY_MSN,
STUN_USAGE_ICE_COMPATIBILITY_WLM2009,
STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 = STUN_USAGE_ICE_COMPATIBILITY_RFC5245, STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 = STUN_USAGE_ICE_COMPATIBILITY_RFC5245,
} StunUsageIceCompatibility; } StunUsageIceCompatibility;
...@@ -130,12 +133,16 @@ typedef enum { ...@@ -130,12 +133,16 @@ typedef enum {
* @priority: The value of the PRIORITY attribute * @priority: The value of the PRIORITY attribute
* @tie: The value of the tie-breaker to put in the ICE-CONTROLLED or * @tie: The value of the tie-breaker to put in the ICE-CONTROLLED or
* ICE-CONTROLLING attribute * ICE-CONTROLLING attribute
* @candidate_identifier: The foundation value to put in the
* CANDIDATE-IDENTIFIER attribute
* @compatibility: The compatibility mode to use for building the conncheck * @compatibility: The compatibility mode to use for building the conncheck
* request * request
* *
* Builds an ICE connectivity check STUN message. * Builds an ICE connectivity check STUN message.
* If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_RFC5245, the * If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_RFC5245, the
* @cand_use, @controlling, @priority and @tie arguments are not used. * @cand_use, @controlling, @priority and @tie arguments are not used.
* If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_WLM2009, the
* @candidate_identifier argument is not used.
* Returns: The length of the message built. * Returns: The length of the message built.
*/ */
size_t size_t
...@@ -144,7 +151,8 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg, ...@@ -144,7 +151,8 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
const uint8_t *username, const size_t username_len, const uint8_t *username, const size_t username_len,
const uint8_t *password, const size_t password_len, const uint8_t *password, const size_t password_len,
bool cand_use, bool controlling, uint32_t priority, bool cand_use, bool controlling, uint32_t priority,
uint64_t tie, StunUsageIceCompatibility compatibility); uint64_t tie, const char *candidate_identifier,
StunUsageIceCompatibility compatibility);
/** /**
......
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