blob: 4ca35ff5de515e4645494140bfb29f3e77fc870f [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001/*
2 * hostapd / Configuration file parser
3 * Copyright (c) 2003-2018, Jouni Malinen <j@w1.fi>
4 *
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
7 */
8
9#include "utils/includes.h"
10#ifndef CONFIG_NATIVE_WINDOWS
11#include <grp.h>
12#endif /* CONFIG_NATIVE_WINDOWS */
13
14#include "utils/common.h"
15#include "utils/uuid.h"
16#include "utils/crc32.h"
17#include "common/ieee802_11_defs.h"
18#include "common/sae.h"
19#include "crypto/sha256.h"
20#include "crypto/tls.h"
21#include "drivers/driver.h"
22#include "eap_server/eap.h"
23#include "radius/radius_client.h"
24#include "ap/wpa_auth.h"
25#include "ap/ap_config.h"
26#include "config_file.h"
27
28
29#ifndef CONFIG_NO_VLAN
30static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
31 const char *fname)
32{
33 FILE *f;
34 char buf[128], *pos, *pos2, *pos3;
35 int line = 0, vlan_id;
36 struct hostapd_vlan *vlan;
37
38 f = fopen(fname, "r");
39 if (!f) {
40 wpa_printf(MSG_ERROR, "VLAN file '%s' not readable.", fname);
41 return -1;
42 }
43
44 while (fgets(buf, sizeof(buf), f)) {
45 line++;
46
47 if (buf[0] == '#')
48 continue;
49 pos = buf;
50 while (*pos != '\0') {
51 if (*pos == '\n') {
52 *pos = '\0';
53 break;
54 }
55 pos++;
56 }
57 if (buf[0] == '\0')
58 continue;
59
60 if (buf[0] == '*') {
61 vlan_id = VLAN_ID_WILDCARD;
62 pos = buf + 1;
63 } else {
64 vlan_id = strtol(buf, &pos, 10);
65 if (buf == pos || vlan_id < 1 ||
66 vlan_id > MAX_VLAN_ID) {
67 wpa_printf(MSG_ERROR, "Invalid VLAN ID at "
68 "line %d in '%s'", line, fname);
69 fclose(f);
70 return -1;
71 }
72 }
73
74 while (*pos == ' ' || *pos == '\t')
75 pos++;
76 pos2 = pos;
77 while (*pos2 != ' ' && *pos2 != '\t' && *pos2 != '\0')
78 pos2++;
79
80 if (*pos2 != '\0')
81 *(pos2++) = '\0';
82
83 if (*pos == '\0' || os_strlen(pos) > IFNAMSIZ) {
84 wpa_printf(MSG_ERROR, "Invalid VLAN ifname at line %d "
85 "in '%s'", line, fname);
86 fclose(f);
87 return -1;
88 }
89
90 while (*pos2 == ' ' || *pos2 == '\t')
91 pos2++;
92 pos3 = pos2;
93 while (*pos3 != ' ' && *pos3 != '\t' && *pos3 != '\0')
94 pos3++;
95 *pos3 = '\0';
96
97 vlan = os_zalloc(sizeof(*vlan));
98 if (vlan == NULL) {
99 wpa_printf(MSG_ERROR, "Out of memory while reading "
100 "VLAN interfaces from '%s'", fname);
101 fclose(f);
102 return -1;
103 }
104
105 vlan->vlan_id = vlan_id;
106 vlan->vlan_desc.untagged = vlan_id;
107 vlan->vlan_desc.notempty = !!vlan_id;
108 os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname));
109 os_strlcpy(vlan->bridge, pos2, sizeof(vlan->bridge));
110 vlan->next = bss->vlan;
111 bss->vlan = vlan;
112 }
113
114 fclose(f);
115
116 return 0;
117}
118#endif /* CONFIG_NO_VLAN */
119
120
121static int hostapd_config_read_maclist(const char *fname,
122 struct mac_acl_entry **acl, int *num)
123{
124 FILE *f;
125 char buf[128], *pos;
126 int line = 0;
127 u8 addr[ETH_ALEN];
128 int vlan_id;
129
130 f = fopen(fname, "r");
131 if (!f) {
132 wpa_printf(MSG_ERROR, "MAC list file '%s' not found.", fname);
133 return -1;
134 }
135
136 while (fgets(buf, sizeof(buf), f)) {
137 int rem = 0;
138
139 line++;
140
141 if (buf[0] == '#')
142 continue;
143 pos = buf;
144 while (*pos != '\0') {
145 if (*pos == '\n') {
146 *pos = '\0';
147 break;
148 }
149 pos++;
150 }
151 if (buf[0] == '\0')
152 continue;
153 pos = buf;
154 if (buf[0] == '-') {
155 rem = 1;
156 pos++;
157 }
158
159 if (hwaddr_aton(pos, addr)) {
160 wpa_printf(MSG_ERROR, "Invalid MAC address '%s' at "
161 "line %d in '%s'", pos, line, fname);
162 fclose(f);
163 return -1;
164 }
165
166 if (rem) {
167 hostapd_remove_acl_mac(acl, num, addr);
168 continue;
169 }
170 vlan_id = 0;
171 pos = buf;
172 while (*pos != '\0' && *pos != ' ' && *pos != '\t')
173 pos++;
174 while (*pos == ' ' || *pos == '\t')
175 pos++;
176 if (*pos != '\0')
177 vlan_id = atoi(pos);
178
179 if (hostapd_add_acl_maclist(acl, num, vlan_id, addr) < 0) {
180 fclose(f);
181 return -1;
182 }
183 }
184
185 fclose(f);
186
187 if (*acl)
188 qsort(*acl, *num, sizeof(**acl), hostapd_acl_comp);
189
190 return 0;
191}
192
193
194#ifdef EAP_SERVER
195
196static int hostapd_config_eap_user_salted(struct hostapd_eap_user *user,
197 const char *hash, size_t len,
198 char **pos, int line,
199 const char *fname)
200{
201 char *pos2 = *pos;
202
203 while (*pos2 != '\0' && *pos2 != ' ' && *pos2 != '\t' && *pos2 != '#')
204 pos2++;
205
206 if (pos2 - *pos < (int) (2 * (len + 1))) { /* at least 1 byte of salt */
207 wpa_printf(MSG_ERROR,
208 "Invalid salted %s hash on line %d in '%s'",
209 hash, line, fname);
210 return -1;
211 }
212
213 user->password = os_malloc(len);
214 if (!user->password) {
215 wpa_printf(MSG_ERROR,
216 "Failed to allocate memory for salted %s hash",
217 hash);
218 return -1;
219 }
220
221 if (hexstr2bin(*pos, user->password, len) < 0) {
222 wpa_printf(MSG_ERROR,
223 "Invalid salted password on line %d in '%s'",
224 line, fname);
225 return -1;
226 }
227 user->password_len = len;
228 *pos += 2 * len;
229
230 user->salt_len = (pos2 - *pos) / 2;
231 user->salt = os_malloc(user->salt_len);
232 if (!user->salt) {
233 wpa_printf(MSG_ERROR,
234 "Failed to allocate memory for salted %s hash",
235 hash);
236 return -1;
237 }
238
239 if (hexstr2bin(*pos, user->salt, user->salt_len) < 0) {
240 wpa_printf(MSG_ERROR,
241 "Invalid salt for password on line %d in '%s'",
242 line, fname);
243 return -1;
244 }
245
246 *pos = pos2;
247 return 0;
248}
249
250
251static int hostapd_config_read_eap_user(const char *fname,
252 struct hostapd_bss_config *conf)
253{
254 FILE *f;
255 char buf[512], *pos, *start, *pos2;
256 int line = 0, ret = 0, num_methods;
257 struct hostapd_eap_user *user = NULL, *tail = NULL, *new_user = NULL;
258
259 if (os_strncmp(fname, "sqlite:", 7) == 0) {
260#ifdef CONFIG_SQLITE
261 os_free(conf->eap_user_sqlite);
262 conf->eap_user_sqlite = os_strdup(fname + 7);
263 return 0;
264#else /* CONFIG_SQLITE */
265 wpa_printf(MSG_ERROR,
266 "EAP user file in SQLite DB, but CONFIG_SQLITE was not enabled in the build.");
267 return -1;
268#endif /* CONFIG_SQLITE */
269 }
270
271 f = fopen(fname, "r");
272 if (!f) {
273 wpa_printf(MSG_ERROR, "EAP user file '%s' not found.", fname);
274 return -1;
275 }
276
277 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
278 while (fgets(buf, sizeof(buf), f)) {
279 line++;
280
281 if (buf[0] == '#')
282 continue;
283 pos = buf;
284 while (*pos != '\0') {
285 if (*pos == '\n') {
286 *pos = '\0';
287 break;
288 }
289 pos++;
290 }
291 if (buf[0] == '\0')
292 continue;
293
294#ifndef CONFIG_NO_RADIUS
295 if (user && os_strncmp(buf, "radius_accept_attr=", 19) == 0) {
296 struct hostapd_radius_attr *attr, *a;
297 attr = hostapd_parse_radius_attr(buf + 19);
298 if (attr == NULL) {
299 wpa_printf(MSG_ERROR, "Invalid radius_accept_attr: %s",
300 buf + 19);
301 user = NULL; /* already in the BSS list */
302 goto failed;
303 }
304 if (user->accept_attr == NULL) {
305 user->accept_attr = attr;
306 } else {
307 a = user->accept_attr;
308 while (a->next)
309 a = a->next;
310 a->next = attr;
311 }
312 continue;
313 }
314#endif /* CONFIG_NO_RADIUS */
315
316 user = NULL;
317
318 if (buf[0] != '"' && buf[0] != '*') {
319 wpa_printf(MSG_ERROR, "Invalid EAP identity (no \" in "
320 "start) on line %d in '%s'", line, fname);
321 goto failed;
322 }
323
324 user = os_zalloc(sizeof(*user));
325 if (user == NULL) {
326 wpa_printf(MSG_ERROR, "EAP user allocation failed");
327 goto failed;
328 }
329 user->force_version = -1;
330
331 if (buf[0] == '*') {
332 pos = buf;
333 } else {
334 pos = buf + 1;
335 start = pos;
336 while (*pos != '"' && *pos != '\0')
337 pos++;
338 if (*pos == '\0') {
339 wpa_printf(MSG_ERROR, "Invalid EAP identity "
340 "(no \" in end) on line %d in '%s'",
341 line, fname);
342 goto failed;
343 }
344
345 user->identity = os_memdup(start, pos - start);
346 if (user->identity == NULL) {
347 wpa_printf(MSG_ERROR, "Failed to allocate "
348 "memory for EAP identity");
349 goto failed;
350 }
351 user->identity_len = pos - start;
352
353 if (pos[0] == '"' && pos[1] == '*') {
354 user->wildcard_prefix = 1;
355 pos++;
356 }
357 }
358 pos++;
359 while (*pos == ' ' || *pos == '\t')
360 pos++;
361
362 if (*pos == '\0') {
363 wpa_printf(MSG_ERROR, "No EAP method on line %d in "
364 "'%s'", line, fname);
365 goto failed;
366 }
367
368 start = pos;
369 while (*pos != ' ' && *pos != '\t' && *pos != '\0')
370 pos++;
371 if (*pos == '\0') {
372 pos = NULL;
373 } else {
374 *pos = '\0';
375 pos++;
376 }
377 num_methods = 0;
378 while (*start) {
379 char *pos3 = os_strchr(start, ',');
380 if (pos3) {
381 *pos3++ = '\0';
382 }
383 user->methods[num_methods].method =
384 eap_server_get_type(
385 start,
386 &user->methods[num_methods].vendor);
387 if (user->methods[num_methods].vendor ==
388 EAP_VENDOR_IETF &&
389 user->methods[num_methods].method == EAP_TYPE_NONE)
390 {
391 if (os_strcmp(start, "TTLS-PAP") == 0) {
392 user->ttls_auth |= EAP_TTLS_AUTH_PAP;
393 goto skip_eap;
394 }
395 if (os_strcmp(start, "TTLS-CHAP") == 0) {
396 user->ttls_auth |= EAP_TTLS_AUTH_CHAP;
397 goto skip_eap;
398 }
399 if (os_strcmp(start, "TTLS-MSCHAP") == 0) {
400 user->ttls_auth |=
401 EAP_TTLS_AUTH_MSCHAP;
402 goto skip_eap;
403 }
404 if (os_strcmp(start, "TTLS-MSCHAPV2") == 0) {
405 user->ttls_auth |=
406 EAP_TTLS_AUTH_MSCHAPV2;
407 goto skip_eap;
408 }
409 if (os_strcmp(start, "MACACL") == 0) {
410 user->macacl = 1;
411 goto skip_eap;
412 }
413 wpa_printf(MSG_ERROR, "Unsupported EAP type "
414 "'%s' on line %d in '%s'",
415 start, line, fname);
416 goto failed;
417 }
418
419 num_methods++;
420 if (num_methods >= EAP_MAX_METHODS)
421 break;
422 skip_eap:
423 if (pos3 == NULL)
424 break;
425 start = pos3;
426 }
427 if (num_methods == 0 && user->ttls_auth == 0 && !user->macacl) {
428 wpa_printf(MSG_ERROR, "No EAP types configured on "
429 "line %d in '%s'", line, fname);
430 goto failed;
431 }
432
433 if (pos == NULL)
434 goto done;
435
436 while (*pos == ' ' || *pos == '\t')
437 pos++;
438 if (*pos == '\0')
439 goto done;
440
441 if (os_strncmp(pos, "[ver=0]", 7) == 0) {
442 user->force_version = 0;
443 goto done;
444 }
445
446 if (os_strncmp(pos, "[ver=1]", 7) == 0) {
447 user->force_version = 1;
448 goto done;
449 }
450
451 if (os_strncmp(pos, "[2]", 3) == 0) {
452 user->phase2 = 1;
453 goto done;
454 }
455
456 if (*pos == '"') {
457 pos++;
458 start = pos;
459 while (*pos != '"' && *pos != '\0')
460 pos++;
461 if (*pos == '\0') {
462 wpa_printf(MSG_ERROR, "Invalid EAP password "
463 "(no \" in end) on line %d in '%s'",
464 line, fname);
465 goto failed;
466 }
467
468 user->password = os_memdup(start, pos - start);
469 if (user->password == NULL) {
470 wpa_printf(MSG_ERROR, "Failed to allocate "
471 "memory for EAP password");
472 goto failed;
473 }
474 user->password_len = pos - start;
475
476 pos++;
477 } else if (os_strncmp(pos, "hash:", 5) == 0) {
478 pos += 5;
479 pos2 = pos;
480 while (*pos2 != '\0' && *pos2 != ' ' &&
481 *pos2 != '\t' && *pos2 != '#')
482 pos2++;
483 if (pos2 - pos != 32) {
484 wpa_printf(MSG_ERROR, "Invalid password hash "
485 "on line %d in '%s'", line, fname);
486 goto failed;
487 }
488 user->password = os_malloc(16);
489 if (user->password == NULL) {
490 wpa_printf(MSG_ERROR, "Failed to allocate "
491 "memory for EAP password hash");
492 goto failed;
493 }
494 if (hexstr2bin(pos, user->password, 16) < 0) {
495 wpa_printf(MSG_ERROR, "Invalid hash password "
496 "on line %d in '%s'", line, fname);
497 goto failed;
498 }
499 user->password_len = 16;
500 user->password_hash = 1;
501 pos = pos2;
502 } else if (os_strncmp(pos, "ssha1:", 6) == 0) {
503 pos += 6;
504 if (hostapd_config_eap_user_salted(user, "sha1", 20,
505 &pos,
506 line, fname) < 0)
507 goto failed;
508 } else if (os_strncmp(pos, "ssha256:", 8) == 0) {
509 pos += 8;
510 if (hostapd_config_eap_user_salted(user, "sha256", 32,
511 &pos,
512 line, fname) < 0)
513 goto failed;
514 } else if (os_strncmp(pos, "ssha512:", 8) == 0) {
515 pos += 8;
516 if (hostapd_config_eap_user_salted(user, "sha512", 64,
517 &pos,
518 line, fname) < 0)
519 goto failed;
520 } else {
521 pos2 = pos;
522 while (*pos2 != '\0' && *pos2 != ' ' &&
523 *pos2 != '\t' && *pos2 != '#')
524 pos2++;
525 if ((pos2 - pos) & 1) {
526 wpa_printf(MSG_ERROR, "Invalid hex password "
527 "on line %d in '%s'", line, fname);
528 goto failed;
529 }
530 user->password = os_malloc((pos2 - pos) / 2);
531 if (user->password == NULL) {
532 wpa_printf(MSG_ERROR, "Failed to allocate "
533 "memory for EAP password");
534 goto failed;
535 }
536 if (hexstr2bin(pos, user->password,
537 (pos2 - pos) / 2) < 0) {
538 wpa_printf(MSG_ERROR, "Invalid hex password "
539 "on line %d in '%s'", line, fname);
540 goto failed;
541 }
542 user->password_len = (pos2 - pos) / 2;
543 pos = pos2;
544 }
545
546 while (*pos == ' ' || *pos == '\t')
547 pos++;
548 if (os_strncmp(pos, "[2]", 3) == 0) {
549 user->phase2 = 1;
550 }
551
552 done:
553 if (tail == NULL) {
554 tail = new_user = user;
555 } else {
556 tail->next = user;
557 tail = user;
558 }
559 continue;
560
561 failed:
562 if (user)
563 hostapd_config_free_eap_user(user);
564 ret = -1;
565 break;
566 }
567
568 fclose(f);
569
570 if (ret == 0) {
571 hostapd_config_free_eap_users(conf->eap_user);
572 conf->eap_user = new_user;
573 } else {
574 hostapd_config_free_eap_users(new_user);
575 }
576
577 return ret;
578}
579
580#endif /* EAP_SERVER */
581
582
583#ifndef CONFIG_NO_RADIUS
584static int
585hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
586 int *num_server, const char *val, int def_port,
587 struct hostapd_radius_server **curr_serv)
588{
589 struct hostapd_radius_server *nserv;
590 int ret;
591 static int server_index = 1;
592
593 nserv = os_realloc_array(*server, *num_server + 1, sizeof(*nserv));
594 if (nserv == NULL)
595 return -1;
596
597 *server = nserv;
598 nserv = &nserv[*num_server];
599 (*num_server)++;
600 (*curr_serv) = nserv;
601
602 os_memset(nserv, 0, sizeof(*nserv));
603 nserv->port = def_port;
604 ret = hostapd_parse_ip_addr(val, &nserv->addr);
605 nserv->index = server_index++;
606
607 return ret;
608}
609
610
611
612static int hostapd_parse_das_client(struct hostapd_bss_config *bss, char *val)
613{
614 char *secret;
615
616 secret = os_strchr(val, ' ');
617 if (secret == NULL)
618 return -1;
619
620 *secret++ = '\0';
621
622 if (hostapd_parse_ip_addr(val, &bss->radius_das_client_addr))
623 return -1;
624
625 os_free(bss->radius_das_shared_secret);
626 bss->radius_das_shared_secret = (u8 *) os_strdup(secret);
627 if (bss->radius_das_shared_secret == NULL)
628 return -1;
629 bss->radius_das_shared_secret_len = os_strlen(secret);
630
631 return 0;
632}
633#endif /* CONFIG_NO_RADIUS */
634
635
636static int hostapd_config_parse_key_mgmt(int line, const char *value)
637{
638 int val = 0, last;
639 char *start, *end, *buf;
640
641 buf = os_strdup(value);
642 if (buf == NULL)
643 return -1;
644 start = buf;
645
646 while (*start != '\0') {
647 while (*start == ' ' || *start == '\t')
648 start++;
649 if (*start == '\0')
650 break;
651 end = start;
652 while (*end != ' ' && *end != '\t' && *end != '\0')
653 end++;
654 last = *end == '\0';
655 *end = '\0';
656 if (os_strcmp(start, "WPA-PSK") == 0)
657 val |= WPA_KEY_MGMT_PSK;
658 else if (os_strcmp(start, "WPA-EAP") == 0)
659 val |= WPA_KEY_MGMT_IEEE8021X;
660#ifdef CONFIG_IEEE80211R_AP
661 else if (os_strcmp(start, "FT-PSK") == 0)
662 val |= WPA_KEY_MGMT_FT_PSK;
663 else if (os_strcmp(start, "FT-EAP") == 0)
664 val |= WPA_KEY_MGMT_FT_IEEE8021X;
665#ifdef CONFIG_SHA384
666 else if (os_strcmp(start, "FT-EAP-SHA384") == 0)
667 val |= WPA_KEY_MGMT_FT_IEEE8021X_SHA384;
668#endif /* CONFIG_SHA384 */
669#endif /* CONFIG_IEEE80211R_AP */
670 else if (os_strcmp(start, "WPA-PSK-SHA256") == 0)
671 val |= WPA_KEY_MGMT_PSK_SHA256;
672 else if (os_strcmp(start, "WPA-EAP-SHA256") == 0)
673 val |= WPA_KEY_MGMT_IEEE8021X_SHA256;
674#ifdef CONFIG_SAE
675 else if (os_strcmp(start, "SAE") == 0)
676 val |= WPA_KEY_MGMT_SAE;
677 else if (os_strcmp(start, "SAE-EXT-KEY") == 0)
678 val |= WPA_KEY_MGMT_SAE_EXT_KEY;
679 else if (os_strcmp(start, "FT-SAE") == 0)
680 val |= WPA_KEY_MGMT_FT_SAE;
681 else if (os_strcmp(start, "FT-SAE-EXT-KEY") == 0)
682 val |= WPA_KEY_MGMT_FT_SAE_EXT_KEY;
683#endif /* CONFIG_SAE */
684#ifdef CONFIG_SUITEB
685 else if (os_strcmp(start, "WPA-EAP-SUITE-B") == 0)
686 val |= WPA_KEY_MGMT_IEEE8021X_SUITE_B;
687#endif /* CONFIG_SUITEB */
688#ifdef CONFIG_SUITEB192
689 else if (os_strcmp(start, "WPA-EAP-SUITE-B-192") == 0)
690 val |= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192;
691#endif /* CONFIG_SUITEB192 */
692#ifdef CONFIG_FILS
693 else if (os_strcmp(start, "FILS-SHA256") == 0)
694 val |= WPA_KEY_MGMT_FILS_SHA256;
695 else if (os_strcmp(start, "FILS-SHA384") == 0)
696 val |= WPA_KEY_MGMT_FILS_SHA384;
697#ifdef CONFIG_IEEE80211R_AP
698 else if (os_strcmp(start, "FT-FILS-SHA256") == 0)
699 val |= WPA_KEY_MGMT_FT_FILS_SHA256;
700 else if (os_strcmp(start, "FT-FILS-SHA384") == 0)
701 val |= WPA_KEY_MGMT_FT_FILS_SHA384;
702#endif /* CONFIG_IEEE80211R_AP */
703#endif /* CONFIG_FILS */
704#ifdef CONFIG_OWE
705 else if (os_strcmp(start, "OWE") == 0)
706 val |= WPA_KEY_MGMT_OWE;
707#endif /* CONFIG_OWE */
708#ifdef CONFIG_DPP
709 else if (os_strcmp(start, "DPP") == 0)
710 val |= WPA_KEY_MGMT_DPP;
711#endif /* CONFIG_DPP */
712#ifdef CONFIG_HS20
713 else if (os_strcmp(start, "OSEN") == 0)
714 val |= WPA_KEY_MGMT_OSEN;
715#endif /* CONFIG_HS20 */
716#ifdef CONFIG_PASN
717 else if (os_strcmp(start, "PASN") == 0)
718 val |= WPA_KEY_MGMT_PASN;
719#endif /* CONFIG_PASN */
720 else {
721 wpa_printf(MSG_ERROR, "Line %d: invalid key_mgmt '%s'",
722 line, start);
723 os_free(buf);
724 return -1;
725 }
726
727 if (last)
728 break;
729 start = end + 1;
730 }
731
732 os_free(buf);
733 if (val == 0) {
734 wpa_printf(MSG_ERROR, "Line %d: no key_mgmt values "
735 "configured.", line);
736 return -1;
737 }
738
739 return val;
740}
741
742
743static int hostapd_config_parse_cipher(int line, const char *value)
744{
745 int val = wpa_parse_cipher(value);
746 if (val < 0) {
747 wpa_printf(MSG_ERROR, "Line %d: invalid cipher '%s'.",
748 line, value);
749 return -1;
750 }
751 if (val == 0) {
752 wpa_printf(MSG_ERROR, "Line %d: no cipher values configured.",
753 line);
754 return -1;
755 }
756 return val;
757}
758
759
760#ifdef CONFIG_WEP
761static int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx,
762 char *val)
763{
764 size_t len = os_strlen(val);
765
766 if (keyidx < 0 || keyidx > 3)
767 return -1;
768
769 if (len == 0) {
770 int i, set = 0;
771
772 bin_clear_free(wep->key[keyidx], wep->len[keyidx]);
773 wep->key[keyidx] = NULL;
774 wep->len[keyidx] = 0;
775 for (i = 0; i < NUM_WEP_KEYS; i++) {
776 if (wep->key[i])
777 set++;
778 }
779 if (!set)
780 wep->keys_set = 0;
781 return 0;
782 }
783
784 if (wep->key[keyidx] != NULL)
785 return -1;
786
787 if (val[0] == '"') {
788 if (len < 2 || val[len - 1] != '"')
789 return -1;
790 len -= 2;
791 wep->key[keyidx] = os_memdup(val + 1, len);
792 if (wep->key[keyidx] == NULL)
793 return -1;
794 wep->len[keyidx] = len;
795 } else {
796 if (len & 1)
797 return -1;
798 len /= 2;
799 wep->key[keyidx] = os_malloc(len);
800 if (wep->key[keyidx] == NULL)
801 return -1;
802 wep->len[keyidx] = len;
803 if (hexstr2bin(val, wep->key[keyidx], len) < 0)
804 return -1;
805 }
806
807 wep->keys_set++;
808
809 return 0;
810}
811#endif /* CONFIG_WEP */
812
813
814static int hostapd_parse_chanlist(struct hostapd_config *conf, char *val)
815{
816 char *pos;
817
818 /* for backwards compatibility, translate ' ' in conf str to ',' */
819 pos = val;
820 while (pos) {
821 pos = os_strchr(pos, ' ');
822 if (pos)
823 *pos++ = ',';
824 }
825 if (freq_range_list_parse(&conf->acs_ch_list, val))
826 return -1;
827
828 return 0;
829}
830
831
832static int hostapd_parse_intlist(int **int_list, char *val)
833{
834 int *list;
835 int count;
836 char *pos, *end;
837
838 os_free(*int_list);
839 *int_list = NULL;
840
841 pos = val;
842 count = 0;
843 while (*pos != '\0') {
844 if (*pos == ' ')
845 count++;
846 pos++;
847 }
848
849 list = os_malloc(sizeof(int) * (count + 2));
850 if (list == NULL)
851 return -1;
852 pos = val;
853 count = 0;
854 while (*pos != '\0') {
855 end = os_strchr(pos, ' ');
856 if (end)
857 *end = '\0';
858
859 list[count++] = atoi(pos);
860 if (!end)
861 break;
862 pos = end + 1;
863 }
864 list[count] = -1;
865
866 *int_list = list;
867 return 0;
868}
869
870
871static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
872{
873 struct hostapd_bss_config **all, *bss;
874
875 if (*ifname == '\0')
876 return -1;
877
878 all = os_realloc_array(conf->bss, conf->num_bss + 1,
879 sizeof(struct hostapd_bss_config *));
880 if (all == NULL) {
881 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
882 "multi-BSS entry");
883 return -1;
884 }
885 conf->bss = all;
886
887 bss = os_zalloc(sizeof(*bss));
888 if (bss == NULL)
889 return -1;
890 bss->radius = os_zalloc(sizeof(*bss->radius));
891 if (bss->radius == NULL) {
892 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
893 "multi-BSS RADIUS data");
894 os_free(bss);
895 return -1;
896 }
897
898 conf->bss[conf->num_bss++] = bss;
899 conf->last_bss = bss;
900
901 hostapd_config_defaults_bss(bss);
902 os_strlcpy(bss->iface, ifname, sizeof(bss->iface));
903 os_memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1);
904
905 return 0;
906}
907
908
909#ifdef CONFIG_IEEE80211R_AP
910
911static int rkh_derive_key(const char *pos, u8 *key, size_t key_len)
912{
913 u8 oldkey[16];
914 int ret;
915
916 if (!hexstr2bin(pos, key, key_len))
917 return 0;
918
919 /* Try to use old short key for backwards compatibility */
920 if (hexstr2bin(pos, oldkey, sizeof(oldkey)))
921 return -1;
922
923 ret = hmac_sha256_kdf(oldkey, sizeof(oldkey), "FT OLDKEY", NULL, 0,
924 key, key_len);
925 os_memset(oldkey, 0, sizeof(oldkey));
926 return ret;
927}
928
929
930static int add_r0kh(struct hostapd_bss_config *bss, char *value)
931{
932 struct ft_remote_r0kh *r0kh;
933 char *pos, *next;
934
935 r0kh = os_zalloc(sizeof(*r0kh));
936 if (r0kh == NULL)
937 return -1;
938
939 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
940 pos = value;
941 next = os_strchr(pos, ' ');
942 if (next)
943 *next++ = '\0';
944 if (next == NULL || hwaddr_aton(pos, r0kh->addr)) {
945 wpa_printf(MSG_ERROR, "Invalid R0KH MAC address: '%s'", pos);
946 os_free(r0kh);
947 return -1;
948 }
949
950 pos = next;
951 next = os_strchr(pos, ' ');
952 if (next)
953 *next++ = '\0';
954 if (next == NULL || next - pos > FT_R0KH_ID_MAX_LEN) {
955 wpa_printf(MSG_ERROR, "Invalid R0KH-ID: '%s'", pos);
956 os_free(r0kh);
957 return -1;
958 }
959 r0kh->id_len = next - pos - 1;
960 os_memcpy(r0kh->id, pos, r0kh->id_len);
961
962 pos = next;
963 if (rkh_derive_key(pos, r0kh->key, sizeof(r0kh->key)) < 0) {
964 wpa_printf(MSG_ERROR, "Invalid R0KH key: '%s'", pos);
965 os_free(r0kh);
966 return -1;
967 }
968
969 r0kh->next = bss->r0kh_list;
970 bss->r0kh_list = r0kh;
971
972 return 0;
973}
974
975
976static int add_r1kh(struct hostapd_bss_config *bss, char *value)
977{
978 struct ft_remote_r1kh *r1kh;
979 char *pos, *next;
980
981 r1kh = os_zalloc(sizeof(*r1kh));
982 if (r1kh == NULL)
983 return -1;
984
985 /* 02:01:02:03:04:05 02:01:02:03:04:05
986 * 000102030405060708090a0b0c0d0e0f */
987 pos = value;
988 next = os_strchr(pos, ' ');
989 if (next)
990 *next++ = '\0';
991 if (next == NULL || hwaddr_aton(pos, r1kh->addr)) {
992 wpa_printf(MSG_ERROR, "Invalid R1KH MAC address: '%s'", pos);
993 os_free(r1kh);
994 return -1;
995 }
996
997 pos = next;
998 next = os_strchr(pos, ' ');
999 if (next)
1000 *next++ = '\0';
1001 if (next == NULL || hwaddr_aton(pos, r1kh->id)) {
1002 wpa_printf(MSG_ERROR, "Invalid R1KH-ID: '%s'", pos);
1003 os_free(r1kh);
1004 return -1;
1005 }
1006
1007 pos = next;
1008 if (rkh_derive_key(pos, r1kh->key, sizeof(r1kh->key)) < 0) {
1009 wpa_printf(MSG_ERROR, "Invalid R1KH key: '%s'", pos);
1010 os_free(r1kh);
1011 return -1;
1012 }
1013
1014 r1kh->next = bss->r1kh_list;
1015 bss->r1kh_list = r1kh;
1016
1017 return 0;
1018}
1019#endif /* CONFIG_IEEE80211R_AP */
1020
1021
1022static int hostapd_config_ht_capab(struct hostapd_config *conf,
1023 const char *capab)
1024{
1025 if (os_strstr(capab, "[LDPC]"))
1026 conf->ht_capab |= HT_CAP_INFO_LDPC_CODING_CAP;
1027 if (os_strstr(capab, "[HT40-]")) {
1028 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
1029 conf->secondary_channel = -1;
1030 }
1031 if (os_strstr(capab, "[HT40+]")) {
1032 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
1033 conf->secondary_channel = 1;
1034 }
1035 if (os_strstr(capab, "[HT40+]") && os_strstr(capab, "[HT40-]")) {
1036 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
1037 conf->ht40_plus_minus_allowed = 1;
1038 }
1039 if (!os_strstr(capab, "[HT40+]") && !os_strstr(capab, "[HT40-]"))
1040 conf->secondary_channel = 0;
1041 if (os_strstr(capab, "[GF]"))
1042 conf->ht_capab |= HT_CAP_INFO_GREEN_FIELD;
1043 if (os_strstr(capab, "[SHORT-GI-20]"))
1044 conf->ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ;
1045 if (os_strstr(capab, "[SHORT-GI-40]"))
1046 conf->ht_capab |= HT_CAP_INFO_SHORT_GI40MHZ;
1047 if (os_strstr(capab, "[TX-STBC]"))
1048 conf->ht_capab |= HT_CAP_INFO_TX_STBC;
1049 if (os_strstr(capab, "[RX-STBC1]")) {
1050 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1051 conf->ht_capab |= HT_CAP_INFO_RX_STBC_1;
1052 }
1053 if (os_strstr(capab, "[RX-STBC12]")) {
1054 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1055 conf->ht_capab |= HT_CAP_INFO_RX_STBC_12;
1056 }
1057 if (os_strstr(capab, "[RX-STBC123]")) {
1058 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1059 conf->ht_capab |= HT_CAP_INFO_RX_STBC_123;
1060 }
1061 if (os_strstr(capab, "[DELAYED-BA]"))
1062 conf->ht_capab |= HT_CAP_INFO_DELAYED_BA;
1063 if (os_strstr(capab, "[MAX-AMSDU-7935]"))
1064 conf->ht_capab |= HT_CAP_INFO_MAX_AMSDU_SIZE;
1065 if (os_strstr(capab, "[DSSS_CCK-40]"))
1066 conf->ht_capab |= HT_CAP_INFO_DSSS_CCK40MHZ;
1067 if (os_strstr(capab, "[40-INTOLERANT]"))
1068 conf->ht_capab |= HT_CAP_INFO_40MHZ_INTOLERANT;
1069 if (os_strstr(capab, "[LSIG-TXOP-PROT]"))
1070 conf->ht_capab |= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT;
1071
1072 return 0;
1073}
1074
1075
1076#ifdef CONFIG_IEEE80211AC
1077static int hostapd_config_vht_capab(struct hostapd_config *conf,
1078 const char *capab)
1079{
1080 if (os_strstr(capab, "[MAX-MPDU-7991]"))
1081 conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_7991;
1082 if (os_strstr(capab, "[MAX-MPDU-11454]"))
1083 conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_11454;
1084 if (os_strstr(capab, "[VHT160]"))
1085 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
1086 if (os_strstr(capab, "[VHT160-80PLUS80]"))
1087 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
1088 if (os_strstr(capab, "[RXLDPC]"))
1089 conf->vht_capab |= VHT_CAP_RXLDPC;
1090 if (os_strstr(capab, "[SHORT-GI-80]"))
1091 conf->vht_capab |= VHT_CAP_SHORT_GI_80;
1092 if (os_strstr(capab, "[SHORT-GI-160]"))
1093 conf->vht_capab |= VHT_CAP_SHORT_GI_160;
1094 if (os_strstr(capab, "[TX-STBC-2BY1]"))
1095 conf->vht_capab |= VHT_CAP_TXSTBC;
1096 if (os_strstr(capab, "[RX-STBC-1]"))
1097 conf->vht_capab |= VHT_CAP_RXSTBC_1;
1098 if (os_strstr(capab, "[RX-STBC-12]"))
1099 conf->vht_capab |= VHT_CAP_RXSTBC_2;
1100 if (os_strstr(capab, "[RX-STBC-123]"))
1101 conf->vht_capab |= VHT_CAP_RXSTBC_3;
1102 if (os_strstr(capab, "[RX-STBC-1234]"))
1103 conf->vht_capab |= VHT_CAP_RXSTBC_4;
1104 if (os_strstr(capab, "[SU-BEAMFORMER]"))
1105 conf->vht_capab |= VHT_CAP_SU_BEAMFORMER_CAPABLE;
1106 if (os_strstr(capab, "[SU-BEAMFORMEE]"))
1107 conf->vht_capab |= VHT_CAP_SU_BEAMFORMEE_CAPABLE;
1108 if (os_strstr(capab, "[BF-ANTENNA-2]") &&
1109 (conf->vht_capab & VHT_CAP_SU_BEAMFORMEE_CAPABLE))
1110 conf->vht_capab |= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET);
1111 if (os_strstr(capab, "[BF-ANTENNA-3]") &&
1112 (conf->vht_capab & VHT_CAP_SU_BEAMFORMEE_CAPABLE))
1113 conf->vht_capab |= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET);
1114 if (os_strstr(capab, "[BF-ANTENNA-4]") &&
1115 (conf->vht_capab & VHT_CAP_SU_BEAMFORMEE_CAPABLE))
1116 conf->vht_capab |= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET);
1117 if (os_strstr(capab, "[SOUNDING-DIMENSION-2]") &&
1118 (conf->vht_capab & VHT_CAP_SU_BEAMFORMER_CAPABLE))
1119 conf->vht_capab |= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET);
1120 if (os_strstr(capab, "[SOUNDING-DIMENSION-3]") &&
1121 (conf->vht_capab & VHT_CAP_SU_BEAMFORMER_CAPABLE))
1122 conf->vht_capab |= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET);
1123 if (os_strstr(capab, "[SOUNDING-DIMENSION-4]") &&
1124 (conf->vht_capab & VHT_CAP_SU_BEAMFORMER_CAPABLE))
1125 conf->vht_capab |= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET);
1126 if (os_strstr(capab, "[MU-BEAMFORMER]"))
1127 conf->vht_capab |= VHT_CAP_MU_BEAMFORMER_CAPABLE;
1128 if (os_strstr(capab, "[VHT-TXOP-PS]"))
1129 conf->vht_capab |= VHT_CAP_VHT_TXOP_PS;
1130 if (os_strstr(capab, "[HTC-VHT]"))
1131 conf->vht_capab |= VHT_CAP_HTC_VHT;
1132 if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP7]"))
1133 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX;
1134 else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP6]"))
1135 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6;
1136 else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP5]"))
1137 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5;
1138 else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP4]"))
1139 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4;
1140 else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP3]"))
1141 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3;
1142 else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP2]"))
1143 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2;
1144 else if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP1]"))
1145 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1;
1146 if (os_strstr(capab, "[VHT-LINK-ADAPT2]") &&
1147 (conf->vht_capab & VHT_CAP_HTC_VHT))
1148 conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB;
1149 if (os_strstr(capab, "[VHT-LINK-ADAPT3]") &&
1150 (conf->vht_capab & VHT_CAP_HTC_VHT))
1151 conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB;
1152 if (os_strstr(capab, "[RX-ANTENNA-PATTERN]"))
1153 conf->vht_capab |= VHT_CAP_RX_ANTENNA_PATTERN;
1154 if (os_strstr(capab, "[TX-ANTENNA-PATTERN]"))
1155 conf->vht_capab |= VHT_CAP_TX_ANTENNA_PATTERN;
1156 if (os_strstr(capab, "[EXT-NSS-BW-SUPP]"))
1157 conf->vht_capab |= VHT_CAP_EXTENDED_NSS_BW_SUPPORT;
1158 return 0;
1159}
1160#endif /* CONFIG_IEEE80211AC */
1161
1162
1163#ifdef CONFIG_IEEE80211AX
1164
1165static u8 find_bit_offset(u8 val)
1166{
1167 u8 res = 0;
1168
1169 for (; val; val >>= 1) {
1170 if (val & 1)
1171 break;
1172 res++;
1173 }
1174
1175 return res;
1176}
1177
1178
1179static u8 set_he_cap(int val, u8 mask)
1180{
1181 return (u8) (mask & (val << find_bit_offset(mask)));
1182}
1183
1184
1185static int hostapd_parse_he_srg_bitmap(u8 *bitmap, char *val)
1186{
1187 int bitpos;
1188 char *pos, *end;
1189
1190 os_memset(bitmap, 0, 8);
1191 pos = val;
1192 while (*pos != '\0') {
1193 end = os_strchr(pos, ' ');
1194 if (end)
1195 *end = '\0';
1196
1197 bitpos = atoi(pos);
1198 if (bitpos < 0 || bitpos > 64)
1199 return -1;
1200
1201 bitmap[bitpos / 8] |= BIT(bitpos % 8);
1202 if (!end)
1203 break;
1204 pos = end + 1;
1205 }
1206
1207 return 0;
1208}
1209
1210#endif /* CONFIG_IEEE80211AX */
1211
1212
1213#ifdef CONFIG_INTERWORKING
1214static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos,
1215 int line)
1216{
1217 size_t len = os_strlen(pos);
1218 u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
1219
1220 struct hostapd_roaming_consortium *rc;
1221
1222 if ((len & 1) || len < 2 * 3 || len / 2 > MAX_ROAMING_CONSORTIUM_LEN ||
1223 hexstr2bin(pos, oi, len / 2)) {
1224 wpa_printf(MSG_ERROR, "Line %d: invalid roaming_consortium "
1225 "'%s'", line, pos);
1226 return -1;
1227 }
1228 len /= 2;
1229
1230 rc = os_realloc_array(bss->roaming_consortium,
1231 bss->roaming_consortium_count + 1,
1232 sizeof(struct hostapd_roaming_consortium));
1233 if (rc == NULL)
1234 return -1;
1235
1236 os_memcpy(rc[bss->roaming_consortium_count].oi, oi, len);
1237 rc[bss->roaming_consortium_count].len = len;
1238
1239 bss->roaming_consortium = rc;
1240 bss->roaming_consortium_count++;
1241
1242 return 0;
1243}
1244
1245
1246static int parse_lang_string(struct hostapd_lang_string **array,
1247 unsigned int *count, char *pos)
1248{
1249 char *sep, *str = NULL;
1250 size_t clen, nlen, slen;
1251 struct hostapd_lang_string *ls;
1252 int ret = -1;
1253
1254 if (*pos == '"' || (*pos == 'P' && pos[1] == '"')) {
1255 str = wpa_config_parse_string(pos, &slen);
1256 if (!str)
1257 return -1;
1258 pos = str;
1259 }
1260
1261 sep = os_strchr(pos, ':');
1262 if (sep == NULL)
1263 goto fail;
1264 *sep++ = '\0';
1265
1266 clen = os_strlen(pos);
1267 if (clen < 2 || clen > sizeof(ls->lang))
1268 goto fail;
1269 nlen = os_strlen(sep);
1270 if (nlen > 252)
1271 goto fail;
1272
1273 ls = os_realloc_array(*array, *count + 1,
1274 sizeof(struct hostapd_lang_string));
1275 if (ls == NULL)
1276 goto fail;
1277
1278 *array = ls;
1279 ls = &(*array)[*count];
1280 (*count)++;
1281
1282 os_memset(ls->lang, 0, sizeof(ls->lang));
1283 os_memcpy(ls->lang, pos, clen);
1284 ls->name_len = nlen;
1285 os_memcpy(ls->name, sep, nlen);
1286
1287 ret = 0;
1288fail:
1289 os_free(str);
1290 return ret;
1291}
1292
1293
1294static int parse_venue_name(struct hostapd_bss_config *bss, char *pos,
1295 int line)
1296{
1297 if (parse_lang_string(&bss->venue_name, &bss->venue_name_count, pos)) {
1298 wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'",
1299 line, pos);
1300 return -1;
1301 }
1302 return 0;
1303}
1304
1305
1306static int parse_venue_url(struct hostapd_bss_config *bss, char *pos,
1307 int line)
1308{
1309 char *sep;
1310 size_t nlen;
1311 struct hostapd_venue_url *url;
1312 int ret = -1;
1313
1314 sep = os_strchr(pos, ':');
1315 if (!sep)
1316 goto fail;
1317 *sep++ = '\0';
1318
1319 nlen = os_strlen(sep);
1320 if (nlen > 254)
1321 goto fail;
1322
1323 url = os_realloc_array(bss->venue_url, bss->venue_url_count + 1,
1324 sizeof(struct hostapd_venue_url));
1325 if (!url)
1326 goto fail;
1327
1328 bss->venue_url = url;
1329 url = &bss->venue_url[bss->venue_url_count++];
1330
1331 url->venue_number = atoi(pos);
1332 url->url_len = nlen;
1333 os_memcpy(url->url, sep, nlen);
1334
1335 ret = 0;
1336fail:
1337 if (ret)
1338 wpa_printf(MSG_ERROR, "Line %d: Invalid venue_url '%s'",
1339 line, pos);
1340 return ret;
1341}
1342
1343
1344static int parse_3gpp_cell_net(struct hostapd_bss_config *bss, char *buf,
1345 int line)
1346{
1347 size_t count;
1348 char *pos;
1349 u8 *info = NULL, *ipos;
1350
1351 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1352
1353 count = 1;
1354 for (pos = buf; *pos; pos++) {
1355 if ((*pos < '0' || *pos > '9') && *pos != ';' && *pos != ',')
1356 goto fail;
1357 if (*pos == ';')
1358 count++;
1359 }
1360 if (1 + count * 3 > 0x7f)
1361 goto fail;
1362
1363 info = os_zalloc(2 + 3 + count * 3);
1364 if (info == NULL)
1365 return -1;
1366
1367 ipos = info;
1368 *ipos++ = 0; /* GUD - Version 1 */
1369 *ipos++ = 3 + count * 3; /* User Data Header Length (UDHL) */
1370 *ipos++ = 0; /* PLMN List IEI */
1371 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1372 *ipos++ = 1 + count * 3;
1373 *ipos++ = count; /* Number of PLMNs */
1374
1375 pos = buf;
1376 while (pos && *pos) {
1377 char *mcc, *mnc;
1378 size_t mnc_len;
1379
1380 mcc = pos;
1381 mnc = os_strchr(pos, ',');
1382 if (mnc == NULL)
1383 goto fail;
1384 *mnc++ = '\0';
1385 pos = os_strchr(mnc, ';');
1386 if (pos)
1387 *pos++ = '\0';
1388
1389 mnc_len = os_strlen(mnc);
1390 if (os_strlen(mcc) != 3 || (mnc_len != 2 && mnc_len != 3))
1391 goto fail;
1392
1393 /* BC coded MCC,MNC */
1394 /* MCC digit 2 | MCC digit 1 */
1395 *ipos++ = ((mcc[1] - '0') << 4) | (mcc[0] - '0');
1396 /* MNC digit 3 | MCC digit 3 */
1397 *ipos++ = (((mnc_len == 2) ? 0xf0 : ((mnc[2] - '0') << 4))) |
1398 (mcc[2] - '0');
1399 /* MNC digit 2 | MNC digit 1 */
1400 *ipos++ = ((mnc[1] - '0') << 4) | (mnc[0] - '0');
1401 }
1402
1403 os_free(bss->anqp_3gpp_cell_net);
1404 bss->anqp_3gpp_cell_net = info;
1405 bss->anqp_3gpp_cell_net_len = 2 + 3 + 3 * count;
1406 wpa_hexdump(MSG_MSGDUMP, "3GPP Cellular Network information",
1407 bss->anqp_3gpp_cell_net, bss->anqp_3gpp_cell_net_len);
1408
1409 return 0;
1410
1411fail:
1412 wpa_printf(MSG_ERROR, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1413 line, buf);
1414 os_free(info);
1415 return -1;
1416}
1417
1418
1419static int parse_nai_realm(struct hostapd_bss_config *bss, char *buf, int line)
1420{
1421 struct hostapd_nai_realm_data *realm;
1422 size_t i, j, len;
1423 int *offsets;
1424 char *pos, *end, *rpos;
1425
1426 offsets = os_calloc(bss->nai_realm_count * MAX_NAI_REALMS,
1427 sizeof(int));
1428 if (offsets == NULL)
1429 return -1;
1430
1431 for (i = 0; i < bss->nai_realm_count; i++) {
1432 realm = &bss->nai_realm_data[i];
1433 for (j = 0; j < MAX_NAI_REALMS; j++) {
1434 offsets[i * MAX_NAI_REALMS + j] =
1435 realm->realm[j] ?
1436 realm->realm[j] - realm->realm_buf : -1;
1437 }
1438 }
1439
1440 realm = os_realloc_array(bss->nai_realm_data, bss->nai_realm_count + 1,
1441 sizeof(struct hostapd_nai_realm_data));
1442 if (realm == NULL) {
1443 os_free(offsets);
1444 return -1;
1445 }
1446 bss->nai_realm_data = realm;
1447
1448 /* patch the pointers after realloc */
1449 for (i = 0; i < bss->nai_realm_count; i++) {
1450 realm = &bss->nai_realm_data[i];
1451 for (j = 0; j < MAX_NAI_REALMS; j++) {
1452 int offs = offsets[i * MAX_NAI_REALMS + j];
1453 if (offs >= 0)
1454 realm->realm[j] = realm->realm_buf + offs;
1455 else
1456 realm->realm[j] = NULL;
1457 }
1458 }
1459 os_free(offsets);
1460
1461 realm = &bss->nai_realm_data[bss->nai_realm_count];
1462 os_memset(realm, 0, sizeof(*realm));
1463
1464 pos = buf;
1465 realm->encoding = atoi(pos);
1466 pos = os_strchr(pos, ',');
1467 if (pos == NULL)
1468 goto fail;
1469 pos++;
1470
1471 end = os_strchr(pos, ',');
1472 if (end) {
1473 len = end - pos;
1474 *end = '\0';
1475 } else {
1476 len = os_strlen(pos);
1477 }
1478
1479 if (len > MAX_NAI_REALMLEN) {
1480 wpa_printf(MSG_ERROR, "Too long a realm string (%d > max %d "
1481 "characters)", (int) len, MAX_NAI_REALMLEN);
1482 goto fail;
1483 }
1484 os_memcpy(realm->realm_buf, pos, len);
1485
1486 if (end)
1487 pos = end + 1;
1488 else
1489 pos = NULL;
1490
1491 while (pos && *pos) {
1492 struct hostapd_nai_realm_eap *eap;
1493
1494 if (realm->eap_method_count >= MAX_NAI_EAP_METHODS) {
1495 wpa_printf(MSG_ERROR, "Too many EAP methods");
1496 goto fail;
1497 }
1498
1499 eap = &realm->eap_method[realm->eap_method_count];
1500 realm->eap_method_count++;
1501
1502 end = os_strchr(pos, ',');
1503 if (end == NULL)
1504 end = pos + os_strlen(pos);
1505
1506 eap->eap_method = atoi(pos);
1507 for (;;) {
1508 pos = os_strchr(pos, '[');
1509 if (pos == NULL || pos > end)
1510 break;
1511 pos++;
1512 if (eap->num_auths >= MAX_NAI_AUTH_TYPES) {
1513 wpa_printf(MSG_ERROR, "Too many auth params");
1514 goto fail;
1515 }
1516 eap->auth_id[eap->num_auths] = atoi(pos);
1517 pos = os_strchr(pos, ':');
1518 if (pos == NULL || pos > end)
1519 goto fail;
1520 pos++;
1521 eap->auth_val[eap->num_auths] = atoi(pos);
1522 pos = os_strchr(pos, ']');
1523 if (pos == NULL || pos > end)
1524 goto fail;
1525 pos++;
1526 eap->num_auths++;
1527 }
1528
1529 if (*end != ',')
1530 break;
1531
1532 pos = end + 1;
1533 }
1534
1535 /* Split realm list into null terminated realms */
1536 rpos = realm->realm_buf;
1537 i = 0;
1538 while (*rpos) {
1539 if (i >= MAX_NAI_REALMS) {
1540 wpa_printf(MSG_ERROR, "Too many realms");
1541 goto fail;
1542 }
1543 realm->realm[i++] = rpos;
1544 rpos = os_strchr(rpos, ';');
1545 if (rpos == NULL)
1546 break;
1547 *rpos++ = '\0';
1548 }
1549
1550 bss->nai_realm_count++;
1551
1552 return 0;
1553
1554fail:
1555 wpa_printf(MSG_ERROR, "Line %d: invalid nai_realm '%s'", line, buf);
1556 return -1;
1557}
1558
1559
1560static int parse_anqp_elem(struct hostapd_bss_config *bss, char *buf, int line)
1561{
1562 char *delim;
1563 u16 infoid;
1564 size_t len;
1565 struct wpabuf *payload;
1566 struct anqp_element *elem;
1567
1568 delim = os_strchr(buf, ':');
1569 if (!delim)
1570 return -1;
1571 delim++;
1572 infoid = atoi(buf);
1573 len = os_strlen(delim);
1574 if (len & 1)
1575 return -1;
1576 len /= 2;
1577 payload = wpabuf_alloc(len);
1578 if (!payload)
1579 return -1;
1580 if (hexstr2bin(delim, wpabuf_put(payload, len), len) < 0) {
1581 wpabuf_free(payload);
1582 return -1;
1583 }
1584
1585 dl_list_for_each(elem, &bss->anqp_elem, struct anqp_element, list) {
1586 if (elem->infoid == infoid) {
1587 /* Update existing entry */
1588 wpabuf_free(elem->payload);
1589 elem->payload = payload;
1590 return 0;
1591 }
1592 }
1593
1594 /* Add a new entry */
1595 elem = os_zalloc(sizeof(*elem));
1596 if (!elem) {
1597 wpabuf_free(payload);
1598 return -1;
1599 }
1600 elem->infoid = infoid;
1601 elem->payload = payload;
1602 dl_list_add(&bss->anqp_elem, &elem->list);
1603
1604 return 0;
1605}
1606
1607#endif /* CONFIG_INTERWORKING */
1608
1609
1610static int parse_qos_map_set(struct hostapd_bss_config *bss,
1611 char *buf, int line)
1612{
1613 u8 qos_map_set[16 + 2 * 21], count = 0;
1614 char *pos = buf;
1615 int val;
1616
1617 for (;;) {
1618 if (count == sizeof(qos_map_set)) {
1619 wpa_printf(MSG_ERROR, "Line %d: Too many qos_map_set "
1620 "parameters '%s'", line, buf);
1621 return -1;
1622 }
1623
1624 val = atoi(pos);
1625 if (val > 255 || val < 0) {
1626 wpa_printf(MSG_ERROR, "Line %d: Invalid qos_map_set "
1627 "'%s'", line, buf);
1628 return -1;
1629 }
1630
1631 qos_map_set[count++] = val;
1632 pos = os_strchr(pos, ',');
1633 if (!pos)
1634 break;
1635 pos++;
1636 }
1637
1638 if (count < 16 || count & 1) {
1639 wpa_printf(MSG_ERROR, "Line %d: Invalid qos_map_set '%s'",
1640 line, buf);
1641 return -1;
1642 }
1643
1644 os_memcpy(bss->qos_map_set, qos_map_set, count);
1645 bss->qos_map_set_len = count;
1646
1647 return 0;
1648}
1649
1650
1651#ifdef CONFIG_HS20
1652static int hs20_parse_conn_capab(struct hostapd_bss_config *bss, char *buf,
1653 int line)
1654{
1655 u8 *conn_cap;
1656 char *pos;
1657
1658 if (bss->hs20_connection_capability_len >= 0xfff0)
1659 return -1;
1660
1661 conn_cap = os_realloc(bss->hs20_connection_capability,
1662 bss->hs20_connection_capability_len + 4);
1663 if (conn_cap == NULL)
1664 return -1;
1665
1666 bss->hs20_connection_capability = conn_cap;
1667 conn_cap += bss->hs20_connection_capability_len;
1668 pos = buf;
1669 conn_cap[0] = atoi(pos);
1670 pos = os_strchr(pos, ':');
1671 if (pos == NULL)
1672 return -1;
1673 pos++;
1674 WPA_PUT_LE16(conn_cap + 1, atoi(pos));
1675 pos = os_strchr(pos, ':');
1676 if (pos == NULL)
1677 return -1;
1678 pos++;
1679 conn_cap[3] = atoi(pos);
1680 bss->hs20_connection_capability_len += 4;
1681
1682 return 0;
1683}
1684
1685
1686static int hs20_parse_wan_metrics(struct hostapd_bss_config *bss, char *buf,
1687 int line)
1688{
1689 u8 *wan_metrics;
1690 char *pos;
1691
1692 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1693
1694 wan_metrics = os_zalloc(13);
1695 if (wan_metrics == NULL)
1696 return -1;
1697
1698 pos = buf;
1699 /* WAN Info */
1700 if (hexstr2bin(pos, wan_metrics, 1) < 0)
1701 goto fail;
1702 pos += 2;
1703 if (*pos != ':')
1704 goto fail;
1705 pos++;
1706
1707 /* Downlink Speed */
1708 WPA_PUT_LE32(wan_metrics + 1, atoi(pos));
1709 pos = os_strchr(pos, ':');
1710 if (pos == NULL)
1711 goto fail;
1712 pos++;
1713
1714 /* Uplink Speed */
1715 WPA_PUT_LE32(wan_metrics + 5, atoi(pos));
1716 pos = os_strchr(pos, ':');
1717 if (pos == NULL)
1718 goto fail;
1719 pos++;
1720
1721 /* Downlink Load */
1722 wan_metrics[9] = atoi(pos);
1723 pos = os_strchr(pos, ':');
1724 if (pos == NULL)
1725 goto fail;
1726 pos++;
1727
1728 /* Uplink Load */
1729 wan_metrics[10] = atoi(pos);
1730 pos = os_strchr(pos, ':');
1731 if (pos == NULL)
1732 goto fail;
1733 pos++;
1734
1735 /* LMD */
1736 WPA_PUT_LE16(wan_metrics + 11, atoi(pos));
1737
1738 os_free(bss->hs20_wan_metrics);
1739 bss->hs20_wan_metrics = wan_metrics;
1740
1741 return 0;
1742
1743fail:
1744 wpa_printf(MSG_ERROR, "Line %d: Invalid hs20_wan_metrics '%s'",
1745 line, buf);
1746 os_free(wan_metrics);
1747 return -1;
1748}
1749
1750
1751static int hs20_parse_oper_friendly_name(struct hostapd_bss_config *bss,
1752 char *pos, int line)
1753{
1754 if (parse_lang_string(&bss->hs20_oper_friendly_name,
1755 &bss->hs20_oper_friendly_name_count, pos)) {
1756 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1757 "hs20_oper_friendly_name '%s'", line, pos);
1758 return -1;
1759 }
1760 return 0;
1761}
1762
1763
1764static int hs20_parse_icon(struct hostapd_bss_config *bss, char *pos)
1765{
1766 struct hs20_icon *icon;
1767 char *end;
1768
1769 icon = os_realloc_array(bss->hs20_icons, bss->hs20_icons_count + 1,
1770 sizeof(struct hs20_icon));
1771 if (icon == NULL)
1772 return -1;
1773 bss->hs20_icons = icon;
1774 icon = &bss->hs20_icons[bss->hs20_icons_count];
1775 os_memset(icon, 0, sizeof(*icon));
1776
1777 icon->width = atoi(pos);
1778 pos = os_strchr(pos, ':');
1779 if (pos == NULL)
1780 return -1;
1781 pos++;
1782
1783 icon->height = atoi(pos);
1784 pos = os_strchr(pos, ':');
1785 if (pos == NULL)
1786 return -1;
1787 pos++;
1788
1789 end = os_strchr(pos, ':');
1790 if (end == NULL || end - pos > 3)
1791 return -1;
1792 os_memcpy(icon->language, pos, end - pos);
1793 pos = end + 1;
1794
1795 end = os_strchr(pos, ':');
1796 if (end == NULL || end - pos > 255)
1797 return -1;
1798 os_memcpy(icon->type, pos, end - pos);
1799 pos = end + 1;
1800
1801 end = os_strchr(pos, ':');
1802 if (end == NULL || end - pos > 255)
1803 return -1;
1804 os_memcpy(icon->name, pos, end - pos);
1805 pos = end + 1;
1806
1807 if (os_strlen(pos) > 255)
1808 return -1;
1809 os_memcpy(icon->file, pos, os_strlen(pos));
1810
1811 bss->hs20_icons_count++;
1812
1813 return 0;
1814}
1815
1816
1817static int hs20_parse_osu_ssid(struct hostapd_bss_config *bss,
1818 char *pos, int line)
1819{
1820 size_t slen;
1821 char *str;
1822
1823 str = wpa_config_parse_string(pos, &slen);
1824 if (str == NULL || slen < 1 || slen > SSID_MAX_LEN) {
1825 wpa_printf(MSG_ERROR, "Line %d: Invalid SSID '%s'", line, pos);
1826 os_free(str);
1827 return -1;
1828 }
1829
1830 os_memcpy(bss->osu_ssid, str, slen);
1831 bss->osu_ssid_len = slen;
1832 os_free(str);
1833
1834 return 0;
1835}
1836
1837
1838static int hs20_parse_osu_server_uri(struct hostapd_bss_config *bss,
1839 char *pos, int line)
1840{
1841 struct hs20_osu_provider *p;
1842
1843 p = os_realloc_array(bss->hs20_osu_providers,
1844 bss->hs20_osu_providers_count + 1, sizeof(*p));
1845 if (p == NULL)
1846 return -1;
1847
1848 bss->hs20_osu_providers = p;
1849 bss->last_osu = &bss->hs20_osu_providers[bss->hs20_osu_providers_count];
1850 bss->hs20_osu_providers_count++;
1851 os_memset(bss->last_osu, 0, sizeof(*p));
1852 bss->last_osu->server_uri = os_strdup(pos);
1853
1854 return 0;
1855}
1856
1857
1858static int hs20_parse_osu_friendly_name(struct hostapd_bss_config *bss,
1859 char *pos, int line)
1860{
1861 if (bss->last_osu == NULL) {
1862 wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line);
1863 return -1;
1864 }
1865
1866 if (parse_lang_string(&bss->last_osu->friendly_name,
1867 &bss->last_osu->friendly_name_count, pos)) {
1868 wpa_printf(MSG_ERROR, "Line %d: Invalid osu_friendly_name '%s'",
1869 line, pos);
1870 return -1;
1871 }
1872
1873 return 0;
1874}
1875
1876
1877static int hs20_parse_osu_nai(struct hostapd_bss_config *bss,
1878 char *pos, int line)
1879{
1880 if (bss->last_osu == NULL) {
1881 wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line);
1882 return -1;
1883 }
1884
1885 os_free(bss->last_osu->osu_nai);
1886 bss->last_osu->osu_nai = os_strdup(pos);
1887 if (bss->last_osu->osu_nai == NULL)
1888 return -1;
1889
1890 return 0;
1891}
1892
1893
1894static int hs20_parse_osu_nai2(struct hostapd_bss_config *bss,
1895 char *pos, int line)
1896{
1897 if (bss->last_osu == NULL) {
1898 wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line);
1899 return -1;
1900 }
1901
1902 os_free(bss->last_osu->osu_nai2);
1903 bss->last_osu->osu_nai2 = os_strdup(pos);
1904 if (bss->last_osu->osu_nai2 == NULL)
1905 return -1;
1906 bss->hs20_osu_providers_nai_count++;
1907
1908 return 0;
1909}
1910
1911
1912static int hs20_parse_osu_method_list(struct hostapd_bss_config *bss, char *pos,
1913 int line)
1914{
1915 if (bss->last_osu == NULL) {
1916 wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line);
1917 return -1;
1918 }
1919
1920 if (hostapd_parse_intlist(&bss->last_osu->method_list, pos)) {
1921 wpa_printf(MSG_ERROR, "Line %d: Invalid osu_method_list", line);
1922 return -1;
1923 }
1924
1925 return 0;
1926}
1927
1928
1929static int hs20_parse_osu_icon(struct hostapd_bss_config *bss, char *pos,
1930 int line)
1931{
1932 char **n;
1933 struct hs20_osu_provider *p = bss->last_osu;
1934
1935 if (p == NULL) {
1936 wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line);
1937 return -1;
1938 }
1939
1940 n = os_realloc_array(p->icons, p->icons_count + 1, sizeof(char *));
1941 if (n == NULL)
1942 return -1;
1943 p->icons = n;
1944 p->icons[p->icons_count] = os_strdup(pos);
1945 if (p->icons[p->icons_count] == NULL)
1946 return -1;
1947 p->icons_count++;
1948
1949 return 0;
1950}
1951
1952
1953static int hs20_parse_osu_service_desc(struct hostapd_bss_config *bss,
1954 char *pos, int line)
1955{
1956 if (bss->last_osu == NULL) {
1957 wpa_printf(MSG_ERROR, "Line %d: Unexpected OSU field", line);
1958 return -1;
1959 }
1960
1961 if (parse_lang_string(&bss->last_osu->service_desc,
1962 &bss->last_osu->service_desc_count, pos)) {
1963 wpa_printf(MSG_ERROR, "Line %d: Invalid osu_service_desc '%s'",
1964 line, pos);
1965 return -1;
1966 }
1967
1968 return 0;
1969}
1970
1971
1972static int hs20_parse_operator_icon(struct hostapd_bss_config *bss, char *pos,
1973 int line)
1974{
1975 char **n;
1976
1977 n = os_realloc_array(bss->hs20_operator_icon,
1978 bss->hs20_operator_icon_count + 1, sizeof(char *));
1979 if (!n)
1980 return -1;
1981 bss->hs20_operator_icon = n;
1982 bss->hs20_operator_icon[bss->hs20_operator_icon_count] = os_strdup(pos);
1983 if (!bss->hs20_operator_icon[bss->hs20_operator_icon_count])
1984 return -1;
1985 bss->hs20_operator_icon_count++;
1986
1987 return 0;
1988}
1989
1990#endif /* CONFIG_HS20 */
1991
1992
1993#ifdef CONFIG_ACS
1994static int hostapd_config_parse_acs_chan_bias(struct hostapd_config *conf,
1995 char *pos)
1996{
1997 struct acs_bias *bias = NULL, *tmp;
1998 unsigned int num = 0;
1999 char *end;
2000
2001 while (*pos) {
2002 tmp = os_realloc_array(bias, num + 1, sizeof(*bias));
2003 if (!tmp)
2004 goto fail;
2005 bias = tmp;
2006
2007 bias[num].channel = atoi(pos);
2008 if (bias[num].channel <= 0)
2009 goto fail;
2010 pos = os_strchr(pos, ':');
2011 if (!pos)
2012 goto fail;
2013 pos++;
2014 bias[num].bias = strtod(pos, &end);
2015 if (end == pos || bias[num].bias < 0.0)
2016 goto fail;
2017 pos = end;
2018 if (*pos != ' ' && *pos != '\0')
2019 goto fail;
2020 num++;
2021 }
2022
2023 os_free(conf->acs_chan_bias);
2024 conf->acs_chan_bias = bias;
2025 conf->num_acs_chan_bias = num;
2026
2027 return 0;
2028fail:
2029 os_free(bias);
2030 return -1;
2031}
2032#endif /* CONFIG_ACS */
2033
2034
2035static int parse_wpabuf_hex(int line, const char *name, struct wpabuf **buf,
2036 const char *val)
2037{
2038 struct wpabuf *elems;
2039
2040 if (val[0] == '\0') {
2041 wpabuf_free(*buf);
2042 *buf = NULL;
2043 return 0;
2044 }
2045
2046 elems = wpabuf_parse_bin(val);
2047 if (!elems) {
2048 wpa_printf(MSG_ERROR, "Line %d: Invalid %s '%s'",
2049 line, name, val);
2050 return -1;
2051 }
2052
2053 wpabuf_free(*buf);
2054 *buf = elems;
2055
2056 return 0;
2057}
2058
2059
2060#ifdef CONFIG_FILS
2061static int parse_fils_realm(struct hostapd_bss_config *bss, const char *val)
2062{
2063 struct fils_realm *realm;
2064 size_t len;
2065
2066 len = os_strlen(val);
2067 realm = os_zalloc(sizeof(*realm) + len + 1);
2068 if (!realm)
2069 return -1;
2070
2071 os_memcpy(realm->realm, val, len);
2072 if (fils_domain_name_hash(val, realm->hash) < 0) {
2073 os_free(realm);
2074 return -1;
2075 }
2076 dl_list_add_tail(&bss->fils_realms, &realm->list);
2077
2078 return 0;
2079}
2080#endif /* CONFIG_FILS */
2081
2082
2083#ifdef EAP_SERVER
2084static unsigned int parse_tls_flags(const char *val)
2085{
2086 unsigned int flags = 0;
2087
2088 /* Disable TLS v1.3 by default for now to avoid interoperability issue.
2089 * This can be enabled by default once the implementation has been fully
2090 * completed and tested with other implementations. */
2091 flags |= TLS_CONN_DISABLE_TLSv1_3;
2092
2093 if (os_strstr(val, "[ALLOW-SIGN-RSA-MD5]"))
2094 flags |= TLS_CONN_ALLOW_SIGN_RSA_MD5;
2095 if (os_strstr(val, "[DISABLE-TIME-CHECKS]"))
2096 flags |= TLS_CONN_DISABLE_TIME_CHECKS;
2097 if (os_strstr(val, "[DISABLE-TLSv1.0]"))
2098 flags |= TLS_CONN_DISABLE_TLSv1_0;
2099 if (os_strstr(val, "[ENABLE-TLSv1.0]"))
2100 flags |= TLS_CONN_ENABLE_TLSv1_0;
2101 if (os_strstr(val, "[DISABLE-TLSv1.1]"))
2102 flags |= TLS_CONN_DISABLE_TLSv1_1;
2103 if (os_strstr(val, "[ENABLE-TLSv1.1]"))
2104 flags |= TLS_CONN_ENABLE_TLSv1_1;
2105 if (os_strstr(val, "[DISABLE-TLSv1.2]"))
2106 flags |= TLS_CONN_DISABLE_TLSv1_2;
2107 if (os_strstr(val, "[ENABLE-TLSv1.2]"))
2108 flags |= TLS_CONN_ENABLE_TLSv1_2;
2109 if (os_strstr(val, "[DISABLE-TLSv1.3]"))
2110 flags |= TLS_CONN_DISABLE_TLSv1_3;
2111 if (os_strstr(val, "[ENABLE-TLSv1.3]"))
2112 flags &= ~TLS_CONN_DISABLE_TLSv1_3;
2113 if (os_strstr(val, "[SUITEB]"))
2114 flags |= TLS_CONN_SUITEB;
2115 if (os_strstr(val, "[SUITEB-NO-ECDH]"))
2116 flags |= TLS_CONN_SUITEB_NO_ECDH | TLS_CONN_SUITEB;
2117
2118 return flags;
2119}
2120#endif /* EAP_SERVER */
2121
2122
2123#ifdef CONFIG_AIRTIME_POLICY
2124static int add_airtime_weight(struct hostapd_bss_config *bss, char *value)
2125{
2126 struct airtime_sta_weight *wt;
2127 char *pos, *next;
2128
2129 wt = os_zalloc(sizeof(*wt));
2130 if (!wt)
2131 return -1;
2132
2133 /* 02:01:02:03:04:05 10 */
2134 pos = value;
2135 next = os_strchr(pos, ' ');
2136 if (next)
2137 *next++ = '\0';
2138 if (!next || hwaddr_aton(pos, wt->addr)) {
2139 wpa_printf(MSG_ERROR, "Invalid station address: '%s'", pos);
2140 os_free(wt);
2141 return -1;
2142 }
2143
2144 pos = next;
2145 wt->weight = atoi(pos);
2146 if (!wt->weight) {
2147 wpa_printf(MSG_ERROR, "Invalid weight: '%s'", pos);
2148 os_free(wt);
2149 return -1;
2150 }
2151
2152 wt->next = bss->airtime_weight_list;
2153 bss->airtime_weight_list = wt;
2154 return 0;
2155}
2156#endif /* CONFIG_AIRTIME_POLICY */
2157
2158
2159#ifdef CONFIG_SAE
2160static int parse_sae_password(struct hostapd_bss_config *bss, const char *val)
2161{
2162 struct sae_password_entry *pw;
2163 const char *pos = val, *pos2, *end = NULL;
2164
2165 pw = os_zalloc(sizeof(*pw));
2166 if (!pw)
2167 return -1;
2168 os_memset(pw->peer_addr, 0xff, ETH_ALEN); /* default to wildcard */
2169
2170 pos2 = os_strstr(pos, "|mac=");
2171 if (pos2) {
2172 end = pos2;
2173 pos2 += 5;
2174 if (hwaddr_aton(pos2, pw->peer_addr) < 0)
2175 goto fail;
2176 pos = pos2 + ETH_ALEN * 3 - 1;
2177 }
2178
2179 pos2 = os_strstr(pos, "|vlanid=");
2180 if (pos2) {
2181 if (!end)
2182 end = pos2;
2183 pos2 += 8;
2184 pw->vlan_id = atoi(pos2);
2185 }
2186
2187#ifdef CONFIG_SAE_PK
2188 pos2 = os_strstr(pos, "|pk=");
2189 if (pos2) {
2190 const char *epos;
2191 char *tmp;
2192
2193 if (!end)
2194 end = pos2;
2195 pos2 += 4;
2196 epos = os_strchr(pos2, '|');
2197 if (epos) {
2198 tmp = os_malloc(epos - pos2 + 1);
2199 if (!tmp)
2200 goto fail;
2201 os_memcpy(tmp, pos2, epos - pos2);
2202 tmp[epos - pos2] = '\0';
2203 } else {
2204 tmp = os_strdup(pos2);
2205 if (!tmp)
2206 goto fail;
2207 }
2208
2209 pw->pk = sae_parse_pk(tmp);
2210 str_clear_free(tmp);
2211 if (!pw->pk)
2212 goto fail;
2213 }
2214#endif /* CONFIG_SAE_PK */
2215
2216 pos2 = os_strstr(pos, "|id=");
2217 if (pos2) {
2218 if (!end)
2219 end = pos2;
2220 pos2 += 4;
2221 pw->identifier = os_strdup(pos2);
2222 if (!pw->identifier)
2223 goto fail;
2224 }
2225
2226 if (!end) {
2227 pw->password = os_strdup(val);
2228 if (!pw->password)
2229 goto fail;
2230 } else {
2231 pw->password = os_malloc(end - val + 1);
2232 if (!pw->password)
2233 goto fail;
2234 os_memcpy(pw->password, val, end - val);
2235 pw->password[end - val] = '\0';
2236 }
2237
2238#ifdef CONFIG_SAE_PK
2239 if (pw->pk &&
2240#ifdef CONFIG_TESTING_OPTIONS
2241 !bss->sae_pk_password_check_skip &&
2242#endif /* CONFIG_TESTING_OPTIONS */
2243 !sae_pk_valid_password(pw->password)) {
2244 wpa_printf(MSG_INFO,
2245 "Invalid SAE password for a SAE-PK sae_password entry");
2246 goto fail;
2247 }
2248#endif /* CONFIG_SAE_PK */
2249
2250 pw->next = bss->sae_passwords;
2251 bss->sae_passwords = pw;
2252
2253 return 0;
2254fail:
2255 str_clear_free(pw->password);
2256 os_free(pw->identifier);
2257#ifdef CONFIG_SAE_PK
2258 sae_deinit_pk(pw->pk);
2259#endif /* CONFIG_SAE_PK */
2260 os_free(pw);
2261 return -1;
2262}
2263#endif /* CONFIG_SAE */
2264
2265
2266#ifdef CONFIG_DPP2
2267static int hostapd_dpp_controller_parse(struct hostapd_bss_config *bss,
2268 const char *pos)
2269{
2270 struct dpp_controller_conf *conf;
2271 char *val;
2272
2273 conf = os_zalloc(sizeof(*conf));
2274 if (!conf)
2275 return -1;
2276 val = get_param(pos, "ipaddr=");
2277 if (!val || hostapd_parse_ip_addr(val, &conf->ipaddr))
2278 goto fail;
2279 os_free(val);
2280 val = get_param(pos, "pkhash=");
2281 if (!val || os_strlen(val) != 2 * SHA256_MAC_LEN ||
2282 hexstr2bin(val, conf->pkhash, SHA256_MAC_LEN) < 0)
2283 goto fail;
2284 os_free(val);
2285 conf->next = bss->dpp_controller;
2286 bss->dpp_controller = conf;
2287 return 0;
2288fail:
2289 os_free(val);
2290 os_free(conf);
2291 return -1;
2292}
2293#endif /* CONFIG_DPP2 */
2294
2295
2296static int get_hex_config(u8 *buf, size_t max_len, int line,
2297 const char *field, const char *val)
2298{
2299 size_t hlen = os_strlen(val), len = hlen / 2;
2300 u8 tmp[EXT_CAPA_MAX_LEN];
2301
2302 os_memset(tmp, 0, EXT_CAPA_MAX_LEN);
2303 if (hlen & 1 || len > EXT_CAPA_MAX_LEN || hexstr2bin(val, tmp, len)) {
2304 wpa_printf(MSG_ERROR, "Line %d: Invalid %s", line, field);
2305 return -1;
2306 }
2307 os_memcpy(buf, tmp, EXT_CAPA_MAX_LEN);
2308 return 0;
2309}
2310
2311
2312static int hostapd_config_fill(struct hostapd_config *conf,
2313 struct hostapd_bss_config *bss,
2314 const char *buf, char *pos, int line)
2315{
2316 if (os_strcmp(buf, "interface") == 0) {
2317 os_strlcpy(conf->bss[0]->iface, pos,
2318 sizeof(conf->bss[0]->iface));
2319 } else if (os_strcmp(buf, "bridge") == 0) {
2320 os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
2321 if (!bss->wds_bridge[0])
2322 os_strlcpy(bss->wds_bridge, pos, sizeof(bss->wds_bridge));
2323 } else if (os_strcmp(buf, "bridge_hairpin") == 0) {
2324 bss->bridge_hairpin = atoi(pos);
2325 } else if (os_strcmp(buf, "snoop_iface") == 0) {
2326 os_strlcpy(bss->snoop_iface, pos, sizeof(bss->snoop_iface));
2327 } else if (os_strcmp(buf, "vlan_bridge") == 0) {
2328 os_strlcpy(bss->vlan_bridge, pos, sizeof(bss->vlan_bridge));
2329 } else if (os_strcmp(buf, "wds_bridge") == 0) {
2330 os_strlcpy(bss->wds_bridge, pos, sizeof(bss->wds_bridge));
2331 } else if (os_strcmp(buf, "driver") == 0) {
2332 int j;
2333 const struct wpa_driver_ops *driver = NULL;
2334
2335 for (j = 0; wpa_drivers[j]; j++) {
2336 if (os_strcmp(pos, wpa_drivers[j]->name) == 0) {
2337 driver = wpa_drivers[j];
2338 break;
2339 }
2340 }
2341 if (!driver) {
2342 wpa_printf(MSG_ERROR,
2343 "Line %d: invalid/unknown driver '%s'",
2344 line, pos);
2345 return 1;
2346 }
2347 conf->driver = driver;
2348 } else if (os_strcmp(buf, "driver_params") == 0) {
2349 os_free(conf->driver_params);
2350 conf->driver_params = os_strdup(pos);
2351 } else if (os_strcmp(buf, "debug") == 0) {
2352 wpa_printf(MSG_DEBUG, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore",
2353 line);
2354 } else if (os_strcmp(buf, "logger_syslog_level") == 0) {
2355 bss->logger_syslog_level = atoi(pos);
2356 } else if (os_strcmp(buf, "logger_stdout_level") == 0) {
2357 bss->logger_stdout_level = atoi(pos);
2358 } else if (os_strcmp(buf, "logger_syslog") == 0) {
2359 bss->logger_syslog = atoi(pos);
2360 } else if (os_strcmp(buf, "logger_stdout") == 0) {
2361 bss->logger_stdout = atoi(pos);
2362 } else if (os_strcmp(buf, "dump_file") == 0) {
2363 wpa_printf(MSG_INFO, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
2364 line);
2365 } else if (os_strcmp(buf, "ssid") == 0) {
2366 struct hostapd_ssid *ssid = &bss->ssid;
2367
2368 ssid->ssid_len = os_strlen(pos);
2369 if (ssid->ssid_len > SSID_MAX_LEN || ssid->ssid_len < 1) {
2370 wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'",
2371 line, pos);
2372 return 1;
2373 }
2374 os_memcpy(ssid->ssid, pos, ssid->ssid_len);
2375 ssid->ssid_set = 1;
2376 ssid->short_ssid = ieee80211_crc32(ssid->ssid, ssid->ssid_len);
2377 } else if (os_strcmp(buf, "ssid2") == 0) {
2378 struct hostapd_ssid *ssid = &bss->ssid;
2379 size_t slen;
2380 char *str = wpa_config_parse_string(pos, &slen);
2381 if (str == NULL || slen < 1 || slen > SSID_MAX_LEN) {
2382 wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'",
2383 line, pos);
2384 os_free(str);
2385 return 1;
2386 }
2387 os_memcpy(ssid->ssid, str, slen);
2388 ssid->ssid_len = slen;
2389 ssid->ssid_set = 1;
2390 ssid->short_ssid = ieee80211_crc32(ssid->ssid, ssid->ssid_len);
2391 os_free(str);
2392 } else if (os_strcmp(buf, "utf8_ssid") == 0) {
2393 bss->ssid.utf8_ssid = atoi(pos) > 0;
2394 } else if (os_strcmp(buf, "macaddr_acl") == 0) {
2395 enum macaddr_acl acl = atoi(pos);
2396
2397 if (acl != ACCEPT_UNLESS_DENIED &&
2398 acl != DENY_UNLESS_ACCEPTED &&
2399 acl != USE_EXTERNAL_RADIUS_AUTH) {
2400 wpa_printf(MSG_ERROR, "Line %d: unknown macaddr_acl %d",
2401 line, acl);
2402 return 1;
2403 }
2404 bss->macaddr_acl = acl;
2405 } else if (os_strcmp(buf, "accept_mac_file") == 0) {
2406 if (hostapd_config_read_maclist(pos, &bss->accept_mac,
2407 &bss->num_accept_mac)) {
2408 wpa_printf(MSG_ERROR, "Line %d: Failed to read accept_mac_file '%s'",
2409 line, pos);
2410 return 1;
2411 }
2412 } else if (os_strcmp(buf, "deny_mac_file") == 0) {
2413 if (hostapd_config_read_maclist(pos, &bss->deny_mac,
2414 &bss->num_deny_mac)) {
2415 wpa_printf(MSG_ERROR, "Line %d: Failed to read deny_mac_file '%s'",
2416 line, pos);
2417 return 1;
2418 }
2419 } else if (os_strcmp(buf, "wds_sta") == 0) {
2420 bss->wds_sta = atoi(pos);
2421 } else if (os_strcmp(buf, "start_disabled") == 0) {
2422 bss->start_disabled = atoi(pos);
2423 } else if (os_strcmp(buf, "ap_isolate") == 0) {
2424 bss->isolate = atoi(pos);
2425 } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
2426 bss->ap_max_inactivity = atoi(pos);
2427 } else if (os_strcmp(buf, "config_id") == 0) {
2428 bss->config_id = os_strdup(pos);
2429 } else if (os_strcmp(buf, "skip_inactivity_poll") == 0) {
2430 bss->skip_inactivity_poll = atoi(pos);
2431 } else if (os_strcmp(buf, "config_id") == 0) {
2432 os_free(bss->config_id);
2433 bss->config_id = os_strdup(pos);
2434 } else if (os_strcmp(buf, "country_code") == 0) {
2435 if (pos[0] < 'A' || pos[0] > 'Z' ||
2436 pos[1] < 'A' || pos[1] > 'Z') {
2437 wpa_printf(MSG_ERROR,
2438 "Line %d: Invalid country_code '%s'",
2439 line, pos);
2440 return 1;
2441 }
2442 os_memcpy(conf->country, pos, 2);
2443 } else if (os_strcmp(buf, "country3") == 0) {
2444 conf->country[2] = strtol(pos, NULL, 16);
2445 } else if (os_strcmp(buf, "ieee80211d") == 0) {
2446 conf->ieee80211d = atoi(pos);
2447 } else if (os_strcmp(buf, "ieee80211h") == 0) {
2448 conf->ieee80211h = atoi(pos);
2449 } else if (os_strcmp(buf, "ieee8021x") == 0) {
2450 bss->ieee802_1x = atoi(pos);
2451 } else if (os_strcmp(buf, "eapol_version") == 0) {
2452 int eapol_version = atoi(pos);
2453#ifdef CONFIG_MACSEC
2454 int max_ver = 3;
2455#else /* CONFIG_MACSEC */
2456 int max_ver = 2;
2457#endif /* CONFIG_MACSEC */
2458
2459 if (eapol_version < 1 || eapol_version > max_ver) {
2460 wpa_printf(MSG_ERROR,
2461 "Line %d: invalid EAPOL version (%d): '%s'.",
2462 line, eapol_version, pos);
2463 return 1;
2464 }
2465 bss->eapol_version = eapol_version;
2466 wpa_printf(MSG_DEBUG, "eapol_version=%d", bss->eapol_version);
2467#ifdef EAP_SERVER
2468 } else if (os_strcmp(buf, "eap_authenticator") == 0) {
2469 bss->eap_server = atoi(pos);
2470 wpa_printf(MSG_ERROR, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line);
2471 } else if (os_strcmp(buf, "eap_server") == 0) {
2472 bss->eap_server = atoi(pos);
2473 } else if (os_strcmp(buf, "eap_user_file") == 0) {
2474 if (hostapd_config_read_eap_user(pos, bss))
2475 return 1;
2476 } else if (os_strcmp(buf, "ca_cert") == 0) {
2477 os_free(bss->ca_cert);
2478 bss->ca_cert = os_strdup(pos);
2479 } else if (os_strcmp(buf, "server_cert") == 0) {
2480 os_free(bss->server_cert);
2481 bss->server_cert = os_strdup(pos);
2482 } else if (os_strcmp(buf, "server_cert2") == 0) {
2483 os_free(bss->server_cert2);
2484 bss->server_cert2 = os_strdup(pos);
2485 } else if (os_strcmp(buf, "private_key") == 0) {
2486 os_free(bss->private_key);
2487 bss->private_key = os_strdup(pos);
2488 } else if (os_strcmp(buf, "private_key2") == 0) {
2489 os_free(bss->private_key2);
2490 bss->private_key2 = os_strdup(pos);
2491 } else if (os_strcmp(buf, "private_key_passwd") == 0) {
2492 os_free(bss->private_key_passwd);
2493 bss->private_key_passwd = os_strdup(pos);
2494 } else if (os_strcmp(buf, "private_key_passwd2") == 0) {
2495 os_free(bss->private_key_passwd2);
2496 bss->private_key_passwd2 = os_strdup(pos);
2497 } else if (os_strcmp(buf, "check_cert_subject") == 0) {
2498 if (!pos[0]) {
2499 wpa_printf(MSG_ERROR, "Line %d: unknown check_cert_subject '%s'",
2500 line, pos);
2501 return 1;
2502 }
2503 os_free(bss->check_cert_subject);
2504 bss->check_cert_subject = os_strdup(pos);
2505 if (!bss->check_cert_subject)
2506 return 1;
2507 } else if (os_strcmp(buf, "check_crl") == 0) {
2508 bss->check_crl = atoi(pos);
2509 } else if (os_strcmp(buf, "check_crl_strict") == 0) {
2510 bss->check_crl_strict = atoi(pos);
2511 } else if (os_strcmp(buf, "crl_reload_interval") == 0) {
2512 bss->crl_reload_interval = atoi(pos);
2513 } else if (os_strcmp(buf, "tls_session_lifetime") == 0) {
2514 bss->tls_session_lifetime = atoi(pos);
2515 } else if (os_strcmp(buf, "tls_flags") == 0) {
2516 bss->tls_flags = parse_tls_flags(pos);
2517 } else if (os_strcmp(buf, "max_auth_rounds") == 0) {
2518 bss->max_auth_rounds = atoi(pos);
2519 } else if (os_strcmp(buf, "max_auth_rounds_short") == 0) {
2520 bss->max_auth_rounds_short = atoi(pos);
2521 } else if (os_strcmp(buf, "ocsp_stapling_response") == 0) {
2522 os_free(bss->ocsp_stapling_response);
2523 bss->ocsp_stapling_response = os_strdup(pos);
2524 } else if (os_strcmp(buf, "ocsp_stapling_response_multi") == 0) {
2525 os_free(bss->ocsp_stapling_response_multi);
2526 bss->ocsp_stapling_response_multi = os_strdup(pos);
2527 } else if (os_strcmp(buf, "dh_file") == 0) {
2528 os_free(bss->dh_file);
2529 bss->dh_file = os_strdup(pos);
2530 } else if (os_strcmp(buf, "openssl_ciphers") == 0) {
2531 os_free(bss->openssl_ciphers);
2532 bss->openssl_ciphers = os_strdup(pos);
2533 } else if (os_strcmp(buf, "openssl_ecdh_curves") == 0) {
2534 os_free(bss->openssl_ecdh_curves);
2535 bss->openssl_ecdh_curves = os_strdup(pos);
2536 } else if (os_strcmp(buf, "fragment_size") == 0) {
2537 bss->fragment_size = atoi(pos);
2538#ifdef EAP_SERVER_FAST
2539 } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
2540 os_free(bss->pac_opaque_encr_key);
2541 bss->pac_opaque_encr_key = os_malloc(16);
2542 if (bss->pac_opaque_encr_key == NULL) {
2543 wpa_printf(MSG_ERROR,
2544 "Line %d: No memory for pac_opaque_encr_key",
2545 line);
2546 return 1;
2547 } else if (hexstr2bin(pos, bss->pac_opaque_encr_key, 16)) {
2548 wpa_printf(MSG_ERROR, "Line %d: Invalid pac_opaque_encr_key",
2549 line);
2550 return 1;
2551 }
2552 } else if (os_strcmp(buf, "eap_fast_a_id") == 0) {
2553 size_t idlen = os_strlen(pos);
2554 if (idlen & 1) {
2555 wpa_printf(MSG_ERROR, "Line %d: Invalid eap_fast_a_id",
2556 line);
2557 return 1;
2558 }
2559 os_free(bss->eap_fast_a_id);
2560 bss->eap_fast_a_id = os_malloc(idlen / 2);
2561 if (bss->eap_fast_a_id == NULL ||
2562 hexstr2bin(pos, bss->eap_fast_a_id, idlen / 2)) {
2563 wpa_printf(MSG_ERROR, "Line %d: Failed to parse eap_fast_a_id",
2564 line);
2565 os_free(bss->eap_fast_a_id);
2566 bss->eap_fast_a_id = NULL;
2567 return 1;
2568 } else {
2569 bss->eap_fast_a_id_len = idlen / 2;
2570 }
2571 } else if (os_strcmp(buf, "eap_fast_a_id_info") == 0) {
2572 os_free(bss->eap_fast_a_id_info);
2573 bss->eap_fast_a_id_info = os_strdup(pos);
2574 } else if (os_strcmp(buf, "eap_fast_prov") == 0) {
2575 bss->eap_fast_prov = atoi(pos);
2576 } else if (os_strcmp(buf, "pac_key_lifetime") == 0) {
2577 bss->pac_key_lifetime = atoi(pos);
2578 } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) {
2579 bss->pac_key_refresh_time = atoi(pos);
2580#endif /* EAP_SERVER_FAST */
2581#ifdef EAP_SERVER_TEAP
2582 } else if (os_strcmp(buf, "eap_teap_auth") == 0) {
2583 int val = atoi(pos);
2584
2585 if (val < 0 || val > 2) {
2586 wpa_printf(MSG_ERROR,
2587 "Line %d: Invalid eap_teap_auth value",
2588 line);
2589 return 1;
2590 }
2591 bss->eap_teap_auth = val;
2592 } else if (os_strcmp(buf, "eap_teap_pac_no_inner") == 0) {
2593 bss->eap_teap_pac_no_inner = atoi(pos);
2594 } else if (os_strcmp(buf, "eap_teap_separate_result") == 0) {
2595 bss->eap_teap_separate_result = atoi(pos);
2596 } else if (os_strcmp(buf, "eap_teap_id") == 0) {
2597 bss->eap_teap_id = atoi(pos);
2598 } else if (os_strcmp(buf, "eap_teap_method_sequence") == 0) {
2599 bss->eap_teap_method_sequence = atoi(pos);
2600#endif /* EAP_SERVER_TEAP */
2601#ifdef EAP_SERVER_SIM
2602 } else if (os_strcmp(buf, "eap_sim_db") == 0) {
2603 os_free(bss->eap_sim_db);
2604 bss->eap_sim_db = os_strdup(pos);
2605 } else if (os_strcmp(buf, "eap_sim_db_timeout") == 0) {
2606 bss->eap_sim_db_timeout = atoi(pos);
2607 } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) {
2608 bss->eap_sim_aka_result_ind = atoi(pos);
2609 } else if (os_strcmp(buf, "eap_sim_id") == 0) {
2610 bss->eap_sim_id = atoi(pos);
2611 } else if (os_strcmp(buf, "imsi_privacy_key") == 0) {
2612 os_free(bss->imsi_privacy_key);
2613 bss->imsi_privacy_key = os_strdup(pos);
2614#endif /* EAP_SERVER_SIM */
2615#ifdef EAP_SERVER_TNC
2616 } else if (os_strcmp(buf, "tnc") == 0) {
2617 bss->tnc = atoi(pos);
2618#endif /* EAP_SERVER_TNC */
2619#ifdef EAP_SERVER_PWD
2620 } else if (os_strcmp(buf, "pwd_group") == 0) {
2621 bss->pwd_group = atoi(pos);
2622#endif /* EAP_SERVER_PWD */
2623#ifdef CONFIG_ERP
2624 } else if (os_strcmp(buf, "eap_server_erp") == 0) {
2625 bss->eap_server_erp = atoi(pos);
2626#endif /* CONFIG_ERP */
2627#endif /* EAP_SERVER */
2628 } else if (os_strcmp(buf, "eap_message") == 0) {
2629 char *term;
2630 os_free(bss->eap_req_id_text);
2631 bss->eap_req_id_text = os_strdup(pos);
2632 if (bss->eap_req_id_text == NULL) {
2633 wpa_printf(MSG_ERROR, "Line %d: Failed to allocate memory for eap_req_id_text",
2634 line);
2635 return 1;
2636 }
2637 bss->eap_req_id_text_len = os_strlen(bss->eap_req_id_text);
2638 term = os_strstr(bss->eap_req_id_text, "\\0");
2639 if (term) {
2640 *term++ = '\0';
2641 os_memmove(term, term + 1,
2642 bss->eap_req_id_text_len -
2643 (term - bss->eap_req_id_text) - 1);
2644 bss->eap_req_id_text_len--;
2645 }
2646 } else if (os_strcmp(buf, "erp_send_reauth_start") == 0) {
2647 bss->erp_send_reauth_start = atoi(pos);
2648 } else if (os_strcmp(buf, "erp_domain") == 0) {
2649 os_free(bss->erp_domain);
2650 bss->erp_domain = os_strdup(pos);
2651#ifdef CONFIG_WEP
2652 } else if (os_strcmp(buf, "wep_key_len_broadcast") == 0) {
2653 int val = atoi(pos);
2654
2655 if (val < 0 || val > 13) {
2656 wpa_printf(MSG_ERROR,
2657 "Line %d: invalid WEP key len %d (= %d bits)",
2658 line, val, val * 8);
2659 return 1;
2660 }
2661 bss->default_wep_key_len = val;
2662 } else if (os_strcmp(buf, "wep_key_len_unicast") == 0) {
2663 int val = atoi(pos);
2664
2665 if (val < 0 || val > 13) {
2666 wpa_printf(MSG_ERROR,
2667 "Line %d: invalid WEP key len %d (= %d bits)",
2668 line, val, val * 8);
2669 return 1;
2670 }
2671 bss->individual_wep_key_len = val;
2672 } else if (os_strcmp(buf, "wep_rekey_period") == 0) {
2673 bss->wep_rekeying_period = atoi(pos);
2674 if (bss->wep_rekeying_period < 0) {
2675 wpa_printf(MSG_ERROR, "Line %d: invalid period %d",
2676 line, bss->wep_rekeying_period);
2677 return 1;
2678 }
2679#endif /* CONFIG_WEP */
2680 } else if (os_strcmp(buf, "eap_reauth_period") == 0) {
2681 bss->eap_reauth_period = atoi(pos);
2682 if (bss->eap_reauth_period < 0) {
2683 wpa_printf(MSG_ERROR, "Line %d: invalid period %d",
2684 line, bss->eap_reauth_period);
2685 return 1;
2686 }
2687 } else if (os_strcmp(buf, "eapol_key_index_workaround") == 0) {
2688 bss->eapol_key_index_workaround = atoi(pos);
2689#ifdef CONFIG_IAPP
2690 } else if (os_strcmp(buf, "iapp_interface") == 0) {
2691 wpa_printf(MSG_INFO, "DEPRECATED: iapp_interface not used");
2692#endif /* CONFIG_IAPP */
2693 } else if (os_strcmp(buf, "dynamic_own_ip_addr") == 0) {
2694 bss->dynamic_own_ip_addr = atoi(pos);
2695 } else if (os_strcmp(buf, "own_ip_addr") == 0) {
2696 if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
2697 wpa_printf(MSG_ERROR,
2698 "Line %d: invalid IP address '%s'",
2699 line, pos);
2700 return 1;
2701 }
2702 } else if (os_strcmp(buf, "nas_identifier") == 0) {
2703 os_free(bss->nas_identifier);
2704 bss->nas_identifier = os_strdup(pos);
2705#ifndef CONFIG_NO_RADIUS
2706 } else if (os_strcmp(buf, "radius_client_addr") == 0) {
2707 if (hostapd_parse_ip_addr(pos, &bss->radius->client_addr)) {
2708 wpa_printf(MSG_ERROR,
2709 "Line %d: invalid IP address '%s'",
2710 line, pos);
2711 return 1;
2712 }
2713 bss->radius->force_client_addr = 1;
2714 } else if (os_strcmp(buf, "radius_client_dev") == 0) {
2715 os_free(bss->radius->force_client_dev);
2716 bss->radius->force_client_dev = os_strdup(pos);
2717 } else if (os_strcmp(buf, "auth_server_addr") == 0) {
2718 if (hostapd_config_read_radius_addr(
2719 &bss->radius->auth_servers,
2720 &bss->radius->num_auth_servers, pos, 1812,
2721 &bss->radius->auth_server)) {
2722 wpa_printf(MSG_ERROR,
2723 "Line %d: invalid IP address '%s'",
2724 line, pos);
2725 return 1;
2726 }
2727 } else if (bss->radius->auth_server &&
2728 os_strcmp(buf, "auth_server_addr_replace") == 0) {
2729 if (hostapd_parse_ip_addr(pos,
2730 &bss->radius->auth_server->addr)) {
2731 wpa_printf(MSG_ERROR,
2732 "Line %d: invalid IP address '%s'",
2733 line, pos);
2734 return 1;
2735 }
2736 } else if (bss->radius->auth_server &&
2737 os_strcmp(buf, "auth_server_port") == 0) {
2738 bss->radius->auth_server->port = atoi(pos);
2739 } else if (bss->radius->auth_server &&
2740 os_strcmp(buf, "auth_server_shared_secret") == 0) {
2741 int len = os_strlen(pos);
2742 if (len == 0) {
2743 /* RFC 2865, Ch. 3 */
2744 wpa_printf(MSG_ERROR, "Line %d: empty shared secret is not allowed",
2745 line);
2746 return 1;
2747 }
2748 os_free(bss->radius->auth_server->shared_secret);
2749 bss->radius->auth_server->shared_secret = (u8 *) os_strdup(pos);
2750 bss->radius->auth_server->shared_secret_len = len;
2751 } else if (os_strcmp(buf, "acct_server_addr") == 0) {
2752 if (hostapd_config_read_radius_addr(
2753 &bss->radius->acct_servers,
2754 &bss->radius->num_acct_servers, pos, 1813,
2755 &bss->radius->acct_server)) {
2756 wpa_printf(MSG_ERROR,
2757 "Line %d: invalid IP address '%s'",
2758 line, pos);
2759 return 1;
2760 }
2761 } else if (bss->radius->acct_server &&
2762 os_strcmp(buf, "acct_server_addr_replace") == 0) {
2763 if (hostapd_parse_ip_addr(pos,
2764 &bss->radius->acct_server->addr)) {
2765 wpa_printf(MSG_ERROR,
2766 "Line %d: invalid IP address '%s'",
2767 line, pos);
2768 return 1;
2769 }
2770 } else if (bss->radius->acct_server &&
2771 os_strcmp(buf, "acct_server_port") == 0) {
2772 bss->radius->acct_server->port = atoi(pos);
2773 } else if (bss->radius->acct_server &&
2774 os_strcmp(buf, "acct_server_shared_secret") == 0) {
2775 int len = os_strlen(pos);
2776 if (len == 0) {
2777 /* RFC 2865, Ch. 3 */
2778 wpa_printf(MSG_ERROR, "Line %d: empty shared secret is not allowed",
2779 line);
2780 return 1;
2781 }
2782 os_free(bss->radius->acct_server->shared_secret);
2783 bss->radius->acct_server->shared_secret = (u8 *) os_strdup(pos);
2784 bss->radius->acct_server->shared_secret_len = len;
2785 } else if (os_strcmp(buf, "radius_retry_primary_interval") == 0) {
2786 bss->radius->retry_primary_interval = atoi(pos);
2787 } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0) {
2788 bss->acct_interim_interval = atoi(pos);
2789 } else if (os_strcmp(buf, "radius_request_cui") == 0) {
2790 bss->radius_request_cui = atoi(pos);
2791 } else if (os_strcmp(buf, "radius_auth_req_attr") == 0) {
2792 struct hostapd_radius_attr *attr, *a;
2793 attr = hostapd_parse_radius_attr(pos);
2794 if (attr == NULL) {
2795 wpa_printf(MSG_ERROR,
2796 "Line %d: invalid radius_auth_req_attr",
2797 line);
2798 return 1;
2799 } else if (bss->radius_auth_req_attr == NULL) {
2800 bss->radius_auth_req_attr = attr;
2801 } else {
2802 a = bss->radius_auth_req_attr;
2803 while (a->next)
2804 a = a->next;
2805 a->next = attr;
2806 }
2807 } else if (os_strcmp(buf, "radius_acct_req_attr") == 0) {
2808 struct hostapd_radius_attr *attr, *a;
2809 attr = hostapd_parse_radius_attr(pos);
2810 if (attr == NULL) {
2811 wpa_printf(MSG_ERROR,
2812 "Line %d: invalid radius_acct_req_attr",
2813 line);
2814 return 1;
2815 } else if (bss->radius_acct_req_attr == NULL) {
2816 bss->radius_acct_req_attr = attr;
2817 } else {
2818 a = bss->radius_acct_req_attr;
2819 while (a->next)
2820 a = a->next;
2821 a->next = attr;
2822 }
2823 } else if (os_strcmp(buf, "radius_req_attr_sqlite") == 0) {
2824 os_free(bss->radius_req_attr_sqlite);
2825 bss->radius_req_attr_sqlite = os_strdup(pos);
2826 } else if (os_strcmp(buf, "radius_das_port") == 0) {
2827 bss->radius_das_port = atoi(pos);
2828 } else if (os_strcmp(buf, "radius_das_client") == 0) {
2829 if (hostapd_parse_das_client(bss, pos) < 0) {
2830 wpa_printf(MSG_ERROR, "Line %d: invalid DAS client",
2831 line);
2832 return 1;
2833 }
2834 } else if (os_strcmp(buf, "radius_das_time_window") == 0) {
2835 bss->radius_das_time_window = atoi(pos);
2836 } else if (os_strcmp(buf, "radius_das_require_event_timestamp") == 0) {
2837 bss->radius_das_require_event_timestamp = atoi(pos);
2838 } else if (os_strcmp(buf, "radius_das_require_message_authenticator") ==
2839 0) {
2840 bss->radius_das_require_message_authenticator = atoi(pos);
2841#endif /* CONFIG_NO_RADIUS */
2842 } else if (os_strcmp(buf, "auth_algs") == 0) {
2843 bss->auth_algs = atoi(pos);
2844 if (bss->auth_algs == 0) {
2845 wpa_printf(MSG_ERROR, "Line %d: no authentication algorithms allowed",
2846 line);
2847 return 1;
2848 }
2849 } else if (os_strcmp(buf, "max_num_sta") == 0) {
2850 bss->max_num_sta = atoi(pos);
2851 if (bss->max_num_sta < 0 ||
2852 bss->max_num_sta > MAX_STA_COUNT) {
2853 wpa_printf(MSG_ERROR, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2854 line, bss->max_num_sta, MAX_STA_COUNT);
2855 return 1;
2856 }
2857 } else if (os_strcmp(buf, "iface_max_num_sta") == 0) {
2858 conf->max_num_sta = atoi(pos);
2859 if (conf->max_num_sta < 0 ||
2860 conf->max_num_sta > MAX_STA_COUNT) {
2861 wpa_printf(MSG_ERROR, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2862 line, conf->max_num_sta, MAX_STA_COUNT);
2863 return 1;
2864 }
2865 } else if (os_strcmp(buf, "wpa") == 0) {
2866 bss->wpa = atoi(pos);
2867 } else if (os_strcmp(buf, "extended_key_id") == 0) {
2868 int val = atoi(pos);
2869
2870 if (val < 0 || val > 2) {
2871 wpa_printf(MSG_ERROR,
2872 "Line %d: Invalid extended_key_id=%d; allowed range 0..2",
2873 line, val);
2874 return 1;
2875 }
2876 bss->extended_key_id = val;
2877 } else if (os_strcmp(buf, "wpa_group_rekey") == 0) {
2878 bss->wpa_group_rekey = atoi(pos);
2879 bss->wpa_group_rekey_set = 1;
2880 } else if (os_strcmp(buf, "wpa_strict_rekey") == 0) {
2881 bss->wpa_strict_rekey = atoi(pos);
2882 } else if (os_strcmp(buf, "wpa_gmk_rekey") == 0) {
2883 bss->wpa_gmk_rekey = atoi(pos);
2884 } else if (os_strcmp(buf, "wpa_ptk_rekey") == 0) {
2885 bss->wpa_ptk_rekey = atoi(pos);
2886 } else if (os_strcmp(buf, "wpa_deny_ptk0_rekey") == 0) {
2887 bss->wpa_deny_ptk0_rekey = atoi(pos);
2888 if (bss->wpa_deny_ptk0_rekey < 0 ||
2889 bss->wpa_deny_ptk0_rekey > 2) {
2890 wpa_printf(MSG_ERROR,
2891 "Line %d: Invalid wpa_deny_ptk0_rekey=%d; allowed range 0..2",
2892 line, bss->wpa_deny_ptk0_rekey);
2893 return 1;
2894 }
2895 } else if (os_strcmp(buf, "wpa_group_update_count") == 0) {
2896 char *endp;
2897 unsigned long val = strtoul(pos, &endp, 0);
2898
2899 if (*endp || val < 1 || val > (u32) -1) {
2900 wpa_printf(MSG_ERROR,
2901 "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295",
2902 line, val);
2903 return 1;
2904 }
2905 bss->wpa_group_update_count = (u32) val;
2906 } else if (os_strcmp(buf, "wpa_pairwise_update_count") == 0) {
2907 char *endp;
2908 unsigned long val = strtoul(pos, &endp, 0);
2909
2910 if (*endp || val < 1 || val > (u32) -1) {
2911 wpa_printf(MSG_ERROR,
2912 "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295",
2913 line, val);
2914 return 1;
2915 }
2916 bss->wpa_pairwise_update_count = (u32) val;
2917 } else if (os_strcmp(buf, "wpa_disable_eapol_key_retries") == 0) {
2918 bss->wpa_disable_eapol_key_retries = atoi(pos);
2919 } else if (os_strcmp(buf, "wpa_passphrase") == 0) {
2920 int len = os_strlen(pos);
2921 if (len < 8 || len > 63) {
2922 wpa_printf(MSG_ERROR, "Line %d: invalid WPA passphrase length %d (expected 8..63)",
2923 line, len);
2924 return 1;
2925 }
2926 os_free(bss->ssid.wpa_passphrase);
2927 bss->ssid.wpa_passphrase = os_strdup(pos);
2928 if (bss->ssid.wpa_passphrase) {
2929 hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk);
2930 bss->ssid.wpa_passphrase_set = 1;
2931 }
2932 } else if (os_strcmp(buf, "wpa_psk") == 0) {
2933 hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk);
2934 bss->ssid.wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
2935 if (bss->ssid.wpa_psk == NULL)
2936 return 1;
2937 if (hexstr2bin(pos, bss->ssid.wpa_psk->psk, PMK_LEN) ||
2938 pos[PMK_LEN * 2] != '\0') {
2939 wpa_printf(MSG_ERROR, "Line %d: Invalid PSK '%s'.",
2940 line, pos);
2941 hostapd_config_clear_wpa_psk(&bss->ssid.wpa_psk);
2942 return 1;
2943 }
2944 bss->ssid.wpa_psk->group = 1;
2945 os_free(bss->ssid.wpa_passphrase);
2946 bss->ssid.wpa_passphrase = NULL;
2947 bss->ssid.wpa_psk_set = 1;
2948 } else if (os_strcmp(buf, "wpa_psk_file") == 0) {
2949 os_free(bss->ssid.wpa_psk_file);
2950 bss->ssid.wpa_psk_file = os_strdup(pos);
2951 if (!bss->ssid.wpa_psk_file) {
2952 wpa_printf(MSG_ERROR, "Line %d: allocation failed",
2953 line);
2954 return 1;
2955 }
2956 } else if (os_strcmp(buf, "wpa_key_mgmt") == 0) {
2957 bss->wpa_key_mgmt = hostapd_config_parse_key_mgmt(line, pos);
2958 if (bss->wpa_key_mgmt == -1)
2959 return 1;
2960 } else if (os_strcmp(buf, "wpa_psk_radius") == 0) {
2961 bss->wpa_psk_radius = atoi(pos);
2962 if (bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
2963 bss->wpa_psk_radius != PSK_RADIUS_ACCEPTED &&
2964 bss->wpa_psk_radius != PSK_RADIUS_REQUIRED &&
2965 bss->wpa_psk_radius != PSK_RADIUS_DURING_4WAY_HS) {
2966 wpa_printf(MSG_ERROR,
2967 "Line %d: unknown wpa_psk_radius %d",
2968 line, bss->wpa_psk_radius);
2969 return 1;
2970 }
2971 } else if (os_strcmp(buf, "wpa_pairwise") == 0) {
2972 bss->wpa_pairwise = hostapd_config_parse_cipher(line, pos);
2973 if (bss->wpa_pairwise == -1 || bss->wpa_pairwise == 0)
2974 return 1;
2975 if (bss->wpa_pairwise &
2976 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)) {
2977 wpa_printf(MSG_ERROR, "Line %d: unsupported pairwise cipher suite '%s'",
2978 line, pos);
2979 return 1;
2980 }
2981 } else if (os_strcmp(buf, "rsn_pairwise") == 0) {
2982 bss->rsn_pairwise = hostapd_config_parse_cipher(line, pos);
2983 if (bss->rsn_pairwise == -1 || bss->rsn_pairwise == 0)
2984 return 1;
2985 if (bss->rsn_pairwise &
2986 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 | WPA_CIPHER_WEP104)) {
2987 wpa_printf(MSG_ERROR, "Line %d: unsupported pairwise cipher suite '%s'",
2988 line, pos);
2989 return 1;
2990 }
2991 } else if (os_strcmp(buf, "group_cipher") == 0) {
2992 bss->group_cipher = hostapd_config_parse_cipher(line, pos);
2993 if (bss->group_cipher == -1 || bss->group_cipher == 0)
2994 return 1;
2995 if (bss->group_cipher != WPA_CIPHER_TKIP &&
2996 bss->group_cipher != WPA_CIPHER_CCMP &&
2997 bss->group_cipher != WPA_CIPHER_GCMP &&
2998 bss->group_cipher != WPA_CIPHER_GCMP_256 &&
2999 bss->group_cipher != WPA_CIPHER_CCMP_256) {
3000 wpa_printf(MSG_ERROR,
3001 "Line %d: unsupported group cipher suite '%s'",
3002 line, pos);
3003 return 1;
3004 }
3005#ifdef CONFIG_RSN_PREAUTH
3006 } else if (os_strcmp(buf, "rsn_preauth") == 0) {
3007 bss->rsn_preauth = atoi(pos);
3008 } else if (os_strcmp(buf, "rsn_preauth_interfaces") == 0) {
3009 os_free(bss->rsn_preauth_interfaces);
3010 bss->rsn_preauth_interfaces = os_strdup(pos);
3011#endif /* CONFIG_RSN_PREAUTH */
3012 } else if (os_strcmp(buf, "peerkey") == 0) {
3013 wpa_printf(MSG_INFO,
3014 "Line %d: Obsolete peerkey parameter ignored", line);
3015#ifdef CONFIG_IEEE80211R_AP
3016 } else if (os_strcmp(buf, "ft_iface") == 0) {
3017 os_strlcpy(bss->ft_iface, pos, sizeof(bss->ft_iface));
3018 } else if (os_strcmp(buf, "mobility_domain") == 0) {
3019 if (os_strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN ||
3020 hexstr2bin(pos, bss->mobility_domain,
3021 MOBILITY_DOMAIN_ID_LEN) != 0) {
3022 wpa_printf(MSG_ERROR,
3023 "Line %d: Invalid mobility_domain '%s'",
3024 line, pos);
3025 return 1;
3026 }
3027 } else if (os_strcmp(buf, "r1_key_holder") == 0) {
3028 if (os_strlen(pos) != 2 * FT_R1KH_ID_LEN ||
3029 hexstr2bin(pos, bss->r1_key_holder, FT_R1KH_ID_LEN) != 0) {
3030 wpa_printf(MSG_ERROR,
3031 "Line %d: Invalid r1_key_holder '%s'",
3032 line, pos);
3033 return 1;
3034 }
3035 } else if (os_strcmp(buf, "r0_key_lifetime") == 0) {
3036 /* DEPRECATED: Use ft_r0_key_lifetime instead. */
3037 bss->r0_key_lifetime = atoi(pos) * 60;
3038 } else if (os_strcmp(buf, "ft_r0_key_lifetime") == 0) {
3039 bss->r0_key_lifetime = atoi(pos);
3040 } else if (os_strcmp(buf, "r1_max_key_lifetime") == 0) {
3041 bss->r1_max_key_lifetime = atoi(pos);
3042 } else if (os_strcmp(buf, "reassociation_deadline") == 0) {
3043 bss->reassociation_deadline = atoi(pos);
3044 } else if (os_strcmp(buf, "rkh_pos_timeout") == 0) {
3045 bss->rkh_pos_timeout = atoi(pos);
3046 } else if (os_strcmp(buf, "rkh_neg_timeout") == 0) {
3047 bss->rkh_neg_timeout = atoi(pos);
3048 } else if (os_strcmp(buf, "rkh_pull_timeout") == 0) {
3049 bss->rkh_pull_timeout = atoi(pos);
3050 } else if (os_strcmp(buf, "rkh_pull_retries") == 0) {
3051 bss->rkh_pull_retries = atoi(pos);
3052 } else if (os_strcmp(buf, "r0kh") == 0) {
3053 if (add_r0kh(bss, pos) < 0) {
3054 wpa_printf(MSG_DEBUG, "Line %d: Invalid r0kh '%s'",
3055 line, pos);
3056 return 1;
3057 }
3058 } else if (os_strcmp(buf, "r1kh") == 0) {
3059 if (add_r1kh(bss, pos) < 0) {
3060 wpa_printf(MSG_DEBUG, "Line %d: Invalid r1kh '%s'",
3061 line, pos);
3062 return 1;
3063 }
3064 } else if (os_strcmp(buf, "pmk_r1_push") == 0) {
3065 bss->pmk_r1_push = atoi(pos);
3066 } else if (os_strcmp(buf, "ft_over_ds") == 0) {
3067 bss->ft_over_ds = atoi(pos);
3068 } else if (os_strcmp(buf, "ft_psk_generate_local") == 0) {
3069 bss->ft_psk_generate_local = atoi(pos);
3070#endif /* CONFIG_IEEE80211R_AP */
3071#ifndef CONFIG_NO_CTRL_IFACE
3072 } else if (os_strcmp(buf, "ctrl_interface") == 0) {
3073 os_free(bss->ctrl_interface);
3074 bss->ctrl_interface = os_strdup(pos);
3075 } else if (os_strcmp(buf, "ctrl_interface_group") == 0) {
3076#ifndef CONFIG_NATIVE_WINDOWS
3077 struct group *grp;
3078 char *endp;
3079 const char *group = pos;
3080
3081 grp = getgrnam(group);
3082 if (grp) {
3083 bss->ctrl_interface_gid = grp->gr_gid;
3084 bss->ctrl_interface_gid_set = 1;
3085 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d (from group name '%s')",
3086 bss->ctrl_interface_gid, group);
3087 return 0;
3088 }
3089
3090 /* Group name not found - try to parse this as gid */
3091 bss->ctrl_interface_gid = strtol(group, &endp, 10);
3092 if (*group == '\0' || *endp != '\0') {
3093 wpa_printf(MSG_DEBUG, "Line %d: Invalid group '%s'",
3094 line, group);
3095 return 1;
3096 }
3097 bss->ctrl_interface_gid_set = 1;
3098 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d",
3099 bss->ctrl_interface_gid);
3100#endif /* CONFIG_NATIVE_WINDOWS */
3101#endif /* CONFIG_NO_CTRL_IFACE */
3102#ifdef RADIUS_SERVER
3103 } else if (os_strcmp(buf, "radius_server_clients") == 0) {
3104 os_free(bss->radius_server_clients);
3105 bss->radius_server_clients = os_strdup(pos);
3106 } else if (os_strcmp(buf, "radius_server_auth_port") == 0) {
3107 bss->radius_server_auth_port = atoi(pos);
3108 } else if (os_strcmp(buf, "radius_server_acct_port") == 0) {
3109 bss->radius_server_acct_port = atoi(pos);
3110 } else if (os_strcmp(buf, "radius_server_ipv6") == 0) {
3111 bss->radius_server_ipv6 = atoi(pos);
3112#endif /* RADIUS_SERVER */
3113 } else if (os_strcmp(buf, "use_pae_group_addr") == 0) {
3114 bss->use_pae_group_addr = atoi(pos);
3115 } else if (os_strcmp(buf, "hw_mode") == 0) {
3116 if (os_strcmp(pos, "a") == 0)
3117 conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
3118 else if (os_strcmp(pos, "b") == 0)
3119 conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
3120 else if (os_strcmp(pos, "g") == 0)
3121 conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
3122 else if (os_strcmp(pos, "ad") == 0)
3123 conf->hw_mode = HOSTAPD_MODE_IEEE80211AD;
3124 else if (os_strcmp(pos, "any") == 0)
3125 conf->hw_mode = HOSTAPD_MODE_IEEE80211ANY;
3126 else {
3127 wpa_printf(MSG_ERROR, "Line %d: unknown hw_mode '%s'",
3128 line, pos);
3129 return 1;
3130 }
3131 conf->hw_mode_set = true;
3132 } else if (os_strcmp(buf, "wps_rf_bands") == 0) {
3133 if (os_strcmp(pos, "ad") == 0)
3134 bss->wps_rf_bands = WPS_RF_60GHZ;
3135 else if (os_strcmp(pos, "a") == 0)
3136 bss->wps_rf_bands = WPS_RF_50GHZ;
3137 else if (os_strcmp(pos, "g") == 0 ||
3138 os_strcmp(pos, "b") == 0)
3139 bss->wps_rf_bands = WPS_RF_24GHZ;
3140 else if (os_strcmp(pos, "ag") == 0 ||
3141 os_strcmp(pos, "ga") == 0)
3142 bss->wps_rf_bands = WPS_RF_24GHZ | WPS_RF_50GHZ;
3143 else {
3144 wpa_printf(MSG_ERROR,
3145 "Line %d: unknown wps_rf_band '%s'",
3146 line, pos);
3147 return 1;
3148 }
3149 } else if (os_strcmp(buf, "acs_exclude_dfs") == 0) {
3150 conf->acs_exclude_dfs = atoi(pos);
3151#ifdef CONFIG_DFS_CAC_TIMER
3152 } else if (os_strcmp(buf, "dfs_cac_s") == 0) {
3153 conf->dfs_cac_s = atoi(pos);
3154#endif /* CONFIG_DFS_CAC_TIMER */
3155 } else if (os_strcmp(buf, "radio_config_id") == 0) {
3156 conf->config_id = os_strdup(pos);
3157 } else if (os_strcmp(buf, "op_class") == 0) {
3158 conf->op_class = atoi(pos);
3159 } else if (os_strcmp(buf, "channel") == 0) {
3160 if (os_strcmp(pos, "acs_survey") == 0) {
3161#ifndef CONFIG_ACS
3162 wpa_printf(MSG_ERROR, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
3163 line);
3164 return 1;
3165#else /* CONFIG_ACS */
3166 conf->acs = 1;
3167 conf->channel = 0;
3168#endif /* CONFIG_ACS */
3169 } else {
3170 conf->channel = atoi(pos);
3171 conf->acs = conf->channel == 0;
3172 }
3173 } else if (os_strcmp(buf, "edmg_channel") == 0) {
3174 conf->edmg_channel = atoi(pos);
3175 } else if (os_strcmp(buf, "enable_edmg") == 0) {
3176 conf->enable_edmg = atoi(pos);
3177 } else if (os_strcmp(buf, "chanlist") == 0) {
3178 if (hostapd_parse_chanlist(conf, pos)) {
3179 wpa_printf(MSG_ERROR, "Line %d: invalid channel list",
3180 line);
3181 return 1;
3182 }
3183 } else if (os_strcmp(buf, "freqlist") == 0) {
3184 if (freq_range_list_parse(&conf->acs_freq_list, pos)) {
3185 wpa_printf(MSG_ERROR, "Line %d: invalid frequency list",
3186 line);
3187 return 1;
3188 }
3189 conf->acs_freq_list_present = 1;
3190 } else if (os_strcmp(buf, "acs_exclude_6ghz_non_psc") == 0) {
3191 conf->acs_exclude_6ghz_non_psc = atoi(pos);
3192 } else if (os_strcmp(buf, "enable_background_radar") == 0) {
3193 conf->enable_background_radar = atoi(pos);
3194 } else if (os_strcmp(buf, "min_tx_power") == 0) {
3195 int val = atoi(pos);
3196
3197 if (val < 0 || val > 255) {
3198 wpa_printf(MSG_ERROR,
3199 "Line %d: invalid min_tx_power %d (expected 0..255)",
3200 line, val);
3201 return 1;
3202 }
3203 conf->min_tx_power = val;
3204 } else if (os_strcmp(buf, "beacon_int") == 0) {
3205 int val = atoi(pos);
3206 /* MIB defines range as 1..65535, but very small values
3207 * cause problems with the current implementation.
3208 * Since it is unlikely that this small numbers are
3209 * useful in real life scenarios, do not allow beacon
3210 * period to be set below 10 TU. */
3211 if (val < 10 || val > 65535) {
3212 wpa_printf(MSG_ERROR,
3213 "Line %d: invalid beacon_int %d (expected 10..65535)",
3214 line, val);
3215 return 1;
3216 }
3217 conf->beacon_int = val;
3218#ifdef CONFIG_ACS
3219 } else if (os_strcmp(buf, "acs_num_scans") == 0) {
3220 int val = atoi(pos);
3221 if (val <= 0 || val > 100) {
3222 wpa_printf(MSG_ERROR, "Line %d: invalid acs_num_scans %d (expected 1..100)",
3223 line, val);
3224 return 1;
3225 }
3226 conf->acs_num_scans = val;
3227 } else if (os_strcmp(buf, "acs_chan_bias") == 0) {
3228 if (hostapd_config_parse_acs_chan_bias(conf, pos)) {
3229 wpa_printf(MSG_ERROR, "Line %d: invalid acs_chan_bias",
3230 line);
3231 return -1;
3232 }
3233#endif /* CONFIG_ACS */
3234 } else if (os_strcmp(buf, "dtim_period") == 0) {
3235 int val = atoi(pos);
3236
3237 if (val < 1 || val > 255) {
3238 wpa_printf(MSG_ERROR, "Line %d: invalid dtim_period %d",
3239 line, val);
3240 return 1;
3241 }
3242 bss->dtim_period = val;
3243 } else if (os_strcmp(buf, "bss_load_update_period") == 0) {
3244 int val = atoi(pos);
3245
3246 if (val < 0 || val > 100) {
3247 wpa_printf(MSG_ERROR,
3248 "Line %d: invalid bss_load_update_period %d",
3249 line, val);
3250 return 1;
3251 }
3252 bss->bss_load_update_period = val;
3253 } else if (os_strcmp(buf, "chan_util_avg_period") == 0) {
3254 int val = atoi(pos);
3255
3256 if (val < 0) {
3257 wpa_printf(MSG_ERROR,
3258 "Line %d: invalid chan_util_avg_period",
3259 line);
3260 return 1;
3261 }
3262 bss->chan_util_avg_period = val;
3263 } else if (os_strcmp(buf, "rts_threshold") == 0) {
3264 conf->rts_threshold = atoi(pos);
3265 if (conf->rts_threshold < -1 || conf->rts_threshold > 65535) {
3266 wpa_printf(MSG_ERROR,
3267 "Line %d: invalid rts_threshold %d",
3268 line, conf->rts_threshold);
3269 return 1;
3270 }
3271 } else if (os_strcmp(buf, "fragm_threshold") == 0) {
3272 conf->fragm_threshold = atoi(pos);
3273 if (conf->fragm_threshold == -1) {
3274 /* allow a value of -1 */
3275 } else if (conf->fragm_threshold < 256 ||
3276 conf->fragm_threshold > 2346) {
3277 wpa_printf(MSG_ERROR,
3278 "Line %d: invalid fragm_threshold %d",
3279 line, conf->fragm_threshold);
3280 return 1;
3281 }
3282 } else if (os_strcmp(buf, "send_probe_response") == 0) {
3283 int val = atoi(pos);
3284 if (val != 0 && val != 1) {
3285 wpa_printf(MSG_ERROR, "Line %d: invalid send_probe_response %d (expected 0 or 1)",
3286 line, val);
3287 return 1;
3288 }
3289 bss->send_probe_response = val;
3290 } else if (os_strcmp(buf, "supported_rates") == 0) {
3291 if (hostapd_parse_intlist(&conf->supported_rates, pos)) {
3292 wpa_printf(MSG_ERROR, "Line %d: invalid rate list",
3293 line);
3294 return 1;
3295 }
3296 } else if (os_strcmp(buf, "basic_rates") == 0) {
3297 if (hostapd_parse_intlist(&conf->basic_rates, pos)) {
3298 wpa_printf(MSG_ERROR, "Line %d: invalid rate list",
3299 line);
3300 return 1;
3301 }
3302 } else if (os_strcmp(buf, "beacon_rate") == 0) {
3303 int val;
3304
3305 if (os_strncmp(pos, "ht:", 3) == 0) {
3306 val = atoi(pos + 3);
3307 if (val < 0 || val > 31) {
3308 wpa_printf(MSG_ERROR,
3309 "Line %d: invalid beacon_rate HT-MCS %d",
3310 line, val);
3311 return 1;
3312 }
3313 conf->rate_type = BEACON_RATE_HT;
3314 conf->beacon_rate = val;
3315 } else if (os_strncmp(pos, "vht:", 4) == 0) {
3316 val = atoi(pos + 4);
3317 if (val < 0 || val > 9) {
3318 wpa_printf(MSG_ERROR,
3319 "Line %d: invalid beacon_rate VHT-MCS %d",
3320 line, val);
3321 return 1;
3322 }
3323 conf->rate_type = BEACON_RATE_VHT;
3324 conf->beacon_rate = val;
3325 } else if (os_strncmp(pos, "he:", 3) == 0) {
3326 val = atoi(pos + 3);
3327 if (val < 0 || val > 11) {
3328 wpa_printf(MSG_ERROR,
3329 "Line %d: invalid beacon_rate HE-MCS %d",
3330 line, val);
3331 return 1;
3332 }
3333 conf->rate_type = BEACON_RATE_HE;
3334 conf->beacon_rate = val;
3335 } else {
3336 val = atoi(pos);
3337 if (val < 10 || val > 10000) {
3338 wpa_printf(MSG_ERROR,
3339 "Line %d: invalid legacy beacon_rate %d",
3340 line, val);
3341 return 1;
3342 }
3343 conf->rate_type = BEACON_RATE_LEGACY;
3344 conf->beacon_rate = val;
3345 }
3346 } else if (os_strcmp(buf, "preamble") == 0) {
3347 if (atoi(pos))
3348 conf->preamble = SHORT_PREAMBLE;
3349 else
3350 conf->preamble = LONG_PREAMBLE;
3351 } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) {
3352 bss->ignore_broadcast_ssid = atoi(pos);
3353 } else if (os_strcmp(buf, "no_probe_resp_if_max_sta") == 0) {
3354 bss->no_probe_resp_if_max_sta = atoi(pos);
3355#ifdef CONFIG_WEP
3356 } else if (os_strcmp(buf, "wep_default_key") == 0) {
3357 bss->ssid.wep.idx = atoi(pos);
3358 if (bss->ssid.wep.idx > 3) {
3359 wpa_printf(MSG_ERROR,
3360 "Invalid wep_default_key index %d",
3361 bss->ssid.wep.idx);
3362 return 1;
3363 }
3364 } else if (os_strcmp(buf, "wep_key0") == 0 ||
3365 os_strcmp(buf, "wep_key1") == 0 ||
3366 os_strcmp(buf, "wep_key2") == 0 ||
3367 os_strcmp(buf, "wep_key3") == 0) {
3368 if (hostapd_config_read_wep(&bss->ssid.wep,
3369 buf[7] - '0', pos)) {
3370 wpa_printf(MSG_ERROR, "Line %d: invalid WEP key '%s'",
3371 line, buf);
3372 return 1;
3373 }
3374#endif /* CONFIG_WEP */
3375#ifndef CONFIG_NO_VLAN
3376 } else if (os_strcmp(buf, "dynamic_vlan") == 0) {
3377 bss->ssid.dynamic_vlan = atoi(pos);
3378 } else if (os_strcmp(buf, "vlan_no_bridge") == 0) {
3379 bss->ssid.vlan_no_bridge = atoi(pos);
3380 } else if (os_strcmp(buf, "per_sta_vif") == 0) {
3381 bss->ssid.per_sta_vif = atoi(pos);
3382 } else if (os_strcmp(buf, "vlan_file") == 0) {
3383 if (hostapd_config_read_vlan_file(bss, pos)) {
3384 wpa_printf(MSG_ERROR, "Line %d: failed to read VLAN file '%s'",
3385 line, pos);
3386 return 1;
3387 }
3388 } else if (os_strcmp(buf, "vlan_naming") == 0) {
3389 bss->ssid.vlan_naming = atoi(pos);
3390 if (bss->ssid.vlan_naming >= DYNAMIC_VLAN_NAMING_END ||
3391 bss->ssid.vlan_naming < 0) {
3392 wpa_printf(MSG_ERROR,
3393 "Line %d: invalid naming scheme %d",
3394 line, bss->ssid.vlan_naming);
3395 return 1;
3396 }
3397#ifdef CONFIG_FULL_DYNAMIC_VLAN
3398 } else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
3399 os_free(bss->ssid.vlan_tagged_interface);
3400 bss->ssid.vlan_tagged_interface = os_strdup(pos);
3401#endif /* CONFIG_FULL_DYNAMIC_VLAN */
3402#endif /* CONFIG_NO_VLAN */
3403 } else if (os_strcmp(buf, "ap_table_max_size") == 0) {
3404 conf->ap_table_max_size = atoi(pos);
3405 } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) {
3406 conf->ap_table_expiration_time = atoi(pos);
3407 } else if (os_strncmp(buf, "tx_queue_", 9) == 0) {
3408 if (hostapd_config_tx_queue(conf->tx_queue, buf, pos)) {
3409 wpa_printf(MSG_ERROR, "Line %d: invalid TX queue item",
3410 line);
3411 return 1;
3412 }
3413 } else if (os_strcmp(buf, "wme_enabled") == 0 ||
3414 os_strcmp(buf, "wmm_enabled") == 0) {
3415 bss->wmm_enabled = atoi(pos);
3416 } else if (os_strcmp(buf, "uapsd_advertisement_enabled") == 0) {
3417 bss->wmm_uapsd = atoi(pos);
3418 } else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
3419 os_strncmp(buf, "wmm_ac_", 7) == 0) {
3420 if (hostapd_config_wmm_ac(conf->wmm_ac_params, buf, pos)) {
3421 wpa_printf(MSG_ERROR, "Line %d: invalid WMM ac item",
3422 line);
3423 return 1;
3424 }
3425 } else if (os_strcmp(buf, "bss") == 0) {
3426 if (hostapd_config_bss(conf, pos)) {
3427 wpa_printf(MSG_ERROR, "Line %d: invalid bss item",
3428 line);
3429 return 1;
3430 }
3431 } else if (os_strcmp(buf, "bssid") == 0) {
3432 if (hwaddr_aton(pos, bss->bssid)) {
3433 wpa_printf(MSG_ERROR, "Line %d: invalid bssid item",
3434 line);
3435 return 1;
3436 }
3437 } else if (os_strcmp(buf, "use_driver_iface_addr") == 0) {
3438 conf->use_driver_iface_addr = atoi(pos);
3439 } else if (os_strcmp(buf, "ieee80211w") == 0) {
3440 bss->ieee80211w = atoi(pos);
3441 } else if (os_strcmp(buf, "group_mgmt_cipher") == 0) {
3442 if (os_strcmp(pos, "AES-128-CMAC") == 0) {
3443 bss->group_mgmt_cipher = WPA_CIPHER_AES_128_CMAC;
3444 } else if (os_strcmp(pos, "BIP-GMAC-128") == 0) {
3445 bss->group_mgmt_cipher = WPA_CIPHER_BIP_GMAC_128;
3446 } else if (os_strcmp(pos, "BIP-GMAC-256") == 0) {
3447 bss->group_mgmt_cipher = WPA_CIPHER_BIP_GMAC_256;
3448 } else if (os_strcmp(pos, "BIP-CMAC-256") == 0) {
3449 bss->group_mgmt_cipher = WPA_CIPHER_BIP_CMAC_256;
3450 } else {
3451 wpa_printf(MSG_ERROR, "Line %d: invalid group_mgmt_cipher: %s",
3452 line, pos);
3453 return 1;
3454 }
3455 } else if (os_strcmp(buf, "beacon_prot") == 0) {
3456 bss->beacon_prot = atoi(pos);
3457 } else if (os_strcmp(buf, "assoc_sa_query_max_timeout") == 0) {
3458 bss->assoc_sa_query_max_timeout = atoi(pos);
3459 if (bss->assoc_sa_query_max_timeout == 0) {
3460 wpa_printf(MSG_ERROR, "Line %d: invalid assoc_sa_query_max_timeout",
3461 line);
3462 return 1;
3463 }
3464 } else if (os_strcmp(buf, "assoc_sa_query_retry_timeout") == 0) {
3465 bss->assoc_sa_query_retry_timeout = atoi(pos);
3466 if (bss->assoc_sa_query_retry_timeout == 0) {
3467 wpa_printf(MSG_ERROR, "Line %d: invalid assoc_sa_query_retry_timeout",
3468 line);
3469 return 1;
3470 }
3471#ifdef CONFIG_OCV
3472 } else if (os_strcmp(buf, "ocv") == 0) {
3473 bss->ocv = atoi(pos);
3474 if (bss->ocv && !bss->ieee80211w)
3475 bss->ieee80211w = 1;
3476#endif /* CONFIG_OCV */
3477 } else if (os_strcmp(buf, "noscan") == 0) {
3478 conf->noscan = atoi(pos);
3479 } else if (os_strcmp(buf, "ht_coex") == 0) {
3480 conf->no_ht_coex = !atoi(pos);
3481 } else if (os_strcmp(buf, "ieee80211n") == 0) {
3482 conf->ieee80211n = atoi(pos);
3483 } else if (os_strcmp(buf, "ht_capab") == 0) {
3484 if (hostapd_config_ht_capab(conf, pos) < 0) {
3485 wpa_printf(MSG_ERROR, "Line %d: invalid ht_capab",
3486 line);
3487 return 1;
3488 }
3489 } else if (os_strcmp(buf, "require_ht") == 0) {
3490 conf->require_ht = atoi(pos);
3491#ifdef CONFIG_24G_BW_SWITCH
3492 } else if (os_strcmp(buf, "auto_20m_40m") == 0) {
3493 conf->auto_20m_40m = atoi(pos);
3494#endif /* CONFIG_24G_BW_SWITCH */
3495#ifdef CONFIG_5G_BW_SWITCH
3496 }else if (os_strcmp(buf, "auto_80m") == 0) {
3497 conf->auto_80m = atoi(pos);
3498#endif /* CONFIG_5G_BW_SWITCH */
3499 } else if (os_strcmp(buf, "obss_interval") == 0) {
3500 conf->obss_interval = atoi(pos);
3501#ifdef CONFIG_IEEE80211AC
3502 } else if (os_strcmp(buf, "ieee80211ac") == 0) {
3503 conf->ieee80211ac = atoi(pos);
3504 } else if (os_strcmp(buf, "vht_capab") == 0) {
3505 if (hostapd_config_vht_capab(conf, pos) < 0) {
3506 wpa_printf(MSG_ERROR, "Line %d: invalid vht_capab",
3507 line);
3508 return 1;
3509 }
3510 } else if (os_strcmp(buf, "require_vht") == 0) {
3511 conf->require_vht = atoi(pos);
3512 } else if (os_strcmp(buf, "vht_oper_chwidth") == 0) {
3513 conf->vht_oper_chwidth = atoi(pos);
3514 } else if (os_strcmp(buf, "vht_oper_centr_freq_seg0_idx") == 0) {
3515 conf->vht_oper_centr_freq_seg0_idx = atoi(pos);
3516 } else if (os_strcmp(buf, "vht_oper_centr_freq_seg1_idx") == 0) {
3517 conf->vht_oper_centr_freq_seg1_idx = atoi(pos);
3518 } else if (os_strcmp(buf, "vendor_vht") == 0) {
3519 bss->vendor_vht = atoi(pos);
3520 } else if (os_strcmp(buf, "use_sta_nsts") == 0) {
3521 bss->use_sta_nsts = atoi(pos);
3522#endif /* CONFIG_IEEE80211AC */
3523#ifdef CONFIG_IEEE80211AX
3524 } else if (os_strcmp(buf, "ieee80211ax") == 0) {
3525 conf->ieee80211ax = atoi(pos);
3526 } else if (os_strcmp(buf, "require_he") == 0) {
3527 conf->require_he = atoi(pos);
3528 } else if (os_strcmp(buf, "he_su_beamformer") == 0) {
3529 conf->he_phy_capab.he_su_beamformer = atoi(pos);
3530 } else if (os_strcmp(buf, "he_su_beamformee") == 0) {
3531 conf->he_phy_capab.he_su_beamformee = atoi(pos);
3532 } else if (os_strcmp(buf, "he_mu_beamformer") == 0) {
3533 conf->he_phy_capab.he_mu_beamformer = atoi(pos);
3534 } else if (os_strcmp(buf, "he_bss_color") == 0) {
3535 conf->he_op.he_bss_color = atoi(pos) & 0x3f;
3536 conf->he_op.he_bss_color_disabled = 0;
3537 if (atoi(pos) > 63)
3538 conf->he_op.he_bss_color = os_random() % 63 + 1;
3539 } else if (os_strcmp(buf, "he_bss_color_partial") == 0) {
3540 conf->he_op.he_bss_color_partial = atoi(pos);
3541 } else if (os_strcmp(buf, "he_default_pe_duration") == 0) {
3542 conf->he_op.he_default_pe_duration = atoi(pos);
3543 } else if (os_strcmp(buf, "he_twt_required") == 0) {
3544 conf->he_op.he_twt_required = atoi(pos);
3545 } else if (os_strcmp(buf, "he_twt_responder") == 0) {
3546 conf->he_op.he_twt_responder = atoi(pos);
3547 } else if (os_strcmp(buf, "he_rts_threshold") == 0) {
3548 conf->he_op.he_rts_threshold = atoi(pos);
3549 } else if (os_strcmp(buf, "he_er_su_disable") == 0) {
3550 conf->he_op.he_er_su_disable = atoi(pos);
3551 } else if (os_strcmp(buf, "he_basic_mcs_nss_set") == 0) {
3552 conf->he_op.he_basic_mcs_nss_set = atoi(pos);
3553 } else if (os_strcmp(buf, "he_mu_edca_qos_info_param_count") == 0) {
3554 conf->he_mu_edca.he_qos_info |=
3555 set_he_cap(atoi(pos), HE_QOS_INFO_EDCA_PARAM_SET_COUNT);
3556 } else if (os_strcmp(buf, "he_mu_edca_qos_info_q_ack") == 0) {
3557 conf->he_mu_edca.he_qos_info |=
3558 set_he_cap(atoi(pos), HE_QOS_INFO_Q_ACK);
3559 } else if (os_strcmp(buf, "he_mu_edca_qos_info_queue_request") == 0) {
3560 conf->he_mu_edca.he_qos_info |=
3561 set_he_cap(atoi(pos), HE_QOS_INFO_QUEUE_REQUEST);
3562 } else if (os_strcmp(buf, "he_mu_edca_qos_info_txop_request") == 0) {
3563 conf->he_mu_edca.he_qos_info |=
3564 set_he_cap(atoi(pos), HE_QOS_INFO_TXOP_REQUEST);
3565 } else if (os_strcmp(buf, "he_mu_edca_ac_be_aifsn") == 0) {
3566 conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ACI_IDX] |=
3567 set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN);
3568 } else if (os_strcmp(buf, "he_mu_edca_ac_be_acm") == 0) {
3569 conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ACI_IDX] |=
3570 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM);
3571 } else if (os_strcmp(buf, "he_mu_edca_ac_be_aci") == 0) {
3572 conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ACI_IDX] |=
3573 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI);
3574 } else if (os_strcmp(buf, "he_mu_edca_ac_be_ecwmin") == 0) {
3575 conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ECW_IDX] |=
3576 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN);
3577 } else if (os_strcmp(buf, "he_mu_edca_ac_be_ecwmax") == 0) {
3578 conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_ECW_IDX] |=
3579 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX);
3580 } else if (os_strcmp(buf, "he_mu_edca_ac_be_timer") == 0) {
3581 conf->he_mu_edca.he_mu_ac_be_param[HE_MU_AC_PARAM_TIMER_IDX] =
3582 atoi(pos) & 0xff;
3583 } else if (os_strcmp(buf, "he_mu_edca_ac_bk_aifsn") == 0) {
3584 conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ACI_IDX] |=
3585 set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN);
3586 } else if (os_strcmp(buf, "he_mu_edca_ac_bk_acm") == 0) {
3587 conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ACI_IDX] |=
3588 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM);
3589 } else if (os_strcmp(buf, "he_mu_edca_ac_bk_aci") == 0) {
3590 conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ACI_IDX] |=
3591 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI);
3592 } else if (os_strcmp(buf, "he_mu_edca_ac_bk_ecwmin") == 0) {
3593 conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ECW_IDX] |=
3594 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN);
3595 } else if (os_strcmp(buf, "he_mu_edca_ac_bk_ecwmax") == 0) {
3596 conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_ECW_IDX] |=
3597 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX);
3598 } else if (os_strcmp(buf, "he_mu_edca_ac_bk_timer") == 0) {
3599 conf->he_mu_edca.he_mu_ac_bk_param[HE_MU_AC_PARAM_TIMER_IDX] =
3600 atoi(pos) & 0xff;
3601 } else if (os_strcmp(buf, "he_mu_edca_ac_vi_aifsn") == 0) {
3602 conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ACI_IDX] |=
3603 set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN);
3604 } else if (os_strcmp(buf, "he_mu_edca_ac_vi_acm") == 0) {
3605 conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ACI_IDX] |=
3606 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM);
3607 } else if (os_strcmp(buf, "he_mu_edca_ac_vi_aci") == 0) {
3608 conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ACI_IDX] |=
3609 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI);
3610 } else if (os_strcmp(buf, "he_mu_edca_ac_vi_ecwmin") == 0) {
3611 conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ECW_IDX] |=
3612 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN);
3613 } else if (os_strcmp(buf, "he_mu_edca_ac_vi_ecwmax") == 0) {
3614 conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_ECW_IDX] |=
3615 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX);
3616 } else if (os_strcmp(buf, "he_mu_edca_ac_vi_timer") == 0) {
3617 conf->he_mu_edca.he_mu_ac_vi_param[HE_MU_AC_PARAM_TIMER_IDX] =
3618 atoi(pos) & 0xff;
3619 } else if (os_strcmp(buf, "he_mu_edca_ac_vo_aifsn") == 0) {
3620 conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ACI_IDX] |=
3621 set_he_cap(atoi(pos), HE_MU_AC_PARAM_AIFSN);
3622 } else if (os_strcmp(buf, "he_mu_edca_ac_vo_acm") == 0) {
3623 conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ACI_IDX] |=
3624 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACM);
3625 } else if (os_strcmp(buf, "he_mu_edca_ac_vo_aci") == 0) {
3626 conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ACI_IDX] |=
3627 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ACI);
3628 } else if (os_strcmp(buf, "he_mu_edca_ac_vo_ecwmin") == 0) {
3629 conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ECW_IDX] |=
3630 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMIN);
3631 } else if (os_strcmp(buf, "he_mu_edca_ac_vo_ecwmax") == 0) {
3632 conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_ECW_IDX] |=
3633 set_he_cap(atoi(pos), HE_MU_AC_PARAM_ECWMAX);
3634 } else if (os_strcmp(buf, "he_mu_edca_ac_vo_timer") == 0) {
3635 conf->he_mu_edca.he_mu_ac_vo_param[HE_MU_AC_PARAM_TIMER_IDX] =
3636 atoi(pos) & 0xff;
3637 } else if (os_strcmp(buf, "he_spr_sr_control") == 0) {
3638 conf->spr.sr_control = atoi(pos) & 0x1f;
3639 } else if (os_strcmp(buf, "he_spr_non_srg_obss_pd_max_offset") == 0) {
3640 conf->spr.non_srg_obss_pd_max_offset = atoi(pos);
3641 } else if (os_strcmp(buf, "he_spr_srg_obss_pd_min_offset") == 0) {
3642 conf->spr.srg_obss_pd_min_offset = atoi(pos);
3643 } else if (os_strcmp(buf, "he_spr_srg_obss_pd_max_offset") == 0) {
3644 conf->spr.srg_obss_pd_max_offset = atoi(pos);
3645 } else if (os_strcmp(buf, "he_spr_srg_bss_colors") == 0) {
3646 if (hostapd_parse_he_srg_bitmap(
3647 conf->spr.srg_bss_color_bitmap, pos)) {
3648 wpa_printf(MSG_ERROR,
3649 "Line %d: Invalid srg bss colors list '%s'",
3650 line, pos);
3651 return 1;
3652 }
3653 } else if (os_strcmp(buf, "he_spr_srg_partial_bssid") == 0) {
3654 if (hostapd_parse_he_srg_bitmap(
3655 conf->spr.srg_partial_bssid_bitmap, pos)) {
3656 wpa_printf(MSG_ERROR,
3657 "Line %d: Invalid srg partial bssid list '%s'",
3658 line, pos);
3659 return 1;
3660 }
3661 } else if (os_strcmp(buf, "he_6ghz_reg_pwr_type") == 0) {
3662 conf->he_6ghz_reg_pwr_type = atoi(pos);
3663 } else if (os_strcmp(buf, "he_oper_chwidth") == 0) {
3664 conf->he_oper_chwidth = atoi(pos);
3665 } else if (os_strcmp(buf, "he_oper_centr_freq_seg0_idx") == 0) {
3666 conf->he_oper_centr_freq_seg0_idx = atoi(pos);
3667 } else if (os_strcmp(buf, "he_oper_centr_freq_seg1_idx") == 0) {
3668 conf->he_oper_centr_freq_seg1_idx = atoi(pos);
3669 } else if (os_strcmp(buf, "he_6ghz_max_mpdu") == 0) {
3670 conf->he_6ghz_max_mpdu = atoi(pos);
3671 } else if (os_strcmp(buf, "he_6ghz_max_ampdu_len_exp") == 0) {
3672 conf->he_6ghz_max_ampdu_len_exp = atoi(pos);
3673 } else if (os_strcmp(buf, "he_6ghz_rx_ant_pat") == 0) {
3674 conf->he_6ghz_rx_ant_pat = atoi(pos);
3675 } else if (os_strcmp(buf, "he_6ghz_tx_ant_pat") == 0) {
3676 conf->he_6ghz_tx_ant_pat = atoi(pos);
3677 } else if (os_strcmp(buf, "unsol_bcast_probe_resp_interval") == 0) {
3678 int val = atoi(pos);
3679
3680 if (val < 0 || val > 20) {
3681 wpa_printf(MSG_ERROR,
3682 "Line %d: invalid unsol_bcast_probe_resp_interval value",
3683 line);
3684 return 1;
3685 }
3686 bss->unsol_bcast_probe_resp_interval = val;
3687 } else if (os_strcmp(buf, "mbssid") == 0) {
3688 int mbssid = atoi(pos);
3689 if (mbssid < 0 || mbssid > ENHANCED_MBSSID_ENABLED) {
3690 wpa_printf(MSG_ERROR,
3691 "Line %d: invalid mbssid (%d): '%s'.",
3692 line, mbssid, pos);
3693 return 1;
3694 }
3695 conf->mbssid = mbssid;
3696#endif /* CONFIG_IEEE80211AX */
3697 } else if (os_strcmp(buf, "max_listen_interval") == 0) {
3698 bss->max_listen_interval = atoi(pos);
3699 } else if (os_strcmp(buf, "disable_pmksa_caching") == 0) {
3700 bss->disable_pmksa_caching = atoi(pos);
3701 } else if (os_strcmp(buf, "okc") == 0) {
3702 bss->okc = atoi(pos);
3703#ifdef CONFIG_WPS
3704 } else if (os_strcmp(buf, "wps_state") == 0) {
3705 bss->wps_state = atoi(pos);
3706 if (bss->wps_state < 0 || bss->wps_state > 2) {
3707 wpa_printf(MSG_ERROR, "Line %d: invalid wps_state",
3708 line);
3709 return 1;
3710 }
3711 } else if (os_strcmp(buf, "wps_independent") == 0) {
3712 bss->wps_independent = atoi(pos);
3713 } else if (os_strcmp(buf, "ap_setup_locked") == 0) {
3714 bss->ap_setup_locked = atoi(pos);
3715 } else if (os_strcmp(buf, "uuid") == 0) {
3716 if (uuid_str2bin(pos, bss->uuid)) {
3717 wpa_printf(MSG_ERROR, "Line %d: invalid UUID", line);
3718 return 1;
3719 }
3720 } else if (os_strcmp(buf, "wps_pin_requests") == 0) {
3721 os_free(bss->wps_pin_requests);
3722 bss->wps_pin_requests = os_strdup(pos);
3723 } else if (os_strcmp(buf, "device_name") == 0) {
3724 if (os_strlen(pos) > WPS_DEV_NAME_MAX_LEN) {
3725 wpa_printf(MSG_ERROR, "Line %d: Too long "
3726 "device_name", line);
3727 return 1;
3728 }
3729 os_free(bss->device_name);
3730 bss->device_name = os_strdup(pos);
3731 } else if (os_strcmp(buf, "manufacturer") == 0) {
3732 if (os_strlen(pos) > 64) {
3733 wpa_printf(MSG_ERROR, "Line %d: Too long manufacturer",
3734 line);
3735 return 1;
3736 }
3737 os_free(bss->manufacturer);
3738 bss->manufacturer = os_strdup(pos);
3739 } else if (os_strcmp(buf, "model_name") == 0) {
3740 if (os_strlen(pos) > 32) {
3741 wpa_printf(MSG_ERROR, "Line %d: Too long model_name",
3742 line);
3743 return 1;
3744 }
3745 os_free(bss->model_name);
3746 bss->model_name = os_strdup(pos);
3747 } else if (os_strcmp(buf, "model_number") == 0) {
3748 if (os_strlen(pos) > 32) {
3749 wpa_printf(MSG_ERROR, "Line %d: Too long model_number",
3750 line);
3751 return 1;
3752 }
3753 os_free(bss->model_number);
3754 bss->model_number = os_strdup(pos);
3755 } else if (os_strcmp(buf, "serial_number") == 0) {
3756 if (os_strlen(pos) > 32) {
3757 wpa_printf(MSG_ERROR, "Line %d: Too long serial_number",
3758 line);
3759 return 1;
3760 }
3761 os_free(bss->serial_number);
3762 bss->serial_number = os_strdup(pos);
3763 } else if (os_strcmp(buf, "device_type") == 0) {
3764 if (wps_dev_type_str2bin(pos, bss->device_type))
3765 return 1;
3766 } else if (os_strcmp(buf, "config_methods") == 0) {
3767 os_free(bss->config_methods);
3768 bss->config_methods = os_strdup(pos);
3769 } else if (os_strcmp(buf, "os_version") == 0) {
3770 if (hexstr2bin(pos, bss->os_version, 4)) {
3771 wpa_printf(MSG_ERROR, "Line %d: invalid os_version",
3772 line);
3773 return 1;
3774 }
3775 } else if (os_strcmp(buf, "ap_pin") == 0) {
3776 os_free(bss->ap_pin);
3777 if (*pos == '\0')
3778 bss->ap_pin = NULL;
3779 else
3780 bss->ap_pin = os_strdup(pos);
3781 } else if (os_strcmp(buf, "skip_cred_build") == 0) {
3782 bss->skip_cred_build = atoi(pos);
3783 } else if (os_strcmp(buf, "extra_cred") == 0) {
3784 os_free(bss->extra_cred);
3785 bss->extra_cred = (u8 *) os_readfile(pos, &bss->extra_cred_len);
3786 if (bss->extra_cred == NULL) {
3787 wpa_printf(MSG_ERROR, "Line %d: could not read Credentials from '%s'",
3788 line, pos);
3789 return 1;
3790 }
3791 } else if (os_strcmp(buf, "wps_cred_processing") == 0) {
3792 bss->wps_cred_processing = atoi(pos);
3793 } else if (os_strcmp(buf, "wps_cred_add_sae") == 0) {
3794 bss->wps_cred_add_sae = atoi(pos);
3795 } else if (os_strcmp(buf, "ap_settings") == 0) {
3796 os_free(bss->ap_settings);
3797 bss->ap_settings =
3798 (u8 *) os_readfile(pos, &bss->ap_settings_len);
3799 if (bss->ap_settings == NULL) {
3800 wpa_printf(MSG_ERROR, "Line %d: could not read AP Settings from '%s'",
3801 line, pos);
3802 return 1;
3803 }
3804 } else if (os_strcmp(buf, "multi_ap_backhaul_ssid") == 0) {
3805 size_t slen;
3806 char *str = wpa_config_parse_string(pos, &slen);
3807
3808 if (!str || slen < 1 || slen > SSID_MAX_LEN) {
3809 wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'",
3810 line, pos);
3811 os_free(str);
3812 return 1;
3813 }
3814 os_memcpy(bss->multi_ap_backhaul_ssid.ssid, str, slen);
3815 bss->multi_ap_backhaul_ssid.ssid_len = slen;
3816 bss->multi_ap_backhaul_ssid.ssid_set = 1;
3817 os_free(str);
3818 } else if (os_strcmp(buf, "multi_ap_backhaul_wpa_passphrase") == 0) {
3819 int len = os_strlen(pos);
3820
3821 if (len < 8 || len > 63) {
3822 wpa_printf(MSG_ERROR,
3823 "Line %d: invalid WPA passphrase length %d (expected 8..63)",
3824 line, len);
3825 return 1;
3826 }
3827 os_free(bss->multi_ap_backhaul_ssid.wpa_passphrase);
3828 bss->multi_ap_backhaul_ssid.wpa_passphrase = os_strdup(pos);
3829 if (bss->multi_ap_backhaul_ssid.wpa_passphrase) {
3830 hostapd_config_clear_wpa_psk(
3831 &bss->multi_ap_backhaul_ssid.wpa_psk);
3832 bss->multi_ap_backhaul_ssid.wpa_passphrase_set = 1;
3833 }
3834 } else if (os_strcmp(buf, "multi_ap_backhaul_wpa_psk") == 0) {
3835 hostapd_config_clear_wpa_psk(
3836 &bss->multi_ap_backhaul_ssid.wpa_psk);
3837 bss->multi_ap_backhaul_ssid.wpa_psk =
3838 os_zalloc(sizeof(struct hostapd_wpa_psk));
3839 if (!bss->multi_ap_backhaul_ssid.wpa_psk)
3840 return 1;
3841 if (hexstr2bin(pos, bss->multi_ap_backhaul_ssid.wpa_psk->psk,
3842 PMK_LEN) ||
3843 pos[PMK_LEN * 2] != '\0') {
3844 wpa_printf(MSG_ERROR, "Line %d: Invalid PSK '%s'.",
3845 line, pos);
3846 hostapd_config_clear_wpa_psk(
3847 &bss->multi_ap_backhaul_ssid.wpa_psk);
3848 return 1;
3849 }
3850 bss->multi_ap_backhaul_ssid.wpa_psk->group = 1;
3851 os_free(bss->multi_ap_backhaul_ssid.wpa_passphrase);
3852 bss->multi_ap_backhaul_ssid.wpa_passphrase = NULL;
3853 bss->multi_ap_backhaul_ssid.wpa_psk_set = 1;
3854 } else if (os_strcmp(buf, "upnp_iface") == 0) {
3855 os_free(bss->upnp_iface);
3856 bss->upnp_iface = os_strdup(pos);
3857 } else if (os_strcmp(buf, "friendly_name") == 0) {
3858 os_free(bss->friendly_name);
3859 bss->friendly_name = os_strdup(pos);
3860 } else if (os_strcmp(buf, "manufacturer_url") == 0) {
3861 os_free(bss->manufacturer_url);
3862 bss->manufacturer_url = os_strdup(pos);
3863 } else if (os_strcmp(buf, "model_description") == 0) {
3864 os_free(bss->model_description);
3865 bss->model_description = os_strdup(pos);
3866 } else if (os_strcmp(buf, "model_url") == 0) {
3867 os_free(bss->model_url);
3868 bss->model_url = os_strdup(pos);
3869 } else if (os_strcmp(buf, "upc") == 0) {
3870 os_free(bss->upc);
3871 bss->upc = os_strdup(pos);
3872 } else if (os_strcmp(buf, "pbc_in_m1") == 0) {
3873 bss->pbc_in_m1 = atoi(pos);
3874 } else if (os_strcmp(buf, "server_id") == 0) {
3875 os_free(bss->server_id);
3876 bss->server_id = os_strdup(pos);
3877 } else if (os_strcmp(buf, "wps_application_ext") == 0) {
3878 wpabuf_free(bss->wps_application_ext);
3879 bss->wps_application_ext = wpabuf_parse_bin(pos);
3880#ifdef CONFIG_WPS_NFC
3881 } else if (os_strcmp(buf, "wps_nfc_dev_pw_id") == 0) {
3882 bss->wps_nfc_dev_pw_id = atoi(pos);
3883 if (bss->wps_nfc_dev_pw_id < 0x10 ||
3884 bss->wps_nfc_dev_pw_id > 0xffff) {
3885 wpa_printf(MSG_ERROR, "Line %d: Invalid wps_nfc_dev_pw_id value",
3886 line);
3887 return 1;
3888 }
3889 bss->wps_nfc_pw_from_config = 1;
3890 } else if (os_strcmp(buf, "wps_nfc_dh_pubkey") == 0) {
3891 wpabuf_free(bss->wps_nfc_dh_pubkey);
3892 bss->wps_nfc_dh_pubkey = wpabuf_parse_bin(pos);
3893 bss->wps_nfc_pw_from_config = 1;
3894 } else if (os_strcmp(buf, "wps_nfc_dh_privkey") == 0) {
3895 wpabuf_free(bss->wps_nfc_dh_privkey);
3896 bss->wps_nfc_dh_privkey = wpabuf_parse_bin(pos);
3897 bss->wps_nfc_pw_from_config = 1;
3898 } else if (os_strcmp(buf, "wps_nfc_dev_pw") == 0) {
3899 wpabuf_free(bss->wps_nfc_dev_pw);
3900 bss->wps_nfc_dev_pw = wpabuf_parse_bin(pos);
3901 bss->wps_nfc_pw_from_config = 1;
3902#endif /* CONFIG_WPS_NFC */
3903#endif /* CONFIG_WPS */
3904#ifdef CONFIG_P2P_MANAGER
3905 } else if (os_strcmp(buf, "manage_p2p") == 0) {
3906 if (atoi(pos))
3907 bss->p2p |= P2P_MANAGE;
3908 else
3909 bss->p2p &= ~P2P_MANAGE;
3910 } else if (os_strcmp(buf, "allow_cross_connection") == 0) {
3911 if (atoi(pos))
3912 bss->p2p |= P2P_ALLOW_CROSS_CONNECTION;
3913 else
3914 bss->p2p &= ~P2P_ALLOW_CROSS_CONNECTION;
3915#endif /* CONFIG_P2P_MANAGER */
3916 } else if (os_strcmp(buf, "disassoc_low_ack") == 0) {
3917 bss->disassoc_low_ack = atoi(pos);
3918 } else if (os_strcmp(buf, "tdls_prohibit") == 0) {
3919 if (atoi(pos))
3920 bss->tdls |= TDLS_PROHIBIT;
3921 else
3922 bss->tdls &= ~TDLS_PROHIBIT;
3923 } else if (os_strcmp(buf, "tdls_prohibit_chan_switch") == 0) {
3924 if (atoi(pos))
3925 bss->tdls |= TDLS_PROHIBIT_CHAN_SWITCH;
3926 else
3927 bss->tdls &= ~TDLS_PROHIBIT_CHAN_SWITCH;
3928#ifdef CONFIG_RSN_TESTING
3929 } else if (os_strcmp(buf, "rsn_testing") == 0) {
3930 extern int rsn_testing;
3931 rsn_testing = atoi(pos);
3932#endif /* CONFIG_RSN_TESTING */
3933 } else if (os_strcmp(buf, "time_advertisement") == 0) {
3934 bss->time_advertisement = atoi(pos);
3935 } else if (os_strcmp(buf, "time_zone") == 0) {
3936 size_t tz_len = os_strlen(pos);
3937 if (tz_len < 4 || tz_len > 255) {
3938 wpa_printf(MSG_DEBUG, "Line %d: invalid time_zone",
3939 line);
3940 return 1;
3941 }
3942 os_free(bss->time_zone);
3943 bss->time_zone = os_strdup(pos);
3944 if (bss->time_zone == NULL)
3945 return 1;
3946#ifdef CONFIG_WNM_AP
3947 } else if (os_strcmp(buf, "wnm_sleep_mode") == 0) {
3948 bss->wnm_sleep_mode = atoi(pos);
3949 } else if (os_strcmp(buf, "wnm_sleep_mode_no_keys") == 0) {
3950 bss->wnm_sleep_mode_no_keys = atoi(pos);
3951 } else if (os_strcmp(buf, "bss_transition") == 0) {
3952 bss->bss_transition = atoi(pos);
3953#endif /* CONFIG_WNM_AP */
3954#ifdef CONFIG_INTERWORKING
3955 } else if (os_strcmp(buf, "interworking") == 0) {
3956 bss->interworking = atoi(pos);
3957 } else if (os_strcmp(buf, "access_network_type") == 0) {
3958 bss->access_network_type = atoi(pos);
3959 if (bss->access_network_type < 0 ||
3960 bss->access_network_type > 15) {
3961 wpa_printf(MSG_ERROR,
3962 "Line %d: invalid access_network_type",
3963 line);
3964 return 1;
3965 }
3966 } else if (os_strcmp(buf, "internet") == 0) {
3967 bss->internet = atoi(pos);
3968 } else if (os_strcmp(buf, "asra") == 0) {
3969 bss->asra = atoi(pos);
3970 } else if (os_strcmp(buf, "esr") == 0) {
3971 bss->esr = atoi(pos);
3972 } else if (os_strcmp(buf, "uesa") == 0) {
3973 bss->uesa = atoi(pos);
3974 } else if (os_strcmp(buf, "venue_group") == 0) {
3975 bss->venue_group = atoi(pos);
3976 bss->venue_info_set = 1;
3977 } else if (os_strcmp(buf, "venue_type") == 0) {
3978 bss->venue_type = atoi(pos);
3979 bss->venue_info_set = 1;
3980 } else if (os_strcmp(buf, "hessid") == 0) {
3981 if (hwaddr_aton(pos, bss->hessid)) {
3982 wpa_printf(MSG_ERROR, "Line %d: invalid hessid", line);
3983 return 1;
3984 }
3985 } else if (os_strcmp(buf, "roaming_consortium") == 0) {
3986 if (parse_roaming_consortium(bss, pos, line) < 0)
3987 return 1;
3988 } else if (os_strcmp(buf, "venue_name") == 0) {
3989 if (parse_venue_name(bss, pos, line) < 0)
3990 return 1;
3991 } else if (os_strcmp(buf, "venue_url") == 0) {
3992 if (parse_venue_url(bss, pos, line) < 0)
3993 return 1;
3994 } else if (os_strcmp(buf, "network_auth_type") == 0) {
3995 u8 auth_type;
3996 u16 redirect_url_len;
3997 if (hexstr2bin(pos, &auth_type, 1)) {
3998 wpa_printf(MSG_ERROR,
3999 "Line %d: Invalid network_auth_type '%s'",
4000 line, pos);
4001 return 1;
4002 }
4003 if (auth_type == 0 || auth_type == 2)
4004 redirect_url_len = os_strlen(pos + 2);
4005 else
4006 redirect_url_len = 0;
4007 os_free(bss->network_auth_type);
4008 bss->network_auth_type = os_malloc(redirect_url_len + 3 + 1);
4009 if (bss->network_auth_type == NULL)
4010 return 1;
4011 *bss->network_auth_type = auth_type;
4012 WPA_PUT_LE16(bss->network_auth_type + 1, redirect_url_len);
4013 if (redirect_url_len)
4014 os_memcpy(bss->network_auth_type + 3, pos + 2,
4015 redirect_url_len);
4016 bss->network_auth_type_len = 3 + redirect_url_len;
4017 } else if (os_strcmp(buf, "ipaddr_type_availability") == 0) {
4018 if (hexstr2bin(pos, &bss->ipaddr_type_availability, 1)) {
4019 wpa_printf(MSG_ERROR, "Line %d: Invalid ipaddr_type_availability '%s'",
4020 line, pos);
4021 bss->ipaddr_type_configured = 0;
4022 return 1;
4023 }
4024 bss->ipaddr_type_configured = 1;
4025 } else if (os_strcmp(buf, "domain_name") == 0) {
4026 int j, num_domains, domain_len, domain_list_len = 0;
4027 char *tok_start, *tok_prev;
4028 u8 *domain_list, *domain_ptr;
4029
4030 domain_list_len = os_strlen(pos) + 1;
4031 domain_list = os_malloc(domain_list_len);
4032 if (domain_list == NULL)
4033 return 1;
4034
4035 domain_ptr = domain_list;
4036 tok_prev = pos;
4037 num_domains = 1;
4038 while ((tok_prev = os_strchr(tok_prev, ','))) {
4039 num_domains++;
4040 tok_prev++;
4041 }
4042 tok_prev = pos;
4043 for (j = 0; j < num_domains; j++) {
4044 tok_start = os_strchr(tok_prev, ',');
4045 if (tok_start) {
4046 domain_len = tok_start - tok_prev;
4047 *domain_ptr = domain_len;
4048 os_memcpy(domain_ptr + 1, tok_prev, domain_len);
4049 domain_ptr += domain_len + 1;
4050 tok_prev = ++tok_start;
4051 } else {
4052 domain_len = os_strlen(tok_prev);
4053 *domain_ptr = domain_len;
4054 os_memcpy(domain_ptr + 1, tok_prev, domain_len);
4055 domain_ptr += domain_len + 1;
4056 }
4057 }
4058
4059 os_free(bss->domain_name);
4060 bss->domain_name = domain_list;
4061 bss->domain_name_len = domain_list_len;
4062 } else if (os_strcmp(buf, "anqp_3gpp_cell_net") == 0) {
4063 if (parse_3gpp_cell_net(bss, pos, line) < 0)
4064 return 1;
4065 } else if (os_strcmp(buf, "nai_realm") == 0) {
4066 if (parse_nai_realm(bss, pos, line) < 0)
4067 return 1;
4068 } else if (os_strcmp(buf, "anqp_elem") == 0) {
4069 if (parse_anqp_elem(bss, pos, line) < 0)
4070 return 1;
4071 } else if (os_strcmp(buf, "gas_frag_limit") == 0) {
4072 int val = atoi(pos);
4073
4074 if (val <= 0) {
4075 wpa_printf(MSG_ERROR,
4076 "Line %d: Invalid gas_frag_limit '%s'",
4077 line, pos);
4078 return 1;
4079 }
4080 bss->gas_frag_limit = val;
4081 } else if (os_strcmp(buf, "gas_comeback_delay") == 0) {
4082 bss->gas_comeback_delay = atoi(pos);
4083#endif /* CONFIG_INTERWORKING */
4084 } else if (os_strcmp(buf, "qos_map_set") == 0) {
4085 if (parse_qos_map_set(bss, pos, line) < 0)
4086 return 1;
4087#ifdef CONFIG_RADIUS_TEST
4088 } else if (os_strcmp(buf, "dump_msk_file") == 0) {
4089 os_free(bss->dump_msk_file);
4090 bss->dump_msk_file = os_strdup(pos);
4091#endif /* CONFIG_RADIUS_TEST */
4092#ifdef CONFIG_PROXYARP
4093 } else if (os_strcmp(buf, "proxy_arp") == 0) {
4094 bss->proxy_arp = atoi(pos);
4095#endif /* CONFIG_PROXYARP */
4096#ifdef CONFIG_HS20
4097 } else if (os_strcmp(buf, "hs20") == 0) {
4098 bss->hs20 = atoi(pos);
4099 } else if (os_strcmp(buf, "hs20_release") == 0) {
4100 int val = atoi(pos);
4101
4102 if (val < 1 || val > (HS20_VERSION >> 4) + 1) {
4103 wpa_printf(MSG_ERROR,
4104 "Line %d: Unsupported hs20_release: %s",
4105 line, pos);
4106 return 1;
4107 }
4108 bss->hs20_release = val;
4109 } else if (os_strcmp(buf, "disable_dgaf") == 0) {
4110 bss->disable_dgaf = atoi(pos);
4111 } else if (os_strcmp(buf, "na_mcast_to_ucast") == 0) {
4112 bss->na_mcast_to_ucast = atoi(pos);
4113 } else if (os_strcmp(buf, "osen") == 0) {
4114 bss->osen = atoi(pos);
4115 } else if (os_strcmp(buf, "anqp_domain_id") == 0) {
4116 bss->anqp_domain_id = atoi(pos);
4117 } else if (os_strcmp(buf, "hs20_deauth_req_timeout") == 0) {
4118 bss->hs20_deauth_req_timeout = atoi(pos);
4119 } else if (os_strcmp(buf, "hs20_oper_friendly_name") == 0) {
4120 if (hs20_parse_oper_friendly_name(bss, pos, line) < 0)
4121 return 1;
4122 } else if (os_strcmp(buf, "hs20_wan_metrics") == 0) {
4123 if (hs20_parse_wan_metrics(bss, pos, line) < 0)
4124 return 1;
4125 } else if (os_strcmp(buf, "hs20_conn_capab") == 0) {
4126 if (hs20_parse_conn_capab(bss, pos, line) < 0) {
4127 return 1;
4128 }
4129 } else if (os_strcmp(buf, "hs20_operating_class") == 0) {
4130 u8 *oper_class;
4131 size_t oper_class_len;
4132 oper_class_len = os_strlen(pos);
4133 if (oper_class_len < 2 || (oper_class_len & 0x01)) {
4134 wpa_printf(MSG_ERROR,
4135 "Line %d: Invalid hs20_operating_class '%s'",
4136 line, pos);
4137 return 1;
4138 }
4139 oper_class_len /= 2;
4140 oper_class = os_malloc(oper_class_len);
4141 if (oper_class == NULL)
4142 return 1;
4143 if (hexstr2bin(pos, oper_class, oper_class_len)) {
4144 wpa_printf(MSG_ERROR,
4145 "Line %d: Invalid hs20_operating_class '%s'",
4146 line, pos);
4147 os_free(oper_class);
4148 return 1;
4149 }
4150 os_free(bss->hs20_operating_class);
4151 bss->hs20_operating_class = oper_class;
4152 bss->hs20_operating_class_len = oper_class_len;
4153 } else if (os_strcmp(buf, "hs20_icon") == 0) {
4154 if (hs20_parse_icon(bss, pos) < 0) {
4155 wpa_printf(MSG_ERROR, "Line %d: Invalid hs20_icon '%s'",
4156 line, pos);
4157 return 1;
4158 }
4159 } else if (os_strcmp(buf, "osu_ssid") == 0) {
4160 if (hs20_parse_osu_ssid(bss, pos, line) < 0)
4161 return 1;
4162 } else if (os_strcmp(buf, "osu_server_uri") == 0) {
4163 if (hs20_parse_osu_server_uri(bss, pos, line) < 0)
4164 return 1;
4165 } else if (os_strcmp(buf, "osu_friendly_name") == 0) {
4166 if (hs20_parse_osu_friendly_name(bss, pos, line) < 0)
4167 return 1;
4168 } else if (os_strcmp(buf, "osu_nai") == 0) {
4169 if (hs20_parse_osu_nai(bss, pos, line) < 0)
4170 return 1;
4171 } else if (os_strcmp(buf, "osu_nai2") == 0) {
4172 if (hs20_parse_osu_nai2(bss, pos, line) < 0)
4173 return 1;
4174 } else if (os_strcmp(buf, "osu_method_list") == 0) {
4175 if (hs20_parse_osu_method_list(bss, pos, line) < 0)
4176 return 1;
4177 } else if (os_strcmp(buf, "osu_icon") == 0) {
4178 if (hs20_parse_osu_icon(bss, pos, line) < 0)
4179 return 1;
4180 } else if (os_strcmp(buf, "osu_service_desc") == 0) {
4181 if (hs20_parse_osu_service_desc(bss, pos, line) < 0)
4182 return 1;
4183 } else if (os_strcmp(buf, "operator_icon") == 0) {
4184 if (hs20_parse_operator_icon(bss, pos, line) < 0)
4185 return 1;
4186 } else if (os_strcmp(buf, "subscr_remediation_url") == 0) {
4187 os_free(bss->subscr_remediation_url);
4188 bss->subscr_remediation_url = os_strdup(pos);
4189 } else if (os_strcmp(buf, "subscr_remediation_method") == 0) {
4190 bss->subscr_remediation_method = atoi(pos);
4191 } else if (os_strcmp(buf, "hs20_t_c_filename") == 0) {
4192 os_free(bss->t_c_filename);
4193 bss->t_c_filename = os_strdup(pos);
4194 } else if (os_strcmp(buf, "hs20_t_c_timestamp") == 0) {
4195 bss->t_c_timestamp = strtol(pos, NULL, 0);
4196 } else if (os_strcmp(buf, "hs20_t_c_server_url") == 0) {
4197 os_free(bss->t_c_server_url);
4198 bss->t_c_server_url = os_strdup(pos);
4199 } else if (os_strcmp(buf, "hs20_sim_provisioning_url") == 0) {
4200 os_free(bss->hs20_sim_provisioning_url);
4201 bss->hs20_sim_provisioning_url = os_strdup(pos);
4202#endif /* CONFIG_HS20 */
4203#ifdef CONFIG_MBO
4204 } else if (os_strcmp(buf, "mbo") == 0) {
4205 bss->mbo_enabled = atoi(pos);
4206 } else if (os_strcmp(buf, "mbo_cell_data_conn_pref") == 0) {
4207 bss->mbo_cell_data_conn_pref = atoi(pos);
4208 } else if (os_strcmp(buf, "oce") == 0) {
4209 bss->oce = atoi(pos);
4210#endif /* CONFIG_MBO */
4211#ifdef CONFIG_TESTING_OPTIONS
4212#define PARSE_TEST_PROBABILITY(_val) \
4213 } else if (os_strcmp(buf, #_val) == 0) { \
4214 char *end; \
4215 \
4216 conf->_val = strtod(pos, &end); \
4217 if (*end || conf->_val < 0.0 || \
4218 conf->_val > 1.0) { \
4219 wpa_printf(MSG_ERROR, \
4220 "Line %d: Invalid value '%s'", \
4221 line, pos); \
4222 return 1; \
4223 }
4224 PARSE_TEST_PROBABILITY(ignore_probe_probability)
4225 PARSE_TEST_PROBABILITY(ignore_auth_probability)
4226 PARSE_TEST_PROBABILITY(ignore_assoc_probability)
4227 PARSE_TEST_PROBABILITY(ignore_reassoc_probability)
4228 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability)
4229 } else if (os_strcmp(buf, "ecsa_ie_only") == 0) {
4230 conf->ecsa_ie_only = atoi(pos);
4231 } else if (os_strcmp(buf, "bss_load_test") == 0) {
4232 WPA_PUT_LE16(bss->bss_load_test, atoi(pos));
4233 pos = os_strchr(pos, ':');
4234 if (pos == NULL) {
4235 wpa_printf(MSG_ERROR, "Line %d: Invalid bss_load_test",
4236 line);
4237 return 1;
4238 }
4239 pos++;
4240 bss->bss_load_test[2] = atoi(pos);
4241 pos = os_strchr(pos, ':');
4242 if (pos == NULL) {
4243 wpa_printf(MSG_ERROR, "Line %d: Invalid bss_load_test",
4244 line);
4245 return 1;
4246 }
4247 pos++;
4248 WPA_PUT_LE16(&bss->bss_load_test[3], atoi(pos));
4249 bss->bss_load_test_set = 1;
4250 } else if (os_strcmp(buf, "radio_measurements") == 0) {
4251 /*
4252 * DEPRECATED: This parameter will be removed in the future.
4253 * Use rrm_neighbor_report instead.
4254 */
4255 int val = atoi(pos);
4256
4257 if (val & BIT(0))
4258 bss->radio_measurements[0] |=
4259 WLAN_RRM_CAPS_NEIGHBOR_REPORT;
4260 } else if (os_strcmp(buf, "own_ie_override") == 0) {
4261 struct wpabuf *tmp;
4262 size_t len = os_strlen(pos) / 2;
4263
4264 tmp = wpabuf_alloc(len);
4265 if (!tmp)
4266 return 1;
4267
4268 if (hexstr2bin(pos, wpabuf_put(tmp, len), len)) {
4269 wpabuf_free(tmp);
4270 wpa_printf(MSG_ERROR,
4271 "Line %d: Invalid own_ie_override '%s'",
4272 line, pos);
4273 return 1;
4274 }
4275
4276 wpabuf_free(bss->own_ie_override);
4277 bss->own_ie_override = tmp;
4278 } else if (os_strcmp(buf, "sae_reflection_attack") == 0) {
4279 bss->sae_reflection_attack = atoi(pos);
4280 } else if (os_strcmp(buf, "sae_commit_status") == 0) {
4281 bss->sae_commit_status = atoi(pos);
4282 } else if (os_strcmp(buf, "sae_pk_omit") == 0) {
4283 bss->sae_pk_omit = atoi(pos);
4284 } else if (os_strcmp(buf, "sae_pk_password_check_skip") == 0) {
4285 bss->sae_pk_password_check_skip = atoi(pos);
4286 } else if (os_strcmp(buf, "sae_commit_override") == 0) {
4287 wpabuf_free(bss->sae_commit_override);
4288 bss->sae_commit_override = wpabuf_parse_bin(pos);
4289 } else if (os_strcmp(buf, "rsne_override_eapol") == 0) {
4290 wpabuf_free(bss->rsne_override_eapol);
4291 bss->rsne_override_eapol = wpabuf_parse_bin(pos);
4292 } else if (os_strcmp(buf, "rsnxe_override_eapol") == 0) {
4293 wpabuf_free(bss->rsnxe_override_eapol);
4294 bss->rsnxe_override_eapol = wpabuf_parse_bin(pos);
4295 } else if (os_strcmp(buf, "rsne_override_ft") == 0) {
4296 wpabuf_free(bss->rsne_override_ft);
4297 bss->rsne_override_ft = wpabuf_parse_bin(pos);
4298 } else if (os_strcmp(buf, "rsnxe_override_ft") == 0) {
4299 wpabuf_free(bss->rsnxe_override_ft);
4300 bss->rsnxe_override_ft = wpabuf_parse_bin(pos);
4301 } else if (os_strcmp(buf, "gtk_rsc_override") == 0) {
4302 wpabuf_free(bss->gtk_rsc_override);
4303 bss->gtk_rsc_override = wpabuf_parse_bin(pos);
4304 } else if (os_strcmp(buf, "igtk_rsc_override") == 0) {
4305 wpabuf_free(bss->igtk_rsc_override);
4306 bss->igtk_rsc_override = wpabuf_parse_bin(pos);
4307 } else if (os_strcmp(buf, "no_beacon_rsnxe") == 0) {
4308 bss->no_beacon_rsnxe = atoi(pos);
4309 } else if (os_strcmp(buf, "skip_prune_assoc") == 0) {
4310 bss->skip_prune_assoc = atoi(pos);
4311 } else if (os_strcmp(buf, "ft_rsnxe_used") == 0) {
4312 bss->ft_rsnxe_used = atoi(pos);
4313 } else if (os_strcmp(buf, "oci_freq_override_eapol_m3") == 0) {
4314 bss->oci_freq_override_eapol_m3 = atoi(pos);
4315 } else if (os_strcmp(buf, "oci_freq_override_eapol_g1") == 0) {
4316 bss->oci_freq_override_eapol_g1 = atoi(pos);
4317 } else if (os_strcmp(buf, "oci_freq_override_saquery_req") == 0) {
4318 bss->oci_freq_override_saquery_req = atoi(pos);
4319 } else if (os_strcmp(buf, "oci_freq_override_saquery_resp") == 0) {
4320 bss->oci_freq_override_saquery_resp = atoi(pos);
4321 } else if (os_strcmp(buf, "oci_freq_override_ft_assoc") == 0) {
4322 bss->oci_freq_override_ft_assoc = atoi(pos);
4323 } else if (os_strcmp(buf, "oci_freq_override_fils_assoc") == 0) {
4324 bss->oci_freq_override_fils_assoc = atoi(pos);
4325 } else if (os_strcmp(buf, "oci_freq_override_wnm_sleep") == 0) {
4326 bss->oci_freq_override_wnm_sleep = atoi(pos);
4327 } else if (os_strcmp(buf, "eap_skip_prot_success") == 0) {
4328 bss->eap_skip_prot_success = atoi(pos);
4329 } else if (os_strcmp(buf, "delay_eapol_tx") == 0) {
4330 conf->delay_eapol_tx = atoi(pos);
4331#endif /* CONFIG_TESTING_OPTIONS */
4332#ifdef CONFIG_SAE
4333 } else if (os_strcmp(buf, "sae_password") == 0) {
4334 if (parse_sae_password(bss, pos) < 0) {
4335 wpa_printf(MSG_ERROR, "Line %d: Invalid sae_password",
4336 line);
4337 return 1;
4338 }
4339#endif /* CONFIG_SAE */
4340 } else if (os_strcmp(buf, "vendor_elements") == 0) {
4341 if (parse_wpabuf_hex(line, buf, &bss->vendor_elements, pos))
4342 return 1;
4343 } else if (os_strcmp(buf, "assocresp_elements") == 0) {
4344 if (parse_wpabuf_hex(line, buf, &bss->assocresp_elements, pos))
4345 return 1;
4346 } else if (os_strcmp(buf, "sae_anti_clogging_threshold") == 0 ||
4347 os_strcmp(buf, "anti_clogging_threshold") == 0) {
4348 bss->anti_clogging_threshold = atoi(pos);
4349 } else if (os_strcmp(buf, "sae_sync") == 0) {
4350 bss->sae_sync = atoi(pos);
4351 } else if (os_strcmp(buf, "sae_groups") == 0) {
4352 if (hostapd_parse_intlist(&bss->sae_groups, pos)) {
4353 wpa_printf(MSG_ERROR,
4354 "Line %d: Invalid sae_groups value '%s'",
4355 line, pos);
4356 return 1;
4357 }
4358 } else if (os_strcmp(buf, "sae_require_mfp") == 0) {
4359 bss->sae_require_mfp = atoi(pos);
4360 } else if (os_strcmp(buf, "sae_confirm_immediate") == 0) {
4361 bss->sae_confirm_immediate = atoi(pos);
4362 } else if (os_strcmp(buf, "sae_pwe") == 0) {
4363 bss->sae_pwe = atoi(pos);
4364 } else if (os_strcmp(buf, "local_pwr_constraint") == 0) {
4365 int val = atoi(pos);
4366 if (val < 0 || val > 255) {
4367 wpa_printf(MSG_ERROR, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
4368 line, val);
4369 return 1;
4370 }
4371 conf->local_pwr_constraint = val;
4372 } else if (os_strcmp(buf, "spectrum_mgmt_required") == 0) {
4373 conf->spectrum_mgmt_required = atoi(pos);
4374 } else if (os_strcmp(buf, "wowlan_triggers") == 0) {
4375 os_free(bss->wowlan_triggers);
4376 bss->wowlan_triggers = os_strdup(pos);
4377#ifdef CONFIG_FST
4378 } else if (os_strcmp(buf, "fst_group_id") == 0) {
4379 size_t len = os_strlen(pos);
4380
4381 if (!len || len >= sizeof(conf->fst_cfg.group_id)) {
4382 wpa_printf(MSG_ERROR,
4383 "Line %d: Invalid fst_group_id value '%s'",
4384 line, pos);
4385 return 1;
4386 }
4387
4388 if (conf->fst_cfg.group_id[0]) {
4389 wpa_printf(MSG_ERROR,
4390 "Line %d: Duplicate fst_group value '%s'",
4391 line, pos);
4392 return 1;
4393 }
4394
4395 os_strlcpy(conf->fst_cfg.group_id, pos,
4396 sizeof(conf->fst_cfg.group_id));
4397 } else if (os_strcmp(buf, "fst_priority") == 0) {
4398 char *endp;
4399 long int val;
4400
4401 if (!*pos) {
4402 wpa_printf(MSG_ERROR,
4403 "Line %d: fst_priority value not supplied (expected 1..%u)",
4404 line, FST_MAX_PRIO_VALUE);
4405 return -1;
4406 }
4407
4408 val = strtol(pos, &endp, 0);
4409 if (*endp || val < 1 || val > FST_MAX_PRIO_VALUE) {
4410 wpa_printf(MSG_ERROR,
4411 "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)",
4412 line, val, pos, FST_MAX_PRIO_VALUE);
4413 return 1;
4414 }
4415 conf->fst_cfg.priority = (u8) val;
4416 } else if (os_strcmp(buf, "fst_llt") == 0) {
4417 char *endp;
4418 long int val;
4419
4420 if (!*pos) {
4421 wpa_printf(MSG_ERROR,
4422 "Line %d: fst_llt value not supplied (expected 1..%u)",
4423 line, FST_MAX_LLT_MS);
4424 return -1;
4425 }
4426 val = strtol(pos, &endp, 0);
4427 if (*endp || val < 1 ||
4428 (unsigned long int) val > FST_MAX_LLT_MS) {
4429 wpa_printf(MSG_ERROR,
4430 "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
4431 line, val, pos, FST_MAX_LLT_MS);
4432 return 1;
4433 }
4434 conf->fst_cfg.llt = (u32) val;
4435#endif /* CONFIG_FST */
4436 } else if (os_strcmp(buf, "track_sta_max_num") == 0) {
4437 conf->track_sta_max_num = atoi(pos);
4438 } else if (os_strcmp(buf, "track_sta_max_age") == 0) {
4439 conf->track_sta_max_age = atoi(pos);
4440 } else if (os_strcmp(buf, "no_probe_resp_if_seen_on") == 0) {
4441 os_free(bss->no_probe_resp_if_seen_on);
4442 bss->no_probe_resp_if_seen_on = os_strdup(pos);
4443 } else if (os_strcmp(buf, "no_auth_if_seen_on") == 0) {
4444 os_free(bss->no_auth_if_seen_on);
4445 bss->no_auth_if_seen_on = os_strdup(pos);
4446 } else if (os_strcmp(buf, "lci") == 0) {
4447 wpabuf_free(conf->lci);
4448 conf->lci = wpabuf_parse_bin(pos);
4449 if (conf->lci && wpabuf_len(conf->lci) == 0) {
4450 wpabuf_free(conf->lci);
4451 conf->lci = NULL;
4452 }
4453 } else if (os_strcmp(buf, "civic") == 0) {
4454 wpabuf_free(conf->civic);
4455 conf->civic = wpabuf_parse_bin(pos);
4456 if (conf->civic && wpabuf_len(conf->civic) == 0) {
4457 wpabuf_free(conf->civic);
4458 conf->civic = NULL;
4459 }
4460 } else if (os_strcmp(buf, "rrm_neighbor_report") == 0) {
4461 if (atoi(pos))
4462 bss->radio_measurements[0] |=
4463 WLAN_RRM_CAPS_NEIGHBOR_REPORT;
4464 } else if (os_strcmp(buf, "rrm_beacon_report") == 0) {
4465 if (atoi(pos))
4466 bss->radio_measurements[0] |=
4467 WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE |
4468 WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE |
4469 WLAN_RRM_CAPS_BEACON_REPORT_TABLE;
4470 } else if (os_strcmp(buf, "gas_address3") == 0) {
4471 bss->gas_address3 = atoi(pos);
4472 } else if (os_strcmp(buf, "stationary_ap") == 0) {
4473 conf->stationary_ap = atoi(pos);
4474 } else if (os_strcmp(buf, "ftm_responder") == 0) {
4475 bss->ftm_responder = atoi(pos);
4476 } else if (os_strcmp(buf, "ftm_initiator") == 0) {
4477 bss->ftm_initiator = atoi(pos);
4478#ifdef CONFIG_FILS
4479 } else if (os_strcmp(buf, "fils_cache_id") == 0) {
4480 if (hexstr2bin(pos, bss->fils_cache_id, FILS_CACHE_ID_LEN)) {
4481 wpa_printf(MSG_ERROR,
4482 "Line %d: Invalid fils_cache_id '%s'",
4483 line, pos);
4484 return 1;
4485 }
4486 bss->fils_cache_id_set = 1;
4487 } else if (os_strcmp(buf, "fils_realm") == 0) {
4488 if (parse_fils_realm(bss, pos) < 0)
4489 return 1;
4490 } else if (os_strcmp(buf, "fils_dh_group") == 0) {
4491 bss->fils_dh_group = atoi(pos);
4492 } else if (os_strcmp(buf, "dhcp_server") == 0) {
4493 if (hostapd_parse_ip_addr(pos, &bss->dhcp_server)) {
4494 wpa_printf(MSG_ERROR,
4495 "Line %d: invalid IP address '%s'",
4496 line, pos);
4497 return 1;
4498 }
4499 } else if (os_strcmp(buf, "dhcp_rapid_commit_proxy") == 0) {
4500 bss->dhcp_rapid_commit_proxy = atoi(pos);
4501 } else if (os_strcmp(buf, "fils_hlp_wait_time") == 0) {
4502 bss->fils_hlp_wait_time = atoi(pos);
4503 } else if (os_strcmp(buf, "dhcp_server_port") == 0) {
4504 bss->dhcp_server_port = atoi(pos);
4505 } else if (os_strcmp(buf, "dhcp_relay_port") == 0) {
4506 bss->dhcp_relay_port = atoi(pos);
4507 } else if (os_strcmp(buf, "fils_discovery_min_interval") == 0) {
4508 bss->fils_discovery_min_int = atoi(pos);
4509 } else if (os_strcmp(buf, "fils_discovery_max_interval") == 0) {
4510 bss->fils_discovery_max_int = atoi(pos);
4511#endif /* CONFIG_FILS */
4512 } else if (os_strcmp(buf, "multicast_to_unicast") == 0) {
4513 bss->multicast_to_unicast = atoi(pos);
4514 } else if (os_strcmp(buf, "bridge_multicast_to_unicast") == 0) {
4515 bss->bridge_multicast_to_unicast = atoi(pos);
4516 } else if (os_strcmp(buf, "broadcast_deauth") == 0) {
4517 bss->broadcast_deauth = atoi(pos);
4518 } else if (os_strcmp(buf, "notify_mgmt_frames") == 0) {
4519 bss->notify_mgmt_frames = atoi(pos);
4520#ifdef CONFIG_DPP
4521 } else if (os_strcmp(buf, "dpp_name") == 0) {
4522 os_free(bss->dpp_name);
4523 bss->dpp_name = os_strdup(pos);
4524 } else if (os_strcmp(buf, "dpp_mud_url") == 0) {
4525 os_free(bss->dpp_mud_url);
4526 bss->dpp_mud_url = os_strdup(pos);
4527 } else if (os_strcmp(buf, "dpp_extra_conf_req_name") == 0) {
4528 os_free(bss->dpp_extra_conf_req_name);
4529 bss->dpp_extra_conf_req_name = os_strdup(pos);
4530 } else if (os_strcmp(buf, "dpp_extra_conf_req_value") == 0) {
4531 os_free(bss->dpp_extra_conf_req_value);
4532 bss->dpp_extra_conf_req_value = os_strdup(pos);
4533 } else if (os_strcmp(buf, "dpp_connector") == 0) {
4534 os_free(bss->dpp_connector);
4535 bss->dpp_connector = os_strdup(pos);
4536 } else if (os_strcmp(buf, "dpp_netaccesskey") == 0) {
4537 if (parse_wpabuf_hex(line, buf, &bss->dpp_netaccesskey, pos))
4538 return 1;
4539 } else if (os_strcmp(buf, "dpp_netaccesskey_expiry") == 0) {
4540 bss->dpp_netaccesskey_expiry = strtol(pos, NULL, 0);
4541 } else if (os_strcmp(buf, "dpp_csign") == 0) {
4542 if (parse_wpabuf_hex(line, buf, &bss->dpp_csign, pos))
4543 return 1;
4544#ifdef CONFIG_DPP2
4545 } else if (os_strcmp(buf, "dpp_controller") == 0) {
4546 if (hostapd_dpp_controller_parse(bss, pos))
4547 return 1;
4548 } else if (os_strcmp(buf, "dpp_relay_port") == 0) {
4549 bss->dpp_relay_port = atoi(pos);
4550 } else if (os_strcmp(buf, "dpp_configurator_connectivity") == 0) {
4551 bss->dpp_configurator_connectivity = atoi(pos);
4552 } else if (os_strcmp(buf, "dpp_pfs") == 0) {
4553 int val = atoi(pos);
4554
4555 if (val < 0 || val > 2) {
4556 wpa_printf(MSG_ERROR,
4557 "Line %d: Invalid dpp_pfs value '%s'",
4558 line, pos);
4559 return -1;
4560 }
4561 bss->dpp_pfs = val;
4562#endif /* CONFIG_DPP2 */
4563#endif /* CONFIG_DPP */
4564#ifdef CONFIG_OWE
4565 } else if (os_strcmp(buf, "owe_transition_bssid") == 0) {
4566 if (hwaddr_aton(pos, bss->owe_transition_bssid)) {
4567 wpa_printf(MSG_ERROR,
4568 "Line %d: invalid owe_transition_bssid",
4569 line);
4570 return 1;
4571 }
4572 } else if (os_strcmp(buf, "owe_transition_ssid") == 0) {
4573 size_t slen;
4574 char *str = wpa_config_parse_string(pos, &slen);
4575
4576 if (!str || slen < 1 || slen > SSID_MAX_LEN) {
4577 wpa_printf(MSG_ERROR, "Line %d: invalid SSID '%s'",
4578 line, pos);
4579 os_free(str);
4580 return 1;
4581 }
4582 os_memcpy(bss->owe_transition_ssid, str, slen);
4583 bss->owe_transition_ssid_len = slen;
4584 os_free(str);
4585 } else if (os_strcmp(buf, "owe_transition_ifname") == 0) {
4586 os_strlcpy(bss->owe_transition_ifname, pos,
4587 sizeof(bss->owe_transition_ifname));
4588 } else if (os_strcmp(buf, "owe_groups") == 0) {
4589 if (hostapd_parse_intlist(&bss->owe_groups, pos)) {
4590 wpa_printf(MSG_ERROR,
4591 "Line %d: Invalid owe_groups value '%s'",
4592 line, pos);
4593 return 1;
4594 }
4595 } else if (os_strcmp(buf, "owe_ptk_workaround") == 0) {
4596 bss->owe_ptk_workaround = atoi(pos);
4597#endif /* CONFIG_OWE */
4598 } else if (os_strcmp(buf, "coloc_intf_reporting") == 0) {
4599 bss->coloc_intf_reporting = atoi(pos);
4600 } else if (os_strcmp(buf, "multi_ap") == 0) {
4601 int val = atoi(pos);
4602
4603 if (val < 0 || val > 3) {
4604 wpa_printf(MSG_ERROR, "Line %d: Invalid multi_ap '%s'",
4605 line, buf);
4606 return -1;
4607 }
4608
4609 bss->multi_ap = val;
4610 } else if (os_strcmp(buf, "rssi_reject_assoc_rssi") == 0) {
4611 conf->rssi_reject_assoc_rssi = atoi(pos);
4612 } else if (os_strcmp(buf, "rssi_reject_assoc_timeout") == 0) {
4613 conf->rssi_reject_assoc_timeout = atoi(pos);
4614 } else if (os_strcmp(buf, "rssi_ignore_probe_request") == 0) {
4615 conf->rssi_ignore_probe_request = atoi(pos);
4616 } else if (os_strcmp(buf, "pbss") == 0) {
4617 bss->pbss = atoi(pos);
4618 } else if (os_strcmp(buf, "transition_disable") == 0) {
4619 bss->transition_disable = strtol(pos, NULL, 16);
4620#ifdef CONFIG_AIRTIME_POLICY
4621 } else if (os_strcmp(buf, "airtime_mode") == 0) {
4622 int val = atoi(pos);
4623
4624 if (val < 0 || val > AIRTIME_MODE_MAX) {
4625 wpa_printf(MSG_ERROR, "Line %d: Unknown airtime_mode",
4626 line);
4627 return 1;
4628 }
4629 conf->airtime_mode = val;
4630 } else if (os_strcmp(buf, "airtime_update_interval") == 0) {
4631 conf->airtime_update_interval = atoi(pos);
4632 } else if (os_strcmp(buf, "airtime_bss_weight") == 0) {
4633 bss->airtime_weight = atoi(pos);
4634 } else if (os_strcmp(buf, "airtime_bss_limit") == 0) {
4635 int val = atoi(pos);
4636
4637 if (val < 0 || val > 1) {
4638 wpa_printf(MSG_ERROR,
4639 "Line %d: Invalid airtime_bss_limit (must be 0 or 1)",
4640 line);
4641 return 1;
4642 }
4643 bss->airtime_limit = val;
4644 } else if (os_strcmp(buf, "airtime_sta_weight") == 0) {
4645 if (add_airtime_weight(bss, pos) < 0) {
4646 wpa_printf(MSG_ERROR,
4647 "Line %d: Invalid airtime weight '%s'",
4648 line, pos);
4649 return 1;
4650 }
4651#endif /* CONFIG_AIRTIME_POLICY */
4652#ifdef CONFIG_MACSEC
4653 } else if (os_strcmp(buf, "macsec_policy") == 0) {
4654 int macsec_policy = atoi(pos);
4655
4656 if (macsec_policy < 0 || macsec_policy > 1) {
4657 wpa_printf(MSG_ERROR,
4658 "Line %d: invalid macsec_policy (%d): '%s'.",
4659 line, macsec_policy, pos);
4660 return 1;
4661 }
4662 bss->macsec_policy = macsec_policy;
4663 } else if (os_strcmp(buf, "macsec_integ_only") == 0) {
4664 int macsec_integ_only = atoi(pos);
4665
4666 if (macsec_integ_only < 0 || macsec_integ_only > 1) {
4667 wpa_printf(MSG_ERROR,
4668 "Line %d: invalid macsec_integ_only (%d): '%s'.",
4669 line, macsec_integ_only, pos);
4670 return 1;
4671 }
4672 bss->macsec_integ_only = macsec_integ_only;
4673 } else if (os_strcmp(buf, "macsec_replay_protect") == 0) {
4674 int macsec_replay_protect = atoi(pos);
4675
4676 if (macsec_replay_protect < 0 || macsec_replay_protect > 1) {
4677 wpa_printf(MSG_ERROR,
4678 "Line %d: invalid macsec_replay_protect (%d): '%s'.",
4679 line, macsec_replay_protect, pos);
4680 return 1;
4681 }
4682 bss->macsec_replay_protect = macsec_replay_protect;
4683 } else if (os_strcmp(buf, "macsec_replay_window") == 0) {
4684 bss->macsec_replay_window = atoi(pos);
4685 } else if (os_strcmp(buf, "macsec_offload") == 0) {
4686 int macsec_offload = atoi(pos);
4687
4688 if (macsec_offload < 0 || macsec_offload > 2) {
4689 wpa_printf(MSG_ERROR,
4690 "Line %d: invalid macsec_offload (%d): '%s'.",
4691 line, macsec_offload, pos);
4692 return 1;
4693 }
4694 bss->macsec_offload = macsec_offload;
4695 } else if (os_strcmp(buf, "macsec_port") == 0) {
4696 int macsec_port = atoi(pos);
4697
4698 if (macsec_port < 1 || macsec_port > 65534) {
4699 wpa_printf(MSG_ERROR,
4700 "Line %d: invalid macsec_port (%d): '%s'.",
4701 line, macsec_port, pos);
4702 return 1;
4703 }
4704 bss->macsec_port = macsec_port;
4705 } else if (os_strcmp(buf, "mka_priority") == 0) {
4706 int mka_priority = atoi(pos);
4707
4708 if (mka_priority < 0 || mka_priority > 255) {
4709 wpa_printf(MSG_ERROR,
4710 "Line %d: invalid mka_priority (%d): '%s'.",
4711 line, mka_priority, pos);
4712 return 1;
4713 }
4714 bss->mka_priority = mka_priority;
4715 } else if (os_strcmp(buf, "macsec_csindex") == 0) {
4716 int macsec_csindex = atoi(pos);
4717
4718 if (macsec_csindex < 0 || macsec_csindex > 1) {
4719 wpa_printf(MSG_ERROR,
4720 "Line %d: invalid macsec_csindex (%d): '%s'.",
4721 line, macsec_csindex, pos);
4722 return 1;
4723 }
4724 bss->macsec_csindex = macsec_csindex;
4725 } else if (os_strcmp(buf, "mka_cak") == 0) {
4726 size_t len = os_strlen(pos);
4727
4728 if (len > 2 * MACSEC_CAK_MAX_LEN ||
4729 (len != 2 * 16 && len != 2 * 32) ||
4730 hexstr2bin(pos, bss->mka_cak, len / 2)) {
4731 wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CAK '%s'.",
4732 line, pos);
4733 return 1;
4734 }
4735 bss->mka_cak_len = len / 2;
4736 bss->mka_psk_set |= MKA_PSK_SET_CAK;
4737 } else if (os_strcmp(buf, "mka_ckn") == 0) {
4738 size_t len = os_strlen(pos);
4739
4740 if (len > 2 * MACSEC_CKN_MAX_LEN || /* too long */
4741 len < 2 || /* too short */
4742 len % 2 != 0 /* not an integral number of bytes */) {
4743 wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.",
4744 line, pos);
4745 return 1;
4746 }
4747 bss->mka_ckn_len = len / 2;
4748 if (hexstr2bin(pos, bss->mka_ckn, bss->mka_ckn_len)) {
4749 wpa_printf(MSG_ERROR, "Line %d: Invalid MKA-CKN '%s'.",
4750 line, pos);
4751 return -1;
4752 }
4753 bss->mka_psk_set |= MKA_PSK_SET_CKN;
4754#endif /* CONFIG_MACSEC */
4755 } else if (os_strcmp(buf, "disable_11n") == 0) {
4756 bss->disable_11n = !!atoi(pos);
4757 } else if (os_strcmp(buf, "disable_11ac") == 0) {
4758 bss->disable_11ac = !!atoi(pos);
4759 } else if (os_strcmp(buf, "disable_11ax") == 0) {
4760 bss->disable_11ax = !!atoi(pos);
4761 } else if (os_strcmp(buf, "disable_11be") == 0) {
4762 bss->disable_11be = !!atoi(pos);
4763#ifdef CONFIG_PASN
4764#ifdef CONFIG_TESTING_OPTIONS
4765 } else if (os_strcmp(buf, "force_kdk_derivation") == 0) {
4766 bss->force_kdk_derivation = atoi(pos);
4767 } else if (os_strcmp(buf, "pasn_corrupt_mic") == 0) {
4768 bss->pasn_corrupt_mic = atoi(pos);
4769#endif /* CONFIG_TESTING_OPTIONS */
4770 } else if (os_strcmp(buf, "pasn_groups") == 0) {
4771 if (hostapd_parse_intlist(&bss->pasn_groups, pos)) {
4772 wpa_printf(MSG_ERROR,
4773 "Line %d: Invalid pasn_groups value '%s'",
4774 line, pos);
4775 return 1;
4776 }
4777 } else if (os_strcmp(buf, "pasn_comeback_after") == 0) {
4778 bss->pasn_comeback_after = atoi(pos);
4779 } else if (os_strcmp(buf, "pasn_noauth") == 0) {
4780 bss->pasn_noauth = atoi(pos);
4781#endif /* CONFIG_PASN */
4782 } else if (os_strcmp(buf, "ext_capa_mask") == 0) {
4783 if (get_hex_config(bss->ext_capa_mask, EXT_CAPA_MAX_LEN,
4784 line, "ext_capa_mask", pos))
4785 return 1;
4786 } else if (os_strcmp(buf, "ext_capa") == 0) {
4787 if (get_hex_config(bss->ext_capa, EXT_CAPA_MAX_LEN,
4788 line, "ext_capa", pos))
4789 return 1;
4790 } else if (os_strcmp(buf, "rnr") == 0) {
4791 bss->rnr = atoi(pos);
4792#ifdef CONFIG_IEEE80211BE
4793 } else if (os_strcmp(buf, "ieee80211be") == 0) {
4794 conf->ieee80211be = atoi(pos);
4795 } else if (os_strcmp(buf, "eht_oper_chwidth") == 0) {
4796 conf->eht_oper_chwidth = atoi(pos);
4797 } else if (os_strcmp(buf, "eht_oper_centr_freq_seg0_idx") == 0) {
4798 conf->eht_oper_centr_freq_seg0_idx = atoi(pos);
4799 } else if (os_strcmp(buf, "eht_su_beamformer") == 0) {
4800 conf->eht_phy_capab.su_beamformer = atoi(pos);
4801 } else if (os_strcmp(buf, "eht_su_beamformee") == 0) {
4802 conf->eht_phy_capab.su_beamformee = atoi(pos);
4803 } else if (os_strcmp(buf, "eht_mu_beamformer") == 0) {
4804 conf->eht_phy_capab.mu_beamformer = atoi(pos);
4805 } else if (os_strcmp(buf, "punct_bitmap") == 0) {
4806 conf->punct_bitmap = atoi(pos);
4807 } else if (os_strcmp(buf, "punct_acs_threshold") == 0) {
4808 int val = atoi(pos);
4809
4810 if (val < 0 || val > 100) {
4811 wpa_printf(MSG_ERROR,
4812 "Line %d: punct_acs_threshold must be between 0 and 100",
4813 line);
4814 return 1;
4815 }
4816 conf->punct_acs_threshold = val;
4817 } else if (os_strcmp(buf, "mld_ap") == 0) {
4818 bss->mld_ap = !!atoi(pos);
4819 } else if (os_strcmp(buf, "mld_id") == 0) {
4820 bss->mld_id = atoi(pos);
4821#endif /* CONFIG_IEEE80211BE */
4822 } else {
4823 wpa_printf(MSG_ERROR,
4824 "Line %d: unknown configuration item '%s'",
4825 line, buf);
4826
4827 wpa_printf(MSG_ERROR, "Ignoring invalid values");
4828 return 0;
4829 }
4830
4831 return 0;
4832}
4833
4834
4835/**
4836 * hostapd_config_read - Read and parse a configuration file
4837 * @fname: Configuration file name (including path, if needed)
4838 * Returns: Allocated configuration data structure
4839 */
4840struct hostapd_config * hostapd_config_read(const char *fname)
4841{
4842 struct hostapd_config *conf;
4843 FILE *f;
4844 char buf[4096], *pos;
4845 int line = 0;
4846 int errors = 0;
4847 size_t i;
4848
4849 f = fopen(fname, "r");
4850 if (f == NULL) {
4851 wpa_printf(MSG_ERROR, "Could not open configuration file '%s' "
4852 "for reading.", fname);
4853 return NULL;
4854 }
4855
4856 conf = hostapd_config_defaults();
4857 if (conf == NULL) {
4858 fclose(f);
4859 return NULL;
4860 }
4861
4862 /* set default driver based on configuration */
4863 conf->driver = wpa_drivers[0];
4864 if (conf->driver == NULL) {
4865 wpa_printf(MSG_ERROR, "No driver wrappers registered!");
4866 hostapd_config_free(conf);
4867 fclose(f);
4868 return NULL;
4869 }
4870
4871 conf->last_bss = conf->bss[0];
4872
4873 while (fgets(buf, sizeof(buf), f)) {
4874 struct hostapd_bss_config *bss;
4875
4876 bss = conf->last_bss;
4877 line++;
4878
4879 if (buf[0] == '#')
4880 continue;
4881 pos = buf;
4882 while (*pos != '\0') {
4883 if (*pos == '\n') {
4884 *pos = '\0';
4885 break;
4886 }
4887 pos++;
4888 }
4889 if (buf[0] == '\0')
4890 continue;
4891
4892 pos = os_strchr(buf, '=');
4893 if (pos == NULL) {
4894 wpa_printf(MSG_ERROR, "Line %d: invalid line '%s'",
4895 line, buf);
4896 errors++;
4897 continue;
4898 }
4899 *pos = '\0';
4900 pos++;
4901 errors += hostapd_config_fill(conf, bss, buf, pos, line);
4902 }
4903
4904 fclose(f);
4905
4906 for (i = 0; i < conf->num_bss; i++)
4907 hostapd_set_security_params(conf->bss[i], 1);
4908
4909 if (hostapd_config_check(conf, 1))
4910 errors++;
4911
4912#ifdef CONFIG_DFS_CAC_TIMER
4913 wpa_printf(MSG_INFO, "config, dfs_cac_s:%d", conf->dfs_cac_s);
4914#endif /* CONFIG_DFS_CAC_TIMER */
4915
4916#ifdef CONFIG_24G_BW_SWITCH
4917 wpa_printf(MSG_INFO, "config, obss_interval:%d, ht_coex:%d, auto_20m_40m:%d",
4918 conf->obss_interval, !conf->no_ht_coex, conf->auto_20m_40m);
4919 if (!conf->auto_20m_40m)
4920 conf->obss_interval = 0;
4921#endif /* CONFIG_24G_BW_SWITCH */
4922
4923#ifdef CONFIG_5G_BW_SWITCH
4924 wpa_printf(MSG_INFO, "config, auto_80m:%d", conf->auto_80m);
4925#endif /* CONFIG_5G_BW_SWITCH */
4926
4927#ifdef CONFIG_BSS_TRANS_IMPL
4928 wpa_printf(MSG_INFO, "config, bss_transition:%d", conf->bss[0]->bss_transition);
4929 wpa_printf(MSG_INFO, "config, radio_measurements:0x%x", conf->bss[0]->radio_measurements[0]);
4930#endif /* CONFIG_BSS_TRANS_IMPL */
4931
4932#ifndef WPA_IGNORE_CONFIG_ERRORS
4933 if (errors) {
4934 wpa_printf(MSG_ERROR, "%d errors found in configuration file "
4935 "'%s'", errors, fname);
4936 hostapd_config_free(conf);
4937 conf = NULL;
4938 }
4939#endif /* WPA_IGNORE_CONFIG_ERRORS */
4940
4941 return conf;
4942}
4943
4944
4945int hostapd_set_iface(struct hostapd_config *conf,
4946 struct hostapd_bss_config *bss, const char *field,
4947 char *value)
4948{
4949 int errors;
4950 size_t i;
4951
4952 errors = hostapd_config_fill(conf, bss, field, value, 0);
4953 if (errors) {
4954 wpa_printf(MSG_INFO, "Failed to set configuration field '%s' "
4955 "to value '%s'", field, value);
4956 return -1;
4957 }
4958
4959 for (i = 0; i < conf->num_bss; i++)
4960 hostapd_set_security_params(conf->bss[i], 0);
4961
4962 if (hostapd_config_check(conf, 0)) {
4963 wpa_printf(MSG_ERROR, "Configuration check failed");
4964 return -1;
4965 }
4966
4967 return 0;
4968}