Index: webrtc/base/virtualsocketserver.h |
diff --git a/webrtc/base/virtualsocketserver.h b/webrtc/base/virtualsocketserver.h |
index b96269c52c46e93b12f2d79afe8ab8508321f202..39f2bae97ad6175d35018ce636cca0ce022c1e0d 100644 |
--- a/webrtc/base/virtualsocketserver.h |
+++ b/webrtc/base/virtualsocketserver.h |
@@ -43,6 +43,25 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { |
uint32 bandwidth() const { return bandwidth_; } |
void set_bandwidth(uint32 bandwidth) { bandwidth_ = bandwidth; } |
+ // Default interface will be used when a binding is done against the any |
+ // address. |
+ const IPAddress default_interface(int family) { |
juberti1
2015/08/06 00:35:26
Style: if it takes arguments, it's usually not low
pthatcher1
2015/08/06 01:06:19
I think this should be GetDefaultRoute.
guoweis_webrtc
2015/08/06 08:50:06
Done.
|
+ if (family == AF_INET) { |
+ return default_interface_v4_; |
+ } |
+ if (family == AF_INET6) { |
+ return default_interface_v6_; |
+ } |
+ return IPAddress(); |
+ } |
+ void set_default_interface(const IPAddress& ipaddr) { |
pthatcher1
2015/08/06 01:06:19
And this should be SetDefaultRoute.
|
+ if (ipaddr.family() == AF_INET) { |
+ default_interface_v4_ = ipaddr; |
+ } else if (ipaddr.family() == AF_INET6) { |
+ default_interface_v6_ = ipaddr; |
+ } |
+ } |
+ |
// Limits the amount of data which can be in flight on the network without |
// packet loss (on a per sender basis). Defaults to 64 KB. |
uint32 network_capacity() const { return network_capacity_; } |
@@ -124,6 +143,10 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { |
IPAddress GetNextIP(int family); |
uint16 GetNextPort(); |
+ // Helper function to return the binding from the any address to default |
+ // interface. |
+ const SocketAddress TryMapAnyAddressToDefault(const SocketAddress& addr); |
+ |
VirtualSocket* CreateSocketInternal(int family, int type); |
// Binds the given socket to addr, assigning and IP and Port if necessary |
@@ -224,6 +247,9 @@ class VirtualSocketServer : public SocketServer, public sigslot::has_slots<> { |
AddressMap* bindings_; |
ConnectionMap* connections_; |
+ IPAddress default_interface_v4_; |
+ IPAddress default_interface_v6_; |
pthatcher1
2015/08/06 01:06:19
And this default_route_vX_;
|
+ |
uint32 bandwidth_; |
uint32 network_capacity_; |
uint32 send_buffer_capacity_; |
@@ -248,9 +274,6 @@ class VirtualSocket : public AsyncSocket, public MessageHandler { |
SocketAddress GetLocalAddress() const override; |
SocketAddress GetRemoteAddress() const override; |
- // Used by server sockets to set the local address without binding. |
- void SetLocalAddress(const SocketAddress& addr); |
- |
// Used by TurnPortTest to mimic a case where proxy returns local host address |
// instead of the original one TurnPort was bound against. Please see WebRTC |
// issue 3927 for more detail. |
@@ -297,6 +320,9 @@ class VirtualSocket : public AsyncSocket, public MessageHandler { |
int SendUdp(const void* pv, size_t cb, const SocketAddress& addr); |
int SendTcp(const void* pv, size_t cb); |
+ // Used by server sockets to set the local address without binding. |
+ void SetLocalAddress(const SocketAddress& addr); |
+ |
VirtualSocketServer* server_; |
int family_; |
int type_; |