2008-02-27 20:34:43 -05:00
|
|
|
/*
|
2009-12-24 14:05:40 -05:00
|
|
|
* hostapd / Configuration helper functions
|
2012-05-05 13:19:56 -04:00
|
|
|
* Copyright (c) 2003-2012, Jouni Malinen <j@w1.fi>
|
2008-02-27 20:34:43 -05:00
|
|
|
*
|
2012-02-11 09:46:35 -05:00
|
|
|
* This software may be distributed under the terms of the BSD license.
|
|
|
|
* See README for more details.
|
2008-02-27 20:34:43 -05:00
|
|
|
*/
|
|
|
|
|
2009-12-25 17:05:40 -05:00
|
|
|
#include "utils/includes.h"
|
2008-02-27 20:34:43 -05:00
|
|
|
|
2009-12-25 17:05:40 -05:00
|
|
|
#include "utils/common.h"
|
2009-11-29 16:04:43 -05:00
|
|
|
#include "crypto/sha1.h"
|
2008-02-27 20:34:43 -05:00
|
|
|
#include "radius/radius_client.h"
|
2009-11-29 14:07:52 -05:00
|
|
|
#include "common/ieee802_11_defs.h"
|
2009-12-24 14:05:40 -05:00
|
|
|
#include "common/eapol_common.h"
|
2009-11-29 16:04:43 -05:00
|
|
|
#include "eap_common/eap_wsc_common.h"
|
|
|
|
#include "eap_server/eap.h"
|
2009-12-25 17:05:40 -05:00
|
|
|
#include "wpa_auth.h"
|
2009-03-25 10:13:35 -04:00
|
|
|
#include "sta_info.h"
|
2009-12-25 17:05:40 -05:00
|
|
|
#include "ap_config.h"
|
2008-02-27 20:34:43 -05: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-24 14:05:40 -05:00
|
|
|
void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
|
2008-02-27 20:34:43 -05: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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
bss->eap_reauth_period = 3600;
|
|
|
|
|
|
|
|
bss->wpa_group_rekey = 600;
|
|
|
|
bss->wpa_gmk_rekey = 86400;
|
|
|
|
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;
|
|
|
|
bss->ap_max_inactivity = AP_MAX_INACTIVITY;
|
|
|
|
bss->eapol_version = EAPOL_VERSION;
|
2008-02-27 20:54:06 -05:00
|
|
|
|
|
|
|
bss->max_listen_interval = 65535;
|
2008-08-31 04:04:47 -04:00
|
|
|
|
2010-09-15 03:51:40 -04:00
|
|
|
bss->pwd_group = 19; /* ECC: GF(p=256) */
|
|
|
|
|
2008-08-31 04:04:47 -04:00
|
|
|
#ifdef CONFIG_IEEE80211W
|
2008-12-26 05:30:34 -05:00
|
|
|
bss->assoc_sa_query_max_timeout = 1000;
|
|
|
|
bss->assoc_sa_query_retry_timeout = 201;
|
2008-08-31 04:04:47 -04:00
|
|
|
#endif /* CONFIG_IEEE80211W */
|
2009-03-25 06:06:19 -04:00
|
|
|
#ifdef EAP_SERVER_FAST
|
2008-10-08 09:55:23 -04:00
|
|
|
/* both anonymous and authenticated provisioning */
|
|
|
|
bss->eap_fast_prov = 3;
|
2008-10-08 10:25:47 -04:00
|
|
|
bss->pac_key_lifetime = 7 * 24 * 60 * 60;
|
|
|
|
bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
|
2009-03-25 06:06:19 -04:00
|
|
|
#endif /* EAP_SERVER_FAST */
|
2011-02-01 07:34:12 -05:00
|
|
|
|
|
|
|
/* Set to -1 as defaults depends on HT in setup */
|
|
|
|
bss->wmm_enabled = -1;
|
2010-10-25 06:35:51 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
bss->ft_over_ds = 1;
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
2012-06-17 10:43:36 -04:00
|
|
|
|
|
|
|
bss->radius_das_time_window = 300;
|
2012-12-31 09:58:36 -05:00
|
|
|
|
|
|
|
bss->sae_anti_clogging_threshold = 5;
|
2008-02-27 20:34:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-26 14:35:49 -04:00
|
|
|
struct hostapd_config * hostapd_config_defaults(void)
|
2008-02-27 20:34:43 -05:00
|
|
|
{
|
2011-02-01 07:34:12 -05:00
|
|
|
#define ecw2cw(ecw) ((1 << (ecw)) - 1)
|
|
|
|
|
2008-02-27 20:34:43 -05:00
|
|
|
struct hostapd_config *conf;
|
|
|
|
struct hostapd_bss_config *bss;
|
2010-01-06 13:48:29 -05:00
|
|
|
const int aCWmin = 4, aCWmax = 10;
|
2009-03-04 05:33:24 -05:00
|
|
|
const struct hostapd_wmm_ac_params ac_bk =
|
2008-02-27 20:34:43 -05:00
|
|
|
{ aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
|
2009-03-04 05:33:24 -05:00
|
|
|
const struct hostapd_wmm_ac_params ac_be =
|
2008-02-27 20:34:43 -05:00
|
|
|
{ aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
|
2009-03-04 05:33:24 -05:00
|
|
|
const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
|
2012-08-12 04:36:45 -04:00
|
|
|
{ aCWmin - 1, aCWmin, 2, 3000 / 32, 0 };
|
2009-03-04 05:33:24 -05:00
|
|
|
const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
|
2012-08-12 04:36:45 -04:00
|
|
|
{ aCWmin - 2, aCWmin - 1, 2, 1500 / 32, 0 };
|
2011-02-01 07:34:12 -05: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-27 20:34:43 -05:00
|
|
|
|
|
|
|
conf = os_zalloc(sizeof(*conf));
|
|
|
|
bss = os_zalloc(sizeof(*bss));
|
|
|
|
if (conf == NULL || bss == NULL) {
|
2009-01-12 09:49:04 -05:00
|
|
|
wpa_printf(MSG_ERROR, "Failed to allocate memory for "
|
|
|
|
"configuration data.");
|
2008-02-27 20:34:43 -05:00
|
|
|
os_free(conf);
|
|
|
|
os_free(bss);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
bss->radius = os_zalloc(sizeof(*bss->radius));
|
|
|
|
if (bss->radius == NULL) {
|
|
|
|
os_free(conf);
|
|
|
|
os_free(bss);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
hostapd_config_defaults_bss(bss);
|
|
|
|
|
|
|
|
conf->num_bss = 1;
|
|
|
|
conf->bss = bss;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2009-03-04 05:33:24 -05: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-27 20:34:43 -05:00
|
|
|
|
2011-02-01 07:34:12 -05: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 08:44:25 -05:00
|
|
|
conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
|
2008-08-21 11:18:38 -04:00
|
|
|
|
2012-12-17 10:45:26 -05:00
|
|
|
conf->ap_table_max_size = 255;
|
|
|
|
conf->ap_table_expiration_time = 60;
|
|
|
|
|
2013-04-23 10:51:28 -04:00
|
|
|
#ifdef CONFIG_TESTING_OPTIONS
|
|
|
|
conf->ignore_probe_probability = 0.0d;
|
|
|
|
conf->ignore_auth_probability = 0.0d;
|
|
|
|
conf->ignore_assoc_probability = 0.0d;
|
|
|
|
conf->ignore_reassoc_probability = 0.0d;
|
2013-05-04 04:45:03 -04:00
|
|
|
conf->corrupt_gtk_rekey_mic_probability = 0.0d;
|
2013-04-23 10:51:28 -04:00
|
|
|
#endif /* CONFIG_TESTING_OPTIONS */
|
|
|
|
|
2013-08-31 04:49:51 -04:00
|
|
|
#ifdef CONFIG_ACS
|
|
|
|
conf->acs_num_scans = 5;
|
|
|
|
#endif /* CONFIG_ACS */
|
|
|
|
|
2008-02-27 20:34:43 -05:00
|
|
|
return conf;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_mac_comp(const void *a, const void *b)
|
|
|
|
{
|
|
|
|
return os_memcmp(a, b, sizeof(macaddr));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_mac_comp_empty(const void *a)
|
|
|
|
{
|
|
|
|
macaddr empty = { 0 };
|
|
|
|
return os_memcmp(a, empty, sizeof(macaddr));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int hostapd_config_read_wpa_psk(const char *fname,
|
|
|
|
struct hostapd_ssid *ssid)
|
|
|
|
{
|
|
|
|
FILE *f;
|
|
|
|
char buf[128], *pos;
|
|
|
|
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 09:49:04 -05:00
|
|
|
wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname);
|
2008-02-27 20:34:43 -05:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (fgets(buf, sizeof(buf), f)) {
|
|
|
|
line++;
|
|
|
|
|
|
|
|
if (buf[0] == '#')
|
|
|
|
continue;
|
|
|
|
pos = buf;
|
|
|
|
while (*pos != '\0') {
|
|
|
|
if (*pos == '\n') {
|
|
|
|
*pos = '\0';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
if (buf[0] == '\0')
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if (hwaddr_aton(buf, addr)) {
|
2009-01-12 09:49:04 -05:00
|
|
|
wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on "
|
|
|
|
"line %d in '%s'", buf, line, fname);
|
2008-02-27 20:34:43 -05:00
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
psk = os_zalloc(sizeof(*psk));
|
|
|
|
if (psk == NULL) {
|
2009-01-12 09:49:04 -05:00
|
|
|
wpa_printf(MSG_ERROR, "WPA PSK allocation failed");
|
2008-02-27 20:34:43 -05:00
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
2008-06-03 11:08:48 -04:00
|
|
|
if (is_zero_ether_addr(addr))
|
2008-02-27 20:34:43 -05:00
|
|
|
psk->group = 1;
|
|
|
|
else
|
|
|
|
os_memcpy(psk->addr, addr, ETH_ALEN);
|
|
|
|
|
|
|
|
pos = buf + 17;
|
2009-01-03 13:46:32 -05:00
|
|
|
if (*pos == '\0') {
|
2009-01-12 09:49:04 -05:00
|
|
|
wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
|
|
|
|
line, fname);
|
2008-02-27 20:34:43 -05:00
|
|
|
os_free(psk);
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
pos++;
|
|
|
|
|
|
|
|
ok = 0;
|
|
|
|
len = os_strlen(pos);
|
|
|
|
if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
|
|
|
|
ok = 1;
|
|
|
|
else if (len >= 8 && len < 64) {
|
|
|
|
pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
|
|
|
|
4096, psk->psk, PMK_LEN);
|
|
|
|
ok = 1;
|
|
|
|
}
|
|
|
|
if (!ok) {
|
2009-01-12 09:49:04 -05:00
|
|
|
wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in "
|
|
|
|
"'%s'", pos, line, fname);
|
2008-02-27 20:34:43 -05:00
|
|
|
os_free(psk);
|
|
|
|
ret = -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
psk->next = ssid->wpa_psk;
|
|
|
|
ssid->wpa_psk = psk;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose(f);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-12-21 05:11:08 -05: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:34:43 -05:00
|
|
|
int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
|
|
|
|
{
|
|
|
|
struct hostapd_ssid *ssid = &conf->ssid;
|
|
|
|
|
|
|
|
if (ssid->wpa_passphrase != NULL) {
|
|
|
|
if (ssid->wpa_psk != NULL) {
|
2009-12-21 05:11:08 -05: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-27 20:34:43 -05:00
|
|
|
}
|
|
|
|
ssid->wpa_psk->group = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ssid->wpa_psk_file) {
|
|
|
|
if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
|
|
|
|
&conf->ssid))
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int hostapd_wep_key_cmp(struct hostapd_wep_keys *a, struct hostapd_wep_keys *b)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (a->idx != b->idx || a->default_len != b->default_len)
|
|
|
|
return 1;
|
|
|
|
for (i = 0; i < NUM_WEP_KEYS; i++)
|
|
|
|
if (a->len[i] != b->len[i] ||
|
|
|
|
os_memcmp(a->key[i], b->key[i], a->len[i]) != 0)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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 13:19:56 -04: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr)
|
|
|
|
{
|
|
|
|
struct hostapd_radius_attr *prev;
|
|
|
|
|
|
|
|
while (attr) {
|
|
|
|
prev = attr;
|
|
|
|
attr = attr->next;
|
|
|
|
wpabuf_free(prev->val);
|
|
|
|
os_free(prev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-02-27 20:34:43 -05:00
|
|
|
static void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
|
|
|
|
{
|
|
|
|
os_free(user->identity);
|
|
|
|
os_free(user->password);
|
|
|
|
os_free(user);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < NUM_WEP_KEYS; i++) {
|
|
|
|
os_free(keys->key[i]);
|
|
|
|
keys->key[i] = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
|
|
|
|
{
|
|
|
|
struct hostapd_wpa_psk *psk, *prev;
|
|
|
|
struct hostapd_eap_user *user, *prev_user;
|
|
|
|
|
|
|
|
if (conf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
psk = conf->ssid.wpa_psk;
|
|
|
|
while (psk) {
|
|
|
|
prev = psk;
|
|
|
|
psk = psk->next;
|
|
|
|
os_free(prev);
|
|
|
|
}
|
|
|
|
|
|
|
|
os_free(conf->ssid.wpa_passphrase);
|
|
|
|
os_free(conf->ssid.wpa_psk_file);
|
2010-08-17 14:04:07 -04:00
|
|
|
hostapd_config_free_wep(&conf->ssid.wep);
|
2008-02-27 20:34:43 -05:00
|
|
|
#ifdef CONFIG_FULL_DYNAMIC_VLAN
|
|
|
|
os_free(conf->ssid.vlan_tagged_interface);
|
|
|
|
#endif /* CONFIG_FULL_DYNAMIC_VLAN */
|
|
|
|
|
|
|
|
user = conf->eap_user;
|
|
|
|
while (user) {
|
|
|
|
prev_user = user;
|
|
|
|
user = user->next;
|
|
|
|
hostapd_config_free_eap_user(prev_user);
|
|
|
|
}
|
2012-11-20 17:47:47 -05:00
|
|
|
os_free(conf->eap_user_sqlite);
|
2008-02-27 20:34:43 -05:00
|
|
|
|
|
|
|
os_free(conf->dump_log_name);
|
|
|
|
os_free(conf->eap_req_id_text);
|
|
|
|
os_free(conf->accept_mac);
|
|
|
|
os_free(conf->deny_mac);
|
|
|
|
os_free(conf->nas_identifier);
|
|
|
|
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 13:19:56 -04:00
|
|
|
hostapd_config_free_radius_attr(conf->radius_auth_req_attr);
|
|
|
|
hostapd_config_free_radius_attr(conf->radius_acct_req_attr);
|
2008-02-27 20:34:43 -05:00
|
|
|
os_free(conf->rsn_preauth_interfaces);
|
|
|
|
os_free(conf->ctrl_interface);
|
|
|
|
os_free(conf->ca_cert);
|
|
|
|
os_free(conf->server_cert);
|
|
|
|
os_free(conf->private_key);
|
|
|
|
os_free(conf->private_key_passwd);
|
2013-06-29 17:54:24 -04:00
|
|
|
os_free(conf->ocsp_stapling_response);
|
2008-02-27 20:34:43 -05:00
|
|
|
os_free(conf->dh_file);
|
|
|
|
os_free(conf->pac_opaque_encr_key);
|
|
|
|
os_free(conf->eap_fast_a_id);
|
2008-10-19 02:55:59 -04:00
|
|
|
os_free(conf->eap_fast_a_id_info);
|
2008-02-27 20:34:43 -05:00
|
|
|
os_free(conf->eap_sim_db);
|
|
|
|
os_free(conf->radius_server_clients);
|
|
|
|
os_free(conf->test_socket);
|
|
|
|
os_free(conf->radius);
|
2012-05-06 15:02:42 -04:00
|
|
|
os_free(conf->radius_das_shared_secret);
|
2008-02-27 20:34:43 -05:00
|
|
|
hostapd_config_free_vlan(conf);
|
2011-10-17 17:24:16 -04:00
|
|
|
os_free(conf->time_zone);
|
|
|
|
|
2008-02-27 20:34:43 -05:00
|
|
|
#ifdef CONFIG_IEEE80211R
|
|
|
|
{
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_IEEE80211R */
|
2008-11-23 12:34:26 -05: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 13:51:26 -05:00
|
|
|
os_free(conf->extra_cred);
|
2009-01-23 14:08:55 -05:00
|
|
|
os_free(conf->ap_settings);
|
2009-01-29 11:47:02 -05: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);
|
2012-06-28 12:43:29 -04: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 12:34:26 -05:00
|
|
|
#endif /* CONFIG_WPS */
|
2011-10-17 16:55:50 -04:00
|
|
|
|
|
|
|
os_free(conf->roaming_consortium);
|
2012-02-26 15:34:21 -05:00
|
|
|
os_free(conf->venue_name);
|
2012-08-25 08:58:30 -04:00
|
|
|
os_free(conf->nai_realm_data);
|
2012-07-30 14:45:31 -04:00
|
|
|
os_free(conf->network_auth_type);
|
2012-07-30 15:07:35 -04:00
|
|
|
os_free(conf->anqp_3gpp_cell_net);
|
2012-07-30 14:55:46 -04:00
|
|
|
os_free(conf->domain_name);
|
2011-12-08 17:15:04 -05:00
|
|
|
|
|
|
|
#ifdef CONFIG_RADIUS_TEST
|
|
|
|
os_free(conf->dump_msk_file);
|
|
|
|
#endif /* CONFIG_RADIUS_TEST */
|
2012-08-25 09:17:21 -04:00
|
|
|
|
|
|
|
#ifdef CONFIG_HS20
|
2012-08-25 09:03:51 -04:00
|
|
|
os_free(conf->hs20_oper_friendly_name);
|
2012-08-25 09:09:01 -04:00
|
|
|
os_free(conf->hs20_wan_metrics);
|
2012-08-25 09:12:40 -04:00
|
|
|
os_free(conf->hs20_connection_capability);
|
2012-08-25 09:17:21 -04:00
|
|
|
os_free(conf->hs20_operating_class);
|
|
|
|
#endif /* CONFIG_HS20 */
|
2012-08-27 09:20:10 -04:00
|
|
|
|
|
|
|
wpabuf_free(conf->vendor_elements);
|
2013-01-01 09:23:47 -05:00
|
|
|
|
|
|
|
os_free(conf->sae_groups);
|
2013-07-06 11:17:15 -04:00
|
|
|
|
|
|
|
os_free(conf->server_id);
|
2008-02-27 20:34:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-08 09:33:00 -05:00
|
|
|
/**
|
|
|
|
* hostapd_config_free - Free hostapd configuration
|
|
|
|
* @conf: Configuration data from hostapd_config_read().
|
|
|
|
*/
|
2008-02-27 20:34:43 -05:00
|
|
|
void hostapd_config_free(struct hostapd_config *conf)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
if (conf == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (i = 0; i < conf->num_bss; i++)
|
|
|
|
hostapd_config_free_bss(&conf->bss[i]);
|
|
|
|
os_free(conf->bss);
|
2009-12-21 15:22:49 -05:00
|
|
|
os_free(conf->supported_rates);
|
|
|
|
os_free(conf->basic_rates);
|
2008-02-27 20:34:43 -05:00
|
|
|
|
|
|
|
os_free(conf);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-08 09:33:00 -05: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 11:43:26 -04:00
|
|
|
int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
|
|
|
|
const u8 *addr, int *vlan_id)
|
2008-02-27 20:34:43 -05:00
|
|
|
{
|
|
|
|
int start, end, middle, res;
|
|
|
|
|
|
|
|
start = 0;
|
|
|
|
end = num_entries - 1;
|
|
|
|
|
|
|
|
while (start <= end) {
|
|
|
|
middle = (start + end) / 2;
|
2008-08-28 11:43:26 -04:00
|
|
|
res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
|
|
|
|
if (res == 0) {
|
|
|
|
if (vlan_id)
|
|
|
|
*vlan_id = list[middle].vlan_id;
|
2008-02-27 20:34:43 -05:00
|
|
|
return 1;
|
2008-08-28 11:43:26 -04:00
|
|
|
}
|
2008-02-27 20:34:43 -05: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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-06-25 05:03:02 -04:00
|
|
|
int hostapd_vlan_id_valid(struct hostapd_vlan *vlan, int vlan_id)
|
2008-02-27 20:34:43 -05:00
|
|
|
{
|
|
|
|
struct hostapd_vlan *v = vlan;
|
|
|
|
while (v) {
|
|
|
|
if (v->vlan_id == vlan_id || v->vlan_id == VLAN_ID_WILDCARD)
|
2013-06-25 05:03:02 -04: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-27 20:34:43 -05:00
|
|
|
return v->ifname;
|
|
|
|
v = v->next;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
|
|
|
|
const u8 *addr, const u8 *prev_psk)
|
|
|
|
{
|
|
|
|
struct hostapd_wpa_psk *psk;
|
|
|
|
int next_ok = prev_psk == NULL;
|
|
|
|
|
|
|
|
for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
|
|
|
|
if (next_ok &&
|
|
|
|
(psk->group || os_memcmp(psk->addr, addr, ETH_ALEN) == 0))
|
|
|
|
return psk->psk;
|
|
|
|
|
|
|
|
if (psk->psk == prev_psk)
|
|
|
|
next_ok = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|