[PATCH 3/6] Intel Lantiq add support for get and free AID using vendor command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The nl80211_get_aid is used to receive a new AID from the kernel
driver, which may in turn ask it from the FW, and that from the HW.
This AID is tied to SID and will need to be freed eventually.

This nl80211_free_aid is used to release an AID back to the kernel
driver, which may release it to the FW, and that to the HW.

Signed-off-by: Sarada Prasanna Garnayak <sarada.prasanna.garnayak@xxxxxxxxx>
---
 src/common/intel-ltq-vendor.h | 102 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

diff --git a/src/common/intel-ltq-vendor.h b/src/common/intel-ltq-vendor.h
index 6e9febe97..7b1b39398 100644
--- a/src/common/intel-ltq-vendor.h
+++ b/src/common/intel-ltq-vendor.h
@@ -21,6 +21,12 @@
 #ifndef INTEL_LTQ_VENDOR_H
 #define INTEL_LTQ_VENDOR_H
 
+#include "ap/hostapd.h"
+#include "ap/ap_drv_ops.h"
+#include "l2_packet/l2_packet.h"
+#include "drivers/driver_nl80211.h"
+#include "ap/sta_info.h"
+
 /**
  * This file is a registry of identifier assignments from
  * the Intel Lantiq OUI AC:9A:96 for purposes other than MAC address
@@ -68,4 +74,100 @@ enum intel_ltq_nl80211_vendor_events {
 	INTEL_LTQ_NL80211_VENDOR_EVENT_RX_EAPOL = 0,
 };
 
+#ifdef CONFIG_DRIVER_NL80211_INTEL_LTQ
+static inline void ap_sta_remove_in_other_bss_now(struct hostapd_data *hapd,
+						  const u8 *addr)
+{
+	struct hostapd_iface *iface = hapd->iface;
+	size_t i;
+
+	for (i = 0; i < iface->num_bss; i++) {
+		struct hostapd_data *bss = iface->bss[i];
+		struct sta_info *sta2;
+		/* BSS should always be set during operation, but it may be
+		 * NULL during reconfiguration. Assume the STA is not
+		 * associated to another BSS in that case to avoid NULL pointer
+		 * dereferences. */
+		if (bss == hapd || bss == NULL)
+			continue;
+
+		sta2 = ap_get_sta(bss, addr);
+		if (!sta2)
+			continue;
+
+		wpa_printf(MSG_DEBUG, "Removing station " MACSTR
+			   " with AID=%d from kernel driver.",
+			   MAC2STR(sta2->addr), sta2->aid);
+		ap_free_sta(bss, sta2);
+	}
+}
+
+static inline int nl80211_get_aid(void *priv, u16 *aid, const u8 *addr)
+{
+	int res = 0;
+	struct wpabuf *rsp_aid;
+	int aid_size = sizeof(u16);
+	struct i802_bss *bss = priv;
+	struct hostapd_data *hapd = bss->drv->ctx;
+
+	ap_sta_remove_in_other_bss_now(hapd, addr);
+	if (*aid > 0) {
+		wpa_printf(MSG_DEBUG, "Reusing old AID %hu", *aid);
+		return 0;
+	}
+
+	if (!bss->drv->get_aid_vendor_cmd_avail)
+		goto vendor_cmd_not_support;
+
+	rsp_aid = wpabuf_alloc(8); /* aid_size + NLA_HDRLEN + NLA_ALLIGN */
+	if (!rsp_aid) {
+		return -ENOBUFS;
+	}
+
+	res = nl80211_vendor_cmd(priv, OUI_INTEL_LTQ,
+				 INTEL_LTQ_NL80211_VENDOR_SUBCMD_GET_AID,
+				 addr, ETH_ALEN, (struct wpabuf *) rsp_aid);
+	if (res) {
+		wpa_printf(MSG_ERROR,
+			   "nl80211: sending/receiving GET_AID failed: %i "
+			   "(%s)", res, strerror(-res));
+		*aid = 0;
+	} else {
+		memcpy(aid, rsp_aid->buf, aid_size);
+		wpa_printf(MSG_DEBUG, "Received a new AID %hu", *aid);
+	}
+
+	return res;
+
+vendor_cmd_not_support:
+	*aid = 0;
+	return -EINVAL;
+}
+
+static inline int nl80211_free_aid(void *priv, u16 *aid)
+{
+	int res = 0;
+	struct i802_bss *bss = priv;
+	struct wpa_driver_nl80211_data *drv = bss->drv;
+
+	if (!(*aid))
+		return 0;
+
+	if (!drv->free_aid_vendor_cmd_avail)
+		return -EINVAL;
+
+	res = nl80211_vendor_cmd(priv, OUI_INTEL_LTQ,
+				 INTEL_LTQ_NL80211_VENDOR_SUBCMD_FREE_AID,
+				 (u8*) aid, sizeof(*aid), NULL);
+	if (res) {
+		wpa_printf(MSG_ERROR, "nl80211: sending FREE_AID failed: %i "
+				   "(%s)", res, strerror(-res));
+	} else {
+		wpa_printf(MSG_DEBUG, "AID %hu released", *aid);
+		*aid = 0;
+	}
+
+	return res;
+}
+#endif /* CONFIG_DRIVER_NL80211_INTEL_LTQ */
 #endif /* INTEL_LTQ_VENDOR_H */
-- 
2.11.0


_______________________________________________
Hostap mailing list
Hostap@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/hostap



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux