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

Side by Side Diff: chrome/browser/media/router/discovery/discovery_network_list_wifi_linux.cc

Issue 2750453002: Add DiscoveryNetworkMonitor implementation (Closed)
Patch Set: Remove extension test files 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/media/router/discovery/discovery_network_list_wifi.h"
6
7 #include <string.h>
8 #include <sys/ioctl.h>
9 #include <sys/socket.h>
10 #include <sys/types.h>
11
12 #include <linux/wireless.h>
13
14 #include "base/files/scoped_file.h"
15 #include "base/logging.h"
16 #include "net/base/network_interfaces_linux.h"
17
18 bool MaybeGetWifiSSID(const char* if_name, std::string* ssid_out) {
19 DCHECK(if_name);
20 DCHECK(ssid_out);
21
22 base::ScopedFD ioctl_socket(socket(AF_INET, SOCK_DGRAM, 0));
23 if (!ioctl_socket.is_valid())
24 return false;
25 struct iwreq wreq = {};
26 strncpy(wreq.ifr_name, if_name, IFNAMSIZ - 1);
27
28 char ssid[IW_ESSID_MAX_SIZE + 1] = {0};
29 wreq.u.essid.pointer = ssid;
30 wreq.u.essid.length = IW_ESSID_MAX_SIZE;
31 if (ioctl(ioctl_socket.get(), SIOCGIWESSID, &wreq) != -1) {
32 ssid_out->assign(ssid);
33 return true;
34 }
35 return false;
36 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698