fork SmartCAWPAP as FreeWTP

This commit is contained in:
Andreas Schultz
2016-08-22 16:59:55 +02:00
parent 8cc6559f08
commit 0101ea6e56
341 changed files with 724 additions and 17737 deletions

View File

@ -0,0 +1,173 @@
#include "capwap.h"
#include "network.h"
#include <linux/socket.h>
#include "wifi_drivers.h"
#include "netlink_link.h"
static void netlink_event_receive_cb(EV_P_ ev_io *w, int revents);
/* */
struct netlink_request {
struct nlmsghdr hdr;
struct ifinfomsg ifinfo;
char opts[16];
};
/* */
struct netlink *netlink_init(wifi_global_handle handle)
{
int sock;
struct sockaddr_nl local;
struct netlink* netlinkhandle;
/* Create netlink socket */
sock = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
if (sock < 0) {
return NULL;
}
/* Bind to kernel */
memset(&local, 0, sizeof(struct sockaddr_nl));
local.nl_family = AF_NETLINK;
local.nl_groups = RTMGRP_LINK;
if (bind(sock, (struct sockaddr*)&local, sizeof(struct sockaddr_nl)) < 0) {
close(sock);
return NULL;
}
/* Netlink reference */
netlinkhandle = (struct netlink*)capwap_alloc(sizeof(struct netlink));
netlinkhandle->handle = handle;
netlinkhandle->sock = sock;
netlinkhandle->nl_sequence = 1;
ev_io_init(&netlinkhandle->io_ev, netlink_event_receive_cb, sock, EV_READ);
ev_io_start(EV_DEFAULT_UC_ &netlinkhandle->io_ev);
return netlinkhandle;
}
/* */
void netlink_free(struct netlink* netlinkhandle)
{
ASSERT(netlinkhandle != NULL);
ASSERT(netlinkhandle->sock >= 0);
if (ev_is_active(&netlinkhandle->io_ev))
ev_io_stop(EV_DEFAULT_UC_ &netlinkhandle->io_ev);
/* */
close(netlinkhandle->sock);
capwap_free(netlinkhandle);
}
static void invoke_event_fn(netlink_event_fn event_fn, struct netlink *netlinkhandle, struct nlmsghdr* message)
{
if (!event_fn)
return;
if (NLMSG_PAYLOAD(message, 0) < sizeof(struct ifinfomsg))
return;
event_fn(netlinkhandle->handle,
NLMSG_DATA(message),
(uint8_t*)(NLMSG_DATA(message) + NLMSG_ALIGN(sizeof(struct ifinfomsg))),
NLMSG_PAYLOAD(message, sizeof(struct ifinfomsg)));
}
/* */
static void netlink_event_receive_cb(EV_P_ ev_io *w, int revents)
{
struct netlink *netlinkhandle = (struct netlink *)
(((char *)w) - offsetof(struct netlink, io_ev));
int result;
struct sockaddr_nl from;
socklen_t fromlen;
char buffer[8192];
struct nlmsghdr* message;
/* Retrieve all netlink message */
for (;;) {
/* Get message */
fromlen = sizeof(struct sockaddr_nl);
result = recvfrom(w->fd, buffer, sizeof(buffer), MSG_DONTWAIT,
(struct sockaddr *)&from, &fromlen);
if (result <= 0) {
if (errno == EINTR) {
continue;
}
/* */
break;
}
/* Parsing message */
message = (struct nlmsghdr*)buffer;
while (NLMSG_OK(message, result)) {
switch (message->nlmsg_type) {
case RTM_NEWLINK:
invoke_event_fn(netlinkhandle->newlink_event,
netlinkhandle, message);
break;
case RTM_DELLINK:
invoke_event_fn(netlinkhandle->dellink_event,
netlinkhandle, message);
break;
default:
break;
}
/* */
message = NLMSG_NEXT(message, result);
}
}
}
int netlink_set_link_status(struct netlink* netlinkhandle, int ifindex, int linkmode, int operstate) {
char* data;
struct rtattr* rta;
struct netlink_request request;
ASSERT(netlinkhandle != NULL);
ASSERT(ifindex >= 0);
/* */
memset(&request, 0, sizeof(struct netlink_request));
request.hdr.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg));
request.hdr.nlmsg_type = RTM_SETLINK;
request.hdr.nlmsg_flags = NLM_F_REQUEST;
request.hdr.nlmsg_seq = netlinkhandle->nl_sequence++;
request.hdr.nlmsg_pid = 0;
request.ifinfo.ifi_family = AF_UNSPEC;
request.ifinfo.ifi_type = 0;
request.ifinfo.ifi_index = ifindex;
request.ifinfo.ifi_flags = 0;
request.ifinfo.ifi_change = 0;
if (linkmode != -1) {
rta = (struct rtattr*)((char*)&request + NLMSG_ALIGN(request.hdr.nlmsg_len));
rta->rta_type = IFLA_LINKMODE;
rta->rta_len = RTA_LENGTH(sizeof(char));
data = (char*)RTA_DATA(rta);
*data = (char)linkmode;
request.hdr.nlmsg_len = NLMSG_ALIGN(request.hdr.nlmsg_len) + RTA_LENGTH(sizeof(char));
}
if (operstate != -1) {
rta = (struct rtattr*)((char*)&request + NLMSG_ALIGN(request.hdr.nlmsg_len));
rta->rta_type = IFLA_OPERSTATE;
rta->rta_len = RTA_LENGTH(sizeof(char));
data = (char*)RTA_DATA(rta);
*data = (char)operstate;
request.hdr.nlmsg_len = NLMSG_ALIGN(request.hdr.nlmsg_len) + RTA_LENGTH(sizeof(char));
}
/* Send new interface operation state */
if (send(netlinkhandle->sock, &request, request.hdr.nlmsg_len, 0) < 0) {
return -1;
}
return 0;
}

View File

@ -0,0 +1,67 @@
#ifndef __NETLINK_LINK_HEADER__
#define __NETLINK_LINK_HEADER__
#include <linux/rtnetlink.h>
#include <linux/netlink.h>
#include <ev.h>
/* */
#ifndef IFLA_IFNAME
#define IFLA_IFNAME 3
#endif
#ifndef IFLA_WIRELESS
#define IFLA_WIRELESS 11
#endif
#ifndef IFLA_OPERSTATE
#define IFLA_OPERSTATE 16
#endif
#ifndef IFLA_LINKMODE
#define IFLA_LINKMODE 17
#endif
#ifndef IF_OPER_DORMANT
#define IF_OPER_DORMANT 5
#endif
#ifndef IF_OPER_UP
#define IF_OPER_UP 6
#endif
#ifndef IFF_LOWER_UP
#define IFF_LOWER_UP 0x10000
#endif
#ifndef IFF_DORMANT
#define IFF_DORMANT 0x20000
#endif
typedef void (*netlink_event_fn)(wifi_global_handle handle, struct ifinfomsg* infomsg,
uint8_t* data, int length);
/* */
struct netlink {
wifi_global_handle handle;
int sock;
ev_io io_ev;
netlink_event_fn newlink_event;
netlink_event_fn dellink_event;
int nl_sequence;
};
/* */
struct netlink* netlink_init(wifi_global_handle handle);
void netlink_free(struct netlink* netlinkhandle);
/* */
int netlink_set_link_status(struct netlink* netlinkhandle, int ifindex, int linkmode, int operstate);
/* */
void netlink_event_receive(int fd, void** params, int paramscount);
#endif /* __NETLINK_LINK_HEADER__ */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,488 @@
#ifndef __WIFI_DRIVERS_HEADER__
#define __WIFI_DRIVERS_HEADER__
#include <net/if_arp.h>
#include <linux/if_ether.h>
#include "ieee80211.h"
#include <ev.h>
/* */
#define WIFI_DRIVER_NAME_SIZE 16
/* */
#define WIFI_BAND_UNKNOWN 0
#define WIFI_BAND_2GHZ 1
#define WIFI_BAND_5GHZ 2
/* */
#define WIFI_CAPABILITY_RADIOSUPPORTED 0x00000001
#define WIFI_CAPABILITY_RADIOTYPE 0x00000002
#define WIFI_CAPABILITY_BANDS 0x00000004
#define WIFI_CAPABILITY_CIPHERS 0x00000008
#define WIFI_CAPABILITY_ANTENNA_MASK 0x00000010
#define WIFI_CAPABILITY_MAX_SCAN_SSIDS 0x00000020
#define WIFI_CAPABILITY_MAX_SCHED_SCAN_SSIDS 0x00000040
#define WIFI_CAPABILITY_MAX_MATCH_SETS 0x00000080
#define WIFI_CAPABILITY_MAX_ACL_MACADDRESS 0x00000100
/* */
#define WIFI_CAPABILITY_FLAGS_OFFCHANNEL_TX_OK 0x00000001
#define WIFI_CAPABILITY_FLAGS_ROAM_SUPPORT 0x00000002
#define WIFI_CAPABILITY_FLAGS_SUPPORT_AP_UAPSD 0x00000004
#define WIFI_CAPABILITY_FLAGS_DEVICE_AP_SME 0x00000008
#define WIFI_CAPABILITY_FLAGS_PROBE_RESPONSE_OFFLOAD 0x00000010
#define WIFI_CAPABILITY_FLAGS_INACTIVITY_TIMER 0x00000020
/* */
#define WIFI_CAPABILITY_AP_SUPPORTED 0x00000001
#define WIFI_CAPABILITY_AP_VLAN_SUPPORTED 0x00000002
#define WIFI_CAPABILITY_ADHOC_SUPPORTED 0x00000004
#define WIFI_CAPABILITY_MONITOR_SUPPORTED 0x00000008
#define WIFI_CAPABILITY_WDS_SUPPORTED 0x00000010
#define FREQ_CAPABILITY_DISABLED 0x00000001
#define FREQ_CAPABILITY_PASSIVE_SCAN 0x00000002
#define FREQ_CAPABILITY_NO_IBBS 0x00000004
#define FREQ_CAPABILITY_RADAR 0x00000008
#define FREQ_CAPABILITY_DFS_STATE 0x00000010
#define FREQ_CAPABILITY_DFS_TIME 0x00000020
#define RATE_CAPABILITY_SHORTPREAMBLE 0x00000001
#define IEEE80211_DFS_USABLE 0
#define IEEE80211_DFS_UNAVAILABLE 1
#define IEEE80211_DFS_AVAILABLE 2
#define WLAN_INTERFACE_AP 1
/* */
DECLARE_OPAQUE_TYPE(wifi_global_handle);
DECLARE_OPAQUE_TYPE(wifi_device_handle);
DECLARE_OPAQUE_TYPE(wifi_wlan_handle);
struct capwap_80211_wtpqos_element;
struct capwap_80211_stationkey_element;
/* */
struct device_setrates_params {
int supportedratescount;
uint8_t supportedrates[IEEE80211_SUPPORTEDRATE_MAX_COUNT];
int basicratescount;
uint8_t basicrates[IEEE80211_SUPPORTEDRATE_MAX_COUNT];
};
/* */
#define WIFI_COUNTRY_LENGTH 4
struct device_setconfiguration_params {
int shortpreamble;
uint8_t maxbssid;
uint8_t dtimperiod;
uint8_t bssid[MACADDRESS_EUI48_LENGTH];
uint16_t beaconperiod;
uint8_t country[WIFI_COUNTRY_LENGTH];
};
/* */
typedef int (*send_frame_to_ac)(void* param, const uint8_t* frame, int length, uint8_t rssi, uint8_t snr, uint16_t rate);
struct wlan_startap_params {
uint8_t radioid;
uint8_t wlanid;
const char* ssid;
uint8_t ssid_hidden;
uint16_t capability;
uint8_t qos;
uint8_t authmode;
uint8_t macmode;
uint8_t tunnelmode;
uint8_t keyindex;
uint8_t keylength;
uint8_t *key;
struct capwap_array *ie;
struct capwap_array *updatekeys;
};
struct wlan_updateap_params {
uint8_t radioid;
uint8_t wlanid;
uint16_t capability;
uint8_t qos;
uint8_t keyindex;
uint8_t keystatus;
uint8_t keylength;
uint8_t *key;
struct capwap_array *ie;
struct capwap_array *updatekeys;
};
/* */
struct wlan_send_frame_params {
uint8_t* packet;
int length;
uint32_t frequency;
uint32_t duration;
int offchannel_tx_ok;
int no_cck_rate;
int no_wait_ack;
uint64_t cookie;
};
/* */
struct station_add_params {
uint8_t* address;
struct ieee80211_ht_cap *ht_cap;
uint32_t pairwise;
struct capwap_80211_stationkey_element *key;
int max_inactivity;
};
/* Interface capability */
struct wifi_freq_capability {
unsigned long flags;
unsigned long frequency; /* MHz */
unsigned long channel;
unsigned long maxtxpower; /* mBm = 100 * dBm */
unsigned long dfsstate;
unsigned long dfstime; /* ms */
};
/* */
struct wifi_rate_capability {
unsigned long flags;
uint8_t bitrate;
};
/* */
struct wifi_band_capability {
unsigned long band;
unsigned long htcapability;
uint8_t a_mpdu_params;
uint8_t mcs_set[16];
struct capwap_array* freq;
struct capwap_array* rate;
};
/* */
struct wifi_commands_capability {
unsigned int poll_command_supported:1;
};
/* */
struct wifi_capability {
struct wifi_device* device;
unsigned long flags;
unsigned long capability;
/* WIFI_CAPABILITY_RADIOSUPPORTED */
unsigned long radiosupported;
/* WIFI_CAPABILITY_RADIOTYPE */
unsigned long radiotype;
/* WIFI_CAPABILITY_ANTENNA_MASK */
unsigned long txantennamask;
unsigned long rxantennamask;
/* WIFI_CAPABILITY_BANDS */
struct capwap_array* bands;
struct wifi_commands_capability supp_cmds;
/* WIFI_CAPABILITY_CIPHERS */
int ciphers_count;
uint32_t *ciphers;
/* WIFI_CAPABILITY_MAX_SCAN_SSIDS */
uint8_t maxscanssids;
/* WIFI_CAPABILITY_MAX_SCHED_SCAN_SSIDS */
uint8_t maxschedscanssids;
/* WIFI_CAPABILITY_MAX_MATCH_SETS */
uint8_t maxmatchsets;
/* WIFI_CAPABILITY_MAX_ACL_MACADDRESS */
uint8_t maxaclmacaddress;
};
/* Frequency configuration */
struct wifi_frequency {
uint32_t band;
uint32_t mode;
uint8_t channel;
uint32_t frequency;
};
/* */
#define WIFI_EVENT_MAX_ITEMS 2
struct wifi_event {
void (*event_handler)(int fd, void** params, int paramscount);
int paramscount;
void* params[WIFI_EVENT_MAX_ITEMS];
};
/* */
struct wifi_driver_instance {
struct wifi_driver_ops* ops; /* Driver functions */
wifi_global_handle handle; /* Global instance handle */
};
/* */
struct wifi_global {
int sock_util;
struct capwap_list* devices;
/* Stations */
struct capwap_hash* stations;
};
/* Device handle */
#define WIFI_DEVICE_SET_FREQUENCY 0x00000001
#define WIFI_DEVICE_SET_RATES 0x00000002
#define WIFI_DEVICE_SET_CONFIGURATION 0x00000004
#define WIFI_DEVICE_REQUIRED_FOR_BSS (WIFI_DEVICE_SET_FREQUENCY | WIFI_DEVICE_SET_RATES | WIFI_DEVICE_SET_CONFIGURATION)
struct wifi_device {
struct wifi_global* global;
wifi_device_handle handle; /* Device handle */
struct wifi_driver_instance* instance; /* Driver instance */
uint32_t phyindex;
char phyname[IFNAMSIZ];
unsigned long flags;
/* */
struct capwap_list* wlans;
unsigned long wlanactive;
/* Current frequency */
struct wifi_frequency currentfrequency;
/* */
uint16_t beaconperiod;
uint8_t dtimperiod;
int shortpreamble;
/* Cached capability */
struct wifi_capability* capability;
/* Rates */
unsigned long supportedratescount;
uint8_t supportedrates[IEEE80211_SUPPORTEDRATE_MAX_COUNT];
unsigned long basicratescount;
uint8_t basicrates[IEEE80211_SUPPORTEDRATE_MAX_COUNT];
/* ERP Information */
int olbc;
unsigned long stationsnonerpcount;
unsigned long stationsnoshortslottimecount;
unsigned long stationsnoshortpreamblecount;
};
/* WLAN handle */
#define WIFI_WLAN_RUNNING 0x00000001
#define WIFI_WLAN_SET_BEACON 0x00000002
#define WIFI_WLAN_OPERSTATE_RUNNING 0x00000004
struct wifi_wlan {
wifi_wlan_handle handle;
struct wifi_device* device;
unsigned long flags;
uint32_t virtindex;
char virtname[IFNAMSIZ];
uint8_t address[MACADDRESS_EUI48_LENGTH];
/* */
uint8_t radioid;
uint8_t wlanid;
/* WLAN information */
char ssid[IEEE80211_SSID_MAX_LENGTH + 1];
uint8_t ssid_hidden;
uint16_t capability;
int ht_opmode;
/* Tunnel */
uint8_t macmode;
uint8_t tunnelmode;
/* Authentication */
uint8_t authmode;
/* Station information */
unsigned long stationscount;
unsigned long maxstationscount;
uint32_t aidbitfield[IEEE80211_AID_BITFIELD_SIZE];
struct ieee80211_ie *rsne;
uint32_t group_cipher_suite;
uint8_t keyindex;
uint8_t keylength;
uint8_t *key;
int beacon_ies_len;
uint8_t *beacon_ies;
int response_ies_len;
uint8_t *response_ies;
};
/* Station handle */
#define WIFI_STATION_FLAGS_AUTHENTICATED 0x00000001
#define WIFI_STATION_FLAGS_ASSOCIATE 0x00000002
#define WIFI_STATION_FLAGS_NON_ERP 0x00000004
#define WIFI_STATION_FLAGS_NO_SHORT_SLOT_TIME 0x00000008
#define WIFI_STATION_FLAGS_NO_SHORT_PREAMBLE 0x00000010
#define WIFI_STATION_FLAGS_WMM 0x00000020
#define WIFI_STATION_FLAGS_AUTHORIZED 0x00000040
#define WIFI_STATION_FLAGS_HT_CAP 0x00000080
#define WIFI_STATION_FLAGS_POLL_PENDING 0x00000100
/* */
#define WIFI_STATION_TIMEOUT_ASSOCIATION_COMPLETE 30000
#define WIFI_STATION_TIMEOUT_AFTER_DEAUTHENTICATED 5000
#define WIFI_STATION_TIMEOUT_BEFORE_DISASSOCIATE 3000
#define WIFI_STATION_TIMEOUT_BEFORE_DEAUTHENTICATE 1000
struct wifi_station {
uint8_t address[MACADDRESS_EUI48_LENGTH];
/* */
struct wifi_wlan* wlan;
/* */
uint32_t flags;
/* Timer */
int max_inactivity;
enum {
WIFI_STATION_TIMEOUT_ACTION_SEND_NULLFUNC = 0,
WIFI_STATION_TIMEOUT_ACTION_DEAUTHENTICATE,
WIFI_STATION_TIMEOUT_ACTION_DISASSOCIATE,
WIFI_STATION_TIMEOUT_ACTION_DELETE
} timeout_action;
struct ev_timer timeout;
/* */
uint16_t capability;
uint16_t listeninterval;
uint16_t aid;
/* */
int supportedratescount;
uint8_t supportedrates[IEEE80211_SUPPORTEDRATE_MAX_COUNT];
/* Authentication */
uint16_t authalgorithm;
uint32_t pairwise_cipher;
struct capwap_80211_stationkey_element *key;
uint8_t qosinfo;
struct ieee80211_ht_cap ht_cap;
};
/* */
struct wifi_driver_ops {
const char* name; /* Name of wifi driver */
const char* description; /* Description of wifi driver */
/* Global initialize driver */
wifi_global_handle (*global_init)(void);
void (*global_deinit)(wifi_global_handle handle);
/* Device functions */
int (*device_init)(wifi_global_handle handle, struct wifi_device* device);
int (*device_getcapability)(struct wifi_device* device, struct wifi_capability* capability);
void (*device_updatebeacons)(struct wifi_device* device);
int (*device_setfrequency)(struct wifi_device* device);
int (*device_settxqueue)(struct wifi_device* device, int queue, int aifs,
int cw_min, int cw_max, int txop);
void (*device_deinit)(struct wifi_device* device);
/* WLAN functions */
wifi_wlan_handle (*wlan_create)(struct wifi_device* device, struct wifi_wlan* wlan);
int (*wlan_startap)(struct wifi_wlan* wlan);
void (*wlan_stopap)(struct wifi_wlan* wlan);
int (*wlan_sendframe)(struct wifi_wlan* wlan, uint8_t* frame, int length, uint32_t frequency, uint32_t duration, int offchannel_tx_ok, int no_cck_rate, int no_wait_ack);
void (*wlan_poll_station)(struct wifi_wlan* wlan, const uint8_t* address, int qos);
void (*wlan_delete)(struct wifi_wlan* wlan);
int (*wlan_set_key)(struct wifi_wlan* wlan,
uint32_t alg, const uint8_t *addr,
int key_idx, int set_tx,
const uint8_t *seq, size_t seq_len,
const uint8_t *key, size_t key_len);
/* Stations functions */
int (*station_authorize)(struct wifi_wlan* wlan, struct wifi_station* station);
int (*station_deauthorize)(struct wifi_wlan* wlan, const uint8_t* address);
int (*station_get_inact_sec)(struct wifi_wlan* wlan, const uint8_t* address);
};
/* Initialize wifi driver engine */
int wifi_driver_init(void);
void wifi_driver_free(void);
/* */
struct wifi_wlan* wifi_get_wlan(uint32_t ifindex);
/* Device management */
struct wifi_device* wifi_device_connect(const char* ifname, const char* driver);
const struct wifi_capability* wifi_device_getcapability(struct wifi_device* device);
int wifi_device_setconfiguration(struct wifi_device* device, struct device_setconfiguration_params* params);
int wifi_device_setfrequency(struct wifi_device* device, uint32_t band, uint32_t mode, uint8_t channel);
int wifi_device_settxqueue(struct wifi_device *device, struct capwap_80211_wtpqos_element *qos);
int wifi_device_updaterates(struct wifi_device* device, uint8_t* rates, int ratescount);
/* WLAN management */
struct wifi_wlan* wifi_wlan_create(struct wifi_device* device, const char* ifname);
int wifi_wlan_startap(struct wifi_wlan* wlan, struct wlan_startap_params* params);
int wifi_wlan_updateap(struct wifi_wlan* wlan, struct wlan_updateap_params* params);
void wifi_wlan_stopap(struct wifi_wlan* wlan);
int wifi_wlan_getbssid(struct wifi_wlan* wlan, uint8_t* bssid);
uint16_t wifi_wlan_check_capability(struct wifi_wlan* wlan, uint16_t capability);
int wifi_wlan_send_frame(struct wifi_wlan* wlan, const uint8_t* data, int length, uint8_t rssi, uint8_t snr, uint16_t rate);
void wifi_wlan_destroy(struct wifi_wlan* wlan);
/* WLAN packet management */
void wifi_wlan_receive_station_frame(struct wifi_wlan* wlan, const struct ieee80211_header* frame, int length, uint32_t frequency, uint8_t rssi, uint8_t snr, uint16_t rate);
void wifi_wlan_receive_station_ackframe(struct wifi_wlan* wlan, const struct ieee80211_header* frame, int length, int ack);
void wifi_wlan_receive_ac_frame(struct wifi_wlan* wlan, struct ieee80211_header* frame, int length);
void wifi_wlan_client_probe_event(struct wifi_wlan *wlan, const uint8_t *address);
/* Station management */
int wifi_station_set_key(struct wifi_wlan *wlan, struct wifi_station* station);
int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* params);
void wifi_station_deauthorize(struct wifi_device* device, const uint8_t* address);
/* Util functions */
uint32_t wifi_iface_index(const char* ifname);
/* */
int wifi_iface_getstatus(int sock, const char* ifname);
int wifi_iface_updown(int sock, const char* ifname, int up);
#define wifi_iface_up(sock, ifname) wifi_iface_updown(sock, ifname, 1)
#define wifi_iface_down(sock, ifname) wifi_iface_updown(sock, ifname, 0)
#endif /* __WIFI_DRIVERS_HEADER__ */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
#ifndef __WIFI_NL80211_HEADER__
#define __WIFI_NL80211_HEADER__
#include <ev.h>
#include "hash.h"
#include "netlink_link.h"
/* Compatibility functions */
#ifdef HAVE_LIBNL_10
#define nl_sock nl_handle
#endif
#define WMM_QOSINFO_STA_AC_MASK 0x0f
#define WMM_QOSINFO_STA_SP_MASK 0x03
#define WMM_QOSINFO_STA_SP_SHIFT 5
/* */
typedef int (*nl_valid_cb)(struct nl_msg* msg, void* data);
/* Global handle */
struct nl80211_global_handle {
int nl80211_id;
struct nl_sock* nl;
struct nl_cb* nl_cb;
struct nl_sock *nl_event;
ev_io nl_event_ev;
struct netlink* netlinkhandle;
int sock_util;
};
/* Device handle */
struct nl80211_device_handle {
struct nl80211_global_handle* globalhandle;
};
/* WLAN handle */
struct nl80211_wlan_handle {
struct nl80211_device_handle* devicehandle;
struct nl_sock *nl;
ev_io nl_ev;
struct nl_cb *nl_cb;
uint64_t last_cookie;
};
/* NL80211 Station statistics */
struct nl80211_station_data {
unsigned long rx_packets, tx_packets;
unsigned long long rx_bytes, tx_bytes;
int bytes_64bit;
unsigned long inactive_msec;
unsigned long tx_retry_failed;
};
#endif /* __WIFI_NL80211_HEADER__ */