-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwifi_scanner.h
58 lines (49 loc) · 1.26 KB
/
wifi_scanner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef WIFI_LOGGER_H
#define WIFI_LOGGER_H
#include <stdio.h>
#include <iostream>
#include <chrono>
#include <map>
#include <string>
#include <functional>
#include "iwlib.h"
#include <chrono>
// ooutputs mac address as a string
static inline char *get_mac_address(const struct sockaddr *sap, char* bufp)
{
iw_ether_ntop((const struct ether_addr *) sap->sa_data, bufp);
return bufp;
};
class access_point
{
public:
access_point();
double timestamp;
std::string mac_address;
int signal_strength;
int signal_quality;
int signal_noise;
int sensitivity;
int max_quality;
bool signal_updated;
double frequency;
std::string essid;
};
typedef void scanning_callback( access_point & );
class wifi_scanner
{
public:
wifi_scanner();
~wifi_scanner();
bool init(std::string, const std::function<scanning_callback> &cb = nullptr);
//void passive_scan(int milliseconds=1000);
int scan();
void process_iw_event(struct stream_descr *stream, struct iw_event * event, access_point **ap, double scan_time);
std::map<std::string, access_point> ap_list;
private:
int socket_fd;
struct iw_range range;
std::string interface_name;
std::function<scanning_callback> scan_callback;
};
#endif //WIFI_LOGGER_H