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