(Auto)update libjingle 66100938-> 66106643
git-svn-id: http://webrtc.googlecode.com/svn/trunk@6046 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
13d6776c46
commit
cc06c75f28
@ -109,12 +109,10 @@ class FakeNetworkManager : public NetworkManagerBase,
|
|||||||
prefix_length = kFakeIPv6NetworkPrefixLength;
|
prefix_length = kFakeIPv6NetworkPrefixLength;
|
||||||
}
|
}
|
||||||
IPAddress prefix = TruncateIP(it->ipaddr(), prefix_length);
|
IPAddress prefix = TruncateIP(it->ipaddr(), prefix_length);
|
||||||
std::string key = MakeNetworkKey(it->hostname(), prefix, prefix_length);
|
|
||||||
scoped_ptr<Network> net(new Network(it->hostname(),
|
scoped_ptr<Network> net(new Network(it->hostname(),
|
||||||
it->hostname(),
|
it->hostname(),
|
||||||
prefix,
|
prefix,
|
||||||
prefix_length,
|
prefix_length));
|
||||||
key));
|
|
||||||
net->AddIP(it->ipaddr());
|
net->AddIP(it->ipaddr());
|
||||||
networks.push_back(net.release());
|
networks.push_back(net.release());
|
||||||
}
|
}
|
||||||
|
@ -112,6 +112,24 @@ bool SortNetworks(const Network* a, const Network* b) {
|
|||||||
return a->key() > b->key();
|
return a->key() > b->key();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string AdapterTypeToString(AdapterType type) {
|
||||||
|
switch (type) {
|
||||||
|
case ADAPTER_TYPE_UNKNOWN:
|
||||||
|
return "Unknown";
|
||||||
|
case ADAPTER_TYPE_ETHERNET:
|
||||||
|
return "Ethernet";
|
||||||
|
case ADAPTER_TYPE_WIFI:
|
||||||
|
return "Wifi";
|
||||||
|
case ADAPTER_TYPE_CELLULAR:
|
||||||
|
return "Cellular";
|
||||||
|
case ADAPTER_TYPE_VPN:
|
||||||
|
return "VPN";
|
||||||
|
default:
|
||||||
|
ASSERT(false);
|
||||||
|
return std::string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
|
std::string MakeNetworkKey(const std::string& name, const IPAddress& prefix,
|
||||||
@ -292,8 +310,7 @@ void BasicNetworkManager::ConvertIfAddrs(struct ifaddrs* interfaces,
|
|||||||
scoped_ptr<Network> network(new Network(cursor->ifa_name,
|
scoped_ptr<Network> network(new Network(cursor->ifa_name,
|
||||||
cursor->ifa_name,
|
cursor->ifa_name,
|
||||||
prefix,
|
prefix,
|
||||||
prefix_length,
|
prefix_length));
|
||||||
key));
|
|
||||||
network->set_scope_id(scope_id);
|
network->set_scope_id(scope_id);
|
||||||
network->AddIP(ip);
|
network->AddIP(ip);
|
||||||
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
|
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
|
||||||
@ -439,8 +456,7 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored,
|
|||||||
scoped_ptr<Network> network(new Network(name,
|
scoped_ptr<Network> network(new Network(name,
|
||||||
description,
|
description,
|
||||||
prefix,
|
prefix,
|
||||||
prefix_length,
|
prefix_length));
|
||||||
key));
|
|
||||||
network->set_scope_id(scope_id);
|
network->set_scope_id(scope_id);
|
||||||
network->AddIP(ip);
|
network->AddIP(ip);
|
||||||
bool ignore = ((adapter_addrs->IfType == IF_TYPE_SOFTWARE_LOOPBACK) ||
|
bool ignore = ((adapter_addrs->IfType == IF_TYPE_SOFTWARE_LOOPBACK) ||
|
||||||
@ -608,18 +624,19 @@ void BasicNetworkManager::DumpNetworks(bool include_ignored) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Network::Network(const std::string& name, const std::string& desc,
|
Network::Network(const std::string& name, const std::string& desc,
|
||||||
const IPAddress& prefix, int prefix_length,
|
const IPAddress& prefix, int prefix_length)
|
||||||
const std::string& key)
|
|
||||||
: name_(name), description_(desc), prefix_(prefix),
|
: name_(name), description_(desc), prefix_(prefix),
|
||||||
prefix_length_(prefix_length), key_(key), scope_id_(0), ignored_(false),
|
prefix_length_(prefix_length),
|
||||||
type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
|
key_(MakeNetworkKey(name, prefix, prefix_length)), scope_id_(0),
|
||||||
|
ignored_(false), type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Network::Network(const std::string& name, const std::string& desc,
|
Network::Network(const std::string& name, const std::string& desc,
|
||||||
const IPAddress& prefix, int prefix_length)
|
const IPAddress& prefix, int prefix_length, AdapterType type)
|
||||||
: name_(name), description_(desc), prefix_(prefix),
|
: name_(name), description_(desc), prefix_(prefix),
|
||||||
prefix_length_(prefix_length), scope_id_(0), ignored_(false),
|
prefix_length_(prefix_length),
|
||||||
type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
|
key_(MakeNetworkKey(name, prefix, prefix_length)), scope_id_(0),
|
||||||
|
ignored_(false), type_(type), preference_(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Network::ToString() const {
|
std::string Network::ToString() const {
|
||||||
@ -627,7 +644,8 @@ std::string Network::ToString() const {
|
|||||||
// Print out the first space-terminated token of the network desc, plus
|
// Print out the first space-terminated token of the network desc, plus
|
||||||
// the IP address.
|
// the IP address.
|
||||||
ss << "Net[" << description_.substr(0, description_.find(' '))
|
ss << "Net[" << description_.substr(0, description_.find(' '))
|
||||||
<< ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ << "]";
|
<< ":" << prefix_.ToSensitiveString() << "/" << prefix_length_
|
||||||
|
<< ":" << AdapterTypeToString(type_) << "]";
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,15 +182,12 @@ class BasicNetworkManager : public NetworkManagerBase,
|
|||||||
// Represents a Unix-type network interface, with a name and single address.
|
// Represents a Unix-type network interface, with a name and single address.
|
||||||
class Network {
|
class Network {
|
||||||
public:
|
public:
|
||||||
Network() : prefix_(INADDR_ANY), scope_id_(0),
|
|
||||||
type_(ADAPTER_TYPE_UNKNOWN) {}
|
|
||||||
Network(const std::string& name, const std::string& description,
|
|
||||||
const IPAddress& prefix, int prefix_length,
|
|
||||||
const std::string& key);
|
|
||||||
|
|
||||||
Network(const std::string& name, const std::string& description,
|
Network(const std::string& name, const std::string& description,
|
||||||
const IPAddress& prefix, int prefix_length);
|
const IPAddress& prefix, int prefix_length);
|
||||||
|
|
||||||
|
Network(const std::string& name, const std::string& description,
|
||||||
|
const IPAddress& prefix, int prefix_length, AdapterType type);
|
||||||
|
|
||||||
// Returns the name of the interface this network is associated wtih.
|
// Returns the name of the interface this network is associated wtih.
|
||||||
const std::string& name() const { return name_; }
|
const std::string& name() const { return name_; }
|
||||||
|
|
||||||
|
@ -554,6 +554,24 @@ TEST_F(NetworkTest, TestNetworkListSorting) {
|
|||||||
EXPECT_TRUE(net1->preference() < net2->preference());
|
EXPECT_TRUE(net1->preference() < net2->preference());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(NetworkTest, TestNetworkAdapterTypes) {
|
||||||
|
Network wifi("wlan0", "Wireless Adapter", IPAddress(0x12345600U), 24,
|
||||||
|
ADAPTER_TYPE_WIFI);
|
||||||
|
EXPECT_EQ(ADAPTER_TYPE_WIFI, wifi.type());
|
||||||
|
Network ethernet("eth0", "Ethernet", IPAddress(0x12345600U), 24,
|
||||||
|
ADAPTER_TYPE_ETHERNET);
|
||||||
|
EXPECT_EQ(ADAPTER_TYPE_ETHERNET, ethernet.type());
|
||||||
|
Network cellular("test_cell", "Cellular Adapter", IPAddress(0x12345600U), 24,
|
||||||
|
ADAPTER_TYPE_CELLULAR);
|
||||||
|
EXPECT_EQ(ADAPTER_TYPE_CELLULAR, cellular.type());
|
||||||
|
Network vpn("bridge_test", "VPN Adapter", IPAddress(0x12345600U), 24,
|
||||||
|
ADAPTER_TYPE_VPN);
|
||||||
|
EXPECT_EQ(ADAPTER_TYPE_VPN, vpn.type());
|
||||||
|
Network unknown("test", "Test Adapter", IPAddress(0x12345600U), 24,
|
||||||
|
ADAPTER_TYPE_UNKNOWN);
|
||||||
|
EXPECT_EQ(ADAPTER_TYPE_UNKNOWN, unknown.type());
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(POSIX)
|
#if defined(POSIX)
|
||||||
// Verify that we correctly handle interfaces with no address.
|
// Verify that we correctly handle interfaces with no address.
|
||||||
TEST_F(NetworkTest, TestConvertIfAddrsNoAddress) {
|
TEST_F(NetworkTest, TestConvertIfAddrsNoAddress) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user