os_memcpy(mgmt.bssid, hapd->own_addr, ETH_ALEN);
mgmt.u.deauth.reason_code = host_to_le16(reason);
if (hostapd_send_mgmt_frame(hapd, &mgmt, IEEE80211_HDRLEN +
- sizeof(mgmt.u.deauth), 0) < 0)
+ sizeof(mgmt.u.deauth)) < 0)
perror("ieee802_11_send_deauth: send");
}
" auth_alg=%d auth_transaction=%d resp=%d (IE len=%lu)",
MAC2STR(dst), auth_alg, auth_transaction,
resp, (unsigned long) ies_len);
- if (hostapd_send_mgmt_frame(hapd, reply, rlen, 0) < 0)
+ if (hostapd_send_mgmt_frame(hapd, reply, rlen) < 0)
perror("send_auth_reply: send");
os_free(buf);
}
+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)
{
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,
send_len += p - reply->u.assoc_resp.variable;
}
- if (hostapd_send_mgmt_frame(hapd, reply, send_len, 0) < 0)
+ if (hostapd_send_mgmt_frame(hapd, reply, send_len) < 0)
perror("handle_assoc: send");
}
os_memcpy(mgmt.u.action.u.sa_query_req.trans_id, trans_id,
WLAN_SA_QUERY_TR_ID_LEN);
end = mgmt.u.action.u.sa_query_req.trans_id + WLAN_SA_QUERY_TR_ID_LEN;
- if (hostapd_send_mgmt_frame(hapd, &mgmt, end - (u8 *) &mgmt, 0) < 0)
+ if (hostapd_send_mgmt_frame(hapd, &mgmt, end - (u8 *) &mgmt) < 0)
perror("ieee802_11_send_sa_query_req: send");
}
os_memcpy(mgmt->bssid, hapd->own_addr, ETH_ALEN);
mgmt->u.action.category |= 0x80;
- hostapd_send_mgmt_frame(hapd, mgmt, len, 0);
+ hostapd_send_mgmt_frame(hapd, mgmt, len);
}
}
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);