]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - src/ap/ap_config.c
HE: Make the basic NSS/MCS configurable
[thirdparty/hostap.git] / src / ap / ap_config.c
index f9b6f295927f9ec77cd43833eaa340b8eb56d5b1..eecd215af278a3072d03427dd7d4cb74eedc1c48 100644 (file)
@@ -19,6 +19,7 @@
 #include "eap_server/eap.h"
 #include "wpa_auth.h"
 #include "sta_info.h"
+#include "airtime_policy.h"
 #include "ap_config.h"
 
 
@@ -131,6 +132,15 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
         * This can be enabled by default once the implementation has been fully
         * completed and tested with other implementations. */
        bss->tls_flags = TLS_CONN_DISABLE_TLSv1_3;
+
+       bss->send_probe_response = 1;
+
+#ifdef CONFIG_HS20
+       bss->hs20_release = (HS20_VERSION >> 4) + 1;
+#endif /* CONFIG_HS20 */
+
+       /* Default to strict CRL checking. */
+       bss->check_crl_strict = 1;
 }
 
 
@@ -191,9 +201,8 @@ struct hostapd_config * hostapd_config_defaults(void)
        conf->num_bss = 1;
 
        conf->beacon_int = 100;
-       conf->rts_threshold = -1; /* use driver default: 2347 */
-       conf->fragm_threshold = -1; /* user driver default: 2346 */
-       conf->send_probe_response = 1;
+       conf->rts_threshold = -2; /* use driver default: 2347 */
+       conf->fragm_threshold = -2; /* user driver default: 2346 */
        /* Set to invalid value means do not add Power Constraint IE */
        conf->local_pwr_constraint = -1;
 
@@ -228,11 +237,25 @@ struct hostapd_config * hostapd_config_defaults(void)
        conf->acs_num_scans = 5;
 #endif /* CONFIG_ACS */
 
+#ifdef CONFIG_IEEE80211AX
+       conf->he_op.he_rts_threshold = HE_OPERATION_RTS_THRESHOLD_MASK >>
+               HE_OPERATION_RTS_THRESHOLD_OFFSET;
+       /* Set default basic MCS/NSS set to single stream MCS 0-7 */
+       conf->he_op.he_basic_mcs_nss_set = 0xfffc;
+#endif /* CONFIG_IEEE80211AX */
+
        /* The third octet of the country string uses an ASCII space character
         * by default to indicate that the regulations encompass all
         * environments for the current frequency band in the country. */
        conf->country[2] = ' ';
 
+       conf->rssi_reject_assoc_rssi = 0;
+       conf->rssi_reject_assoc_timeout = 30;
+
+#ifdef CONFIG_AIRTIME_POLICY
+       conf->airtime_update_interval = AIRTIME_DEFAULT_UPDATE_INTERVAL;
+#endif /* CONFIG_AIRTIME_POLICY */
+
        return conf;
 }
 
@@ -248,6 +271,12 @@ static int hostapd_config_read_wpa_psk(const char *fname,
 {
        FILE *f;
        char buf[128], *pos;
+       const char *keyid;
+       char *context;
+       char *context2;
+       char *token;
+       char *name;
+       char *value;
        int line = 0, ret = 0, len, ok;
        u8 addr[ETH_ALEN];
        struct hostapd_wpa_psk *psk;
@@ -262,6 +291,8 @@ static int hostapd_config_read_wpa_psk(const char *fname,
        }
 
        while (fgets(buf, sizeof(buf), f)) {
+               int vlan_id = 0;
+
                line++;
 
                if (buf[0] == '#')
@@ -277,9 +308,39 @@ static int hostapd_config_read_wpa_psk(const char *fname,
                if (buf[0] == '\0')
                        continue;
 
-               if (hwaddr_aton(buf, addr)) {
+               context = NULL;
+               keyid = NULL;
+               while ((token = str_token(buf, " ", &context))) {
+                       if (!os_strchr(token, '='))
+                               break;
+                       context2 = NULL;
+                       name = str_token(token, "=", &context2);
+                       if (!name)
+                               break;
+                       value = str_token(token, "", &context2);
+                       if (!value)
+                               value = "";
+                       if (!os_strcmp(name, "keyid")) {
+                               keyid = value;
+                       } else if (!os_strcmp(name, "vlanid")) {
+                               vlan_id = atoi(value);
+                       } else {
+                               wpa_printf(MSG_ERROR,
+                                          "Unrecognized '%s=%s' on line %d in '%s'",
+                                          name, value, line, fname);
+                               ret = -1;
+                               break;
+                       }
+               }
+
+               if (ret == -1)
+                       break;
+
+               if (!token)
+                       token = "";
+               if (hwaddr_aton(token, addr)) {
                        wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on "
-                                  "line %d in '%s'", buf, line, fname);
+                                  "line %d in '%s'", token, line, fname);
                        ret = -1;
                        break;
                }
@@ -290,20 +351,20 @@ static int hostapd_config_read_wpa_psk(const char *fname,
                        ret = -1;
                        break;
                }
+               psk->vlan_id = vlan_id;
                if (is_zero_ether_addr(addr))
                        psk->group = 1;
                else
                        os_memcpy(psk->addr, addr, ETH_ALEN);
 
-               pos = buf + 17;
-               if (*pos == '\0') {
+               pos = str_token(buf, "", &context);
+               if (!pos) {
                        wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
                                   line, fname);
                        os_free(psk);
                        ret = -1;
                        break;
                }
-               pos++;
 
                ok = 0;
                len = os_strlen(pos);
@@ -322,6 +383,18 @@ static int hostapd_config_read_wpa_psk(const char *fname,
                        break;
                }
 
+               if (keyid) {
+                       len = os_strlcpy(psk->keyid, keyid, sizeof(psk->keyid));
+                       if ((size_t) len >= sizeof(psk->keyid)) {
+                               wpa_printf(MSG_ERROR,
+                                          "PSK keyid too long on line %d in '%s'",
+                                          line, fname);
+                               os_free(psk);
+                               ret = -1;
+                               break;
+                       }
+               }
+
                psk->next = ssid->wpa_psk;
                ssid->wpa_psk = psk;
        }
@@ -498,6 +571,20 @@ static void hostapd_config_free_sae_passwords(struct hostapd_bss_config *conf)
 }
 
 
+#ifdef CONFIG_DPP2
+static void hostapd_dpp_controller_conf_free(struct dpp_controller_conf *conf)
+{
+       struct dpp_controller_conf *prev;
+
+       while (conf) {
+               prev = conf;
+               conf = conf->next;
+               os_free(prev);
+       }
+}
+#endif /* CONFIG_DPP2 */
+
+
 void hostapd_config_free_bss(struct hostapd_bss_config *conf)
 {
        if (conf == NULL)
@@ -534,10 +621,12 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
        os_free(conf->server_cert);
        os_free(conf->private_key);
        os_free(conf->private_key_passwd);
+       os_free(conf->check_cert_subject);
        os_free(conf->ocsp_stapling_response);
        os_free(conf->ocsp_stapling_response_multi);
        os_free(conf->dh_file);
        os_free(conf->openssl_ciphers);
+       os_free(conf->openssl_ecdh_curves);
        os_free(conf->pac_opaque_encr_key);
        os_free(conf->eap_fast_a_id);
        os_free(conf->eap_fast_a_id_info);
@@ -582,6 +671,8 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
        os_free(conf->ap_pin);
        os_free(conf->extra_cred);
        os_free(conf->ap_settings);
+       hostapd_config_clear_wpa_psk(&conf->multi_ap_backhaul_ssid.wpa_psk);
+       str_clear_free(conf->multi_ap_backhaul_ssid.wpa_passphrase);
        os_free(conf->upnp_iface);
        os_free(conf->friendly_name);
        os_free(conf->manufacturer_url);
@@ -644,6 +735,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
                os_free(conf->hs20_operator_icon);
        }
        os_free(conf->subscr_remediation_url);
+       os_free(conf->hs20_sim_provisioning_url);
        os_free(conf->t_c_filename);
        os_free(conf->t_c_server_url);
 #endif /* CONFIG_HS20 */
@@ -674,10 +766,27 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
        os_free(conf->dpp_connector);
        wpabuf_free(conf->dpp_netaccesskey);
        wpabuf_free(conf->dpp_csign);
+#ifdef CONFIG_DPP2
+       hostapd_dpp_controller_conf_free(conf->dpp_controller);
+#endif /* CONFIG_DPP2 */
 #endif /* CONFIG_DPP */
 
        hostapd_config_free_sae_passwords(conf);
 
+#ifdef CONFIG_AIRTIME_POLICY
+       {
+               struct airtime_sta_weight *wt, *wt_prev;
+
+               wt = conf->airtime_weight_list;
+               conf->airtime_weight_list = NULL;
+               while (wt) {
+                       wt_prev = wt;
+                       wt = wt->next;
+                       os_free(wt_prev);
+               }
+       }
+#endif /* CONFIG_AIRTIME_POLICY */
+
        os_free(conf);
 }
 
@@ -802,11 +911,14 @@ const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
 
 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
                           const u8 *addr, const u8 *p2p_dev_addr,
-                          const u8 *prev_psk)
+                          const u8 *prev_psk, int *vlan_id)
 {
        struct hostapd_wpa_psk *psk;
        int next_ok = prev_psk == NULL;
 
+       if (vlan_id)
+               *vlan_id = 0;
+
        if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) {
                wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
                           " p2p_dev_addr=" MACSTR " prev_psk=%p",
@@ -824,8 +936,11 @@ const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
                     (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) ||
                     (!addr && p2p_dev_addr &&
                      os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) ==
-                     0)))
+                     0))) {
+                       if (vlan_id)
+                               *vlan_id = psk->vlan_id;
                        return psk->psk;
+               }
 
                if (psk->psk == prev_psk)
                        next_ok = 1;
@@ -1003,6 +1118,15 @@ static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
        }
 #endif /* CONFIG_MBO */
 
+#ifdef CONFIG_OCV
+       if (full_config && bss->ieee80211w == NO_MGMT_FRAME_PROTECTION &&
+           bss->ocv) {
+               wpa_printf(MSG_ERROR,
+                          "OCV: PMF needs to be enabled whenever using OCV");
+               return -1;
+       }
+#endif /* CONFIG_OCV */
+
        return 0;
 }
 
@@ -1059,6 +1183,13 @@ int hostapd_config_check(struct hostapd_config *conf, int full_config)
                return -1;
        }
 
+#ifdef CONFIG_AIRTIME_POLICY
+       if (full_config && conf->airtime_mode > AIRTIME_MODE_STATIC &&
+           !conf->airtime_update_interval) {
+               wpa_printf(MSG_ERROR, "Airtime update interval cannot be zero");
+               return -1;
+       }
+#endif /* CONFIG_AIRTIME_POLICY */
        for (i = 0; i < NUM_TX_QUEUES; i++) {
                if (hostapd_config_check_cw(conf, i))
                        return -1;
@@ -1146,3 +1277,26 @@ void hostapd_set_security_params(struct hostapd_bss_config *bss,
                }
        }
 }
+
+
+int hostapd_sae_pw_id_in_use(struct hostapd_bss_config *conf)
+{
+       int with_id = 0, without_id = 0;
+       struct sae_password_entry *pw;
+
+       if (conf->ssid.wpa_passphrase)
+               without_id = 1;
+
+       for (pw = conf->sae_passwords; pw; pw = pw->next) {
+               if (pw->identifier)
+                       with_id = 1;
+               else
+                       without_id = 1;
+               if (with_id && without_id)
+                       break;
+       }
+
+       if (with_id && !without_id)
+               return 2;
+       return with_id;
+}