From 4c2ddda4955b8f32f6dfafceeb988ed3917430b8 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Thu, 24 Dec 2009 23:11:16 +0200 Subject: [PATCH] Move hostapd-to-driver flag mapping to be within ap_drv_ops.c --- hostapd/ap_drv_ops.c | 32 ++++++++++++++++++++++++++++++++ hostapd/hostapd.c | 15 --------------- hostapd/hostapd.h | 2 +- hostapd/ieee802_11.c | 11 +---------- 4 files changed, 34 insertions(+), 26 deletions(-) diff --git a/hostapd/ap_drv_ops.c b/hostapd/ap_drv_ops.c index bce685954..b771f4715 100644 --- a/hostapd/ap_drv_ops.c +++ b/hostapd/ap_drv_ops.c @@ -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; } diff --git a/hostapd/hostapd.c b/hostapd/hostapd.c index fefe06689..17012e657 100644 --- a/hostapd/hostapd.c +++ b/hostapd/hostapd.c @@ -1505,18 +1505,3 @@ int hostapd_set_drv_ieee8021x(struct hostapd_data *hapd, const char *ifname, } return hostapd_set_ieee8021x(hapd, ¶ms); } - - -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; -} diff --git a/hostapd/hostapd.h b/hostapd/hostapd.h index b5f8f111e..b3f5cb8f5 100644 --- a/hostapd/hostapd.h +++ b/hostapd/hostapd.h @@ -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); diff --git a/hostapd/ieee802_11.c b/hostapd/ieee802_11.c index f3dc81a3a..d74bb0baf 100644 --- a/hostapd/ieee802_11.c +++ b/hostapd/ieee802_11.c @@ -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);