Detach ctrl_iface monitor if the client socket is removed
[wpasupplicant] / hostapd / driver_hostap.c
index 6586372..57c6ee8 100644 (file)
 
 #include "hostapd.h"
 #include "driver.h"
-#include "ieee802_1x.h"
 #include "eloop.h"
 #include "priv_netlink.h"
-#include "ieee802_11.h"
-#include "sta_info.h"
 #include "hostap_common.h"
 #include "hw_features.h"
+#include "ieee802_11_defs.h"
 
+static const u8 rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
 
 struct hostap_driver_data {
        struct hostapd_data *hapd;
@@ -73,7 +72,6 @@ static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len,
        u16 fc, ethertype;
        u8 *pos, *sa;
        size_t left;
-       struct sta_info *sta;
 
        if (len < sizeof(struct ieee80211_hdr))
                return;
@@ -87,20 +85,7 @@ static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len,
        }
 
        sa = hdr->addr2;
-       sta = ap_get_sta(drv->hapd, sa);
-       if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
-               printf("Data frame from not associated STA " MACSTR "\n",
-                      MAC2STR(sa));
-               if (sta && (sta->flags & WLAN_STA_AUTH))
-                       hostap_sta_disassoc(
-                               drv, sa,
-                               WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-               else
-                       hostap_sta_deauth(
-                               drv, sa,
-                               WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-               return;
-       }
+       hostapd_rx_from_unknown_sta(drv->hapd, sa);
 
        pos = (u8 *) (hdr + 1);
        left = len - sizeof(*hdr);
@@ -127,7 +112,7 @@ static void handle_data(struct hostap_driver_data *drv, u8 *buf, size_t len,
        left -= 2;
        switch (ethertype) {
        case ETH_P_PAE:
-               ieee802_1x_receive(drv->hapd, sa, pos, left);
+               hostapd_eapol_receive(drv->hapd, sa, pos, left);
                break;
 
        default:
@@ -142,7 +127,6 @@ static void handle_tx_callback(struct hostap_driver_data *drv, u8 *buf,
 {
        struct ieee80211_hdr *hdr;
        u16 fc, type, stype;
-       struct sta_info *sta;
 
        hdr = (struct ieee80211_hdr *) buf;
        fc = le_to_host16(hdr->frame_control);
@@ -154,7 +138,7 @@ static void handle_tx_callback(struct hostap_driver_data *drv, u8 *buf,
        case WLAN_FC_TYPE_MGMT:
                wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
                           ok ? "ACK" : "fail");
-               ieee802_11_mgmt_cb(drv->hapd, buf, len, stype, ok);
+               hostapd_mgmt_tx_cb(drv->hapd, buf, len, stype, ok);
                break;
        case WLAN_FC_TYPE_CTRL:
                wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
@@ -163,17 +147,7 @@ static void handle_tx_callback(struct hostap_driver_data *drv, u8 *buf,
        case WLAN_FC_TYPE_DATA:
                wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
                           ok ? "ACK" : "fail");
-               sta = ap_get_sta(drv->hapd, hdr->addr1);
-               if (sta && sta->flags & WLAN_STA_PENDING_POLL) {
-                       wpa_printf(MSG_DEBUG, "STA " MACSTR
-                                  " %s pending activity poll",
-                                  MAC2STR(sta->addr),
-                                  ok ? "ACKed" : "did not ACK");
-                       if (ok)
-                               sta->flags &= ~WLAN_STA_PENDING_POLL;
-               }
-               if (sta)
-                       ieee802_1x_tx_status(drv->hapd, sta, buf, len, ok);
+               hostapd_tx_status(drv->hapd, hdr->addr1, buf, len, ok);
                break;
        default:
                printf("unknown TX callback frame type %d\n", type);
@@ -235,7 +209,7 @@ static void handle_frame(struct hostap_driver_data *drv, u8 *buf, size_t len)
        case WLAN_FC_TYPE_MGMT:
                if (stype != WLAN_FC_STYPE_BEACON)
                        wpa_printf(MSG_MSGDUMP, "MGMT");
-               ieee802_11_mgmt(drv->hapd, buf, data_len, stype, NULL);
+               hostapd_mgmt_rx(drv->hapd, buf, data_len, stype, NULL);
                break;
        case WLAN_FC_TYPE_CTRL:
                wpa_printf(MSG_DEBUG, "CTRL");
@@ -870,7 +844,7 @@ hostapd_wireless_event_wireless_custom(struct hostap_driver_data *drv,
                }
                pos += 5;
                if (hwaddr_aton(pos, addr) == 0) {
-                       ieee80211_michael_mic_failure(drv->hapd, addr, 1);
+                       hostapd_michael_mic_failure(drv->hapd, addr);
                } else {
                        wpa_printf(MSG_DEBUG,
                                   "MLME-MICHAELMICFAILURE.indication "