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 1629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); | 1640 EXPECT_TRUE(msg->GetUInt32(STUN_ATTR_FINGERPRINT) != NULL); |
1641 EXPECT_TRUE(StunMessage::ValidateFingerprint( | 1641 EXPECT_TRUE(StunMessage::ValidateFingerprint( |
1642 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size())); | 1642 lport->last_stun_buf()->data<char>(), lport->last_stun_buf()->size())); |
1643 | 1643 |
1644 // Request should not include ping count. | 1644 // Request should not include ping count. |
1645 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); | 1645 ASSERT_TRUE(msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT) == NULL); |
1646 | 1646 |
1647 // Save a copy of the BINDING-REQUEST for use below. | 1647 // Save a copy of the BINDING-REQUEST for use below. |
1648 std::unique_ptr<IceMessage> request(CopyStunMessage(msg)); | 1648 std::unique_ptr<IceMessage> request(CopyStunMessage(msg)); |
1649 | 1649 |
1650 // Respond with a BINDING-RESPONSE. | 1650 // Receive the BINDING-REQUEST and respond with BINDING-RESPONSE. |
1651 rport->SendBindingResponse(request.get(), lport->Candidates()[0].address()); | 1651 rconn->OnReadPacket(lport->last_stun_buf()->data<char>(), |
| 1652 lport->last_stun_buf()->size(), rtc::PacketTime()); |
1652 msg = rport->last_stun_msg(); | 1653 msg = rport->last_stun_msg(); |
1653 ASSERT_TRUE(msg != NULL); | 1654 ASSERT_TRUE(msg != NULL); |
1654 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); | 1655 EXPECT_EQ(STUN_BINDING_RESPONSE, msg->type()); |
1655 | 1656 // Received a BINDING-RESPONSE. |
| 1657 lconn->OnReadPacket(rport->last_stun_buf()->data<char>(), |
| 1658 rport->last_stun_buf()->size(), rtc::PacketTime()); |
| 1659 // Verify the STUN Stats. |
| 1660 EXPECT_EQ(1U, lconn->sent_ping_requests_total()); |
| 1661 EXPECT_EQ(1U, lconn->sent_ping_requests_before_first_response()); |
| 1662 EXPECT_EQ(1U, lconn->recv_ping_responses()); |
| 1663 EXPECT_EQ(1U, rconn->recv_ping_requests()); |
| 1664 EXPECT_EQ(1U, rconn->sent_ping_responses()); |
1656 | 1665 |
1657 EXPECT_FALSE(msg->IsLegacy()); | 1666 EXPECT_FALSE(msg->IsLegacy()); |
1658 const StunAddressAttribute* addr_attr = msg->GetAddress( | 1667 const StunAddressAttribute* addr_attr = msg->GetAddress( |
1659 STUN_ATTR_XOR_MAPPED_ADDRESS); | 1668 STUN_ATTR_XOR_MAPPED_ADDRESS); |
1660 ASSERT_TRUE(addr_attr != NULL); | 1669 ASSERT_TRUE(addr_attr != NULL); |
1661 EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress()); | 1670 EXPECT_EQ(lport->Candidates()[0].address(), addr_attr->GetAddress()); |
1662 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); | 1671 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_MESSAGE_INTEGRITY) != NULL); |
1663 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( | 1672 EXPECT_TRUE(StunMessage::ValidateMessageIntegrity( |
1664 rport->last_stun_buf()->data<char>(), rport->last_stun_buf()->size(), | 1673 rport->last_stun_buf()->data<char>(), rport->last_stun_buf()->size(), |
1665 "rpass")); | 1674 "rpass")); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1719 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); | 1728 EXPECT_TRUE(msg->GetByteString(STUN_ATTR_USE_CANDIDATE) == NULL); |
1720 | 1729 |
1721 // Request should include ping count. | 1730 // Request should include ping count. |
1722 const StunUInt32Attribute* retransmit_attr = | 1731 const StunUInt32Attribute* retransmit_attr = |
1723 msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); | 1732 msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); |
1724 ASSERT_TRUE(retransmit_attr != NULL); | 1733 ASSERT_TRUE(retransmit_attr != NULL); |
1725 EXPECT_EQ(2U, retransmit_attr->value()); | 1734 EXPECT_EQ(2U, retransmit_attr->value()); |
1726 | 1735 |
1727 // Respond with a BINDING-RESPONSE. | 1736 // Respond with a BINDING-RESPONSE. |
1728 request.reset(CopyStunMessage(msg)); | 1737 request.reset(CopyStunMessage(msg)); |
1729 lport->SendBindingResponse(request.get(), rport->Candidates()[0].address()); | 1738 lconn->OnReadPacket(rport->last_stun_buf()->data<char>(), |
| 1739 rport->last_stun_buf()->size(), rtc::PacketTime()); |
1730 msg = lport->last_stun_msg(); | 1740 msg = lport->last_stun_msg(); |
| 1741 // Receive the BINDING-RESPONSE. |
| 1742 rconn->OnReadPacket(lport->last_stun_buf()->data<char>(), |
| 1743 lport->last_stun_buf()->size(), rtc::PacketTime()); |
| 1744 |
| 1745 // Verify the Stun ping stats. |
| 1746 EXPECT_EQ(3U, rconn->sent_ping_requests_total()); |
| 1747 EXPECT_EQ(3U, rconn->sent_ping_requests_before_first_response()); |
| 1748 EXPECT_EQ(1U, rconn->recv_ping_responses()); |
| 1749 EXPECT_EQ(1U, lconn->sent_ping_responses()); |
| 1750 EXPECT_EQ(1U, lconn->recv_ping_requests()); |
| 1751 // Ping after receiver the first response |
| 1752 rconn->Ping(0); |
| 1753 rconn->Ping(0); |
| 1754 EXPECT_EQ(5U, rconn->sent_ping_requests_total()); |
| 1755 EXPECT_EQ(3U, rconn->sent_ping_requests_before_first_response()); |
1731 | 1756 |
1732 // Response should include same ping count. | 1757 // Response should include same ping count. |
1733 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); | 1758 retransmit_attr = msg->GetUInt32(STUN_ATTR_RETRANSMIT_COUNT); |
1734 ASSERT_TRUE(retransmit_attr != NULL); | 1759 ASSERT_TRUE(retransmit_attr != NULL); |
1735 EXPECT_EQ(2U, retransmit_attr->value()); | 1760 EXPECT_EQ(2U, retransmit_attr->value()); |
1736 } | 1761 } |
1737 | 1762 |
1738 TEST_F(PortTest, TestUseCandidateAttribute) { | 1763 TEST_F(PortTest, TestUseCandidateAttribute) { |
1739 std::unique_ptr<TestPort> lport( | 1764 std::unique_ptr<TestPort> lport( |
1740 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 1765 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
(...skipping 855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2596 EXPECT_EQ(1UL, port->Candidates().size()); | 2621 EXPECT_EQ(1UL, port->Candidates().size()); |
2597 port->SetIceParameters(1, "ufrag2", "password2"); | 2622 port->SetIceParameters(1, "ufrag2", "password2"); |
2598 EXPECT_EQ(1, port->component()); | 2623 EXPECT_EQ(1, port->component()); |
2599 EXPECT_EQ("ufrag2", port->username_fragment()); | 2624 EXPECT_EQ("ufrag2", port->username_fragment()); |
2600 EXPECT_EQ("password2", port->password()); | 2625 EXPECT_EQ("password2", port->password()); |
2601 const Candidate& candidate = port->Candidates()[0]; | 2626 const Candidate& candidate = port->Candidates()[0]; |
2602 EXPECT_EQ(1, candidate.component()); | 2627 EXPECT_EQ(1, candidate.component()); |
2603 EXPECT_EQ("ufrag2", candidate.username()); | 2628 EXPECT_EQ("ufrag2", candidate.username()); |
2604 EXPECT_EQ("password2", candidate.password()); | 2629 EXPECT_EQ("password2", candidate.password()); |
2605 } | 2630 } |
OLD | NEW |