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 bss->logger_syslog_level = HOSTAPD_LEVEL_INFO;
42 bss->logger_stdout_level = HOSTAPD_LEVEL_INFO;
43 bss->logger_syslog = (unsigned int) -1;
44 bss->logger_stdout = (unsigned int) -1;
46 bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED;
48 bss->wep_rekeying_period = 300;
49 /* use key0 in individual key and key1 in broadcast key */
50 bss->broadcast_key_idx_min = 1;
51 bss->broadcast_key_idx_max = 2;
52 bss->eap_reauth_period = 3600;
54 bss->wpa_group_rekey = 600;
55 bss->wpa_gmk_rekey = 86400;
56 bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
57 bss->wpa_pairwise = WPA_CIPHER_TKIP;
58 bss->wpa_group = WPA_CIPHER_TKIP;
59 bss->rsn_pairwise = 0;
61 bss->max_num_sta = MAX_STA_COUNT;
65 bss->radius_server_auth_port = 1812;
66 bss->ap_max_inactivity = AP_MAX_INACTIVITY;
67 bss->eapol_version = EAPOL_VERSION;
69 bss->max_listen_interval = 65535;
71 bss->pwd_group = 19; /* ECC: GF(p=256) */
73 #ifdef CONFIG_IEEE80211W
74 bss->assoc_sa_query_max_timeout = 1000;
75 bss->assoc_sa_query_retry_timeout = 201;
76 bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC;
77 #endif /* CONFIG_IEEE80211W */
78 #ifdef EAP_SERVER_FAST
79 /* both anonymous and authenticated provisioning */
80 bss->eap_fast_prov = 3;
81 bss->pac_key_lifetime = 7 * 24 * 60 * 60;
82 bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
83 #endif /* EAP_SERVER_FAST */
85 /* Set to -1 as defaults depends on HT in setup */
86 bss->wmm_enabled = -1;
88 #ifdef CONFIG_IEEE80211R
90 #endif /* CONFIG_IEEE80211R */
92 bss->radius_das_time_window = 300;
94 bss->sae_anti_clogging_threshold = 5;
98 struct hostapd_config * hostapd_config_defaults(void)
100 #define ecw2cw(ecw) ((1 << (ecw)) - 1)
102 struct hostapd_config *conf;
103 struct hostapd_bss_config *bss;
104 const int aCWmin = 4, aCWmax = 10;
105 const struct hostapd_wmm_ac_params ac_bk =
106 { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
107 const struct hostapd_wmm_ac_params ac_be =
108 { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
109 const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
110 { aCWmin - 1, aCWmin, 2, 3008 / 32, 0 };
111 const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
112 { aCWmin - 2, aCWmin - 1, 2, 1504 / 32, 0 };
113 const struct hostapd_tx_queue_params txq_bk =
114 { 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 };
115 const struct hostapd_tx_queue_params txq_be =
116 { 3, ecw2cw(aCWmin), 4 * (ecw2cw(aCWmin) + 1) - 1, 0};
117 const struct hostapd_tx_queue_params txq_vi =
118 { 1, (ecw2cw(aCWmin) + 1) / 2 - 1, ecw2cw(aCWmin), 30};
119 const struct hostapd_tx_queue_params txq_vo =
120 { 1, (ecw2cw(aCWmin) + 1) / 4 - 1,
121 (ecw2cw(aCWmin) + 1) / 2 - 1, 15};
125 conf = os_zalloc(sizeof(*conf));
126 bss = os_zalloc(sizeof(*bss));
127 if (conf == NULL || bss == NULL) {
128 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
129 "configuration data.");
134 conf->bss = os_calloc(1, sizeof(struct hostapd_bss_config *));
135 if (conf->bss == NULL) {
142 bss->radius = os_zalloc(sizeof(*bss->radius));
143 if (bss->radius == NULL) {
150 hostapd_config_defaults_bss(bss);
154 conf->beacon_int = 100;
155 conf->rts_threshold = -1; /* use driver default: 2347 */
156 conf->fragm_threshold = -1; /* user driver default: 2346 */
157 conf->send_probe_response = 1;
158 /* Set to invalid value means do not add Power Constraint IE */
159 conf->local_pwr_constraint = -1;
161 conf->wmm_ac_params[0] = ac_be;
162 conf->wmm_ac_params[1] = ac_bk;
163 conf->wmm_ac_params[2] = ac_vi;
164 conf->wmm_ac_params[3] = ac_vo;
166 conf->tx_queue[0] = txq_vo;
167 conf->tx_queue[1] = txq_vi;
168 conf->tx_queue[2] = txq_be;
169 conf->tx_queue[3] = txq_bk;
171 conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
173 conf->ap_table_max_size = 255;
174 conf->ap_table_expiration_time = 60;
176 #ifdef CONFIG_TESTING_OPTIONS
177 conf->ignore_probe_probability = 0.0;
178 conf->ignore_auth_probability = 0.0;
179 conf->ignore_assoc_probability = 0.0;
180 conf->ignore_reassoc_probability = 0.0;
181 conf->corrupt_gtk_rekey_mic_probability = 0.0;
182 #endif /* CONFIG_TESTING_OPTIONS */
185 conf->acs_ch_list.num = 0;
187 conf->acs_num_scans = 5;
188 #endif /* CONFIG_ACS */
194 int hostapd_mac_comp(const void *a, const void *b)
196 return os_memcmp(a, b, sizeof(macaddr));
200 int hostapd_mac_comp_empty(const void *a)
202 macaddr empty = { 0 };
203 return os_memcmp(a, empty, sizeof(macaddr));
207 static int hostapd_config_read_wpa_psk(const char *fname,
208 struct hostapd_ssid *ssid)
212 int line = 0, ret = 0, len, ok;
214 struct hostapd_wpa_psk *psk;
219 f = fopen(fname, "r");
221 wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname);
225 while (fgets(buf, sizeof(buf), f)) {
231 while (*pos != '\0') {
241 if (hwaddr_aton(buf, addr)) {
242 wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on "
243 "line %d in '%s'", buf, line, fname);
248 psk = os_zalloc(sizeof(*psk));
250 wpa_printf(MSG_ERROR, "WPA PSK allocation failed");
254 if (is_zero_ether_addr(addr))
257 os_memcpy(psk->addr, addr, ETH_ALEN);
261 wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
270 len = os_strlen(pos);
271 if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
273 else if (len >= 8 && len < 64) {
274 pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
275 4096, psk->psk, PMK_LEN);
279 wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in "
280 "'%s'", pos, line, fname);
286 psk->next = ssid->wpa_psk;
296 static int hostapd_derive_psk(struct hostapd_ssid *ssid)
298 ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
299 if (ssid->wpa_psk == NULL) {
300 wpa_printf(MSG_ERROR, "Unable to alloc space for PSK");
303 wpa_hexdump_ascii(MSG_DEBUG, "SSID",
304 (u8 *) ssid->ssid, ssid->ssid_len);
305 wpa_hexdump_ascii_key(MSG_DEBUG, "PSK (ASCII passphrase)",
306 (u8 *) ssid->wpa_passphrase,
307 os_strlen(ssid->wpa_passphrase));
308 pbkdf2_sha1(ssid->wpa_passphrase,
309 ssid->ssid, ssid->ssid_len,
310 4096, ssid->wpa_psk->psk, PMK_LEN);
311 wpa_hexdump_key(MSG_DEBUG, "PSK (from passphrase)",
312 ssid->wpa_psk->psk, PMK_LEN);
317 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
319 struct hostapd_ssid *ssid = &conf->ssid;
321 if (ssid->wpa_passphrase != NULL) {
322 if (ssid->wpa_psk != NULL) {
323 wpa_printf(MSG_DEBUG, "Using pre-configured WPA PSK "
324 "instead of passphrase");
326 wpa_printf(MSG_DEBUG, "Deriving WPA PSK based on "
328 if (hostapd_derive_psk(ssid) < 0)
331 ssid->wpa_psk->group = 1;
334 if (ssid->wpa_psk_file) {
335 if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
344 static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
349 for (i = 0; i < num_servers; i++) {
350 os_free(servers[i].shared_secret);
356 struct hostapd_radius_attr *
357 hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type)
359 for (; attr; attr = attr->next) {
360 if (attr->type == type)
367 static void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr)
369 struct hostapd_radius_attr *prev;
374 wpabuf_free(prev->val);
380 void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
382 hostapd_config_free_radius_attr(user->accept_attr);
383 os_free(user->identity);
384 bin_clear_free(user->password, user->password_len);
389 static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
392 for (i = 0; i < NUM_WEP_KEYS; i++) {
393 bin_clear_free(keys->key[i], keys->len[i]);
399 void hostapd_config_clear_wpa_psk(struct hostapd_wpa_psk **l)
401 struct hostapd_wpa_psk *psk, *tmp;
403 for (psk = *l; psk;) {
406 bin_clear_free(tmp, sizeof(*tmp));
412 void hostapd_config_free_bss(struct hostapd_bss_config *conf)
414 struct hostapd_eap_user *user, *prev_user;
419 hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk);
421 str_clear_free(conf->ssid.wpa_passphrase);
422 os_free(conf->ssid.wpa_psk_file);
423 hostapd_config_free_wep(&conf->ssid.wep);
424 #ifdef CONFIG_FULL_DYNAMIC_VLAN
425 os_free(conf->ssid.vlan_tagged_interface);
426 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
428 user = conf->eap_user;
432 hostapd_config_free_eap_user(prev_user);
434 os_free(conf->eap_user_sqlite);
436 os_free(conf->eap_req_id_text);
437 os_free(conf->erp_domain);
438 os_free(conf->accept_mac);
439 os_free(conf->deny_mac);
440 os_free(conf->nas_identifier);
442 hostapd_config_free_radius(conf->radius->auth_servers,
443 conf->radius->num_auth_servers);
444 hostapd_config_free_radius(conf->radius->acct_servers,
445 conf->radius->num_acct_servers);
447 hostapd_config_free_radius_attr(conf->radius_auth_req_attr);
448 hostapd_config_free_radius_attr(conf->radius_acct_req_attr);
449 os_free(conf->rsn_preauth_interfaces);
450 os_free(conf->ctrl_interface);
451 os_free(conf->ca_cert);
452 os_free(conf->server_cert);
453 os_free(conf->private_key);
454 os_free(conf->private_key_passwd);
455 os_free(conf->ocsp_stapling_response);
456 os_free(conf->dh_file);
457 os_free(conf->openssl_ciphers);
458 os_free(conf->pac_opaque_encr_key);
459 os_free(conf->eap_fast_a_id);
460 os_free(conf->eap_fast_a_id_info);
461 os_free(conf->eap_sim_db);
462 os_free(conf->radius_server_clients);
463 os_free(conf->radius);
464 os_free(conf->radius_das_shared_secret);
465 hostapd_config_free_vlan(conf);
466 os_free(conf->time_zone);
468 #ifdef CONFIG_IEEE80211R
470 struct ft_remote_r0kh *r0kh, *r0kh_prev;
471 struct ft_remote_r1kh *r1kh, *r1kh_prev;
473 r0kh = conf->r0kh_list;
474 conf->r0kh_list = NULL;
481 r1kh = conf->r1kh_list;
482 conf->r1kh_list = NULL;
489 #endif /* CONFIG_IEEE80211R */
492 os_free(conf->wps_pin_requests);
493 os_free(conf->device_name);
494 os_free(conf->manufacturer);
495 os_free(conf->model_name);
496 os_free(conf->model_number);
497 os_free(conf->serial_number);
498 os_free(conf->config_methods);
499 os_free(conf->ap_pin);
500 os_free(conf->extra_cred);
501 os_free(conf->ap_settings);
502 os_free(conf->upnp_iface);
503 os_free(conf->friendly_name);
504 os_free(conf->manufacturer_url);
505 os_free(conf->model_description);
506 os_free(conf->model_url);
511 for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++)
512 wpabuf_free(conf->wps_vendor_ext[i]);
514 wpabuf_free(conf->wps_nfc_dh_pubkey);
515 wpabuf_free(conf->wps_nfc_dh_privkey);
516 wpabuf_free(conf->wps_nfc_dev_pw);
517 #endif /* CONFIG_WPS */
519 os_free(conf->roaming_consortium);
520 os_free(conf->venue_name);
521 os_free(conf->nai_realm_data);
522 os_free(conf->network_auth_type);
523 os_free(conf->anqp_3gpp_cell_net);
524 os_free(conf->domain_name);
526 #ifdef CONFIG_RADIUS_TEST
527 os_free(conf->dump_msk_file);
528 #endif /* CONFIG_RADIUS_TEST */
531 os_free(conf->hs20_oper_friendly_name);
532 os_free(conf->hs20_wan_metrics);
533 os_free(conf->hs20_connection_capability);
534 os_free(conf->hs20_operating_class);
535 os_free(conf->hs20_icons);
536 if (conf->hs20_osu_providers) {
538 for (i = 0; i < conf->hs20_osu_providers_count; i++) {
539 struct hs20_osu_provider *p;
541 p = &conf->hs20_osu_providers[i];
542 os_free(p->friendly_name);
543 os_free(p->server_uri);
544 os_free(p->method_list);
545 for (j = 0; j < p->icons_count; j++)
546 os_free(p->icons[j]);
549 os_free(p->service_desc);
551 os_free(conf->hs20_osu_providers);
553 os_free(conf->subscr_remediation_url);
554 #endif /* CONFIG_HS20 */
556 wpabuf_free(conf->vendor_elements);
558 os_free(conf->sae_groups);
560 os_free(conf->wowlan_triggers);
562 os_free(conf->server_id);
569 * hostapd_config_free - Free hostapd configuration
570 * @conf: Configuration data from hostapd_config_read().
572 void hostapd_config_free(struct hostapd_config *conf)
579 for (i = 0; i < conf->num_bss; i++)
580 hostapd_config_free_bss(conf->bss[i]);
582 os_free(conf->supported_rates);
583 os_free(conf->basic_rates);
584 os_free(conf->acs_ch_list.range);
585 os_free(conf->driver_params);
587 os_free(conf->acs_chan_bias);
588 #endif /* CONFIG_ACS */
595 * hostapd_maclist_found - Find a MAC address from a list
596 * @list: MAC address list
597 * @num_entries: Number of addresses in the list
598 * @addr: Address to search for
599 * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
600 * Returns: 1 if address is in the list or 0 if not.
602 * Perform a binary search for given MAC address from a pre-sorted list.
604 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
605 const u8 *addr, int *vlan_id)
607 int start, end, middle, res;
610 end = num_entries - 1;
612 while (start <= end) {
613 middle = (start + end) / 2;
614 res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
617 *vlan_id = list[middle].vlan_id;
630 int hostapd_rate_found(int *list, int rate)
637 for (i = 0; list[i] >= 0; i++)
645 int hostapd_vlan_id_valid(struct hostapd_vlan *vlan, int vlan_id)
647 struct hostapd_vlan *v = vlan;
649 if (v->vlan_id == vlan_id || v->vlan_id == VLAN_ID_WILDCARD)
657 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
659 struct hostapd_vlan *v = vlan;
661 if (v->vlan_id == vlan_id)
669 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
670 const u8 *addr, const u8 *p2p_dev_addr,
673 struct hostapd_wpa_psk *psk;
674 int next_ok = prev_psk == NULL;
676 if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) {
677 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
678 " p2p_dev_addr=" MACSTR " prev_psk=%p",
679 MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk);
680 addr = NULL; /* Use P2P Device Address for matching */
682 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
684 MAC2STR(addr), prev_psk);
687 for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
690 (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) ||
691 (!addr && p2p_dev_addr &&
692 os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) ==
696 if (psk->psk == prev_psk)
704 static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
705 struct hostapd_config *conf,
708 if (full_config && bss->ieee802_1x && !bss->eap_server &&
709 !bss->radius->auth_servers) {
710 wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
711 "EAP authenticator configured).");
718 wep = bss->default_wep_key_len > 0 ||
719 bss->individual_wep_key_len > 0;
720 for (i = 0; i < NUM_WEP_KEYS; i++) {
721 if (bss->ssid.wep.keys_set) {
728 wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported");
733 if (full_config && bss->wpa &&
734 bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
735 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
736 wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no "
737 "RADIUS checking (macaddr_acl=2) enabled.");
741 if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
742 bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
743 bss->ssid.wpa_psk_file == NULL &&
744 (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED ||
745 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) {
746 wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
747 "is not configured.");
751 if (full_config && hostapd_mac_comp_empty(bss->bssid) != 0) {
754 for (i = 0; i < conf->num_bss; i++) {
755 if (conf->bss[i] != bss &&
756 (hostapd_mac_comp(conf->bss[i]->bssid,
758 wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
759 " on interface '%s' and '%s'.",
761 conf->bss[i]->iface, bss->iface);
767 #ifdef CONFIG_IEEE80211R
768 if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) &&
769 (bss->nas_identifier == NULL ||
770 os_strlen(bss->nas_identifier) < 1 ||
771 os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
772 wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
773 "nas_identifier to be configured as a 1..48 octet "
777 #endif /* CONFIG_IEEE80211R */
779 #ifdef CONFIG_IEEE80211N
780 if (full_config && conf->ieee80211n &&
781 conf->hw_mode == HOSTAPD_MODE_IEEE80211B) {
782 bss->disable_11n = 1;
783 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not "
784 "allowed, disabling HT capabilities");
787 if (full_config && conf->ieee80211n &&
788 bss->ssid.security_policy == SECURITY_STATIC_WEP) {
789 bss->disable_11n = 1;
790 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not "
791 "allowed, disabling HT capabilities");
794 if (full_config && conf->ieee80211n && bss->wpa &&
795 !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
796 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
797 WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256)))
799 bss->disable_11n = 1;
800 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
801 "requires CCMP/GCMP to be enabled, disabling HT "
804 #endif /* CONFIG_IEEE80211N */
807 if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) {
808 wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
809 "configuration forced WPS to be disabled");
813 if (full_config && bss->wps_state &&
814 bss->ssid.wep.keys_set && bss->wpa == 0) {
815 wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
820 if (full_config && bss->wps_state && bss->wpa &&
822 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)))) {
823 wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
824 "WPA2/CCMP/GCMP forced WPS to be disabled");
827 #endif /* CONFIG_WPS */
830 if (full_config && bss->hs20 &&
832 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
833 WPA_CIPHER_CCMP_256 |
834 WPA_CIPHER_GCMP_256)))) {
835 wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP "
836 "configuration is required for Hotspot 2.0 "
840 #endif /* CONFIG_HS20 */
846 static int hostapd_config_check_cw(struct hostapd_config *conf, int queue)
848 int tx_cwmin = conf->tx_queue[queue].cwmin;
849 int tx_cwmax = conf->tx_queue[queue].cwmax;
850 int ac_cwmin = conf->wmm_ac_params[queue].cwmin;
851 int ac_cwmax = conf->wmm_ac_params[queue].cwmax;
853 if (tx_cwmin > tx_cwmax) {
854 wpa_printf(MSG_ERROR,
855 "Invalid TX queue cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
859 if (ac_cwmin > ac_cwmax) {
860 wpa_printf(MSG_ERROR,
861 "Invalid WMM AC cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
869 int hostapd_config_check(struct hostapd_config *conf, int full_config)
873 if (full_config && conf->ieee80211d &&
874 (!conf->country[0] || !conf->country[1])) {
875 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
876 "setting the country_code");
880 if (full_config && conf->ieee80211h && !conf->ieee80211d) {
881 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without "
882 "IEEE 802.11d enabled");
886 if (full_config && conf->local_pwr_constraint != -1 &&
888 wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element");
892 if (full_config && conf->spectrum_mgmt_required &&
893 conf->local_pwr_constraint == -1) {
894 wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements");
898 for (i = 0; i < NUM_TX_QUEUES; i++) {
899 if (hostapd_config_check_cw(conf, i))
903 for (i = 0; i < conf->num_bss; i++) {
904 if (hostapd_config_check_bss(conf->bss[i], conf, full_config))
912 void hostapd_set_security_params(struct hostapd_bss_config *bss,
915 if (bss->individual_wep_key_len == 0) {
916 /* individual keys are not use; can use key idx0 for
918 bss->broadcast_key_idx_min = 0;
921 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
922 bss->rsn_pairwise = bss->wpa_pairwise;
923 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
927 bss->radius->auth_server = bss->radius->auth_servers;
928 bss->radius->acct_server = bss->radius->acct_servers;
931 if (bss->wpa && bss->ieee802_1x) {
932 bss->ssid.security_policy = SECURITY_WPA;
933 } else if (bss->wpa) {
934 bss->ssid.security_policy = SECURITY_WPA_PSK;
935 } else if (bss->ieee802_1x) {
936 int cipher = WPA_CIPHER_NONE;
937 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
938 bss->ssid.wep.default_len = bss->default_wep_key_len;
939 if (full_config && bss->default_wep_key_len) {
940 cipher = bss->default_wep_key_len >= 13 ?
941 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
942 } else if (full_config && bss->ssid.wep.keys_set) {
943 if (bss->ssid.wep.len[0] >= 13)
944 cipher = WPA_CIPHER_WEP104;
946 cipher = WPA_CIPHER_WEP40;
948 bss->wpa_group = cipher;
949 bss->wpa_pairwise = cipher;
950 bss->rsn_pairwise = cipher;
952 bss->wpa_key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
953 } else if (bss->ssid.wep.keys_set) {
954 int cipher = WPA_CIPHER_WEP40;
955 if (bss->ssid.wep.len[0] >= 13)
956 cipher = WPA_CIPHER_WEP104;
957 bss->ssid.security_policy = SECURITY_STATIC_WEP;
958 bss->wpa_group = cipher;
959 bss->wpa_pairwise = cipher;
960 bss->rsn_pairwise = cipher;
962 bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;
963 } else if (bss->osen) {
964 bss->ssid.security_policy = SECURITY_OSEN;
965 bss->wpa_group = WPA_CIPHER_CCMP;
966 bss->wpa_pairwise = 0;
967 bss->rsn_pairwise = WPA_CIPHER_CCMP;
969 bss->ssid.security_policy = SECURITY_PLAINTEXT;
970 bss->wpa_group = WPA_CIPHER_NONE;
971 bss->wpa_pairwise = WPA_CIPHER_NONE;
972 bss->rsn_pairwise = WPA_CIPHER_NONE;
974 bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;