OLD | NEW |
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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 size_t network_prefix = 0; | 101 size_t network_prefix = 0; |
102 CHECK(ParseCIDRBlock(network_tokenizer.token(), | 102 CHECK(ParseCIDRBlock(network_tokenizer.token(), |
103 &address, | 103 &address, |
104 &network_prefix)); | 104 &network_prefix)); |
105 | 105 |
106 CHECK(network_tokenizer.GetNext()); | 106 CHECK(network_tokenizer.GetNext()); |
107 uint32 index = 0; | 107 uint32 index = 0; |
108 CHECK(base::StringToUint(network_tokenizer.token(), &index)); | 108 CHECK(base::StringToUint(network_tokenizer.token(), &index)); |
109 | 109 |
110 networks->push_back( | 110 networks->push_back( |
111 NetworkInterface(name, name, index, address, network_prefix)); | 111 NetworkInterface(name, name, index, NETWORK_INTERFACE_UNKNOWN, |
| 112 address, network_prefix)); |
112 } | 113 } |
113 return true; | 114 return true; |
114 #else | 115 #else |
115 // getifaddrs() may require IO operations. | 116 // getifaddrs() may require IO operations. |
116 base::ThreadRestrictions::AssertIOAllowed(); | 117 base::ThreadRestrictions::AssertIOAllowed(); |
117 | 118 |
118 int ioctl_socket = -1; | 119 int ioctl_socket = -1; |
119 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) { | 120 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) { |
120 // we need a socket to query information about temporary address. | 121 // we need a socket to query information about temporary address. |
121 ioctl_socket = socket(AF_INET6, SOCK_DGRAM, 0); | 122 ioctl_socket = socket(AF_INET6, SOCK_DGRAM, 0); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 // If not otherwise set, assume the same sa_family as ifa_addr. | 202 // If not otherwise set, assume the same sa_family as ifa_addr. |
202 if (interface->ifa_netmask->sa_family == 0) { | 203 if (interface->ifa_netmask->sa_family == 0) { |
203 interface->ifa_netmask->sa_family = addr->sa_family; | 204 interface->ifa_netmask->sa_family = addr->sa_family; |
204 } | 205 } |
205 IPEndPoint netmask; | 206 IPEndPoint netmask; |
206 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { | 207 if (netmask.FromSockAddr(interface->ifa_netmask, addr_size)) { |
207 net_mask = MaskPrefixLength(netmask.address()); | 208 net_mask = MaskPrefixLength(netmask.address()); |
208 } | 209 } |
209 } | 210 } |
210 network_info.interface = NetworkInterface( | 211 network_info.interface = NetworkInterface( |
211 name, name, if_nametoindex(name.c_str()), | 212 name, name, if_nametoindex(name.c_str()), NETWORK_INTERFACE_UNKNOWN, |
212 address.address(), net_mask); | 213 address.address(), net_mask); |
213 | 214 |
214 network_infos.push_back(NetworkInterfaceInfo(network_info)); | 215 network_infos.push_back(NetworkInterfaceInfo(network_info)); |
215 } | 216 } |
216 } | 217 } |
217 freeifaddrs(interfaces); | 218 freeifaddrs(interfaces); |
218 if (ioctl_socket >= 0) { | 219 if (ioctl_socket >= 0) { |
219 close(ioctl_socket); | 220 close(ioctl_socket); |
220 } | 221 } |
221 | 222 |
222 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) { | 223 if (policy & INCLUDE_ONLY_TEMP_IPV6_ADDRESS_IF_POSSIBLE) { |
223 RemovePermanentIPv6AddressesWhereTemporaryExists(&network_infos); | 224 RemovePermanentIPv6AddressesWhereTemporaryExists(&network_infos); |
224 } | 225 } |
225 | 226 |
226 for (size_t i = 0; i < network_infos.size(); ++i) { | 227 for (size_t i = 0; i < network_infos.size(); ++i) { |
227 networks->push_back(network_infos[i].interface); | 228 networks->push_back(network_infos[i].interface); |
228 } | 229 } |
229 return true; | 230 return true; |
230 #endif | 231 #endif |
231 } | 232 } |
232 | 233 |
233 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { | 234 WifiPHYLayerProtocol GetWifiPHYLayerProtocol() { |
234 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; | 235 return WIFI_PHY_LAYER_PROTOCOL_UNKNOWN; |
235 } | 236 } |
236 | 237 |
237 } // namespace net | 238 } // namespace net |
OLD | NEW |