Remove direct driver calls from vlan_init.c
[libeap.git] / hostapd / beacon.c
index 1f65323..a796cc3 100644 (file)
@@ -25,9 +25,9 @@
 #include "wme.h"
 #include "beacon.h"
 #include "hw_features.h"
-#include "driver_i.h"
+#include "drivers/driver.h"
+#include "config.h"
 #include "sta_info.h"
-#include "wps_hostapd.h"
 
 
 static u8 ieee802_11_erp_info(struct hostapd_data *hapd)
@@ -201,11 +201,14 @@ void handle_probe_req(struct hostapd_data *hapd,
        const u8 *ie;
        size_t ssid_len, ie_len;
        struct sta_info *sta = NULL;
+       size_t i;
 
        ie = mgmt->u.probe_req.variable;
        ie_len = len - (IEEE80211_HDRLEN + sizeof(mgmt->u.probe_req));
 
-       hostapd_probe_req_rx(hapd, mgmt->sa, ie, ie_len);
+       for (i = 0; hapd->probereq_cb && i < hapd->num_probereq_cb; i++)
+               hapd->probereq_cb[i].cb(hapd->probereq_cb[i].ctx,
+                                       mgmt->sa, ie, ie_len);
 
        if (!hapd->iconf->send_probe_response)
                return;
@@ -309,13 +312,13 @@ void handle_probe_req(struct hostapd_data *hapd,
 
 #ifdef CONFIG_WPS
        if (hapd->conf->wps_state && hapd->wps_probe_resp_ie) {
-               os_memcpy(pos, hapd->wps_probe_resp_ie,
-                         hapd->wps_probe_resp_ie_len);
-               pos += hapd->wps_probe_resp_ie_len;
+               os_memcpy(pos, wpabuf_head(hapd->wps_probe_resp_ie),
+                         wpabuf_len(hapd->wps_probe_resp_ie));
+               pos += wpabuf_len(hapd->wps_probe_resp_ie);
        }
 #endif /* CONFIG_WPS */
 
-       if (hostapd_send_mgmt_frame(hapd, resp, pos - (u8 *) resp) < 0)
+       if (hapd->drv.send_mgmt_frame(hapd, resp, pos - (u8 *) resp) < 0)
                perror("handle_probe_req: send");
 
        os_free(resp);
@@ -330,11 +333,8 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
 {
        struct ieee80211_mgmt *head;
        u8 *pos, *tail, *tailpos;
-       int preamble;
        u16 capab_info;
        size_t head_len, tail_len;
-       int cts_protection = ((ieee802_11_erp_info(hapd) &
-                             ERP_INFO_USE_PROTECTION) ? 1 : 0);
 
 #define BEACON_HEAD_BUF_SIZE 256
 #define BEACON_TAIL_BUF_SIZE 512
@@ -402,63 +402,32 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
        tailpos = hostapd_eid_wmm(hapd, tailpos);
 
 #ifdef CONFIG_IEEE80211N
-       if (hapd->iconf->ieee80211n) {
-               u8 *ht_capab, *ht_oper;
-               ht_capab = tailpos;
-               tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
-
-               ht_oper = tailpos;
-               tailpos = hostapd_eid_ht_operation(hapd, tailpos);
-
-               if (tailpos > ht_oper && ht_oper > ht_capab &&
-                   hostapd_set_ht_params(hapd->conf->iface, hapd,
-                                         ht_capab + 2, ht_capab[1],
-                                         ht_oper + 2, ht_oper[1])) {
-                       wpa_printf(MSG_ERROR, "Could not set HT capabilities "
-                                  "for kernel driver");
-               }
-       }
+       tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
+       tailpos = hostapd_eid_ht_operation(hapd, tailpos);
 #endif /* CONFIG_IEEE80211N */
 
 #ifdef CONFIG_WPS
        if (hapd->conf->wps_state && hapd->wps_beacon_ie) {
-               os_memcpy(tailpos, hapd->wps_beacon_ie,
-                         hapd->wps_beacon_ie_len);
-               tailpos += hapd->wps_beacon_ie_len;
+               os_memcpy(tailpos, wpabuf_head(hapd->wps_beacon_ie),
+                         wpabuf_len(hapd->wps_beacon_ie));
+               tailpos += wpabuf_len(hapd->wps_beacon_ie);
        }
 #endif /* CONFIG_WPS */
 
        tail_len = tailpos > tail ? tailpos - tail : 0;
 
-       if (hostapd_set_beacon(hapd->conf->iface, hapd, (u8 *) head, head_len,
-                              tail, tail_len, hapd->conf->dtim_period,
-                              hapd->iconf->beacon_int))
+       if (hapd->drv.set_beacon(hapd->conf->iface, hapd,
+                                (u8 *) head, head_len,
+                                tail, tail_len, hapd->conf->dtim_period,
+                                hapd->iconf->beacon_int))
                wpa_printf(MSG_ERROR, "Failed to set beacon head/tail or DTIM "
                           "period");
 
        os_free(tail);
        os_free(head);
 
-       if (hostapd_set_cts_protect(hapd, cts_protection))
-               wpa_printf(MSG_ERROR, "Failed to set CTS protect in kernel "
-                          "driver");
-
-       if (hapd->iface->current_mode &&
-           hapd->iface->current_mode->mode == HOSTAPD_MODE_IEEE80211G &&
-           hostapd_set_short_slot_time(hapd,
-                                       hapd->iface->num_sta_no_short_slot_time
-                                       > 0 ? 0 : 1))
-               wpa_printf(MSG_ERROR, "Failed to set Short Slot Time option "
-                          "in kernel driver");
-
-       if (hapd->iface->num_sta_no_short_preamble == 0 &&
-           hapd->iconf->preamble == SHORT_PREAMBLE)
-               preamble = SHORT_PREAMBLE;
-       else
-               preamble = LONG_PREAMBLE;
-       if (hostapd_set_preamble(hapd, preamble))
-               wpa_printf(MSG_ERROR, "Could not set preamble for kernel "
-                          "driver");
+       hapd->drv.set_bss_params(hapd, !!(ieee802_11_erp_info(hapd) &
+                                         ERP_INFO_USE_PROTECTION));
 }