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_VLAN
28 static int hostapd_config_read_vlan_file(struct hostapd_bss_config
*bss
,
32 char buf
[128], *pos
, *pos2
, *pos3
;
33 int line
= 0, vlan_id
;
34 struct hostapd_vlan
*vlan
;
36 f
= fopen(fname
, "r");
38 wpa_printf(MSG_ERROR
, "VLAN file '%s' not readable.", fname
);
42 while (fgets(buf
, sizeof(buf
), f
)) {
48 while (*pos
!= '\0') {
59 vlan_id
= VLAN_ID_WILDCARD
;
62 vlan_id
= strtol(buf
, &pos
, 10);
63 if (buf
== pos
|| vlan_id
< 1 ||
64 vlan_id
> MAX_VLAN_ID
) {
65 wpa_printf(MSG_ERROR
, "Invalid VLAN ID at "
66 "line %d in '%s'", line
, fname
);
72 while (*pos
== ' ' || *pos
== '\t')
75 while (*pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '\0')
81 if (*pos
== '\0' || os_strlen(pos
) > IFNAMSIZ
) {
82 wpa_printf(MSG_ERROR
, "Invalid VLAN ifname at line %d "
83 "in '%s'", line
, fname
);
88 while (*pos2
== ' ' || *pos2
== '\t')
91 while (*pos3
!= ' ' && *pos3
!= '\t' && *pos3
!= '\0')
95 vlan
= os_zalloc(sizeof(*vlan
));
97 wpa_printf(MSG_ERROR
, "Out of memory while reading "
98 "VLAN interfaces from '%s'", fname
);
103 vlan
->vlan_id
= vlan_id
;
104 vlan
->vlan_desc
.untagged
= vlan_id
;
105 vlan
->vlan_desc
.notempty
= !!vlan_id
;
106 os_strlcpy(vlan
->ifname
, pos
, sizeof(vlan
->ifname
));
107 os_strlcpy(vlan
->bridge
, pos2
, sizeof(vlan
->bridge
));
108 vlan
->next
= bss
->vlan
;
116 #endif /* CONFIG_NO_VLAN */
119 int hostapd_acl_comp(const void *a
, const void *b
)
121 const struct mac_acl_entry
*aa
= a
;
122 const struct mac_acl_entry
*bb
= b
;
123 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
127 int hostapd_add_acl_maclist(struct mac_acl_entry
**acl
, int *num
,
128 int vlan_id
, const u8
*addr
)
130 struct mac_acl_entry
*newacl
;
132 newacl
= os_realloc_array(*acl
, *num
+ 1, sizeof(**acl
));
134 wpa_printf(MSG_ERROR
, "MAC list reallocation failed");
139 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
140 os_memset(&(*acl
)[*num
].vlan_id
, 0, sizeof((*acl
)[*num
].vlan_id
));
141 (*acl
)[*num
].vlan_id
.untagged
= vlan_id
;
142 (*acl
)[*num
].vlan_id
.notempty
= !!vlan_id
;
149 void hostapd_remove_acl_mac(struct mac_acl_entry
**acl
, int *num
,
155 if (os_memcmp((*acl
)[i
].addr
, addr
, ETH_ALEN
) == 0) {
156 os_remove_in_array(*acl
, *num
, sizeof(**acl
), i
);
165 static int hostapd_config_read_maclist(const char *fname
,
166 struct mac_acl_entry
**acl
, int *num
)
174 f
= fopen(fname
, "r");
176 wpa_printf(MSG_ERROR
, "MAC list file '%s' not found.", fname
);
180 while (fgets(buf
, sizeof(buf
), f
)) {
188 while (*pos
!= '\0') {
203 if (hwaddr_aton(pos
, addr
)) {
204 wpa_printf(MSG_ERROR
, "Invalid MAC address '%s' at "
205 "line %d in '%s'", pos
, line
, fname
);
211 hostapd_remove_acl_mac(acl
, num
, addr
);
216 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
218 while (*pos
== ' ' || *pos
== '\t')
223 if (hostapd_add_acl_maclist(acl
, num
, vlan_id
, addr
) < 0) {
232 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
240 static int hostapd_config_eap_user_salted(struct hostapd_eap_user
*user
,
241 const char *hash
, size_t len
,
242 char **pos
, int line
,
247 while (*pos2
!= '\0' && *pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '#')
250 if (pos2
- *pos
< (int) (2 * (len
+ 1))) { /* at least 1 byte of salt */
251 wpa_printf(MSG_ERROR
,
252 "Invalid salted %s hash on line %d in '%s'",
257 user
->password
= os_malloc(len
);
258 if (!user
->password
) {
259 wpa_printf(MSG_ERROR
,
260 "Failed to allocate memory for salted %s hash",
265 if (hexstr2bin(*pos
, user
->password
, len
) < 0) {
266 wpa_printf(MSG_ERROR
,
267 "Invalid salted password on line %d in '%s'",
271 user
->password_len
= len
;
274 user
->salt_len
= (pos2
- *pos
) / 2;
275 user
->salt
= os_malloc(user
->salt_len
);
277 wpa_printf(MSG_ERROR
,
278 "Failed to allocate memory for salted %s hash",
283 if (hexstr2bin(*pos
, user
->salt
, user
->salt_len
) < 0) {
284 wpa_printf(MSG_ERROR
,
285 "Invalid salt for password on line %d in '%s'",
295 static int hostapd_config_read_eap_user(const char *fname
,
296 struct hostapd_bss_config
*conf
)
299 char buf
[512], *pos
, *start
, *pos2
;
300 int line
= 0, ret
= 0, num_methods
;
301 struct hostapd_eap_user
*user
= NULL
, *tail
= NULL
, *new_user
= NULL
;
303 if (os_strncmp(fname
, "sqlite:", 7) == 0) {
305 os_free(conf
->eap_user_sqlite
);
306 conf
->eap_user_sqlite
= os_strdup(fname
+ 7);
308 #else /* CONFIG_SQLITE */
309 wpa_printf(MSG_ERROR
,
310 "EAP user file in SQLite DB, but CONFIG_SQLITE was not enabled in the build.");
312 #endif /* CONFIG_SQLITE */
315 f
= fopen(fname
, "r");
317 wpa_printf(MSG_ERROR
, "EAP user file '%s' not found.", fname
);
321 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
322 while (fgets(buf
, sizeof(buf
), f
)) {
328 while (*pos
!= '\0') {
338 #ifndef CONFIG_NO_RADIUS
339 if (user
&& os_strncmp(buf
, "radius_accept_attr=", 19) == 0) {
340 struct hostapd_radius_attr
*attr
, *a
;
341 attr
= hostapd_parse_radius_attr(buf
+ 19);
343 wpa_printf(MSG_ERROR
, "Invalid radius_auth_req_attr: %s",
345 user
= NULL
; /* already in the BSS list */
348 if (user
->accept_attr
== NULL
) {
349 user
->accept_attr
= attr
;
351 a
= user
->accept_attr
;
358 #endif /* CONFIG_NO_RADIUS */
362 if (buf
[0] != '"' && buf
[0] != '*') {
363 wpa_printf(MSG_ERROR
, "Invalid EAP identity (no \" in "
364 "start) on line %d in '%s'", line
, fname
);
368 user
= os_zalloc(sizeof(*user
));
370 wpa_printf(MSG_ERROR
, "EAP user allocation failed");
373 user
->force_version
= -1;
380 while (*pos
!= '"' && *pos
!= '\0')
383 wpa_printf(MSG_ERROR
, "Invalid EAP identity "
384 "(no \" in end) on line %d in '%s'",
389 user
->identity
= os_memdup(start
, pos
- start
);
390 if (user
->identity
== NULL
) {
391 wpa_printf(MSG_ERROR
, "Failed to allocate "
392 "memory for EAP identity");
395 user
->identity_len
= pos
- start
;
397 if (pos
[0] == '"' && pos
[1] == '*') {
398 user
->wildcard_prefix
= 1;
403 while (*pos
== ' ' || *pos
== '\t')
407 wpa_printf(MSG_ERROR
, "No EAP method on line %d in "
408 "'%s'", line
, fname
);
413 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
423 char *pos3
= os_strchr(start
, ',');
427 user
->methods
[num_methods
].method
=
430 &user
->methods
[num_methods
].vendor
);
431 if (user
->methods
[num_methods
].vendor
==
433 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
435 if (os_strcmp(start
, "TTLS-PAP") == 0) {
436 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
439 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
440 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
443 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
445 EAP_TTLS_AUTH_MSCHAP
;
448 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
450 EAP_TTLS_AUTH_MSCHAPV2
;
453 if (os_strcmp(start
, "MACACL") == 0) {
457 wpa_printf(MSG_ERROR
, "Unsupported EAP type "
458 "'%s' on line %d in '%s'",
464 if (num_methods
>= EAP_MAX_METHODS
)
471 if (num_methods
== 0 && user
->ttls_auth
== 0 && !user
->macacl
) {
472 wpa_printf(MSG_ERROR
, "No EAP types configured on "
473 "line %d in '%s'", line
, fname
);
480 while (*pos
== ' ' || *pos
== '\t')
485 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
486 user
->force_version
= 0;
490 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
491 user
->force_version
= 1;
495 if (os_strncmp(pos
, "[2]", 3) == 0) {
503 while (*pos
!= '"' && *pos
!= '\0')
506 wpa_printf(MSG_ERROR
, "Invalid EAP password "
507 "(no \" in end) on line %d in '%s'",
512 user
->password
= os_memdup(start
, pos
- start
);
513 if (user
->password
== NULL
) {
514 wpa_printf(MSG_ERROR
, "Failed to allocate "
515 "memory for EAP password");
518 user
->password_len
= pos
- start
;
521 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
524 while (*pos2
!= '\0' && *pos2
!= ' ' &&
525 *pos2
!= '\t' && *pos2
!= '#')
527 if (pos2
- pos
!= 32) {
528 wpa_printf(MSG_ERROR
, "Invalid password hash "
529 "on line %d in '%s'", line
, fname
);
532 user
->password
= os_malloc(16);
533 if (user
->password
== NULL
) {
534 wpa_printf(MSG_ERROR
, "Failed to allocate "
535 "memory for EAP password hash");
538 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
539 wpa_printf(MSG_ERROR
, "Invalid hash password "
540 "on line %d in '%s'", line
, fname
);
543 user
->password_len
= 16;
544 user
->password_hash
= 1;
546 } else if (os_strncmp(pos
, "ssha1:", 6) == 0) {
548 if (hostapd_config_eap_user_salted(user
, "sha1", 20,
552 } else if (os_strncmp(pos
, "ssha256:", 8) == 0) {
554 if (hostapd_config_eap_user_salted(user
, "sha256", 32,
558 } else if (os_strncmp(pos
, "ssha512:", 8) == 0) {
560 if (hostapd_config_eap_user_salted(user
, "sha512", 64,
566 while (*pos2
!= '\0' && *pos2
!= ' ' &&
567 *pos2
!= '\t' && *pos2
!= '#')
569 if ((pos2
- pos
) & 1) {
570 wpa_printf(MSG_ERROR
, "Invalid hex password "
571 "on line %d in '%s'", line
, fname
);
574 user
->password
= os_malloc((pos2
- pos
) / 2);
575 if (user
->password
== NULL
) {
576 wpa_printf(MSG_ERROR
, "Failed to allocate "
577 "memory for EAP password");
580 if (hexstr2bin(pos
, user
->password
,
581 (pos2
- pos
) / 2) < 0) {
582 wpa_printf(MSG_ERROR
, "Invalid hex password "
583 "on line %d in '%s'", line
, fname
);
586 user
->password_len
= (pos2
- pos
) / 2;
590 while (*pos
== ' ' || *pos
== '\t')
592 if (os_strncmp(pos
, "[2]", 3) == 0) {
598 tail
= new_user
= user
;
607 hostapd_config_free_eap_user(user
);
615 hostapd_config_free_eap_users(conf
->eap_user
);
616 conf
->eap_user
= new_user
;
618 hostapd_config_free_eap_users(new_user
);
624 #endif /* EAP_SERVER */
627 #ifndef CONFIG_NO_RADIUS
629 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
630 int *num_server
, const char *val
, int def_port
,
631 struct hostapd_radius_server
**curr_serv
)
633 struct hostapd_radius_server
*nserv
;
635 static int server_index
= 1;
637 nserv
= os_realloc_array(*server
, *num_server
+ 1, sizeof(*nserv
));
642 nserv
= &nserv
[*num_server
];
644 (*curr_serv
) = nserv
;
646 os_memset(nserv
, 0, sizeof(*nserv
));
647 nserv
->port
= def_port
;
648 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
649 nserv
->index
= server_index
++;
656 static int hostapd_parse_das_client(struct hostapd_bss_config
*bss
, char *val
)
660 secret
= os_strchr(val
, ' ');
666 if (hostapd_parse_ip_addr(val
, &bss
->radius_das_client_addr
))
669 os_free(bss
->radius_das_shared_secret
);
670 bss
->radius_das_shared_secret
= (u8
*) os_strdup(secret
);
671 if (bss
->radius_das_shared_secret
== NULL
)
673 bss
->radius_das_shared_secret_len
= os_strlen(secret
);
677 #endif /* CONFIG_NO_RADIUS */
680 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
683 char *start
, *end
, *buf
;
685 buf
= os_strdup(value
);
690 while (*start
!= '\0') {
691 while (*start
== ' ' || *start
== '\t')
696 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
700 if (os_strcmp(start
, "WPA-PSK") == 0)
701 val
|= WPA_KEY_MGMT_PSK
;
702 else if (os_strcmp(start
, "WPA-EAP") == 0)
703 val
|= WPA_KEY_MGMT_IEEE8021X
;
704 #ifdef CONFIG_IEEE80211R_AP
705 else if (os_strcmp(start
, "FT-PSK") == 0)
706 val
|= WPA_KEY_MGMT_FT_PSK
;
707 else if (os_strcmp(start
, "FT-EAP") == 0)
708 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
710 else if (os_strcmp(start
, "FT-EAP-SHA384") == 0)
711 val
|= WPA_KEY_MGMT_FT_IEEE8021X_SHA384
;
712 #endif /* CONFIG_SHA384 */
713 #endif /* CONFIG_IEEE80211R_AP */
714 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
715 val
|= WPA_KEY_MGMT_PSK_SHA256
;
716 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
717 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
719 else if (os_strcmp(start
, "SAE") == 0)
720 val
|= WPA_KEY_MGMT_SAE
;
721 else if (os_strcmp(start
, "FT-SAE") == 0)
722 val
|= WPA_KEY_MGMT_FT_SAE
;
723 #endif /* CONFIG_SAE */
725 else if (os_strcmp(start
, "WPA-EAP-SUITE-B") == 0)
726 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B
;
727 #endif /* CONFIG_SUITEB */
728 #ifdef CONFIG_SUITEB192
729 else if (os_strcmp(start
, "WPA-EAP-SUITE-B-192") == 0)
730 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192
;
731 #endif /* CONFIG_SUITEB192 */
733 else if (os_strcmp(start
, "FILS-SHA256") == 0)
734 val
|= WPA_KEY_MGMT_FILS_SHA256
;
735 else if (os_strcmp(start
, "FILS-SHA384") == 0)
736 val
|= WPA_KEY_MGMT_FILS_SHA384
;
737 #ifdef CONFIG_IEEE80211R_AP
738 else if (os_strcmp(start
, "FT-FILS-SHA256") == 0)
739 val
|= WPA_KEY_MGMT_FT_FILS_SHA256
;
740 else if (os_strcmp(start
, "FT-FILS-SHA384") == 0)
741 val
|= WPA_KEY_MGMT_FT_FILS_SHA384
;
742 #endif /* CONFIG_IEEE80211R_AP */
743 #endif /* CONFIG_FILS */
745 else if (os_strcmp(start
, "OWE") == 0)
746 val
|= WPA_KEY_MGMT_OWE
;
747 #endif /* CONFIG_OWE */
749 else if (os_strcmp(start
, "DPP") == 0)
750 val
|= WPA_KEY_MGMT_DPP
;
751 #endif /* CONFIG_DPP */
753 else if (os_strcmp(start
, "OSEN") == 0)
754 val
|= WPA_KEY_MGMT_OSEN
;
755 #endif /* CONFIG_HS20 */
757 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
770 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
771 "configured.", line
);
779 static int hostapd_config_parse_cipher(int line
, const char *value
)
781 int val
= wpa_parse_cipher(value
);
783 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
788 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
796 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
799 size_t len
= os_strlen(val
);
801 if (keyidx
< 0 || keyidx
> 3)
807 bin_clear_free(wep
->key
[keyidx
], wep
->len
[keyidx
]);
808 wep
->key
[keyidx
] = NULL
;
809 wep
->len
[keyidx
] = 0;
810 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
819 if (wep
->key
[keyidx
] != NULL
)
823 if (len
< 2 || val
[len
- 1] != '"')
826 wep
->key
[keyidx
] = os_memdup(val
+ 1, len
);
827 if (wep
->key
[keyidx
] == NULL
)
829 wep
->len
[keyidx
] = len
;
834 wep
->key
[keyidx
] = os_malloc(len
);
835 if (wep
->key
[keyidx
] == NULL
)
837 wep
->len
[keyidx
] = len
;
838 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
848 static int hostapd_parse_chanlist(struct hostapd_config
*conf
, char *val
)
852 /* for backwards compatibility, translate ' ' in conf str to ',' */
855 pos
= os_strchr(pos
, ' ');
859 if (freq_range_list_parse(&conf
->acs_ch_list
, val
))
866 static int hostapd_parse_intlist(int **int_list
, char *val
)
877 while (*pos
!= '\0') {
883 list
= os_malloc(sizeof(int) * (count
+ 2));
888 while (*pos
!= '\0') {
889 end
= os_strchr(pos
, ' ');
893 list
[count
++] = atoi(pos
);
905 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
907 struct hostapd_bss_config
**all
, *bss
;
912 all
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
913 sizeof(struct hostapd_bss_config
*));
915 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
921 bss
= os_zalloc(sizeof(*bss
));
924 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
925 if (bss
->radius
== NULL
) {
926 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
927 "multi-BSS RADIUS data");
932 conf
->bss
[conf
->num_bss
++] = bss
;
933 conf
->last_bss
= bss
;
935 hostapd_config_defaults_bss(bss
);
936 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
937 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
943 /* convert floats with one decimal place to value*10 int, i.e.,
944 * "1.5" will return 15 */
945 static int hostapd_config_read_int10(const char *value
)
951 pos
= os_strchr(value
, '.');
955 if (*pos
>= '0' && *pos
<= '9')
963 static int valid_cw(int cw
)
965 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
966 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023 ||
967 cw
== 2047 || cw
== 4095 || cw
== 8191 || cw
== 16383 ||
973 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
974 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
975 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
976 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
979 static int hostapd_config_tx_queue(struct hostapd_config
*conf
,
980 const char *name
, const char *val
)
984 struct hostapd_tx_queue_params
*queue
;
986 /* skip 'tx_queue_' prefix */
988 if (os_strncmp(pos
, "data", 4) == 0 &&
989 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
992 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
993 os_strncmp(pos
, "beacon_", 7) == 0) {
994 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
997 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
1001 if (num
>= NUM_TX_QUEUES
) {
1002 /* for backwards compatibility, do not trigger failure */
1003 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
1007 queue
= &conf
->tx_queue
[num
];
1009 if (os_strcmp(pos
, "aifs") == 0) {
1010 queue
->aifs
= atoi(val
);
1011 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
1012 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
1016 } else if (os_strcmp(pos
, "cwmin") == 0) {
1017 queue
->cwmin
= atoi(val
);
1018 if (!valid_cw(queue
->cwmin
)) {
1019 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
1023 } else if (os_strcmp(pos
, "cwmax") == 0) {
1024 queue
->cwmax
= atoi(val
);
1025 if (!valid_cw(queue
->cwmax
)) {
1026 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
1030 } else if (os_strcmp(pos
, "burst") == 0) {
1031 queue
->burst
= hostapd_config_read_int10(val
);
1033 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
1041 #ifdef CONFIG_IEEE80211R_AP
1043 static int rkh_derive_key(const char *pos
, u8
*key
, size_t key_len
)
1048 if (!hexstr2bin(pos
, key
, key_len
))
1051 /* Try to use old short key for backwards compatibility */
1052 if (hexstr2bin(pos
, oldkey
, sizeof(oldkey
)))
1055 ret
= hmac_sha256_kdf(oldkey
, sizeof(oldkey
), "FT OLDKEY", NULL
, 0,
1057 os_memset(oldkey
, 0, sizeof(oldkey
));
1062 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
1064 struct ft_remote_r0kh
*r0kh
;
1067 r0kh
= os_zalloc(sizeof(*r0kh
));
1071 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1073 next
= os_strchr(pos
, ' ');
1076 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
1077 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
1083 next
= os_strchr(pos
, ' ');
1086 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
1087 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
1091 r0kh
->id_len
= next
- pos
- 1;
1092 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
1095 if (rkh_derive_key(pos
, r0kh
->key
, sizeof(r0kh
->key
)) < 0) {
1096 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
1101 r0kh
->next
= bss
->r0kh_list
;
1102 bss
->r0kh_list
= r0kh
;
1108 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
1110 struct ft_remote_r1kh
*r1kh
;
1113 r1kh
= os_zalloc(sizeof(*r1kh
));
1117 /* 02:01:02:03:04:05 02:01:02:03:04:05
1118 * 000102030405060708090a0b0c0d0e0f */
1120 next
= os_strchr(pos
, ' ');
1123 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
1124 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
1130 next
= os_strchr(pos
, ' ');
1133 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
1134 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
1140 if (rkh_derive_key(pos
, r1kh
->key
, sizeof(r1kh
->key
)) < 0) {
1141 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
1146 r1kh
->next
= bss
->r1kh_list
;
1147 bss
->r1kh_list
= r1kh
;
1151 #endif /* CONFIG_IEEE80211R_AP */
1154 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
1157 if (os_strstr(capab
, "[LDPC]"))
1158 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
1159 if (os_strstr(capab
, "[HT40-]")) {
1160 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1161 conf
->secondary_channel
= -1;
1163 if (os_strstr(capab
, "[HT40+]")) {
1164 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1165 conf
->secondary_channel
= 1;
1167 if (os_strstr(capab
, "[HT40+]") && os_strstr(capab
, "[HT40-]")) {
1168 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1169 conf
->ht40_plus_minus_allowed
= 1;
1171 if (!os_strstr(capab
, "[HT40+]") && !os_strstr(capab
, "[HT40-]"))
1172 conf
->secondary_channel
= 0;
1173 if (os_strstr(capab
, "[GF]"))
1174 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
1175 if (os_strstr(capab
, "[SHORT-GI-20]"))
1176 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1177 if (os_strstr(capab
, "[SHORT-GI-40]"))
1178 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1179 if (os_strstr(capab
, "[TX-STBC]"))
1180 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1181 if (os_strstr(capab
, "[RX-STBC1]")) {
1182 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1183 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1185 if (os_strstr(capab
, "[RX-STBC12]")) {
1186 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1187 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1189 if (os_strstr(capab
, "[RX-STBC123]")) {
1190 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1191 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1193 if (os_strstr(capab
, "[DELAYED-BA]"))
1194 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1195 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1196 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1197 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1198 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1199 if (os_strstr(capab
, "[40-INTOLERANT]"))
1200 conf
->ht_capab
|= HT_CAP_INFO_40MHZ_INTOLERANT
;
1201 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1202 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1208 #ifdef CONFIG_IEEE80211AC
1209 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1212 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1213 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1214 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1215 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1216 if (os_strstr(capab
, "[VHT160]"))
1217 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1218 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1219 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1220 if (os_strstr(capab
, "[RXLDPC]"))
1221 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1222 if (os_strstr(capab
, "[SHORT-GI-80]"))
1223 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1224 if (os_strstr(capab
, "[SHORT-GI-160]"))
1225 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1226 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1227 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1228 if (os_strstr(capab
, "[RX-STBC-1]"))
1229 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1230 if (os_strstr(capab
, "[RX-STBC-12]"))
1231 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1232 if (os_strstr(capab
, "[RX-STBC-123]"))
1233 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1234 if (os_strstr(capab
, "[RX-STBC-1234]"))
1235 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1236 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1237 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMER_CAPABLE
;
1238 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1239 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
1240 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1241 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1242 conf
->vht_capab
|= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1243 if (os_strstr(capab
, "[BF-ANTENNA-3]") &&
1244 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1245 conf
->vht_capab
|= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1246 if (os_strstr(capab
, "[BF-ANTENNA-4]") &&
1247 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1248 conf
->vht_capab
|= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1249 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1250 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1251 conf
->vht_capab
|= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1252 if (os_strstr(capab
, "[SOUNDING-DIMENSION-3]") &&
1253 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1254 conf
->vht_capab
|= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1255 if (os_strstr(capab
, "[SOUNDING-DIMENSION-4]") &&
1256 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1257 conf
->vht_capab
|= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1258 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1259 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1260 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1261 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1262 if (os_strstr(capab
, "[HTC-VHT]"))
1263 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1264 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP7]"))
1265 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX
;
1266 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP6]"))
1267 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6
;
1268 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP5]"))
1269 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5
;
1270 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP4]"))
1271 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4
;
1272 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP3]"))
1273 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3
;
1274 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP2]"))
1275 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2
;
1276 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP1]"))
1277 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1
;
1278 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1279 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1280 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1281 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1282 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1283 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1284 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1285 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1286 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1287 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1290 #endif /* CONFIG_IEEE80211AC */
1293 #ifdef CONFIG_IEEE80211AX
1295 static u8
find_bit_offset(u8 val
)
1299 for (; val
; val
>>= 1) {
1309 static u8
set_he_cap(int val
, u8 mask
)
1311 return (u8
) (mask
& (val
<< find_bit_offset(mask
)));
1314 #endif /* CONFIG_IEEE80211AX */
1317 #ifdef CONFIG_INTERWORKING
1318 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1321 size_t len
= os_strlen(pos
);
1322 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1324 struct hostapd_roaming_consortium
*rc
;
1326 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1327 hexstr2bin(pos
, oi
, len
/ 2)) {
1328 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1334 rc
= os_realloc_array(bss
->roaming_consortium
,
1335 bss
->roaming_consortium_count
+ 1,
1336 sizeof(struct hostapd_roaming_consortium
));
1340 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1341 rc
[bss
->roaming_consortium_count
].len
= len
;
1343 bss
->roaming_consortium
= rc
;
1344 bss
->roaming_consortium_count
++;
1350 static int parse_lang_string(struct hostapd_lang_string
**array
,
1351 unsigned int *count
, char *pos
)
1353 char *sep
, *str
= NULL
;
1354 size_t clen
, nlen
, slen
;
1355 struct hostapd_lang_string
*ls
;
1358 if (*pos
== '"' || (*pos
== 'P' && pos
[1] == '"')) {
1359 str
= wpa_config_parse_string(pos
, &slen
);
1365 sep
= os_strchr(pos
, ':');
1370 clen
= os_strlen(pos
);
1371 if (clen
< 2 || clen
> sizeof(ls
->lang
))
1373 nlen
= os_strlen(sep
);
1377 ls
= os_realloc_array(*array
, *count
+ 1,
1378 sizeof(struct hostapd_lang_string
));
1383 ls
= &(*array
)[*count
];
1386 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1387 os_memcpy(ls
->lang
, pos
, clen
);
1388 ls
->name_len
= nlen
;
1389 os_memcpy(ls
->name
, sep
, nlen
);
1398 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1401 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1402 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1410 static int parse_venue_url(struct hostapd_bss_config
*bss
, char *pos
,
1415 struct hostapd_venue_url
*url
;
1418 sep
= os_strchr(pos
, ':');
1423 nlen
= os_strlen(sep
);
1427 url
= os_realloc_array(bss
->venue_url
, bss
->venue_url_count
+ 1,
1428 sizeof(struct hostapd_venue_url
));
1432 bss
->venue_url
= url
;
1433 url
= &bss
->venue_url
[bss
->venue_url_count
++];
1435 url
->venue_number
= atoi(pos
);
1436 url
->url_len
= nlen
;
1437 os_memcpy(url
->url
, sep
, nlen
);
1442 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_url '%s'",
1448 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1453 u8
*info
= NULL
, *ipos
;
1455 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1458 for (pos
= buf
; *pos
; pos
++) {
1459 if ((*pos
< '0' || *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1464 if (1 + count
* 3 > 0x7f)
1467 info
= os_zalloc(2 + 3 + count
* 3);
1472 *ipos
++ = 0; /* GUD - Version 1 */
1473 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1474 *ipos
++ = 0; /* PLMN List IEI */
1475 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1476 *ipos
++ = 1 + count
* 3;
1477 *ipos
++ = count
; /* Number of PLMNs */
1480 while (pos
&& *pos
) {
1485 mnc
= os_strchr(pos
, ',');
1489 pos
= os_strchr(mnc
, ';');
1493 mnc_len
= os_strlen(mnc
);
1494 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1497 /* BC coded MCC,MNC */
1498 /* MCC digit 2 | MCC digit 1 */
1499 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1500 /* MNC digit 3 | MCC digit 3 */
1501 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1503 /* MNC digit 2 | MNC digit 1 */
1504 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1507 os_free(bss
->anqp_3gpp_cell_net
);
1508 bss
->anqp_3gpp_cell_net
= info
;
1509 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1510 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1511 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1516 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1523 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1525 struct hostapd_nai_realm_data
*realm
;
1528 char *pos
, *end
, *rpos
;
1530 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1532 if (offsets
== NULL
)
1535 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1536 realm
= &bss
->nai_realm_data
[i
];
1537 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1538 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1540 realm
->realm
[j
] - realm
->realm_buf
: -1;
1544 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1545 sizeof(struct hostapd_nai_realm_data
));
1546 if (realm
== NULL
) {
1550 bss
->nai_realm_data
= realm
;
1552 /* patch the pointers after realloc */
1553 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1554 realm
= &bss
->nai_realm_data
[i
];
1555 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1556 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1558 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1560 realm
->realm
[j
] = NULL
;
1565 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1566 os_memset(realm
, 0, sizeof(*realm
));
1569 realm
->encoding
= atoi(pos
);
1570 pos
= os_strchr(pos
, ',');
1575 end
= os_strchr(pos
, ',');
1580 len
= os_strlen(pos
);
1583 if (len
> MAX_NAI_REALMLEN
) {
1584 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1585 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1588 os_memcpy(realm
->realm_buf
, pos
, len
);
1595 while (pos
&& *pos
) {
1596 struct hostapd_nai_realm_eap
*eap
;
1598 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1599 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1603 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1604 realm
->eap_method_count
++;
1606 end
= os_strchr(pos
, ',');
1608 end
= pos
+ os_strlen(pos
);
1610 eap
->eap_method
= atoi(pos
);
1612 pos
= os_strchr(pos
, '[');
1613 if (pos
== NULL
|| pos
> end
)
1616 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1617 wpa_printf(MSG_ERROR
, "Too many auth params");
1620 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1621 pos
= os_strchr(pos
, ':');
1622 if (pos
== NULL
|| pos
> end
)
1625 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1626 pos
= os_strchr(pos
, ']');
1627 if (pos
== NULL
|| pos
> end
)
1639 /* Split realm list into null terminated realms */
1640 rpos
= realm
->realm_buf
;
1643 if (i
>= MAX_NAI_REALMS
) {
1644 wpa_printf(MSG_ERROR
, "Too many realms");
1647 realm
->realm
[i
++] = rpos
;
1648 rpos
= os_strchr(rpos
, ';');
1654 bss
->nai_realm_count
++;
1659 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1664 static int parse_anqp_elem(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1669 struct wpabuf
*payload
;
1670 struct anqp_element
*elem
;
1672 delim
= os_strchr(buf
, ':');
1677 len
= os_strlen(delim
);
1681 payload
= wpabuf_alloc(len
);
1684 if (hexstr2bin(delim
, wpabuf_put(payload
, len
), len
) < 0) {
1685 wpabuf_free(payload
);
1689 dl_list_for_each(elem
, &bss
->anqp_elem
, struct anqp_element
, list
) {
1690 if (elem
->infoid
== infoid
) {
1691 /* Update existing entry */
1692 wpabuf_free(elem
->payload
);
1693 elem
->payload
= payload
;
1698 /* Add a new entry */
1699 elem
= os_zalloc(sizeof(*elem
));
1701 wpabuf_free(payload
);
1704 elem
->infoid
= infoid
;
1705 elem
->payload
= payload
;
1706 dl_list_add(&bss
->anqp_elem
, &elem
->list
);
1712 static int parse_qos_map_set(struct hostapd_bss_config
*bss
,
1713 char *buf
, int line
)
1715 u8 qos_map_set
[16 + 2 * 21], count
= 0;
1720 if (count
== sizeof(qos_map_set
)) {
1721 wpa_printf(MSG_ERROR
, "Line %d: Too many qos_map_set "
1722 "parameters '%s'", line
, buf
);
1727 if (val
> 255 || val
< 0) {
1728 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set "
1733 qos_map_set
[count
++] = val
;
1734 pos
= os_strchr(pos
, ',');
1740 if (count
< 16 || count
& 1) {
1741 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set '%s'",
1746 os_memcpy(bss
->qos_map_set
, qos_map_set
, count
);
1747 bss
->qos_map_set_len
= count
;
1752 #endif /* CONFIG_INTERWORKING */
1756 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1762 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1765 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1766 bss
->hs20_connection_capability_len
+ 4);
1767 if (conn_cap
== NULL
)
1770 bss
->hs20_connection_capability
= conn_cap
;
1771 conn_cap
+= bss
->hs20_connection_capability_len
;
1773 conn_cap
[0] = atoi(pos
);
1774 pos
= os_strchr(pos
, ':');
1778 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1779 pos
= os_strchr(pos
, ':');
1783 conn_cap
[3] = atoi(pos
);
1784 bss
->hs20_connection_capability_len
+= 4;
1790 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1796 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1798 wan_metrics
= os_zalloc(13);
1799 if (wan_metrics
== NULL
)
1804 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1811 /* Downlink Speed */
1812 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1813 pos
= os_strchr(pos
, ':');
1819 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1820 pos
= os_strchr(pos
, ':');
1826 wan_metrics
[9] = atoi(pos
);
1827 pos
= os_strchr(pos
, ':');
1833 wan_metrics
[10] = atoi(pos
);
1834 pos
= os_strchr(pos
, ':');
1840 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1842 os_free(bss
->hs20_wan_metrics
);
1843 bss
->hs20_wan_metrics
= wan_metrics
;
1848 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1850 os_free(wan_metrics
);
1855 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1856 char *pos
, int line
)
1858 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1859 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1860 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1861 "hs20_oper_friendly_name '%s'", line
, pos
);
1868 static int hs20_parse_icon(struct hostapd_bss_config
*bss
, char *pos
)
1870 struct hs20_icon
*icon
;
1873 icon
= os_realloc_array(bss
->hs20_icons
, bss
->hs20_icons_count
+ 1,
1874 sizeof(struct hs20_icon
));
1877 bss
->hs20_icons
= icon
;
1878 icon
= &bss
->hs20_icons
[bss
->hs20_icons_count
];
1879 os_memset(icon
, 0, sizeof(*icon
));
1881 icon
->width
= atoi(pos
);
1882 pos
= os_strchr(pos
, ':');
1887 icon
->height
= atoi(pos
);
1888 pos
= os_strchr(pos
, ':');
1893 end
= os_strchr(pos
, ':');
1894 if (end
== NULL
|| end
- pos
> 3)
1896 os_memcpy(icon
->language
, pos
, end
- pos
);
1899 end
= os_strchr(pos
, ':');
1900 if (end
== NULL
|| end
- pos
> 255)
1902 os_memcpy(icon
->type
, pos
, end
- pos
);
1905 end
= os_strchr(pos
, ':');
1906 if (end
== NULL
|| end
- pos
> 255)
1908 os_memcpy(icon
->name
, pos
, end
- pos
);
1911 if (os_strlen(pos
) > 255)
1913 os_memcpy(icon
->file
, pos
, os_strlen(pos
));
1915 bss
->hs20_icons_count
++;
1921 static int hs20_parse_osu_ssid(struct hostapd_bss_config
*bss
,
1922 char *pos
, int line
)
1927 str
= wpa_config_parse_string(pos
, &slen
);
1928 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
1929 wpa_printf(MSG_ERROR
, "Line %d: Invalid SSID '%s'", line
, pos
);
1934 os_memcpy(bss
->osu_ssid
, str
, slen
);
1935 bss
->osu_ssid_len
= slen
;
1942 static int hs20_parse_osu_server_uri(struct hostapd_bss_config
*bss
,
1943 char *pos
, int line
)
1945 struct hs20_osu_provider
*p
;
1947 p
= os_realloc_array(bss
->hs20_osu_providers
,
1948 bss
->hs20_osu_providers_count
+ 1, sizeof(*p
));
1952 bss
->hs20_osu_providers
= p
;
1953 bss
->last_osu
= &bss
->hs20_osu_providers
[bss
->hs20_osu_providers_count
];
1954 bss
->hs20_osu_providers_count
++;
1955 os_memset(bss
->last_osu
, 0, sizeof(*p
));
1956 bss
->last_osu
->server_uri
= os_strdup(pos
);
1962 static int hs20_parse_osu_friendly_name(struct hostapd_bss_config
*bss
,
1963 char *pos
, int line
)
1965 if (bss
->last_osu
== NULL
) {
1966 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1970 if (parse_lang_string(&bss
->last_osu
->friendly_name
,
1971 &bss
->last_osu
->friendly_name_count
, pos
)) {
1972 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_friendly_name '%s'",
1981 static int hs20_parse_osu_nai(struct hostapd_bss_config
*bss
,
1982 char *pos
, int line
)
1984 if (bss
->last_osu
== NULL
) {
1985 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1989 os_free(bss
->last_osu
->osu_nai
);
1990 bss
->last_osu
->osu_nai
= os_strdup(pos
);
1991 if (bss
->last_osu
->osu_nai
== NULL
)
1998 static int hs20_parse_osu_nai2(struct hostapd_bss_config
*bss
,
1999 char *pos
, int line
)
2001 if (bss
->last_osu
== NULL
) {
2002 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2006 os_free(bss
->last_osu
->osu_nai2
);
2007 bss
->last_osu
->osu_nai2
= os_strdup(pos
);
2008 if (bss
->last_osu
->osu_nai2
== NULL
)
2010 bss
->hs20_osu_providers_nai_count
++;
2016 static int hs20_parse_osu_method_list(struct hostapd_bss_config
*bss
, char *pos
,
2019 if (bss
->last_osu
== NULL
) {
2020 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2024 if (hostapd_parse_intlist(&bss
->last_osu
->method_list
, pos
)) {
2025 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_method_list", line
);
2033 static int hs20_parse_osu_icon(struct hostapd_bss_config
*bss
, char *pos
,
2037 struct hs20_osu_provider
*p
= bss
->last_osu
;
2040 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2044 n
= os_realloc_array(p
->icons
, p
->icons_count
+ 1, sizeof(char *));
2048 p
->icons
[p
->icons_count
] = os_strdup(pos
);
2049 if (p
->icons
[p
->icons_count
] == NULL
)
2057 static int hs20_parse_osu_service_desc(struct hostapd_bss_config
*bss
,
2058 char *pos
, int line
)
2060 if (bss
->last_osu
== NULL
) {
2061 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2065 if (parse_lang_string(&bss
->last_osu
->service_desc
,
2066 &bss
->last_osu
->service_desc_count
, pos
)) {
2067 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_service_desc '%s'",
2076 static int hs20_parse_operator_icon(struct hostapd_bss_config
*bss
, char *pos
,
2081 n
= os_realloc_array(bss
->hs20_operator_icon
,
2082 bss
->hs20_operator_icon_count
+ 1, sizeof(char *));
2085 bss
->hs20_operator_icon
= n
;
2086 bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
] = os_strdup(pos
);
2087 if (!bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
])
2089 bss
->hs20_operator_icon_count
++;
2094 #endif /* CONFIG_HS20 */
2098 static int hostapd_config_parse_acs_chan_bias(struct hostapd_config
*conf
,
2101 struct acs_bias
*bias
= NULL
, *tmp
;
2102 unsigned int num
= 0;
2106 tmp
= os_realloc_array(bias
, num
+ 1, sizeof(*bias
));
2111 bias
[num
].channel
= atoi(pos
);
2112 if (bias
[num
].channel
<= 0)
2114 pos
= os_strchr(pos
, ':');
2118 bias
[num
].bias
= strtod(pos
, &end
);
2119 if (end
== pos
|| bias
[num
].bias
< 0.0)
2122 if (*pos
!= ' ' && *pos
!= '\0')
2127 os_free(conf
->acs_chan_bias
);
2128 conf
->acs_chan_bias
= bias
;
2129 conf
->num_acs_chan_bias
= num
;
2136 #endif /* CONFIG_ACS */
2139 static int parse_wpabuf_hex(int line
, const char *name
, struct wpabuf
**buf
,
2142 struct wpabuf
*elems
;
2144 if (val
[0] == '\0') {
2150 elems
= wpabuf_parse_bin(val
);
2152 wpa_printf(MSG_ERROR
, "Line %d: Invalid %s '%s'",
2165 static int parse_fils_realm(struct hostapd_bss_config
*bss
, const char *val
)
2167 struct fils_realm
*realm
;
2170 len
= os_strlen(val
);
2171 realm
= os_zalloc(sizeof(*realm
) + len
+ 1);
2175 os_memcpy(realm
->realm
, val
, len
);
2176 if (fils_domain_name_hash(val
, realm
->hash
) < 0) {
2180 dl_list_add_tail(&bss
->fils_realms
, &realm
->list
);
2184 #endif /* CONFIG_FILS */
2188 static unsigned int parse_tls_flags(const char *val
)
2190 unsigned int flags
= 0;
2192 /* Disable TLS v1.3 by default for now to avoid interoperability issue.
2193 * This can be enabled by default once the implementation has been fully
2194 * completed and tested with other implementations. */
2195 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2197 if (os_strstr(val
, "[ALLOW-SIGN-RSA-MD5]"))
2198 flags
|= TLS_CONN_ALLOW_SIGN_RSA_MD5
;
2199 if (os_strstr(val
, "[DISABLE-TIME-CHECKS]"))
2200 flags
|= TLS_CONN_DISABLE_TIME_CHECKS
;
2201 if (os_strstr(val
, "[DISABLE-TLSv1.0]"))
2202 flags
|= TLS_CONN_DISABLE_TLSv1_0
;
2203 if (os_strstr(val
, "[ENABLE-TLSv1.0]"))
2204 flags
|= TLS_CONN_ENABLE_TLSv1_0
;
2205 if (os_strstr(val
, "[DISABLE-TLSv1.1]"))
2206 flags
|= TLS_CONN_DISABLE_TLSv1_1
;
2207 if (os_strstr(val
, "[ENABLE-TLSv1.1]"))
2208 flags
|= TLS_CONN_ENABLE_TLSv1_1
;
2209 if (os_strstr(val
, "[DISABLE-TLSv1.2]"))
2210 flags
|= TLS_CONN_DISABLE_TLSv1_2
;
2211 if (os_strstr(val
, "[ENABLE-TLSv1.2]"))
2212 flags
|= TLS_CONN_ENABLE_TLSv1_2
;
2213 if (os_strstr(val
, "[DISABLE-TLSv1.3]"))
2214 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2215 if (os_strstr(val
, "[ENABLE-TLSv1.3]"))
2216 flags
&= ~TLS_CONN_DISABLE_TLSv1_3
;
2217 if (os_strstr(val
, "[SUITEB]"))
2218 flags
|= TLS_CONN_SUITEB
;
2219 if (os_strstr(val
, "[SUITEB-NO-ECDH]"))
2220 flags
|= TLS_CONN_SUITEB_NO_ECDH
| TLS_CONN_SUITEB
;
2224 #endif /* EAP_SERVER */
2227 #ifdef CONFIG_AIRTIME_POLICY
2228 static int add_airtime_weight(struct hostapd_bss_config
*bss
, char *value
)
2230 struct airtime_sta_weight
*wt
;
2233 wt
= os_zalloc(sizeof(*wt
));
2237 /* 02:01:02:03:04:05 10 */
2239 next
= os_strchr(pos
, ' ');
2242 if (!next
|| hwaddr_aton(pos
, wt
->addr
)) {
2243 wpa_printf(MSG_ERROR
, "Invalid station address: '%s'", pos
);
2249 wt
->weight
= atoi(pos
);
2251 wpa_printf(MSG_ERROR
, "Invalid weight: '%s'", pos
);
2256 wt
->next
= bss
->airtime_weight_list
;
2257 bss
->airtime_weight_list
= wt
;
2260 #endif /* CONFIG_AIRTIME_POLICY */
2264 static int parse_sae_password(struct hostapd_bss_config
*bss
, const char *val
)
2266 struct sae_password_entry
*pw
;
2267 const char *pos
= val
, *pos2
, *end
= NULL
;
2269 pw
= os_zalloc(sizeof(*pw
));
2272 os_memset(pw
->peer_addr
, 0xff, ETH_ALEN
); /* default to wildcard */
2274 pos2
= os_strstr(pos
, "|mac=");
2278 if (hwaddr_aton(pos2
, pw
->peer_addr
) < 0)
2280 pos
= pos2
+ ETH_ALEN
* 3 - 1;
2283 pos2
= os_strstr(pos
, "|vlanid=");
2288 pw
->vlan_id
= atoi(pos2
);
2291 pos2
= os_strstr(pos
, "|id=");
2296 pw
->identifier
= os_strdup(pos2
);
2297 if (!pw
->identifier
)
2302 pw
->password
= os_strdup(val
);
2306 pw
->password
= os_malloc(end
- val
+ 1);
2309 os_memcpy(pw
->password
, val
, end
- val
);
2310 pw
->password
[end
- val
] = '\0';
2313 pw
->next
= bss
->sae_passwords
;
2314 bss
->sae_passwords
= pw
;
2318 str_clear_free(pw
->password
);
2319 os_free(pw
->identifier
);
2323 #endif /* CONFIG_SAE */
2327 static int hostapd_dpp_controller_parse(struct hostapd_bss_config
*bss
,
2330 struct dpp_controller_conf
*conf
;
2333 conf
= os_zalloc(sizeof(*conf
));
2336 val
= get_param(pos
, "ipaddr=");
2337 if (!val
|| hostapd_parse_ip_addr(val
, &conf
->ipaddr
))
2340 val
= get_param(pos
, "pkhash=");
2341 if (!val
|| os_strlen(val
) != 2 * SHA256_MAC_LEN
||
2342 hexstr2bin(val
, conf
->pkhash
, SHA256_MAC_LEN
) < 0)
2345 conf
->next
= bss
->dpp_controller
;
2346 bss
->dpp_controller
= conf
;
2353 #endif /* CONFIG_DPP2 */
2356 static int hostapd_config_fill(struct hostapd_config
*conf
,
2357 struct hostapd_bss_config
*bss
,
2358 const char *buf
, char *pos
, int line
)
2360 if (os_strcmp(buf
, "interface") == 0) {
2361 os_strlcpy(conf
->bss
[0]->iface
, pos
,
2362 sizeof(conf
->bss
[0]->iface
));
2363 } else if (os_strcmp(buf
, "bridge") == 0) {
2364 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
2365 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
2366 os_strlcpy(bss
->vlan_bridge
, pos
, sizeof(bss
->vlan_bridge
));
2367 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
2368 os_strlcpy(bss
->wds_bridge
, pos
, sizeof(bss
->wds_bridge
));
2369 } else if (os_strcmp(buf
, "driver") == 0) {
2371 const struct wpa_driver_ops
*driver
= NULL
;
2373 for (j
= 0; wpa_drivers
[j
]; j
++) {
2374 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0) {
2375 driver
= wpa_drivers
[j
];
2380 wpa_printf(MSG_ERROR
,
2381 "Line %d: invalid/unknown driver '%s'",
2385 conf
->driver
= driver
;
2386 } else if (os_strcmp(buf
, "driver_params") == 0) {
2387 os_free(conf
->driver_params
);
2388 conf
->driver_params
= os_strdup(pos
);
2389 } else if (os_strcmp(buf
, "debug") == 0) {
2390 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore",
2392 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
2393 bss
->logger_syslog_level
= atoi(pos
);
2394 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
2395 bss
->logger_stdout_level
= atoi(pos
);
2396 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
2397 bss
->logger_syslog
= atoi(pos
);
2398 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
2399 bss
->logger_stdout
= atoi(pos
);
2400 } else if (os_strcmp(buf
, "dump_file") == 0) {
2401 wpa_printf(MSG_INFO
, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
2403 } else if (os_strcmp(buf
, "ssid") == 0) {
2404 bss
->ssid
.ssid_len
= os_strlen(pos
);
2405 if (bss
->ssid
.ssid_len
> SSID_MAX_LEN
||
2406 bss
->ssid
.ssid_len
< 1) {
2407 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2411 os_memcpy(bss
->ssid
.ssid
, pos
, bss
->ssid
.ssid_len
);
2412 bss
->ssid
.ssid_set
= 1;
2413 } else if (os_strcmp(buf
, "ssid2") == 0) {
2415 char *str
= wpa_config_parse_string(pos
, &slen
);
2416 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
2417 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2422 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
2423 bss
->ssid
.ssid_len
= slen
;
2424 bss
->ssid
.ssid_set
= 1;
2426 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
2427 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
2428 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
2429 enum macaddr_acl acl
= atoi(pos
);
2431 if (acl
!= ACCEPT_UNLESS_DENIED
&&
2432 acl
!= DENY_UNLESS_ACCEPTED
&&
2433 acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
2434 wpa_printf(MSG_ERROR
, "Line %d: unknown macaddr_acl %d",
2438 bss
->macaddr_acl
= acl
;
2439 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
2440 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
2441 &bss
->num_accept_mac
)) {
2442 wpa_printf(MSG_ERROR
, "Line %d: Failed to read accept_mac_file '%s'",
2446 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
2447 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
2448 &bss
->num_deny_mac
)) {
2449 wpa_printf(MSG_ERROR
, "Line %d: Failed to read deny_mac_file '%s'",
2453 } else if (os_strcmp(buf
, "wds_sta") == 0) {
2454 bss
->wds_sta
= atoi(pos
);
2455 } else if (os_strcmp(buf
, "start_disabled") == 0) {
2456 bss
->start_disabled
= atoi(pos
);
2457 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
2458 bss
->isolate
= atoi(pos
);
2459 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
2460 bss
->ap_max_inactivity
= atoi(pos
);
2461 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
2462 bss
->skip_inactivity_poll
= atoi(pos
);
2463 } else if (os_strcmp(buf
, "country_code") == 0) {
2464 os_memcpy(conf
->country
, pos
, 2);
2465 } else if (os_strcmp(buf
, "country3") == 0) {
2466 conf
->country
[2] = strtol(pos
, NULL
, 16);
2467 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
2468 conf
->ieee80211d
= atoi(pos
);
2469 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
2470 conf
->ieee80211h
= atoi(pos
);
2471 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
2472 bss
->ieee802_1x
= atoi(pos
);
2473 } else if (os_strcmp(buf
, "eapol_version") == 0) {
2474 int eapol_version
= atoi(pos
);
2476 #ifdef CONFIG_MACSEC
2477 if (eapol_version
< 1 || eapol_version
> 3) {
2478 #else /* CONFIG_MACSEC */
2479 if (eapol_version
< 1 || eapol_version
> 2) {
2480 #endif /* CONFIG_MACSEC */
2481 wpa_printf(MSG_ERROR
,
2482 "Line %d: invalid EAPOL version (%d): '%s'.",
2483 line
, eapol_version
, pos
);
2486 bss
->eapol_version
= eapol_version
;
2487 wpa_printf(MSG_DEBUG
, "eapol_version=%d", bss
->eapol_version
);
2489 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
2490 bss
->eap_server
= atoi(pos
);
2491 wpa_printf(MSG_ERROR
, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line
);
2492 } else if (os_strcmp(buf
, "eap_server") == 0) {
2493 bss
->eap_server
= atoi(pos
);
2494 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
2495 if (hostapd_config_read_eap_user(pos
, bss
))
2497 } else if (os_strcmp(buf
, "ca_cert") == 0) {
2498 os_free(bss
->ca_cert
);
2499 bss
->ca_cert
= os_strdup(pos
);
2500 } else if (os_strcmp(buf
, "server_cert") == 0) {
2501 os_free(bss
->server_cert
);
2502 bss
->server_cert
= os_strdup(pos
);
2503 } else if (os_strcmp(buf
, "server_cert2") == 0) {
2504 os_free(bss
->server_cert2
);
2505 bss
->server_cert2
= os_strdup(pos
);
2506 } else if (os_strcmp(buf
, "private_key") == 0) {
2507 os_free(bss
->private_key
);
2508 bss
->private_key
= os_strdup(pos
);
2509 } else if (os_strcmp(buf
, "private_key2") == 0) {
2510 os_free(bss
->private_key2
);
2511 bss
->private_key2
= os_strdup(pos
);
2512 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
2513 os_free(bss
->private_key_passwd
);
2514 bss
->private_key_passwd
= os_strdup(pos
);
2515 } else if (os_strcmp(buf
, "private_key_passwd2") == 0) {
2516 os_free(bss
->private_key_passwd2
);
2517 bss
->private_key_passwd2
= os_strdup(pos
);
2518 } else if (os_strcmp(buf
, "check_cert_subject") == 0) {
2520 wpa_printf(MSG_ERROR
, "Line %d: unknown check_cert_subject '%s'",
2524 os_free(bss
->check_cert_subject
);
2525 bss
->check_cert_subject
= os_strdup(pos
);
2526 if (!bss
->check_cert_subject
)
2528 } else if (os_strcmp(buf
, "check_crl") == 0) {
2529 bss
->check_crl
= atoi(pos
);
2530 } else if (os_strcmp(buf
, "check_crl_strict") == 0) {
2531 bss
->check_crl_strict
= atoi(pos
);
2532 } else if (os_strcmp(buf
, "crl_reload_interval") == 0) {
2533 bss
->crl_reload_interval
= atoi(pos
);
2534 } else if (os_strcmp(buf
, "tls_session_lifetime") == 0) {
2535 bss
->tls_session_lifetime
= atoi(pos
);
2536 } else if (os_strcmp(buf
, "tls_flags") == 0) {
2537 bss
->tls_flags
= parse_tls_flags(pos
);
2538 } else if (os_strcmp(buf
, "max_auth_rounds") == 0) {
2539 bss
->max_auth_rounds
= atoi(pos
);
2540 } else if (os_strcmp(buf
, "max_auth_rounds_short") == 0) {
2541 bss
->max_auth_rounds_short
= atoi(pos
);
2542 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
2543 os_free(bss
->ocsp_stapling_response
);
2544 bss
->ocsp_stapling_response
= os_strdup(pos
);
2545 } else if (os_strcmp(buf
, "ocsp_stapling_response_multi") == 0) {
2546 os_free(bss
->ocsp_stapling_response_multi
);
2547 bss
->ocsp_stapling_response_multi
= os_strdup(pos
);
2548 } else if (os_strcmp(buf
, "dh_file") == 0) {
2549 os_free(bss
->dh_file
);
2550 bss
->dh_file
= os_strdup(pos
);
2551 } else if (os_strcmp(buf
, "openssl_ciphers") == 0) {
2552 os_free(bss
->openssl_ciphers
);
2553 bss
->openssl_ciphers
= os_strdup(pos
);
2554 } else if (os_strcmp(buf
, "openssl_ecdh_curves") == 0) {
2555 os_free(bss
->openssl_ecdh_curves
);
2556 bss
->openssl_ecdh_curves
= os_strdup(pos
);
2557 } else if (os_strcmp(buf
, "fragment_size") == 0) {
2558 bss
->fragment_size
= atoi(pos
);
2559 #ifdef EAP_SERVER_FAST
2560 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
2561 os_free(bss
->pac_opaque_encr_key
);
2562 bss
->pac_opaque_encr_key
= os_malloc(16);
2563 if (bss
->pac_opaque_encr_key
== NULL
) {
2564 wpa_printf(MSG_ERROR
,
2565 "Line %d: No memory for pac_opaque_encr_key",
2568 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
, 16)) {
2569 wpa_printf(MSG_ERROR
, "Line %d: Invalid pac_opaque_encr_key",
2573 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
2574 size_t idlen
= os_strlen(pos
);
2576 wpa_printf(MSG_ERROR
, "Line %d: Invalid eap_fast_a_id",
2580 os_free(bss
->eap_fast_a_id
);
2581 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
2582 if (bss
->eap_fast_a_id
== NULL
||
2583 hexstr2bin(pos
, bss
->eap_fast_a_id
, idlen
/ 2)) {
2584 wpa_printf(MSG_ERROR
, "Line %d: Failed to parse eap_fast_a_id",
2586 os_free(bss
->eap_fast_a_id
);
2587 bss
->eap_fast_a_id
= NULL
;
2590 bss
->eap_fast_a_id_len
= idlen
/ 2;
2592 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
2593 os_free(bss
->eap_fast_a_id_info
);
2594 bss
->eap_fast_a_id_info
= os_strdup(pos
);
2595 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
2596 bss
->eap_fast_prov
= atoi(pos
);
2597 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
2598 bss
->pac_key_lifetime
= atoi(pos
);
2599 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
2600 bss
->pac_key_refresh_time
= atoi(pos
);
2601 #endif /* EAP_SERVER_FAST */
2602 #ifdef EAP_SERVER_TEAP
2603 } else if (os_strcmp(buf
, "eap_teap_auth") == 0) {
2604 int val
= atoi(pos
);
2606 if (val
< 0 || val
> 1) {
2607 wpa_printf(MSG_ERROR
,
2608 "Line %d: Invalid eap_teap_auth value",
2612 bss
->eap_teap_auth
= val
;
2613 } else if (os_strcmp(buf
, "eap_teap_pac_no_inner") == 0) {
2614 bss
->eap_teap_pac_no_inner
= atoi(pos
);
2615 } else if (os_strcmp(buf
, "eap_teap_separate_result") == 0) {
2616 bss
->eap_teap_separate_result
= atoi(pos
);
2617 } else if (os_strcmp(buf
, "eap_teap_id") == 0) {
2618 bss
->eap_teap_id
= atoi(pos
);
2619 #endif /* EAP_SERVER_TEAP */
2620 #ifdef EAP_SERVER_SIM
2621 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
2622 os_free(bss
->eap_sim_db
);
2623 bss
->eap_sim_db
= os_strdup(pos
);
2624 } else if (os_strcmp(buf
, "eap_sim_db_timeout") == 0) {
2625 bss
->eap_sim_db_timeout
= atoi(pos
);
2626 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
2627 bss
->eap_sim_aka_result_ind
= atoi(pos
);
2628 } else if (os_strcmp(buf
, "eap_sim_id") == 0) {
2629 bss
->eap_sim_id
= atoi(pos
);
2630 #endif /* EAP_SERVER_SIM */
2631 #ifdef EAP_SERVER_TNC
2632 } else if (os_strcmp(buf
, "tnc") == 0) {
2633 bss
->tnc
= atoi(pos
);
2634 #endif /* EAP_SERVER_TNC */
2635 #ifdef EAP_SERVER_PWD
2636 } else if (os_strcmp(buf
, "pwd_group") == 0) {
2637 bss
->pwd_group
= atoi(pos
);
2638 #endif /* EAP_SERVER_PWD */
2640 } else if (os_strcmp(buf
, "eap_server_erp") == 0) {
2641 bss
->eap_server_erp
= atoi(pos
);
2642 #endif /* CONFIG_ERP */
2643 #endif /* EAP_SERVER */
2644 } else if (os_strcmp(buf
, "eap_message") == 0) {
2646 os_free(bss
->eap_req_id_text
);
2647 bss
->eap_req_id_text
= os_strdup(pos
);
2648 if (bss
->eap_req_id_text
== NULL
) {
2649 wpa_printf(MSG_ERROR
, "Line %d: Failed to allocate memory for eap_req_id_text",
2653 bss
->eap_req_id_text_len
= os_strlen(bss
->eap_req_id_text
);
2654 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
2657 os_memmove(term
, term
+ 1,
2658 bss
->eap_req_id_text_len
-
2659 (term
- bss
->eap_req_id_text
) - 1);
2660 bss
->eap_req_id_text_len
--;
2662 } else if (os_strcmp(buf
, "erp_send_reauth_start") == 0) {
2663 bss
->erp_send_reauth_start
= atoi(pos
);
2664 } else if (os_strcmp(buf
, "erp_domain") == 0) {
2665 os_free(bss
->erp_domain
);
2666 bss
->erp_domain
= os_strdup(pos
);
2667 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
2668 int val
= atoi(pos
);
2670 if (val
< 0 || val
> 13) {
2671 wpa_printf(MSG_ERROR
,
2672 "Line %d: invalid WEP key len %d (= %d bits)",
2673 line
, val
, val
* 8);
2676 bss
->default_wep_key_len
= val
;
2677 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
2678 int val
= atoi(pos
);
2680 if (val
< 0 || val
> 13) {
2681 wpa_printf(MSG_ERROR
,
2682 "Line %d: invalid WEP key len %d (= %d bits)",
2683 line
, val
, val
* 8);
2686 bss
->individual_wep_key_len
= val
;
2687 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
2688 bss
->wep_rekeying_period
= atoi(pos
);
2689 if (bss
->wep_rekeying_period
< 0) {
2690 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2691 line
, bss
->wep_rekeying_period
);
2694 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
2695 bss
->eap_reauth_period
= atoi(pos
);
2696 if (bss
->eap_reauth_period
< 0) {
2697 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2698 line
, bss
->eap_reauth_period
);
2701 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
2702 bss
->eapol_key_index_workaround
= atoi(pos
);
2704 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
2705 wpa_printf(MSG_INFO
, "DEPRECATED: iapp_interface not used");
2706 #endif /* CONFIG_IAPP */
2707 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
2708 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
2709 wpa_printf(MSG_ERROR
,
2710 "Line %d: invalid IP address '%s'",
2714 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
2715 os_free(bss
->nas_identifier
);
2716 bss
->nas_identifier
= os_strdup(pos
);
2717 #ifndef CONFIG_NO_RADIUS
2718 } else if (os_strcmp(buf
, "radius_client_addr") == 0) {
2719 if (hostapd_parse_ip_addr(pos
, &bss
->radius
->client_addr
)) {
2720 wpa_printf(MSG_ERROR
,
2721 "Line %d: invalid IP address '%s'",
2725 bss
->radius
->force_client_addr
= 1;
2726 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
2727 if (hostapd_config_read_radius_addr(
2728 &bss
->radius
->auth_servers
,
2729 &bss
->radius
->num_auth_servers
, pos
, 1812,
2730 &bss
->radius
->auth_server
)) {
2731 wpa_printf(MSG_ERROR
,
2732 "Line %d: invalid IP address '%s'",
2736 } else if (bss
->radius
->auth_server
&&
2737 os_strcmp(buf
, "auth_server_addr_replace") == 0) {
2738 if (hostapd_parse_ip_addr(pos
,
2739 &bss
->radius
->auth_server
->addr
)) {
2740 wpa_printf(MSG_ERROR
,
2741 "Line %d: invalid IP address '%s'",
2745 } else if (bss
->radius
->auth_server
&&
2746 os_strcmp(buf
, "auth_server_port") == 0) {
2747 bss
->radius
->auth_server
->port
= atoi(pos
);
2748 } else if (bss
->radius
->auth_server
&&
2749 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
2750 int len
= os_strlen(pos
);
2752 /* RFC 2865, Ch. 3 */
2753 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2757 os_free(bss
->radius
->auth_server
->shared_secret
);
2758 bss
->radius
->auth_server
->shared_secret
= (u8
*) os_strdup(pos
);
2759 bss
->radius
->auth_server
->shared_secret_len
= len
;
2760 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
2761 if (hostapd_config_read_radius_addr(
2762 &bss
->radius
->acct_servers
,
2763 &bss
->radius
->num_acct_servers
, pos
, 1813,
2764 &bss
->radius
->acct_server
)) {
2765 wpa_printf(MSG_ERROR
,
2766 "Line %d: invalid IP address '%s'",
2770 } else if (bss
->radius
->acct_server
&&
2771 os_strcmp(buf
, "acct_server_addr_replace") == 0) {
2772 if (hostapd_parse_ip_addr(pos
,
2773 &bss
->radius
->acct_server
->addr
)) {
2774 wpa_printf(MSG_ERROR
,
2775 "Line %d: invalid IP address '%s'",
2779 } else if (bss
->radius
->acct_server
&&
2780 os_strcmp(buf
, "acct_server_port") == 0) {
2781 bss
->radius
->acct_server
->port
= atoi(pos
);
2782 } else if (bss
->radius
->acct_server
&&
2783 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
2784 int len
= os_strlen(pos
);
2786 /* RFC 2865, Ch. 3 */
2787 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2791 os_free(bss
->radius
->acct_server
->shared_secret
);
2792 bss
->radius
->acct_server
->shared_secret
= (u8
*) os_strdup(pos
);
2793 bss
->radius
->acct_server
->shared_secret_len
= len
;
2794 } else if (os_strcmp(buf
, "radius_retry_primary_interval") == 0) {
2795 bss
->radius
->retry_primary_interval
= atoi(pos
);
2796 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0) {
2797 bss
->acct_interim_interval
= atoi(pos
);
2798 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
2799 bss
->radius_request_cui
= atoi(pos
);
2800 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
2801 struct hostapd_radius_attr
*attr
, *a
;
2802 attr
= hostapd_parse_radius_attr(pos
);
2804 wpa_printf(MSG_ERROR
,
2805 "Line %d: invalid radius_auth_req_attr",
2808 } else if (bss
->radius_auth_req_attr
== NULL
) {
2809 bss
->radius_auth_req_attr
= attr
;
2811 a
= bss
->radius_auth_req_attr
;
2816 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
2817 struct hostapd_radius_attr
*attr
, *a
;
2818 attr
= hostapd_parse_radius_attr(pos
);
2820 wpa_printf(MSG_ERROR
,
2821 "Line %d: invalid radius_acct_req_attr",
2824 } else if (bss
->radius_acct_req_attr
== NULL
) {
2825 bss
->radius_acct_req_attr
= attr
;
2827 a
= bss
->radius_acct_req_attr
;
2832 } else if (os_strcmp(buf
, "radius_req_attr_sqlite") == 0) {
2833 os_free(bss
->radius_req_attr_sqlite
);
2834 bss
->radius_req_attr_sqlite
= os_strdup(pos
);
2835 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
2836 bss
->radius_das_port
= atoi(pos
);
2837 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
2838 if (hostapd_parse_das_client(bss
, pos
) < 0) {
2839 wpa_printf(MSG_ERROR
, "Line %d: invalid DAS client",
2843 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2844 bss
->radius_das_time_window
= atoi(pos
);
2845 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp") == 0) {
2846 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2847 } else if (os_strcmp(buf
, "radius_das_require_message_authenticator") ==
2849 bss
->radius_das_require_message_authenticator
= atoi(pos
);
2850 #endif /* CONFIG_NO_RADIUS */
2851 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2852 bss
->auth_algs
= atoi(pos
);
2853 if (bss
->auth_algs
== 0) {
2854 wpa_printf(MSG_ERROR
, "Line %d: no authentication algorithms allowed",
2858 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2859 bss
->max_num_sta
= atoi(pos
);
2860 if (bss
->max_num_sta
< 0 ||
2861 bss
->max_num_sta
> MAX_STA_COUNT
) {
2862 wpa_printf(MSG_ERROR
, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2863 line
, bss
->max_num_sta
, MAX_STA_COUNT
);
2866 } else if (os_strcmp(buf
, "wpa") == 0) {
2867 bss
->wpa
= atoi(pos
);
2868 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2869 bss
->wpa_group_rekey
= atoi(pos
);
2870 bss
->wpa_group_rekey_set
= 1;
2871 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2872 bss
->wpa_strict_rekey
= atoi(pos
);
2873 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2874 bss
->wpa_gmk_rekey
= atoi(pos
);
2875 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2876 bss
->wpa_ptk_rekey
= atoi(pos
);
2877 } else if (os_strcmp(buf
, "wpa_deny_ptk0_rekey") == 0) {
2878 bss
->wpa_deny_ptk0_rekey
= atoi(pos
);
2879 if (bss
->wpa_deny_ptk0_rekey
< 0 ||
2880 bss
->wpa_deny_ptk0_rekey
> 2) {
2881 wpa_printf(MSG_ERROR
,
2882 "Line %d: Invalid wpa_deny_ptk0_rekey=%d; allowed range 0..2",
2883 line
, bss
->wpa_deny_ptk0_rekey
);
2886 } else if (os_strcmp(buf
, "wpa_group_update_count") == 0) {
2888 unsigned long val
= strtoul(pos
, &endp
, 0);
2890 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2891 wpa_printf(MSG_ERROR
,
2892 "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295",
2896 bss
->wpa_group_update_count
= (u32
) val
;
2897 } else if (os_strcmp(buf
, "wpa_pairwise_update_count") == 0) {
2899 unsigned long val
= strtoul(pos
, &endp
, 0);
2901 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2902 wpa_printf(MSG_ERROR
,
2903 "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295",
2907 bss
->wpa_pairwise_update_count
= (u32
) val
;
2908 } else if (os_strcmp(buf
, "wpa_disable_eapol_key_retries") == 0) {
2909 bss
->wpa_disable_eapol_key_retries
= atoi(pos
);
2910 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2911 int len
= os_strlen(pos
);
2912 if (len
< 8 || len
> 63) {
2913 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA passphrase length %d (expected 8..63)",
2917 os_free(bss
->ssid
.wpa_passphrase
);
2918 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2919 if (bss
->ssid
.wpa_passphrase
) {
2920 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2921 bss
->ssid
.wpa_passphrase_set
= 1;
2923 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2924 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2925 bss
->ssid
.wpa_psk
= os_zalloc(sizeof(struct hostapd_wpa_psk
));
2926 if (bss
->ssid
.wpa_psk
== NULL
)
2928 if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
, PMK_LEN
) ||
2929 pos
[PMK_LEN
* 2] != '\0') {
2930 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
2932 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2935 bss
->ssid
.wpa_psk
->group
= 1;
2936 os_free(bss
->ssid
.wpa_passphrase
);
2937 bss
->ssid
.wpa_passphrase
= NULL
;
2938 bss
->ssid
.wpa_psk_set
= 1;
2939 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2940 os_free(bss
->ssid
.wpa_psk_file
);
2941 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
2942 if (!bss
->ssid
.wpa_psk_file
) {
2943 wpa_printf(MSG_ERROR
, "Line %d: allocation failed",
2947 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
2948 bss
->wpa_key_mgmt
= hostapd_config_parse_key_mgmt(line
, pos
);
2949 if (bss
->wpa_key_mgmt
== -1)
2951 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
2952 bss
->wpa_psk_radius
= atoi(pos
);
2953 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
2954 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
2955 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
2956 wpa_printf(MSG_ERROR
,
2957 "Line %d: unknown wpa_psk_radius %d",
2958 line
, bss
->wpa_psk_radius
);
2961 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
2962 bss
->wpa_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2963 if (bss
->wpa_pairwise
== -1 || bss
->wpa_pairwise
== 0)
2965 if (bss
->wpa_pairwise
&
2966 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2967 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2971 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
2972 bss
->rsn_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2973 if (bss
->rsn_pairwise
== -1 || bss
->rsn_pairwise
== 0)
2975 if (bss
->rsn_pairwise
&
2976 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2977 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2981 } else if (os_strcmp(buf
, "group_cipher") == 0) {
2982 bss
->group_cipher
= hostapd_config_parse_cipher(line
, pos
);
2983 if (bss
->group_cipher
== -1 || bss
->group_cipher
== 0)
2985 if (bss
->group_cipher
!= WPA_CIPHER_TKIP
&&
2986 bss
->group_cipher
!= WPA_CIPHER_CCMP
&&
2987 bss
->group_cipher
!= WPA_CIPHER_GCMP
&&
2988 bss
->group_cipher
!= WPA_CIPHER_GCMP_256
&&
2989 bss
->group_cipher
!= WPA_CIPHER_CCMP_256
) {
2990 wpa_printf(MSG_ERROR
,
2991 "Line %d: unsupported group cipher suite '%s'",
2995 #ifdef CONFIG_RSN_PREAUTH
2996 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
2997 bss
->rsn_preauth
= atoi(pos
);
2998 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
2999 os_free(bss
->rsn_preauth_interfaces
);
3000 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
3001 #endif /* CONFIG_RSN_PREAUTH */
3002 } else if (os_strcmp(buf
, "peerkey") == 0) {
3003 wpa_printf(MSG_INFO
,
3004 "Line %d: Obsolete peerkey parameter ignored", line
);
3005 #ifdef CONFIG_IEEE80211R_AP
3006 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
3007 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
3008 hexstr2bin(pos
, bss
->mobility_domain
,
3009 MOBILITY_DOMAIN_ID_LEN
) != 0) {
3010 wpa_printf(MSG_ERROR
,
3011 "Line %d: Invalid mobility_domain '%s'",
3015 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
3016 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
3017 hexstr2bin(pos
, bss
->r1_key_holder
, FT_R1KH_ID_LEN
) != 0) {
3018 wpa_printf(MSG_ERROR
,
3019 "Line %d: Invalid r1_key_holder '%s'",
3023 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
3024 /* DEPRECATED: Use ft_r0_key_lifetime instead. */
3025 bss
->r0_key_lifetime
= atoi(pos
) * 60;
3026 } else if (os_strcmp(buf
, "ft_r0_key_lifetime") == 0) {
3027 bss
->r0_key_lifetime
= atoi(pos
);
3028 } else if (os_strcmp(buf
, "r1_max_key_lifetime") == 0) {
3029 bss
->r1_max_key_lifetime
= atoi(pos
);
3030 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
3031 bss
->reassociation_deadline
= atoi(pos
);
3032 } else if (os_strcmp(buf
, "rkh_pos_timeout") == 0) {
3033 bss
->rkh_pos_timeout
= atoi(pos
);
3034 } else if (os_strcmp(buf
, "rkh_neg_timeout") == 0) {
3035 bss
->rkh_neg_timeout
= atoi(pos
);
3036 } else if (os_strcmp(buf
, "rkh_pull_timeout") == 0) {
3037 bss
->rkh_pull_timeout
= atoi(pos
);
3038 } else if (os_strcmp(buf
, "rkh_pull_retries") == 0) {
3039 bss
->rkh_pull_retries
= atoi(pos
);
3040 } else if (os_strcmp(buf
, "r0kh") == 0) {
3041 if (add_r0kh(bss
, pos
) < 0) {
3042 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r0kh '%s'",
3046 } else if (os_strcmp(buf
, "r1kh") == 0) {
3047 if (add_r1kh(bss
, pos
) < 0) {
3048 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r1kh '%s'",
3052 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
3053 bss
->pmk_r1_push
= atoi(pos
);
3054 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
3055 bss
->ft_over_ds
= atoi(pos
);
3056 } else if (os_strcmp(buf
, "ft_psk_generate_local") == 0) {
3057 bss
->ft_psk_generate_local
= atoi(pos
);
3058 #endif /* CONFIG_IEEE80211R_AP */
3059 #ifndef CONFIG_NO_CTRL_IFACE
3060 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
3061 os_free(bss
->ctrl_interface
);
3062 bss
->ctrl_interface
= os_strdup(pos
);
3063 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
3064 #ifndef CONFIG_NATIVE_WINDOWS
3067 const char *group
= pos
;
3069 grp
= getgrnam(group
);
3071 bss
->ctrl_interface_gid
= grp
->gr_gid
;
3072 bss
->ctrl_interface_gid_set
= 1;
3073 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d (from group name '%s')",
3074 bss
->ctrl_interface_gid
, group
);
3078 /* Group name not found - try to parse this as gid */
3079 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
3080 if (*group
== '\0' || *endp
!= '\0') {
3081 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group '%s'",
3085 bss
->ctrl_interface_gid_set
= 1;
3086 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
3087 bss
->ctrl_interface_gid
);
3088 #endif /* CONFIG_NATIVE_WINDOWS */
3089 #endif /* CONFIG_NO_CTRL_IFACE */
3090 #ifdef RADIUS_SERVER
3091 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
3092 os_free(bss
->radius_server_clients
);
3093 bss
->radius_server_clients
= os_strdup(pos
);
3094 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
3095 bss
->radius_server_auth_port
= atoi(pos
);
3096 } else if (os_strcmp(buf
, "radius_server_acct_port") == 0) {
3097 bss
->radius_server_acct_port
= atoi(pos
);
3098 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
3099 bss
->radius_server_ipv6
= atoi(pos
);
3100 #endif /* RADIUS_SERVER */
3101 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
3102 bss
->use_pae_group_addr
= atoi(pos
);
3103 } else if (os_strcmp(buf
, "hw_mode") == 0) {
3104 if (os_strcmp(pos
, "a") == 0)
3105 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
3106 else if (os_strcmp(pos
, "b") == 0)
3107 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
3108 else if (os_strcmp(pos
, "g") == 0)
3109 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
3110 else if (os_strcmp(pos
, "ad") == 0)
3111 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
3112 else if (os_strcmp(pos
, "any") == 0)
3113 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211ANY
;
3115 wpa_printf(MSG_ERROR
, "Line %d: unknown hw_mode '%s'",
3119 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
3120 if (os_strcmp(pos
, "ad") == 0)
3121 bss
->wps_rf_bands
= WPS_RF_60GHZ
;
3122 else if (os_strcmp(pos
, "a") == 0)
3123 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
3124 else if (os_strcmp(pos
, "g") == 0 ||
3125 os_strcmp(pos
, "b") == 0)
3126 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
3127 else if (os_strcmp(pos
, "ag") == 0 ||
3128 os_strcmp(pos
, "ga") == 0)
3129 bss
->wps_rf_bands
= WPS_RF_24GHZ
| WPS_RF_50GHZ
;
3131 wpa_printf(MSG_ERROR
,
3132 "Line %d: unknown wps_rf_band '%s'",
3136 } else if (os_strcmp(buf
, "acs_exclude_dfs") == 0) {
3137 conf
->acs_exclude_dfs
= atoi(pos
);
3138 } else if (os_strcmp(buf
, "op_class") == 0) {
3139 conf
->op_class
= atoi(pos
);
3140 } else if (os_strcmp(buf
, "channel") == 0) {
3141 if (os_strcmp(pos
, "acs_survey") == 0) {
3143 wpa_printf(MSG_ERROR
, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
3146 #else /* CONFIG_ACS */
3149 #endif /* CONFIG_ACS */
3151 conf
->channel
= atoi(pos
);
3152 conf
->acs
= conf
->channel
== 0;
3154 } else if (os_strcmp(buf
, "edmg_channel") == 0) {
3155 conf
->edmg_channel
= atoi(pos
);
3156 } else if (os_strcmp(buf
, "enable_edmg") == 0) {
3157 conf
->enable_edmg
= atoi(pos
);
3158 } else if (os_strcmp(buf
, "chanlist") == 0) {
3159 if (hostapd_parse_chanlist(conf
, pos
)) {
3160 wpa_printf(MSG_ERROR
, "Line %d: invalid channel list",
3164 } else if (os_strcmp(buf
, "freqlist") == 0) {
3165 if (freq_range_list_parse(&conf
->acs_freq_list
, pos
)) {
3166 wpa_printf(MSG_ERROR
, "Line %d: invalid frequency list",
3170 conf
->acs_freq_list_present
= 1;
3171 } else if (os_strcmp(buf
, "acs_exclude_6ghz_non_psc") == 0) {
3172 conf
->acs_exclude_6ghz_non_psc
= atoi(pos
);
3173 } else if (os_strcmp(buf
, "beacon_int") == 0) {
3174 int val
= atoi(pos
);
3175 /* MIB defines range as 1..65535, but very small values
3176 * cause problems with the current implementation.
3177 * Since it is unlikely that this small numbers are
3178 * useful in real life scenarios, do not allow beacon
3179 * period to be set below 10 TU. */
3180 if (val
< 10 || val
> 65535) {
3181 wpa_printf(MSG_ERROR
,
3182 "Line %d: invalid beacon_int %d (expected 10..65535)",
3186 conf
->beacon_int
= val
;
3188 } else if (os_strcmp(buf
, "acs_num_scans") == 0) {
3189 int val
= atoi(pos
);
3190 if (val
<= 0 || val
> 100) {
3191 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_num_scans %d (expected 1..100)",
3195 conf
->acs_num_scans
= val
;
3196 } else if (os_strcmp(buf
, "acs_chan_bias") == 0) {
3197 if (hostapd_config_parse_acs_chan_bias(conf
, pos
)) {
3198 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_chan_bias",
3202 #endif /* CONFIG_ACS */
3203 } else if (os_strcmp(buf
, "dtim_period") == 0) {
3204 int val
= atoi(pos
);
3206 if (val
< 1 || val
> 255) {
3207 wpa_printf(MSG_ERROR
, "Line %d: invalid dtim_period %d",
3211 bss
->dtim_period
= val
;
3212 } else if (os_strcmp(buf
, "bss_load_update_period") == 0) {
3213 int val
= atoi(pos
);
3215 if (val
< 0 || val
> 100) {
3216 wpa_printf(MSG_ERROR
,
3217 "Line %d: invalid bss_load_update_period %d",
3221 bss
->bss_load_update_period
= val
;
3222 } else if (os_strcmp(buf
, "chan_util_avg_period") == 0) {
3223 int val
= atoi(pos
);
3226 wpa_printf(MSG_ERROR
,
3227 "Line %d: invalid chan_util_avg_period",
3231 bss
->chan_util_avg_period
= val
;
3232 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
3233 conf
->rts_threshold
= atoi(pos
);
3234 if (conf
->rts_threshold
< -1 || conf
->rts_threshold
> 65535) {
3235 wpa_printf(MSG_ERROR
,
3236 "Line %d: invalid rts_threshold %d",
3237 line
, conf
->rts_threshold
);
3240 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
3241 conf
->fragm_threshold
= atoi(pos
);
3242 if (conf
->fragm_threshold
== -1) {
3243 /* allow a value of -1 */
3244 } else if (conf
->fragm_threshold
< 256 ||
3245 conf
->fragm_threshold
> 2346) {
3246 wpa_printf(MSG_ERROR
,
3247 "Line %d: invalid fragm_threshold %d",
3248 line
, conf
->fragm_threshold
);
3251 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
3252 int val
= atoi(pos
);
3253 if (val
!= 0 && val
!= 1) {
3254 wpa_printf(MSG_ERROR
, "Line %d: invalid send_probe_response %d (expected 0 or 1)",
3258 bss
->send_probe_response
= val
;
3259 } else if (os_strcmp(buf
, "supported_rates") == 0) {
3260 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
)) {
3261 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3265 } else if (os_strcmp(buf
, "basic_rates") == 0) {
3266 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
3267 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3271 } else if (os_strcmp(buf
, "beacon_rate") == 0) {
3274 if (os_strncmp(pos
, "ht:", 3) == 0) {
3275 val
= atoi(pos
+ 3);
3276 if (val
< 0 || val
> 31) {
3277 wpa_printf(MSG_ERROR
,
3278 "Line %d: invalid beacon_rate HT-MCS %d",
3282 conf
->rate_type
= BEACON_RATE_HT
;
3283 conf
->beacon_rate
= val
;
3284 } else if (os_strncmp(pos
, "vht:", 4) == 0) {
3285 val
= atoi(pos
+ 4);
3286 if (val
< 0 || val
> 9) {
3287 wpa_printf(MSG_ERROR
,
3288 "Line %d: invalid beacon_rate VHT-MCS %d",
3292 conf
->rate_type
= BEACON_RATE_VHT
;
3293 conf
->beacon_rate
= val
;
3296 if (val
< 10 || val
> 10000) {
3297 wpa_printf(MSG_ERROR
,
3298 "Line %d: invalid legacy beacon_rate %d",
3302 conf
->rate_type
= BEACON_RATE_LEGACY
;
3303 conf
->beacon_rate
= val
;
3305 } else if (os_strcmp(buf
, "preamble") == 0) {
3307 conf
->preamble
= SHORT_PREAMBLE
;
3309 conf
->preamble
= LONG_PREAMBLE
;
3310 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
3311 bss
->ignore_broadcast_ssid
= atoi(pos
);
3312 } else if (os_strcmp(buf
, "no_probe_resp_if_max_sta") == 0) {
3313 bss
->no_probe_resp_if_max_sta
= atoi(pos
);
3314 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
3315 bss
->ssid
.wep
.idx
= atoi(pos
);
3316 if (bss
->ssid
.wep
.idx
> 3) {
3317 wpa_printf(MSG_ERROR
,
3318 "Invalid wep_default_key index %d",
3322 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
3323 os_strcmp(buf
, "wep_key1") == 0 ||
3324 os_strcmp(buf
, "wep_key2") == 0 ||
3325 os_strcmp(buf
, "wep_key3") == 0) {
3326 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
3327 buf
[7] - '0', pos
)) {
3328 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP key '%s'",
3332 #ifndef CONFIG_NO_VLAN
3333 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
3334 bss
->ssid
.dynamic_vlan
= atoi(pos
);
3335 } else if (os_strcmp(buf
, "per_sta_vif") == 0) {
3336 bss
->ssid
.per_sta_vif
= atoi(pos
);
3337 } else if (os_strcmp(buf
, "vlan_file") == 0) {
3338 if (hostapd_config_read_vlan_file(bss
, pos
)) {
3339 wpa_printf(MSG_ERROR
, "Line %d: failed to read VLAN file '%s'",
3343 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
3344 bss
->ssid
.vlan_naming
= atoi(pos
);
3345 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
3346 bss
->ssid
.vlan_naming
< 0) {
3347 wpa_printf(MSG_ERROR
,
3348 "Line %d: invalid naming scheme %d",
3349 line
, bss
->ssid
.vlan_naming
);
3352 #ifdef CONFIG_FULL_DYNAMIC_VLAN
3353 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
3354 os_free(bss
->ssid
.vlan_tagged_interface
);
3355 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
3356 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
3357 #endif /* CONFIG_NO_VLAN */
3358 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
3359 conf
->ap_table_max_size
= atoi(pos
);
3360 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
3361 conf
->ap_table_expiration_time
= atoi(pos
);
3362 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
3363 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
3364 wpa_printf(MSG_ERROR
, "Line %d: invalid TX queue item",
3368 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
3369 os_strcmp(buf
, "wmm_enabled") == 0) {
3370 bss
->wmm_enabled
= atoi(pos
);
3371 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
3372 bss
->wmm_uapsd
= atoi(pos
);
3373 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
3374 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
3375 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
, pos
)) {
3376 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM ac item",
3380 } else if (os_strcmp(buf
, "bss") == 0) {
3381 if (hostapd_config_bss(conf
, pos
)) {
3382 wpa_printf(MSG_ERROR
, "Line %d: invalid bss item",
3386 } else if (os_strcmp(buf
, "bssid") == 0) {
3387 if (hwaddr_aton(pos
, bss
->bssid
)) {
3388 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid item",
3392 } else if (os_strcmp(buf
, "use_driver_iface_addr") == 0) {
3393 conf
->use_driver_iface_addr
= atoi(pos
);
3394 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
3395 bss
->ieee80211w
= atoi(pos
);
3396 } else if (os_strcmp(buf
, "group_mgmt_cipher") == 0) {
3397 if (os_strcmp(pos
, "AES-128-CMAC") == 0) {
3398 bss
->group_mgmt_cipher
= WPA_CIPHER_AES_128_CMAC
;
3399 } else if (os_strcmp(pos
, "BIP-GMAC-128") == 0) {
3400 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_128
;
3401 } else if (os_strcmp(pos
, "BIP-GMAC-256") == 0) {
3402 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_256
;
3403 } else if (os_strcmp(pos
, "BIP-CMAC-256") == 0) {
3404 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_CMAC_256
;
3406 wpa_printf(MSG_ERROR
, "Line %d: invalid group_mgmt_cipher: %s",
3410 } else if (os_strcmp(buf
, "beacon_prot") == 0) {
3411 bss
->beacon_prot
= atoi(pos
);
3412 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
3413 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
3414 if (bss
->assoc_sa_query_max_timeout
== 0) {
3415 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_max_timeout",
3419 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0) {
3420 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
3421 if (bss
->assoc_sa_query_retry_timeout
== 0) {
3422 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_retry_timeout",
3427 } else if (os_strcmp(buf
, "ocv") == 0) {
3428 bss
->ocv
= atoi(pos
);
3429 if (bss
->ocv
&& !bss
->ieee80211w
)
3430 bss
->ieee80211w
= 1;
3431 #endif /* CONFIG_OCV */
3432 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
3433 conf
->ieee80211n
= atoi(pos
);
3434 } else if (os_strcmp(buf
, "ht_capab") == 0) {
3435 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
3436 wpa_printf(MSG_ERROR
, "Line %d: invalid ht_capab",
3440 } else if (os_strcmp(buf
, "require_ht") == 0) {
3441 conf
->require_ht
= atoi(pos
);
3442 } else if (os_strcmp(buf
, "obss_interval") == 0) {
3443 conf
->obss_interval
= atoi(pos
);
3444 #ifdef CONFIG_IEEE80211AC
3445 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
3446 conf
->ieee80211ac
= atoi(pos
);
3447 } else if (os_strcmp(buf
, "vht_capab") == 0) {
3448 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
3449 wpa_printf(MSG_ERROR
, "Line %d: invalid vht_capab",
3453 } else if (os_strcmp(buf
, "require_vht") == 0) {
3454 conf
->require_vht
= atoi(pos
);
3455 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
3456 conf
->vht_oper_chwidth
= atoi(pos
);
3457 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0) {
3458 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
3459 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0) {
3460 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
3461 } else if (os_strcmp(buf
, "vendor_vht") == 0) {
3462 bss
->vendor_vht
= atoi(pos
);
3463 } else if (os_strcmp(buf
, "use_sta_nsts") == 0) {
3464 bss
->use_sta_nsts
= atoi(pos
);
3465 #endif /* CONFIG_IEEE80211AC */
3466 #ifdef CONFIG_IEEE80211AX
3467 } else if (os_strcmp(buf
, "ieee80211ax") == 0) {
3468 conf
->ieee80211ax
= atoi(pos
);
3469 } else if (os_strcmp(buf
, "he_su_beamformer") == 0) {
3470 conf
->he_phy_capab
.he_su_beamformer
= atoi(pos
);
3471 } else if (os_strcmp(buf
, "he_su_beamformee") == 0) {
3472 conf
->he_phy_capab
.he_su_beamformee
= atoi(pos
);
3473 } else if (os_strcmp(buf
, "he_mu_beamformer") == 0) {
3474 conf
->he_phy_capab
.he_mu_beamformer
= atoi(pos
);
3475 } else if (os_strcmp(buf
, "he_bss_color") == 0) {
3476 conf
->he_op
.he_bss_color
= atoi(pos
) & 0x3f;
3477 conf
->he_op
.he_bss_color_disabled
= 0;
3478 } else if (os_strcmp(buf
, "he_bss_color_partial") == 0) {
3479 conf
->he_op
.he_bss_color_partial
= atoi(pos
);
3480 } else if (os_strcmp(buf
, "he_default_pe_duration") == 0) {
3481 conf
->he_op
.he_default_pe_duration
= atoi(pos
);
3482 } else if (os_strcmp(buf
, "he_twt_required") == 0) {
3483 conf
->he_op
.he_twt_required
= atoi(pos
);
3484 } else if (os_strcmp(buf
, "he_rts_threshold") == 0) {
3485 conf
->he_op
.he_rts_threshold
= atoi(pos
);
3486 } else if (os_strcmp(buf
, "he_basic_mcs_nss_set") == 0) {
3487 conf
->he_op
.he_basic_mcs_nss_set
= atoi(pos
);
3488 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_param_count") == 0) {
3489 conf
->he_mu_edca
.he_qos_info
|=
3490 set_he_cap(atoi(pos
), HE_QOS_INFO_EDCA_PARAM_SET_COUNT
);
3491 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_q_ack") == 0) {
3492 conf
->he_mu_edca
.he_qos_info
|=
3493 set_he_cap(atoi(pos
), HE_QOS_INFO_Q_ACK
);
3494 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_queue_request") == 0) {
3495 conf
->he_mu_edca
.he_qos_info
|=
3496 set_he_cap(atoi(pos
), HE_QOS_INFO_QUEUE_REQUEST
);
3497 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_txop_request") == 0) {
3498 conf
->he_mu_edca
.he_qos_info
|=
3499 set_he_cap(atoi(pos
), HE_QOS_INFO_TXOP_REQUEST
);
3500 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_aifsn") == 0) {
3501 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3502 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3503 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_acm") == 0) {
3504 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3505 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3506 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_aci") == 0) {
3507 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3508 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3509 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_ecwmin") == 0) {
3510 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3511 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3512 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_ecwmax") == 0) {
3513 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3514 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3515 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_timer") == 0) {
3516 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3518 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_aifsn") == 0) {
3519 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3520 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3521 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_acm") == 0) {
3522 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3523 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3524 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_aci") == 0) {
3525 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3526 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3527 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_ecwmin") == 0) {
3528 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3529 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3530 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_ecwmax") == 0) {
3531 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3532 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3533 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_timer") == 0) {
3534 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3536 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_aifsn") == 0) {
3537 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3538 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3539 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_acm") == 0) {
3540 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3541 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3542 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_aci") == 0) {
3543 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3544 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3545 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_ecwmin") == 0) {
3546 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3547 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3548 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_ecwmax") == 0) {
3549 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3550 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3551 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_timer") == 0) {
3552 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3554 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_aifsn") == 0) {
3555 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3556 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3557 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_acm") == 0) {
3558 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3559 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3560 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_aci") == 0) {
3561 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3562 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3563 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_ecwmin") == 0) {
3564 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3565 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3566 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_ecwmax") == 0) {
3567 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3568 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3569 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_timer") == 0) {
3570 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3572 } else if (os_strcmp(buf
, "he_spr_sr_control") == 0) {
3573 conf
->spr
.sr_control
= atoi(pos
) & 0xff;
3574 } else if (os_strcmp(buf
, "he_spr_non_srg_obss_pd_max_offset") == 0) {
3575 conf
->spr
.non_srg_obss_pd_max_offset
= atoi(pos
);
3576 } else if (os_strcmp(buf
, "he_spr_srg_obss_pd_min_offset") == 0) {
3577 conf
->spr
.srg_obss_pd_min_offset
= atoi(pos
);
3578 } else if (os_strcmp(buf
, "he_spr_srg_obss_pd_max_offset") == 0) {
3579 conf
->spr
.srg_obss_pd_max_offset
= atoi(pos
);
3580 } else if (os_strcmp(buf
, "he_oper_chwidth") == 0) {
3581 conf
->he_oper_chwidth
= atoi(pos
);
3582 } else if (os_strcmp(buf
, "he_oper_centr_freq_seg0_idx") == 0) {
3583 conf
->he_oper_centr_freq_seg0_idx
= atoi(pos
);
3584 } else if (os_strcmp(buf
, "he_oper_centr_freq_seg1_idx") == 0) {
3585 conf
->he_oper_centr_freq_seg1_idx
= atoi(pos
);
3586 #endif /* CONFIG_IEEE80211AX */
3587 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
3588 bss
->max_listen_interval
= atoi(pos
);
3589 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
3590 bss
->disable_pmksa_caching
= atoi(pos
);
3591 } else if (os_strcmp(buf
, "okc") == 0) {
3592 bss
->okc
= atoi(pos
);
3594 } else if (os_strcmp(buf
, "wps_state") == 0) {
3595 bss
->wps_state
= atoi(pos
);
3596 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
3597 wpa_printf(MSG_ERROR
, "Line %d: invalid wps_state",
3601 } else if (os_strcmp(buf
, "wps_independent") == 0) {
3602 bss
->wps_independent
= atoi(pos
);
3603 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
3604 bss
->ap_setup_locked
= atoi(pos
);
3605 } else if (os_strcmp(buf
, "uuid") == 0) {
3606 if (uuid_str2bin(pos
, bss
->uuid
)) {
3607 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID", line
);
3610 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
3611 os_free(bss
->wps_pin_requests
);
3612 bss
->wps_pin_requests
= os_strdup(pos
);
3613 } else if (os_strcmp(buf
, "device_name") == 0) {
3614 if (os_strlen(pos
) > WPS_DEV_NAME_MAX_LEN
) {
3615 wpa_printf(MSG_ERROR
, "Line %d: Too long "
3616 "device_name", line
);
3619 os_free(bss
->device_name
);
3620 bss
->device_name
= os_strdup(pos
);
3621 } else if (os_strcmp(buf
, "manufacturer") == 0) {
3622 if (os_strlen(pos
) > 64) {
3623 wpa_printf(MSG_ERROR
, "Line %d: Too long manufacturer",
3627 os_free(bss
->manufacturer
);
3628 bss
->manufacturer
= os_strdup(pos
);
3629 } else if (os_strcmp(buf
, "model_name") == 0) {
3630 if (os_strlen(pos
) > 32) {
3631 wpa_printf(MSG_ERROR
, "Line %d: Too long model_name",
3635 os_free(bss
->model_name
);
3636 bss
->model_name
= os_strdup(pos
);
3637 } else if (os_strcmp(buf
, "model_number") == 0) {
3638 if (os_strlen(pos
) > 32) {
3639 wpa_printf(MSG_ERROR
, "Line %d: Too long model_number",
3643 os_free(bss
->model_number
);
3644 bss
->model_number
= os_strdup(pos
);
3645 } else if (os_strcmp(buf
, "serial_number") == 0) {
3646 if (os_strlen(pos
) > 32) {
3647 wpa_printf(MSG_ERROR
, "Line %d: Too long serial_number",
3651 os_free(bss
->serial_number
);
3652 bss
->serial_number
= os_strdup(pos
);
3653 } else if (os_strcmp(buf
, "device_type") == 0) {
3654 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
3656 } else if (os_strcmp(buf
, "config_methods") == 0) {
3657 os_free(bss
->config_methods
);
3658 bss
->config_methods
= os_strdup(pos
);
3659 } else if (os_strcmp(buf
, "os_version") == 0) {
3660 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
3661 wpa_printf(MSG_ERROR
, "Line %d: invalid os_version",
3665 } else if (os_strcmp(buf
, "ap_pin") == 0) {
3666 os_free(bss
->ap_pin
);
3670 bss
->ap_pin
= os_strdup(pos
);
3671 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
3672 bss
->skip_cred_build
= atoi(pos
);
3673 } else if (os_strcmp(buf
, "extra_cred") == 0) {
3674 os_free(bss
->extra_cred
);
3675 bss
->extra_cred
= (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
3676 if (bss
->extra_cred
== NULL
) {
3677 wpa_printf(MSG_ERROR
, "Line %d: could not read Credentials from '%s'",
3681 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
3682 bss
->wps_cred_processing
= atoi(pos
);
3683 } else if (os_strcmp(buf
, "wps_cred_add_sae") == 0) {
3684 bss
->wps_cred_add_sae
= atoi(pos
);
3685 } else if (os_strcmp(buf
, "ap_settings") == 0) {
3686 os_free(bss
->ap_settings
);
3688 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
3689 if (bss
->ap_settings
== NULL
) {
3690 wpa_printf(MSG_ERROR
, "Line %d: could not read AP Settings from '%s'",
3694 } else if (os_strcmp(buf
, "multi_ap_backhaul_ssid") == 0) {
3696 char *str
= wpa_config_parse_string(pos
, &slen
);
3698 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
3699 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
3704 os_memcpy(bss
->multi_ap_backhaul_ssid
.ssid
, str
, slen
);
3705 bss
->multi_ap_backhaul_ssid
.ssid_len
= slen
;
3706 bss
->multi_ap_backhaul_ssid
.ssid_set
= 1;
3708 } else if (os_strcmp(buf
, "multi_ap_backhaul_wpa_passphrase") == 0) {
3709 int len
= os_strlen(pos
);
3711 if (len
< 8 || len
> 63) {
3712 wpa_printf(MSG_ERROR
,
3713 "Line %d: invalid WPA passphrase length %d (expected 8..63)",
3717 os_free(bss
->multi_ap_backhaul_ssid
.wpa_passphrase
);
3718 bss
->multi_ap_backhaul_ssid
.wpa_passphrase
= os_strdup(pos
);
3719 if (bss
->multi_ap_backhaul_ssid
.wpa_passphrase
) {
3720 hostapd_config_clear_wpa_psk(
3721 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3722 bss
->multi_ap_backhaul_ssid
.wpa_passphrase_set
= 1;
3724 } else if (os_strcmp(buf
, "multi_ap_backhaul_wpa_psk") == 0) {
3725 hostapd_config_clear_wpa_psk(
3726 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3727 bss
->multi_ap_backhaul_ssid
.wpa_psk
=
3728 os_zalloc(sizeof(struct hostapd_wpa_psk
));
3729 if (!bss
->multi_ap_backhaul_ssid
.wpa_psk
)
3731 if (hexstr2bin(pos
, bss
->multi_ap_backhaul_ssid
.wpa_psk
->psk
,
3733 pos
[PMK_LEN
* 2] != '\0') {
3734 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
3736 hostapd_config_clear_wpa_psk(
3737 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3740 bss
->multi_ap_backhaul_ssid
.wpa_psk
->group
= 1;
3741 os_free(bss
->multi_ap_backhaul_ssid
.wpa_passphrase
);
3742 bss
->multi_ap_backhaul_ssid
.wpa_passphrase
= NULL
;
3743 bss
->multi_ap_backhaul_ssid
.wpa_psk_set
= 1;
3744 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
3745 os_free(bss
->upnp_iface
);
3746 bss
->upnp_iface
= os_strdup(pos
);
3747 } else if (os_strcmp(buf
, "friendly_name") == 0) {
3748 os_free(bss
->friendly_name
);
3749 bss
->friendly_name
= os_strdup(pos
);
3750 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
3751 os_free(bss
->manufacturer_url
);
3752 bss
->manufacturer_url
= os_strdup(pos
);
3753 } else if (os_strcmp(buf
, "model_description") == 0) {
3754 os_free(bss
->model_description
);
3755 bss
->model_description
= os_strdup(pos
);
3756 } else if (os_strcmp(buf
, "model_url") == 0) {
3757 os_free(bss
->model_url
);
3758 bss
->model_url
= os_strdup(pos
);
3759 } else if (os_strcmp(buf
, "upc") == 0) {
3761 bss
->upc
= os_strdup(pos
);
3762 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
3763 bss
->pbc_in_m1
= atoi(pos
);
3764 } else if (os_strcmp(buf
, "server_id") == 0) {
3765 os_free(bss
->server_id
);
3766 bss
->server_id
= os_strdup(pos
);
3767 } else if (os_strcmp(buf
, "wps_application_ext") == 0) {
3768 wpabuf_free(bss
->wps_application_ext
);
3769 bss
->wps_application_ext
= wpabuf_parse_bin(pos
);
3770 #ifdef CONFIG_WPS_NFC
3771 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
3772 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
3773 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
3774 bss
->wps_nfc_dev_pw_id
> 0xffff) {
3775 wpa_printf(MSG_ERROR
, "Line %d: Invalid wps_nfc_dev_pw_id value",
3779 bss
->wps_nfc_pw_from_config
= 1;
3780 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
3781 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
3782 bss
->wps_nfc_dh_pubkey
= wpabuf_parse_bin(pos
);
3783 bss
->wps_nfc_pw_from_config
= 1;
3784 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
3785 wpabuf_free(bss
->wps_nfc_dh_privkey
);
3786 bss
->wps_nfc_dh_privkey
= wpabuf_parse_bin(pos
);
3787 bss
->wps_nfc_pw_from_config
= 1;
3788 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
3789 wpabuf_free(bss
->wps_nfc_dev_pw
);
3790 bss
->wps_nfc_dev_pw
= wpabuf_parse_bin(pos
);
3791 bss
->wps_nfc_pw_from_config
= 1;
3792 #endif /* CONFIG_WPS_NFC */
3793 #endif /* CONFIG_WPS */
3794 #ifdef CONFIG_P2P_MANAGER
3795 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
3797 bss
->p2p
|= P2P_MANAGE
;
3799 bss
->p2p
&= ~P2P_MANAGE
;
3800 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
3802 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
3804 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
3805 #endif /* CONFIG_P2P_MANAGER */
3806 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
3807 bss
->disassoc_low_ack
= atoi(pos
);
3808 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
3810 bss
->tdls
|= TDLS_PROHIBIT
;
3812 bss
->tdls
&= ~TDLS_PROHIBIT
;
3813 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
3815 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
3817 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
3818 #ifdef CONFIG_RSN_TESTING
3819 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
3820 extern int rsn_testing
;
3821 rsn_testing
= atoi(pos
);
3822 #endif /* CONFIG_RSN_TESTING */
3823 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
3824 bss
->time_advertisement
= atoi(pos
);
3825 } else if (os_strcmp(buf
, "time_zone") == 0) {
3826 size_t tz_len
= os_strlen(pos
);
3827 if (tz_len
< 4 || tz_len
> 255) {
3828 wpa_printf(MSG_DEBUG
, "Line %d: invalid time_zone",
3832 os_free(bss
->time_zone
);
3833 bss
->time_zone
= os_strdup(pos
);
3834 if (bss
->time_zone
== NULL
)
3836 #ifdef CONFIG_WNM_AP
3837 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
3838 bss
->wnm_sleep_mode
= atoi(pos
);
3839 } else if (os_strcmp(buf
, "wnm_sleep_mode_no_keys") == 0) {
3840 bss
->wnm_sleep_mode_no_keys
= atoi(pos
);
3841 } else if (os_strcmp(buf
, "bss_transition") == 0) {
3842 bss
->bss_transition
= atoi(pos
);
3843 #endif /* CONFIG_WNM_AP */
3844 #ifdef CONFIG_INTERWORKING
3845 } else if (os_strcmp(buf
, "interworking") == 0) {
3846 bss
->interworking
= atoi(pos
);
3847 } else if (os_strcmp(buf
, "access_network_type") == 0) {
3848 bss
->access_network_type
= atoi(pos
);
3849 if (bss
->access_network_type
< 0 ||
3850 bss
->access_network_type
> 15) {
3851 wpa_printf(MSG_ERROR
,
3852 "Line %d: invalid access_network_type",
3856 } else if (os_strcmp(buf
, "internet") == 0) {
3857 bss
->internet
= atoi(pos
);
3858 } else if (os_strcmp(buf
, "asra") == 0) {
3859 bss
->asra
= atoi(pos
);
3860 } else if (os_strcmp(buf
, "esr") == 0) {
3861 bss
->esr
= atoi(pos
);
3862 } else if (os_strcmp(buf
, "uesa") == 0) {
3863 bss
->uesa
= atoi(pos
);
3864 } else if (os_strcmp(buf
, "venue_group") == 0) {
3865 bss
->venue_group
= atoi(pos
);
3866 bss
->venue_info_set
= 1;
3867 } else if (os_strcmp(buf
, "venue_type") == 0) {
3868 bss
->venue_type
= atoi(pos
);
3869 bss
->venue_info_set
= 1;
3870 } else if (os_strcmp(buf
, "hessid") == 0) {
3871 if (hwaddr_aton(pos
, bss
->hessid
)) {
3872 wpa_printf(MSG_ERROR
, "Line %d: invalid hessid", line
);
3875 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
3876 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
3878 } else if (os_strcmp(buf
, "venue_name") == 0) {
3879 if (parse_venue_name(bss
, pos
, line
) < 0)
3881 } else if (os_strcmp(buf
, "venue_url") == 0) {
3882 if (parse_venue_url(bss
, pos
, line
) < 0)
3884 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
3886 u16 redirect_url_len
;
3887 if (hexstr2bin(pos
, &auth_type
, 1)) {
3888 wpa_printf(MSG_ERROR
,
3889 "Line %d: Invalid network_auth_type '%s'",
3893 if (auth_type
== 0 || auth_type
== 2)
3894 redirect_url_len
= os_strlen(pos
+ 2);
3896 redirect_url_len
= 0;
3897 os_free(bss
->network_auth_type
);
3898 bss
->network_auth_type
= os_malloc(redirect_url_len
+ 3 + 1);
3899 if (bss
->network_auth_type
== NULL
)
3901 *bss
->network_auth_type
= auth_type
;
3902 WPA_PUT_LE16(bss
->network_auth_type
+ 1, redirect_url_len
);
3903 if (redirect_url_len
)
3904 os_memcpy(bss
->network_auth_type
+ 3, pos
+ 2,
3906 bss
->network_auth_type_len
= 3 + redirect_url_len
;
3907 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
3908 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1)) {
3909 wpa_printf(MSG_ERROR
, "Line %d: Invalid ipaddr_type_availability '%s'",
3911 bss
->ipaddr_type_configured
= 0;
3914 bss
->ipaddr_type_configured
= 1;
3915 } else if (os_strcmp(buf
, "domain_name") == 0) {
3916 int j
, num_domains
, domain_len
, domain_list_len
= 0;
3917 char *tok_start
, *tok_prev
;
3918 u8
*domain_list
, *domain_ptr
;
3920 domain_list_len
= os_strlen(pos
) + 1;
3921 domain_list
= os_malloc(domain_list_len
);
3922 if (domain_list
== NULL
)
3925 domain_ptr
= domain_list
;
3928 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
3933 for (j
= 0; j
< num_domains
; j
++) {
3934 tok_start
= os_strchr(tok_prev
, ',');
3936 domain_len
= tok_start
- tok_prev
;
3937 *domain_ptr
= domain_len
;
3938 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3939 domain_ptr
+= domain_len
+ 1;
3940 tok_prev
= ++tok_start
;
3942 domain_len
= os_strlen(tok_prev
);
3943 *domain_ptr
= domain_len
;
3944 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3945 domain_ptr
+= domain_len
+ 1;
3949 os_free(bss
->domain_name
);
3950 bss
->domain_name
= domain_list
;
3951 bss
->domain_name_len
= domain_list_len
;
3952 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
3953 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
3955 } else if (os_strcmp(buf
, "nai_realm") == 0) {
3956 if (parse_nai_realm(bss
, pos
, line
) < 0)
3958 } else if (os_strcmp(buf
, "anqp_elem") == 0) {
3959 if (parse_anqp_elem(bss
, pos
, line
) < 0)
3961 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
3962 int val
= atoi(pos
);
3965 wpa_printf(MSG_ERROR
,
3966 "Line %d: Invalid gas_frag_limit '%s'",
3970 bss
->gas_frag_limit
= val
;
3971 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
3972 bss
->gas_comeback_delay
= atoi(pos
);
3973 } else if (os_strcmp(buf
, "qos_map_set") == 0) {
3974 if (parse_qos_map_set(bss
, pos
, line
) < 0)
3976 #endif /* CONFIG_INTERWORKING */
3977 #ifdef CONFIG_RADIUS_TEST
3978 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
3979 os_free(bss
->dump_msk_file
);
3980 bss
->dump_msk_file
= os_strdup(pos
);
3981 #endif /* CONFIG_RADIUS_TEST */
3982 #ifdef CONFIG_PROXYARP
3983 } else if (os_strcmp(buf
, "proxy_arp") == 0) {
3984 bss
->proxy_arp
= atoi(pos
);
3985 #endif /* CONFIG_PROXYARP */
3987 } else if (os_strcmp(buf
, "hs20") == 0) {
3988 bss
->hs20
= atoi(pos
);
3989 } else if (os_strcmp(buf
, "hs20_release") == 0) {
3990 int val
= atoi(pos
);
3992 if (val
< 1 || val
> (HS20_VERSION
>> 4) + 1) {
3993 wpa_printf(MSG_ERROR
,
3994 "Line %d: Unsupported hs20_release: %s",
3998 bss
->hs20_release
= val
;
3999 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
4000 bss
->disable_dgaf
= atoi(pos
);
4001 } else if (os_strcmp(buf
, "na_mcast_to_ucast") == 0) {
4002 bss
->na_mcast_to_ucast
= atoi(pos
);
4003 } else if (os_strcmp(buf
, "osen") == 0) {
4004 bss
->osen
= atoi(pos
);
4005 } else if (os_strcmp(buf
, "anqp_domain_id") == 0) {
4006 bss
->anqp_domain_id
= atoi(pos
);
4007 } else if (os_strcmp(buf
, "hs20_deauth_req_timeout") == 0) {
4008 bss
->hs20_deauth_req_timeout
= atoi(pos
);
4009 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
4010 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
4012 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
4013 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0)
4015 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
4016 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
4019 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
4021 size_t oper_class_len
;
4022 oper_class_len
= os_strlen(pos
);
4023 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
4024 wpa_printf(MSG_ERROR
,
4025 "Line %d: Invalid hs20_operating_class '%s'",
4029 oper_class_len
/= 2;
4030 oper_class
= os_malloc(oper_class_len
);
4031 if (oper_class
== NULL
)
4033 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
4034 wpa_printf(MSG_ERROR
,
4035 "Line %d: Invalid hs20_operating_class '%s'",
4037 os_free(oper_class
);
4040 os_free(bss
->hs20_operating_class
);
4041 bss
->hs20_operating_class
= oper_class
;
4042 bss
->hs20_operating_class_len
= oper_class_len
;
4043 } else if (os_strcmp(buf
, "hs20_icon") == 0) {
4044 if (hs20_parse_icon(bss
, pos
) < 0) {
4045 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_icon '%s'",
4049 } else if (os_strcmp(buf
, "osu_ssid") == 0) {
4050 if (hs20_parse_osu_ssid(bss
, pos
, line
) < 0)
4052 } else if (os_strcmp(buf
, "osu_server_uri") == 0) {
4053 if (hs20_parse_osu_server_uri(bss
, pos
, line
) < 0)
4055 } else if (os_strcmp(buf
, "osu_friendly_name") == 0) {
4056 if (hs20_parse_osu_friendly_name(bss
, pos
, line
) < 0)
4058 } else if (os_strcmp(buf
, "osu_nai") == 0) {
4059 if (hs20_parse_osu_nai(bss
, pos
, line
) < 0)
4061 } else if (os_strcmp(buf
, "osu_nai2") == 0) {
4062 if (hs20_parse_osu_nai2(bss
, pos
, line
) < 0)
4064 } else if (os_strcmp(buf
, "osu_method_list") == 0) {
4065 if (hs20_parse_osu_method_list(bss
, pos
, line
) < 0)
4067 } else if (os_strcmp(buf
, "osu_icon") == 0) {
4068 if (hs20_parse_osu_icon(bss
, pos
, line
) < 0)
4070 } else if (os_strcmp(buf
, "osu_service_desc") == 0) {
4071 if (hs20_parse_osu_service_desc(bss
, pos
, line
) < 0)
4073 } else if (os_strcmp(buf
, "operator_icon") == 0) {
4074 if (hs20_parse_operator_icon(bss
, pos
, line
) < 0)
4076 } else if (os_strcmp(buf
, "subscr_remediation_url") == 0) {
4077 os_free(bss
->subscr_remediation_url
);
4078 bss
->subscr_remediation_url
= os_strdup(pos
);
4079 } else if (os_strcmp(buf
, "subscr_remediation_method") == 0) {
4080 bss
->subscr_remediation_method
= atoi(pos
);
4081 } else if (os_strcmp(buf
, "hs20_t_c_filename") == 0) {
4082 os_free(bss
->t_c_filename
);
4083 bss
->t_c_filename
= os_strdup(pos
);
4084 } else if (os_strcmp(buf
, "hs20_t_c_timestamp") == 0) {
4085 bss
->t_c_timestamp
= strtol(pos
, NULL
, 0);
4086 } else if (os_strcmp(buf
, "hs20_t_c_server_url") == 0) {
4087 os_free(bss
->t_c_server_url
);
4088 bss
->t_c_server_url
= os_strdup(pos
);
4089 } else if (os_strcmp(buf
, "hs20_sim_provisioning_url") == 0) {
4090 os_free(bss
->hs20_sim_provisioning_url
);
4091 bss
->hs20_sim_provisioning_url
= os_strdup(pos
);
4092 #endif /* CONFIG_HS20 */
4094 } else if (os_strcmp(buf
, "mbo") == 0) {
4095 bss
->mbo_enabled
= atoi(pos
);
4096 } else if (os_strcmp(buf
, "mbo_cell_data_conn_pref") == 0) {
4097 bss
->mbo_cell_data_conn_pref
= atoi(pos
);
4098 } else if (os_strcmp(buf
, "oce") == 0) {
4099 bss
->oce
= atoi(pos
);
4100 #endif /* CONFIG_MBO */
4101 #ifdef CONFIG_TESTING_OPTIONS
4102 #define PARSE_TEST_PROBABILITY(_val) \
4103 } else if (os_strcmp(buf, #_val) == 0) { \
4106 conf->_val = strtod(pos, &end); \
4107 if (*end || conf->_val < 0.0 || \
4108 conf->_val > 1.0) { \
4109 wpa_printf(MSG_ERROR, \
4110 "Line %d: Invalid value '%s'", \
4114 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
4115 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
4116 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
4117 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
4118 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
4119 } else if (os_strcmp(buf
, "ecsa_ie_only") == 0) {
4120 conf
->ecsa_ie_only
= atoi(pos
);
4121 } else if (os_strcmp(buf
, "bss_load_test") == 0) {
4122 WPA_PUT_LE16(bss
->bss_load_test
, atoi(pos
));
4123 pos
= os_strchr(pos
, ':');
4125 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
4130 bss
->bss_load_test
[2] = atoi(pos
);
4131 pos
= os_strchr(pos
, ':');
4133 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
4138 WPA_PUT_LE16(&bss
->bss_load_test
[3], atoi(pos
));
4139 bss
->bss_load_test_set
= 1;
4140 } else if (os_strcmp(buf
, "radio_measurements") == 0) {
4142 * DEPRECATED: This parameter will be removed in the future.
4143 * Use rrm_neighbor_report instead.
4145 int val
= atoi(pos
);
4148 bss
->radio_measurements
[0] |=
4149 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
4150 } else if (os_strcmp(buf
, "own_ie_override") == 0) {
4152 size_t len
= os_strlen(pos
) / 2;
4154 tmp
= wpabuf_alloc(len
);
4158 if (hexstr2bin(pos
, wpabuf_put(tmp
, len
), len
)) {
4160 wpa_printf(MSG_ERROR
,
4161 "Line %d: Invalid own_ie_override '%s'",
4166 wpabuf_free(bss
->own_ie_override
);
4167 bss
->own_ie_override
= tmp
;
4168 } else if (os_strcmp(buf
, "sae_reflection_attack") == 0) {
4169 bss
->sae_reflection_attack
= atoi(pos
);
4170 } else if (os_strcmp(buf
, "sae_commit_override") == 0) {
4171 wpabuf_free(bss
->sae_commit_override
);
4172 bss
->sae_commit_override
= wpabuf_parse_bin(pos
);
4173 } else if (os_strcmp(buf
, "rsnxe_override_eapol") == 0) {
4174 wpabuf_free(bss
->rsnxe_override_eapol
);
4175 bss
->rsnxe_override_eapol
= wpabuf_parse_bin(pos
);
4176 } else if (os_strcmp(buf
, "gtk_rsc_override") == 0) {
4177 wpabuf_free(bss
->gtk_rsc_override
);
4178 bss
->gtk_rsc_override
= wpabuf_parse_bin(pos
);
4179 } else if (os_strcmp(buf
, "igtk_rsc_override") == 0) {
4180 wpabuf_free(bss
->igtk_rsc_override
);
4181 bss
->igtk_rsc_override
= wpabuf_parse_bin(pos
);
4182 #endif /* CONFIG_TESTING_OPTIONS */
4184 } else if (os_strcmp(buf
, "sae_password") == 0) {
4185 if (parse_sae_password(bss
, pos
) < 0) {
4186 wpa_printf(MSG_ERROR
, "Line %d: Invalid sae_password",
4190 #endif /* CONFIG_SAE */
4191 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
4192 if (parse_wpabuf_hex(line
, buf
, &bss
->vendor_elements
, pos
))
4194 } else if (os_strcmp(buf
, "assocresp_elements") == 0) {
4195 if (parse_wpabuf_hex(line
, buf
, &bss
->assocresp_elements
, pos
))
4197 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
4198 bss
->sae_anti_clogging_threshold
= atoi(pos
);
4199 } else if (os_strcmp(buf
, "sae_sync") == 0) {
4200 bss
->sae_sync
= atoi(pos
);
4201 } else if (os_strcmp(buf
, "sae_groups") == 0) {
4202 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
4203 wpa_printf(MSG_ERROR
,
4204 "Line %d: Invalid sae_groups value '%s'",
4208 } else if (os_strcmp(buf
, "sae_require_mfp") == 0) {
4209 bss
->sae_require_mfp
= atoi(pos
);
4210 } else if (os_strcmp(buf
, "sae_confirm_immediate") == 0) {
4211 bss
->sae_confirm_immediate
= atoi(pos
);
4212 } else if (os_strcmp(buf
, "sae_pwe") == 0) {
4213 bss
->sae_pwe
= atoi(pos
);
4214 } else if (os_strcmp(buf
, "local_pwr_constraint") == 0) {
4215 int val
= atoi(pos
);
4216 if (val
< 0 || val
> 255) {
4217 wpa_printf(MSG_ERROR
, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
4221 conf
->local_pwr_constraint
= val
;
4222 } else if (os_strcmp(buf
, "spectrum_mgmt_required") == 0) {
4223 conf
->spectrum_mgmt_required
= atoi(pos
);
4224 } else if (os_strcmp(buf
, "wowlan_triggers") == 0) {
4225 os_free(bss
->wowlan_triggers
);
4226 bss
->wowlan_triggers
= os_strdup(pos
);
4228 } else if (os_strcmp(buf
, "fst_group_id") == 0) {
4229 size_t len
= os_strlen(pos
);
4231 if (!len
|| len
>= sizeof(conf
->fst_cfg
.group_id
)) {
4232 wpa_printf(MSG_ERROR
,
4233 "Line %d: Invalid fst_group_id value '%s'",
4238 if (conf
->fst_cfg
.group_id
[0]) {
4239 wpa_printf(MSG_ERROR
,
4240 "Line %d: Duplicate fst_group value '%s'",
4245 os_strlcpy(conf
->fst_cfg
.group_id
, pos
,
4246 sizeof(conf
->fst_cfg
.group_id
));
4247 } else if (os_strcmp(buf
, "fst_priority") == 0) {
4252 wpa_printf(MSG_ERROR
,
4253 "Line %d: fst_priority value not supplied (expected 1..%u)",
4254 line
, FST_MAX_PRIO_VALUE
);
4258 val
= strtol(pos
, &endp
, 0);
4259 if (*endp
|| val
< 1 || val
> FST_MAX_PRIO_VALUE
) {
4260 wpa_printf(MSG_ERROR
,
4261 "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)",
4262 line
, val
, pos
, FST_MAX_PRIO_VALUE
);
4265 conf
->fst_cfg
.priority
= (u8
) val
;
4266 } else if (os_strcmp(buf
, "fst_llt") == 0) {
4271 wpa_printf(MSG_ERROR
,
4272 "Line %d: fst_llt value not supplied (expected 1..%u)",
4273 line
, FST_MAX_LLT_MS
);
4276 val
= strtol(pos
, &endp
, 0);
4277 if (*endp
|| val
< 1 ||
4278 (unsigned long int) val
> FST_MAX_LLT_MS
) {
4279 wpa_printf(MSG_ERROR
,
4280 "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
4281 line
, val
, pos
, FST_MAX_LLT_MS
);
4284 conf
->fst_cfg
.llt
= (u32
) val
;
4285 #endif /* CONFIG_FST */
4286 } else if (os_strcmp(buf
, "track_sta_max_num") == 0) {
4287 conf
->track_sta_max_num
= atoi(pos
);
4288 } else if (os_strcmp(buf
, "track_sta_max_age") == 0) {
4289 conf
->track_sta_max_age
= atoi(pos
);
4290 } else if (os_strcmp(buf
, "no_probe_resp_if_seen_on") == 0) {
4291 os_free(bss
->no_probe_resp_if_seen_on
);
4292 bss
->no_probe_resp_if_seen_on
= os_strdup(pos
);
4293 } else if (os_strcmp(buf
, "no_auth_if_seen_on") == 0) {
4294 os_free(bss
->no_auth_if_seen_on
);
4295 bss
->no_auth_if_seen_on
= os_strdup(pos
);
4296 } else if (os_strcmp(buf
, "lci") == 0) {
4297 wpabuf_free(conf
->lci
);
4298 conf
->lci
= wpabuf_parse_bin(pos
);
4299 if (conf
->lci
&& wpabuf_len(conf
->lci
) == 0) {
4300 wpabuf_free(conf
->lci
);
4303 } else if (os_strcmp(buf
, "civic") == 0) {
4304 wpabuf_free(conf
->civic
);
4305 conf
->civic
= wpabuf_parse_bin(pos
);
4306 if (conf
->civic
&& wpabuf_len(conf
->civic
) == 0) {
4307 wpabuf_free(conf
->civic
);
4310 } else if (os_strcmp(buf
, "rrm_neighbor_report") == 0) {
4312 bss
->radio_measurements
[0] |=
4313 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
4314 } else if (os_strcmp(buf
, "rrm_beacon_report") == 0) {
4316 bss
->radio_measurements
[0] |=
4317 WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE
|
4318 WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE
|
4319 WLAN_RRM_CAPS_BEACON_REPORT_TABLE
;
4320 } else if (os_strcmp(buf
, "gas_address3") == 0) {
4321 bss
->gas_address3
= atoi(pos
);
4322 } else if (os_strcmp(buf
, "stationary_ap") == 0) {
4323 conf
->stationary_ap
= atoi(pos
);
4324 } else if (os_strcmp(buf
, "ftm_responder") == 0) {
4325 bss
->ftm_responder
= atoi(pos
);
4326 } else if (os_strcmp(buf
, "ftm_initiator") == 0) {
4327 bss
->ftm_initiator
= atoi(pos
);
4329 } else if (os_strcmp(buf
, "fils_cache_id") == 0) {
4330 if (hexstr2bin(pos
, bss
->fils_cache_id
, FILS_CACHE_ID_LEN
)) {
4331 wpa_printf(MSG_ERROR
,
4332 "Line %d: Invalid fils_cache_id '%s'",
4336 bss
->fils_cache_id_set
= 1;
4337 } else if (os_strcmp(buf
, "fils_realm") == 0) {
4338 if (parse_fils_realm(bss
, pos
) < 0)
4340 } else if (os_strcmp(buf
, "fils_dh_group") == 0) {
4341 bss
->fils_dh_group
= atoi(pos
);
4342 } else if (os_strcmp(buf
, "dhcp_server") == 0) {
4343 if (hostapd_parse_ip_addr(pos
, &bss
->dhcp_server
)) {
4344 wpa_printf(MSG_ERROR
,
4345 "Line %d: invalid IP address '%s'",
4349 } else if (os_strcmp(buf
, "dhcp_rapid_commit_proxy") == 0) {
4350 bss
->dhcp_rapid_commit_proxy
= atoi(pos
);
4351 } else if (os_strcmp(buf
, "fils_hlp_wait_time") == 0) {
4352 bss
->fils_hlp_wait_time
= atoi(pos
);
4353 } else if (os_strcmp(buf
, "dhcp_server_port") == 0) {
4354 bss
->dhcp_server_port
= atoi(pos
);
4355 } else if (os_strcmp(buf
, "dhcp_relay_port") == 0) {
4356 bss
->dhcp_relay_port
= atoi(pos
);
4357 #endif /* CONFIG_FILS */
4358 } else if (os_strcmp(buf
, "multicast_to_unicast") == 0) {
4359 bss
->multicast_to_unicast
= atoi(pos
);
4360 } else if (os_strcmp(buf
, "broadcast_deauth") == 0) {
4361 bss
->broadcast_deauth
= atoi(pos
);
4363 } else if (os_strcmp(buf
, "dpp_name") == 0) {
4364 os_free(bss
->dpp_name
);
4365 bss
->dpp_name
= os_strdup(pos
);
4366 } else if (os_strcmp(buf
, "dpp_mud_url") == 0) {
4367 os_free(bss
->dpp_mud_url
);
4368 bss
->dpp_mud_url
= os_strdup(pos
);
4369 } else if (os_strcmp(buf
, "dpp_connector") == 0) {
4370 os_free(bss
->dpp_connector
);
4371 bss
->dpp_connector
= os_strdup(pos
);
4372 } else if (os_strcmp(buf
, "dpp_netaccesskey") == 0) {
4373 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_netaccesskey
, pos
))
4375 } else if (os_strcmp(buf
, "dpp_netaccesskey_expiry") == 0) {
4376 bss
->dpp_netaccesskey_expiry
= strtol(pos
, NULL
, 0);
4377 } else if (os_strcmp(buf
, "dpp_csign") == 0) {
4378 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_csign
, pos
))
4381 } else if (os_strcmp(buf
, "dpp_controller") == 0) {
4382 if (hostapd_dpp_controller_parse(bss
, pos
))
4384 #endif /* CONFIG_DPP2 */
4385 #endif /* CONFIG_DPP */
4387 } else if (os_strcmp(buf
, "owe_transition_bssid") == 0) {
4388 if (hwaddr_aton(pos
, bss
->owe_transition_bssid
)) {
4389 wpa_printf(MSG_ERROR
,
4390 "Line %d: invalid owe_transition_bssid",
4394 } else if (os_strcmp(buf
, "owe_transition_ssid") == 0) {
4396 char *str
= wpa_config_parse_string(pos
, &slen
);
4398 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
4399 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
4404 os_memcpy(bss
->owe_transition_ssid
, str
, slen
);
4405 bss
->owe_transition_ssid_len
= slen
;
4407 } else if (os_strcmp(buf
, "owe_transition_ifname") == 0) {
4408 os_strlcpy(bss
->owe_transition_ifname
, pos
,
4409 sizeof(bss
->owe_transition_ifname
));
4410 } else if (os_strcmp(buf
, "owe_groups") == 0) {
4411 if (hostapd_parse_intlist(&bss
->owe_groups
, pos
)) {
4412 wpa_printf(MSG_ERROR
,
4413 "Line %d: Invalid owe_groups value '%s'",
4417 } else if (os_strcmp(buf
, "owe_ptk_workaround") == 0) {
4418 bss
->owe_ptk_workaround
= atoi(pos
);
4419 #endif /* CONFIG_OWE */
4420 } else if (os_strcmp(buf
, "coloc_intf_reporting") == 0) {
4421 bss
->coloc_intf_reporting
= atoi(pos
);
4422 } else if (os_strcmp(buf
, "multi_ap") == 0) {
4423 int val
= atoi(pos
);
4425 if (val
< 0 || val
> 3) {
4426 wpa_printf(MSG_ERROR
, "Line %d: Invalid multi_ap '%s'",
4431 bss
->multi_ap
= val
;
4432 } else if (os_strcmp(buf
, "rssi_reject_assoc_rssi") == 0) {
4433 conf
->rssi_reject_assoc_rssi
= atoi(pos
);
4434 } else if (os_strcmp(buf
, "rssi_reject_assoc_timeout") == 0) {
4435 conf
->rssi_reject_assoc_timeout
= atoi(pos
);
4436 } else if (os_strcmp(buf
, "pbss") == 0) {
4437 bss
->pbss
= atoi(pos
);
4438 #ifdef CONFIG_AIRTIME_POLICY
4439 } else if (os_strcmp(buf
, "airtime_mode") == 0) {
4440 int val
= atoi(pos
);
4442 if (val
< 0 || val
> AIRTIME_MODE_MAX
) {
4443 wpa_printf(MSG_ERROR
, "Line %d: Unknown airtime_mode",
4447 conf
->airtime_mode
= val
;
4448 } else if (os_strcmp(buf
, "airtime_update_interval") == 0) {
4449 conf
->airtime_update_interval
= atoi(pos
);
4450 } else if (os_strcmp(buf
, "airtime_bss_weight") == 0) {
4451 bss
->airtime_weight
= atoi(pos
);
4452 } else if (os_strcmp(buf
, "airtime_bss_limit") == 0) {
4453 int val
= atoi(pos
);
4455 if (val
< 0 || val
> 1) {
4456 wpa_printf(MSG_ERROR
,
4457 "Line %d: Invalid airtime_bss_limit (must be 0 or 1)",
4461 bss
->airtime_limit
= val
;
4462 } else if (os_strcmp(buf
, "airtime_sta_weight") == 0) {
4463 if (add_airtime_weight(bss
, pos
) < 0) {
4464 wpa_printf(MSG_ERROR
,
4465 "Line %d: Invalid airtime weight '%s'",
4469 #endif /* CONFIG_AIRTIME_POLICY */
4470 #ifdef CONFIG_MACSEC
4471 } else if (os_strcmp(buf
, "macsec_policy") == 0) {
4472 int macsec_policy
= atoi(pos
);
4474 if (macsec_policy
< 0 || macsec_policy
> 1) {
4475 wpa_printf(MSG_ERROR
,
4476 "Line %d: invalid macsec_policy (%d): '%s'.",
4477 line
, macsec_policy
, pos
);
4480 bss
->macsec_policy
= macsec_policy
;
4481 } else if (os_strcmp(buf
, "macsec_integ_only") == 0) {
4482 int macsec_integ_only
= atoi(pos
);
4484 if (macsec_integ_only
< 0 || macsec_integ_only
> 1) {
4485 wpa_printf(MSG_ERROR
,
4486 "Line %d: invalid macsec_integ_only (%d): '%s'.",
4487 line
, macsec_integ_only
, pos
);
4490 bss
->macsec_integ_only
= macsec_integ_only
;
4491 } else if (os_strcmp(buf
, "macsec_replay_protect") == 0) {
4492 int macsec_replay_protect
= atoi(pos
);
4494 if (macsec_replay_protect
< 0 || macsec_replay_protect
> 1) {
4495 wpa_printf(MSG_ERROR
,
4496 "Line %d: invalid macsec_replay_protect (%d): '%s'.",
4497 line
, macsec_replay_protect
, pos
);
4500 bss
->macsec_replay_protect
= macsec_replay_protect
;
4501 } else if (os_strcmp(buf
, "macsec_replay_window") == 0) {
4502 bss
->macsec_replay_window
= atoi(pos
);
4503 } else if (os_strcmp(buf
, "macsec_port") == 0) {
4504 int macsec_port
= atoi(pos
);
4506 if (macsec_port
< 1 || macsec_port
> 65534) {
4507 wpa_printf(MSG_ERROR
,
4508 "Line %d: invalid macsec_port (%d): '%s'.",
4509 line
, macsec_port
, pos
);
4512 bss
->macsec_port
= macsec_port
;
4513 } else if (os_strcmp(buf
, "mka_priority") == 0) {
4514 int mka_priority
= atoi(pos
);
4516 if (mka_priority
< 0 || mka_priority
> 255) {
4517 wpa_printf(MSG_ERROR
,
4518 "Line %d: invalid mka_priority (%d): '%s'.",
4519 line
, mka_priority
, pos
);
4522 bss
->mka_priority
= mka_priority
;
4523 } else if (os_strcmp(buf
, "mka_cak") == 0) {
4524 size_t len
= os_strlen(pos
);
4526 if (len
> 2 * MACSEC_CAK_MAX_LEN
||
4527 (len
!= 2 * 16 && len
!= 2 * 32) ||
4528 hexstr2bin(pos
, bss
->mka_cak
, len
/ 2)) {
4529 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CAK '%s'.",
4533 bss
->mka_cak_len
= len
/ 2;
4534 bss
->mka_psk_set
|= MKA_PSK_SET_CAK
;
4535 } else if (os_strcmp(buf
, "mka_ckn") == 0) {
4536 size_t len
= os_strlen(pos
);
4538 if (len
> 2 * MACSEC_CKN_MAX_LEN
|| /* too long */
4539 len
< 2 || /* too short */
4540 len
% 2 != 0 /* not an integral number of bytes */) {
4541 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CKN '%s'.",
4545 bss
->mka_ckn_len
= len
/ 2;
4546 if (hexstr2bin(pos
, bss
->mka_ckn
, bss
->mka_ckn_len
)) {
4547 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CKN '%s'.",
4551 bss
->mka_psk_set
|= MKA_PSK_SET_CKN
;
4552 #endif /* CONFIG_MACSEC */
4554 wpa_printf(MSG_ERROR
,
4555 "Line %d: unknown configuration item '%s'",
4565 * hostapd_config_read - Read and parse a configuration file
4566 * @fname: Configuration file name (including path, if needed)
4567 * Returns: Allocated configuration data structure
4569 struct hostapd_config
* hostapd_config_read(const char *fname
)
4571 struct hostapd_config
*conf
;
4573 char buf
[4096], *pos
;
4578 f
= fopen(fname
, "r");
4580 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
4581 "for reading.", fname
);
4585 conf
= hostapd_config_defaults();
4591 /* set default driver based on configuration */
4592 conf
->driver
= wpa_drivers
[0];
4593 if (conf
->driver
== NULL
) {
4594 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
4595 hostapd_config_free(conf
);
4600 conf
->last_bss
= conf
->bss
[0];
4602 while (fgets(buf
, sizeof(buf
), f
)) {
4603 struct hostapd_bss_config
*bss
;
4605 bss
= conf
->last_bss
;
4611 while (*pos
!= '\0') {
4621 pos
= os_strchr(buf
, '=');
4623 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
4630 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
4635 for (i
= 0; i
< conf
->num_bss
; i
++)
4636 hostapd_set_security_params(conf
->bss
[i
], 1);
4638 if (hostapd_config_check(conf
, 1))
4641 #ifndef WPA_IGNORE_CONFIG_ERRORS
4643 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
4644 "'%s'", errors
, fname
);
4645 hostapd_config_free(conf
);
4648 #endif /* WPA_IGNORE_CONFIG_ERRORS */
4654 int hostapd_set_iface(struct hostapd_config
*conf
,
4655 struct hostapd_bss_config
*bss
, const char *field
,
4661 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
4663 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
4664 "to value '%s'", field
, value
);
4668 for (i
= 0; i
< conf
->num_bss
; i
++)
4669 hostapd_set_security_params(conf
->bss
[i
], 0);
4671 if (hostapd_config_check(conf
, 0)) {
4672 wpa_printf(MSG_ERROR
, "Configuration check failed");