Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: webrtc/p2p/base/stunport.h

Issue 1411253008: WebRTC should generate default private address even when adapter enumeration is disabled. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: after rebase on master Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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);
138 void OnReadPacket(rtc::AsyncPacketSocket* socket, 136 void OnReadPacket(rtc::AsyncPacketSocket* socket,
139 const char* data, size_t size, 137 const char* data, size_t size,
140 const rtc::SocketAddress& remote_addr, 138 const rtc::SocketAddress& remote_addr,
141 const rtc::PacketTime& packet_time); 139 const rtc::PacketTime& packet_time);
142 140
143 void OnSentPacket(rtc::AsyncPacketSocket* socket, 141 void OnSentPacket(rtc::AsyncPacketSocket* socket,
144 const rtc::SentPacket& sent_packet); 142 const rtc::SentPacket& sent_packet);
145 143
146 void OnReadyToSend(rtc::AsyncPacketSocket* socket); 144 void OnReadyToSend(rtc::AsyncPacketSocket* socket);
147 145
148 // This method will send STUN binding request if STUN server address is set. 146 // This method will send STUN binding request if STUN server address is set.
149 void MaybePrepareStunCandidate(); 147 void MaybePrepareStunCandidate();
150 148
151 void SendStunBindingRequests(); 149 void SendStunBindingRequests();
152 150
151 // Helper function which will set |addr|'s IP to the default local address if
152 // |addr| is the "any" address and |emit_local_for_anyaddress_| is true.
153 void MaybeSetDefaultLocalAddress(rtc::SocketAddress* addr) const;
154
153 private: 155 private:
154 // A helper class which can be called repeatedly to resolve multiple 156 // A helper class which can be called repeatedly to resolve multiple
155 // addresses, as opposed to rtc::AsyncResolverInterface, which can only 157 // addresses, as opposed to rtc::AsyncResolverInterface, which can only
156 // resolve one address per instance. 158 // resolve one address per instance.
157 class AddressResolver : public sigslot::has_slots<> { 159 class AddressResolver : public sigslot::has_slots<> {
158 public: 160 public:
159 explicit AddressResolver(rtc::PacketSocketFactory* factory); 161 explicit AddressResolver(rtc::PacketSocketFactory* factory);
160 ~AddressResolver(); 162 ~AddressResolver();
161 163
162 void Resolve(const rtc::SocketAddress& address); 164 void Resolve(const rtc::SocketAddress& address);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 ServerAddresses server_addresses_; 206 ServerAddresses server_addresses_;
205 ServerAddresses bind_request_succeeded_servers_; 207 ServerAddresses bind_request_succeeded_servers_;
206 ServerAddresses bind_request_failed_servers_; 208 ServerAddresses bind_request_failed_servers_;
207 StunRequestManager requests_; 209 StunRequestManager requests_;
208 rtc::AsyncPacketSocket* socket_; 210 rtc::AsyncPacketSocket* socket_;
209 int error_; 211 int error_;
210 rtc::scoped_ptr<AddressResolver> resolver_; 212 rtc::scoped_ptr<AddressResolver> resolver_;
211 bool ready_; 213 bool ready_;
212 int stun_keepalive_delay_; 214 int stun_keepalive_delay_;
213 215
214 // This is true when PORTALLOCATOR_ENABLE_LOCALHOST_CANDIDATE is specified. 216 // This is true by default and false when
215 bool emit_localhost_for_anyaddress_; 217 // PORTALLOCATOR_DISABLE_DEFAULT_LOCAL_CANDIDATE is specified.
218 bool emit_local_for_anyaddress_;
216 219
217 friend class StunBindingRequest; 220 friend class StunBindingRequest;
218 }; 221 };
219 222
220 class StunPort : public UDPPort { 223 class StunPort : public UDPPort {
221 public: 224 public:
222 static StunPort* Create(rtc::Thread* thread, 225 static StunPort* Create(rtc::Thread* thread,
223 rtc::PacketSocketFactory* factory, 226 rtc::PacketSocketFactory* factory,
224 rtc::Network* network, 227 rtc::Network* network,
225 const rtc::IPAddress& ip, 228 const rtc::IPAddress& ip,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 false) { 272 false) {
270 // UDPPort will set these to local udp, updating these to STUN. 273 // UDPPort will set these to local udp, updating these to STUN.
271 set_type(STUN_PORT_TYPE); 274 set_type(STUN_PORT_TYPE);
272 set_server_addresses(servers); 275 set_server_addresses(servers);
273 } 276 }
274 }; 277 };
275 278
276 } // namespace cricket 279 } // namespace cricket
277 280
278 #endif // WEBRTC_P2P_BASE_STUNPORT_H_ 281 #endif // WEBRTC_P2P_BASE_STUNPORT_H_
OLDNEW
« no previous file with comments | « webrtc/p2p/base/portallocator.h ('k') | webrtc/p2p/base/stunport.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698