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 17 matching lines...) Expand all Loading... |
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 bool emit_local_for_anyaddress) { |
39 UDPPort* port = new UDPPort(thread, factory, network, socket, | 39 UDPPort* port = new UDPPort(thread, factory, network, socket, username, |
40 username, password, origin, | 40 password, origin, emit_local_for_anyaddress); |
41 emit_localhost_for_anyaddress); | |
42 if (!port->Init()) { | 41 if (!port->Init()) { |
43 delete port; | 42 delete port; |
44 port = NULL; | 43 port = NULL; |
45 } | 44 } |
46 return port; | 45 return port; |
47 } | 46 } |
48 | 47 |
49 static UDPPort* Create(rtc::Thread* thread, | 48 static UDPPort* Create(rtc::Thread* thread, |
50 rtc::PacketSocketFactory* factory, | 49 rtc::PacketSocketFactory* factory, |
51 rtc::Network* network, | 50 rtc::Network* network, |
52 const rtc::IPAddress& ip, | 51 const rtc::IPAddress& ip, |
53 uint16_t min_port, | 52 uint16_t min_port, |
54 uint16_t max_port, | 53 uint16_t max_port, |
55 const std::string& username, | 54 const std::string& username, |
56 const std::string& password, | 55 const std::string& password, |
57 const std::string& origin, | 56 const std::string& origin, |
58 bool emit_localhost_for_anyaddress) { | 57 bool emit_local_for_anyaddress) { |
59 UDPPort* port = new UDPPort(thread, factory, network, | 58 UDPPort* port = |
60 ip, min_port, max_port, | 59 new UDPPort(thread, factory, network, ip, min_port, max_port, username, |
61 username, password, origin, | 60 password, origin, emit_local_for_anyaddress); |
62 emit_localhost_for_anyaddress); | |
63 if (!port->Init()) { | 61 if (!port->Init()) { |
64 delete port; | 62 delete port; |
65 port = NULL; | 63 port = NULL; |
66 } | 64 } |
67 return port; | 65 return port; |
68 } | 66 } |
69 | 67 |
70 virtual ~UDPPort(); | 68 virtual ~UDPPort(); |
71 | 69 |
72 rtc::SocketAddress GetLocalAddress() const { | 70 rtc::SocketAddress GetLocalAddress() const { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 protected: | 106 protected: |
109 UDPPort(rtc::Thread* thread, | 107 UDPPort(rtc::Thread* thread, |
110 rtc::PacketSocketFactory* factory, | 108 rtc::PacketSocketFactory* factory, |
111 rtc::Network* network, | 109 rtc::Network* network, |
112 const rtc::IPAddress& ip, | 110 const rtc::IPAddress& ip, |
113 uint16_t min_port, | 111 uint16_t min_port, |
114 uint16_t max_port, | 112 uint16_t max_port, |
115 const std::string& username, | 113 const std::string& username, |
116 const std::string& password, | 114 const std::string& password, |
117 const std::string& origin, | 115 const std::string& origin, |
118 bool emit_localhost_for_anyaddress); | 116 bool emit_local_for_anyaddress); |
119 | 117 |
120 UDPPort(rtc::Thread* thread, | 118 UDPPort(rtc::Thread* thread, |
121 rtc::PacketSocketFactory* factory, | 119 rtc::PacketSocketFactory* factory, |
122 rtc::Network* network, | 120 rtc::Network* network, |
123 rtc::AsyncPacketSocket* socket, | 121 rtc::AsyncPacketSocket* socket, |
124 const std::string& username, | 122 const std::string& username, |
125 const std::string& password, | 123 const std::string& password, |
126 const std::string& origin, | 124 const std::string& origin, |
127 bool emit_localhost_for_anyaddress); | 125 bool emit_local_for_anyaddress); |
128 | 126 |
129 bool Init(); | 127 bool Init(); |
130 | 128 |
131 virtual int SendTo(const void* data, size_t size, | 129 virtual int SendTo(const void* data, size_t size, |
132 const rtc::SocketAddress& addr, | 130 const rtc::SocketAddress& addr, |
133 const rtc::PacketOptions& options, | 131 const rtc::PacketOptions& options, |
134 bool payload); | 132 bool payload); |
135 | 133 |
136 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, | 134 void OnLocalAddressReady(rtc::AsyncPacketSocket* socket, |
137 const rtc::SocketAddress& address); | 135 const rtc::SocketAddress& address); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 ServerAddresses server_addresses_; | 202 ServerAddresses server_addresses_; |
205 ServerAddresses bind_request_succeeded_servers_; | 203 ServerAddresses bind_request_succeeded_servers_; |
206 ServerAddresses bind_request_failed_servers_; | 204 ServerAddresses bind_request_failed_servers_; |
207 StunRequestManager requests_; | 205 StunRequestManager requests_; |
208 rtc::AsyncPacketSocket* socket_; | 206 rtc::AsyncPacketSocket* socket_; |
209 int error_; | 207 int error_; |
210 rtc::scoped_ptr<AddressResolver> resolver_; | 208 rtc::scoped_ptr<AddressResolver> resolver_; |
211 bool ready_; | 209 bool ready_; |
212 int stun_keepalive_delay_; | 210 int stun_keepalive_delay_; |
213 | 211 |
214 // This is true when PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified. | 212 // This is true by default and false when |
215 bool emit_localhost_for_anyaddress_; | 213 // PORTALLOCATOR_DISABLE_LOCAL_CANDIDATE is specified. |
| 214 bool emit_local_for_anyaddress_; |
216 | 215 |
217 friend class StunBindingRequest; | 216 friend class StunBindingRequest; |
218 }; | 217 }; |
219 | 218 |
220 class StunPort : public UDPPort { | 219 class StunPort : public UDPPort { |
221 public: | 220 public: |
222 static StunPort* Create(rtc::Thread* thread, | 221 static StunPort* Create(rtc::Thread* thread, |
223 rtc::PacketSocketFactory* factory, | 222 rtc::PacketSocketFactory* factory, |
224 rtc::Network* network, | 223 rtc::Network* network, |
225 const rtc::IPAddress& ip, | 224 const rtc::IPAddress& ip, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 false) { | 268 false) { |
270 // UDPPort will set these to local udp, updating these to STUN. | 269 // UDPPort will set these to local udp, updating these to STUN. |
271 set_type(STUN_PORT_TYPE); | 270 set_type(STUN_PORT_TYPE); |
272 set_server_addresses(servers); | 271 set_server_addresses(servers); |
273 } | 272 } |
274 }; | 273 }; |
275 | 274 |
276 } // namespace cricket | 275 } // namespace cricket |
277 | 276 |
278 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ | 277 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ |
OLD | NEW |