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

Side by Side Diff: webrtc/base/virtualsocketserver.h

Issue 1274013002: Bug 4865: Enable connectivity when the remote peer is on public internet. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 5 years, 4 months 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
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 20 matching lines...) Expand all
31 // they are bound to addresses from incompatible families. 31 // they are bound to addresses from incompatible families.
32 class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { 32 class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> {
33 public: 33 public:
34 // TODO: Add "owned" parameter. 34 // TODO: Add "owned" parameter.
35 // If "owned" is set, the supplied socketserver will be deleted later. 35 // If "owned" is set, the supplied socketserver will be deleted later.
36 explicit VirtualSocketServer(SocketServer* ss); 36 explicit VirtualSocketServer(SocketServer* ss);
37 ~VirtualSocketServer() override; 37 ~VirtualSocketServer() override;
38 38
39 SocketServer* socketserver() { return server_; } 39 SocketServer* socketserver() { return server_; }
40 40
41 // The default route indicates which local address to use when a socket is
42 // bound to the 'any' address, e.g. 0.0.0.0.
43 IPAddress GetDefaultRoute(int family);
44 void SetDefaultRoute(const IPAddress& from_addr);
45
41 // Limits the network bandwidth (maximum bytes per second). Zero means that 46 // Limits the network bandwidth (maximum bytes per second). Zero means that
42 // all sends occur instantly. Defaults to 0. 47 // all sends occur instantly. Defaults to 0.
43 uint32 bandwidth() const { return bandwidth_; } 48 uint32 bandwidth() const { return bandwidth_; }
44 void set_bandwidth(uint32 bandwidth) { bandwidth_ = bandwidth; } 49 void set_bandwidth(uint32 bandwidth) { bandwidth_ = bandwidth; }
45 50
46 // Limits the amount of data which can be in flight on the network without 51 // Limits the amount of data which can be in flight on the network without
47 // packet loss (on a per sender basis). Defaults to 64 KB. 52 // packet loss (on a per sender basis). Defaults to 64 KB.
48 uint32 network_capacity() const { return network_capacity_; } 53 uint32 network_capacity() const { return network_capacity_; }
49 void set_network_capacity(uint32 capacity) { 54 void set_network_capacity(uint32 capacity) {
50 network_capacity_ = capacity; 55 network_capacity_ = capacity;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 bool server_owned_; 222 bool server_owned_;
218 MessageQueue* msg_queue_; 223 MessageQueue* msg_queue_;
219 bool stop_on_idle_; 224 bool stop_on_idle_;
220 uint32 network_delay_; 225 uint32 network_delay_;
221 in_addr next_ipv4_; 226 in_addr next_ipv4_;
222 in6_addr next_ipv6_; 227 in6_addr next_ipv6_;
223 uint16 next_port_; 228 uint16 next_port_;
224 AddressMap* bindings_; 229 AddressMap* bindings_;
225 ConnectionMap* connections_; 230 ConnectionMap* connections_;
226 231
232 IPAddress default_route_v4_;
233 IPAddress default_route_v6_;
234
227 uint32 bandwidth_; 235 uint32 bandwidth_;
228 uint32 network_capacity_; 236 uint32 network_capacity_;
229 uint32 send_buffer_capacity_; 237 uint32 send_buffer_capacity_;
230 uint32 recv_buffer_capacity_; 238 uint32 recv_buffer_capacity_;
231 uint32 delay_mean_; 239 uint32 delay_mean_;
232 uint32 delay_stddev_; 240 uint32 delay_stddev_;
233 uint32 delay_samples_; 241 uint32 delay_samples_;
234 Function* delay_dist_; 242 Function* delay_dist_;
235 CriticalSection delay_crit_; 243 CriticalSection delay_crit_;
236 244
237 double drop_prob_; 245 double drop_prob_;
238 DISALLOW_COPY_AND_ASSIGN(VirtualSocketServer); 246 DISALLOW_COPY_AND_ASSIGN(VirtualSocketServer);
239 }; 247 };
240 248
241 // Implements the socket interface using the virtual network. Packets are 249 // Implements the socket interface using the virtual network. Packets are
242 // passed as messages using the message queue of the socket server. 250 // passed as messages using the message queue of the socket server.
243 class VirtualSocket : public AsyncSocket, public MessageHandler { 251 class VirtualSocket : public AsyncSocket, public MessageHandler {
244 public: 252 public:
245 VirtualSocket(VirtualSocketServer* server, int family, int type, bool async); 253 VirtualSocket(VirtualSocketServer* server, int family, int type, bool async);
246 ~VirtualSocket() override; 254 ~VirtualSocket() override;
247 255
248 SocketAddress GetLocalAddress() const override; 256 SocketAddress GetLocalAddress() const override;
249 SocketAddress GetRemoteAddress() const override; 257 SocketAddress GetRemoteAddress() const override;
250 258
251 // Used by server sockets to set the local address without binding.
252 void SetLocalAddress(const SocketAddress& addr);
253
254 // Used by TurnPortTest to mimic a case where proxy returns local host address 259 // Used by TurnPortTest to mimic a case where proxy returns local host address
255 // instead of the original one TurnPort was bound against. Please see WebRTC 260 // instead of the original one TurnPort was bound against. Please see WebRTC
256 // issue 3927 for more detail. 261 // issue 3927 for more detail.
257 void SetAlternativeLocalAddress(const SocketAddress& addr); 262 void SetAlternativeLocalAddress(const SocketAddress& addr);
258 263
259 int Bind(const SocketAddress& addr) override; 264 int Bind(const SocketAddress& addr) override;
260 int Connect(const SocketAddress& addr) override; 265 int Connect(const SocketAddress& addr) override;
261 int Close() override; 266 int Close() override;
262 int Send(const void* pv, size_t cb) override; 267 int Send(const void* pv, size_t cb) override;
263 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override; 268 int SendTo(const void* pv, size_t cb, const SocketAddress& addr) override;
(...skipping 26 matching lines...) Expand all
290 typedef std::deque<NetworkEntry> NetworkQueue; 295 typedef std::deque<NetworkEntry> NetworkQueue;
291 typedef std::vector<char> SendBuffer; 296 typedef std::vector<char> SendBuffer;
292 typedef std::list<Packet*> RecvBuffer; 297 typedef std::list<Packet*> RecvBuffer;
293 typedef std::map<Option, int> OptionsMap; 298 typedef std::map<Option, int> OptionsMap;
294 299
295 int InitiateConnect(const SocketAddress& addr, bool use_delay); 300 int InitiateConnect(const SocketAddress& addr, bool use_delay);
296 void CompleteConnect(const SocketAddress& addr, bool notify); 301 void CompleteConnect(const SocketAddress& addr, bool notify);
297 int SendUdp(const void* pv, size_t cb, const SocketAddress& addr); 302 int SendUdp(const void* pv, size_t cb, const SocketAddress& addr);
298 int SendTcp(const void* pv, size_t cb); 303 int SendTcp(const void* pv, size_t cb);
299 304
305 // Used by server sockets to set the local address without binding.
306 void SetLocalAddress(const SocketAddress& addr);
307
300 VirtualSocketServer* server_; 308 VirtualSocketServer* server_;
301 int family_; 309 int family_;
302 int type_; 310 int type_;
303 bool async_; 311 bool async_;
304 ConnState state_; 312 ConnState state_;
305 int error_; 313 int error_;
306 SocketAddress local_addr_; 314 SocketAddress local_addr_;
307 SocketAddress alternative_local_addr_; 315 SocketAddress alternative_local_addr_;
308 SocketAddress remote_addr_; 316 SocketAddress remote_addr_;
309 317
(...skipping 27 matching lines...) Expand all
337 345
338 // Store the options that are set 346 // Store the options that are set
339 OptionsMap options_map_; 347 OptionsMap options_map_;
340 348
341 friend class VirtualSocketServer; 349 friend class VirtualSocketServer;
342 }; 350 };
343 351
344 } // namespace rtc 352 } // namespace rtc
345 353
346 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_ 354 #endif // WEBRTC_BASE_VIRTUALSOCKETSERVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698