Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Unified Diff: net/base/net_util_posix.cc

Issue 23726043: Added NetworkInterface::network_prefix (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..6bd64c01404a7766abfcacc1928ab1f359ff1bbe 100644
--- a/net/base/net_util_posix.cc
+++ b/net/base/net_util_posix.cc
@@ -133,10 +133,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));
}
}

Powered by Google App Engine
This is Rietveld 408576698