audio: uploaded patches for third party libs
[siplcs.git] / contrib / media-patches / libnice-Compatibility-with-OC2007-R2.patch
blobc7deb55db63bae72821338164f75b448b4f43640
1 From b4f47a693e6359741965a78f40b1044458370038 Mon Sep 17 00:00:00 2001
2 From: Jakub Adam <jakub.adam@ktknet.cz>
3 Date: Sun, 28 Mar 2010 14:53:43 +0200
4 Subject: [PATCH] Compatibility with OC2007 R2
6 ---
7 agent/agent.c | 5 ++++-
8 agent/agent.h | 3 ++-
9 agent/conncheck.c | 12 ++++++++----
10 stun/stunmessage.h | 4 +++-
11 stun/usages/ice.c | 29 +++++++++++++++++++++++++++--
12 stun/usages/ice.h | 5 +++--
13 6 files changed, 47 insertions(+), 11 deletions(-)
15 diff --git a/agent/agent.c b/agent/agent.c
16 index 19d52fa..e6c46a9 100644
17 --- a/agent/agent.c
18 +++ b/agent/agent.c
19 @@ -149,6 +149,8 @@ agent_to_ice_compatibility (NiceAgent *agent)
20 STUN_USAGE_ICE_COMPATIBILITY_GOOGLE :
21 agent->compatibility == NICE_COMPATIBILITY_MSN ?
22 STUN_USAGE_ICE_COMPATIBILITY_MSN :
23 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2 ?
24 + STUN_USAGE_ICE_COMPATIBILITY_OC2007R2 :
25 STUN_USAGE_ICE_COMPATIBILITY_DRAFT19;
28 @@ -833,7 +835,8 @@ nice_agent_set_property (
29 STUN_COMPATIBILITY_RFC3489,
30 STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
31 STUN_AGENT_USAGE_FORCE_VALIDATER);
32 - } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009) {
33 + } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
34 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
35 stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
36 STUN_COMPATIBILITY_WLM2009,
37 STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
38 diff --git a/agent/agent.h b/agent/agent.h
39 index 922a935..8bc6acb 100644
40 --- a/agent/agent.h
41 +++ b/agent/agent.h
42 @@ -224,7 +224,8 @@ typedef enum
43 NICE_COMPATIBILITY_GOOGLE,
44 NICE_COMPATIBILITY_MSN,
45 NICE_COMPATIBILITY_WLM2009,
46 - NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_WLM2009
47 + NICE_COMPATIBILITY_OC2007R2,
48 + NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_OC2007R2
49 } NiceCompatibility;
51 /**
52 diff --git a/agent/conncheck.c b/agent/conncheck.c
53 index 28d4f07..ee72f71 100644
54 --- a/agent/conncheck.c
55 +++ b/agent/conncheck.c
56 @@ -599,7 +599,8 @@ static gboolean priv_conn_keepalive_tick_unlocked (NiceAgent *agent)
57 uname, uname_len, password, password_len,
58 agent->controlling_mode, agent->controlling_mode, priority,
59 agent->tie_breaker,
60 - agent_to_ice_compatibility (agent));
61 + agent_to_ice_compatibility (agent),
62 + NULL);
64 nice_debug ("Agent %p: conncheck created %d - %p",
65 agent, buf_len, p->keepalive.stun_message.buffer);
66 @@ -1460,7 +1461,8 @@ size_t priv_gen_username (NiceAgent *agent, guint component_id,
67 len++;
68 memcpy (dest + len, local, local_len);
69 len += local_len;
70 - } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009 &&
71 + } else if ((agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
72 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
73 dest_len >= remote_len + local_len + 4 ) {
74 memcpy (dest, remote, remote_len);
75 len += remote_len;
76 @@ -1661,7 +1663,8 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
77 uname, uname_len, password, password_len,
78 cand_use, controlling, priority,
79 agent->tie_breaker,
80 - agent_to_ice_compatibility (agent));
81 + agent_to_ice_compatibility (agent),
82 + pair->foundation);
84 nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer);
86 @@ -1794,7 +1797,8 @@ static gboolean priv_schedule_triggered_check (NiceAgent *agent, Stream *stream,
87 * aggressive nomination mode, send a new triggered
88 * check to nominate the pair */
89 if ((agent->compatibility == NICE_COMPATIBILITY_DRAFT19 ||
90 - agent->compatibility == NICE_COMPATIBILITY_WLM2009) &&
91 + agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
92 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
93 agent->controlling_mode)
94 priv_conn_check_initiate (agent, p);
96 diff --git a/stun/stunmessage.h b/stun/stunmessage.h
97 index b9291b2..d35196f 100644
98 --- a/stun/stunmessage.h
99 +++ b/stun/stunmessage.h
100 @@ -288,7 +288,9 @@ typedef enum
101 STUN_ATTRIBUTE_FINGERPRINT=0x8028, /* RFC5389 */
102 STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */
103 STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */
104 - /* 0x802B-0xFFFF */ /* reserved */
105 + /* 0x802B-0x8053 */ /* reserved */
106 + STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER=0x8054 /* MS-ICE2 */
107 + /* 0x8055-0xFFFF */ /* reserved */
108 } StunAttribute;
111 diff --git a/stun/usages/ice.c b/stun/usages/ice.c
112 index 5977296..174184d 100644
113 --- a/stun/usages/ice.c
114 +++ b/stun/usages/ice.c
115 @@ -42,6 +42,7 @@
117 #include <string.h>
118 #include <assert.h>
119 +#include <stdlib.h>
121 #ifdef _WIN32
122 #include <winsock2.h>
123 @@ -64,13 +65,15 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
124 const uint8_t *username, const size_t username_len,
125 const uint8_t *password, const size_t password_len,
126 bool cand_use, bool controlling, uint32_t priority,
127 - uint64_t tie, StunUsageIceCompatibility compatibility)
128 + uint64_t tie, StunUsageIceCompatibility compatibility,
129 + const char *candidate_identifier)
131 StunMessageReturn val;
133 stun_agent_init_request (agent, msg, buffer, buffer_len, STUN_BINDING);
135 - if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_DRAFT19) {
136 + if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 ||
137 + compatibility == STUN_USAGE_ICE_COMPATIBILITY_OC2007R2) {
138 if (cand_use)
140 val = stun_message_append_flag (msg, STUN_ATTRIBUTE_USE_CANDIDATE);
141 @@ -97,6 +100,28 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
142 return 0;
145 + if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_OC2007R2) {
146 + size_t identifier_len = strlen(candidate_identifier);
147 + size_t buffer_len = identifier_len;
148 + int modulo4 = identifier_len % 4;
149 + uint8_t* buf;
151 + if (modulo4)
152 + buffer_len += 4 - modulo4;
154 + buf = malloc(buffer_len);
155 + memset(buf, 0, buffer_len);
156 + memcpy(buf, candidate_identifier, identifier_len);
158 + val = stun_message_append_bytes (msg, STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER,
159 + buf, buffer_len);
161 + free(buf);
163 + if (val != STUN_MESSAGE_RETURN_SUCCESS)
164 + return 0;
167 return stun_agent_finish_message (agent, msg, password, password_len);
170 diff --git a/stun/usages/ice.h b/stun/usages/ice.h
171 index 9fe8ea2..ad2cbe2 100644
172 --- a/stun/usages/ice.h
173 +++ b/stun/usages/ice.h
174 @@ -72,6 +72,7 @@ typedef enum {
175 STUN_USAGE_ICE_COMPATIBILITY_DRAFT19,
176 STUN_USAGE_ICE_COMPATIBILITY_GOOGLE,
177 STUN_USAGE_ICE_COMPATIBILITY_MSN,
178 + STUN_USAGE_ICE_COMPATIBILITY_OC2007R2,
179 } StunUsageIceCompatibility;
182 @@ -137,8 +138,8 @@ stun_usage_ice_conncheck_create (StunAgent *agent, StunMessage *msg,
183 const uint8_t *username, const size_t username_len,
184 const uint8_t *password, const size_t password_len,
185 bool cand_use, bool controlling, uint32_t priority,
186 - uint64_t tie, StunUsageIceCompatibility compatibility);
188 + uint64_t tie, StunUsageIceCompatibility compatibility,
189 + const char *candidate_identifier);
192 * stun_usage_ice_conncheck_process:
194 1.7.0