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

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

Issue 580283002: Interface change for net_util.h for WebRTC IPv6 support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: modify one extra test case for the new NetworkInterface constructor parameter Created 6 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 unified diff | Download patch
« no previous file with comments | « net/base/net_util.cc ('k') | net/base/net_util_win.cc » ('j') | 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 <set> 7 #include <set>
8 #include <sys/types.h> 8 #include <sys/types.h>
9 9
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 size_t network_prefix = 0; 133 size_t network_prefix = 0;
134 CHECK(ParseCIDRBlock(network_tokenizer.token(), 134 CHECK(ParseCIDRBlock(network_tokenizer.token(),
135 &address, 135 &address,
136 &network_prefix)); 136 &network_prefix));
137 137
138 CHECK(network_tokenizer.GetNext()); 138 CHECK(network_tokenizer.GetNext());
139 uint32 index = 0; 139 uint32 index = 0;
140 CHECK(base::StringToUint(network_tokenizer.token(), &index)); 140 CHECK(base::StringToUint(network_tokenizer.token(), &index));
141 141
142 networks->push_back( 142 networks->push_back(
143 NetworkInterface(name, name, index, 143 NetworkInterface(name,
144 name,
145 index,
144 NetworkChangeNotifier::CONNECTION_UNKNOWN, 146 NetworkChangeNotifier::CONNECTION_UNKNOWN,
145 address, network_prefix)); 147 address,
148 network_prefix,
149 IP_ADDRESS_ATTRIBUTE_NONE));
146 } 150 }
147 return true; 151 return true;
148 #else 152 #else
149 // getifaddrs() may require IO operations. 153 // getifaddrs() may require IO operations.
150 base::ThreadRestrictions::AssertIOAllowed(); 154 base::ThreadRestrictions::AssertIOAllowed();
151 155
152 #if defined(OS_MACOSX) && !defined(OS_IOS) 156 #if defined(OS_MACOSX) && !defined(OS_IOS)
153 int ioctl_socket = -1; 157 int ioctl_socket = -1;
154 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) { 158 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) {
155 // we need a socket to query information about temporary address. 159 // we need a socket to query information about temporary address.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 if (interface->ifa_netmask) { 244 if (interface->ifa_netmask) {
241 // If not otherwise set, assume the same sa_family as ifa_addr. 245 // If not otherwise set, assume the same sa_family as ifa_addr.
242 if (interface->ifa_netmask->sa_family == 0) { 246 if (interface->ifa_netmask->sa_family == 0) {
243 interface->ifa_netmask->sa_family = addr->sa_family; 247 interface->ifa_netmask->sa_family = addr->sa_family;
244 } 248 }
245 IPEndPoint netmask; 249 IPEndPoint netmask;
246 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { 250 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) {
247 net_mask = MaskPrefixLength(netmask.address()); 251 net_mask = MaskPrefixLength(netmask.address());
248 } 252 }
249 } 253 }
250 network_info.interface = NetworkInterface( 254 network_info.interface = NetworkInterface(name,
251 name, name, if_nametoindex(name.c_str()), 255 name,
252 connection_type, address.address(), net_mask); 256 if_nametoindex(name.c_str()),
257 connection_type,
258 address.address(),
259 net_mask,
260 IP_ADDRESS_ATTRIBUTE_NONE);
253 261
254 network_infos.push_back(NetworkInterfaceInfo(network_info)); 262 network_infos.push_back(NetworkInterfaceInfo(network_info));
255 } 263 }
256 } 264 }
257 freeifaddrs(interfaces); 265 freeifaddrs(interfaces);
258 #if defined(OS_MACOSX) && !defined(OS_IOS) 266 #if defined(OS_MACOSX) && !defined(OS_IOS)
259 if (ioctl_socket >= 0) { 267 if (ioctl_socket >= 0) {
260 close(ioctl_socket); 268 close(ioctl_socket);
261 } 269 }
262 #endif 270 #endif
263 271
264 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) { 272 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) {
265 RemovePermanentIPv6AddressesWhereTemporaryExists(&network_infos); 273 RemovePermanentIPv6AddressesWhereTemporaryExists(&network_infos);
266 } 274 }
267 275
268 for (size_t i = 0; i < network_infos.size(); ++i) { 276 for (size_t i = 0; i < network_infos.size(); ++i) {
269 networks->push_back(network_infos[i].interface); 277 networks->push_back(network_infos[i].interface);
270 } 278 }
271 return true; 279 return true;
272 #endif 280 #endif
273 } 281 }
274 282
275 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { 283 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() {
276 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; 284 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN;
277 } 285 }
278 286
279 } // namespace net 287 } // namespace net
OLDNEW
« no previous file with comments | « net/base/net_util.cc ('k') | net/base/net_util_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698