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_num_scans = 5;
186 #endif /* CONFIG_ACS */
192 int hostapd_mac_comp(const void *a, const void *b)
194 return os_memcmp(a, b, sizeof(macaddr));
198 int hostapd_mac_comp_empty(const void *a)
200 macaddr empty = { 0 };
201 return os_memcmp(a, empty, 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 os_free(user->password);
387 static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
390 for (i = 0; i < NUM_WEP_KEYS; i++) {
391 os_free(keys->key[i]);
397 void hostapd_config_free_bss(struct hostapd_bss_config *conf)
399 struct hostapd_wpa_psk *psk, *prev;
400 struct hostapd_eap_user *user, *prev_user;
405 psk = conf->ssid.wpa_psk;
412 os_free(conf->ssid.wpa_passphrase);
413 os_free(conf->ssid.wpa_psk_file);
414 hostapd_config_free_wep(&conf->ssid.wep);
415 #ifdef CONFIG_FULL_DYNAMIC_VLAN
416 os_free(conf->ssid.vlan_tagged_interface);
417 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
419 user = conf->eap_user;
423 hostapd_config_free_eap_user(prev_user);
425 os_free(conf->eap_user_sqlite);
427 os_free(conf->eap_req_id_text);
428 os_free(conf->accept_mac);
429 os_free(conf->deny_mac);
430 os_free(conf->nas_identifier);
432 hostapd_config_free_radius(conf->radius->auth_servers,
433 conf->radius->num_auth_servers);
434 hostapd_config_free_radius(conf->radius->acct_servers,
435 conf->radius->num_acct_servers);
437 hostapd_config_free_radius_attr(conf->radius_auth_req_attr);
438 hostapd_config_free_radius_attr(conf->radius_acct_req_attr);
439 os_free(conf->rsn_preauth_interfaces);
440 os_free(conf->ctrl_interface);
441 os_free(conf->ca_cert);
442 os_free(conf->server_cert);
443 os_free(conf->private_key);
444 os_free(conf->private_key_passwd);
445 os_free(conf->ocsp_stapling_response);
446 os_free(conf->dh_file);
447 os_free(conf->pac_opaque_encr_key);
448 os_free(conf->eap_fast_a_id);
449 os_free(conf->eap_fast_a_id_info);
450 os_free(conf->eap_sim_db);
451 os_free(conf->radius_server_clients);
452 os_free(conf->test_socket);
453 os_free(conf->radius);
454 os_free(conf->radius_das_shared_secret);
455 hostapd_config_free_vlan(conf);
456 os_free(conf->time_zone);
458 #ifdef CONFIG_IEEE80211R
460 struct ft_remote_r0kh *r0kh, *r0kh_prev;
461 struct ft_remote_r1kh *r1kh, *r1kh_prev;
463 r0kh = conf->r0kh_list;
464 conf->r0kh_list = NULL;
471 r1kh = conf->r1kh_list;
472 conf->r1kh_list = NULL;
479 #endif /* CONFIG_IEEE80211R */
482 os_free(conf->wps_pin_requests);
483 os_free(conf->device_name);
484 os_free(conf->manufacturer);
485 os_free(conf->model_name);
486 os_free(conf->model_number);
487 os_free(conf->serial_number);
488 os_free(conf->config_methods);
489 os_free(conf->ap_pin);
490 os_free(conf->extra_cred);
491 os_free(conf->ap_settings);
492 os_free(conf->upnp_iface);
493 os_free(conf->friendly_name);
494 os_free(conf->manufacturer_url);
495 os_free(conf->model_description);
496 os_free(conf->model_url);
498 wpabuf_free(conf->wps_nfc_dh_pubkey);
499 wpabuf_free(conf->wps_nfc_dh_privkey);
500 wpabuf_free(conf->wps_nfc_dev_pw);
501 #endif /* CONFIG_WPS */
503 os_free(conf->roaming_consortium);
504 os_free(conf->venue_name);
505 os_free(conf->nai_realm_data);
506 os_free(conf->network_auth_type);
507 os_free(conf->anqp_3gpp_cell_net);
508 os_free(conf->domain_name);
510 #ifdef CONFIG_RADIUS_TEST
511 os_free(conf->dump_msk_file);
512 #endif /* CONFIG_RADIUS_TEST */
515 os_free(conf->hs20_oper_friendly_name);
516 os_free(conf->hs20_wan_metrics);
517 os_free(conf->hs20_connection_capability);
518 os_free(conf->hs20_operating_class);
519 os_free(conf->hs20_icons);
520 if (conf->hs20_osu_providers) {
522 for (i = 0; i < conf->hs20_osu_providers_count; i++) {
523 struct hs20_osu_provider *p;
525 p = &conf->hs20_osu_providers[i];
526 os_free(p->friendly_name);
527 os_free(p->server_uri);
528 os_free(p->method_list);
529 for (j = 0; j < p->icons_count; j++)
530 os_free(p->icons[j]);
533 os_free(p->service_desc);
535 os_free(conf->hs20_osu_providers);
537 os_free(conf->subscr_remediation_url);
538 #endif /* CONFIG_HS20 */
540 wpabuf_free(conf->vendor_elements);
542 os_free(conf->sae_groups);
544 os_free(conf->server_id);
551 * hostapd_config_free - Free hostapd configuration
552 * @conf: Configuration data from hostapd_config_read().
554 void hostapd_config_free(struct hostapd_config *conf)
561 for (i = 0; i < conf->num_bss; i++)
562 hostapd_config_free_bss(conf->bss[i]);
564 os_free(conf->supported_rates);
565 os_free(conf->basic_rates);
566 os_free(conf->chanlist);
573 * hostapd_maclist_found - Find a MAC address from a list
574 * @list: MAC address list
575 * @num_entries: Number of addresses in the list
576 * @addr: Address to search for
577 * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
578 * Returns: 1 if address is in the list or 0 if not.
580 * Perform a binary search for given MAC address from a pre-sorted list.
582 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
583 const u8 *addr, int *vlan_id)
585 int start, end, middle, res;
588 end = num_entries - 1;
590 while (start <= end) {
591 middle = (start + end) / 2;
592 res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
595 *vlan_id = list[middle].vlan_id;
608 int hostapd_rate_found(int *list, int rate)
615 for (i = 0; list[i] >= 0; i++)
623 int hostapd_vlan_id_valid(struct hostapd_vlan *vlan, int vlan_id)
625 struct hostapd_vlan *v = vlan;
627 if (v->vlan_id == vlan_id || v->vlan_id == VLAN_ID_WILDCARD)
635 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
637 struct hostapd_vlan *v = vlan;
639 if (v->vlan_id == vlan_id)
647 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
648 const u8 *addr, const u8 *p2p_dev_addr,
651 struct hostapd_wpa_psk *psk;
652 int next_ok = prev_psk == NULL;
654 if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) {
655 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
656 " p2p_dev_addr=" MACSTR " prev_psk=%p",
657 MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk);
658 addr = NULL; /* Use P2P Device Address for matching */
660 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
662 MAC2STR(addr), prev_psk);
665 for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
668 (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) ||
669 (!addr && p2p_dev_addr &&
670 os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) ==
674 if (psk->psk == prev_psk)
682 static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
683 struct hostapd_config *conf,
686 if (full_config && bss->ieee802_1x && !bss->eap_server &&
687 !bss->radius->auth_servers) {
688 wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
689 "EAP authenticator configured).");
696 wep = bss->default_wep_key_len > 0 ||
697 bss->individual_wep_key_len > 0;
698 for (i = 0; i < NUM_WEP_KEYS; i++) {
699 if (bss->ssid.wep.keys_set) {
706 wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported");
711 if (full_config && bss->wpa &&
712 bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
713 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
714 wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no "
715 "RADIUS checking (macaddr_acl=2) enabled.");
719 if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
720 bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
721 bss->ssid.wpa_psk_file == NULL &&
722 (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED ||
723 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) {
724 wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
725 "is not configured.");
729 if (full_config && hostapd_mac_comp_empty(bss->bssid) != 0) {
732 for (i = 0; i < conf->num_bss; i++) {
733 if (conf->bss[i] != bss &&
734 (hostapd_mac_comp(conf->bss[i]->bssid,
736 wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
737 " on interface '%s' and '%s'.",
739 conf->bss[i]->iface, bss->iface);
745 #ifdef CONFIG_IEEE80211R
746 if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) &&
747 (bss->nas_identifier == NULL ||
748 os_strlen(bss->nas_identifier) < 1 ||
749 os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
750 wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
751 "nas_identifier to be configured as a 1..48 octet "
755 #endif /* CONFIG_IEEE80211R */
757 #ifdef CONFIG_IEEE80211N
758 if (full_config && conf->ieee80211n &&
759 conf->hw_mode == HOSTAPD_MODE_IEEE80211B) {
760 bss->disable_11n = 1;
761 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not "
762 "allowed, disabling HT capabilites");
765 if (full_config && conf->ieee80211n &&
766 bss->ssid.security_policy == SECURITY_STATIC_WEP) {
767 bss->disable_11n = 1;
768 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not "
769 "allowed, disabling HT capabilities");
772 if (full_config && conf->ieee80211n && bss->wpa &&
773 !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
774 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
775 WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256)))
777 bss->disable_11n = 1;
778 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
779 "requires CCMP/GCMP to be enabled, disabling HT "
782 #endif /* CONFIG_IEEE80211N */
785 if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) {
786 wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
787 "configuration forced WPS to be disabled");
791 if (full_config && bss->wps_state &&
792 bss->ssid.wep.keys_set && bss->wpa == 0) {
793 wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
798 if (full_config && bss->wps_state && bss->wpa &&
800 !(bss->rsn_pairwise & WPA_CIPHER_CCMP))) {
801 wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
802 "WPA2/CCMP forced WPS to be disabled");
805 #endif /* CONFIG_WPS */
808 if (full_config && bss->hs20 &&
810 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
811 WPA_CIPHER_CCMP_256 |
812 WPA_CIPHER_GCMP_256)))) {
813 wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP "
814 "configuration is required for Hotspot 2.0 "
818 #endif /* CONFIG_HS20 */
824 int hostapd_config_check(struct hostapd_config *conf, int full_config)
828 if (full_config && conf->ieee80211d &&
829 (!conf->country[0] || !conf->country[1])) {
830 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
831 "setting the country_code");
835 if (full_config && conf->ieee80211h && !conf->ieee80211d) {
836 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without "
837 "IEEE 802.11d enabled");
841 if (full_config && conf->local_pwr_constraint != -1 &&
843 wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element");
847 if (full_config && conf->spectrum_mgmt_required &&
848 conf->local_pwr_constraint == -1) {
849 wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements");
853 for (i = 0; i < conf->num_bss; i++) {
854 if (hostapd_config_check_bss(conf->bss[i], conf, full_config))
862 void hostapd_set_security_params(struct hostapd_bss_config *bss)
864 if (bss->individual_wep_key_len == 0) {
865 /* individual keys are not use; can use key idx0 for
867 bss->broadcast_key_idx_min = 0;
870 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
871 bss->rsn_pairwise = bss->wpa_pairwise;
872 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
875 bss->radius->auth_server = bss->radius->auth_servers;
876 bss->radius->acct_server = bss->radius->acct_servers;
878 if (bss->wpa && bss->ieee802_1x) {
879 bss->ssid.security_policy = SECURITY_WPA;
880 } else if (bss->wpa) {
881 bss->ssid.security_policy = SECURITY_WPA_PSK;
882 } else if (bss->ieee802_1x) {
883 int cipher = WPA_CIPHER_NONE;
884 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
885 bss->ssid.wep.default_len = bss->default_wep_key_len;
886 if (bss->default_wep_key_len)
887 cipher = bss->default_wep_key_len >= 13 ?
888 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
889 bss->wpa_group = cipher;
890 bss->wpa_pairwise = cipher;
891 bss->rsn_pairwise = cipher;
892 } else if (bss->ssid.wep.keys_set) {
893 int cipher = WPA_CIPHER_WEP40;
894 if (bss->ssid.wep.len[0] >= 13)
895 cipher = WPA_CIPHER_WEP104;
896 bss->ssid.security_policy = SECURITY_STATIC_WEP;
897 bss->wpa_group = cipher;
898 bss->wpa_pairwise = cipher;
899 bss->rsn_pairwise = cipher;
900 } else if (bss->osen) {
901 bss->ssid.security_policy = SECURITY_OSEN;
902 bss->wpa_group = WPA_CIPHER_CCMP;
903 bss->wpa_pairwise = 0;
904 bss->rsn_pairwise = WPA_CIPHER_CCMP;
906 bss->ssid.security_policy = SECURITY_PLAINTEXT;
907 bss->wpa_group = WPA_CIPHER_NONE;
908 bss->wpa_pairwise = WPA_CIPHER_NONE;
909 bss->rsn_pairwise = WPA_CIPHER_NONE;