Index: content/renderer/p2p/ipc_network_manager.cc |
=================================================================== |
--- content/renderer/p2p/ipc_network_manager.cc (revision 229244) |
+++ content/renderer/p2p/ipc_network_manager.cc (working copy) |
@@ -3,7 +3,7 @@ |
// found in the LICENSE file. |
#include "content/renderer/p2p/ipc_network_manager.h" |
- |
+#include <iostream> |
#include "base/bind.h" |
#include "base/sys_byteorder.h" |
#include "net/base/net_util.h" |
@@ -49,15 +49,28 @@ |
std::vector<talk_base::Network*> networks; |
for (net::NetworkInterfaceList::const_iterator it = list.begin(); |
it != list.end(); it++) { |
- 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); |
+ if (it->address.size() == net::kIPv4AddressSize) { |
+ uint32 address; |
+ memcpy(&address, &it->address[0], sizeof(uint32)); |
+ address = talk_base::NetworkToHost32(address); |
+ talk_base::IPAddress ip4_addr(address); |
+ int prefix_length = talk_base::CountIPMaskBits(ip4_addr); |
Ronghua Wu (Left Chromium)
2013/10/21 16:49:58
Is the CountIPMaskBits (returns the number of cont
Mallinath (Gone from Chromium)
2013/10/21 16:55:46
Agree. Prefix length should be used for only ident
|
+ talk_base::Network* network = new talk_base::Network( |
+ it->name, it->name, talk_base::TruncateIP(ip4_addr, prefix_length), |
+ prefix_length); |
+ network->AddIP(ip4_addr); |
+ 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); |
+ int prefix_length = talk_base::CountIPMaskBits(ip6_addr); |
+ talk_base::Network* network = new talk_base::Network( |
+ it->name, it->name, talk_base::TruncateIP(ip6_addr, prefix_length), |
+ prefix_length); |
+ network->AddIP(ip6_addr); |
+ networks.push_back(network); |
+ } |
} |
bool changed = false; |