[PATCH] mesh: generate proper aid for peer

Bob Copeland me
Mon Oct 5 05:16:40 PDT 2015


802.11-2012 13.3.1 states that the AID should be generated
on the local node for each peer.  Previously, we were using
the peer link ID (generated by the peer) which may not be
unique among all peers.  Correct this by reusing the AP AID
generation code.

Signed-off-by: Bob Copeland <me at bobcopeland.com>
---
 src/ap/ieee802_11.c       |  2 +-
 src/ap/ieee802_11.h       |  1 +
 wpa_supplicant/mesh_mpm.c | 10 ++++++++--
 3 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c
index 43d405d2336a..01b514eee3fe 100644
--- a/src/ap/ieee802_11.c
+++ b/src/ap/ieee802_11.c
@@ -1210,7 +1210,7 @@ static void handle_auth(struct hostapd_data *hapd,
 }
 
 
-static int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
+int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta)
 {
 	int i, j = 32, aid;
 
diff --git a/src/ap/ieee802_11.h b/src/ap/ieee802_11.h
index 93f9dc333f3c..a2dd132838fd 100644
--- a/src/ap/ieee802_11.h
+++ b/src/ap/ieee802_11.h
@@ -64,6 +64,7 @@ void hostapd_get_ht_capab(struct hostapd_data *hapd,
 void hostapd_get_vht_capab(struct hostapd_data *hapd,
 			   struct ieee80211_vht_capabilities *vht_cap,
 			   struct ieee80211_vht_capabilities *neg_vht_cap);
+int hostapd_get_aid(struct hostapd_data *hapd, struct sta_info *sta);
 u16 copy_sta_ht_capab(struct hostapd_data *hapd, struct sta_info *sta,
 		      const u8 *ht_capab);
 u16 copy_sta_vendor_vht(struct hostapd_data *hapd, struct sta_info *sta,
diff --git a/wpa_supplicant/mesh_mpm.c b/wpa_supplicant/mesh_mpm.c
index f81b88c89401..86b2bcb09377 100644
--- a/wpa_supplicant/mesh_mpm.c
+++ b/wpa_supplicant/mesh_mpm.c
@@ -258,7 +258,7 @@ static void mesh_mpm_send_plink_action(struct wpa_supplicant *wpa_s,
 
 		/* aid */
 		if (type == PLINK_CONFIRM)
-			wpabuf_put_le16(buf, sta->peer_lid);
+			wpabuf_put_le16(buf, sta->aid);
 
 		/* IE: supp + ext. supp rates */
 		pos = hostapd_eid_supp_rates(bss, supp_rates);
@@ -561,13 +561,19 @@ static struct sta_info * mesh_mpm_add_peer(struct wpa_supplicant *wpa_s,
 	update_ht_state(data, sta);
 #endif /* CONFIG_IEEE80211N */
 
+	if (hostapd_get_aid(data, sta) < 0) {
+		wpa_msg(wpa_s, MSG_ERROR, "No AIDs available");
+		ap_free_sta(data, sta);
+		return NULL;
+	}
+
 	/* insert into driver */
 	os_memset(&params, 0, sizeof(params));
 	params.supp_rates = sta->supported_rates;
 	params.supp_rates_len = sta->supported_rates_len;
 	params.addr = addr;
 	params.plink_state = sta->plink_state;
-	params.aid = sta->peer_lid;
+	params.aid = sta->aid;
 	params.listen_interval = 100;
 	params.ht_capabilities = sta->ht_capabilities;
 	params.flags |= WPA_STA_WMM;
-- 
2.1.4




More information about the Hostap mailing list