1#ifndef SNIFF_NET_CARD_MANAGER
2#define SNIFF_NET_CARD_MANAGER
4#include "netlink/attr.h"
5#include "netlink/handlers.h"
6#include "netlink/netlink.h"
7#include <linux/nl80211.h>
11#include <spdlog/logger.h>
12#include <spdlog/sinks/stdout_color_sinks.h>
13#include <spdlog/spdlog.h>
37 void attach(nl_recvmsg_msg_cb_t func,
void *arg);
46 static int finish(nl_msg *msg,
void *arg);
47 static int error(sockaddr_nl *nla, nlmsgerr *err,
void *arg);
48 static int ack(nl_msg *msg,
void *arg);
50 nl_sock *sock =
nullptr;
51 nl_cb *callback =
nullptr;
141 std::optional<phy_info>
phy_details(
int phy_idx)
const;
180 nl_socket_free(this->sock);
184 static int phy_interfaces_callback(nl_msg *msg,
void *arg);
185 static int phy_details_callback(nl_msg *msg,
void *arg);
186 static int net_iface_details_callback(nl_msg *msg,
void *arg);
188 std::shared_ptr<spdlog::logger> logger;
189 nl_sock *sock =
nullptr;
Manager for network card information gathering and state control.
Definition net_card_manager.h:58
void disconnect()
Definition net_card_manager.cpp:88
bool set_phy_channel(int phy_idx, int chan) const
Definition net_card_manager.cpp:150
std::optional< phy_info > phy_details(int phy_idx) const
Definition net_card_manager.cpp:110
FcsState
Definition net_card_manager.h:75
@ FCS_INVALID
Definition net_card_manager.h:75
@ FCS_ALL
Definition net_card_manager.h:75
@ FCS_VALID
Definition net_card_manager.h:75
std::set< std::string > phy_interfaces() const
Definition net_card_manager.cpp:97
bool connect()
Definition net_card_manager.cpp:61
NetCardManager()
Definition net_card_manager.cpp:59
ChannelModes
Definition net_card_manager.h:60
@ VHT80
Definition net_card_manager.h:67
@ VHT80P80
Definition net_card_manager.h:69
@ HT40MINUS
Definition net_card_manager.h:63
@ HT20
Definition net_card_manager.h:62
@ VHT160
Definition net_card_manager.h:72
@ NO_HT
Definition net_card_manager.h:61
@ HT40PLUS
Definition net_card_manager.h:65
std::optional< iface_state > net_iface_details(const std::string &ifname) const
Definition net_card_manager.cpp:129
~NetCardManager()
Definition net_card_manager.h:178
static std::set< std::string > net_interfaces()
Definition net_card_manager.cpp:90
static int freq_to_chan(int freq)
Definition net_card_manager.cpp:170
static int chan_to_freq(int chan)
Definition net_card_manager.cpp:174
Netlink socket family callback handler for asynchronous communication.
Definition net_card_manager.h:22
int wait()
Definition net_card_manager.cpp:35
NetlinkCallback(nl_sock *sock)
Definition net_card_manager.h:29
void attach(nl_recvmsg_msg_cb_t func, void *arg)
Definition net_card_manager.cpp:23
Definition access_point.cpp:22
Logical network interface (e.g. wlan0) data.
Definition net_card_manager.h:95
ChannelModes chan_type
Definition net_card_manager.h:100
int type
Definition net_card_manager.h:96
int center_freq1
Definition net_card_manager.h:101
FcsState fcs_state
Definition net_card_manager.h:103
int freq
Definition net_card_manager.h:99
int logic_idx
Definition net_card_manager.h:98
int center_freq2
Definition net_card_manager.h:102
int phy_idx
Definition net_card_manager.h:97
Physical network interface (e.g. phy0) capability info.
Definition net_card_manager.h:80
int can_monitor
Definition net_card_manager.h:85
bool can_check_fcs
Definition net_card_manager.h:83
int channel_opts
Definition net_card_manager.h:84
std::set< uint32_t > frequencies
Definition net_card_manager.h:82
std::string ifname
Definition net_card_manager.h:81
bool operator<(const phy_info &other) const
Definition net_card_manager.h:87