nl80211: Remove unuset set_privacy() and set_internal_bridge()
[wpasupplicant] / hostapd / ieee802_11.c
index 0faf6e1..759d9ff 100644 (file)
@@ -301,8 +301,9 @@ static u8 * hostapd_eid_assoc_comeback_time(struct hostapd_data *hapd,
        u32 timeout, tu;
        struct os_time now, passed;
 
-       *pos++ = WLAN_EID_ASSOC_COMEBACK_TIME;
-       *pos++ = 4;
+       *pos++ = WLAN_EID_TIMEOUT_INTERVAL;
+       *pos++ = 5;
+       *pos++ = WLAN_TIMEOUT_ASSOC_COMEBACK;
        os_get_time(&now);
        os_time_sub(&now, &sta->sa_query_start, &passed);
        tu = (passed.sec * 1000000 + passed.usec) / 1024;
@@ -664,6 +665,39 @@ static void handle_auth(struct hostapd_data *hapd, struct ieee80211_mgmt *mgmt,
 }
 
 
+static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
+{
+       int i, j = 32, aid;
+
+       /* get a unique AID */
+       if (sta->aid > 0) {
+               wpa_printf(MSG_DEBUG, "  old AID %d", sta->aid);
+               return 0;
+       }
+
+       for (i = 0; i < AID_WORDS; i++) {
+               if (hapd->sta_aid[i] == (u32) -1)
+                       continue;
+               for (j = 0; j < 32; j++) {
+                       if (!(hapd->sta_aid[i] & BIT(j)))
+                               break;
+               }
+               if (j < 32)
+                       break;
+       }
+       if (j == 32)
+               return -1;
+       aid = i * 32 + j + 1;
+       if (aid > 2007)
+               return -1;
+
+       sta->aid = aid;
+       hapd->sta_aid[i] |= BIT(j);
+       wpa_printf(MSG_DEBUG, "  new AID %d", sta->aid);
+       return 0;
+}
+
+
 static void handle_assoc(struct hostapd_data *hapd,
                         struct ieee80211_mgmt *mgmt, size_t len, int reassoc)
 {
@@ -674,7 +708,7 @@ static void handle_assoc(struct hostapd_data *hapd,
        int send_deauth = 0, send_len, left, i;
        struct sta_info *sta;
        struct ieee802_11_elems elems;
-       u8 buf[sizeof(struct ieee80211_mgmt) + 512];
+       u8 buf[sizeof(struct ieee80211_mgmt) + 1024];
        struct ieee80211_mgmt *reply;
 
        if (len < IEEE80211_HDRLEN + (reassoc ? sizeof(mgmt->u.reassoc_req) :
@@ -765,16 +799,16 @@ static void handle_assoc(struct hostapd_data *hapd,
                goto fail;
        }
 
-       sta->flags &= ~WLAN_STA_WME;
-       if (elems.wme && hapd->conf->wme_enabled) {
-               if (hostapd_eid_wme_valid(hapd, elems.wme, elems.wme_len))
+       sta->flags &= ~WLAN_STA_WMM;
+       if (elems.wmm && hapd->conf->wmm_enabled) {
+               if (hostapd_eid_wmm_valid(hapd, elems.wmm, elems.wmm_len))
                        hostapd_logger(hapd, sta->addr,
                                       HOSTAPD_MODULE_WPA,
                                       HOSTAPD_LEVEL_DEBUG,
-                                      "invalid WME element in association "
+                                      "invalid WMM element in association "
                                       "request");
                else
-                       sta->flags |= WLAN_STA_WME;
+                       sta->flags |= WLAN_STA_WMM;
        }
 
        if (!elems.supp_rates) {
@@ -1043,22 +1077,10 @@ static void handle_assoc(struct hostapd_data *hapd,
                ieee802_11_set_beacons(hapd->iface);
 #endif /* CONFIG_IEEE80211N */
 
-       /* get a unique AID */
-       if (sta->aid > 0) {
-               wpa_printf(MSG_DEBUG, "  old AID %d", sta->aid);
-       } else {
-               for (sta->aid = 1; sta->aid <= MAX_AID_TABLE_SIZE; sta->aid++)
-                       if (hapd->sta_aid[sta->aid - 1] == NULL)
-                               break;
-               if (sta->aid > MAX_AID_TABLE_SIZE) {
-                       sta->aid = 0;
-                       resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
-                       wpa_printf(MSG_ERROR, "  no room for more AIDs");
-                       goto fail;
-               } else {
-                       hapd->sta_aid[sta->aid - 1] = sta;
-                       wpa_printf(MSG_DEBUG, "  new AID %d", sta->aid);
-               }
+       if (hostapd_get_aid(hapd, sta) < 0) {
+               resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
+               wpa_printf(MSG_ERROR, "  no room for more AIDs");
+               goto fail;
        }
 
        hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
@@ -1123,8 +1145,8 @@ static void handle_assoc(struct hostapd_data *hapd,
                p = hostapd_eid_supp_rates(hapd, reply->u.assoc_resp.variable);
                /* Extended supported rates */
                p = hostapd_eid_ext_supp_rates(hapd, p);
-               if (sta->flags & WLAN_STA_WME)
-                       p = hostapd_eid_wme(hapd, p);
+               if (sta->flags & WLAN_STA_WMM)
+                       p = hostapd_eid_wmm(hapd, p);
 
                p = hostapd_eid_ht_capabilities_info(hapd, p);
                p = hostapd_eid_ht_operation(hapd, p);
@@ -1132,10 +1154,11 @@ static void handle_assoc(struct hostapd_data *hapd,
 #ifdef CONFIG_IEEE80211R
                if (resp == WLAN_STATUS_SUCCESS) {
                        /* IEEE 802.11r: Mobility Domain Information, Fast BSS
-                        * Transition Information, RSN */
+                        * Transition Information, RSN, [RIC Response] */
                        p = wpa_sm_write_assoc_resp_ies(sta->wpa_sm, p,
                                                        buf + sizeof(buf) - p,
-                                                       sta->auth_alg);
+                                                       sta->auth_alg,
+                                                       pos, left);
                }
 #endif /* CONFIG_IEEE80211R */
 
@@ -1365,7 +1388,7 @@ static void handle_action(struct hostapd_data *hapd,
        }
 #endif /* CONFIG_IEEE80211R */
        case WLAN_ACTION_WMM:
-               hostapd_wme_action(hapd, mgmt, len);
+               hostapd_wmm_action(hapd, mgmt, len);
                return;
 #ifdef CONFIG_IEEE80211W
        case WLAN_ACTION_SA_QUERY:
@@ -1526,6 +1549,34 @@ static void handle_auth_cb(struct hostapd_data *hapd,
 }
 
 
+#ifdef CONFIG_IEEE80211N
+static void
+hostapd_get_ht_capab(struct hostapd_data *hapd,
+                    struct ht_cap_ie *ht_cap_ie,
+                    struct ht_cap_ie *neg_ht_cap_ie)
+{
+
+       os_memcpy(neg_ht_cap_ie, ht_cap_ie, sizeof(struct ht_cap_ie));
+       neg_ht_cap_ie->data.capabilities_info =
+               ht_cap_ie->data.capabilities_info & hapd->iconf->ht_capab;
+
+       neg_ht_cap_ie->data.capabilities_info &= ~HT_CAP_INFO_SMPS_DISABLED;
+       if ((ht_cap_ie->data.capabilities_info & HT_CAP_INFO_SMPS_DISABLED) ==
+           (hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_DISABLED))
+               neg_ht_cap_ie->data.capabilities_info |=
+                       hapd->iconf->ht_capab & HT_CAP_INFO_SMPS_DISABLED;
+       else
+               neg_ht_cap_ie->data.capabilities_info |=
+                       HT_CAP_INFO_SMPS_DISABLED;
+
+       /* FIXME: Rx STBC needs to be handled specially */
+       neg_ht_cap_ie->data.capabilities_info &= ~HT_CAP_INFO_RX_STBC_MASK;
+       neg_ht_cap_ie->data.capabilities_info |=
+               hapd->iconf->ht_capab & HT_CAP_INFO_RX_STBC_MASK;
+}
+#endif /* CONFIG_IEEE80211N */
+
+
 static void handle_assoc_cb(struct hostapd_data *hapd,
                            struct ieee80211_mgmt *mgmt,
                            size_t len, int reassoc, int ok)
@@ -1533,7 +1584,10 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
        u16 status;
        struct sta_info *sta;
        int new_assoc = 1;
-       struct ht_cap_ie *ht_cap = NULL;
+#ifdef CONFIG_IEEE80211N
+       struct ht_cap_ie ht_cap;
+#endif /* CONFIG_IEEE80211N */
+       struct ht_cap_ie *ht_cap_ptr = NULL;
 
        if (!ok) {
                hostapd_logger(hapd, mgmt->da, HOSTAPD_MODULE_IEEE80211,
@@ -1576,6 +1630,10 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
        if (sta->flags & WLAN_STA_ASSOC)
                new_assoc = 0;
        sta->flags |= WLAN_STA_ASSOC;
+       if (!hapd->conf->ieee802_1x && !hapd->conf->wpa) {
+               /* Open or static WEP; no separate authorization */
+               sta->flags |= WLAN_STA_AUTHORIZED;
+       }
 
        if (reassoc)
                mlme_reassociate_indication(hapd, sta);
@@ -1583,8 +1641,10 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
                mlme_associate_indication(hapd, sta);
 
 #ifdef CONFIG_IEEE80211N
-       if (sta->flags & WLAN_STA_HT)
-               ht_cap = &sta->ht_capabilities;
+       if (sta->flags & WLAN_STA_HT) {
+               ht_cap_ptr = &ht_cap;
+               hostapd_get_ht_capab(hapd, &sta->ht_capabilities, ht_cap_ptr);
+       }
 #endif /* CONFIG_IEEE80211N */
 
 #ifdef CONFIG_IEEE80211W
@@ -1594,7 +1654,7 @@ static void handle_assoc_cb(struct hostapd_data *hapd,
        if (hostapd_sta_add(hapd->conf->iface, hapd, sta->addr, sta->aid,
                            sta->capability, sta->supported_rates,
                            sta->supported_rates_len, 0, sta->listen_interval,
-                           ht_cap))
+                           ht_cap_ptr))
        {
                hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,
                               HOSTAPD_LEVEL_NOTICE,