Remove direct driver calls from sta_info.c
This commit is contained in:
parent
36592d31c1
commit
bdee6fceb9
8 changed files with 99 additions and 79 deletions
|
@ -250,6 +250,61 @@ static int hostapd_vlan_if_remove(struct hostapd_data *hapd,
|
|||
}
|
||||
|
||||
|
||||
static int hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr,
|
||||
int aid, int val)
|
||||
{
|
||||
if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
|
||||
return 0;
|
||||
return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val);
|
||||
}
|
||||
|
||||
|
||||
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_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)
|
||||
{
|
||||
ops->set_ap_wps_ie = hostapd_set_ap_wps_ie;
|
||||
|
@ -267,4 +322,10 @@ void hostapd_set_driver_ops(struct hostapd_driver_ops *ops)
|
|||
ops->set_beacon = hostapd_set_beacon;
|
||||
ops->vlan_if_add = hostapd_vlan_if_add;
|
||||
ops->vlan_if_remove = hostapd_vlan_if_remove;
|
||||
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_remove = hostapd_sta_remove;
|
||||
}
|
||||
|
|
|
@ -107,32 +107,6 @@ hostapd_set_generic_elem(struct hostapd_data *hapd, const u8 *elem,
|
|||
hapd->drv_priv, elem, elem_len);
|
||||
}
|
||||
|
||||
static inline 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 inline 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 inline 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);
|
||||
}
|
||||
|
||||
static inline int
|
||||
hostapd_get_ssid(struct hostapd_data *hapd, u8 *buf, size_t len)
|
||||
{
|
||||
|
@ -184,14 +158,6 @@ hostapd_sta_add(const char *ifname, struct hostapd_data *hapd, const u8 *addr,
|
|||
return hapd->driver->sta_add(ifname, hapd->drv_priv, ¶ms);
|
||||
}
|
||||
|
||||
static inline 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 inline int
|
||||
hostapd_set_freq(struct hostapd_data *hapd, int mode, int freq, int channel,
|
||||
int ht_enabled, int sec_channel_offset)
|
||||
|
@ -328,24 +294,6 @@ hostapd_get_hw_feature_data(struct hostapd_data *hapd, u16 *num_modes,
|
|||
flags);
|
||||
}
|
||||
|
||||
static inline 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 inline int
|
||||
hostapd_set_wds_sta(struct hostapd_data *hapd, const u8 *addr, int aid,
|
||||
int val)
|
||||
{
|
||||
if (hapd->driver == NULL || hapd->driver->set_wds_sta == NULL)
|
||||
return 0;
|
||||
return hapd->driver->set_wds_sta(hapd->drv_priv, addr, aid, val);
|
||||
}
|
||||
|
||||
static inline int
|
||||
hostapd_driver_commit(struct hostapd_data *hapd)
|
||||
{
|
||||
|
|
|
@ -117,7 +117,7 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
|
|||
#endif /* CONFIG_IEEE80211W */
|
||||
else
|
||||
resp = WLAN_REASON_INVALID_IE;
|
||||
hostapd_sta_disassoc(hapd, sta->addr, resp);
|
||||
hapd->drv.sta_disassoc(hapd, sta->addr, resp);
|
||||
ap_free_sta(hapd, sta);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -441,8 +441,8 @@ static int hostapd_flush_old_stations(struct hostapd_data *hapd)
|
|||
if (hapd->driver && os_strcmp(hapd->driver->name, "hostap") != 0) {
|
||||
u8 addr[ETH_ALEN];
|
||||
os_memset(addr, 0xff, ETH_ALEN);
|
||||
hostapd_sta_deauth(hapd, addr,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
hapd->drv.sta_deauth(hapd, addr,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -1549,8 +1549,8 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
int reassoc)
|
||||
{
|
||||
if (hapd->tkip_countermeasures) {
|
||||
hostapd_sta_deauth(hapd, sta->addr,
|
||||
WLAN_REASON_MICHAEL_MIC_FAILURE);
|
||||
hapd->drv.sta_deauth(hapd, sta->addr,
|
||||
WLAN_REASON_MICHAEL_MIC_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,16 @@ struct hostapd_driver_ops {
|
|||
int beacon_int);
|
||||
int (*vlan_if_add)(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 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_remove)(struct hostapd_data *hapd, const u8 *addr);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -1089,7 +1089,7 @@ static void handle_disassoc(struct hostapd_data *hapd,
|
|||
* authenticated. */
|
||||
accounting_sta_stop(hapd, sta);
|
||||
ieee802_1x_free_station(sta);
|
||||
hostapd_sta_remove(hapd, sta->addr);
|
||||
hapd->drv.sta_remove(hapd, sta->addr);
|
||||
|
||||
if (sta->timeout_next == STA_NULLFUNC ||
|
||||
sta->timeout_next == STA_DISASSOC) {
|
||||
|
@ -1543,7 +1543,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
|
|||
* cleared and configuration gets updated in case of reassociation back
|
||||
* to the same AP.
|
||||
*/
|
||||
hostapd_sta_remove(hapd, sta->addr);
|
||||
hapd->drv.sta_remove(hapd, sta->addr);
|
||||
|
||||
#ifdef CONFIG_IEEE80211N
|
||||
if (sta->flags & WLAN_STA_HT)
|
||||
|
@ -1692,7 +1692,7 @@ void ieee802_11_rx_from_unknown(struct hostapd_data *hapd, const u8 *src,
|
|||
"STA " MACSTR " (aid %u)",
|
||||
MAC2STR(sta->addr), sta->aid);
|
||||
sta->flags |= WLAN_STA_WDS;
|
||||
hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 1);
|
||||
hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1700,11 +1700,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 "
|
||||
MACSTR, MAC2STR(src));
|
||||
if (sta && (sta->flags & WLAN_STA_AUTH))
|
||||
hostapd_sta_disassoc(
|
||||
hapd->drv.sta_disassoc(
|
||||
hapd, src,
|
||||
WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
|
||||
else
|
||||
hostapd_sta_deauth(
|
||||
hapd->drv.sta_deauth(
|
||||
hapd, src,
|
||||
WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* hostapd / Station table
|
||||
* Copyright (c) 2002-2008, Jouni Malinen <j@w1.fi>
|
||||
* Copyright (c) 2002-2009, Jouni Malinen <j@w1.fi>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
|
@ -15,17 +15,18 @@
|
|||
#include "includes.h"
|
||||
|
||||
#include "common.h"
|
||||
#include "radius/radius.h"
|
||||
#include "radius/radius_client.h"
|
||||
#include "drivers/driver.h"
|
||||
#include "hostapd.h"
|
||||
#include "sta_info.h"
|
||||
#include "eloop.h"
|
||||
#include "accounting.h"
|
||||
#include "ieee802_1x.h"
|
||||
#include "ieee802_11.h"
|
||||
#include "radius/radius.h"
|
||||
#include "wpa.h"
|
||||
#include "preauth.h"
|
||||
#include "radius/radius_client.h"
|
||||
#include "driver_i.h"
|
||||
#include "config.h"
|
||||
#include "beacon.h"
|
||||
#include "hw_features.h"
|
||||
#include "mlme.h"
|
||||
|
@ -120,10 +121,10 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
|
|||
|
||||
accounting_sta_stop(hapd, sta);
|
||||
|
||||
hostapd_set_wds_sta(hapd, sta->addr, sta->aid, 0);
|
||||
hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0);
|
||||
if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC) &&
|
||||
!(sta->flags & WLAN_STA_PREAUTH))
|
||||
hostapd_sta_remove(hapd, sta->addr);
|
||||
hapd->drv.sta_remove(hapd, sta->addr);
|
||||
|
||||
ap_sta_hash_del(hapd, sta);
|
||||
ap_sta_list_del(hapd, sta);
|
||||
|
@ -253,7 +254,7 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
|
|||
int inactive_sec;
|
||||
wpa_printf(MSG_DEBUG, "Checking STA " MACSTR " inactivity:",
|
||||
MAC2STR(sta->addr));
|
||||
inactive_sec = hostapd_get_inact_sec(hapd, sta->addr);
|
||||
inactive_sec = hapd->drv.get_inact_sec(hapd, sta->addr);
|
||||
if (inactive_sec == -1) {
|
||||
wpa_printf(MSG_DEBUG, "Could not get station info "
|
||||
"from kernel driver for " MACSTR ".",
|
||||
|
@ -328,10 +329,10 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
|
|||
MAC2STR(sta->addr));
|
||||
|
||||
if (deauth) {
|
||||
hostapd_sta_deauth(hapd, sta->addr,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
hapd->drv.sta_deauth(hapd, sta->addr,
|
||||
WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
} else {
|
||||
hostapd_sta_disassoc(
|
||||
hapd->drv.sta_disassoc(
|
||||
hapd, sta->addr,
|
||||
WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY);
|
||||
}
|
||||
|
@ -395,7 +396,7 @@ static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx)
|
|||
RADIUS_ACCT_TERMINATE_CAUSE_SESSION_TIMEOUT;
|
||||
os_memcpy(addr, sta->addr, ETH_ALEN);
|
||||
ap_free_sta(hapd, sta);
|
||||
hostapd_sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
hapd->drv.sta_deauth(hapd, addr, WLAN_REASON_PREV_AUTH_NOT_VALID);
|
||||
}
|
||||
|
||||
|
||||
|
@ -460,7 +461,7 @@ static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
|
|||
|
||||
wpa_printf(MSG_DEBUG, "Removing STA " MACSTR " from kernel driver",
|
||||
MAC2STR(sta->addr));
|
||||
if (hostapd_sta_remove(hapd, sta->addr) &&
|
||||
if (hapd->drv.sta_remove(hapd, sta->addr) &&
|
||||
sta->flags & WLAN_STA_ASSOC) {
|
||||
wpa_printf(MSG_DEBUG, "Could not remove station " MACSTR
|
||||
" from kernel driver.", MAC2STR(sta->addr));
|
||||
|
@ -633,7 +634,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)
|
||||
wpa_printf(MSG_INFO, "Failed to update VLAN-ID for WPA");
|
||||
|
||||
return hostapd_set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
|
||||
return hapd->drv.set_sta_vlan(iface, hapd, sta->addr, sta->vlan_id);
|
||||
#else /* CONFIG_NO_VLAN */
|
||||
return 0;
|
||||
#endif /* CONFIG_NO_VLAN */
|
||||
|
@ -731,7 +732,7 @@ void ap_sta_disconnect(struct hostapd_data *hapd, struct sta_info *sta,
|
|||
sta = ap_get_sta(hapd, addr);
|
||||
|
||||
if (addr)
|
||||
hostapd_sta_deauth(hapd, addr, reason);
|
||||
hapd->drv.sta_deauth(hapd, addr, reason);
|
||||
|
||||
if (sta == NULL)
|
||||
return;
|
||||
|
|
|
@ -51,11 +51,11 @@ static void ieee80211_tkip_countermeasures_start(struct hostapd_data *hapd)
|
|||
eloop_register_timeout(60, 0, ieee80211_tkip_countermeasures_stop,
|
||||
hapd, NULL);
|
||||
for (sta = hapd->sta_list; sta != NULL; sta = sta->next) {
|
||||
hostapd_sta_deauth(hapd, sta->addr,
|
||||
WLAN_REASON_MICHAEL_MIC_FAILURE);
|
||||
hapd->drv.sta_deauth(hapd, sta->addr,
|
||||
WLAN_REASON_MICHAEL_MIC_FAILURE);
|
||||
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
|
||||
WLAN_STA_AUTHORIZED);
|
||||
hostapd_sta_remove(hapd, sta->addr);
|
||||
hapd->drv.sta_remove(hapd, sta->addr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue