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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 0, 0, username, password_); | 536 0, 0, username, password_); |
537 // TODO: Add an external address for ext_proto, so that the | 537 // TODO: Add an external address for ext_proto, so that the |
538 // other side can connect to this port using a non-UDP protocol. | 538 // other side can connect to this port using a non-UDP protocol. |
539 } | 539 } |
540 rtc::NATServer* CreateNatServer(const SocketAddress& addr, | 540 rtc::NATServer* CreateNatServer(const SocketAddress& addr, |
541 rtc::NATType type) { | 541 rtc::NATType type) { |
542 return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr); | 542 return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr); |
543 } | 543 } |
544 static const char* StunName(NATType type) { | 544 static const char* StunName(NATType type) { |
545 switch (type) { | 545 switch (type) { |
546 case NAT_OPEN_CONE: return "stun(open cone)"; | 546 case NAT_OPEN_CONE: |
547 case NAT_ADDR_RESTRICTED: return "stun(addr restricted)"; | 547 return "stun(open cone)"; |
548 case NAT_PORT_RESTRICTED: return "stun(port restricted)"; | 548 case NAT_ADDR_RESTRICTED: |
549 case NAT_SYMMETRIC: return "stun(symmetric)"; | 549 return "stun(addr restricted)"; |
550 default: return "stun(?)"; | 550 case NAT_PORT_RESTRICTED: |
| 551 return "stun(port restricted)"; |
| 552 case NAT_SYMMETRIC: |
| 553 return "stun(symmetric)"; |
| 554 default: |
| 555 return "stun(?)"; |
551 } | 556 } |
552 } | 557 } |
553 static const char* RelayName(RelayType type, ProtocolType proto) { | 558 static const char* RelayName(RelayType type, ProtocolType proto) { |
554 if (type == RELAY_TURN) { | 559 if (type == RELAY_TURN) { |
555 switch (proto) { | 560 switch (proto) { |
556 case PROTO_UDP: return "turn(udp)"; | 561 case PROTO_UDP: |
557 case PROTO_TCP: return "turn(tcp)"; | 562 return "turn(udp)"; |
558 case PROTO_SSLTCP: return "turn(ssltcp)"; | 563 case PROTO_TCP: |
559 default: return "turn(?)"; | 564 return "turn(tcp)"; |
| 565 case PROTO_SSLTCP: |
| 566 return "turn(ssltcp)"; |
| 567 case PROTO_TLS: |
| 568 return "turn(tls)"; |
| 569 default: |
| 570 return "turn(?)"; |
560 } | 571 } |
561 } else { | 572 } else { |
562 switch (proto) { | 573 switch (proto) { |
563 case PROTO_UDP: return "gturn(udp)"; | 574 case PROTO_UDP: |
564 case PROTO_TCP: return "gturn(tcp)"; | 575 return "gturn(udp)"; |
565 case PROTO_SSLTCP: return "gturn(ssltcp)"; | 576 case PROTO_TCP: |
566 default: return "gturn(?)"; | 577 return "gturn(tcp)"; |
| 578 case PROTO_SSLTCP: |
| 579 return "gturn(ssltcp)"; |
| 580 case PROTO_TLS: |
| 581 return "gturn(tls)"; |
| 582 default: |
| 583 return "gturn(?)"; |
567 } | 584 } |
568 } | 585 } |
569 } | 586 } |
570 | 587 |
571 void SetNetworkType(rtc::AdapterType adapter_type) { | 588 void SetNetworkType(rtc::AdapterType adapter_type) { |
572 network_.set_type(adapter_type); | 589 network_.set_type(adapter_type); |
573 } | 590 } |
574 | 591 |
575 void TestCrossFamilyPorts(int type); | 592 void TestCrossFamilyPorts(int type); |
576 | 593 |
(...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2370 EXPECT_TRUE(cand1.priority() > cand2.priority()); | 2387 EXPECT_TRUE(cand1.priority() > cand2.priority()); |
2371 } | 2388 } |
2372 | 2389 |
2373 // Test the Connection priority is calculated correctly. | 2390 // Test the Connection priority is calculated correctly. |
2374 TEST_F(PortTest, TestConnectionPriority) { | 2391 TEST_F(PortTest, TestConnectionPriority) { |
2375 std::unique_ptr<TestPort> lport( | 2392 std::unique_ptr<TestPort> lport( |
2376 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); | 2393 CreateTestPort(kLocalAddr1, "lfrag", "lpass")); |
2377 lport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_HOST); | 2394 lport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_HOST); |
2378 std::unique_ptr<TestPort> rport( | 2395 std::unique_ptr<TestPort> rport( |
2379 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); | 2396 CreateTestPort(kLocalAddr2, "rfrag", "rpass")); |
2380 rport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_RELAY); | 2397 rport->set_type_preference(cricket::ICE_TYPE_PREFERENCE_RELAY_UDP); |
2381 lport->set_component(123); | 2398 lport->set_component(123); |
2382 lport->AddCandidateAddress(SocketAddress("192.168.1.4", 1234)); | 2399 lport->AddCandidateAddress(SocketAddress("192.168.1.4", 1234)); |
2383 rport->set_component(23); | 2400 rport->set_component(23); |
2384 rport->AddCandidateAddress(SocketAddress("10.1.1.100", 1234)); | 2401 rport->AddCandidateAddress(SocketAddress("10.1.1.100", 1234)); |
2385 | 2402 |
2386 EXPECT_EQ(0x7E001E85U, lport->Candidates()[0].priority()); | 2403 EXPECT_EQ(0x7E001E85U, lport->Candidates()[0].priority()); |
2387 EXPECT_EQ(0x2001EE9U, rport->Candidates()[0].priority()); | 2404 EXPECT_EQ(0x2001EE9U, rport->Candidates()[0].priority()); |
2388 | 2405 |
2389 // RFC 5245 | 2406 // RFC 5245 |
2390 // pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) | 2407 // pair priority = 2^32*MIN(G,D) + 2*MAX(G,D) + (G>D?1:0) |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2745 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); | 2762 port->CreateConnection(candidate, Port::ORIGIN_MESSAGE); |
2746 EXPECT_NE(conn1, conn2); | 2763 EXPECT_NE(conn1, conn2); |
2747 conn_in_use = port->GetConnection(address); | 2764 conn_in_use = port->GetConnection(address); |
2748 EXPECT_EQ(conn2, conn_in_use); | 2765 EXPECT_EQ(conn2, conn_in_use); |
2749 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); | 2766 EXPECT_EQ(2u, conn_in_use->remote_candidate().generation()); |
2750 | 2767 |
2751 // Make sure the new connection was not deleted. | 2768 // Make sure the new connection was not deleted. |
2752 rtc::Thread::Current()->ProcessMessages(300); | 2769 rtc::Thread::Current()->ProcessMessages(300); |
2753 EXPECT_TRUE(port->GetConnection(address) != nullptr); | 2770 EXPECT_TRUE(port->GetConnection(address) != nullptr); |
2754 } | 2771 } |
OLD | NEW |