]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd_driver_ops reduction
authorJouni Malinen <jouni.malinen@atheros.com>
Wed, 24 Nov 2010 13:36:02 +0000 (15:36 +0200)
committerJouni Malinen <j@w1.fi>
Wed, 24 Nov 2010 13:36:02 +0000 (15:36 +0200)
set_sta_vlan, get_inact_sec, sta_deauth, sta_disassoc, and sta_remove
to use inline functions instead of extra abstraction.

hostapd/ctrl_iface.c
src/ap/ap_drv_ops.c
src/ap/ap_drv_ops.h
src/ap/drv_callbacks.c
src/ap/hostapd.c
src/ap/hostapd.h
src/ap/ieee802_11.c
src/ap/sta_info.c
src/ap/tkip_countermeasures.c

index 152134c609099a77f3bc403004164a2fe953fe17..e78fba42e0d0177c05615651e6efa0c81214f90e 100644 (file)
@@ -35,6 +35,7 @@
 #include "ap/accounting.h"
 #include "ap/wps_hostapd.h"
 #include "ap/ctrl_iface_ap.h"
+#include "ap/ap_drv_ops.h"
 #include "wps/wps_defs.h"
 #include "wps/wps.h"
 #include "ctrl_iface.h"
@@ -255,7 +256,7 @@ static int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
        }
 #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);
        if (sta)
                ap_sta_deauthenticate(hapd, sta,
@@ -311,7 +312,7 @@ static int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
        }
 #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);
        if (sta)
                ap_sta_disassociate(hapd, sta,
index d62829ffbeaa3adf171ccd1c0d7d89e3d3812b0b..c651ff984cc0a36acfa9b0998e42b9c49c9924c0 100644 (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,
                           const u8 *addr, u16 aid, u16 capability,
                           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)
 {
        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_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_add = hostapd_sta_add;
-       ops->sta_remove = hostapd_sta_remove;
 }
 
 
index e2059e8cf748fcb6d8c8c4f782a712fc0512a39d..254a9d5383eb3c5783ecdb7cafe3c036995b4a35 100644 (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);
 }
 
+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 */
index 04ff6a155cae508b18f2be0e2f9584363f6e954a..5469d05c0c7a0afb68160f94626dc073de4d3242 100644 (file)
@@ -33,6 +33,7 @@
 #include "wpa_auth.h"
 #include "wmm.h"
 #include "wps_hostapd.h"
+#include "ap_drv_ops.h"
 #include "ap_config.h"
 
 
@@ -150,7 +151,7 @@ int hostapd_notif_assoc(struct hostapd_data *hapd, const u8 *addr,
 #endif /* CONFIG_IEEE80211W */
                        else
                                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);
                        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_IE_VENDOR_TYPE);
                if (wps && wps_validate_assoc_req(wps) < 0) {
-                       hapd->drv.sta_disassoc(hapd, sta->addr,
-                                              WLAN_REASON_INVALID_IE);
+                       hostapd_drv_sta_disassoc(hapd, sta->addr,
+                                                WLAN_REASON_INVALID_IE);
                        ap_free_sta(hapd, sta);
                        wpabuf_free(wps);
                        return -1;
index f4517f84ee4695098536f3ad9a89acbcd0723481..b19a564095559610652ffb41a4c97cca6c7ceef1 100644 (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) {
                u8 addr[ETH_ALEN];
                os_memset(addr, 0xff, ETH_ALEN);
-               hapd->drv.sta_deauth(hapd, addr,
-                                    WLAN_REASON_PREV_AUTH_NOT_VALID);
+               hostapd_drv_sta_deauth(hapd, addr,
+                                      WLAN_REASON_PREV_AUTH_NOT_VALID);
        }
 
        return ret;
@@ -890,8 +890,8 @@ void hostapd_new_assoc_sta(struct hostapd_data *hapd, struct sta_info *sta,
                           int reassoc)
 {
        if (hapd->tkip_countermeasures) {
-               hapd->drv.sta_deauth(hapd, sta->addr,
-                                    WLAN_REASON_MICHAEL_MIC_FAILURE);
+               hostapd_drv_sta_deauth(hapd, sta->addr,
+                                      WLAN_REASON_MICHAEL_MIC_FAILURE);
                return;
        }
 
index c0d3491cbb4c757d0339acd9ff067b6299bd30ff..bba9a8f228db16230c0d25b0001aa92137842a3c 100644 (file)
@@ -80,19 +80,11 @@ struct hostapd_driver_ops {
        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_add)(struct hostapd_data *hapd,
                       const u8 *addr, u16 aid, u16 capability,
                       const u8 *supp_rates, size_t supp_rates_len,
                       u16 listen_interval,
                       const struct ieee80211_ht_capabilities *ht_capab);
-       int (*sta_remove)(struct hostapd_data *hapd, const u8 *addr);
 };
 
 /**
index c7604160ba101b2d7661f736302ef17ee7367d6f..b2e0a4101ff516bf230bacc74a20d6a283f6bdab 100644 (file)
@@ -1125,7 +1125,7 @@ static void handle_disassoc(struct hostapd_data *hapd,
         * authenticated. */
        accounting_sta_stop(hapd, 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 ||
            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
         * to the same AP.
         */
-       hapd->drv.sta_remove(hapd, sta->addr);
+       hostapd_drv_sta_remove(hapd, sta->addr);
 
 #ifdef CONFIG_IEEE80211N
        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 "
                   MACSTR, MAC2STR(src));
        if (sta && (sta->flags & WLAN_STA_AUTH))
-               hapd->drv.sta_disassoc(
+               hostapd_drv_sta_disassoc(
                        hapd, src,
                        WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
        else
-               hapd->drv.sta_deauth(
+               hostapd_drv_sta_deauth(
                        hapd, src,
                        WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
 }
index 928b5489d6fa658c1929a42e006c177de051f241..330bd663a97de0dd98403f94d83b9f78f9f08f20 100644 (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);
 
        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_list_del(hapd, sta);
@@ -272,7 +272,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 = hapd->drv.get_inact_sec(hapd, sta->addr);
+               inactive_sec = hostapd_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 ".",
@@ -347,10 +347,11 @@ void ap_handle_timer(void *eloop_ctx, void *timeout_ctx)
                           MAC2STR(sta->addr));
 
                if (deauth) {
-                       hapd->drv.sta_deauth(hapd, sta->addr,
-                                            WLAN_REASON_PREV_AUTH_NOT_VALID);
+                       hostapd_drv_sta_deauth(
+                               hapd, sta->addr,
+                               WLAN_REASON_PREV_AUTH_NOT_VALID);
                } else {
-                       hapd->drv.sta_disassoc(
+                       hostapd_drv_sta_disassoc(
                                hapd, sta->addr,
                                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;
        os_memcpy(addr, sta->addr, ETH_ALEN);
        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",
                   MAC2STR(sta->addr));
-       if (hapd->drv.sta_remove(hapd, sta->addr) &&
+       if (hostapd_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));
@@ -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)
                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) {
                hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
                               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);
 
        if (addr)
-               hapd->drv.sta_deauth(hapd, addr, reason);
+               hostapd_drv_sta_deauth(hapd, addr, reason);
 
        if (sta == NULL)
                return;
index 9e4a5d96b86d85b809fdd4297a740f52e5441b8c..7df86e88caab7e04880496d1b743397b686e3bbb 100644 (file)
@@ -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) {
-               hapd->drv.sta_deauth(hapd, sta->addr,
-                                    WLAN_REASON_MICHAEL_MIC_FAILURE);
+               hostapd_drv_sta_deauth(hapd, sta->addr,
+                                      WLAN_REASON_MICHAEL_MIC_FAILURE);
                sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC |
                                WLAN_STA_AUTHORIZED);
-               hapd->drv.sta_remove(hapd, sta->addr);
+               hostapd_drv_sta_remove(hapd, sta->addr);
        }
 }