2 * hostapd / Configuration file parser
3 * Copyright (c) 2003-2018, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
10 #ifndef CONFIG_NATIVE_WINDOWS
12 #endif /* CONFIG_NATIVE_WINDOWS */
14 #include "utils/common.h"
15 #include "utils/uuid.h"
16 #include "common/ieee802_11_defs.h"
17 #include "crypto/sha256.h"
18 #include "crypto/tls.h"
19 #include "drivers/driver.h"
20 #include "eap_server/eap.h"
21 #include "radius/radius_client.h"
22 #include "ap/wpa_auth.h"
23 #include "ap/ap_config.h"
24 #include "config_file.h"
27 #ifndef CONFIG_NO_RADIUS
29 static struct hostapd_radius_attr
*
30 hostapd_parse_radius_attr(const char *value
);
31 #endif /* EAP_SERVER */
32 #endif /* CONFIG_NO_RADIUS */
35 #ifndef CONFIG_NO_VLAN
36 static int hostapd_config_read_vlan_file(struct hostapd_bss_config
*bss
,
40 char buf
[128], *pos
, *pos2
, *pos3
;
41 int line
= 0, vlan_id
;
42 struct hostapd_vlan
*vlan
;
44 f
= fopen(fname
, "r");
46 wpa_printf(MSG_ERROR
, "VLAN file '%s' not readable.", fname
);
50 while (fgets(buf
, sizeof(buf
), f
)) {
56 while (*pos
!= '\0') {
67 vlan_id
= VLAN_ID_WILDCARD
;
70 vlan_id
= strtol(buf
, &pos
, 10);
71 if (buf
== pos
|| vlan_id
< 1 ||
72 vlan_id
> MAX_VLAN_ID
) {
73 wpa_printf(MSG_ERROR
, "Invalid VLAN ID at "
74 "line %d in '%s'", line
, fname
);
80 while (*pos
== ' ' || *pos
== '\t')
83 while (*pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '\0')
89 if (*pos
== '\0' || os_strlen(pos
) > IFNAMSIZ
) {
90 wpa_printf(MSG_ERROR
, "Invalid VLAN ifname at line %d "
91 "in '%s'", line
, fname
);
96 while (*pos2
== ' ' || *pos2
== '\t')
99 while (*pos3
!= ' ' && *pos3
!= '\t' && *pos3
!= '\0')
103 vlan
= os_zalloc(sizeof(*vlan
));
105 wpa_printf(MSG_ERROR
, "Out of memory while reading "
106 "VLAN interfaces from '%s'", fname
);
111 vlan
->vlan_id
= vlan_id
;
112 vlan
->vlan_desc
.untagged
= vlan_id
;
113 vlan
->vlan_desc
.notempty
= !!vlan_id
;
114 os_strlcpy(vlan
->ifname
, pos
, sizeof(vlan
->ifname
));
115 os_strlcpy(vlan
->bridge
, pos2
, sizeof(vlan
->bridge
));
116 vlan
->next
= bss
->vlan
;
124 #endif /* CONFIG_NO_VLAN */
127 int hostapd_acl_comp(const void *a
, const void *b
)
129 const struct mac_acl_entry
*aa
= a
;
130 const struct mac_acl_entry
*bb
= b
;
131 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
135 int hostapd_add_acl_maclist(struct mac_acl_entry
**acl
, int *num
,
136 int vlan_id
, const u8
*addr
)
138 struct mac_acl_entry
*newacl
;
140 newacl
= os_realloc_array(*acl
, *num
+ 1, sizeof(**acl
));
142 wpa_printf(MSG_ERROR
, "MAC list reallocation failed");
147 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
148 os_memset(&(*acl
)[*num
].vlan_id
, 0, sizeof((*acl
)[*num
].vlan_id
));
149 (*acl
)[*num
].vlan_id
.untagged
= vlan_id
;
150 (*acl
)[*num
].vlan_id
.notempty
= !!vlan_id
;
157 void hostapd_remove_acl_mac(struct mac_acl_entry
**acl
, int *num
,
163 if (os_memcmp((*acl
)[i
].addr
, addr
, ETH_ALEN
) == 0) {
164 os_remove_in_array(*acl
, *num
, sizeof(**acl
), i
);
173 static int hostapd_config_read_maclist(const char *fname
,
174 struct mac_acl_entry
**acl
, int *num
)
182 f
= fopen(fname
, "r");
184 wpa_printf(MSG_ERROR
, "MAC list file '%s' not found.", fname
);
188 while (fgets(buf
, sizeof(buf
), f
)) {
196 while (*pos
!= '\0') {
211 if (hwaddr_aton(pos
, addr
)) {
212 wpa_printf(MSG_ERROR
, "Invalid MAC address '%s' at "
213 "line %d in '%s'", pos
, line
, fname
);
219 hostapd_remove_acl_mac(acl
, num
, addr
);
224 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
226 while (*pos
== ' ' || *pos
== '\t')
231 if (hostapd_add_acl_maclist(acl
, num
, vlan_id
, addr
) < 0) {
240 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
248 static int hostapd_config_eap_user_salted(struct hostapd_eap_user
*user
,
249 const char *hash
, size_t len
,
250 char **pos
, int line
,
255 while (*pos2
!= '\0' && *pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '#')
258 if (pos2
- *pos
< (int) (2 * (len
+ 1))) { /* at least 1 byte of salt */
259 wpa_printf(MSG_ERROR
,
260 "Invalid salted %s hash on line %d in '%s'",
265 user
->password
= os_malloc(len
);
266 if (!user
->password
) {
267 wpa_printf(MSG_ERROR
,
268 "Failed to allocate memory for salted %s hash",
273 if (hexstr2bin(*pos
, user
->password
, len
) < 0) {
274 wpa_printf(MSG_ERROR
,
275 "Invalid salted password on line %d in '%s'",
279 user
->password_len
= len
;
282 user
->salt_len
= (pos2
- *pos
) / 2;
283 user
->salt
= os_malloc(user
->salt_len
);
285 wpa_printf(MSG_ERROR
,
286 "Failed to allocate memory for salted %s hash",
291 if (hexstr2bin(*pos
, user
->salt
, user
->salt_len
) < 0) {
292 wpa_printf(MSG_ERROR
,
293 "Invalid salt for password on line %d in '%s'",
303 static int hostapd_config_read_eap_user(const char *fname
,
304 struct hostapd_bss_config
*conf
)
307 char buf
[512], *pos
, *start
, *pos2
;
308 int line
= 0, ret
= 0, num_methods
;
309 struct hostapd_eap_user
*user
= NULL
, *tail
= NULL
, *new_user
= NULL
;
311 if (os_strncmp(fname
, "sqlite:", 7) == 0) {
313 os_free(conf
->eap_user_sqlite
);
314 conf
->eap_user_sqlite
= os_strdup(fname
+ 7);
316 #else /* CONFIG_SQLITE */
317 wpa_printf(MSG_ERROR
,
318 "EAP user file in SQLite DB, but CONFIG_SQLITE was not enabled in the build.");
320 #endif /* CONFIG_SQLITE */
323 f
= fopen(fname
, "r");
325 wpa_printf(MSG_ERROR
, "EAP user file '%s' not found.", fname
);
329 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
330 while (fgets(buf
, sizeof(buf
), f
)) {
336 while (*pos
!= '\0') {
346 #ifndef CONFIG_NO_RADIUS
347 if (user
&& os_strncmp(buf
, "radius_accept_attr=", 19) == 0) {
348 struct hostapd_radius_attr
*attr
, *a
;
349 attr
= hostapd_parse_radius_attr(buf
+ 19);
351 wpa_printf(MSG_ERROR
, "Invalid radius_auth_req_attr: %s",
353 user
= NULL
; /* already in the BSS list */
356 if (user
->accept_attr
== NULL
) {
357 user
->accept_attr
= attr
;
359 a
= user
->accept_attr
;
366 #endif /* CONFIG_NO_RADIUS */
370 if (buf
[0] != '"' && buf
[0] != '*') {
371 wpa_printf(MSG_ERROR
, "Invalid EAP identity (no \" in "
372 "start) on line %d in '%s'", line
, fname
);
376 user
= os_zalloc(sizeof(*user
));
378 wpa_printf(MSG_ERROR
, "EAP user allocation failed");
381 user
->force_version
= -1;
388 while (*pos
!= '"' && *pos
!= '\0')
391 wpa_printf(MSG_ERROR
, "Invalid EAP identity "
392 "(no \" in end) on line %d in '%s'",
397 user
->identity
= os_memdup(start
, pos
- start
);
398 if (user
->identity
== NULL
) {
399 wpa_printf(MSG_ERROR
, "Failed to allocate "
400 "memory for EAP identity");
403 user
->identity_len
= pos
- start
;
405 if (pos
[0] == '"' && pos
[1] == '*') {
406 user
->wildcard_prefix
= 1;
411 while (*pos
== ' ' || *pos
== '\t')
415 wpa_printf(MSG_ERROR
, "No EAP method on line %d in "
416 "'%s'", line
, fname
);
421 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
431 char *pos3
= os_strchr(start
, ',');
435 user
->methods
[num_methods
].method
=
438 &user
->methods
[num_methods
].vendor
);
439 if (user
->methods
[num_methods
].vendor
==
441 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
443 if (os_strcmp(start
, "TTLS-PAP") == 0) {
444 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
447 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
448 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
451 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
453 EAP_TTLS_AUTH_MSCHAP
;
456 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
458 EAP_TTLS_AUTH_MSCHAPV2
;
461 if (os_strcmp(start
, "MACACL") == 0) {
465 wpa_printf(MSG_ERROR
, "Unsupported EAP type "
466 "'%s' on line %d in '%s'",
472 if (num_methods
>= EAP_MAX_METHODS
)
479 if (num_methods
== 0 && user
->ttls_auth
== 0 && !user
->macacl
) {
480 wpa_printf(MSG_ERROR
, "No EAP types configured on "
481 "line %d in '%s'", line
, fname
);
488 while (*pos
== ' ' || *pos
== '\t')
493 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
494 user
->force_version
= 0;
498 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
499 user
->force_version
= 1;
503 if (os_strncmp(pos
, "[2]", 3) == 0) {
511 while (*pos
!= '"' && *pos
!= '\0')
514 wpa_printf(MSG_ERROR
, "Invalid EAP password "
515 "(no \" in end) on line %d in '%s'",
520 user
->password
= os_memdup(start
, pos
- start
);
521 if (user
->password
== NULL
) {
522 wpa_printf(MSG_ERROR
, "Failed to allocate "
523 "memory for EAP password");
526 user
->password_len
= pos
- start
;
529 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
532 while (*pos2
!= '\0' && *pos2
!= ' ' &&
533 *pos2
!= '\t' && *pos2
!= '#')
535 if (pos2
- pos
!= 32) {
536 wpa_printf(MSG_ERROR
, "Invalid password hash "
537 "on line %d in '%s'", line
, fname
);
540 user
->password
= os_malloc(16);
541 if (user
->password
== NULL
) {
542 wpa_printf(MSG_ERROR
, "Failed to allocate "
543 "memory for EAP password hash");
546 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
547 wpa_printf(MSG_ERROR
, "Invalid hash password "
548 "on line %d in '%s'", line
, fname
);
551 user
->password_len
= 16;
552 user
->password_hash
= 1;
554 } else if (os_strncmp(pos
, "ssha1:", 6) == 0) {
556 if (hostapd_config_eap_user_salted(user
, "sha1", 20,
560 } else if (os_strncmp(pos
, "ssha256:", 8) == 0) {
562 if (hostapd_config_eap_user_salted(user
, "sha256", 32,
566 } else if (os_strncmp(pos
, "ssha512:", 8) == 0) {
568 if (hostapd_config_eap_user_salted(user
, "sha512", 64,
574 while (*pos2
!= '\0' && *pos2
!= ' ' &&
575 *pos2
!= '\t' && *pos2
!= '#')
577 if ((pos2
- pos
) & 1) {
578 wpa_printf(MSG_ERROR
, "Invalid hex password "
579 "on line %d in '%s'", line
, fname
);
582 user
->password
= os_malloc((pos2
- pos
) / 2);
583 if (user
->password
== NULL
) {
584 wpa_printf(MSG_ERROR
, "Failed to allocate "
585 "memory for EAP password");
588 if (hexstr2bin(pos
, user
->password
,
589 (pos2
- pos
) / 2) < 0) {
590 wpa_printf(MSG_ERROR
, "Invalid hex password "
591 "on line %d in '%s'", line
, fname
);
594 user
->password_len
= (pos2
- pos
) / 2;
598 while (*pos
== ' ' || *pos
== '\t')
600 if (os_strncmp(pos
, "[2]", 3) == 0) {
606 tail
= new_user
= user
;
615 hostapd_config_free_eap_user(user
);
623 hostapd_config_free_eap_users(conf
->eap_user
);
624 conf
->eap_user
= new_user
;
626 hostapd_config_free_eap_users(new_user
);
632 #endif /* EAP_SERVER */
635 #ifndef CONFIG_NO_RADIUS
637 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
638 int *num_server
, const char *val
, int def_port
,
639 struct hostapd_radius_server
**curr_serv
)
641 struct hostapd_radius_server
*nserv
;
643 static int server_index
= 1;
645 nserv
= os_realloc_array(*server
, *num_server
+ 1, sizeof(*nserv
));
650 nserv
= &nserv
[*num_server
];
652 (*curr_serv
) = nserv
;
654 os_memset(nserv
, 0, sizeof(*nserv
));
655 nserv
->port
= def_port
;
656 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
657 nserv
->index
= server_index
++;
663 static struct hostapd_radius_attr
*
664 hostapd_parse_radius_attr(const char *value
)
668 struct hostapd_radius_attr
*attr
;
671 attr
= os_zalloc(sizeof(*attr
));
675 attr
->type
= atoi(value
);
677 pos
= os_strchr(value
, ':');
679 attr
->val
= wpabuf_alloc(1);
680 if (attr
->val
== NULL
) {
684 wpabuf_put_u8(attr
->val
, 0);
689 if (pos
[0] == '\0' || pos
[1] != ':') {
698 attr
->val
= wpabuf_alloc_copy(pos
, os_strlen(pos
));
701 len
= os_strlen(pos
);
705 attr
->val
= wpabuf_alloc(len
);
706 if (attr
->val
== NULL
)
708 if (hexstr2bin(pos
, wpabuf_put(attr
->val
, len
), len
) < 0) {
709 wpabuf_free(attr
->val
);
715 attr
->val
= wpabuf_alloc(4);
717 wpabuf_put_be32(attr
->val
, atoi(pos
));
724 if (attr
->val
== NULL
) {
733 static int hostapd_parse_das_client(struct hostapd_bss_config
*bss
, char *val
)
737 secret
= os_strchr(val
, ' ');
743 if (hostapd_parse_ip_addr(val
, &bss
->radius_das_client_addr
))
746 os_free(bss
->radius_das_shared_secret
);
747 bss
->radius_das_shared_secret
= (u8
*) os_strdup(secret
);
748 if (bss
->radius_das_shared_secret
== NULL
)
750 bss
->radius_das_shared_secret_len
= os_strlen(secret
);
754 #endif /* CONFIG_NO_RADIUS */
757 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
760 char *start
, *end
, *buf
;
762 buf
= os_strdup(value
);
767 while (*start
!= '\0') {
768 while (*start
== ' ' || *start
== '\t')
773 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
777 if (os_strcmp(start
, "WPA-PSK") == 0)
778 val
|= WPA_KEY_MGMT_PSK
;
779 else if (os_strcmp(start
, "WPA-EAP") == 0)
780 val
|= WPA_KEY_MGMT_IEEE8021X
;
781 #ifdef CONFIG_IEEE80211R_AP
782 else if (os_strcmp(start
, "FT-PSK") == 0)
783 val
|= WPA_KEY_MGMT_FT_PSK
;
784 else if (os_strcmp(start
, "FT-EAP") == 0)
785 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
787 else if (os_strcmp(start
, "FT-EAP-SHA384") == 0)
788 val
|= WPA_KEY_MGMT_FT_IEEE8021X_SHA384
;
789 #endif /* CONFIG_SHA384 */
790 #endif /* CONFIG_IEEE80211R_AP */
791 #ifdef CONFIG_IEEE80211W
792 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
793 val
|= WPA_KEY_MGMT_PSK_SHA256
;
794 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
795 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
796 #endif /* CONFIG_IEEE80211W */
798 else if (os_strcmp(start
, "SAE") == 0)
799 val
|= WPA_KEY_MGMT_SAE
;
800 else if (os_strcmp(start
, "FT-SAE") == 0)
801 val
|= WPA_KEY_MGMT_FT_SAE
;
802 #endif /* CONFIG_SAE */
804 else if (os_strcmp(start
, "WPA-EAP-SUITE-B") == 0)
805 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B
;
806 #endif /* CONFIG_SUITEB */
807 #ifdef CONFIG_SUITEB192
808 else if (os_strcmp(start
, "WPA-EAP-SUITE-B-192") == 0)
809 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192
;
810 #endif /* CONFIG_SUITEB192 */
812 else if (os_strcmp(start
, "FILS-SHA256") == 0)
813 val
|= WPA_KEY_MGMT_FILS_SHA256
;
814 else if (os_strcmp(start
, "FILS-SHA384") == 0)
815 val
|= WPA_KEY_MGMT_FILS_SHA384
;
816 #ifdef CONFIG_IEEE80211R_AP
817 else if (os_strcmp(start
, "FT-FILS-SHA256") == 0)
818 val
|= WPA_KEY_MGMT_FT_FILS_SHA256
;
819 else if (os_strcmp(start
, "FT-FILS-SHA384") == 0)
820 val
|= WPA_KEY_MGMT_FT_FILS_SHA384
;
821 #endif /* CONFIG_IEEE80211R_AP */
822 #endif /* CONFIG_FILS */
824 else if (os_strcmp(start
, "OWE") == 0)
825 val
|= WPA_KEY_MGMT_OWE
;
826 #endif /* CONFIG_OWE */
828 else if (os_strcmp(start
, "DPP") == 0)
829 val
|= WPA_KEY_MGMT_DPP
;
830 #endif /* CONFIG_DPP */
832 else if (os_strcmp(start
, "OSEN") == 0)
833 val
|= WPA_KEY_MGMT_OSEN
;
834 #endif /* CONFIG_HS20 */
836 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
849 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
850 "configured.", line
);
858 static int hostapd_config_parse_cipher(int line
, const char *value
)
860 int val
= wpa_parse_cipher(value
);
862 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
867 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
875 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
878 size_t len
= os_strlen(val
);
880 if (keyidx
< 0 || keyidx
> 3)
886 bin_clear_free(wep
->key
[keyidx
], wep
->len
[keyidx
]);
887 wep
->key
[keyidx
] = NULL
;
888 wep
->len
[keyidx
] = 0;
889 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
898 if (wep
->key
[keyidx
] != NULL
)
902 if (len
< 2 || val
[len
- 1] != '"')
905 wep
->key
[keyidx
] = os_memdup(val
+ 1, len
);
906 if (wep
->key
[keyidx
] == NULL
)
908 wep
->len
[keyidx
] = len
;
913 wep
->key
[keyidx
] = os_malloc(len
);
914 if (wep
->key
[keyidx
] == NULL
)
916 wep
->len
[keyidx
] = len
;
917 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
927 static int hostapd_parse_chanlist(struct hostapd_config
*conf
, char *val
)
931 /* for backwards compatibility, translate ' ' in conf str to ',' */
934 pos
= os_strchr(pos
, ' ');
938 if (freq_range_list_parse(&conf
->acs_ch_list
, val
))
945 static int hostapd_parse_intlist(int **int_list
, char *val
)
956 while (*pos
!= '\0') {
962 list
= os_malloc(sizeof(int) * (count
+ 2));
967 while (*pos
!= '\0') {
968 end
= os_strchr(pos
, ' ');
972 list
[count
++] = atoi(pos
);
984 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
986 struct hostapd_bss_config
**all
, *bss
;
991 all
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
992 sizeof(struct hostapd_bss_config
*));
994 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
1000 bss
= os_zalloc(sizeof(*bss
));
1003 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
1004 if (bss
->radius
== NULL
) {
1005 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
1006 "multi-BSS RADIUS data");
1011 conf
->bss
[conf
->num_bss
++] = bss
;
1012 conf
->last_bss
= bss
;
1014 hostapd_config_defaults_bss(bss
);
1015 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
1016 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
1022 /* convert floats with one decimal place to value*10 int, i.e.,
1023 * "1.5" will return 15 */
1024 static int hostapd_config_read_int10(const char *value
)
1030 pos
= os_strchr(value
, '.');
1034 if (*pos
>= '0' && *pos
<= '9')
1042 static int valid_cw(int cw
)
1044 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
1045 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023 ||
1046 cw
== 2047 || cw
== 4095 || cw
== 8191 || cw
== 16383 ||
1052 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
1053 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
1054 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
1055 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
1058 static int hostapd_config_tx_queue(struct hostapd_config
*conf
,
1059 const char *name
, const char *val
)
1063 struct hostapd_tx_queue_params
*queue
;
1065 /* skip 'tx_queue_' prefix */
1067 if (os_strncmp(pos
, "data", 4) == 0 &&
1068 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
1071 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
1072 os_strncmp(pos
, "beacon_", 7) == 0) {
1073 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
1076 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
1080 if (num
>= NUM_TX_QUEUES
) {
1081 /* for backwards compatibility, do not trigger failure */
1082 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
1086 queue
= &conf
->tx_queue
[num
];
1088 if (os_strcmp(pos
, "aifs") == 0) {
1089 queue
->aifs
= atoi(val
);
1090 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
1091 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
1095 } else if (os_strcmp(pos
, "cwmin") == 0) {
1096 queue
->cwmin
= atoi(val
);
1097 if (!valid_cw(queue
->cwmin
)) {
1098 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
1102 } else if (os_strcmp(pos
, "cwmax") == 0) {
1103 queue
->cwmax
= atoi(val
);
1104 if (!valid_cw(queue
->cwmax
)) {
1105 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
1109 } else if (os_strcmp(pos
, "burst") == 0) {
1110 queue
->burst
= hostapd_config_read_int10(val
);
1112 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
1120 #ifdef CONFIG_IEEE80211R_AP
1122 static int rkh_derive_key(const char *pos
, u8
*key
, size_t key_len
)
1127 if (!hexstr2bin(pos
, key
, key_len
))
1130 /* Try to use old short key for backwards compatibility */
1131 if (hexstr2bin(pos
, oldkey
, sizeof(oldkey
)))
1134 ret
= hmac_sha256_kdf(oldkey
, sizeof(oldkey
), "FT OLDKEY", NULL
, 0,
1136 os_memset(oldkey
, 0, sizeof(oldkey
));
1141 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
1143 struct ft_remote_r0kh
*r0kh
;
1146 r0kh
= os_zalloc(sizeof(*r0kh
));
1150 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1152 next
= os_strchr(pos
, ' ');
1155 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
1156 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
1162 next
= os_strchr(pos
, ' ');
1165 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
1166 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
1170 r0kh
->id_len
= next
- pos
- 1;
1171 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
1174 if (rkh_derive_key(pos
, r0kh
->key
, sizeof(r0kh
->key
)) < 0) {
1175 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
1180 r0kh
->next
= bss
->r0kh_list
;
1181 bss
->r0kh_list
= r0kh
;
1187 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
1189 struct ft_remote_r1kh
*r1kh
;
1192 r1kh
= os_zalloc(sizeof(*r1kh
));
1196 /* 02:01:02:03:04:05 02:01:02:03:04:05
1197 * 000102030405060708090a0b0c0d0e0f */
1199 next
= os_strchr(pos
, ' ');
1202 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
1203 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
1209 next
= os_strchr(pos
, ' ');
1212 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
1213 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
1219 if (rkh_derive_key(pos
, r1kh
->key
, sizeof(r1kh
->key
)) < 0) {
1220 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
1225 r1kh
->next
= bss
->r1kh_list
;
1226 bss
->r1kh_list
= r1kh
;
1230 #endif /* CONFIG_IEEE80211R_AP */
1233 #ifdef CONFIG_IEEE80211N
1234 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
1237 if (os_strstr(capab
, "[LDPC]"))
1238 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
1239 if (os_strstr(capab
, "[HT40-]")) {
1240 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1241 conf
->secondary_channel
= -1;
1243 if (os_strstr(capab
, "[HT40+]")) {
1244 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1245 conf
->secondary_channel
= 1;
1247 if (os_strstr(capab
, "[HT40+]") && os_strstr(capab
, "[HT40-]")) {
1248 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1249 conf
->ht40_plus_minus_allowed
= 1;
1251 if (!os_strstr(capab
, "[HT40+]") && !os_strstr(capab
, "[HT40-]"))
1252 conf
->secondary_channel
= 0;
1253 if (os_strstr(capab
, "[SMPS-STATIC]")) {
1254 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1255 conf
->ht_capab
|= HT_CAP_INFO_SMPS_STATIC
;
1257 if (os_strstr(capab
, "[SMPS-DYNAMIC]")) {
1258 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1259 conf
->ht_capab
|= HT_CAP_INFO_SMPS_DYNAMIC
;
1261 if (os_strstr(capab
, "[GF]"))
1262 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
1263 if (os_strstr(capab
, "[SHORT-GI-20]"))
1264 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1265 if (os_strstr(capab
, "[SHORT-GI-40]"))
1266 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1267 if (os_strstr(capab
, "[TX-STBC]"))
1268 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1269 if (os_strstr(capab
, "[RX-STBC1]")) {
1270 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1271 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1273 if (os_strstr(capab
, "[RX-STBC12]")) {
1274 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1275 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1277 if (os_strstr(capab
, "[RX-STBC123]")) {
1278 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1279 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1281 if (os_strstr(capab
, "[DELAYED-BA]"))
1282 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1283 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1284 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1285 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1286 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1287 if (os_strstr(capab
, "[40-INTOLERANT]"))
1288 conf
->ht_capab
|= HT_CAP_INFO_40MHZ_INTOLERANT
;
1289 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1290 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1294 #endif /* CONFIG_IEEE80211N */
1297 #ifdef CONFIG_IEEE80211AC
1298 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1301 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1302 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1303 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1304 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1305 if (os_strstr(capab
, "[VHT160]"))
1306 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1307 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1308 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1309 if (os_strstr(capab
, "[RXLDPC]"))
1310 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1311 if (os_strstr(capab
, "[SHORT-GI-80]"))
1312 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1313 if (os_strstr(capab
, "[SHORT-GI-160]"))
1314 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1315 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1316 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1317 if (os_strstr(capab
, "[RX-STBC-1]"))
1318 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1319 if (os_strstr(capab
, "[RX-STBC-12]"))
1320 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1321 if (os_strstr(capab
, "[RX-STBC-123]"))
1322 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1323 if (os_strstr(capab
, "[RX-STBC-1234]"))
1324 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1325 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1326 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMER_CAPABLE
;
1327 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1328 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
1329 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1330 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1331 conf
->vht_capab
|= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1332 if (os_strstr(capab
, "[BF-ANTENNA-3]") &&
1333 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1334 conf
->vht_capab
|= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1335 if (os_strstr(capab
, "[BF-ANTENNA-4]") &&
1336 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1337 conf
->vht_capab
|= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1338 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1339 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1340 conf
->vht_capab
|= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1341 if (os_strstr(capab
, "[SOUNDING-DIMENSION-3]") &&
1342 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1343 conf
->vht_capab
|= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1344 if (os_strstr(capab
, "[SOUNDING-DIMENSION-4]") &&
1345 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1346 conf
->vht_capab
|= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1347 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1348 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1349 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1350 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1351 if (os_strstr(capab
, "[HTC-VHT]"))
1352 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1353 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP7]"))
1354 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX
;
1355 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP6]"))
1356 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6
;
1357 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP5]"))
1358 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5
;
1359 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP4]"))
1360 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4
;
1361 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP3]"))
1362 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3
;
1363 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP2]"))
1364 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2
;
1365 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP1]"))
1366 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1
;
1367 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1368 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1369 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1370 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1371 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1372 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1373 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1374 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1375 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1376 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1379 #endif /* CONFIG_IEEE80211AC */
1382 #ifdef CONFIG_IEEE80211AX
1384 static u8
find_bit_offset(u8 val
)
1388 for (; val
; val
>>= 1) {
1398 static u8
set_he_cap(int val
, u8 mask
)
1400 return (u8
) (mask
& (val
<< find_bit_offset(mask
)));
1403 #endif /* CONFIG_IEEE80211AX */
1406 #ifdef CONFIG_INTERWORKING
1407 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1410 size_t len
= os_strlen(pos
);
1411 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1413 struct hostapd_roaming_consortium
*rc
;
1415 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1416 hexstr2bin(pos
, oi
, len
/ 2)) {
1417 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1423 rc
= os_realloc_array(bss
->roaming_consortium
,
1424 bss
->roaming_consortium_count
+ 1,
1425 sizeof(struct hostapd_roaming_consortium
));
1429 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1430 rc
[bss
->roaming_consortium_count
].len
= len
;
1432 bss
->roaming_consortium
= rc
;
1433 bss
->roaming_consortium_count
++;
1439 static int parse_lang_string(struct hostapd_lang_string
**array
,
1440 unsigned int *count
, char *pos
)
1442 char *sep
, *str
= NULL
;
1443 size_t clen
, nlen
, slen
;
1444 struct hostapd_lang_string
*ls
;
1447 if (*pos
== '"' || (*pos
== 'P' && pos
[1] == '"')) {
1448 str
= wpa_config_parse_string(pos
, &slen
);
1454 sep
= os_strchr(pos
, ':');
1459 clen
= os_strlen(pos
);
1460 if (clen
< 2 || clen
> sizeof(ls
->lang
))
1462 nlen
= os_strlen(sep
);
1466 ls
= os_realloc_array(*array
, *count
+ 1,
1467 sizeof(struct hostapd_lang_string
));
1472 ls
= &(*array
)[*count
];
1475 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1476 os_memcpy(ls
->lang
, pos
, clen
);
1477 ls
->name_len
= nlen
;
1478 os_memcpy(ls
->name
, sep
, nlen
);
1487 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1490 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1491 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1499 static int parse_venue_url(struct hostapd_bss_config
*bss
, char *pos
,
1504 struct hostapd_venue_url
*url
;
1507 sep
= os_strchr(pos
, ':');
1512 nlen
= os_strlen(sep
);
1516 url
= os_realloc_array(bss
->venue_url
, bss
->venue_url_count
+ 1,
1517 sizeof(struct hostapd_venue_url
));
1521 bss
->venue_url
= url
;
1522 url
= &bss
->venue_url
[bss
->venue_url_count
++];
1524 url
->venue_number
= atoi(pos
);
1525 url
->url_len
= nlen
;
1526 os_memcpy(url
->url
, sep
, nlen
);
1531 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_url '%s'",
1537 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1542 u8
*info
= NULL
, *ipos
;
1544 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1547 for (pos
= buf
; *pos
; pos
++) {
1548 if ((*pos
< '0' || *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1553 if (1 + count
* 3 > 0x7f)
1556 info
= os_zalloc(2 + 3 + count
* 3);
1561 *ipos
++ = 0; /* GUD - Version 1 */
1562 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1563 *ipos
++ = 0; /* PLMN List IEI */
1564 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1565 *ipos
++ = 1 + count
* 3;
1566 *ipos
++ = count
; /* Number of PLMNs */
1569 while (pos
&& *pos
) {
1574 mnc
= os_strchr(pos
, ',');
1578 pos
= os_strchr(mnc
, ';');
1582 mnc_len
= os_strlen(mnc
);
1583 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1586 /* BC coded MCC,MNC */
1587 /* MCC digit 2 | MCC digit 1 */
1588 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1589 /* MNC digit 3 | MCC digit 3 */
1590 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1592 /* MNC digit 2 | MNC digit 1 */
1593 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1596 os_free(bss
->anqp_3gpp_cell_net
);
1597 bss
->anqp_3gpp_cell_net
= info
;
1598 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1599 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1600 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1605 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1612 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1614 struct hostapd_nai_realm_data
*realm
;
1617 char *pos
, *end
, *rpos
;
1619 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1621 if (offsets
== NULL
)
1624 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1625 realm
= &bss
->nai_realm_data
[i
];
1626 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1627 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1629 realm
->realm
[j
] - realm
->realm_buf
: -1;
1633 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1634 sizeof(struct hostapd_nai_realm_data
));
1635 if (realm
== NULL
) {
1639 bss
->nai_realm_data
= realm
;
1641 /* patch the pointers after realloc */
1642 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1643 realm
= &bss
->nai_realm_data
[i
];
1644 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1645 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1647 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1649 realm
->realm
[j
] = NULL
;
1654 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1655 os_memset(realm
, 0, sizeof(*realm
));
1658 realm
->encoding
= atoi(pos
);
1659 pos
= os_strchr(pos
, ',');
1664 end
= os_strchr(pos
, ',');
1669 len
= os_strlen(pos
);
1672 if (len
> MAX_NAI_REALMLEN
) {
1673 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1674 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1677 os_memcpy(realm
->realm_buf
, pos
, len
);
1684 while (pos
&& *pos
) {
1685 struct hostapd_nai_realm_eap
*eap
;
1687 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1688 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1692 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1693 realm
->eap_method_count
++;
1695 end
= os_strchr(pos
, ',');
1697 end
= pos
+ os_strlen(pos
);
1699 eap
->eap_method
= atoi(pos
);
1701 pos
= os_strchr(pos
, '[');
1702 if (pos
== NULL
|| pos
> end
)
1705 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1706 wpa_printf(MSG_ERROR
, "Too many auth params");
1709 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1710 pos
= os_strchr(pos
, ':');
1711 if (pos
== NULL
|| pos
> end
)
1714 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1715 pos
= os_strchr(pos
, ']');
1716 if (pos
== NULL
|| pos
> end
)
1728 /* Split realm list into null terminated realms */
1729 rpos
= realm
->realm_buf
;
1732 if (i
>= MAX_NAI_REALMS
) {
1733 wpa_printf(MSG_ERROR
, "Too many realms");
1736 realm
->realm
[i
++] = rpos
;
1737 rpos
= os_strchr(rpos
, ';');
1743 bss
->nai_realm_count
++;
1748 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1753 static int parse_anqp_elem(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1758 struct wpabuf
*payload
;
1759 struct anqp_element
*elem
;
1761 delim
= os_strchr(buf
, ':');
1766 len
= os_strlen(delim
);
1770 payload
= wpabuf_alloc(len
);
1773 if (hexstr2bin(delim
, wpabuf_put(payload
, len
), len
) < 0) {
1774 wpabuf_free(payload
);
1778 dl_list_for_each(elem
, &bss
->anqp_elem
, struct anqp_element
, list
) {
1779 if (elem
->infoid
== infoid
) {
1780 /* Update existing entry */
1781 wpabuf_free(elem
->payload
);
1782 elem
->payload
= payload
;
1787 /* Add a new entry */
1788 elem
= os_zalloc(sizeof(*elem
));
1790 wpabuf_free(payload
);
1793 elem
->infoid
= infoid
;
1794 elem
->payload
= payload
;
1795 dl_list_add(&bss
->anqp_elem
, &elem
->list
);
1801 static int parse_qos_map_set(struct hostapd_bss_config
*bss
,
1802 char *buf
, int line
)
1804 u8 qos_map_set
[16 + 2 * 21], count
= 0;
1809 if (count
== sizeof(qos_map_set
)) {
1810 wpa_printf(MSG_ERROR
, "Line %d: Too many qos_map_set "
1811 "parameters '%s'", line
, buf
);
1816 if (val
> 255 || val
< 0) {
1817 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set "
1822 qos_map_set
[count
++] = val
;
1823 pos
= os_strchr(pos
, ',');
1829 if (count
< 16 || count
& 1) {
1830 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set '%s'",
1835 os_memcpy(bss
->qos_map_set
, qos_map_set
, count
);
1836 bss
->qos_map_set_len
= count
;
1841 #endif /* CONFIG_INTERWORKING */
1845 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1851 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1854 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1855 bss
->hs20_connection_capability_len
+ 4);
1856 if (conn_cap
== NULL
)
1859 bss
->hs20_connection_capability
= conn_cap
;
1860 conn_cap
+= bss
->hs20_connection_capability_len
;
1862 conn_cap
[0] = atoi(pos
);
1863 pos
= os_strchr(pos
, ':');
1867 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1868 pos
= os_strchr(pos
, ':');
1872 conn_cap
[3] = atoi(pos
);
1873 bss
->hs20_connection_capability_len
+= 4;
1879 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1885 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1887 wan_metrics
= os_zalloc(13);
1888 if (wan_metrics
== NULL
)
1893 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1900 /* Downlink Speed */
1901 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1902 pos
= os_strchr(pos
, ':');
1908 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1909 pos
= os_strchr(pos
, ':');
1915 wan_metrics
[9] = atoi(pos
);
1916 pos
= os_strchr(pos
, ':');
1922 wan_metrics
[10] = atoi(pos
);
1923 pos
= os_strchr(pos
, ':');
1929 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1931 os_free(bss
->hs20_wan_metrics
);
1932 bss
->hs20_wan_metrics
= wan_metrics
;
1937 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1939 os_free(wan_metrics
);
1944 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1945 char *pos
, int line
)
1947 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1948 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1949 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1950 "hs20_oper_friendly_name '%s'", line
, pos
);
1957 static int hs20_parse_icon(struct hostapd_bss_config
*bss
, char *pos
)
1959 struct hs20_icon
*icon
;
1962 icon
= os_realloc_array(bss
->hs20_icons
, bss
->hs20_icons_count
+ 1,
1963 sizeof(struct hs20_icon
));
1966 bss
->hs20_icons
= icon
;
1967 icon
= &bss
->hs20_icons
[bss
->hs20_icons_count
];
1968 os_memset(icon
, 0, sizeof(*icon
));
1970 icon
->width
= atoi(pos
);
1971 pos
= os_strchr(pos
, ':');
1976 icon
->height
= atoi(pos
);
1977 pos
= os_strchr(pos
, ':');
1982 end
= os_strchr(pos
, ':');
1983 if (end
== NULL
|| end
- pos
> 3)
1985 os_memcpy(icon
->language
, pos
, end
- pos
);
1988 end
= os_strchr(pos
, ':');
1989 if (end
== NULL
|| end
- pos
> 255)
1991 os_memcpy(icon
->type
, pos
, end
- pos
);
1994 end
= os_strchr(pos
, ':');
1995 if (end
== NULL
|| end
- pos
> 255)
1997 os_memcpy(icon
->name
, pos
, end
- pos
);
2000 if (os_strlen(pos
) > 255)
2002 os_memcpy(icon
->file
, pos
, os_strlen(pos
));
2004 bss
->hs20_icons_count
++;
2010 static int hs20_parse_osu_ssid(struct hostapd_bss_config
*bss
,
2011 char *pos
, int line
)
2016 str
= wpa_config_parse_string(pos
, &slen
);
2017 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
2018 wpa_printf(MSG_ERROR
, "Line %d: Invalid SSID '%s'", line
, pos
);
2023 os_memcpy(bss
->osu_ssid
, str
, slen
);
2024 bss
->osu_ssid_len
= slen
;
2031 static int hs20_parse_osu_server_uri(struct hostapd_bss_config
*bss
,
2032 char *pos
, int line
)
2034 struct hs20_osu_provider
*p
;
2036 p
= os_realloc_array(bss
->hs20_osu_providers
,
2037 bss
->hs20_osu_providers_count
+ 1, sizeof(*p
));
2041 bss
->hs20_osu_providers
= p
;
2042 bss
->last_osu
= &bss
->hs20_osu_providers
[bss
->hs20_osu_providers_count
];
2043 bss
->hs20_osu_providers_count
++;
2044 os_memset(bss
->last_osu
, 0, sizeof(*p
));
2045 bss
->last_osu
->server_uri
= os_strdup(pos
);
2051 static int hs20_parse_osu_friendly_name(struct hostapd_bss_config
*bss
,
2052 char *pos
, int line
)
2054 if (bss
->last_osu
== NULL
) {
2055 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2059 if (parse_lang_string(&bss
->last_osu
->friendly_name
,
2060 &bss
->last_osu
->friendly_name_count
, pos
)) {
2061 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_friendly_name '%s'",
2070 static int hs20_parse_osu_nai(struct hostapd_bss_config
*bss
,
2071 char *pos
, int line
)
2073 if (bss
->last_osu
== NULL
) {
2074 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2078 os_free(bss
->last_osu
->osu_nai
);
2079 bss
->last_osu
->osu_nai
= os_strdup(pos
);
2080 if (bss
->last_osu
->osu_nai
== NULL
)
2087 static int hs20_parse_osu_nai2(struct hostapd_bss_config
*bss
,
2088 char *pos
, int line
)
2090 if (bss
->last_osu
== NULL
) {
2091 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2095 os_free(bss
->last_osu
->osu_nai2
);
2096 bss
->last_osu
->osu_nai2
= os_strdup(pos
);
2097 if (bss
->last_osu
->osu_nai2
== NULL
)
2099 bss
->hs20_osu_providers_nai_count
++;
2105 static int hs20_parse_osu_method_list(struct hostapd_bss_config
*bss
, char *pos
,
2108 if (bss
->last_osu
== NULL
) {
2109 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2113 if (hostapd_parse_intlist(&bss
->last_osu
->method_list
, pos
)) {
2114 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_method_list", line
);
2122 static int hs20_parse_osu_icon(struct hostapd_bss_config
*bss
, char *pos
,
2126 struct hs20_osu_provider
*p
= bss
->last_osu
;
2129 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2133 n
= os_realloc_array(p
->icons
, p
->icons_count
+ 1, sizeof(char *));
2137 p
->icons
[p
->icons_count
] = os_strdup(pos
);
2138 if (p
->icons
[p
->icons_count
] == NULL
)
2146 static int hs20_parse_osu_service_desc(struct hostapd_bss_config
*bss
,
2147 char *pos
, int line
)
2149 if (bss
->last_osu
== NULL
) {
2150 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2154 if (parse_lang_string(&bss
->last_osu
->service_desc
,
2155 &bss
->last_osu
->service_desc_count
, pos
)) {
2156 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_service_desc '%s'",
2165 static int hs20_parse_operator_icon(struct hostapd_bss_config
*bss
, char *pos
,
2170 n
= os_realloc_array(bss
->hs20_operator_icon
,
2171 bss
->hs20_operator_icon_count
+ 1, sizeof(char *));
2174 bss
->hs20_operator_icon
= n
;
2175 bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
] = os_strdup(pos
);
2176 if (!bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
])
2178 bss
->hs20_operator_icon_count
++;
2183 #endif /* CONFIG_HS20 */
2187 static int hostapd_config_parse_acs_chan_bias(struct hostapd_config
*conf
,
2190 struct acs_bias
*bias
= NULL
, *tmp
;
2191 unsigned int num
= 0;
2195 tmp
= os_realloc_array(bias
, num
+ 1, sizeof(*bias
));
2200 bias
[num
].channel
= atoi(pos
);
2201 if (bias
[num
].channel
<= 0)
2203 pos
= os_strchr(pos
, ':');
2207 bias
[num
].bias
= strtod(pos
, &end
);
2208 if (end
== pos
|| bias
[num
].bias
< 0.0)
2211 if (*pos
!= ' ' && *pos
!= '\0')
2216 os_free(conf
->acs_chan_bias
);
2217 conf
->acs_chan_bias
= bias
;
2218 conf
->num_acs_chan_bias
= num
;
2225 #endif /* CONFIG_ACS */
2228 static int parse_wpabuf_hex(int line
, const char *name
, struct wpabuf
**buf
,
2231 struct wpabuf
*elems
;
2233 if (val
[0] == '\0') {
2239 elems
= wpabuf_parse_bin(val
);
2241 wpa_printf(MSG_ERROR
, "Line %d: Invalid %s '%s'",
2254 static int parse_fils_realm(struct hostapd_bss_config
*bss
, const char *val
)
2256 struct fils_realm
*realm
;
2259 len
= os_strlen(val
);
2260 realm
= os_zalloc(sizeof(*realm
) + len
+ 1);
2264 os_memcpy(realm
->realm
, val
, len
);
2265 if (fils_domain_name_hash(val
, realm
->hash
) < 0) {
2269 dl_list_add_tail(&bss
->fils_realms
, &realm
->list
);
2273 #endif /* CONFIG_FILS */
2277 static unsigned int parse_tls_flags(const char *val
)
2279 unsigned int flags
= 0;
2281 /* Disable TLS v1.3 by default for now to avoid interoperability issue.
2282 * This can be enabled by default once the implementation has been fully
2283 * completed and tested with other implementations. */
2284 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2286 if (os_strstr(val
, "[ALLOW-SIGN-RSA-MD5]"))
2287 flags
|= TLS_CONN_ALLOW_SIGN_RSA_MD5
;
2288 if (os_strstr(val
, "[DISABLE-TIME-CHECKS]"))
2289 flags
|= TLS_CONN_DISABLE_TIME_CHECKS
;
2290 if (os_strstr(val
, "[DISABLE-TLSv1.0]"))
2291 flags
|= TLS_CONN_DISABLE_TLSv1_0
;
2292 if (os_strstr(val
, "[ENABLE-TLSv1.0]"))
2293 flags
|= TLS_CONN_ENABLE_TLSv1_0
;
2294 if (os_strstr(val
, "[DISABLE-TLSv1.1]"))
2295 flags
|= TLS_CONN_DISABLE_TLSv1_1
;
2296 if (os_strstr(val
, "[ENABLE-TLSv1.1]"))
2297 flags
|= TLS_CONN_ENABLE_TLSv1_1
;
2298 if (os_strstr(val
, "[DISABLE-TLSv1.2]"))
2299 flags
|= TLS_CONN_DISABLE_TLSv1_2
;
2300 if (os_strstr(val
, "[ENABLE-TLSv1.2]"))
2301 flags
|= TLS_CONN_ENABLE_TLSv1_2
;
2302 if (os_strstr(val
, "[DISABLE-TLSv1.3]"))
2303 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2304 if (os_strstr(val
, "[ENABLE-TLSv1.3]"))
2305 flags
&= ~TLS_CONN_DISABLE_TLSv1_3
;
2306 if (os_strstr(val
, "[SUITEB]"))
2307 flags
|= TLS_CONN_SUITEB
;
2308 if (os_strstr(val
, "[SUITEB-NO-ECDH]"))
2309 flags
|= TLS_CONN_SUITEB_NO_ECDH
| TLS_CONN_SUITEB
;
2313 #endif /* EAP_SERVER */
2316 #ifdef CONFIG_AIRTIME_POLICY
2317 static int add_airtime_weight(struct hostapd_bss_config
*bss
, char *value
)
2319 struct airtime_sta_weight
*wt
;
2322 wt
= os_zalloc(sizeof(*wt
));
2326 /* 02:01:02:03:04:05 10 */
2328 next
= os_strchr(pos
, ' ');
2331 if (!next
|| hwaddr_aton(pos
, wt
->addr
)) {
2332 wpa_printf(MSG_ERROR
, "Invalid station address: '%s'", pos
);
2338 wt
->weight
= atoi(pos
);
2340 wpa_printf(MSG_ERROR
, "Invalid weight: '%s'", pos
);
2345 wt
->next
= bss
->airtime_weight_list
;
2346 bss
->airtime_weight_list
= wt
;
2349 #endif /* CONFIG_AIRTIME_POLICY */
2353 static int parse_sae_password(struct hostapd_bss_config
*bss
, const char *val
)
2355 struct sae_password_entry
*pw
;
2356 const char *pos
= val
, *pos2
, *end
= NULL
;
2358 pw
= os_zalloc(sizeof(*pw
));
2361 os_memset(pw
->peer_addr
, 0xff, ETH_ALEN
); /* default to wildcard */
2363 pos2
= os_strstr(pos
, "|mac=");
2367 if (hwaddr_aton(pos2
, pw
->peer_addr
) < 0)
2369 pos
= pos2
+ ETH_ALEN
* 3 - 1;
2372 pos2
= os_strstr(pos
, "|vlanid=");
2377 pw
->vlan_id
= atoi(pos2
);
2380 pos2
= os_strstr(pos
, "|id=");
2385 pw
->identifier
= os_strdup(pos2
);
2386 if (!pw
->identifier
)
2391 pw
->password
= os_strdup(val
);
2395 pw
->password
= os_malloc(end
- val
+ 1);
2398 os_memcpy(pw
->password
, val
, end
- val
);
2399 pw
->password
[end
- val
] = '\0';
2402 pw
->next
= bss
->sae_passwords
;
2403 bss
->sae_passwords
= pw
;
2407 str_clear_free(pw
->password
);
2408 os_free(pw
->identifier
);
2412 #endif /* CONFIG_SAE */
2416 static int hostapd_dpp_controller_parse(struct hostapd_bss_config
*bss
,
2419 struct dpp_controller_conf
*conf
;
2422 conf
= os_zalloc(sizeof(*conf
));
2425 val
= get_param(pos
, "ipaddr=");
2426 if (!val
|| hostapd_parse_ip_addr(val
, &conf
->ipaddr
))
2429 val
= get_param(pos
, "pkhash=");
2430 if (!val
|| os_strlen(val
) != 2 * SHA256_MAC_LEN
||
2431 hexstr2bin(val
, conf
->pkhash
, SHA256_MAC_LEN
) < 0)
2434 conf
->next
= bss
->dpp_controller
;
2435 bss
->dpp_controller
= conf
;
2442 #endif /* CONFIG_DPP2 */
2445 static int hostapd_config_fill(struct hostapd_config
*conf
,
2446 struct hostapd_bss_config
*bss
,
2447 const char *buf
, char *pos
, int line
)
2449 if (os_strcmp(buf
, "interface") == 0) {
2450 os_strlcpy(conf
->bss
[0]->iface
, pos
,
2451 sizeof(conf
->bss
[0]->iface
));
2452 } else if (os_strcmp(buf
, "bridge") == 0) {
2453 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
2454 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
2455 os_strlcpy(bss
->vlan_bridge
, pos
, sizeof(bss
->vlan_bridge
));
2456 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
2457 os_strlcpy(bss
->wds_bridge
, pos
, sizeof(bss
->wds_bridge
));
2458 } else if (os_strcmp(buf
, "driver") == 0) {
2460 const struct wpa_driver_ops
*driver
= NULL
;
2462 for (j
= 0; wpa_drivers
[j
]; j
++) {
2463 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0) {
2464 driver
= wpa_drivers
[j
];
2469 wpa_printf(MSG_ERROR
,
2470 "Line %d: invalid/unknown driver '%s'",
2474 conf
->driver
= driver
;
2475 } else if (os_strcmp(buf
, "driver_params") == 0) {
2476 os_free(conf
->driver_params
);
2477 conf
->driver_params
= os_strdup(pos
);
2478 } else if (os_strcmp(buf
, "debug") == 0) {
2479 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore",
2481 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
2482 bss
->logger_syslog_level
= atoi(pos
);
2483 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
2484 bss
->logger_stdout_level
= atoi(pos
);
2485 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
2486 bss
->logger_syslog
= atoi(pos
);
2487 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
2488 bss
->logger_stdout
= atoi(pos
);
2489 } else if (os_strcmp(buf
, "dump_file") == 0) {
2490 wpa_printf(MSG_INFO
, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
2492 } else if (os_strcmp(buf
, "ssid") == 0) {
2493 bss
->ssid
.ssid_len
= os_strlen(pos
);
2494 if (bss
->ssid
.ssid_len
> SSID_MAX_LEN
||
2495 bss
->ssid
.ssid_len
< 1) {
2496 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2500 os_memcpy(bss
->ssid
.ssid
, pos
, bss
->ssid
.ssid_len
);
2501 bss
->ssid
.ssid_set
= 1;
2502 } else if (os_strcmp(buf
, "ssid2") == 0) {
2504 char *str
= wpa_config_parse_string(pos
, &slen
);
2505 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
2506 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2511 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
2512 bss
->ssid
.ssid_len
= slen
;
2513 bss
->ssid
.ssid_set
= 1;
2515 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
2516 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
2517 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
2518 enum macaddr_acl acl
= atoi(pos
);
2520 if (acl
!= ACCEPT_UNLESS_DENIED
&&
2521 acl
!= DENY_UNLESS_ACCEPTED
&&
2522 acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
2523 wpa_printf(MSG_ERROR
, "Line %d: unknown macaddr_acl %d",
2527 bss
->macaddr_acl
= acl
;
2528 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
2529 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
2530 &bss
->num_accept_mac
)) {
2531 wpa_printf(MSG_ERROR
, "Line %d: Failed to read accept_mac_file '%s'",
2535 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
2536 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
2537 &bss
->num_deny_mac
)) {
2538 wpa_printf(MSG_ERROR
, "Line %d: Failed to read deny_mac_file '%s'",
2542 } else if (os_strcmp(buf
, "wds_sta") == 0) {
2543 bss
->wds_sta
= atoi(pos
);
2544 } else if (os_strcmp(buf
, "start_disabled") == 0) {
2545 bss
->start_disabled
= atoi(pos
);
2546 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
2547 bss
->isolate
= atoi(pos
);
2548 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
2549 bss
->ap_max_inactivity
= atoi(pos
);
2550 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
2551 bss
->skip_inactivity_poll
= atoi(pos
);
2552 } else if (os_strcmp(buf
, "country_code") == 0) {
2553 os_memcpy(conf
->country
, pos
, 2);
2554 } else if (os_strcmp(buf
, "country3") == 0) {
2555 conf
->country
[2] = strtol(pos
, NULL
, 16);
2556 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
2557 conf
->ieee80211d
= atoi(pos
);
2558 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
2559 conf
->ieee80211h
= atoi(pos
);
2560 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
2561 bss
->ieee802_1x
= atoi(pos
);
2562 } else if (os_strcmp(buf
, "eapol_version") == 0) {
2563 int eapol_version
= atoi(pos
);
2565 #ifdef CONFIG_MACSEC
2566 if (eapol_version
< 1 || eapol_version
> 3) {
2567 #else /* CONFIG_MACSEC */
2568 if (eapol_version
< 1 || eapol_version
> 2) {
2569 #endif /* CONFIG_MACSEC */
2570 wpa_printf(MSG_ERROR
,
2571 "Line %d: invalid EAPOL version (%d): '%s'.",
2572 line
, eapol_version
, pos
);
2575 bss
->eapol_version
= eapol_version
;
2576 wpa_printf(MSG_DEBUG
, "eapol_version=%d", bss
->eapol_version
);
2578 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
2579 bss
->eap_server
= atoi(pos
);
2580 wpa_printf(MSG_ERROR
, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line
);
2581 } else if (os_strcmp(buf
, "eap_server") == 0) {
2582 bss
->eap_server
= atoi(pos
);
2583 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
2584 if (hostapd_config_read_eap_user(pos
, bss
))
2586 } else if (os_strcmp(buf
, "ca_cert") == 0) {
2587 os_free(bss
->ca_cert
);
2588 bss
->ca_cert
= os_strdup(pos
);
2589 } else if (os_strcmp(buf
, "server_cert") == 0) {
2590 os_free(bss
->server_cert
);
2591 bss
->server_cert
= os_strdup(pos
);
2592 } else if (os_strcmp(buf
, "private_key") == 0) {
2593 os_free(bss
->private_key
);
2594 bss
->private_key
= os_strdup(pos
);
2595 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
2596 os_free(bss
->private_key_passwd
);
2597 bss
->private_key_passwd
= os_strdup(pos
);
2598 } else if (os_strcmp(buf
, "check_cert_subject") == 0) {
2600 wpa_printf(MSG_ERROR
, "Line %d: unknown check_cert_subject '%s'",
2604 os_free(bss
->check_cert_subject
);
2605 bss
->check_cert_subject
= os_strdup(pos
);
2606 if (!bss
->check_cert_subject
)
2608 } else if (os_strcmp(buf
, "check_crl") == 0) {
2609 bss
->check_crl
= atoi(pos
);
2610 } else if (os_strcmp(buf
, "check_crl_strict") == 0) {
2611 bss
->check_crl_strict
= atoi(pos
);
2612 } else if (os_strcmp(buf
, "crl_reload_interval") == 0) {
2613 bss
->crl_reload_interval
= atoi(pos
);
2614 } else if (os_strcmp(buf
, "tls_session_lifetime") == 0) {
2615 bss
->tls_session_lifetime
= atoi(pos
);
2616 } else if (os_strcmp(buf
, "tls_flags") == 0) {
2617 bss
->tls_flags
= parse_tls_flags(pos
);
2618 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
2619 os_free(bss
->ocsp_stapling_response
);
2620 bss
->ocsp_stapling_response
= os_strdup(pos
);
2621 } else if (os_strcmp(buf
, "ocsp_stapling_response_multi") == 0) {
2622 os_free(bss
->ocsp_stapling_response_multi
);
2623 bss
->ocsp_stapling_response_multi
= os_strdup(pos
);
2624 } else if (os_strcmp(buf
, "dh_file") == 0) {
2625 os_free(bss
->dh_file
);
2626 bss
->dh_file
= os_strdup(pos
);
2627 } else if (os_strcmp(buf
, "openssl_ciphers") == 0) {
2628 os_free(bss
->openssl_ciphers
);
2629 bss
->openssl_ciphers
= os_strdup(pos
);
2630 } else if (os_strcmp(buf
, "openssl_ecdh_curves") == 0) {
2631 os_free(bss
->openssl_ecdh_curves
);
2632 bss
->openssl_ecdh_curves
= os_strdup(pos
);
2633 } else if (os_strcmp(buf
, "fragment_size") == 0) {
2634 bss
->fragment_size
= atoi(pos
);
2635 #ifdef EAP_SERVER_FAST
2636 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
2637 os_free(bss
->pac_opaque_encr_key
);
2638 bss
->pac_opaque_encr_key
= os_malloc(16);
2639 if (bss
->pac_opaque_encr_key
== NULL
) {
2640 wpa_printf(MSG_ERROR
,
2641 "Line %d: No memory for pac_opaque_encr_key",
2644 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
, 16)) {
2645 wpa_printf(MSG_ERROR
, "Line %d: Invalid pac_opaque_encr_key",
2649 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
2650 size_t idlen
= os_strlen(pos
);
2652 wpa_printf(MSG_ERROR
, "Line %d: Invalid eap_fast_a_id",
2656 os_free(bss
->eap_fast_a_id
);
2657 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
2658 if (bss
->eap_fast_a_id
== NULL
||
2659 hexstr2bin(pos
, bss
->eap_fast_a_id
, idlen
/ 2)) {
2660 wpa_printf(MSG_ERROR
, "Line %d: Failed to parse eap_fast_a_id",
2662 os_free(bss
->eap_fast_a_id
);
2663 bss
->eap_fast_a_id
= NULL
;
2666 bss
->eap_fast_a_id_len
= idlen
/ 2;
2668 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
2669 os_free(bss
->eap_fast_a_id_info
);
2670 bss
->eap_fast_a_id_info
= os_strdup(pos
);
2671 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
2672 bss
->eap_fast_prov
= atoi(pos
);
2673 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
2674 bss
->pac_key_lifetime
= atoi(pos
);
2675 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
2676 bss
->pac_key_refresh_time
= atoi(pos
);
2677 #endif /* EAP_SERVER_FAST */
2678 #ifdef EAP_SERVER_TEAP
2679 } else if (os_strcmp(buf
, "eap_teap_auth") == 0) {
2680 int val
= atoi(pos
);
2682 if (val
< 0 || val
> 1) {
2683 wpa_printf(MSG_ERROR
,
2684 "Line %d: Invalid eap_teap_auth value",
2688 bss
->eap_teap_auth
= val
;
2689 } else if (os_strcmp(buf
, "eap_teap_pac_no_inner") == 0) {
2690 bss
->eap_teap_pac_no_inner
= atoi(pos
);
2691 #endif /* EAP_SERVER_TEAP */
2692 #ifdef EAP_SERVER_SIM
2693 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
2694 os_free(bss
->eap_sim_db
);
2695 bss
->eap_sim_db
= os_strdup(pos
);
2696 } else if (os_strcmp(buf
, "eap_sim_db_timeout") == 0) {
2697 bss
->eap_sim_db_timeout
= atoi(pos
);
2698 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
2699 bss
->eap_sim_aka_result_ind
= atoi(pos
);
2700 #endif /* EAP_SERVER_SIM */
2701 #ifdef EAP_SERVER_TNC
2702 } else if (os_strcmp(buf
, "tnc") == 0) {
2703 bss
->tnc
= atoi(pos
);
2704 #endif /* EAP_SERVER_TNC */
2705 #ifdef EAP_SERVER_PWD
2706 } else if (os_strcmp(buf
, "pwd_group") == 0) {
2707 bss
->pwd_group
= atoi(pos
);
2708 #endif /* EAP_SERVER_PWD */
2710 } else if (os_strcmp(buf
, "eap_server_erp") == 0) {
2711 bss
->eap_server_erp
= atoi(pos
);
2712 #endif /* CONFIG_ERP */
2713 #endif /* EAP_SERVER */
2714 } else if (os_strcmp(buf
, "eap_message") == 0) {
2716 os_free(bss
->eap_req_id_text
);
2717 bss
->eap_req_id_text
= os_strdup(pos
);
2718 if (bss
->eap_req_id_text
== NULL
) {
2719 wpa_printf(MSG_ERROR
, "Line %d: Failed to allocate memory for eap_req_id_text",
2723 bss
->eap_req_id_text_len
= os_strlen(bss
->eap_req_id_text
);
2724 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
2727 os_memmove(term
, term
+ 1,
2728 bss
->eap_req_id_text_len
-
2729 (term
- bss
->eap_req_id_text
) - 1);
2730 bss
->eap_req_id_text_len
--;
2732 } else if (os_strcmp(buf
, "erp_send_reauth_start") == 0) {
2733 bss
->erp_send_reauth_start
= atoi(pos
);
2734 } else if (os_strcmp(buf
, "erp_domain") == 0) {
2735 os_free(bss
->erp_domain
);
2736 bss
->erp_domain
= os_strdup(pos
);
2737 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
2738 int val
= atoi(pos
);
2740 if (val
< 0 || val
> 13) {
2741 wpa_printf(MSG_ERROR
,
2742 "Line %d: invalid WEP key len %d (= %d bits)",
2743 line
, val
, val
* 8);
2746 bss
->default_wep_key_len
= val
;
2747 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
2748 int val
= atoi(pos
);
2750 if (val
< 0 || val
> 13) {
2751 wpa_printf(MSG_ERROR
,
2752 "Line %d: invalid WEP key len %d (= %d bits)",
2753 line
, val
, val
* 8);
2756 bss
->individual_wep_key_len
= val
;
2757 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
2758 bss
->wep_rekeying_period
= atoi(pos
);
2759 if (bss
->wep_rekeying_period
< 0) {
2760 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2761 line
, bss
->wep_rekeying_period
);
2764 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
2765 bss
->eap_reauth_period
= atoi(pos
);
2766 if (bss
->eap_reauth_period
< 0) {
2767 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2768 line
, bss
->eap_reauth_period
);
2771 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
2772 bss
->eapol_key_index_workaround
= atoi(pos
);
2774 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
2775 bss
->ieee802_11f
= 1;
2776 os_strlcpy(bss
->iapp_iface
, pos
, sizeof(bss
->iapp_iface
));
2777 #endif /* CONFIG_IAPP */
2778 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
2779 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
2780 wpa_printf(MSG_ERROR
,
2781 "Line %d: invalid IP address '%s'",
2785 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
2786 os_free(bss
->nas_identifier
);
2787 bss
->nas_identifier
= os_strdup(pos
);
2788 #ifndef CONFIG_NO_RADIUS
2789 } else if (os_strcmp(buf
, "radius_client_addr") == 0) {
2790 if (hostapd_parse_ip_addr(pos
, &bss
->radius
->client_addr
)) {
2791 wpa_printf(MSG_ERROR
,
2792 "Line %d: invalid IP address '%s'",
2796 bss
->radius
->force_client_addr
= 1;
2797 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
2798 if (hostapd_config_read_radius_addr(
2799 &bss
->radius
->auth_servers
,
2800 &bss
->radius
->num_auth_servers
, pos
, 1812,
2801 &bss
->radius
->auth_server
)) {
2802 wpa_printf(MSG_ERROR
,
2803 "Line %d: invalid IP address '%s'",
2807 } else if (bss
->radius
->auth_server
&&
2808 os_strcmp(buf
, "auth_server_addr_replace") == 0) {
2809 if (hostapd_parse_ip_addr(pos
,
2810 &bss
->radius
->auth_server
->addr
)) {
2811 wpa_printf(MSG_ERROR
,
2812 "Line %d: invalid IP address '%s'",
2816 } else if (bss
->radius
->auth_server
&&
2817 os_strcmp(buf
, "auth_server_port") == 0) {
2818 bss
->radius
->auth_server
->port
= atoi(pos
);
2819 } else if (bss
->radius
->auth_server
&&
2820 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
2821 int len
= os_strlen(pos
);
2823 /* RFC 2865, Ch. 3 */
2824 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2828 os_free(bss
->radius
->auth_server
->shared_secret
);
2829 bss
->radius
->auth_server
->shared_secret
= (u8
*) os_strdup(pos
);
2830 bss
->radius
->auth_server
->shared_secret_len
= len
;
2831 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
2832 if (hostapd_config_read_radius_addr(
2833 &bss
->radius
->acct_servers
,
2834 &bss
->radius
->num_acct_servers
, pos
, 1813,
2835 &bss
->radius
->acct_server
)) {
2836 wpa_printf(MSG_ERROR
,
2837 "Line %d: invalid IP address '%s'",
2841 } else if (bss
->radius
->acct_server
&&
2842 os_strcmp(buf
, "acct_server_addr_replace") == 0) {
2843 if (hostapd_parse_ip_addr(pos
,
2844 &bss
->radius
->acct_server
->addr
)) {
2845 wpa_printf(MSG_ERROR
,
2846 "Line %d: invalid IP address '%s'",
2850 } else if (bss
->radius
->acct_server
&&
2851 os_strcmp(buf
, "acct_server_port") == 0) {
2852 bss
->radius
->acct_server
->port
= atoi(pos
);
2853 } else if (bss
->radius
->acct_server
&&
2854 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
2855 int len
= os_strlen(pos
);
2857 /* RFC 2865, Ch. 3 */
2858 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2862 os_free(bss
->radius
->acct_server
->shared_secret
);
2863 bss
->radius
->acct_server
->shared_secret
= (u8
*) os_strdup(pos
);
2864 bss
->radius
->acct_server
->shared_secret_len
= len
;
2865 } else if (os_strcmp(buf
, "radius_retry_primary_interval") == 0) {
2866 bss
->radius
->retry_primary_interval
= atoi(pos
);
2867 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0) {
2868 bss
->acct_interim_interval
= atoi(pos
);
2869 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
2870 bss
->radius_request_cui
= atoi(pos
);
2871 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
2872 struct hostapd_radius_attr
*attr
, *a
;
2873 attr
= hostapd_parse_radius_attr(pos
);
2875 wpa_printf(MSG_ERROR
,
2876 "Line %d: invalid radius_auth_req_attr",
2879 } else if (bss
->radius_auth_req_attr
== NULL
) {
2880 bss
->radius_auth_req_attr
= attr
;
2882 a
= bss
->radius_auth_req_attr
;
2887 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
2888 struct hostapd_radius_attr
*attr
, *a
;
2889 attr
= hostapd_parse_radius_attr(pos
);
2891 wpa_printf(MSG_ERROR
,
2892 "Line %d: invalid radius_acct_req_attr",
2895 } else if (bss
->radius_acct_req_attr
== NULL
) {
2896 bss
->radius_acct_req_attr
= attr
;
2898 a
= bss
->radius_acct_req_attr
;
2903 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
2904 bss
->radius_das_port
= atoi(pos
);
2905 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
2906 if (hostapd_parse_das_client(bss
, pos
) < 0) {
2907 wpa_printf(MSG_ERROR
, "Line %d: invalid DAS client",
2911 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2912 bss
->radius_das_time_window
= atoi(pos
);
2913 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp") == 0) {
2914 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2915 } else if (os_strcmp(buf
, "radius_das_require_message_authenticator") ==
2917 bss
->radius_das_require_message_authenticator
= atoi(pos
);
2918 #endif /* CONFIG_NO_RADIUS */
2919 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2920 bss
->auth_algs
= atoi(pos
);
2921 if (bss
->auth_algs
== 0) {
2922 wpa_printf(MSG_ERROR
, "Line %d: no authentication algorithms allowed",
2926 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2927 bss
->max_num_sta
= atoi(pos
);
2928 if (bss
->max_num_sta
< 0 ||
2929 bss
->max_num_sta
> MAX_STA_COUNT
) {
2930 wpa_printf(MSG_ERROR
, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2931 line
, bss
->max_num_sta
, MAX_STA_COUNT
);
2934 } else if (os_strcmp(buf
, "wpa") == 0) {
2935 bss
->wpa
= atoi(pos
);
2936 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2937 bss
->wpa_group_rekey
= atoi(pos
);
2938 bss
->wpa_group_rekey_set
= 1;
2939 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2940 bss
->wpa_strict_rekey
= atoi(pos
);
2941 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2942 bss
->wpa_gmk_rekey
= atoi(pos
);
2943 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2944 bss
->wpa_ptk_rekey
= atoi(pos
);
2945 } else if (os_strcmp(buf
, "wpa_group_update_count") == 0) {
2947 unsigned long val
= strtoul(pos
, &endp
, 0);
2949 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2950 wpa_printf(MSG_ERROR
,
2951 "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295",
2955 bss
->wpa_group_update_count
= (u32
) val
;
2956 } else if (os_strcmp(buf
, "wpa_pairwise_update_count") == 0) {
2958 unsigned long val
= strtoul(pos
, &endp
, 0);
2960 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2961 wpa_printf(MSG_ERROR
,
2962 "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295",
2966 bss
->wpa_pairwise_update_count
= (u32
) val
;
2967 } else if (os_strcmp(buf
, "wpa_disable_eapol_key_retries") == 0) {
2968 bss
->wpa_disable_eapol_key_retries
= atoi(pos
);
2969 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2970 int len
= os_strlen(pos
);
2971 if (len
< 8 || len
> 63) {
2972 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA passphrase length %d (expected 8..63)",
2976 os_free(bss
->ssid
.wpa_passphrase
);
2977 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2978 if (bss
->ssid
.wpa_passphrase
) {
2979 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2980 bss
->ssid
.wpa_passphrase_set
= 1;
2982 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2983 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2984 bss
->ssid
.wpa_psk
= os_zalloc(sizeof(struct hostapd_wpa_psk
));
2985 if (bss
->ssid
.wpa_psk
== NULL
)
2987 if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
, PMK_LEN
) ||
2988 pos
[PMK_LEN
* 2] != '\0') {
2989 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
2991 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2994 bss
->ssid
.wpa_psk
->group
= 1;
2995 os_free(bss
->ssid
.wpa_passphrase
);
2996 bss
->ssid
.wpa_passphrase
= NULL
;
2997 bss
->ssid
.wpa_psk_set
= 1;
2998 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2999 os_free(bss
->ssid
.wpa_psk_file
);
3000 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
3001 if (!bss
->ssid
.wpa_psk_file
) {
3002 wpa_printf(MSG_ERROR
, "Line %d: allocation failed",
3006 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
3007 bss
->wpa_key_mgmt
= hostapd_config_parse_key_mgmt(line
, pos
);
3008 if (bss
->wpa_key_mgmt
== -1)
3010 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
3011 bss
->wpa_psk_radius
= atoi(pos
);
3012 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
3013 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
3014 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
3015 wpa_printf(MSG_ERROR
,
3016 "Line %d: unknown wpa_psk_radius %d",
3017 line
, bss
->wpa_psk_radius
);
3020 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
3021 bss
->wpa_pairwise
= hostapd_config_parse_cipher(line
, pos
);
3022 if (bss
->wpa_pairwise
== -1 || bss
->wpa_pairwise
== 0)
3024 if (bss
->wpa_pairwise
&
3025 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
3026 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
3030 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
3031 bss
->rsn_pairwise
= hostapd_config_parse_cipher(line
, pos
);
3032 if (bss
->rsn_pairwise
== -1 || bss
->rsn_pairwise
== 0)
3034 if (bss
->rsn_pairwise
&
3035 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
3036 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
3040 } else if (os_strcmp(buf
, "group_cipher") == 0) {
3041 bss
->group_cipher
= hostapd_config_parse_cipher(line
, pos
);
3042 if (bss
->group_cipher
== -1 || bss
->group_cipher
== 0)
3044 if (bss
->group_cipher
!= WPA_CIPHER_TKIP
&&
3045 bss
->group_cipher
!= WPA_CIPHER_CCMP
&&
3046 bss
->group_cipher
!= WPA_CIPHER_GCMP
&&
3047 bss
->group_cipher
!= WPA_CIPHER_GCMP_256
&&
3048 bss
->group_cipher
!= WPA_CIPHER_CCMP_256
) {
3049 wpa_printf(MSG_ERROR
,
3050 "Line %d: unsupported group cipher suite '%s'",
3054 #ifdef CONFIG_RSN_PREAUTH
3055 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
3056 bss
->rsn_preauth
= atoi(pos
);
3057 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
3058 os_free(bss
->rsn_preauth_interfaces
);
3059 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
3060 #endif /* CONFIG_RSN_PREAUTH */
3061 } else if (os_strcmp(buf
, "peerkey") == 0) {
3062 wpa_printf(MSG_INFO
,
3063 "Line %d: Obsolete peerkey parameter ignored", line
);
3064 #ifdef CONFIG_IEEE80211R_AP
3065 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
3066 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
3067 hexstr2bin(pos
, bss
->mobility_domain
,
3068 MOBILITY_DOMAIN_ID_LEN
) != 0) {
3069 wpa_printf(MSG_ERROR
,
3070 "Line %d: Invalid mobility_domain '%s'",
3074 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
3075 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
3076 hexstr2bin(pos
, bss
->r1_key_holder
, FT_R1KH_ID_LEN
) != 0) {
3077 wpa_printf(MSG_ERROR
,
3078 "Line %d: Invalid r1_key_holder '%s'",
3082 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
3083 /* DEPRECATED: Use ft_r0_key_lifetime instead. */
3084 bss
->r0_key_lifetime
= atoi(pos
) * 60;
3085 } else if (os_strcmp(buf
, "ft_r0_key_lifetime") == 0) {
3086 bss
->r0_key_lifetime
= atoi(pos
);
3087 } else if (os_strcmp(buf
, "r1_max_key_lifetime") == 0) {
3088 bss
->r1_max_key_lifetime
= atoi(pos
);
3089 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
3090 bss
->reassociation_deadline
= atoi(pos
);
3091 } else if (os_strcmp(buf
, "rkh_pos_timeout") == 0) {
3092 bss
->rkh_pos_timeout
= atoi(pos
);
3093 } else if (os_strcmp(buf
, "rkh_neg_timeout") == 0) {
3094 bss
->rkh_neg_timeout
= atoi(pos
);
3095 } else if (os_strcmp(buf
, "rkh_pull_timeout") == 0) {
3096 bss
->rkh_pull_timeout
= atoi(pos
);
3097 } else if (os_strcmp(buf
, "rkh_pull_retries") == 0) {
3098 bss
->rkh_pull_retries
= atoi(pos
);
3099 } else if (os_strcmp(buf
, "r0kh") == 0) {
3100 if (add_r0kh(bss
, pos
) < 0) {
3101 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r0kh '%s'",
3105 } else if (os_strcmp(buf
, "r1kh") == 0) {
3106 if (add_r1kh(bss
, pos
) < 0) {
3107 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r1kh '%s'",
3111 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
3112 bss
->pmk_r1_push
= atoi(pos
);
3113 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
3114 bss
->ft_over_ds
= atoi(pos
);
3115 } else if (os_strcmp(buf
, "ft_psk_generate_local") == 0) {
3116 bss
->ft_psk_generate_local
= atoi(pos
);
3117 #endif /* CONFIG_IEEE80211R_AP */
3118 #ifndef CONFIG_NO_CTRL_IFACE
3119 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
3120 os_free(bss
->ctrl_interface
);
3121 bss
->ctrl_interface
= os_strdup(pos
);
3122 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
3123 #ifndef CONFIG_NATIVE_WINDOWS
3126 const char *group
= pos
;
3128 grp
= getgrnam(group
);
3130 bss
->ctrl_interface_gid
= grp
->gr_gid
;
3131 bss
->ctrl_interface_gid_set
= 1;
3132 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d (from group name '%s')",
3133 bss
->ctrl_interface_gid
, group
);
3137 /* Group name not found - try to parse this as gid */
3138 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
3139 if (*group
== '\0' || *endp
!= '\0') {
3140 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group '%s'",
3144 bss
->ctrl_interface_gid_set
= 1;
3145 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
3146 bss
->ctrl_interface_gid
);
3147 #endif /* CONFIG_NATIVE_WINDOWS */
3148 #endif /* CONFIG_NO_CTRL_IFACE */
3149 #ifdef RADIUS_SERVER
3150 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
3151 os_free(bss
->radius_server_clients
);
3152 bss
->radius_server_clients
= os_strdup(pos
);
3153 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
3154 bss
->radius_server_auth_port
= atoi(pos
);
3155 } else if (os_strcmp(buf
, "radius_server_acct_port") == 0) {
3156 bss
->radius_server_acct_port
= atoi(pos
);
3157 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
3158 bss
->radius_server_ipv6
= atoi(pos
);
3159 #endif /* RADIUS_SERVER */
3160 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
3161 bss
->use_pae_group_addr
= atoi(pos
);
3162 } else if (os_strcmp(buf
, "hw_mode") == 0) {
3163 if (os_strcmp(pos
, "a") == 0)
3164 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
3165 else if (os_strcmp(pos
, "b") == 0)
3166 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
3167 else if (os_strcmp(pos
, "g") == 0)
3168 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
3169 else if (os_strcmp(pos
, "ad") == 0)
3170 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
3171 else if (os_strcmp(pos
, "any") == 0)
3172 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211ANY
;
3174 wpa_printf(MSG_ERROR
, "Line %d: unknown hw_mode '%s'",
3178 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
3179 if (os_strcmp(pos
, "ad") == 0)
3180 bss
->wps_rf_bands
= WPS_RF_60GHZ
;
3181 else if (os_strcmp(pos
, "a") == 0)
3182 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
3183 else if (os_strcmp(pos
, "g") == 0 ||
3184 os_strcmp(pos
, "b") == 0)
3185 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
3186 else if (os_strcmp(pos
, "ag") == 0 ||
3187 os_strcmp(pos
, "ga") == 0)
3188 bss
->wps_rf_bands
= WPS_RF_24GHZ
| WPS_RF_50GHZ
;
3190 wpa_printf(MSG_ERROR
,
3191 "Line %d: unknown wps_rf_band '%s'",
3195 } else if (os_strcmp(buf
, "acs_exclude_dfs") == 0) {
3196 conf
->acs_exclude_dfs
= atoi(pos
);
3197 } else if (os_strcmp(buf
, "channel") == 0) {
3198 if (os_strcmp(pos
, "acs_survey") == 0) {
3200 wpa_printf(MSG_ERROR
, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
3203 #else /* CONFIG_ACS */
3206 #endif /* CONFIG_ACS */
3208 conf
->channel
= atoi(pos
);
3209 conf
->acs
= conf
->channel
== 0;
3211 } else if (os_strcmp(buf
, "chanlist") == 0) {
3212 if (hostapd_parse_chanlist(conf
, pos
)) {
3213 wpa_printf(MSG_ERROR
, "Line %d: invalid channel list",
3217 } else if (os_strcmp(buf
, "beacon_int") == 0) {
3218 int val
= atoi(pos
);
3219 /* MIB defines range as 1..65535, but very small values
3220 * cause problems with the current implementation.
3221 * Since it is unlikely that this small numbers are
3222 * useful in real life scenarios, do not allow beacon
3223 * period to be set below 10 TU. */
3224 if (val
< 10 || val
> 65535) {
3225 wpa_printf(MSG_ERROR
,
3226 "Line %d: invalid beacon_int %d (expected 10..65535)",
3230 conf
->beacon_int
= val
;
3232 } else if (os_strcmp(buf
, "acs_num_scans") == 0) {
3233 int val
= atoi(pos
);
3234 if (val
<= 0 || val
> 100) {
3235 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_num_scans %d (expected 1..100)",
3239 conf
->acs_num_scans
= val
;
3240 } else if (os_strcmp(buf
, "acs_chan_bias") == 0) {
3241 if (hostapd_config_parse_acs_chan_bias(conf
, pos
)) {
3242 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_chan_bias",
3246 #endif /* CONFIG_ACS */
3247 } else if (os_strcmp(buf
, "dtim_period") == 0) {
3248 int val
= atoi(pos
);
3250 if (val
< 1 || val
> 255) {
3251 wpa_printf(MSG_ERROR
, "Line %d: invalid dtim_period %d",
3255 bss
->dtim_period
= val
;
3256 } else if (os_strcmp(buf
, "bss_load_update_period") == 0) {
3257 int val
= atoi(pos
);
3259 if (val
< 0 || val
> 100) {
3260 wpa_printf(MSG_ERROR
,
3261 "Line %d: invalid bss_load_update_period %d",
3265 bss
->bss_load_update_period
= val
;
3266 } else if (os_strcmp(buf
, "chan_util_avg_period") == 0) {
3267 int val
= atoi(pos
);
3270 wpa_printf(MSG_ERROR
,
3271 "Line %d: invalid chan_util_avg_period",
3275 bss
->chan_util_avg_period
= val
;
3276 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
3277 conf
->rts_threshold
= atoi(pos
);
3278 if (conf
->rts_threshold
< -1 || conf
->rts_threshold
> 65535) {
3279 wpa_printf(MSG_ERROR
,
3280 "Line %d: invalid rts_threshold %d",
3281 line
, conf
->rts_threshold
);
3284 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
3285 conf
->fragm_threshold
= atoi(pos
);
3286 if (conf
->fragm_threshold
== -1) {
3287 /* allow a value of -1 */
3288 } else if (conf
->fragm_threshold
< 256 ||
3289 conf
->fragm_threshold
> 2346) {
3290 wpa_printf(MSG_ERROR
,
3291 "Line %d: invalid fragm_threshold %d",
3292 line
, conf
->fragm_threshold
);
3295 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
3296 int val
= atoi(pos
);
3297 if (val
!= 0 && val
!= 1) {
3298 wpa_printf(MSG_ERROR
, "Line %d: invalid send_probe_response %d (expected 0 or 1)",
3302 bss
->send_probe_response
= val
;
3303 } else if (os_strcmp(buf
, "supported_rates") == 0) {
3304 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
)) {
3305 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3309 } else if (os_strcmp(buf
, "basic_rates") == 0) {
3310 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
3311 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3315 } else if (os_strcmp(buf
, "beacon_rate") == 0) {
3318 if (os_strncmp(pos
, "ht:", 3) == 0) {
3319 val
= atoi(pos
+ 3);
3320 if (val
< 0 || val
> 31) {
3321 wpa_printf(MSG_ERROR
,
3322 "Line %d: invalid beacon_rate HT-MCS %d",
3326 conf
->rate_type
= BEACON_RATE_HT
;
3327 conf
->beacon_rate
= val
;
3328 } else if (os_strncmp(pos
, "vht:", 4) == 0) {
3329 val
= atoi(pos
+ 4);
3330 if (val
< 0 || val
> 9) {
3331 wpa_printf(MSG_ERROR
,
3332 "Line %d: invalid beacon_rate VHT-MCS %d",
3336 conf
->rate_type
= BEACON_RATE_VHT
;
3337 conf
->beacon_rate
= val
;
3340 if (val
< 10 || val
> 10000) {
3341 wpa_printf(MSG_ERROR
,
3342 "Line %d: invalid legacy beacon_rate %d",
3346 conf
->rate_type
= BEACON_RATE_LEGACY
;
3347 conf
->beacon_rate
= val
;
3349 } else if (os_strcmp(buf
, "preamble") == 0) {
3351 conf
->preamble
= SHORT_PREAMBLE
;
3353 conf
->preamble
= LONG_PREAMBLE
;
3354 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
3355 bss
->ignore_broadcast_ssid
= atoi(pos
);
3356 } else if (os_strcmp(buf
, "no_probe_resp_if_max_sta") == 0) {
3357 bss
->no_probe_resp_if_max_sta
= atoi(pos
);
3358 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
3359 bss
->ssid
.wep
.idx
= atoi(pos
);
3360 if (bss
->ssid
.wep
.idx
> 3) {
3361 wpa_printf(MSG_ERROR
,
3362 "Invalid wep_default_key index %d",
3366 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
3367 os_strcmp(buf
, "wep_key1") == 0 ||
3368 os_strcmp(buf
, "wep_key2") == 0 ||
3369 os_strcmp(buf
, "wep_key3") == 0) {
3370 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
3371 buf
[7] - '0', pos
)) {
3372 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP key '%s'",
3376 #ifndef CONFIG_NO_VLAN
3377 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
3378 bss
->ssid
.dynamic_vlan
= atoi(pos
);
3379 } else if (os_strcmp(buf
, "per_sta_vif") == 0) {
3380 bss
->ssid
.per_sta_vif
= atoi(pos
);
3381 } else if (os_strcmp(buf
, "vlan_file") == 0) {
3382 if (hostapd_config_read_vlan_file(bss
, pos
)) {
3383 wpa_printf(MSG_ERROR
, "Line %d: failed to read VLAN file '%s'",
3387 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
3388 bss
->ssid
.vlan_naming
= atoi(pos
);
3389 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
3390 bss
->ssid
.vlan_naming
< 0) {
3391 wpa_printf(MSG_ERROR
,
3392 "Line %d: invalid naming scheme %d",
3393 line
, bss
->ssid
.vlan_naming
);
3396 #ifdef CONFIG_FULL_DYNAMIC_VLAN
3397 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
3398 os_free(bss
->ssid
.vlan_tagged_interface
);
3399 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
3400 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
3401 #endif /* CONFIG_NO_VLAN */
3402 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
3403 conf
->ap_table_max_size
= atoi(pos
);
3404 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
3405 conf
->ap_table_expiration_time
= atoi(pos
);
3406 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
3407 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
3408 wpa_printf(MSG_ERROR
, "Line %d: invalid TX queue item",
3412 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
3413 os_strcmp(buf
, "wmm_enabled") == 0) {
3414 bss
->wmm_enabled
= atoi(pos
);
3415 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
3416 bss
->wmm_uapsd
= atoi(pos
);
3417 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
3418 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
3419 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
, pos
)) {
3420 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM ac item",
3424 } else if (os_strcmp(buf
, "bss") == 0) {
3425 if (hostapd_config_bss(conf
, pos
)) {
3426 wpa_printf(MSG_ERROR
, "Line %d: invalid bss item",
3430 } else if (os_strcmp(buf
, "bssid") == 0) {
3431 if (hwaddr_aton(pos
, bss
->bssid
)) {
3432 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid item",
3436 } else if (os_strcmp(buf
, "use_driver_iface_addr") == 0) {
3437 conf
->use_driver_iface_addr
= atoi(pos
);
3438 #ifdef CONFIG_IEEE80211W
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
;
3451 wpa_printf(MSG_ERROR
, "Line %d: invalid group_mgmt_cipher: %s",
3455 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
3456 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
3457 if (bss
->assoc_sa_query_max_timeout
== 0) {
3458 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_max_timeout",
3462 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0) {
3463 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
3464 if (bss
->assoc_sa_query_retry_timeout
== 0) {
3465 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_retry_timeout",
3469 #endif /* CONFIG_IEEE80211W */
3471 } else if (os_strcmp(buf
, "ocv") == 0) {
3472 bss
->ocv
= atoi(pos
);
3473 if (bss
->ocv
&& !bss
->ieee80211w
)
3474 bss
->ieee80211w
= 1;
3475 #endif /* CONFIG_OCV */
3476 #ifdef CONFIG_IEEE80211N
3477 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
3478 conf
->ieee80211n
= atoi(pos
);
3479 } else if (os_strcmp(buf
, "ht_capab") == 0) {
3480 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
3481 wpa_printf(MSG_ERROR
, "Line %d: invalid ht_capab",
3485 } else if (os_strcmp(buf
, "require_ht") == 0) {
3486 conf
->require_ht
= atoi(pos
);
3487 } else if (os_strcmp(buf
, "obss_interval") == 0) {
3488 conf
->obss_interval
= atoi(pos
);
3489 #endif /* CONFIG_IEEE80211N */
3490 #ifdef CONFIG_IEEE80211AC
3491 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
3492 conf
->ieee80211ac
= atoi(pos
);
3493 } else if (os_strcmp(buf
, "vht_capab") == 0) {
3494 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
3495 wpa_printf(MSG_ERROR
, "Line %d: invalid vht_capab",
3499 } else if (os_strcmp(buf
, "require_vht") == 0) {
3500 conf
->require_vht
= atoi(pos
);
3501 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
3502 conf
->vht_oper_chwidth
= atoi(pos
);
3503 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0) {
3504 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
3505 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0) {
3506 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
3507 } else if (os_strcmp(buf
, "vendor_vht") == 0) {
3508 bss
->vendor_vht
= atoi(pos
);
3509 } else if (os_strcmp(buf
, "use_sta_nsts") == 0) {
3510 bss
->use_sta_nsts
= atoi(pos
);
3511 #endif /* CONFIG_IEEE80211AC */
3512 #ifdef CONFIG_IEEE80211AX
3513 } else if (os_strcmp(buf
, "ieee80211ax") == 0) {
3514 conf
->ieee80211ax
= atoi(pos
);
3515 } else if (os_strcmp(buf
, "he_su_beamformer") == 0) {
3516 conf
->he_phy_capab
.he_su_beamformer
= atoi(pos
);
3517 } else if (os_strcmp(buf
, "he_su_beamformee") == 0) {
3518 conf
->he_phy_capab
.he_su_beamformee
= atoi(pos
);
3519 } else if (os_strcmp(buf
, "he_mu_beamformer") == 0) {
3520 conf
->he_phy_capab
.he_mu_beamformer
= atoi(pos
);
3521 } else if (os_strcmp(buf
, "he_bss_color") == 0) {
3522 conf
->he_op
.he_bss_color
= atoi(pos
);
3523 } else if (os_strcmp(buf
, "he_default_pe_duration") == 0) {
3524 conf
->he_op
.he_default_pe_duration
= atoi(pos
);
3525 } else if (os_strcmp(buf
, "he_twt_required") == 0) {
3526 conf
->he_op
.he_twt_required
= atoi(pos
);
3527 } else if (os_strcmp(buf
, "he_rts_threshold") == 0) {
3528 conf
->he_op
.he_rts_threshold
= atoi(pos
);
3529 } else if (os_strcmp(buf
, "he_basic_mcs_nss_set") == 0) {
3530 conf
->he_op
.he_basic_mcs_nss_set
= atoi(pos
);
3531 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_param_count") == 0) {
3532 conf
->he_mu_edca
.he_qos_info
|=
3533 set_he_cap(atoi(pos
), HE_QOS_INFO_EDCA_PARAM_SET_COUNT
);
3534 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_q_ack") == 0) {
3535 conf
->he_mu_edca
.he_qos_info
|=
3536 set_he_cap(atoi(pos
), HE_QOS_INFO_Q_ACK
);
3537 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_queue_request") == 0) {
3538 conf
->he_mu_edca
.he_qos_info
|=
3539 set_he_cap(atoi(pos
), HE_QOS_INFO_QUEUE_REQUEST
);
3540 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_txop_request") == 0) {
3541 conf
->he_mu_edca
.he_qos_info
|=
3542 set_he_cap(atoi(pos
), HE_QOS_INFO_TXOP_REQUEST
);
3543 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_aifsn") == 0) {
3544 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3545 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3546 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_acm") == 0) {
3547 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3548 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3549 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_aci") == 0) {
3550 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3551 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3552 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_ecwmin") == 0) {
3553 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3554 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3555 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_ecwmax") == 0) {
3556 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3557 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3558 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_timer") == 0) {
3559 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3561 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_aifsn") == 0) {
3562 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3563 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3564 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_acm") == 0) {
3565 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3566 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3567 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_aci") == 0) {
3568 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3569 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3570 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_ecwmin") == 0) {
3571 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3572 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3573 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_ecwmax") == 0) {
3574 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3575 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3576 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_timer") == 0) {
3577 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3579 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_aifsn") == 0) {
3580 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3581 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3582 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_acm") == 0) {
3583 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3584 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3585 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_aci") == 0) {
3586 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3587 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3588 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_ecwmin") == 0) {
3589 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3590 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3591 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_ecwmax") == 0) {
3592 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3593 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3594 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_timer") == 0) {
3595 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3597 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_aifsn") == 0) {
3598 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3599 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3600 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_acm") == 0) {
3601 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3602 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3603 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_aci") == 0) {
3604 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3605 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3606 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_ecwmin") == 0) {
3607 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3608 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3609 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_ecwmax") == 0) {
3610 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3611 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3612 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_timer") == 0) {
3613 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3615 } else if (os_strcmp(buf
, "he_spr_sr_control") == 0) {
3616 conf
->spr
.sr_control
= atoi(pos
) & 0xff;
3617 } else if (os_strcmp(buf
, "he_spr_non_srg_obss_pd_max_offset") == 0) {
3618 conf
->spr
.non_srg_obss_pd_max_offset
= atoi(pos
);
3619 } else if (os_strcmp(buf
, "he_spr_srg_obss_pd_min_offset") == 0) {
3620 conf
->spr
.srg_obss_pd_min_offset
= atoi(pos
);
3621 } else if (os_strcmp(buf
, "he_spr_srg_obss_pd_max_offset") == 0) {
3622 conf
->spr
.srg_obss_pd_max_offset
= atoi(pos
);
3623 } else if (os_strcmp(buf
, "he_oper_chwidth") == 0) {
3624 conf
->he_oper_chwidth
= atoi(pos
);
3625 } else if (os_strcmp(buf
, "he_oper_centr_freq_seg0_idx") == 0) {
3626 conf
->he_oper_centr_freq_seg0_idx
= atoi(pos
);
3627 } else if (os_strcmp(buf
, "he_oper_centr_freq_seg1_idx") == 0) {
3628 conf
->he_oper_centr_freq_seg1_idx
= atoi(pos
);
3629 #endif /* CONFIG_IEEE80211AX */
3630 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
3631 bss
->max_listen_interval
= atoi(pos
);
3632 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
3633 bss
->disable_pmksa_caching
= atoi(pos
);
3634 } else if (os_strcmp(buf
, "okc") == 0) {
3635 bss
->okc
= atoi(pos
);
3637 } else if (os_strcmp(buf
, "wps_state") == 0) {
3638 bss
->wps_state
= atoi(pos
);
3639 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
3640 wpa_printf(MSG_ERROR
, "Line %d: invalid wps_state",
3644 } else if (os_strcmp(buf
, "wps_independent") == 0) {
3645 bss
->wps_independent
= atoi(pos
);
3646 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
3647 bss
->ap_setup_locked
= atoi(pos
);
3648 } else if (os_strcmp(buf
, "uuid") == 0) {
3649 if (uuid_str2bin(pos
, bss
->uuid
)) {
3650 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID", line
);
3653 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
3654 os_free(bss
->wps_pin_requests
);
3655 bss
->wps_pin_requests
= os_strdup(pos
);
3656 } else if (os_strcmp(buf
, "device_name") == 0) {
3657 if (os_strlen(pos
) > WPS_DEV_NAME_MAX_LEN
) {
3658 wpa_printf(MSG_ERROR
, "Line %d: Too long "
3659 "device_name", line
);
3662 os_free(bss
->device_name
);
3663 bss
->device_name
= os_strdup(pos
);
3664 } else if (os_strcmp(buf
, "manufacturer") == 0) {
3665 if (os_strlen(pos
) > 64) {
3666 wpa_printf(MSG_ERROR
, "Line %d: Too long manufacturer",
3670 os_free(bss
->manufacturer
);
3671 bss
->manufacturer
= os_strdup(pos
);
3672 } else if (os_strcmp(buf
, "model_name") == 0) {
3673 if (os_strlen(pos
) > 32) {
3674 wpa_printf(MSG_ERROR
, "Line %d: Too long model_name",
3678 os_free(bss
->model_name
);
3679 bss
->model_name
= os_strdup(pos
);
3680 } else if (os_strcmp(buf
, "model_number") == 0) {
3681 if (os_strlen(pos
) > 32) {
3682 wpa_printf(MSG_ERROR
, "Line %d: Too long model_number",
3686 os_free(bss
->model_number
);
3687 bss
->model_number
= os_strdup(pos
);
3688 } else if (os_strcmp(buf
, "serial_number") == 0) {
3689 if (os_strlen(pos
) > 32) {
3690 wpa_printf(MSG_ERROR
, "Line %d: Too long serial_number",
3694 os_free(bss
->serial_number
);
3695 bss
->serial_number
= os_strdup(pos
);
3696 } else if (os_strcmp(buf
, "device_type") == 0) {
3697 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
3699 } else if (os_strcmp(buf
, "config_methods") == 0) {
3700 os_free(bss
->config_methods
);
3701 bss
->config_methods
= os_strdup(pos
);
3702 } else if (os_strcmp(buf
, "os_version") == 0) {
3703 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
3704 wpa_printf(MSG_ERROR
, "Line %d: invalid os_version",
3708 } else if (os_strcmp(buf
, "ap_pin") == 0) {
3709 os_free(bss
->ap_pin
);
3713 bss
->ap_pin
= os_strdup(pos
);
3714 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
3715 bss
->skip_cred_build
= atoi(pos
);
3716 } else if (os_strcmp(buf
, "extra_cred") == 0) {
3717 os_free(bss
->extra_cred
);
3718 bss
->extra_cred
= (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
3719 if (bss
->extra_cred
== NULL
) {
3720 wpa_printf(MSG_ERROR
, "Line %d: could not read Credentials from '%s'",
3724 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
3725 bss
->wps_cred_processing
= atoi(pos
);
3726 } else if (os_strcmp(buf
, "wps_cred_add_sae") == 0) {
3727 bss
->wps_cred_add_sae
= atoi(pos
);
3728 } else if (os_strcmp(buf
, "ap_settings") == 0) {
3729 os_free(bss
->ap_settings
);
3731 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
3732 if (bss
->ap_settings
== NULL
) {
3733 wpa_printf(MSG_ERROR
, "Line %d: could not read AP Settings from '%s'",
3737 } else if (os_strcmp(buf
, "multi_ap_backhaul_ssid") == 0) {
3739 char *str
= wpa_config_parse_string(pos
, &slen
);
3741 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
3742 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
3747 os_memcpy(bss
->multi_ap_backhaul_ssid
.ssid
, str
, slen
);
3748 bss
->multi_ap_backhaul_ssid
.ssid_len
= slen
;
3749 bss
->multi_ap_backhaul_ssid
.ssid_set
= 1;
3751 } else if (os_strcmp(buf
, "multi_ap_backhaul_wpa_passphrase") == 0) {
3752 int len
= os_strlen(pos
);
3754 if (len
< 8 || len
> 63) {
3755 wpa_printf(MSG_ERROR
,
3756 "Line %d: invalid WPA passphrase length %d (expected 8..63)",
3760 os_free(bss
->multi_ap_backhaul_ssid
.wpa_passphrase
);
3761 bss
->multi_ap_backhaul_ssid
.wpa_passphrase
= os_strdup(pos
);
3762 if (bss
->multi_ap_backhaul_ssid
.wpa_passphrase
) {
3763 hostapd_config_clear_wpa_psk(
3764 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3765 bss
->multi_ap_backhaul_ssid
.wpa_passphrase_set
= 1;
3767 } else if (os_strcmp(buf
, "multi_ap_backhaul_wpa_psk") == 0) {
3768 hostapd_config_clear_wpa_psk(
3769 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3770 bss
->multi_ap_backhaul_ssid
.wpa_psk
=
3771 os_zalloc(sizeof(struct hostapd_wpa_psk
));
3772 if (!bss
->multi_ap_backhaul_ssid
.wpa_psk
)
3774 if (hexstr2bin(pos
, bss
->multi_ap_backhaul_ssid
.wpa_psk
->psk
,
3776 pos
[PMK_LEN
* 2] != '\0') {
3777 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
3779 hostapd_config_clear_wpa_psk(
3780 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3783 bss
->multi_ap_backhaul_ssid
.wpa_psk
->group
= 1;
3784 os_free(bss
->multi_ap_backhaul_ssid
.wpa_passphrase
);
3785 bss
->multi_ap_backhaul_ssid
.wpa_passphrase
= NULL
;
3786 bss
->multi_ap_backhaul_ssid
.wpa_psk_set
= 1;
3787 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
3788 os_free(bss
->upnp_iface
);
3789 bss
->upnp_iface
= os_strdup(pos
);
3790 } else if (os_strcmp(buf
, "friendly_name") == 0) {
3791 os_free(bss
->friendly_name
);
3792 bss
->friendly_name
= os_strdup(pos
);
3793 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
3794 os_free(bss
->manufacturer_url
);
3795 bss
->manufacturer_url
= os_strdup(pos
);
3796 } else if (os_strcmp(buf
, "model_description") == 0) {
3797 os_free(bss
->model_description
);
3798 bss
->model_description
= os_strdup(pos
);
3799 } else if (os_strcmp(buf
, "model_url") == 0) {
3800 os_free(bss
->model_url
);
3801 bss
->model_url
= os_strdup(pos
);
3802 } else if (os_strcmp(buf
, "upc") == 0) {
3804 bss
->upc
= os_strdup(pos
);
3805 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
3806 bss
->pbc_in_m1
= atoi(pos
);
3807 } else if (os_strcmp(buf
, "server_id") == 0) {
3808 os_free(bss
->server_id
);
3809 bss
->server_id
= os_strdup(pos
);
3810 #ifdef CONFIG_WPS_NFC
3811 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
3812 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
3813 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
3814 bss
->wps_nfc_dev_pw_id
> 0xffff) {
3815 wpa_printf(MSG_ERROR
, "Line %d: Invalid wps_nfc_dev_pw_id value",
3819 bss
->wps_nfc_pw_from_config
= 1;
3820 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
3821 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
3822 bss
->wps_nfc_dh_pubkey
= wpabuf_parse_bin(pos
);
3823 bss
->wps_nfc_pw_from_config
= 1;
3824 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
3825 wpabuf_free(bss
->wps_nfc_dh_privkey
);
3826 bss
->wps_nfc_dh_privkey
= wpabuf_parse_bin(pos
);
3827 bss
->wps_nfc_pw_from_config
= 1;
3828 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
3829 wpabuf_free(bss
->wps_nfc_dev_pw
);
3830 bss
->wps_nfc_dev_pw
= wpabuf_parse_bin(pos
);
3831 bss
->wps_nfc_pw_from_config
= 1;
3832 #endif /* CONFIG_WPS_NFC */
3833 #endif /* CONFIG_WPS */
3834 #ifdef CONFIG_P2P_MANAGER
3835 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
3837 bss
->p2p
|= P2P_MANAGE
;
3839 bss
->p2p
&= ~P2P_MANAGE
;
3840 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
3842 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
3844 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
3845 #endif /* CONFIG_P2P_MANAGER */
3846 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
3847 bss
->disassoc_low_ack
= atoi(pos
);
3848 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
3850 bss
->tdls
|= TDLS_PROHIBIT
;
3852 bss
->tdls
&= ~TDLS_PROHIBIT
;
3853 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
3855 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
3857 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
3858 #ifdef CONFIG_RSN_TESTING
3859 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
3860 extern int rsn_testing
;
3861 rsn_testing
= atoi(pos
);
3862 #endif /* CONFIG_RSN_TESTING */
3863 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
3864 bss
->time_advertisement
= atoi(pos
);
3865 } else if (os_strcmp(buf
, "time_zone") == 0) {
3866 size_t tz_len
= os_strlen(pos
);
3867 if (tz_len
< 4 || tz_len
> 255) {
3868 wpa_printf(MSG_DEBUG
, "Line %d: invalid time_zone",
3872 os_free(bss
->time_zone
);
3873 bss
->time_zone
= os_strdup(pos
);
3874 if (bss
->time_zone
== NULL
)
3876 #ifdef CONFIG_WNM_AP
3877 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
3878 bss
->wnm_sleep_mode
= atoi(pos
);
3879 } else if (os_strcmp(buf
, "wnm_sleep_mode_no_keys") == 0) {
3880 bss
->wnm_sleep_mode_no_keys
= atoi(pos
);
3881 } else if (os_strcmp(buf
, "bss_transition") == 0) {
3882 bss
->bss_transition
= atoi(pos
);
3883 #endif /* CONFIG_WNM_AP */
3884 #ifdef CONFIG_INTERWORKING
3885 } else if (os_strcmp(buf
, "interworking") == 0) {
3886 bss
->interworking
= atoi(pos
);
3887 } else if (os_strcmp(buf
, "access_network_type") == 0) {
3888 bss
->access_network_type
= atoi(pos
);
3889 if (bss
->access_network_type
< 0 ||
3890 bss
->access_network_type
> 15) {
3891 wpa_printf(MSG_ERROR
,
3892 "Line %d: invalid access_network_type",
3896 } else if (os_strcmp(buf
, "internet") == 0) {
3897 bss
->internet
= atoi(pos
);
3898 } else if (os_strcmp(buf
, "asra") == 0) {
3899 bss
->asra
= atoi(pos
);
3900 } else if (os_strcmp(buf
, "esr") == 0) {
3901 bss
->esr
= atoi(pos
);
3902 } else if (os_strcmp(buf
, "uesa") == 0) {
3903 bss
->uesa
= atoi(pos
);
3904 } else if (os_strcmp(buf
, "venue_group") == 0) {
3905 bss
->venue_group
= atoi(pos
);
3906 bss
->venue_info_set
= 1;
3907 } else if (os_strcmp(buf
, "venue_type") == 0) {
3908 bss
->venue_type
= atoi(pos
);
3909 bss
->venue_info_set
= 1;
3910 } else if (os_strcmp(buf
, "hessid") == 0) {
3911 if (hwaddr_aton(pos
, bss
->hessid
)) {
3912 wpa_printf(MSG_ERROR
, "Line %d: invalid hessid", line
);
3915 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
3916 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
3918 } else if (os_strcmp(buf
, "venue_name") == 0) {
3919 if (parse_venue_name(bss
, pos
, line
) < 0)
3921 } else if (os_strcmp(buf
, "venue_url") == 0) {
3922 if (parse_venue_url(bss
, pos
, line
) < 0)
3924 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
3926 u16 redirect_url_len
;
3927 if (hexstr2bin(pos
, &auth_type
, 1)) {
3928 wpa_printf(MSG_ERROR
,
3929 "Line %d: Invalid network_auth_type '%s'",
3933 if (auth_type
== 0 || auth_type
== 2)
3934 redirect_url_len
= os_strlen(pos
+ 2);
3936 redirect_url_len
= 0;
3937 os_free(bss
->network_auth_type
);
3938 bss
->network_auth_type
= os_malloc(redirect_url_len
+ 3 + 1);
3939 if (bss
->network_auth_type
== NULL
)
3941 *bss
->network_auth_type
= auth_type
;
3942 WPA_PUT_LE16(bss
->network_auth_type
+ 1, redirect_url_len
);
3943 if (redirect_url_len
)
3944 os_memcpy(bss
->network_auth_type
+ 3, pos
+ 2,
3946 bss
->network_auth_type_len
= 3 + redirect_url_len
;
3947 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
3948 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1)) {
3949 wpa_printf(MSG_ERROR
, "Line %d: Invalid ipaddr_type_availability '%s'",
3951 bss
->ipaddr_type_configured
= 0;
3954 bss
->ipaddr_type_configured
= 1;
3955 } else if (os_strcmp(buf
, "domain_name") == 0) {
3956 int j
, num_domains
, domain_len
, domain_list_len
= 0;
3957 char *tok_start
, *tok_prev
;
3958 u8
*domain_list
, *domain_ptr
;
3960 domain_list_len
= os_strlen(pos
) + 1;
3961 domain_list
= os_malloc(domain_list_len
);
3962 if (domain_list
== NULL
)
3965 domain_ptr
= domain_list
;
3968 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
3973 for (j
= 0; j
< num_domains
; j
++) {
3974 tok_start
= os_strchr(tok_prev
, ',');
3976 domain_len
= tok_start
- tok_prev
;
3977 *domain_ptr
= domain_len
;
3978 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3979 domain_ptr
+= domain_len
+ 1;
3980 tok_prev
= ++tok_start
;
3982 domain_len
= os_strlen(tok_prev
);
3983 *domain_ptr
= domain_len
;
3984 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3985 domain_ptr
+= domain_len
+ 1;
3989 os_free(bss
->domain_name
);
3990 bss
->domain_name
= domain_list
;
3991 bss
->domain_name_len
= domain_list_len
;
3992 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
3993 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
3995 } else if (os_strcmp(buf
, "nai_realm") == 0) {
3996 if (parse_nai_realm(bss
, pos
, line
) < 0)
3998 } else if (os_strcmp(buf
, "anqp_elem") == 0) {
3999 if (parse_anqp_elem(bss
, pos
, line
) < 0)
4001 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
4002 int val
= atoi(pos
);
4005 wpa_printf(MSG_ERROR
,
4006 "Line %d: Invalid gas_frag_limit '%s'",
4010 bss
->gas_frag_limit
= val
;
4011 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
4012 bss
->gas_comeback_delay
= atoi(pos
);
4013 } else if (os_strcmp(buf
, "qos_map_set") == 0) {
4014 if (parse_qos_map_set(bss
, pos
, line
) < 0)
4016 #endif /* CONFIG_INTERWORKING */
4017 #ifdef CONFIG_RADIUS_TEST
4018 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
4019 os_free(bss
->dump_msk_file
);
4020 bss
->dump_msk_file
= os_strdup(pos
);
4021 #endif /* CONFIG_RADIUS_TEST */
4022 #ifdef CONFIG_PROXYARP
4023 } else if (os_strcmp(buf
, "proxy_arp") == 0) {
4024 bss
->proxy_arp
= atoi(pos
);
4025 #endif /* CONFIG_PROXYARP */
4027 } else if (os_strcmp(buf
, "hs20") == 0) {
4028 bss
->hs20
= atoi(pos
);
4029 } else if (os_strcmp(buf
, "hs20_release") == 0) {
4030 int val
= atoi(pos
);
4032 if (val
< 1 || val
> (HS20_VERSION
>> 4) + 1) {
4033 wpa_printf(MSG_ERROR
,
4034 "Line %d: Unsupported hs20_release: %s",
4038 bss
->hs20_release
= val
;
4039 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
4040 bss
->disable_dgaf
= atoi(pos
);
4041 } else if (os_strcmp(buf
, "na_mcast_to_ucast") == 0) {
4042 bss
->na_mcast_to_ucast
= atoi(pos
);
4043 } else if (os_strcmp(buf
, "osen") == 0) {
4044 bss
->osen
= atoi(pos
);
4045 } else if (os_strcmp(buf
, "anqp_domain_id") == 0) {
4046 bss
->anqp_domain_id
= atoi(pos
);
4047 } else if (os_strcmp(buf
, "hs20_deauth_req_timeout") == 0) {
4048 bss
->hs20_deauth_req_timeout
= atoi(pos
);
4049 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
4050 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
4052 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
4053 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0)
4055 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
4056 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
4059 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
4061 size_t oper_class_len
;
4062 oper_class_len
= os_strlen(pos
);
4063 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
4064 wpa_printf(MSG_ERROR
,
4065 "Line %d: Invalid hs20_operating_class '%s'",
4069 oper_class_len
/= 2;
4070 oper_class
= os_malloc(oper_class_len
);
4071 if (oper_class
== NULL
)
4073 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
4074 wpa_printf(MSG_ERROR
,
4075 "Line %d: Invalid hs20_operating_class '%s'",
4077 os_free(oper_class
);
4080 os_free(bss
->hs20_operating_class
);
4081 bss
->hs20_operating_class
= oper_class
;
4082 bss
->hs20_operating_class_len
= oper_class_len
;
4083 } else if (os_strcmp(buf
, "hs20_icon") == 0) {
4084 if (hs20_parse_icon(bss
, pos
) < 0) {
4085 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_icon '%s'",
4089 } else if (os_strcmp(buf
, "osu_ssid") == 0) {
4090 if (hs20_parse_osu_ssid(bss
, pos
, line
) < 0)
4092 } else if (os_strcmp(buf
, "osu_server_uri") == 0) {
4093 if (hs20_parse_osu_server_uri(bss
, pos
, line
) < 0)
4095 } else if (os_strcmp(buf
, "osu_friendly_name") == 0) {
4096 if (hs20_parse_osu_friendly_name(bss
, pos
, line
) < 0)
4098 } else if (os_strcmp(buf
, "osu_nai") == 0) {
4099 if (hs20_parse_osu_nai(bss
, pos
, line
) < 0)
4101 } else if (os_strcmp(buf
, "osu_nai2") == 0) {
4102 if (hs20_parse_osu_nai2(bss
, pos
, line
) < 0)
4104 } else if (os_strcmp(buf
, "osu_method_list") == 0) {
4105 if (hs20_parse_osu_method_list(bss
, pos
, line
) < 0)
4107 } else if (os_strcmp(buf
, "osu_icon") == 0) {
4108 if (hs20_parse_osu_icon(bss
, pos
, line
) < 0)
4110 } else if (os_strcmp(buf
, "osu_service_desc") == 0) {
4111 if (hs20_parse_osu_service_desc(bss
, pos
, line
) < 0)
4113 } else if (os_strcmp(buf
, "operator_icon") == 0) {
4114 if (hs20_parse_operator_icon(bss
, pos
, line
) < 0)
4116 } else if (os_strcmp(buf
, "subscr_remediation_url") == 0) {
4117 os_free(bss
->subscr_remediation_url
);
4118 bss
->subscr_remediation_url
= os_strdup(pos
);
4119 } else if (os_strcmp(buf
, "subscr_remediation_method") == 0) {
4120 bss
->subscr_remediation_method
= atoi(pos
);
4121 } else if (os_strcmp(buf
, "hs20_t_c_filename") == 0) {
4122 os_free(bss
->t_c_filename
);
4123 bss
->t_c_filename
= os_strdup(pos
);
4124 } else if (os_strcmp(buf
, "hs20_t_c_timestamp") == 0) {
4125 bss
->t_c_timestamp
= strtol(pos
, NULL
, 0);
4126 } else if (os_strcmp(buf
, "hs20_t_c_server_url") == 0) {
4127 os_free(bss
->t_c_server_url
);
4128 bss
->t_c_server_url
= os_strdup(pos
);
4129 } else if (os_strcmp(buf
, "hs20_sim_provisioning_url") == 0) {
4130 os_free(bss
->hs20_sim_provisioning_url
);
4131 bss
->hs20_sim_provisioning_url
= os_strdup(pos
);
4132 #endif /* CONFIG_HS20 */
4134 } else if (os_strcmp(buf
, "mbo") == 0) {
4135 bss
->mbo_enabled
= atoi(pos
);
4136 } else if (os_strcmp(buf
, "mbo_cell_data_conn_pref") == 0) {
4137 bss
->mbo_cell_data_conn_pref
= atoi(pos
);
4138 } else if (os_strcmp(buf
, "oce") == 0) {
4139 bss
->oce
= atoi(pos
);
4140 #endif /* CONFIG_MBO */
4141 #ifdef CONFIG_TESTING_OPTIONS
4142 #define PARSE_TEST_PROBABILITY(_val) \
4143 } else if (os_strcmp(buf, #_val) == 0) { \
4146 conf->_val = strtod(pos, &end); \
4147 if (*end || conf->_val < 0.0 || \
4148 conf->_val > 1.0) { \
4149 wpa_printf(MSG_ERROR, \
4150 "Line %d: Invalid value '%s'", \
4154 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
4155 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
4156 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
4157 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
4158 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
4159 } else if (os_strcmp(buf
, "ecsa_ie_only") == 0) {
4160 conf
->ecsa_ie_only
= atoi(pos
);
4161 } else if (os_strcmp(buf
, "bss_load_test") == 0) {
4162 WPA_PUT_LE16(bss
->bss_load_test
, atoi(pos
));
4163 pos
= os_strchr(pos
, ':');
4165 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
4170 bss
->bss_load_test
[2] = atoi(pos
);
4171 pos
= os_strchr(pos
, ':');
4173 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
4178 WPA_PUT_LE16(&bss
->bss_load_test
[3], atoi(pos
));
4179 bss
->bss_load_test_set
= 1;
4180 } else if (os_strcmp(buf
, "radio_measurements") == 0) {
4182 * DEPRECATED: This parameter will be removed in the future.
4183 * Use rrm_neighbor_report instead.
4185 int val
= atoi(pos
);
4188 bss
->radio_measurements
[0] |=
4189 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
4190 } else if (os_strcmp(buf
, "own_ie_override") == 0) {
4192 size_t len
= os_strlen(pos
) / 2;
4194 tmp
= wpabuf_alloc(len
);
4198 if (hexstr2bin(pos
, wpabuf_put(tmp
, len
), len
)) {
4200 wpa_printf(MSG_ERROR
,
4201 "Line %d: Invalid own_ie_override '%s'",
4206 wpabuf_free(bss
->own_ie_override
);
4207 bss
->own_ie_override
= tmp
;
4208 } else if (os_strcmp(buf
, "sae_reflection_attack") == 0) {
4209 bss
->sae_reflection_attack
= atoi(pos
);
4210 } else if (os_strcmp(buf
, "sae_commit_override") == 0) {
4211 wpabuf_free(bss
->sae_commit_override
);
4212 bss
->sae_commit_override
= wpabuf_parse_bin(pos
);
4213 #endif /* CONFIG_TESTING_OPTIONS */
4215 } else if (os_strcmp(buf
, "sae_password") == 0) {
4216 if (parse_sae_password(bss
, pos
) < 0) {
4217 wpa_printf(MSG_ERROR
, "Line %d: Invalid sae_password",
4221 #endif /* CONFIG_SAE */
4222 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
4223 if (parse_wpabuf_hex(line
, buf
, &bss
->vendor_elements
, pos
))
4225 } else if (os_strcmp(buf
, "assocresp_elements") == 0) {
4226 if (parse_wpabuf_hex(line
, buf
, &bss
->assocresp_elements
, pos
))
4228 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
4229 bss
->sae_anti_clogging_threshold
= atoi(pos
);
4230 } else if (os_strcmp(buf
, "sae_sync") == 0) {
4231 bss
->sae_sync
= atoi(pos
);
4232 } else if (os_strcmp(buf
, "sae_groups") == 0) {
4233 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
4234 wpa_printf(MSG_ERROR
,
4235 "Line %d: Invalid sae_groups value '%s'",
4239 } else if (os_strcmp(buf
, "sae_require_mfp") == 0) {
4240 bss
->sae_require_mfp
= atoi(pos
);
4241 } else if (os_strcmp(buf
, "local_pwr_constraint") == 0) {
4242 int val
= atoi(pos
);
4243 if (val
< 0 || val
> 255) {
4244 wpa_printf(MSG_ERROR
, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
4248 conf
->local_pwr_constraint
= val
;
4249 } else if (os_strcmp(buf
, "spectrum_mgmt_required") == 0) {
4250 conf
->spectrum_mgmt_required
= atoi(pos
);
4251 } else if (os_strcmp(buf
, "wowlan_triggers") == 0) {
4252 os_free(bss
->wowlan_triggers
);
4253 bss
->wowlan_triggers
= os_strdup(pos
);
4255 } else if (os_strcmp(buf
, "fst_group_id") == 0) {
4256 size_t len
= os_strlen(pos
);
4258 if (!len
|| len
>= sizeof(conf
->fst_cfg
.group_id
)) {
4259 wpa_printf(MSG_ERROR
,
4260 "Line %d: Invalid fst_group_id value '%s'",
4265 if (conf
->fst_cfg
.group_id
[0]) {
4266 wpa_printf(MSG_ERROR
,
4267 "Line %d: Duplicate fst_group value '%s'",
4272 os_strlcpy(conf
->fst_cfg
.group_id
, pos
,
4273 sizeof(conf
->fst_cfg
.group_id
));
4274 } else if (os_strcmp(buf
, "fst_priority") == 0) {
4279 wpa_printf(MSG_ERROR
,
4280 "Line %d: fst_priority value not supplied (expected 1..%u)",
4281 line
, FST_MAX_PRIO_VALUE
);
4285 val
= strtol(pos
, &endp
, 0);
4286 if (*endp
|| val
< 1 || val
> FST_MAX_PRIO_VALUE
) {
4287 wpa_printf(MSG_ERROR
,
4288 "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)",
4289 line
, val
, pos
, FST_MAX_PRIO_VALUE
);
4292 conf
->fst_cfg
.priority
= (u8
) val
;
4293 } else if (os_strcmp(buf
, "fst_llt") == 0) {
4298 wpa_printf(MSG_ERROR
,
4299 "Line %d: fst_llt value not supplied (expected 1..%u)",
4300 line
, FST_MAX_LLT_MS
);
4303 val
= strtol(pos
, &endp
, 0);
4304 if (*endp
|| val
< 1 ||
4305 (unsigned long int) val
> FST_MAX_LLT_MS
) {
4306 wpa_printf(MSG_ERROR
,
4307 "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
4308 line
, val
, pos
, FST_MAX_LLT_MS
);
4311 conf
->fst_cfg
.llt
= (u32
) val
;
4312 #endif /* CONFIG_FST */
4313 } else if (os_strcmp(buf
, "track_sta_max_num") == 0) {
4314 conf
->track_sta_max_num
= atoi(pos
);
4315 } else if (os_strcmp(buf
, "track_sta_max_age") == 0) {
4316 conf
->track_sta_max_age
= atoi(pos
);
4317 } else if (os_strcmp(buf
, "no_probe_resp_if_seen_on") == 0) {
4318 os_free(bss
->no_probe_resp_if_seen_on
);
4319 bss
->no_probe_resp_if_seen_on
= os_strdup(pos
);
4320 } else if (os_strcmp(buf
, "no_auth_if_seen_on") == 0) {
4321 os_free(bss
->no_auth_if_seen_on
);
4322 bss
->no_auth_if_seen_on
= os_strdup(pos
);
4323 } else if (os_strcmp(buf
, "lci") == 0) {
4324 wpabuf_free(conf
->lci
);
4325 conf
->lci
= wpabuf_parse_bin(pos
);
4326 if (conf
->lci
&& wpabuf_len(conf
->lci
) == 0) {
4327 wpabuf_free(conf
->lci
);
4330 } else if (os_strcmp(buf
, "civic") == 0) {
4331 wpabuf_free(conf
->civic
);
4332 conf
->civic
= wpabuf_parse_bin(pos
);
4333 if (conf
->civic
&& wpabuf_len(conf
->civic
) == 0) {
4334 wpabuf_free(conf
->civic
);
4337 } else if (os_strcmp(buf
, "rrm_neighbor_report") == 0) {
4339 bss
->radio_measurements
[0] |=
4340 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
4341 } else if (os_strcmp(buf
, "rrm_beacon_report") == 0) {
4343 bss
->radio_measurements
[0] |=
4344 WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE
|
4345 WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE
|
4346 WLAN_RRM_CAPS_BEACON_REPORT_TABLE
;
4347 } else if (os_strcmp(buf
, "gas_address3") == 0) {
4348 bss
->gas_address3
= atoi(pos
);
4349 } else if (os_strcmp(buf
, "stationary_ap") == 0) {
4350 conf
->stationary_ap
= atoi(pos
);
4351 } else if (os_strcmp(buf
, "ftm_responder") == 0) {
4352 bss
->ftm_responder
= atoi(pos
);
4353 } else if (os_strcmp(buf
, "ftm_initiator") == 0) {
4354 bss
->ftm_initiator
= atoi(pos
);
4356 } else if (os_strcmp(buf
, "fils_cache_id") == 0) {
4357 if (hexstr2bin(pos
, bss
->fils_cache_id
, FILS_CACHE_ID_LEN
)) {
4358 wpa_printf(MSG_ERROR
,
4359 "Line %d: Invalid fils_cache_id '%s'",
4363 bss
->fils_cache_id_set
= 1;
4364 } else if (os_strcmp(buf
, "fils_realm") == 0) {
4365 if (parse_fils_realm(bss
, pos
) < 0)
4367 } else if (os_strcmp(buf
, "fils_dh_group") == 0) {
4368 bss
->fils_dh_group
= atoi(pos
);
4369 } else if (os_strcmp(buf
, "dhcp_server") == 0) {
4370 if (hostapd_parse_ip_addr(pos
, &bss
->dhcp_server
)) {
4371 wpa_printf(MSG_ERROR
,
4372 "Line %d: invalid IP address '%s'",
4376 } else if (os_strcmp(buf
, "dhcp_rapid_commit_proxy") == 0) {
4377 bss
->dhcp_rapid_commit_proxy
= atoi(pos
);
4378 } else if (os_strcmp(buf
, "fils_hlp_wait_time") == 0) {
4379 bss
->fils_hlp_wait_time
= atoi(pos
);
4380 } else if (os_strcmp(buf
, "dhcp_server_port") == 0) {
4381 bss
->dhcp_server_port
= atoi(pos
);
4382 } else if (os_strcmp(buf
, "dhcp_relay_port") == 0) {
4383 bss
->dhcp_relay_port
= atoi(pos
);
4384 #endif /* CONFIG_FILS */
4385 } else if (os_strcmp(buf
, "multicast_to_unicast") == 0) {
4386 bss
->multicast_to_unicast
= atoi(pos
);
4387 } else if (os_strcmp(buf
, "broadcast_deauth") == 0) {
4388 bss
->broadcast_deauth
= atoi(pos
);
4390 } else if (os_strcmp(buf
, "dpp_connector") == 0) {
4391 os_free(bss
->dpp_connector
);
4392 bss
->dpp_connector
= os_strdup(pos
);
4393 } else if (os_strcmp(buf
, "dpp_netaccesskey") == 0) {
4394 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_netaccesskey
, pos
))
4396 } else if (os_strcmp(buf
, "dpp_netaccesskey_expiry") == 0) {
4397 bss
->dpp_netaccesskey_expiry
= strtol(pos
, NULL
, 0);
4398 } else if (os_strcmp(buf
, "dpp_csign") == 0) {
4399 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_csign
, pos
))
4402 } else if (os_strcmp(buf
, "dpp_controller") == 0) {
4403 if (hostapd_dpp_controller_parse(bss
, pos
))
4405 #endif /* CONFIG_DPP2 */
4406 #endif /* CONFIG_DPP */
4408 } else if (os_strcmp(buf
, "owe_transition_bssid") == 0) {
4409 if (hwaddr_aton(pos
, bss
->owe_transition_bssid
)) {
4410 wpa_printf(MSG_ERROR
,
4411 "Line %d: invalid owe_transition_bssid",
4415 } else if (os_strcmp(buf
, "owe_transition_ssid") == 0) {
4417 char *str
= wpa_config_parse_string(pos
, &slen
);
4419 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
4420 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
4425 os_memcpy(bss
->owe_transition_ssid
, str
, slen
);
4426 bss
->owe_transition_ssid_len
= slen
;
4428 } else if (os_strcmp(buf
, "owe_transition_ifname") == 0) {
4429 os_strlcpy(bss
->owe_transition_ifname
, pos
,
4430 sizeof(bss
->owe_transition_ifname
));
4431 } else if (os_strcmp(buf
, "owe_groups") == 0) {
4432 if (hostapd_parse_intlist(&bss
->owe_groups
, pos
)) {
4433 wpa_printf(MSG_ERROR
,
4434 "Line %d: Invalid owe_groups value '%s'",
4438 } else if (os_strcmp(buf
, "coloc_intf_reporting") == 0) {
4439 bss
->coloc_intf_reporting
= atoi(pos
);
4440 #endif /* CONFIG_OWE */
4441 } else if (os_strcmp(buf
, "multi_ap") == 0) {
4442 int val
= atoi(pos
);
4444 if (val
< 0 || val
> 3) {
4445 wpa_printf(MSG_ERROR
, "Line %d: Invalid multi_ap '%s'",
4450 bss
->multi_ap
= val
;
4451 } else if (os_strcmp(buf
, "rssi_reject_assoc_rssi") == 0) {
4452 conf
->rssi_reject_assoc_rssi
= atoi(pos
);
4453 } else if (os_strcmp(buf
, "rssi_reject_assoc_timeout") == 0) {
4454 conf
->rssi_reject_assoc_timeout
= atoi(pos
);
4455 } else if (os_strcmp(buf
, "pbss") == 0) {
4456 bss
->pbss
= atoi(pos
);
4457 #ifdef CONFIG_AIRTIME_POLICY
4458 } else if (os_strcmp(buf
, "airtime_mode") == 0) {
4459 int val
= atoi(pos
);
4461 if (val
< 0 || val
> AIRTIME_MODE_MAX
) {
4462 wpa_printf(MSG_ERROR
, "Line %d: Unknown airtime_mode",
4466 conf
->airtime_mode
= val
;
4467 } else if (os_strcmp(buf
, "airtime_update_interval") == 0) {
4468 conf
->airtime_update_interval
= atoi(pos
);
4469 } else if (os_strcmp(buf
, "airtime_bss_weight") == 0) {
4470 bss
->airtime_weight
= atoi(pos
);
4471 } else if (os_strcmp(buf
, "airtime_bss_limit") == 0) {
4472 int val
= atoi(pos
);
4474 if (val
< 0 || val
> 1) {
4475 wpa_printf(MSG_ERROR
,
4476 "Line %d: Invalid airtime_bss_limit (must be 0 or 1)",
4480 bss
->airtime_limit
= val
;
4481 } else if (os_strcmp(buf
, "airtime_sta_weight") == 0) {
4482 if (add_airtime_weight(bss
, pos
) < 0) {
4483 wpa_printf(MSG_ERROR
,
4484 "Line %d: Invalid airtime weight '%s'",
4488 #endif /* CONFIG_AIRTIME_POLICY */
4489 #ifdef CONFIG_MACSEC
4490 } else if (os_strcmp(buf
, "macsec_policy") == 0) {
4491 int macsec_policy
= atoi(pos
);
4493 if (macsec_policy
< 0 || macsec_policy
> 1) {
4494 wpa_printf(MSG_ERROR
,
4495 "Line %d: invalid macsec_policy (%d): '%s'.",
4496 line
, macsec_policy
, pos
);
4499 bss
->macsec_policy
= macsec_policy
;
4500 } else if (os_strcmp(buf
, "macsec_integ_only") == 0) {
4501 int macsec_integ_only
= atoi(pos
);
4503 if (macsec_integ_only
< 0 || macsec_integ_only
> 1) {
4504 wpa_printf(MSG_ERROR
,
4505 "Line %d: invalid macsec_integ_only (%d): '%s'.",
4506 line
, macsec_integ_only
, pos
);
4509 bss
->macsec_integ_only
= macsec_integ_only
;
4510 } else if (os_strcmp(buf
, "macsec_replay_protect") == 0) {
4511 int macsec_replay_protect
= atoi(pos
);
4513 if (macsec_replay_protect
< 0 || macsec_replay_protect
> 1) {
4514 wpa_printf(MSG_ERROR
,
4515 "Line %d: invalid macsec_replay_protect (%d): '%s'.",
4516 line
, macsec_replay_protect
, pos
);
4519 bss
->macsec_replay_protect
= macsec_replay_protect
;
4520 } else if (os_strcmp(buf
, "macsec_replay_window") == 0) {
4521 bss
->macsec_replay_window
= atoi(pos
);
4522 } else if (os_strcmp(buf
, "macsec_port") == 0) {
4523 int macsec_port
= atoi(pos
);
4525 if (macsec_port
< 1 || macsec_port
> 65534) {
4526 wpa_printf(MSG_ERROR
,
4527 "Line %d: invalid macsec_port (%d): '%s'.",
4528 line
, macsec_port
, pos
);
4531 bss
->macsec_port
= macsec_port
;
4532 } else if (os_strcmp(buf
, "mka_priority") == 0) {
4533 int mka_priority
= atoi(pos
);
4535 if (mka_priority
< 0 || mka_priority
> 255) {
4536 wpa_printf(MSG_ERROR
,
4537 "Line %d: invalid mka_priority (%d): '%s'.",
4538 line
, mka_priority
, pos
);
4541 bss
->mka_priority
= mka_priority
;
4542 } else if (os_strcmp(buf
, "mka_cak") == 0) {
4543 size_t len
= os_strlen(pos
);
4545 if (len
> 2 * MACSEC_CAK_MAX_LEN
||
4546 (len
!= 2 * 16 && len
!= 2 * 32) ||
4547 hexstr2bin(pos
, bss
->mka_cak
, len
/ 2)) {
4548 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CAK '%s'.",
4552 bss
->mka_cak_len
= len
/ 2;
4553 bss
->mka_psk_set
|= MKA_PSK_SET_CAK
;
4554 } else if (os_strcmp(buf
, "mka_ckn") == 0) {
4555 size_t len
= os_strlen(pos
);
4557 if (len
> 2 * MACSEC_CKN_MAX_LEN
|| /* too long */
4558 len
< 2 || /* too short */
4559 len
% 2 != 0 /* not an integral number of bytes */) {
4560 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CKN '%s'.",
4564 bss
->mka_ckn_len
= len
/ 2;
4565 if (hexstr2bin(pos
, bss
->mka_ckn
, bss
->mka_ckn_len
)) {
4566 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CKN '%s'.",
4570 bss
->mka_psk_set
|= MKA_PSK_SET_CKN
;
4571 #endif /* CONFIG_MACSEC */
4573 wpa_printf(MSG_ERROR
,
4574 "Line %d: unknown configuration item '%s'",
4584 * hostapd_config_read - Read and parse a configuration file
4585 * @fname: Configuration file name (including path, if needed)
4586 * Returns: Allocated configuration data structure
4588 struct hostapd_config
* hostapd_config_read(const char *fname
)
4590 struct hostapd_config
*conf
;
4592 char buf
[4096], *pos
;
4597 f
= fopen(fname
, "r");
4599 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
4600 "for reading.", fname
);
4604 conf
= hostapd_config_defaults();
4610 /* set default driver based on configuration */
4611 conf
->driver
= wpa_drivers
[0];
4612 if (conf
->driver
== NULL
) {
4613 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
4614 hostapd_config_free(conf
);
4619 conf
->last_bss
= conf
->bss
[0];
4621 while (fgets(buf
, sizeof(buf
), f
)) {
4622 struct hostapd_bss_config
*bss
;
4624 bss
= conf
->last_bss
;
4630 while (*pos
!= '\0') {
4640 pos
= os_strchr(buf
, '=');
4642 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
4649 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
4654 for (i
= 0; i
< conf
->num_bss
; i
++)
4655 hostapd_set_security_params(conf
->bss
[i
], 1);
4657 if (hostapd_config_check(conf
, 1))
4660 #ifndef WPA_IGNORE_CONFIG_ERRORS
4662 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
4663 "'%s'", errors
, fname
);
4664 hostapd_config_free(conf
);
4667 #endif /* WPA_IGNORE_CONFIG_ERRORS */
4673 int hostapd_set_iface(struct hostapd_config
*conf
,
4674 struct hostapd_bss_config
*bss
, const char *field
,
4680 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
4682 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
4683 "to value '%s'", field
, value
);
4687 for (i
= 0; i
< conf
->num_bss
; i
++)
4688 hostapd_set_security_params(conf
->bss
[i
], 0);
4690 if (hostapd_config_check(conf
, 0)) {
4691 wpa_printf(MSG_ERROR
, "Configuration check failed");