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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 // INIT: The state when a port is just created. | 135 // INIT: The state when a port is just created. |
136 // KEEP_ALIVE_UNTIL_PRUNED: A port should not be destroyed even if no | 136 // KEEP_ALIVE_UNTIL_PRUNED: A port should not be destroyed even if no |
137 // connection is using it. | 137 // connection is using it. |
138 // PRUNED: It will be destroyed if no connection is using it for a period of | 138 // PRUNED: It will be destroyed if no connection is using it for a period of |
139 // 30 seconds. | 139 // 30 seconds. |
140 enum class State { INIT, KEEP_ALIVE_UNTIL_PRUNED, PRUNED }; | 140 enum class State { INIT, KEEP_ALIVE_UNTIL_PRUNED, PRUNED }; |
141 Port(rtc::Thread* thread, | 141 Port(rtc::Thread* thread, |
142 const std::string& type, | 142 const std::string& type, |
143 rtc::PacketSocketFactory* factory, | 143 rtc::PacketSocketFactory* factory, |
144 rtc::Network* network, | 144 rtc::Network* network, |
| 145 const std::string& username_fragment, |
| 146 const std::string& password); |
| 147 // TODO(deadbeef): Delete this constructor once clients are moved off of it. |
| 148 Port(rtc::Thread* thread, |
| 149 const std::string& type, |
| 150 rtc::PacketSocketFactory* factory, |
| 151 rtc::Network* network, |
145 const rtc::IPAddress& ip, | 152 const rtc::IPAddress& ip, |
146 const std::string& username_fragment, | 153 const std::string& username_fragment, |
147 const std::string& password); | 154 const std::string& password) |
| 155 : Port(thread, type, factory, network, username_fragment, password) {} |
148 Port(rtc::Thread* thread, | 156 Port(rtc::Thread* thread, |
149 const std::string& type, | 157 const std::string& type, |
150 rtc::PacketSocketFactory* factory, | 158 rtc::PacketSocketFactory* factory, |
151 rtc::Network* network, | 159 rtc::Network* network, |
152 const rtc::IPAddress& ip, | |
153 uint16_t min_port, | 160 uint16_t min_port, |
154 uint16_t max_port, | 161 uint16_t max_port, |
155 const std::string& username_fragment, | 162 const std::string& username_fragment, |
156 const std::string& password); | 163 const std::string& password); |
157 virtual ~Port(); | 164 virtual ~Port(); |
158 | 165 |
159 virtual const std::string& Type() const { return type_; } | 166 virtual const std::string& Type() const { return type_; } |
160 virtual rtc::Network* Network() const { return network_; } | 167 virtual rtc::Network* Network() const { return network_; } |
161 | 168 |
162 // Methods to set/get ICE role and tiebreaker values. | 169 // Methods to set/get ICE role and tiebreaker values. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 283 |
277 virtual void EnablePortPackets(); | 284 virtual void EnablePortPackets(); |
278 | 285 |
279 // Called if the port has no connections and is no longer useful. | 286 // Called if the port has no connections and is no longer useful. |
280 void Destroy(); | 287 void Destroy(); |
281 | 288 |
282 virtual void OnMessage(rtc::Message *pmsg); | 289 virtual void OnMessage(rtc::Message *pmsg); |
283 | 290 |
284 // Debugging description of this port | 291 // Debugging description of this port |
285 virtual std::string ToString() const; | 292 virtual std::string ToString() const; |
286 const rtc::IPAddress& ip() const { return ip_; } | |
287 uint16_t min_port() { return min_port_; } | 293 uint16_t min_port() { return min_port_; } |
288 uint16_t max_port() { return max_port_; } | 294 uint16_t max_port() { return max_port_; } |
289 | 295 |
290 // Timeout shortening function to speed up unit tests. | 296 // Timeout shortening function to speed up unit tests. |
291 void set_timeout_delay(int delay) { timeout_delay_ = delay; } | 297 void set_timeout_delay(int delay) { timeout_delay_ = delay; } |
292 | 298 |
293 // This method will return local and remote username fragements from the | 299 // This method will return local and remote username fragements from the |
294 // stun username attribute if present. | 300 // stun username attribute if present. |
295 bool ParseStunUsername(const StunMessage* stun_msg, | 301 bool ParseStunUsername(const StunMessage* stun_msg, |
296 std::string* local_username, | 302 std::string* local_username, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 // Called when one of our connections deletes itself. | 396 // Called when one of our connections deletes itself. |
391 void OnConnectionDestroyed(Connection* conn); | 397 void OnConnectionDestroyed(Connection* conn); |
392 | 398 |
393 void OnNetworkTypeChanged(const rtc::Network* network); | 399 void OnNetworkTypeChanged(const rtc::Network* network); |
394 | 400 |
395 rtc::Thread* thread_; | 401 rtc::Thread* thread_; |
396 rtc::PacketSocketFactory* factory_; | 402 rtc::PacketSocketFactory* factory_; |
397 std::string type_; | 403 std::string type_; |
398 bool send_retransmit_count_attribute_; | 404 bool send_retransmit_count_attribute_; |
399 rtc::Network* network_; | 405 rtc::Network* network_; |
400 rtc::IPAddress ip_; | |
401 uint16_t min_port_; | 406 uint16_t min_port_; |
402 uint16_t max_port_; | 407 uint16_t max_port_; |
403 std::string content_name_; | 408 std::string content_name_; |
404 int component_; | 409 int component_; |
405 uint32_t generation_; | 410 uint32_t generation_; |
406 // In order to establish a connection to this Port (so that real data can be | 411 // In order to establish a connection to this Port (so that real data can be |
407 // sent through), the other side must send us a STUN binding request that is | 412 // sent through), the other side must send us a STUN binding request that is |
408 // authenticated with this username_fragment and password. | 413 // authenticated with this username_fragment and password. |
409 // PortAllocatorSession will provide these username_fragment and password. | 414 // PortAllocatorSession will provide these username_fragment and password. |
410 // | 415 // |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 const rtc::PacketOptions& options) override; | 748 const rtc::PacketOptions& options) override; |
744 int GetError() override { return error_; } | 749 int GetError() override { return error_; } |
745 | 750 |
746 private: | 751 private: |
747 int error_ = 0; | 752 int error_ = 0; |
748 }; | 753 }; |
749 | 754 |
750 } // namespace cricket | 755 } // namespace cricket |
751 | 756 |
752 #endif // WEBRTC_P2P_BASE_PORT_H_ | 757 #endif // WEBRTC_P2P_BASE_PORT_H_ |
OLD | NEW |