From 0f4a43047d0e9d2d3b0ea31e6420033ecffeddc9 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Wed, 3 Jun 2020 17:07:05 +0200 Subject: [PATCH 801/820] multiple_bssid: add 2 new helper functions 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 --- src/ap/hostapd.c | 20 ++++++++++++++++++++ src/ap/hostapd.h | 2 ++ 2 files changed, 22 insertions(+) Index: hostapd-2020-07-02-58b384f4/src/ap/hostapd.c =================================================================== --- hostapd-2020-07-02-58b384f4.orig/src/ap/hostapd.c +++ hostapd-2020-07-02-58b384f4/src/ap/hostapd.c @@ -87,6 +87,26 @@ int hostapd_for_each_interface(struct ha } +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) Index: hostapd-2020-07-02-58b384f4/src/ap/hostapd.h =================================================================== --- hostapd-2020-07-02-58b384f4.orig/src/ap/hostapd.h +++ hostapd-2020-07-02-58b384f4/src/ap/hostapd.h @@ -598,6 +598,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, int reconf); void hostapd_reconfig_encryption(struct hostapd_data *hapd); struct hostapd_data *