Remove direct driver calls from sta_info.c
[libeap.git] / hostapd / ap_list.c
index e554609..ec6c2c0 100644 (file)
@@ -3,7 +3,6 @@
  * Copyright (c) 2002-2003, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2003-2004, Instant802 Networks, Inc.
  * Copyright (c) 2006, Devicescape Software, Inc.
- * Copyright (c) 2007-2008, Intel Corporation
  *
  * 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
 
 #include "includes.h"
 
+#include "common.h"
 #include "hostapd.h"
+#include "config.h"
 #include "ieee802_11.h"
 #include "eloop.h"
+#include "sta_info.h"
 #include "ap_list.h"
 #include "hw_features.h"
 #include "beacon.h"
-#include "driver.h"
-
-
-struct ieee80211_frame_info {
-       u32 version;
-       u32 length;
-       u64 mactime;
-       u64 hosttime;
-       u32 phytype;
-       u32 channel;
-       u32 datarate;
-       u32 antenna;
-       u32 priority;
-       u32 ssi_type;
-       u32 ssi_signal;
-       u32 ssi_noise;
-       u32 preamble;
-       u32 encoding;
-
-       /* Note: this structure is otherwise identical to capture format used
-        * in linux-wlan-ng, but this additional field is used to provide meta
-        * data about the frame to hostapd. This was the easiest method for
-        * providing this information, but this might change in the future. */
-       u32 msg_type;
-} __attribute__ ((packed));
-
-
-enum ieee80211_phytype {
-       ieee80211_phytype_fhss_dot11_97  = 1,
-       ieee80211_phytype_dsss_dot11_97  = 2,
-       ieee80211_phytype_irbaseband     = 3,
-       ieee80211_phytype_dsss_dot11_b   = 4,
-       ieee80211_phytype_pbcc_dot11_b   = 5,
-       ieee80211_phytype_ofdm_dot11_g   = 6,
-       ieee80211_phytype_pbcc_dot11_g   = 7,
-       ieee80211_phytype_ofdm_dot11_a   = 8,
-       ieee80211_phytype_dsss_dot11_turbog = 255,
-       ieee80211_phytype_dsss_dot11_turbo = 256,
-};
+#include "drivers/driver.h"
 
 
 /* AP list is a double linked list with head->prev pointing to the end of the
@@ -70,29 +34,11 @@ enum ieee80211_phytype {
  * in this link will thus be the least recently used entry. */
 
 
-static void ap_list_new_ap(struct hostapd_iface *iface, struct ap_info *ap)
-{
-       wpa_printf(MSG_DEBUG, "New AP detected: " MACSTR, MAC2STR(ap->addr));
-
-       /* TODO: could send a notification message to an external program that
-        * would then determine whether a rogue AP has been detected */
-}
-
-
-static void ap_list_expired_ap(struct hostapd_iface *iface, struct ap_info *ap)
-{
-       wpa_printf(MSG_DEBUG, "AP info expired: " MACSTR, MAC2STR(ap->addr));
-
-       /* TODO: could send a notification message to an external program */
-}
-
-
 static int ap_list_beacon_olbc(struct hostapd_iface *iface, struct ap_info *ap)
 {
        int i;
 
        if (iface->current_mode->mode != HOSTAPD_MODE_IEEE80211G ||
-           ap->phytype != ieee80211_phytype_pbcc_dot11_g ||
            iface->conf->channel != ap->channel)
                return 0;
 
@@ -109,16 +55,7 @@ static int ap_list_beacon_olbc(struct hostapd_iface *iface, struct ap_info *ap)
 }
 
 
-#ifdef CONFIG_IEEE80211N
-static int ap_list_beacon_olbc_ht(struct hostapd_iface *iface,
-                                 struct ap_info *ap)
-{
-       return !ap->ht_support;
-}
-#endif /* CONFIG_IEEE80211N */
-
-
-struct ap_info * ap_get_ap(struct hostapd_iface *iface, u8 *ap)
+struct ap_info * ap_get_ap(struct hostapd_iface *iface, const u8 *ap)
 {
        struct ap_info *s;
 
@@ -258,7 +195,7 @@ int ap_ap_for_each(struct hostapd_iface *iface,
 }
 
 
-static struct ap_info * ap_ap_add(struct hostapd_iface *iface, u8 *addr)
+static struct ap_info * ap_ap_add(struct hostapd_iface *iface, const u8 *addr)
 {
        struct ap_info *ap;
 
@@ -276,8 +213,6 @@ static struct ap_info * ap_ap_add(struct hostapd_iface *iface, u8 *addr)
        if (iface->num_ap > iface->conf->ap_table_max_size && ap != ap->prev) {
                wpa_printf(MSG_DEBUG, "Removing the least recently used AP "
                           MACSTR " from AP table", MAC2STR(ap->prev->addr));
-               if (iface->conf->passive_scan_interval > 0)
-                       ap_list_expired_ap(iface, ap->prev);
                ap_free_ap(iface, ap->prev);
        }
 
@@ -286,7 +221,7 @@ static struct ap_info * ap_ap_add(struct hostapd_iface *iface, u8 *addr)
 
 
 void ap_list_process_beacon(struct hostapd_iface *iface,
-                           struct ieee80211_mgmt *mgmt,
+                           const struct ieee80211_mgmt *mgmt,
                            struct ieee802_11_elems *elems,
                            struct hostapd_frame_info *fi)
 {
@@ -358,15 +293,11 @@ void ap_list_process_beacon(struct hostapd_iface *iface,
        ap->num_beacons++;
        time(&ap->last_beacon);
        if (fi) {
-               ap->phytype = fi->phytype;
                ap->ssi_signal = fi->ssi_signal;
                ap->datarate = fi->datarate;
        }
 
-       if (new_ap) {
-               if (iface->conf->passive_scan_interval > 0)
-                       ap_list_new_ap(iface, ap);
-       } else if (ap != iface->ap_list) {
+       if (!new_ap && ap != iface->ap_list) {
                /* move AP entry into the beginning of the list so that the
                 * oldest entry is always in the end of the list */
                ap_ap_list_del(iface, ap);
@@ -382,7 +313,7 @@ void ap_list_process_beacon(struct hostapd_iface *iface,
        }
 
 #ifdef CONFIG_IEEE80211N
-       if (!iface->olbc_ht && ap_list_beacon_olbc_ht(iface, ap)) {
+       if (!iface->olbc_ht && !ap->ht_support) {
                iface->olbc_ht = 1;
                hostapd_ht_operation_update(iface);
                wpa_printf(MSG_DEBUG, "OLBC HT AP detected: " MACSTR
@@ -410,18 +341,12 @@ static void ap_list_timer(void *eloop_ctx, void *timeout_ctx)
 
        time(&now);
 
-       /* FIX: it looks like jkm-Purina ended up in busy loop in this
-        * function. Apparently, something can still cause a loop in the AP
-        * list.. */
-
        while (iface->ap_list) {
                ap = iface->ap_list->prev;
                if (ap->last_beacon + iface->conf->ap_table_expiration_time >=
                    now)
                        break;
 
-               if (iface->conf->passive_scan_interval > 0)
-                       ap_list_expired_ap(iface, ap);
                ap_free_ap(iface, ap);
        }
 
@@ -433,10 +358,8 @@ static void ap_list_timer(void *eloop_ctx, void *timeout_ctx)
                while (ap && (olbc == 0 || olbc_ht == 0)) {
                        if (ap_list_beacon_olbc(iface, ap))
                                olbc = 1;
-#ifdef CONFIG_IEEE80211N
-                       if (ap_list_beacon_olbc_ht(iface, ap))
+                       if (!ap->ht_support)
                                olbc_ht = 1;
-#endif /* CONFIG_IEEE80211N */
                        ap = ap->next;
                }
                if (!olbc && iface->olbc) {
@@ -471,32 +394,3 @@ void ap_list_deinit(struct hostapd_iface *iface)
        eloop_cancel_timeout(ap_list_timer, iface, NULL);
        hostapd_free_aps(iface);
 }
-
-
-int ap_list_reconfig(struct hostapd_iface *iface,
-                    struct hostapd_config *oldconf)
-{
-       time_t now;
-       struct ap_info *ap;
-
-       if (iface->conf->ap_table_max_size == oldconf->ap_table_max_size &&
-           iface->conf->ap_table_expiration_time ==
-           oldconf->ap_table_expiration_time)
-               return 0;
-
-       time(&now);
-
-       while (iface->ap_list) {
-               ap = iface->ap_list->prev;
-               if (iface->num_ap <= iface->conf->ap_table_max_size &&
-                   ap->last_beacon + iface->conf->ap_table_expiration_time >=
-                   now)
-                       break;
-
-               if (iface->conf->passive_scan_interval > 0)
-                       ap_list_expired_ap(iface, iface->ap_list->prev);
-               ap_free_ap(iface, iface->ap_list->prev);
-       }
-
-       return 0;
-}