| Index: content/renderer/p2p/ipc_network_manager.cc
|
| diff --git a/content/renderer/p2p/ipc_network_manager.cc b/content/renderer/p2p/ipc_network_manager.cc
|
| index d1ea5ca5d26560fda2b0802e6b689c77c168d0bd..567af8dff3fa3c56fbe23f1b5ffd3f37c66b8867 100644
|
| --- a/content/renderer/p2p/ipc_network_manager.cc
|
| +++ b/content/renderer/p2p/ipc_network_manager.cc
|
| @@ -13,10 +13,12 @@
|
| #include "base/sys_byteorder.h"
|
| #include "base/thread_task_runner_handle.h"
|
| #include "content/public/common/content_switches.h"
|
| +#include "jingle/glue/utils.h"
|
| #include "net/base/ip_address_number.h"
|
| #include "net/base/net_util.h"
|
| #include "net/base/network_change_notifier.h"
|
| #include "net/base/network_interfaces.h"
|
| +#include "third_party/webrtc/base/socketaddress.h"
|
|
|
| namespace content {
|
|
|
| @@ -71,49 +73,50 @@ void IpcNetworkManager::StopUpdating() {
|
| }
|
|
|
| void IpcNetworkManager::OnNetworkListChanged(
|
| - const net::NetworkInterfaceList& list) {
|
| -
|
| + const net::NetworkInterfaceList& list,
|
| + const net::IPAddressNumber& default_ipv4_local_address,
|
| + const net::IPAddressNumber& default_ipv6_local_address) {
|
| // Update flag if network list received for the first time.
|
| if (!network_list_received_)
|
| network_list_received_ = true;
|
|
|
| + // Update the default local interfaces.
|
| + set_default_local_addresses(
|
| + jingle_glue::IPAddressNumberToIPAddress(default_ipv4_local_address),
|
| + jingle_glue::IPAddressNumberToIPAddress(default_ipv6_local_address));
|
| +
|
| // rtc::Network uses these prefix_length to compare network
|
| // interfaces discovered.
|
| std::vector<rtc::Network*> networks;
|
| for (net::NetworkInterfaceList::const_iterator it = list.begin();
|
| it != list.end(); it++) {
|
| + rtc::IPAddress ip_address =
|
| + jingle_glue::IPAddressNumberToIPAddress(it->address);
|
| + DCHECK(!ip_address.IsNil());
|
| +
|
| + rtc::IPAddress prefix = rtc::TruncateIP(ip_address, it->prefix_length);
|
| + scoped_ptr<rtc::Network> network(
|
| + new rtc::Network(it->name, it->name, prefix, it->prefix_length,
|
| + ConvertConnectionTypeToAdapterType(it->type)));
|
| + network->set_default_local_address_provider(this);
|
| +
|
| + rtc::InterfaceAddress iface_addr;
|
| if (it->address.size() == net::kIPv4AddressSize) {
|
| - uint32 address;
|
| - memcpy(&address, &it->address[0], sizeof(uint32));
|
| - address = rtc::NetworkToHost32(address);
|
| - rtc::IPAddress prefix =
|
| - rtc::TruncateIP(rtc::IPAddress(address), it->prefix_length);
|
| - rtc::Network* network =
|
| - new rtc::Network(it->name, it->name, prefix, it->prefix_length,
|
| - ConvertConnectionTypeToAdapterType(it->type));
|
| - network->AddIP(rtc::IPAddress(address));
|
| - networks.push_back(network);
|
| - } else if (it->address.size() == net::kIPv6AddressSize) {
|
| - in6_addr address;
|
| - memcpy(&address, &it->address[0], sizeof(in6_addr));
|
| - rtc::InterfaceAddress ip6_addr(address, it->ip_address_attributes);
|
| -
|
| - // Only allow non-deprecated IPv6 addresses which don't contain MAC.
|
| - if (rtc::IPIsMacBased(ip6_addr) ||
|
| - (it->ip_address_attributes & net::IP_ADDRESS_ATTRIBUTE_DEPRECATED)) {
|
| + iface_addr = rtc::InterfaceAddress(ip_address);
|
| + } else {
|
| + DCHECK(it->address.size() == net::kIPv6AddressSize);
|
| + iface_addr = rtc::InterfaceAddress(ip_address, it->ip_address_attributes);
|
| +
|
| + // Only allow non-private, non-deprecated IPv6 addresses which don't
|
| + // contain MAC.
|
| + if (rtc::IPIsMacBased(iface_addr) ||
|
| + (it->ip_address_attributes & net::IP_ADDRESS_ATTRIBUTE_DEPRECATED) ||
|
| + rtc::IPIsPrivate(iface_addr)) {
|
| continue;
|
| }
|
| -
|
| - if (!rtc::IPIsPrivate(ip6_addr)) {
|
| - rtc::IPAddress prefix =
|
| - rtc::TruncateIP(rtc::IPAddress(ip6_addr), it->prefix_length);
|
| - rtc::Network* network =
|
| - new rtc::Network(it->name, it->name, prefix, it->prefix_length,
|
| - ConvertConnectionTypeToAdapterType(it->type));
|
| - network->AddIP(ip6_addr);
|
| - networks.push_back(network);
|
| - }
|
| }
|
| + network->AddIP(iface_addr);
|
| + networks.push_back(network.release());
|
| }
|
|
|
| if (base::CommandLine::ForCurrentProcess()->HasSwitch(
|
| @@ -122,6 +125,7 @@ void IpcNetworkManager::OnNetworkListChanged(
|
| rtc::IPAddress ip_address_v4(INADDR_LOOPBACK);
|
| rtc::Network* network_v4 = new rtc::Network(
|
| name_v4, name_v4, ip_address_v4, 32, rtc::ADAPTER_TYPE_UNKNOWN);
|
| + network_v4->set_default_local_address_provider(this);
|
| network_v4->AddIP(ip_address_v4);
|
| networks.push_back(network_v4);
|
|
|
| @@ -129,6 +133,7 @@ void IpcNetworkManager::OnNetworkListChanged(
|
| rtc::IPAddress ip_address_v6(in6addr_loopback);
|
| rtc::Network* network_v6 = new rtc::Network(
|
| name_v6, name_v6, ip_address_v6, 64, rtc::ADAPTER_TYPE_UNKNOWN);
|
| + network_v6->set_default_local_address_provider(this);
|
| network_v6->AddIP(ip_address_v6);
|
| networks.push_back(network_v6);
|
| }
|
|
|