| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 delete port; | 43 delete port; |
| 44 port = NULL; | 44 port = NULL; |
| 45 } | 45 } |
| 46 return port; | 46 return port; |
| 47 } | 47 } |
| 48 | 48 |
| 49 static UDPPort* Create(rtc::Thread* thread, | 49 static UDPPort* Create(rtc::Thread* thread, |
| 50 rtc::PacketSocketFactory* factory, | 50 rtc::PacketSocketFactory* factory, |
| 51 rtc::Network* network, | 51 rtc::Network* network, |
| 52 const rtc::IPAddress& ip, | 52 const rtc::IPAddress& ip, |
| 53 uint16 min_port, | 53 uint16_t min_port, |
| 54 uint16 max_port, | 54 uint16_t max_port, |
| 55 const std::string& username, | 55 const std::string& username, |
| 56 const std::string& password, | 56 const std::string& password, |
| 57 const std::string& origin, | 57 const std::string& origin, |
| 58 bool emit_localhost_for_anyaddress) { | 58 bool emit_localhost_for_anyaddress) { |
| 59 UDPPort* port = new UDPPort(thread, factory, network, | 59 UDPPort* port = new UDPPort(thread, factory, network, |
| 60 ip, min_port, max_port, | 60 ip, min_port, max_port, |
| 61 username, password, origin, | 61 username, password, origin, |
| 62 emit_localhost_for_anyaddress); | 62 emit_localhost_for_anyaddress); |
| 63 if (!port->Init()) { | 63 if (!port->Init()) { |
| 64 delete port; | 64 delete port; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 } | 103 } |
| 104 int stun_keepalive_delay() const { | 104 int stun_keepalive_delay() const { |
| 105 return stun_keepalive_delay_; | 105 return stun_keepalive_delay_; |
| 106 } | 106 } |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 UDPPort(rtc::Thread* thread, | 109 UDPPort(rtc::Thread* thread, |
| 110 rtc::PacketSocketFactory* factory, | 110 rtc::PacketSocketFactory* factory, |
| 111 rtc::Network* network, | 111 rtc::Network* network, |
| 112 const rtc::IPAddress& ip, | 112 const rtc::IPAddress& ip, |
| 113 uint16 min_port, | 113 uint16_t min_port, |
| 114 uint16 max_port, | 114 uint16_t max_port, |
| 115 const std::string& username, | 115 const std::string& username, |
| 116 const std::string& password, | 116 const std::string& password, |
| 117 const std::string& origin, | 117 const std::string& origin, |
| 118 bool emit_localhost_for_anyaddress); | 118 bool emit_localhost_for_anyaddress); |
| 119 | 119 |
| 120 UDPPort(rtc::Thread* thread, | 120 UDPPort(rtc::Thread* thread, |
| 121 rtc::PacketSocketFactory* factory, | 121 rtc::PacketSocketFactory* factory, |
| 122 rtc::Network* network, | 122 rtc::Network* network, |
| 123 rtc::AsyncPacketSocket* socket, | 123 rtc::AsyncPacketSocket* socket, |
| 124 const std::string& username, | 124 const std::string& username, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 friend class StunBindingRequest; | 214 friend class StunBindingRequest; |
| 215 }; | 215 }; |
| 216 | 216 |
| 217 class StunPort : public UDPPort { | 217 class StunPort : public UDPPort { |
| 218 public: | 218 public: |
| 219 static StunPort* Create(rtc::Thread* thread, | 219 static StunPort* Create(rtc::Thread* thread, |
| 220 rtc::PacketSocketFactory* factory, | 220 rtc::PacketSocketFactory* factory, |
| 221 rtc::Network* network, | 221 rtc::Network* network, |
| 222 const rtc::IPAddress& ip, | 222 const rtc::IPAddress& ip, |
| 223 uint16 min_port, uint16 max_port, | 223 uint16_t min_port, |
| 224 uint16_t max_port, |
| 224 const std::string& username, | 225 const std::string& username, |
| 225 const std::string& password, | 226 const std::string& password, |
| 226 const ServerAddresses& servers, | 227 const ServerAddresses& servers, |
| 227 const std::string& origin) { | 228 const std::string& origin) { |
| 228 StunPort* port = new StunPort(thread, factory, network, | 229 StunPort* port = new StunPort(thread, factory, network, |
| 229 ip, min_port, max_port, | 230 ip, min_port, max_port, |
| 230 username, password, servers, | 231 username, password, servers, |
| 231 origin); | 232 origin); |
| 232 if (!port->Init()) { | 233 if (!port->Init()) { |
| 233 delete port; | 234 delete port; |
| 234 port = NULL; | 235 port = NULL; |
| 235 } | 236 } |
| 236 return port; | 237 return port; |
| 237 } | 238 } |
| 238 | 239 |
| 239 virtual ~StunPort() {} | 240 virtual ~StunPort() {} |
| 240 | 241 |
| 241 virtual void PrepareAddress() { | 242 virtual void PrepareAddress() { |
| 242 SendStunBindingRequests(); | 243 SendStunBindingRequests(); |
| 243 } | 244 } |
| 244 | 245 |
| 245 protected: | 246 protected: |
| 246 StunPort(rtc::Thread* thread, | 247 StunPort(rtc::Thread* thread, |
| 247 rtc::PacketSocketFactory* factory, | 248 rtc::PacketSocketFactory* factory, |
| 248 rtc::Network* network, | 249 rtc::Network* network, |
| 249 const rtc::IPAddress& ip, | 250 const rtc::IPAddress& ip, |
| 250 uint16 min_port, | 251 uint16_t min_port, |
| 251 uint16 max_port, | 252 uint16_t max_port, |
| 252 const std::string& username, | 253 const std::string& username, |
| 253 const std::string& password, | 254 const std::string& password, |
| 254 const ServerAddresses& servers, | 255 const ServerAddresses& servers, |
| 255 const std::string& origin) | 256 const std::string& origin) |
| 256 : UDPPort(thread, factory, network, ip, min_port, max_port, username, | 257 : UDPPort(thread, |
| 257 password, origin, false) { | 258 factory, |
| 259 network, |
| 260 ip, |
| 261 min_port, |
| 262 max_port, |
| 263 username, |
| 264 password, |
| 265 origin, |
| 266 false) { |
| 258 // UDPPort will set these to local udp, updating these to STUN. | 267 // UDPPort will set these to local udp, updating these to STUN. |
| 259 set_type(STUN_PORT_TYPE); | 268 set_type(STUN_PORT_TYPE); |
| 260 set_server_addresses(servers); | 269 set_server_addresses(servers); |
| 261 } | 270 } |
| 262 }; | 271 }; |
| 263 | 272 |
| 264 } // namespace cricket | 273 } // namespace cricket |
| 265 | 274 |
| 266 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ | 275 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ |
| OLD | NEW |