]> 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 07310f93c33b52e6fc781fb83bb793e7a21d4eab..eecd215af278a3072d03427dd7d4cb74eedc1c48 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "utils/common.h"
 #include "crypto/sha1.h"
+#include "crypto/tls.h"
 #include "radius/radius_client.h"
 #include "common/ieee802_11_defs.h"
 #include "common/eapol_common.h"
@@ -18,6 +19,7 @@
 #include "eap_server/eap.h"
 #include "wpa_auth.h"
 #include "sta_info.h"
+#include "airtime_policy.h"
 #include "ap_config.h"
 
 
@@ -103,11 +105,13 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
        bss->rkh_neg_timeout = 60;
        bss->rkh_pull_timeout = 1000;
        bss->rkh_pull_retries = 4;
+       bss->r0_key_lifetime = 1209600;
 #endif /* CONFIG_IEEE80211R_AP */
 
        bss->radius_das_time_window = 300;
 
        bss->sae_anti_clogging_threshold = 5;
+       bss->sae_sync = 5;
 
        bss->gas_frag_limit = 1400;
 
@@ -123,6 +127,20 @@ void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
 #ifdef CONFIG_MBO
        bss->mbo_cell_data_conn_pref = -1;
 #endif /* CONFIG_MBO */
+
+       /* Disable TLS v1.3 by default for now to avoid interoperability issue.
+        * 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;
 }
 
 
@@ -183,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;
 
@@ -220,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;
 }
 
@@ -240,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;
@@ -254,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] == '#')
@@ -269,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;
                }
@@ -282,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);
@@ -314,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;
        }
@@ -407,6 +488,7 @@ void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
        hostapd_config_free_radius_attr(user->accept_attr);
        os_free(user->identity);
        bin_clear_free(user->password, user->password_len);
+       bin_clear_free(user->salt, user->salt_len);
        os_free(user);
 }
 
@@ -473,6 +555,36 @@ static void hostapd_config_free_fils_realms(struct hostapd_bss_config *conf)
 }
 
 
+static void hostapd_config_free_sae_passwords(struct hostapd_bss_config *conf)
+{
+       struct sae_password_entry *pw, *tmp;
+
+       pw = conf->sae_passwords;
+       conf->sae_passwords = NULL;
+       while (pw) {
+               tmp = pw;
+               pw = pw->next;
+               str_clear_free(tmp->password);
+               os_free(tmp->identifier);
+               os_free(tmp);
+       }
+}
+
+
+#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)
@@ -509,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);
@@ -557,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);
@@ -576,6 +692,7 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
 
        os_free(conf->roaming_consortium);
        os_free(conf->venue_name);
+       os_free(conf->venue_url);
        os_free(conf->nai_realm_data);
        os_free(conf->network_auth_type);
        os_free(conf->anqp_3gpp_cell_net);
@@ -605,11 +722,22 @@ void hostapd_config_free_bss(struct hostapd_bss_config *conf)
                                os_free(p->icons[j]);
                        os_free(p->icons);
                        os_free(p->osu_nai);
+                       os_free(p->osu_nai2);
                        os_free(p->service_desc);
                }
                os_free(conf->hs20_osu_providers);
        }
+       if (conf->hs20_operator_icon) {
+               size_t i;
+
+               for (i = 0; i < conf->hs20_operator_icon_count; i++)
+                       os_free(conf->hs20_operator_icon[i]);
+               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 */
 
        wpabuf_free(conf->vendor_elements);
@@ -638,9 +766,26 @@ 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 */
 
-       os_free(conf->sae_password);
+       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);
 }
@@ -766,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",
@@ -788,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;
@@ -936,7 +1087,9 @@ static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
 
        if (full_config && bss->wps_state && bss->wpa &&
            (!(bss->wpa & 2) ||
-            !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)))) {
+            !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
+                                   WPA_CIPHER_CCMP_256 |
+                                   WPA_CIPHER_GCMP_256)))) {
                wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
                           "WPA2/CCMP/GCMP forced WPS to be disabled");
                bss->wps_state = 0;
@@ -965,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;
 }
 
@@ -1021,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;
@@ -1046,8 +1215,12 @@ void hostapd_set_security_params(struct hostapd_bss_config *bss,
 
        if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
                bss->rsn_pairwise = bss->wpa_pairwise;
-       bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
-                                                   bss->rsn_pairwise);
+       if (bss->group_cipher)
+               bss->wpa_group = bss->group_cipher;
+       else
+               bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa,
+                                                           bss->wpa_pairwise,
+                                                           bss->rsn_pairwise);
        if (!bss->wpa_group_rekey_set)
                bss->wpa_group_rekey = bss->wpa_group == WPA_CIPHER_TKIP ?
                        600 : 86400;
@@ -1104,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;
+}