Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 1 | /* |
| 2 | * hostapd / Configuration helper functions |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 3 | * Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi> |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 4 | * |
Dmitry Shmidt | c5ec7f5 | 2012-03-06 16:33:24 -0800 | [diff] [blame] | 5 | * This software may be distributed under the terms of the BSD license. |
| 6 | * See README for more details. |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include "utils/includes.h" |
| 10 | |
| 11 | #include "utils/common.h" |
| 12 | #include "crypto/sha1.h" |
| 13 | #include "radius/radius_client.h" |
| 14 | #include "common/ieee802_11_defs.h" |
| 15 | #include "common/eapol_common.h" |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 16 | #include "common/dhcp.h" |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 17 | #include "eap_common/eap_wsc_common.h" |
| 18 | #include "eap_server/eap.h" |
| 19 | #include "wpa_auth.h" |
| 20 | #include "sta_info.h" |
| 21 | #include "ap_config.h" |
| 22 | |
| 23 | |
| 24 | static void hostapd_config_free_vlan(struct hostapd_bss_config *bss) |
| 25 | { |
| 26 | struct hostapd_vlan *vlan, *prev; |
| 27 | |
| 28 | vlan = bss->vlan; |
| 29 | prev = NULL; |
| 30 | while (vlan) { |
| 31 | prev = vlan; |
| 32 | vlan = vlan->next; |
| 33 | os_free(prev); |
| 34 | } |
| 35 | |
| 36 | bss->vlan = NULL; |
| 37 | } |
| 38 | |
| 39 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 40 | #ifndef DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES |
| 41 | #define DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES 0 |
| 42 | #endif /* DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES */ |
| 43 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 44 | void hostapd_config_defaults_bss(struct hostapd_bss_config *bss) |
| 45 | { |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 46 | dl_list_init(&bss->anqp_elem); |
| 47 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 48 | bss->logger_syslog_level = HOSTAPD_LEVEL_INFO; |
| 49 | bss->logger_stdout_level = HOSTAPD_LEVEL_INFO; |
| 50 | bss->logger_syslog = (unsigned int) -1; |
| 51 | bss->logger_stdout = (unsigned int) -1; |
| 52 | |
| 53 | bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED; |
| 54 | |
| 55 | bss->wep_rekeying_period = 300; |
| 56 | /* use key0 in individual key and key1 in broadcast key */ |
| 57 | bss->broadcast_key_idx_min = 1; |
| 58 | bss->broadcast_key_idx_max = 2; |
| 59 | bss->eap_reauth_period = 3600; |
| 60 | |
| 61 | bss->wpa_group_rekey = 600; |
| 62 | bss->wpa_gmk_rekey = 86400; |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 63 | bss->wpa_group_update_count = 4; |
| 64 | bss->wpa_pairwise_update_count = 4; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 65 | bss->wpa_disable_eapol_key_retries = |
| 66 | DEFAULT_WPA_DISABLE_EAPOL_KEY_RETRIES; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 67 | bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK; |
| 68 | bss->wpa_pairwise = WPA_CIPHER_TKIP; |
| 69 | bss->wpa_group = WPA_CIPHER_TKIP; |
| 70 | bss->rsn_pairwise = 0; |
| 71 | |
| 72 | bss->max_num_sta = MAX_STA_COUNT; |
| 73 | |
| 74 | bss->dtim_period = 2; |
| 75 | |
| 76 | bss->radius_server_auth_port = 1812; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 77 | bss->eap_sim_db_timeout = 1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 78 | bss->ap_max_inactivity = AP_MAX_INACTIVITY; |
| 79 | bss->eapol_version = EAPOL_VERSION; |
| 80 | |
| 81 | bss->max_listen_interval = 65535; |
| 82 | |
| 83 | bss->pwd_group = 19; /* ECC: GF(p=256) */ |
| 84 | |
| 85 | #ifdef CONFIG_IEEE80211W |
| 86 | bss->assoc_sa_query_max_timeout = 1000; |
| 87 | bss->assoc_sa_query_retry_timeout = 201; |
Dmitry Shmidt | b36ed7c | 2014-03-17 10:57:26 -0700 | [diff] [blame] | 88 | bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 89 | #endif /* CONFIG_IEEE80211W */ |
| 90 | #ifdef EAP_SERVER_FAST |
| 91 | /* both anonymous and authenticated provisioning */ |
| 92 | bss->eap_fast_prov = 3; |
| 93 | bss->pac_key_lifetime = 7 * 24 * 60 * 60; |
| 94 | bss->pac_key_refresh_time = 1 * 24 * 60 * 60; |
| 95 | #endif /* EAP_SERVER_FAST */ |
| 96 | |
| 97 | /* Set to -1 as defaults depends on HT in setup */ |
| 98 | bss->wmm_enabled = -1; |
| 99 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 100 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 101 | bss->ft_over_ds = 1; |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 102 | bss->rkh_pos_timeout = 86400; |
| 103 | bss->rkh_neg_timeout = 60; |
| 104 | bss->rkh_pull_timeout = 1000; |
| 105 | bss->rkh_pull_retries = 4; |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 106 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 107 | |
| 108 | bss->radius_das_time_window = 300; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 109 | |
| 110 | bss->sae_anti_clogging_threshold = 5; |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 111 | |
| 112 | bss->gas_frag_limit = 1400; |
| 113 | |
| 114 | #ifdef CONFIG_FILS |
| 115 | dl_list_init(&bss->fils_realms); |
Dmitry Shmidt | ebd93af | 2017-02-21 13:40:44 -0800 | [diff] [blame] | 116 | bss->fils_hlp_wait_time = 30; |
| 117 | bss->dhcp_server_port = DHCP_SERVER_PORT; |
| 118 | bss->dhcp_relay_port = DHCP_SERVER_PORT; |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 119 | #endif /* CONFIG_FILS */ |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 120 | |
| 121 | bss->broadcast_deauth = 1; |
| 122 | |
| 123 | #ifdef CONFIG_MBO |
| 124 | bss->mbo_cell_data_conn_pref = -1; |
| 125 | #endif /* CONFIG_MBO */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 126 | } |
| 127 | |
| 128 | |
| 129 | struct hostapd_config * hostapd_config_defaults(void) |
| 130 | { |
| 131 | #define ecw2cw(ecw) ((1 << (ecw)) - 1) |
| 132 | |
| 133 | struct hostapd_config *conf; |
| 134 | struct hostapd_bss_config *bss; |
| 135 | const int aCWmin = 4, aCWmax = 10; |
| 136 | const struct hostapd_wmm_ac_params ac_bk = |
| 137 | { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */ |
| 138 | const struct hostapd_wmm_ac_params ac_be = |
| 139 | { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */ |
| 140 | const struct hostapd_wmm_ac_params ac_vi = /* video traffic */ |
Dmitry Shmidt | b36ed7c | 2014-03-17 10:57:26 -0700 | [diff] [blame] | 141 | { aCWmin - 1, aCWmin, 2, 3008 / 32, 0 }; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 142 | const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */ |
Dmitry Shmidt | b36ed7c | 2014-03-17 10:57:26 -0700 | [diff] [blame] | 143 | { aCWmin - 2, aCWmin - 1, 2, 1504 / 32, 0 }; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 144 | const struct hostapd_tx_queue_params txq_bk = |
| 145 | { 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 }; |
| 146 | const struct hostapd_tx_queue_params txq_be = |
| 147 | { 3, ecw2cw(aCWmin), 4 * (ecw2cw(aCWmin) + 1) - 1, 0}; |
| 148 | const struct hostapd_tx_queue_params txq_vi = |
| 149 | { 1, (ecw2cw(aCWmin) + 1) / 2 - 1, ecw2cw(aCWmin), 30}; |
| 150 | const struct hostapd_tx_queue_params txq_vo = |
| 151 | { 1, (ecw2cw(aCWmin) + 1) / 4 - 1, |
| 152 | (ecw2cw(aCWmin) + 1) / 2 - 1, 15}; |
| 153 | |
| 154 | #undef ecw2cw |
| 155 | |
| 156 | conf = os_zalloc(sizeof(*conf)); |
| 157 | bss = os_zalloc(sizeof(*bss)); |
| 158 | if (conf == NULL || bss == NULL) { |
| 159 | wpa_printf(MSG_ERROR, "Failed to allocate memory for " |
| 160 | "configuration data."); |
| 161 | os_free(conf); |
| 162 | os_free(bss); |
| 163 | return NULL; |
| 164 | } |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 165 | conf->bss = os_calloc(1, sizeof(struct hostapd_bss_config *)); |
| 166 | if (conf->bss == NULL) { |
| 167 | os_free(conf); |
| 168 | os_free(bss); |
| 169 | return NULL; |
| 170 | } |
| 171 | conf->bss[0] = bss; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 172 | |
| 173 | bss->radius = os_zalloc(sizeof(*bss->radius)); |
| 174 | if (bss->radius == NULL) { |
Dmitry Shmidt | 9767226 | 2014-02-03 13:02:54 -0800 | [diff] [blame] | 175 | os_free(conf->bss); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 176 | os_free(conf); |
| 177 | os_free(bss); |
| 178 | return NULL; |
| 179 | } |
| 180 | |
| 181 | hostapd_config_defaults_bss(bss); |
| 182 | |
| 183 | conf->num_bss = 1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 184 | |
| 185 | conf->beacon_int = 100; |
| 186 | conf->rts_threshold = -1; /* use driver default: 2347 */ |
| 187 | conf->fragm_threshold = -1; /* user driver default: 2346 */ |
| 188 | conf->send_probe_response = 1; |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 189 | /* Set to invalid value means do not add Power Constraint IE */ |
| 190 | conf->local_pwr_constraint = -1; |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 191 | |
| 192 | conf->wmm_ac_params[0] = ac_be; |
| 193 | conf->wmm_ac_params[1] = ac_bk; |
| 194 | conf->wmm_ac_params[2] = ac_vi; |
| 195 | conf->wmm_ac_params[3] = ac_vo; |
| 196 | |
| 197 | conf->tx_queue[0] = txq_vo; |
| 198 | conf->tx_queue[1] = txq_vi; |
| 199 | conf->tx_queue[2] = txq_be; |
| 200 | conf->tx_queue[3] = txq_bk; |
| 201 | |
| 202 | conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED; |
| 203 | |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 204 | conf->ap_table_max_size = 255; |
| 205 | conf->ap_table_expiration_time = 60; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 206 | conf->track_sta_max_age = 180; |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 207 | |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 208 | #ifdef CONFIG_TESTING_OPTIONS |
Dmitry Shmidt | 7832adb | 2014-04-29 10:53:02 -0700 | [diff] [blame] | 209 | conf->ignore_probe_probability = 0.0; |
| 210 | conf->ignore_auth_probability = 0.0; |
| 211 | conf->ignore_assoc_probability = 0.0; |
| 212 | conf->ignore_reassoc_probability = 0.0; |
| 213 | conf->corrupt_gtk_rekey_mic_probability = 0.0; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 214 | conf->ecsa_ie_only = 0; |
Dmitry Shmidt | 8da800a | 2013-04-24 12:57:01 -0700 | [diff] [blame] | 215 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 216 | |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 217 | conf->acs = 0; |
| 218 | conf->acs_ch_list.num = 0; |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 219 | #ifdef CONFIG_ACS |
| 220 | conf->acs_num_scans = 5; |
| 221 | #endif /* CONFIG_ACS */ |
| 222 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 223 | /* The third octet of the country string uses an ASCII space character |
| 224 | * by default to indicate that the regulations encompass all |
| 225 | * environments for the current frequency band in the country. */ |
| 226 | conf->country[2] = ' '; |
| 227 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 228 | return conf; |
| 229 | } |
| 230 | |
| 231 | |
| 232 | int hostapd_mac_comp(const void *a, const void *b) |
| 233 | { |
| 234 | return os_memcmp(a, b, sizeof(macaddr)); |
| 235 | } |
| 236 | |
| 237 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 238 | static int hostapd_config_read_wpa_psk(const char *fname, |
| 239 | struct hostapd_ssid *ssid) |
| 240 | { |
| 241 | FILE *f; |
| 242 | char buf[128], *pos; |
| 243 | int line = 0, ret = 0, len, ok; |
| 244 | u8 addr[ETH_ALEN]; |
| 245 | struct hostapd_wpa_psk *psk; |
| 246 | |
| 247 | if (!fname) |
| 248 | return 0; |
| 249 | |
| 250 | f = fopen(fname, "r"); |
| 251 | if (!f) { |
| 252 | wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname); |
| 253 | return -1; |
| 254 | } |
| 255 | |
| 256 | while (fgets(buf, sizeof(buf), f)) { |
| 257 | line++; |
| 258 | |
| 259 | if (buf[0] == '#') |
| 260 | continue; |
| 261 | pos = buf; |
| 262 | while (*pos != '\0') { |
| 263 | if (*pos == '\n') { |
| 264 | *pos = '\0'; |
| 265 | break; |
| 266 | } |
| 267 | pos++; |
| 268 | } |
| 269 | if (buf[0] == '\0') |
| 270 | continue; |
| 271 | |
| 272 | if (hwaddr_aton(buf, addr)) { |
| 273 | wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on " |
| 274 | "line %d in '%s'", buf, line, fname); |
| 275 | ret = -1; |
| 276 | break; |
| 277 | } |
| 278 | |
| 279 | psk = os_zalloc(sizeof(*psk)); |
| 280 | if (psk == NULL) { |
| 281 | wpa_printf(MSG_ERROR, "WPA PSK allocation failed"); |
| 282 | ret = -1; |
| 283 | break; |
| 284 | } |
| 285 | if (is_zero_ether_addr(addr)) |
| 286 | psk->group = 1; |
| 287 | else |
| 288 | os_memcpy(psk->addr, addr, ETH_ALEN); |
| 289 | |
| 290 | pos = buf + 17; |
| 291 | if (*pos == '\0') { |
| 292 | wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'", |
| 293 | line, fname); |
| 294 | os_free(psk); |
| 295 | ret = -1; |
| 296 | break; |
| 297 | } |
| 298 | pos++; |
| 299 | |
| 300 | ok = 0; |
| 301 | len = os_strlen(pos); |
| 302 | if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0) |
| 303 | ok = 1; |
| 304 | else if (len >= 8 && len < 64) { |
| 305 | pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len, |
| 306 | 4096, psk->psk, PMK_LEN); |
| 307 | ok = 1; |
| 308 | } |
| 309 | if (!ok) { |
| 310 | wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in " |
| 311 | "'%s'", pos, line, fname); |
| 312 | os_free(psk); |
| 313 | ret = -1; |
| 314 | break; |
| 315 | } |
| 316 | |
| 317 | psk->next = ssid->wpa_psk; |
| 318 | ssid->wpa_psk = psk; |
| 319 | } |
| 320 | |
| 321 | fclose(f); |
| 322 | |
| 323 | return ret; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | static int hostapd_derive_psk(struct hostapd_ssid *ssid) |
| 328 | { |
| 329 | ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk)); |
| 330 | if (ssid->wpa_psk == NULL) { |
| 331 | wpa_printf(MSG_ERROR, "Unable to alloc space for PSK"); |
| 332 | return -1; |
| 333 | } |
| 334 | wpa_hexdump_ascii(MSG_DEBUG, "SSID", |
| 335 | (u8 *) ssid->ssid, ssid->ssid_len); |
| 336 | wpa_hexdump_ascii_key(MSG_DEBUG, "PSK (ASCII passphrase)", |
| 337 | (u8 *) ssid->wpa_passphrase, |
| 338 | os_strlen(ssid->wpa_passphrase)); |
| 339 | pbkdf2_sha1(ssid->wpa_passphrase, |
| 340 | ssid->ssid, ssid->ssid_len, |
| 341 | 4096, ssid->wpa_psk->psk, PMK_LEN); |
| 342 | wpa_hexdump_key(MSG_DEBUG, "PSK (from passphrase)", |
| 343 | ssid->wpa_psk->psk, PMK_LEN); |
| 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | |
| 348 | int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf) |
| 349 | { |
| 350 | struct hostapd_ssid *ssid = &conf->ssid; |
| 351 | |
| 352 | if (ssid->wpa_passphrase != NULL) { |
| 353 | if (ssid->wpa_psk != NULL) { |
| 354 | wpa_printf(MSG_DEBUG, "Using pre-configured WPA PSK " |
| 355 | "instead of passphrase"); |
| 356 | } else { |
| 357 | wpa_printf(MSG_DEBUG, "Deriving WPA PSK based on " |
| 358 | "passphrase"); |
| 359 | if (hostapd_derive_psk(ssid) < 0) |
| 360 | return -1; |
| 361 | } |
| 362 | ssid->wpa_psk->group = 1; |
| 363 | } |
| 364 | |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 365 | return hostapd_config_read_wpa_psk(ssid->wpa_psk_file, &conf->ssid); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 366 | } |
| 367 | |
| 368 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 369 | static void hostapd_config_free_radius(struct hostapd_radius_server *servers, |
| 370 | int num_servers) |
| 371 | { |
| 372 | int i; |
| 373 | |
| 374 | for (i = 0; i < num_servers; i++) { |
| 375 | os_free(servers[i].shared_secret); |
| 376 | } |
| 377 | os_free(servers); |
| 378 | } |
| 379 | |
| 380 | |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 381 | struct hostapd_radius_attr * |
| 382 | hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type) |
| 383 | { |
| 384 | for (; attr; attr = attr->next) { |
| 385 | if (attr->type == type) |
| 386 | return attr; |
| 387 | } |
| 388 | return NULL; |
| 389 | } |
| 390 | |
| 391 | |
| 392 | static void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr) |
| 393 | { |
| 394 | struct hostapd_radius_attr *prev; |
| 395 | |
| 396 | while (attr) { |
| 397 | prev = attr; |
| 398 | attr = attr->next; |
| 399 | wpabuf_free(prev->val); |
| 400 | os_free(prev); |
| 401 | } |
| 402 | } |
| 403 | |
| 404 | |
Dmitry Shmidt | 818ea48 | 2014-03-10 13:15:21 -0700 | [diff] [blame] | 405 | void hostapd_config_free_eap_user(struct hostapd_eap_user *user) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 406 | { |
Dmitry Shmidt | 818ea48 | 2014-03-10 13:15:21 -0700 | [diff] [blame] | 407 | hostapd_config_free_radius_attr(user->accept_attr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 408 | os_free(user->identity); |
Dmitry Shmidt | c281702 | 2014-07-02 10:32:10 -0700 | [diff] [blame] | 409 | bin_clear_free(user->password, user->password_len); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 410 | os_free(user); |
| 411 | } |
| 412 | |
| 413 | |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 414 | void hostapd_config_free_eap_users(struct hostapd_eap_user *user) |
| 415 | { |
| 416 | struct hostapd_eap_user *prev_user; |
| 417 | |
| 418 | while (user) { |
| 419 | prev_user = user; |
| 420 | user = user->next; |
| 421 | hostapd_config_free_eap_user(prev_user); |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 426 | static void hostapd_config_free_wep(struct hostapd_wep_keys *keys) |
| 427 | { |
| 428 | int i; |
| 429 | for (i = 0; i < NUM_WEP_KEYS; i++) { |
Dmitry Shmidt | c281702 | 2014-07-02 10:32:10 -0700 | [diff] [blame] | 430 | bin_clear_free(keys->key[i], keys->len[i]); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 431 | keys->key[i] = NULL; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 436 | void hostapd_config_clear_wpa_psk(struct hostapd_wpa_psk **l) |
| 437 | { |
| 438 | struct hostapd_wpa_psk *psk, *tmp; |
| 439 | |
| 440 | for (psk = *l; psk;) { |
| 441 | tmp = psk; |
| 442 | psk = psk->next; |
| 443 | bin_clear_free(tmp, sizeof(*tmp)); |
| 444 | } |
| 445 | *l = NULL; |
| 446 | } |
| 447 | |
| 448 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 449 | static void hostapd_config_free_anqp_elem(struct hostapd_bss_config *conf) |
| 450 | { |
| 451 | struct anqp_element *elem; |
| 452 | |
| 453 | while ((elem = dl_list_first(&conf->anqp_elem, struct anqp_element, |
| 454 | list))) { |
| 455 | dl_list_del(&elem->list); |
| 456 | wpabuf_free(elem->payload); |
| 457 | os_free(elem); |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 462 | static void hostapd_config_free_fils_realms(struct hostapd_bss_config *conf) |
| 463 | { |
| 464 | #ifdef CONFIG_FILS |
| 465 | struct fils_realm *realm; |
| 466 | |
| 467 | while ((realm = dl_list_first(&conf->fils_realms, struct fils_realm, |
| 468 | list))) { |
| 469 | dl_list_del(&realm->list); |
| 470 | os_free(realm); |
| 471 | } |
| 472 | #endif /* CONFIG_FILS */ |
| 473 | } |
| 474 | |
| 475 | |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 476 | void hostapd_config_free_bss(struct hostapd_bss_config *conf) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 477 | { |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 478 | if (conf == NULL) |
| 479 | return; |
| 480 | |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 481 | hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 482 | |
Dmitry Shmidt | c281702 | 2014-07-02 10:32:10 -0700 | [diff] [blame] | 483 | str_clear_free(conf->ssid.wpa_passphrase); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 484 | os_free(conf->ssid.wpa_psk_file); |
| 485 | hostapd_config_free_wep(&conf->ssid.wep); |
| 486 | #ifdef CONFIG_FULL_DYNAMIC_VLAN |
| 487 | os_free(conf->ssid.vlan_tagged_interface); |
| 488 | #endif /* CONFIG_FULL_DYNAMIC_VLAN */ |
| 489 | |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 490 | hostapd_config_free_eap_users(conf->eap_user); |
Dmitry Shmidt | d5e4923 | 2012-12-03 15:08:10 -0800 | [diff] [blame] | 491 | os_free(conf->eap_user_sqlite); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 492 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 493 | os_free(conf->eap_req_id_text); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 494 | os_free(conf->erp_domain); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 495 | os_free(conf->accept_mac); |
| 496 | os_free(conf->deny_mac); |
| 497 | os_free(conf->nas_identifier); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 498 | if (conf->radius) { |
| 499 | hostapd_config_free_radius(conf->radius->auth_servers, |
| 500 | conf->radius->num_auth_servers); |
| 501 | hostapd_config_free_radius(conf->radius->acct_servers, |
| 502 | conf->radius->num_acct_servers); |
| 503 | } |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 504 | hostapd_config_free_radius_attr(conf->radius_auth_req_attr); |
| 505 | hostapd_config_free_radius_attr(conf->radius_acct_req_attr); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 506 | os_free(conf->rsn_preauth_interfaces); |
| 507 | os_free(conf->ctrl_interface); |
| 508 | os_free(conf->ca_cert); |
| 509 | os_free(conf->server_cert); |
| 510 | os_free(conf->private_key); |
| 511 | os_free(conf->private_key_passwd); |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 512 | os_free(conf->ocsp_stapling_response); |
Dmitry Shmidt | 014a3ff | 2015-12-28 13:27:49 -0800 | [diff] [blame] | 513 | os_free(conf->ocsp_stapling_response_multi); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 514 | os_free(conf->dh_file); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 515 | os_free(conf->openssl_ciphers); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 516 | os_free(conf->pac_opaque_encr_key); |
| 517 | os_free(conf->eap_fast_a_id); |
| 518 | os_free(conf->eap_fast_a_id_info); |
| 519 | os_free(conf->eap_sim_db); |
| 520 | os_free(conf->radius_server_clients); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 521 | os_free(conf->radius); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 522 | os_free(conf->radius_das_shared_secret); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 523 | hostapd_config_free_vlan(conf); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 524 | os_free(conf->time_zone); |
| 525 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 526 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 527 | { |
| 528 | struct ft_remote_r0kh *r0kh, *r0kh_prev; |
| 529 | struct ft_remote_r1kh *r1kh, *r1kh_prev; |
| 530 | |
| 531 | r0kh = conf->r0kh_list; |
| 532 | conf->r0kh_list = NULL; |
| 533 | while (r0kh) { |
| 534 | r0kh_prev = r0kh; |
| 535 | r0kh = r0kh->next; |
| 536 | os_free(r0kh_prev); |
| 537 | } |
| 538 | |
| 539 | r1kh = conf->r1kh_list; |
| 540 | conf->r1kh_list = NULL; |
| 541 | while (r1kh) { |
| 542 | r1kh_prev = r1kh; |
| 543 | r1kh = r1kh->next; |
| 544 | os_free(r1kh_prev); |
| 545 | } |
| 546 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 547 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 548 | |
| 549 | #ifdef CONFIG_WPS |
| 550 | os_free(conf->wps_pin_requests); |
| 551 | os_free(conf->device_name); |
| 552 | os_free(conf->manufacturer); |
| 553 | os_free(conf->model_name); |
| 554 | os_free(conf->model_number); |
| 555 | os_free(conf->serial_number); |
| 556 | os_free(conf->config_methods); |
| 557 | os_free(conf->ap_pin); |
| 558 | os_free(conf->extra_cred); |
| 559 | os_free(conf->ap_settings); |
| 560 | os_free(conf->upnp_iface); |
| 561 | os_free(conf->friendly_name); |
| 562 | os_free(conf->manufacturer_url); |
| 563 | os_free(conf->model_description); |
| 564 | os_free(conf->model_url); |
| 565 | os_free(conf->upc); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 566 | { |
| 567 | unsigned int i; |
| 568 | |
| 569 | for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) |
| 570 | wpabuf_free(conf->wps_vendor_ext[i]); |
| 571 | } |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 572 | wpabuf_free(conf->wps_nfc_dh_pubkey); |
| 573 | wpabuf_free(conf->wps_nfc_dh_privkey); |
| 574 | wpabuf_free(conf->wps_nfc_dev_pw); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 575 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 576 | |
| 577 | os_free(conf->roaming_consortium); |
Dmitry Shmidt | 0494959 | 2012-07-19 12:16:46 -0700 | [diff] [blame] | 578 | os_free(conf->venue_name); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 579 | os_free(conf->nai_realm_data); |
| 580 | os_free(conf->network_auth_type); |
| 581 | os_free(conf->anqp_3gpp_cell_net); |
| 582 | os_free(conf->domain_name); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 583 | hostapd_config_free_anqp_elem(conf); |
Dmitry Shmidt | 1f69aa5 | 2012-01-24 16:10:04 -0800 | [diff] [blame] | 584 | |
| 585 | #ifdef CONFIG_RADIUS_TEST |
| 586 | os_free(conf->dump_msk_file); |
| 587 | #endif /* CONFIG_RADIUS_TEST */ |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 588 | |
| 589 | #ifdef CONFIG_HS20 |
| 590 | os_free(conf->hs20_oper_friendly_name); |
| 591 | os_free(conf->hs20_wan_metrics); |
| 592 | os_free(conf->hs20_connection_capability); |
| 593 | os_free(conf->hs20_operating_class); |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 594 | os_free(conf->hs20_icons); |
| 595 | if (conf->hs20_osu_providers) { |
| 596 | size_t i; |
| 597 | for (i = 0; i < conf->hs20_osu_providers_count; i++) { |
| 598 | struct hs20_osu_provider *p; |
| 599 | size_t j; |
| 600 | p = &conf->hs20_osu_providers[i]; |
| 601 | os_free(p->friendly_name); |
| 602 | os_free(p->server_uri); |
| 603 | os_free(p->method_list); |
| 604 | for (j = 0; j < p->icons_count; j++) |
| 605 | os_free(p->icons[j]); |
| 606 | os_free(p->icons); |
| 607 | os_free(p->osu_nai); |
| 608 | os_free(p->service_desc); |
| 609 | } |
| 610 | os_free(conf->hs20_osu_providers); |
| 611 | } |
| 612 | os_free(conf->subscr_remediation_url); |
Dmitry Shmidt | 61d9df3 | 2012-08-29 16:22:06 -0700 | [diff] [blame] | 613 | #endif /* CONFIG_HS20 */ |
| 614 | |
| 615 | wpabuf_free(conf->vendor_elements); |
Dmitry Shmidt | 849734c | 2016-05-27 09:59:01 -0700 | [diff] [blame] | 616 | wpabuf_free(conf->assocresp_elements); |
Dmitry Shmidt | a54fa5f | 2013-01-15 13:53:35 -0800 | [diff] [blame] | 617 | |
| 618 | os_free(conf->sae_groups); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 619 | #ifdef CONFIG_OWE |
| 620 | os_free(conf->owe_groups); |
| 621 | #endif /* CONFIG_OWE */ |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 622 | |
Dmitry Shmidt | 0207e23 | 2014-09-03 14:58:37 -0700 | [diff] [blame] | 623 | os_free(conf->wowlan_triggers); |
| 624 | |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 625 | os_free(conf->server_id); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 626 | |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 627 | #ifdef CONFIG_TESTING_OPTIONS |
| 628 | wpabuf_free(conf->own_ie_override); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 629 | wpabuf_free(conf->sae_commit_override); |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 630 | #endif /* CONFIG_TESTING_OPTIONS */ |
| 631 | |
| 632 | os_free(conf->no_probe_resp_if_seen_on); |
| 633 | os_free(conf->no_auth_if_seen_on); |
| 634 | |
Dmitry Shmidt | 2933359 | 2017-01-09 12:27:11 -0800 | [diff] [blame] | 635 | hostapd_config_free_fils_realms(conf); |
| 636 | |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 637 | #ifdef CONFIG_DPP |
| 638 | os_free(conf->dpp_connector); |
| 639 | wpabuf_free(conf->dpp_netaccesskey); |
| 640 | wpabuf_free(conf->dpp_csign); |
| 641 | #endif /* CONFIG_DPP */ |
| 642 | |
| 643 | os_free(conf->sae_password); |
| 644 | |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 645 | os_free(conf); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 646 | } |
| 647 | |
| 648 | |
| 649 | /** |
| 650 | * hostapd_config_free - Free hostapd configuration |
| 651 | * @conf: Configuration data from hostapd_config_read(). |
| 652 | */ |
| 653 | void hostapd_config_free(struct hostapd_config *conf) |
| 654 | { |
| 655 | size_t i; |
| 656 | |
| 657 | if (conf == NULL) |
| 658 | return; |
| 659 | |
| 660 | for (i = 0; i < conf->num_bss; i++) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 661 | hostapd_config_free_bss(conf->bss[i]); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 662 | os_free(conf->bss); |
| 663 | os_free(conf->supported_rates); |
| 664 | os_free(conf->basic_rates); |
Dmitry Shmidt | dda10c2 | 2015-03-24 16:05:01 -0700 | [diff] [blame] | 665 | os_free(conf->acs_ch_list.range); |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 666 | os_free(conf->driver_params); |
Dmitry Shmidt | 7f65602 | 2015-02-25 14:36:37 -0800 | [diff] [blame] | 667 | #ifdef CONFIG_ACS |
| 668 | os_free(conf->acs_chan_bias); |
| 669 | #endif /* CONFIG_ACS */ |
Dmitry Shmidt | 849734c | 2016-05-27 09:59:01 -0700 | [diff] [blame] | 670 | wpabuf_free(conf->lci); |
| 671 | wpabuf_free(conf->civic); |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 672 | |
| 673 | os_free(conf); |
| 674 | } |
| 675 | |
| 676 | |
| 677 | /** |
| 678 | * hostapd_maclist_found - Find a MAC address from a list |
| 679 | * @list: MAC address list |
| 680 | * @num_entries: Number of addresses in the list |
| 681 | * @addr: Address to search for |
| 682 | * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed |
| 683 | * Returns: 1 if address is in the list or 0 if not. |
| 684 | * |
| 685 | * Perform a binary search for given MAC address from a pre-sorted list. |
| 686 | */ |
| 687 | int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries, |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 688 | const u8 *addr, struct vlan_description *vlan_id) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 689 | { |
| 690 | int start, end, middle, res; |
| 691 | |
| 692 | start = 0; |
| 693 | end = num_entries - 1; |
| 694 | |
| 695 | while (start <= end) { |
| 696 | middle = (start + end) / 2; |
| 697 | res = os_memcmp(list[middle].addr, addr, ETH_ALEN); |
| 698 | if (res == 0) { |
| 699 | if (vlan_id) |
| 700 | *vlan_id = list[middle].vlan_id; |
| 701 | return 1; |
| 702 | } |
| 703 | if (res < 0) |
| 704 | start = middle + 1; |
| 705 | else |
| 706 | end = middle - 1; |
| 707 | } |
| 708 | |
| 709 | return 0; |
| 710 | } |
| 711 | |
| 712 | |
| 713 | int hostapd_rate_found(int *list, int rate) |
| 714 | { |
| 715 | int i; |
| 716 | |
| 717 | if (list == NULL) |
| 718 | return 0; |
| 719 | |
| 720 | for (i = 0; list[i] >= 0; i++) |
| 721 | if (list[i] == rate) |
| 722 | return 1; |
| 723 | |
| 724 | return 0; |
| 725 | } |
| 726 | |
| 727 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 728 | int hostapd_vlan_valid(struct hostapd_vlan *vlan, |
| 729 | struct vlan_description *vlan_desc) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 730 | { |
| 731 | struct hostapd_vlan *v = vlan; |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 732 | int i; |
| 733 | |
| 734 | if (!vlan_desc->notempty || vlan_desc->untagged < 0 || |
| 735 | vlan_desc->untagged > MAX_VLAN_ID) |
| 736 | return 0; |
| 737 | for (i = 0; i < MAX_NUM_TAGGED_VLAN; i++) { |
| 738 | if (vlan_desc->tagged[i] < 0 || |
| 739 | vlan_desc->tagged[i] > MAX_VLAN_ID) |
| 740 | return 0; |
| 741 | } |
| 742 | if (!vlan_desc->untagged && !vlan_desc->tagged[0]) |
| 743 | return 0; |
| 744 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 745 | while (v) { |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 746 | if (!vlan_compare(&v->vlan_desc, vlan_desc) || |
| 747 | v->vlan_id == VLAN_ID_WILDCARD) |
Dmitry Shmidt | 34af306 | 2013-07-11 10:46:32 -0700 | [diff] [blame] | 748 | return 1; |
| 749 | v = v->next; |
| 750 | } |
| 751 | return 0; |
| 752 | } |
| 753 | |
| 754 | |
| 755 | const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id) |
| 756 | { |
| 757 | struct hostapd_vlan *v = vlan; |
| 758 | while (v) { |
| 759 | if (v->vlan_id == vlan_id) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 760 | return v->ifname; |
| 761 | v = v->next; |
| 762 | } |
| 763 | return NULL; |
| 764 | } |
| 765 | |
| 766 | |
| 767 | const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf, |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 768 | const u8 *addr, const u8 *p2p_dev_addr, |
| 769 | const u8 *prev_psk) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 770 | { |
| 771 | struct hostapd_wpa_psk *psk; |
| 772 | int next_ok = prev_psk == NULL; |
| 773 | |
Dmitry Shmidt | df5a7e4 | 2014-04-02 12:59:59 -0700 | [diff] [blame] | 774 | if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) { |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 775 | wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR |
| 776 | " p2p_dev_addr=" MACSTR " prev_psk=%p", |
| 777 | MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk); |
Dmitry Shmidt | df5a7e4 | 2014-04-02 12:59:59 -0700 | [diff] [blame] | 778 | addr = NULL; /* Use P2P Device Address for matching */ |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 779 | } else { |
| 780 | wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR |
| 781 | " prev_psk=%p", |
| 782 | MAC2STR(addr), prev_psk); |
| 783 | } |
| 784 | |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 785 | for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) { |
| 786 | if (next_ok && |
Dmitry Shmidt | 391c59f | 2013-09-03 12:16:28 -0700 | [diff] [blame] | 787 | (psk->group || |
| 788 | (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) || |
| 789 | (!addr && p2p_dev_addr && |
| 790 | os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) == |
| 791 | 0))) |
Dmitry Shmidt | 8d520ff | 2011-05-09 14:06:53 -0700 | [diff] [blame] | 792 | return psk->psk; |
| 793 | |
| 794 | if (psk->psk == prev_psk) |
| 795 | next_ok = 1; |
| 796 | } |
| 797 | |
| 798 | return NULL; |
| 799 | } |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 800 | |
| 801 | |
| 802 | static int hostapd_config_check_bss(struct hostapd_bss_config *bss, |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 803 | struct hostapd_config *conf, |
| 804 | int full_config) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 805 | { |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 806 | if (full_config && bss->ieee802_1x && !bss->eap_server && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 807 | !bss->radius->auth_servers) { |
| 808 | wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no " |
| 809 | "EAP authenticator configured)."); |
| 810 | return -1; |
| 811 | } |
| 812 | |
| 813 | if (bss->wpa) { |
| 814 | int wep, i; |
| 815 | |
| 816 | wep = bss->default_wep_key_len > 0 || |
| 817 | bss->individual_wep_key_len > 0; |
| 818 | for (i = 0; i < NUM_WEP_KEYS; i++) { |
| 819 | if (bss->ssid.wep.keys_set) { |
| 820 | wep = 1; |
| 821 | break; |
| 822 | } |
| 823 | } |
| 824 | |
| 825 | if (wep) { |
| 826 | wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported"); |
| 827 | return -1; |
| 828 | } |
| 829 | } |
| 830 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 831 | if (full_config && bss->wpa && |
| 832 | bss->wpa_psk_radius != PSK_RADIUS_IGNORED && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 833 | bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) { |
| 834 | wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no " |
| 835 | "RADIUS checking (macaddr_acl=2) enabled."); |
| 836 | return -1; |
| 837 | } |
| 838 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 839 | if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 840 | bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL && |
| 841 | bss->ssid.wpa_psk_file == NULL && |
| 842 | (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED || |
| 843 | bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) { |
| 844 | wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase " |
| 845 | "is not configured."); |
| 846 | return -1; |
| 847 | } |
| 848 | |
Dmitry Shmidt | 9c17526 | 2016-03-03 10:20:07 -0800 | [diff] [blame] | 849 | if (full_config && !is_zero_ether_addr(bss->bssid)) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 850 | size_t i; |
| 851 | |
| 852 | for (i = 0; i < conf->num_bss; i++) { |
| 853 | if (conf->bss[i] != bss && |
| 854 | (hostapd_mac_comp(conf->bss[i]->bssid, |
| 855 | bss->bssid) == 0)) { |
| 856 | wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR |
| 857 | " on interface '%s' and '%s'.", |
| 858 | MAC2STR(bss->bssid), |
| 859 | conf->bss[i]->iface, bss->iface); |
| 860 | return -1; |
| 861 | } |
| 862 | } |
| 863 | } |
| 864 | |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 865 | #ifdef CONFIG_IEEE80211R_AP |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 866 | if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 867 | (bss->nas_identifier == NULL || |
| 868 | os_strlen(bss->nas_identifier) < 1 || |
| 869 | os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) { |
| 870 | wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires " |
| 871 | "nas_identifier to be configured as a 1..48 octet " |
| 872 | "string"); |
| 873 | return -1; |
| 874 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 875 | #endif /* CONFIG_IEEE80211R_AP */ |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 876 | |
| 877 | #ifdef CONFIG_IEEE80211N |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 878 | if (full_config && conf->ieee80211n && |
| 879 | conf->hw_mode == HOSTAPD_MODE_IEEE80211B) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 880 | bss->disable_11n = 1; |
| 881 | wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not " |
Dmitry Shmidt | 661b4f7 | 2014-09-29 14:58:27 -0700 | [diff] [blame] | 882 | "allowed, disabling HT capabilities"); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 883 | } |
| 884 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 885 | if (full_config && conf->ieee80211n && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 886 | bss->ssid.security_policy == SECURITY_STATIC_WEP) { |
| 887 | bss->disable_11n = 1; |
| 888 | wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not " |
| 889 | "allowed, disabling HT capabilities"); |
| 890 | } |
| 891 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 892 | if (full_config && conf->ieee80211n && bss->wpa && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 893 | !(bss->wpa_pairwise & WPA_CIPHER_CCMP) && |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 894 | !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | |
| 895 | WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256))) |
| 896 | { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 897 | bss->disable_11n = 1; |
| 898 | wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 " |
| 899 | "requires CCMP/GCMP to be enabled, disabling HT " |
| 900 | "capabilities"); |
| 901 | } |
| 902 | #endif /* CONFIG_IEEE80211N */ |
| 903 | |
Dmitry Shmidt | 7f2c753 | 2016-08-15 09:48:12 -0700 | [diff] [blame] | 904 | #ifdef CONFIG_IEEE80211AC |
| 905 | if (full_config && conf->ieee80211ac && |
| 906 | bss->ssid.security_policy == SECURITY_STATIC_WEP) { |
| 907 | bss->disable_11ac = 1; |
| 908 | wpa_printf(MSG_ERROR, |
| 909 | "VHT (IEEE 802.11ac) with WEP is not allowed, disabling VHT capabilities"); |
| 910 | } |
Dmitry Shmidt | 9839ecd | 2016-11-07 11:05:47 -0800 | [diff] [blame] | 911 | |
| 912 | if (full_config && conf->ieee80211ac && bss->wpa && |
| 913 | !(bss->wpa_pairwise & WPA_CIPHER_CCMP) && |
| 914 | !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | |
| 915 | WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256))) |
| 916 | { |
| 917 | bss->disable_11ac = 1; |
| 918 | wpa_printf(MSG_ERROR, |
| 919 | "VHT (IEEE 802.11ac) with WPA/WPA2 requires CCMP/GCMP to be enabled, disabling VHT capabilities"); |
| 920 | } |
Dmitry Shmidt | 7f2c753 | 2016-08-15 09:48:12 -0700 | [diff] [blame] | 921 | #endif /* CONFIG_IEEE80211AC */ |
| 922 | |
Dmitry Shmidt | 1590709 | 2014-03-25 10:42:57 -0700 | [diff] [blame] | 923 | #ifdef CONFIG_WPS |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 924 | if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 925 | wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid " |
| 926 | "configuration forced WPS to be disabled"); |
| 927 | bss->wps_state = 0; |
| 928 | } |
| 929 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 930 | if (full_config && bss->wps_state && |
| 931 | bss->ssid.wep.keys_set && bss->wpa == 0) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 932 | wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be " |
| 933 | "disabled"); |
| 934 | bss->wps_state = 0; |
| 935 | } |
| 936 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 937 | if (full_config && bss->wps_state && bss->wpa && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 938 | (!(bss->wpa & 2) || |
Dmitry Shmidt | 1d755d0 | 2015-04-28 10:34:29 -0700 | [diff] [blame] | 939 | !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)))) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 940 | wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without " |
Dmitry Shmidt | 1d755d0 | 2015-04-28 10:34:29 -0700 | [diff] [blame] | 941 | "WPA2/CCMP/GCMP forced WPS to be disabled"); |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 942 | bss->wps_state = 0; |
| 943 | } |
Dmitry Shmidt | 1590709 | 2014-03-25 10:42:57 -0700 | [diff] [blame] | 944 | #endif /* CONFIG_WPS */ |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 945 | |
| 946 | #ifdef CONFIG_HS20 |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 947 | if (full_config && bss->hs20 && |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 948 | (!(bss->wpa & 2) || |
Dmitry Shmidt | fb79edc | 2014-01-10 10:45:54 -0800 | [diff] [blame] | 949 | !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | |
| 950 | WPA_CIPHER_CCMP_256 | |
| 951 | WPA_CIPHER_GCMP_256)))) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 952 | wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP " |
| 953 | "configuration is required for Hotspot 2.0 " |
| 954 | "functionality"); |
| 955 | return -1; |
| 956 | } |
| 957 | #endif /* CONFIG_HS20 */ |
| 958 | |
Dmitry Shmidt | 57c2d39 | 2016-02-23 13:40:19 -0800 | [diff] [blame] | 959 | #ifdef CONFIG_MBO |
| 960 | if (full_config && bss->mbo_enabled && (bss->wpa & 2) && |
| 961 | bss->ieee80211w == NO_MGMT_FRAME_PROTECTION) { |
| 962 | wpa_printf(MSG_ERROR, |
| 963 | "MBO: PMF needs to be enabled whenever using WPA2 with MBO"); |
| 964 | return -1; |
| 965 | } |
| 966 | #endif /* CONFIG_MBO */ |
| 967 | |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 968 | return 0; |
| 969 | } |
| 970 | |
| 971 | |
Dmitry Shmidt | 05df46a | 2015-05-19 11:02:01 -0700 | [diff] [blame] | 972 | static int hostapd_config_check_cw(struct hostapd_config *conf, int queue) |
| 973 | { |
| 974 | int tx_cwmin = conf->tx_queue[queue].cwmin; |
| 975 | int tx_cwmax = conf->tx_queue[queue].cwmax; |
| 976 | int ac_cwmin = conf->wmm_ac_params[queue].cwmin; |
| 977 | int ac_cwmax = conf->wmm_ac_params[queue].cwmax; |
| 978 | |
| 979 | if (tx_cwmin > tx_cwmax) { |
| 980 | wpa_printf(MSG_ERROR, |
| 981 | "Invalid TX queue cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)", |
| 982 | tx_cwmin, tx_cwmax); |
| 983 | return -1; |
| 984 | } |
| 985 | if (ac_cwmin > ac_cwmax) { |
| 986 | wpa_printf(MSG_ERROR, |
| 987 | "Invalid WMM AC cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)", |
| 988 | ac_cwmin, ac_cwmax); |
| 989 | return -1; |
| 990 | } |
| 991 | return 0; |
| 992 | } |
| 993 | |
| 994 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 995 | int hostapd_config_check(struct hostapd_config *conf, int full_config) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 996 | { |
| 997 | size_t i; |
| 998 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 999 | if (full_config && conf->ieee80211d && |
| 1000 | (!conf->country[0] || !conf->country[1])) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1001 | wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without " |
| 1002 | "setting the country_code"); |
| 1003 | return -1; |
| 1004 | } |
| 1005 | |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 1006 | if (full_config && conf->ieee80211h && !conf->ieee80211d) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1007 | wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without " |
| 1008 | "IEEE 802.11d enabled"); |
| 1009 | return -1; |
| 1010 | } |
| 1011 | |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1012 | if (full_config && conf->local_pwr_constraint != -1 && |
| 1013 | !conf->ieee80211d) { |
| 1014 | wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element"); |
| 1015 | return -1; |
| 1016 | } |
| 1017 | |
| 1018 | if (full_config && conf->spectrum_mgmt_required && |
| 1019 | conf->local_pwr_constraint == -1) { |
| 1020 | wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements"); |
| 1021 | return -1; |
| 1022 | } |
| 1023 | |
Dmitry Shmidt | 05df46a | 2015-05-19 11:02:01 -0700 | [diff] [blame] | 1024 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
| 1025 | if (hostapd_config_check_cw(conf, i)) |
| 1026 | return -1; |
| 1027 | } |
| 1028 | |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1029 | for (i = 0; i < conf->num_bss; i++) { |
Dmitry Shmidt | 344abd3 | 2014-01-14 13:17:00 -0800 | [diff] [blame] | 1030 | if (hostapd_config_check_bss(conf->bss[i], conf, full_config)) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1031 | return -1; |
| 1032 | } |
| 1033 | |
| 1034 | return 0; |
| 1035 | } |
| 1036 | |
| 1037 | |
Dmitry Shmidt | 7175743 | 2014-06-02 13:50:35 -0700 | [diff] [blame] | 1038 | void hostapd_set_security_params(struct hostapd_bss_config *bss, |
| 1039 | int full_config) |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1040 | { |
| 1041 | if (bss->individual_wep_key_len == 0) { |
| 1042 | /* individual keys are not use; can use key idx0 for |
| 1043 | * broadcast keys */ |
| 1044 | bss->broadcast_key_idx_min = 0; |
| 1045 | } |
| 1046 | |
| 1047 | if ((bss->wpa & 2) && bss->rsn_pairwise == 0) |
| 1048 | bss->rsn_pairwise = bss->wpa_pairwise; |
| 1049 | bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise, |
| 1050 | bss->rsn_pairwise); |
Dmitry Shmidt | d2986c2 | 2017-10-23 14:22:09 -0700 | [diff] [blame^] | 1051 | if (!bss->wpa_group_rekey_set) |
| 1052 | bss->wpa_group_rekey = bss->wpa_group == WPA_CIPHER_TKIP ? |
| 1053 | 600 : 86400; |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1054 | |
Dmitry Shmidt | 7175743 | 2014-06-02 13:50:35 -0700 | [diff] [blame] | 1055 | if (full_config) { |
| 1056 | bss->radius->auth_server = bss->radius->auth_servers; |
| 1057 | bss->radius->acct_server = bss->radius->acct_servers; |
| 1058 | } |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1059 | |
| 1060 | if (bss->wpa && bss->ieee802_1x) { |
| 1061 | bss->ssid.security_policy = SECURITY_WPA; |
| 1062 | } else if (bss->wpa) { |
| 1063 | bss->ssid.security_policy = SECURITY_WPA_PSK; |
| 1064 | } else if (bss->ieee802_1x) { |
| 1065 | int cipher = WPA_CIPHER_NONE; |
| 1066 | bss->ssid.security_policy = SECURITY_IEEE_802_1X; |
| 1067 | bss->ssid.wep.default_len = bss->default_wep_key_len; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1068 | if (full_config && bss->default_wep_key_len) { |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1069 | cipher = bss->default_wep_key_len >= 13 ? |
| 1070 | WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1071 | } else if (full_config && bss->ssid.wep.keys_set) { |
| 1072 | if (bss->ssid.wep.len[0] >= 13) |
| 1073 | cipher = WPA_CIPHER_WEP104; |
| 1074 | else |
| 1075 | cipher = WPA_CIPHER_WEP40; |
| 1076 | } |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1077 | bss->wpa_group = cipher; |
| 1078 | bss->wpa_pairwise = cipher; |
| 1079 | bss->rsn_pairwise = cipher; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1080 | if (full_config) |
| 1081 | bss->wpa_key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA; |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1082 | } else if (bss->ssid.wep.keys_set) { |
| 1083 | int cipher = WPA_CIPHER_WEP40; |
| 1084 | if (bss->ssid.wep.len[0] >= 13) |
| 1085 | cipher = WPA_CIPHER_WEP104; |
| 1086 | bss->ssid.security_policy = SECURITY_STATIC_WEP; |
| 1087 | bss->wpa_group = cipher; |
| 1088 | bss->wpa_pairwise = cipher; |
| 1089 | bss->rsn_pairwise = cipher; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1090 | if (full_config) |
| 1091 | bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE; |
Dmitry Shmidt | f21452a | 2014-02-26 10:55:25 -0800 | [diff] [blame] | 1092 | } else if (bss->osen) { |
| 1093 | bss->ssid.security_policy = SECURITY_OSEN; |
| 1094 | bss->wpa_group = WPA_CIPHER_CCMP; |
| 1095 | bss->wpa_pairwise = 0; |
| 1096 | bss->rsn_pairwise = WPA_CIPHER_CCMP; |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1097 | } else { |
| 1098 | bss->ssid.security_policy = SECURITY_PLAINTEXT; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1099 | if (full_config) { |
| 1100 | bss->wpa_group = WPA_CIPHER_NONE; |
| 1101 | bss->wpa_pairwise = WPA_CIPHER_NONE; |
| 1102 | bss->rsn_pairwise = WPA_CIPHER_NONE; |
Dmitry Shmidt | 6c0da2b | 2015-01-05 13:08:17 -0800 | [diff] [blame] | 1103 | bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE; |
Dmitry Shmidt | d80a401 | 2015-11-05 16:35:40 -0800 | [diff] [blame] | 1104 | } |
Dmitry Shmidt | cce0666 | 2013-11-04 18:44:24 -0800 | [diff] [blame] | 1105 | } |
| 1106 | } |