Index: net/base/net_util_posix.cc |
diff --git a/net/base/net_util_posix.cc b/net/base/net_util_posix.cc |
index 904d8028bc26e22d76bc05bda11705838d010326..ad003f73765865c682c5130c70c631c318fdd7c4 100644 |
--- a/net/base/net_util_posix.cc |
+++ b/net/base/net_util_posix.cc |
@@ -9,6 +9,7 @@ |
#include "base/files/file_path.h" |
#include "base/logging.h" |
#include "base/posix/eintr_wrapper.h" |
+#include "base/strings/string_number_conversions.h" |
#include "base/strings/string_tokenizer.h" |
#include "base/strings/string_util.h" |
#include "base/threading/thread_restrictions.h" |
@@ -80,10 +81,21 @@ bool GetNetworkList(NetworkInterfaceList* networks) { |
continue; |
szym
2013/09/23 17:26:55
I don't quite understand why the code here silentl
|
literal_address = network_tokenizer.token(); |
+ uint8 net_mask = 0; |
+ if (network_tokenizer.GetNext()) { |
+ unsigned int_token = 0; |
+ if (base::StringToUint(network_tokenizer.token(), &int_token) && |
+ int_token <= 255) { |
+ net_mask = int_token; |
+ } else { |
+ NOTREACHED(); |
szym
2013/09/23 17:26:55
This should be consistent with the rest of the cod
|
+ } |
+ } |
+ |
IPAddressNumber address; |
if (!ParseIPLiteralToNumber(literal_address, &address)) |
continue; |
- networks->push_back(NetworkInterface(name, address)); |
+ networks->push_back(NetworkInterface(name, address, net_mask)); |
} |
return true; |
#else |
@@ -133,10 +145,19 @@ bool GetNetworkList(NetworkInterfaceList* networks) { |
// Skip non-IP addresses. |
continue; |
} |
+ |
IPEndPoint address; |
std::string name = interface->ifa_name; |
if (address.FromSockAddr(addr, addr_size)) { |
- networks->push_back(NetworkInterface(name, address.address())); |
+ uint8 net_mask = 0; |
+ if (interface->ifa_netmask) { |
+ IPEndPoint netmask; |
+ if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { |
+ net_mask = MaskPrefixLength(netmask.address()); |
+ } |
+ } |
+ |
+ networks->push_back(NetworkInterface(name, address.address(), net_mask)); |
} |
} |