Move hostapd-to-driver flag mapping to be within ap_drv_ops.c

This commit is contained in:
Jouni Malinen 2009-12-24 23:11:16 +02:00
parent d3b86aed73
commit 4c2ddda495
4 changed files with 34 additions and 26 deletions

View file

@ -20,6 +20,21 @@
#include "driver_i.h"
static int hostapd_sta_flags_to_drv(int flags)
{
int res = 0;
if (flags & WLAN_STA_AUTHORIZED)
res |= WPA_STA_AUTHORIZED;
if (flags & WLAN_STA_WMM)
res |= WPA_STA_WMM;
if (flags & WLAN_STA_SHORT_PREAMBLE)
res |= WPA_STA_SHORT_PREAMBLE;
if (flags & WLAN_STA_MFP)
res |= WPA_STA_MFP;
return res;
}
static int hostapd_set_ap_wps_ie(struct hostapd_data *hapd,
const struct wpabuf *beacon,
const struct wpabuf *proberesp)
@ -98,6 +113,22 @@ static int hostapd_sta_clear_stats(struct hostapd_data *hapd, const u8 *addr)
}
static int hostapd_set_sta_flags(struct hostapd_data *hapd,
struct sta_info *sta)
{
int set_flags, total_flags, flags_and, flags_or;
total_flags = hostapd_sta_flags_to_drv(sta->flags);
set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
if (!hapd->conf->ieee802_1x && !hapd->conf->wpa &&
sta->flags & WLAN_STA_AUTHORIZED)
set_flags |= WPA_STA_AUTHORIZED;
flags_or = total_flags & set_flags;
flags_and = total_flags | ~set_flags;
return hostapd_sta_set_flags(hapd, sta->addr, total_flags,
flags_or, flags_and);
}
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
{
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
@ -107,4 +138,5 @@ void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
ops->set_key = hostapd_set_key;
ops->read_sta_data = hostapd_read_sta_data;
ops->sta_clear_stats = hostapd_sta_clear_stats;
ops->set_sta_flags = hostapd_set_sta_flags;
}

View file

@ -1505,18 +1505,3 @@ int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
}
return hostapd_set_ieee8021x(hapd, &params);
}
int hostapd_sta_flags_to_drv(int flags)
{
int res = 0;
if (flags & WLAN_STA_AUTHORIZED)
res |= WPA_STA_AUTHORIZED;
if (flags & WLAN_STA_WMM)
res |= WPA_STA_WMM;
if (flags & WLAN_STA_SHORT_PREAMBLE)
res |= WPA_STA_SHORT_PREAMBLE;
if (flags & WLAN_STA_MFP)
res |= WPA_STA_MFP;
return res;
}

View file

@ -61,6 +61,7 @@ struct hostapd_driver_ops {
struct hostap_sta_driver_data *data,
const u8 *addr);
int (*sta_clear_stats)(struct hostapd_data *hapd, const u8 *addr);
int (*set_sta_flags)(struct hostapd_data *hapd, struct sta_info *sta);
};
/**
@ -215,7 +216,6 @@ int hostapd_register_probereq_cb(struct hostapd_data *hapd,
void *ctx);
int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
int enabled);
int hostapd_sta_flags_to_drv(int flags);
int eap_server_register_methods(void);
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops);

View file

@ -1480,7 +1480,6 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
struct sta_info *sta;
int new_assoc = 1;
struct ieee80211_ht_capabilities ht_cap;
int set_flags, total_flags, flags_and, flags_or;
if (!ok) {
hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
@ -1573,15 +1572,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
ap_sta_bind_vlan(hapd, sta, 0);
}
total_flags = hostapd_sta_flags_to_drv(sta->flags);
set_flags = WPA_STA_SHORT_PREAMBLE | WPA_STA_WMM | WPA_STA_MFP;
if (!hapd->conf->ieee802_1x && !hapd->conf->wpa &&
sta->flags & WLAN_STA_AUTHORIZED)
set_flags |= WPA_STA_AUTHORIZED;
flags_or = total_flags & set_flags;
flags_and = total_flags | ~set_flags;
hostapd_sta_set_flags(hapd, sta->addr, total_flags,
flags_or, flags_and);
hapd->drv.set_sta_flags(hapd, sta);
if (sta->auth_alg == WLAN_AUTH_FT)
wpa_auth_sm_event(sta->wpa_sm, WPA_ASSOC_FT);