blob: 66b843ca0f4d617e67fd772cb0efb034cd12a636 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
2 * hostapd / Configuration helper functions
Dmitry Shmidt344abd32014-01-14 13:17:00 -08003 * Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi>
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07004 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08005 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07007 */
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"
16#include "eap_common/eap_wsc_common.h"
17#include "eap_server/eap.h"
18#include "wpa_auth.h"
19#include "sta_info.h"
20#include "ap_config.h"
21
22
23static void hostapd_config_free_vlan(struct hostapd_bss_config *bss)
24{
25 struct hostapd_vlan *vlan, *prev;
26
27 vlan = bss->vlan;
28 prev = NULL;
29 while (vlan) {
30 prev = vlan;
31 vlan = vlan->next;
32 os_free(prev);
33 }
34
35 bss->vlan = NULL;
36}
37
38
39void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
40{
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080041 dl_list_init(&bss->anqp_elem);
42
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070043 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;
47
48 bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED;
49
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;
55
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;
62
63 bss->max_num_sta = MAX_STA_COUNT;
64
65 bss->dtim_period = 2;
66
67 bss->radius_server_auth_port = 1812;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -080068 bss->eap_sim_db_timeout = 1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070069 bss->ap_max_inactivity = AP_MAX_INACTIVITY;
70 bss->eapol_version = EAPOL_VERSION;
71
72 bss->max_listen_interval = 65535;
73
74 bss->pwd_group = 19; /* ECC: GF(p=256) */
75
76#ifdef CONFIG_IEEE80211W
77 bss->assoc_sa_query_max_timeout = 1000;
78 bss->assoc_sa_query_retry_timeout = 201;
Dmitry Shmidtb36ed7c2014-03-17 10:57:26 -070079 bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070080#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 */
87
88 /* Set to -1 as defaults depends on HT in setup */
89 bss->wmm_enabled = -1;
90
91#ifdef CONFIG_IEEE80211R
92 bss->ft_over_ds = 1;
93#endif /* CONFIG_IEEE80211R */
Dmitry Shmidt04949592012-07-19 12:16:46 -070094
95 bss->radius_das_time_window = 300;
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -080096
97 bss->sae_anti_clogging_threshold = 5;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070098}
99
100
101struct hostapd_config * hostapd_config_defaults(void)
102{
103#define ecw2cw(ecw) ((1 << (ecw)) - 1)
104
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 */
Dmitry Shmidtb36ed7c2014-03-17 10:57:26 -0700113 { aCWmin - 1, aCWmin, 2, 3008 / 32, 0 };
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700114 const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */
Dmitry Shmidtb36ed7c2014-03-17 10:57:26 -0700115 { aCWmin - 2, aCWmin - 1, 2, 1504 / 32, 0 };
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700116 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};
125
126#undef ecw2cw
127
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.");
133 os_free(conf);
134 os_free(bss);
135 return NULL;
136 }
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800137 conf->bss = os_calloc(1, sizeof(struct hostapd_bss_config *));
138 if (conf->bss == NULL) {
139 os_free(conf);
140 os_free(bss);
141 return NULL;
142 }
143 conf->bss[0] = bss;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700144
145 bss->radius = os_zalloc(sizeof(*bss->radius));
146 if (bss->radius == NULL) {
Dmitry Shmidt97672262014-02-03 13:02:54 -0800147 os_free(conf->bss);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700148 os_free(conf);
149 os_free(bss);
150 return NULL;
151 }
152
153 hostapd_config_defaults_bss(bss);
154
155 conf->num_bss = 1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700156
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;
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800161 /* Set to invalid value means do not add Power Constraint IE */
162 conf->local_pwr_constraint = -1;
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700163
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;
168
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;
173
174 conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
175
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800176 conf->ap_table_max_size = 255;
177 conf->ap_table_expiration_time = 60;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800178 conf->track_sta_max_age = 180;
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800179
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700180#ifdef CONFIG_TESTING_OPTIONS
Dmitry Shmidt7832adb2014-04-29 10:53:02 -0700181 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;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800186 conf->ecsa_ie_only = 0;
Dmitry Shmidt8da800a2013-04-24 12:57:01 -0700187#endif /* CONFIG_TESTING_OPTIONS */
188
Dmitry Shmidtdda10c22015-03-24 16:05:01 -0700189 conf->acs = 0;
190 conf->acs_ch_list.num = 0;
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700191#ifdef CONFIG_ACS
192 conf->acs_num_scans = 5;
193#endif /* CONFIG_ACS */
194
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700195 return conf;
196}
197
198
199int hostapd_mac_comp(const void *a, const void *b)
200{
201 return os_memcmp(a, b, sizeof(macaddr));
202}
203
204
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700205static int hostapd_config_read_wpa_psk(const char *fname,
206 struct hostapd_ssid *ssid)
207{
208 FILE *f;
209 char buf[128], *pos;
210 int line = 0, ret = 0, len, ok;
211 u8 addr[ETH_ALEN];
212 struct hostapd_wpa_psk *psk;
213
214 if (!fname)
215 return 0;
216
217 f = fopen(fname, "r");
218 if (!f) {
219 wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname);
220 return -1;
221 }
222
223 while (fgets(buf, sizeof(buf), f)) {
224 line++;
225
226 if (buf[0] == '#')
227 continue;
228 pos = buf;
229 while (*pos != '\0') {
230 if (*pos == '\n') {
231 *pos = '\0';
232 break;
233 }
234 pos++;
235 }
236 if (buf[0] == '\0')
237 continue;
238
239 if (hwaddr_aton(buf, addr)) {
240 wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on "
241 "line %d in '%s'", buf, line, fname);
242 ret = -1;
243 break;
244 }
245
246 psk = os_zalloc(sizeof(*psk));
247 if (psk == NULL) {
248 wpa_printf(MSG_ERROR, "WPA PSK allocation failed");
249 ret = -1;
250 break;
251 }
252 if (is_zero_ether_addr(addr))
253 psk->group = 1;
254 else
255 os_memcpy(psk->addr, addr, ETH_ALEN);
256
257 pos = buf + 17;
258 if (*pos == '\0') {
259 wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'",
260 line, fname);
261 os_free(psk);
262 ret = -1;
263 break;
264 }
265 pos++;
266
267 ok = 0;
268 len = os_strlen(pos);
269 if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
270 ok = 1;
271 else if (len >= 8 && len < 64) {
272 pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
273 4096, psk->psk, PMK_LEN);
274 ok = 1;
275 }
276 if (!ok) {
277 wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in "
278 "'%s'", pos, line, fname);
279 os_free(psk);
280 ret = -1;
281 break;
282 }
283
284 psk->next = ssid->wpa_psk;
285 ssid->wpa_psk = psk;
286 }
287
288 fclose(f);
289
290 return ret;
291}
292
293
294static int hostapd_derive_psk(struct hostapd_ssid *ssid)
295{
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");
299 return -1;
300 }
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);
311 return 0;
312}
313
314
315int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
316{
317 struct hostapd_ssid *ssid = &conf->ssid;
318
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");
323 } else {
324 wpa_printf(MSG_DEBUG, "Deriving WPA PSK based on "
325 "passphrase");
326 if (hostapd_derive_psk(ssid) < 0)
327 return -1;
328 }
329 ssid->wpa_psk->group = 1;
330 }
331
332 if (ssid->wpa_psk_file) {
333 if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
334 &conf->ssid))
335 return -1;
336 }
337
338 return 0;
339}
340
341
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700342static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
343 int num_servers)
344{
345 int i;
346
347 for (i = 0; i < num_servers; i++) {
348 os_free(servers[i].shared_secret);
349 }
350 os_free(servers);
351}
352
353
Dmitry Shmidt04949592012-07-19 12:16:46 -0700354struct hostapd_radius_attr *
355hostapd_config_get_radius_attr(struct hostapd_radius_attr *attr, u8 type)
356{
357 for (; attr; attr = attr->next) {
358 if (attr->type == type)
359 return attr;
360 }
361 return NULL;
362}
363
364
365static void hostapd_config_free_radius_attr(struct hostapd_radius_attr *attr)
366{
367 struct hostapd_radius_attr *prev;
368
369 while (attr) {
370 prev = attr;
371 attr = attr->next;
372 wpabuf_free(prev->val);
373 os_free(prev);
374 }
375}
376
377
Dmitry Shmidt818ea482014-03-10 13:15:21 -0700378void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700379{
Dmitry Shmidt818ea482014-03-10 13:15:21 -0700380 hostapd_config_free_radius_attr(user->accept_attr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700381 os_free(user->identity);
Dmitry Shmidtc2817022014-07-02 10:32:10 -0700382 bin_clear_free(user->password, user->password_len);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700383 os_free(user);
384}
385
386
387static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
388{
389 int i;
390 for (i = 0; i < NUM_WEP_KEYS; i++) {
Dmitry Shmidtc2817022014-07-02 10:32:10 -0700391 bin_clear_free(keys->key[i], keys->len[i]);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700392 keys->key[i] = NULL;
393 }
394}
395
396
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800397void hostapd_config_clear_wpa_psk(struct hostapd_wpa_psk **l)
398{
399 struct hostapd_wpa_psk *psk, *tmp;
400
401 for (psk = *l; psk;) {
402 tmp = psk;
403 psk = psk->next;
404 bin_clear_free(tmp, sizeof(*tmp));
405 }
406 *l = NULL;
407}
408
409
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800410static void hostapd_config_free_anqp_elem(struct hostapd_bss_config *conf)
411{
412 struct anqp_element *elem;
413
414 while ((elem = dl_list_first(&conf->anqp_elem, struct anqp_element,
415 list))) {
416 dl_list_del(&elem->list);
417 wpabuf_free(elem->payload);
418 os_free(elem);
419 }
420}
421
422
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800423void hostapd_config_free_bss(struct hostapd_bss_config *conf)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700424{
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700425 struct hostapd_eap_user *user, *prev_user;
426
427 if (conf == NULL)
428 return;
429
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800430 hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700431
Dmitry Shmidtc2817022014-07-02 10:32:10 -0700432 str_clear_free(conf->ssid.wpa_passphrase);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700433 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 */
438
439 user = conf->eap_user;
440 while (user) {
441 prev_user = user;
442 user = user->next;
443 hostapd_config_free_eap_user(prev_user);
444 }
Dmitry Shmidtd5e49232012-12-03 15:08:10 -0800445 os_free(conf->eap_user_sqlite);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700446
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700447 os_free(conf->eap_req_id_text);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800448 os_free(conf->erp_domain);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700449 os_free(conf->accept_mac);
450 os_free(conf->deny_mac);
451 os_free(conf->nas_identifier);
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800452 if (conf->radius) {
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);
457 }
Dmitry Shmidt04949592012-07-19 12:16:46 -0700458 hostapd_config_free_radius_attr(conf->radius_auth_req_attr);
459 hostapd_config_free_radius_attr(conf->radius_acct_req_attr);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700460 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);
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700466 os_free(conf->ocsp_stapling_response);
Dmitry Shmidt014a3ff2015-12-28 13:27:49 -0800467 os_free(conf->ocsp_stapling_response_multi);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700468 os_free(conf->dh_file);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800469 os_free(conf->openssl_ciphers);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700470 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);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700475 os_free(conf->radius);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700476 os_free(conf->radius_das_shared_secret);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700477 hostapd_config_free_vlan(conf);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800478 os_free(conf->time_zone);
479
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700480#ifdef CONFIG_IEEE80211R
481 {
482 struct ft_remote_r0kh *r0kh, *r0kh_prev;
483 struct ft_remote_r1kh *r1kh, *r1kh_prev;
484
485 r0kh = conf->r0kh_list;
486 conf->r0kh_list = NULL;
487 while (r0kh) {
488 r0kh_prev = r0kh;
489 r0kh = r0kh->next;
490 os_free(r0kh_prev);
491 }
492
493 r1kh = conf->r1kh_list;
494 conf->r1kh_list = NULL;
495 while (r1kh) {
496 r1kh_prev = r1kh;
497 r1kh = r1kh->next;
498 os_free(r1kh_prev);
499 }
500 }
501#endif /* CONFIG_IEEE80211R */
502
503#ifdef CONFIG_WPS
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);
519 os_free(conf->upc);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800520 {
521 unsigned int i;
522
523 for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++)
524 wpabuf_free(conf->wps_vendor_ext[i]);
525 }
Dmitry Shmidt04949592012-07-19 12:16:46 -0700526 wpabuf_free(conf->wps_nfc_dh_pubkey);
527 wpabuf_free(conf->wps_nfc_dh_privkey);
528 wpabuf_free(conf->wps_nfc_dev_pw);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700529#endif /* CONFIG_WPS */
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800530
531 os_free(conf->roaming_consortium);
Dmitry Shmidt04949592012-07-19 12:16:46 -0700532 os_free(conf->venue_name);
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700533 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);
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800537 hostapd_config_free_anqp_elem(conf);
Dmitry Shmidt1f69aa52012-01-24 16:10:04 -0800538
539#ifdef CONFIG_RADIUS_TEST
540 os_free(conf->dump_msk_file);
541#endif /* CONFIG_RADIUS_TEST */
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700542
543#ifdef CONFIG_HS20
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);
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800548 os_free(conf->hs20_icons);
549 if (conf->hs20_osu_providers) {
550 size_t i;
551 for (i = 0; i < conf->hs20_osu_providers_count; i++) {
552 struct hs20_osu_provider *p;
553 size_t j;
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]);
560 os_free(p->icons);
561 os_free(p->osu_nai);
562 os_free(p->service_desc);
563 }
564 os_free(conf->hs20_osu_providers);
565 }
566 os_free(conf->subscr_remediation_url);
Dmitry Shmidt61d9df32012-08-29 16:22:06 -0700567#endif /* CONFIG_HS20 */
568
569 wpabuf_free(conf->vendor_elements);
Dmitry Shmidta54fa5f2013-01-15 13:53:35 -0800570
571 os_free(conf->sae_groups);
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700572
Dmitry Shmidt0207e232014-09-03 14:58:37 -0700573 os_free(conf->wowlan_triggers);
574
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700575 os_free(conf->server_id);
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800576
Dmitry Shmidtd80a4012015-11-05 16:35:40 -0800577#ifdef CONFIG_TESTING_OPTIONS
578 wpabuf_free(conf->own_ie_override);
579#endif /* CONFIG_TESTING_OPTIONS */
580
581 os_free(conf->no_probe_resp_if_seen_on);
582 os_free(conf->no_auth_if_seen_on);
583
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800584 os_free(conf);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700585}
586
587
588/**
589 * hostapd_config_free - Free hostapd configuration
590 * @conf: Configuration data from hostapd_config_read().
591 */
592void hostapd_config_free(struct hostapd_config *conf)
593{
594 size_t i;
595
596 if (conf == NULL)
597 return;
598
599 for (i = 0; i < conf->num_bss; i++)
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800600 hostapd_config_free_bss(conf->bss[i]);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700601 os_free(conf->bss);
602 os_free(conf->supported_rates);
603 os_free(conf->basic_rates);
Dmitry Shmidtdda10c22015-03-24 16:05:01 -0700604 os_free(conf->acs_ch_list.range);
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800605 os_free(conf->driver_params);
Dmitry Shmidt7f656022015-02-25 14:36:37 -0800606#ifdef CONFIG_ACS
607 os_free(conf->acs_chan_bias);
608#endif /* CONFIG_ACS */
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700609
610 os_free(conf);
611}
612
613
614/**
615 * hostapd_maclist_found - Find a MAC address from a list
616 * @list: MAC address list
617 * @num_entries: Number of addresses in the list
618 * @addr: Address to search for
619 * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed
620 * Returns: 1 if address is in the list or 0 if not.
621 *
622 * Perform a binary search for given MAC address from a pre-sorted list.
623 */
624int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800625 const u8 *addr, struct vlan_description *vlan_id)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700626{
627 int start, end, middle, res;
628
629 start = 0;
630 end = num_entries - 1;
631
632 while (start <= end) {
633 middle = (start + end) / 2;
634 res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
635 if (res == 0) {
636 if (vlan_id)
637 *vlan_id = list[middle].vlan_id;
638 return 1;
639 }
640 if (res < 0)
641 start = middle + 1;
642 else
643 end = middle - 1;
644 }
645
646 return 0;
647}
648
649
650int hostapd_rate_found(int *list, int rate)
651{
652 int i;
653
654 if (list == NULL)
655 return 0;
656
657 for (i = 0; list[i] >= 0; i++)
658 if (list[i] == rate)
659 return 1;
660
661 return 0;
662}
663
664
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800665int hostapd_vlan_valid(struct hostapd_vlan *vlan,
666 struct vlan_description *vlan_desc)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700667{
668 struct hostapd_vlan *v = vlan;
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800669 int i;
670
671 if (!vlan_desc->notempty || vlan_desc->untagged < 0 ||
672 vlan_desc->untagged > MAX_VLAN_ID)
673 return 0;
674 for (i = 0; i < MAX_NUM_TAGGED_VLAN; i++) {
675 if (vlan_desc->tagged[i] < 0 ||
676 vlan_desc->tagged[i] > MAX_VLAN_ID)
677 return 0;
678 }
679 if (!vlan_desc->untagged && !vlan_desc->tagged[0])
680 return 0;
681
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700682 while (v) {
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800683 if (!vlan_compare(&v->vlan_desc, vlan_desc) ||
684 v->vlan_id == VLAN_ID_WILDCARD)
Dmitry Shmidt34af3062013-07-11 10:46:32 -0700685 return 1;
686 v = v->next;
687 }
688 return 0;
689}
690
691
692const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
693{
694 struct hostapd_vlan *v = vlan;
695 while (v) {
696 if (v->vlan_id == vlan_id)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700697 return v->ifname;
698 v = v->next;
699 }
700 return NULL;
701}
702
703
704const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700705 const u8 *addr, const u8 *p2p_dev_addr,
706 const u8 *prev_psk)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700707{
708 struct hostapd_wpa_psk *psk;
709 int next_ok = prev_psk == NULL;
710
Dmitry Shmidtdf5a7e42014-04-02 12:59:59 -0700711 if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) {
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700712 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
713 " p2p_dev_addr=" MACSTR " prev_psk=%p",
714 MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk);
Dmitry Shmidtdf5a7e42014-04-02 12:59:59 -0700715 addr = NULL; /* Use P2P Device Address for matching */
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700716 } else {
717 wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR
718 " prev_psk=%p",
719 MAC2STR(addr), prev_psk);
720 }
721
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700722 for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
723 if (next_ok &&
Dmitry Shmidt391c59f2013-09-03 12:16:28 -0700724 (psk->group ||
725 (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) ||
726 (!addr && p2p_dev_addr &&
727 os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) ==
728 0)))
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700729 return psk->psk;
730
731 if (psk->psk == prev_psk)
732 next_ok = 1;
733 }
734
735 return NULL;
736}
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800737
738
739static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800740 struct hostapd_config *conf,
741 int full_config)
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800742{
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800743 if (full_config && bss->ieee802_1x && !bss->eap_server &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800744 !bss->radius->auth_servers) {
745 wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
746 "EAP authenticator configured).");
747 return -1;
748 }
749
750 if (bss->wpa) {
751 int wep, i;
752
753 wep = bss->default_wep_key_len > 0 ||
754 bss->individual_wep_key_len > 0;
755 for (i = 0; i < NUM_WEP_KEYS; i++) {
756 if (bss->ssid.wep.keys_set) {
757 wep = 1;
758 break;
759 }
760 }
761
762 if (wep) {
763 wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported");
764 return -1;
765 }
766 }
767
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800768 if (full_config && bss->wpa &&
769 bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800770 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
771 wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no "
772 "RADIUS checking (macaddr_acl=2) enabled.");
773 return -1;
774 }
775
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800776 if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800777 bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
778 bss->ssid.wpa_psk_file == NULL &&
779 (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED ||
780 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) {
781 wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
782 "is not configured.");
783 return -1;
784 }
785
Dmitry Shmidt9c175262016-03-03 10:20:07 -0800786 if (full_config && !is_zero_ether_addr(bss->bssid)) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800787 size_t i;
788
789 for (i = 0; i < conf->num_bss; i++) {
790 if (conf->bss[i] != bss &&
791 (hostapd_mac_comp(conf->bss[i]->bssid,
792 bss->bssid) == 0)) {
793 wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
794 " on interface '%s' and '%s'.",
795 MAC2STR(bss->bssid),
796 conf->bss[i]->iface, bss->iface);
797 return -1;
798 }
799 }
800 }
801
802#ifdef CONFIG_IEEE80211R
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800803 if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800804 (bss->nas_identifier == NULL ||
805 os_strlen(bss->nas_identifier) < 1 ||
806 os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
807 wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
808 "nas_identifier to be configured as a 1..48 octet "
809 "string");
810 return -1;
811 }
812#endif /* CONFIG_IEEE80211R */
813
814#ifdef CONFIG_IEEE80211N
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800815 if (full_config && conf->ieee80211n &&
816 conf->hw_mode == HOSTAPD_MODE_IEEE80211B) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800817 bss->disable_11n = 1;
818 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not "
Dmitry Shmidt661b4f72014-09-29 14:58:27 -0700819 "allowed, disabling HT capabilities");
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800820 }
821
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800822 if (full_config && conf->ieee80211n &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800823 bss->ssid.security_policy == SECURITY_STATIC_WEP) {
824 bss->disable_11n = 1;
825 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not "
826 "allowed, disabling HT capabilities");
827 }
828
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800829 if (full_config && conf->ieee80211n && bss->wpa &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800830 !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800831 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
832 WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256)))
833 {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800834 bss->disable_11n = 1;
835 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
836 "requires CCMP/GCMP to be enabled, disabling HT "
837 "capabilities");
838 }
839#endif /* CONFIG_IEEE80211N */
840
Dmitry Shmidt15907092014-03-25 10:42:57 -0700841#ifdef CONFIG_WPS
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800842 if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800843 wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
844 "configuration forced WPS to be disabled");
845 bss->wps_state = 0;
846 }
847
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800848 if (full_config && bss->wps_state &&
849 bss->ssid.wep.keys_set && bss->wpa == 0) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800850 wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
851 "disabled");
852 bss->wps_state = 0;
853 }
854
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800855 if (full_config && bss->wps_state && bss->wpa &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800856 (!(bss->wpa & 2) ||
Dmitry Shmidt1d755d02015-04-28 10:34:29 -0700857 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)))) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800858 wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
Dmitry Shmidt1d755d02015-04-28 10:34:29 -0700859 "WPA2/CCMP/GCMP forced WPS to be disabled");
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800860 bss->wps_state = 0;
861 }
Dmitry Shmidt15907092014-03-25 10:42:57 -0700862#endif /* CONFIG_WPS */
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800863
864#ifdef CONFIG_HS20
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800865 if (full_config && bss->hs20 &&
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800866 (!(bss->wpa & 2) ||
Dmitry Shmidtfb79edc2014-01-10 10:45:54 -0800867 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP |
868 WPA_CIPHER_CCMP_256 |
869 WPA_CIPHER_GCMP_256)))) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800870 wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP "
871 "configuration is required for Hotspot 2.0 "
872 "functionality");
873 return -1;
874 }
875#endif /* CONFIG_HS20 */
876
Dmitry Shmidt57c2d392016-02-23 13:40:19 -0800877#ifdef CONFIG_MBO
878 if (full_config && bss->mbo_enabled && (bss->wpa & 2) &&
879 bss->ieee80211w == NO_MGMT_FRAME_PROTECTION) {
880 wpa_printf(MSG_ERROR,
881 "MBO: PMF needs to be enabled whenever using WPA2 with MBO");
882 return -1;
883 }
884#endif /* CONFIG_MBO */
885
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800886 return 0;
887}
888
889
Dmitry Shmidt05df46a2015-05-19 11:02:01 -0700890static int hostapd_config_check_cw(struct hostapd_config *conf, int queue)
891{
892 int tx_cwmin = conf->tx_queue[queue].cwmin;
893 int tx_cwmax = conf->tx_queue[queue].cwmax;
894 int ac_cwmin = conf->wmm_ac_params[queue].cwmin;
895 int ac_cwmax = conf->wmm_ac_params[queue].cwmax;
896
897 if (tx_cwmin > tx_cwmax) {
898 wpa_printf(MSG_ERROR,
899 "Invalid TX queue cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
900 tx_cwmin, tx_cwmax);
901 return -1;
902 }
903 if (ac_cwmin > ac_cwmax) {
904 wpa_printf(MSG_ERROR,
905 "Invalid WMM AC cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)",
906 ac_cwmin, ac_cwmax);
907 return -1;
908 }
909 return 0;
910}
911
912
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800913int hostapd_config_check(struct hostapd_config *conf, int full_config)
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800914{
915 size_t i;
916
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800917 if (full_config && conf->ieee80211d &&
918 (!conf->country[0] || !conf->country[1])) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800919 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
920 "setting the country_code");
921 return -1;
922 }
923
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800924 if (full_config && conf->ieee80211h && !conf->ieee80211d) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800925 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without "
926 "IEEE 802.11d enabled");
927 return -1;
928 }
929
Dmitry Shmidtf21452a2014-02-26 10:55:25 -0800930 if (full_config && conf->local_pwr_constraint != -1 &&
931 !conf->ieee80211d) {
932 wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element");
933 return -1;
934 }
935
936 if (full_config && conf->spectrum_mgmt_required &&
937 conf->local_pwr_constraint == -1) {
938 wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements");
939 return -1;
940 }
941
Dmitry Shmidt05df46a2015-05-19 11:02:01 -0700942 for (i = 0; i < NUM_TX_QUEUES; i++) {
943 if (hostapd_config_check_cw(conf, i))
944 return -1;
945 }
946
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800947 for (i = 0; i < conf->num_bss; i++) {
Dmitry Shmidt344abd32014-01-14 13:17:00 -0800948 if (hostapd_config_check_bss(conf->bss[i], conf, full_config))
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800949 return -1;
950 }
951
952 return 0;
953}
954
955
Dmitry Shmidt71757432014-06-02 13:50:35 -0700956void hostapd_set_security_params(struct hostapd_bss_config *bss,
957 int full_config)
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800958{
959 if (bss->individual_wep_key_len == 0) {
960 /* individual keys are not use; can use key idx0 for
961 * broadcast keys */
962 bss->broadcast_key_idx_min = 0;
963 }
964
965 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
966 bss->rsn_pairwise = bss->wpa_pairwise;
967 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
968 bss->rsn_pairwise);
969
Dmitry Shmidt71757432014-06-02 13:50:35 -0700970 if (full_config) {
971 bss->radius->auth_server = bss->radius->auth_servers;
972 bss->radius->acct_server = bss->radius->acct_servers;
973 }
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800974
975 if (bss->wpa && bss->ieee802_1x) {
976 bss->ssid.security_policy = SECURITY_WPA;
977 } else if (bss->wpa) {
978 bss->ssid.security_policy = SECURITY_WPA_PSK;
979 } else if (bss->ieee802_1x) {
980 int cipher = WPA_CIPHER_NONE;
981 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
982 bss->ssid.wep.default_len = bss->default_wep_key_len;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800983 if (full_config && bss->default_wep_key_len) {
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800984 cipher = bss->default_wep_key_len >= 13 ?
985 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800986 } else if (full_config && bss->ssid.wep.keys_set) {
987 if (bss->ssid.wep.len[0] >= 13)
988 cipher = WPA_CIPHER_WEP104;
989 else
990 cipher = WPA_CIPHER_WEP40;
991 }
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800992 bss->wpa_group = cipher;
993 bss->wpa_pairwise = cipher;
994 bss->rsn_pairwise = cipher;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -0800995 if (full_config)
996 bss->wpa_key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA;
Dmitry Shmidtcce06662013-11-04 18:44:24 -0800997 } else if (bss->ssid.wep.keys_set) {
998 int cipher = WPA_CIPHER_WEP40;
999 if (bss->ssid.wep.len[0] >= 13)
1000 cipher = WPA_CIPHER_WEP104;
1001 bss->ssid.security_policy = SECURITY_STATIC_WEP;
1002 bss->wpa_group = cipher;
1003 bss->wpa_pairwise = cipher;
1004 bss->rsn_pairwise = cipher;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001005 if (full_config)
1006 bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;
Dmitry Shmidtf21452a2014-02-26 10:55:25 -08001007 } else if (bss->osen) {
1008 bss->ssid.security_policy = SECURITY_OSEN;
1009 bss->wpa_group = WPA_CIPHER_CCMP;
1010 bss->wpa_pairwise = 0;
1011 bss->rsn_pairwise = WPA_CIPHER_CCMP;
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001012 } else {
1013 bss->ssid.security_policy = SECURITY_PLAINTEXT;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001014 if (full_config) {
1015 bss->wpa_group = WPA_CIPHER_NONE;
1016 bss->wpa_pairwise = WPA_CIPHER_NONE;
1017 bss->rsn_pairwise = WPA_CIPHER_NONE;
Dmitry Shmidt6c0da2b2015-01-05 13:08:17 -08001018 bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE;
Dmitry Shmidtd80a4012015-11-05 16:35:40 -08001019 }
Dmitry Shmidtcce06662013-11-04 18:44:24 -08001020 }
1021}