2008-02-28 02:34:43 +01:00
|
|
|
/*
|
2009-12-24 20:05:40 +01:00
|
|
|
* hostapd / Configuration helper functions
|
2014-01-07 19:14:53 +01:00
|
|
|
* Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi>
|
2008-02-28 02:34:43 +01:00
|
|
|
*
|
2012-02-11 15:46:35 +01:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2008-02-28 02:34:43 +01:00
|
|
|
*/
|
|
|
|
|
2009-12-25 23:05:40 +01:00
|
|
|
#include "utils/includes.h"
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-12-25 23:05:40 +01:00
|
|
|
#include "utils/common.h"
|
2009-11-29 22:04:43 +01:00
|
|
|
#include "crypto/sha1.h"
|
2018-05-01 21:12:37 +02:00
|
|
|
#include "crypto/tls.h"
|
2008-02-28 02:34:43 +01:00
|
|
|
#include "radius/radius_client.h"
|
2009-11-29 20:07:52 +01:00
|
|
|
#include "common/ieee802_11_defs.h"
|
2019-05-24 09:26:46 +02:00
|
|
|
#include "common/ieee802_1x_defs.h"
|
2009-12-24 20:05:40 +01:00
|
|
|
#include "common/eapol_common.h"
|
2017-01-31 13:38:44 +01:00
|
|
|
#include "common/dhcp.h"
|
2019-09-06 14:51:37 +02:00
|
|
|
#include "common/sae.h"
|
2009-11-29 22:04:43 +01:00
|
|
|
#include "eap_common/eap_wsc_common.h"
|
|
|
|
#include "eap_server/eap.h"
|
2009-12-25 23:05:40 +01:00
|
|
|
#include "wpa_auth.h"
|
2009-03-25 15:13:35 +01:00
|
|
|
#include "sta_info.h"
|
2019-03-20 15:58:52 +01:00
|
|
|
#include "airtime_policy.h"
|
2009-12-25 23:05:40 +01:00
|
|
|
#include "ap_config.h"
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
static void hostapd_config_free_vlan(struct hostapd_bss_config *bss)
|
|
|
|
{
|
|
|
|
struct hostapd_vlan *vlan, *prev;
|
|
|
|
|
|
|
|
vlan = bss->vlan;
|
|
|
|
prev = NULL;
|
|
|
|
while (vlan) {
|
|
|
|
prev = vlan;
|
|
|
|
vlan = vlan->next;
|
|
|
|
os_free(prev);
|
|
|
|
}
|
|
|
|
|
|
|
|
bss->vlan = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-10-16 17:37:43 +02:00
|
|
|
#ifndef DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES
|
|
|
|
#define DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES 0
|
|
|
|
#endif /* DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES */
|
|
|
|
|
2009-12-24 20:05:40 +01:00
|
|
|
void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2015-10-07 15:14:09 +02:00
|
|
|
dl_list_init(&bss->anqp_elem);
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
bss->logger_syslog_level = HOSTAPD_LEVEL_INFO;
|
|
|
|
bss->logger_stdout_level = HOSTAPD_LEVEL_INFO;
|
|
|
|
bss->logger_syslog = (unsigned int) -1;
|
|
|
|
bss->logger_stdout = (unsigned int) -1;
|
|
|
|
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2008-02-28 02:34:43 +01:00
|
|
|
bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED;
|
|
|
|
|
|
|
|
bss->wep_rekeying_period = 300;
|
|
|
|
/* use key0 in individual key and key1 in broadcast key */
|
|
|
|
bss->broadcast_key_idx_min = 1;
|
|
|
|
bss->broadcast_key_idx_max = 2;
|
2020-02-29 15:52:39 +01:00
|
|
|
#else /* CONFIG_WEP */
|
|
|
|
bss->auth_algs = WPA_AUTH_ALG_OPEN;
|
|
|
|
#endif /* CONFIG_WEP */
|
2008-02-28 02:34:43 +01:00
|
|
|
bss->eap_reauth_period = 3600;
|
|
|
|
|
|
|
|
bss->wpa_group_rekey = 600;
|
|
|
|
bss->wpa_gmk_rekey = 86400;
|
2020-01-10 23:19:08 +01:00
|
|
|
bss->wpa_deny_ptk0_rekey = PTK0_REKEY_ALLOW_ALWAYS;
|
2017-01-05 17:00:33 +01:00
|
|
|
bss->wpa_group_update_count = 4;
|
|
|
|
bss->wpa_pairwise_update_count = 4;
|
2017-10-16 17:37:43 +02:00
|
|
|
bss->wpa_disable_eapol_key_retries =
|
|
|
|
DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES;
|
2008-02-28 02:34:43 +01:00
|
|
|
bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
|
|
|
|
bss->wpa_pairwise = WPA_CIPHER_TKIP;
|
|
|
|
bss->wpa_group = WPA_CIPHER_TKIP;
|
|
|
|
bss->rsn_pairwise = 0;
|
|
|
|
|
|
|
|
bss->max_num_sta = MAX_STA_COUNT;
|
|
|
|
|
|
|
|
bss->dtim_period = 2;
|
|
|
|
|
|
|
|
bss->radius_server_auth_port = 1812;
|
2015-06-10 13:15:24 +02:00
|
|
|
bss->eap_sim_db_timeout = 1;
|
2019-07-31 23:02:02 +02:00
|
|
|
bss->eap_sim_id = 3;
|
2008-02-28 02:34:43 +01:00
|
|
|
bss->ap_max_inactivity = AP_MAX_INACTIVITY;
|
|
|
|
bss->eapol_version = EAPOL_VERSION;
|
2008-02-28 02:54:06 +01:00
|
|
|
|
|
|
|
bss->max_listen_interval = 65535;
|
2008-08-31 10:04:47 +02:00
|
|
|
|
2010-09-15 09:51:40 +02:00
|
|
|
bss->pwd_group = 19; /* ECC: GF(p=256) */
|
|
|
|
|
2008-12-26 11:30:34 +01:00
|
|
|
bss->assoc_sa_query_max_timeout = 1000;
|
|
|
|
bss->assoc_sa_query_retry_timeout = 201;
|
2014-03-12 19:26:37 +01:00
|
|
|
bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC;
|
2009-03-25 11:06:19 +01:00
|
|
|
#ifdef EAP_SERVER_FAST
|
2008-10-08 15:55:23 +02:00
|
|
|
/* both anonymous and authenticated provisioning */
|
|
|
|
bss->eap_fast_prov = 3;
|
2008-10-08 16:25:47 +02:00
|
|
|
bss->pac_key_lifetime = 7 * 24 * 60 * 60;
|
|
|
|
bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
|
2009-03-25 11:06:19 +01:00
|
|
|
#endif /* EAP_SERVER_FAST */
|
2011-02-01 13:34:12 +01:00
|
|
|
|
|
|
|
/* Set to -1 as defaults depends on HT in setup */
|
|
|
|
bss->wmm_enabled = -1;
|
2010-10-25 12:35:51 +02:00
|
|
|
|
2016-10-27 14:18:32 +02:00
|
|
|
#ifdef CONFIG_IEEE80211R_AP
|
2010-10-25 12:35:51 +02:00
|
|
|
bss->ft_over_ds = 1;
|
2017-04-02 14:52:52 +02:00
|
|
|
bss->rkh_pos_timeout = 86400;
|
|
|
|
bss->rkh_neg_timeout = 60;
|
|
|
|
bss->rkh_pull_timeout = 1000;
|
|
|
|
bss->rkh_pull_retries = 4;
|
2017-05-18 15:21:50 +02:00
|
|
|
bss->r0_key_lifetime = 1209600;
|
2016-10-27 14:18:32 +02:00
|
|
|
#endif /* CONFIG_IEEE80211R_AP */
|
2012-06-17 16:43:36 +02:00
|
|
|
|
|
|
|
bss->radius_das_time_window = 300;
|
2012-12-31 15:58:36 +01:00
|
|
|
|
|
|
|
bss->sae_anti_clogging_threshold = 5;
|
2017-12-26 11:46:22 +01:00
|
|
|
bss->sae_sync = 5;
|
2016-12-17 16:19:34 +01:00
|
|
|
|
2016-12-29 23:23:10 +01:00
|
|
|
bss->gas_frag_limit = 1400;
|
|
|
|
|
2016-12-17 16:19:34 +01:00
|
|
|
#ifdef CONFIG_FILS
|
|
|
|
dl_list_init(&bss->fils_realms);
|
2017-01-31 13:38:44 +01:00
|
|
|
bss->fils_hlp_wait_time = 30;
|
|
|
|
bss->dhcp_server_port = DHCP_SERVER_PORT;
|
|
|
|
bss->dhcp_relay_port = DHCP_SERVER_PORT;
|
2016-12-17 16:19:34 +01:00
|
|
|
#endif /* CONFIG_FILS */
|
2017-02-22 23:03:00 +01:00
|
|
|
|
|
|
|
bss->broadcast_deauth = 1;
|
2017-03-10 17:33:51 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_MBO
|
|
|
|
bss->mbo_cell_data_conn_pref = -1;
|
|
|
|
#endif /* CONFIG_MBO */
|
2018-05-01 21:12:37 +02:00
|
|
|
|
|
|
|
/* 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;
|
2018-12-07 12:07:36 +01:00
|
|
|
|
2019-09-01 14:58:10 +02:00
|
|
|
bss->max_auth_rounds = 100;
|
|
|
|
bss->max_auth_rounds_short = 50;
|
|
|
|
|
2018-12-07 12:07:36 +01:00
|
|
|
bss->send_probe_response = 1;
|
2018-12-07 23:39:00 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_HS20
|
|
|
|
bss->hs20_release = (HS20_VERSION >> 4) + 1;
|
|
|
|
#endif /* CONFIG_HS20 */
|
2017-08-07 18:26:33 +02:00
|
|
|
|
2019-05-24 09:26:46 +02:00
|
|
|
#ifdef CONFIG_MACSEC
|
|
|
|
bss->mka_priority = DEFAULT_PRIO_NOT_KEY_SERVER;
|
|
|
|
bss->macsec_port = 1;
|
|
|
|
#endif /* CONFIG_MACSEC */
|
|
|
|
|
2017-08-07 18:26:33 +02:00
|
|
|
/* Default to strict CRL checking. */
|
|
|
|
bss->check_crl_strict = 1;
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-26 19:35:49 +01:00
|
|
|
struct hostapd_config * hostapd_config_defaults(void)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2011-02-01 13:34:12 +01:00
|
|
|
#define ecw2cw(ecw) ((1 << (ecw)) - 1)
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
struct hostapd_config *conf;
|
|
|
|
struct hostapd_bss_config *bss;
|
2010-01-06 19:48:29 +01:00
|
|
|
const int aCWmin = 4, aCWmax = 10;
|
2009-03-04 11:33:24 +01:00
|
|
|
const struct hostapd_wmm_ac_params ac_bk =
|
2008-02-28 02:34:43 +01:00
|
|
|
{ aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
|
2009-03-04 11:33:24 +01:00
|
|
|
const struct hostapd_wmm_ac_params ac_be =
|
2008-02-28 02:34:43 +01:00
|
|
|
{ aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
|
2009-03-04 11:33:24 +01:00
|
|
|
const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
|
2014-03-17 17:23:13 +01:00
|
|
|
{ aCWmin - 1, aCWmin, 2, 3008 / 32, 0 };
|
2009-03-04 11:33:24 +01:00
|
|
|
const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
|
2014-03-17 17:23:13 +01:00
|
|
|
{ aCWmin - 2, aCWmin - 1, 2, 1504 / 32, 0 };
|
2011-02-01 13:34:12 +01:00
|
|
|
const struct hostapd_tx_queue_params txq_bk =
|
|
|
|
{ 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 };
|
|
|
|
const struct hostapd_tx_queue_params txq_be =
|
|
|
|
{ 3, ecw2cw(aCWmin), 4 * (ecw2cw(aCWmin) + 1) - 1, 0};
|
|
|
|
const struct hostapd_tx_queue_params txq_vi =
|
|
|
|
{ 1, (ecw2cw(aCWmin) + 1) / 2 - 1, ecw2cw(aCWmin), 30};
|
|
|
|
const struct hostapd_tx_queue_params txq_vo =
|
|
|
|
{ 1, (ecw2cw(aCWmin) + 1) / 4 - 1,
|
|
|
|
(ecw2cw(aCWmin) + 1) / 2 - 1, 15};
|
|
|
|
|
|
|
|
#undef ecw2cw
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
conf = os_zalloc(sizeof(*conf));
|
|
|
|
bss = os_zalloc(sizeof(*bss));
|
|
|
|
if (conf == NULL || bss == NULL) {
|
2009-01-12 15:49:04 +01:00
|
|
|
wpa_printf(MSG_ERROR, "Failed to allocate memory for "
|
|
|
|
"configuration data.");
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf);
|
|
|
|
os_free(bss);
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-10-29 15:23:23 +01:00
|
|
|
conf->bss = os_calloc(1, sizeof(struct hostapd_bss_config *));
|
|
|
|
if (conf->bss == NULL) {
|
|
|
|
os_free(conf);
|
|
|
|
os_free(bss);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
conf->bss[0] = bss;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
bss->radius = os_zalloc(sizeof(*bss->radius));
|
|
|
|
if (bss->radius == NULL) {
|
2014-01-28 08:32:35 +01:00
|
|
|
os_free(conf->bss);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf);
|
|
|
|
os_free(bss);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hostapd_config_defaults_bss(bss);
|
|
|
|
|
|
|
|
conf->num_bss = 1;
|
|
|
|
|
|
|
|
conf->beacon_int = 100;
|
2019-03-12 16:15:08 +01:00
|
|
|
conf->rts_threshold = -2; /* use driver default: 2347 */
|
|
|
|
conf->fragm_threshold = -2; /* user driver default: 2346 */
|
2014-02-21 14:42:17 +01:00
|
|
|
/* Set to invalid value means do not add Power Constraint IE */
|
|
|
|
conf->local_pwr_constraint = -1;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2009-03-04 11:33:24 +01:00
|
|
|
conf->wmm_ac_params[0] = ac_be;
|
|
|
|
conf->wmm_ac_params[1] = ac_bk;
|
|
|
|
conf->wmm_ac_params[2] = ac_vi;
|
|
|
|
conf->wmm_ac_params[3] = ac_vo;
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2011-02-01 13:34:12 +01:00
|
|
|
conf->tx_queue[0] = txq_vo;
|
|
|
|
conf->tx_queue[1] = txq_vi;
|
|
|
|
conf->tx_queue[2] = txq_be;
|
|
|
|
conf->tx_queue[3] = txq_bk;
|
|
|
|
|
2008-11-24 14:44:25 +01:00
|
|
|
conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
|
2008-08-21 17:18:38 +02:00
|
|
|
|
2012-12-17 16:45:26 +01:00
|
|
|
conf->ap_table_max_size = 255;
|
|
|
|
conf->ap_table_expiration_time = 60;
|
2015-09-05 16:11:11 +02:00
|
|
|
conf->track_sta_max_age = 180;
|
2012-12-17 16:45:26 +01:00
|
|
|
|
2013-04-23 16:51:28 +02:00
|
|
|
#ifdef CONFIG_TESTING_OPTIONS
|
2014-04-26 10:09:29 +02:00
|
|
|
conf->ignore_probe_probability = 0.0;
|
|
|
|
conf->ignore_auth_probability = 0.0;
|
|
|
|
conf->ignore_assoc_probability = 0.0;
|
|
|
|
conf->ignore_reassoc_probability = 0.0;
|
|
|
|
conf->corrupt_gtk_rekey_mic_probability = 0.0;
|
2015-09-08 11:46:32 +02:00
|
|
|
conf->ecsa_ie_only = 0;
|
2013-04-23 16:51:28 +02:00
|
|
|
#endif /* CONFIG_TESTING_OPTIONS */
|
|
|
|
|
2015-03-11 21:03:58 +01:00
|
|
|
conf->acs = 0;
|
|
|
|
conf->acs_ch_list.num = 0;
|
2013-08-31 10:49:51 +02:00
|
|
|
#ifdef CONFIG_ACS
|
|
|
|
conf->acs_num_scans = 5;
|
|
|
|
#endif /* CONFIG_ACS */
|
|
|
|
|
2019-04-16 14:33:58 +02:00
|
|
|
#ifdef CONFIG_IEEE80211AX
|
|
|
|
conf->he_op.he_rts_threshold = HE_OPERATION_RTS_THRESHOLD_MASK >>
|
|
|
|
HE_OPERATION_RTS_THRESHOLD_OFFSET;
|
2019-05-20 09:55:04 +02:00
|
|
|
/* Set default basic MCS/NSS set to single stream MCS 0-7 */
|
|
|
|
conf->he_op.he_basic_mcs_nss_set = 0xfffc;
|
2020-02-04 09:04:54 +01:00
|
|
|
conf->he_op.he_bss_color_disabled = 1;
|
|
|
|
conf->he_op.he_bss_color_partial = 0;
|
|
|
|
conf->he_op.he_bss_color = 1;
|
2019-04-16 14:33:58 +02:00
|
|
|
#endif /* CONFIG_IEEE80211AX */
|
|
|
|
|
2017-03-01 09:58:15 +01:00
|
|
|
/* 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] = ' ';
|
|
|
|
|
2017-08-21 18:43:53 +02:00
|
|
|
conf->rssi_reject_assoc_rssi = 0;
|
|
|
|
conf->rssi_reject_assoc_timeout = 30;
|
|
|
|
|
2019-03-20 15:58:52 +01:00
|
|
|
#ifdef CONFIG_AIRTIME_POLICY
|
|
|
|
conf->airtime_update_interval = AIRTIME_DEFAULT_UPDATE_INTERVAL;
|
|
|
|
#endif /* CONFIG_AIRTIME_POLICY */
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
return conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_mac_comp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
return os_memcmp(a, b, sizeof(macaddr));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int hostapd_config_read_wpa_psk(const char *fname,
|
|
|
|
struct hostapd_ssid *ssid)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[128], *pos;
|
2019-01-16 13:35:19 +01:00
|
|
|
const char *keyid;
|
|
|
|
char *context;
|
|
|
|
char *context2;
|
|
|
|
char *token;
|
|
|
|
char *name;
|
|
|
|
char *value;
|
2008-02-28 02:34:43 +01:00
|
|
|
int line = 0, ret = 0, len, ok;
|
|
|
|
u8 addr[ETH_ALEN];
|
|
|
|
struct hostapd_wpa_psk *psk;
|
|
|
|
|
|
|
|
if (!fname)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
f = fopen(fname, "r");
|
|
|
|
if (!f) {
|
2009-01-12 15:49:04 +01:00
|
|
|
wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname);
|
2008-02-28 02:34:43 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgets(buf, sizeof(buf), f)) {
|
2019-02-14 12:34:33 +01:00
|
|
|
int vlan_id = 0;
|
2020-02-10 12:49:33 +01:00
|
|
|
int wps = 0;
|
2019-02-14 12:34:33 +01:00
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
line++;
|
|
|
|
|
|
|
|
if (buf[0] == '#')
|
|
|
|
continue;
|
|
|
|
pos = buf;
|
|
|
|
while (*pos != '\0') {
|
|
|
|
if (*pos == '\n') {
|
|
|
|
*pos = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
if (buf[0] == '\0')
|
|
|
|
continue;
|
|
|
|
|
2019-01-16 13:35:19 +01:00
|
|
|
context = NULL;
|
|
|
|
keyid = NULL;
|
|
|
|
while ((token = str_token(buf, " ", &context))) {
|
|
|
|
if (!os_strchr(token, '='))
|
|
|
|
break;
|
|
|
|
context2 = NULL;
|
|
|
|
name = str_token(token, "=", &context2);
|
2019-02-18 17:24:52 +01:00
|
|
|
if (!name)
|
|
|
|
break;
|
2019-01-16 13:35:19 +01:00
|
|
|
value = str_token(token, "", &context2);
|
|
|
|
if (!value)
|
|
|
|
value = "";
|
|
|
|
if (!os_strcmp(name, "keyid")) {
|
|
|
|
keyid = value;
|
2020-02-10 12:49:33 +01:00
|
|
|
} else if (!os_strcmp(name, "wps")) {
|
|
|
|
wps = atoi(value);
|
2019-02-14 12:34:33 +01:00
|
|
|
} else if (!os_strcmp(name, "vlanid")) {
|
|
|
|
vlan_id = atoi(value);
|
2019-01-16 13:35:19 +01:00
|
|
|
} 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)) {
|
2020-02-15 16:12:45 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"Invalid MAC address '%s' on line %d in '%s'",
|
|
|
|
token, line, fname);
|
2008-02-28 02:34:43 +01:00
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
psk = os_zalloc(sizeof(*psk));
|
|
|
|
if (psk == NULL) {
|
2009-01-12 15:49:04 +01:00
|
|
|
wpa_printf(MSG_ERROR, "WPA PSK allocation failed");
|
2008-02-28 02:34:43 +01:00
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
2019-02-14 12:34:33 +01:00
|
|
|
psk->vlan_id = vlan_id;
|
2008-06-03 17:08:48 +02:00
|
|
|
if (is_zero_ether_addr(addr))
|
2008-02-28 02:34:43 +01:00
|
|
|
psk->group = 1;
|
|
|
|
else
|
|
|
|
os_memcpy(psk->addr, addr, ETH_ALEN);
|
|
|
|
|
2019-01-16 13:35:19 +01:00
|
|
|
pos = str_token(buf, "", &context);
|
|
|
|
if (!pos) {
|
2009-01-12 15:49:04 +01:00
|
|
|
wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
|
|
|
|
line, fname);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(psk);
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok = 0;
|
|
|
|
len = os_strlen(pos);
|
2020-02-15 16:11:18 +01:00
|
|
|
if (len == 2 * PMK_LEN &&
|
|
|
|
hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
ok = 1;
|
2020-02-15 16:10:08 +01:00
|
|
|
else if (len >= 8 && len < 64 &&
|
|
|
|
pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
|
|
|
|
4096, psk->psk, PMK_LEN) == 0)
|
2008-02-28 02:34:43 +01:00
|
|
|
ok = 1;
|
|
|
|
if (!ok) {
|
2020-02-15 16:12:45 +01:00
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"Invalid PSK '%s' on line %d in '%s'",
|
|
|
|
pos, line, fname);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(psk);
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2019-01-16 13:35:19 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-10 12:49:33 +01:00
|
|
|
psk->wps = wps;
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
psk->next = ssid->wpa_psk;
|
|
|
|
ssid->wpa_psk = psk;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-21 11:11:08 +01:00
|
|
|
static int hostapd_derive_psk(struct hostapd_ssid *ssid)
|
|
|
|
{
|
|
|
|
ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
|
|
|
|
if (ssid->wpa_psk == NULL) {
|
|
|
|
wpa_printf(MSG_ERROR, "Unable to alloc space for PSK");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
wpa_hexdump_ascii(MSG_DEBUG, "SSID",
|
|
|
|
(u8 *) ssid->ssid, ssid->ssid_len);
|
|
|
|
wpa_hexdump_ascii_key(MSG_DEBUG, "PSK (ASCII passphrase)",
|
|
|
|
(u8 *) ssid->wpa_passphrase,
|
|
|
|
os_strlen(ssid->wpa_passphrase));
|
|
|
|
pbkdf2_sha1(ssid->wpa_passphrase,
|
|
|
|
ssid->ssid, ssid->ssid_len,
|
|
|
|
4096, ssid->wpa_psk->psk, PMK_LEN);
|
|
|
|
wpa_hexdump_key(MSG_DEBUG, "PSK (from passphrase)",
|
|
|
|
ssid->wpa_psk->psk, PMK_LEN);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-09-06 14:51:37 +02:00
|
|
|
int hostapd_setup_sae_pt(struct hostapd_bss_config *conf)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SAE
|
|
|
|
struct hostapd_ssid *ssid = &conf->ssid;
|
|
|
|
struct sae_password_entry *pw;
|
|
|
|
|
2020-01-20 20:15:04 +01:00
|
|
|
if ((conf->sae_pwe == 0 && !hostapd_sae_pw_id_in_use(conf)) ||
|
2020-02-10 03:59:10 +01:00
|
|
|
conf->sae_pwe == 3 ||
|
2020-01-20 20:15:04 +01:00
|
|
|
!wpa_key_mgmt_sae(conf->wpa_key_mgmt))
|
2019-09-06 14:51:37 +02:00
|
|
|
return 0; /* PT not needed */
|
|
|
|
|
|
|
|
sae_deinit_pt(ssid->pt);
|
|
|
|
ssid->pt = NULL;
|
|
|
|
if (ssid->wpa_passphrase) {
|
|
|
|
ssid->pt = sae_derive_pt(conf->sae_groups, ssid->ssid,
|
|
|
|
ssid->ssid_len,
|
|
|
|
(const u8 *) ssid->wpa_passphrase,
|
|
|
|
os_strlen(ssid->wpa_passphrase),
|
|
|
|
NULL);
|
|
|
|
if (!ssid->pt)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (pw = conf->sae_passwords; pw; pw = pw->next) {
|
|
|
|
sae_deinit_pt(pw->pt);
|
|
|
|
pw->pt = sae_derive_pt(conf->sae_groups, ssid->ssid,
|
|
|
|
ssid->ssid_len,
|
|
|
|
(const u8 *) pw->password,
|
|
|
|
os_strlen(pw->password),
|
|
|
|
pw->identifier);
|
|
|
|
if (!pw->pt)
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_SAE */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
|
|
|
|
{
|
|
|
|
struct hostapd_ssid *ssid = &conf->ssid;
|
|
|
|
|
2019-09-06 14:51:37 +02:00
|
|
|
if (hostapd_setup_sae_pt(conf) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
if (ssid->wpa_passphrase != NULL) {
|
|
|
|
if (ssid->wpa_psk != NULL) {
|
2009-12-21 11:11:08 +01:00
|
|
|
wpa_printf(MSG_DEBUG, "Using pre-configured WPA PSK "
|
|
|
|
"instead of passphrase");
|
|
|
|
} else {
|
|
|
|
wpa_printf(MSG_DEBUG, "Deriving WPA PSK based on "
|
|
|
|
"passphrase");
|
|
|
|
if (hostapd_derive_psk(ssid) < 0)
|
|
|
|
return -1;
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
ssid->wpa_psk->group = 1;
|
|
|
|
}
|
|
|
|
|
2016-12-26 16:42:41 +01:00
|
|
|
return hostapd_config_read_wpa_psk(ssid->wpa_psk_file, &conf->ssid);
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
|
|
|
|
int num_servers)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < num_servers; i++) {
|
|
|
|
os_free(servers[i].shared_secret);
|
|
|
|
}
|
|
|
|
os_free(servers);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-05 19:19:56 +02:00
|
|
|
struct hostapd_radius_attr *
|
|
|
|
hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type)
|
|
|
|
{
|
|
|
|
for (; attr; attr = attr->next) {
|
|
|
|
if (attr->type == type)
|
|
|
|
return attr;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-21 14:05:55 +02:00
|
|
|
struct hostapd_radius_attr * hostapd_parse_radius_attr(const char *value)
|
|
|
|
{
|
|
|
|
const char *pos;
|
|
|
|
char syntax;
|
|
|
|
struct hostapd_radius_attr *attr;
|
|
|
|
size_t len;
|
|
|
|
|
|
|
|
attr = os_zalloc(sizeof(*attr));
|
|
|
|
if (!attr)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
attr->type = atoi(value);
|
|
|
|
|
|
|
|
pos = os_strchr(value, ':');
|
|
|
|
if (!pos) {
|
|
|
|
attr->val = wpabuf_alloc(1);
|
|
|
|
if (!attr->val) {
|
|
|
|
os_free(attr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
wpabuf_put_u8(attr->val, 0);
|
|
|
|
return attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos++;
|
|
|
|
if (pos[0] == '\0' || pos[1] != ':') {
|
|
|
|
os_free(attr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
syntax = *pos++;
|
|
|
|
pos++;
|
|
|
|
|
|
|
|
switch (syntax) {
|
|
|
|
case 's':
|
|
|
|
attr->val = wpabuf_alloc_copy(pos, os_strlen(pos));
|
|
|
|
break;
|
|
|
|
case 'x':
|
|
|
|
len = os_strlen(pos);
|
|
|
|
if (len & 1)
|
|
|
|
break;
|
|
|
|
len /= 2;
|
|
|
|
attr->val = wpabuf_alloc(len);
|
|
|
|
if (!attr->val)
|
|
|
|
break;
|
|
|
|
if (hexstr2bin(pos, wpabuf_put(attr->val, len), len) < 0) {
|
|
|
|
wpabuf_free(attr->val);
|
|
|
|
os_free(attr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
attr->val = wpabuf_alloc(4);
|
|
|
|
if (attr->val)
|
|
|
|
wpabuf_put_be32(attr->val, atoi(pos));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
os_free(attr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!attr->val) {
|
|
|
|
os_free(attr);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return attr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-21 14:05:56 +02:00
|
|
|
void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr)
|
2012-05-05 19:19:56 +02:00
|
|
|
{
|
|
|
|
struct hostapd_radius_attr *prev;
|
|
|
|
|
|
|
|
while (attr) {
|
|
|
|
prev = attr;
|
|
|
|
attr = attr->next;
|
|
|
|
wpabuf_free(prev->val);
|
|
|
|
os_free(prev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-07 22:19:52 +01:00
|
|
|
void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2014-03-07 22:19:52 +01:00
|
|
|
hostapd_config_free_radius_attr(user->accept_attr);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(user->identity);
|
2014-07-02 00:45:45 +02:00
|
|
|
bin_clear_free(user->password, user->password_len);
|
2018-05-25 20:40:04 +02:00
|
|
|
bin_clear_free(user->salt, user->salt_len);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(user);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-28 11:12:14 +01:00
|
|
|
void hostapd_config_free_eap_users(struct hostapd_eap_user *user)
|
|
|
|
{
|
|
|
|
struct hostapd_eap_user *prev_user;
|
|
|
|
|
|
|
|
while (user) {
|
|
|
|
prev_user = user;
|
|
|
|
user = user->next;
|
|
|
|
hostapd_config_free_eap_user(prev_user);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2008-02-28 02:34:43 +01:00
|
|
|
static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < NUM_WEP_KEYS; i++) {
|
2014-07-02 00:45:45 +02:00
|
|
|
bin_clear_free(keys->key[i], keys->len[i]);
|
2008-02-28 02:34:43 +01:00
|
|
|
keys->key[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
|
2015-01-19 23:57:41 +01:00
|
|
|
void hostapd_config_clear_wpa_psk(struct hostapd_wpa_psk **l)
|
|
|
|
{
|
|
|
|
struct hostapd_wpa_psk *psk, *tmp;
|
|
|
|
|
|
|
|
for (psk = *l; psk;) {
|
|
|
|
tmp = psk;
|
|
|
|
psk = psk->next;
|
|
|
|
bin_clear_free(tmp, sizeof(*tmp));
|
|
|
|
}
|
|
|
|
*l = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-07 15:14:09 +02:00
|
|
|
static void hostapd_config_free_anqp_elem(struct hostapd_bss_config *conf)
|
|
|
|
{
|
|
|
|
struct anqp_element *elem;
|
|
|
|
|
|
|
|
while ((elem = dl_list_first(&conf->anqp_elem, struct anqp_element,
|
|
|
|
list))) {
|
|
|
|
dl_list_del(&elem->list);
|
|
|
|
wpabuf_free(elem->payload);
|
|
|
|
os_free(elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-12-17 16:19:34 +01:00
|
|
|
static void hostapd_config_free_fils_realms(struct hostapd_bss_config *conf)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_FILS
|
|
|
|
struct fils_realm *realm;
|
|
|
|
|
|
|
|
while ((realm = dl_list_first(&conf->fils_realms, struct fils_realm,
|
|
|
|
list))) {
|
|
|
|
dl_list_del(&realm->list);
|
|
|
|
os_free(realm);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_FILS */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-05-19 16:28:01 +02:00
|
|
|
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);
|
2019-09-06 14:51:37 +02:00
|
|
|
#ifdef CONFIG_SAE
|
|
|
|
sae_deinit_pt(tmp->pt);
|
|
|
|
#endif /* CONFIG_SAE */
|
2018-05-19 16:28:01 +02:00
|
|
|
os_free(tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-03-24 21:17:49 +01:00
|
|
|
#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 */
|
|
|
|
|
|
|
|
|
2013-10-17 17:56:30 +02:00
|
|
|
void hostapd_config_free_bss(struct hostapd_bss_config *conf)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
2019-06-19 14:49:14 +02:00
|
|
|
#if defined(CONFIG_WPS) || defined(CONFIG_HS20)
|
|
|
|
size_t i;
|
|
|
|
#endif
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
if (conf == NULL)
|
|
|
|
return;
|
|
|
|
|
2015-01-19 23:57:41 +01:00
|
|
|
hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2014-07-02 00:45:45 +02:00
|
|
|
str_clear_free(conf->ssid.wpa_passphrase);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->ssid.wpa_psk_file);
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2010-08-17 20:04:07 +02:00
|
|
|
hostapd_config_free_wep(&conf->ssid.wep);
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2008-02-28 02:34:43 +01:00
|
|
|
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
|
|
|
os_free(conf->ssid.vlan_tagged_interface);
|
|
|
|
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
|
2019-09-06 14:51:37 +02:00
|
|
|
#ifdef CONFIG_SAE
|
|
|
|
sae_deinit_pt(conf->ssid.pt);
|
|
|
|
#endif /* CONFIG_SAE */
|
2008-02-28 02:34:43 +01:00
|
|
|
|
2016-12-28 11:12:14 +01:00
|
|
|
hostapd_config_free_eap_users(conf->eap_user);
|
2012-11-20 23:47:47 +01:00
|
|
|
os_free(conf->eap_user_sqlite);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
os_free(conf->eap_req_id_text);
|
2014-11-29 19:33:09 +01:00
|
|
|
os_free(conf->erp_domain);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->accept_mac);
|
|
|
|
os_free(conf->deny_mac);
|
|
|
|
os_free(conf->nas_identifier);
|
2013-10-17 16:41:26 +02:00
|
|
|
if (conf->radius) {
|
|
|
|
hostapd_config_free_radius(conf->radius->auth_servers,
|
|
|
|
conf->radius->num_auth_servers);
|
|
|
|
hostapd_config_free_radius(conf->radius->acct_servers,
|
|
|
|
conf->radius->num_acct_servers);
|
|
|
|
}
|
2012-05-05 19:19:56 +02:00
|
|
|
hostapd_config_free_radius_attr(conf->radius_auth_req_attr);
|
|
|
|
hostapd_config_free_radius_attr(conf->radius_acct_req_attr);
|
2019-07-21 14:05:56 +02:00
|
|
|
os_free(conf->radius_req_attr_sqlite);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->rsn_preauth_interfaces);
|
|
|
|
os_free(conf->ctrl_interface);
|
|
|
|
os_free(conf->ca_cert);
|
|
|
|
os_free(conf->server_cert);
|
2019-07-12 17:11:53 +02:00
|
|
|
os_free(conf->server_cert2);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->private_key);
|
2019-07-12 17:11:53 +02:00
|
|
|
os_free(conf->private_key2);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->private_key_passwd);
|
2019-07-12 17:11:53 +02:00
|
|
|
os_free(conf->private_key_passwd2);
|
2019-02-28 20:39:50 +01:00
|
|
|
os_free(conf->check_cert_subject);
|
2013-06-29 23:54:24 +02:00
|
|
|
os_free(conf->ocsp_stapling_response);
|
2015-12-22 18:34:36 +01:00
|
|
|
os_free(conf->ocsp_stapling_response_multi);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->dh_file);
|
2014-10-12 10:52:05 +02:00
|
|
|
os_free(conf->openssl_ciphers);
|
2017-04-20 15:44:31 +02:00
|
|
|
os_free(conf->openssl_ecdh_curves);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->pac_opaque_encr_key);
|
|
|
|
os_free(conf->eap_fast_a_id);
|
2008-10-19 08:55:59 +02:00
|
|
|
os_free(conf->eap_fast_a_id_info);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->eap_sim_db);
|
|
|
|
os_free(conf->radius_server_clients);
|
|
|
|
os_free(conf->radius);
|
2012-05-06 21:02:42 +02:00
|
|
|
os_free(conf->radius_das_shared_secret);
|
2008-02-28 02:34:43 +01:00
|
|
|
hostapd_config_free_vlan(conf);
|
2011-10-17 23:24:16 +02:00
|
|
|
os_free(conf->time_zone);
|
|
|
|
|
2016-10-27 14:18:32 +02:00
|
|
|
#ifdef CONFIG_IEEE80211R_AP
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
|
|
|
struct ft_remote_r0kh *r0kh, *r0kh_prev;
|
|
|
|
struct ft_remote_r1kh *r1kh, *r1kh_prev;
|
|
|
|
|
|
|
|
r0kh = conf->r0kh_list;
|
|
|
|
conf->r0kh_list = NULL;
|
|
|
|
while (r0kh) {
|
|
|
|
r0kh_prev = r0kh;
|
|
|
|
r0kh = r0kh->next;
|
|
|
|
os_free(r0kh_prev);
|
|
|
|
}
|
|
|
|
|
|
|
|
r1kh = conf->r1kh_list;
|
|
|
|
conf->r1kh_list = NULL;
|
|
|
|
while (r1kh) {
|
|
|
|
r1kh_prev = r1kh;
|
|
|
|
r1kh = r1kh->next;
|
|
|
|
os_free(r1kh_prev);
|
|
|
|
}
|
|
|
|
}
|
2016-10-27 14:18:32 +02:00
|
|
|
#endif /* CONFIG_IEEE80211R_AP */
|
2008-11-23 18:34:26 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_WPS
|
|
|
|
os_free(conf->wps_pin_requests);
|
|
|
|
os_free(conf->device_name);
|
|
|
|
os_free(conf->manufacturer);
|
|
|
|
os_free(conf->model_name);
|
|
|
|
os_free(conf->model_number);
|
|
|
|
os_free(conf->serial_number);
|
|
|
|
os_free(conf->config_methods);
|
|
|
|
os_free(conf->ap_pin);
|
2009-01-23 19:51:26 +01:00
|
|
|
os_free(conf->extra_cred);
|
2009-01-23 20:08:55 +01:00
|
|
|
os_free(conf->ap_settings);
|
hostapd: Support Multi-AP backhaul STA onboarding with WPS
The Wi-Fi Alliance Multi-AP Specification v1.0 allows onboarding of a
backhaul STA through WPS. To enable this, the WPS Registrar offers a
different set of credentials (backhaul credentials instead of fronthaul
credentials) when the Multi-AP subelement is present in the WFA vendor
extension element of the WSC M1 message.
Add new configuration options to specify the backhaul credentials for
the hostapd internal registrar: multi_ap_backhaul_ssid,
multi_ap_backhaul_wpa_psk, multi_ap_backhaul_wpa_passphrase. These are
only relevant for a fronthaul SSID, i.e., where multi_ap is set to 2 or
3. When these options are set, pass the backhaul credentials instead of
the normal credentials when the Multi-AP subelement is present.
Ignore the Multi-AP subelement if the backhaul config options are not
set. Note that for an SSID which is fronthaul and backhaul at the same
time (i.e., multi_ap == 3), this results in the correct credentials
being sent anyway.
The security to be used for the backaul BSS is fixed to WPA2PSK. The
Multi-AP Specification only allows Open and WPA2PSK networks to be
configured. Although not stated explicitly, the backhaul link is
intended to be always encrypted, hence WPA2PSK.
To build the credentials, the credential-building code is essentially
copied and simplified. Indeed, the backhaul credentials are always
WPA2PSK and never use per-device PSK. All the options set for the
fronthaul BSS WPS are simply ignored.
Signed-off-by: Davina Lu <ylu@quantenna.com>
Signed-off-by: Igor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Cc: Marianna Carrera <marianna.carrera.so@quantenna.com>
2019-02-12 15:35:26 +01:00
|
|
|
hostapd_config_clear_wpa_psk(&conf->multi_ap_backhaul_ssid.wpa_psk);
|
|
|
|
str_clear_free(conf->multi_ap_backhaul_ssid.wpa_passphrase);
|
2009-01-29 17:47:02 +01:00
|
|
|
os_free(conf->upnp_iface);
|
|
|
|
os_free(conf->friendly_name);
|
|
|
|
os_free(conf->manufacturer_url);
|
|
|
|
os_free(conf->model_description);
|
|
|
|
os_free(conf->model_url);
|
|
|
|
os_free(conf->upc);
|
2019-06-19 14:49:14 +02:00
|
|
|
for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++)
|
|
|
|
wpabuf_free(conf->wps_vendor_ext[i]);
|
2020-01-03 09:58:26 +01:00
|
|
|
wpabuf_free(conf->wps_application_ext);
|
2012-06-28 18:43:29 +02:00
|
|
|
wpabuf_free(conf->wps_nfc_dh_pubkey);
|
|
|
|
wpabuf_free(conf->wps_nfc_dh_privkey);
|
|
|
|
wpabuf_free(conf->wps_nfc_dev_pw);
|
2008-11-23 18:34:26 +01:00
|
|
|
#endif /* CONFIG_WPS */
|
2011-10-17 22:55:50 +02:00
|
|
|
|
|
|
|
os_free(conf->roaming_consortium);
|
2012-02-26 21:34:21 +01:00
|
|
|
os_free(conf->venue_name);
|
2018-03-26 15:10:47 +02:00
|
|
|
os_free(conf->venue_url);
|
2012-08-25 14:58:30 +02:00
|
|
|
os_free(conf->nai_realm_data);
|
2012-07-30 20:45:31 +02:00
|
|
|
os_free(conf->network_auth_type);
|
2012-07-30 21:07:35 +02:00
|
|
|
os_free(conf->anqp_3gpp_cell_net);
|
2012-07-30 20:55:46 +02:00
|
|
|
os_free(conf->domain_name);
|
2015-10-07 15:14:09 +02:00
|
|
|
hostapd_config_free_anqp_elem(conf);
|
2011-12-08 23:15:04 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_RADIUS_TEST
|
|
|
|
os_free(conf->dump_msk_file);
|
|
|
|
#endif /* CONFIG_RADIUS_TEST */
|
2012-08-25 15:17:21 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_HS20
|
2012-08-25 15:03:51 +02:00
|
|
|
os_free(conf->hs20_oper_friendly_name);
|
2012-08-25 15:09:01 +02:00
|
|
|
os_free(conf->hs20_wan_metrics);
|
2012-08-25 15:12:40 +02:00
|
|
|
os_free(conf->hs20_connection_capability);
|
2012-08-25 15:17:21 +02:00
|
|
|
os_free(conf->hs20_operating_class);
|
2013-03-17 15:28:59 +01:00
|
|
|
os_free(conf->hs20_icons);
|
2013-03-17 15:34:09 +01:00
|
|
|
if (conf->hs20_osu_providers) {
|
|
|
|
for (i = 0; i < conf->hs20_osu_providers_count; i++) {
|
|
|
|
struct hs20_osu_provider *p;
|
|
|
|
size_t j;
|
|
|
|
p = &conf->hs20_osu_providers[i];
|
|
|
|
os_free(p->friendly_name);
|
|
|
|
os_free(p->server_uri);
|
|
|
|
os_free(p->method_list);
|
|
|
|
for (j = 0; j < p->icons_count; j++)
|
|
|
|
os_free(p->icons[j]);
|
|
|
|
os_free(p->icons);
|
|
|
|
os_free(p->osu_nai);
|
2018-10-05 19:49:42 +02:00
|
|
|
os_free(p->osu_nai2);
|
2013-03-17 15:34:09 +01:00
|
|
|
os_free(p->service_desc);
|
|
|
|
}
|
|
|
|
os_free(conf->hs20_osu_providers);
|
|
|
|
}
|
2018-04-16 12:18:57 +02:00
|
|
|
if (conf->hs20_operator_icon) {
|
|
|
|
for (i = 0; i < conf->hs20_operator_icon_count; i++)
|
|
|
|
os_free(conf->hs20_operator_icon[i]);
|
|
|
|
os_free(conf->hs20_operator_icon);
|
|
|
|
}
|
2012-11-21 16:04:21 +01:00
|
|
|
os_free(conf->subscr_remediation_url);
|
2018-12-14 14:58:13 +01:00
|
|
|
os_free(conf->hs20_sim_provisioning_url);
|
2018-04-23 20:10:52 +02:00
|
|
|
os_free(conf->t_c_filename);
|
2018-04-23 23:05:44 +02:00
|
|
|
os_free(conf->t_c_server_url);
|
2012-08-25 15:17:21 +02:00
|
|
|
#endif /* CONFIG_HS20 */
|
2012-08-27 15:20:10 +02:00
|
|
|
|
|
|
|
wpabuf_free(conf->vendor_elements);
|
2016-04-20 06:04:17 +02:00
|
|
|
wpabuf_free(conf->assocresp_elements);
|
2013-01-01 15:23:47 +01:00
|
|
|
|
|
|
|
os_free(conf->sae_groups);
|
2017-10-10 18:00:57 +02:00
|
|
|
#ifdef CONFIG_OWE
|
|
|
|
os_free(conf->owe_groups);
|
|
|
|
#endif /* CONFIG_OWE */
|
2013-07-06 17:17:15 +02:00
|
|
|
|
2014-09-03 23:58:37 +02:00
|
|
|
os_free(conf->wowlan_triggers);
|
|
|
|
|
2013-07-06 17:17:15 +02:00
|
|
|
os_free(conf->server_id);
|
2013-10-29 15:23:23 +01:00
|
|
|
|
2015-08-08 17:18:03 +02:00
|
|
|
#ifdef CONFIG_TESTING_OPTIONS
|
|
|
|
wpabuf_free(conf->own_ie_override);
|
2017-09-02 00:52:15 +02:00
|
|
|
wpabuf_free(conf->sae_commit_override);
|
2020-03-07 15:45:52 +01:00
|
|
|
wpabuf_free(conf->rsne_override_eapol);
|
2019-12-07 15:53:08 +01:00
|
|
|
wpabuf_free(conf->rsnxe_override_eapol);
|
2020-03-14 22:30:27 +01:00
|
|
|
wpabuf_free(conf->rsne_override_ft);
|
|
|
|
wpabuf_free(conf->rsnxe_override_ft);
|
2020-01-04 12:05:26 +01:00
|
|
|
wpabuf_free(conf->gtk_rsc_override);
|
|
|
|
wpabuf_free(conf->igtk_rsc_override);
|
2015-08-08 17:18:03 +02:00
|
|
|
#endif /* CONFIG_TESTING_OPTIONS */
|
|
|
|
|
2015-09-05 16:53:15 +02:00
|
|
|
os_free(conf->no_probe_resp_if_seen_on);
|
2015-09-05 18:00:03 +02:00
|
|
|
os_free(conf->no_auth_if_seen_on);
|
2015-09-05 16:53:15 +02:00
|
|
|
|
2016-12-17 16:19:34 +01:00
|
|
|
hostapd_config_free_fils_realms(conf);
|
|
|
|
|
2017-06-18 16:29:57 +02:00
|
|
|
#ifdef CONFIG_DPP
|
2019-09-17 12:36:22 +02:00
|
|
|
os_free(conf->dpp_name);
|
|
|
|
os_free(conf->dpp_mud_url);
|
2017-06-18 16:29:57 +02:00
|
|
|
os_free(conf->dpp_connector);
|
|
|
|
wpabuf_free(conf->dpp_netaccesskey);
|
|
|
|
wpabuf_free(conf->dpp_csign);
|
2019-03-24 21:17:49 +01:00
|
|
|
#ifdef CONFIG_DPP2
|
|
|
|
hostapd_dpp_controller_conf_free(conf->dpp_controller);
|
|
|
|
#endif /* CONFIG_DPP2 */
|
2017-06-18 16:29:57 +02:00
|
|
|
#endif /* CONFIG_DPP */
|
|
|
|
|
2018-05-19 16:28:01 +02:00
|
|
|
hostapd_config_free_sae_passwords(conf);
|
2017-10-11 22:07:08 +02:00
|
|
|
|
2019-03-20 15:58:52 +01:00
|
|
|
#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 */
|
|
|
|
|
2013-10-29 15:23:23 +01:00
|
|
|
os_free(conf);
|
2008-02-28 02:34:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-08 15:33:00 +01:00
|
|
|
/**
|
|
|
|
* hostapd_config_free - Free hostapd configuration
|
|
|
|
* @conf: Configuration data from hostapd_config_read().
|
|
|
|
*/
|
2008-02-28 02:34:43 +01:00
|
|
|
void hostapd_config_free(struct hostapd_config *conf)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (conf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < conf->num_bss; i++)
|
2013-10-29 15:23:23 +01:00
|
|
|
hostapd_config_free_bss(conf->bss[i]);
|
2008-02-28 02:34:43 +01:00
|
|
|
os_free(conf->bss);
|
2009-12-21 21:22:49 +01:00
|
|
|
os_free(conf->supported_rates);
|
|
|
|
os_free(conf->basic_rates);
|
2015-03-11 21:03:58 +01:00
|
|
|
os_free(conf->acs_ch_list.range);
|
2019-11-26 06:49:32 +01:00
|
|
|
os_free(conf->acs_freq_list.range);
|
2014-11-29 12:24:42 +01:00
|
|
|
os_free(conf->driver_params);
|
2015-02-06 16:59:57 +01:00
|
|
|
#ifdef CONFIG_ACS
|
|
|
|
os_free(conf->acs_chan_bias);
|
|
|
|
#endif /* CONFIG_ACS */
|
2016-04-06 18:42:01 +02:00
|
|
|
wpabuf_free(conf->lci);
|
|
|
|
wpabuf_free(conf->civic);
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
os_free(conf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-08 15:33:00 +01:00
|
|
|
/**
|
|
|
|
* hostapd_maclist_found - Find a MAC address from a list
|
|
|
|
* @list: MAC address list
|
|
|
|
* @num_entries: Number of addresses in the list
|
|
|
|
* @addr: Address to search for
|
|
|
|
* @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
|
|
|
|
* Returns: 1 if address is in the list or 0 if not.
|
|
|
|
*
|
|
|
|
* Perform a binary search for given MAC address from a pre-sorted list.
|
|
|
|
*/
|
2008-08-28 17:43:26 +02:00
|
|
|
int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
|
2016-01-21 14:51:56 +01:00
|
|
|
const u8 *addr, struct vlan_description *vlan_id)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
|
|
|
int start, end, middle, res;
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
end = num_entries - 1;
|
|
|
|
|
|
|
|
while (start <= end) {
|
|
|
|
middle = (start + end) / 2;
|
2008-08-28 17:43:26 +02:00
|
|
|
res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
|
|
|
|
if (res == 0) {
|
|
|
|
if (vlan_id)
|
|
|
|
*vlan_id = list[middle].vlan_id;
|
2008-02-28 02:34:43 +01:00
|
|
|
return 1;
|
2008-08-28 17:43:26 +02:00
|
|
|
}
|
2008-02-28 02:34:43 +01:00
|
|
|
if (res < 0)
|
|
|
|
start = middle + 1;
|
|
|
|
else
|
|
|
|
end = middle - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_rate_found(int *list, int rate)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (list == NULL)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
for (i = 0; list[i] >= 0; i++)
|
|
|
|
if (list[i] == rate)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-01-21 14:51:56 +01:00
|
|
|
int hostapd_vlan_valid(struct hostapd_vlan *vlan,
|
|
|
|
struct vlan_description *vlan_desc)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
|
|
|
struct hostapd_vlan *v = vlan;
|
2016-01-21 14:51:57 +01:00
|
|
|
int i;
|
2016-01-21 14:51:56 +01:00
|
|
|
|
2016-01-21 14:51:57 +01:00
|
|
|
if (!vlan_desc->notempty || vlan_desc->untagged < 0 ||
|
2016-01-21 14:51:56 +01:00
|
|
|
vlan_desc->untagged > MAX_VLAN_ID)
|
|
|
|
return 0;
|
2016-01-21 14:51:57 +01:00
|
|
|
for (i = 0; i < MAX_NUM_TAGGED_VLAN; i++) {
|
|
|
|
if (vlan_desc->tagged[i] < 0 ||
|
|
|
|
vlan_desc->tagged[i] > MAX_VLAN_ID)
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!vlan_desc->untagged && !vlan_desc->tagged[0])
|
|
|
|
return 0;
|
2016-01-21 14:51:56 +01:00
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
while (v) {
|
2016-01-21 14:51:56 +01:00
|
|
|
if (!vlan_compare(&v->vlan_desc, vlan_desc) ||
|
|
|
|
v->vlan_id == VLAN_ID_WILDCARD)
|
2013-06-25 11:03:02 +02:00
|
|
|
return 1;
|
|
|
|
v = v->next;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
|
|
|
|
{
|
|
|
|
struct hostapd_vlan *v = vlan;
|
|
|
|
while (v) {
|
|
|
|
if (v->vlan_id == vlan_id)
|
2008-02-28 02:34:43 +01:00
|
|
|
return v->ifname;
|
|
|
|
v = v->next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
|
2013-09-01 10:30:26 +02:00
|
|
|
const u8 *addr, const u8 *p2p_dev_addr,
|
2019-02-14 12:34:33 +01:00
|
|
|
const u8 *prev_psk, int *vlan_id)
|
2008-02-28 02:34:43 +01:00
|
|
|
{
|
|
|
|
struct hostapd_wpa_psk *psk;
|
|
|
|
int next_ok = prev_psk == NULL;
|
|
|
|
|
2019-02-14 12:34:33 +01:00
|
|
|
if (vlan_id)
|
|
|
|
*vlan_id = 0;
|
|
|
|
|
2014-03-29 08:50:51 +01:00
|
|
|
if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) {
|
2013-09-01 10:30:26 +02:00
|
|
|
wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
|
|
|
|
" p2p_dev_addr=" MACSTR " prev_psk=%p",
|
|
|
|
MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk);
|
2014-03-29 08:50:51 +01:00
|
|
|
addr = NULL; /* Use P2P Device Address for matching */
|
2013-09-01 10:30:26 +02:00
|
|
|
} else {
|
|
|
|
wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
|
|
|
|
" prev_psk=%p",
|
|
|
|
MAC2STR(addr), prev_psk);
|
|
|
|
}
|
|
|
|
|
2008-02-28 02:34:43 +01:00
|
|
|
for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
|
|
|
|
if (next_ok &&
|
2013-09-01 10:30:26 +02:00
|
|
|
(psk->group ||
|
|
|
|
(addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) ||
|
|
|
|
(!addr && p2p_dev_addr &&
|
|
|
|
os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) ==
|
2019-02-14 12:34:33 +01:00
|
|
|
0))) {
|
|
|
|
if (vlan_id)
|
|
|
|
*vlan_id = psk->vlan_id;
|
2008-02-28 02:34:43 +01:00
|
|
|
return psk->psk;
|
2019-02-14 12:34:33 +01:00
|
|
|
}
|
2008-02-28 02:34:43 +01:00
|
|
|
|
|
|
|
if (psk->psk == prev_psk)
|
|
|
|
next_ok = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2013-10-29 15:40:12 +01:00
|
|
|
|
|
|
|
|
|
|
|
static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
|
2014-01-07 19:14:53 +01:00
|
|
|
struct hostapd_config *conf,
|
|
|
|
int full_config)
|
2013-10-29 15:40:12 +01:00
|
|
|
{
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && bss->ieee802_1x && !bss->eap_server &&
|
2013-10-29 15:40:12 +01:00
|
|
|
!bss->radius->auth_servers) {
|
|
|
|
wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
|
|
|
|
"EAP authenticator configured).");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2013-10-29 15:40:12 +01:00
|
|
|
if (bss->wpa) {
|
|
|
|
int wep, i;
|
|
|
|
|
|
|
|
wep = bss->default_wep_key_len > 0 ||
|
|
|
|
bss->individual_wep_key_len > 0;
|
|
|
|
for (i = 0; i < NUM_WEP_KEYS; i++) {
|
|
|
|
if (bss->ssid.wep.keys_set) {
|
|
|
|
wep = 1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (wep) {
|
|
|
|
wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2013-10-29 15:40:12 +01:00
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && bss->wpa &&
|
|
|
|
bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
|
|
|
|
wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no "
|
|
|
|
"RADIUS checking (macaddr_acl=2) enabled.");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
|
|
|
|
bss->ssid.wpa_psk_file == NULL &&
|
|
|
|
(bss->wpa_psk_radius != PSK_RADIUS_REQUIRED ||
|
|
|
|
bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) {
|
|
|
|
wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
|
|
|
|
"is not configured.");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-02-28 17:00:48 +01:00
|
|
|
if (full_config && !is_zero_ether_addr(bss->bssid)) {
|
2013-10-29 15:40:12 +01:00
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < conf->num_bss; i++) {
|
|
|
|
if (conf->bss[i] != bss &&
|
|
|
|
(hostapd_mac_comp(conf->bss[i]->bssid,
|
|
|
|
bss->bssid) == 0)) {
|
|
|
|
wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
|
|
|
|
" on interface '%s' and '%s'.",
|
|
|
|
MAC2STR(bss->bssid),
|
|
|
|
conf->bss[i]->iface, bss->iface);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-27 14:18:32 +02:00
|
|
|
#ifdef CONFIG_IEEE80211R_AP
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) &&
|
2013-10-29 15:40:12 +01:00
|
|
|
(bss->nas_identifier == NULL ||
|
|
|
|
os_strlen(bss->nas_identifier) < 1 ||
|
|
|
|
os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
|
|
|
|
wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
|
|
|
|
"nas_identifier to be configured as a 1..48 octet "
|
|
|
|
"string");
|
|
|
|
return -1;
|
|
|
|
}
|
2016-10-27 14:18:32 +02:00
|
|
|
#endif /* CONFIG_IEEE80211R_AP */
|
2013-10-29 15:40:12 +01:00
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && conf->ieee80211n &&
|
|
|
|
conf->hw_mode == HOSTAPD_MODE_IEEE80211B) {
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->disable_11n = 1;
|
|
|
|
wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not "
|
2014-09-17 01:22:06 +02:00
|
|
|
"allowed, disabling HT capabilities");
|
2013-10-29 15:40:12 +01:00
|
|
|
}
|
|
|
|
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && conf->ieee80211n &&
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->ssid.security_policy == SECURITY_STATIC_WEP) {
|
|
|
|
bss->disable_11n = 1;
|
|
|
|
wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not "
|
|
|
|
"allowed, disabling HT capabilities");
|
|
|
|
}
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2013-10-29 15:40:12 +01:00
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && conf->ieee80211n && bss->wpa &&
|
2013-10-29 15:40:12 +01:00
|
|
|
!(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
|
2013-12-24 21:21:04 +01:00
|
|
|
!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
|
|
|
|
WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256)))
|
|
|
|
{
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->disable_11n = 1;
|
|
|
|
wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
|
|
|
|
"requires CCMP/GCMP to be enabled, disabling HT "
|
|
|
|
"capabilities");
|
|
|
|
}
|
|
|
|
|
2016-08-02 16:31:48 +02:00
|
|
|
#ifdef CONFIG_IEEE80211AC
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2016-08-02 16:31:48 +02:00
|
|
|
if (full_config && conf->ieee80211ac &&
|
|
|
|
bss->ssid.security_policy == SECURITY_STATIC_WEP) {
|
|
|
|
bss->disable_11ac = 1;
|
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"VHT (IEEE 802.11ac) with WEP is not allowed, disabling VHT capabilities");
|
|
|
|
}
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2016-10-17 16:53:09 +02:00
|
|
|
|
|
|
|
if (full_config && conf->ieee80211ac && bss->wpa &&
|
|
|
|
!(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
|
|
|
|
!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
|
|
|
|
WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256)))
|
|
|
|
{
|
|
|
|
bss->disable_11ac = 1;
|
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"VHT (IEEE 802.11ac) with WPA/WPA2 requires CCMP/GCMP to be enabled, disabling VHT capabilities");
|
|
|
|
}
|
2016-08-02 16:31:48 +02:00
|
|
|
#endif /* CONFIG_IEEE80211AC */
|
|
|
|
|
2014-03-25 16:40:50 +01:00
|
|
|
#ifdef CONFIG_WPS
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) {
|
2013-10-29 15:40:12 +01:00
|
|
|
wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
|
|
|
|
"configuration forced WPS to be disabled");
|
|
|
|
bss->wps_state = 0;
|
|
|
|
}
|
|
|
|
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && bss->wps_state &&
|
|
|
|
bss->ssid.wep.keys_set && bss->wpa == 0) {
|
2013-10-29 15:40:12 +01:00
|
|
|
wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
|
|
|
|
"disabled");
|
|
|
|
bss->wps_state = 0;
|
|
|
|
}
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2013-10-29 15:40:12 +01:00
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && bss->wps_state && bss->wpa &&
|
2013-10-29 15:40:12 +01:00
|
|
|
(!(bss->wpa & 2) ||
|
2017-12-02 00:22:55 +01:00
|
|
|
!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
|
|
|
|
WPA_CIPHER_CCMP_256 |
|
|
|
|
WPA_CIPHER_GCMP_256)))) {
|
2013-10-29 15:40:12 +01:00
|
|
|
wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
|
2015-04-27 19:42:08 +02:00
|
|
|
"WPA2/CCMP/GCMP forced WPS to be disabled");
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->wps_state = 0;
|
|
|
|
}
|
2014-03-25 16:40:50 +01:00
|
|
|
#endif /* CONFIG_WPS */
|
2013-10-29 15:40:12 +01:00
|
|
|
|
|
|
|
#ifdef CONFIG_HS20
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && bss->hs20 &&
|
2013-10-29 15:40:12 +01:00
|
|
|
(!(bss->wpa & 2) ||
|
2013-12-24 21:21:04 +01:00
|
|
|
!(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
|
|
|
|
WPA_CIPHER_CCMP_256 |
|
|
|
|
WPA_CIPHER_GCMP_256)))) {
|
2013-10-29 15:40:12 +01:00
|
|
|
wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP "
|
|
|
|
"configuration is required for Hotspot 2.0 "
|
|
|
|
"functionality");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_HS20 */
|
|
|
|
|
2016-02-22 15:39:24 +01:00
|
|
|
#ifdef CONFIG_MBO
|
|
|
|
if (full_config && bss->mbo_enabled && (bss->wpa & 2) &&
|
|
|
|
bss->ieee80211w == NO_MGMT_FRAME_PROTECTION) {
|
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"MBO: PMF needs to be enabled whenever using WPA2 with MBO");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_MBO */
|
|
|
|
|
2018-08-06 21:46:25 +02:00
|
|
|
#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 */
|
|
|
|
|
2013-10-29 15:40:12 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-06 09:18:07 +02:00
|
|
|
static int hostapd_config_check_cw(struct hostapd_config *conf, int queue)
|
|
|
|
{
|
|
|
|
int tx_cwmin = conf->tx_queue[queue].cwmin;
|
|
|
|
int tx_cwmax = conf->tx_queue[queue].cwmax;
|
|
|
|
int ac_cwmin = conf->wmm_ac_params[queue].cwmin;
|
|
|
|
int ac_cwmax = conf->wmm_ac_params[queue].cwmax;
|
|
|
|
|
|
|
|
if (tx_cwmin > tx_cwmax) {
|
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"Invalid TX queue cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
|
|
|
|
tx_cwmin, tx_cwmax);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (ac_cwmin > ac_cwmax) {
|
|
|
|
wpa_printf(MSG_ERROR,
|
|
|
|
"Invalid WMM AC cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
|
|
|
|
ac_cwmin, ac_cwmax);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
int hostapd_config_check(struct hostapd_config *conf, int full_config)
|
2013-10-29 15:40:12 +01:00
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && conf->ieee80211d &&
|
|
|
|
(!conf->country[0] || !conf->country[1])) {
|
2013-10-29 15:40:12 +01:00
|
|
|
wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
|
|
|
|
"setting the country_code");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-01-07 19:14:53 +01:00
|
|
|
if (full_config && conf->ieee80211h && !conf->ieee80211d) {
|
2013-10-29 15:40:12 +01:00
|
|
|
wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without "
|
|
|
|
"IEEE 802.11d enabled");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-02-21 14:42:17 +01:00
|
|
|
if (full_config && conf->local_pwr_constraint != -1 &&
|
|
|
|
!conf->ieee80211d) {
|
|
|
|
wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2014-02-21 14:42:18 +01:00
|
|
|
if (full_config && conf->spectrum_mgmt_required &&
|
|
|
|
conf->local_pwr_constraint == -1) {
|
|
|
|
wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2019-03-20 15:58:52 +01:00
|
|
|
#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 */
|
2015-05-06 09:18:07 +02:00
|
|
|
for (i = 0; i < NUM_TX_QUEUES; i++) {
|
|
|
|
if (hostapd_config_check_cw(conf, i))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2013-10-29 15:40:12 +01:00
|
|
|
for (i = 0; i < conf->num_bss; i++) {
|
2014-01-07 19:14:53 +01:00
|
|
|
if (hostapd_config_check_bss(conf->bss[i], conf, full_config))
|
2013-10-29 15:40:12 +01:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-30 19:40:11 +02:00
|
|
|
void hostapd_set_security_params(struct hostapd_bss_config *bss,
|
|
|
|
int full_config)
|
2013-10-29 15:40:12 +01:00
|
|
|
{
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2013-10-29 15:40:12 +01:00
|
|
|
if (bss->individual_wep_key_len == 0) {
|
|
|
|
/* individual keys are not use; can use key idx0 for
|
|
|
|
* broadcast keys */
|
|
|
|
bss->broadcast_key_idx_min = 0;
|
|
|
|
}
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2013-10-29 15:40:12 +01:00
|
|
|
|
|
|
|
if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
|
|
|
|
bss->rsn_pairwise = bss->wpa_pairwise;
|
2017-11-17 11:31:41 +01:00
|
|
|
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);
|
2017-07-03 12:42:55 +02:00
|
|
|
if (!bss->wpa_group_rekey_set)
|
|
|
|
bss->wpa_group_rekey = bss->wpa_group == WPA_CIPHER_TKIP ?
|
|
|
|
600 : 86400;
|
2013-10-29 15:40:12 +01:00
|
|
|
|
2014-05-30 19:40:11 +02:00
|
|
|
if (full_config) {
|
|
|
|
bss->radius->auth_server = bss->radius->auth_servers;
|
|
|
|
bss->radius->acct_server = bss->radius->acct_servers;
|
|
|
|
}
|
2013-10-29 15:40:12 +01:00
|
|
|
|
|
|
|
if (bss->wpa && bss->ieee802_1x) {
|
|
|
|
bss->ssid.security_policy = SECURITY_WPA;
|
|
|
|
} else if (bss->wpa) {
|
|
|
|
bss->ssid.security_policy = SECURITY_WPA_PSK;
|
|
|
|
} else if (bss->ieee802_1x) {
|
|
|
|
int cipher = WPA_CIPHER_NONE;
|
|
|
|
bss->ssid.security_policy = SECURITY_IEEE_802_1X;
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->ssid.wep.default_len = bss->default_wep_key_len;
|
2014-12-20 16:45:03 +01:00
|
|
|
if (full_config && bss->default_wep_key_len) {
|
2013-10-29 15:40:12 +01:00
|
|
|
cipher = bss->default_wep_key_len >= 13 ?
|
|
|
|
WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
|
2014-12-20 16:45:03 +01:00
|
|
|
} else if (full_config && bss->ssid.wep.keys_set) {
|
|
|
|
if (bss->ssid.wep.len[0] >= 13)
|
|
|
|
cipher = WPA_CIPHER_WEP104;
|
|
|
|
else
|
|
|
|
cipher = WPA_CIPHER_WEP40;
|
|
|
|
}
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2013-10-29 15:40:12 +01:00
|
|
|
bss->wpa_group = cipher;
|
|
|
|
bss->wpa_pairwise = cipher;
|
|
|
|
bss->rsn_pairwise = cipher;
|
2014-12-20 16:45:03 +01:00
|
|
|
if (full_config)
|
|
|
|
bss->wpa_key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
|
2020-02-29 15:52:39 +01:00
|
|
|
#ifdef CONFIG_WEP
|
2013-10-29 15:40:12 +01:00
|
|
|
} else if (bss->ssid.wep.keys_set) {
|
|
|
|
int cipher = WPA_CIPHER_WEP40;
|
|
|
|
if (bss->ssid.wep.len[0] >= 13)
|
|
|
|
cipher = WPA_CIPHER_WEP104;
|
|
|
|
bss->ssid.security_policy = SECURITY_STATIC_WEP;
|
|
|
|
bss->wpa_group = cipher;
|
|
|
|
bss->wpa_pairwise = cipher;
|
|
|
|
bss->rsn_pairwise = cipher;
|
2014-12-20 16:45:03 +01:00
|
|
|
if (full_config)
|
|
|
|
bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;
|
2020-02-29 15:52:39 +01:00
|
|
|
#endif /* CONFIG_WEP */
|
2013-07-23 20:25:21 +02:00
|
|
|
} else if (bss->osen) {
|
|
|
|
bss->ssid.security_policy = SECURITY_OSEN;
|
|
|
|
bss->wpa_group = WPA_CIPHER_CCMP;
|
|
|
|
bss->wpa_pairwise = 0;
|
|
|
|
bss->rsn_pairwise = WPA_CIPHER_CCMP;
|
2013-10-29 15:40:12 +01:00
|
|
|
} else {
|
|
|
|
bss->ssid.security_policy = SECURITY_PLAINTEXT;
|
2015-09-27 12:25:00 +02:00
|
|
|
if (full_config) {
|
|
|
|
bss->wpa_group = WPA_CIPHER_NONE;
|
|
|
|
bss->wpa_pairwise = WPA_CIPHER_NONE;
|
|
|
|
bss->rsn_pairwise = WPA_CIPHER_NONE;
|
2014-12-20 16:45:03 +01:00
|
|
|
bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;
|
2015-09-27 12:25:00 +02:00
|
|
|
}
|
2013-10-29 15:40:12 +01:00
|
|
|
}
|
|
|
|
}
|
2019-01-23 23:00:28 +01:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|