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

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

Issue 1856943002: Allow TransportController to create a QuicTransportChannel (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fix dtlstransport.h Created 4 years, 8 months 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
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // creation, we have the negotiation state saved until a new 393 // creation, we have the negotiation state saved until a new
394 // negotiation happens. 394 // negotiation happens.
395 for (const auto& kv : channels_) { 395 for (const auto& kv : channels_) {
396 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) { 396 if (!ApplyNegotiatedTransportDescription(kv.second, error_desc)) {
397 return false; 397 return false;
398 } 398 }
399 } 399 }
400 return true; 400 return true;
401 } 401 }
402 402
403 bool Transport::VerifyCertificateFingerprint(
404 const rtc::RTCCertificate* certificate,
405 const rtc::SSLFingerprint* local_fingerprint,
406 std::string* error_desc) const {
407 if (!local_fingerprint) {
408 return BadTransportDescription("No Local fingerprint.", error_desc);
pthatcher1 2016/04/12 23:26:59 Here to, perhaps just stay "no fingerprint" and "f
mikescarlett 2016/04/13 00:58:24 Done.
409 }
410 if (!certificate) {
411 return BadTransportDescription(
412 "Local fingerprint provided but no identity available.", error_desc);
413 }
414 rtc::scoped_ptr<rtc::SSLFingerprint> local_fp_tmp(rtc::SSLFingerprint::Create(
415 local_fingerprint->algorithm, certificate->identity()));
416 ASSERT(local_fp_tmp.get() != NULL);
417 if (*local_fp_tmp == *local_fingerprint) {
418 return true;
419 }
420 std::ostringstream desc;
421 desc << "Local fingerprint does not match identity. Expected: ";
422 desc << local_fp_tmp->ToString();
423 desc << " Got: " << local_fingerprint->ToString();
424 return BadTransportDescription(desc.str(), error_desc);
425 }
426
427 bool Transport::NegotiateRole(ContentAction local_role,
428 rtc::SSLRole* ssl_role,
429 std::string* error_desc) const {
430 if (!local_description() || !remote_description()) {
431 const std::string msg =
432 "Local and Remote description must be set before "
433 "transport descriptions are negotiated";
434 return BadTransportDescription(msg, error_desc);
435 }
436
437 // From RFC 4145, section-4.1, The following are the values that the
438 // 'setup' attribute can take in an offer/answer exchange:
439 // Offer Answer
440 // ________________
441 // active passive / holdconn
442 // passive active / holdconn
443 // actpass active / passive / holdconn
444 // holdconn holdconn
445 //
446 // Set the role that is most conformant with RFC 5763, Section 5, bullet 1
447 // The endpoint MUST use the setup attribute defined in [RFC4145].
448 // The endpoint that is the offerer MUST use the setup attribute
449 // value of setup:actpass and be prepared to receive a client_hello
450 // before it receives the answer. The answerer MUST use either a
451 // setup attribute value of setup:active or setup:passive. Note that
452 // if the answerer uses setup:passive, then the DTLS handshake will
453 // not begin until the answerer is received, which adds additional
454 // latency. setup:active allows the answer and the DTLS handshake to
455 // occur in parallel. Thus, setup:active is RECOMMENDED. Whichever
456 // party is active MUST initiate a DTLS handshake by sending a
457 // ClientHello over each flow (host/port quartet).
458 // IOW - actpass and passive modes should be treated as server and
459 // active as client.
460 ConnectionRole local_connection_role = local_description()->connection_role;
461 ConnectionRole remote_connection_role = remote_description()->connection_role;
462
463 bool is_remote_server = false;
464 if (local_role == CA_OFFER) {
465 if (local_connection_role != CONNECTIONROLE_ACTPASS) {
466 return BadTransportDescription(
467 "Offerer must use actpass value for setup attribute.", error_desc);
468 }
469
470 if (remote_connection_role == CONNECTIONROLE_ACTIVE ||
471 remote_connection_role == CONNECTIONROLE_PASSIVE ||
472 remote_connection_role == CONNECTIONROLE_NONE) {
473 is_remote_server = (remote_connection_role == CONNECTIONROLE_PASSIVE);
474 } else {
475 const std::string msg =
476 "Answerer must use either active or passive value "
477 "for setup attribute.";
478 return BadTransportDescription(msg, error_desc);
479 }
480 // If remote is NONE or ACTIVE it will act as client.
481 } else {
482 if (remote_connection_role != CONNECTIONROLE_ACTPASS &&
483 remote_connection_role != CONNECTIONROLE_NONE) {
484 return BadTransportDescription(
485 "Offerer must use actpass value for setup attribute.", error_desc);
486 }
487
488 if (local_connection_role == CONNECTIONROLE_ACTIVE ||
489 local_connection_role == CONNECTIONROLE_PASSIVE) {
490 is_remote_server = (local_connection_role == CONNECTIONROLE_ACTIVE);
491 } else {
492 const std::string msg =
493 "Answerer must use either active or passive value "
494 "for setup attribute.";
495 return BadTransportDescription(msg, error_desc);
496 }
497
498 // If local is passive, local will act as server.
499 }
500
501 *ssl_role = is_remote_server ? rtc::SSL_CLIENT : rtc::SSL_SERVER;
502 return true;
503 }
504
403 } // namespace cricket 505 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698