diff mbox series

[V2,2/7] multiple_bssid: add 2 new helper functions

Message ID 20200706125031.668258-3-john@phrozen.org
State Superseded
Headers show
Series multiple_bssid: add support | expand

Commit Message

John Crispin July 6, 2020, 12:50 p.m. UTC
Wehn dealing with multiple bssid support we need to have a means to get a
BSSs index and hostapd_data of the transmitting interface.

Signed-off-by: John Crispin <john@phrozen.org>
---
 src/ap/hostapd.c | 20 ++++++++++++++++++++
 src/ap/hostapd.h |  2 ++
 2 files changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index b37f49f9a..c442b82db 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -87,6 +87,26 @@  int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
 }
 
 
+int hostapd_get_bss_index(struct hostapd_data *hapd)
+{
+	size_t i;
+
+	for (i = 1; i < hapd->iface->num_bss; i++)
+		if (hapd->iface->bss[i] == hapd)
+			return i;
+	return 0;
+}
+
+
+struct hostapd_data * hostapd_get_primary_bss(struct hostapd_data *hapd)
+{
+	if (hapd->iconf->multiple_bssid)
+		return hapd->iface->bss[0];
+
+	return hapd;
+}
+
+
 void hostapd_reconfig_encryption(struct hostapd_data *hapd)
 {
 	if (hapd->wpa_auth)
diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
index b70d13fba..44d2c6068 100644
--- a/src/ap/hostapd.h
+++ b/src/ap/hostapd.h
@@ -595,6 +595,8 @@  struct hostapd_iface {
 int hostapd_for_each_interface(struct hapd_interfaces *interfaces,
 			       int (*cb)(struct hostapd_iface *iface,
 					 void *ctx), void *ctx);
+int hostapd_get_bss_index(struct hostapd_data *hapd);
+struct hostapd_data * hostapd_get_primary_bss(struct hostapd_data *hapd);
 int hostapd_reload_config(struct hostapd_iface *iface);
 void hostapd_reconfig_encryption(struct hostapd_data *hapd);
 struct hostapd_data *