2 * hostapd / Configuration helper functions
3 * Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
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"
16 #include "eap_common/eap_wsc_common.h"
17 #include "eap_server/eap.h"
20 #include "ap_config.h"
23 static void hostapd_config_free_vlan(struct hostapd_bss_config *bss)
25 struct hostapd_vlan *vlan, *prev;
39 void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
41 dl_list_init(&bss->anqp_elem);
43 bss->logger_syslog_level = HOSTAPD_LEVEL_INFO;
44 bss->logger_stdout_level = HOSTAPD_LEVEL_INFO;
45 bss->logger_syslog = (unsigned int) -1;
46 bss->logger_stdout = (unsigned int) -1;
48 bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED;
50 bss->wep_rekeying_period = 300;
51 /* use key0 in individual key and key1 in broadcast key */
52 bss->broadcast_key_idx_min = 1;
53 bss->broadcast_key_idx_max = 2;
54 bss->eap_reauth_period = 3600;
56 bss->wpa_group_rekey = 600;
57 bss->wpa_gmk_rekey = 86400;
58 bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
59 bss->wpa_pairwise = WPA_CIPHER_TKIP;
60 bss->wpa_group = WPA_CIPHER_TKIP;
61 bss->rsn_pairwise = 0;
63 bss->max_num_sta = MAX_STA_COUNT;
67 bss->radius_server_auth_port = 1812;
68 bss->eap_sim_db_timeout = 1;
69 bss->ap_max_inactivity = AP_MAX_INACTIVITY;
70 bss->eapol_version = EAPOL_VERSION;
72 bss->max_listen_interval = 65535;
74 bss->pwd_group = 19; /* ECC: GF(p=256) */
76 #ifdef CONFIG_IEEE80211W
77 bss->assoc_sa_query_max_timeout = 1000;
78 bss->assoc_sa_query_retry_timeout = 201;
79 bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC;
80 #endif /* CONFIG_IEEE80211W */
81 #ifdef EAP_SERVER_FAST
82 /* both anonymous and authenticated provisioning */
83 bss->eap_fast_prov = 3;
84 bss->pac_key_lifetime = 7 * 24 * 60 * 60;
85 bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
86 #endif /* EAP_SERVER_FAST */
88 /* Set to -1 as defaults depends on HT in setup */
89 bss->wmm_enabled = -1;
91 #ifdef CONFIG_IEEE80211R
93 #endif /* CONFIG_IEEE80211R */
95 bss->radius_das_time_window = 300;
97 bss->sae_anti_clogging_threshold = 5;
101 struct hostapd_config * hostapd_config_defaults(void)
103 #define ecw2cw(ecw) ((1 << (ecw)) - 1)
105 struct hostapd_config *conf;
106 struct hostapd_bss_config *bss;
107 const int aCWmin = 4, aCWmax = 10;
108 const struct hostapd_wmm_ac_params ac_bk =
109 { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
110 const struct hostapd_wmm_ac_params ac_be =
111 { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
112 const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
113 { aCWmin - 1, aCWmin, 2, 3008 / 32, 0 };
114 const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
115 { aCWmin - 2, aCWmin - 1, 2, 1504 / 32, 0 };
116 const struct hostapd_tx_queue_params txq_bk =
117 { 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 };
118 const struct hostapd_tx_queue_params txq_be =
119 { 3, ecw2cw(aCWmin), 4 * (ecw2cw(aCWmin) + 1) - 1, 0};
120 const struct hostapd_tx_queue_params txq_vi =
121 { 1, (ecw2cw(aCWmin) + 1) / 2 - 1, ecw2cw(aCWmin), 30};
122 const struct hostapd_tx_queue_params txq_vo =
123 { 1, (ecw2cw(aCWmin) + 1) / 4 - 1,
124 (ecw2cw(aCWmin) + 1) / 2 - 1, 15};
128 conf = os_zalloc(sizeof(*conf));
129 bss = os_zalloc(sizeof(*bss));
130 if (conf == NULL || bss == NULL) {
131 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
132 "configuration data.");
137 conf->bss = os_calloc(1, sizeof(struct hostapd_bss_config *));
138 if (conf->bss == NULL) {
145 bss->radius = os_zalloc(sizeof(*bss->radius));
146 if (bss->radius == NULL) {
153 hostapd_config_defaults_bss(bss);
157 conf->beacon_int = 100;
158 conf->rts_threshold = -1; /* use driver default: 2347 */
159 conf->fragm_threshold = -1; /* user driver default: 2346 */
160 conf->send_probe_response = 1;
161 /* Set to invalid value means do not add Power Constraint IE */
162 conf->local_pwr_constraint = -1;
164 conf->wmm_ac_params[0] = ac_be;
165 conf->wmm_ac_params[1] = ac_bk;
166 conf->wmm_ac_params[2] = ac_vi;
167 conf->wmm_ac_params[3] = ac_vo;
169 conf->tx_queue[0] = txq_vo;
170 conf->tx_queue[1] = txq_vi;
171 conf->tx_queue[2] = txq_be;
172 conf->tx_queue[3] = txq_bk;
174 conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
176 conf->ap_table_max_size = 255;
177 conf->ap_table_expiration_time = 60;
178 conf->track_sta_max_age = 180;
180 #ifdef CONFIG_TESTING_OPTIONS
181 conf->ignore_probe_probability = 0.0;
182 conf->ignore_auth_probability = 0.0;
183 conf->ignore_assoc_probability = 0.0;
184 conf->ignore_reassoc_probability = 0.0;
185 conf->corrupt_gtk_rekey_mic_probability = 0.0;
186 conf->ecsa_ie_only = 0;
187 #endif /* CONFIG_TESTING_OPTIONS */
190 conf->acs_ch_list.num = 0;
192 conf->acs_num_scans = 5;
193 #endif /* CONFIG_ACS */
199 int hostapd_mac_comp(const void *a, const void *b)
201 return os_memcmp(a, b, sizeof(macaddr));
205 static int hostapd_config_read_wpa_psk(const char *fname,
206 struct hostapd_ssid *ssid)
210 int line = 0, ret = 0, len, ok;
212 struct hostapd_wpa_psk *psk;
217 f = fopen(fname, "r");
219 wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname);
223 while (fgets(buf, sizeof(buf), f)) {
229 while (*pos != '\0') {
239 if (hwaddr_aton(buf, addr)) {
240 wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on "
241 "line %d in '%s'", buf, line, fname);
246 psk = os_zalloc(sizeof(*psk));
248 wpa_printf(MSG_ERROR, "WPA PSK allocation failed");
252 if (is_zero_ether_addr(addr))
255 os_memcpy(psk->addr, addr, ETH_ALEN);
259 wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
268 len = os_strlen(pos);
269 if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
271 else if (len >= 8 && len < 64) {
272 pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
273 4096, psk->psk, PMK_LEN);
277 wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in "
278 "'%s'", pos, line, fname);
284 psk->next = ssid->wpa_psk;
294 static int hostapd_derive_psk(struct hostapd_ssid *ssid)
296 ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
297 if (ssid->wpa_psk == NULL) {
298 wpa_printf(MSG_ERROR, "Unable to alloc space for PSK");
301 wpa_hexdump_ascii(MSG_DEBUG, "SSID",
302 (u8 *) ssid->ssid, ssid->ssid_len);
303 wpa_hexdump_ascii_key(MSG_DEBUG, "PSK (ASCII passphrase)",
304 (u8 *) ssid->wpa_passphrase,
305 os_strlen(ssid->wpa_passphrase));
306 pbkdf2_sha1(ssid->wpa_passphrase,
307 ssid->ssid, ssid->ssid_len,
308 4096, ssid->wpa_psk->psk, PMK_LEN);
309 wpa_hexdump_key(MSG_DEBUG, "PSK (from passphrase)",
310 ssid->wpa_psk->psk, PMK_LEN);
315 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
317 struct hostapd_ssid *ssid = &conf->ssid;
319 if (ssid->wpa_passphrase != NULL) {
320 if (ssid->wpa_psk != NULL) {
321 wpa_printf(MSG_DEBUG, "Using pre-configured WPA PSK "
322 "instead of passphrase");
324 wpa_printf(MSG_DEBUG, "Deriving WPA PSK based on "
326 if (hostapd_derive_psk(ssid) < 0)
329 ssid->wpa_psk->group = 1;
332 if (ssid->wpa_psk_file) {
333 if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
342 static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
347 for (i = 0; i < num_servers; i++) {
348 os_free(servers[i].shared_secret);
354 struct hostapd_radius_attr *
355 hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type)
357 for (; attr; attr = attr->next) {
358 if (attr->type == type)
365 static void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr)
367 struct hostapd_radius_attr *prev;
372 wpabuf_free(prev->val);
378 void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
380 hostapd_config_free_radius_attr(user->accept_attr);
381 os_free(user->identity);
382 bin_clear_free(user->password, user->password_len);
387 static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
390 for (i = 0; i < NUM_WEP_KEYS; i++) {
391 bin_clear_free(keys->key[i], keys->len[i]);
397 void hostapd_config_clear_wpa_psk(struct hostapd_wpa_psk **l)
399 struct hostapd_wpa_psk *psk, *tmp;
401 for (psk = *l; psk;) {
404 bin_clear_free(tmp, sizeof(*tmp));
410 static void hostapd_config_free_anqp_elem(struct hostapd_bss_config *conf)
412 struct anqp_element *elem;
414 while ((elem = dl_list_first(&conf->anqp_elem, struct anqp_element,
416 dl_list_del(&elem->list);
417 wpabuf_free(elem->payload);
423 void hostapd_config_free_bss(struct hostapd_bss_config *conf)
425 struct hostapd_eap_user *user, *prev_user;
430 hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk);
432 str_clear_free(conf->ssid.wpa_passphrase);
433 os_free(conf->ssid.wpa_psk_file);
434 hostapd_config_free_wep(&conf->ssid.wep);
435 #ifdef CONFIG_FULL_DYNAMIC_VLAN
436 os_free(conf->ssid.vlan_tagged_interface);
437 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
439 user = conf->eap_user;
443 hostapd_config_free_eap_user(prev_user);
445 os_free(conf->eap_user_sqlite);
447 os_free(conf->eap_req_id_text);
448 os_free(conf->erp_domain);
449 os_free(conf->accept_mac);
450 os_free(conf->deny_mac);
451 os_free(conf->nas_identifier);
453 hostapd_config_free_radius(conf->radius->auth_servers,
454 conf->radius->num_auth_servers);
455 hostapd_config_free_radius(conf->radius->acct_servers,
456 conf->radius->num_acct_servers);
458 hostapd_config_free_radius_attr(conf->radius_auth_req_attr);
459 hostapd_config_free_radius_attr(conf->radius_acct_req_attr);
460 os_free(conf->rsn_preauth_interfaces);
461 os_free(conf->ctrl_interface);
462 os_free(conf->ca_cert);
463 os_free(conf->server_cert);
464 os_free(conf->private_key);
465 os_free(conf->private_key_passwd);
466 os_free(conf->ocsp_stapling_response);
467 os_free(conf->ocsp_stapling_response_multi);
468 os_free(conf->dh_file);
469 os_free(conf->openssl_ciphers);
470 os_free(conf->pac_opaque_encr_key);
471 os_free(conf->eap_fast_a_id);
472 os_free(conf->eap_fast_a_id_info);
473 os_free(conf->eap_sim_db);
474 os_free(conf->radius_server_clients);
475 os_free(conf->radius);
476 os_free(conf->radius_das_shared_secret);
477 hostapd_config_free_vlan(conf);
478 os_free(conf->time_zone);
480 #ifdef CONFIG_IEEE80211R
482 struct ft_remote_r0kh *r0kh, *r0kh_prev;
483 struct ft_remote_r1kh *r1kh, *r1kh_prev;
485 r0kh = conf->r0kh_list;
486 conf->r0kh_list = NULL;
493 r1kh = conf->r1kh_list;
494 conf->r1kh_list = NULL;
501 #endif /* CONFIG_IEEE80211R */
504 os_free(conf->wps_pin_requests);
505 os_free(conf->device_name);
506 os_free(conf->manufacturer);
507 os_free(conf->model_name);
508 os_free(conf->model_number);
509 os_free(conf->serial_number);
510 os_free(conf->config_methods);
511 os_free(conf->ap_pin);
512 os_free(conf->extra_cred);
513 os_free(conf->ap_settings);
514 os_free(conf->upnp_iface);
515 os_free(conf->friendly_name);
516 os_free(conf->manufacturer_url);
517 os_free(conf->model_description);
518 os_free(conf->model_url);
523 for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++)
524 wpabuf_free(conf->wps_vendor_ext[i]);
526 wpabuf_free(conf->wps_nfc_dh_pubkey);
527 wpabuf_free(conf->wps_nfc_dh_privkey);
528 wpabuf_free(conf->wps_nfc_dev_pw);
529 #endif /* CONFIG_WPS */
531 os_free(conf->roaming_consortium);
532 os_free(conf->venue_name);
533 os_free(conf->nai_realm_data);
534 os_free(conf->network_auth_type);
535 os_free(conf->anqp_3gpp_cell_net);
536 os_free(conf->domain_name);
537 hostapd_config_free_anqp_elem(conf);
539 #ifdef CONFIG_RADIUS_TEST
540 os_free(conf->dump_msk_file);
541 #endif /* CONFIG_RADIUS_TEST */
544 os_free(conf->hs20_oper_friendly_name);
545 os_free(conf->hs20_wan_metrics);
546 os_free(conf->hs20_connection_capability);
547 os_free(conf->hs20_operating_class);
548 os_free(conf->hs20_icons);
549 if (conf->hs20_osu_providers) {
551 for (i = 0; i < conf->hs20_osu_providers_count; i++) {
552 struct hs20_osu_provider *p;
554 p = &conf->hs20_osu_providers[i];
555 os_free(p->friendly_name);
556 os_free(p->server_uri);
557 os_free(p->method_list);
558 for (j = 0; j < p->icons_count; j++)
559 os_free(p->icons[j]);
562 os_free(p->service_desc);
564 os_free(conf->hs20_osu_providers);
566 os_free(conf->subscr_remediation_url);
567 #endif /* CONFIG_HS20 */
569 wpabuf_free(conf->vendor_elements);
570 wpabuf_free(conf->assocresp_elements);
572 os_free(conf->sae_groups);
574 os_free(conf->wowlan_triggers);
576 os_free(conf->server_id);
578 #ifdef CONFIG_TESTING_OPTIONS
579 wpabuf_free(conf->own_ie_override);
580 #endif /* CONFIG_TESTING_OPTIONS */
582 os_free(conf->no_probe_resp_if_seen_on);
583 os_free(conf->no_auth_if_seen_on);
590 * hostapd_config_free - Free hostapd configuration
591 * @conf: Configuration data from hostapd_config_read().
593 void hostapd_config_free(struct hostapd_config *conf)
600 for (i = 0; i < conf->num_bss; i++)
601 hostapd_config_free_bss(conf->bss[i]);
603 os_free(conf->supported_rates);
604 os_free(conf->basic_rates);
605 os_free(conf->acs_ch_list.range);
606 os_free(conf->driver_params);
608 os_free(conf->acs_chan_bias);
609 #endif /* CONFIG_ACS */
610 wpabuf_free(conf->lci);
611 wpabuf_free(conf->civic);
618 * hostapd_maclist_found - Find a MAC address from a list
619 * @list: MAC address list
620 * @num_entries: Number of addresses in the list
621 * @addr: Address to search for
622 * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
623 * Returns: 1 if address is in the list or 0 if not.
625 * Perform a binary search for given MAC address from a pre-sorted list.
627 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
628 const u8 *addr, struct vlan_description *vlan_id)
630 int start, end, middle, res;
633 end = num_entries - 1;
635 while (start <= end) {
636 middle = (start + end) / 2;
637 res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
640 *vlan_id = list[middle].vlan_id;
653 int hostapd_rate_found(int *list, int rate)
660 for (i = 0; list[i] >= 0; i++)
668 int hostapd_vlan_valid(struct hostapd_vlan *vlan,
669 struct vlan_description *vlan_desc)
671 struct hostapd_vlan *v = vlan;
674 if (!vlan_desc->notempty || vlan_desc->untagged < 0 ||
675 vlan_desc->untagged > MAX_VLAN_ID)
677 for (i = 0; i < MAX_NUM_TAGGED_VLAN; i++) {
678 if (vlan_desc->tagged[i] < 0 ||
679 vlan_desc->tagged[i] > MAX_VLAN_ID)
682 if (!vlan_desc->untagged && !vlan_desc->tagged[0])
686 if (!vlan_compare(&v->vlan_desc, vlan_desc) ||
687 v->vlan_id == VLAN_ID_WILDCARD)
695 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
697 struct hostapd_vlan *v = vlan;
699 if (v->vlan_id == vlan_id)
707 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
708 const u8 *addr, const u8 *p2p_dev_addr,
711 struct hostapd_wpa_psk *psk;
712 int next_ok = prev_psk == NULL;
714 if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) {
715 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
716 " p2p_dev_addr=" MACSTR " prev_psk=%p",
717 MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk);
718 addr = NULL; /* Use P2P Device Address for matching */
720 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
722 MAC2STR(addr), prev_psk);
725 for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
728 (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) ||
729 (!addr && p2p_dev_addr &&
730 os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) ==
734 if (psk->psk == prev_psk)
742 static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
743 struct hostapd_config *conf,
746 if (full_config && bss->ieee802_1x && !bss->eap_server &&
747 !bss->radius->auth_servers) {
748 wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
749 "EAP authenticator configured).");
756 wep = bss->default_wep_key_len > 0 ||
757 bss->individual_wep_key_len > 0;
758 for (i = 0; i < NUM_WEP_KEYS; i++) {
759 if (bss->ssid.wep.keys_set) {
766 wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported");
771 if (full_config && bss->wpa &&
772 bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
773 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
774 wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no "
775 "RADIUS checking (macaddr_acl=2) enabled.");
779 if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
780 bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
781 bss->ssid.wpa_psk_file == NULL &&
782 (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED ||
783 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) {
784 wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
785 "is not configured.");
789 if (full_config && !is_zero_ether_addr(bss->bssid)) {
792 for (i = 0; i < conf->num_bss; i++) {
793 if (conf->bss[i] != bss &&
794 (hostapd_mac_comp(conf->bss[i]->bssid,
796 wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
797 " on interface '%s' and '%s'.",
799 conf->bss[i]->iface, bss->iface);
805 #ifdef CONFIG_IEEE80211R
806 if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) &&
807 (bss->nas_identifier == NULL ||
808 os_strlen(bss->nas_identifier) < 1 ||
809 os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
810 wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
811 "nas_identifier to be configured as a 1..48 octet "
815 #endif /* CONFIG_IEEE80211R */
817 #ifdef CONFIG_IEEE80211N
818 if (full_config && conf->ieee80211n &&
819 conf->hw_mode == HOSTAPD_MODE_IEEE80211B) {
820 bss->disable_11n = 1;
821 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not "
822 "allowed, disabling HT capabilities");
825 if (full_config && conf->ieee80211n &&
826 bss->ssid.security_policy == SECURITY_STATIC_WEP) {
827 bss->disable_11n = 1;
828 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not "
829 "allowed, disabling HT capabilities");
832 if (full_config && conf->ieee80211n && bss->wpa &&
833 !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
834 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
835 WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256)))
837 bss->disable_11n = 1;
838 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
839 "requires CCMP/GCMP to be enabled, disabling HT "
842 #endif /* CONFIG_IEEE80211N */
844 #ifdef CONFIG_IEEE80211AC
845 if (full_config && conf->ieee80211ac &&
846 bss->ssid.security_policy == SECURITY_STATIC_WEP) {
847 bss->disable_11ac = 1;
848 wpa_printf(MSG_ERROR,
849 "VHT (IEEE 802.11ac) with WEP is not allowed, disabling VHT capabilities");
851 #endif /* CONFIG_IEEE80211AC */
854 if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) {
855 wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
856 "configuration forced WPS to be disabled");
860 if (full_config && bss->wps_state &&
861 bss->ssid.wep.keys_set && bss->wpa == 0) {
862 wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
867 if (full_config && bss->wps_state && bss->wpa &&
869 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)))) {
870 wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
871 "WPA2/CCMP/GCMP forced WPS to be disabled");
874 #endif /* CONFIG_WPS */
877 if (full_config && bss->hs20 &&
879 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
880 WPA_CIPHER_CCMP_256 |
881 WPA_CIPHER_GCMP_256)))) {
882 wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP "
883 "configuration is required for Hotspot 2.0 "
887 #endif /* CONFIG_HS20 */
890 if (full_config && bss->mbo_enabled && (bss->wpa & 2) &&
891 bss->ieee80211w == NO_MGMT_FRAME_PROTECTION) {
892 wpa_printf(MSG_ERROR,
893 "MBO: PMF needs to be enabled whenever using WPA2 with MBO");
896 #endif /* CONFIG_MBO */
902 static int hostapd_config_check_cw(struct hostapd_config *conf, int queue)
904 int tx_cwmin = conf->tx_queue[queue].cwmin;
905 int tx_cwmax = conf->tx_queue[queue].cwmax;
906 int ac_cwmin = conf->wmm_ac_params[queue].cwmin;
907 int ac_cwmax = conf->wmm_ac_params[queue].cwmax;
909 if (tx_cwmin > tx_cwmax) {
910 wpa_printf(MSG_ERROR,
911 "Invalid TX queue cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
915 if (ac_cwmin > ac_cwmax) {
916 wpa_printf(MSG_ERROR,
917 "Invalid WMM AC cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
925 int hostapd_config_check(struct hostapd_config *conf, int full_config)
929 if (full_config && conf->ieee80211d &&
930 (!conf->country[0] || !conf->country[1])) {
931 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
932 "setting the country_code");
936 if (full_config && conf->ieee80211h && !conf->ieee80211d) {
937 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without "
938 "IEEE 802.11d enabled");
942 if (full_config && conf->local_pwr_constraint != -1 &&
944 wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element");
948 if (full_config && conf->spectrum_mgmt_required &&
949 conf->local_pwr_constraint == -1) {
950 wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements");
954 for (i = 0; i < NUM_TX_QUEUES; i++) {
955 if (hostapd_config_check_cw(conf, i))
959 for (i = 0; i < conf->num_bss; i++) {
960 if (hostapd_config_check_bss(conf->bss[i], conf, full_config))
968 void hostapd_set_security_params(struct hostapd_bss_config *bss,
971 if (bss->individual_wep_key_len == 0) {
972 /* individual keys are not use; can use key idx0 for
974 bss->broadcast_key_idx_min = 0;
977 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
978 bss->rsn_pairwise = bss->wpa_pairwise;
979 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
983 bss->radius->auth_server = bss->radius->auth_servers;
984 bss->radius->acct_server = bss->radius->acct_servers;
987 if (bss->wpa && bss->ieee802_1x) {
988 bss->ssid.security_policy = SECURITY_WPA;
989 } else if (bss->wpa) {
990 bss->ssid.security_policy = SECURITY_WPA_PSK;
991 } else if (bss->ieee802_1x) {
992 int cipher = WPA_CIPHER_NONE;
993 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
994 bss->ssid.wep.default_len = bss->default_wep_key_len;
995 if (full_config && bss->default_wep_key_len) {
996 cipher = bss->default_wep_key_len >= 13 ?
997 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
998 } else if (full_config && bss->ssid.wep.keys_set) {
999 if (bss->ssid.wep.len[0] >= 13)
1000 cipher = WPA_CIPHER_WEP104;
1002 cipher = WPA_CIPHER_WEP40;
1004 bss->wpa_group = cipher;
1005 bss->wpa_pairwise = cipher;
1006 bss->rsn_pairwise = cipher;
1008 bss->wpa_key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
1009 } else if (bss->ssid.wep.keys_set) {
1010 int cipher = WPA_CIPHER_WEP40;
1011 if (bss->ssid.wep.len[0] >= 13)
1012 cipher = WPA_CIPHER_WEP104;
1013 bss->ssid.security_policy = SECURITY_STATIC_WEP;
1014 bss->wpa_group = cipher;
1015 bss->wpa_pairwise = cipher;
1016 bss->rsn_pairwise = cipher;
1018 bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;
1019 } else if (bss->osen) {
1020 bss->ssid.security_policy = SECURITY_OSEN;
1021 bss->wpa_group = WPA_CIPHER_CCMP;
1022 bss->wpa_pairwise = 0;
1023 bss->rsn_pairwise = WPA_CIPHER_CCMP;
1025 bss->ssid.security_policy = SECURITY_PLAINTEXT;
1027 bss->wpa_group = WPA_CIPHER_NONE;
1028 bss->wpa_pairwise = WPA_CIPHER_NONE;
1029 bss->rsn_pairwise = WPA_CIPHER_NONE;
1030 bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;