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

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

Issue 1815473002: Add 16-bit network id to the candidate signaling. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Remove the old NETWORK_COST attribute. Created 4 years, 9 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
« no previous file with comments | « webrtc/p2p/base/candidate.h ('k') | webrtc/p2p/base/port.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 if (!priority_attr) { 607 if (!priority_attr) {
608 LOG(LS_WARNING) << "P2PTransportChannel::OnUnknownAddress - " 608 LOG(LS_WARNING) << "P2PTransportChannel::OnUnknownAddress - "
609 << "No STUN_ATTR_PRIORITY found in the " 609 << "No STUN_ATTR_PRIORITY found in the "
610 << "stun request message"; 610 << "stun request message";
611 port->SendBindingErrorResponse(stun_msg, address, STUN_ERROR_BAD_REQUEST, 611 port->SendBindingErrorResponse(stun_msg, address, STUN_ERROR_BAD_REQUEST,
612 STUN_ERROR_REASON_BAD_REQUEST); 612 STUN_ERROR_REASON_BAD_REQUEST);
613 return; 613 return;
614 } 614 }
615 int remote_candidate_priority = priority_attr->value(); 615 int remote_candidate_priority = priority_attr->value();
616 616
617 const StunUInt32Attribute* cost_attr = 617 uint16_t network_id = 0;
618 stun_msg->GetUInt32(STUN_ATTR_NETWORK_COST); 618 uint16_t network_cost = 0;
619 uint32_t network_cost = (cost_attr) ? cost_attr->value() : 0; 619 const StunUInt32Attribute* network_attr =
620 stun_msg->GetUInt32(STUN_ATTR_NETWORK_INFO);
621 if (network_attr) {
622 uint32_t network_info = network_attr->value();
623 network_id = static_cast<uint16_t>(network_info >> 16);
624 network_cost = static_cast<uint16_t>(network_info);
625 }
620 626
621 // RFC 5245 627 // RFC 5245
622 // If the source transport address of the request does not match any 628 // If the source transport address of the request does not match any
623 // existing remote candidates, it represents a new peer reflexive remote 629 // existing remote candidates, it represents a new peer reflexive remote
624 // candidate. 630 // candidate.
625 remote_candidate = Candidate(component(), ProtoToString(proto), address, 0, 631 remote_candidate = Candidate(
626 remote_username, remote_password, 632 component(), ProtoToString(proto), address, remote_candidate_priority,
627 PRFLX_PORT_TYPE, remote_generation, ""); 633 remote_username, remote_password, PRFLX_PORT_TYPE, remote_generation,
634 "", network_id, network_cost);
628 635
629 // From RFC 5245, section-7.2.1.3: 636 // From RFC 5245, section-7.2.1.3:
630 // The foundation of the candidate is set to an arbitrary value, different 637 // The foundation of the candidate is set to an arbitrary value, different
631 // from the foundation for all other remote candidates. 638 // from the foundation for all other remote candidates.
632 remote_candidate.set_foundation( 639 remote_candidate.set_foundation(
633 rtc::ToString<uint32_t>(rtc::ComputeCrc32(remote_candidate.id()))); 640 rtc::ToString<uint32_t>(rtc::ComputeCrc32(remote_candidate.id())));
634 remote_candidate.set_priority(remote_candidate_priority);
635 remote_candidate.set_network_cost(network_cost);
636 } 641 }
637 642
638 // RFC5245, the agent constructs a pair whose local candidate is equal to 643 // RFC5245, the agent constructs a pair whose local candidate is equal to
639 // the transport address on which the STUN request was received, and a 644 // the transport address on which the STUN request was received, and a
640 // remote candidate equal to the source transport address where the 645 // remote candidate equal to the source transport address where the
641 // request came from. 646 // request came from.
642 647
643 // There shouldn't be an existing connection with this remote address. 648 // There shouldn't be an existing connection with this remote address.
644 // When ports are muxed, this channel might get multiple unknown address 649 // When ports are muxed, this channel might get multiple unknown address
645 // signals. In that case if the connection is already exists, we should 650 // signals. In that case if the connection is already exists, we should
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 1619
1615 // During the initial state when nothing has been pinged yet, return the first 1620 // During the initial state when nothing has been pinged yet, return the first
1616 // one in the ordered |connections_|. 1621 // one in the ordered |connections_|.
1617 return *(std::find_if(connections_.begin(), connections_.end(), 1622 return *(std::find_if(connections_.begin(), connections_.end(),
1618 [conn1, conn2](Connection* conn) { 1623 [conn1, conn2](Connection* conn) {
1619 return conn == conn1 || conn == conn2; 1624 return conn == conn1 || conn == conn2;
1620 })); 1625 }));
1621 } 1626 }
1622 1627
1623 } // namespace cricket 1628 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/candidate.h ('k') | webrtc/p2p/base/port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698