[PATCH V2 3/7] multiple_bssid: add support for non/transmitting mode

John Crispin john at phrozen.org
Mon Jul 6 08:50:27 EDT 2020


When starting the non-transmitting BSSs we need to let if_add() known what
the bss_index and bss_parent are.

Signed-off-by: John Crispin <john at phrozen.org>
---
 src/ap/ap_drv_ops.c       |  8 +++++---
 src/ap/ap_drv_ops.h       |  3 ++-
 src/ap/beacon.c           |  4 ++++
 src/ap/hostapd.c          |  9 ++++++++-
 src/common/defs.h         |  7 +++++++
 src/drivers/driver.h      | 10 +++++++++-
 wpa_supplicant/driver_i.h |  2 +-
 7 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
index f15765945..3a46b5745 100644
--- a/src/ap/ap_drv_ops.c
+++ b/src/ap/ap_drv_ops.c
@@ -321,7 +321,7 @@ int hostapd_vlan_if_add(struct hostapd_data *hapd, const char *ifname)
 	char force_ifname[IFNAMSIZ];
 	u8 if_addr[ETH_ALEN];
 	return hostapd_if_add(hapd, WPA_IF_AP_VLAN, ifname, hapd->own_addr,
-			      NULL, NULL, force_ifname, if_addr, NULL, 0);
+			      NULL, NULL, force_ifname, if_addr, NULL, 0, 0, NULL);
 }
 
 
@@ -497,13 +497,15 @@ int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len)
 int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
 		   const char *ifname, const u8 *addr, void *bss_ctx,
 		   void **drv_priv, char *force_ifname, u8 *if_addr,
-		   const char *bridge, int use_existing)
+		   const char *bridge, int use_existing,
+		   int multi_bssid_mode, const char *multi_bssid_parent)
 {
 	if (hapd->driver == NULL || hapd->driver->if_add == NULL)
 		return -1;
 	return hapd->driver->if_add(hapd->drv_priv, type, ifname, addr,
 				    bss_ctx, drv_priv, force_ifname, if_addr,
-				    bridge, use_existing, 1);
+				    bridge, use_existing, 1,
+				    multi_bssid_mode, multi_bssid_parent);
 }
 
 
diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h
index 5738c1c97..651b77e9a 100644
--- a/src/ap/ap_drv_ops.h
+++ b/src/ap/ap_drv_ops.h
@@ -54,7 +54,8 @@ int hostapd_set_ssid(struct hostapd_data *hapd, const u8 *buf, size_t len);
 int hostapd_if_add(struct hostapd_data *hapd, enum wpa_driver_if_type type,
 		   const char *ifname, const u8 *addr, void *bss_ctx,
 		   void **drv_priv, char *force_ifname, u8 *if_addr,
-		   const char *bridge, int use_existing);
+		   const char *bridge, int use_existin,
+		   int multi_bssid_mode, const char *multi_bssid_parent);
 int hostapd_if_remove(struct hostapd_data *hapd, enum wpa_driver_if_type type,
 		      const char *ifname);
 int hostapd_set_ieee8021x(struct hostapd_data *hapd,
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index b3b33b7fa..4988ee2a1 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -1506,6 +1506,10 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
 	params.twt_responder = hostapd_get_he_twt_responder(hapd,
 							    IEEE80211_MODE_AP);
 #endif /* CONFIG_IEEE80211AX */
+        if (hapd->iconf->multiple_bssid) {
+		params.multiple_bssid_index = hostapd_get_bss_index(hapd);
+		params.multiple_bssid_count = iface->num_bss;
+	}
 	hapd->reenable_beacon = 0;
 
 	if (cmode &&
diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index c442b82db..26e62d991 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -1149,6 +1149,13 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
 
 	if (!first || first == -1) {
 		u8 *addr = hapd->own_addr;
+		int multiple_bssid_mode = HOSTAPD_BSSID_LEGACY;
+		const char *multiple_bssid_parent = NULL;
+
+		if (hapd->iconf->multiple_bssid) {
+			multiple_bssid_mode = HOSTAPD_BSSID_NON_TRANSMITTED;
+			multiple_bssid_parent = hapd->iface->bss[0]->conf->iface;
+		}
 
 		if (!is_zero_ether_addr(conf->bssid)) {
 			/* Allocate the configured BSSID. */
@@ -1176,7 +1183,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
 				   conf->iface, addr, hapd,
 				   &hapd->drv_priv, force_ifname, if_addr,
 				   conf->bridge[0] ? conf->bridge : NULL,
-				   first == -1)) {
+				   first == -1, multiple_bssid_mode, multiple_bssid_parent)) {
 			wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
 				   MACSTR ")", MAC2STR(hapd->own_addr));
 			hapd->interface_added = 0;
diff --git a/src/common/defs.h b/src/common/defs.h
index bbe3120de..ef6f518d2 100644
--- a/src/common/defs.h
+++ b/src/common/defs.h
@@ -471,4 +471,11 @@ enum ptk0_rekey_handling {
 	PTK0_REKEY_ALLOW_NEVER
 };
 
+
+enum hostapd_multi_bssid_mode {
+	HOSTAPD_BSSID_LEGACY = 0,
+	HOSTAPD_BSSID_TRANSMITTED,
+	HOSTAPD_BSSID_NON_TRANSMITTED,
+};
+
 #endif /* DEFS_H */
diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index cb412cbfe..cfeb94781 100644
--- a/src/drivers/driver.h
+++ b/src/drivers/driver.h
@@ -1508,6 +1508,13 @@ struct wpa_driver_ap_params {
 	 * twt_responder - Whether Target Wait Time responder is enabled
 	 */
 	int twt_responder;
+
+	/**
+	 * multiple_bssid_mode - The multi bssid mode
+	 */
+	 int multiple_bssid_mode;
+	 unsigned int multiple_bssid_index;
+	 unsigned int multiple_bssid_count;
 };
 
 struct wpa_driver_mesh_bss_params {
@@ -3244,7 +3251,8 @@ struct wpa_driver_ops {
 	int (*if_add)(void *priv, enum wpa_driver_if_type type,
 		      const char *ifname, const u8 *addr, void *bss_ctx,
 		      void **drv_priv, char *force_ifname, u8 *if_addr,
-		      const char *bridge, int use_existing, int setup_ap);
+		      const char *bridge, int use_existing, int setup_ap,
+		      int multi_bssid_mode, const char *multi_bssid_parent);
 
 	/**
 	 * if_remove - Remove a virtual interface
diff --git a/wpa_supplicant/driver_i.h b/wpa_supplicant/driver_i.h
index 54ae03b5a..85af3c971 100644
--- a/wpa_supplicant/driver_i.h
+++ b/wpa_supplicant/driver_i.h
@@ -444,7 +444,7 @@ static inline int wpa_drv_if_add(struct wpa_supplicant *wpa_s,
 	if (wpa_s->driver->if_add)
 		return wpa_s->driver->if_add(wpa_s->drv_priv, type, ifname,
 					     addr, bss_ctx, NULL, force_ifname,
-					     if_addr, bridge, 0, 0);
+					     if_addr, bridge, 0, 0, 0, NULL);
 	return -1;
 }
 
-- 
2.25.1




More information about the Hostap mailing list