media: updated version of libnice patch
[siplcs.git] / contrib / media-patches / libnice-Compatibility-with-OC2007-R2.patch
blob22647d4f0ca38e066596cf368800f6e4850cc3d0
1 --- a/agent/agent.h
2 +++ b/agent/agent.h
3 @@ -213,6 +213,8 @@
4 * @NICE_COMPATIBILITY_MSN: Use compatibility for MSN Messenger specs
5 * @NICE_COMPATIBILITY_WLM2009: Use compatibility with Windows Live Messenger
6 * 2009
7 + * @NICE_COMPATIBILITY_OC2007R2: Use compatibility with Microsoft Office
8 + * Communicator 2007 R2
9 * @NICE_COMPATIBILITY_DRAFT19: Use compatibility for ICE Draft 19 specs
10 * @NICE_COMPATIBILITY_LAST: Dummy last compatibility mode
12 @@ -229,8 +231,9 @@
13 NICE_COMPATIBILITY_GOOGLE,
14 NICE_COMPATIBILITY_MSN,
15 NICE_COMPATIBILITY_WLM2009,
16 + NICE_COMPATIBILITY_OC2007R2,
17 NICE_COMPATIBILITY_DRAFT19 = NICE_COMPATIBILITY_RFC5245,
18 - NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_WLM2009,
19 + NICE_COMPATIBILITY_LAST = NICE_COMPATIBILITY_OC2007R2,
20 } NiceCompatibility;
22 /**
23 @@ -681,8 +684,9 @@
24 * This function will set the value of the SOFTWARE attribute to be added to
25 * STUN requests, responses and error responses sent during connectivity checks.
26 * <para>
27 - * The SOFTWARE attribute will only be added in the #NICE_COMPATIBILITY_RFC5245
28 - * and #NICE_COMPATIBILITY_WLM2009 compatibility modes.
29 + * The SOFTWARE attribute will only be added in the #NICE_COMPATIBILITY_RFC5245,
30 + * #NICE_COMPATIBILITY_WLM2009 and #NICE_COMPATIBILITY_OC2007R2 compatibility
31 + * modes.
33 * </para>
34 * <note>
36 --- a/agent/agent.c
37 +++ b/agent/agent.c
38 @@ -149,6 +149,8 @@
39 STUN_USAGE_ICE_COMPATIBILITY_GOOGLE :
40 agent->compatibility == NICE_COMPATIBILITY_MSN ?
41 STUN_USAGE_ICE_COMPATIBILITY_MSN :
42 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2 ?
43 + STUN_USAGE_ICE_COMPATIBILITY_OC2007R2 :
44 STUN_USAGE_ICE_COMPATIBILITY_RFC5245;
47 @@ -161,6 +163,8 @@
48 agent->compatibility == NICE_COMPATIBILITY_MSN ?
49 STUN_USAGE_TURN_COMPATIBILITY_MSN :
50 agent->compatibility == NICE_COMPATIBILITY_WLM2009 ?
51 + STUN_USAGE_TURN_COMPATIBILITY_MSN :
52 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2 ?
53 STUN_USAGE_TURN_COMPATIBILITY_MSN : STUN_USAGE_TURN_COMPATIBILITY_DRAFT9;
56 @@ -835,7 +839,8 @@
57 STUN_COMPATIBILITY_RFC3489,
58 STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
59 STUN_AGENT_USAGE_FORCE_VALIDATER);
60 - } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009) {
61 + } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
62 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2) {
63 stun_agent_init (&agent->stun_agent, STUN_ALL_KNOWN_ATTRIBUTES,
64 STUN_COMPATIBILITY_WLM2009,
65 STUN_AGENT_USAGE_SHORT_TERM_CREDENTIALS |
67 --- a/agent/conncheck.c
68 +++ b/agent/conncheck.c
69 @@ -599,7 +599,8 @@
70 uname, uname_len, password, password_len,
71 agent->controlling_mode, agent->controlling_mode, priority,
72 agent->tie_breaker,
73 - agent_to_ice_compatibility (agent));
74 + agent_to_ice_compatibility (agent),
75 + NULL);
77 nice_debug ("Agent %p: conncheck created %d - %p",
78 agent, buf_len, p->keepalive.stun_message.buffer);
79 @@ -1461,7 +1462,8 @@
80 len++;
81 memcpy (dest + len, local, local_len);
82 len += local_len;
83 - } else if (agent->compatibility == NICE_COMPATIBILITY_WLM2009 &&
84 + } else if ((agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
85 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
86 dest_len >= remote_len + local_len + 4 ) {
87 memcpy (dest, remote, remote_len);
88 len += remote_len;
89 @@ -1662,7 +1664,8 @@
90 uname, uname_len, password, password_len,
91 cand_use, controlling, priority,
92 agent->tie_breaker,
93 - agent_to_ice_compatibility (agent));
94 + agent_to_ice_compatibility (agent),
95 + pair->foundation);
97 nice_debug ("Agent %p: conncheck created %d - %p", agent, buffer_len, pair->stun_message.buffer);
99 @@ -1795,7 +1798,8 @@
100 * aggressive nomination mode, send a new triggered
101 * check to nominate the pair */
102 if ((agent->compatibility == NICE_COMPATIBILITY_RFC5245 ||
103 - agent->compatibility == NICE_COMPATIBILITY_WLM2009) &&
104 + agent->compatibility == NICE_COMPATIBILITY_WLM2009 ||
105 + agent->compatibility == NICE_COMPATIBILITY_OC2007R2) &&
106 agent->controlling_mode)
107 priv_conn_check_initiate (agent, p);
110 --- a/stun/usages/ice.h
111 +++ b/stun/usages/ice.h
112 @@ -65,6 +65,8 @@
113 * implementation of ICE
114 * @STUN_USAGE_ICE_COMPATIBILITY_MSN: The ICE compatibility with MSN's
115 * implementation of ICE
116 + * @STUN_USAGE_ICE_COMPATIBILITY_OC2007R2: The ICE compatibility with Microsoft
117 + * Office Communicator 2007 R2 implementation of ICE
118 * @STUN_USAGE_ICE_COMPATIBILITY_DRAFT19: The ICE compatibility with draft 19
120 * This enum defines which compatibility modes this ICE usage can use
121 @@ -78,6 +80,7 @@
122 STUN_USAGE_ICE_COMPATIBILITY_RFC5245,
123 STUN_USAGE_ICE_COMPATIBILITY_GOOGLE,
124 STUN_USAGE_ICE_COMPATIBILITY_MSN,
125 + STUN_USAGE_ICE_COMPATIBILITY_OC2007R2,
126 STUN_USAGE_ICE_COMPATIBILITY_DRAFT19 = STUN_USAGE_ICE_COMPATIBILITY_RFC5245,
127 } StunUsageIceCompatibility;
129 @@ -132,10 +135,14 @@
130 * ICE-CONTROLLING attribute
131 * @compatibility: The compatibility mode to use for building the conncheck
132 * request
133 + * @candidate_identifier: The foundation value to put in the
134 + * CANDIDATE-IDENTIFIER attribute
136 * Builds an ICE connectivity check STUN message.
137 * If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_RFC5245, the
138 * @cand_use, @controlling, @priority and @tie arguments are not used.
139 + * If the compatibility is not #STUN_USAGE_ICE_COMPATIBILITY_OC2007R2, the
140 + * @candidate_identifier argument is not used.
141 * Returns: The length of the message built.
143 size_t
144 @@ -144,8 +151,8 @@
145 const uint8_t *username, const size_t username_len,
146 const uint8_t *password, const size_t password_len,
147 bool cand_use, bool controlling, uint32_t priority,
148 - uint64_t tie, StunUsageIceCompatibility compatibility);
150 + uint64_t tie, StunUsageIceCompatibility compatibility,
151 + const char *candidate_identifier);
154 * stun_usage_ice_conncheck_process:
156 --- a/stun/usages/ice.c
157 +++ b/stun/usages/ice.c
158 @@ -42,6 +42,7 @@
160 #include <string.h>
161 #include <assert.h>
162 +#include <stdlib.h>
164 #ifdef _WIN32
165 #include <winsock2.h>
166 @@ -64,13 +65,15 @@
167 const uint8_t *username, const size_t username_len,
168 const uint8_t *password, const size_t password_len,
169 bool cand_use, bool controlling, uint32_t priority,
170 - uint64_t tie, StunUsageIceCompatibility compatibility)
171 + uint64_t tie, StunUsageIceCompatibility compatibility,
172 + const char *candidate_identifier)
174 StunMessageReturn val;
176 stun_agent_init_request (agent, msg, buffer, buffer_len, STUN_BINDING);
178 - if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_RFC5245) {
179 + if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_RFC5245 ||
180 + compatibility == STUN_USAGE_ICE_COMPATIBILITY_OC2007R2) {
181 if (cand_use)
183 val = stun_message_append_flag (msg, STUN_ATTRIBUTE_USE_CANDIDATE);
184 @@ -95,6 +98,28 @@
185 username, username_len);
186 if (val != STUN_MESSAGE_RETURN_SUCCESS)
187 return 0;
190 + if (compatibility == STUN_USAGE_ICE_COMPATIBILITY_OC2007R2) {
191 + size_t identifier_len = strlen(candidate_identifier);
192 + size_t buffer_len = identifier_len;
193 + int modulo4 = identifier_len % 4;
194 + uint8_t* buf;
196 + if (modulo4)
197 + buffer_len += 4 - modulo4;
199 + buf = malloc(buffer_len);
200 + memset(buf, 0, buffer_len);
201 + memcpy(buf, candidate_identifier, identifier_len);
203 + val = stun_message_append_bytes (msg, STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER,
204 + buf, buffer_len);
206 + free(buf);
208 + if (val != STUN_MESSAGE_RETURN_SUCCESS)
209 + return 0;
212 return stun_agent_finish_message (agent, msg, password, password_len);
214 --- a/stun/stunmessage.h
215 +++ b/stun/stunmessage.h
216 @@ -218,6 +218,8 @@
217 * defined by ICE draft 19
218 * @STUN_ATTRIBUTE_ICE_CONTROLLING: The ICE-CONTROLLING optional attribute as
219 * defined by ICE draft 19
220 + * @STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER: The CANDIDATE-IDENTIFIER attribute as
221 + * defined by [MS-ICE2]
223 * Known STUN attribute types as defined by various RFCs and drafts
225 @@ -288,7 +290,9 @@
226 STUN_ATTRIBUTE_FINGERPRINT=0x8028, /* RFC5389 */
227 STUN_ATTRIBUTE_ICE_CONTROLLED=0x8029, /* ICE-19 */
228 STUN_ATTRIBUTE_ICE_CONTROLLING=0x802A, /* ICE-19 */
229 - /* 0x802B-0xFFFF */ /* reserved */
230 + /* 0x802B-0x8053 */ /* reserved */
231 + STUN_ATTRIBUTE_CANDIDATE_IDENTIFIER=0x8054 /* MS-ICE2 */
232 + /* 0x8055-0xFFFF */ /* reserved */
233 } StunAttribute;