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

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

Issue 1565303002: Change IPEndpoint::address() to return a net::IPAddress (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase for ChromeOS Created 4 years, 11 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/network_interfaces_mac.cc ('k') | net/dns/address_sorter_posix.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) 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/network_interfaces_win.h" 5 #include "net/base/network_interfaces_win.h"
6 6
7 #pragma comment(lib, "iphlpapi.lib") 7 #pragma comment(lib, "iphlpapi.lib")
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 if (is_xp) { 173 if (is_xp) {
174 // Prior to Windows Vista the FirstPrefix pointed to the list with 174 // Prior to Windows Vista the FirstPrefix pointed to the list with
175 // single prefix for each IP address assigned to the adapter. 175 // single prefix for each IP address assigned to the adapter.
176 // Order of FirstPrefix does not match order of FirstUnicastAddress, 176 // Order of FirstPrefix does not match order of FirstUnicastAddress,
177 // so we need to find corresponding prefix. 177 // so we need to find corresponding prefix.
178 for (IP_ADAPTER_PREFIX* prefix = adapter->FirstPrefix; prefix; 178 for (IP_ADAPTER_PREFIX* prefix = adapter->FirstPrefix; prefix;
179 prefix = prefix->Next) { 179 prefix = prefix->Next) {
180 int prefix_family = prefix->Address.lpSockaddr->sa_family; 180 int prefix_family = prefix->Address.lpSockaddr->sa_family;
181 IPEndPoint network_endpoint; 181 IPEndPoint network_endpoint;
182 if (prefix_family == family && 182 if (prefix_family == family &&
183 network_endpoint.FromSockAddr(prefix->Address.lpSockaddr, 183 network_endpoint.FromSockAddr(
184 prefix->Address.lpSockaddr,
184 prefix->Address.iSockaddrLength) && 185 prefix->Address.iSockaddrLength) &&
185 IPNumberMatchesPrefix(endpoint.address(), 186 IPNumberMatchesPrefix(endpoint.address().bytes(),
186 network_endpoint.address(), 187 network_endpoint.address().bytes(),
187 prefix->PrefixLength)) { 188 prefix->PrefixLength)) {
188 prefix_length = 189 prefix_length =
189 std::max<size_t>(prefix_length, prefix->PrefixLength); 190 std::max<size_t>(prefix_length, prefix->PrefixLength);
190 } 191 }
191 } 192 }
192 } 193 }
193 194
194 // If the duplicate address detection (DAD) state is not changed to 195 // If the duplicate address detection (DAD) state is not changed to
195 // Preferred, skip this address. 196 // Preferred, skip this address.
196 if (address->DadState != IpDadStatePreferred) { 197 if (address->DadState != IpDadStatePreferred) {
(...skipping 10 matching lines...) Expand all
207 int ip_address_attributes = IP_ADDRESS_ATTRIBUTE_NONE; 208 int ip_address_attributes = IP_ADDRESS_ATTRIBUTE_NONE;
208 if (family == AF_INET6) { 209 if (family == AF_INET6) {
209 if (address->PrefixOrigin == IpPrefixOriginRouterAdvertisement && 210 if (address->PrefixOrigin == IpPrefixOriginRouterAdvertisement &&
210 address->SuffixOrigin == IpSuffixOriginRandom) { 211 address->SuffixOrigin == IpSuffixOriginRandom) {
211 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_TEMPORARY; 212 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_TEMPORARY;
212 } 213 }
213 if (address->PreferredLifetime == 0) { 214 if (address->PreferredLifetime == 0) {
214 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_DEPRECATED; 215 ip_address_attributes |= IP_ADDRESS_ATTRIBUTE_DEPRECATED;
215 } 216 }
216 } 217 }
217 networks->push_back(NetworkInterface( 218 networks->push_back(
218 adapter->AdapterName, 219 NetworkInterface(adapter->AdapterName,
219 base::SysWideToNativeMB(adapter->FriendlyName), index, 220 base::SysWideToNativeMB(adapter->FriendlyName),
220 GetNetworkInterfaceType(adapter->IfType), endpoint.address(), 221 index, GetNetworkInterfaceType(adapter->IfType),
221 prefix_length, ip_address_attributes)); 222 endpoint.address().bytes(), prefix_length,
223 ip_address_attributes));
222 } 224 }
223 } 225 }
224 } 226 }
225 } 227 }
226 return true; 228 return true;
227 } 229 }
228 230
229 } // namespace internal 231 } // namespace internal
230 232
231 bool GetNetworkList(NetworkInterfaceList* networks, int policy) { 233 bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 340
339 if (!conn_info.get()) 341 if (!conn_info.get())
340 return ""; 342 return "";
341 343
342 const DOT11_SSID dot11_ssid = conn_info->wlanAssociationAttributes.dot11Ssid; 344 const DOT11_SSID dot11_ssid = conn_info->wlanAssociationAttributes.dot11Ssid;
343 return std::string(reinterpret_cast<const char*>(dot11_ssid.ucSSID), 345 return std::string(reinterpret_cast<const char*>(dot11_ssid.ucSSID),
344 dot11_ssid.uSSIDLength); 346 dot11_ssid.uSSIDLength);
345 } 347 }
346 348
347 } // namespace net 349 } // namespace net
OLDNEW
« no previous file with comments | « net/base/network_interfaces_mac.cc ('k') | net/dns/address_sorter_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698