Fix couple of forgotten wpa_hw_modes -> hostapd_hw_modes
[wpasupplicant] / hostapd / driver_hostap.c
index cf8b9ba..1d4bef1 100644 (file)
 #endif /* USE_KERNEL_HEADERS */
 
 #include "hostapd.h"
+#include "config.h"
 #include "driver.h"
 #include "eloop.h"
 #include "priv_netlink.h"
-#include "ieee802_11.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 };
 
@@ -138,7 +139,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",
@@ -209,7 +210,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");
@@ -435,10 +436,10 @@ static int hostapd_ioctl(void *priv, struct prism2_hostapd_param *param,
 }
 
 
-static int hostap_set_encryption(const char *ifname, void *priv,
-                                const char *alg, const u8 *addr,
-                                int idx, const u8 *key, size_t key_len,
-                                int txkey)
+static int hostap_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 hostap_driver_data *drv = priv;
        struct prism2_hostapd_param *param;
@@ -457,10 +458,29 @@ static int hostap_set_encryption(const char *ifname, void *priv,
                memset(param->sta_addr, 0xff, ETH_ALEN);
        else
                memcpy(param->sta_addr, addr, ETH_ALEN);
-       os_strlcpy((char *) param->u.crypt.alg, alg,
-                  HOSTAP_CRYPT_ALG_NAME_LEN);
-       param->u.crypt.flags = txkey ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
-       param->u.crypt.idx = idx;
+       switch (alg) {
+       case WPA_ALG_NONE:
+               os_strlcpy((char *) param->u.crypt.alg, "NONE",
+                          HOSTAP_CRYPT_ALG_NAME_LEN);
+               break;
+       case WPA_ALG_WEP:
+               os_strlcpy((char *) param->u.crypt.alg, "WEP",
+                          HOSTAP_CRYPT_ALG_NAME_LEN);
+               break;
+       case WPA_ALG_TKIP:
+               os_strlcpy((char *) param->u.crypt.alg, "TKIP",
+                          HOSTAP_CRYPT_ALG_NAME_LEN);
+               break;
+       case WPA_ALG_CCMP:
+               os_strlcpy((char *) param->u.crypt.alg, "CCMP",
+                          HOSTAP_CRYPT_ALG_NAME_LEN);
+               break;
+       default:
+               os_free(buf);
+               return -1;
+       }
+       param->u.crypt.flags = set_tx ? HOSTAP_CRYPT_FLAG_SET_TX_KEY : 0;
+       param->u.crypt.idx = key_idx;
        param->u.crypt.key_len = key_len;
        memcpy((u8 *) (param + 1), key, key_len);
 
@@ -640,10 +660,8 @@ static int hostap_read_sta_data(void *priv,
 }
 
 
-static int hostap_sta_add(const char *ifname, void *priv, const u8 *addr,
-                         u16 aid, u16 capability, u8 *supp_rates,
-                         size_t supp_rates_len, int flags,
-                         u16 listen_interval)
+static int hostap_sta_add(const char *ifname, void *priv,
+                         struct hostapd_sta_add_params *params)
 {
        struct hostap_driver_data *drv = priv;
        struct prism2_hostapd_param param;
@@ -655,22 +673,22 @@ static int hostap_sta_add(const char *ifname, void *priv, const u8 *addr,
 #define WLAN_RATE_5M5 BIT(2)
 #define WLAN_RATE_11M BIT(3)
 
-       for (i = 0; i < supp_rates_len; i++) {
-               if ((supp_rates[i] & 0x7f) == 2)
+       for (i = 0; i < params->supp_rates_len; i++) {
+               if ((params->supp_rates[i] & 0x7f) == 2)
                        tx_supp_rates |= WLAN_RATE_1M;
-               if ((supp_rates[i] & 0x7f) == 4)
+               if ((params->supp_rates[i] & 0x7f) == 4)
                        tx_supp_rates |= WLAN_RATE_2M;
-               if ((supp_rates[i] & 0x7f) == 11)
+               if ((params->supp_rates[i] & 0x7f) == 11)
                        tx_supp_rates |= WLAN_RATE_5M5;
-               if ((supp_rates[i] & 0x7f) == 22)
+               if ((params->supp_rates[i] & 0x7f) == 22)
                        tx_supp_rates |= WLAN_RATE_11M;
        }
 
        memset(&param, 0, sizeof(param));
        param.cmd = PRISM2_HOSTAPD_ADD_STA;
-       memcpy(param.sta_addr, addr, ETH_ALEN);
-       param.u.add_sta.aid = aid;
-       param.u.add_sta.capability = capability;
+       memcpy(param.sta_addr, params->addr, ETH_ALEN);
+       param.u.add_sta.aid = params->aid;
+       param.u.add_sta.capability = params->capability;
        param.u.add_sta.tx_supp_rates = tx_supp_rates;
        return hostapd_ioctl(drv, &param, sizeof(param));
 }
@@ -726,21 +744,6 @@ static int hostap_sta_clear_stats(void *priv, const u8 *addr)
 }
 
 
-static int hostap_set_assoc_ap(void *priv, const u8 *addr)
-{
-       struct hostap_driver_data *drv = priv;
-       struct prism2_hostapd_param param;
-
-       memset(&param, 0, sizeof(param));
-       param.cmd = PRISM2_HOSTAPD_SET_ASSOC_AP_ADDR;
-       memcpy(param.sta_addr, addr, ETH_ALEN);
-       if (hostapd_ioctl(drv, &param, sizeof(param)))
-               return -1;
-
-       return 0;
-}
-
-
 static int hostapd_ioctl_set_generic_elem(struct hostap_driver_data *drv)
 {
        struct prism2_hostapd_param *param;
@@ -844,7 +847,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 "
@@ -1034,9 +1037,8 @@ static int hostap_get_we_version(struct hostap_driver_data *drv)
 }
 
 
-static int hostap_wireless_event_init(void *priv)
+static int hostap_wireless_event_init(struct hostap_driver_data *drv)
 {
-       struct hostap_driver_data *drv = priv;
        int s;
        struct sockaddr_nl local;
 
@@ -1067,9 +1069,8 @@ static int hostap_wireless_event_init(void *priv)
 }
 
 
-static void hostap_wireless_event_deinit(void *priv)
+static void hostap_wireless_event_deinit(struct hostap_driver_data *drv)
 {
-       struct hostap_driver_data *drv = priv;
        if (drv->wext_sock < 0)
                return;
        eloop_unregister_read_sock(drv->wext_sock);
@@ -1106,7 +1107,7 @@ static void * hostap_init(struct hostapd_data *hapd)
                return NULL;
        }
 
-       if (hostap_init_sockets(drv)) {
+       if (hostap_init_sockets(drv) || hostap_wireless_event_init(drv)) {
                close(drv->ioctl_sock);
                free(drv);
                return NULL;
@@ -1120,6 +1121,7 @@ static void hostap_driver_deinit(void *priv)
 {
        struct hostap_driver_data *drv = priv;
 
+       hostap_wireless_event_deinit(drv);
        (void) hostap_set_iface_flags(drv, 0);
        (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD, 0);
        (void) hostap_ioctl_prism2param(drv, PRISM2_PARAM_HOSTAPD_STA, 0);
@@ -1224,15 +1226,13 @@ static struct hostapd_hw_modes * hostap_get_hw_feature_data(void *priv,
 }
 
 
-const struct wpa_driver_ops wpa_driver_hostap_ops = {
+const struct hapd_driver_ops wpa_driver_hostap_ops = {
        .name = "hostap",
        .init = hostap_init,
        .deinit = hostap_driver_deinit,
-       .wireless_event_init = hostap_wireless_event_init,
-       .wireless_event_deinit = hostap_wireless_event_deinit,
        .set_ieee8021x = hostap_set_ieee8021x,
        .set_privacy = hostap_set_privacy,
-       .set_encryption = hostap_set_encryption,
+       .set_key = hostap_set_key,
        .get_seqnum = hostap_get_seqnum,
        .flush = hostap_flush,
        .set_generic_elem = hostap_set_generic_elem,
@@ -1244,7 +1244,6 @@ const struct wpa_driver_ops wpa_driver_hostap_ops = {
        .sta_remove = hostap_sta_remove,
        .set_ssid = hostap_set_ssid,
        .send_mgmt_frame = hostap_send_mgmt_frame,
-       .set_assoc_ap = hostap_set_assoc_ap,
        .sta_add = hostap_sta_add,
        .get_inact_sec = hostap_get_inact_sec,
        .sta_clear_stats = hostap_sta_clear_stats,