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 rtc::IPAddress& ip, | |
146 const std::string& username_fragment, | 145 const std::string& username_fragment, |
147 const std::string& password); | 146 const std::string& password); |
148 Port(rtc::Thread* thread, | 147 Port(rtc::Thread* thread, |
149 const std::string& type, | 148 const std::string& type, |
150 rtc::PacketSocketFactory* factory, | 149 rtc::PacketSocketFactory* factory, |
151 rtc::Network* network, | 150 rtc::Network* network, |
152 const rtc::IPAddress& ip, | |
153 uint16_t min_port, | 151 uint16_t min_port, |
154 uint16_t max_port, | 152 uint16_t max_port, |
155 const std::string& username_fragment, | 153 const std::string& username_fragment, |
156 const std::string& password); | 154 const std::string& password); |
157 virtual ~Port(); | 155 virtual ~Port(); |
158 | 156 |
159 virtual const std::string& Type() const { return type_; } | 157 virtual const std::string& Type() const { return type_; } |
160 virtual rtc::Network* Network() const { return network_; } | 158 virtual rtc::Network* Network() const { return network_; } |
161 | 159 |
162 // Methods to set/get ICE role and tiebreaker values. | 160 // Methods to set/get ICE role and tiebreaker values. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 | 274 |
277 virtual void EnablePortPackets(); | 275 virtual void EnablePortPackets(); |
278 | 276 |
279 // Called if the port has no connections and is no longer useful. | 277 // Called if the port has no connections and is no longer useful. |
280 void Destroy(); | 278 void Destroy(); |
281 | 279 |
282 virtual void OnMessage(rtc::Message *pmsg); | 280 virtual void OnMessage(rtc::Message *pmsg); |
283 | 281 |
284 // Debugging description of this port | 282 // Debugging description of this port |
285 virtual std::string ToString() const; | 283 virtual std::string ToString() const; |
286 const rtc::IPAddress& ip() const { return ip_; } | |
287 uint16_t min_port() { return min_port_; } | 284 uint16_t min_port() { return min_port_; } |
288 uint16_t max_port() { return max_port_; } | 285 uint16_t max_port() { return max_port_; } |
289 | 286 |
290 // Timeout shortening function to speed up unit tests. | 287 // Timeout shortening function to speed up unit tests. |
291 void set_timeout_delay(int delay) { timeout_delay_ = delay; } | 288 void set_timeout_delay(int delay) { timeout_delay_ = delay; } |
292 | 289 |
293 // This method will return local and remote username fragements from the | 290 // This method will return local and remote username fragements from the |
294 // stun username attribute if present. | 291 // stun username attribute if present. |
295 bool ParseStunUsername(const StunMessage* stun_msg, | 292 bool ParseStunUsername(const StunMessage* stun_msg, |
296 std::string* local_username, | 293 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. | 387 // Called when one of our connections deletes itself. |
391 void OnConnectionDestroyed(Connection* conn); | 388 void OnConnectionDestroyed(Connection* conn); |
392 | 389 |
393 void OnNetworkTypeChanged(const rtc::Network* network); | 390 void OnNetworkTypeChanged(const rtc::Network* network); |
394 | 391 |
395 rtc::Thread* thread_; | 392 rtc::Thread* thread_; |
396 rtc::PacketSocketFactory* factory_; | 393 rtc::PacketSocketFactory* factory_; |
397 std::string type_; | 394 std::string type_; |
398 bool send_retransmit_count_attribute_; | 395 bool send_retransmit_count_attribute_; |
399 rtc::Network* network_; | 396 rtc::Network* network_; |
400 rtc::IPAddress ip_; | |
401 uint16_t min_port_; | 397 uint16_t min_port_; |
402 uint16_t max_port_; | 398 uint16_t max_port_; |
403 std::string content_name_; | 399 std::string content_name_; |
404 int component_; | 400 int component_; |
405 uint32_t generation_; | 401 uint32_t generation_; |
406 // In order to establish a connection to this Port (so that real data can be | 402 // 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 | 403 // sent through), the other side must send us a STUN binding request that is |
408 // authenticated with this username_fragment and password. | 404 // authenticated with this username_fragment and password. |
409 // PortAllocatorSession will provide these username_fragment and password. | 405 // PortAllocatorSession will provide these username_fragment and password. |
410 // | 406 // |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 const rtc::PacketOptions& options) override; | 739 const rtc::PacketOptions& options) override; |
744 int GetError() override { return error_; } | 740 int GetError() override { return error_; } |
745 | 741 |
746 private: | 742 private: |
747 int error_ = 0; | 743 int error_ = 0; |
748 }; | 744 }; |
749 | 745 |
750 } // namespace cricket | 746 } // namespace cricket |
751 | 747 |
752 #endif // WEBRTC_P2P_BASE_PORT_H_ | 748 #endif // WEBRTC_P2P_BASE_PORT_H_ |
OLD | NEW |