-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnl_client.h
48 lines (42 loc) · 1.26 KB
/
nl_client.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
#pragma once
#include "nl80211_socket.h"
#include <array>
#include <cstdint>
#include <string>
#include <vector>
/**
* @brief Struct to hold data about a wireless interface.
*
*/
struct if_info {
if_info() = default;
std::array<uint8_t, 6> mac;
uint32_t wiphy;
uint16_t frequency;
uint16_t channel;
uint16_t bandwidth;
uint16_t frequency_center1;
uint16_t frequency_center2;
};
class nl80211_client {
public:
virtual ~nl80211_client() = default;
/**
* @brief Get metadata about an interface with name 'interface_name'
*
* @param interface_name The name of the interface of interest
* @param info[out] POD of interface metadata.
* @return true on success, false and default-initialized info otherwise.
*/
virtual bool get_interface_info(const std::string &interface_name, if_info &info) = 0;
};
class nl80211_client_impl : public nl80211_client {
nl80211_socket *m_socket;
public:
explicit nl80211_client_impl(nl80211_socket *socket);
virtual ~nl80211_client_impl() = default;
virtual bool get_interface_info(const std::string &interface_name, if_info &info) override;
bool get_wiphy_bandwidth(if_info &info);
private:
void get_bandwidth_from_attr(struct nlattr **tb, if_info &info);
};