Move AID derivation into a separate function

This commit is contained in:
Jouni Malinen 2009-03-25 15:35:00 +02:00 committed by Jouni Malinen
parent f1a4871084
commit d42a62b36c

View file

@ -665,6 +665,28 @@ 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)
{
/* get a unique AID */
if (sta->aid > 0) {
wpa_printf(MSG_DEBUG, " old AID %d", sta->aid);
return 0;
}
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;
return -1;
}
hapd->sta_aid[sta->aid - 1] = sta;
wpa_printf(MSG_DEBUG, " new AID %d", sta->aid);
return 0;
}
static void handle_assoc(struct hostapd_data *hapd, static void handle_assoc(struct hostapd_data *hapd,
struct ieee80211_mgmt *mgmt, size_t len, int reassoc) struct ieee80211_mgmt *mgmt, size_t len, int reassoc)
{ {
@ -1044,22 +1066,10 @@ static void handle_assoc(struct hostapd_data *hapd,
ieee802_11_set_beacons(hapd->iface); ieee802_11_set_beacons(hapd->iface);
#endif /* CONFIG_IEEE80211N */ #endif /* CONFIG_IEEE80211N */
/* get a unique AID */ if (hostapd_get_aid(hapd, sta) < 0) {
if (sta->aid > 0) { resp = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA;
wpa_printf(MSG_DEBUG, " old AID %d", sta->aid); wpa_printf(MSG_ERROR, " no room for more AIDs");
} else { goto fail;
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);
}
} }
hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211, hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_IEEE80211,