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
;
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')
86 if (*pos
== '\0' || os_strlen(pos
) > IFNAMSIZ
) {
87 wpa_printf(MSG_ERROR
, "Invalid VLAN ifname at line %d "
88 "in '%s'", line
, fname
);
93 vlan
= os_zalloc(sizeof(*vlan
));
95 wpa_printf(MSG_ERROR
, "Out of memory while reading "
96 "VLAN interfaces from '%s'", fname
);
101 vlan
->vlan_id
= vlan_id
;
102 vlan
->vlan_desc
.untagged
= vlan_id
;
103 vlan
->vlan_desc
.notempty
= !!vlan_id
;
104 os_strlcpy(vlan
->ifname
, pos
, sizeof(vlan
->ifname
));
105 vlan
->next
= bss
->vlan
;
113 #endif /* CONFIG_NO_VLAN */
116 int hostapd_acl_comp(const void *a
, const void *b
)
118 const struct mac_acl_entry
*aa
= a
;
119 const struct mac_acl_entry
*bb
= b
;
120 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
124 int hostapd_add_acl_maclist(struct mac_acl_entry
**acl
, int *num
,
125 int vlan_id
, const u8
*addr
)
127 struct mac_acl_entry
*newacl
;
129 newacl
= os_realloc_array(*acl
, *num
+ 1, sizeof(**acl
));
131 wpa_printf(MSG_ERROR
, "MAC list reallocation failed");
136 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
137 os_memset(&(*acl
)[*num
].vlan_id
, 0, sizeof((*acl
)[*num
].vlan_id
));
138 (*acl
)[*num
].vlan_id
.untagged
= vlan_id
;
139 (*acl
)[*num
].vlan_id
.notempty
= !!vlan_id
;
146 void hostapd_remove_acl_mac(struct mac_acl_entry
**acl
, int *num
,
152 if (os_memcmp((*acl
)[i
].addr
, addr
, ETH_ALEN
) == 0) {
153 os_remove_in_array(*acl
, *num
, sizeof(**acl
), i
);
162 static int hostapd_config_read_maclist(const char *fname
,
163 struct mac_acl_entry
**acl
, int *num
)
171 f
= fopen(fname
, "r");
173 wpa_printf(MSG_ERROR
, "MAC list file '%s' not found.", fname
);
177 while (fgets(buf
, sizeof(buf
), f
)) {
185 while (*pos
!= '\0') {
200 if (hwaddr_aton(pos
, addr
)) {
201 wpa_printf(MSG_ERROR
, "Invalid MAC address '%s' at "
202 "line %d in '%s'", pos
, line
, fname
);
208 hostapd_remove_acl_mac(acl
, num
, addr
);
213 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
215 while (*pos
== ' ' || *pos
== '\t')
220 if (hostapd_add_acl_maclist(acl
, num
, vlan_id
, addr
) < 0) {
229 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
237 static int hostapd_config_eap_user_salted(struct hostapd_eap_user
*user
,
238 const char *hash
, size_t len
,
239 char **pos
, int line
,
244 while (*pos2
!= '\0' && *pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '#')
247 if (pos2
- *pos
< (int) (2 * (len
+ 1))) { /* at least 1 byte of salt */
248 wpa_printf(MSG_ERROR
,
249 "Invalid salted %s hash on line %d in '%s'",
254 user
->password
= os_malloc(len
);
255 if (!user
->password
) {
256 wpa_printf(MSG_ERROR
,
257 "Failed to allocate memory for salted %s hash",
262 if (hexstr2bin(*pos
, user
->password
, len
) < 0) {
263 wpa_printf(MSG_ERROR
,
264 "Invalid salted password on line %d in '%s'",
268 user
->password_len
= len
;
271 user
->salt_len
= (pos2
- *pos
) / 2;
272 user
->salt
= os_malloc(user
->salt_len
);
274 wpa_printf(MSG_ERROR
,
275 "Failed to allocate memory for salted %s hash",
280 if (hexstr2bin(*pos
, user
->salt
, user
->salt_len
) < 0) {
281 wpa_printf(MSG_ERROR
,
282 "Invalid salt for password on line %d in '%s'",
292 static int hostapd_config_read_eap_user(const char *fname
,
293 struct hostapd_bss_config
*conf
)
296 char buf
[512], *pos
, *start
, *pos2
;
297 int line
= 0, ret
= 0, num_methods
;
298 struct hostapd_eap_user
*user
= NULL
, *tail
= NULL
, *new_user
= NULL
;
300 if (os_strncmp(fname
, "sqlite:", 7) == 0) {
302 os_free(conf
->eap_user_sqlite
);
303 conf
->eap_user_sqlite
= os_strdup(fname
+ 7);
305 #else /* CONFIG_SQLITE */
306 wpa_printf(MSG_ERROR
,
307 "EAP user file in SQLite DB, but CONFIG_SQLITE was not enabled in the build.");
309 #endif /* CONFIG_SQLITE */
312 f
= fopen(fname
, "r");
314 wpa_printf(MSG_ERROR
, "EAP user file '%s' not found.", fname
);
318 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
319 while (fgets(buf
, sizeof(buf
), f
)) {
325 while (*pos
!= '\0') {
335 #ifndef CONFIG_NO_RADIUS
336 if (user
&& os_strncmp(buf
, "radius_accept_attr=", 19) == 0) {
337 struct hostapd_radius_attr
*attr
, *a
;
338 attr
= hostapd_parse_radius_attr(buf
+ 19);
340 wpa_printf(MSG_ERROR
, "Invalid radius_auth_req_attr: %s",
342 user
= NULL
; /* already in the BSS list */
345 if (user
->accept_attr
== NULL
) {
346 user
->accept_attr
= attr
;
348 a
= user
->accept_attr
;
355 #endif /* CONFIG_NO_RADIUS */
359 if (buf
[0] != '"' && buf
[0] != '*') {
360 wpa_printf(MSG_ERROR
, "Invalid EAP identity (no \" in "
361 "start) on line %d in '%s'", line
, fname
);
365 user
= os_zalloc(sizeof(*user
));
367 wpa_printf(MSG_ERROR
, "EAP user allocation failed");
370 user
->force_version
= -1;
377 while (*pos
!= '"' && *pos
!= '\0')
380 wpa_printf(MSG_ERROR
, "Invalid EAP identity "
381 "(no \" in end) on line %d in '%s'",
386 user
->identity
= os_memdup(start
, pos
- start
);
387 if (user
->identity
== NULL
) {
388 wpa_printf(MSG_ERROR
, "Failed to allocate "
389 "memory for EAP identity");
392 user
->identity_len
= pos
- start
;
394 if (pos
[0] == '"' && pos
[1] == '*') {
395 user
->wildcard_prefix
= 1;
400 while (*pos
== ' ' || *pos
== '\t')
404 wpa_printf(MSG_ERROR
, "No EAP method on line %d in "
405 "'%s'", line
, fname
);
410 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
420 char *pos3
= os_strchr(start
, ',');
424 user
->methods
[num_methods
].method
=
427 &user
->methods
[num_methods
].vendor
);
428 if (user
->methods
[num_methods
].vendor
==
430 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
432 if (os_strcmp(start
, "TTLS-PAP") == 0) {
433 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
436 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
437 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
440 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
442 EAP_TTLS_AUTH_MSCHAP
;
445 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
447 EAP_TTLS_AUTH_MSCHAPV2
;
450 if (os_strcmp(start
, "MACACL") == 0) {
454 wpa_printf(MSG_ERROR
, "Unsupported EAP type "
455 "'%s' on line %d in '%s'",
461 if (num_methods
>= EAP_MAX_METHODS
)
468 if (num_methods
== 0 && user
->ttls_auth
== 0 && !user
->macacl
) {
469 wpa_printf(MSG_ERROR
, "No EAP types configured on "
470 "line %d in '%s'", line
, fname
);
477 while (*pos
== ' ' || *pos
== '\t')
482 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
483 user
->force_version
= 0;
487 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
488 user
->force_version
= 1;
492 if (os_strncmp(pos
, "[2]", 3) == 0) {
500 while (*pos
!= '"' && *pos
!= '\0')
503 wpa_printf(MSG_ERROR
, "Invalid EAP password "
504 "(no \" in end) on line %d in '%s'",
509 user
->password
= os_memdup(start
, pos
- start
);
510 if (user
->password
== NULL
) {
511 wpa_printf(MSG_ERROR
, "Failed to allocate "
512 "memory for EAP password");
515 user
->password_len
= pos
- start
;
518 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
521 while (*pos2
!= '\0' && *pos2
!= ' ' &&
522 *pos2
!= '\t' && *pos2
!= '#')
524 if (pos2
- pos
!= 32) {
525 wpa_printf(MSG_ERROR
, "Invalid password hash "
526 "on line %d in '%s'", line
, fname
);
529 user
->password
= os_malloc(16);
530 if (user
->password
== NULL
) {
531 wpa_printf(MSG_ERROR
, "Failed to allocate "
532 "memory for EAP password hash");
535 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
536 wpa_printf(MSG_ERROR
, "Invalid hash password "
537 "on line %d in '%s'", line
, fname
);
540 user
->password_len
= 16;
541 user
->password_hash
= 1;
543 } else if (os_strncmp(pos
, "ssha1:", 6) == 0) {
545 if (hostapd_config_eap_user_salted(user
, "sha1", 20,
549 } else if (os_strncmp(pos
, "ssha256:", 8) == 0) {
551 if (hostapd_config_eap_user_salted(user
, "sha256", 32,
555 } else if (os_strncmp(pos
, "ssha512:", 8) == 0) {
557 if (hostapd_config_eap_user_salted(user
, "sha512", 64,
563 while (*pos2
!= '\0' && *pos2
!= ' ' &&
564 *pos2
!= '\t' && *pos2
!= '#')
566 if ((pos2
- pos
) & 1) {
567 wpa_printf(MSG_ERROR
, "Invalid hex password "
568 "on line %d in '%s'", line
, fname
);
571 user
->password
= os_malloc((pos2
- pos
) / 2);
572 if (user
->password
== NULL
) {
573 wpa_printf(MSG_ERROR
, "Failed to allocate "
574 "memory for EAP password");
577 if (hexstr2bin(pos
, user
->password
,
578 (pos2
- pos
) / 2) < 0) {
579 wpa_printf(MSG_ERROR
, "Invalid hex password "
580 "on line %d in '%s'", line
, fname
);
583 user
->password_len
= (pos2
- pos
) / 2;
587 while (*pos
== ' ' || *pos
== '\t')
589 if (os_strncmp(pos
, "[2]", 3) == 0) {
595 tail
= new_user
= user
;
604 hostapd_config_free_eap_user(user
);
612 hostapd_config_free_eap_users(conf
->eap_user
);
613 conf
->eap_user
= new_user
;
615 hostapd_config_free_eap_users(new_user
);
621 #endif /* EAP_SERVER */
624 #ifndef CONFIG_NO_RADIUS
626 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
627 int *num_server
, const char *val
, int def_port
,
628 struct hostapd_radius_server
**curr_serv
)
630 struct hostapd_radius_server
*nserv
;
632 static int server_index
= 1;
634 nserv
= os_realloc_array(*server
, *num_server
+ 1, sizeof(*nserv
));
639 nserv
= &nserv
[*num_server
];
641 (*curr_serv
) = nserv
;
643 os_memset(nserv
, 0, sizeof(*nserv
));
644 nserv
->port
= def_port
;
645 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
646 nserv
->index
= server_index
++;
652 static struct hostapd_radius_attr
*
653 hostapd_parse_radius_attr(const char *value
)
657 struct hostapd_radius_attr
*attr
;
660 attr
= os_zalloc(sizeof(*attr
));
664 attr
->type
= atoi(value
);
666 pos
= os_strchr(value
, ':');
668 attr
->val
= wpabuf_alloc(1);
669 if (attr
->val
== NULL
) {
673 wpabuf_put_u8(attr
->val
, 0);
678 if (pos
[0] == '\0' || pos
[1] != ':') {
687 attr
->val
= wpabuf_alloc_copy(pos
, os_strlen(pos
));
690 len
= os_strlen(pos
);
694 attr
->val
= wpabuf_alloc(len
);
695 if (attr
->val
== NULL
)
697 if (hexstr2bin(pos
, wpabuf_put(attr
->val
, len
), len
) < 0) {
698 wpabuf_free(attr
->val
);
704 attr
->val
= wpabuf_alloc(4);
706 wpabuf_put_be32(attr
->val
, atoi(pos
));
713 if (attr
->val
== NULL
) {
722 static int hostapd_parse_das_client(struct hostapd_bss_config
*bss
, char *val
)
726 secret
= os_strchr(val
, ' ');
732 if (hostapd_parse_ip_addr(val
, &bss
->radius_das_client_addr
))
735 os_free(bss
->radius_das_shared_secret
);
736 bss
->radius_das_shared_secret
= (u8
*) os_strdup(secret
);
737 if (bss
->radius_das_shared_secret
== NULL
)
739 bss
->radius_das_shared_secret_len
= os_strlen(secret
);
743 #endif /* CONFIG_NO_RADIUS */
746 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
749 char *start
, *end
, *buf
;
751 buf
= os_strdup(value
);
756 while (*start
!= '\0') {
757 while (*start
== ' ' || *start
== '\t')
762 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
766 if (os_strcmp(start
, "WPA-PSK") == 0)
767 val
|= WPA_KEY_MGMT_PSK
;
768 else if (os_strcmp(start
, "WPA-EAP") == 0)
769 val
|= WPA_KEY_MGMT_IEEE8021X
;
770 #ifdef CONFIG_IEEE80211R_AP
771 else if (os_strcmp(start
, "FT-PSK") == 0)
772 val
|= WPA_KEY_MGMT_FT_PSK
;
773 else if (os_strcmp(start
, "FT-EAP") == 0)
774 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
776 else if (os_strcmp(start
, "FT-EAP-SHA384") == 0)
777 val
|= WPA_KEY_MGMT_FT_IEEE8021X_SHA384
;
778 #endif /* CONFIG_SHA384 */
779 #endif /* CONFIG_IEEE80211R_AP */
780 #ifdef CONFIG_IEEE80211W
781 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
782 val
|= WPA_KEY_MGMT_PSK_SHA256
;
783 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
784 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
785 #endif /* CONFIG_IEEE80211W */
787 else if (os_strcmp(start
, "SAE") == 0)
788 val
|= WPA_KEY_MGMT_SAE
;
789 else if (os_strcmp(start
, "FT-SAE") == 0)
790 val
|= WPA_KEY_MGMT_FT_SAE
;
791 #endif /* CONFIG_SAE */
793 else if (os_strcmp(start
, "WPA-EAP-SUITE-B") == 0)
794 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B
;
795 #endif /* CONFIG_SUITEB */
796 #ifdef CONFIG_SUITEB192
797 else if (os_strcmp(start
, "WPA-EAP-SUITE-B-192") == 0)
798 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192
;
799 #endif /* CONFIG_SUITEB192 */
801 else if (os_strcmp(start
, "FILS-SHA256") == 0)
802 val
|= WPA_KEY_MGMT_FILS_SHA256
;
803 else if (os_strcmp(start
, "FILS-SHA384") == 0)
804 val
|= WPA_KEY_MGMT_FILS_SHA384
;
805 #ifdef CONFIG_IEEE80211R_AP
806 else if (os_strcmp(start
, "FT-FILS-SHA256") == 0)
807 val
|= WPA_KEY_MGMT_FT_FILS_SHA256
;
808 else if (os_strcmp(start
, "FT-FILS-SHA384") == 0)
809 val
|= WPA_KEY_MGMT_FT_FILS_SHA384
;
810 #endif /* CONFIG_IEEE80211R_AP */
811 #endif /* CONFIG_FILS */
813 else if (os_strcmp(start
, "OWE") == 0)
814 val
|= WPA_KEY_MGMT_OWE
;
815 #endif /* CONFIG_OWE */
817 else if (os_strcmp(start
, "DPP") == 0)
818 val
|= WPA_KEY_MGMT_DPP
;
819 #endif /* CONFIG_DPP */
821 else if (os_strcmp(start
, "OSEN") == 0)
822 val
|= WPA_KEY_MGMT_OSEN
;
823 #endif /* CONFIG_HS20 */
825 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
838 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
839 "configured.", line
);
847 static int hostapd_config_parse_cipher(int line
, const char *value
)
849 int val
= wpa_parse_cipher(value
);
851 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
856 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
864 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
867 size_t len
= os_strlen(val
);
869 if (keyidx
< 0 || keyidx
> 3)
875 bin_clear_free(wep
->key
[keyidx
], wep
->len
[keyidx
]);
876 wep
->key
[keyidx
] = NULL
;
877 wep
->len
[keyidx
] = 0;
878 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
887 if (wep
->key
[keyidx
] != NULL
)
891 if (len
< 2 || val
[len
- 1] != '"')
894 wep
->key
[keyidx
] = os_memdup(val
+ 1, len
);
895 if (wep
->key
[keyidx
] == NULL
)
897 wep
->len
[keyidx
] = len
;
902 wep
->key
[keyidx
] = os_malloc(len
);
903 if (wep
->key
[keyidx
] == NULL
)
905 wep
->len
[keyidx
] = len
;
906 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
916 static int hostapd_parse_chanlist(struct hostapd_config
*conf
, char *val
)
920 /* for backwards compatibility, translate ' ' in conf str to ',' */
923 pos
= os_strchr(pos
, ' ');
927 if (freq_range_list_parse(&conf
->acs_ch_list
, val
))
934 static int hostapd_parse_intlist(int **int_list
, char *val
)
945 while (*pos
!= '\0') {
951 list
= os_malloc(sizeof(int) * (count
+ 2));
956 while (*pos
!= '\0') {
957 end
= os_strchr(pos
, ' ');
961 list
[count
++] = atoi(pos
);
973 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
975 struct hostapd_bss_config
**all
, *bss
;
980 all
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
981 sizeof(struct hostapd_bss_config
*));
983 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
989 bss
= os_zalloc(sizeof(*bss
));
992 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
993 if (bss
->radius
== NULL
) {
994 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
995 "multi-BSS RADIUS data");
1000 conf
->bss
[conf
->num_bss
++] = bss
;
1001 conf
->last_bss
= bss
;
1003 hostapd_config_defaults_bss(bss
);
1004 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
1005 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
1011 /* convert floats with one decimal place to value*10 int, i.e.,
1012 * "1.5" will return 15 */
1013 static int hostapd_config_read_int10(const char *value
)
1019 pos
= os_strchr(value
, '.');
1023 if (*pos
>= '0' && *pos
<= '9')
1031 static int valid_cw(int cw
)
1033 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
1034 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023 ||
1035 cw
== 2047 || cw
== 4095 || cw
== 8191 || cw
== 16383 ||
1041 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
1042 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
1043 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
1044 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
1047 static int hostapd_config_tx_queue(struct hostapd_config
*conf
,
1048 const char *name
, const char *val
)
1052 struct hostapd_tx_queue_params
*queue
;
1054 /* skip 'tx_queue_' prefix */
1056 if (os_strncmp(pos
, "data", 4) == 0 &&
1057 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
1060 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
1061 os_strncmp(pos
, "beacon_", 7) == 0) {
1062 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
1065 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
1069 if (num
>= NUM_TX_QUEUES
) {
1070 /* for backwards compatibility, do not trigger failure */
1071 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
1075 queue
= &conf
->tx_queue
[num
];
1077 if (os_strcmp(pos
, "aifs") == 0) {
1078 queue
->aifs
= atoi(val
);
1079 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
1080 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
1084 } else if (os_strcmp(pos
, "cwmin") == 0) {
1085 queue
->cwmin
= atoi(val
);
1086 if (!valid_cw(queue
->cwmin
)) {
1087 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
1091 } else if (os_strcmp(pos
, "cwmax") == 0) {
1092 queue
->cwmax
= atoi(val
);
1093 if (!valid_cw(queue
->cwmax
)) {
1094 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
1098 } else if (os_strcmp(pos
, "burst") == 0) {
1099 queue
->burst
= hostapd_config_read_int10(val
);
1101 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
1109 #ifdef CONFIG_IEEE80211R_AP
1111 static int rkh_derive_key(const char *pos
, u8
*key
, size_t key_len
)
1116 if (!hexstr2bin(pos
, key
, key_len
))
1119 /* Try to use old short key for backwards compatibility */
1120 if (hexstr2bin(pos
, oldkey
, sizeof(oldkey
)))
1123 ret
= hmac_sha256_kdf(oldkey
, sizeof(oldkey
), "FT OLDKEY", NULL
, 0,
1125 os_memset(oldkey
, 0, sizeof(oldkey
));
1130 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
1132 struct ft_remote_r0kh
*r0kh
;
1135 r0kh
= os_zalloc(sizeof(*r0kh
));
1139 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1141 next
= os_strchr(pos
, ' ');
1144 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
1145 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
1151 next
= os_strchr(pos
, ' ');
1154 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
1155 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
1159 r0kh
->id_len
= next
- pos
- 1;
1160 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
1163 if (rkh_derive_key(pos
, r0kh
->key
, sizeof(r0kh
->key
)) < 0) {
1164 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
1169 r0kh
->next
= bss
->r0kh_list
;
1170 bss
->r0kh_list
= r0kh
;
1176 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
1178 struct ft_remote_r1kh
*r1kh
;
1181 r1kh
= os_zalloc(sizeof(*r1kh
));
1185 /* 02:01:02:03:04:05 02:01:02:03:04:05
1186 * 000102030405060708090a0b0c0d0e0f */
1188 next
= os_strchr(pos
, ' ');
1191 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
1192 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
1198 next
= os_strchr(pos
, ' ');
1201 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
1202 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
1208 if (rkh_derive_key(pos
, r1kh
->key
, sizeof(r1kh
->key
)) < 0) {
1209 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
1214 r1kh
->next
= bss
->r1kh_list
;
1215 bss
->r1kh_list
= r1kh
;
1219 #endif /* CONFIG_IEEE80211R_AP */
1222 #ifdef CONFIG_IEEE80211N
1223 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
1226 if (os_strstr(capab
, "[LDPC]"))
1227 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
1228 if (os_strstr(capab
, "[HT40-]")) {
1229 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1230 conf
->secondary_channel
= -1;
1232 if (os_strstr(capab
, "[HT40+]")) {
1233 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1234 conf
->secondary_channel
= 1;
1236 if (os_strstr(capab
, "[HT40+]") && os_strstr(capab
, "[HT40-]")) {
1237 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1238 conf
->ht40_plus_minus_allowed
= 1;
1240 if (!os_strstr(capab
, "[HT40+]") && !os_strstr(capab
, "[HT40-]"))
1241 conf
->secondary_channel
= 0;
1242 if (os_strstr(capab
, "[SMPS-STATIC]")) {
1243 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1244 conf
->ht_capab
|= HT_CAP_INFO_SMPS_STATIC
;
1246 if (os_strstr(capab
, "[SMPS-DYNAMIC]")) {
1247 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1248 conf
->ht_capab
|= HT_CAP_INFO_SMPS_DYNAMIC
;
1250 if (os_strstr(capab
, "[GF]"))
1251 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
1252 if (os_strstr(capab
, "[SHORT-GI-20]"))
1253 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1254 if (os_strstr(capab
, "[SHORT-GI-40]"))
1255 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1256 if (os_strstr(capab
, "[TX-STBC]"))
1257 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1258 if (os_strstr(capab
, "[RX-STBC1]")) {
1259 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1260 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1262 if (os_strstr(capab
, "[RX-STBC12]")) {
1263 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1264 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1266 if (os_strstr(capab
, "[RX-STBC123]")) {
1267 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1268 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1270 if (os_strstr(capab
, "[DELAYED-BA]"))
1271 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1272 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1273 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1274 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1275 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1276 if (os_strstr(capab
, "[40-INTOLERANT]"))
1277 conf
->ht_capab
|= HT_CAP_INFO_40MHZ_INTOLERANT
;
1278 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1279 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1283 #endif /* CONFIG_IEEE80211N */
1286 #ifdef CONFIG_IEEE80211AC
1287 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1290 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1291 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1292 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1293 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1294 if (os_strstr(capab
, "[VHT160]"))
1295 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1296 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1297 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1298 if (os_strstr(capab
, "[RXLDPC]"))
1299 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1300 if (os_strstr(capab
, "[SHORT-GI-80]"))
1301 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1302 if (os_strstr(capab
, "[SHORT-GI-160]"))
1303 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1304 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1305 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1306 if (os_strstr(capab
, "[RX-STBC-1]"))
1307 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1308 if (os_strstr(capab
, "[RX-STBC-12]"))
1309 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1310 if (os_strstr(capab
, "[RX-STBC-123]"))
1311 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1312 if (os_strstr(capab
, "[RX-STBC-1234]"))
1313 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1314 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1315 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMER_CAPABLE
;
1316 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1317 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
1318 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1319 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1320 conf
->vht_capab
|= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1321 if (os_strstr(capab
, "[BF-ANTENNA-3]") &&
1322 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1323 conf
->vht_capab
|= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1324 if (os_strstr(capab
, "[BF-ANTENNA-4]") &&
1325 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1326 conf
->vht_capab
|= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1327 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1328 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1329 conf
->vht_capab
|= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1330 if (os_strstr(capab
, "[SOUNDING-DIMENSION-3]") &&
1331 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1332 conf
->vht_capab
|= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1333 if (os_strstr(capab
, "[SOUNDING-DIMENSION-4]") &&
1334 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1335 conf
->vht_capab
|= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1336 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1337 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1338 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1339 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1340 if (os_strstr(capab
, "[HTC-VHT]"))
1341 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1342 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP7]"))
1343 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX
;
1344 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP6]"))
1345 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6
;
1346 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP5]"))
1347 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5
;
1348 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP4]"))
1349 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4
;
1350 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP3]"))
1351 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3
;
1352 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP2]"))
1353 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2
;
1354 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP1]"))
1355 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1
;
1356 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1357 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1358 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1359 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1360 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1361 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1362 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1363 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1364 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1365 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1368 #endif /* CONFIG_IEEE80211AC */
1371 #ifdef CONFIG_INTERWORKING
1372 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1375 size_t len
= os_strlen(pos
);
1376 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1378 struct hostapd_roaming_consortium
*rc
;
1380 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1381 hexstr2bin(pos
, oi
, len
/ 2)) {
1382 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1388 rc
= os_realloc_array(bss
->roaming_consortium
,
1389 bss
->roaming_consortium_count
+ 1,
1390 sizeof(struct hostapd_roaming_consortium
));
1394 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1395 rc
[bss
->roaming_consortium_count
].len
= len
;
1397 bss
->roaming_consortium
= rc
;
1398 bss
->roaming_consortium_count
++;
1404 static int parse_lang_string(struct hostapd_lang_string
**array
,
1405 unsigned int *count
, char *pos
)
1407 char *sep
, *str
= NULL
;
1408 size_t clen
, nlen
, slen
;
1409 struct hostapd_lang_string
*ls
;
1412 if (*pos
== '"' || (*pos
== 'P' && pos
[1] == '"')) {
1413 str
= wpa_config_parse_string(pos
, &slen
);
1419 sep
= os_strchr(pos
, ':');
1424 clen
= os_strlen(pos
);
1425 if (clen
< 2 || clen
> sizeof(ls
->lang
))
1427 nlen
= os_strlen(sep
);
1431 ls
= os_realloc_array(*array
, *count
+ 1,
1432 sizeof(struct hostapd_lang_string
));
1437 ls
= &(*array
)[*count
];
1440 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1441 os_memcpy(ls
->lang
, pos
, clen
);
1442 ls
->name_len
= nlen
;
1443 os_memcpy(ls
->name
, sep
, nlen
);
1452 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1455 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1456 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1464 static int parse_venue_url(struct hostapd_bss_config
*bss
, char *pos
,
1469 struct hostapd_venue_url
*url
;
1472 sep
= os_strchr(pos
, ':');
1477 nlen
= os_strlen(sep
);
1481 url
= os_realloc_array(bss
->venue_url
, bss
->venue_url_count
+ 1,
1482 sizeof(struct hostapd_venue_url
));
1486 bss
->venue_url
= url
;
1487 url
= &bss
->venue_url
[bss
->venue_url_count
++];
1489 url
->venue_number
= atoi(pos
);
1490 url
->url_len
= nlen
;
1491 os_memcpy(url
->url
, sep
, nlen
);
1496 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_url '%s'",
1502 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1507 u8
*info
= NULL
, *ipos
;
1509 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1512 for (pos
= buf
; *pos
; pos
++) {
1513 if ((*pos
< '0' || *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1518 if (1 + count
* 3 > 0x7f)
1521 info
= os_zalloc(2 + 3 + count
* 3);
1526 *ipos
++ = 0; /* GUD - Version 1 */
1527 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1528 *ipos
++ = 0; /* PLMN List IEI */
1529 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1530 *ipos
++ = 1 + count
* 3;
1531 *ipos
++ = count
; /* Number of PLMNs */
1534 while (pos
&& *pos
) {
1539 mnc
= os_strchr(pos
, ',');
1543 pos
= os_strchr(mnc
, ';');
1547 mnc_len
= os_strlen(mnc
);
1548 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1551 /* BC coded MCC,MNC */
1552 /* MCC digit 2 | MCC digit 1 */
1553 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1554 /* MNC digit 3 | MCC digit 3 */
1555 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1557 /* MNC digit 2 | MNC digit 1 */
1558 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1561 os_free(bss
->anqp_3gpp_cell_net
);
1562 bss
->anqp_3gpp_cell_net
= info
;
1563 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1564 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1565 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1570 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1577 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1579 struct hostapd_nai_realm_data
*realm
;
1582 char *pos
, *end
, *rpos
;
1584 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1586 if (offsets
== NULL
)
1589 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1590 realm
= &bss
->nai_realm_data
[i
];
1591 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1592 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1594 realm
->realm
[j
] - realm
->realm_buf
: -1;
1598 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1599 sizeof(struct hostapd_nai_realm_data
));
1600 if (realm
== NULL
) {
1604 bss
->nai_realm_data
= realm
;
1606 /* patch the pointers after realloc */
1607 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1608 realm
= &bss
->nai_realm_data
[i
];
1609 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1610 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1612 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1614 realm
->realm
[j
] = NULL
;
1619 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1620 os_memset(realm
, 0, sizeof(*realm
));
1623 realm
->encoding
= atoi(pos
);
1624 pos
= os_strchr(pos
, ',');
1629 end
= os_strchr(pos
, ',');
1634 len
= os_strlen(pos
);
1637 if (len
> MAX_NAI_REALMLEN
) {
1638 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1639 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1642 os_memcpy(realm
->realm_buf
, pos
, len
);
1649 while (pos
&& *pos
) {
1650 struct hostapd_nai_realm_eap
*eap
;
1652 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1653 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1657 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1658 realm
->eap_method_count
++;
1660 end
= os_strchr(pos
, ',');
1662 end
= pos
+ os_strlen(pos
);
1664 eap
->eap_method
= atoi(pos
);
1666 pos
= os_strchr(pos
, '[');
1667 if (pos
== NULL
|| pos
> end
)
1670 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1671 wpa_printf(MSG_ERROR
, "Too many auth params");
1674 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1675 pos
= os_strchr(pos
, ':');
1676 if (pos
== NULL
|| pos
> end
)
1679 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1680 pos
= os_strchr(pos
, ']');
1681 if (pos
== NULL
|| pos
> end
)
1693 /* Split realm list into null terminated realms */
1694 rpos
= realm
->realm_buf
;
1697 if (i
>= MAX_NAI_REALMS
) {
1698 wpa_printf(MSG_ERROR
, "Too many realms");
1701 realm
->realm
[i
++] = rpos
;
1702 rpos
= os_strchr(rpos
, ';');
1708 bss
->nai_realm_count
++;
1713 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1718 static int parse_anqp_elem(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1723 struct wpabuf
*payload
;
1724 struct anqp_element
*elem
;
1726 delim
= os_strchr(buf
, ':');
1731 len
= os_strlen(delim
);
1735 payload
= wpabuf_alloc(len
);
1738 if (hexstr2bin(delim
, wpabuf_put(payload
, len
), len
) < 0) {
1739 wpabuf_free(payload
);
1743 dl_list_for_each(elem
, &bss
->anqp_elem
, struct anqp_element
, list
) {
1744 if (elem
->infoid
== infoid
) {
1745 /* Update existing entry */
1746 wpabuf_free(elem
->payload
);
1747 elem
->payload
= payload
;
1752 /* Add a new entry */
1753 elem
= os_zalloc(sizeof(*elem
));
1755 wpabuf_free(payload
);
1758 elem
->infoid
= infoid
;
1759 elem
->payload
= payload
;
1760 dl_list_add(&bss
->anqp_elem
, &elem
->list
);
1766 static int parse_qos_map_set(struct hostapd_bss_config
*bss
,
1767 char *buf
, int line
)
1769 u8 qos_map_set
[16 + 2 * 21], count
= 0;
1774 if (count
== sizeof(qos_map_set
)) {
1775 wpa_printf(MSG_ERROR
, "Line %d: Too many qos_map_set "
1776 "parameters '%s'", line
, buf
);
1781 if (val
> 255 || val
< 0) {
1782 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set "
1787 qos_map_set
[count
++] = val
;
1788 pos
= os_strchr(pos
, ',');
1794 if (count
< 16 || count
& 1) {
1795 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set '%s'",
1800 os_memcpy(bss
->qos_map_set
, qos_map_set
, count
);
1801 bss
->qos_map_set_len
= count
;
1806 #endif /* CONFIG_INTERWORKING */
1810 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1816 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1819 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1820 bss
->hs20_connection_capability_len
+ 4);
1821 if (conn_cap
== NULL
)
1824 bss
->hs20_connection_capability
= conn_cap
;
1825 conn_cap
+= bss
->hs20_connection_capability_len
;
1827 conn_cap
[0] = atoi(pos
);
1828 pos
= os_strchr(pos
, ':');
1832 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1833 pos
= os_strchr(pos
, ':');
1837 conn_cap
[3] = atoi(pos
);
1838 bss
->hs20_connection_capability_len
+= 4;
1844 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1850 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1852 wan_metrics
= os_zalloc(13);
1853 if (wan_metrics
== NULL
)
1858 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1865 /* Downlink Speed */
1866 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1867 pos
= os_strchr(pos
, ':');
1873 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1874 pos
= os_strchr(pos
, ':');
1880 wan_metrics
[9] = atoi(pos
);
1881 pos
= os_strchr(pos
, ':');
1887 wan_metrics
[10] = atoi(pos
);
1888 pos
= os_strchr(pos
, ':');
1894 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1896 os_free(bss
->hs20_wan_metrics
);
1897 bss
->hs20_wan_metrics
= wan_metrics
;
1902 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1904 os_free(wan_metrics
);
1909 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1910 char *pos
, int line
)
1912 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1913 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1914 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1915 "hs20_oper_friendly_name '%s'", line
, pos
);
1922 static int hs20_parse_icon(struct hostapd_bss_config
*bss
, char *pos
)
1924 struct hs20_icon
*icon
;
1927 icon
= os_realloc_array(bss
->hs20_icons
, bss
->hs20_icons_count
+ 1,
1928 sizeof(struct hs20_icon
));
1931 bss
->hs20_icons
= icon
;
1932 icon
= &bss
->hs20_icons
[bss
->hs20_icons_count
];
1933 os_memset(icon
, 0, sizeof(*icon
));
1935 icon
->width
= atoi(pos
);
1936 pos
= os_strchr(pos
, ':');
1941 icon
->height
= atoi(pos
);
1942 pos
= os_strchr(pos
, ':');
1947 end
= os_strchr(pos
, ':');
1948 if (end
== NULL
|| end
- pos
> 3)
1950 os_memcpy(icon
->language
, pos
, end
- pos
);
1953 end
= os_strchr(pos
, ':');
1954 if (end
== NULL
|| end
- pos
> 255)
1956 os_memcpy(icon
->type
, pos
, end
- pos
);
1959 end
= os_strchr(pos
, ':');
1960 if (end
== NULL
|| end
- pos
> 255)
1962 os_memcpy(icon
->name
, pos
, end
- pos
);
1965 if (os_strlen(pos
) > 255)
1967 os_memcpy(icon
->file
, pos
, os_strlen(pos
));
1969 bss
->hs20_icons_count
++;
1975 static int hs20_parse_osu_ssid(struct hostapd_bss_config
*bss
,
1976 char *pos
, int line
)
1981 str
= wpa_config_parse_string(pos
, &slen
);
1982 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
1983 wpa_printf(MSG_ERROR
, "Line %d: Invalid SSID '%s'", line
, pos
);
1988 os_memcpy(bss
->osu_ssid
, str
, slen
);
1989 bss
->osu_ssid_len
= slen
;
1996 static int hs20_parse_osu_server_uri(struct hostapd_bss_config
*bss
,
1997 char *pos
, int line
)
1999 struct hs20_osu_provider
*p
;
2001 p
= os_realloc_array(bss
->hs20_osu_providers
,
2002 bss
->hs20_osu_providers_count
+ 1, sizeof(*p
));
2006 bss
->hs20_osu_providers
= p
;
2007 bss
->last_osu
= &bss
->hs20_osu_providers
[bss
->hs20_osu_providers_count
];
2008 bss
->hs20_osu_providers_count
++;
2009 os_memset(bss
->last_osu
, 0, sizeof(*p
));
2010 bss
->last_osu
->server_uri
= os_strdup(pos
);
2016 static int hs20_parse_osu_friendly_name(struct hostapd_bss_config
*bss
,
2017 char *pos
, int line
)
2019 if (bss
->last_osu
== NULL
) {
2020 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2024 if (parse_lang_string(&bss
->last_osu
->friendly_name
,
2025 &bss
->last_osu
->friendly_name_count
, pos
)) {
2026 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_friendly_name '%s'",
2035 static int hs20_parse_osu_nai(struct hostapd_bss_config
*bss
,
2036 char *pos
, int line
)
2038 if (bss
->last_osu
== NULL
) {
2039 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2043 os_free(bss
->last_osu
->osu_nai
);
2044 bss
->last_osu
->osu_nai
= os_strdup(pos
);
2045 if (bss
->last_osu
->osu_nai
== NULL
)
2052 static int hs20_parse_osu_nai2(struct hostapd_bss_config
*bss
,
2053 char *pos
, int line
)
2055 if (bss
->last_osu
== NULL
) {
2056 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2060 os_free(bss
->last_osu
->osu_nai2
);
2061 bss
->last_osu
->osu_nai2
= os_strdup(pos
);
2062 if (bss
->last_osu
->osu_nai2
== NULL
)
2064 bss
->hs20_osu_providers_nai_count
++;
2070 static int hs20_parse_osu_method_list(struct hostapd_bss_config
*bss
, char *pos
,
2073 if (bss
->last_osu
== NULL
) {
2074 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2078 if (hostapd_parse_intlist(&bss
->last_osu
->method_list
, pos
)) {
2079 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_method_list", line
);
2087 static int hs20_parse_osu_icon(struct hostapd_bss_config
*bss
, char *pos
,
2091 struct hs20_osu_provider
*p
= bss
->last_osu
;
2094 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2098 n
= os_realloc_array(p
->icons
, p
->icons_count
+ 1, sizeof(char *));
2102 p
->icons
[p
->icons_count
] = os_strdup(pos
);
2103 if (p
->icons
[p
->icons_count
] == NULL
)
2111 static int hs20_parse_osu_service_desc(struct hostapd_bss_config
*bss
,
2112 char *pos
, int line
)
2114 if (bss
->last_osu
== NULL
) {
2115 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2119 if (parse_lang_string(&bss
->last_osu
->service_desc
,
2120 &bss
->last_osu
->service_desc_count
, pos
)) {
2121 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_service_desc '%s'",
2130 static int hs20_parse_operator_icon(struct hostapd_bss_config
*bss
, char *pos
,
2135 n
= os_realloc_array(bss
->hs20_operator_icon
,
2136 bss
->hs20_operator_icon_count
+ 1, sizeof(char *));
2139 bss
->hs20_operator_icon
= n
;
2140 bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
] = os_strdup(pos
);
2141 if (!bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
])
2143 bss
->hs20_operator_icon_count
++;
2148 #endif /* CONFIG_HS20 */
2152 static int hostapd_config_parse_acs_chan_bias(struct hostapd_config
*conf
,
2155 struct acs_bias
*bias
= NULL
, *tmp
;
2156 unsigned int num
= 0;
2160 tmp
= os_realloc_array(bias
, num
+ 1, sizeof(*bias
));
2165 bias
[num
].channel
= atoi(pos
);
2166 if (bias
[num
].channel
<= 0)
2168 pos
= os_strchr(pos
, ':');
2172 bias
[num
].bias
= strtod(pos
, &end
);
2173 if (end
== pos
|| bias
[num
].bias
< 0.0)
2176 if (*pos
!= ' ' && *pos
!= '\0')
2181 os_free(conf
->acs_chan_bias
);
2182 conf
->acs_chan_bias
= bias
;
2183 conf
->num_acs_chan_bias
= num
;
2190 #endif /* CONFIG_ACS */
2193 static int parse_wpabuf_hex(int line
, const char *name
, struct wpabuf
**buf
,
2196 struct wpabuf
*elems
;
2198 if (val
[0] == '\0') {
2204 elems
= wpabuf_parse_bin(val
);
2206 wpa_printf(MSG_ERROR
, "Line %d: Invalid %s '%s'",
2219 static int parse_fils_realm(struct hostapd_bss_config
*bss
, const char *val
)
2221 struct fils_realm
*realm
;
2224 len
= os_strlen(val
);
2225 realm
= os_zalloc(sizeof(*realm
) + len
+ 1);
2229 os_memcpy(realm
->realm
, val
, len
);
2230 if (fils_domain_name_hash(val
, realm
->hash
) < 0) {
2234 dl_list_add_tail(&bss
->fils_realms
, &realm
->list
);
2238 #endif /* CONFIG_FILS */
2242 static unsigned int parse_tls_flags(const char *val
)
2244 unsigned int flags
= 0;
2246 /* Disable TLS v1.3 by default for now to avoid interoperability issue.
2247 * This can be enabled by default once the implementation has been fully
2248 * completed and tested with other implementations. */
2249 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2251 if (os_strstr(val
, "[ALLOW-SIGN-RSA-MD5]"))
2252 flags
|= TLS_CONN_ALLOW_SIGN_RSA_MD5
;
2253 if (os_strstr(val
, "[DISABLE-TIME-CHECKS]"))
2254 flags
|= TLS_CONN_DISABLE_TIME_CHECKS
;
2255 if (os_strstr(val
, "[DISABLE-TLSv1.0]"))
2256 flags
|= TLS_CONN_DISABLE_TLSv1_0
;
2257 if (os_strstr(val
, "[DISABLE-TLSv1.1]"))
2258 flags
|= TLS_CONN_DISABLE_TLSv1_1
;
2259 if (os_strstr(val
, "[DISABLE-TLSv1.2]"))
2260 flags
|= TLS_CONN_DISABLE_TLSv1_2
;
2261 if (os_strstr(val
, "[DISABLE-TLSv1.3]"))
2262 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2263 if (os_strstr(val
, "[ENABLE-TLSv1.3]"))
2264 flags
&= ~TLS_CONN_DISABLE_TLSv1_3
;
2265 if (os_strstr(val
, "[SUITEB]"))
2266 flags
|= TLS_CONN_SUITEB
;
2267 if (os_strstr(val
, "[SUITEB-NO-ECDH]"))
2268 flags
|= TLS_CONN_SUITEB_NO_ECDH
| TLS_CONN_SUITEB
;
2272 #endif /* EAP_SERVER */
2276 static int parse_sae_password(struct hostapd_bss_config
*bss
, const char *val
)
2278 struct sae_password_entry
*pw
;
2279 const char *pos
= val
, *pos2
, *end
= NULL
;
2281 pw
= os_zalloc(sizeof(*pw
));
2284 os_memset(pw
->peer_addr
, 0xff, ETH_ALEN
); /* default to wildcard */
2286 pos2
= os_strstr(pos
, "|mac=");
2290 if (hwaddr_aton(pos2
, pw
->peer_addr
) < 0)
2292 pos
= pos2
+ ETH_ALEN
* 3 - 1;
2295 pos2
= os_strstr(pos
, "|id=");
2300 pw
->identifier
= os_strdup(pos2
);
2301 if (!pw
->identifier
)
2306 pw
->password
= os_strdup(val
);
2310 pw
->password
= os_malloc(end
- val
+ 1);
2313 os_memcpy(pw
->password
, val
, end
- val
);
2314 pw
->password
[end
- val
] = '\0';
2317 pw
->next
= bss
->sae_passwords
;
2318 bss
->sae_passwords
= pw
;
2322 str_clear_free(pw
->password
);
2323 os_free(pw
->identifier
);
2327 #endif /* CONFIG_SAE */
2330 static int hostapd_config_fill(struct hostapd_config
*conf
,
2331 struct hostapd_bss_config
*bss
,
2332 const char *buf
, char *pos
, int line
)
2334 if (os_strcmp(buf
, "interface") == 0) {
2335 os_strlcpy(conf
->bss
[0]->iface
, pos
,
2336 sizeof(conf
->bss
[0]->iface
));
2337 } else if (os_strcmp(buf
, "bridge") == 0) {
2338 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
2339 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
2340 os_strlcpy(bss
->vlan_bridge
, pos
, sizeof(bss
->vlan_bridge
));
2341 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
2342 os_strlcpy(bss
->wds_bridge
, pos
, sizeof(bss
->wds_bridge
));
2343 } else if (os_strcmp(buf
, "driver") == 0) {
2345 const struct wpa_driver_ops
*driver
= NULL
;
2347 for (j
= 0; wpa_drivers
[j
]; j
++) {
2348 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0) {
2349 driver
= wpa_drivers
[j
];
2354 wpa_printf(MSG_ERROR
,
2355 "Line %d: invalid/unknown driver '%s'",
2359 conf
->driver
= driver
;
2360 } else if (os_strcmp(buf
, "driver_params") == 0) {
2361 os_free(conf
->driver_params
);
2362 conf
->driver_params
= os_strdup(pos
);
2363 } else if (os_strcmp(buf
, "debug") == 0) {
2364 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore",
2366 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
2367 bss
->logger_syslog_level
= atoi(pos
);
2368 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
2369 bss
->logger_stdout_level
= atoi(pos
);
2370 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
2371 bss
->logger_syslog
= atoi(pos
);
2372 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
2373 bss
->logger_stdout
= atoi(pos
);
2374 } else if (os_strcmp(buf
, "dump_file") == 0) {
2375 wpa_printf(MSG_INFO
, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
2377 } else if (os_strcmp(buf
, "ssid") == 0) {
2378 bss
->ssid
.ssid_len
= os_strlen(pos
);
2379 if (bss
->ssid
.ssid_len
> SSID_MAX_LEN
||
2380 bss
->ssid
.ssid_len
< 1) {
2381 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2385 os_memcpy(bss
->ssid
.ssid
, pos
, bss
->ssid
.ssid_len
);
2386 bss
->ssid
.ssid_set
= 1;
2387 } else if (os_strcmp(buf
, "ssid2") == 0) {
2389 char *str
= wpa_config_parse_string(pos
, &slen
);
2390 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
2391 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2396 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
2397 bss
->ssid
.ssid_len
= slen
;
2398 bss
->ssid
.ssid_set
= 1;
2400 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
2401 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
2402 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
2403 enum macaddr_acl acl
= atoi(pos
);
2405 if (acl
!= ACCEPT_UNLESS_DENIED
&&
2406 acl
!= DENY_UNLESS_ACCEPTED
&&
2407 acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
2408 wpa_printf(MSG_ERROR
, "Line %d: unknown macaddr_acl %d",
2412 bss
->macaddr_acl
= acl
;
2413 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
2414 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
2415 &bss
->num_accept_mac
)) {
2416 wpa_printf(MSG_ERROR
, "Line %d: Failed to read accept_mac_file '%s'",
2420 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
2421 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
2422 &bss
->num_deny_mac
)) {
2423 wpa_printf(MSG_ERROR
, "Line %d: Failed to read deny_mac_file '%s'",
2427 } else if (os_strcmp(buf
, "wds_sta") == 0) {
2428 bss
->wds_sta
= atoi(pos
);
2429 } else if (os_strcmp(buf
, "start_disabled") == 0) {
2430 bss
->start_disabled
= atoi(pos
);
2431 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
2432 bss
->isolate
= atoi(pos
);
2433 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
2434 bss
->ap_max_inactivity
= atoi(pos
);
2435 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
2436 bss
->skip_inactivity_poll
= atoi(pos
);
2437 } else if (os_strcmp(buf
, "country_code") == 0) {
2438 os_memcpy(conf
->country
, pos
, 2);
2439 } else if (os_strcmp(buf
, "country3") == 0) {
2440 conf
->country
[2] = strtol(pos
, NULL
, 16);
2441 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
2442 conf
->ieee80211d
= atoi(pos
);
2443 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
2444 conf
->ieee80211h
= atoi(pos
);
2445 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
2446 bss
->ieee802_1x
= atoi(pos
);
2447 } else if (os_strcmp(buf
, "eapol_version") == 0) {
2448 int eapol_version
= atoi(pos
);
2450 if (eapol_version
< 1 || eapol_version
> 2) {
2451 wpa_printf(MSG_ERROR
,
2452 "Line %d: invalid EAPOL version (%d): '%s'.",
2453 line
, eapol_version
, pos
);
2456 bss
->eapol_version
= eapol_version
;
2457 wpa_printf(MSG_DEBUG
, "eapol_version=%d", bss
->eapol_version
);
2459 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
2460 bss
->eap_server
= atoi(pos
);
2461 wpa_printf(MSG_ERROR
, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line
);
2462 } else if (os_strcmp(buf
, "eap_server") == 0) {
2463 bss
->eap_server
= atoi(pos
);
2464 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
2465 if (hostapd_config_read_eap_user(pos
, bss
))
2467 } else if (os_strcmp(buf
, "ca_cert") == 0) {
2468 os_free(bss
->ca_cert
);
2469 bss
->ca_cert
= os_strdup(pos
);
2470 } else if (os_strcmp(buf
, "server_cert") == 0) {
2471 os_free(bss
->server_cert
);
2472 bss
->server_cert
= os_strdup(pos
);
2473 } else if (os_strcmp(buf
, "private_key") == 0) {
2474 os_free(bss
->private_key
);
2475 bss
->private_key
= os_strdup(pos
);
2476 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
2477 os_free(bss
->private_key_passwd
);
2478 bss
->private_key_passwd
= os_strdup(pos
);
2479 } else if (os_strcmp(buf
, "check_crl") == 0) {
2480 bss
->check_crl
= atoi(pos
);
2481 } else if (os_strcmp(buf
, "tls_session_lifetime") == 0) {
2482 bss
->tls_session_lifetime
= atoi(pos
);
2483 } else if (os_strcmp(buf
, "tls_flags") == 0) {
2484 bss
->tls_flags
= parse_tls_flags(pos
);
2485 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
2486 os_free(bss
->ocsp_stapling_response
);
2487 bss
->ocsp_stapling_response
= os_strdup(pos
);
2488 } else if (os_strcmp(buf
, "ocsp_stapling_response_multi") == 0) {
2489 os_free(bss
->ocsp_stapling_response_multi
);
2490 bss
->ocsp_stapling_response_multi
= os_strdup(pos
);
2491 } else if (os_strcmp(buf
, "dh_file") == 0) {
2492 os_free(bss
->dh_file
);
2493 bss
->dh_file
= os_strdup(pos
);
2494 } else if (os_strcmp(buf
, "openssl_ciphers") == 0) {
2495 os_free(bss
->openssl_ciphers
);
2496 bss
->openssl_ciphers
= os_strdup(pos
);
2497 } else if (os_strcmp(buf
, "fragment_size") == 0) {
2498 bss
->fragment_size
= atoi(pos
);
2499 #ifdef EAP_SERVER_FAST
2500 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
2501 os_free(bss
->pac_opaque_encr_key
);
2502 bss
->pac_opaque_encr_key
= os_malloc(16);
2503 if (bss
->pac_opaque_encr_key
== NULL
) {
2504 wpa_printf(MSG_ERROR
,
2505 "Line %d: No memory for pac_opaque_encr_key",
2508 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
, 16)) {
2509 wpa_printf(MSG_ERROR
, "Line %d: Invalid pac_opaque_encr_key",
2513 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
2514 size_t idlen
= os_strlen(pos
);
2516 wpa_printf(MSG_ERROR
, "Line %d: Invalid eap_fast_a_id",
2520 os_free(bss
->eap_fast_a_id
);
2521 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
2522 if (bss
->eap_fast_a_id
== NULL
||
2523 hexstr2bin(pos
, bss
->eap_fast_a_id
, idlen
/ 2)) {
2524 wpa_printf(MSG_ERROR
, "Line %d: Failed to parse eap_fast_a_id",
2526 os_free(bss
->eap_fast_a_id
);
2527 bss
->eap_fast_a_id
= NULL
;
2530 bss
->eap_fast_a_id_len
= idlen
/ 2;
2532 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
2533 os_free(bss
->eap_fast_a_id_info
);
2534 bss
->eap_fast_a_id_info
= os_strdup(pos
);
2535 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
2536 bss
->eap_fast_prov
= atoi(pos
);
2537 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
2538 bss
->pac_key_lifetime
= atoi(pos
);
2539 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
2540 bss
->pac_key_refresh_time
= atoi(pos
);
2541 #endif /* EAP_SERVER_FAST */
2542 #ifdef EAP_SERVER_SIM
2543 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
2544 os_free(bss
->eap_sim_db
);
2545 bss
->eap_sim_db
= os_strdup(pos
);
2546 } else if (os_strcmp(buf
, "eap_sim_db_timeout") == 0) {
2547 bss
->eap_sim_db_timeout
= atoi(pos
);
2548 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
2549 bss
->eap_sim_aka_result_ind
= atoi(pos
);
2550 #endif /* EAP_SERVER_SIM */
2551 #ifdef EAP_SERVER_TNC
2552 } else if (os_strcmp(buf
, "tnc") == 0) {
2553 bss
->tnc
= atoi(pos
);
2554 #endif /* EAP_SERVER_TNC */
2555 #ifdef EAP_SERVER_PWD
2556 } else if (os_strcmp(buf
, "pwd_group") == 0) {
2557 bss
->pwd_group
= atoi(pos
);
2558 #endif /* EAP_SERVER_PWD */
2560 } else if (os_strcmp(buf
, "eap_server_erp") == 0) {
2561 bss
->eap_server_erp
= atoi(pos
);
2562 #endif /* CONFIG_ERP */
2563 #endif /* EAP_SERVER */
2564 } else if (os_strcmp(buf
, "eap_message") == 0) {
2566 os_free(bss
->eap_req_id_text
);
2567 bss
->eap_req_id_text
= os_strdup(pos
);
2568 if (bss
->eap_req_id_text
== NULL
) {
2569 wpa_printf(MSG_ERROR
, "Line %d: Failed to allocate memory for eap_req_id_text",
2573 bss
->eap_req_id_text_len
= os_strlen(bss
->eap_req_id_text
);
2574 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
2577 os_memmove(term
, term
+ 1,
2578 bss
->eap_req_id_text_len
-
2579 (term
- bss
->eap_req_id_text
) - 1);
2580 bss
->eap_req_id_text_len
--;
2582 } else if (os_strcmp(buf
, "erp_send_reauth_start") == 0) {
2583 bss
->erp_send_reauth_start
= atoi(pos
);
2584 } else if (os_strcmp(buf
, "erp_domain") == 0) {
2585 os_free(bss
->erp_domain
);
2586 bss
->erp_domain
= os_strdup(pos
);
2587 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
2588 int val
= atoi(pos
);
2590 if (val
< 0 || val
> 13) {
2591 wpa_printf(MSG_ERROR
,
2592 "Line %d: invalid WEP key len %d (= %d bits)",
2593 line
, val
, val
* 8);
2596 bss
->default_wep_key_len
= val
;
2597 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
2598 int val
= atoi(pos
);
2600 if (val
< 0 || val
> 13) {
2601 wpa_printf(MSG_ERROR
,
2602 "Line %d: invalid WEP key len %d (= %d bits)",
2603 line
, val
, val
* 8);
2606 bss
->individual_wep_key_len
= val
;
2607 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
2608 bss
->wep_rekeying_period
= atoi(pos
);
2609 if (bss
->wep_rekeying_period
< 0) {
2610 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2611 line
, bss
->wep_rekeying_period
);
2614 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
2615 bss
->eap_reauth_period
= atoi(pos
);
2616 if (bss
->eap_reauth_period
< 0) {
2617 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2618 line
, bss
->eap_reauth_period
);
2621 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
2622 bss
->eapol_key_index_workaround
= atoi(pos
);
2624 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
2625 bss
->ieee802_11f
= 1;
2626 os_strlcpy(bss
->iapp_iface
, pos
, sizeof(bss
->iapp_iface
));
2627 #endif /* CONFIG_IAPP */
2628 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
2629 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
2630 wpa_printf(MSG_ERROR
,
2631 "Line %d: invalid IP address '%s'",
2635 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
2636 os_free(bss
->nas_identifier
);
2637 bss
->nas_identifier
= os_strdup(pos
);
2638 #ifndef CONFIG_NO_RADIUS
2639 } else if (os_strcmp(buf
, "radius_client_addr") == 0) {
2640 if (hostapd_parse_ip_addr(pos
, &bss
->radius
->client_addr
)) {
2641 wpa_printf(MSG_ERROR
,
2642 "Line %d: invalid IP address '%s'",
2646 bss
->radius
->force_client_addr
= 1;
2647 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
2648 if (hostapd_config_read_radius_addr(
2649 &bss
->radius
->auth_servers
,
2650 &bss
->radius
->num_auth_servers
, pos
, 1812,
2651 &bss
->radius
->auth_server
)) {
2652 wpa_printf(MSG_ERROR
,
2653 "Line %d: invalid IP address '%s'",
2657 } else if (bss
->radius
->auth_server
&&
2658 os_strcmp(buf
, "auth_server_addr_replace") == 0) {
2659 if (hostapd_parse_ip_addr(pos
,
2660 &bss
->radius
->auth_server
->addr
)) {
2661 wpa_printf(MSG_ERROR
,
2662 "Line %d: invalid IP address '%s'",
2666 } else if (bss
->radius
->auth_server
&&
2667 os_strcmp(buf
, "auth_server_port") == 0) {
2668 bss
->radius
->auth_server
->port
= atoi(pos
);
2669 } else if (bss
->radius
->auth_server
&&
2670 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
2671 int len
= os_strlen(pos
);
2673 /* RFC 2865, Ch. 3 */
2674 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2678 os_free(bss
->radius
->auth_server
->shared_secret
);
2679 bss
->radius
->auth_server
->shared_secret
= (u8
*) os_strdup(pos
);
2680 bss
->radius
->auth_server
->shared_secret_len
= len
;
2681 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
2682 if (hostapd_config_read_radius_addr(
2683 &bss
->radius
->acct_servers
,
2684 &bss
->radius
->num_acct_servers
, pos
, 1813,
2685 &bss
->radius
->acct_server
)) {
2686 wpa_printf(MSG_ERROR
,
2687 "Line %d: invalid IP address '%s'",
2691 } else if (bss
->radius
->acct_server
&&
2692 os_strcmp(buf
, "acct_server_addr_replace") == 0) {
2693 if (hostapd_parse_ip_addr(pos
,
2694 &bss
->radius
->acct_server
->addr
)) {
2695 wpa_printf(MSG_ERROR
,
2696 "Line %d: invalid IP address '%s'",
2700 } else if (bss
->radius
->acct_server
&&
2701 os_strcmp(buf
, "acct_server_port") == 0) {
2702 bss
->radius
->acct_server
->port
= atoi(pos
);
2703 } else if (bss
->radius
->acct_server
&&
2704 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
2705 int len
= os_strlen(pos
);
2707 /* RFC 2865, Ch. 3 */
2708 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2712 os_free(bss
->radius
->acct_server
->shared_secret
);
2713 bss
->radius
->acct_server
->shared_secret
= (u8
*) os_strdup(pos
);
2714 bss
->radius
->acct_server
->shared_secret_len
= len
;
2715 } else if (os_strcmp(buf
, "radius_retry_primary_interval") == 0) {
2716 bss
->radius
->retry_primary_interval
= atoi(pos
);
2717 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0) {
2718 bss
->acct_interim_interval
= atoi(pos
);
2719 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
2720 bss
->radius_request_cui
= atoi(pos
);
2721 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
2722 struct hostapd_radius_attr
*attr
, *a
;
2723 attr
= hostapd_parse_radius_attr(pos
);
2725 wpa_printf(MSG_ERROR
,
2726 "Line %d: invalid radius_auth_req_attr",
2729 } else if (bss
->radius_auth_req_attr
== NULL
) {
2730 bss
->radius_auth_req_attr
= attr
;
2732 a
= bss
->radius_auth_req_attr
;
2737 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
2738 struct hostapd_radius_attr
*attr
, *a
;
2739 attr
= hostapd_parse_radius_attr(pos
);
2741 wpa_printf(MSG_ERROR
,
2742 "Line %d: invalid radius_acct_req_attr",
2745 } else if (bss
->radius_acct_req_attr
== NULL
) {
2746 bss
->radius_acct_req_attr
= attr
;
2748 a
= bss
->radius_acct_req_attr
;
2753 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
2754 bss
->radius_das_port
= atoi(pos
);
2755 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
2756 if (hostapd_parse_das_client(bss
, pos
) < 0) {
2757 wpa_printf(MSG_ERROR
, "Line %d: invalid DAS client",
2761 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2762 bss
->radius_das_time_window
= atoi(pos
);
2763 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp") == 0) {
2764 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2765 } else if (os_strcmp(buf
, "radius_das_require_message_authenticator") ==
2767 bss
->radius_das_require_message_authenticator
= atoi(pos
);
2768 #endif /* CONFIG_NO_RADIUS */
2769 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2770 bss
->auth_algs
= atoi(pos
);
2771 if (bss
->auth_algs
== 0) {
2772 wpa_printf(MSG_ERROR
, "Line %d: no authentication algorithms allowed",
2776 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2777 bss
->max_num_sta
= atoi(pos
);
2778 if (bss
->max_num_sta
< 0 ||
2779 bss
->max_num_sta
> MAX_STA_COUNT
) {
2780 wpa_printf(MSG_ERROR
, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2781 line
, bss
->max_num_sta
, MAX_STA_COUNT
);
2784 } else if (os_strcmp(buf
, "wpa") == 0) {
2785 bss
->wpa
= atoi(pos
);
2786 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2787 bss
->wpa_group_rekey
= atoi(pos
);
2788 bss
->wpa_group_rekey_set
= 1;
2789 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2790 bss
->wpa_strict_rekey
= atoi(pos
);
2791 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2792 bss
->wpa_gmk_rekey
= atoi(pos
);
2793 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2794 bss
->wpa_ptk_rekey
= atoi(pos
);
2795 } else if (os_strcmp(buf
, "wpa_group_update_count") == 0) {
2797 unsigned long val
= strtoul(pos
, &endp
, 0);
2799 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2800 wpa_printf(MSG_ERROR
,
2801 "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295",
2805 bss
->wpa_group_update_count
= (u32
) val
;
2806 } else if (os_strcmp(buf
, "wpa_pairwise_update_count") == 0) {
2808 unsigned long val
= strtoul(pos
, &endp
, 0);
2810 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2811 wpa_printf(MSG_ERROR
,
2812 "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295",
2816 bss
->wpa_pairwise_update_count
= (u32
) val
;
2817 } else if (os_strcmp(buf
, "wpa_disable_eapol_key_retries") == 0) {
2818 bss
->wpa_disable_eapol_key_retries
= atoi(pos
);
2819 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2820 int len
= os_strlen(pos
);
2821 if (len
< 8 || len
> 63) {
2822 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA passphrase length %d (expected 8..63)",
2826 os_free(bss
->ssid
.wpa_passphrase
);
2827 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2828 if (bss
->ssid
.wpa_passphrase
) {
2829 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2830 bss
->ssid
.wpa_passphrase_set
= 1;
2832 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2833 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2834 bss
->ssid
.wpa_psk
= os_zalloc(sizeof(struct hostapd_wpa_psk
));
2835 if (bss
->ssid
.wpa_psk
== NULL
)
2837 if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
, PMK_LEN
) ||
2838 pos
[PMK_LEN
* 2] != '\0') {
2839 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
2841 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2844 bss
->ssid
.wpa_psk
->group
= 1;
2845 os_free(bss
->ssid
.wpa_passphrase
);
2846 bss
->ssid
.wpa_passphrase
= NULL
;
2847 bss
->ssid
.wpa_psk_set
= 1;
2848 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2849 os_free(bss
->ssid
.wpa_psk_file
);
2850 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
2851 if (!bss
->ssid
.wpa_psk_file
) {
2852 wpa_printf(MSG_ERROR
, "Line %d: allocation failed",
2856 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
2857 bss
->wpa_key_mgmt
= hostapd_config_parse_key_mgmt(line
, pos
);
2858 if (bss
->wpa_key_mgmt
== -1)
2860 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
2861 bss
->wpa_psk_radius
= atoi(pos
);
2862 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
2863 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
2864 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
2865 wpa_printf(MSG_ERROR
,
2866 "Line %d: unknown wpa_psk_radius %d",
2867 line
, bss
->wpa_psk_radius
);
2870 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
2871 bss
->wpa_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2872 if (bss
->wpa_pairwise
== -1 || bss
->wpa_pairwise
== 0)
2874 if (bss
->wpa_pairwise
&
2875 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2876 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2880 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
2881 bss
->rsn_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2882 if (bss
->rsn_pairwise
== -1 || bss
->rsn_pairwise
== 0)
2884 if (bss
->rsn_pairwise
&
2885 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2886 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2890 } else if (os_strcmp(buf
, "group_cipher") == 0) {
2891 bss
->group_cipher
= hostapd_config_parse_cipher(line
, pos
);
2892 if (bss
->group_cipher
== -1 || bss
->group_cipher
== 0)
2894 if (bss
->group_cipher
!= WPA_CIPHER_TKIP
&&
2895 bss
->group_cipher
!= WPA_CIPHER_CCMP
&&
2896 bss
->group_cipher
!= WPA_CIPHER_GCMP
&&
2897 bss
->group_cipher
!= WPA_CIPHER_GCMP_256
&&
2898 bss
->group_cipher
!= WPA_CIPHER_CCMP_256
) {
2899 wpa_printf(MSG_ERROR
,
2900 "Line %d: unsupported group cipher suite '%s'",
2904 #ifdef CONFIG_RSN_PREAUTH
2905 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
2906 bss
->rsn_preauth
= atoi(pos
);
2907 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
2908 os_free(bss
->rsn_preauth_interfaces
);
2909 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
2910 #endif /* CONFIG_RSN_PREAUTH */
2911 } else if (os_strcmp(buf
, "peerkey") == 0) {
2912 wpa_printf(MSG_INFO
,
2913 "Line %d: Obsolete peerkey parameter ignored", line
);
2914 #ifdef CONFIG_IEEE80211R_AP
2915 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
2916 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
2917 hexstr2bin(pos
, bss
->mobility_domain
,
2918 MOBILITY_DOMAIN_ID_LEN
) != 0) {
2919 wpa_printf(MSG_ERROR
,
2920 "Line %d: Invalid mobility_domain '%s'",
2924 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
2925 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
2926 hexstr2bin(pos
, bss
->r1_key_holder
, FT_R1KH_ID_LEN
) != 0) {
2927 wpa_printf(MSG_ERROR
,
2928 "Line %d: Invalid r1_key_holder '%s'",
2932 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
2933 /* DEPRECATED: Use ft_r0_key_lifetime instead. */
2934 bss
->r0_key_lifetime
= atoi(pos
) * 60;
2935 } else if (os_strcmp(buf
, "ft_r0_key_lifetime") == 0) {
2936 bss
->r0_key_lifetime
= atoi(pos
);
2937 } else if (os_strcmp(buf
, "r1_max_key_lifetime") == 0) {
2938 bss
->r1_max_key_lifetime
= atoi(pos
);
2939 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
2940 bss
->reassociation_deadline
= atoi(pos
);
2941 } else if (os_strcmp(buf
, "rkh_pos_timeout") == 0) {
2942 bss
->rkh_pos_timeout
= atoi(pos
);
2943 } else if (os_strcmp(buf
, "rkh_neg_timeout") == 0) {
2944 bss
->rkh_neg_timeout
= atoi(pos
);
2945 } else if (os_strcmp(buf
, "rkh_pull_timeout") == 0) {
2946 bss
->rkh_pull_timeout
= atoi(pos
);
2947 } else if (os_strcmp(buf
, "rkh_pull_retries") == 0) {
2948 bss
->rkh_pull_retries
= atoi(pos
);
2949 } else if (os_strcmp(buf
, "r0kh") == 0) {
2950 if (add_r0kh(bss
, pos
) < 0) {
2951 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r0kh '%s'",
2955 } else if (os_strcmp(buf
, "r1kh") == 0) {
2956 if (add_r1kh(bss
, pos
) < 0) {
2957 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r1kh '%s'",
2961 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
2962 bss
->pmk_r1_push
= atoi(pos
);
2963 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
2964 bss
->ft_over_ds
= atoi(pos
);
2965 } else if (os_strcmp(buf
, "ft_psk_generate_local") == 0) {
2966 bss
->ft_psk_generate_local
= atoi(pos
);
2967 #endif /* CONFIG_IEEE80211R_AP */
2968 #ifndef CONFIG_NO_CTRL_IFACE
2969 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
2970 os_free(bss
->ctrl_interface
);
2971 bss
->ctrl_interface
= os_strdup(pos
);
2972 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
2973 #ifndef CONFIG_NATIVE_WINDOWS
2976 const char *group
= pos
;
2978 grp
= getgrnam(group
);
2980 bss
->ctrl_interface_gid
= grp
->gr_gid
;
2981 bss
->ctrl_interface_gid_set
= 1;
2982 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d (from group name '%s')",
2983 bss
->ctrl_interface_gid
, group
);
2987 /* Group name not found - try to parse this as gid */
2988 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
2989 if (*group
== '\0' || *endp
!= '\0') {
2990 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group '%s'",
2994 bss
->ctrl_interface_gid_set
= 1;
2995 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
2996 bss
->ctrl_interface_gid
);
2997 #endif /* CONFIG_NATIVE_WINDOWS */
2998 #endif /* CONFIG_NO_CTRL_IFACE */
2999 #ifdef RADIUS_SERVER
3000 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
3001 os_free(bss
->radius_server_clients
);
3002 bss
->radius_server_clients
= os_strdup(pos
);
3003 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
3004 bss
->radius_server_auth_port
= atoi(pos
);
3005 } else if (os_strcmp(buf
, "radius_server_acct_port") == 0) {
3006 bss
->radius_server_acct_port
= atoi(pos
);
3007 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
3008 bss
->radius_server_ipv6
= atoi(pos
);
3009 #endif /* RADIUS_SERVER */
3010 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
3011 bss
->use_pae_group_addr
= atoi(pos
);
3012 } else if (os_strcmp(buf
, "hw_mode") == 0) {
3013 if (os_strcmp(pos
, "a") == 0)
3014 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
3015 else if (os_strcmp(pos
, "b") == 0)
3016 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
3017 else if (os_strcmp(pos
, "g") == 0)
3018 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
3019 else if (os_strcmp(pos
, "ad") == 0)
3020 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
3021 else if (os_strcmp(pos
, "any") == 0)
3022 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211ANY
;
3024 wpa_printf(MSG_ERROR
, "Line %d: unknown hw_mode '%s'",
3028 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
3029 if (os_strcmp(pos
, "ad") == 0)
3030 bss
->wps_rf_bands
= WPS_RF_60GHZ
;
3031 else if (os_strcmp(pos
, "a") == 0)
3032 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
3033 else if (os_strcmp(pos
, "g") == 0 ||
3034 os_strcmp(pos
, "b") == 0)
3035 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
3036 else if (os_strcmp(pos
, "ag") == 0 ||
3037 os_strcmp(pos
, "ga") == 0)
3038 bss
->wps_rf_bands
= WPS_RF_24GHZ
| WPS_RF_50GHZ
;
3040 wpa_printf(MSG_ERROR
,
3041 "Line %d: unknown wps_rf_band '%s'",
3045 } else if (os_strcmp(buf
, "acs_exclude_dfs") == 0) {
3046 conf
->acs_exclude_dfs
= atoi(pos
);
3047 } else if (os_strcmp(buf
, "channel") == 0) {
3048 if (os_strcmp(pos
, "acs_survey") == 0) {
3050 wpa_printf(MSG_ERROR
, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
3053 #else /* CONFIG_ACS */
3056 #endif /* CONFIG_ACS */
3058 conf
->channel
= atoi(pos
);
3059 conf
->acs
= conf
->channel
== 0;
3061 } else if (os_strcmp(buf
, "chanlist") == 0) {
3062 if (hostapd_parse_chanlist(conf
, pos
)) {
3063 wpa_printf(MSG_ERROR
, "Line %d: invalid channel list",
3067 } else if (os_strcmp(buf
, "beacon_int") == 0) {
3068 int val
= atoi(pos
);
3069 /* MIB defines range as 1..65535, but very small values
3070 * cause problems with the current implementation.
3071 * Since it is unlikely that this small numbers are
3072 * useful in real life scenarios, do not allow beacon
3073 * period to be set below 15 TU. */
3074 if (val
< 15 || val
> 65535) {
3075 wpa_printf(MSG_ERROR
, "Line %d: invalid beacon_int %d (expected 15..65535)",
3079 conf
->beacon_int
= val
;
3081 } else if (os_strcmp(buf
, "acs_num_scans") == 0) {
3082 int val
= atoi(pos
);
3083 if (val
<= 0 || val
> 100) {
3084 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_num_scans %d (expected 1..100)",
3088 conf
->acs_num_scans
= val
;
3089 } else if (os_strcmp(buf
, "acs_chan_bias") == 0) {
3090 if (hostapd_config_parse_acs_chan_bias(conf
, pos
)) {
3091 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_chan_bias",
3095 #endif /* CONFIG_ACS */
3096 } else if (os_strcmp(buf
, "dtim_period") == 0) {
3097 int val
= atoi(pos
);
3099 if (val
< 1 || val
> 255) {
3100 wpa_printf(MSG_ERROR
, "Line %d: invalid dtim_period %d",
3104 bss
->dtim_period
= val
;
3105 } else if (os_strcmp(buf
, "bss_load_update_period") == 0) {
3106 int val
= atoi(pos
);
3108 if (val
< 0 || val
> 100) {
3109 wpa_printf(MSG_ERROR
,
3110 "Line %d: invalid bss_load_update_period %d",
3114 bss
->bss_load_update_period
= val
;
3115 } else if (os_strcmp(buf
, "chan_util_avg_period") == 0) {
3116 int val
= atoi(pos
);
3119 wpa_printf(MSG_ERROR
,
3120 "Line %d: invalid chan_util_avg_period",
3124 bss
->chan_util_avg_period
= val
;
3125 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
3126 conf
->rts_threshold
= atoi(pos
);
3127 if (conf
->rts_threshold
< -1 || conf
->rts_threshold
> 65535) {
3128 wpa_printf(MSG_ERROR
,
3129 "Line %d: invalid rts_threshold %d",
3130 line
, conf
->rts_threshold
);
3133 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
3134 conf
->fragm_threshold
= atoi(pos
);
3135 if (conf
->fragm_threshold
== -1) {
3136 /* allow a value of -1 */
3137 } else if (conf
->fragm_threshold
< 256 ||
3138 conf
->fragm_threshold
> 2346) {
3139 wpa_printf(MSG_ERROR
,
3140 "Line %d: invalid fragm_threshold %d",
3141 line
, conf
->fragm_threshold
);
3144 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
3145 int val
= atoi(pos
);
3146 if (val
!= 0 && val
!= 1) {
3147 wpa_printf(MSG_ERROR
, "Line %d: invalid send_probe_response %d (expected 0 or 1)",
3151 bss
->send_probe_response
= val
;
3152 } else if (os_strcmp(buf
, "supported_rates") == 0) {
3153 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
)) {
3154 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3158 } else if (os_strcmp(buf
, "basic_rates") == 0) {
3159 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
3160 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3164 } else if (os_strcmp(buf
, "beacon_rate") == 0) {
3167 if (os_strncmp(pos
, "ht:", 3) == 0) {
3168 val
= atoi(pos
+ 3);
3169 if (val
< 0 || val
> 31) {
3170 wpa_printf(MSG_ERROR
,
3171 "Line %d: invalid beacon_rate HT-MCS %d",
3175 conf
->rate_type
= BEACON_RATE_HT
;
3176 conf
->beacon_rate
= val
;
3177 } else if (os_strncmp(pos
, "vht:", 4) == 0) {
3178 val
= atoi(pos
+ 4);
3179 if (val
< 0 || val
> 9) {
3180 wpa_printf(MSG_ERROR
,
3181 "Line %d: invalid beacon_rate VHT-MCS %d",
3185 conf
->rate_type
= BEACON_RATE_VHT
;
3186 conf
->beacon_rate
= val
;
3189 if (val
< 10 || val
> 10000) {
3190 wpa_printf(MSG_ERROR
,
3191 "Line %d: invalid legacy beacon_rate %d",
3195 conf
->rate_type
= BEACON_RATE_LEGACY
;
3196 conf
->beacon_rate
= val
;
3198 } else if (os_strcmp(buf
, "preamble") == 0) {
3200 conf
->preamble
= SHORT_PREAMBLE
;
3202 conf
->preamble
= LONG_PREAMBLE
;
3203 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
3204 bss
->ignore_broadcast_ssid
= atoi(pos
);
3205 } else if (os_strcmp(buf
, "no_probe_resp_if_max_sta") == 0) {
3206 bss
->no_probe_resp_if_max_sta
= atoi(pos
);
3207 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
3208 bss
->ssid
.wep
.idx
= atoi(pos
);
3209 if (bss
->ssid
.wep
.idx
> 3) {
3210 wpa_printf(MSG_ERROR
,
3211 "Invalid wep_default_key index %d",
3215 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
3216 os_strcmp(buf
, "wep_key1") == 0 ||
3217 os_strcmp(buf
, "wep_key2") == 0 ||
3218 os_strcmp(buf
, "wep_key3") == 0) {
3219 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
3220 buf
[7] - '0', pos
)) {
3221 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP key '%s'",
3225 #ifndef CONFIG_NO_VLAN
3226 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
3227 bss
->ssid
.dynamic_vlan
= atoi(pos
);
3228 } else if (os_strcmp(buf
, "per_sta_vif") == 0) {
3229 bss
->ssid
.per_sta_vif
= atoi(pos
);
3230 } else if (os_strcmp(buf
, "vlan_file") == 0) {
3231 if (hostapd_config_read_vlan_file(bss
, pos
)) {
3232 wpa_printf(MSG_ERROR
, "Line %d: failed to read VLAN file '%s'",
3236 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
3237 bss
->ssid
.vlan_naming
= atoi(pos
);
3238 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
3239 bss
->ssid
.vlan_naming
< 0) {
3240 wpa_printf(MSG_ERROR
,
3241 "Line %d: invalid naming scheme %d",
3242 line
, bss
->ssid
.vlan_naming
);
3245 #ifdef CONFIG_FULL_DYNAMIC_VLAN
3246 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
3247 os_free(bss
->ssid
.vlan_tagged_interface
);
3248 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
3249 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
3250 #endif /* CONFIG_NO_VLAN */
3251 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
3252 conf
->ap_table_max_size
= atoi(pos
);
3253 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
3254 conf
->ap_table_expiration_time
= atoi(pos
);
3255 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
3256 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
3257 wpa_printf(MSG_ERROR
, "Line %d: invalid TX queue item",
3261 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
3262 os_strcmp(buf
, "wmm_enabled") == 0) {
3263 bss
->wmm_enabled
= atoi(pos
);
3264 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
3265 bss
->wmm_uapsd
= atoi(pos
);
3266 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
3267 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
3268 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
, pos
)) {
3269 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM ac item",
3273 } else if (os_strcmp(buf
, "bss") == 0) {
3274 if (hostapd_config_bss(conf
, pos
)) {
3275 wpa_printf(MSG_ERROR
, "Line %d: invalid bss item",
3279 } else if (os_strcmp(buf
, "bssid") == 0) {
3280 if (hwaddr_aton(pos
, bss
->bssid
)) {
3281 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid item",
3285 } else if (os_strcmp(buf
, "use_driver_iface_addr") == 0) {
3286 conf
->use_driver_iface_addr
= atoi(pos
);
3287 #ifdef CONFIG_IEEE80211W
3288 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
3289 bss
->ieee80211w
= atoi(pos
);
3290 } else if (os_strcmp(buf
, "group_mgmt_cipher") == 0) {
3291 if (os_strcmp(pos
, "AES-128-CMAC") == 0) {
3292 bss
->group_mgmt_cipher
= WPA_CIPHER_AES_128_CMAC
;
3293 } else if (os_strcmp(pos
, "BIP-GMAC-128") == 0) {
3294 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_128
;
3295 } else if (os_strcmp(pos
, "BIP-GMAC-256") == 0) {
3296 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_256
;
3297 } else if (os_strcmp(pos
, "BIP-CMAC-256") == 0) {
3298 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_CMAC_256
;
3300 wpa_printf(MSG_ERROR
, "Line %d: invalid group_mgmt_cipher: %s",
3304 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
3305 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
3306 if (bss
->assoc_sa_query_max_timeout
== 0) {
3307 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_max_timeout",
3311 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0) {
3312 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
3313 if (bss
->assoc_sa_query_retry_timeout
== 0) {
3314 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_retry_timeout",
3318 #endif /* CONFIG_IEEE80211W */
3320 } else if (os_strcmp(buf
, "ocv") == 0) {
3321 bss
->ocv
= atoi(pos
);
3322 if (bss
->ocv
&& !bss
->ieee80211w
)
3323 bss
->ieee80211w
= 1;
3324 #endif /* CONFIG_OCV */
3325 #ifdef CONFIG_IEEE80211N
3326 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
3327 conf
->ieee80211n
= atoi(pos
);
3328 } else if (os_strcmp(buf
, "ht_capab") == 0) {
3329 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
3330 wpa_printf(MSG_ERROR
, "Line %d: invalid ht_capab",
3334 } else if (os_strcmp(buf
, "require_ht") == 0) {
3335 conf
->require_ht
= atoi(pos
);
3336 } else if (os_strcmp(buf
, "obss_interval") == 0) {
3337 conf
->obss_interval
= atoi(pos
);
3338 #endif /* CONFIG_IEEE80211N */
3339 #ifdef CONFIG_IEEE80211AC
3340 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
3341 conf
->ieee80211ac
= atoi(pos
);
3342 } else if (os_strcmp(buf
, "vht_capab") == 0) {
3343 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
3344 wpa_printf(MSG_ERROR
, "Line %d: invalid vht_capab",
3348 } else if (os_strcmp(buf
, "require_vht") == 0) {
3349 conf
->require_vht
= atoi(pos
);
3350 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
3351 conf
->vht_oper_chwidth
= atoi(pos
);
3352 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0) {
3353 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
3354 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0) {
3355 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
3356 } else if (os_strcmp(buf
, "vendor_vht") == 0) {
3357 bss
->vendor_vht
= atoi(pos
);
3358 } else if (os_strcmp(buf
, "use_sta_nsts") == 0) {
3359 bss
->use_sta_nsts
= atoi(pos
);
3360 #endif /* CONFIG_IEEE80211AC */
3361 #ifdef CONFIG_IEEE80211AX
3362 } else if (os_strcmp(buf
, "ieee80211ax") == 0) {
3363 conf
->ieee80211ax
= atoi(pos
);
3364 } else if (os_strcmp(buf
, "he_su_beamformer") == 0) {
3365 conf
->he_phy_capab
.he_su_beamformer
= atoi(pos
);
3366 } else if (os_strcmp(buf
, "he_su_beamformee") == 0) {
3367 conf
->he_phy_capab
.he_su_beamformee
= atoi(pos
);
3368 } else if (os_strcmp(buf
, "he_mu_beamformer") == 0) {
3369 conf
->he_phy_capab
.he_mu_beamformer
= atoi(pos
);
3370 } else if (os_strcmp(buf
, "he_bss_color") == 0) {
3371 conf
->he_op
.he_bss_color
= atoi(pos
);
3372 } else if (os_strcmp(buf
, "he_default_pe_duration") == 0) {
3373 conf
->he_op
.he_default_pe_duration
= atoi(pos
);
3374 } else if (os_strcmp(buf
, "he_twt_required") == 0) {
3375 conf
->he_op
.he_twt_required
= atoi(pos
);
3376 } else if (os_strcmp(buf
, "he_rts_threshold") == 0) {
3377 conf
->he_op
.he_rts_threshold
= atoi(pos
);
3378 #endif /* CONFIG_IEEE80211AX */
3379 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
3380 bss
->max_listen_interval
= atoi(pos
);
3381 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
3382 bss
->disable_pmksa_caching
= atoi(pos
);
3383 } else if (os_strcmp(buf
, "okc") == 0) {
3384 bss
->okc
= atoi(pos
);
3386 } else if (os_strcmp(buf
, "wps_state") == 0) {
3387 bss
->wps_state
= atoi(pos
);
3388 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
3389 wpa_printf(MSG_ERROR
, "Line %d: invalid wps_state",
3393 } else if (os_strcmp(buf
, "wps_independent") == 0) {
3394 bss
->wps_independent
= atoi(pos
);
3395 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
3396 bss
->ap_setup_locked
= atoi(pos
);
3397 } else if (os_strcmp(buf
, "uuid") == 0) {
3398 if (uuid_str2bin(pos
, bss
->uuid
)) {
3399 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID", line
);
3402 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
3403 os_free(bss
->wps_pin_requests
);
3404 bss
->wps_pin_requests
= os_strdup(pos
);
3405 } else if (os_strcmp(buf
, "device_name") == 0) {
3406 if (os_strlen(pos
) > WPS_DEV_NAME_MAX_LEN
) {
3407 wpa_printf(MSG_ERROR
, "Line %d: Too long "
3408 "device_name", line
);
3411 os_free(bss
->device_name
);
3412 bss
->device_name
= os_strdup(pos
);
3413 } else if (os_strcmp(buf
, "manufacturer") == 0) {
3414 if (os_strlen(pos
) > 64) {
3415 wpa_printf(MSG_ERROR
, "Line %d: Too long manufacturer",
3419 os_free(bss
->manufacturer
);
3420 bss
->manufacturer
= os_strdup(pos
);
3421 } else if (os_strcmp(buf
, "model_name") == 0) {
3422 if (os_strlen(pos
) > 32) {
3423 wpa_printf(MSG_ERROR
, "Line %d: Too long model_name",
3427 os_free(bss
->model_name
);
3428 bss
->model_name
= os_strdup(pos
);
3429 } else if (os_strcmp(buf
, "model_number") == 0) {
3430 if (os_strlen(pos
) > 32) {
3431 wpa_printf(MSG_ERROR
, "Line %d: Too long model_number",
3435 os_free(bss
->model_number
);
3436 bss
->model_number
= os_strdup(pos
);
3437 } else if (os_strcmp(buf
, "serial_number") == 0) {
3438 if (os_strlen(pos
) > 32) {
3439 wpa_printf(MSG_ERROR
, "Line %d: Too long serial_number",
3443 os_free(bss
->serial_number
);
3444 bss
->serial_number
= os_strdup(pos
);
3445 } else if (os_strcmp(buf
, "device_type") == 0) {
3446 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
3448 } else if (os_strcmp(buf
, "config_methods") == 0) {
3449 os_free(bss
->config_methods
);
3450 bss
->config_methods
= os_strdup(pos
);
3451 } else if (os_strcmp(buf
, "os_version") == 0) {
3452 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
3453 wpa_printf(MSG_ERROR
, "Line %d: invalid os_version",
3457 } else if (os_strcmp(buf
, "ap_pin") == 0) {
3458 os_free(bss
->ap_pin
);
3462 bss
->ap_pin
= os_strdup(pos
);
3463 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
3464 bss
->skip_cred_build
= atoi(pos
);
3465 } else if (os_strcmp(buf
, "extra_cred") == 0) {
3466 os_free(bss
->extra_cred
);
3467 bss
->extra_cred
= (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
3468 if (bss
->extra_cred
== NULL
) {
3469 wpa_printf(MSG_ERROR
, "Line %d: could not read Credentials from '%s'",
3473 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
3474 bss
->wps_cred_processing
= atoi(pos
);
3475 } else if (os_strcmp(buf
, "ap_settings") == 0) {
3476 os_free(bss
->ap_settings
);
3478 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
3479 if (bss
->ap_settings
== NULL
) {
3480 wpa_printf(MSG_ERROR
, "Line %d: could not read AP Settings from '%s'",
3484 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
3485 os_free(bss
->upnp_iface
);
3486 bss
->upnp_iface
= os_strdup(pos
);
3487 } else if (os_strcmp(buf
, "friendly_name") == 0) {
3488 os_free(bss
->friendly_name
);
3489 bss
->friendly_name
= os_strdup(pos
);
3490 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
3491 os_free(bss
->manufacturer_url
);
3492 bss
->manufacturer_url
= os_strdup(pos
);
3493 } else if (os_strcmp(buf
, "model_description") == 0) {
3494 os_free(bss
->model_description
);
3495 bss
->model_description
= os_strdup(pos
);
3496 } else if (os_strcmp(buf
, "model_url") == 0) {
3497 os_free(bss
->model_url
);
3498 bss
->model_url
= os_strdup(pos
);
3499 } else if (os_strcmp(buf
, "upc") == 0) {
3501 bss
->upc
= os_strdup(pos
);
3502 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
3503 bss
->pbc_in_m1
= atoi(pos
);
3504 } else if (os_strcmp(buf
, "server_id") == 0) {
3505 os_free(bss
->server_id
);
3506 bss
->server_id
= os_strdup(pos
);
3507 #ifdef CONFIG_WPS_NFC
3508 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
3509 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
3510 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
3511 bss
->wps_nfc_dev_pw_id
> 0xffff) {
3512 wpa_printf(MSG_ERROR
, "Line %d: Invalid wps_nfc_dev_pw_id value",
3516 bss
->wps_nfc_pw_from_config
= 1;
3517 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
3518 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
3519 bss
->wps_nfc_dh_pubkey
= wpabuf_parse_bin(pos
);
3520 bss
->wps_nfc_pw_from_config
= 1;
3521 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
3522 wpabuf_free(bss
->wps_nfc_dh_privkey
);
3523 bss
->wps_nfc_dh_privkey
= wpabuf_parse_bin(pos
);
3524 bss
->wps_nfc_pw_from_config
= 1;
3525 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
3526 wpabuf_free(bss
->wps_nfc_dev_pw
);
3527 bss
->wps_nfc_dev_pw
= wpabuf_parse_bin(pos
);
3528 bss
->wps_nfc_pw_from_config
= 1;
3529 #endif /* CONFIG_WPS_NFC */
3530 #endif /* CONFIG_WPS */
3531 #ifdef CONFIG_P2P_MANAGER
3532 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
3534 bss
->p2p
|= P2P_MANAGE
;
3536 bss
->p2p
&= ~P2P_MANAGE
;
3537 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
3539 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
3541 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
3542 #endif /* CONFIG_P2P_MANAGER */
3543 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
3544 bss
->disassoc_low_ack
= atoi(pos
);
3545 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
3547 bss
->tdls
|= TDLS_PROHIBIT
;
3549 bss
->tdls
&= ~TDLS_PROHIBIT
;
3550 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
3552 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
3554 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
3555 #ifdef CONFIG_RSN_TESTING
3556 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
3557 extern int rsn_testing
;
3558 rsn_testing
= atoi(pos
);
3559 #endif /* CONFIG_RSN_TESTING */
3560 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
3561 bss
->time_advertisement
= atoi(pos
);
3562 } else if (os_strcmp(buf
, "time_zone") == 0) {
3563 size_t tz_len
= os_strlen(pos
);
3564 if (tz_len
< 4 || tz_len
> 255) {
3565 wpa_printf(MSG_DEBUG
, "Line %d: invalid time_zone",
3569 os_free(bss
->time_zone
);
3570 bss
->time_zone
= os_strdup(pos
);
3571 if (bss
->time_zone
== NULL
)
3573 #ifdef CONFIG_WNM_AP
3574 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
3575 bss
->wnm_sleep_mode
= atoi(pos
);
3576 } else if (os_strcmp(buf
, "wnm_sleep_mode_no_keys") == 0) {
3577 bss
->wnm_sleep_mode_no_keys
= atoi(pos
);
3578 } else if (os_strcmp(buf
, "bss_transition") == 0) {
3579 bss
->bss_transition
= atoi(pos
);
3580 #endif /* CONFIG_WNM_AP */
3581 #ifdef CONFIG_INTERWORKING
3582 } else if (os_strcmp(buf
, "interworking") == 0) {
3583 bss
->interworking
= atoi(pos
);
3584 } else if (os_strcmp(buf
, "access_network_type") == 0) {
3585 bss
->access_network_type
= atoi(pos
);
3586 if (bss
->access_network_type
< 0 ||
3587 bss
->access_network_type
> 15) {
3588 wpa_printf(MSG_ERROR
,
3589 "Line %d: invalid access_network_type",
3593 } else if (os_strcmp(buf
, "internet") == 0) {
3594 bss
->internet
= atoi(pos
);
3595 } else if (os_strcmp(buf
, "asra") == 0) {
3596 bss
->asra
= atoi(pos
);
3597 } else if (os_strcmp(buf
, "esr") == 0) {
3598 bss
->esr
= atoi(pos
);
3599 } else if (os_strcmp(buf
, "uesa") == 0) {
3600 bss
->uesa
= atoi(pos
);
3601 } else if (os_strcmp(buf
, "venue_group") == 0) {
3602 bss
->venue_group
= atoi(pos
);
3603 bss
->venue_info_set
= 1;
3604 } else if (os_strcmp(buf
, "venue_type") == 0) {
3605 bss
->venue_type
= atoi(pos
);
3606 bss
->venue_info_set
= 1;
3607 } else if (os_strcmp(buf
, "hessid") == 0) {
3608 if (hwaddr_aton(pos
, bss
->hessid
)) {
3609 wpa_printf(MSG_ERROR
, "Line %d: invalid hessid", line
);
3612 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
3613 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
3615 } else if (os_strcmp(buf
, "venue_name") == 0) {
3616 if (parse_venue_name(bss
, pos
, line
) < 0)
3618 } else if (os_strcmp(buf
, "venue_url") == 0) {
3619 if (parse_venue_url(bss
, pos
, line
) < 0)
3621 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
3623 u16 redirect_url_len
;
3624 if (hexstr2bin(pos
, &auth_type
, 1)) {
3625 wpa_printf(MSG_ERROR
,
3626 "Line %d: Invalid network_auth_type '%s'",
3630 if (auth_type
== 0 || auth_type
== 2)
3631 redirect_url_len
= os_strlen(pos
+ 2);
3633 redirect_url_len
= 0;
3634 os_free(bss
->network_auth_type
);
3635 bss
->network_auth_type
= os_malloc(redirect_url_len
+ 3 + 1);
3636 if (bss
->network_auth_type
== NULL
)
3638 *bss
->network_auth_type
= auth_type
;
3639 WPA_PUT_LE16(bss
->network_auth_type
+ 1, redirect_url_len
);
3640 if (redirect_url_len
)
3641 os_memcpy(bss
->network_auth_type
+ 3, pos
+ 2,
3643 bss
->network_auth_type_len
= 3 + redirect_url_len
;
3644 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
3645 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1)) {
3646 wpa_printf(MSG_ERROR
, "Line %d: Invalid ipaddr_type_availability '%s'",
3648 bss
->ipaddr_type_configured
= 0;
3651 bss
->ipaddr_type_configured
= 1;
3652 } else if (os_strcmp(buf
, "domain_name") == 0) {
3653 int j
, num_domains
, domain_len
, domain_list_len
= 0;
3654 char *tok_start
, *tok_prev
;
3655 u8
*domain_list
, *domain_ptr
;
3657 domain_list_len
= os_strlen(pos
) + 1;
3658 domain_list
= os_malloc(domain_list_len
);
3659 if (domain_list
== NULL
)
3662 domain_ptr
= domain_list
;
3665 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
3670 for (j
= 0; j
< num_domains
; j
++) {
3671 tok_start
= os_strchr(tok_prev
, ',');
3673 domain_len
= tok_start
- tok_prev
;
3674 *domain_ptr
= domain_len
;
3675 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3676 domain_ptr
+= domain_len
+ 1;
3677 tok_prev
= ++tok_start
;
3679 domain_len
= os_strlen(tok_prev
);
3680 *domain_ptr
= domain_len
;
3681 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3682 domain_ptr
+= domain_len
+ 1;
3686 os_free(bss
->domain_name
);
3687 bss
->domain_name
= domain_list
;
3688 bss
->domain_name_len
= domain_list_len
;
3689 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
3690 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
3692 } else if (os_strcmp(buf
, "nai_realm") == 0) {
3693 if (parse_nai_realm(bss
, pos
, line
) < 0)
3695 } else if (os_strcmp(buf
, "anqp_elem") == 0) {
3696 if (parse_anqp_elem(bss
, pos
, line
) < 0)
3698 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
3699 int val
= atoi(pos
);
3702 wpa_printf(MSG_ERROR
,
3703 "Line %d: Invalid gas_frag_limit '%s'",
3707 bss
->gas_frag_limit
= val
;
3708 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
3709 bss
->gas_comeback_delay
= atoi(pos
);
3710 } else if (os_strcmp(buf
, "qos_map_set") == 0) {
3711 if (parse_qos_map_set(bss
, pos
, line
) < 0)
3713 #endif /* CONFIG_INTERWORKING */
3714 #ifdef CONFIG_RADIUS_TEST
3715 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
3716 os_free(bss
->dump_msk_file
);
3717 bss
->dump_msk_file
= os_strdup(pos
);
3718 #endif /* CONFIG_RADIUS_TEST */
3719 #ifdef CONFIG_PROXYARP
3720 } else if (os_strcmp(buf
, "proxy_arp") == 0) {
3721 bss
->proxy_arp
= atoi(pos
);
3722 #endif /* CONFIG_PROXYARP */
3724 } else if (os_strcmp(buf
, "hs20") == 0) {
3725 bss
->hs20
= atoi(pos
);
3726 } else if (os_strcmp(buf
, "hs20_release") == 0) {
3727 int val
= atoi(pos
);
3729 if (val
< 1 || val
> (HS20_VERSION
>> 4) + 1) {
3730 wpa_printf(MSG_ERROR
,
3731 "Line %d: Unsupported hs20_release: %s",
3735 bss
->hs20_release
= val
;
3736 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
3737 bss
->disable_dgaf
= atoi(pos
);
3738 } else if (os_strcmp(buf
, "na_mcast_to_ucast") == 0) {
3739 bss
->na_mcast_to_ucast
= atoi(pos
);
3740 } else if (os_strcmp(buf
, "osen") == 0) {
3741 bss
->osen
= atoi(pos
);
3742 } else if (os_strcmp(buf
, "anqp_domain_id") == 0) {
3743 bss
->anqp_domain_id
= atoi(pos
);
3744 } else if (os_strcmp(buf
, "hs20_deauth_req_timeout") == 0) {
3745 bss
->hs20_deauth_req_timeout
= atoi(pos
);
3746 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
3747 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
3749 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
3750 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0)
3752 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
3753 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
3756 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
3758 size_t oper_class_len
;
3759 oper_class_len
= os_strlen(pos
);
3760 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
3761 wpa_printf(MSG_ERROR
,
3762 "Line %d: Invalid hs20_operating_class '%s'",
3766 oper_class_len
/= 2;
3767 oper_class
= os_malloc(oper_class_len
);
3768 if (oper_class
== NULL
)
3770 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
3771 wpa_printf(MSG_ERROR
,
3772 "Line %d: Invalid hs20_operating_class '%s'",
3774 os_free(oper_class
);
3777 os_free(bss
->hs20_operating_class
);
3778 bss
->hs20_operating_class
= oper_class
;
3779 bss
->hs20_operating_class_len
= oper_class_len
;
3780 } else if (os_strcmp(buf
, "hs20_icon") == 0) {
3781 if (hs20_parse_icon(bss
, pos
) < 0) {
3782 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_icon '%s'",
3786 } else if (os_strcmp(buf
, "osu_ssid") == 0) {
3787 if (hs20_parse_osu_ssid(bss
, pos
, line
) < 0)
3789 } else if (os_strcmp(buf
, "osu_server_uri") == 0) {
3790 if (hs20_parse_osu_server_uri(bss
, pos
, line
) < 0)
3792 } else if (os_strcmp(buf
, "osu_friendly_name") == 0) {
3793 if (hs20_parse_osu_friendly_name(bss
, pos
, line
) < 0)
3795 } else if (os_strcmp(buf
, "osu_nai") == 0) {
3796 if (hs20_parse_osu_nai(bss
, pos
, line
) < 0)
3798 } else if (os_strcmp(buf
, "osu_nai2") == 0) {
3799 if (hs20_parse_osu_nai2(bss
, pos
, line
) < 0)
3801 } else if (os_strcmp(buf
, "osu_method_list") == 0) {
3802 if (hs20_parse_osu_method_list(bss
, pos
, line
) < 0)
3804 } else if (os_strcmp(buf
, "osu_icon") == 0) {
3805 if (hs20_parse_osu_icon(bss
, pos
, line
) < 0)
3807 } else if (os_strcmp(buf
, "osu_service_desc") == 0) {
3808 if (hs20_parse_osu_service_desc(bss
, pos
, line
) < 0)
3810 } else if (os_strcmp(buf
, "operator_icon") == 0) {
3811 if (hs20_parse_operator_icon(bss
, pos
, line
) < 0)
3813 } else if (os_strcmp(buf
, "subscr_remediation_url") == 0) {
3814 os_free(bss
->subscr_remediation_url
);
3815 bss
->subscr_remediation_url
= os_strdup(pos
);
3816 } else if (os_strcmp(buf
, "subscr_remediation_method") == 0) {
3817 bss
->subscr_remediation_method
= atoi(pos
);
3818 } else if (os_strcmp(buf
, "hs20_t_c_filename") == 0) {
3819 os_free(bss
->t_c_filename
);
3820 bss
->t_c_filename
= os_strdup(pos
);
3821 } else if (os_strcmp(buf
, "hs20_t_c_timestamp") == 0) {
3822 bss
->t_c_timestamp
= strtol(pos
, NULL
, 0);
3823 } else if (os_strcmp(buf
, "hs20_t_c_server_url") == 0) {
3824 os_free(bss
->t_c_server_url
);
3825 bss
->t_c_server_url
= os_strdup(pos
);
3826 } else if (os_strcmp(buf
, "hs20_sim_provisioning_url") == 0) {
3827 os_free(bss
->hs20_sim_provisioning_url
);
3828 bss
->hs20_sim_provisioning_url
= os_strdup(pos
);
3829 #endif /* CONFIG_HS20 */
3831 } else if (os_strcmp(buf
, "mbo") == 0) {
3832 bss
->mbo_enabled
= atoi(pos
);
3833 } else if (os_strcmp(buf
, "mbo_cell_data_conn_pref") == 0) {
3834 bss
->mbo_cell_data_conn_pref
= atoi(pos
);
3835 } else if (os_strcmp(buf
, "oce") == 0) {
3836 bss
->oce
= atoi(pos
);
3837 #endif /* CONFIG_MBO */
3838 #ifdef CONFIG_TESTING_OPTIONS
3839 #define PARSE_TEST_PROBABILITY(_val) \
3840 } else if (os_strcmp(buf, #_val) == 0) { \
3843 conf->_val = strtod(pos, &end); \
3844 if (*end || conf->_val < 0.0 || \
3845 conf->_val > 1.0) { \
3846 wpa_printf(MSG_ERROR, \
3847 "Line %d: Invalid value '%s'", \
3851 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
3852 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
3853 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
3854 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
3855 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
3856 } else if (os_strcmp(buf
, "ecsa_ie_only") == 0) {
3857 conf
->ecsa_ie_only
= atoi(pos
);
3858 } else if (os_strcmp(buf
, "bss_load_test") == 0) {
3859 WPA_PUT_LE16(bss
->bss_load_test
, atoi(pos
));
3860 pos
= os_strchr(pos
, ':');
3862 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
3867 bss
->bss_load_test
[2] = atoi(pos
);
3868 pos
= os_strchr(pos
, ':');
3870 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
3875 WPA_PUT_LE16(&bss
->bss_load_test
[3], atoi(pos
));
3876 bss
->bss_load_test_set
= 1;
3877 } else if (os_strcmp(buf
, "radio_measurements") == 0) {
3879 * DEPRECATED: This parameter will be removed in the future.
3880 * Use rrm_neighbor_report instead.
3882 int val
= atoi(pos
);
3885 bss
->radio_measurements
[0] |=
3886 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
3887 } else if (os_strcmp(buf
, "own_ie_override") == 0) {
3889 size_t len
= os_strlen(pos
) / 2;
3891 tmp
= wpabuf_alloc(len
);
3895 if (hexstr2bin(pos
, wpabuf_put(tmp
, len
), len
)) {
3897 wpa_printf(MSG_ERROR
,
3898 "Line %d: Invalid own_ie_override '%s'",
3903 wpabuf_free(bss
->own_ie_override
);
3904 bss
->own_ie_override
= tmp
;
3905 } else if (os_strcmp(buf
, "sae_reflection_attack") == 0) {
3906 bss
->sae_reflection_attack
= atoi(pos
);
3907 } else if (os_strcmp(buf
, "sae_commit_override") == 0) {
3908 wpabuf_free(bss
->sae_commit_override
);
3909 bss
->sae_commit_override
= wpabuf_parse_bin(pos
);
3910 #endif /* CONFIG_TESTING_OPTIONS */
3912 } else if (os_strcmp(buf
, "sae_password") == 0) {
3913 if (parse_sae_password(bss
, pos
) < 0) {
3914 wpa_printf(MSG_ERROR
, "Line %d: Invalid sae_password",
3918 #endif /* CONFIG_SAE */
3919 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
3920 if (parse_wpabuf_hex(line
, buf
, &bss
->vendor_elements
, pos
))
3922 } else if (os_strcmp(buf
, "assocresp_elements") == 0) {
3923 if (parse_wpabuf_hex(line
, buf
, &bss
->assocresp_elements
, pos
))
3925 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
3926 bss
->sae_anti_clogging_threshold
= atoi(pos
);
3927 } else if (os_strcmp(buf
, "sae_sync") == 0) {
3928 bss
->sae_sync
= atoi(pos
);
3929 } else if (os_strcmp(buf
, "sae_groups") == 0) {
3930 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
3931 wpa_printf(MSG_ERROR
,
3932 "Line %d: Invalid sae_groups value '%s'",
3936 } else if (os_strcmp(buf
, "sae_require_mfp") == 0) {
3937 bss
->sae_require_mfp
= atoi(pos
);
3938 } else if (os_strcmp(buf
, "local_pwr_constraint") == 0) {
3939 int val
= atoi(pos
);
3940 if (val
< 0 || val
> 255) {
3941 wpa_printf(MSG_ERROR
, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
3945 conf
->local_pwr_constraint
= val
;
3946 } else if (os_strcmp(buf
, "spectrum_mgmt_required") == 0) {
3947 conf
->spectrum_mgmt_required
= atoi(pos
);
3948 } else if (os_strcmp(buf
, "wowlan_triggers") == 0) {
3949 os_free(bss
->wowlan_triggers
);
3950 bss
->wowlan_triggers
= os_strdup(pos
);
3952 } else if (os_strcmp(buf
, "fst_group_id") == 0) {
3953 size_t len
= os_strlen(pos
);
3955 if (!len
|| len
>= sizeof(conf
->fst_cfg
.group_id
)) {
3956 wpa_printf(MSG_ERROR
,
3957 "Line %d: Invalid fst_group_id value '%s'",
3962 if (conf
->fst_cfg
.group_id
[0]) {
3963 wpa_printf(MSG_ERROR
,
3964 "Line %d: Duplicate fst_group value '%s'",
3969 os_strlcpy(conf
->fst_cfg
.group_id
, pos
,
3970 sizeof(conf
->fst_cfg
.group_id
));
3971 } else if (os_strcmp(buf
, "fst_priority") == 0) {
3976 wpa_printf(MSG_ERROR
,
3977 "Line %d: fst_priority value not supplied (expected 1..%u)",
3978 line
, FST_MAX_PRIO_VALUE
);
3982 val
= strtol(pos
, &endp
, 0);
3983 if (*endp
|| val
< 1 || val
> FST_MAX_PRIO_VALUE
) {
3984 wpa_printf(MSG_ERROR
,
3985 "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)",
3986 line
, val
, pos
, FST_MAX_PRIO_VALUE
);
3989 conf
->fst_cfg
.priority
= (u8
) val
;
3990 } else if (os_strcmp(buf
, "fst_llt") == 0) {
3995 wpa_printf(MSG_ERROR
,
3996 "Line %d: fst_llt value not supplied (expected 1..%u)",
3997 line
, FST_MAX_LLT_MS
);
4000 val
= strtol(pos
, &endp
, 0);
4001 if (*endp
|| val
< 1 ||
4002 (unsigned long int) val
> FST_MAX_LLT_MS
) {
4003 wpa_printf(MSG_ERROR
,
4004 "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
4005 line
, val
, pos
, FST_MAX_LLT_MS
);
4008 conf
->fst_cfg
.llt
= (u32
) val
;
4009 #endif /* CONFIG_FST */
4010 } else if (os_strcmp(buf
, "track_sta_max_num") == 0) {
4011 conf
->track_sta_max_num
= atoi(pos
);
4012 } else if (os_strcmp(buf
, "track_sta_max_age") == 0) {
4013 conf
->track_sta_max_age
= atoi(pos
);
4014 } else if (os_strcmp(buf
, "no_probe_resp_if_seen_on") == 0) {
4015 os_free(bss
->no_probe_resp_if_seen_on
);
4016 bss
->no_probe_resp_if_seen_on
= os_strdup(pos
);
4017 } else if (os_strcmp(buf
, "no_auth_if_seen_on") == 0) {
4018 os_free(bss
->no_auth_if_seen_on
);
4019 bss
->no_auth_if_seen_on
= os_strdup(pos
);
4020 } else if (os_strcmp(buf
, "lci") == 0) {
4021 wpabuf_free(conf
->lci
);
4022 conf
->lci
= wpabuf_parse_bin(pos
);
4023 if (conf
->lci
&& wpabuf_len(conf
->lci
) == 0) {
4024 wpabuf_free(conf
->lci
);
4027 } else if (os_strcmp(buf
, "civic") == 0) {
4028 wpabuf_free(conf
->civic
);
4029 conf
->civic
= wpabuf_parse_bin(pos
);
4030 if (conf
->civic
&& wpabuf_len(conf
->civic
) == 0) {
4031 wpabuf_free(conf
->civic
);
4034 } else if (os_strcmp(buf
, "rrm_neighbor_report") == 0) {
4036 bss
->radio_measurements
[0] |=
4037 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
4038 } else if (os_strcmp(buf
, "rrm_beacon_report") == 0) {
4040 bss
->radio_measurements
[0] |=
4041 WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE
|
4042 WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE
|
4043 WLAN_RRM_CAPS_BEACON_REPORT_TABLE
;
4044 } else if (os_strcmp(buf
, "gas_address3") == 0) {
4045 bss
->gas_address3
= atoi(pos
);
4046 } else if (os_strcmp(buf
, "stationary_ap") == 0) {
4047 conf
->stationary_ap
= atoi(pos
);
4048 } else if (os_strcmp(buf
, "ftm_responder") == 0) {
4049 bss
->ftm_responder
= atoi(pos
);
4050 } else if (os_strcmp(buf
, "ftm_initiator") == 0) {
4051 bss
->ftm_initiator
= atoi(pos
);
4053 } else if (os_strcmp(buf
, "fils_cache_id") == 0) {
4054 if (hexstr2bin(pos
, bss
->fils_cache_id
, FILS_CACHE_ID_LEN
)) {
4055 wpa_printf(MSG_ERROR
,
4056 "Line %d: Invalid fils_cache_id '%s'",
4060 bss
->fils_cache_id_set
= 1;
4061 } else if (os_strcmp(buf
, "fils_realm") == 0) {
4062 if (parse_fils_realm(bss
, pos
) < 0)
4064 } else if (os_strcmp(buf
, "fils_dh_group") == 0) {
4065 bss
->fils_dh_group
= atoi(pos
);
4066 } else if (os_strcmp(buf
, "dhcp_server") == 0) {
4067 if (hostapd_parse_ip_addr(pos
, &bss
->dhcp_server
)) {
4068 wpa_printf(MSG_ERROR
,
4069 "Line %d: invalid IP address '%s'",
4073 } else if (os_strcmp(buf
, "dhcp_rapid_commit_proxy") == 0) {
4074 bss
->dhcp_rapid_commit_proxy
= atoi(pos
);
4075 } else if (os_strcmp(buf
, "fils_hlp_wait_time") == 0) {
4076 bss
->fils_hlp_wait_time
= atoi(pos
);
4077 } else if (os_strcmp(buf
, "dhcp_server_port") == 0) {
4078 bss
->dhcp_server_port
= atoi(pos
);
4079 } else if (os_strcmp(buf
, "dhcp_relay_port") == 0) {
4080 bss
->dhcp_relay_port
= atoi(pos
);
4081 #endif /* CONFIG_FILS */
4082 } else if (os_strcmp(buf
, "multicast_to_unicast") == 0) {
4083 bss
->multicast_to_unicast
= atoi(pos
);
4084 } else if (os_strcmp(buf
, "broadcast_deauth") == 0) {
4085 bss
->broadcast_deauth
= atoi(pos
);
4087 } else if (os_strcmp(buf
, "dpp_connector") == 0) {
4088 os_free(bss
->dpp_connector
);
4089 bss
->dpp_connector
= os_strdup(pos
);
4090 } else if (os_strcmp(buf
, "dpp_netaccesskey") == 0) {
4091 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_netaccesskey
, pos
))
4093 } else if (os_strcmp(buf
, "dpp_netaccesskey_expiry") == 0) {
4094 bss
->dpp_netaccesskey_expiry
= strtol(pos
, NULL
, 0);
4095 } else if (os_strcmp(buf
, "dpp_csign") == 0) {
4096 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_csign
, pos
))
4098 #endif /* CONFIG_DPP */
4100 } else if (os_strcmp(buf
, "owe_transition_bssid") == 0) {
4101 if (hwaddr_aton(pos
, bss
->owe_transition_bssid
)) {
4102 wpa_printf(MSG_ERROR
,
4103 "Line %d: invalid owe_transition_bssid",
4107 } else if (os_strcmp(buf
, "owe_transition_ssid") == 0) {
4109 char *str
= wpa_config_parse_string(pos
, &slen
);
4111 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
4112 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
4117 os_memcpy(bss
->owe_transition_ssid
, str
, slen
);
4118 bss
->owe_transition_ssid_len
= slen
;
4120 } else if (os_strcmp(buf
, "owe_transition_ifname") == 0) {
4121 os_strlcpy(bss
->owe_transition_ifname
, pos
,
4122 sizeof(bss
->owe_transition_ifname
));
4123 } else if (os_strcmp(buf
, "owe_groups") == 0) {
4124 if (hostapd_parse_intlist(&bss
->owe_groups
, pos
)) {
4125 wpa_printf(MSG_ERROR
,
4126 "Line %d: Invalid owe_groups value '%s'",
4130 } else if (os_strcmp(buf
, "coloc_intf_reporting") == 0) {
4131 bss
->coloc_intf_reporting
= atoi(pos
);
4132 #endif /* CONFIG_OWE */
4134 wpa_printf(MSG_ERROR
,
4135 "Line %d: unknown configuration item '%s'",
4145 * hostapd_config_read - Read and parse a configuration file
4146 * @fname: Configuration file name (including path, if needed)
4147 * Returns: Allocated configuration data structure
4149 struct hostapd_config
* hostapd_config_read(const char *fname
)
4151 struct hostapd_config
*conf
;
4153 char buf
[4096], *pos
;
4158 f
= fopen(fname
, "r");
4160 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
4161 "for reading.", fname
);
4165 conf
= hostapd_config_defaults();
4171 /* set default driver based on configuration */
4172 conf
->driver
= wpa_drivers
[0];
4173 if (conf
->driver
== NULL
) {
4174 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
4175 hostapd_config_free(conf
);
4180 conf
->last_bss
= conf
->bss
[0];
4182 while (fgets(buf
, sizeof(buf
), f
)) {
4183 struct hostapd_bss_config
*bss
;
4185 bss
= conf
->last_bss
;
4191 while (*pos
!= '\0') {
4201 pos
= os_strchr(buf
, '=');
4203 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
4210 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
4215 for (i
= 0; i
< conf
->num_bss
; i
++)
4216 hostapd_set_security_params(conf
->bss
[i
], 1);
4218 if (hostapd_config_check(conf
, 1))
4221 #ifndef WPA_IGNORE_CONFIG_ERRORS
4223 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
4224 "'%s'", errors
, fname
);
4225 hostapd_config_free(conf
);
4228 #endif /* WPA_IGNORE_CONFIG_ERRORS */
4234 int hostapd_set_iface(struct hostapd_config
*conf
,
4235 struct hostapd_bss_config
*bss
, const char *field
,
4241 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
4243 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
4244 "to value '%s'", field
, value
);
4248 for (i
= 0; i
< conf
->num_bss
; i
++)
4249 hostapd_set_security_params(conf
->bss
[i
], 0);
4251 if (hostapd_config_check(conf
, 0)) {
4252 wpa_printf(MSG_ERROR
, "Configuration check failed");