aboutsummaryrefslogtreecommitdiff
path: root/webrtc/base/fakenetwork.h
diff options
context:
space:
mode:
Diffstat (limited to 'webrtc/base/fakenetwork.h')
-rw-r--r--webrtc/base/fakenetwork.h33
1 files changed, 22 insertions, 11 deletions
diff --git a/webrtc/base/fakenetwork.h b/webrtc/base/fakenetwork.h
index fb99d59e1b..e3996e6649 100644
--- a/webrtc/base/fakenetwork.h
+++ b/webrtc/base/fakenetwork.h
@@ -12,6 +12,7 @@
#define WEBRTC_BASE_FAKENETWORK_H_
#include <string>
+#include <utility>
#include <vector>
#include "webrtc/base/network.h"
@@ -31,7 +32,7 @@ class FakeNetworkManager : public NetworkManagerBase,
public:
FakeNetworkManager() : thread_(Thread::Current()) {}
- typedef std::vector<SocketAddress> IfaceList;
+ typedef std::vector<std::pair<SocketAddress, AdapterType>> IfaceList;
void AddInterface(const SocketAddress& iface) {
// Ensure a unique name for the interface if its name is not given.
@@ -39,16 +40,22 @@ class FakeNetworkManager : public NetworkManagerBase,
}
void AddInterface(const SocketAddress& iface, const std::string& if_name) {
+ AddInterface(iface, if_name, ADAPTER_TYPE_UNKNOWN);
+ }
+
+ void AddInterface(const SocketAddress& iface,
+ const std::string& if_name,
+ AdapterType type) {
SocketAddress address(if_name, 0);
address.SetResolvedIP(iface.ipaddr());
- ifaces_.push_back(address);
+ ifaces_.push_back(std::make_pair(address, type));
DoUpdateNetworks();
}
void RemoveInterface(const SocketAddress& iface) {
for (IfaceList::iterator it = ifaces_.begin();
it != ifaces_.end(); ++it) {
- if (it->EqualIPs(iface)) {
+ if (it->first.EqualIPs(iface)) {
ifaces_.erase(it);
break;
}
@@ -76,6 +83,7 @@ class FakeNetworkManager : public NetworkManagerBase,
}
using NetworkManagerBase::set_enumeration_permission;
+ using NetworkManagerBase::set_default_local_addresses;
private:
void DoUpdateNetworks() {
@@ -85,17 +93,17 @@ class FakeNetworkManager : public NetworkManagerBase,
for (IfaceList::iterator it = ifaces_.begin();
it != ifaces_.end(); ++it) {
int prefix_length = 0;
- if (it->ipaddr().family() == AF_INET) {
+ if (it->first.ipaddr().family() == AF_INET) {
prefix_length = kFakeIPv4NetworkPrefixLength;
- } else if (it->ipaddr().family() == AF_INET6) {
+ } else if (it->first.ipaddr().family() == AF_INET6) {
prefix_length = kFakeIPv6NetworkPrefixLength;
}
- IPAddress prefix = TruncateIP(it->ipaddr(), prefix_length);
- scoped_ptr<Network> net(new Network(it->hostname(),
- it->hostname(),
- prefix,
- prefix_length));
- net->AddIP(it->ipaddr());
+ IPAddress prefix = TruncateIP(it->first.ipaddr(), prefix_length);
+ scoped_ptr<Network> net(new Network(it->first.hostname(),
+ it->first.hostname(), prefix,
+ prefix_length, it->second));
+ net->set_default_local_address_provider(this);
+ net->AddIP(it->first.ipaddr());
networks.push_back(net.release());
}
bool changed;
@@ -111,6 +119,9 @@ class FakeNetworkManager : public NetworkManagerBase,
int next_index_ = 0;
int start_count_ = 0;
bool sent_first_update_ = false;
+
+ IPAddress default_local_ipv4_address_;
+ IPAddress default_local_ipv6_address_;
};
} // namespace rtc