]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Multi-AP: Add support for VLAN related information
authorManoj Sekar <quic_sekar@quicinc.com>
Mon, 26 Feb 2024 12:56:38 +0000 (18:26 +0530)
committerJouni Malinen <j@w1.fi>
Tue, 19 Mar 2024 17:20:51 +0000 (19:20 +0200)
Add support to fill "multi_ap_vlanid" info to the hostapd config file.
Add the Multi-AP Default 802.1Q Setting subelement into Multi-AP element
generating and parsing.

Signed-off-by: Manoj Sekar <quic_sekar@quicinc.com>
hostapd/config_file.c
hostapd/hostapd.conf
src/ap/ap_config.h
src/ap/ieee802_11.c
src/common/ieee802_11_common.c
src/common/ieee802_11_common.h
src/common/ieee802_11_defs.h

index 2f9c9286a65c6ad9563e808cedd386200985efca..e9f0c5ca2344524d5793554236a2b4d68bbff6a0 100644 (file)
@@ -4822,6 +4822,16 @@ static int hostapd_config_fill(struct hostapd_config *conf,
                        return -1;
                }
                bss->multi_ap_client_disallow = val;
+       } else if (os_strcmp(buf, "multi_ap_vlanid") == 0) {
+               int val = atoi(pos);
+
+               if (val < 0 || val > MAX_VLAN_ID) {
+                       wpa_printf(MSG_ERROR,
+                                  "Line %d: Invalid multi_ap_vlan_id '%s'",
+                                  line, buf);
+                       return -1;
+               }
+               bss->multi_ap_vlanid = val;
        } else if (os_strcmp(buf, "rssi_reject_assoc_rssi") == 0) {
                conf->rssi_reject_assoc_rssi = atoi(pos);
        } else if (os_strcmp(buf, "rssi_reject_assoc_timeout") == 0) {
index ca1989893146663237f20aeabdcde0d505e1299c..727a87770a86ecee000663f01ccdfcd9d8966393 100644 (file)
@@ -2578,6 +2578,10 @@ own_ip_addr=127.0.0.1
 # 2 = Profile-2 Backhaul STA association disallowed
 #multi_ap_client_disallow=0
 
+# Multi-AP VLAN ID
+# A valid non-zero VLAN ID will be used to update Default IEEE 802.1Q Setting
+#multi_ap_vlanid=0
+
 # WPS UPnP interface
 # If set, support for external Registrars is enabled.
 #upnp_iface=br0
index 3254bfd8cf06f5cf7150b5f51bc9fccf2bc417d0..754d553311d89ae642c04739d6c7f34a948452ff 100644 (file)
@@ -806,6 +806,8 @@ struct hostapd_bss_config {
        /* Multi-AP Profile-2 clients not allowed to connect */
 #define PROFILE2_CLIENT_ASSOC_DISALLOW BIT(1)
        unsigned int multi_ap_client_disallow;
+       /* Primary VLAN ID to use in Multi-AP */
+       int multi_ap_vlanid;
 
 #ifdef CONFIG_AIRTIME_POLICY
        unsigned int airtime_weight;
index dfc5a5c392118bd1206c282a1c28882bb3720f53..17f98f59d9a3dcb0d508d363cf33bff5bfe08866 100644 (file)
@@ -110,6 +110,7 @@ static u8 * hostapd_eid_multi_ap(struct hostapd_data *hapd, u8 *eid, size_t len)
                        MULTI_AP_PROFILE2_BACKHAUL_STA_DISALLOWED;
 
        multi_ap.profile = hapd->conf->multi_ap_profile;
+       multi_ap.vlanid = hapd->conf->multi_ap_vlanid;
 
        return eid + add_multi_ap_ie(eid, len, &multi_ap);
 }
index 560e48a38703a292812e00999865530096a68901..7c3a21fe5c893e781c5ef9ed70e4a2559e8d4130 100644 (file)
@@ -2576,6 +2576,7 @@ u16 check_multi_ap_ie(const u8 *multi_ap_ie, size_t multi_ap_len,
 {
        const struct element *elem;
        bool ext_present = false;
+       unsigned int vlan_id;
 
        os_memset(multi_ap, 0, sizeof(*multi_ap));
 
@@ -2613,6 +2614,27 @@ u16 check_multi_ap_ie(const u8 *multi_ap_ie, size_t multi_ap_len,
                                return WLAN_STATUS_ASSOC_DENIED_UNSPEC;
                        }
                        break;
+               case MULTI_AP_VLAN_SUB_ELEM_TYPE:
+                       if (multi_ap->profile < MULTI_AP_PROFILE_2) {
+                               wpa_printf(MSG_DEBUG,
+                                          "Multi-AP IE invalid profile to read VLAN IE");
+                               return WLAN_STATUS_INVALID_IE;
+                       }
+                       if (elen < 2) {
+                               wpa_printf(MSG_DEBUG,
+                                          "Multi-AP IE invalid Multi-AP VLAN subelement");
+                               return WLAN_STATUS_INVALID_IE;
+                       }
+
+                       vlan_id = WPA_GET_LE16(pos);
+                       if (vlan_id < 1 || vlan_id > 4094) {
+                               wpa_printf(MSG_INFO,
+                                          "Multi-AP IE invalid Multi-AP VLAN ID %d",
+                                          vlan_id);
+                               return WLAN_STATUS_INVALID_IE;
+                       }
+                       multi_ap->vlanid = vlan_id;
+                       break;
                default:
                        wpa_printf(MSG_DEBUG,
                                   "Ignore unknown subelement %u in Multi-AP IE",
@@ -2670,6 +2692,19 @@ size_t add_multi_ap_ie(u8 *buf, size_t len,
                *pos++ = multi_ap->profile;
        }
 
+       /* Add Multi-AP Default 802.1Q Setting subelement only for backhaul BSS
+        */
+       if (multi_ap->vlanid &&
+           multi_ap->profile >= MULTI_AP_PROFILE_2 &&
+           (multi_ap->capability & MULTI_AP_BACKHAUL_BSS)) {
+               if (buf + len - pos < 4)
+                       return 0;
+               *pos++ = MULTI_AP_VLAN_SUB_ELEM_TYPE;
+               *pos++ = 2;
+               WPA_PUT_LE16(pos, multi_ap->vlanid);
+               pos += 2;
+       }
+
        *len_ptr = pos - len_ptr - 1;
 
        return pos - buf;
index cd04666baa071ff033ed923ae11497781ec61db4..4eaeed505ede1cf43acb7eef02b92404cadaff4c 100644 (file)
@@ -33,6 +33,7 @@ struct mb_ies_info {
 struct multi_ap_params {
        u8 capability;
        u8 profile;
+       u16 vlanid;
 };
 
 /* Parsed Information Elements */
index b248a5cac0558a2f2eeb7e584a500d5fd718737e..5b39a61e10672eb4afc4e7d221b05c012744de17 100644 (file)
@@ -1448,6 +1448,7 @@ struct ieee80211_ampe_ie {
 
 #define MULTI_AP_SUB_ELEM_TYPE 0x06
 #define MULTI_AP_PROFILE_SUB_ELEM_TYPE 0x07
+#define MULTI_AP_VLAN_SUB_ELEM_TYPE 0x08
 
 #define MULTI_AP_PROFILE2_BACKHAUL_STA_DISALLOWED BIT(2)
 #define MULTI_AP_PROFILE1_BACKHAUL_STA_DISALLOWED BIT(3)