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 16 matching lines...) Expand all Loading... |
27 | 27 |
28 // Communicates using the address on the outside of a NAT. | 28 // Communicates using the address on the outside of a NAT. |
29 class UDPPort : public Port { | 29 class UDPPort : public Port { |
30 public: | 30 public: |
31 static UDPPort* Create(rtc::Thread* thread, | 31 static UDPPort* Create(rtc::Thread* thread, |
32 rtc::PacketSocketFactory* factory, | 32 rtc::PacketSocketFactory* factory, |
33 rtc::Network* network, | 33 rtc::Network* network, |
34 rtc::AsyncPacketSocket* socket, | 34 rtc::AsyncPacketSocket* socket, |
35 const std::string& username, | 35 const std::string& username, |
36 const std::string& password, | 36 const std::string& password, |
37 const std::string& origin) { | 37 const std::string& origin, |
| 38 bool emit_localhost_for_anyaddress) { |
38 UDPPort* port = new UDPPort(thread, factory, network, socket, | 39 UDPPort* port = new UDPPort(thread, factory, network, socket, |
39 username, password, origin); | 40 username, password, origin, |
| 41 emit_localhost_for_anyaddress); |
40 if (!port->Init()) { | 42 if (!port->Init()) { |
41 delete port; | 43 delete port; |
42 port = NULL; | 44 port = NULL; |
43 } | 45 } |
44 return port; | 46 return port; |
45 } | 47 } |
46 | 48 |
47 static UDPPort* Create(rtc::Thread* thread, | 49 static UDPPort* Create(rtc::Thread* thread, |
48 rtc::PacketSocketFactory* factory, | 50 rtc::PacketSocketFactory* factory, |
49 rtc::Network* network, | 51 rtc::Network* network, |
50 const rtc::IPAddress& ip, | 52 const rtc::IPAddress& ip, |
51 uint16 min_port, | 53 uint16 min_port, |
52 uint16 max_port, | 54 uint16 max_port, |
53 const std::string& username, | 55 const std::string& username, |
54 const std::string& password, | 56 const std::string& password, |
55 const std::string& origin) { | 57 const std::string& origin, |
| 58 bool emit_localhost_for_anyaddress) { |
56 UDPPort* port = new UDPPort(thread, factory, network, | 59 UDPPort* port = new UDPPort(thread, factory, network, |
57 ip, min_port, max_port, | 60 ip, min_port, max_port, |
58 username, password, origin); | 61 username, password, origin, |
| 62 emit_localhost_for_anyaddress); |
59 if (!port->Init()) { | 63 if (!port->Init()) { |
60 delete port; | 64 delete port; |
61 port = NULL; | 65 port = NULL; |
62 } | 66 } |
63 return port; | 67 return port; |
64 } | 68 } |
65 | 69 |
66 virtual ~UDPPort(); | 70 virtual ~UDPPort(); |
67 | 71 |
68 rtc::SocketAddress GetLocalAddress() const { | 72 rtc::SocketAddress GetLocalAddress() const { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 | 107 |
104 protected: | 108 protected: |
105 UDPPort(rtc::Thread* thread, | 109 UDPPort(rtc::Thread* thread, |
106 rtc::PacketSocketFactory* factory, | 110 rtc::PacketSocketFactory* factory, |
107 rtc::Network* network, | 111 rtc::Network* network, |
108 const rtc::IPAddress& ip, | 112 const rtc::IPAddress& ip, |
109 uint16 min_port, | 113 uint16 min_port, |
110 uint16 max_port, | 114 uint16 max_port, |
111 const std::string& username, | 115 const std::string& username, |
112 const std::string& password, | 116 const std::string& password, |
113 const std::string& origin); | 117 const std::string& origin, |
| 118 bool emit_localhost_for_anyaddress); |
114 | 119 |
115 UDPPort(rtc::Thread* thread, | 120 UDPPort(rtc::Thread* thread, |
116 rtc::PacketSocketFactory* factory, | 121 rtc::PacketSocketFactory* factory, |
117 rtc::Network* network, | 122 rtc::Network* network, |
118 rtc::AsyncPacketSocket* socket, | 123 rtc::AsyncPacketSocket* socket, |
119 const std::string& username, | 124 const std::string& username, |
120 const std::string& password, | 125 const std::string& password, |
121 const std::string& origin); | 126 const std::string& origin, |
| 127 bool emit_localhost_for_anyaddress); |
122 | 128 |
123 bool Init(); | 129 bool Init(); |
124 | 130 |
125 virtual int SendTo(const void* data, size_t size, | 131 virtual int SendTo(const void* data, size_t size, |
126 const rtc::SocketAddress& addr, | 132 const rtc::SocketAddress& addr, |
127 const rtc::PacketOptions& options, | 133 const rtc::PacketOptions& options, |
128 bool payload); | 134 bool payload); |
129 | 135 |
130 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, | 136 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, |
131 const rtc::SocketAddress& address); | 137 const rtc::SocketAddress& address); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 ServerAddresses server_addresses_; | 201 ServerAddresses server_addresses_; |
196 ServerAddresses bind_request_succeeded_servers_; | 202 ServerAddresses bind_request_succeeded_servers_; |
197 ServerAddresses bind_request_failed_servers_; | 203 ServerAddresses bind_request_failed_servers_; |
198 StunRequestManager requests_; | 204 StunRequestManager requests_; |
199 rtc::AsyncPacketSocket* socket_; | 205 rtc::AsyncPacketSocket* socket_; |
200 int error_; | 206 int error_; |
201 rtc::scoped_ptr<AddressResolver> resolver_; | 207 rtc::scoped_ptr<AddressResolver> resolver_; |
202 bool ready_; | 208 bool ready_; |
203 int stun_keepalive_delay_; | 209 int stun_keepalive_delay_; |
204 | 210 |
| 211 // This is true when PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified. |
| 212 bool emit_localhost_for_anyaddress_; |
| 213 |
205 friend class StunBindingRequest; | 214 friend class StunBindingRequest; |
206 }; | 215 }; |
207 | 216 |
208 class StunPort : public UDPPort { | 217 class StunPort : public UDPPort { |
209 public: | 218 public: |
210 static StunPort* Create(rtc::Thread* thread, | 219 static StunPort* Create(rtc::Thread* thread, |
211 rtc::PacketSocketFactory* factory, | 220 rtc::PacketSocketFactory* factory, |
212 rtc::Network* network, | 221 rtc::Network* network, |
213 const rtc::IPAddress& ip, | 222 const rtc::IPAddress& ip, |
214 uint16 min_port, uint16 max_port, | 223 uint16 min_port, uint16 max_port, |
(...skipping 23 matching lines...) Expand all Loading... |
238 rtc::PacketSocketFactory* factory, | 247 rtc::PacketSocketFactory* factory, |
239 rtc::Network* network, | 248 rtc::Network* network, |
240 const rtc::IPAddress& ip, | 249 const rtc::IPAddress& ip, |
241 uint16 min_port, | 250 uint16 min_port, |
242 uint16 max_port, | 251 uint16 max_port, |
243 const std::string& username, | 252 const std::string& username, |
244 const std::string& password, | 253 const std::string& password, |
245 const ServerAddresses& servers, | 254 const ServerAddresses& servers, |
246 const std::string& origin) | 255 const std::string& origin) |
247 : UDPPort(thread, factory, network, ip, min_port, max_port, username, | 256 : UDPPort(thread, factory, network, ip, min_port, max_port, username, |
248 password, origin) { | 257 password, origin, false) { |
249 // UDPPort will set these to local udp, updating these to STUN. | 258 // UDPPort will set these to local udp, updating these to STUN. |
250 set_type(STUN_PORT_TYPE); | 259 set_type(STUN_PORT_TYPE); |
251 set_server_addresses(servers); | 260 set_server_addresses(servers); |
252 } | 261 } |
253 }; | 262 }; |
254 | 263 |
255 } // namespace cricket | 264 } // namespace cricket |
256 | 265 |
257 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ | 266 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ |
OLD | NEW |