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 #endif /* CONFIG_IEEE80211W */
77 #ifdef EAP_SERVER_FAST
78 /* both anonymous and authenticated provisioning */
79 bss->eap_fast_prov = 3;
80 bss->pac_key_lifetime = 7 * 24 * 60 * 60;
81 bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
82 #endif /* EAP_SERVER_FAST */
84 /* Set to -1 as defaults depends on HT in setup */
85 bss->wmm_enabled = -1;
87 #ifdef CONFIG_IEEE80211R
89 #endif /* CONFIG_IEEE80211R */
91 bss->radius_das_time_window = 300;
93 bss->sae_anti_clogging_threshold = 5;
97 struct hostapd_config * hostapd_config_defaults(void)
99 #define ecw2cw(ecw) ((1 << (ecw)) - 1)
101 struct hostapd_config *conf;
102 struct hostapd_bss_config *bss;
103 const int aCWmin = 4, aCWmax = 10;
104 const struct hostapd_wmm_ac_params ac_bk =
105 { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
106 const struct hostapd_wmm_ac_params ac_be =
107 { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
108 const struct hostapd_wmm_ac_params ac_vi = /* video traffic */
109 { aCWmin - 1, aCWmin, 2, 3000 / 32, 0 };
110 const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
111 { aCWmin - 2, aCWmin - 1, 2, 1500 / 32, 0 };
112 const struct hostapd_tx_queue_params txq_bk =
113 { 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 };
114 const struct hostapd_tx_queue_params txq_be =
115 { 3, ecw2cw(aCWmin), 4 * (ecw2cw(aCWmin) + 1) - 1, 0};
116 const struct hostapd_tx_queue_params txq_vi =
117 { 1, (ecw2cw(aCWmin) + 1) / 2 - 1, ecw2cw(aCWmin), 30};
118 const struct hostapd_tx_queue_params txq_vo =
119 { 1, (ecw2cw(aCWmin) + 1) / 4 - 1,
120 (ecw2cw(aCWmin) + 1) / 2 - 1, 15};
124 conf = os_zalloc(sizeof(*conf));
125 bss = os_zalloc(sizeof(*bss));
126 if (conf == NULL || bss == NULL) {
127 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
128 "configuration data.");
133 conf->bss = os_calloc(1, sizeof(struct hostapd_bss_config *));
134 if (conf->bss == NULL) {
141 bss->radius = os_zalloc(sizeof(*bss->radius));
142 if (bss->radius == NULL) {
149 hostapd_config_defaults_bss(bss);
153 conf->beacon_int = 100;
154 conf->rts_threshold = -1; /* use driver default: 2347 */
155 conf->fragm_threshold = -1; /* user driver default: 2346 */
156 conf->send_probe_response = 1;
157 /* Set to invalid value means do not add Power Constraint IE */
158 conf->local_pwr_constraint = -1;
160 conf->wmm_ac_params[0] = ac_be;
161 conf->wmm_ac_params[1] = ac_bk;
162 conf->wmm_ac_params[2] = ac_vi;
163 conf->wmm_ac_params[3] = ac_vo;
165 conf->tx_queue[0] = txq_vo;
166 conf->tx_queue[1] = txq_vi;
167 conf->tx_queue[2] = txq_be;
168 conf->tx_queue[3] = txq_bk;
170 conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
172 conf->ap_table_max_size = 255;
173 conf->ap_table_expiration_time = 60;
175 #ifdef CONFIG_TESTING_OPTIONS
176 conf->ignore_probe_probability = 0.0d;
177 conf->ignore_auth_probability = 0.0d;
178 conf->ignore_assoc_probability = 0.0d;
179 conf->ignore_reassoc_probability = 0.0d;
180 conf->corrupt_gtk_rekey_mic_probability = 0.0d;
181 #endif /* CONFIG_TESTING_OPTIONS */
184 conf->acs_num_scans = 5;
185 #endif /* CONFIG_ACS */
191 int hostapd_mac_comp(const void *a, const void *b)
193 return os_memcmp(a, b, sizeof(macaddr));
197 int hostapd_mac_comp_empty(const void *a)
199 macaddr empty = { 0 };
200 return os_memcmp(a, empty, sizeof(macaddr));
204 static int hostapd_config_read_wpa_psk(const char *fname,
205 struct hostapd_ssid *ssid)
209 int line = 0, ret = 0, len, ok;
211 struct hostapd_wpa_psk *psk;
216 f = fopen(fname, "r");
218 wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname);
222 while (fgets(buf, sizeof(buf), f)) {
228 while (*pos != '\0') {
238 if (hwaddr_aton(buf, addr)) {
239 wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on "
240 "line %d in '%s'", buf, line, fname);
245 psk = os_zalloc(sizeof(*psk));
247 wpa_printf(MSG_ERROR, "WPA PSK allocation failed");
251 if (is_zero_ether_addr(addr))
254 os_memcpy(psk->addr, addr, ETH_ALEN);
258 wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
267 len = os_strlen(pos);
268 if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
270 else if (len >= 8 && len < 64) {
271 pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
272 4096, psk->psk, PMK_LEN);
276 wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in "
277 "'%s'", pos, line, fname);
283 psk->next = ssid->wpa_psk;
293 static int hostapd_derive_psk(struct hostapd_ssid *ssid)
295 ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
296 if (ssid->wpa_psk == NULL) {
297 wpa_printf(MSG_ERROR, "Unable to alloc space for PSK");
300 wpa_hexdump_ascii(MSG_DEBUG, "SSID",
301 (u8 *) ssid->ssid, ssid->ssid_len);
302 wpa_hexdump_ascii_key(MSG_DEBUG, "PSK (ASCII passphrase)",
303 (u8 *) ssid->wpa_passphrase,
304 os_strlen(ssid->wpa_passphrase));
305 pbkdf2_sha1(ssid->wpa_passphrase,
306 ssid->ssid, ssid->ssid_len,
307 4096, ssid->wpa_psk->psk, PMK_LEN);
308 wpa_hexdump_key(MSG_DEBUG, "PSK (from passphrase)",
309 ssid->wpa_psk->psk, PMK_LEN);
314 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
316 struct hostapd_ssid *ssid = &conf->ssid;
318 if (ssid->wpa_passphrase != NULL) {
319 if (ssid->wpa_psk != NULL) {
320 wpa_printf(MSG_DEBUG, "Using pre-configured WPA PSK "
321 "instead of passphrase");
323 wpa_printf(MSG_DEBUG, "Deriving WPA PSK based on "
325 if (hostapd_derive_psk(ssid) < 0)
328 ssid->wpa_psk->group = 1;
331 if (ssid->wpa_psk_file) {
332 if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
341 int hostapd_wep_key_cmp(struct hostapd_wep_keys *a, struct hostapd_wep_keys *b)
345 if (a->idx != b->idx || a->default_len != b->default_len)
347 for (i = 0; i < NUM_WEP_KEYS; i++)
348 if (a->len[i] != b->len[i] ||
349 os_memcmp(a->key[i], b->key[i], a->len[i]) != 0)
355 static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
360 for (i = 0; i < num_servers; i++) {
361 os_free(servers[i].shared_secret);
367 struct hostapd_radius_attr *
368 hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type)
370 for (; attr; attr = attr->next) {
371 if (attr->type == type)
378 static void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr)
380 struct hostapd_radius_attr *prev;
385 wpabuf_free(prev->val);
391 static void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
393 os_free(user->identity);
394 os_free(user->password);
399 static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
402 for (i = 0; i < NUM_WEP_KEYS; i++) {
403 os_free(keys->key[i]);
409 void hostapd_config_free_bss(struct hostapd_bss_config *conf)
411 struct hostapd_wpa_psk *psk, *prev;
412 struct hostapd_eap_user *user, *prev_user;
417 psk = conf->ssid.wpa_psk;
424 os_free(conf->ssid.wpa_passphrase);
425 os_free(conf->ssid.wpa_psk_file);
426 hostapd_config_free_wep(&conf->ssid.wep);
427 #ifdef CONFIG_FULL_DYNAMIC_VLAN
428 os_free(conf->ssid.vlan_tagged_interface);
429 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
431 user = conf->eap_user;
435 hostapd_config_free_eap_user(prev_user);
437 os_free(conf->eap_user_sqlite);
439 os_free(conf->eap_req_id_text);
440 os_free(conf->accept_mac);
441 os_free(conf->deny_mac);
442 os_free(conf->nas_identifier);
444 hostapd_config_free_radius(conf->radius->auth_servers,
445 conf->radius->num_auth_servers);
446 hostapd_config_free_radius(conf->radius->acct_servers,
447 conf->radius->num_acct_servers);
449 hostapd_config_free_radius_attr(conf->radius_auth_req_attr);
450 hostapd_config_free_radius_attr(conf->radius_acct_req_attr);
451 os_free(conf->rsn_preauth_interfaces);
452 os_free(conf->ctrl_interface);
453 os_free(conf->ca_cert);
454 os_free(conf->server_cert);
455 os_free(conf->private_key);
456 os_free(conf->private_key_passwd);
457 os_free(conf->ocsp_stapling_response);
458 os_free(conf->dh_file);
459 os_free(conf->pac_opaque_encr_key);
460 os_free(conf->eap_fast_a_id);
461 os_free(conf->eap_fast_a_id_info);
462 os_free(conf->eap_sim_db);
463 os_free(conf->radius_server_clients);
464 os_free(conf->test_socket);
465 os_free(conf->radius);
466 os_free(conf->radius_das_shared_secret);
467 hostapd_config_free_vlan(conf);
468 os_free(conf->time_zone);
470 #ifdef CONFIG_IEEE80211R
472 struct ft_remote_r0kh *r0kh, *r0kh_prev;
473 struct ft_remote_r1kh *r1kh, *r1kh_prev;
475 r0kh = conf->r0kh_list;
476 conf->r0kh_list = NULL;
483 r1kh = conf->r1kh_list;
484 conf->r1kh_list = NULL;
491 #endif /* CONFIG_IEEE80211R */
494 os_free(conf->wps_pin_requests);
495 os_free(conf->device_name);
496 os_free(conf->manufacturer);
497 os_free(conf->model_name);
498 os_free(conf->model_number);
499 os_free(conf->serial_number);
500 os_free(conf->config_methods);
501 os_free(conf->ap_pin);
502 os_free(conf->extra_cred);
503 os_free(conf->ap_settings);
504 os_free(conf->upnp_iface);
505 os_free(conf->friendly_name);
506 os_free(conf->manufacturer_url);
507 os_free(conf->model_description);
508 os_free(conf->model_url);
510 wpabuf_free(conf->wps_nfc_dh_pubkey);
511 wpabuf_free(conf->wps_nfc_dh_privkey);
512 wpabuf_free(conf->wps_nfc_dev_pw);
513 #endif /* CONFIG_WPS */
515 os_free(conf->roaming_consortium);
516 os_free(conf->venue_name);
517 os_free(conf->nai_realm_data);
518 os_free(conf->network_auth_type);
519 os_free(conf->anqp_3gpp_cell_net);
520 os_free(conf->domain_name);
522 #ifdef CONFIG_RADIUS_TEST
523 os_free(conf->dump_msk_file);
524 #endif /* CONFIG_RADIUS_TEST */
527 os_free(conf->hs20_oper_friendly_name);
528 os_free(conf->hs20_wan_metrics);
529 os_free(conf->hs20_connection_capability);
530 os_free(conf->hs20_operating_class);
531 os_free(conf->hs20_icons);
532 if (conf->hs20_osu_providers) {
534 for (i = 0; i < conf->hs20_osu_providers_count; i++) {
535 struct hs20_osu_provider *p;
537 p = &conf->hs20_osu_providers[i];
538 os_free(p->friendly_name);
539 os_free(p->server_uri);
540 os_free(p->method_list);
541 for (j = 0; j < p->icons_count; j++)
542 os_free(p->icons[j]);
545 os_free(p->service_desc);
547 os_free(conf->hs20_osu_providers);
549 os_free(conf->subscr_remediation_url);
550 #endif /* CONFIG_HS20 */
552 wpabuf_free(conf->vendor_elements);
554 os_free(conf->sae_groups);
556 os_free(conf->server_id);
563 * hostapd_config_free - Free hostapd configuration
564 * @conf: Configuration data from hostapd_config_read().
566 void hostapd_config_free(struct hostapd_config *conf)
573 for (i = 0; i < conf->num_bss; i++)
574 hostapd_config_free_bss(conf->bss[i]);
576 os_free(conf->supported_rates);
577 os_free(conf->basic_rates);
584 * hostapd_maclist_found - Find a MAC address from a list
585 * @list: MAC address list
586 * @num_entries: Number of addresses in the list
587 * @addr: Address to search for
588 * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
589 * Returns: 1 if address is in the list or 0 if not.
591 * Perform a binary search for given MAC address from a pre-sorted list.
593 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
594 const u8 *addr, int *vlan_id)
596 int start, end, middle, res;
599 end = num_entries - 1;
601 while (start <= end) {
602 middle = (start + end) / 2;
603 res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
606 *vlan_id = list[middle].vlan_id;
619 int hostapd_rate_found(int *list, int rate)
626 for (i = 0; list[i] >= 0; i++)
634 int hostapd_vlan_id_valid(struct hostapd_vlan *vlan, int vlan_id)
636 struct hostapd_vlan *v = vlan;
638 if (v->vlan_id == vlan_id || v->vlan_id == VLAN_ID_WILDCARD)
646 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
648 struct hostapd_vlan *v = vlan;
650 if (v->vlan_id == vlan_id)
658 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
659 const u8 *addr, const u8 *p2p_dev_addr,
662 struct hostapd_wpa_psk *psk;
663 int next_ok = prev_psk == NULL;
666 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
667 " p2p_dev_addr=" MACSTR " prev_psk=%p",
668 MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk);
669 if (!is_zero_ether_addr(p2p_dev_addr))
670 addr = NULL; /* Use P2P Device Address for matching */
672 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
674 MAC2STR(addr), prev_psk);
677 for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
680 (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) ||
681 (!addr && p2p_dev_addr &&
682 os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) ==
686 if (psk->psk == prev_psk)
694 static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
695 struct hostapd_config *conf,
698 if (full_config && bss->ieee802_1x && !bss->eap_server &&
699 !bss->radius->auth_servers) {
700 wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
701 "EAP authenticator configured).");
708 wep = bss->default_wep_key_len > 0 ||
709 bss->individual_wep_key_len > 0;
710 for (i = 0; i < NUM_WEP_KEYS; i++) {
711 if (bss->ssid.wep.keys_set) {
718 wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported");
723 if (full_config && bss->wpa &&
724 bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
725 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
726 wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no "
727 "RADIUS checking (macaddr_acl=2) enabled.");
731 if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
732 bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
733 bss->ssid.wpa_psk_file == NULL &&
734 (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED ||
735 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) {
736 wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
737 "is not configured.");
741 if (full_config && hostapd_mac_comp_empty(bss->bssid) != 0) {
744 for (i = 0; i < conf->num_bss; i++) {
745 if (conf->bss[i] != bss &&
746 (hostapd_mac_comp(conf->bss[i]->bssid,
748 wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
749 " on interface '%s' and '%s'.",
751 conf->bss[i]->iface, bss->iface);
757 #ifdef CONFIG_IEEE80211R
758 if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) &&
759 (bss->nas_identifier == NULL ||
760 os_strlen(bss->nas_identifier) < 1 ||
761 os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
762 wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
763 "nas_identifier to be configured as a 1..48 octet "
767 #endif /* CONFIG_IEEE80211R */
769 #ifdef CONFIG_IEEE80211N
770 if (full_config && conf->ieee80211n &&
771 conf->hw_mode == HOSTAPD_MODE_IEEE80211B) {
772 bss->disable_11n = 1;
773 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not "
774 "allowed, disabling HT capabilites");
777 if (full_config && conf->ieee80211n &&
778 bss->ssid.security_policy == SECURITY_STATIC_WEP) {
779 bss->disable_11n = 1;
780 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not "
781 "allowed, disabling HT capabilities");
784 if (full_config && conf->ieee80211n && bss->wpa &&
785 !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
786 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
787 WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256)))
789 bss->disable_11n = 1;
790 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
791 "requires CCMP/GCMP to be enabled, disabling HT "
794 #endif /* CONFIG_IEEE80211N */
797 if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) {
798 wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
799 "configuration forced WPS to be disabled");
803 if (full_config && bss->wps_state &&
804 bss->ssid.wep.keys_set && bss->wpa == 0) {
805 wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
810 if (full_config && bss->wps_state && bss->wpa &&
812 !(bss->rsn_pairwise & WPA_CIPHER_CCMP))) {
813 wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
814 "WPA2/CCMP forced WPS to be disabled");
817 #endif /* CONFIG_WPS2 */
820 if (full_config && bss->hs20 &&
822 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
823 WPA_CIPHER_CCMP_256 |
824 WPA_CIPHER_GCMP_256)))) {
825 wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP "
826 "configuration is required for Hotspot 2.0 "
830 #endif /* CONFIG_HS20 */
836 int hostapd_config_check(struct hostapd_config *conf, int full_config)
840 if (full_config && conf->ieee80211d &&
841 (!conf->country[0] || !conf->country[1])) {
842 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
843 "setting the country_code");
847 if (full_config && conf->ieee80211h && !conf->ieee80211d) {
848 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without "
849 "IEEE 802.11d enabled");
853 if (full_config && conf->local_pwr_constraint != -1 &&
855 wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element");
859 if (full_config && conf->spectrum_mgmt_required &&
860 conf->local_pwr_constraint == -1) {
861 wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements");
865 for (i = 0; i < conf->num_bss; i++) {
866 if (hostapd_config_check_bss(conf->bss[i], conf, full_config))
874 void hostapd_set_security_params(struct hostapd_bss_config *bss)
876 if (bss->individual_wep_key_len == 0) {
877 /* individual keys are not use; can use key idx0 for
879 bss->broadcast_key_idx_min = 0;
882 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
883 bss->rsn_pairwise = bss->wpa_pairwise;
884 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
887 bss->radius->auth_server = bss->radius->auth_servers;
888 bss->radius->acct_server = bss->radius->acct_servers;
890 if (bss->wpa && bss->ieee802_1x) {
891 bss->ssid.security_policy = SECURITY_WPA;
892 } else if (bss->wpa) {
893 bss->ssid.security_policy = SECURITY_WPA_PSK;
894 } else if (bss->ieee802_1x) {
895 int cipher = WPA_CIPHER_NONE;
896 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
897 bss->ssid.wep.default_len = bss->default_wep_key_len;
898 if (bss->default_wep_key_len)
899 cipher = bss->default_wep_key_len >= 13 ?
900 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
901 bss->wpa_group = cipher;
902 bss->wpa_pairwise = cipher;
903 bss->rsn_pairwise = cipher;
904 } else if (bss->ssid.wep.keys_set) {
905 int cipher = WPA_CIPHER_WEP40;
906 if (bss->ssid.wep.len[0] >= 13)
907 cipher = WPA_CIPHER_WEP104;
908 bss->ssid.security_policy = SECURITY_STATIC_WEP;
909 bss->wpa_group = cipher;
910 bss->wpa_pairwise = cipher;
911 bss->rsn_pairwise = cipher;
912 } else if (bss->osen) {
913 bss->ssid.security_policy = SECURITY_OSEN;
914 bss->wpa_group = WPA_CIPHER_CCMP;
915 bss->wpa_pairwise = 0;
916 bss->rsn_pairwise = WPA_CIPHER_CCMP;
918 bss->ssid.security_policy = SECURITY_PLAINTEXT;
919 bss->wpa_group = WPA_CIPHER_NONE;
920 bss->wpa_pairwise = WPA_CIPHER_NONE;
921 bss->rsn_pairwise = WPA_CIPHER_NONE;