Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: webrtc/p2p/base/transport.cc

Issue 2517883002: Refactoring that removes P2PTransport and DtlsTransport classes. (Closed)
Patch Set: Leaving comments about what we'd need to do to support QUIC again. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <memory> 11 #include <memory>
12 #include <utility> // for std::pair 12 #include <utility> // for std::pair
13 13
14 #include "webrtc/p2p/base/transport.h" 14 #include "webrtc/p2p/base/transport.h"
15 15
16 #include "webrtc/p2p/base/candidate.h" 16 #include "webrtc/p2p/base/candidate.h"
17 #include "webrtc/p2p/base/dtlstransportchannel.h"
17 #include "webrtc/p2p/base/p2pconstants.h" 18 #include "webrtc/p2p/base/p2pconstants.h"
19 #include "webrtc/p2p/base/p2ptransportchannel.h"
18 #include "webrtc/p2p/base/port.h" 20 #include "webrtc/p2p/base/port.h"
19 #include "webrtc/p2p/base/transportchannelimpl.h" 21 #include "webrtc/p2p/base/transportchannelimpl.h"
20 #include "webrtc/base/bind.h" 22 #include "webrtc/base/bind.h"
21 #include "webrtc/base/checks.h" 23 #include "webrtc/base/checks.h"
22 #include "webrtc/base/logging.h" 24 #include "webrtc/base/logging.h"
23 25
24 namespace cricket { 26 namespace cricket {
25 27
26 static bool VerifyIceParams(const TransportDescription& desc) { 28 static bool VerifyIceParams(const TransportDescription& desc) {
27 // For legacy protocols. 29 // For legacy protocols.
(...skipping 23 matching lines...) Expand all
51 const std::string& old_pwd, 53 const std::string& old_pwd,
52 const std::string& new_ufrag, 54 const std::string& new_ufrag,
53 const std::string& new_pwd) { 55 const std::string& new_pwd) {
54 // The standard (RFC 5245 Section 9.1.1.1) says that ICE restarts MUST change 56 // The standard (RFC 5245 Section 9.1.1.1) says that ICE restarts MUST change
55 // both the ufrag and password. However, section 9.2.1.1 says changing the 57 // both the ufrag and password. However, section 9.2.1.1 says changing the
56 // ufrag OR password indicates an ICE restart. So, to keep compatibility with 58 // ufrag OR password indicates an ICE restart. So, to keep compatibility with
57 // endpoints that only change one, we'll treat this as an ICE restart. 59 // endpoints that only change one, we'll treat this as an ICE restart.
58 return (old_ufrag != new_ufrag) || (old_pwd != new_pwd); 60 return (old_ufrag != new_ufrag) || (old_pwd != new_pwd);
59 } 61 }
60 62
61 Transport::Transport(const std::string& name, PortAllocator* allocator) 63 bool VerifyCandidate(const Candidate& cand, std::string* error) {
62 : name_(name), allocator_(allocator) {} 64 // No address zero.
65 if (cand.address().IsNil() || cand.address().IsAnyIP()) {
66 *error = "candidate has address of zero";
67 return false;
68 }
63 69
64 Transport::~Transport() { 70 // Disallow all ports below 1024, except for 80 and 443 on public addresses.
65 RTC_DCHECK(channels_destroyed_); 71 int port = cand.address().port();
72 if (cand.protocol() == TCP_PROTOCOL_NAME &&
73 (cand.tcptype() == TCPTYPE_ACTIVE_STR || port == 0)) {
74 // Expected for active-only candidates per
75 // http://tools.ietf.org/html/rfc6544#section-4.5 so no error.
76 // Libjingle clients emit port 0, in "active" mode.
77 return true;
78 }
79 if (port < 1024) {
80 if ((port != 80) && (port != 443)) {
81 *error = "candidate has port below 1024, but not 80 or 443";
82 return false;
83 }
84
85 if (cand.address().IsPrivateIP()) {
86 *error = "candidate has port of 80 or 443 with private IP address";
87 return false;
88 }
89 }
90
91 return true;
66 } 92 }
67 93
68 void Transport::SetIceRole(IceRole role) { 94 bool VerifyCandidates(const Candidates& candidates, std::string* error) {
69 ice_role_ = role; 95 for (const Candidate& candidate : candidates) {
70 for (const auto& kv : channels_) { 96 if (!VerifyCandidate(candidate, error)) {
71 kv.second->SetIceRole(ice_role_); 97 return false;
98 }
72 } 99 }
100 return true;
73 } 101 }
74 102
75 std::unique_ptr<rtc::SSLCertificate> Transport::GetRemoteSSLCertificate() { 103 Transport::Transport(const std::string& name,
76 if (channels_.empty()) { 104 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate)
77 return nullptr; 105 : name_(name), certificate_(certificate) {}
106
107 bool Transport::AddChannel(TransportChannelImpl* dtls,
108 TransportChannelImpl* ice,
109 int component) {
110 if (channels_.find(component) != channels_.end()) {
111 LOG(LS_ERROR) << "Adding channel for component " << component << " twice.";
112 return false;
113 }
114 channels_[component] = ChannelPair{dtls, ice};
115 // Something's wrong if a channel is being added after a description is set.
116 // This may currently occur if rtcp-mux is negotiated, then a new m= section
117 // is added in a later offer/answer. But this is suboptimal and should be
118 // changed; we shouldn't support going from muxed to non-muxed.
119 if (local_description_set_ || remote_description_set_) {
120 LOG(LS_WARNING) << "Adding new transport channel after "
121 "transport description already applied.";
122 }
123 bool ret = true;
124 std::string err;
125 if (local_description_set_) {
126 ret &= ApplyLocalTransportDescription(channels_[component], &err);
127 }
128 if (remote_description_set_) {
129 ret &= ApplyRemoteTransportDescription(channels_[component], &err);
130 }
131 if (local_description_set_ && remote_description_set_) {
132 ret &= ApplyNegotiatedTransportDescription(channels_[component], &err);
133 }
134 return ret;
135 }
136
137 bool Transport::RemoveChannel(int component) {
138 auto it = channels_.find(component);
139 if (it == channels_.end()) {
140 LOG(LS_ERROR) << "Trying to remove channel for component " << component
141 << ", which doesn't exist.";
142 return false;
143 }
144 channels_.erase(component);
145 return true;
146 }
147
148 bool Transport::HasChannels() const {
149 return !channels_.empty();
150 }
151
152 void Transport::SetLocalCertificate(
153 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
154 certificate_ = certificate;
155 }
156
157 bool Transport::GetLocalCertificate(
158 rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const {
159 if (!certificate_) {
160 return false;
78 } 161 }
79 162
80 auto iter = channels_.begin(); 163 *certificate = certificate_;
81 return iter->second->GetRemoteSSLCertificate(); 164 return true;
82 }
83
84 void Transport::SetIceConfig(const IceConfig& config) {
85 ice_config_ = config;
86 for (const auto& kv : channels_) {
87 kv.second->SetIceConfig(ice_config_);
88 }
89 } 165 }
90 166
91 bool Transport::SetLocalTransportDescription( 167 bool Transport::SetLocalTransportDescription(
92 const TransportDescription& description, 168 const TransportDescription& description,
93 ContentAction action, 169 ContentAction action,
94 std::string* error_desc) { 170 std::string* error_desc) {
95 bool ret = true; 171 bool ret = true;
96 172
97 if (!VerifyIceParams(description)) { 173 if (!VerifyIceParams(description)) {
98 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length", 174 return BadTransportDescription("Invalid ice-ufrag or ice-pwd length",
99 error_desc); 175 error_desc);
100 } 176 }
101 177
102 local_description_.reset(new TransportDescription(description)); 178 local_description_.reset(new TransportDescription(description));
103 179
180 rtc::SSLFingerprint* local_fp =
181 local_description_->identity_fingerprint.get();
182
183 if (!local_fp) {
184 certificate_ = nullptr;
185 } else if (!VerifyCertificateFingerprint(certificate_.get(), local_fp,
186 error_desc)) {
187 return false;
188 }
189
104 for (const auto& kv : channels_) { 190 for (const auto& kv : channels_) {
105 ret &= ApplyLocalTransportDescription(kv.second, error_desc); 191 ret &= ApplyLocalTransportDescription(kv.second, error_desc);
106 } 192 }
107 if (!ret) { 193 if (!ret) {
108 return false; 194 return false;
109 } 195 }
110 196
111 // If PRANSWER/ANSWER is set, we should decide transport protocol type. 197 // If PRANSWER/ANSWER is set, we should decide transport protocol type.
112 if (action == CA_PRANSWER || action == CA_ANSWER) { 198 if (action == CA_PRANSWER || action == CA_ANSWER) {
113 ret &= NegotiateTransportDescription(action, error_desc); 199 ret &= NegotiateTransportDescription(action, error_desc);
(...skipping 25 matching lines...) Expand all
139 if (action == CA_PRANSWER || action == CA_ANSWER) { 225 if (action == CA_PRANSWER || action == CA_ANSWER) {
140 ret = NegotiateTransportDescription(CA_OFFER, error_desc); 226 ret = NegotiateTransportDescription(CA_OFFER, error_desc);
141 } 227 }
142 if (ret) { 228 if (ret) {
143 remote_description_set_ = true; 229 remote_description_set_ = true;
144 } 230 }
145 231
146 return ret; 232 return ret;
147 } 233 }
148 234
149 TransportChannelImpl* Transport::CreateChannel(int component) { 235 void Transport::GetSslRole(rtc::SSLRole* ssl_role) const {
150 TransportChannelImpl* channel; 236 RTC_DCHECK(ssl_role);
151 237 *ssl_role = secure_role_;
152 // Create the entry if it does not exist.
153 bool channel_exists = false;
154 auto iter = channels_.find(component);
155 if (iter == channels_.end()) {
156 channel = CreateTransportChannel(component);
157 channels_.insert(std::pair<int, TransportChannelImpl*>(component, channel));
158 } else {
159 channel = iter->second;
160 channel_exists = true;
161 }
162
163 channels_destroyed_ = false;
164
165 if (channel_exists) {
166 // If this is an existing channel, we should just return it.
167 return channel;
168 }
169
170 // Push down our transport state to the new channel.
171 channel->SetIceRole(ice_role_);
172 channel->SetIceTiebreaker(tiebreaker_);
173 channel->SetIceConfig(ice_config_);
174 // TODO(ronghuawu): Change CreateChannel to be able to return error since
175 // below Apply**Description calls can fail.
176 if (local_description_)
177 ApplyLocalTransportDescription(channel, nullptr);
178 if (remote_description_)
179 ApplyRemoteTransportDescription(channel, nullptr);
180 if (local_description_ && remote_description_)
181 ApplyNegotiatedTransportDescription(channel, nullptr);
182
183 return channel;
184 } 238 }
185 239
186 TransportChannelImpl* Transport::GetChannel(int component) { 240 bool Transport::GetStats(TransportStats* stats) const {
187 auto iter = channels_.find(component);
188 return (iter != channels_.end()) ? iter->second : nullptr;
189 }
190
191 bool Transport::HasChannels() {
192 return !channels_.empty();
193 }
194
195 void Transport::DestroyChannel(int component) {
196 auto iter = channels_.find(component);
197 if (iter == channels_.end())
198 return;
199
200 TransportChannelImpl* channel = iter->second;
201 channels_.erase(iter);
202 DestroyTransportChannel(channel);
203 }
204
205 void Transport::MaybeStartGathering() {
206 CallChannels(&TransportChannelImpl::MaybeStartGathering);
207 }
208
209 void Transport::DestroyAllChannels() {
210 for (const auto& kv : channels_) {
211 DestroyTransportChannel(kv.second);
212 }
213 channels_.clear();
214 channels_destroyed_ = true;
215 }
216
217 void Transport::CallChannels(TransportChannelFunc func) {
218 for (const auto& kv : channels_) {
219 (kv.second->*func)();
220 }
221 }
222
223 bool Transport::VerifyCandidate(const Candidate& cand, std::string* error) {
224 // No address zero.
225 if (cand.address().IsNil() || cand.address().IsAnyIP()) {
226 *error = "candidate has address of zero";
227 return false;
228 }
229
230 // Disallow all ports below 1024, except for 80 and 443 on public addresses.
231 int port = cand.address().port();
232 if (cand.protocol() == TCP_PROTOCOL_NAME &&
233 (cand.tcptype() == TCPTYPE_ACTIVE_STR || port == 0)) {
234 // Expected for active-only candidates per
235 // http://tools.ietf.org/html/rfc6544#section-4.5 so no error.
236 // Libjingle clients emit port 0, in "active" mode.
237 return true;
238 }
239 if (port < 1024) {
240 if ((port != 80) && (port != 443)) {
241 *error = "candidate has port below 1024, but not 80 or 443";
242 return false;
243 }
244
245 if (cand.address().IsPrivateIP()) {
246 *error = "candidate has port of 80 or 443 with private IP address";
247 return false;
248 }
249 }
250
251 if (!HasChannel(cand.component())) {
252 *error = "Candidate has an unknown component: " + cand.ToString() +
253 " for content: " + name();
254 return false;
255 }
256
257 return true;
258 }
259
260 bool Transport::VerifyCandidates(const Candidates& candidates,
261 std::string* error) {
262 for (const Candidate& candidate : candidates) {
263 if (!VerifyCandidate(candidate, error)) {
264 return false;
265 }
266 }
267 return true;
268 }
269
270
271 bool Transport::GetStats(TransportStats* stats) {
272 stats->transport_name = name(); 241 stats->transport_name = name();
273 stats->channel_stats.clear(); 242 stats->channel_stats.clear();
274 for (auto kv : channels_) { 243 for (const auto& kv : channels_) {
275 TransportChannelImpl* channel = kv.second; 244 const ChannelPair& channel = kv.second;
276 TransportChannelStats substats; 245 TransportChannelStats substats;
277 substats.component = channel->component(); 246 substats.component = kv.first;
278 channel->GetSrtpCryptoSuite(&substats.srtp_crypto_suite); 247 channel.dtls->GetSrtpCryptoSuite(&substats.srtp_crypto_suite);
279 channel->GetSslCipherSuite(&substats.ssl_cipher_suite); 248 channel.dtls->GetSslCipherSuite(&substats.ssl_cipher_suite);
280 if (!channel->GetStats(&substats.connection_infos)) { 249 if (!channel.dtls->GetStats(&substats.connection_infos)) {
281 return false; 250 return false;
282 } 251 }
283 stats->channel_stats.push_back(substats); 252 stats->channel_stats.push_back(substats);
284 } 253 }
285 return true; 254 return true;
286 } 255 }
287 256
288 bool Transport::AddRemoteCandidates(const std::vector<Candidate>& candidates, 257 bool Transport::VerifyCertificateFingerprint(
289 std::string* error) { 258 const rtc::RTCCertificate* certificate,
290 ASSERT(!channels_destroyed_); 259 const rtc::SSLFingerprint* fingerprint,
291 // Verify each candidate before passing down to the transport layer. 260 std::string* error_desc) const {
292 if (!VerifyCandidates(candidates, error)) { 261 if (!fingerprint) {
293 return false; 262 return BadTransportDescription("No fingerprint.", error_desc);
294 } 263 }
264 if (!certificate) {
265 return BadTransportDescription(
266 "Fingerprint provided but no identity available.", error_desc);
267 }
268 std::unique_ptr<rtc::SSLFingerprint> fp_tmp(rtc::SSLFingerprint::Create(
269 fingerprint->algorithm, certificate->identity()));
270 ASSERT(fp_tmp.get() != NULL);
271 if (*fp_tmp == *fingerprint) {
272 return true;
273 }
274 std::ostringstream desc;
275 desc << "Local fingerprint does not match identity. Expected: ";
276 desc << fp_tmp->ToString();
277 desc << " Got: " << fingerprint->ToString();
278 return BadTransportDescription(desc.str(), error_desc);
279 }
295 280
296 for (const Candidate& candidate : candidates) { 281 bool Transport::ApplyLocalTransportDescription(const ChannelPair& channel,
297 TransportChannelImpl* channel = GetChannel(candidate.component()); 282 std::string* error_desc) {
298 if (channel != nullptr) { 283 channel.dtls->SetIceParameters(local_description_->GetIceParameters());
299 channel->AddRemoteCandidate(candidate);
300 }
301 }
302 return true; 284 return true;
303 } 285 }
304 286
305 bool Transport::RemoveRemoteCandidates(const std::vector<Candidate>& candidates, 287 bool Transport::ApplyRemoteTransportDescription(const ChannelPair& channel,
306 std::string* error) { 288 std::string* error_desc) {
307 ASSERT(!channels_destroyed_); 289 channel.dtls->SetRemoteIceParameters(remote_description_->GetIceParameters());
308 // Verify each candidate before passing down to the transport layer. 290 channel.dtls->SetRemoteIceMode(remote_description_->ice_mode);
309 if (!VerifyCandidates(candidates, error)) {
310 return false;
311 }
312
313 for (const Candidate& candidate : candidates) {
314 TransportChannelImpl* channel = GetChannel(candidate.component());
315 if (channel != nullptr) {
316 channel->RemoveRemoteCandidate(candidate);
317 }
318 }
319 return true; 291 return true;
320 } 292 }
321 293
322 bool Transport::ApplyLocalTransportDescription(TransportChannelImpl* ch, 294 bool Transport::ApplyNegotiatedTransportDescription(const ChannelPair& channel,
323 std::string* error_desc) { 295 std::string* error_desc) {
324 ch->SetIceParameters(local_description_->GetIceParameters()); 296 // Set SSL role. Role must be set before fingerprint is applied, which
325 return true; 297 // initiates DTLS setup.
326 } 298 if (!channel.dtls->SetSslRole(secure_role_)) {
327 299 return BadTransportDescription("Failed to set SSL role for the channel.",
328 bool Transport::ApplyRemoteTransportDescription(TransportChannelImpl* ch, 300 error_desc);
329 std::string* error_desc) { 301 }
330 ch->SetRemoteIceParameters(remote_description_->GetIceParameters()); 302 // Apply remote fingerprint.
331 return true; 303 if (!channel.dtls->SetRemoteFingerprint(
332 } 304 remote_fingerprint_->algorithm,
333 305 reinterpret_cast<const uint8_t*>(remote_fingerprint_->digest.data()),
334 bool Transport::ApplyNegotiatedTransportDescription( 306 remote_fingerprint_->digest.size())) {
335 TransportChannelImpl* channel, 307 return BadTransportDescription("Failed to apply remote fingerprint.",
336 std::string* error_desc) { 308 error_desc);
337 channel->SetRemoteIceMode(remote_ice_mode_); 309 }
338 return true; 310 return true;
339 } 311 }
340 312
341 bool Transport::NegotiateTransportDescription(ContentAction local_role, 313 bool Transport::NegotiateTransportDescription(ContentAction local_role,
342 std::string* error_desc) { 314 std::string* error_desc) {
343 // TODO(ekr@rtfm.com): This is ICE-specific stuff. Refactor into 315 if (!local_description_ || !remote_description_) {
344 // P2PTransport. 316 const std::string msg =
345 317 "Applying an answer transport description "
346 // If transport is in ICEROLE_CONTROLLED and remote end point supports only 318 "without applying any offer.";
347 // ice_lite, this local end point should take CONTROLLING role. 319 return BadTransportDescription(msg, error_desc);
348 if (ice_role_ == ICEROLE_CONTROLLED &&
349 remote_description_->ice_mode == ICEMODE_LITE) {
350 SetIceRole(ICEROLE_CONTROLLING);
351 } 320 }
352 321 rtc::SSLFingerprint* local_fp =
353 // Update remote ice_mode to all existing channels. 322 local_description_->identity_fingerprint.get();
354 remote_ice_mode_ = remote_description_->ice_mode; 323 rtc::SSLFingerprint* remote_fp =
355 324 remote_description_->identity_fingerprint.get();
325 if (remote_fp && local_fp) {
326 remote_fingerprint_.reset(new rtc::SSLFingerprint(*remote_fp));
327 if (!NegotiateRole(local_role, &secure_role_, error_desc)) {
328 return false;
329 }
330 } else if (local_fp && (local_role == CA_ANSWER)) {
331 return BadTransportDescription(
332 "Local fingerprint supplied when caller didn't offer DTLS.",
333 error_desc);
334 } else {
335 // We are not doing DTLS
336 remote_fingerprint_.reset(new rtc::SSLFingerprint("", nullptr, 0));
337 }
356 // Now that we have negotiated everything, push it downward. 338 // Now that we have negotiated everything, push it downward.
357 // Note that we cache the result so that if we have race conditions 339 // Note that we cache the result so that if we have race conditions
358 // between future SetRemote/SetLocal invocations and new channel 340 // between future SetRemote/SetLocal invocations and new channel
359 // creation, we have the negotiation state saved until a new 341 // creation, we have the negotiation state saved until a new
360 // negotiation happens. 342 // negotiation happens.
361 for (const auto& kv : channels_) { 343 for (const auto& kv : channels_) {
362 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) { 344 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) {
363 return false; 345 return false;
364 } 346 }
365 } 347 }
366 return true; 348 return true;
367 } 349 }
368 350
369 bool Transport::VerifyCertificateFingerprint(
370 const rtc::RTCCertificate* certificate,
371 const rtc::SSLFingerprint* fingerprint,
372 std::string* error_desc) const {
373 if (!fingerprint) {
374 return BadTransportDescription("No fingerprint.", error_desc);
375 }
376 if (!certificate) {
377 return BadTransportDescription(
378 "Fingerprint provided but no identity available.", error_desc);
379 }
380 std::unique_ptr<rtc::SSLFingerprint> fp_tmp(rtc::SSLFingerprint::Create(
381 fingerprint->algorithm, certificate->identity()));
382 ASSERT(fp_tmp.get() != NULL);
383 if (*fp_tmp == *fingerprint) {
384 return true;
385 }
386 std::ostringstream desc;
387 desc << "Local fingerprint does not match identity. Expected: ";
388 desc << fp_tmp->ToString();
389 desc << " Got: " << fingerprint->ToString();
390 return BadTransportDescription(desc.str(), error_desc);
391 }
392
393 bool Transport::NegotiateRole(ContentAction local_role, 351 bool Transport::NegotiateRole(ContentAction local_role,
394 rtc::SSLRole* ssl_role, 352 rtc::SSLRole* ssl_role,
395 std::string* error_desc) const { 353 std::string* error_desc) const {
396 RTC_DCHECK(ssl_role); 354 RTC_DCHECK(ssl_role);
397 if (!local_description() || !remote_description()) { 355 if (!local_description_ || !remote_description_) {
398 const std::string msg = 356 const std::string msg =
399 "Local and Remote description must be set before " 357 "Local and Remote description must be set before "
400 "transport descriptions are negotiated"; 358 "transport descriptions are negotiated";
401 return BadTransportDescription(msg, error_desc); 359 return BadTransportDescription(msg, error_desc);
402 } 360 }
403 361
404 // From RFC 4145, section-4.1, The following are the values that the 362 // From RFC 4145, section-4.1, The following are the values that the
405 // 'setup' attribute can take in an offer/answer exchange: 363 // 'setup' attribute can take in an offer/answer exchange:
406 // Offer Answer 364 // Offer Answer
407 // ________________ 365 // ________________
408 // active passive / holdconn 366 // active passive / holdconn
409 // passive active / holdconn 367 // passive active / holdconn
410 // actpass active / passive / holdconn 368 // actpass active / passive / holdconn
411 // holdconn holdconn 369 // holdconn holdconn
412 // 370 //
413 // Set the role that is most conformant with RFC 5763, Section 5, bullet 1 371 // Set the role that is most conformant with RFC 5763, Section 5, bullet 1
414 // The endpoint MUST use the setup attribute defined in [RFC4145]. 372 // The endpoint MUST use the setup attribute defined in [RFC4145].
415 // The endpoint that is the offerer MUST use the setup attribute 373 // The endpoint that is the offerer MUST use the setup attribute
416 // value of setup:actpass and be prepared to receive a client_hello 374 // value of setup:actpass and be prepared to receive a client_hello
417 // before it receives the answer. The answerer MUST use either a 375 // before it receives the answer. The answerer MUST use either a
418 // setup attribute value of setup:active or setup:passive. Note that 376 // setup attribute value of setup:active or setup:passive. Note that
419 // if the answerer uses setup:passive, then the DTLS handshake will 377 // if the answerer uses setup:passive, then the DTLS handshake will
420 // not begin until the answerer is received, which adds additional 378 // not begin until the answerer is received, which adds additional
421 // latency. setup:active allows the answer and the DTLS handshake to 379 // latency. setup:active allows the answer and the DTLS handshake to
422 // occur in parallel. Thus, setup:active is RECOMMENDED. Whichever 380 // occur in parallel. Thus, setup:active is RECOMMENDED. Whichever
423 // party is active MUST initiate a DTLS handshake by sending a 381 // party is active MUST initiate a DTLS handshake by sending a
424 // ClientHello over each flow (host/port quartet). 382 // ClientHello over each flow (host/port quartet).
425 // IOW - actpass and passive modes should be treated as server and 383 // IOW - actpass and passive modes should be treated as server and
426 // active as client. 384 // active as client.
427 ConnectionRole local_connection_role = local_description()->connection_role; 385 ConnectionRole local_connection_role = local_description_->connection_role;
428 ConnectionRole remote_connection_role = remote_description()->connection_role; 386 ConnectionRole remote_connection_role = remote_description_->connection_role;
429 387
430 bool is_remote_server = false; 388 bool is_remote_server = false;
431 if (local_role == CA_OFFER) { 389 if (local_role == CA_OFFER) {
432 if (local_connection_role != CONNECTIONROLE_ACTPASS) { 390 if (local_connection_role != CONNECTIONROLE_ACTPASS) {
433 return BadTransportDescription( 391 return BadTransportDescription(
434 "Offerer must use actpass value for setup attribute.", error_desc); 392 "Offerer must use actpass value for setup attribute.", error_desc);
435 } 393 }
436 394
437 if (remote_connection_role == CONNECTIONROLE_ACTIVE || 395 if (remote_connection_role == CONNECTIONROLE_ACTIVE ||
438 remote_connection_role == CONNECTIONROLE_PASSIVE || 396 remote_connection_role == CONNECTIONROLE_PASSIVE ||
(...skipping 24 matching lines...) Expand all
463 } 421 }
464 422
465 // If local is passive, local will act as server. 423 // If local is passive, local will act as server.
466 } 424 }
467 425
468 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER; 426 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER;
469 return true; 427 return true;
470 } 428 }
471 429
472 } // namespace cricket 430 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698