Commit dab34160 authored by Jakub Adam's avatar Jakub Adam Committed by Olivier Crête

stun: add STUN_COMPATIBILITY_MSICE2

Windows Live Messenger is a discontinued service. We can repurpose
STUN_COMPATIBILITY_WLM2009 as [MS-ICE2] compatibility.

The orignial WLM enumerator is kept for the sake of API compatibility.

Differential Revision: https://phabricator.freedesktop.org/D1137
parent b3910a9c
...@@ -1209,7 +1209,7 @@ nice_agent_init_stun_agent (NiceAgent *agent, StunAgent *stun_agent) ...@@ -1209,7 +1209,7 @@ nice_agent_init_stun_agent (NiceAgent *agent, StunAgent *stun_agent)
STUN_AGENT_USAGE_FORCE_VALIDATER); STUN_AGENT_USAGE_FORCE_VALIDATER);
} else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009) { } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009) {
stun_agent_init (stun_agent, STUN_ALL_KNOWN_ATTRIBUTES, stun_agent_init (stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_WLM2009, STUN_COMPATIBILITY_MSICE2,
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_OC2007) { } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007) {
...@@ -1220,7 +1220,7 @@ nice_agent_init_stun_agent (NiceAgent *agent, StunAgent *stun_agent) ...@@ -1220,7 +1220,7 @@ nice_agent_init_stun_agent (NiceAgent *agent, StunAgent *stun_agent)
STUN_AGENT_USAGE_NO_ALIGNED_ATTRIBUTES); STUN_AGENT_USAGE_NO_ALIGNED_ATTRIBUTES);
} else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) { } else if (agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
stun_agent_init (stun_agent, STUN_ALL_KNOWN_ATTRIBUTES, stun_agent_init (stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
STUN_COMPATIBILITY_WLM2009, STUN_COMPATIBILITY_MSICE2,
STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS | STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
STUN_AGENT_USAGE_USE_FINGERPRINT | STUN_AGENT_USAGE_USE_FINGERPRINT |
STUN_AGENT_USAGE_NO_ALIGNED_ATTRIBUTES); STUN_AGENT_USAGE_NO_ALIGNED_ATTRIBUTES);
......
...@@ -139,14 +139,14 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -139,14 +139,14 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
/* TODO: reject it or not ? */ /* TODO: reject it or not ? */
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 || if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) && agent->compatibility == STUN_COMPATIBILITY_MSICE2) &&
!stun_message_has_cookie (msg)) { !stun_message_has_cookie (msg)) {
stun_debug ("STUN demux error: no cookie!"); stun_debug ("STUN demux error: no cookie!");
return STUN_VALIDATION_BAD_REQUEST; return STUN_VALIDATION_BAD_REQUEST;
} }
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 || if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) && agent->compatibility == STUN_COMPATIBILITY_MSICE2) &&
agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) { agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) {
/* Looks for FINGERPRINT */ /* Looks for FINGERPRINT */
if (stun_message_find32 (msg, STUN_ATTRIBUTE_FINGERPRINT, &fpr) != if (stun_message_find32 (msg, STUN_ATTRIBUTE_FINGERPRINT, &fpr) !=
...@@ -263,7 +263,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -263,7 +263,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
agent->compatibility == STUN_COMPATIBILITY_OC2007) { agent->compatibility == STUN_COMPATIBILITY_OC2007) {
stun_sha1 (msg->buffer, hash + 20 - msg->buffer, hash - msg->buffer, stun_sha1 (msg->buffer, hash + 20 - msg->buffer, hash - msg->buffer,
sha, md5, sizeof(md5), TRUE); sha, md5, sizeof(md5), TRUE);
} else if (agent->compatibility == STUN_COMPATIBILITY_WLM2009) { } else if (agent->compatibility == STUN_COMPATIBILITY_MSICE2) {
stun_sha1 (msg->buffer, hash + 20 - msg->buffer, stun_sha1 (msg->buffer, hash + 20 - msg->buffer,
stun_message_length (msg) - 20, sha, md5, sizeof(md5), TRUE); stun_message_length (msg) - 20, sha, md5, sizeof(md5), TRUE);
} else { } else {
...@@ -275,7 +275,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg, ...@@ -275,7 +275,7 @@ StunValidationStatus stun_agent_validate (StunAgent *agent, StunMessage *msg,
agent->compatibility == STUN_COMPATIBILITY_OC2007) { agent->compatibility == STUN_COMPATIBILITY_OC2007) {
stun_sha1 (msg->buffer, hash + 20 - msg->buffer, hash - msg->buffer, stun_sha1 (msg->buffer, hash + 20 - msg->buffer, hash - msg->buffer,
sha, key, key_len, TRUE); sha, key, key_len, TRUE);
} else if (agent->compatibility == STUN_COMPATIBILITY_WLM2009) { } else if (agent->compatibility == STUN_COMPATIBILITY_MSICE2) {
stun_sha1 (msg->buffer, hash + 20 - msg->buffer, stun_sha1 (msg->buffer, hash + 20 - msg->buffer,
stun_message_length (msg) - 20, sha, key, key_len, TRUE); stun_message_length (msg) - 20, sha, key, key_len, TRUE);
} else { } else {
...@@ -356,12 +356,12 @@ bool stun_agent_init_request (StunAgent *agent, StunMessage *msg, ...@@ -356,12 +356,12 @@ bool stun_agent_init_request (StunAgent *agent, StunMessage *msg,
if (ret) { if (ret) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 || if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) { agent->compatibility == STUN_COMPATIBILITY_MSICE2) {
uint32_t cookie = htonl (STUN_MAGIC_COOKIE); uint32_t cookie = htonl (STUN_MAGIC_COOKIE);
memcpy (msg->buffer + STUN_MESSAGE_TRANS_ID_POS, &cookie, sizeof (cookie)); memcpy (msg->buffer + STUN_MESSAGE_TRANS_ID_POS, &cookie, sizeof (cookie));
} }
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 || if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) && agent->compatibility == STUN_COMPATIBILITY_MSICE2) &&
(agent->software_attribute != NULL || (agent->software_attribute != NULL ||
agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE)) { agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE)) {
stun_message_append_software (msg, agent->software_attribute); stun_message_append_software (msg, agent->software_attribute);
...@@ -390,7 +390,7 @@ bool stun_agent_init_indication (StunAgent *agent, StunMessage *msg, ...@@ -390,7 +390,7 @@ bool stun_agent_init_indication (StunAgent *agent, StunMessage *msg,
if (ret) { if (ret) {
if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 || if (agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) { agent->compatibility == STUN_COMPATIBILITY_MSICE2) {
uint32_t cookie = htonl (STUN_MAGIC_COOKIE); uint32_t cookie = htonl (STUN_MAGIC_COOKIE);
memcpy (msg->buffer + STUN_MESSAGE_TRANS_ID_POS, &cookie, sizeof (cookie)); memcpy (msg->buffer + STUN_MESSAGE_TRANS_ID_POS, &cookie, sizeof (cookie));
} }
...@@ -425,7 +425,7 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg, ...@@ -425,7 +425,7 @@ bool stun_agent_init_response (StunAgent *agent, StunMessage *msg,
stun_message_get_method (request), id)) { stun_message_get_method (request), id)) {
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 || if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) && agent->compatibility == STUN_COMPATIBILITY_MSICE2) &&
(agent->software_attribute != NULL || (agent->software_attribute != NULL ||
agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE)) { agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE)) {
stun_message_append_software (msg, agent->software_attribute); stun_message_append_software (msg, agent->software_attribute);
...@@ -462,7 +462,7 @@ bool stun_agent_init_error (StunAgent *agent, StunMessage *msg, ...@@ -462,7 +462,7 @@ bool stun_agent_init_error (StunAgent *agent, StunMessage *msg,
stun_message_get_method (request), id)) { stun_message_get_method (request), id)) {
if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 || if ((agent->compatibility == STUN_COMPATIBILITY_RFC5389 ||
agent->compatibility == STUN_COMPATIBILITY_WLM2009) && agent->compatibility == STUN_COMPATIBILITY_MSICE2) &&
(agent->software_attribute != NULL || (agent->software_attribute != NULL ||
agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE)) { agent->usage_flags & STUN_AGENT_USAGE_ADD_SOFTWARE)) {
stun_message_append_software (msg, agent->software_attribute); stun_message_append_software (msg, agent->software_attribute);
...@@ -580,7 +580,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, ...@@ -580,7 +580,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
agent->compatibility == STUN_COMPATIBILITY_OC2007) { agent->compatibility == STUN_COMPATIBILITY_OC2007) {
stun_sha1 (msg->buffer, stun_message_length (msg), stun_sha1 (msg->buffer, stun_message_length (msg),
stun_message_length (msg) - 20, ptr, md5, sizeof(md5), TRUE); stun_message_length (msg) - 20, ptr, md5, sizeof(md5), TRUE);
} else if (agent->compatibility == STUN_COMPATIBILITY_WLM2009) { } else if (agent->compatibility == STUN_COMPATIBILITY_MSICE2) {
size_t minus = 20; size_t minus = 20;
if (agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) if (agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT)
minus -= 8; minus -= 8;
...@@ -596,7 +596,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, ...@@ -596,7 +596,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg,
agent->compatibility == STUN_COMPATIBILITY_OC2007) { agent->compatibility == STUN_COMPATIBILITY_OC2007) {
stun_sha1 (msg->buffer, stun_message_length (msg), stun_sha1 (msg->buffer, stun_message_length (msg),
stun_message_length (msg) - 20, ptr, key, key_len, TRUE); stun_message_length (msg) - 20, ptr, key, key_len, TRUE);
} else if (agent->compatibility == STUN_COMPATIBILITY_WLM2009) { } else if (agent->compatibility == STUN_COMPATIBILITY_MSICE2) {
size_t minus = 20; size_t minus = 20;
if (agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) if (agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT)
minus -= 8; minus -= 8;
...@@ -616,7 +616,7 @@ size_t stun_agent_finish_message (StunAgent *agent, StunMessage *msg, ...@@ -616,7 +616,7 @@ 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->compatibility == STUN_COMPATIBILITY_MSICE2) &&
agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) { agent->usage_flags & STUN_AGENT_USAGE_USE_FINGERPRINT) {
ptr = stun_message_append (msg, STUN_ATTRIBUTE_FINGERPRINT, 4); ptr = stun_message_append (msg, STUN_ATTRIBUTE_FINGERPRINT, 4);
if (ptr == NULL) { if (ptr == NULL) {
......
...@@ -79,21 +79,26 @@ typedef struct stun_agent_t StunAgent; ...@@ -79,21 +79,26 @@ typedef struct stun_agent_t StunAgent;
* RFC 3489 * RFC 3489
* @STUN_COMPATIBILITY_RFC5389: Use the STUN specifications compatible with * @STUN_COMPATIBILITY_RFC5389: Use the STUN specifications compatible with
* RFC 5389 * RFC 5389
* @STUN_COMPATIBILITY_WLM2009: Use the STUN specifications compatible with * @STUN_COMPATIBILITY_MSICE2: Use the STUN specifications compatible with
* Windows Live Messenger 2009 (a mix between RFC3489 and RFC5389, as well as * [MS-ICE2] (a mix between RFC3489 and RFC5389)
* a special usecase against a typo in their code)
* @STUN_COMPATIBILITY_OC2007: Use the STUN specifications compatible with * @STUN_COMPATIBILITY_OC2007: Use the STUN specifications compatible with
* Microsoft Office Communicator 2007 (basically RFC3489 with swapped * Microsoft Office Communicator 2007 (basically RFC3489 with swapped
* REALM and NONCE attribute hex IDs, attributes are not aligned) * REALM and NONCE attribute hex IDs, attributes are not aligned)
* @STUN_COMPATIBILITY_WLM2009: An alias for @STUN_COMPATIBILITY_MSICE2
* @STUN_COMPATIBILITY_LAST: Dummy last compatibility mode * @STUN_COMPATIBILITY_LAST: Dummy last compatibility mode
* *
* Enum that specifies the STUN compatibility mode of the #StunAgent * Enum that specifies the STUN compatibility mode of the #StunAgent
*
* <warning>@STUN_COMPATIBILITY_WLM2009 is deprecated and should not be used
* in newly-written code. It is kept for compatibility reasons and represents
* the same compatibility as @STUN_COMPATIBILITY_MSICE2.</warning>
*/ */
typedef enum { typedef enum {
STUN_COMPATIBILITY_RFC3489, STUN_COMPATIBILITY_RFC3489,
STUN_COMPATIBILITY_RFC5389, STUN_COMPATIBILITY_RFC5389,
STUN_COMPATIBILITY_WLM2009, STUN_COMPATIBILITY_MSICE2,
STUN_COMPATIBILITY_OC2007, STUN_COMPATIBILITY_OC2007,
STUN_COMPATIBILITY_WLM2009 = STUN_COMPATIBILITY_MSICE2,
STUN_COMPATIBILITY_LAST = STUN_COMPATIBILITY_OC2007 STUN_COMPATIBILITY_LAST = STUN_COMPATIBILITY_OC2007
} StunCompatibility; } StunCompatibility;
...@@ -147,7 +152,7 @@ typedef enum { ...@@ -147,7 +152,7 @@ typedef enum {
* to the STUN messages it creates. Calling nice_agent_set_software() will have * to the STUN messages it creates. Calling nice_agent_set_software() will have
* the same effect as enabling this Usage. STUN Indications do not have the * the same effect as enabling this Usage. STUN Indications do not have the
* SOFTWARE attributes added to them though. The SOFTWARE attribute is only * SOFTWARE attributes added to them though. The SOFTWARE attribute is only
* added for the RFC5389 and WLM2009 compatibility modes. * added for the RFC5389 and MSICE2 compatibility modes.
* @STUN_AGENT_USAGE_IGNORE_CREDENTIALS: The agent should ignore any credentials * @STUN_AGENT_USAGE_IGNORE_CREDENTIALS: The agent should ignore any credentials
* in the STUN messages it receives (the MESSAGE-INTEGRITY attribute * in the STUN messages it receives (the MESSAGE-INTEGRITY attribute
* will never be validated by stun_agent_validate()) * will never be validated by stun_agent_validate())
...@@ -296,7 +301,7 @@ bool stun_agent_default_validater (StunAgent *agent, ...@@ -296,7 +301,7 @@ bool stun_agent_default_validater (StunAgent *agent,
<para> <para>
The #STUN_AGENT_USAGE_USE_FINGERPRINT and #STUN_AGENT_USAGE_ADD_SOFTWARE The #STUN_AGENT_USAGE_USE_FINGERPRINT and #STUN_AGENT_USAGE_ADD_SOFTWARE
usage flags are only valid if the #STUN_COMPATIBILITY_RFC5389 or usage flags are only valid if the #STUN_COMPATIBILITY_RFC5389 or
#STUN_COMPATIBILITY_WLM2009 @compatibility is used #STUN_COMPATIBILITY_MSICE2 @compatibility is used
</para> </para>
</note> </note>
*/ */
...@@ -494,7 +499,7 @@ bool stun_agent_forget_transaction (StunAgent *agent, StunTransactionId id); ...@@ -494,7 +499,7 @@ bool stun_agent_forget_transaction (StunAgent *agent, StunTransactionId id);
* STUN requests, responses and error responses. * STUN requests, responses and error responses.
* <para> * <para>
* Calling this function will automatically enable the addition of the SOFTWARE * Calling this function will automatically enable the addition of the SOFTWARE
* attribute for RFC5389 and WLM2009 compatibility modes. * attribute for RFC5389 and MSICE2 compatibility modes.
* *
* </para> * </para>
* <note> * <note>
......
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