| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2010 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2010 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 14 matching lines...) Expand all Loading... |
| 25 class Thread; | 25 class Thread; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace cricket { | 28 namespace cricket { |
| 29 | 29 |
| 30 class TestUDPPort : public UDPPort { | 30 class TestUDPPort : public UDPPort { |
| 31 public: | 31 public: |
| 32 static TestUDPPort* Create(rtc::Thread* thread, | 32 static TestUDPPort* Create(rtc::Thread* thread, |
| 33 rtc::PacketSocketFactory* factory, | 33 rtc::PacketSocketFactory* factory, |
| 34 rtc::Network* network, | 34 rtc::Network* network, |
| 35 const rtc::IPAddress& ip, | |
| 36 uint16_t min_port, | 35 uint16_t min_port, |
| 37 uint16_t max_port, | 36 uint16_t max_port, |
| 38 const std::string& username, | 37 const std::string& username, |
| 39 const std::string& password, | 38 const std::string& password, |
| 40 const std::string& origin, | 39 const std::string& origin, |
| 41 bool emit_localhost_for_anyaddress) { | 40 bool emit_localhost_for_anyaddress) { |
| 42 TestUDPPort* port = new TestUDPPort(thread, factory, network, ip, min_port, | 41 TestUDPPort* port = |
| 43 max_port, username, password, origin, | 42 new TestUDPPort(thread, factory, network, min_port, max_port, username, |
| 44 emit_localhost_for_anyaddress); | 43 password, origin, emit_localhost_for_anyaddress); |
| 45 if (!port->Init()) { | 44 if (!port->Init()) { |
| 46 delete port; | 45 delete port; |
| 47 port = nullptr; | 46 port = nullptr; |
| 48 } | 47 } |
| 49 return port; | 48 return port; |
| 50 } | 49 } |
| 51 void SendBindingResponse(StunMessage* request, | 50 void SendBindingResponse(StunMessage* request, |
| 52 const rtc::SocketAddress& addr) override { | 51 const rtc::SocketAddress& addr) override { |
| 53 UDPPort::SendBindingResponse(request, addr); | 52 UDPPort::SendBindingResponse(request, addr); |
| 54 sent_binding_response_ = true; | 53 sent_binding_response_ = true; |
| 55 } | 54 } |
| 56 bool sent_binding_response() { return sent_binding_response_; } | 55 bool sent_binding_response() { return sent_binding_response_; } |
| 57 void set_sent_binding_response(bool response) { | 56 void set_sent_binding_response(bool response) { |
| 58 sent_binding_response_ = response; | 57 sent_binding_response_ = response; |
| 59 } | 58 } |
| 60 | 59 |
| 61 protected: | 60 protected: |
| 62 TestUDPPort(rtc::Thread* thread, | 61 TestUDPPort(rtc::Thread* thread, |
| 63 rtc::PacketSocketFactory* factory, | 62 rtc::PacketSocketFactory* factory, |
| 64 rtc::Network* network, | 63 rtc::Network* network, |
| 65 const rtc::IPAddress& ip, | |
| 66 uint16_t min_port, | 64 uint16_t min_port, |
| 67 uint16_t max_port, | 65 uint16_t max_port, |
| 68 const std::string& username, | 66 const std::string& username, |
| 69 const std::string& password, | 67 const std::string& password, |
| 70 const std::string& origin, | 68 const std::string& origin, |
| 71 bool emit_localhost_for_anyaddress) | 69 bool emit_localhost_for_anyaddress) |
| 72 : UDPPort(thread, | 70 : UDPPort(thread, |
| 73 factory, | 71 factory, |
| 74 network, | 72 network, |
| 75 ip, | |
| 76 min_port, | 73 min_port, |
| 77 max_port, | 74 max_port, |
| 78 username, | 75 username, |
| 79 password, | 76 password, |
| 80 origin, | 77 origin, |
| 81 emit_localhost_for_anyaddress) {} | 78 emit_localhost_for_anyaddress) {} |
| 82 | 79 |
| 83 bool sent_binding_response_ = false; | 80 bool sent_binding_response_ = false; |
| 84 }; | 81 }; |
| 85 | 82 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 void SetCandidateFilter(uint32_t filter) override { | 118 void SetCandidateFilter(uint32_t filter) override { |
| 122 candidate_filter_ = filter; | 119 candidate_filter_ = filter; |
| 123 } | 120 } |
| 124 | 121 |
| 125 void StartGettingPorts() override { | 122 void StartGettingPorts() override { |
| 126 if (!port_) { | 123 if (!port_) { |
| 127 rtc::Network& network = | 124 rtc::Network& network = |
| 128 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) | 125 (rtc::HasIPv6Enabled() && (flags() & PORTALLOCATOR_ENABLE_IPV6)) |
| 129 ? ipv6_network_ | 126 ? ipv6_network_ |
| 130 : ipv4_network_; | 127 : ipv4_network_; |
| 131 port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, | 128 port_.reset(TestUDPPort::Create(network_thread_, factory_, &network, 0, 0, |
| 132 network.GetBestIP(), 0, 0, username(), | 129 username(), password(), std::string(), |
| 133 password(), std::string(), false)); | 130 false)); |
| 134 port_->SignalDestroyed.connect( | 131 port_->SignalDestroyed.connect( |
| 135 this, &FakePortAllocatorSession::OnPortDestroyed); | 132 this, &FakePortAllocatorSession::OnPortDestroyed); |
| 136 AddPort(port_.get()); | 133 AddPort(port_.get()); |
| 137 } | 134 } |
| 138 ++port_config_count_; | 135 ++port_config_count_; |
| 139 running_ = true; | 136 running_ = true; |
| 140 } | 137 } |
| 141 | 138 |
| 142 void StopGettingPorts() override { running_ = false; } | 139 void StopGettingPorts() override { running_ = false; } |
| 143 bool IsGettingPorts() override { return running_; } | 140 bool IsGettingPorts() override { return running_; } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 private: | 244 private: |
| 248 rtc::Thread* network_thread_; | 245 rtc::Thread* network_thread_; |
| 249 rtc::PacketSocketFactory* factory_; | 246 rtc::PacketSocketFactory* factory_; |
| 250 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; | 247 std::unique_ptr<rtc::BasicPacketSocketFactory> owned_factory_; |
| 251 bool initialized_ = false; | 248 bool initialized_ = false; |
| 252 }; | 249 }; |
| 253 | 250 |
| 254 } // namespace cricket | 251 } // namespace cricket |
| 255 | 252 |
| 256 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ | 253 #endif // WEBRTC_P2P_BASE_FAKEPORTALLOCATOR_H_ |
| OLD | NEW |