Fix couple of forgotten wpa_hw_modes -> hostapd_hw_modes
[wpasupplicant] / hostapd / driver_hostap.c
index 125db82..1d4bef1 100644 (file)
@@ -436,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;
@@ -458,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);
 
@@ -1018,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;
 
@@ -1051,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);
@@ -1090,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;
@@ -1104,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);
@@ -1208,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,