]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - wpa_supplicant/config_file.c
wpa_supplicant: Add HE override support
[thirdparty/hostap.git] / wpa_supplicant / config_file.c
index 5005aa9254265332035604001d9f287b97c7670d..a69c4cc6dbc1c005b686c272e6d6a6e88f7464e9 100644 (file)
@@ -213,8 +213,22 @@ static struct wpa_ssid * wpa_config_read_network(FILE *f, int *line, int id)
                        }
                }
 
-               if (wpa_config_set(ssid, pos, pos2, *line) < 0)
+               if (wpa_config_set(ssid, pos, pos2, *line) < 0) {
+#ifndef CONFIG_WEP
+                       if (os_strcmp(pos, "wep_key0") == 0 ||
+                           os_strcmp(pos, "wep_key1") == 0 ||
+                           os_strcmp(pos, "wep_key2") == 0 ||
+                           os_strcmp(pos, "wep_key3") == 0 ||
+                           os_strcmp(pos, "wep_tx_keyidx") == 0) {
+                               wpa_printf(MSG_ERROR,
+                                          "Line %d: unsupported WEP parameter",
+                                          *line);
+                               ssid->disabled = 1;
+                               continue;
+                       }
+#endif /* CONFIG_WEP */
                        errors++;
+               }
        }
 
        if (!end) {
@@ -296,7 +310,7 @@ static struct wpa_config_blob * wpa_config_read_blob(FILE *f, int *line,
 {
        struct wpa_config_blob *blob;
        char buf[256], *pos;
-       unsigned char *encoded = NULL, *nencoded;
+       char *encoded = NULL, *nencoded;
        int end = 0;
        size_t encoded_len = 0, len;
 
@@ -653,6 +667,7 @@ static void write_eap(FILE *f, struct wpa_ssid *ssid)
 #endif /* IEEE8021X_EAPOL */
 
 
+#ifdef CONFIG_WEP
 static void write_wep_key(FILE *f, int idx, struct wpa_ssid *ssid)
 {
        char field[20], *value;
@@ -667,6 +682,7 @@ static void write_wep_key(FILE *f, int idx, struct wpa_ssid *ssid)
                os_free(value);
        }
 }
+#endif /* CONFIG_WEP */
 
 
 #ifdef CONFIG_P2P
@@ -741,8 +757,6 @@ static void write_mka_ckn(FILE *f, struct wpa_ssid *ssid)
 
 static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
 {
-       int i;
-
 #define STR(t) write_str(f, #t, ssid)
 #define INT(t) write_int(f, #t, ssid->t, 0)
 #define INTe(t, m) write_int(f, #t, ssid->eap.m, 0)
@@ -831,9 +845,15 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
        STR(openssl_ciphers);
        INTe(erp, erp);
 #endif /* IEEE8021X_EAPOL */
-       for (i = 0; i < 4; i++)
-               write_wep_key(f, i, ssid);
-       INT(wep_tx_keyidx);
+#ifdef CONFIG_WEP
+       {
+               int i;
+
+               for (i = 0; i < 4; i++)
+                       write_wep_key(f, i, ssid);
+               INT(wep_tx_keyidx);
+       }
+#endif /* CONFIG_WEP */
        INT(priority);
 #ifdef IEEE8021X_EAPOL
        INT_DEF(eap_workaround, DEFAULT_EAP_WORKAROUND);
@@ -847,6 +867,8 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
        INT(mode);
        INT(no_auto_peer);
        INT(frequency);
+       INT(enable_edmg);
+       INT(edmg_channel);
        INT(fixed_freq);
 #ifdef CONFIG_ACS
        INT(acs);
@@ -898,6 +920,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
        INT_DEF(mesh_rssi_threshold, DEFAULT_MESH_RSSI_THRESHOLD);
 #endif /* CONFIG_MESH */
        INT(wpa_ptk_rekey);
+       INT(wpa_deny_ptk0_rekey);
        INT(group_rekey);
        INT(ignore_broadcast_ssid);
 #ifdef CONFIG_DPP
@@ -905,11 +928,15 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
        STR(dpp_netaccesskey);
        INT(dpp_netaccesskey_expiry);
        STR(dpp_csign);
+       INT(dpp_pfs);
 #endif /* CONFIG_DPP */
        INT(owe_group);
        INT(owe_only);
+       INT(owe_ptk_workaround);
        INT(multi_ap_backhaul_sta);
        INT(ft_eap_pmksa_caching);
+       INT(beacon_prot);
+       INT(transition_disable);
 #ifdef CONFIG_HT_OVERRIDES
        INT_DEF(disable_ht, DEFAULT_DISABLE_HT);
        INT_DEF(disable_ht40, DEFAULT_DISABLE_HT40);
@@ -944,6 +971,9 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
        INT_DEF(vht_tx_mcs_nss_7, -1);
        INT_DEF(vht_tx_mcs_nss_8, -1);
 #endif /* CONFIG_VHT_OVERRIDES */
+#ifdef CONFIG_HE_OVERRIDES
+       INT(disable_he);
+#endif /* CONFIG_HE_OVERRIDES */
 
 #undef STR
 #undef INT
@@ -1096,7 +1126,7 @@ static void wpa_config_write_cred(FILE *f, struct wpa_cred *cred)
 #ifndef CONFIG_NO_CONFIG_BLOBS
 static int wpa_config_write_blob(FILE *f, struct wpa_config_blob *blob)
 {
-       unsigned char *encoded;
+       char *encoded;
 
        encoded = base64_encode(blob->data, blob->len, NULL);
        if (encoded == NULL)
@@ -1285,6 +1315,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
                fprintf(f, "p2p_go_vht=%d\n", config->p2p_go_vht);
        if (config->p2p_go_he)
                fprintf(f, "p2p_go_he=%d\n", config->p2p_go_he);
+       if (config->p2p_go_edmg)
+               fprintf(f, "p2p_go_edmg=%d\n", config->p2p_go_edmg);
        if (config->p2p_go_ctwindow != DEFAULT_P2P_GO_CTWINDOW)
                fprintf(f, "p2p_go_ctwindow=%d\n", config->p2p_go_ctwindow);
        if (config->p2p_disabled)
@@ -1405,6 +1437,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
                fprintf(f, "\n");
        }
 
+       if (config->sae_pwe)
+               fprintf(f, "sae_pwe=%d\n", config->sae_pwe);
+
        if (config->sae_pmkid_in_assoc)
                fprintf(f, "sae_pmkid_in_assoc=%d\n",
                        config->sae_pmkid_in_assoc);
@@ -1566,6 +1601,9 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
                        config->p2p_interface_random_mac_addr);
        if (config->disable_btm)
                fprintf(f, "disable_btm=1\n");
+       if (config->extended_key_id != DEFAULT_EXTENDED_KEY_ID)
+               fprintf(f, "extended_key_id=%d\n",
+                       config->extended_key_id);
 }
 
 #endif /* CONFIG_NO_CONFIG_WRITE */
@@ -1582,9 +1620,16 @@ int wpa_config_write(const char *name, struct wpa_config *config)
 #endif /* CONFIG_NO_CONFIG_BLOBS */
        int ret = 0;
        const char *orig_name = name;
-       int tmp_len = os_strlen(name) + 5; /* allow space for .tmp suffix */
-       char *tmp_name = os_malloc(tmp_len);
+       int tmp_len;
+       char *tmp_name;
+
+       if (!name) {
+               wpa_printf(MSG_ERROR, "No configuration file for writing");
+               return -1;
+       }
 
+       tmp_len = os_strlen(name) + 5; /* allow space for .tmp suffix */
+       tmp_name = os_malloc(tmp_len);
        if (tmp_name) {
                os_snprintf(tmp_name, tmp_len, "%s.tmp", name);
                name = tmp_name;
@@ -1612,8 +1657,11 @@ int wpa_config_write(const char *name, struct wpa_config *config)
        for (ssid = config->ssid; ssid; ssid = ssid->next) {
                if (ssid->key_mgmt == WPA_KEY_MGMT_WPS || ssid->temporary)
                        continue; /* do not save temporary networks */
-               if (wpa_key_mgmt_wpa_psk(ssid->key_mgmt) && !ssid->psk_set &&
-                   !ssid->passphrase)
+               if (wpa_key_mgmt_wpa_psk_no_sae(ssid->key_mgmt) &&
+                   !ssid->psk_set && !ssid->passphrase)
+                       continue; /* do not save invalid network */
+               if (wpa_key_mgmt_sae(ssid->key_mgmt) &&
+                   !ssid->passphrase && !ssid->sae_password)
                        continue; /* do not save invalid network */
                fprintf(f, "\nnetwork={\n");
                wpa_config_write_network(f, ssid);