nl80211: Remove unuset set_privacy() and set_internal_bridge()
[wpasupplicant] / hostapd / driver_bsd.c
index f200d15..2f16d7d 100644 (file)
 #undef WPA_OUI_TYPE
 
 #include "hostapd.h"
+#include "config.h"
 #include "driver.h"
-#include "ieee802_1x.h"
 #include "eloop.h"
-#include "sta_info.h"
 #include "l2_packet/l2_packet.h"
 
 #include "eapol_sm.h"
-#include "wpa.h"
-#include "radius/radius.h"
-#include "ieee802_11.h"
 #include "common.h"
 
 struct bsd_driver_data {
@@ -345,28 +341,28 @@ bsd_del_key(void *priv, const u8 *addr, int key_idx)
 }
 
 static int
-bsd_set_key(const char *ifname, void *priv, const char *alg,
-           const u8 *addr, int key_idx,
-           const u8 *key, size_t key_len, int txkey)
+bsd_set_key(const char *ifname, void *priv, wpa_alg alg,
+           const u8 *addr, int key_idx, int set_tx, const u8 *seq,
+           size_t seq_len, const u8 *key, size_t key_len)
 {
        struct bsd_driver_data *drv = priv;
        struct ieee80211req_key wk;
        u_int8_t cipher;
 
-       if (strcmp(alg, "none") == 0)
+       if (alg == WPA_ALG_NONE)
                return bsd_del_key(drv, addr, key_idx);
 
-       wpa_printf(MSG_DEBUG, "%s: alg=%s addr=%s key_idx=%d",
+       wpa_printf(MSG_DEBUG, "%s: alg=%d addr=%s key_idx=%d",
                   __func__, alg, ether_sprintf(addr), key_idx);
 
-       if (strcmp(alg, "WEP") == 0)
+       if (alg == WPA_ALG_WEP)
                cipher = IEEE80211_CIPHER_WEP;
-       else if (strcmp(alg, "TKIP") == 0)
+       else if (alg == WPA_ALG_TKIP)
                cipher = IEEE80211_CIPHER_TKIP;
-       else if (strcmp(alg, "CCMP") == 0)
+       else if (alg == WPA_ALG_CCMP)
                cipher = IEEE80211_CIPHER_AES_CCM;
        else {
-               printf("%s: unknown/unsupported algorithm %s\n",
+               printf("%s: unknown/unsupported algorithm %d\n",
                        __func__, alg);
                return -1;
        }
@@ -505,33 +501,11 @@ bsd_sta_disassoc(void *priv, const u8 *addr, int reason_code)
 }
 
 static int
-bsd_del_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
-{
-       struct hostapd_data *hapd = drv->hapd;
-       struct hostapd_bss_config *conf = hapd->conf;
-       struct sta_info *sta;
-
-       hostapd_logger(hapd, addr, HOSTAPD_MODULE_IEEE80211,
-               HOSTAPD_LEVEL_INFO, "deassociated");
-
-       sta = ap_get_sta(hapd, addr);
-       if (sta != NULL) {
-               sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
-               if (conf->wpa)
-                       wpa_auth_sm_event(sta->wpa_sm, WPA_DISASSOC);
-               sta->acct_terminate_cause = RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST;
-               ieee802_1x_notify_port_enabled(sta->eapol_sm, 0);
-               ap_free_sta(hapd, sta);
-       }
-       return 0;
-}
-
-static int
 bsd_new_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
 {
        struct hostapd_data *hapd = drv->hapd;
        struct ieee80211req_wpaie ie;
-       int new_assoc, ielen = 0, res;
+       int ielen = 0;
        u8 *iebuf = NULL;
 
        /*
@@ -550,6 +524,7 @@ bsd_new_sta(struct bsd_driver_data *drv, u8 addr[IEEE80211_ADDR_LEN])
        else
                ielen += 2;
 
+no_ie:
        return hostapd_notif_assoc(hapd, addr, iebuf, ielen);
 }
 
@@ -593,7 +568,7 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
                        break;
                case RTM_IEEE80211_LEAVE:
                        leave = (struct ieee80211_leave_event *) &ifan[1];
-                       bsd_del_sta(drv, leave->iev_addr);
+                       hostapd_notif_disassoc(drv->hapd, leave->iev_addr);
                        break;
                case RTM_IEEE80211_JOIN:
 #ifdef RTM_IEEE80211_REJOIN
@@ -611,7 +586,7 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
                                "Michael MIC failure wireless event: "
                                "keyix=%u src_addr=" MACSTR, mic->iev_keyix,
                                MAC2STR(mic->iev_src));
-                       ieee80211_michael_mic_failure(hapd, mic->iev_src, 1);
+                       hostapd_michael_mic_failure(hapd, mic->iev_src);
                        break;
                }
                break;
@@ -619,9 +594,8 @@ bsd_wireless_event_receive(int sock, void *ctx, void *sock_ctx)
 }
 
 static int
-bsd_wireless_event_init(void *priv)
+bsd_wireless_event_init(struct bsd_driver_data *drv)
 {
-       struct bsd_driver_data *drv = priv;
        int s;
 
        drv->wext_sock = -1;
@@ -638,16 +612,12 @@ bsd_wireless_event_init(void *priv)
 }
 
 static void
-bsd_wireless_event_deinit(void *priv)
+bsd_wireless_event_deinit(struct bsd_driver_data *drv)
 {
-       struct bsd_driver_data *drv = priv;
-
-       if (drv != NULL) {
-               if (drv->wext_sock < 0)
-                       return;
-               eloop_unregister_read_sock(drv->wext_sock);
-               close(drv->wext_sock);
-       }
+       if (drv->wext_sock < 0)
+               return;
+       eloop_unregister_read_sock(drv->wext_sock);
+       close(drv->wext_sock);
 }
 
 
@@ -696,10 +666,9 @@ static void
 handle_read(void *ctx, const u8 *src_addr, const u8 *buf, size_t len)
 {
        struct bsd_driver_data *drv = ctx;
-       struct hostapd_data *hapd = drv->hapd;
-
-       ieee802_1x_receive(hapd, src_addr, buf + sizeof(struct l2_ethhdr),
-                          len - sizeof(struct l2_ethhdr));
+       hostapd_eapol_receive(drv->hapd, src_addr,
+                             buf + sizeof(struct l2_ethhdr),
+                             len - sizeof(struct l2_ethhdr));
 }
 
 static int
@@ -750,6 +719,8 @@ bsd_init(struct hostapd_data *hapd)
                goto bad;
 
        bsd_set_iface_flags(drv, 0);    /* mark down during setup */
+       if (bsd_wireless_event_init(drv))
+               goto bad;
 
        return drv;
 bad:
@@ -768,6 +739,7 @@ bsd_deinit(void *priv)
 {
        struct bsd_driver_data *drv = priv;
 
+       bsd_wireless_event_deinit(drv);
        (void) bsd_set_iface_flags(drv, 0);
        if (drv->ioctl_sock >= 0)
                close(drv->ioctl_sock);
@@ -776,18 +748,16 @@ bsd_deinit(void *priv)
        free(drv);
 }
 
-const struct wpa_driver_ops wpa_driver_bsd_ops = {
+const struct hapd_driver_ops wpa_driver_bsd_ops = {
        .name                   = "bsd",
        .init                   = bsd_init,
        .deinit                 = bsd_deinit,
        .set_ieee8021x          = bsd_set_ieee8021x,
        .set_privacy            = bsd_set_privacy,
-       .set_encryption         = bsd_set_key,
+       .set_key                = bsd_set_key,
        .get_seqnum             = bsd_get_seqnum,
        .flush                  = bsd_flush,
        .set_generic_elem       = bsd_set_opt_ie,
-       .wireless_event_init    = bsd_wireless_event_init,
-       .wireless_event_deinit  = bsd_wireless_event_deinit,
        .sta_set_flags          = bsd_sta_set_flags,
        .read_sta_data          = bsd_read_sta_driver_data,
        .send_eapol             = bsd_send_eapol,