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

Unified Diff: net/base/network_interfaces_linux.cc

Issue 2890773002: When creating sockets for ioctl() use AF_INET6 or AF_INET (Closed)
Patch Set: Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/base/network_interfaces_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/network_interfaces_linux.cc
diff --git a/net/base/network_interfaces_linux.cc b/net/base/network_interfaces_linux.cc
index 3c460be2871952a2485326894123ad874d0d4c73..1e506df642566aad88c1f8962e741c75ce560d83 100644
--- a/net/base/network_interfaces_linux.cc
+++ b/net/base/network_interfaces_linux.cc
@@ -76,7 +76,7 @@ namespace internal {
// or ethtool extensions.
NetworkChangeNotifier::ConnectionType GetInterfaceConnectionType(
const std::string& ifname) {
- base::ScopedFD s(socket(AF_INET, SOCK_STREAM, 0));
+ base::ScopedFD s = GetSocketForIoctl();
if (!s.is_valid())
return NetworkChangeNotifier::CONNECTION_UNKNOWN;
@@ -101,7 +101,7 @@ NetworkChangeNotifier::ConnectionType GetInterfaceConnectionType(
}
std::string GetInterfaceSSID(const std::string& ifname) {
- base::ScopedFD ioctl_socket(socket(AF_INET, SOCK_DGRAM, 0));
+ base::ScopedFD ioctl_socket = GetSocketForIoctl();
if (!ioctl_socket.is_valid())
return "";
struct iwreq wreq = {};
@@ -201,6 +201,13 @@ std::string GetWifiSSIDFromInterfaceListInternal(
return connected_ssid;
}
+base::ScopedFD GetSocketForIoctl() {
+ base::ScopedFD ioctl_socket(socket(AF_INET6, SOCK_DGRAM, 0));
+ if (ioctl_socket.is_valid())
+ return ioctl_socket;
+ return base::ScopedFD(socket(AF_INET, SOCK_DGRAM, 0));
+}
+
} // namespace internal
bool GetNetworkList(NetworkInterfaceList* networks, int policy) {
« no previous file with comments | « net/base/network_interfaces_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698