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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // Magic value of 30 is from RFC3484, for IPv4 addresses. | 69 // Magic value of 30 is from RFC3484, for IPv4 addresses. |
70 static const uint32_t kDefaultPrflxPriority = | 70 static const uint32_t kDefaultPrflxPriority = |
71 ICE_TYPE_PREFERENCE_PRFLX << 24 | 30 << 8 | | 71 ICE_TYPE_PREFERENCE_PRFLX << 24 | 30 << 8 | |
72 (256 - ICE_CANDIDATE_COMPONENT_DEFAULT); | 72 (256 - ICE_CANDIDATE_COMPONENT_DEFAULT); |
73 | 73 |
74 static const int kTiebreaker1 = 11111; | 74 static const int kTiebreaker1 = 11111; |
75 static const int kTiebreaker2 = 22222; | 75 static const int kTiebreaker2 = 22222; |
76 | 76 |
77 static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; | 77 static const char* data = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; |
78 | 78 |
79 static const int kGturnUserNameLength = 16; | |
80 | |
81 static Candidate GetCandidate(Port* port) { | 79 static Candidate GetCandidate(Port* port) { |
82 assert(port->Candidates().size() >= 1); | 80 assert(port->Candidates().size() >= 1); |
83 return port->Candidates()[0]; | 81 return port->Candidates()[0]; |
84 } | 82 } |
85 | 83 |
86 static SocketAddress GetAddress(Port* port) { | 84 static SocketAddress GetAddress(Port* port) { |
87 return GetCandidate(port).address(); | 85 return GetCandidate(port).address(); |
88 } | 86 } |
89 | 87 |
90 static IceMessage* CopyStunMessage(const IceMessage* src) { | 88 static IceMessage* CopyStunMessage(const IceMessage* src) { |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 RelayPort* CreateGturnPort(const SocketAddress& addr, | 518 RelayPort* CreateGturnPort(const SocketAddress& addr, |
521 ProtocolType int_proto, ProtocolType ext_proto) { | 519 ProtocolType int_proto, ProtocolType ext_proto) { |
522 RelayPort* port = CreateGturnPort(addr); | 520 RelayPort* port = CreateGturnPort(addr); |
523 SocketAddress addrs[] = | 521 SocketAddress addrs[] = |
524 { kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr }; | 522 { kRelayUdpIntAddr, kRelayTcpIntAddr, kRelaySslTcpIntAddr }; |
525 port->AddServerAddress(ProtocolAddress(addrs[int_proto], int_proto)); | 523 port->AddServerAddress(ProtocolAddress(addrs[int_proto], int_proto)); |
526 return port; | 524 return port; |
527 } | 525 } |
528 RelayPort* CreateGturnPort(const SocketAddress& addr) { | 526 RelayPort* CreateGturnPort(const SocketAddress& addr) { |
529 // TODO(pthatcher): Remove GTURN. | 527 // TODO(pthatcher): Remove GTURN. |
530 // Generate a username with length of 16 for Gturn only. | 528 return RelayPort::Create(main_, &socket_factory_, &network_, |
531 std::string username = rtc::CreateRandomString(kGturnUserNameLength); | 529 addr.ipaddr(), 0, 0, |
532 return RelayPort::Create(main_, &socket_factory_, &network_, addr.ipaddr(), | 530 username_, password_); |
533 0, 0, username, password_); | |
534 // TODO: Add an external address for ext_proto, so that the | 531 // TODO: Add an external address for ext_proto, so that the |
535 // other side can connect to this port using a non-UDP protocol. | 532 // other side can connect to this port using a non-UDP protocol. |
536 } | 533 } |
537 rtc::NATServer* CreateNatServer(const SocketAddress& addr, | 534 rtc::NATServer* CreateNatServer(const SocketAddress& addr, |
538 rtc::NATType type) { | 535 rtc::NATType type) { |
539 return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr); | 536 return new rtc::NATServer(type, ss_.get(), addr, addr, ss_.get(), addr); |
540 } | 537 } |
541 static const char* StunName(NATType type) { | 538 static const char* StunName(NATType type) { |
542 switch (type) { | 539 switch (type) { |
543 case NAT_OPEN_CONE: return "stun(open cone)"; | 540 case NAT_OPEN_CONE: return "stun(open cone)"; |
(...skipping 2114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2658 EXPECT_EQ(1UL, port->Candidates().size()); | 2655 EXPECT_EQ(1UL, port->Candidates().size()); |
2659 port->SetIceParameters(1, "ufrag2", "password2"); | 2656 port->SetIceParameters(1, "ufrag2", "password2"); |
2660 EXPECT_EQ(1, port->component()); | 2657 EXPECT_EQ(1, port->component()); |
2661 EXPECT_EQ("ufrag2", port->username_fragment()); | 2658 EXPECT_EQ("ufrag2", port->username_fragment()); |
2662 EXPECT_EQ("password2", port->password()); | 2659 EXPECT_EQ("password2", port->password()); |
2663 const Candidate& candidate = port->Candidates()[0]; | 2660 const Candidate& candidate = port->Candidates()[0]; |
2664 EXPECT_EQ(1, candidate.component()); | 2661 EXPECT_EQ(1, candidate.component()); |
2665 EXPECT_EQ("ufrag2", candidate.username()); | 2662 EXPECT_EQ("ufrag2", candidate.username()); |
2666 EXPECT_EQ("password2", candidate.password()); | 2663 EXPECT_EQ("password2", candidate.password()); |
2667 } | 2664 } |
OLD | NEW |