]>
Commit | Line | Data |
---|---|---|
6fc6879b | 1 | /* |
41d719d6 | 2 | * hostapd / Configuration helper functions |
08081ad8 | 3 | * Copyright (c) 2003-2014, Jouni Malinen <j@w1.fi> |
6fc6879b | 4 | * |
0f3d578e JM |
5 | * This software may be distributed under the terms of the BSD license. |
6 | * See README for more details. | |
6fc6879b JM |
7 | */ |
8 | ||
6226e38d | 9 | #include "utils/includes.h" |
6fc6879b | 10 | |
6226e38d | 11 | #include "utils/common.h" |
03da66bd | 12 | #include "crypto/sha1.h" |
6fc6879b | 13 | #include "radius/radius_client.h" |
df84268a | 14 | #include "common/ieee802_11_defs.h" |
41d719d6 | 15 | #include "common/eapol_common.h" |
03da66bd JM |
16 | #include "eap_common/eap_wsc_common.h" |
17 | #include "eap_server/eap.h" | |
6226e38d | 18 | #include "wpa_auth.h" |
97234b50 | 19 | #include "sta_info.h" |
6226e38d | 20 | #include "ap_config.h" |
6fc6879b JM |
21 | |
22 | ||
6fc6879b JM |
23 | static 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 | ||
41d719d6 | 39 | void hostapd_config_defaults_bss(struct hostapd_bss_config *bss) |
6fc6879b | 40 | { |
695dbbea JM |
41 | dl_list_init(&bss->anqp_elem); |
42 | ||
6fc6879b JM |
43 | bss->logger_syslog_level = HOSTAPD_LEVEL_INFO; |
44 | bss->logger_stdout_level = HOSTAPD_LEVEL_INFO; | |
45 | bss->logger_syslog = (unsigned int) -1; | |
46 | bss->logger_stdout = (unsigned int) -1; | |
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; | |
7b0f5500 | 68 | bss->eap_sim_db_timeout = 1; |
6fc6879b JM |
69 | bss->ap_max_inactivity = AP_MAX_INACTIVITY; |
70 | bss->eapol_version = EAPOL_VERSION; | |
b0194fe0 JM |
71 | |
72 | bss->max_listen_interval = 65535; | |
5d22a1d5 | 73 | |
df684d82 DH |
74 | bss->pwd_group = 19; /* ECC: GF(p=256) */ |
75 | ||
5d22a1d5 | 76 | #ifdef CONFIG_IEEE80211W |
45c94154 JM |
77 | bss->assoc_sa_query_max_timeout = 1000; |
78 | bss->assoc_sa_query_retry_timeout = 201; | |
8dd9f9cd | 79 | bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC; |
5d22a1d5 | 80 | #endif /* CONFIG_IEEE80211W */ |
1e5839e0 | 81 | #ifdef EAP_SERVER_FAST |
378eae5e JM |
82 | /* both anonymous and authenticated provisioning */ |
83 | bss->eap_fast_prov = 3; | |
a11c90a6 JM |
84 | bss->pac_key_lifetime = 7 * 24 * 60 * 60; |
85 | bss->pac_key_refresh_time = 1 * 24 * 60 * 60; | |
1e5839e0 | 86 | #endif /* EAP_SERVER_FAST */ |
d2da2249 JB |
87 | |
88 | /* Set to -1 as defaults depends on HT in setup */ | |
89 | bss->wmm_enabled = -1; | |
d7956add SP |
90 | |
91 | #ifdef CONFIG_IEEE80211R | |
92 | bss->ft_over_ds = 1; | |
93 | #endif /* CONFIG_IEEE80211R */ | |
bde7ba6c JM |
94 | |
95 | bss->radius_das_time_window = 300; | |
d136c376 JM |
96 | |
97 | bss->sae_anti_clogging_threshold = 5; | |
6fc6879b JM |
98 | } |
99 | ||
100 | ||
89111f3b | 101 | struct hostapd_config * hostapd_config_defaults(void) |
6fc6879b | 102 | { |
d2da2249 JB |
103 | #define ecw2cw(ecw) ((1 << (ecw)) - 1) |
104 | ||
6fc6879b JM |
105 | struct hostapd_config *conf; |
106 | struct hostapd_bss_config *bss; | |
594cf8b9 | 107 | const int aCWmin = 4, aCWmax = 10; |
3ae0800c | 108 | const struct hostapd_wmm_ac_params ac_bk = |
6fc6879b | 109 | { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */ |
3ae0800c | 110 | const struct hostapd_wmm_ac_params ac_be = |
6fc6879b | 111 | { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */ |
3ae0800c | 112 | const struct hostapd_wmm_ac_params ac_vi = /* video traffic */ |
f4e3860f | 113 | { aCWmin - 1, aCWmin, 2, 3008 / 32, 0 }; |
3ae0800c | 114 | const struct hostapd_wmm_ac_params ac_vo = /* voice traffic */ |
f4e3860f | 115 | { aCWmin - 2, aCWmin - 1, 2, 1504 / 32, 0 }; |
d2da2249 JB |
116 | const struct hostapd_tx_queue_params txq_bk = |
117 | { 7, ecw2cw(aCWmin), ecw2cw(aCWmax), 0 }; | |
118 | const struct hostapd_tx_queue_params txq_be = | |
119 | { 3, ecw2cw(aCWmin), 4 * (ecw2cw(aCWmin) + 1) - 1, 0}; | |
120 | const struct hostapd_tx_queue_params txq_vi = | |
121 | { 1, (ecw2cw(aCWmin) + 1) / 2 - 1, ecw2cw(aCWmin), 30}; | |
122 | const struct hostapd_tx_queue_params txq_vo = | |
123 | { 1, (ecw2cw(aCWmin) + 1) / 4 - 1, | |
124 | (ecw2cw(aCWmin) + 1) / 2 - 1, 15}; | |
125 | ||
126 | #undef ecw2cw | |
6fc6879b JM |
127 | |
128 | conf = os_zalloc(sizeof(*conf)); | |
129 | bss = os_zalloc(sizeof(*bss)); | |
130 | if (conf == NULL || bss == NULL) { | |
10656fc2 JM |
131 | wpa_printf(MSG_ERROR, "Failed to allocate memory for " |
132 | "configuration data."); | |
6fc6879b JM |
133 | os_free(conf); |
134 | os_free(bss); | |
135 | return NULL; | |
136 | } | |
ebd79f07 JM |
137 | 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; | |
6fc6879b | 144 | |
6fc6879b JM |
145 | bss->radius = os_zalloc(sizeof(*bss->radius)); |
146 | if (bss->radius == NULL) { | |
04c366cb | 147 | os_free(conf->bss); |
6fc6879b JM |
148 | os_free(conf); |
149 | os_free(bss); | |
150 | return NULL; | |
151 | } | |
152 | ||
153 | hostapd_config_defaults_bss(bss); | |
154 | ||
155 | conf->num_bss = 1; | |
6fc6879b JM |
156 | |
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; | |
e0392f82 S |
161 | /* Set to invalid value means do not add Power Constraint IE */ |
162 | conf->local_pwr_constraint = -1; | |
6fc6879b | 163 | |
3ae0800c JM |
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; | |
6fc6879b | 168 | |
d2da2249 JB |
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 | ||
fc14f567 | 174 | conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED; |
de9289c8 | 175 | |
f1b44874 SE |
176 | conf->ap_table_max_size = 255; |
177 | conf->ap_table_expiration_time = 60; | |
a65a9b8d | 178 | conf->track_sta_max_age = 180; |
f1b44874 | 179 | |
c2aff6b1 | 180 | #ifdef CONFIG_TESTING_OPTIONS |
06df2aa6 JM |
181 | conf->ignore_probe_probability = 0.0; |
182 | conf->ignore_auth_probability = 0.0; | |
183 | conf->ignore_assoc_probability = 0.0; | |
184 | conf->ignore_reassoc_probability = 0.0; | |
185 | conf->corrupt_gtk_rekey_mic_probability = 0.0; | |
2b6e1216 | 186 | conf->ecsa_ie_only = 0; |
c2aff6b1 JB |
187 | #endif /* CONFIG_TESTING_OPTIONS */ |
188 | ||
857d9422 MM |
189 | conf->acs = 0; |
190 | conf->acs_ch_list.num = 0; | |
50f4f2a0 MK |
191 | #ifdef CONFIG_ACS |
192 | conf->acs_num_scans = 5; | |
193 | #endif /* CONFIG_ACS */ | |
194 | ||
6fc6879b JM |
195 | return conf; |
196 | } | |
197 | ||
198 | ||
199 | int hostapd_mac_comp(const void *a, const void *b) | |
200 | { | |
201 | return os_memcmp(a, b, sizeof(macaddr)); | |
202 | } | |
203 | ||
204 | ||
6fc6879b JM |
205 | static 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) { | |
10656fc2 | 219 | wpa_printf(MSG_ERROR, "WPA PSK file '%s' not found.", fname); |
6fc6879b JM |
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)) { | |
10656fc2 JM |
240 | wpa_printf(MSG_ERROR, "Invalid MAC address '%s' on " |
241 | "line %d in '%s'", buf, line, fname); | |
6fc6879b JM |
242 | ret = -1; |
243 | break; | |
244 | } | |
245 | ||
246 | psk = os_zalloc(sizeof(*psk)); | |
247 | if (psk == NULL) { | |
10656fc2 | 248 | wpa_printf(MSG_ERROR, "WPA PSK allocation failed"); |
6fc6879b JM |
249 | ret = -1; |
250 | break; | |
251 | } | |
a8e16edc | 252 | if (is_zero_ether_addr(addr)) |
6fc6879b JM |
253 | psk->group = 1; |
254 | else | |
255 | os_memcpy(psk->addr, addr, ETH_ALEN); | |
256 | ||
257 | pos = buf + 17; | |
5306f43f | 258 | if (*pos == '\0') { |
10656fc2 JM |
259 | wpa_printf(MSG_ERROR, "No PSK on line %d in '%s'", |
260 | line, fname); | |
6fc6879b JM |
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) { | |
10656fc2 JM |
277 | wpa_printf(MSG_ERROR, "Invalid PSK '%s' on line %d in " |
278 | "'%s'", pos, line, fname); | |
6fc6879b JM |
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 | ||
0ae687bd JM |
294 | static 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 | ||
6fc6879b JM |
315 | int 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) { | |
0ae687bd JM |
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; | |
6fc6879b | 328 | } |
6fc6879b | 329 | ssid->wpa_psk->group = 1; |
6fc6879b JM |
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 | ||
6fc6879b JM |
342 | static 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 | ||
af35e7af JM |
354 | struct hostapd_radius_attr * |
355 | hostapd_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 | ||
365 | static 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 | ||
d0ee16ed | 378 | void hostapd_config_free_eap_user(struct hostapd_eap_user *user) |
6fc6879b | 379 | { |
d0ee16ed | 380 | hostapd_config_free_radius_attr(user->accept_attr); |
6fc6879b | 381 | os_free(user->identity); |
b7175b4d | 382 | bin_clear_free(user->password, user->password_len); |
6fc6879b JM |
383 | os_free(user); |
384 | } | |
385 | ||
386 | ||
387 | static void hostapd_config_free_wep(struct hostapd_wep_keys *keys) | |
388 | { | |
389 | int i; | |
390 | for (i = 0; i < NUM_WEP_KEYS; i++) { | |
b7175b4d | 391 | bin_clear_free(keys->key[i], keys->len[i]); |
6fc6879b JM |
392 | keys->key[i] = NULL; |
393 | } | |
394 | } | |
395 | ||
396 | ||
891dfb33 ST |
397 | void 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 | ||
695dbbea JM |
410 | static 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 | ||
55920658 | 423 | void hostapd_config_free_bss(struct hostapd_bss_config *conf) |
6fc6879b | 424 | { |
6fc6879b JM |
425 | struct hostapd_eap_user *user, *prev_user; |
426 | ||
427 | if (conf == NULL) | |
428 | return; | |
429 | ||
891dfb33 | 430 | hostapd_config_clear_wpa_psk(&conf->ssid.wpa_psk); |
6fc6879b | 431 | |
b7175b4d | 432 | str_clear_free(conf->ssid.wpa_passphrase); |
6fc6879b | 433 | os_free(conf->ssid.wpa_psk_file); |
43dd46b3 | 434 | hostapd_config_free_wep(&conf->ssid.wep); |
6fc6879b JM |
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 | } | |
ee431d77 | 445 | os_free(conf->eap_user_sqlite); |
6fc6879b | 446 | |
6fc6879b | 447 | os_free(conf->eap_req_id_text); |
2a5156a6 | 448 | os_free(conf->erp_domain); |
6fc6879b JM |
449 | os_free(conf->accept_mac); |
450 | os_free(conf->deny_mac); | |
451 | os_free(conf->nas_identifier); | |
5afaa067 JM |
452 | 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 | } | |
af35e7af JM |
458 | hostapd_config_free_radius_attr(conf->radius_auth_req_attr); |
459 | hostapd_config_free_radius_attr(conf->radius_acct_req_attr); | |
6fc6879b JM |
460 | os_free(conf->rsn_preauth_interfaces); |
461 | os_free(conf->ctrl_interface); | |
462 | os_free(conf->ca_cert); | |
463 | os_free(conf->server_cert); | |
464 | os_free(conf->private_key); | |
465 | os_free(conf->private_key_passwd); | |
080585c0 | 466 | os_free(conf->ocsp_stapling_response); |
5addb0df | 467 | os_free(conf->ocsp_stapling_response_multi); |
6fc6879b | 468 | os_free(conf->dh_file); |
f8995f8f | 469 | os_free(conf->openssl_ciphers); |
6fc6879b JM |
470 | os_free(conf->pac_opaque_encr_key); |
471 | os_free(conf->eap_fast_a_id); | |
2d867244 | 472 | os_free(conf->eap_fast_a_id_info); |
6fc6879b JM |
473 | os_free(conf->eap_sim_db); |
474 | os_free(conf->radius_server_clients); | |
6fc6879b | 475 | os_free(conf->radius); |
b031338c | 476 | os_free(conf->radius_das_shared_secret); |
6fc6879b | 477 | hostapd_config_free_vlan(conf); |
39b97072 JM |
478 | os_free(conf->time_zone); |
479 | ||
6fc6879b JM |
480 | #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 */ | |
ad08c363 JM |
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); | |
ad08c363 JM |
510 | os_free(conf->config_methods); |
511 | os_free(conf->ap_pin); | |
62966253 | 512 | os_free(conf->extra_cred); |
4c29cae9 | 513 | os_free(conf->ap_settings); |
f620268f JM |
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); | |
8509fb5c JM |
520 | { |
521 | unsigned int i; | |
522 | ||
523 | for (i = 0; i < MAX_WPS_VENDOR_EXTENSIONS; i++) | |
524 | wpabuf_free(conf->wps_vendor_ext[i]); | |
525 | } | |
ffdaa05a JM |
526 | wpabuf_free(conf->wps_nfc_dh_pubkey); |
527 | wpabuf_free(conf->wps_nfc_dh_privkey); | |
528 | wpabuf_free(conf->wps_nfc_dev_pw); | |
ad08c363 | 529 | #endif /* CONFIG_WPS */ |
4b2a77ab JM |
530 | |
531 | os_free(conf->roaming_consortium); | |
648cc711 | 532 | os_free(conf->venue_name); |
8047b186 | 533 | os_free(conf->nai_realm_data); |
550a3958 | 534 | os_free(conf->network_auth_type); |
7515adb2 | 535 | os_free(conf->anqp_3gpp_cell_net); |
26fac8b6 | 536 | os_free(conf->domain_name); |
695dbbea | 537 | hostapd_config_free_anqp_elem(conf); |
505a3694 JM |
538 | |
539 | #ifdef CONFIG_RADIUS_TEST | |
540 | os_free(conf->dump_msk_file); | |
541 | #endif /* CONFIG_RADIUS_TEST */ | |
df5934f1 JK |
542 | |
543 | #ifdef CONFIG_HS20 | |
a9277e85 | 544 | os_free(conf->hs20_oper_friendly_name); |
4065a309 | 545 | os_free(conf->hs20_wan_metrics); |
5ccc54aa | 546 | os_free(conf->hs20_connection_capability); |
df5934f1 | 547 | os_free(conf->hs20_operating_class); |
f7bd7a01 | 548 | os_free(conf->hs20_icons); |
ae6d15c7 JM |
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 | } | |
8d2a9921 | 566 | os_free(conf->subscr_remediation_url); |
df5934f1 | 567 | #endif /* CONFIG_HS20 */ |
b52f084c JM |
568 | |
569 | wpabuf_free(conf->vendor_elements); | |
a9112270 | 570 | wpabuf_free(conf->assocresp_elements); |
625f202a JM |
571 | |
572 | os_free(conf->sae_groups); | |
67fe933d | 573 | |
88cb27c7 DS |
574 | os_free(conf->wowlan_triggers); |
575 | ||
67fe933d | 576 | os_free(conf->server_id); |
ebd79f07 | 577 | |
bc02843e JM |
578 | #ifdef CONFIG_TESTING_OPTIONS |
579 | wpabuf_free(conf->own_ie_override); | |
580 | #endif /* CONFIG_TESTING_OPTIONS */ | |
581 | ||
964f64e2 | 582 | os_free(conf->no_probe_resp_if_seen_on); |
0e2412d0 | 583 | os_free(conf->no_auth_if_seen_on); |
964f64e2 | 584 | |
ebd79f07 | 585 | os_free(conf); |
6fc6879b JM |
586 | } |
587 | ||
588 | ||
1c6e69cc JM |
589 | /** |
590 | * hostapd_config_free - Free hostapd configuration | |
591 | * @conf: Configuration data from hostapd_config_read(). | |
592 | */ | |
6fc6879b JM |
593 | void hostapd_config_free(struct hostapd_config *conf) |
594 | { | |
595 | size_t i; | |
596 | ||
597 | if (conf == NULL) | |
598 | return; | |
599 | ||
600 | for (i = 0; i < conf->num_bss; i++) | |
ebd79f07 | 601 | hostapd_config_free_bss(conf->bss[i]); |
6fc6879b | 602 | os_free(conf->bss); |
79d6c85f JM |
603 | os_free(conf->supported_rates); |
604 | os_free(conf->basic_rates); | |
857d9422 | 605 | os_free(conf->acs_ch_list.range); |
0ecff8d7 | 606 | os_free(conf->driver_params); |
68fa00c3 JM |
607 | #ifdef CONFIG_ACS |
608 | os_free(conf->acs_chan_bias); | |
609 | #endif /* CONFIG_ACS */ | |
74e982d8 DS |
610 | wpabuf_free(conf->lci); |
611 | wpabuf_free(conf->civic); | |
6fc6879b JM |
612 | |
613 | os_free(conf); | |
614 | } | |
615 | ||
616 | ||
1c6e69cc JM |
617 | /** |
618 | * hostapd_maclist_found - Find a MAC address from a list | |
619 | * @list: MAC address list | |
620 | * @num_entries: Number of addresses in the list | |
621 | * @addr: Address to search for | |
622 | * @vlan_id: Buffer for returning VLAN ID or %NULL if not needed | |
623 | * Returns: 1 if address is in the list or 0 if not. | |
624 | * | |
625 | * Perform a binary search for given MAC address from a pre-sorted list. | |
626 | */ | |
271d2830 | 627 | int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries, |
1889af2e | 628 | const u8 *addr, struct vlan_description *vlan_id) |
6fc6879b JM |
629 | { |
630 | int start, end, middle, res; | |
631 | ||
632 | start = 0; | |
633 | end = num_entries - 1; | |
634 | ||
635 | while (start <= end) { | |
636 | middle = (start + end) / 2; | |
271d2830 JM |
637 | res = os_memcmp(list[middle].addr, addr, ETH_ALEN); |
638 | if (res == 0) { | |
639 | if (vlan_id) | |
640 | *vlan_id = list[middle].vlan_id; | |
6fc6879b | 641 | return 1; |
271d2830 | 642 | } |
6fc6879b JM |
643 | if (res < 0) |
644 | start = middle + 1; | |
645 | else | |
646 | end = middle - 1; | |
647 | } | |
648 | ||
649 | return 0; | |
650 | } | |
651 | ||
652 | ||
653 | int hostapd_rate_found(int *list, int rate) | |
654 | { | |
655 | int i; | |
656 | ||
657 | if (list == NULL) | |
658 | return 0; | |
659 | ||
660 | for (i = 0; list[i] >= 0; i++) | |
661 | if (list[i] == rate) | |
662 | return 1; | |
663 | ||
664 | return 0; | |
665 | } | |
666 | ||
667 | ||
1889af2e MB |
668 | int hostapd_vlan_valid(struct hostapd_vlan *vlan, |
669 | struct vlan_description *vlan_desc) | |
6fc6879b JM |
670 | { |
671 | struct hostapd_vlan *v = vlan; | |
8e44c192 | 672 | int i; |
1889af2e | 673 | |
8e44c192 | 674 | if (!vlan_desc->notempty || vlan_desc->untagged < 0 || |
1889af2e MB |
675 | vlan_desc->untagged > MAX_VLAN_ID) |
676 | return 0; | |
8e44c192 MB |
677 | for (i = 0; i < MAX_NUM_TAGGED_VLAN; i++) { |
678 | if (vlan_desc->tagged[i] < 0 || | |
679 | vlan_desc->tagged[i] > MAX_VLAN_ID) | |
680 | return 0; | |
681 | } | |
682 | if (!vlan_desc->untagged && !vlan_desc->tagged[0]) | |
683 | return 0; | |
1889af2e | 684 | |
6fc6879b | 685 | while (v) { |
1889af2e MB |
686 | if (!vlan_compare(&v->vlan_desc, vlan_desc) || |
687 | v->vlan_id == VLAN_ID_WILDCARD) | |
80ebfd95 MB |
688 | return 1; |
689 | v = v->next; | |
690 | } | |
691 | return 0; | |
692 | } | |
693 | ||
694 | ||
695 | const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id) | |
696 | { | |
697 | struct hostapd_vlan *v = vlan; | |
698 | while (v) { | |
699 | if (v->vlan_id == vlan_id) | |
6fc6879b JM |
700 | return v->ifname; |
701 | v = v->next; | |
702 | } | |
703 | return NULL; | |
704 | } | |
705 | ||
706 | ||
707 | const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf, | |
759fd76b JM |
708 | const u8 *addr, const u8 *p2p_dev_addr, |
709 | const u8 *prev_psk) | |
6fc6879b JM |
710 | { |
711 | struct hostapd_wpa_psk *psk; | |
712 | int next_ok = prev_psk == NULL; | |
713 | ||
dc87541e | 714 | if (p2p_dev_addr && !is_zero_ether_addr(p2p_dev_addr)) { |
759fd76b JM |
715 | wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR |
716 | " p2p_dev_addr=" MACSTR " prev_psk=%p", | |
717 | MAC2STR(addr), MAC2STR(p2p_dev_addr), prev_psk); | |
dc87541e | 718 | addr = NULL; /* Use P2P Device Address for matching */ |
759fd76b JM |
719 | } else { |
720 | wpa_printf(MSG_DEBUG, "Searching a PSK for " MACSTR | |
721 | " prev_psk=%p", | |
722 | MAC2STR(addr), prev_psk); | |
723 | } | |
724 | ||
6fc6879b JM |
725 | for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) { |
726 | if (next_ok && | |
759fd76b JM |
727 | (psk->group || |
728 | (addr && os_memcmp(psk->addr, addr, ETH_ALEN) == 0) || | |
729 | (!addr && p2p_dev_addr && | |
730 | os_memcmp(psk->p2p_dev_addr, p2p_dev_addr, ETH_ALEN) == | |
731 | 0))) | |
6fc6879b JM |
732 | return psk->psk; |
733 | ||
734 | if (psk->psk == prev_psk) | |
735 | next_ok = 1; | |
736 | } | |
737 | ||
738 | return NULL; | |
739 | } | |
eff0fd1e JM |
740 | |
741 | ||
742 | static int hostapd_config_check_bss(struct hostapd_bss_config *bss, | |
08081ad8 JM |
743 | struct hostapd_config *conf, |
744 | int full_config) | |
eff0fd1e | 745 | { |
08081ad8 | 746 | if (full_config && bss->ieee802_1x && !bss->eap_server && |
eff0fd1e JM |
747 | !bss->radius->auth_servers) { |
748 | wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no " | |
749 | "EAP authenticator configured)."); | |
750 | return -1; | |
751 | } | |
752 | ||
753 | if (bss->wpa) { | |
754 | int wep, i; | |
755 | ||
756 | wep = bss->default_wep_key_len > 0 || | |
757 | bss->individual_wep_key_len > 0; | |
758 | for (i = 0; i < NUM_WEP_KEYS; i++) { | |
759 | if (bss->ssid.wep.keys_set) { | |
760 | wep = 1; | |
761 | break; | |
762 | } | |
763 | } | |
764 | ||
765 | if (wep) { | |
766 | wpa_printf(MSG_ERROR, "WEP configuration in a WPA network is not supported"); | |
767 | return -1; | |
768 | } | |
769 | } | |
770 | ||
08081ad8 JM |
771 | if (full_config && bss->wpa && |
772 | bss->wpa_psk_radius != PSK_RADIUS_IGNORED && | |
eff0fd1e JM |
773 | bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) { |
774 | wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no " | |
775 | "RADIUS checking (macaddr_acl=2) enabled."); | |
776 | return -1; | |
777 | } | |
778 | ||
08081ad8 | 779 | if (full_config && bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) && |
eff0fd1e JM |
780 | bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL && |
781 | bss->ssid.wpa_psk_file == NULL && | |
782 | (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED || | |
783 | bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) { | |
784 | wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase " | |
785 | "is not configured."); | |
786 | return -1; | |
787 | } | |
788 | ||
902c07a7 | 789 | if (full_config && !is_zero_ether_addr(bss->bssid)) { |
eff0fd1e JM |
790 | size_t i; |
791 | ||
792 | for (i = 0; i < conf->num_bss; i++) { | |
793 | if (conf->bss[i] != bss && | |
794 | (hostapd_mac_comp(conf->bss[i]->bssid, | |
795 | bss->bssid) == 0)) { | |
796 | wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR | |
797 | " on interface '%s' and '%s'.", | |
798 | MAC2STR(bss->bssid), | |
799 | conf->bss[i]->iface, bss->iface); | |
800 | return -1; | |
801 | } | |
802 | } | |
803 | } | |
804 | ||
805 | #ifdef CONFIG_IEEE80211R | |
08081ad8 | 806 | if (full_config && wpa_key_mgmt_ft(bss->wpa_key_mgmt) && |
eff0fd1e JM |
807 | (bss->nas_identifier == NULL || |
808 | os_strlen(bss->nas_identifier) < 1 || | |
809 | os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) { | |
810 | wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires " | |
811 | "nas_identifier to be configured as a 1..48 octet " | |
812 | "string"); | |
813 | return -1; | |
814 | } | |
815 | #endif /* CONFIG_IEEE80211R */ | |
816 | ||
817 | #ifdef CONFIG_IEEE80211N | |
08081ad8 JM |
818 | if (full_config && conf->ieee80211n && |
819 | conf->hw_mode == HOSTAPD_MODE_IEEE80211B) { | |
eff0fd1e JM |
820 | bss->disable_11n = 1; |
821 | wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not " | |
8c6f4a5a | 822 | "allowed, disabling HT capabilities"); |
eff0fd1e JM |
823 | } |
824 | ||
08081ad8 | 825 | if (full_config && conf->ieee80211n && |
eff0fd1e JM |
826 | bss->ssid.security_policy == SECURITY_STATIC_WEP) { |
827 | bss->disable_11n = 1; | |
828 | wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not " | |
829 | "allowed, disabling HT capabilities"); | |
830 | } | |
831 | ||
08081ad8 | 832 | if (full_config && conf->ieee80211n && bss->wpa && |
eff0fd1e | 833 | !(bss->wpa_pairwise & WPA_CIPHER_CCMP) && |
30675c34 JM |
834 | !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | |
835 | WPA_CIPHER_CCMP_256 | WPA_CIPHER_GCMP_256))) | |
836 | { | |
eff0fd1e JM |
837 | bss->disable_11n = 1; |
838 | wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 " | |
839 | "requires CCMP/GCMP to be enabled, disabling HT " | |
840 | "capabilities"); | |
841 | } | |
842 | #endif /* CONFIG_IEEE80211N */ | |
843 | ||
c201f93a | 844 | #ifdef CONFIG_WPS |
08081ad8 | 845 | if (full_config && bss->wps_state && bss->ignore_broadcast_ssid) { |
eff0fd1e JM |
846 | wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid " |
847 | "configuration forced WPS to be disabled"); | |
848 | bss->wps_state = 0; | |
849 | } | |
850 | ||
08081ad8 JM |
851 | if (full_config && bss->wps_state && |
852 | bss->ssid.wep.keys_set && bss->wpa == 0) { | |
eff0fd1e JM |
853 | wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be " |
854 | "disabled"); | |
855 | bss->wps_state = 0; | |
856 | } | |
857 | ||
08081ad8 | 858 | if (full_config && bss->wps_state && bss->wpa && |
eff0fd1e | 859 | (!(bss->wpa & 2) || |
01a02593 | 860 | !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)))) { |
eff0fd1e | 861 | wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without " |
01a02593 | 862 | "WPA2/CCMP/GCMP forced WPS to be disabled"); |
eff0fd1e JM |
863 | bss->wps_state = 0; |
864 | } | |
c201f93a | 865 | #endif /* CONFIG_WPS */ |
eff0fd1e JM |
866 | |
867 | #ifdef CONFIG_HS20 | |
08081ad8 | 868 | if (full_config && bss->hs20 && |
eff0fd1e | 869 | (!(bss->wpa & 2) || |
30675c34 JM |
870 | !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP | |
871 | WPA_CIPHER_CCMP_256 | | |
872 | WPA_CIPHER_GCMP_256)))) { | |
eff0fd1e JM |
873 | wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP " |
874 | "configuration is required for Hotspot 2.0 " | |
875 | "functionality"); | |
876 | return -1; | |
877 | } | |
878 | #endif /* CONFIG_HS20 */ | |
879 | ||
4c572281 JM |
880 | #ifdef CONFIG_MBO |
881 | if (full_config && bss->mbo_enabled && (bss->wpa & 2) && | |
882 | bss->ieee80211w == NO_MGMT_FRAME_PROTECTION) { | |
883 | wpa_printf(MSG_ERROR, | |
884 | "MBO: PMF needs to be enabled whenever using WPA2 with MBO"); | |
885 | return -1; | |
886 | } | |
887 | #endif /* CONFIG_MBO */ | |
888 | ||
eff0fd1e JM |
889 | return 0; |
890 | } | |
891 | ||
892 | ||
8884ce03 MM |
893 | static int hostapd_config_check_cw(struct hostapd_config *conf, int queue) |
894 | { | |
895 | int tx_cwmin = conf->tx_queue[queue].cwmin; | |
896 | int tx_cwmax = conf->tx_queue[queue].cwmax; | |
897 | int ac_cwmin = conf->wmm_ac_params[queue].cwmin; | |
898 | int ac_cwmax = conf->wmm_ac_params[queue].cwmax; | |
899 | ||
900 | if (tx_cwmin > tx_cwmax) { | |
901 | wpa_printf(MSG_ERROR, | |
902 | "Invalid TX queue cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)", | |
903 | tx_cwmin, tx_cwmax); | |
904 | return -1; | |
905 | } | |
906 | if (ac_cwmin > ac_cwmax) { | |
907 | wpa_printf(MSG_ERROR, | |
908 | "Invalid WMM AC cwMin/cwMax values. cwMin(%d) greater than cwMax(%d)", | |
909 | ac_cwmin, ac_cwmax); | |
910 | return -1; | |
911 | } | |
912 | return 0; | |
913 | } | |
914 | ||
915 | ||
08081ad8 | 916 | int hostapd_config_check(struct hostapd_config *conf, int full_config) |
eff0fd1e JM |
917 | { |
918 | size_t i; | |
919 | ||
08081ad8 JM |
920 | if (full_config && conf->ieee80211d && |
921 | (!conf->country[0] || !conf->country[1])) { | |
eff0fd1e JM |
922 | wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without " |
923 | "setting the country_code"); | |
924 | return -1; | |
925 | } | |
926 | ||
08081ad8 | 927 | if (full_config && conf->ieee80211h && !conf->ieee80211d) { |
eff0fd1e JM |
928 | wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11h without " |
929 | "IEEE 802.11d enabled"); | |
930 | return -1; | |
931 | } | |
932 | ||
e0392f82 S |
933 | if (full_config && conf->local_pwr_constraint != -1 && |
934 | !conf->ieee80211d) { | |
935 | wpa_printf(MSG_ERROR, "Cannot add Power Constraint element without Country element"); | |
936 | return -1; | |
937 | } | |
938 | ||
3d7ad2f6 C |
939 | if (full_config && conf->spectrum_mgmt_required && |
940 | conf->local_pwr_constraint == -1) { | |
941 | wpa_printf(MSG_ERROR, "Cannot set Spectrum Management bit without Country and Power Constraint elements"); | |
942 | return -1; | |
943 | } | |
944 | ||
8884ce03 MM |
945 | for (i = 0; i < NUM_TX_QUEUES; i++) { |
946 | if (hostapd_config_check_cw(conf, i)) | |
947 | return -1; | |
948 | } | |
949 | ||
eff0fd1e | 950 | for (i = 0; i < conf->num_bss; i++) { |
08081ad8 | 951 | if (hostapd_config_check_bss(conf->bss[i], conf, full_config)) |
eff0fd1e JM |
952 | return -1; |
953 | } | |
954 | ||
955 | return 0; | |
956 | } | |
957 | ||
958 | ||
5d67bf15 JM |
959 | void hostapd_set_security_params(struct hostapd_bss_config *bss, |
960 | int full_config) | |
eff0fd1e JM |
961 | { |
962 | if (bss->individual_wep_key_len == 0) { | |
963 | /* individual keys are not use; can use key idx0 for | |
964 | * broadcast keys */ | |
965 | bss->broadcast_key_idx_min = 0; | |
966 | } | |
967 | ||
968 | if ((bss->wpa & 2) && bss->rsn_pairwise == 0) | |
969 | bss->rsn_pairwise = bss->wpa_pairwise; | |
970 | bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise, | |
971 | bss->rsn_pairwise); | |
972 | ||
5d67bf15 JM |
973 | if (full_config) { |
974 | bss->radius->auth_server = bss->radius->auth_servers; | |
975 | bss->radius->acct_server = bss->radius->acct_servers; | |
976 | } | |
eff0fd1e JM |
977 | |
978 | if (bss->wpa && bss->ieee802_1x) { | |
979 | bss->ssid.security_policy = SECURITY_WPA; | |
980 | } else if (bss->wpa) { | |
981 | bss->ssid.security_policy = SECURITY_WPA_PSK; | |
982 | } else if (bss->ieee802_1x) { | |
983 | int cipher = WPA_CIPHER_NONE; | |
984 | bss->ssid.security_policy = SECURITY_IEEE_802_1X; | |
985 | bss->ssid.wep.default_len = bss->default_wep_key_len; | |
13a3a20d | 986 | if (full_config && bss->default_wep_key_len) { |
eff0fd1e JM |
987 | cipher = bss->default_wep_key_len >= 13 ? |
988 | WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40; | |
13a3a20d JM |
989 | } else if (full_config && bss->ssid.wep.keys_set) { |
990 | if (bss->ssid.wep.len[0] >= 13) | |
991 | cipher = WPA_CIPHER_WEP104; | |
992 | else | |
993 | cipher = WPA_CIPHER_WEP40; | |
994 | } | |
eff0fd1e JM |
995 | bss->wpa_group = cipher; |
996 | bss->wpa_pairwise = cipher; | |
997 | bss->rsn_pairwise = cipher; | |
13a3a20d JM |
998 | if (full_config) |
999 | bss->wpa_key_mgmt = WPA_KEY_MGMT_IEEE8021X_NO_WPA; | |
eff0fd1e JM |
1000 | } else if (bss->ssid.wep.keys_set) { |
1001 | int cipher = WPA_CIPHER_WEP40; | |
1002 | if (bss->ssid.wep.len[0] >= 13) | |
1003 | cipher = WPA_CIPHER_WEP104; | |
1004 | bss->ssid.security_policy = SECURITY_STATIC_WEP; | |
1005 | bss->wpa_group = cipher; | |
1006 | bss->wpa_pairwise = cipher; | |
1007 | bss->rsn_pairwise = cipher; | |
13a3a20d JM |
1008 | if (full_config) |
1009 | bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE; | |
a14896e8 JM |
1010 | } else if (bss->osen) { |
1011 | bss->ssid.security_policy = SECURITY_OSEN; | |
1012 | bss->wpa_group = WPA_CIPHER_CCMP; | |
1013 | bss->wpa_pairwise = 0; | |
1014 | bss->rsn_pairwise = WPA_CIPHER_CCMP; | |
eff0fd1e JM |
1015 | } else { |
1016 | bss->ssid.security_policy = SECURITY_PLAINTEXT; | |
29767152 JM |
1017 | if (full_config) { |
1018 | bss->wpa_group = WPA_CIPHER_NONE; | |
1019 | bss->wpa_pairwise = WPA_CIPHER_NONE; | |
1020 | bss->rsn_pairwise = WPA_CIPHER_NONE; | |
13a3a20d | 1021 | bss->wpa_key_mgmt = WPA_KEY_MGMT_NONE; |
29767152 | 1022 | } |
eff0fd1e JM |
1023 | } |
1024 | } |