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

Side by Side Diff: chrome/browser/net/discovery_network_list_wifi_linux.cc

Issue 2750453002: Add DiscoveryNetworkMonitor implementation (Closed)
Patch Set: Created 3 years, 9 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/net/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/logging.h"
15
16 bool MaybeGetWifiSSID(const char* if_name, std::string* ssid) {
imcheng 2017/03/14 22:45:35 Can this be reused? https://cs.chromium.org/chromi
btolsch 2017/04/03 10:16:35 Done. Should I move it out of the internal namesp
17 DCHECK(if_name);
18
19 struct iwreq iwreq;
20 memset(&iwreq, 0, sizeof(iwreq));
21
22 int sock = socket(AF_INET, SOCK_DGRAM, 0);
23 if (sock == -1) {
24 return false;
25 }
26
27 strncpy(iwreq.ifr_name, if_name, IFNAMSIZ);
28 char id[IW_ESSID_MAX_SIZE];
29 iwreq.u.essid.pointer = id;
30 iwreq.u.essid.length = IW_ESSID_MAX_SIZE;
31
32 if (ioctl(sock, SIOCGIWESSID, &iwreq) == -1) {
33 return false;
34 }
35 ssid->assign(std::string(id, iwreq.u.essid.length));
36 return true;
37 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698