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

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

Issue 9419053: Make GetNetworkList on Windows filter out 'down' interfaces, as on POSIX. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 10 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 | « 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 <iphlpapi.h> 7 #include <iphlpapi.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return false; 98 return false;
99 } 99 }
100 100
101 for (IP_ADAPTER_ADDRESSES *adapter = adapters; adapter != NULL; 101 for (IP_ADAPTER_ADDRESSES *adapter = adapters; adapter != NULL;
102 adapter = adapter->Next) { 102 adapter = adapter->Next) {
103 // Ignore the loopback device. 103 // Ignore the loopback device.
104 if (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK) { 104 if (adapter->IfType == IF_TYPE_SOFTWARE_LOOPBACK) {
105 continue; 105 continue;
106 } 106 }
107 107
108 if (adapter->OperStatus != IfOperStatusUp) {
109 continue;
110 }
111
108 IP_ADAPTER_UNICAST_ADDRESS* address; 112 IP_ADAPTER_UNICAST_ADDRESS* address;
109 for (address = adapter->FirstUnicastAddress; address != NULL; 113 for (address = adapter->FirstUnicastAddress; address != NULL;
110 address = address->Next) { 114 address = address->Next) {
wtc 2012/02/17 19:36:23 Comparing this code with the GetNetworkList functi
111 int family = address->Address.lpSockaddr->sa_family; 115 int family = address->Address.lpSockaddr->sa_family;
112 if (family == AF_INET || family == AF_INET6) { 116 if (family == AF_INET || family == AF_INET6) {
113 IPEndPoint endpoint; 117 IPEndPoint endpoint;
114 if (endpoint.FromSockAddr(address->Address.lpSockaddr, 118 if (endpoint.FromSockAddr(address->Address.lpSockaddr,
115 address->Address.iSockaddrLength)) { 119 address->Address.iSockaddrLength)) {
116 std::string name = adapter->AdapterName; 120 std::string name = adapter->AdapterName;
117 networks->push_back(NetworkInterface(name, endpoint.address())); 121 networks->push_back(NetworkInterface(name, endpoint.address()));
118 } 122 }
119 } 123 }
120 } 124 }
121 } 125 }
122 126
123 return true; 127 return true;
124 } 128 }
125 129
126 } // namespace net 130 } // 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