Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37912583
en ru br
Репозитории ALT
S:0.1.21-alt2
5.1: 0.0.9-alt1
www.altlinux.org/Changes

Группа :: Система/Библиотеки
Пакет: libnice

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: libnice-Compatibility-with-OC2007-R2.patch
Скачать


From 4459cb2ac2198e040804da3fd7d9b61083fdeb59 Mon Sep 17 00:00:00 2001
From: Jakub Adam <jakub.adam@ktknet.cz>
Date: Sun, 28 Mar 2010 14:53:43 +0200
Subject: [PATCH] Compatibility with OC2007 R2
---
 agent/agent.c      |    5 ++++-
 agent/agent.h      |    3 ++-
 agent/conncheck.c  |   12 ++++++++----
 stun/stunmessage.h |    4 +++-
 stun/usages/ice.c  |   29 +++++++++++++++++++++++++++--
 stun/usages/ice.h  |    5 +++--
 6 files changed, 47 insertions(+), 11 deletions(-)
diff --git a/agent/agent.c b/agent/agent.c
index 7deb2dd..b032a2a 100644
--- a/agent/agent.c
+++ b/agent/agent.c
@@ -149,6 +149,8 @@ agent_to_ice_compatibility (NiceAgent *agent)
       STUN_USAGE_ICE_COMPATIBILITY_GOOGLE :
       agent->compatibility == NICE_COMPATIBILITY_MSN ?
       STUN_USAGE_ICE_COMPATIBILITY_MSN :
+	  agent->compatibility == NICE_COMPATIBILITY_OC2007R2 ?
+      STUN_USAGE_ICE_COMPATIBILITY_OC2007R2 :
       STUN_USAGE_ICE_COMPATIBILITY_RFC5245;
 }
 
@@ -835,7 +837,8 @@ 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) {
+      } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
+				 agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
         stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
             STUN_COMPATIBILITY_WLM2009,
             STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
diff --git a/agent/agent.h b/agent/agent.h
index 524bae2..c37bf21 100644
--- a/agent/agent.h
+++ b/agent/agent.h
@@ -229,8 +229,9 @@ typedef enum
   NICE_COMPATIBILITY_GOOGLE,
   NICE_COMPATIBILITY_MSN,
   NICE_COMPATIBILITY_WLM2009,
+  NICE_COMPATIBILITY_OC2007R2,
   NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245,
-  NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_WLM2009,
+  NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_OC2007R2,
 } NiceCompatibility;
 
 /**
diff --git a/agent/conncheck.c b/agent/conncheck.c
index 30d13d3..a36b719 100644
--- a/agent/conncheck.c
+++ b/agent/conncheck.c
@@ -599,7 +599,8 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
                 uname, uname_len, password, password_len,
                 agent->controlling_mode, agent->controlling_mode, priority,
                 agent->tie_breaker,
-                agent_to_ice_compatibility (agent));
+                agent_to_ice_compatibility (agent),
+                NULL);
 
             nice_debug ("Agent %p: conncheck created %d - %p",
                 agent, buf_len, p->keepalive.stun_message.buffer);
@@ -1461,7 +1462,8 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
       len++;
       memcpy (dest + len, local, 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 ) {
       memcpy (dest, remote, remote_len);
       len += remote_len;
@@ -1662,7 +1664,8 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
         uname, uname_len, password, password_len,
         cand_use, controlling, priority,
         agent->tie_breaker,
-        agent_to_ice_compatibility (agent));
+        agent_to_ice_compatibility (agent),
+        pair->foundation);
 
     nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer);
 
@@ -1795,7 +1798,8 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
 	   *       aggressive nomination mode, send a new triggered
 	   *       check to nominate the pair */
 	  if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 ||
-                  agent->compatibility == NICE_COMPATIBILITY_WLM2009) &&
+           agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
+           agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
               agent->controlling_mode)
 	    priv_conn_check_initiate (agent, p);
 	}
diff --git a/stun/stunmessage.h b/stun/stunmessage.h
index b9291b2..d35196f 100644
--- a/stun/stunmessage.h
+++ b/stun/stunmessage.h
@@ -288,7 +288,9 @@ typedef enum
   STUN_ATTRIBUTE_FINGERPRINT=0x8028,    /* RFC5389 */
   STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029,    /* 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;
 
 
diff --git a/stun/usages/ice.c b/stun/usages/ice.c
index e469f32..53765be 100644
--- a/stun/usages/ice.c
+++ b/stun/usages/ice.c
@@ -42,6 +42,7 @@
 
 #include <string.h>
 #include <assert.h>
+#include <stdlib.h>
 
 #ifdef _WIN32
 #include <winsock2.h>
@@ -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 *password, const size_t password_len,
     bool cand_use, bool controlling, uint32_t priority,
-    uint64_t tie, StunUsageIceCompatibility compatibility)
+    uint64_t tie, StunUsageIceCompatibility compatibility,
+    const char *candidate_identifier)
 {
   StunMessageReturn val;
 
   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_OC2007R2) {
     if (cand_use)
     {
       val = stun_message_append_flag (msg, STUN_ATTRIBUTE_USE_CANDIDATE);
@@ -97,6 +100,28 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
       return 0;
   }
 
+  if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_OC2007R2) {
+    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);
 
 }
diff --git a/stun/usages/ice.h b/stun/usages/ice.h
index 39bafaa..d9fdab2 100644
--- a/stun/usages/ice.h
+++ b/stun/usages/ice.h
@@ -78,6 +78,7 @@ typedef enum {
   STUN_USAGE_ICE_COMPATIBILITY_RFC5245,
   STUN_USAGE_ICE_COMPATIBILITY_GOOGLE,
   STUN_USAGE_ICE_COMPATIBILITY_MSN,
+  STUN_USAGE_ICE_COMPATIBILITY_OC2007R2,
   STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 = STUN_USAGE_ICE_COMPATIBILITY_RFC5245,
 } StunUsageIceCompatibility;
 
@@ -144,8 +145,8 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
     const uint8_t *username, const size_t username_len,
     const uint8_t *password, const size_t password_len,
     bool cand_use, bool controlling, uint32_t priority,
-    uint64_t tie, StunUsageIceCompatibility compatibility);
-
+    uint64_t tie, StunUsageIceCompatibility compatibility,
+	const char *candidate_identifier);
 
 /**
  * stun_usage_ice_conncheck_process:
-- 
1.7.1
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin