Push IPv6 addresses to libjingle PortAllocator.

Currently we have disabled IPv6 support in libjingle, but
there is effort going on to support it. This is the one of the first step in that process.

TBR=sergeyu@chromium.org
BUG=https://code.google.com/p/webrtc/issues/detail?id=1406

Review URL: https://codereview.chromium.org/30193002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233473 0039d316-1c4b-4281-b951-d872f2087c98
parent 0f642e8c
......@@ -46,18 +46,32 @@ void IpcNetworkManager::OnNetworkListChanged(
if (!network_list_received_)
network_list_received_ = true;
// Note: 32 and 64 are the arbitrary(kind of) prefix length used to
// differentiate IPv4 and IPv6 addresses.
// talk_base::Network uses these prefix_length to compare network
// interfaces discovered.
std::vector<talk_base::Network*> networks;
for (net::NetworkInterfaceList::const_iterator it = list.begin();
it != list.end(); it++) {
if (it->address.size() == net::kIPv4AddressSize) {
uint32 address;
if (it->address.size() != net::kIPv4AddressSize)
continue;
memcpy(&address, &it->address[0], sizeof(uint32));
address = talk_base::NetworkToHost32(address);
talk_base::Network* network = new talk_base::Network(
it->name, it->name, talk_base::IPAddress(address), 32);
network->AddIP(talk_base::IPAddress(address));
networks.push_back(network);
} else if (it->address.size() == net::kIPv6AddressSize) {
in6_addr address;
memcpy(&address, &it->address[0], sizeof(in6_addr));
talk_base::IPAddress ip6_addr(address);
if (!talk_base::IPIsPrivate(ip6_addr)) {
talk_base::Network* network = new talk_base::Network(
it->name, it->name, ip6_addr, 64);
network->AddIP(ip6_addr);
networks.push_back(network);
}
}
}
bool changed = false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment