OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <iphlpapi.h> | 7 #include <iphlpapi.h> |
8 #include <wlanapi.h> | 8 #include <wlanapi.h> |
9 #pragma comment(lib, "iphlpapi.lib") | 9 #pragma comment(lib, "iphlpapi.lib") |
10 | 10 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if (is_xp) { | 175 if (is_xp) { |
176 // Prior to Windows Vista the FirstPrefix pointed to the list with | 176 // Prior to Windows Vista the FirstPrefix pointed to the list with |
177 // single prefix for each IP address assigned to the adapter. | 177 // single prefix for each IP address assigned to the adapter. |
178 // Order of FirstPrefix does not match order of FirstUnicastAddress, | 178 // Order of FirstPrefix does not match order of FirstUnicastAddress, |
179 // so we need to find corresponding prefix. | 179 // so we need to find corresponding prefix. |
180 for (IP_ADAPTER_PREFIX* prefix = adapter->FirstPrefix; prefix; | 180 for (IP_ADAPTER_PREFIX* prefix = adapter->FirstPrefix; prefix; |
181 prefix = prefix->Next) { | 181 prefix = prefix->Next) { |
182 int prefix_family = prefix->Address.lpSockaddr->sa_family; | 182 int prefix_family = prefix->Address.lpSockaddr->sa_family; |
183 IPEndPoint network_endpoint; | 183 IPEndPoint network_endpoint; |
184 if (prefix_family == family && | 184 if (prefix_family == family && |
185 network_endpoint.FromSockAddr(prefix->Address.lpSockaddr, | 185 network_endpoint.FromSockAddr( |
| 186 prefix->Address.lpSockaddr, |
186 prefix->Address.iSockaddrLength) && | 187 prefix->Address.iSockaddrLength) && |
187 IPNumberMatchesPrefix(endpoint.address(), | 188 IPNumberMatchesPrefix(endpoint.address_number(), |
188 network_endpoint.address(), | 189 network_endpoint.address_number(), |
189 prefix->PrefixLength)) { | 190 prefix->PrefixLength)) { |
190 prefix_length = | 191 prefix_length = |
191 std::max<size_t>(prefix_length, prefix->PrefixLength); | 192 std::max<size_t>(prefix_length, prefix->PrefixLength); |
192 } | 193 } |
193 } | 194 } |
194 } | 195 } |
195 | 196 |
196 // If the duplicate address detection (DAD) state is not changed to | 197 // If the duplicate address detection (DAD) state is not changed to |
197 // Preferred, skip this address. | 198 // Preferred, skip this address. |
198 if (address->DadState != IpDadStatePreferred) { | 199 if (address->DadState != IpDadStatePreferred) { |
(...skipping 13 matching lines...) Expand all Loading... |
212 address->SuffixOrigin == IpSuffixOriginRandom) { | 213 address->SuffixOrigin == IpSuffixOriginRandom) { |
213 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_TEMPORARY; | 214 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_TEMPORARY; |
214 } | 215 } |
215 if (address->PreferredLifetime == 0) { | 216 if (address->PreferredLifetime == 0) { |
216 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_DEPRECATED; | 217 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_DEPRECATED; |
217 } | 218 } |
218 } | 219 } |
219 networks->push_back(NetworkInterface( | 220 networks->push_back(NetworkInterface( |
220 adapter->AdapterName, | 221 adapter->AdapterName, |
221 base::SysWideToNativeMB(adapter->FriendlyName), index, | 222 base::SysWideToNativeMB(adapter->FriendlyName), index, |
222 GetNetworkInterfaceType(adapter->IfType), endpoint.address(), | 223 GetNetworkInterfaceType(adapter->IfType), |
223 prefix_length, ip_address_attributes)); | 224 endpoint.address_number(), prefix_length, ip_address_attributes)); |
224 } | 225 } |
225 } | 226 } |
226 } | 227 } |
227 } | 228 } |
228 return true; | 229 return true; |
229 } | 230 } |
230 | 231 |
231 } // namespace internal | 232 } // namespace internal |
232 | 233 |
233 bool GetNetworkList(NetworkInterfaceList* networks, int policy) { | 234 bool GetNetworkList(NetworkInterfaceList* networks, int policy) { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 | 341 |
341 if (!conn_info.get()) | 342 if (!conn_info.get()) |
342 return ""; | 343 return ""; |
343 | 344 |
344 const DOT11_SSID dot11_ssid = conn_info->wlanAssociationAttributes.dot11Ssid; | 345 const DOT11_SSID dot11_ssid = conn_info->wlanAssociationAttributes.dot11Ssid; |
345 return std::string(reinterpret_cast<const char*>(dot11_ssid.ucSSID), | 346 return std::string(reinterpret_cast<const char*>(dot11_ssid.ucSSID), |
346 dot11_ssid.uSSIDLength); | 347 dot11_ssid.uSSIDLength); |
347 } | 348 } |
348 | 349 |
349 } // namespace net | 350 } // namespace net |
OLD | NEW |