implement basic 802.11n support
Add suport to enable 80211n support on the BSS and set station parameters through the "Add Station" procedure. Setting 802.11n radio parameters is rudementary and does not work yet.
This commit is contained in:
@ -721,7 +721,7 @@ static void wifi_wlan_receive_station_mgmt_association_request(struct wifi_wlan*
|
||||
}
|
||||
|
||||
/* Create association response packet */
|
||||
memset(¶ms, 0, sizeof(struct ieee80211_authentication_params));
|
||||
memset(¶ms, 0, sizeof(struct ieee80211_associationresponse_params));
|
||||
memcpy(params.bssid, wlan->address, ETH_ALEN);
|
||||
memcpy(params.station, frame->sa, ETH_ALEN);
|
||||
params.capability = wifi_wlan_check_capability(wlan, wlan->capability);
|
||||
@ -1603,6 +1603,40 @@ static void build_80211_ie(uint8_t radioid, uint8_t wlanid, uint8_t type,
|
||||
}
|
||||
}
|
||||
|
||||
/* Scan AC provided IEs for HT Capabilities and HT Operation */
|
||||
static int ht_opmode_from_ie(uint8_t radioid, uint8_t wlanid,
|
||||
struct capwap_array *ie)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!ie)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < ie->count; i++) {
|
||||
struct ieee80211_ht_operation *ht_oper;
|
||||
struct capwap_80211_ie_element *e =
|
||||
*(struct capwap_80211_ie_element **)capwap_array_get_item_pointer(ie, i);
|
||||
|
||||
log_printf(LOG_DEBUG, "HT Mode WIFI 802.11: IE: %d:%d %02x (%p)",
|
||||
radioid, wlanid, e->flags, &e->flags);
|
||||
|
||||
if (e->radioid != radioid ||
|
||||
e->wlanid != wlanid ||
|
||||
!(e->flags & CAPWAP_IE_BEACONS_ASSOCIATED) ||
|
||||
e->ielength < 2)
|
||||
continue;
|
||||
|
||||
ht_oper = (struct ieee80211_ht_operation *)e->ie;
|
||||
log_printf(LOG_DEBUG, "HT Mode WIFI 802.11: IE: %02d (%p)",
|
||||
ht_oper->id, ht_oper);
|
||||
if (ht_oper->id == IEEE80211_IE_HT_OPERATION)
|
||||
return __le16_to_cpu(ht_oper->operation_mode);
|
||||
}
|
||||
|
||||
log_printf(LOG_DEBUG, "WIFI 802.11: No HT Operation IE present");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* */
|
||||
int wifi_wlan_startap(struct wifi_wlan* wlan, struct wlan_startap_params* params) {
|
||||
int result;
|
||||
@ -1625,6 +1659,9 @@ int wifi_wlan_startap(struct wifi_wlan* wlan, struct wlan_startap_params* params
|
||||
wlan->tunnelmode = params->tunnelmode;
|
||||
wlan->radioid = params->radioid;
|
||||
wlan->wlanid = params->wlanid;
|
||||
wlan->ht_opmode = ht_opmode_from_ie(wlan->radioid, wlan->wlanid,
|
||||
params->ie);
|
||||
log_printf(LOG_DEBUG, "WIFI 802.11: HT OpMode: %04x", wlan->ht_opmode);
|
||||
|
||||
build_80211_ie(wlan->radioid, wlan->wlanid,
|
||||
CAPWAP_IE_BEACONS_ASSOCIATED,
|
||||
@ -1855,8 +1892,13 @@ int wifi_station_authorize(struct wifi_wlan* wlan, struct station_add_params* pa
|
||||
|
||||
/* Station is authorized only after Authentication and Association */
|
||||
station->flags |= WIFI_STATION_FLAGS_AUTHORIZED;
|
||||
if (!(station->flags & WIFI_STATION_FLAGS_AUTHENTICATED) || !(station->flags & WIFI_STATION_FLAGS_ASSOCIATE)) {
|
||||
if (!(station->flags & WIFI_STATION_FLAGS_AUTHENTICATED) ||
|
||||
!(station->flags & WIFI_STATION_FLAGS_ASSOCIATE))
|
||||
return 0;
|
||||
|
||||
if (params->ht_cap) {
|
||||
memcpy(&station->ht_cap, params->ht_cap, sizeof(station->ht_cap));
|
||||
station->flags |= WIFI_STATION_FLAGS_HT_CAP;
|
||||
}
|
||||
|
||||
/* Station authorized */
|
||||
|
@ -124,6 +124,7 @@ struct wlan_send_frame_params {
|
||||
/* */
|
||||
struct station_add_params {
|
||||
uint8_t* address;
|
||||
struct ieee80211_ht_cap *ht_cap;
|
||||
};
|
||||
|
||||
/* Interface capability */
|
||||
@ -151,6 +152,8 @@ 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;
|
||||
@ -300,6 +303,7 @@ struct wifi_wlan {
|
||||
char ssid[IEEE80211_SSID_MAX_LENGTH + 1];
|
||||
uint8_t ssid_hidden;
|
||||
uint16_t capability;
|
||||
int ht_opmode;
|
||||
|
||||
/* Tunnel */
|
||||
uint8_t macmode;
|
||||
@ -321,13 +325,14 @@ struct wifi_wlan {
|
||||
};
|
||||
|
||||
/* 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_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_WMM 0x00000020
|
||||
#define WIFI_STATION_FLAGS_AUTHORIZED 0x00000040
|
||||
#define WIFI_STATION_FLAGS_HT_CAP 0x00000080
|
||||
|
||||
/* */
|
||||
#define WIFI_STATION_TIMEOUT_ASSOCIATION_COMPLETE 30000
|
||||
@ -364,6 +369,8 @@ struct wifi_station {
|
||||
uint16_t authalgorithm;
|
||||
|
||||
uint8_t qosinfo;
|
||||
|
||||
struct ieee80211_ht_cap ht_cap;
|
||||
};
|
||||
|
||||
/* */
|
||||
|
@ -762,6 +762,11 @@ static int nl80211_wlan_setbeacon(struct wifi_wlan* wlan) {
|
||||
nla_put(msg, NL80211_ATTR_BSS_BASIC_RATES, wlan->device->basicratescount, wlan->device->basicrates);
|
||||
}
|
||||
|
||||
if (wlan->ht_opmode >= 0) {
|
||||
log_printf(LOG_DEBUG, "nl80211: h_opmode=%04x", wlan->ht_opmode);
|
||||
nla_put_u16(msg, NL80211_ATTR_BSS_HT_OPMODE, wlan->ht_opmode);
|
||||
}
|
||||
|
||||
/* */
|
||||
result = nl80211_send_and_recv_msg(wlanhandle->devicehandle->globalhandle, msg, NULL, NULL);
|
||||
if (!result) {
|
||||
@ -1036,6 +1041,14 @@ int nl80211_station_authorize(struct wifi_wlan* wlan, struct wifi_station* stati
|
||||
|
||||
/* */
|
||||
wlanhandle = (struct nl80211_wlan_handle*)wlan->handle;
|
||||
|
||||
log_printf(LOG_DEBUG, "nl80211: Add STA " MACSTR, MAC2STR(station->address));
|
||||
log_hexdump(LOG_DEBUG, " * supported rates",
|
||||
station->supportedrates, station->supportedratescount);
|
||||
log_printf(LOG_DEBUG, " * aid=%u", station->aid);
|
||||
log_printf(LOG_DEBUG, " * listen_interval=%u", station->listeninterval);
|
||||
log_printf(LOG_DEBUG, " * capability=0x%x", station->capability);
|
||||
|
||||
genlmsg_put(msg, 0, 0, wlanhandle->devicehandle->globalhandle->nl80211_id, 0, 0, NL80211_CMD_NEW_STATION, 0);
|
||||
nla_put_u32(msg, NL80211_ATTR_IFINDEX, wlan->virtindex);
|
||||
nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, station->address);
|
||||
@ -1066,6 +1079,13 @@ int nl80211_station_authorize(struct wifi_wlan* wlan, struct wifi_station* stati
|
||||
nla_nest_end(msg, wme);
|
||||
}
|
||||
|
||||
if (station->flags & WIFI_STATION_FLAGS_HT_CAP) {
|
||||
log_hexdump(LOG_DEBUG, " * ht_capabilities",
|
||||
(uint8_t *)&station->ht_cap, sizeof(station->ht_cap));
|
||||
nla_put(msg, NL80211_ATTR_HT_CAPABILITY,
|
||||
sizeof(station->ht_cap), &station->ht_cap);
|
||||
}
|
||||
|
||||
/* */
|
||||
result = nl80211_send_and_recv_msg(wlanhandle->devicehandle->globalhandle, msg, NULL, NULL);
|
||||
if (result) {
|
||||
@ -1391,6 +1411,18 @@ static int cb_get_phydevice_capability(struct nl_msg* msg, void* data) {
|
||||
capability->radiotype |= CAPWAP_RADIO_TYPE_80211N;
|
||||
}
|
||||
|
||||
if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR])
|
||||
bandcap->a_mpdu_params |= nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_FACTOR]) & 0x03;
|
||||
|
||||
if (tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY])
|
||||
bandcap->a_mpdu_params |= nla_get_u8(tb_band[NL80211_BAND_ATTR_HT_AMPDU_DENSITY]) << 2;
|
||||
|
||||
|
||||
if (tb_band[NL80211_BAND_ATTR_HT_MCS_SET] &&
|
||||
nla_len(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]) >= 16) {
|
||||
memcpy(bandcap->mcs_set, nla_data(tb_band[NL80211_BAND_ATTR_HT_MCS_SET]), 16);
|
||||
}
|
||||
|
||||
/* Frequency */
|
||||
if (tb_band[NL80211_BAND_ATTR_FREQS]) {
|
||||
struct nlattr* nl_freq;
|
||||
|
Reference in New Issue
Block a user