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

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

Issue 2086793002: Set the generation on peer reflexive candidates when created. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 PortInterface* port, 567 PortInterface* port,
568 const rtc::SocketAddress& address, ProtocolType proto, 568 const rtc::SocketAddress& address, ProtocolType proto,
569 IceMessage* stun_msg, const std::string &remote_username, 569 IceMessage* stun_msg, const std::string &remote_username,
570 bool port_muxed) { 570 bool port_muxed) {
571 ASSERT(worker_thread_ == rtc::Thread::Current()); 571 ASSERT(worker_thread_ == rtc::Thread::Current());
572 572
573 // Port has received a valid stun packet from an address that no Connection 573 // Port has received a valid stun packet from an address that no Connection
574 // is currently available for. See if we already have a candidate with the 574 // is currently available for. See if we already have a candidate with the
575 // address. If it isn't we need to create new candidate for it. 575 // address. If it isn't we need to create new candidate for it.
576 576
577 // Determine if the remote candidates use shared ufrag. 577 const Candidate* candidate = nullptr;
Taylor Brandstetter 2016/06/21 01:53:10 This is code to handle the "disable shared ufrag"
578 bool ufrag_per_port = false; 578 for (const Candidate& c : remote_candidates_) {
579 std::vector<RemoteCandidate>::iterator it; 579 if (c.username() == remote_username && c.address() == address &&
580 if (remote_candidates_.size() > 0) { 580 c.protocol() == ProtoToString(proto)) {
581 it = remote_candidates_.begin(); 581 candidate = &c;
582 std::string username = it->username(); 582 break;
583 for (; it != remote_candidates_.end(); ++it) {
584 if (it->username() != username) {
585 ufrag_per_port = true;
586 break;
587 }
588 }
589 }
590
591 const Candidate* candidate = NULL;
592 std::string remote_password;
593 for (it = remote_candidates_.begin(); it != remote_candidates_.end(); ++it) {
594 if (it->username() == remote_username) {
595 remote_password = it->password();
596 if (ufrag_per_port ||
597 (it->address() == address &&
598 it->protocol() == ProtoToString(proto))) {
599 candidate = &(*it);
600 break;
601 }
602 // We don't want to break here because we may find a match of the address
603 // later.
604 } 583 }
605 } 584 }
606 585
607 uint32_t remote_generation = 0; 586 uint32_t remote_generation = 0;
587 std::string remote_password;
608 // The STUN binding request may arrive after setRemoteDescription and before 588 // The STUN binding request may arrive after setRemoteDescription and before
609 // adding remote candidate, so we need to set the password to the shared 589 // adding remote candidate, so we need to set the password to the shared
610 // password if the user name matches. 590 // password and set the generation if the user name matches.
611 if (remote_password.empty()) { 591 const IceParameters* ice_param =
612 const IceParameters* ice_param = 592 FindRemoteIceFromUfrag(remote_username, &remote_generation);
613 FindRemoteIceFromUfrag(remote_username, &remote_generation); 593 // Note: if not found, the remote_generation will still be 0.
614 // Note: if not found, the remote_generation will still be 0. 594 if (ice_param != nullptr) {
615 if (ice_param != nullptr) { 595 remote_password = ice_param->pwd;
616 remote_password = ice_param->pwd;
617 }
618 } 596 }
619 597
620 Candidate remote_candidate; 598 Candidate remote_candidate;
621 bool remote_candidate_is_new = (candidate == nullptr); 599 bool remote_candidate_is_new = (candidate == nullptr);
622 if (!remote_candidate_is_new) { 600 if (!remote_candidate_is_new) {
623 remote_candidate = *candidate; 601 remote_candidate = *candidate;
624 if (ufrag_per_port) {
625 remote_candidate.set_address(address);
626 }
627 } else { 602 } else {
628 // Create a new candidate with this address. 603 // Create a new candidate with this address.
629 // The priority of the candidate is set to the PRIORITY attribute 604 // The priority of the candidate is set to the PRIORITY attribute
630 // from the request. 605 // from the request.
631 const StunUInt32Attribute* priority_attr = 606 const StunUInt32Attribute* priority_attr =
632 stun_msg->GetUInt32(STUN_ATTR_PRIORITY); 607 stun_msg->GetUInt32(STUN_ATTR_PRIORITY);
633 if (!priority_attr) { 608 if (!priority_attr) {
634 LOG(LS_WARNING) << "P2PTransportChannel::OnUnknownAddress - " 609 LOG(LS_WARNING) << "P2PTransportChannel::OnUnknownAddress - "
635 << "No STUN_ATTR_PRIORITY found in the " 610 << "No STUN_ATTR_PRIORITY found in the "
636 << "stun request message"; 611 << "stun request message";
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after
1693 1668
1694 // During the initial state when nothing has been pinged yet, return the first 1669 // During the initial state when nothing has been pinged yet, return the first
1695 // one in the ordered |connections_|. 1670 // one in the ordered |connections_|.
1696 return *(std::find_if(connections_.begin(), connections_.end(), 1671 return *(std::find_if(connections_.begin(), connections_.end(),
1697 [conn1, conn2](Connection* conn) { 1672 [conn1, conn2](Connection* conn) {
1698 return conn == conn1 || conn == conn2; 1673 return conn == conn1 || conn == conn2;
1699 })); 1674 }));
1700 } 1675 }
1701 1676
1702 } // namespace cricket 1677 } // namespace cricket
OLDNEW
« no previous file with comments | « no previous file | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698