Avoid a direct call to drv_callbacks.c from beacon.c
[libeap.git] / hostapd / beacon.c
index d76586a..c00d8f0 100644 (file)
@@ -2,8 +2,7 @@
  * hostapd / IEEE 802.11 Management: Beacon and Probe Request/Response
  * Copyright (c) 2002-2004, Instant802 Networks, Inc.
  * Copyright (c) 2005-2006, Devicescape Software, Inc.
- * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
- * Copyright (c) 2007-2008, Intel Corporation
+ * Copyright (c) 2008-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
@@ -19,6 +18,7 @@
 
 #ifndef CONFIG_NATIVE_WINDOWS
 
+#include "common.h"
 #include "hostapd.h"
 #include "ieee802_11.h"
 #include "wpa.h"
@@ -191,20 +191,24 @@ static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len,
 }
 
 
-void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
-                     size_t len)
+void handle_probe_req(struct hostapd_data *hapd,
+                     const struct ieee80211_mgmt *mgmt, size_t len)
 {
        struct ieee80211_mgmt *resp;
        struct ieee802_11_elems elems;
        char *ssid;
-       u8 *pos, *epos, *ie;
+       u8 *pos, *epos;
+       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_wps_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;
@@ -298,21 +302,23 @@ void handle_probe_req(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
 
        pos = hostapd_eid_wpa(hapd, pos, epos - pos, sta);
 
-       /* Wi-Fi Wireless Multimedia Extensions */
-       pos = hostapd_eid_wme(hapd, pos);
+       /* Wi-Fi Alliance WMM */
+       pos = hostapd_eid_wmm(hapd, pos);
 
-       pos = hostapd_eid_ht_capabilities_info(hapd, pos);
+#ifdef CONFIG_IEEE80211N
+       pos = hostapd_eid_ht_capabilities(hapd, pos);
        pos = hostapd_eid_ht_operation(hapd, pos);
+#endif /* CONFIG_IEEE80211N */
 
 #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) < 0)
+       if (hapd->drv.send_mgmt_frame(hapd, resp, pos - (u8 *) resp) < 0)
                perror("handle_probe_req: send");
 
        os_free(resp);
@@ -395,14 +401,14 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
        tailpos = hostapd_eid_wpa(hapd, tailpos, tail + BEACON_TAIL_BUF_SIZE -
                                  tailpos, NULL);
 
-       /* Wi-Fi Wireless Multimedia Extensions */
-       tailpos = hostapd_eid_wme(hapd, tailpos);
+       /* Wi-Fi Alliance WMM */
+       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_info(hapd, tailpos);
+               tailpos = hostapd_eid_ht_capabilities(hapd, tailpos);
 
                ht_oper = tailpos;
                tailpos = hostapd_eid_ht_operation(hapd, tailpos);
@@ -419,17 +425,19 @@ void ieee802_11_set_beacon(struct hostapd_data *hapd)
 
 #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))
-               wpa_printf(MSG_ERROR, "Failed to set beacon head/tail");
+                              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);