Commit 7100ca5a authored by btolsch's avatar btolsch Committed by Commit Bot

Support IPv6-only wifi in DiscoveryNetworkMonitor on linux

Using only AF_INET to probe a Wifi interface that IPv6-only will fail,
even though the interface is functional.  This change adds an AF_INET6
check if AF_INET fails.

Bug: None
Change-Id: I81f9c2a2a51041597ee384804018b4de7dccc88d
Reviewed-on: https://chromium-review.googlesource.com/1017344
Commit-Queue: Brandon Tolsch <btolsch@chromium.org>
Reviewed-by: default avatarAdam Parker <amp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#551796}
parent 5e34d9d2
......@@ -21,8 +21,13 @@ bool MaybeGetWifiSSID(const std::string& if_name, std::string* ssid_out) {
DCHECK(ssid_out);
base::ScopedFD ioctl_socket(socket(AF_INET, SOCK_DGRAM, 0));
if (!ioctl_socket.is_valid())
return false;
if (!ioctl_socket.is_valid()) {
// AF_INET is for IPv4, so it may fail for IPv6-only hosts even when there
// are interfaces up.
ioctl_socket.reset(socket(AF_INET6, SOCK_DGRAM, 0));
if (!ioctl_socket.is_valid())
return false;
}
struct iwreq wreq = {};
strncpy(wreq.ifr_name, if_name.data(), IFNAMSIZ - 1);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment