OLD | NEW |
---|---|
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 Loading... | |
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 } else { | |
626 // TODO(honghaiz): Delete this once no client sends this attribute. | |
627 const StunUInt32Attribute* cost_attr = | |
628 stun_msg->GetUInt32(STUN_ATTR_NETWORK_COST); | |
629 network_cost = | |
630 (cost_attr) ? static_cast<uint16_t>(cost_attr->value()) : 0; | |
pthatcher1
2016/03/21 17:49:24
Why can't we just have it be the same attribute, b
honghaiz3
2016/03/22 16:30:03
If a new client talks to an old client, the old c
pthatcher1
2016/03/22 21:12:09
I think since the network cost is signalled, and t
honghaiz3
2016/03/23 18:59:33
Done.
| |
631 } | |
620 | 632 |
621 // RFC 5245 | 633 // RFC 5245 |
622 // If the source transport address of the request does not match any | 634 // If the source transport address of the request does not match any |
623 // existing remote candidates, it represents a new peer reflexive remote | 635 // existing remote candidates, it represents a new peer reflexive remote |
624 // candidate. | 636 // candidate. |
625 remote_candidate = Candidate(component(), ProtoToString(proto), address, 0, | 637 remote_candidate = Candidate( |
626 remote_username, remote_password, | 638 component(), ProtoToString(proto), address, remote_candidate_priority, |
627 PRFLX_PORT_TYPE, remote_generation, ""); | 639 remote_username, remote_password, PRFLX_PORT_TYPE, remote_generation, |
640 "", network_id, network_cost); | |
628 | 641 |
629 // From RFC 5245, section-7.2.1.3: | 642 // From RFC 5245, section-7.2.1.3: |
630 // The foundation of the candidate is set to an arbitrary value, different | 643 // The foundation of the candidate is set to an arbitrary value, different |
631 // from the foundation for all other remote candidates. | 644 // from the foundation for all other remote candidates. |
632 remote_candidate.set_foundation( | 645 remote_candidate.set_foundation( |
633 rtc::ToString<uint32_t>(rtc::ComputeCrc32(remote_candidate.id()))); | 646 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 } | 647 } |
637 | 648 |
638 // RFC5245, the agent constructs a pair whose local candidate is equal to | 649 // 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 | 650 // the transport address on which the STUN request was received, and a |
640 // remote candidate equal to the source transport address where the | 651 // remote candidate equal to the source transport address where the |
641 // request came from. | 652 // request came from. |
642 | 653 |
643 // There shouldn't be an existing connection with this remote address. | 654 // There shouldn't be an existing connection with this remote address. |
644 // When ports are muxed, this channel might get multiple unknown address | 655 // When ports are muxed, this channel might get multiple unknown address |
645 // signals. In that case if the connection is already exists, we should | 656 // signals. In that case if the connection is already exists, we should |
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1614 | 1625 |
1615 // During the initial state when nothing has been pinged yet, return the first | 1626 // During the initial state when nothing has been pinged yet, return the first |
1616 // one in the ordered |connections_|. | 1627 // one in the ordered |connections_|. |
1617 return *(std::find_if(connections_.begin(), connections_.end(), | 1628 return *(std::find_if(connections_.begin(), connections_.end(), |
1618 [conn1, conn2](Connection* conn) { | 1629 [conn1, conn2](Connection* conn) { |
1619 return conn == conn1 || conn == conn2; | 1630 return conn == conn1 || conn == conn2; |
1620 })); | 1631 })); |
1621 } | 1632 } |
1622 | 1633 |
1623 } // namespace cricket | 1634 } // namespace cricket |
OLD | NEW |