hostapd_driver_ops reduction

set_sta_vlan, get_inact_sec, sta_deauth, sta_disassoc, and sta_remove
to use inline functions instead of extra abstraction.
This commit is contained in:
Jouni Malinen 2010-11-24 15:36:02 +02:00 committed by Jouni Malinen
parent b5b1b18f39
commit 51e2a27a21
9 changed files with 72 additions and 84 deletions

View file

@ -35,6 +35,7 @@
#include "ap/accounting.h" #include "ap/accounting.h"
#include "ap/wps_hostapd.h" #include "ap/wps_hostapd.h"
#include "ap/ctrl_iface_ap.h" #include "ap/ctrl_iface_ap.h"
#include "ap/ap_drv_ops.h"
#include "wps/wps_defs.h" #include "wps/wps_defs.h"
#include "wps/wps.h" #include "wps/wps.h"
#include "ctrl_iface.h" #include "ctrl_iface.h"
@ -255,7 +256,7 @@ static int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
} }
#endif /* CONFIG_P2P_MANAGER */ #endif /* CONFIG_P2P_MANAGER */
hapd->drv.sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_drv_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
sta = ap_get_sta(hapd, addr); sta = ap_get_sta(hapd, addr);
if (sta) if (sta)
ap_sta_deauthenticate(hapd, sta, ap_sta_deauthenticate(hapd, sta,
@ -311,7 +312,7 @@ static int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
} }
#endif /* CONFIG_P2P_MANAGER */ #endif /* CONFIG_P2P_MANAGER */
hapd->drv.sta_disassoc(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_drv_sta_disassoc(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
sta = ap_get_sta(hapd, addr); sta = ap_get_sta(hapd, addr);
if (sta) if (sta)
ap_sta_disassociate(hapd, sta, ap_sta_disassociate(hapd, sta,

View file

@ -384,44 +384,6 @@ static int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr,
} }
static int hostapd_set_sta_vlan(const char *ifname, struct hostapd_data *hapd,
const u8 *addr, int vlan_id)
{
if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
return 0;
return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname,
vlan_id);
}
static int hostapd_get_inact_sec(struct hostapd_data *hapd, const u8 *addr)
{
if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
return 0;
return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
}
static int hostapd_sta_deauth(struct hostapd_data *hapd, const u8 *addr,
int reason)
{
if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
return 0;
return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
reason);
}
static int hostapd_sta_disassoc(struct hostapd_data *hapd, const u8 *addr,
int reason)
{
if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
return 0;
return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
reason);
}
static int hostapd_sta_add(struct hostapd_data *hapd, static int hostapd_sta_add(struct hostapd_data *hapd,
const u8 *addr, u16 aid, u16 capability, const u8 *addr, u16 aid, u16 capability,
const u8 *supp_rates, size_t supp_rates_len, const u8 *supp_rates, size_t supp_rates_len,
@ -447,14 +409,6 @@ static int hostapd_sta_add(struct hostapd_data *hapd,
} }
static int hostapd_sta_remove(struct hostapd_data *hapd, const u8 *addr)
{
if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
return 0;
return hapd->driver->sta_remove(hapd->drv_priv, addr);
}
void hostapd_set_driver_ops(struct hostapd_driver_ops *ops) void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
{ {
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie; ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
@ -472,12 +426,7 @@ void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
ops->vlan_if_add = hostapd_vlan_if_add; ops->vlan_if_add = hostapd_vlan_if_add;
ops->vlan_if_remove = hostapd_vlan_if_remove; ops->vlan_if_remove = hostapd_vlan_if_remove;
ops->set_wds_sta = hostapd_set_wds_sta; ops->set_wds_sta = hostapd_set_wds_sta;
ops->set_sta_vlan = hostapd_set_sta_vlan;
ops->get_inact_sec = hostapd_get_inact_sec;
ops->sta_deauth = hostapd_sta_deauth;
ops->sta_disassoc = hostapd_sta_disassoc;
ops->sta_add = hostapd_sta_add; ops->sta_add = hostapd_sta_add;
ops->sta_remove = hostapd_sta_remove;
} }

View file

@ -86,4 +86,48 @@ static inline int hostapd_drv_set_countermeasures(struct hostapd_data *hapd,
return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled); return hapd->driver->hapd_set_countermeasures(hapd->drv_priv, enabled);
} }
static inline int hostapd_drv_set_sta_vlan(const char *ifname,
struct hostapd_data *hapd,
const u8 *addr, int vlan_id)
{
if (hapd->driver == NULL || hapd->driver->set_sta_vlan == NULL)
return 0;
return hapd->driver->set_sta_vlan(hapd->drv_priv, addr, ifname,
vlan_id);
}
static inline int hostapd_drv_get_inact_sec(struct hostapd_data *hapd,
const u8 *addr)
{
if (hapd->driver == NULL || hapd->driver->get_inact_sec == NULL)
return 0;
return hapd->driver->get_inact_sec(hapd->drv_priv, addr);
}
static inline int hostapd_drv_sta_deauth(struct hostapd_data *hapd,
const u8 *addr, int reason)
{
if (hapd->driver == NULL || hapd->driver->sta_deauth == NULL)
return 0;
return hapd->driver->sta_deauth(hapd->drv_priv, hapd->own_addr, addr,
reason);
}
static inline int hostapd_drv_sta_disassoc(struct hostapd_data *hapd,
const u8 *addr, int reason)
{
if (hapd->driver == NULL || hapd->driver->sta_disassoc == NULL)
return 0;
return hapd->driver->sta_disassoc(hapd->drv_priv, hapd->own_addr, addr,
reason);
}
static inline int hostapd_drv_sta_remove(struct hostapd_data *hapd,
const u8 *addr)
{
if (hapd->driver == NULL || hapd->driver->sta_remove == NULL)
return 0;
return hapd->driver->sta_remove(hapd->drv_priv, addr);
}
#endif /* AP_DRV_OPS */ #endif /* AP_DRV_OPS */

View file

@ -33,6 +33,7 @@
#include "wpa_auth.h" #include "wpa_auth.h"
#include "wmm.h" #include "wmm.h"
#include "wps_hostapd.h" #include "wps_hostapd.h"
#include "ap_drv_ops.h"
#include "ap_config.h" #include "ap_config.h"
@ -150,7 +151,7 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
#endif /* CONFIG_IEEE80211W */ #endif /* CONFIG_IEEE80211W */
else else
resp = WLAN_REASON_INVALID_IE; resp = WLAN_REASON_INVALID_IE;
hapd->drv.sta_disassoc(hapd, sta->addr, resp); hostapd_drv_sta_disassoc(hapd, sta->addr, resp);
ap_free_sta(hapd, sta); ap_free_sta(hapd, sta);
return -1; return -1;
} }
@ -160,8 +161,8 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
wps = ieee802_11_vendor_ie_concat(ie, ielen, wps = ieee802_11_vendor_ie_concat(ie, ielen,
WPS_IE_VENDOR_TYPE); WPS_IE_VENDOR_TYPE);
if (wps && wps_validate_assoc_req(wps) < 0) { if (wps && wps_validate_assoc_req(wps) < 0) {
hapd->drv.sta_disassoc(hapd, sta->addr, hostapd_drv_sta_disassoc(hapd, sta->addr,
WLAN_REASON_INVALID_IE); WLAN_REASON_INVALID_IE);
ap_free_sta(hapd, sta); ap_free_sta(hapd, sta);
wpabuf_free(wps); wpabuf_free(wps);
return -1; return -1;

View file

@ -341,8 +341,8 @@ static int hostapd_flush_old_stations(struct hostapd_data *hapd)
if (hapd->driver && os_strcmp(hapd->driver->name, "hostap") != 0) { if (hapd->driver && os_strcmp(hapd->driver->name, "hostap") != 0) {
u8 addr[ETH_ALEN]; u8 addr[ETH_ALEN];
os_memset(addr, 0xff, ETH_ALEN); os_memset(addr, 0xff, ETH_ALEN);
hapd->drv.sta_deauth(hapd, addr, hostapd_drv_sta_deauth(hapd, addr,
WLAN_REASON_PREV_AUTH_NOT_VALID); WLAN_REASON_PREV_AUTH_NOT_VALID);
} }
return ret; return ret;
@ -890,8 +890,8 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
int reassoc) int reassoc)
{ {
if (hapd->tkip_countermeasures) { if (hapd->tkip_countermeasures) {
hapd->drv.sta_deauth(hapd, sta->addr, hostapd_drv_sta_deauth(hapd, sta->addr,
WLAN_REASON_MICHAEL_MIC_FAILURE); WLAN_REASON_MICHAEL_MIC_FAILURE);
return; return;
} }

View file

@ -80,19 +80,11 @@ struct hostapd_driver_ops {
int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname); int (*vlan_if_remove)(struct hostapd_data *hapd, const char *ifname);
int (*set_wds_sta)(struct hostapd_data *hapd, const u8 *addr, int aid, int (*set_wds_sta)(struct hostapd_data *hapd, const u8 *addr, int aid,
int val); int val);
int (*set_sta_vlan)(const char *ifname, struct hostapd_data *hapd,
const u8 *addr, int vlan_id);
int (*get_inact_sec)(struct hostapd_data *hapd, const u8 *addr);
int (*sta_deauth)(struct hostapd_data *hapd, const u8 *addr,
int reason);
int (*sta_disassoc)(struct hostapd_data *hapd, const u8 *addr,
int reason);
int (*sta_add)(struct hostapd_data *hapd, int (*sta_add)(struct hostapd_data *hapd,
const u8 *addr, u16 aid, u16 capability, const u8 *addr, u16 aid, u16 capability,
const u8 *supp_rates, size_t supp_rates_len, const u8 *supp_rates, size_t supp_rates_len,
u16 listen_interval, u16 listen_interval,
const struct ieee80211_ht_capabilities *ht_capab); const struct ieee80211_ht_capabilities *ht_capab);
int (*sta_remove)(struct hostapd_data *hapd, const u8 *addr);
}; };
/** /**

View file

@ -1125,7 +1125,7 @@ static void handle_disassoc(struct hostapd_data *hapd,
* authenticated. */ * authenticated. */
accounting_sta_stop(hapd, sta); accounting_sta_stop(hapd, sta);
ieee802_1x_free_station(sta); ieee802_1x_free_station(sta);
hapd->drv.sta_remove(hapd, sta->addr); hostapd_drv_sta_remove(hapd, sta->addr);
if (sta->timeout_next == STA_NULLFUNC || if (sta->timeout_next == STA_NULLFUNC ||
sta->timeout_next == STA_DISASSOC) { sta->timeout_next == STA_DISASSOC) {
@ -1644,7 +1644,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
* cleared and configuration gets updated in case of reassociation back * cleared and configuration gets updated in case of reassociation back
* to the same AP. * to the same AP.
*/ */
hapd->drv.sta_remove(hapd, sta->addr); hostapd_drv_sta_remove(hapd, sta->addr);
#ifdef CONFIG_IEEE80211N #ifdef CONFIG_IEEE80211N
if (sta->flags & WLAN_STA_HT) if (sta->flags & WLAN_STA_HT)
@ -1805,11 +1805,11 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
wpa_printf(MSG_DEBUG, "Data/PS-poll frame from not associated STA " wpa_printf(MSG_DEBUG, "Data/PS-poll frame from not associated STA "
MACSTR, MAC2STR(src)); MACSTR, MAC2STR(src));
if (sta && (sta->flags & WLAN_STA_AUTH)) if (sta && (sta->flags & WLAN_STA_AUTH))
hapd->drv.sta_disassoc( hostapd_drv_sta_disassoc(
hapd, src, hapd, src,
WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
else else
hapd->drv.sta_deauth( hostapd_drv_sta_deauth(
hapd, src, hapd, src,
WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
} }

View file

@ -128,7 +128,7 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0); hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0);
if (!(sta->flags & WLAN_STA_PREAUTH)) if (!(sta->flags & WLAN_STA_PREAUTH))
hapd->drv.sta_remove(hapd, sta->addr); hostapd_drv_sta_remove(hapd, sta->addr);
ap_sta_hash_del(hapd, sta); ap_sta_hash_del(hapd, sta);
ap_sta_list_del(hapd, sta); ap_sta_list_del(hapd, sta);
@ -272,7 +272,7 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
int inactive_sec; int inactive_sec;
wpa_printf(MSG_DEBUG, "Checking STA " MACSTR " inactivity:", wpa_printf(MSG_DEBUG, "Checking STA " MACSTR " inactivity:",
MAC2STR(sta->addr)); MAC2STR(sta->addr));
inactive_sec = hapd->drv.get_inact_sec(hapd, sta->addr); inactive_sec = hostapd_drv_get_inact_sec(hapd, sta->addr);
if (inactive_sec == -1) { if (inactive_sec == -1) {
wpa_printf(MSG_DEBUG, "Could not get station info " wpa_printf(MSG_DEBUG, "Could not get station info "
"from kernel driver for " MACSTR ".", "from kernel driver for " MACSTR ".",
@ -347,10 +347,11 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
MAC2STR(sta->addr)); MAC2STR(sta->addr));
if (deauth) { if (deauth) {
hapd->drv.sta_deauth(hapd, sta->addr, hostapd_drv_sta_deauth(
WLAN_REASON_PREV_AUTH_NOT_VALID); hapd, sta->addr,
WLAN_REASON_PREV_AUTH_NOT_VALID);
} else { } else {
hapd->drv.sta_disassoc( hostapd_drv_sta_disassoc(
hapd, sta->addr, hapd, sta->addr,
WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY); WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
} }
@ -414,7 +415,7 @@ static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx)
RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT; RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT;
os_memcpy(addr, sta->addr, ETH_ALEN); os_memcpy(addr, sta->addr, ETH_ALEN);
ap_free_sta(hapd, sta); ap_free_sta(hapd, sta);
hapd->drv.sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID); hostapd_drv_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
} }
@ -480,7 +481,7 @@ static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver", wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver",
MAC2STR(sta->addr)); MAC2STR(sta->addr));
if (hapd->drv.sta_remove(hapd, sta->addr) && if (hostapd_drv_sta_remove(hapd, sta->addr) &&
sta->flags & WLAN_STA_ASSOC) { sta->flags & WLAN_STA_ASSOC) {
wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR
" from kernel driver.", MAC2STR(sta->addr)); " from kernel driver.", MAC2STR(sta->addr));
@ -653,7 +654,7 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0) if (wpa_auth_sta_set_vlan(sta->wpa_sm, sta->vlan_id) < 0)
wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA"); wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA");
ret = hapd->drv.set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id); ret = hostapd_drv_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
if (ret < 0) { if (ret < 0) {
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
HOSTAPD_LEVEL_DEBUG, "could not bind the STA " HOSTAPD_LEVEL_DEBUG, "could not bind the STA "
@ -757,7 +758,7 @@ void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
sta = ap_get_sta(hapd, addr); sta = ap_get_sta(hapd, addr);
if (addr) if (addr)
hapd->drv.sta_deauth(hapd, addr, reason); hostapd_drv_sta_deauth(hapd, addr, reason);
if (sta == NULL) if (sta == NULL)
return; return;

View file

@ -51,11 +51,11 @@ static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop, eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop,
hapd, NULL); hapd, NULL);
for (sta = hapd->sta_list; sta != NULL; sta = sta->next) { for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
hapd->drv.sta_deauth(hapd, sta->addr, hostapd_drv_sta_deauth(hapd, sta->addr,
WLAN_REASON_MICHAEL_MIC_FAILURE); WLAN_REASON_MICHAEL_MIC_FAILURE);
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC | sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
WLAN_STA_AUTHORIZED); WLAN_STA_AUTHORIZED);
hapd->drv.sta_remove(hapd, sta->addr); hostapd_drv_sta_remove(hapd, sta->addr);
} }
} }