Moved the management of the AP and Stations from nl80211 driver to generic wifi.
This commit is contained in:
parent
fbd717b779
commit
7668ab7c7c
@ -311,25 +311,23 @@ static void ac_ieee80211_mgmt_packet(struct ac_session_data_t* sessiondata, uint
|
||||
}
|
||||
|
||||
/* */
|
||||
void ac_ieee80211_packet(struct ac_session_data_t* sessiondata, uint8_t radioid, const uint8_t* buffer, int length) {
|
||||
const struct ieee80211_header* header;
|
||||
void ac_ieee80211_packet(struct ac_session_data_t* sessiondata, uint8_t radioid, const struct ieee80211_header* header, int length) {
|
||||
uint16_t framecontrol;
|
||||
uint16_t framecontrol_type;
|
||||
uint16_t framecontrol_subtype;
|
||||
|
||||
ASSERT(sessiondata != NULL);
|
||||
ASSERT(IS_VALID_RADIOID(radioid));
|
||||
ASSERT(buffer != NULL);
|
||||
ASSERT(header != NULL);
|
||||
ASSERT(length >= sizeof(struct ieee80211_header));
|
||||
|
||||
/* Get type frame */
|
||||
header = (const struct ieee80211_header*)buffer;
|
||||
framecontrol = __le16_to_cpu(header->framecontrol);
|
||||
framecontrol_type = IEEE80211_FRAME_CONTROL_GET_TYPE(framecontrol);
|
||||
framecontrol_subtype = IEEE80211_FRAME_CONTROL_GET_SUBTYPE(framecontrol);
|
||||
|
||||
/* Parsing frame */
|
||||
if (framecontrol_type == IEEE80211_FRAMECONTROL_TYPE_MGMT) {
|
||||
ac_ieee80211_mgmt_packet(sessiondata, radioid, (const struct ieee80211_header_mgmt*)buffer, length, framecontrol_subtype);
|
||||
ac_ieee80211_mgmt_packet(sessiondata, radioid, (const struct ieee80211_header_mgmt*)header, length, framecontrol_subtype);
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "capwap_event.h"
|
||||
#include "capwap_lock.h"
|
||||
#include "ac_soap.h"
|
||||
#include "ieee80211.h"
|
||||
|
||||
/* AC packet */
|
||||
struct ac_packet {
|
||||
@ -210,7 +211,7 @@ void ac_session_data_release_reference(struct ac_session_data_t* sessiondata);
|
||||
void ac_session_data_send_data_packet(struct ac_session_data_t* sessiondata, uint8_t radioid, uint8_t wlanid, const uint8_t* data, int length, int leavenativeframe);
|
||||
|
||||
/* IEEE802.11 Packet */
|
||||
void ac_ieee80211_packet(struct ac_session_data_t* sessiondata, uint8_t radioid, const uint8_t* buffer, int length);
|
||||
void ac_ieee80211_packet(struct ac_session_data_t* sessiondata, uint8_t radioid, const struct ieee80211_header* header, int length);
|
||||
|
||||
/* */
|
||||
int ac_has_sessionid(struct capwap_sessionid_element* sessionid);
|
||||
|
@ -442,7 +442,7 @@ static void ac_session_data_run(struct ac_session_data_t* sessiondata) {
|
||||
radioid = GET_RID_HEADER(sessiondata->rxmngpacket->header);
|
||||
binding = GET_WBID_HEADER(sessiondata->rxmngpacket->header);
|
||||
if ((binding == CAPWAP_WIRELESS_BINDING_IEEE80211) && (bodypacketlength >= sizeof(struct ieee80211_header))) {
|
||||
ac_ieee80211_packet(sessiondata, radioid, bodypacket, bodypacketlength);
|
||||
ac_ieee80211_packet(sessiondata, radioid, (struct ieee80211_header*)bodypacket, bodypacketlength);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,6 +284,38 @@ int ieee80211_is_broadcast_addr(const uint8_t* addr) {
|
||||
return (((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)) ? 1 : 0);
|
||||
}
|
||||
|
||||
/* */
|
||||
const uint8_t* ieee80211_get_bssid_addr(const struct ieee80211_header* header) {
|
||||
uint16_t framecontrol;
|
||||
uint16_t framecontrol_type;
|
||||
|
||||
ASSERT(header);
|
||||
|
||||
/* Get type frame */
|
||||
framecontrol = __le16_to_cpu(header->framecontrol);
|
||||
framecontrol_type = IEEE80211_FRAME_CONTROL_GET_TYPE(framecontrol);
|
||||
|
||||
if (framecontrol_type == IEEE80211_FRAMECONTROL_TYPE_MGMT) {
|
||||
return header->address3;
|
||||
} else if (framecontrol_type == IEEE80211_FRAMECONTROL_TYPE_DATA) {
|
||||
switch (framecontrol & (IEEE80211_FRAME_CONTROL_MASK_TODS | IEEE80211_FRAME_CONTROL_MASK_FROMDS)) {
|
||||
case 0: {
|
||||
return header->address3;
|
||||
}
|
||||
|
||||
case IEEE80211_FRAME_CONTROL_MASK_TODS: {
|
||||
return header->address1;
|
||||
}
|
||||
|
||||
case IEEE80211_FRAME_CONTROL_MASK_FROMDS: {
|
||||
return header->address2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* */
|
||||
int ieee80211_is_valid_ssid(const char* ssid, struct ieee80211_ie_ssid* iessid, struct ieee80211_ie_ssid_list* isssidlist) {
|
||||
int ssidlength;
|
||||
|
@ -99,9 +99,21 @@
|
||||
#define IEEE80211_FRAMECONTROL_DATA_SUBTYPE_QOSCFACK_CFPOLL 15
|
||||
|
||||
/* */
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_PROTOCOL_VERSION 0x0003
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_TYPE 0x000c
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_SUBTYPE 0x00f0
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_TODS 0x0100
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_FROMDS 0x0200
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_MORE_FRAGMENT 0x0400
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_RETRY 0x0800
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_POWER_MANAGEMENT 0x1000
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_MORE_DATA 0x2000
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_PROTECTED_FRAME 0x4000
|
||||
#define IEEE80211_FRAME_CONTROL_MASK_ORDER 0x8000
|
||||
|
||||
#define IEEE80211_FRAME_CONTROL(type, stype) __cpu_to_le16((type << 2) | (stype << 4))
|
||||
#define IEEE80211_FRAME_CONTROL_GET_TYPE(framecontrol) (((framecontrol) & 0x000c) >> 2)
|
||||
#define IEEE80211_FRAME_CONTROL_GET_SUBTYPE(framecontrol) (((framecontrol) & 0x00f0) >> 4)
|
||||
#define IEEE80211_FRAME_CONTROL_GET_TYPE(framecontrol) (((framecontrol) & IEEE80211_FRAME_CONTROL_MASK_TYPE) >> 2)
|
||||
#define IEEE80211_FRAME_CONTROL_GET_SUBTYPE(framecontrol) (((framecontrol) & IEEE80211_FRAME_CONTROL_MASK_SUBTYPE) >> 4)
|
||||
|
||||
/* IEEE802.11 Status Code */
|
||||
#define IEEE80211_STATUS_SUCCESS 0
|
||||
@ -572,6 +584,7 @@ int ieee80211_create_deauthentication(uint8_t* buffer, int length, struct ieee80
|
||||
int ieee80211_retrieve_information_elements_position(struct ieee80211_ie_items* items, const uint8_t* data, int length);
|
||||
unsigned long ieee80211_frequency_to_channel(uint32_t freq);
|
||||
int ieee80211_is_broadcast_addr(const uint8_t* addr);
|
||||
const uint8_t* ieee80211_get_bssid_addr(const struct ieee80211_header* header);
|
||||
|
||||
/* */
|
||||
#define IEEE80211_VALID_SSID 1
|
||||
|
@ -39,6 +39,9 @@
|
||||
#define min(a,b) ((a) <= (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* Opaque type */
|
||||
#define DECLARE_OPAQUE_TYPE(name) struct name##__opaque__ { int unused; }; typedef struct name##__opaque__* name
|
||||
|
||||
/* UDPLite */
|
||||
#ifdef HAVE_NETINET_UDPLITE_H
|
||||
#include <netinet/udplite.h>
|
||||
@ -55,6 +58,7 @@
|
||||
#endif
|
||||
|
||||
/* standard include */
|
||||
#include "capwap_rfc.h"
|
||||
#include "capwap_logging.h"
|
||||
#include "capwap_debug.h"
|
||||
#include "capwap_error.h"
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __CAPWAP_ELEMENT_HEADER__
|
||||
#define __CAPWAP_ELEMENT_HEADER__
|
||||
|
||||
#include "capwap_rfc.h"
|
||||
#include "capwap_array.h"
|
||||
#include "capwap_list.h"
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
#ifndef __CAPWAP_PROTOCOL_HEADER__
|
||||
#define __CAPWAP_PROTOCOL_HEADER__
|
||||
|
||||
#include "capwap_rfc.h"
|
||||
#include "capwap_element.h"
|
||||
#include "capwap_network.h"
|
||||
#include "capwap_dtls.h"
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -64,19 +64,9 @@
|
||||
#define WLAN_INTERFACE_AP 1
|
||||
|
||||
/* */
|
||||
typedef void* wifi_global_handle;
|
||||
typedef void* wifi_device_handle;
|
||||
typedef void* wifi_wlan_handle;
|
||||
|
||||
/* */
|
||||
struct global_init_params {
|
||||
struct capwap_timeout* timeout;
|
||||
};
|
||||
|
||||
/* */
|
||||
struct device_init_params {
|
||||
const char* ifname;
|
||||
};
|
||||
DECLARE_OPAQUE_TYPE(wifi_global_handle);
|
||||
DECLARE_OPAQUE_TYPE(wifi_device_handle);
|
||||
DECLARE_OPAQUE_TYPE(wifi_wlan_handle);
|
||||
|
||||
/* */
|
||||
struct device_setrates_params {
|
||||
@ -92,7 +82,7 @@ struct device_setconfiguration_params {
|
||||
int shortpreamble;
|
||||
uint8_t maxbssid;
|
||||
uint8_t dtimperiod;
|
||||
uint8_t bssid[ETH_ALEN];
|
||||
uint8_t bssid[MACADDRESS_EUI48_LENGTH];
|
||||
uint16_t beaconperiod;
|
||||
uint8_t country[WIFI_COUNTRY_LENGTH];
|
||||
};
|
||||
@ -175,7 +165,7 @@ struct wifi_cipher_capability {
|
||||
|
||||
/* */
|
||||
struct wifi_capability {
|
||||
wifi_device_handle device;
|
||||
struct wifi_device* device;
|
||||
|
||||
unsigned long flags;
|
||||
unsigned long capability;
|
||||
@ -225,38 +215,6 @@ struct wifi_event {
|
||||
void* params[WIFI_EVENT_MAX_ITEMS];
|
||||
};
|
||||
|
||||
/* */
|
||||
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)(struct global_init_params* params);
|
||||
int (*global_getfdevent)(wifi_global_handle handle, struct pollfd* fds, struct wifi_event* events);
|
||||
void (*global_deinit)(wifi_global_handle handle);
|
||||
|
||||
/* Device functions */
|
||||
wifi_device_handle (*device_init)(wifi_global_handle handle, struct device_init_params* params);
|
||||
int (*device_getfdevent)(wifi_device_handle handle, struct pollfd* fds, struct wifi_event* events);
|
||||
const struct wifi_capability* (*device_getcapability)(wifi_device_handle handle);
|
||||
int (*device_setconfiguration)(wifi_device_handle handle, struct device_setconfiguration_params* params);
|
||||
int (*device_setfrequency)(wifi_device_handle handle, struct wifi_frequency* freq);
|
||||
int (*device_setrates)(wifi_device_handle handle, struct device_setrates_params* params);
|
||||
void (*device_deinit)(wifi_device_handle handle);
|
||||
|
||||
/* WLAN functions */
|
||||
wifi_wlan_handle (*wlan_create)(wifi_device_handle handle, const char* ifname);
|
||||
int (*wlan_getfdevent)(wifi_wlan_handle handle, struct pollfd* fds, struct wifi_event* events);
|
||||
int (*wlan_startap)(wifi_wlan_handle handle, struct wlan_startap_params* params);
|
||||
void (*wlan_stopap)(wifi_wlan_handle handle);
|
||||
int (*wlan_getmacaddress)(wifi_wlan_handle handle, uint8_t* address);
|
||||
void (*wlan_delete)(wifi_wlan_handle handle);
|
||||
|
||||
/* Stations functions */
|
||||
int (*station_add)(wifi_wlan_handle handle, struct station_add_params* params);
|
||||
int (*station_delete)(wifi_device_handle handle, struct station_delete_params* params);
|
||||
};
|
||||
|
||||
/* */
|
||||
struct wifi_driver_instance {
|
||||
struct wifi_driver_ops* ops; /* Driver functions */
|
||||
@ -264,20 +222,173 @@ struct wifi_driver_instance {
|
||||
};
|
||||
|
||||
/* */
|
||||
struct wifi_global {
|
||||
int sock_util;
|
||||
struct capwap_list* devices;
|
||||
|
||||
/* Timeout */
|
||||
struct capwap_timeout* timeout;
|
||||
|
||||
/* 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 */
|
||||
|
||||
struct capwap_list* wlan; /* BSS */
|
||||
uint32_t phyindex;
|
||||
char phyname[IFNAMSIZ];
|
||||
|
||||
unsigned long flags;
|
||||
|
||||
/* */
|
||||
struct capwap_list* wlans;
|
||||
unsigned long wlanactive;
|
||||
|
||||
/* Current frequency */
|
||||
struct wifi_frequency currentfreq;
|
||||
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];
|
||||
|
||||
/* */
|
||||
send_mgmtframe_to_ac send_mgmtframe;
|
||||
void* send_mgmtframe_to_ac_cbparam;
|
||||
|
||||
/* WLAN information */
|
||||
char ssid[WIFI_SSID_MAX_LENGTH + 1];
|
||||
uint8_t ssid_hidden;
|
||||
uint16_t capability;
|
||||
|
||||
/* 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];
|
||||
};
|
||||
|
||||
/* 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_TIMEOUT_ASSOCIATION_COMPLETE 30000
|
||||
#define WIFI_STATION_TIMEOUT_AFTER_DEAUTHENTICATED 5000
|
||||
|
||||
/* */
|
||||
#define WIFI_STATION_TIMEOUT_ACTION_DELETE 0x00000001
|
||||
#define WIFI_STATION_TIMEOUT_ACTION_DEAUTHENTICATE 0x00000002
|
||||
|
||||
struct wifi_station {
|
||||
uint8_t address[MACADDRESS_EUI48_LENGTH];
|
||||
|
||||
/* */
|
||||
struct wifi_wlan* wlan;
|
||||
|
||||
/* */
|
||||
unsigned long flags;
|
||||
|
||||
/* Timers */
|
||||
int timeoutaction;
|
||||
unsigned long idtimeout;
|
||||
|
||||
/* */
|
||||
uint16_t capability;
|
||||
uint16_t listeninterval;
|
||||
uint16_t aid;
|
||||
|
||||
/* */
|
||||
int supportedratescount;
|
||||
uint8_t supportedrates[IEEE80211_SUPPORTEDRATE_MAX_COUNT];
|
||||
|
||||
/* Authentication */
|
||||
uint16_t authalgorithm;
|
||||
};
|
||||
|
||||
/* */
|
||||
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);
|
||||
int (*global_getfdevent)(wifi_global_handle handle, struct pollfd* fds, struct wifi_event* events);
|
||||
void (*global_deinit)(wifi_global_handle handle);
|
||||
|
||||
/* Device functions */
|
||||
int (*device_init)(wifi_global_handle handle, struct wifi_device* device);
|
||||
int (*device_getfdevent)(struct wifi_device* device, struct pollfd* fds, struct wifi_event* events);
|
||||
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);
|
||||
void (*device_deinit)(struct wifi_device* device);
|
||||
|
||||
/* WLAN functions */
|
||||
wifi_wlan_handle (*wlan_create)(struct wifi_device* device, struct wifi_wlan* wlan);
|
||||
int (*wlan_getfdevent)(struct wifi_wlan* wlan, struct pollfd* fds, struct wifi_event* events);
|
||||
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_delete)(struct wifi_wlan* wlan);
|
||||
|
||||
/* Stations functions */
|
||||
int (*station_authorize)(struct wifi_wlan* wlan, struct wifi_station* station);
|
||||
int (*station_deauthorize)(struct wifi_wlan* wlan, const uint8_t* address);
|
||||
};
|
||||
|
||||
/* Initialize wifi driver engine */
|
||||
@ -288,22 +399,31 @@ void wifi_driver_free(void);
|
||||
int wifi_event_getfd(struct pollfd* fds, struct wifi_event* events, int count);
|
||||
|
||||
/* */
|
||||
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_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);
|
||||
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);
|
||||
void wifi_wlan_destroy(struct wifi_wlan* wlan);
|
||||
|
||||
/* */
|
||||
int wifi_station_add(struct wifi_wlan* wlan, struct station_add_params* params);
|
||||
int wifi_station_delete(struct wifi_device* device, struct station_delete_params* params);
|
||||
/* 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, const struct ieee80211_header* frame, int length);
|
||||
|
||||
/* Station management */
|
||||
int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* params);
|
||||
int wifi_station_deauthorize(struct wifi_device* device, struct station_delete_params* params);
|
||||
|
||||
/* Util functions */
|
||||
uint32_t wifi_iface_index(const char* ifname);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,10 +9,6 @@
|
||||
#define nl_sock nl_handle
|
||||
#endif
|
||||
|
||||
/* */
|
||||
#define WIFI_NL80211_STATIONS_HASH_SIZE 256
|
||||
#define WIFI_NL80211_STATIONS_KEY_SIZE ETH_ALEN
|
||||
|
||||
/* */
|
||||
typedef int (*nl_valid_cb)(struct nl_msg* msg, void* data);
|
||||
|
||||
@ -28,62 +24,14 @@ struct nl80211_global_handle {
|
||||
struct netlink* netlinkhandle;
|
||||
|
||||
int sock_util;
|
||||
|
||||
struct capwap_list* devicelist;
|
||||
struct capwap_timeout* timeout;
|
||||
|
||||
/* Stations */
|
||||
struct capwap_hash* stations;
|
||||
};
|
||||
|
||||
/* Device handle */
|
||||
#define NL80211_DEVICE_SET_FREQUENCY 0x00000001
|
||||
#define NL80211_DEVICE_SET_RATES 0x00000002
|
||||
#define NL80211_DEVICE_SET_CONFIGURATION 0x00000004
|
||||
|
||||
#define NL80211_DEVICE_REQUIRED_FOR_BSS (NL80211_DEVICE_SET_FREQUENCY | NL80211_DEVICE_SET_RATES | NL80211_DEVICE_SET_CONFIGURATION)
|
||||
|
||||
struct nl80211_device_handle {
|
||||
struct nl80211_global_handle* globalhandle;
|
||||
|
||||
uint32_t phyindex;
|
||||
char phyname[IFNAMSIZ];
|
||||
|
||||
unsigned long flags;
|
||||
|
||||
/* */
|
||||
struct capwap_list* wlanlist;
|
||||
unsigned long wlanactive;
|
||||
|
||||
/* */
|
||||
uint16_t beaconperiod;
|
||||
uint8_t dtimperiod;
|
||||
int shortpreamble;
|
||||
|
||||
/* */
|
||||
struct wifi_frequency currentfrequency;
|
||||
|
||||
/* 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 NL80211_WLAN_RUNNING 0x00000001
|
||||
#define NL80211_WLAN_SET_BEACON 0x00000002
|
||||
#define NL80211_WLAN_OPERSTATE_RUNNING 0x00000004
|
||||
|
||||
struct nl80211_wlan_handle {
|
||||
struct nl80211_device_handle* devicehandle;
|
||||
|
||||
@ -91,94 +39,7 @@ struct nl80211_wlan_handle {
|
||||
int nl_fd;
|
||||
struct nl_cb* nl_cb;
|
||||
|
||||
unsigned long flags;
|
||||
|
||||
uint32_t virtindex;
|
||||
char virtname[IFNAMSIZ];
|
||||
|
||||
uint8_t address[ETH_ALEN];
|
||||
|
||||
uint64_t last_cookie;
|
||||
|
||||
/* */
|
||||
send_mgmtframe_to_ac send_mgmtframe;
|
||||
void* send_mgmtframe_to_ac_cbparam;
|
||||
|
||||
/* WLAN information */
|
||||
char ssid[WIFI_SSID_MAX_LENGTH + 1];
|
||||
uint8_t ssid_hidden;
|
||||
uint16_t capability;
|
||||
|
||||
/* Tunnel */
|
||||
uint8_t macmode;
|
||||
uint8_t tunnelmode;
|
||||
|
||||
/* Authentication */
|
||||
uint8_t authenticationtype;
|
||||
|
||||
/* Station information */
|
||||
unsigned long stationscount;
|
||||
unsigned long maxstationscount;
|
||||
|
||||
uint32_t aidbitfield[IEEE80211_AID_BITFIELD_SIZE];
|
||||
};
|
||||
|
||||
/* Physical device info */
|
||||
struct nl80211_phydevice_item {
|
||||
uint32_t index;
|
||||
char name[IFNAMSIZ];
|
||||
};
|
||||
|
||||
/* Virtual device info */
|
||||
struct nl80211_virtdevice_item {
|
||||
uint32_t phyindex;
|
||||
uint32_t virtindex;
|
||||
char virtname[IFNAMSIZ];
|
||||
};
|
||||
|
||||
/* Station */
|
||||
#define NL80211_STATION_FLAGS_AUTHENTICATED 0x00000001
|
||||
#define NL80211_STATION_FLAGS_ASSOCIATE 0x00000002
|
||||
#define NL80211_STATION_FLAGS_NON_ERP 0x00000004
|
||||
#define NL80211_STATION_FLAGS_NO_SHORT_SLOT_TIME 0x00000008
|
||||
#define NL80211_STATION_FLAGS_NO_SHORT_PREAMBLE 0x00000010
|
||||
#define NL80211_STATION_FLAGS_WMM 0x00000020
|
||||
#define NL80211_STATION_FLAGS_AUTHORIZED 0x00000040
|
||||
|
||||
/* */
|
||||
#define NL80211_STATION_TIMEOUT_ASSOCIATION_COMPLETE 30000
|
||||
#define NL80211_STATION_TIMEOUT_AFTER_DEAUTHENTICATED 5000
|
||||
|
||||
/* */
|
||||
#define NL80211_STATION_TIMEOUT_ACTION_DELETE 0x00000001
|
||||
#define NL80211_STATION_TIMEOUT_ACTION_DEAUTHENTICATE 0x00000002
|
||||
|
||||
/* */
|
||||
struct nl80211_station {
|
||||
struct nl80211_global_handle* globalhandle;
|
||||
uint8_t address[ETH_ALEN];
|
||||
|
||||
/* */
|
||||
struct nl80211_wlan_handle* wlanhandle;
|
||||
|
||||
/* */
|
||||
unsigned long flags;
|
||||
|
||||
/* Timers */
|
||||
int timeoutaction;
|
||||
unsigned long idtimeout;
|
||||
|
||||
/* */
|
||||
uint16_t capability;
|
||||
uint16_t listeninterval;
|
||||
uint16_t aid;
|
||||
|
||||
/* */
|
||||
int supportedratescount;
|
||||
uint8_t supportedrates[IEEE80211_SUPPORTEDRATE_MAX_COUNT];
|
||||
|
||||
/* Authentication */
|
||||
uint16_t authalgorithm;
|
||||
};
|
||||
|
||||
#endif /* __WIFI_NL80211_HEADER__ */
|
||||
|
@ -65,6 +65,7 @@ void wtp_dfa_state_run_keepalivedead_timeout(struct capwap_timeout* timeout, uns
|
||||
void wtp_dfa_state_reset(void);
|
||||
|
||||
/* */
|
||||
void wtp_ieee80211_packet(uint8_t radioid, const struct ieee80211_header* header, int length);
|
||||
void wtp_send_data_packet(uint8_t radioid, uint8_t wlanid, const uint8_t* data, int length, int leavenativeframe);
|
||||
|
||||
#endif /* __WTP_DFA_HEADER__ */
|
||||
|
@ -3,6 +3,11 @@
|
||||
#include "capwap_element.h"
|
||||
#include "wtp_dfa.h"
|
||||
#include "wtp_radio.h"
|
||||
#include "ieee80211.h"
|
||||
|
||||
/* */
|
||||
#define WTP_BODY_PACKET_MAX_SIZE 8192
|
||||
static uint8_t g_bodypacket[WTP_BODY_PACKET_MAX_SIZE];
|
||||
|
||||
/* */
|
||||
static int send_echo_request(void) {
|
||||
@ -371,7 +376,14 @@ void wtp_dfa_state_run(struct capwap_parsed_packet* packet) {
|
||||
capwap_timeout_set(g_wtp.timeout, g_wtp.idtimerkeepalive, WTP_DATACHANNEL_KEEPALIVE_INTERVAL, wtp_dfa_state_run_keepalive_timeout, NULL, NULL);
|
||||
}
|
||||
} else {
|
||||
/* TODO */
|
||||
/* Get body packet */
|
||||
int bodypacketlength = capwap_packet_getdata(packet->rxmngpacket, g_bodypacket, WTP_BODY_PACKET_MAX_SIZE);
|
||||
if (bodypacketlength > 0) {
|
||||
uint8_t radioid = GET_RID_HEADER(packet->rxmngpacket->header);
|
||||
unsigned short binding = GET_WBID_HEADER(packet->rxmngpacket->header);
|
||||
|
||||
wtp_radio_receive_data_packet(radioid, binding, g_bodypacket, bodypacketlength);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -537,6 +537,24 @@ struct wtp_radio_wlan* wtp_radio_get_wlan(struct wtp_radio* radio, uint8_t wlani
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* */
|
||||
struct wtp_radio_wlan* wtp_radio_search_wlan(struct wtp_radio* radio, const uint8_t* bssid) {
|
||||
struct capwap_list_item* itemwlan;
|
||||
|
||||
ASSERT(radio != NULL);
|
||||
ASSERT(bssid != NULL);
|
||||
|
||||
/* Retrieve BSS */
|
||||
for (itemwlan = radio->wlan->first; itemwlan != NULL; itemwlan = itemwlan->next) {
|
||||
struct wtp_radio_wlan* wlan = (struct wtp_radio_wlan*)itemwlan->item;
|
||||
if (!memcmp(bssid, wlan->wlanhandle->address, MACADDRESS_EUI48_LENGTH)) {
|
||||
return wlan;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* */
|
||||
void wtp_radio_update_fdevent(struct wtp_fds* fds) {
|
||||
int count;
|
||||
@ -579,6 +597,34 @@ void wtp_radio_update_fdevent(struct wtp_fds* fds) {
|
||||
}
|
||||
}
|
||||
|
||||
/* */
|
||||
void wtp_radio_receive_data_packet(uint8_t radioid, unsigned short binding, const uint8_t* frame, int length) {
|
||||
struct wtp_radio* radio;
|
||||
struct wtp_radio_wlan* wlan;
|
||||
|
||||
ASSERT(frame != NULL);
|
||||
ASSERT(length > 0);
|
||||
|
||||
/* Get radio */
|
||||
radio = wtp_radio_get_phy(radioid);
|
||||
if (!radio) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((binding == CAPWAP_WIRELESS_BINDING_IEEE80211) && (length >= sizeof(struct ieee80211_header))) {
|
||||
const struct ieee80211_header* header = (const struct ieee80211_header*)frame;
|
||||
const uint8_t* bssid = ieee80211_get_bssid_addr(header);
|
||||
|
||||
if (bssid) {
|
||||
wlan = wtp_radio_search_wlan(radio, bssid);
|
||||
if (wlan) {
|
||||
wifi_wlan_receive_ac_frame(wlan->wlanhandle, header, length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* */
|
||||
uint32_t wtp_radio_create_wlan(struct capwap_parsed_packet* packet, struct capwap_80211_assignbssid_element* bssid) {
|
||||
struct wtp_radio* radio;
|
||||
@ -711,7 +757,7 @@ uint32_t wtp_radio_add_station(struct capwap_parsed_packet* packet) {
|
||||
memset(&stationparams, 0, sizeof(struct station_add_params));
|
||||
stationparams.address = station80211->address;
|
||||
|
||||
if (wifi_station_add(wlan->wlanhandle, &stationparams)) {
|
||||
if (wifi_station_authorize(wlan->wlanhandle, &stationparams)) {
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
@ -737,7 +783,7 @@ uint32_t wtp_radio_delete_station(struct capwap_parsed_packet* packet) {
|
||||
memset(&stationparams, 0, sizeof(struct station_delete_params));
|
||||
stationparams.address = deletestation->address;
|
||||
|
||||
if (wifi_station_delete(radio->devicehandle, &stationparams)) {
|
||||
if (wifi_station_deauthorize(radio->devicehandle, &stationparams)) {
|
||||
return CAPWAP_RESULTCODE_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -66,6 +66,10 @@ void wtp_radio_free(void);
|
||||
struct wtp_radio* wtp_radio_create_phy(void);
|
||||
struct wtp_radio* wtp_radio_get_phy(uint8_t radioid);
|
||||
struct wtp_radio_wlan* wtp_radio_get_wlan(struct wtp_radio* radio, uint8_t wlanid);
|
||||
struct wtp_radio_wlan* wtp_radio_search_wlan(struct wtp_radio* radio, const uint8_t* bssid);
|
||||
|
||||
/* */
|
||||
void wtp_radio_receive_data_packet(uint8_t radioid, unsigned short binding, const uint8_t* frame, int length);
|
||||
|
||||
/* */
|
||||
int wtp_radio_setconfiguration(struct capwap_parsed_packet* packet);
|
||||
|
Loading…
Reference in New Issue
Block a user