Map STA flags into values defined in driver.h

This removes need for including hostapd/sta_flags.h into driver
wrappers and removes any remaining dependencies between driver flags
and internal hostapd flags.
This commit is contained in:
Jouni Malinen 2009-12-13 11:35:39 +02:00
parent a34325dde9
commit 0de39516ae
10 changed files with 60 additions and 35 deletions

View file

@ -1507,3 +1507,18 @@ int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
} }
return hostapd_set_ieee8021x(hapd, &params); 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

@ -189,6 +189,7 @@ int hostapd_register_probereq_cb(struct hostapd_data *hapd,
void *ctx); void *ctx);
int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname, int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname,
int enabled); int enabled);
int hostapd_sta_flags_to_drv(int flags);
int eap_server_register_methods(void); int eap_server_register_methods(void);

View file

@ -1466,7 +1466,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
struct sta_info *sta; struct sta_info *sta;
int new_assoc = 1; int new_assoc = 1;
struct ieee80211_ht_capabilities ht_cap; struct ieee80211_ht_capabilities ht_cap;
int set_flags, flags_and, flags_or; int set_flags, total_flags, flags_and, flags_or;
if (!ok) { if (!ok) {
hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211, hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
@ -1559,13 +1559,14 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
ap_sta_bind_vlan(hapd, sta, 0); ap_sta_bind_vlan(hapd, sta, 0);
} }
set_flags = WLAN_STA_SHORT_PREAMBLE | WLAN_STA_WMM | WLAN_STA_MFP; 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 && if (!hapd->conf->ieee802_1x && !hapd->conf->wpa &&
sta->flags & WLAN_STA_AUTHORIZED) sta->flags & WLAN_STA_AUTHORIZED)
set_flags |= WLAN_STA_AUTHORIZED; set_flags |= WPA_STA_AUTHORIZED;
flags_or = sta->flags & set_flags; flags_or = total_flags & set_flags;
flags_and = sta->flags | ~set_flags; flags_and = total_flags | ~set_flags;
hostapd_sta_set_flags(hapd, sta->addr, sta->flags, hostapd_sta_set_flags(hapd, sta->addr, total_flags,
flags_or, flags_and); flags_or, flags_and);
if (sta->auth_alg == WLAN_AUTH_FT) if (sta->auth_alg == WLAN_AUTH_FT)

View file

@ -91,8 +91,10 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
wpa_msg(hapd->msg_ctx, MSG_INFO, wpa_msg(hapd->msg_ctx, MSG_INFO,
AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr)); AP_STA_CONNECTED MACSTR, MAC2STR(sta->addr));
sta->flags |= WLAN_STA_AUTHORIZED; sta->flags |= WLAN_STA_AUTHORIZED;
res = hostapd_sta_set_flags(hapd, sta->addr, sta->flags, res = hostapd_sta_set_flags(hapd, sta->addr,
WLAN_STA_AUTHORIZED, ~0); hostapd_sta_flags_to_drv(
sta->flags),
WPA_STA_AUTHORIZED, ~0);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X, hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_DEBUG, "authorizing port"); HOSTAPD_LEVEL_DEBUG, "authorizing port");
} else { } else {
@ -102,8 +104,10 @@ void ieee802_1x_set_sta_authorized(struct hostapd_data *hapd,
AP_STA_DISCONNECTED MACSTR, AP_STA_DISCONNECTED MACSTR,
MAC2STR(sta->addr)); MAC2STR(sta->addr));
sta->flags &= ~WLAN_STA_AUTHORIZED; sta->flags &= ~WLAN_STA_AUTHORIZED;
res = hostapd_sta_set_flags(hapd, sta->addr, sta->flags, res = hostapd_sta_set_flags(hapd, sta->addr,
0, ~WLAN_STA_AUTHORIZED); hostapd_sta_flags_to_drv(
sta->flags),
0, ~WPA_STA_AUTHORIZED);
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X, hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE8021X,
HOSTAPD_LEVEL_DEBUG, "unauthorizing port"); HOSTAPD_LEVEL_DEBUG, "unauthorizing port");
} }

View file

@ -494,6 +494,10 @@ struct wpa_bss_params {
int rsn_preauth; int rsn_preauth;
}; };
#define WPA_STA_AUTHORIZED BIT(0)
#define WPA_STA_WMM BIT(1)
#define WPA_STA_SHORT_PREAMBLE BIT(2)
#define WPA_STA_MFP BIT(3)
/** /**
* struct wpa_driver_ops - Driver interface API definition * struct wpa_driver_ops - Driver interface API definition
@ -1320,9 +1324,9 @@ struct wpa_driver_ops {
* sta_set_flags - Set station flags (AP only) * sta_set_flags - Set station flags (AP only)
* @priv: Private driver interface data * @priv: Private driver interface data
* @addr: Station address * @addr: Station address
* @total_flags: Bitmap of all WLAN_STA_* flags currently set * @total_flags: Bitmap of all WPA_STA_* flags currently set
* @flags_or: Bitmap of WLAN_STA_* flags to add * @flags_or: Bitmap of WPA_STA_* flags to add
* @flags_and: Bitmap of WLAN_STA_* flags to us as a mask * @flags_and: Bitmap of WPA_STA_* flags to us as a mask
* Returns: 0 on success, -1 on failure * Returns: 0 on success, -1 on failure
*/ */
int (*sta_set_flags)(void *priv, const u8 *addr, int (*sta_set_flags)(void *priv, const u8 *addr,

View file

@ -58,7 +58,6 @@
#include "wireless_copy.h" #include "wireless_copy.h"
#include "../hostapd/sta_flags.h"
#include "driver.h" #include "driver.h"
#include "eloop.h" #include "eloop.h"
#include "priv_netlink.h" #include "priv_netlink.h"
@ -375,9 +374,9 @@ madwifi_sta_set_flags(void *priv, const u8 *addr, int total_flags,
int flags_or, int flags_and) int flags_or, int flags_and)
{ {
/* For now, only support setting Authorized flag */ /* For now, only support setting Authorized flag */
if (flags_or & WLAN_STA_AUTHORIZED) if (flags_or & WPA_STA_AUTHORIZED)
return madwifi_set_sta_authorized(priv, addr, 1); return madwifi_set_sta_authorized(priv, addr, 1);
if (!(flags_and & WLAN_STA_AUTHORIZED)) if (!(flags_and & WPA_STA_AUTHORIZED))
return madwifi_set_sta_authorized(priv, addr, 0); return madwifi_set_sta_authorized(priv, addr, 0);
return 0; return 0;
} }

View file

@ -154,7 +154,6 @@ bsd_set_ssid(int s, const char *ifname, const u8 *ssid, size_t ssid_len)
#undef WPA_OUI_TYPE #undef WPA_OUI_TYPE
#include "l2_packet/l2_packet.h" #include "l2_packet/l2_packet.h"
#include "../../hostapd/sta_flags.h"
struct bsd_driver_data { struct bsd_driver_data {
struct hostapd_data *hapd; /* back pointer */ struct hostapd_data *hapd; /* back pointer */
@ -382,9 +381,9 @@ bsd_sta_set_flags(void *priv, const u8 *addr, int total_flags, int flags_or,
int flags_and) int flags_and)
{ {
/* For now, only support setting Authorized flag */ /* For now, only support setting Authorized flag */
if (flags_or & WLAN_STA_AUTHORIZED) if (flags_or & WPA_STA_AUTHORIZED)
return bsd_set_sta_authorized(priv, addr, 1); return bsd_set_sta_authorized(priv, addr, 1);
if (!(flags_and & WLAN_STA_AUTHORIZED)) if (!(flags_and & WPA_STA_AUTHORIZED))
return bsd_set_sta_authorized(priv, addr, 0); return bsd_set_sta_authorized(priv, addr, 0);
return 0; return 0;
} }

View file

@ -30,7 +30,6 @@
#include "priv_netlink.h" #include "priv_netlink.h"
#include "common/ieee802_11_defs.h" #include "common/ieee802_11_defs.h"
#include "../../hostapd/sta_flags.h"
/* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X /* MTU to be set for the wlan#ap device; this is mainly needed for IEEE 802.1X
@ -359,6 +358,12 @@ static int hostap_sta_set_flags(void *priv, const u8 *addr,
struct hostap_driver_data *drv = priv; struct hostap_driver_data *drv = priv;
struct prism2_hostapd_param param; struct prism2_hostapd_param param;
if (flags_or & WPA_STA_AUTHORIZED)
flags_or = BIT(5); /* WLAN_STA_AUTHORIZED */
if (!(flags_and & WPA_STA_AUTHORIZED))
flags_and = ~BIT(5);
else
flags_and = ~0;
memset(&param, 0, sizeof(param)); memset(&param, 0, sizeof(param));
param.cmd = PRISM2_HOSTAPD_SET_FLAGS_STA; param.cmd = PRISM2_HOSTAPD_SET_FLAGS_STA;
memcpy(param.sta_addr, addr, ETH_ALEN); memcpy(param.sta_addr, addr, ETH_ALEN);
@ -693,7 +698,7 @@ static int hostap_sta_remove(void *priv, const u8 *addr)
struct hostap_driver_data *drv = priv; struct hostap_driver_data *drv = priv;
struct prism2_hostapd_param param; struct prism2_hostapd_param param;
hostap_sta_set_flags(drv, addr, 0, 0, ~WLAN_STA_AUTHORIZED); hostap_sta_set_flags(drv, addr, 0, 0, ~WPA_STA_AUTHORIZED);
memset(&param, 0, sizeof(param)); memset(&param, 0, sizeof(param));
param.cmd = PRISM2_HOSTAPD_REMOVE_STA; param.cmd = PRISM2_HOSTAPD_REMOVE_STA;

View file

@ -74,7 +74,6 @@
#include "priv_netlink.h" #include "priv_netlink.h"
#include "l2_packet/l2_packet.h" #include "l2_packet/l2_packet.h"
#include "../../hostapd/sta_flags.h"
struct madwifi_driver_data { struct madwifi_driver_data {
@ -420,9 +419,9 @@ madwifi_sta_set_flags(void *priv, const u8 *addr, int total_flags,
int flags_or, int flags_and) int flags_or, int flags_and)
{ {
/* For now, only support setting Authorized flag */ /* For now, only support setting Authorized flag */
if (flags_or & WLAN_STA_AUTHORIZED) if (flags_or & WPA_STA_AUTHORIZED)
return madwifi_set_sta_authorized(priv, addr, 1); return madwifi_set_sta_authorized(priv, addr, 1);
if (!(flags_and & WLAN_STA_AUTHORIZED)) if (!(flags_and & WPA_STA_AUTHORIZED))
return madwifi_set_sta_authorized(priv, addr, 0); return madwifi_set_sta_authorized(priv, addr, 0);
return 0; return 0;
} }

View file

@ -35,8 +35,6 @@
#include <linux/filter.h> #include <linux/filter.h>
#include "radiotap.h" #include "radiotap.h"
#include "radiotap_iter.h" #include "radiotap_iter.h"
#include "../../hostapd/sta_flags.h"
#endif /* CONFIG_AP || HOSTAPD */ #endif /* CONFIG_AP || HOSTAPD */
#ifdef CONFIG_LIBNL20 #ifdef CONFIG_LIBNL20
@ -3252,7 +3250,7 @@ static int wpa_driver_nl80211_hapd_send_eapol(
u8 *pos; u8 *pos;
int res; int res;
#if 0 /* FIX */ #if 0 /* FIX */
int qos = sta->flags & WLAN_STA_WME; int qos = sta->flags & WPA_STA_WMM;
#else #else
int qos = 0; int qos = 0;
#endif #endif
@ -3314,13 +3312,13 @@ static u32 sta_flags_nl80211(int flags)
{ {
u32 f = 0; u32 f = 0;
if (flags & WLAN_STA_AUTHORIZED) if (flags & WPA_STA_AUTHORIZED)
f |= BIT(NL80211_STA_FLAG_AUTHORIZED); f |= BIT(NL80211_STA_FLAG_AUTHORIZED);
if (flags & WLAN_STA_WMM) if (flags & WPA_STA_WMM)
f |= BIT(NL80211_STA_FLAG_WME); f |= BIT(NL80211_STA_FLAG_WME);
if (flags & WLAN_STA_SHORT_PREAMBLE) if (flags & WPA_STA_SHORT_PREAMBLE)
f |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE); f |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
if (flags & WLAN_STA_MFP) if (flags & WPA_STA_MFP)
f |= BIT(NL80211_STA_FLAG_MFP); f |= BIT(NL80211_STA_FLAG_MFP);
return f; return f;
@ -3356,16 +3354,16 @@ static int wpa_driver_nl80211_sta_set_flags(void *priv, const u8 *addr,
* Backwards compatibility version using NL80211_ATTR_STA_FLAGS. This * Backwards compatibility version using NL80211_ATTR_STA_FLAGS. This
* can be removed eventually. * can be removed eventually.
*/ */
if (total_flags & WLAN_STA_AUTHORIZED) if (total_flags & WPA_STA_AUTHORIZED)
NLA_PUT_FLAG(flags, NL80211_STA_FLAG_AUTHORIZED); NLA_PUT_FLAG(flags, NL80211_STA_FLAG_AUTHORIZED);
if (total_flags & WLAN_STA_WMM) if (total_flags & WPA_STA_WMM)
NLA_PUT_FLAG(flags, NL80211_STA_FLAG_WME); NLA_PUT_FLAG(flags, NL80211_STA_FLAG_WME);
if (total_flags & WLAN_STA_SHORT_PREAMBLE) if (total_flags & WPA_STA_SHORT_PREAMBLE)
NLA_PUT_FLAG(flags, NL80211_STA_FLAG_SHORT_PREAMBLE); NLA_PUT_FLAG(flags, NL80211_STA_FLAG_SHORT_PREAMBLE);
if (total_flags & WLAN_STA_MFP) if (total_flags & WPA_STA_MFP)
NLA_PUT_FLAG(flags, NL80211_STA_FLAG_MFP); NLA_PUT_FLAG(flags, NL80211_STA_FLAG_MFP);
if (nla_put_nested(msg, NL80211_ATTR_STA_FLAGS, flags)) if (nla_put_nested(msg, NL80211_ATTR_STA_FLAGS, flags))