Added an option to add (or override) Credential attribute(s) in M8
[wpasupplicant] / hostapd / driver_nl80211.c
index 3ed7652..508a379 100644 (file)
 
 #include "hostapd.h"
 #include "driver.h"
-#include "ieee802_1x.h"
 #include "eloop.h"
-#include "ieee802_11.h"
-#include "sta_info.h"
 #include "hw_features.h"
 #include "mlme.h"
 #include "radiotap.h"
 #include "radiotap_iter.h"
+#include "ieee802_11_defs.h"
 
 #ifdef CONFIG_LIBNL20
 /* libnl 2.0 compatibility code */
@@ -46,6 +44,8 @@
 #define nl_handle_destroy nl_socket_free
 #endif /* CONFIG_LIBNL20 */
 
+static const u8 rfc1042_header[6] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 };
+
 enum ieee80211_msg_type {
        ieee80211_msg_normal = 0,
        ieee80211_msg_tx_callback_ack = 1,
@@ -609,14 +609,14 @@ static int i802_set_retry(void *priv, int short_retry, int long_retry)
 
        iwr.u.retry.value = short_retry;
        iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MIN;
-       if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
+       if (ioctl(drv->ioctl_sock, SIOCSIWRETRY, &iwr) < 0) {
                perror("ioctl[SIOCSIWRETRY(short)]");
                return -1;
        }
 
        iwr.u.retry.value = long_retry;
        iwr.u.retry.flags = IW_RETRY_LIMIT | IW_RETRY_MAX;
-       if (ioctl(drv->ioctl_sock, SIOCSIWFRAG, &iwr) < 0) {
+       if (ioctl(drv->ioctl_sock, SIOCSIWRETRY, &iwr) < 0) {
                perror("ioctl[SIOCSIWRETRY(long)]");
                return -1;
        }
@@ -920,12 +920,6 @@ static int i802_sta_set_flags(void *priv, const u8 *addr,
 }
 
 
-static int i802_set_regulatory_domain(void *priv, unsigned int rd)
-{
-       return -1;
-}
-
-
 static int i802_set_tx_queue_params(void *priv, int queue, int aifs,
                                    int cw_min, int cw_max, int burst_time)
 {
@@ -1634,32 +1628,11 @@ static int i802_set_country(void *priv, const char *country)
 }
 
 
-static void handle_unknown_sta(struct i802_driver_data *drv, u8 *ta)
-{
-       struct sta_info *sta;
-
-       sta = ap_get_sta(drv->hapd, ta);
-       if (!sta || !(sta->flags & WLAN_STA_ASSOC)) {
-               printf("Data/PS-poll frame from not associated STA "
-                      MACSTR "\n", MAC2STR(ta));
-               if (sta && (sta->flags & WLAN_STA_AUTH))
-                       i802_sta_disassoc(
-                               drv, ta,
-                               WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-               else
-                       i802_sta_deauth(
-                               drv, ta,
-                               WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA);
-       }
-}
-
-
 static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
                               int ok)
 {
        struct ieee80211_hdr *hdr;
        u16 fc, type, stype;
-       struct sta_info *sta;
 
        hdr = (struct ieee80211_hdr *) buf;
        fc = le_to_host16(hdr->frame_control);
@@ -1671,7 +1644,7 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
        case WLAN_FC_TYPE_MGMT:
                wpa_printf(MSG_DEBUG, "MGMT (TX callback) %s",
                           ok ? "ACK" : "fail");
-               ieee802_11_mgmt_cb(hapd, buf, len, stype, ok);
+               hostapd_mgmt_tx_cb(hapd, buf, len, stype, ok);
                break;
        case WLAN_FC_TYPE_CTRL:
                wpa_printf(MSG_DEBUG, "CTRL (TX callback) %s",
@@ -1680,16 +1653,7 @@ static void handle_tx_callback(struct hostapd_data *hapd, u8 *buf, size_t len,
        case WLAN_FC_TYPE_DATA:
                wpa_printf(MSG_DEBUG, "DATA (TX callback) %s",
                           ok ? "ACK" : "fail");
-               sta = ap_get_sta(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(hapd, sta, buf, len, ok);
+               hostapd_tx_status(hapd, hdr->addr1, buf, len, ok);
                break;
        default:
                printf("unknown TX callback frame type %d\n", type);
@@ -1797,18 +1761,18 @@ static void handle_frame(struct i802_driver_data *drv,
                        wpa_printf(MSG_MSGDUMP, "MGMT");
                if (broadcast_bssid) {
                        for (i = 0; i < iface->num_bss; i++)
-                               ieee802_11_mgmt(iface->bss[i], buf, data_len,
+                               hostapd_mgmt_rx(iface->bss[i], buf, data_len,
                                                stype, hfi);
                } else
-                       ieee802_11_mgmt(hapd, buf, data_len, stype, hfi);
+                       hostapd_mgmt_rx(hapd, buf, data_len, stype, hfi);
                break;
        case WLAN_FC_TYPE_CTRL:
                /* can only get here with PS-Poll frames */
                wpa_printf(MSG_DEBUG, "CTRL");
-               handle_unknown_sta(drv, hdr->addr2);
+               hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2);
                break;
        case WLAN_FC_TYPE_DATA:
-               handle_unknown_sta(drv, hdr->addr2);
+               hostapd_rx_from_unknown_sta(drv->hapd, hdr->addr2);
                break;
        }
 }
@@ -1831,7 +1795,7 @@ static void handle_eapol(int sock, void *eloop_ctx, void *sock_ctx)
        }
 
        if (have_ifidx(drv, lladdr.sll_ifindex))
-               ieee802_1x_receive(hapd, lladdr.sll_addr, buf, len);
+               hostapd_eapol_receive(hapd, lladdr.sll_addr, buf, len);
 }
 
 
@@ -1998,8 +1962,6 @@ static int i802_init_sockets(struct i802_driver_data *drv, const u8 *bssid)
        struct ifreq ifr;
        struct sockaddr_ll addr;
 
-       drv->ioctl_sock = -1;
-
        drv->ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0);
        if (drv->ioctl_sock < 0) {
                perror("socket[PF_INET,SOCK_DGRAM]");
@@ -2152,7 +2114,7 @@ hostapd_wireless_event_wireless_custom(struct i802_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 "
@@ -2525,7 +2487,6 @@ const struct wpa_driver_ops wpa_driver_nl80211_ops = {
        .set_retry = i802_set_retry,
        .get_retry = i802_get_retry,
        .set_rate_sets = i802_set_rate_sets,
-       .set_regulatory_domain = i802_set_regulatory_domain,
        .set_beacon = i802_set_beacon,
        .set_internal_bridge = i802_set_internal_bridge,
        .set_beacon_int = i802_set_beacon_int,