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

Side by Side Diff: net/base/net_util_posix.cc

Issue 105653003: GetNetworkList() copies sa_family of ifa_addr to ifa_netmask if unset (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase onto HEAD Created 7 years 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <sys/types.h> 7 #include <sys/types.h>
8 8
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 } else { 136 } else {
137 // Skip non-IP addresses. 137 // Skip non-IP addresses.
138 continue; 138 continue;
139 } 139 }
140 140
141 IPEndPoint address; 141 IPEndPoint address;
142 std::string name = interface->ifa_name; 142 std::string name = interface->ifa_name;
143 if (address.FromSockAddr(addr, addr_size)) { 143 if (address.FromSockAddr(addr, addr_size)) {
144 uint8 net_mask = 0; 144 uint8 net_mask = 0;
145 if (interface->ifa_netmask) { 145 if (interface->ifa_netmask) {
146 // If not otherwise set, assume the same sa_family as ifa_addr.
147 if (interface->ifa_netmask->sa_family == 0) {
148 interface->ifa_netmask->sa_family = addr->sa_family;
149 }
146 IPEndPoint netmask; 150 IPEndPoint netmask;
147 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { 151 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) {
148 net_mask = MaskPrefixLength(netmask.address()); 152 net_mask = MaskPrefixLength(netmask.address());
149 } 153 }
150 } 154 }
151 155
152 networks->push_back( 156 networks->push_back(
153 NetworkInterface(name, if_nametoindex(name.c_str()), 157 NetworkInterface(name, if_nametoindex(name.c_str()),
154 address.address(), net_mask)); 158 address.address(), net_mask));
155 } 159 }
156 } 160 }
157 161
158 freeifaddrs(interfaces); 162 freeifaddrs(interfaces);
159 163
160 return true; 164 return true;
161 #endif 165 #endif
162 } 166 }
163 167
164 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { 168 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() {
165 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; 169 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN;
166 } 170 }
167 171
168 } // namespace net 172 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698