(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:
buildbot@webrtc.org 2014-05-02 18:51:11 +00:00
parent 13d6776c46
commit cc06c75f28
4 changed files with 52 additions and 21 deletions

View File

@ -109,12 +109,10 @@ class FakeNetworkManager : public NetworkManagerBase,
prefix_length = kFakeIPv6NetworkPrefixLength;
}
IPAddress prefix = TruncateIP(it->ipaddr(), prefix_length);
std::string key = MakeNetworkKey(it->hostname(), prefix, prefix_length);
scoped_ptr<Network> net(new Network(it->hostname(),
it->hostname(),
prefix,
prefix_length,
key));
prefix_length));
net->AddIP(it->ipaddr());
networks.push_back(net.release());
}

View File

@ -112,6 +112,24 @@ bool SortNetworks(const Network* a, const Network* b) {
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
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,
cursor->ifa_name,
prefix,
prefix_length,
key));
prefix_length));
network->set_scope_id(scope_id);
network->AddIP(ip);
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
@ -439,8 +456,7 @@ bool BasicNetworkManager::CreateNetworks(bool include_ignored,
scoped_ptr<Network> network(new Network(name,
description,
prefix,
prefix_length,
key));
prefix_length));
network->set_scope_id(scope_id);
network->AddIP(ip);
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,
const IPAddress& prefix, int prefix_length,
const std::string& key)
const IPAddress& prefix, int prefix_length)
: name_(name), description_(desc), prefix_(prefix),
prefix_length_(prefix_length), key_(key), scope_id_(0), ignored_(false),
type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
prefix_length_(prefix_length),
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,
const IPAddress& prefix, int prefix_length)
const IPAddress& prefix, int prefix_length, AdapterType type)
: name_(name), description_(desc), prefix_(prefix),
prefix_length_(prefix_length), scope_id_(0), ignored_(false),
type_(ADAPTER_TYPE_UNKNOWN), preference_(0) {
prefix_length_(prefix_length),
key_(MakeNetworkKey(name, prefix, prefix_length)), scope_id_(0),
ignored_(false), type_(type), preference_(0) {
}
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
// the IP address.
ss << "Net[" << description_.substr(0, description_.find(' '))
<< ":" << prefix_.ToSensitiveString() << "/" << prefix_length_ << "]";
<< ":" << prefix_.ToSensitiveString() << "/" << prefix_length_
<< ":" << AdapterTypeToString(type_) << "]";
return ss.str();
}

View File

@ -182,15 +182,12 @@ class BasicNetworkManager : public NetworkManagerBase,
// Represents a Unix-type network interface, with a name and single address.
class Network {
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,
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.
const std::string& name() const { return name_; }

View File

@ -554,6 +554,24 @@ TEST_F(NetworkTest, TestNetworkListSorting) {
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)
// Verify that we correctly handle interfaces with no address.
TEST_F(NetworkTest, TestConvertIfAddrsNoAddress) {