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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 return protocol == UDP_PROTOCOL_NAME; | 99 return protocol == UDP_PROTOCOL_NAME; |
100 } | 100 } |
101 | 101 |
102 void set_stun_keepalive_delay(int delay) { | 102 void set_stun_keepalive_delay(int delay) { |
103 stun_keepalive_delay_ = delay; | 103 stun_keepalive_delay_ = delay; |
104 } | 104 } |
105 int stun_keepalive_delay() const { | 105 int stun_keepalive_delay() const { |
106 return stun_keepalive_delay_; | 106 return stun_keepalive_delay_; |
107 } | 107 } |
108 | 108 |
| 109 // Visible for testing. |
| 110 int stun_keepalive_lifetime() const { return stun_keepalive_lifetime_; } |
| 111 void set_stun_keepalive_lifetime(int lifetime) { |
| 112 stun_keepalive_lifetime_ = lifetime; |
| 113 } |
| 114 // Returns true if there is a pending request with type |msg_type|. |
| 115 bool HasPendingRequest(int msg_type) { |
| 116 return requests_.HasRequest(msg_type); |
| 117 } |
| 118 |
109 protected: | 119 protected: |
110 UDPPort(rtc::Thread* thread, | 120 UDPPort(rtc::Thread* thread, |
111 rtc::PacketSocketFactory* factory, | 121 rtc::PacketSocketFactory* factory, |
112 rtc::Network* network, | 122 rtc::Network* network, |
113 const rtc::IPAddress& ip, | 123 const rtc::IPAddress& ip, |
114 uint16_t min_port, | 124 uint16_t min_port, |
115 uint16_t max_port, | 125 uint16_t max_port, |
116 const std::string& username, | 126 const std::string& username, |
117 const std::string& password, | 127 const std::string& password, |
118 const std::string& origin, | 128 const std::string& origin, |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 220 |
211 ServerAddresses server_addresses_; | 221 ServerAddresses server_addresses_; |
212 ServerAddresses bind_request_succeeded_servers_; | 222 ServerAddresses bind_request_succeeded_servers_; |
213 ServerAddresses bind_request_failed_servers_; | 223 ServerAddresses bind_request_failed_servers_; |
214 StunRequestManager requests_; | 224 StunRequestManager requests_; |
215 rtc::AsyncPacketSocket* socket_; | 225 rtc::AsyncPacketSocket* socket_; |
216 int error_; | 226 int error_; |
217 rtc::scoped_ptr<AddressResolver> resolver_; | 227 rtc::scoped_ptr<AddressResolver> resolver_; |
218 bool ready_; | 228 bool ready_; |
219 int stun_keepalive_delay_; | 229 int stun_keepalive_delay_; |
| 230 int stun_keepalive_lifetime_; |
220 | 231 |
221 // This is true by default and false when | 232 // This is true by default and false when |
222 // PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE is specified. | 233 // PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE is specified. |
223 bool emit_local_for_anyaddress_; | 234 bool emit_local_for_anyaddress_; |
224 | 235 |
225 friend class StunBindingRequest; | 236 friend class StunBindingRequest; |
226 }; | 237 }; |
227 | 238 |
228 class StunPort : public UDPPort { | 239 class StunPort : public UDPPort { |
229 public: | 240 public: |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 false) { | 288 false) { |
278 // UDPPort will set these to local udp, updating these to STUN. | 289 // UDPPort will set these to local udp, updating these to STUN. |
279 set_type(STUN_PORT_TYPE); | 290 set_type(STUN_PORT_TYPE); |
280 set_server_addresses(servers); | 291 set_server_addresses(servers); |
281 } | 292 } |
282 }; | 293 }; |
283 | 294 |
284 } // namespace cricket | 295 } // namespace cricket |
285 | 296 |
286 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ | 297 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ |
OLD | NEW |