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 #ifdef CONFIG_IEEE80211W
715 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
716 val
|= WPA_KEY_MGMT_PSK_SHA256
;
717 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
718 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
719 #endif /* CONFIG_IEEE80211W */
721 else if (os_strcmp(start
, "SAE") == 0)
722 val
|= WPA_KEY_MGMT_SAE
;
723 else if (os_strcmp(start
, "FT-SAE") == 0)
724 val
|= WPA_KEY_MGMT_FT_SAE
;
725 #endif /* CONFIG_SAE */
727 else if (os_strcmp(start
, "WPA-EAP-SUITE-B") == 0)
728 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B
;
729 #endif /* CONFIG_SUITEB */
730 #ifdef CONFIG_SUITEB192
731 else if (os_strcmp(start
, "WPA-EAP-SUITE-B-192") == 0)
732 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192
;
733 #endif /* CONFIG_SUITEB192 */
735 else if (os_strcmp(start
, "FILS-SHA256") == 0)
736 val
|= WPA_KEY_MGMT_FILS_SHA256
;
737 else if (os_strcmp(start
, "FILS-SHA384") == 0)
738 val
|= WPA_KEY_MGMT_FILS_SHA384
;
739 #ifdef CONFIG_IEEE80211R_AP
740 else if (os_strcmp(start
, "FT-FILS-SHA256") == 0)
741 val
|= WPA_KEY_MGMT_FT_FILS_SHA256
;
742 else if (os_strcmp(start
, "FT-FILS-SHA384") == 0)
743 val
|= WPA_KEY_MGMT_FT_FILS_SHA384
;
744 #endif /* CONFIG_IEEE80211R_AP */
745 #endif /* CONFIG_FILS */
747 else if (os_strcmp(start
, "OWE") == 0)
748 val
|= WPA_KEY_MGMT_OWE
;
749 #endif /* CONFIG_OWE */
751 else if (os_strcmp(start
, "DPP") == 0)
752 val
|= WPA_KEY_MGMT_DPP
;
753 #endif /* CONFIG_DPP */
755 else if (os_strcmp(start
, "OSEN") == 0)
756 val
|= WPA_KEY_MGMT_OSEN
;
757 #endif /* CONFIG_HS20 */
759 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
772 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
773 "configured.", line
);
781 static int hostapd_config_parse_cipher(int line
, const char *value
)
783 int val
= wpa_parse_cipher(value
);
785 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
790 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
798 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
801 size_t len
= os_strlen(val
);
803 if (keyidx
< 0 || keyidx
> 3)
809 bin_clear_free(wep
->key
[keyidx
], wep
->len
[keyidx
]);
810 wep
->key
[keyidx
] = NULL
;
811 wep
->len
[keyidx
] = 0;
812 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
821 if (wep
->key
[keyidx
] != NULL
)
825 if (len
< 2 || val
[len
- 1] != '"')
828 wep
->key
[keyidx
] = os_memdup(val
+ 1, len
);
829 if (wep
->key
[keyidx
] == NULL
)
831 wep
->len
[keyidx
] = len
;
836 wep
->key
[keyidx
] = os_malloc(len
);
837 if (wep
->key
[keyidx
] == NULL
)
839 wep
->len
[keyidx
] = len
;
840 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
850 static int hostapd_parse_chanlist(struct hostapd_config
*conf
, char *val
)
854 /* for backwards compatibility, translate ' ' in conf str to ',' */
857 pos
= os_strchr(pos
, ' ');
861 if (freq_range_list_parse(&conf
->acs_ch_list
, val
))
868 static int hostapd_parse_intlist(int **int_list
, char *val
)
879 while (*pos
!= '\0') {
885 list
= os_malloc(sizeof(int) * (count
+ 2));
890 while (*pos
!= '\0') {
891 end
= os_strchr(pos
, ' ');
895 list
[count
++] = atoi(pos
);
907 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
909 struct hostapd_bss_config
**all
, *bss
;
914 all
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
915 sizeof(struct hostapd_bss_config
*));
917 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
923 bss
= os_zalloc(sizeof(*bss
));
926 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
927 if (bss
->radius
== NULL
) {
928 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
929 "multi-BSS RADIUS data");
934 conf
->bss
[conf
->num_bss
++] = bss
;
935 conf
->last_bss
= bss
;
937 hostapd_config_defaults_bss(bss
);
938 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
939 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
945 /* convert floats with one decimal place to value*10 int, i.e.,
946 * "1.5" will return 15 */
947 static int hostapd_config_read_int10(const char *value
)
953 pos
= os_strchr(value
, '.');
957 if (*pos
>= '0' && *pos
<= '9')
965 static int valid_cw(int cw
)
967 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
968 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023 ||
969 cw
== 2047 || cw
== 4095 || cw
== 8191 || cw
== 16383 ||
975 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
976 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
977 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
978 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
981 static int hostapd_config_tx_queue(struct hostapd_config
*conf
,
982 const char *name
, const char *val
)
986 struct hostapd_tx_queue_params
*queue
;
988 /* skip 'tx_queue_' prefix */
990 if (os_strncmp(pos
, "data", 4) == 0 &&
991 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
994 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
995 os_strncmp(pos
, "beacon_", 7) == 0) {
996 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
999 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
1003 if (num
>= NUM_TX_QUEUES
) {
1004 /* for backwards compatibility, do not trigger failure */
1005 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
1009 queue
= &conf
->tx_queue
[num
];
1011 if (os_strcmp(pos
, "aifs") == 0) {
1012 queue
->aifs
= atoi(val
);
1013 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
1014 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
1018 } else if (os_strcmp(pos
, "cwmin") == 0) {
1019 queue
->cwmin
= atoi(val
);
1020 if (!valid_cw(queue
->cwmin
)) {
1021 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
1025 } else if (os_strcmp(pos
, "cwmax") == 0) {
1026 queue
->cwmax
= atoi(val
);
1027 if (!valid_cw(queue
->cwmax
)) {
1028 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
1032 } else if (os_strcmp(pos
, "burst") == 0) {
1033 queue
->burst
= hostapd_config_read_int10(val
);
1035 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
1043 #ifdef CONFIG_IEEE80211R_AP
1045 static int rkh_derive_key(const char *pos
, u8
*key
, size_t key_len
)
1050 if (!hexstr2bin(pos
, key
, key_len
))
1053 /* Try to use old short key for backwards compatibility */
1054 if (hexstr2bin(pos
, oldkey
, sizeof(oldkey
)))
1057 ret
= hmac_sha256_kdf(oldkey
, sizeof(oldkey
), "FT OLDKEY", NULL
, 0,
1059 os_memset(oldkey
, 0, sizeof(oldkey
));
1064 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
1066 struct ft_remote_r0kh
*r0kh
;
1069 r0kh
= os_zalloc(sizeof(*r0kh
));
1073 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1075 next
= os_strchr(pos
, ' ');
1078 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
1079 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
1085 next
= os_strchr(pos
, ' ');
1088 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
1089 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
1093 r0kh
->id_len
= next
- pos
- 1;
1094 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
1097 if (rkh_derive_key(pos
, r0kh
->key
, sizeof(r0kh
->key
)) < 0) {
1098 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
1103 r0kh
->next
= bss
->r0kh_list
;
1104 bss
->r0kh_list
= r0kh
;
1110 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
1112 struct ft_remote_r1kh
*r1kh
;
1115 r1kh
= os_zalloc(sizeof(*r1kh
));
1119 /* 02:01:02:03:04:05 02:01:02:03:04:05
1120 * 000102030405060708090a0b0c0d0e0f */
1122 next
= os_strchr(pos
, ' ');
1125 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
1126 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
1132 next
= os_strchr(pos
, ' ');
1135 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
1136 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
1142 if (rkh_derive_key(pos
, r1kh
->key
, sizeof(r1kh
->key
)) < 0) {
1143 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
1148 r1kh
->next
= bss
->r1kh_list
;
1149 bss
->r1kh_list
= r1kh
;
1153 #endif /* CONFIG_IEEE80211R_AP */
1156 #ifdef CONFIG_IEEE80211N
1157 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
1160 if (os_strstr(capab
, "[LDPC]"))
1161 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
1162 if (os_strstr(capab
, "[HT40-]")) {
1163 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1164 conf
->secondary_channel
= -1;
1166 if (os_strstr(capab
, "[HT40+]")) {
1167 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1168 conf
->secondary_channel
= 1;
1170 if (os_strstr(capab
, "[HT40+]") && os_strstr(capab
, "[HT40-]")) {
1171 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1172 conf
->ht40_plus_minus_allowed
= 1;
1174 if (!os_strstr(capab
, "[HT40+]") && !os_strstr(capab
, "[HT40-]"))
1175 conf
->secondary_channel
= 0;
1176 if (os_strstr(capab
, "[SMPS-STATIC]")) {
1177 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1178 conf
->ht_capab
|= HT_CAP_INFO_SMPS_STATIC
;
1180 if (os_strstr(capab
, "[SMPS-DYNAMIC]")) {
1181 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1182 conf
->ht_capab
|= HT_CAP_INFO_SMPS_DYNAMIC
;
1184 if (os_strstr(capab
, "[GF]"))
1185 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
1186 if (os_strstr(capab
, "[SHORT-GI-20]"))
1187 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1188 if (os_strstr(capab
, "[SHORT-GI-40]"))
1189 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1190 if (os_strstr(capab
, "[TX-STBC]"))
1191 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1192 if (os_strstr(capab
, "[RX-STBC1]")) {
1193 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1194 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1196 if (os_strstr(capab
, "[RX-STBC12]")) {
1197 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1198 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1200 if (os_strstr(capab
, "[RX-STBC123]")) {
1201 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1202 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1204 if (os_strstr(capab
, "[DELAYED-BA]"))
1205 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1206 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1207 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1208 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1209 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1210 if (os_strstr(capab
, "[40-INTOLERANT]"))
1211 conf
->ht_capab
|= HT_CAP_INFO_40MHZ_INTOLERANT
;
1212 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1213 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1217 #endif /* CONFIG_IEEE80211N */
1220 #ifdef CONFIG_IEEE80211AC
1221 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1224 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1225 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1226 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1227 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1228 if (os_strstr(capab
, "[VHT160]"))
1229 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1230 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1231 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1232 if (os_strstr(capab
, "[RXLDPC]"))
1233 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1234 if (os_strstr(capab
, "[SHORT-GI-80]"))
1235 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1236 if (os_strstr(capab
, "[SHORT-GI-160]"))
1237 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1238 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1239 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1240 if (os_strstr(capab
, "[RX-STBC-1]"))
1241 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1242 if (os_strstr(capab
, "[RX-STBC-12]"))
1243 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1244 if (os_strstr(capab
, "[RX-STBC-123]"))
1245 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1246 if (os_strstr(capab
, "[RX-STBC-1234]"))
1247 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1248 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1249 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMER_CAPABLE
;
1250 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1251 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
1252 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1253 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1254 conf
->vht_capab
|= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1255 if (os_strstr(capab
, "[BF-ANTENNA-3]") &&
1256 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1257 conf
->vht_capab
|= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1258 if (os_strstr(capab
, "[BF-ANTENNA-4]") &&
1259 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1260 conf
->vht_capab
|= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1261 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1262 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1263 conf
->vht_capab
|= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1264 if (os_strstr(capab
, "[SOUNDING-DIMENSION-3]") &&
1265 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1266 conf
->vht_capab
|= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1267 if (os_strstr(capab
, "[SOUNDING-DIMENSION-4]") &&
1268 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1269 conf
->vht_capab
|= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1270 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1271 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1272 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1273 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1274 if (os_strstr(capab
, "[HTC-VHT]"))
1275 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1276 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP7]"))
1277 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX
;
1278 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP6]"))
1279 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6
;
1280 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP5]"))
1281 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5
;
1282 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP4]"))
1283 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4
;
1284 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP3]"))
1285 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3
;
1286 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP2]"))
1287 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2
;
1288 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP1]"))
1289 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1
;
1290 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1291 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1292 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1293 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1294 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1295 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1296 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1297 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1298 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1299 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1302 #endif /* CONFIG_IEEE80211AC */
1305 #ifdef CONFIG_IEEE80211AX
1307 static u8
find_bit_offset(u8 val
)
1311 for (; val
; val
>>= 1) {
1321 static u8
set_he_cap(int val
, u8 mask
)
1323 return (u8
) (mask
& (val
<< find_bit_offset(mask
)));
1326 #endif /* CONFIG_IEEE80211AX */
1329 #ifdef CONFIG_INTERWORKING
1330 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1333 size_t len
= os_strlen(pos
);
1334 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1336 struct hostapd_roaming_consortium
*rc
;
1338 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1339 hexstr2bin(pos
, oi
, len
/ 2)) {
1340 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1346 rc
= os_realloc_array(bss
->roaming_consortium
,
1347 bss
->roaming_consortium_count
+ 1,
1348 sizeof(struct hostapd_roaming_consortium
));
1352 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1353 rc
[bss
->roaming_consortium_count
].len
= len
;
1355 bss
->roaming_consortium
= rc
;
1356 bss
->roaming_consortium_count
++;
1362 static int parse_lang_string(struct hostapd_lang_string
**array
,
1363 unsigned int *count
, char *pos
)
1365 char *sep
, *str
= NULL
;
1366 size_t clen
, nlen
, slen
;
1367 struct hostapd_lang_string
*ls
;
1370 if (*pos
== '"' || (*pos
== 'P' && pos
[1] == '"')) {
1371 str
= wpa_config_parse_string(pos
, &slen
);
1377 sep
= os_strchr(pos
, ':');
1382 clen
= os_strlen(pos
);
1383 if (clen
< 2 || clen
> sizeof(ls
->lang
))
1385 nlen
= os_strlen(sep
);
1389 ls
= os_realloc_array(*array
, *count
+ 1,
1390 sizeof(struct hostapd_lang_string
));
1395 ls
= &(*array
)[*count
];
1398 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1399 os_memcpy(ls
->lang
, pos
, clen
);
1400 ls
->name_len
= nlen
;
1401 os_memcpy(ls
->name
, sep
, nlen
);
1410 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1413 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1414 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1422 static int parse_venue_url(struct hostapd_bss_config
*bss
, char *pos
,
1427 struct hostapd_venue_url
*url
;
1430 sep
= os_strchr(pos
, ':');
1435 nlen
= os_strlen(sep
);
1439 url
= os_realloc_array(bss
->venue_url
, bss
->venue_url_count
+ 1,
1440 sizeof(struct hostapd_venue_url
));
1444 bss
->venue_url
= url
;
1445 url
= &bss
->venue_url
[bss
->venue_url_count
++];
1447 url
->venue_number
= atoi(pos
);
1448 url
->url_len
= nlen
;
1449 os_memcpy(url
->url
, sep
, nlen
);
1454 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_url '%s'",
1460 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1465 u8
*info
= NULL
, *ipos
;
1467 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1470 for (pos
= buf
; *pos
; pos
++) {
1471 if ((*pos
< '0' || *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1476 if (1 + count
* 3 > 0x7f)
1479 info
= os_zalloc(2 + 3 + count
* 3);
1484 *ipos
++ = 0; /* GUD - Version 1 */
1485 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1486 *ipos
++ = 0; /* PLMN List IEI */
1487 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1488 *ipos
++ = 1 + count
* 3;
1489 *ipos
++ = count
; /* Number of PLMNs */
1492 while (pos
&& *pos
) {
1497 mnc
= os_strchr(pos
, ',');
1501 pos
= os_strchr(mnc
, ';');
1505 mnc_len
= os_strlen(mnc
);
1506 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1509 /* BC coded MCC,MNC */
1510 /* MCC digit 2 | MCC digit 1 */
1511 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1512 /* MNC digit 3 | MCC digit 3 */
1513 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1515 /* MNC digit 2 | MNC digit 1 */
1516 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1519 os_free(bss
->anqp_3gpp_cell_net
);
1520 bss
->anqp_3gpp_cell_net
= info
;
1521 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1522 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1523 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1528 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1535 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1537 struct hostapd_nai_realm_data
*realm
;
1540 char *pos
, *end
, *rpos
;
1542 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1544 if (offsets
== NULL
)
1547 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1548 realm
= &bss
->nai_realm_data
[i
];
1549 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1550 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1552 realm
->realm
[j
] - realm
->realm_buf
: -1;
1556 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1557 sizeof(struct hostapd_nai_realm_data
));
1558 if (realm
== NULL
) {
1562 bss
->nai_realm_data
= realm
;
1564 /* patch the pointers after realloc */
1565 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1566 realm
= &bss
->nai_realm_data
[i
];
1567 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1568 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1570 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1572 realm
->realm
[j
] = NULL
;
1577 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1578 os_memset(realm
, 0, sizeof(*realm
));
1581 realm
->encoding
= atoi(pos
);
1582 pos
= os_strchr(pos
, ',');
1587 end
= os_strchr(pos
, ',');
1592 len
= os_strlen(pos
);
1595 if (len
> MAX_NAI_REALMLEN
) {
1596 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1597 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1600 os_memcpy(realm
->realm_buf
, pos
, len
);
1607 while (pos
&& *pos
) {
1608 struct hostapd_nai_realm_eap
*eap
;
1610 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1611 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1615 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1616 realm
->eap_method_count
++;
1618 end
= os_strchr(pos
, ',');
1620 end
= pos
+ os_strlen(pos
);
1622 eap
->eap_method
= atoi(pos
);
1624 pos
= os_strchr(pos
, '[');
1625 if (pos
== NULL
|| pos
> end
)
1628 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1629 wpa_printf(MSG_ERROR
, "Too many auth params");
1632 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1633 pos
= os_strchr(pos
, ':');
1634 if (pos
== NULL
|| pos
> end
)
1637 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1638 pos
= os_strchr(pos
, ']');
1639 if (pos
== NULL
|| pos
> end
)
1651 /* Split realm list into null terminated realms */
1652 rpos
= realm
->realm_buf
;
1655 if (i
>= MAX_NAI_REALMS
) {
1656 wpa_printf(MSG_ERROR
, "Too many realms");
1659 realm
->realm
[i
++] = rpos
;
1660 rpos
= os_strchr(rpos
, ';');
1666 bss
->nai_realm_count
++;
1671 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1676 static int parse_anqp_elem(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1681 struct wpabuf
*payload
;
1682 struct anqp_element
*elem
;
1684 delim
= os_strchr(buf
, ':');
1689 len
= os_strlen(delim
);
1693 payload
= wpabuf_alloc(len
);
1696 if (hexstr2bin(delim
, wpabuf_put(payload
, len
), len
) < 0) {
1697 wpabuf_free(payload
);
1701 dl_list_for_each(elem
, &bss
->anqp_elem
, struct anqp_element
, list
) {
1702 if (elem
->infoid
== infoid
) {
1703 /* Update existing entry */
1704 wpabuf_free(elem
->payload
);
1705 elem
->payload
= payload
;
1710 /* Add a new entry */
1711 elem
= os_zalloc(sizeof(*elem
));
1713 wpabuf_free(payload
);
1716 elem
->infoid
= infoid
;
1717 elem
->payload
= payload
;
1718 dl_list_add(&bss
->anqp_elem
, &elem
->list
);
1724 static int parse_qos_map_set(struct hostapd_bss_config
*bss
,
1725 char *buf
, int line
)
1727 u8 qos_map_set
[16 + 2 * 21], count
= 0;
1732 if (count
== sizeof(qos_map_set
)) {
1733 wpa_printf(MSG_ERROR
, "Line %d: Too many qos_map_set "
1734 "parameters '%s'", line
, buf
);
1739 if (val
> 255 || val
< 0) {
1740 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set "
1745 qos_map_set
[count
++] = val
;
1746 pos
= os_strchr(pos
, ',');
1752 if (count
< 16 || count
& 1) {
1753 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set '%s'",
1758 os_memcpy(bss
->qos_map_set
, qos_map_set
, count
);
1759 bss
->qos_map_set_len
= count
;
1764 #endif /* CONFIG_INTERWORKING */
1768 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1774 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1777 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1778 bss
->hs20_connection_capability_len
+ 4);
1779 if (conn_cap
== NULL
)
1782 bss
->hs20_connection_capability
= conn_cap
;
1783 conn_cap
+= bss
->hs20_connection_capability_len
;
1785 conn_cap
[0] = atoi(pos
);
1786 pos
= os_strchr(pos
, ':');
1790 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1791 pos
= os_strchr(pos
, ':');
1795 conn_cap
[3] = atoi(pos
);
1796 bss
->hs20_connection_capability_len
+= 4;
1802 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1808 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1810 wan_metrics
= os_zalloc(13);
1811 if (wan_metrics
== NULL
)
1816 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1823 /* Downlink Speed */
1824 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1825 pos
= os_strchr(pos
, ':');
1831 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1832 pos
= os_strchr(pos
, ':');
1838 wan_metrics
[9] = atoi(pos
);
1839 pos
= os_strchr(pos
, ':');
1845 wan_metrics
[10] = atoi(pos
);
1846 pos
= os_strchr(pos
, ':');
1852 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1854 os_free(bss
->hs20_wan_metrics
);
1855 bss
->hs20_wan_metrics
= wan_metrics
;
1860 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1862 os_free(wan_metrics
);
1867 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1868 char *pos
, int line
)
1870 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1871 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1872 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1873 "hs20_oper_friendly_name '%s'", line
, pos
);
1880 static int hs20_parse_icon(struct hostapd_bss_config
*bss
, char *pos
)
1882 struct hs20_icon
*icon
;
1885 icon
= os_realloc_array(bss
->hs20_icons
, bss
->hs20_icons_count
+ 1,
1886 sizeof(struct hs20_icon
));
1889 bss
->hs20_icons
= icon
;
1890 icon
= &bss
->hs20_icons
[bss
->hs20_icons_count
];
1891 os_memset(icon
, 0, sizeof(*icon
));
1893 icon
->width
= atoi(pos
);
1894 pos
= os_strchr(pos
, ':');
1899 icon
->height
= atoi(pos
);
1900 pos
= os_strchr(pos
, ':');
1905 end
= os_strchr(pos
, ':');
1906 if (end
== NULL
|| end
- pos
> 3)
1908 os_memcpy(icon
->language
, pos
, end
- pos
);
1911 end
= os_strchr(pos
, ':');
1912 if (end
== NULL
|| end
- pos
> 255)
1914 os_memcpy(icon
->type
, pos
, end
- pos
);
1917 end
= os_strchr(pos
, ':');
1918 if (end
== NULL
|| end
- pos
> 255)
1920 os_memcpy(icon
->name
, pos
, end
- pos
);
1923 if (os_strlen(pos
) > 255)
1925 os_memcpy(icon
->file
, pos
, os_strlen(pos
));
1927 bss
->hs20_icons_count
++;
1933 static int hs20_parse_osu_ssid(struct hostapd_bss_config
*bss
,
1934 char *pos
, int line
)
1939 str
= wpa_config_parse_string(pos
, &slen
);
1940 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
1941 wpa_printf(MSG_ERROR
, "Line %d: Invalid SSID '%s'", line
, pos
);
1946 os_memcpy(bss
->osu_ssid
, str
, slen
);
1947 bss
->osu_ssid_len
= slen
;
1954 static int hs20_parse_osu_server_uri(struct hostapd_bss_config
*bss
,
1955 char *pos
, int line
)
1957 struct hs20_osu_provider
*p
;
1959 p
= os_realloc_array(bss
->hs20_osu_providers
,
1960 bss
->hs20_osu_providers_count
+ 1, sizeof(*p
));
1964 bss
->hs20_osu_providers
= p
;
1965 bss
->last_osu
= &bss
->hs20_osu_providers
[bss
->hs20_osu_providers_count
];
1966 bss
->hs20_osu_providers_count
++;
1967 os_memset(bss
->last_osu
, 0, sizeof(*p
));
1968 bss
->last_osu
->server_uri
= os_strdup(pos
);
1974 static int hs20_parse_osu_friendly_name(struct hostapd_bss_config
*bss
,
1975 char *pos
, int line
)
1977 if (bss
->last_osu
== NULL
) {
1978 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1982 if (parse_lang_string(&bss
->last_osu
->friendly_name
,
1983 &bss
->last_osu
->friendly_name_count
, pos
)) {
1984 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_friendly_name '%s'",
1993 static int hs20_parse_osu_nai(struct hostapd_bss_config
*bss
,
1994 char *pos
, int line
)
1996 if (bss
->last_osu
== NULL
) {
1997 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2001 os_free(bss
->last_osu
->osu_nai
);
2002 bss
->last_osu
->osu_nai
= os_strdup(pos
);
2003 if (bss
->last_osu
->osu_nai
== NULL
)
2010 static int hs20_parse_osu_nai2(struct hostapd_bss_config
*bss
,
2011 char *pos
, int line
)
2013 if (bss
->last_osu
== NULL
) {
2014 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2018 os_free(bss
->last_osu
->osu_nai2
);
2019 bss
->last_osu
->osu_nai2
= os_strdup(pos
);
2020 if (bss
->last_osu
->osu_nai2
== NULL
)
2022 bss
->hs20_osu_providers_nai_count
++;
2028 static int hs20_parse_osu_method_list(struct hostapd_bss_config
*bss
, char *pos
,
2031 if (bss
->last_osu
== NULL
) {
2032 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2036 if (hostapd_parse_intlist(&bss
->last_osu
->method_list
, pos
)) {
2037 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_method_list", line
);
2045 static int hs20_parse_osu_icon(struct hostapd_bss_config
*bss
, char *pos
,
2049 struct hs20_osu_provider
*p
= bss
->last_osu
;
2052 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2056 n
= os_realloc_array(p
->icons
, p
->icons_count
+ 1, sizeof(char *));
2060 p
->icons
[p
->icons_count
] = os_strdup(pos
);
2061 if (p
->icons
[p
->icons_count
] == NULL
)
2069 static int hs20_parse_osu_service_desc(struct hostapd_bss_config
*bss
,
2070 char *pos
, int line
)
2072 if (bss
->last_osu
== NULL
) {
2073 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2077 if (parse_lang_string(&bss
->last_osu
->service_desc
,
2078 &bss
->last_osu
->service_desc_count
, pos
)) {
2079 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_service_desc '%s'",
2088 static int hs20_parse_operator_icon(struct hostapd_bss_config
*bss
, char *pos
,
2093 n
= os_realloc_array(bss
->hs20_operator_icon
,
2094 bss
->hs20_operator_icon_count
+ 1, sizeof(char *));
2097 bss
->hs20_operator_icon
= n
;
2098 bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
] = os_strdup(pos
);
2099 if (!bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
])
2101 bss
->hs20_operator_icon_count
++;
2106 #endif /* CONFIG_HS20 */
2110 static int hostapd_config_parse_acs_chan_bias(struct hostapd_config
*conf
,
2113 struct acs_bias
*bias
= NULL
, *tmp
;
2114 unsigned int num
= 0;
2118 tmp
= os_realloc_array(bias
, num
+ 1, sizeof(*bias
));
2123 bias
[num
].channel
= atoi(pos
);
2124 if (bias
[num
].channel
<= 0)
2126 pos
= os_strchr(pos
, ':');
2130 bias
[num
].bias
= strtod(pos
, &end
);
2131 if (end
== pos
|| bias
[num
].bias
< 0.0)
2134 if (*pos
!= ' ' && *pos
!= '\0')
2139 os_free(conf
->acs_chan_bias
);
2140 conf
->acs_chan_bias
= bias
;
2141 conf
->num_acs_chan_bias
= num
;
2148 #endif /* CONFIG_ACS */
2151 static int parse_wpabuf_hex(int line
, const char *name
, struct wpabuf
**buf
,
2154 struct wpabuf
*elems
;
2156 if (val
[0] == '\0') {
2162 elems
= wpabuf_parse_bin(val
);
2164 wpa_printf(MSG_ERROR
, "Line %d: Invalid %s '%s'",
2177 static int parse_fils_realm(struct hostapd_bss_config
*bss
, const char *val
)
2179 struct fils_realm
*realm
;
2182 len
= os_strlen(val
);
2183 realm
= os_zalloc(sizeof(*realm
) + len
+ 1);
2187 os_memcpy(realm
->realm
, val
, len
);
2188 if (fils_domain_name_hash(val
, realm
->hash
) < 0) {
2192 dl_list_add_tail(&bss
->fils_realms
, &realm
->list
);
2196 #endif /* CONFIG_FILS */
2200 static unsigned int parse_tls_flags(const char *val
)
2202 unsigned int flags
= 0;
2204 /* Disable TLS v1.3 by default for now to avoid interoperability issue.
2205 * This can be enabled by default once the implementation has been fully
2206 * completed and tested with other implementations. */
2207 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2209 if (os_strstr(val
, "[ALLOW-SIGN-RSA-MD5]"))
2210 flags
|= TLS_CONN_ALLOW_SIGN_RSA_MD5
;
2211 if (os_strstr(val
, "[DISABLE-TIME-CHECKS]"))
2212 flags
|= TLS_CONN_DISABLE_TIME_CHECKS
;
2213 if (os_strstr(val
, "[DISABLE-TLSv1.0]"))
2214 flags
|= TLS_CONN_DISABLE_TLSv1_0
;
2215 if (os_strstr(val
, "[ENABLE-TLSv1.0]"))
2216 flags
|= TLS_CONN_ENABLE_TLSv1_0
;
2217 if (os_strstr(val
, "[DISABLE-TLSv1.1]"))
2218 flags
|= TLS_CONN_DISABLE_TLSv1_1
;
2219 if (os_strstr(val
, "[ENABLE-TLSv1.1]"))
2220 flags
|= TLS_CONN_ENABLE_TLSv1_1
;
2221 if (os_strstr(val
, "[DISABLE-TLSv1.2]"))
2222 flags
|= TLS_CONN_DISABLE_TLSv1_2
;
2223 if (os_strstr(val
, "[ENABLE-TLSv1.2]"))
2224 flags
|= TLS_CONN_ENABLE_TLSv1_2
;
2225 if (os_strstr(val
, "[DISABLE-TLSv1.3]"))
2226 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2227 if (os_strstr(val
, "[ENABLE-TLSv1.3]"))
2228 flags
&= ~TLS_CONN_DISABLE_TLSv1_3
;
2229 if (os_strstr(val
, "[SUITEB]"))
2230 flags
|= TLS_CONN_SUITEB
;
2231 if (os_strstr(val
, "[SUITEB-NO-ECDH]"))
2232 flags
|= TLS_CONN_SUITEB_NO_ECDH
| TLS_CONN_SUITEB
;
2236 #endif /* EAP_SERVER */
2239 #ifdef CONFIG_AIRTIME_POLICY
2240 static int add_airtime_weight(struct hostapd_bss_config
*bss
, char *value
)
2242 struct airtime_sta_weight
*wt
;
2245 wt
= os_zalloc(sizeof(*wt
));
2249 /* 02:01:02:03:04:05 10 */
2251 next
= os_strchr(pos
, ' ');
2254 if (!next
|| hwaddr_aton(pos
, wt
->addr
)) {
2255 wpa_printf(MSG_ERROR
, "Invalid station address: '%s'", pos
);
2261 wt
->weight
= atoi(pos
);
2263 wpa_printf(MSG_ERROR
, "Invalid weight: '%s'", pos
);
2268 wt
->next
= bss
->airtime_weight_list
;
2269 bss
->airtime_weight_list
= wt
;
2272 #endif /* CONFIG_AIRTIME_POLICY */
2276 static int parse_sae_password(struct hostapd_bss_config
*bss
, const char *val
)
2278 struct sae_password_entry
*pw
;
2279 const char *pos
= val
, *pos2
, *end
= NULL
;
2281 pw
= os_zalloc(sizeof(*pw
));
2284 os_memset(pw
->peer_addr
, 0xff, ETH_ALEN
); /* default to wildcard */
2286 pos2
= os_strstr(pos
, "|mac=");
2290 if (hwaddr_aton(pos2
, pw
->peer_addr
) < 0)
2292 pos
= pos2
+ ETH_ALEN
* 3 - 1;
2295 pos2
= os_strstr(pos
, "|vlanid=");
2300 pw
->vlan_id
= atoi(pos2
);
2303 pos2
= os_strstr(pos
, "|id=");
2308 pw
->identifier
= os_strdup(pos2
);
2309 if (!pw
->identifier
)
2314 pw
->password
= os_strdup(val
);
2318 pw
->password
= os_malloc(end
- val
+ 1);
2321 os_memcpy(pw
->password
, val
, end
- val
);
2322 pw
->password
[end
- val
] = '\0';
2325 pw
->next
= bss
->sae_passwords
;
2326 bss
->sae_passwords
= pw
;
2330 str_clear_free(pw
->password
);
2331 os_free(pw
->identifier
);
2335 #endif /* CONFIG_SAE */
2339 static int hostapd_dpp_controller_parse(struct hostapd_bss_config
*bss
,
2342 struct dpp_controller_conf
*conf
;
2345 conf
= os_zalloc(sizeof(*conf
));
2348 val
= get_param(pos
, "ipaddr=");
2349 if (!val
|| hostapd_parse_ip_addr(val
, &conf
->ipaddr
))
2352 val
= get_param(pos
, "pkhash=");
2353 if (!val
|| os_strlen(val
) != 2 * SHA256_MAC_LEN
||
2354 hexstr2bin(val
, conf
->pkhash
, SHA256_MAC_LEN
) < 0)
2357 conf
->next
= bss
->dpp_controller
;
2358 bss
->dpp_controller
= conf
;
2365 #endif /* CONFIG_DPP2 */
2368 static int hostapd_config_fill(struct hostapd_config
*conf
,
2369 struct hostapd_bss_config
*bss
,
2370 const char *buf
, char *pos
, int line
)
2372 if (os_strcmp(buf
, "interface") == 0) {
2373 os_strlcpy(conf
->bss
[0]->iface
, pos
,
2374 sizeof(conf
->bss
[0]->iface
));
2375 } else if (os_strcmp(buf
, "bridge") == 0) {
2376 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
2377 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
2378 os_strlcpy(bss
->vlan_bridge
, pos
, sizeof(bss
->vlan_bridge
));
2379 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
2380 os_strlcpy(bss
->wds_bridge
, pos
, sizeof(bss
->wds_bridge
));
2381 } else if (os_strcmp(buf
, "driver") == 0) {
2383 const struct wpa_driver_ops
*driver
= NULL
;
2385 for (j
= 0; wpa_drivers
[j
]; j
++) {
2386 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0) {
2387 driver
= wpa_drivers
[j
];
2392 wpa_printf(MSG_ERROR
,
2393 "Line %d: invalid/unknown driver '%s'",
2397 conf
->driver
= driver
;
2398 } else if (os_strcmp(buf
, "driver_params") == 0) {
2399 os_free(conf
->driver_params
);
2400 conf
->driver_params
= os_strdup(pos
);
2401 } else if (os_strcmp(buf
, "debug") == 0) {
2402 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore",
2404 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
2405 bss
->logger_syslog_level
= atoi(pos
);
2406 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
2407 bss
->logger_stdout_level
= atoi(pos
);
2408 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
2409 bss
->logger_syslog
= atoi(pos
);
2410 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
2411 bss
->logger_stdout
= atoi(pos
);
2412 } else if (os_strcmp(buf
, "dump_file") == 0) {
2413 wpa_printf(MSG_INFO
, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
2415 } else if (os_strcmp(buf
, "ssid") == 0) {
2416 bss
->ssid
.ssid_len
= os_strlen(pos
);
2417 if (bss
->ssid
.ssid_len
> SSID_MAX_LEN
||
2418 bss
->ssid
.ssid_len
< 1) {
2419 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2423 os_memcpy(bss
->ssid
.ssid
, pos
, bss
->ssid
.ssid_len
);
2424 bss
->ssid
.ssid_set
= 1;
2425 } else if (os_strcmp(buf
, "ssid2") == 0) {
2427 char *str
= wpa_config_parse_string(pos
, &slen
);
2428 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
2429 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2434 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
2435 bss
->ssid
.ssid_len
= slen
;
2436 bss
->ssid
.ssid_set
= 1;
2438 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
2439 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
2440 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
2441 enum macaddr_acl acl
= atoi(pos
);
2443 if (acl
!= ACCEPT_UNLESS_DENIED
&&
2444 acl
!= DENY_UNLESS_ACCEPTED
&&
2445 acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
2446 wpa_printf(MSG_ERROR
, "Line %d: unknown macaddr_acl %d",
2450 bss
->macaddr_acl
= acl
;
2451 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
2452 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
2453 &bss
->num_accept_mac
)) {
2454 wpa_printf(MSG_ERROR
, "Line %d: Failed to read accept_mac_file '%s'",
2458 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
2459 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
2460 &bss
->num_deny_mac
)) {
2461 wpa_printf(MSG_ERROR
, "Line %d: Failed to read deny_mac_file '%s'",
2465 } else if (os_strcmp(buf
, "wds_sta") == 0) {
2466 bss
->wds_sta
= atoi(pos
);
2467 } else if (os_strcmp(buf
, "start_disabled") == 0) {
2468 bss
->start_disabled
= atoi(pos
);
2469 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
2470 bss
->isolate
= atoi(pos
);
2471 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
2472 bss
->ap_max_inactivity
= atoi(pos
);
2473 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
2474 bss
->skip_inactivity_poll
= atoi(pos
);
2475 } else if (os_strcmp(buf
, "country_code") == 0) {
2476 os_memcpy(conf
->country
, pos
, 2);
2477 } else if (os_strcmp(buf
, "country3") == 0) {
2478 conf
->country
[2] = strtol(pos
, NULL
, 16);
2479 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
2480 conf
->ieee80211d
= atoi(pos
);
2481 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
2482 conf
->ieee80211h
= atoi(pos
);
2483 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
2484 bss
->ieee802_1x
= atoi(pos
);
2485 } else if (os_strcmp(buf
, "eapol_version") == 0) {
2486 int eapol_version
= atoi(pos
);
2488 #ifdef CONFIG_MACSEC
2489 if (eapol_version
< 1 || eapol_version
> 3) {
2490 #else /* CONFIG_MACSEC */
2491 if (eapol_version
< 1 || eapol_version
> 2) {
2492 #endif /* CONFIG_MACSEC */
2493 wpa_printf(MSG_ERROR
,
2494 "Line %d: invalid EAPOL version (%d): '%s'.",
2495 line
, eapol_version
, pos
);
2498 bss
->eapol_version
= eapol_version
;
2499 wpa_printf(MSG_DEBUG
, "eapol_version=%d", bss
->eapol_version
);
2501 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
2502 bss
->eap_server
= atoi(pos
);
2503 wpa_printf(MSG_ERROR
, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line
);
2504 } else if (os_strcmp(buf
, "eap_server") == 0) {
2505 bss
->eap_server
= atoi(pos
);
2506 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
2507 if (hostapd_config_read_eap_user(pos
, bss
))
2509 } else if (os_strcmp(buf
, "ca_cert") == 0) {
2510 os_free(bss
->ca_cert
);
2511 bss
->ca_cert
= os_strdup(pos
);
2512 } else if (os_strcmp(buf
, "server_cert") == 0) {
2513 os_free(bss
->server_cert
);
2514 bss
->server_cert
= os_strdup(pos
);
2515 } else if (os_strcmp(buf
, "server_cert2") == 0) {
2516 os_free(bss
->server_cert2
);
2517 bss
->server_cert2
= os_strdup(pos
);
2518 } else if (os_strcmp(buf
, "private_key") == 0) {
2519 os_free(bss
->private_key
);
2520 bss
->private_key
= os_strdup(pos
);
2521 } else if (os_strcmp(buf
, "private_key2") == 0) {
2522 os_free(bss
->private_key2
);
2523 bss
->private_key2
= os_strdup(pos
);
2524 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
2525 os_free(bss
->private_key_passwd
);
2526 bss
->private_key_passwd
= os_strdup(pos
);
2527 } else if (os_strcmp(buf
, "private_key_passwd2") == 0) {
2528 os_free(bss
->private_key_passwd2
);
2529 bss
->private_key_passwd2
= os_strdup(pos
);
2530 } else if (os_strcmp(buf
, "check_cert_subject") == 0) {
2532 wpa_printf(MSG_ERROR
, "Line %d: unknown check_cert_subject '%s'",
2536 os_free(bss
->check_cert_subject
);
2537 bss
->check_cert_subject
= os_strdup(pos
);
2538 if (!bss
->check_cert_subject
)
2540 } else if (os_strcmp(buf
, "check_crl") == 0) {
2541 bss
->check_crl
= atoi(pos
);
2542 } else if (os_strcmp(buf
, "check_crl_strict") == 0) {
2543 bss
->check_crl_strict
= atoi(pos
);
2544 } else if (os_strcmp(buf
, "crl_reload_interval") == 0) {
2545 bss
->crl_reload_interval
= atoi(pos
);
2546 } else if (os_strcmp(buf
, "tls_session_lifetime") == 0) {
2547 bss
->tls_session_lifetime
= atoi(pos
);
2548 } else if (os_strcmp(buf
, "tls_flags") == 0) {
2549 bss
->tls_flags
= parse_tls_flags(pos
);
2550 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
2551 os_free(bss
->ocsp_stapling_response
);
2552 bss
->ocsp_stapling_response
= os_strdup(pos
);
2553 } else if (os_strcmp(buf
, "ocsp_stapling_response_multi") == 0) {
2554 os_free(bss
->ocsp_stapling_response_multi
);
2555 bss
->ocsp_stapling_response_multi
= os_strdup(pos
);
2556 } else if (os_strcmp(buf
, "dh_file") == 0) {
2557 os_free(bss
->dh_file
);
2558 bss
->dh_file
= os_strdup(pos
);
2559 } else if (os_strcmp(buf
, "openssl_ciphers") == 0) {
2560 os_free(bss
->openssl_ciphers
);
2561 bss
->openssl_ciphers
= os_strdup(pos
);
2562 } else if (os_strcmp(buf
, "openssl_ecdh_curves") == 0) {
2563 os_free(bss
->openssl_ecdh_curves
);
2564 bss
->openssl_ecdh_curves
= os_strdup(pos
);
2565 } else if (os_strcmp(buf
, "fragment_size") == 0) {
2566 bss
->fragment_size
= atoi(pos
);
2567 #ifdef EAP_SERVER_FAST
2568 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
2569 os_free(bss
->pac_opaque_encr_key
);
2570 bss
->pac_opaque_encr_key
= os_malloc(16);
2571 if (bss
->pac_opaque_encr_key
== NULL
) {
2572 wpa_printf(MSG_ERROR
,
2573 "Line %d: No memory for pac_opaque_encr_key",
2576 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
, 16)) {
2577 wpa_printf(MSG_ERROR
, "Line %d: Invalid pac_opaque_encr_key",
2581 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
2582 size_t idlen
= os_strlen(pos
);
2584 wpa_printf(MSG_ERROR
, "Line %d: Invalid eap_fast_a_id",
2588 os_free(bss
->eap_fast_a_id
);
2589 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
2590 if (bss
->eap_fast_a_id
== NULL
||
2591 hexstr2bin(pos
, bss
->eap_fast_a_id
, idlen
/ 2)) {
2592 wpa_printf(MSG_ERROR
, "Line %d: Failed to parse eap_fast_a_id",
2594 os_free(bss
->eap_fast_a_id
);
2595 bss
->eap_fast_a_id
= NULL
;
2598 bss
->eap_fast_a_id_len
= idlen
/ 2;
2600 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
2601 os_free(bss
->eap_fast_a_id_info
);
2602 bss
->eap_fast_a_id_info
= os_strdup(pos
);
2603 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
2604 bss
->eap_fast_prov
= atoi(pos
);
2605 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
2606 bss
->pac_key_lifetime
= atoi(pos
);
2607 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
2608 bss
->pac_key_refresh_time
= atoi(pos
);
2609 #endif /* EAP_SERVER_FAST */
2610 #ifdef EAP_SERVER_TEAP
2611 } else if (os_strcmp(buf
, "eap_teap_auth") == 0) {
2612 int val
= atoi(pos
);
2614 if (val
< 0 || val
> 1) {
2615 wpa_printf(MSG_ERROR
,
2616 "Line %d: Invalid eap_teap_auth value",
2620 bss
->eap_teap_auth
= val
;
2621 } else if (os_strcmp(buf
, "eap_teap_pac_no_inner") == 0) {
2622 bss
->eap_teap_pac_no_inner
= atoi(pos
);
2623 #endif /* EAP_SERVER_TEAP */
2624 #ifdef EAP_SERVER_SIM
2625 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
2626 os_free(bss
->eap_sim_db
);
2627 bss
->eap_sim_db
= os_strdup(pos
);
2628 } else if (os_strcmp(buf
, "eap_sim_db_timeout") == 0) {
2629 bss
->eap_sim_db_timeout
= atoi(pos
);
2630 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
2631 bss
->eap_sim_aka_result_ind
= atoi(pos
);
2632 } else if (os_strcmp(buf
, "eap_sim_id") == 0) {
2633 bss
->eap_sim_id
= atoi(pos
);
2634 #endif /* EAP_SERVER_SIM */
2635 #ifdef EAP_SERVER_TNC
2636 } else if (os_strcmp(buf
, "tnc") == 0) {
2637 bss
->tnc
= atoi(pos
);
2638 #endif /* EAP_SERVER_TNC */
2639 #ifdef EAP_SERVER_PWD
2640 } else if (os_strcmp(buf
, "pwd_group") == 0) {
2641 bss
->pwd_group
= atoi(pos
);
2642 #endif /* EAP_SERVER_PWD */
2644 } else if (os_strcmp(buf
, "eap_server_erp") == 0) {
2645 bss
->eap_server_erp
= atoi(pos
);
2646 #endif /* CONFIG_ERP */
2647 #endif /* EAP_SERVER */
2648 } else if (os_strcmp(buf
, "eap_message") == 0) {
2650 os_free(bss
->eap_req_id_text
);
2651 bss
->eap_req_id_text
= os_strdup(pos
);
2652 if (bss
->eap_req_id_text
== NULL
) {
2653 wpa_printf(MSG_ERROR
, "Line %d: Failed to allocate memory for eap_req_id_text",
2657 bss
->eap_req_id_text_len
= os_strlen(bss
->eap_req_id_text
);
2658 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
2661 os_memmove(term
, term
+ 1,
2662 bss
->eap_req_id_text_len
-
2663 (term
- bss
->eap_req_id_text
) - 1);
2664 bss
->eap_req_id_text_len
--;
2666 } else if (os_strcmp(buf
, "erp_send_reauth_start") == 0) {
2667 bss
->erp_send_reauth_start
= atoi(pos
);
2668 } else if (os_strcmp(buf
, "erp_domain") == 0) {
2669 os_free(bss
->erp_domain
);
2670 bss
->erp_domain
= os_strdup(pos
);
2671 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
2672 int val
= atoi(pos
);
2674 if (val
< 0 || val
> 13) {
2675 wpa_printf(MSG_ERROR
,
2676 "Line %d: invalid WEP key len %d (= %d bits)",
2677 line
, val
, val
* 8);
2680 bss
->default_wep_key_len
= val
;
2681 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
2682 int val
= atoi(pos
);
2684 if (val
< 0 || val
> 13) {
2685 wpa_printf(MSG_ERROR
,
2686 "Line %d: invalid WEP key len %d (= %d bits)",
2687 line
, val
, val
* 8);
2690 bss
->individual_wep_key_len
= val
;
2691 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
2692 bss
->wep_rekeying_period
= atoi(pos
);
2693 if (bss
->wep_rekeying_period
< 0) {
2694 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2695 line
, bss
->wep_rekeying_period
);
2698 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
2699 bss
->eap_reauth_period
= atoi(pos
);
2700 if (bss
->eap_reauth_period
< 0) {
2701 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2702 line
, bss
->eap_reauth_period
);
2705 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
2706 bss
->eapol_key_index_workaround
= atoi(pos
);
2708 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
2709 bss
->ieee802_11f
= 1;
2710 os_strlcpy(bss
->iapp_iface
, pos
, sizeof(bss
->iapp_iface
));
2711 #endif /* CONFIG_IAPP */
2712 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
2713 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
2714 wpa_printf(MSG_ERROR
,
2715 "Line %d: invalid IP address '%s'",
2719 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
2720 os_free(bss
->nas_identifier
);
2721 bss
->nas_identifier
= os_strdup(pos
);
2722 #ifndef CONFIG_NO_RADIUS
2723 } else if (os_strcmp(buf
, "radius_client_addr") == 0) {
2724 if (hostapd_parse_ip_addr(pos
, &bss
->radius
->client_addr
)) {
2725 wpa_printf(MSG_ERROR
,
2726 "Line %d: invalid IP address '%s'",
2730 bss
->radius
->force_client_addr
= 1;
2731 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
2732 if (hostapd_config_read_radius_addr(
2733 &bss
->radius
->auth_servers
,
2734 &bss
->radius
->num_auth_servers
, pos
, 1812,
2735 &bss
->radius
->auth_server
)) {
2736 wpa_printf(MSG_ERROR
,
2737 "Line %d: invalid IP address '%s'",
2741 } else if (bss
->radius
->auth_server
&&
2742 os_strcmp(buf
, "auth_server_addr_replace") == 0) {
2743 if (hostapd_parse_ip_addr(pos
,
2744 &bss
->radius
->auth_server
->addr
)) {
2745 wpa_printf(MSG_ERROR
,
2746 "Line %d: invalid IP address '%s'",
2750 } else if (bss
->radius
->auth_server
&&
2751 os_strcmp(buf
, "auth_server_port") == 0) {
2752 bss
->radius
->auth_server
->port
= atoi(pos
);
2753 } else if (bss
->radius
->auth_server
&&
2754 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
2755 int len
= os_strlen(pos
);
2757 /* RFC 2865, Ch. 3 */
2758 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2762 os_free(bss
->radius
->auth_server
->shared_secret
);
2763 bss
->radius
->auth_server
->shared_secret
= (u8
*) os_strdup(pos
);
2764 bss
->radius
->auth_server
->shared_secret_len
= len
;
2765 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
2766 if (hostapd_config_read_radius_addr(
2767 &bss
->radius
->acct_servers
,
2768 &bss
->radius
->num_acct_servers
, pos
, 1813,
2769 &bss
->radius
->acct_server
)) {
2770 wpa_printf(MSG_ERROR
,
2771 "Line %d: invalid IP address '%s'",
2775 } else if (bss
->radius
->acct_server
&&
2776 os_strcmp(buf
, "acct_server_addr_replace") == 0) {
2777 if (hostapd_parse_ip_addr(pos
,
2778 &bss
->radius
->acct_server
->addr
)) {
2779 wpa_printf(MSG_ERROR
,
2780 "Line %d: invalid IP address '%s'",
2784 } else if (bss
->radius
->acct_server
&&
2785 os_strcmp(buf
, "acct_server_port") == 0) {
2786 bss
->radius
->acct_server
->port
= atoi(pos
);
2787 } else if (bss
->radius
->acct_server
&&
2788 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
2789 int len
= os_strlen(pos
);
2791 /* RFC 2865, Ch. 3 */
2792 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2796 os_free(bss
->radius
->acct_server
->shared_secret
);
2797 bss
->radius
->acct_server
->shared_secret
= (u8
*) os_strdup(pos
);
2798 bss
->radius
->acct_server
->shared_secret_len
= len
;
2799 } else if (os_strcmp(buf
, "radius_retry_primary_interval") == 0) {
2800 bss
->radius
->retry_primary_interval
= atoi(pos
);
2801 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0) {
2802 bss
->acct_interim_interval
= atoi(pos
);
2803 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
2804 bss
->radius_request_cui
= atoi(pos
);
2805 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
2806 struct hostapd_radius_attr
*attr
, *a
;
2807 attr
= hostapd_parse_radius_attr(pos
);
2809 wpa_printf(MSG_ERROR
,
2810 "Line %d: invalid radius_auth_req_attr",
2813 } else if (bss
->radius_auth_req_attr
== NULL
) {
2814 bss
->radius_auth_req_attr
= attr
;
2816 a
= bss
->radius_auth_req_attr
;
2821 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
2822 struct hostapd_radius_attr
*attr
, *a
;
2823 attr
= hostapd_parse_radius_attr(pos
);
2825 wpa_printf(MSG_ERROR
,
2826 "Line %d: invalid radius_acct_req_attr",
2829 } else if (bss
->radius_acct_req_attr
== NULL
) {
2830 bss
->radius_acct_req_attr
= attr
;
2832 a
= bss
->radius_acct_req_attr
;
2837 } else if (os_strcmp(buf
, "radius_req_attr_sqlite") == 0) {
2838 os_free(bss
->radius_req_attr_sqlite
);
2839 bss
->radius_req_attr_sqlite
= os_strdup(pos
);
2840 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
2841 bss
->radius_das_port
= atoi(pos
);
2842 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
2843 if (hostapd_parse_das_client(bss
, pos
) < 0) {
2844 wpa_printf(MSG_ERROR
, "Line %d: invalid DAS client",
2848 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2849 bss
->radius_das_time_window
= atoi(pos
);
2850 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp") == 0) {
2851 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2852 } else if (os_strcmp(buf
, "radius_das_require_message_authenticator") ==
2854 bss
->radius_das_require_message_authenticator
= atoi(pos
);
2855 #endif /* CONFIG_NO_RADIUS */
2856 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2857 bss
->auth_algs
= atoi(pos
);
2858 if (bss
->auth_algs
== 0) {
2859 wpa_printf(MSG_ERROR
, "Line %d: no authentication algorithms allowed",
2863 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2864 bss
->max_num_sta
= atoi(pos
);
2865 if (bss
->max_num_sta
< 0 ||
2866 bss
->max_num_sta
> MAX_STA_COUNT
) {
2867 wpa_printf(MSG_ERROR
, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2868 line
, bss
->max_num_sta
, MAX_STA_COUNT
);
2871 } else if (os_strcmp(buf
, "wpa") == 0) {
2872 bss
->wpa
= atoi(pos
);
2873 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2874 bss
->wpa_group_rekey
= atoi(pos
);
2875 bss
->wpa_group_rekey_set
= 1;
2876 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2877 bss
->wpa_strict_rekey
= atoi(pos
);
2878 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2879 bss
->wpa_gmk_rekey
= atoi(pos
);
2880 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2881 bss
->wpa_ptk_rekey
= atoi(pos
);
2882 } else if (os_strcmp(buf
, "wpa_group_update_count") == 0) {
2884 unsigned long val
= strtoul(pos
, &endp
, 0);
2886 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2887 wpa_printf(MSG_ERROR
,
2888 "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295",
2892 bss
->wpa_group_update_count
= (u32
) val
;
2893 } else if (os_strcmp(buf
, "wpa_pairwise_update_count") == 0) {
2895 unsigned long val
= strtoul(pos
, &endp
, 0);
2897 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2898 wpa_printf(MSG_ERROR
,
2899 "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295",
2903 bss
->wpa_pairwise_update_count
= (u32
) val
;
2904 } else if (os_strcmp(buf
, "wpa_disable_eapol_key_retries") == 0) {
2905 bss
->wpa_disable_eapol_key_retries
= atoi(pos
);
2906 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2907 int len
= os_strlen(pos
);
2908 if (len
< 8 || len
> 63) {
2909 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA passphrase length %d (expected 8..63)",
2913 os_free(bss
->ssid
.wpa_passphrase
);
2914 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2915 if (bss
->ssid
.wpa_passphrase
) {
2916 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2917 bss
->ssid
.wpa_passphrase_set
= 1;
2919 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2920 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2921 bss
->ssid
.wpa_psk
= os_zalloc(sizeof(struct hostapd_wpa_psk
));
2922 if (bss
->ssid
.wpa_psk
== NULL
)
2924 if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
, PMK_LEN
) ||
2925 pos
[PMK_LEN
* 2] != '\0') {
2926 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
2928 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2931 bss
->ssid
.wpa_psk
->group
= 1;
2932 os_free(bss
->ssid
.wpa_passphrase
);
2933 bss
->ssid
.wpa_passphrase
= NULL
;
2934 bss
->ssid
.wpa_psk_set
= 1;
2935 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2936 os_free(bss
->ssid
.wpa_psk_file
);
2937 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
2938 if (!bss
->ssid
.wpa_psk_file
) {
2939 wpa_printf(MSG_ERROR
, "Line %d: allocation failed",
2943 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
2944 bss
->wpa_key_mgmt
= hostapd_config_parse_key_mgmt(line
, pos
);
2945 if (bss
->wpa_key_mgmt
== -1)
2947 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
2948 bss
->wpa_psk_radius
= atoi(pos
);
2949 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
2950 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
2951 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
2952 wpa_printf(MSG_ERROR
,
2953 "Line %d: unknown wpa_psk_radius %d",
2954 line
, bss
->wpa_psk_radius
);
2957 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
2958 bss
->wpa_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2959 if (bss
->wpa_pairwise
== -1 || bss
->wpa_pairwise
== 0)
2961 if (bss
->wpa_pairwise
&
2962 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2963 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2967 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
2968 bss
->rsn_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2969 if (bss
->rsn_pairwise
== -1 || bss
->rsn_pairwise
== 0)
2971 if (bss
->rsn_pairwise
&
2972 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2973 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2977 } else if (os_strcmp(buf
, "group_cipher") == 0) {
2978 bss
->group_cipher
= hostapd_config_parse_cipher(line
, pos
);
2979 if (bss
->group_cipher
== -1 || bss
->group_cipher
== 0)
2981 if (bss
->group_cipher
!= WPA_CIPHER_TKIP
&&
2982 bss
->group_cipher
!= WPA_CIPHER_CCMP
&&
2983 bss
->group_cipher
!= WPA_CIPHER_GCMP
&&
2984 bss
->group_cipher
!= WPA_CIPHER_GCMP_256
&&
2985 bss
->group_cipher
!= WPA_CIPHER_CCMP_256
) {
2986 wpa_printf(MSG_ERROR
,
2987 "Line %d: unsupported group cipher suite '%s'",
2991 #ifdef CONFIG_RSN_PREAUTH
2992 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
2993 bss
->rsn_preauth
= atoi(pos
);
2994 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
2995 os_free(bss
->rsn_preauth_interfaces
);
2996 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
2997 #endif /* CONFIG_RSN_PREAUTH */
2998 } else if (os_strcmp(buf
, "peerkey") == 0) {
2999 wpa_printf(MSG_INFO
,
3000 "Line %d: Obsolete peerkey parameter ignored", line
);
3001 #ifdef CONFIG_IEEE80211R_AP
3002 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
3003 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
3004 hexstr2bin(pos
, bss
->mobility_domain
,
3005 MOBILITY_DOMAIN_ID_LEN
) != 0) {
3006 wpa_printf(MSG_ERROR
,
3007 "Line %d: Invalid mobility_domain '%s'",
3011 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
3012 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
3013 hexstr2bin(pos
, bss
->r1_key_holder
, FT_R1KH_ID_LEN
) != 0) {
3014 wpa_printf(MSG_ERROR
,
3015 "Line %d: Invalid r1_key_holder '%s'",
3019 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
3020 /* DEPRECATED: Use ft_r0_key_lifetime instead. */
3021 bss
->r0_key_lifetime
= atoi(pos
) * 60;
3022 } else if (os_strcmp(buf
, "ft_r0_key_lifetime") == 0) {
3023 bss
->r0_key_lifetime
= atoi(pos
);
3024 } else if (os_strcmp(buf
, "r1_max_key_lifetime") == 0) {
3025 bss
->r1_max_key_lifetime
= atoi(pos
);
3026 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
3027 bss
->reassociation_deadline
= atoi(pos
);
3028 } else if (os_strcmp(buf
, "rkh_pos_timeout") == 0) {
3029 bss
->rkh_pos_timeout
= atoi(pos
);
3030 } else if (os_strcmp(buf
, "rkh_neg_timeout") == 0) {
3031 bss
->rkh_neg_timeout
= atoi(pos
);
3032 } else if (os_strcmp(buf
, "rkh_pull_timeout") == 0) {
3033 bss
->rkh_pull_timeout
= atoi(pos
);
3034 } else if (os_strcmp(buf
, "rkh_pull_retries") == 0) {
3035 bss
->rkh_pull_retries
= atoi(pos
);
3036 } else if (os_strcmp(buf
, "r0kh") == 0) {
3037 if (add_r0kh(bss
, pos
) < 0) {
3038 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r0kh '%s'",
3042 } else if (os_strcmp(buf
, "r1kh") == 0) {
3043 if (add_r1kh(bss
, pos
) < 0) {
3044 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r1kh '%s'",
3048 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
3049 bss
->pmk_r1_push
= atoi(pos
);
3050 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
3051 bss
->ft_over_ds
= atoi(pos
);
3052 } else if (os_strcmp(buf
, "ft_psk_generate_local") == 0) {
3053 bss
->ft_psk_generate_local
= atoi(pos
);
3054 #endif /* CONFIG_IEEE80211R_AP */
3055 #ifndef CONFIG_NO_CTRL_IFACE
3056 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
3057 os_free(bss
->ctrl_interface
);
3058 bss
->ctrl_interface
= os_strdup(pos
);
3059 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
3060 #ifndef CONFIG_NATIVE_WINDOWS
3063 const char *group
= pos
;
3065 grp
= getgrnam(group
);
3067 bss
->ctrl_interface_gid
= grp
->gr_gid
;
3068 bss
->ctrl_interface_gid_set
= 1;
3069 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d (from group name '%s')",
3070 bss
->ctrl_interface_gid
, group
);
3074 /* Group name not found - try to parse this as gid */
3075 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
3076 if (*group
== '\0' || *endp
!= '\0') {
3077 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group '%s'",
3081 bss
->ctrl_interface_gid_set
= 1;
3082 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
3083 bss
->ctrl_interface_gid
);
3084 #endif /* CONFIG_NATIVE_WINDOWS */
3085 #endif /* CONFIG_NO_CTRL_IFACE */
3086 #ifdef RADIUS_SERVER
3087 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
3088 os_free(bss
->radius_server_clients
);
3089 bss
->radius_server_clients
= os_strdup(pos
);
3090 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
3091 bss
->radius_server_auth_port
= atoi(pos
);
3092 } else if (os_strcmp(buf
, "radius_server_acct_port") == 0) {
3093 bss
->radius_server_acct_port
= atoi(pos
);
3094 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
3095 bss
->radius_server_ipv6
= atoi(pos
);
3096 #endif /* RADIUS_SERVER */
3097 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
3098 bss
->use_pae_group_addr
= atoi(pos
);
3099 } else if (os_strcmp(buf
, "hw_mode") == 0) {
3100 if (os_strcmp(pos
, "a") == 0)
3101 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
3102 else if (os_strcmp(pos
, "b") == 0)
3103 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
3104 else if (os_strcmp(pos
, "g") == 0)
3105 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
3106 else if (os_strcmp(pos
, "ad") == 0)
3107 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
3108 else if (os_strcmp(pos
, "any") == 0)
3109 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211ANY
;
3111 wpa_printf(MSG_ERROR
, "Line %d: unknown hw_mode '%s'",
3115 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
3116 if (os_strcmp(pos
, "ad") == 0)
3117 bss
->wps_rf_bands
= WPS_RF_60GHZ
;
3118 else if (os_strcmp(pos
, "a") == 0)
3119 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
3120 else if (os_strcmp(pos
, "g") == 0 ||
3121 os_strcmp(pos
, "b") == 0)
3122 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
3123 else if (os_strcmp(pos
, "ag") == 0 ||
3124 os_strcmp(pos
, "ga") == 0)
3125 bss
->wps_rf_bands
= WPS_RF_24GHZ
| WPS_RF_50GHZ
;
3127 wpa_printf(MSG_ERROR
,
3128 "Line %d: unknown wps_rf_band '%s'",
3132 } else if (os_strcmp(buf
, "acs_exclude_dfs") == 0) {
3133 conf
->acs_exclude_dfs
= atoi(pos
);
3134 } else if (os_strcmp(buf
, "channel") == 0) {
3135 if (os_strcmp(pos
, "acs_survey") == 0) {
3137 wpa_printf(MSG_ERROR
, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
3140 #else /* CONFIG_ACS */
3143 #endif /* CONFIG_ACS */
3145 conf
->channel
= atoi(pos
);
3146 conf
->acs
= conf
->channel
== 0;
3148 } else if (os_strcmp(buf
, "chanlist") == 0) {
3149 if (hostapd_parse_chanlist(conf
, pos
)) {
3150 wpa_printf(MSG_ERROR
, "Line %d: invalid channel list",
3154 } else if (os_strcmp(buf
, "beacon_int") == 0) {
3155 int val
= atoi(pos
);
3156 /* MIB defines range as 1..65535, but very small values
3157 * cause problems with the current implementation.
3158 * Since it is unlikely that this small numbers are
3159 * useful in real life scenarios, do not allow beacon
3160 * period to be set below 10 TU. */
3161 if (val
< 10 || val
> 65535) {
3162 wpa_printf(MSG_ERROR
,
3163 "Line %d: invalid beacon_int %d (expected 10..65535)",
3167 conf
->beacon_int
= val
;
3169 } else if (os_strcmp(buf
, "acs_num_scans") == 0) {
3170 int val
= atoi(pos
);
3171 if (val
<= 0 || val
> 100) {
3172 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_num_scans %d (expected 1..100)",
3176 conf
->acs_num_scans
= val
;
3177 } else if (os_strcmp(buf
, "acs_chan_bias") == 0) {
3178 if (hostapd_config_parse_acs_chan_bias(conf
, pos
)) {
3179 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_chan_bias",
3183 #endif /* CONFIG_ACS */
3184 } else if (os_strcmp(buf
, "dtim_period") == 0) {
3185 int val
= atoi(pos
);
3187 if (val
< 1 || val
> 255) {
3188 wpa_printf(MSG_ERROR
, "Line %d: invalid dtim_period %d",
3192 bss
->dtim_period
= val
;
3193 } else if (os_strcmp(buf
, "bss_load_update_period") == 0) {
3194 int val
= atoi(pos
);
3196 if (val
< 0 || val
> 100) {
3197 wpa_printf(MSG_ERROR
,
3198 "Line %d: invalid bss_load_update_period %d",
3202 bss
->bss_load_update_period
= val
;
3203 } else if (os_strcmp(buf
, "chan_util_avg_period") == 0) {
3204 int val
= atoi(pos
);
3207 wpa_printf(MSG_ERROR
,
3208 "Line %d: invalid chan_util_avg_period",
3212 bss
->chan_util_avg_period
= val
;
3213 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
3214 conf
->rts_threshold
= atoi(pos
);
3215 if (conf
->rts_threshold
< -1 || conf
->rts_threshold
> 65535) {
3216 wpa_printf(MSG_ERROR
,
3217 "Line %d: invalid rts_threshold %d",
3218 line
, conf
->rts_threshold
);
3221 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
3222 conf
->fragm_threshold
= atoi(pos
);
3223 if (conf
->fragm_threshold
== -1) {
3224 /* allow a value of -1 */
3225 } else if (conf
->fragm_threshold
< 256 ||
3226 conf
->fragm_threshold
> 2346) {
3227 wpa_printf(MSG_ERROR
,
3228 "Line %d: invalid fragm_threshold %d",
3229 line
, conf
->fragm_threshold
);
3232 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
3233 int val
= atoi(pos
);
3234 if (val
!= 0 && val
!= 1) {
3235 wpa_printf(MSG_ERROR
, "Line %d: invalid send_probe_response %d (expected 0 or 1)",
3239 bss
->send_probe_response
= val
;
3240 } else if (os_strcmp(buf
, "supported_rates") == 0) {
3241 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
)) {
3242 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3246 } else if (os_strcmp(buf
, "basic_rates") == 0) {
3247 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
3248 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3252 } else if (os_strcmp(buf
, "beacon_rate") == 0) {
3255 if (os_strncmp(pos
, "ht:", 3) == 0) {
3256 val
= atoi(pos
+ 3);
3257 if (val
< 0 || val
> 31) {
3258 wpa_printf(MSG_ERROR
,
3259 "Line %d: invalid beacon_rate HT-MCS %d",
3263 conf
->rate_type
= BEACON_RATE_HT
;
3264 conf
->beacon_rate
= val
;
3265 } else if (os_strncmp(pos
, "vht:", 4) == 0) {
3266 val
= atoi(pos
+ 4);
3267 if (val
< 0 || val
> 9) {
3268 wpa_printf(MSG_ERROR
,
3269 "Line %d: invalid beacon_rate VHT-MCS %d",
3273 conf
->rate_type
= BEACON_RATE_VHT
;
3274 conf
->beacon_rate
= val
;
3277 if (val
< 10 || val
> 10000) {
3278 wpa_printf(MSG_ERROR
,
3279 "Line %d: invalid legacy beacon_rate %d",
3283 conf
->rate_type
= BEACON_RATE_LEGACY
;
3284 conf
->beacon_rate
= val
;
3286 } else if (os_strcmp(buf
, "preamble") == 0) {
3288 conf
->preamble
= SHORT_PREAMBLE
;
3290 conf
->preamble
= LONG_PREAMBLE
;
3291 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
3292 bss
->ignore_broadcast_ssid
= atoi(pos
);
3293 } else if (os_strcmp(buf
, "no_probe_resp_if_max_sta") == 0) {
3294 bss
->no_probe_resp_if_max_sta
= atoi(pos
);
3295 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
3296 bss
->ssid
.wep
.idx
= atoi(pos
);
3297 if (bss
->ssid
.wep
.idx
> 3) {
3298 wpa_printf(MSG_ERROR
,
3299 "Invalid wep_default_key index %d",
3303 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
3304 os_strcmp(buf
, "wep_key1") == 0 ||
3305 os_strcmp(buf
, "wep_key2") == 0 ||
3306 os_strcmp(buf
, "wep_key3") == 0) {
3307 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
3308 buf
[7] - '0', pos
)) {
3309 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP key '%s'",
3313 #ifndef CONFIG_NO_VLAN
3314 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
3315 bss
->ssid
.dynamic_vlan
= atoi(pos
);
3316 } else if (os_strcmp(buf
, "per_sta_vif") == 0) {
3317 bss
->ssid
.per_sta_vif
= atoi(pos
);
3318 } else if (os_strcmp(buf
, "vlan_file") == 0) {
3319 if (hostapd_config_read_vlan_file(bss
, pos
)) {
3320 wpa_printf(MSG_ERROR
, "Line %d: failed to read VLAN file '%s'",
3324 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
3325 bss
->ssid
.vlan_naming
= atoi(pos
);
3326 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
3327 bss
->ssid
.vlan_naming
< 0) {
3328 wpa_printf(MSG_ERROR
,
3329 "Line %d: invalid naming scheme %d",
3330 line
, bss
->ssid
.vlan_naming
);
3333 #ifdef CONFIG_FULL_DYNAMIC_VLAN
3334 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
3335 os_free(bss
->ssid
.vlan_tagged_interface
);
3336 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
3337 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
3338 #endif /* CONFIG_NO_VLAN */
3339 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
3340 conf
->ap_table_max_size
= atoi(pos
);
3341 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
3342 conf
->ap_table_expiration_time
= atoi(pos
);
3343 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
3344 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
3345 wpa_printf(MSG_ERROR
, "Line %d: invalid TX queue item",
3349 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
3350 os_strcmp(buf
, "wmm_enabled") == 0) {
3351 bss
->wmm_enabled
= atoi(pos
);
3352 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
3353 bss
->wmm_uapsd
= atoi(pos
);
3354 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
3355 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
3356 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
, pos
)) {
3357 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM ac item",
3361 } else if (os_strcmp(buf
, "bss") == 0) {
3362 if (hostapd_config_bss(conf
, pos
)) {
3363 wpa_printf(MSG_ERROR
, "Line %d: invalid bss item",
3367 } else if (os_strcmp(buf
, "bssid") == 0) {
3368 if (hwaddr_aton(pos
, bss
->bssid
)) {
3369 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid item",
3373 } else if (os_strcmp(buf
, "use_driver_iface_addr") == 0) {
3374 conf
->use_driver_iface_addr
= atoi(pos
);
3375 #ifdef CONFIG_IEEE80211W
3376 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
3377 bss
->ieee80211w
= atoi(pos
);
3378 } else if (os_strcmp(buf
, "group_mgmt_cipher") == 0) {
3379 if (os_strcmp(pos
, "AES-128-CMAC") == 0) {
3380 bss
->group_mgmt_cipher
= WPA_CIPHER_AES_128_CMAC
;
3381 } else if (os_strcmp(pos
, "BIP-GMAC-128") == 0) {
3382 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_128
;
3383 } else if (os_strcmp(pos
, "BIP-GMAC-256") == 0) {
3384 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_256
;
3385 } else if (os_strcmp(pos
, "BIP-CMAC-256") == 0) {
3386 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_CMAC_256
;
3388 wpa_printf(MSG_ERROR
, "Line %d: invalid group_mgmt_cipher: %s",
3392 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
3393 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
3394 if (bss
->assoc_sa_query_max_timeout
== 0) {
3395 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_max_timeout",
3399 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0) {
3400 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
3401 if (bss
->assoc_sa_query_retry_timeout
== 0) {
3402 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_retry_timeout",
3406 #endif /* CONFIG_IEEE80211W */
3408 } else if (os_strcmp(buf
, "ocv") == 0) {
3409 bss
->ocv
= atoi(pos
);
3410 if (bss
->ocv
&& !bss
->ieee80211w
)
3411 bss
->ieee80211w
= 1;
3412 #endif /* CONFIG_OCV */
3413 #ifdef CONFIG_IEEE80211N
3414 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
3415 conf
->ieee80211n
= atoi(pos
);
3416 } else if (os_strcmp(buf
, "ht_capab") == 0) {
3417 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
3418 wpa_printf(MSG_ERROR
, "Line %d: invalid ht_capab",
3422 } else if (os_strcmp(buf
, "require_ht") == 0) {
3423 conf
->require_ht
= atoi(pos
);
3424 } else if (os_strcmp(buf
, "obss_interval") == 0) {
3425 conf
->obss_interval
= atoi(pos
);
3426 #endif /* CONFIG_IEEE80211N */
3427 #ifdef CONFIG_IEEE80211AC
3428 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
3429 conf
->ieee80211ac
= atoi(pos
);
3430 } else if (os_strcmp(buf
, "vht_capab") == 0) {
3431 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
3432 wpa_printf(MSG_ERROR
, "Line %d: invalid vht_capab",
3436 } else if (os_strcmp(buf
, "require_vht") == 0) {
3437 conf
->require_vht
= atoi(pos
);
3438 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
3439 conf
->vht_oper_chwidth
= atoi(pos
);
3440 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0) {
3441 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
3442 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0) {
3443 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
3444 } else if (os_strcmp(buf
, "vendor_vht") == 0) {
3445 bss
->vendor_vht
= atoi(pos
);
3446 } else if (os_strcmp(buf
, "use_sta_nsts") == 0) {
3447 bss
->use_sta_nsts
= atoi(pos
);
3448 #endif /* CONFIG_IEEE80211AC */
3449 #ifdef CONFIG_IEEE80211AX
3450 } else if (os_strcmp(buf
, "ieee80211ax") == 0) {
3451 conf
->ieee80211ax
= atoi(pos
);
3452 } else if (os_strcmp(buf
, "he_su_beamformer") == 0) {
3453 conf
->he_phy_capab
.he_su_beamformer
= atoi(pos
);
3454 } else if (os_strcmp(buf
, "he_su_beamformee") == 0) {
3455 conf
->he_phy_capab
.he_su_beamformee
= atoi(pos
);
3456 } else if (os_strcmp(buf
, "he_mu_beamformer") == 0) {
3457 conf
->he_phy_capab
.he_mu_beamformer
= atoi(pos
);
3458 } else if (os_strcmp(buf
, "he_bss_color") == 0) {
3459 conf
->he_op
.he_bss_color
= atoi(pos
);
3460 } else if (os_strcmp(buf
, "he_default_pe_duration") == 0) {
3461 conf
->he_op
.he_default_pe_duration
= atoi(pos
);
3462 } else if (os_strcmp(buf
, "he_twt_required") == 0) {
3463 conf
->he_op
.he_twt_required
= atoi(pos
);
3464 } else if (os_strcmp(buf
, "he_rts_threshold") == 0) {
3465 conf
->he_op
.he_rts_threshold
= atoi(pos
);
3466 } else if (os_strcmp(buf
, "he_basic_mcs_nss_set") == 0) {
3467 conf
->he_op
.he_basic_mcs_nss_set
= atoi(pos
);
3468 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_param_count") == 0) {
3469 conf
->he_mu_edca
.he_qos_info
|=
3470 set_he_cap(atoi(pos
), HE_QOS_INFO_EDCA_PARAM_SET_COUNT
);
3471 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_q_ack") == 0) {
3472 conf
->he_mu_edca
.he_qos_info
|=
3473 set_he_cap(atoi(pos
), HE_QOS_INFO_Q_ACK
);
3474 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_queue_request") == 0) {
3475 conf
->he_mu_edca
.he_qos_info
|=
3476 set_he_cap(atoi(pos
), HE_QOS_INFO_QUEUE_REQUEST
);
3477 } else if (os_strcmp(buf
, "he_mu_edca_qos_info_txop_request") == 0) {
3478 conf
->he_mu_edca
.he_qos_info
|=
3479 set_he_cap(atoi(pos
), HE_QOS_INFO_TXOP_REQUEST
);
3480 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_aifsn") == 0) {
3481 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3482 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3483 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_acm") == 0) {
3484 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3485 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3486 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_aci") == 0) {
3487 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3488 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3489 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_ecwmin") == 0) {
3490 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3491 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3492 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_ecwmax") == 0) {
3493 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3494 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3495 } else if (os_strcmp(buf
, "he_mu_edca_ac_be_timer") == 0) {
3496 conf
->he_mu_edca
.he_mu_ac_be_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3498 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_aifsn") == 0) {
3499 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3500 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3501 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_acm") == 0) {
3502 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3503 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3504 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_aci") == 0) {
3505 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3506 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3507 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_ecwmin") == 0) {
3508 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3509 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3510 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_ecwmax") == 0) {
3511 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3512 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3513 } else if (os_strcmp(buf
, "he_mu_edca_ac_bk_timer") == 0) {
3514 conf
->he_mu_edca
.he_mu_ac_bk_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3516 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_aifsn") == 0) {
3517 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3518 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3519 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_acm") == 0) {
3520 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3521 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3522 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_aci") == 0) {
3523 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3524 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3525 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_ecwmin") == 0) {
3526 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3527 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3528 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_ecwmax") == 0) {
3529 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3530 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3531 } else if (os_strcmp(buf
, "he_mu_edca_ac_vi_timer") == 0) {
3532 conf
->he_mu_edca
.he_mu_ac_vi_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3534 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_aifsn") == 0) {
3535 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3536 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_AIFSN
);
3537 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_acm") == 0) {
3538 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3539 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACM
);
3540 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_aci") == 0) {
3541 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ACI_IDX
] |=
3542 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ACI
);
3543 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_ecwmin") == 0) {
3544 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3545 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMIN
);
3546 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_ecwmax") == 0) {
3547 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_ECW_IDX
] |=
3548 set_he_cap(atoi(pos
), HE_MU_AC_PARAM_ECWMAX
);
3549 } else if (os_strcmp(buf
, "he_mu_edca_ac_vo_timer") == 0) {
3550 conf
->he_mu_edca
.he_mu_ac_vo_param
[HE_MU_AC_PARAM_TIMER_IDX
] =
3552 } else if (os_strcmp(buf
, "he_spr_sr_control") == 0) {
3553 conf
->spr
.sr_control
= atoi(pos
) & 0xff;
3554 } else if (os_strcmp(buf
, "he_spr_non_srg_obss_pd_max_offset") == 0) {
3555 conf
->spr
.non_srg_obss_pd_max_offset
= atoi(pos
);
3556 } else if (os_strcmp(buf
, "he_spr_srg_obss_pd_min_offset") == 0) {
3557 conf
->spr
.srg_obss_pd_min_offset
= atoi(pos
);
3558 } else if (os_strcmp(buf
, "he_spr_srg_obss_pd_max_offset") == 0) {
3559 conf
->spr
.srg_obss_pd_max_offset
= atoi(pos
);
3560 } else if (os_strcmp(buf
, "he_oper_chwidth") == 0) {
3561 conf
->he_oper_chwidth
= atoi(pos
);
3562 } else if (os_strcmp(buf
, "he_oper_centr_freq_seg0_idx") == 0) {
3563 conf
->he_oper_centr_freq_seg0_idx
= atoi(pos
);
3564 } else if (os_strcmp(buf
, "he_oper_centr_freq_seg1_idx") == 0) {
3565 conf
->he_oper_centr_freq_seg1_idx
= atoi(pos
);
3566 #endif /* CONFIG_IEEE80211AX */
3567 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
3568 bss
->max_listen_interval
= atoi(pos
);
3569 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
3570 bss
->disable_pmksa_caching
= atoi(pos
);
3571 } else if (os_strcmp(buf
, "okc") == 0) {
3572 bss
->okc
= atoi(pos
);
3574 } else if (os_strcmp(buf
, "wps_state") == 0) {
3575 bss
->wps_state
= atoi(pos
);
3576 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
3577 wpa_printf(MSG_ERROR
, "Line %d: invalid wps_state",
3581 } else if (os_strcmp(buf
, "wps_independent") == 0) {
3582 bss
->wps_independent
= atoi(pos
);
3583 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
3584 bss
->ap_setup_locked
= atoi(pos
);
3585 } else if (os_strcmp(buf
, "uuid") == 0) {
3586 if (uuid_str2bin(pos
, bss
->uuid
)) {
3587 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID", line
);
3590 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
3591 os_free(bss
->wps_pin_requests
);
3592 bss
->wps_pin_requests
= os_strdup(pos
);
3593 } else if (os_strcmp(buf
, "device_name") == 0) {
3594 if (os_strlen(pos
) > WPS_DEV_NAME_MAX_LEN
) {
3595 wpa_printf(MSG_ERROR
, "Line %d: Too long "
3596 "device_name", line
);
3599 os_free(bss
->device_name
);
3600 bss
->device_name
= os_strdup(pos
);
3601 } else if (os_strcmp(buf
, "manufacturer") == 0) {
3602 if (os_strlen(pos
) > 64) {
3603 wpa_printf(MSG_ERROR
, "Line %d: Too long manufacturer",
3607 os_free(bss
->manufacturer
);
3608 bss
->manufacturer
= os_strdup(pos
);
3609 } else if (os_strcmp(buf
, "model_name") == 0) {
3610 if (os_strlen(pos
) > 32) {
3611 wpa_printf(MSG_ERROR
, "Line %d: Too long model_name",
3615 os_free(bss
->model_name
);
3616 bss
->model_name
= os_strdup(pos
);
3617 } else if (os_strcmp(buf
, "model_number") == 0) {
3618 if (os_strlen(pos
) > 32) {
3619 wpa_printf(MSG_ERROR
, "Line %d: Too long model_number",
3623 os_free(bss
->model_number
);
3624 bss
->model_number
= os_strdup(pos
);
3625 } else if (os_strcmp(buf
, "serial_number") == 0) {
3626 if (os_strlen(pos
) > 32) {
3627 wpa_printf(MSG_ERROR
, "Line %d: Too long serial_number",
3631 os_free(bss
->serial_number
);
3632 bss
->serial_number
= os_strdup(pos
);
3633 } else if (os_strcmp(buf
, "device_type") == 0) {
3634 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
3636 } else if (os_strcmp(buf
, "config_methods") == 0) {
3637 os_free(bss
->config_methods
);
3638 bss
->config_methods
= os_strdup(pos
);
3639 } else if (os_strcmp(buf
, "os_version") == 0) {
3640 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
3641 wpa_printf(MSG_ERROR
, "Line %d: invalid os_version",
3645 } else if (os_strcmp(buf
, "ap_pin") == 0) {
3646 os_free(bss
->ap_pin
);
3650 bss
->ap_pin
= os_strdup(pos
);
3651 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
3652 bss
->skip_cred_build
= atoi(pos
);
3653 } else if (os_strcmp(buf
, "extra_cred") == 0) {
3654 os_free(bss
->extra_cred
);
3655 bss
->extra_cred
= (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
3656 if (bss
->extra_cred
== NULL
) {
3657 wpa_printf(MSG_ERROR
, "Line %d: could not read Credentials from '%s'",
3661 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
3662 bss
->wps_cred_processing
= atoi(pos
);
3663 } else if (os_strcmp(buf
, "wps_cred_add_sae") == 0) {
3664 bss
->wps_cred_add_sae
= atoi(pos
);
3665 } else if (os_strcmp(buf
, "ap_settings") == 0) {
3666 os_free(bss
->ap_settings
);
3668 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
3669 if (bss
->ap_settings
== NULL
) {
3670 wpa_printf(MSG_ERROR
, "Line %d: could not read AP Settings from '%s'",
3674 } else if (os_strcmp(buf
, "multi_ap_backhaul_ssid") == 0) {
3676 char *str
= wpa_config_parse_string(pos
, &slen
);
3678 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
3679 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
3684 os_memcpy(bss
->multi_ap_backhaul_ssid
.ssid
, str
, slen
);
3685 bss
->multi_ap_backhaul_ssid
.ssid_len
= slen
;
3686 bss
->multi_ap_backhaul_ssid
.ssid_set
= 1;
3688 } else if (os_strcmp(buf
, "multi_ap_backhaul_wpa_passphrase") == 0) {
3689 int len
= os_strlen(pos
);
3691 if (len
< 8 || len
> 63) {
3692 wpa_printf(MSG_ERROR
,
3693 "Line %d: invalid WPA passphrase length %d (expected 8..63)",
3697 os_free(bss
->multi_ap_backhaul_ssid
.wpa_passphrase
);
3698 bss
->multi_ap_backhaul_ssid
.wpa_passphrase
= os_strdup(pos
);
3699 if (bss
->multi_ap_backhaul_ssid
.wpa_passphrase
) {
3700 hostapd_config_clear_wpa_psk(
3701 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3702 bss
->multi_ap_backhaul_ssid
.wpa_passphrase_set
= 1;
3704 } else if (os_strcmp(buf
, "multi_ap_backhaul_wpa_psk") == 0) {
3705 hostapd_config_clear_wpa_psk(
3706 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3707 bss
->multi_ap_backhaul_ssid
.wpa_psk
=
3708 os_zalloc(sizeof(struct hostapd_wpa_psk
));
3709 if (!bss
->multi_ap_backhaul_ssid
.wpa_psk
)
3711 if (hexstr2bin(pos
, bss
->multi_ap_backhaul_ssid
.wpa_psk
->psk
,
3713 pos
[PMK_LEN
* 2] != '\0') {
3714 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
3716 hostapd_config_clear_wpa_psk(
3717 &bss
->multi_ap_backhaul_ssid
.wpa_psk
);
3720 bss
->multi_ap_backhaul_ssid
.wpa_psk
->group
= 1;
3721 os_free(bss
->multi_ap_backhaul_ssid
.wpa_passphrase
);
3722 bss
->multi_ap_backhaul_ssid
.wpa_passphrase
= NULL
;
3723 bss
->multi_ap_backhaul_ssid
.wpa_psk_set
= 1;
3724 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
3725 os_free(bss
->upnp_iface
);
3726 bss
->upnp_iface
= os_strdup(pos
);
3727 } else if (os_strcmp(buf
, "friendly_name") == 0) {
3728 os_free(bss
->friendly_name
);
3729 bss
->friendly_name
= os_strdup(pos
);
3730 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
3731 os_free(bss
->manufacturer_url
);
3732 bss
->manufacturer_url
= os_strdup(pos
);
3733 } else if (os_strcmp(buf
, "model_description") == 0) {
3734 os_free(bss
->model_description
);
3735 bss
->model_description
= os_strdup(pos
);
3736 } else if (os_strcmp(buf
, "model_url") == 0) {
3737 os_free(bss
->model_url
);
3738 bss
->model_url
= os_strdup(pos
);
3739 } else if (os_strcmp(buf
, "upc") == 0) {
3741 bss
->upc
= os_strdup(pos
);
3742 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
3743 bss
->pbc_in_m1
= atoi(pos
);
3744 } else if (os_strcmp(buf
, "server_id") == 0) {
3745 os_free(bss
->server_id
);
3746 bss
->server_id
= os_strdup(pos
);
3747 #ifdef CONFIG_WPS_NFC
3748 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
3749 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
3750 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
3751 bss
->wps_nfc_dev_pw_id
> 0xffff) {
3752 wpa_printf(MSG_ERROR
, "Line %d: Invalid wps_nfc_dev_pw_id value",
3756 bss
->wps_nfc_pw_from_config
= 1;
3757 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
3758 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
3759 bss
->wps_nfc_dh_pubkey
= wpabuf_parse_bin(pos
);
3760 bss
->wps_nfc_pw_from_config
= 1;
3761 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
3762 wpabuf_free(bss
->wps_nfc_dh_privkey
);
3763 bss
->wps_nfc_dh_privkey
= wpabuf_parse_bin(pos
);
3764 bss
->wps_nfc_pw_from_config
= 1;
3765 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
3766 wpabuf_free(bss
->wps_nfc_dev_pw
);
3767 bss
->wps_nfc_dev_pw
= wpabuf_parse_bin(pos
);
3768 bss
->wps_nfc_pw_from_config
= 1;
3769 #endif /* CONFIG_WPS_NFC */
3770 #endif /* CONFIG_WPS */
3771 #ifdef CONFIG_P2P_MANAGER
3772 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
3774 bss
->p2p
|= P2P_MANAGE
;
3776 bss
->p2p
&= ~P2P_MANAGE
;
3777 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
3779 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
3781 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
3782 #endif /* CONFIG_P2P_MANAGER */
3783 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
3784 bss
->disassoc_low_ack
= atoi(pos
);
3785 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
3787 bss
->tdls
|= TDLS_PROHIBIT
;
3789 bss
->tdls
&= ~TDLS_PROHIBIT
;
3790 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
3792 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
3794 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
3795 #ifdef CONFIG_RSN_TESTING
3796 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
3797 extern int rsn_testing
;
3798 rsn_testing
= atoi(pos
);
3799 #endif /* CONFIG_RSN_TESTING */
3800 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
3801 bss
->time_advertisement
= atoi(pos
);
3802 } else if (os_strcmp(buf
, "time_zone") == 0) {
3803 size_t tz_len
= os_strlen(pos
);
3804 if (tz_len
< 4 || tz_len
> 255) {
3805 wpa_printf(MSG_DEBUG
, "Line %d: invalid time_zone",
3809 os_free(bss
->time_zone
);
3810 bss
->time_zone
= os_strdup(pos
);
3811 if (bss
->time_zone
== NULL
)
3813 #ifdef CONFIG_WNM_AP
3814 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
3815 bss
->wnm_sleep_mode
= atoi(pos
);
3816 } else if (os_strcmp(buf
, "wnm_sleep_mode_no_keys") == 0) {
3817 bss
->wnm_sleep_mode_no_keys
= atoi(pos
);
3818 } else if (os_strcmp(buf
, "bss_transition") == 0) {
3819 bss
->bss_transition
= atoi(pos
);
3820 #endif /* CONFIG_WNM_AP */
3821 #ifdef CONFIG_INTERWORKING
3822 } else if (os_strcmp(buf
, "interworking") == 0) {
3823 bss
->interworking
= atoi(pos
);
3824 } else if (os_strcmp(buf
, "access_network_type") == 0) {
3825 bss
->access_network_type
= atoi(pos
);
3826 if (bss
->access_network_type
< 0 ||
3827 bss
->access_network_type
> 15) {
3828 wpa_printf(MSG_ERROR
,
3829 "Line %d: invalid access_network_type",
3833 } else if (os_strcmp(buf
, "internet") == 0) {
3834 bss
->internet
= atoi(pos
);
3835 } else if (os_strcmp(buf
, "asra") == 0) {
3836 bss
->asra
= atoi(pos
);
3837 } else if (os_strcmp(buf
, "esr") == 0) {
3838 bss
->esr
= atoi(pos
);
3839 } else if (os_strcmp(buf
, "uesa") == 0) {
3840 bss
->uesa
= atoi(pos
);
3841 } else if (os_strcmp(buf
, "venue_group") == 0) {
3842 bss
->venue_group
= atoi(pos
);
3843 bss
->venue_info_set
= 1;
3844 } else if (os_strcmp(buf
, "venue_type") == 0) {
3845 bss
->venue_type
= atoi(pos
);
3846 bss
->venue_info_set
= 1;
3847 } else if (os_strcmp(buf
, "hessid") == 0) {
3848 if (hwaddr_aton(pos
, bss
->hessid
)) {
3849 wpa_printf(MSG_ERROR
, "Line %d: invalid hessid", line
);
3852 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
3853 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
3855 } else if (os_strcmp(buf
, "venue_name") == 0) {
3856 if (parse_venue_name(bss
, pos
, line
) < 0)
3858 } else if (os_strcmp(buf
, "venue_url") == 0) {
3859 if (parse_venue_url(bss
, pos
, line
) < 0)
3861 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
3863 u16 redirect_url_len
;
3864 if (hexstr2bin(pos
, &auth_type
, 1)) {
3865 wpa_printf(MSG_ERROR
,
3866 "Line %d: Invalid network_auth_type '%s'",
3870 if (auth_type
== 0 || auth_type
== 2)
3871 redirect_url_len
= os_strlen(pos
+ 2);
3873 redirect_url_len
= 0;
3874 os_free(bss
->network_auth_type
);
3875 bss
->network_auth_type
= os_malloc(redirect_url_len
+ 3 + 1);
3876 if (bss
->network_auth_type
== NULL
)
3878 *bss
->network_auth_type
= auth_type
;
3879 WPA_PUT_LE16(bss
->network_auth_type
+ 1, redirect_url_len
);
3880 if (redirect_url_len
)
3881 os_memcpy(bss
->network_auth_type
+ 3, pos
+ 2,
3883 bss
->network_auth_type_len
= 3 + redirect_url_len
;
3884 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
3885 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1)) {
3886 wpa_printf(MSG_ERROR
, "Line %d: Invalid ipaddr_type_availability '%s'",
3888 bss
->ipaddr_type_configured
= 0;
3891 bss
->ipaddr_type_configured
= 1;
3892 } else if (os_strcmp(buf
, "domain_name") == 0) {
3893 int j
, num_domains
, domain_len
, domain_list_len
= 0;
3894 char *tok_start
, *tok_prev
;
3895 u8
*domain_list
, *domain_ptr
;
3897 domain_list_len
= os_strlen(pos
) + 1;
3898 domain_list
= os_malloc(domain_list_len
);
3899 if (domain_list
== NULL
)
3902 domain_ptr
= domain_list
;
3905 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
3910 for (j
= 0; j
< num_domains
; j
++) {
3911 tok_start
= os_strchr(tok_prev
, ',');
3913 domain_len
= tok_start
- tok_prev
;
3914 *domain_ptr
= domain_len
;
3915 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3916 domain_ptr
+= domain_len
+ 1;
3917 tok_prev
= ++tok_start
;
3919 domain_len
= os_strlen(tok_prev
);
3920 *domain_ptr
= domain_len
;
3921 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3922 domain_ptr
+= domain_len
+ 1;
3926 os_free(bss
->domain_name
);
3927 bss
->domain_name
= domain_list
;
3928 bss
->domain_name_len
= domain_list_len
;
3929 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
3930 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
3932 } else if (os_strcmp(buf
, "nai_realm") == 0) {
3933 if (parse_nai_realm(bss
, pos
, line
) < 0)
3935 } else if (os_strcmp(buf
, "anqp_elem") == 0) {
3936 if (parse_anqp_elem(bss
, pos
, line
) < 0)
3938 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
3939 int val
= atoi(pos
);
3942 wpa_printf(MSG_ERROR
,
3943 "Line %d: Invalid gas_frag_limit '%s'",
3947 bss
->gas_frag_limit
= val
;
3948 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
3949 bss
->gas_comeback_delay
= atoi(pos
);
3950 } else if (os_strcmp(buf
, "qos_map_set") == 0) {
3951 if (parse_qos_map_set(bss
, pos
, line
) < 0)
3953 #endif /* CONFIG_INTERWORKING */
3954 #ifdef CONFIG_RADIUS_TEST
3955 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
3956 os_free(bss
->dump_msk_file
);
3957 bss
->dump_msk_file
= os_strdup(pos
);
3958 #endif /* CONFIG_RADIUS_TEST */
3959 #ifdef CONFIG_PROXYARP
3960 } else if (os_strcmp(buf
, "proxy_arp") == 0) {
3961 bss
->proxy_arp
= atoi(pos
);
3962 #endif /* CONFIG_PROXYARP */
3964 } else if (os_strcmp(buf
, "hs20") == 0) {
3965 bss
->hs20
= atoi(pos
);
3966 } else if (os_strcmp(buf
, "hs20_release") == 0) {
3967 int val
= atoi(pos
);
3969 if (val
< 1 || val
> (HS20_VERSION
>> 4) + 1) {
3970 wpa_printf(MSG_ERROR
,
3971 "Line %d: Unsupported hs20_release: %s",
3975 bss
->hs20_release
= val
;
3976 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
3977 bss
->disable_dgaf
= atoi(pos
);
3978 } else if (os_strcmp(buf
, "na_mcast_to_ucast") == 0) {
3979 bss
->na_mcast_to_ucast
= atoi(pos
);
3980 } else if (os_strcmp(buf
, "osen") == 0) {
3981 bss
->osen
= atoi(pos
);
3982 } else if (os_strcmp(buf
, "anqp_domain_id") == 0) {
3983 bss
->anqp_domain_id
= atoi(pos
);
3984 } else if (os_strcmp(buf
, "hs20_deauth_req_timeout") == 0) {
3985 bss
->hs20_deauth_req_timeout
= atoi(pos
);
3986 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
3987 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
3989 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
3990 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0)
3992 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
3993 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
3996 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
3998 size_t oper_class_len
;
3999 oper_class_len
= os_strlen(pos
);
4000 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
4001 wpa_printf(MSG_ERROR
,
4002 "Line %d: Invalid hs20_operating_class '%s'",
4006 oper_class_len
/= 2;
4007 oper_class
= os_malloc(oper_class_len
);
4008 if (oper_class
== NULL
)
4010 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
4011 wpa_printf(MSG_ERROR
,
4012 "Line %d: Invalid hs20_operating_class '%s'",
4014 os_free(oper_class
);
4017 os_free(bss
->hs20_operating_class
);
4018 bss
->hs20_operating_class
= oper_class
;
4019 bss
->hs20_operating_class_len
= oper_class_len
;
4020 } else if (os_strcmp(buf
, "hs20_icon") == 0) {
4021 if (hs20_parse_icon(bss
, pos
) < 0) {
4022 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_icon '%s'",
4026 } else if (os_strcmp(buf
, "osu_ssid") == 0) {
4027 if (hs20_parse_osu_ssid(bss
, pos
, line
) < 0)
4029 } else if (os_strcmp(buf
, "osu_server_uri") == 0) {
4030 if (hs20_parse_osu_server_uri(bss
, pos
, line
) < 0)
4032 } else if (os_strcmp(buf
, "osu_friendly_name") == 0) {
4033 if (hs20_parse_osu_friendly_name(bss
, pos
, line
) < 0)
4035 } else if (os_strcmp(buf
, "osu_nai") == 0) {
4036 if (hs20_parse_osu_nai(bss
, pos
, line
) < 0)
4038 } else if (os_strcmp(buf
, "osu_nai2") == 0) {
4039 if (hs20_parse_osu_nai2(bss
, pos
, line
) < 0)
4041 } else if (os_strcmp(buf
, "osu_method_list") == 0) {
4042 if (hs20_parse_osu_method_list(bss
, pos
, line
) < 0)
4044 } else if (os_strcmp(buf
, "osu_icon") == 0) {
4045 if (hs20_parse_osu_icon(bss
, pos
, line
) < 0)
4047 } else if (os_strcmp(buf
, "osu_service_desc") == 0) {
4048 if (hs20_parse_osu_service_desc(bss
, pos
, line
) < 0)
4050 } else if (os_strcmp(buf
, "operator_icon") == 0) {
4051 if (hs20_parse_operator_icon(bss
, pos
, line
) < 0)
4053 } else if (os_strcmp(buf
, "subscr_remediation_url") == 0) {
4054 os_free(bss
->subscr_remediation_url
);
4055 bss
->subscr_remediation_url
= os_strdup(pos
);
4056 } else if (os_strcmp(buf
, "subscr_remediation_method") == 0) {
4057 bss
->subscr_remediation_method
= atoi(pos
);
4058 } else if (os_strcmp(buf
, "hs20_t_c_filename") == 0) {
4059 os_free(bss
->t_c_filename
);
4060 bss
->t_c_filename
= os_strdup(pos
);
4061 } else if (os_strcmp(buf
, "hs20_t_c_timestamp") == 0) {
4062 bss
->t_c_timestamp
= strtol(pos
, NULL
, 0);
4063 } else if (os_strcmp(buf
, "hs20_t_c_server_url") == 0) {
4064 os_free(bss
->t_c_server_url
);
4065 bss
->t_c_server_url
= os_strdup(pos
);
4066 } else if (os_strcmp(buf
, "hs20_sim_provisioning_url") == 0) {
4067 os_free(bss
->hs20_sim_provisioning_url
);
4068 bss
->hs20_sim_provisioning_url
= os_strdup(pos
);
4069 #endif /* CONFIG_HS20 */
4071 } else if (os_strcmp(buf
, "mbo") == 0) {
4072 bss
->mbo_enabled
= atoi(pos
);
4073 } else if (os_strcmp(buf
, "mbo_cell_data_conn_pref") == 0) {
4074 bss
->mbo_cell_data_conn_pref
= atoi(pos
);
4075 } else if (os_strcmp(buf
, "oce") == 0) {
4076 bss
->oce
= atoi(pos
);
4077 #endif /* CONFIG_MBO */
4078 #ifdef CONFIG_TESTING_OPTIONS
4079 #define PARSE_TEST_PROBABILITY(_val) \
4080 } else if (os_strcmp(buf, #_val) == 0) { \
4083 conf->_val = strtod(pos, &end); \
4084 if (*end || conf->_val < 0.0 || \
4085 conf->_val > 1.0) { \
4086 wpa_printf(MSG_ERROR, \
4087 "Line %d: Invalid value '%s'", \
4091 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
4092 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
4093 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
4094 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
4095 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
4096 } else if (os_strcmp(buf
, "ecsa_ie_only") == 0) {
4097 conf
->ecsa_ie_only
= atoi(pos
);
4098 } else if (os_strcmp(buf
, "bss_load_test") == 0) {
4099 WPA_PUT_LE16(bss
->bss_load_test
, atoi(pos
));
4100 pos
= os_strchr(pos
, ':');
4102 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
4107 bss
->bss_load_test
[2] = atoi(pos
);
4108 pos
= os_strchr(pos
, ':');
4110 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
4115 WPA_PUT_LE16(&bss
->bss_load_test
[3], atoi(pos
));
4116 bss
->bss_load_test_set
= 1;
4117 } else if (os_strcmp(buf
, "radio_measurements") == 0) {
4119 * DEPRECATED: This parameter will be removed in the future.
4120 * Use rrm_neighbor_report instead.
4122 int val
= atoi(pos
);
4125 bss
->radio_measurements
[0] |=
4126 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
4127 } else if (os_strcmp(buf
, "own_ie_override") == 0) {
4129 size_t len
= os_strlen(pos
) / 2;
4131 tmp
= wpabuf_alloc(len
);
4135 if (hexstr2bin(pos
, wpabuf_put(tmp
, len
), len
)) {
4137 wpa_printf(MSG_ERROR
,
4138 "Line %d: Invalid own_ie_override '%s'",
4143 wpabuf_free(bss
->own_ie_override
);
4144 bss
->own_ie_override
= tmp
;
4145 } else if (os_strcmp(buf
, "sae_reflection_attack") == 0) {
4146 bss
->sae_reflection_attack
= atoi(pos
);
4147 } else if (os_strcmp(buf
, "sae_commit_override") == 0) {
4148 wpabuf_free(bss
->sae_commit_override
);
4149 bss
->sae_commit_override
= wpabuf_parse_bin(pos
);
4150 #endif /* CONFIG_TESTING_OPTIONS */
4152 } else if (os_strcmp(buf
, "sae_password") == 0) {
4153 if (parse_sae_password(bss
, pos
) < 0) {
4154 wpa_printf(MSG_ERROR
, "Line %d: Invalid sae_password",
4158 #endif /* CONFIG_SAE */
4159 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
4160 if (parse_wpabuf_hex(line
, buf
, &bss
->vendor_elements
, pos
))
4162 } else if (os_strcmp(buf
, "assocresp_elements") == 0) {
4163 if (parse_wpabuf_hex(line
, buf
, &bss
->assocresp_elements
, pos
))
4165 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
4166 bss
->sae_anti_clogging_threshold
= atoi(pos
);
4167 } else if (os_strcmp(buf
, "sae_sync") == 0) {
4168 bss
->sae_sync
= atoi(pos
);
4169 } else if (os_strcmp(buf
, "sae_groups") == 0) {
4170 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
4171 wpa_printf(MSG_ERROR
,
4172 "Line %d: Invalid sae_groups value '%s'",
4176 } else if (os_strcmp(buf
, "sae_require_mfp") == 0) {
4177 bss
->sae_require_mfp
= atoi(pos
);
4178 } else if (os_strcmp(buf
, "local_pwr_constraint") == 0) {
4179 int val
= atoi(pos
);
4180 if (val
< 0 || val
> 255) {
4181 wpa_printf(MSG_ERROR
, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
4185 conf
->local_pwr_constraint
= val
;
4186 } else if (os_strcmp(buf
, "spectrum_mgmt_required") == 0) {
4187 conf
->spectrum_mgmt_required
= atoi(pos
);
4188 } else if (os_strcmp(buf
, "wowlan_triggers") == 0) {
4189 os_free(bss
->wowlan_triggers
);
4190 bss
->wowlan_triggers
= os_strdup(pos
);
4192 } else if (os_strcmp(buf
, "fst_group_id") == 0) {
4193 size_t len
= os_strlen(pos
);
4195 if (!len
|| len
>= sizeof(conf
->fst_cfg
.group_id
)) {
4196 wpa_printf(MSG_ERROR
,
4197 "Line %d: Invalid fst_group_id value '%s'",
4202 if (conf
->fst_cfg
.group_id
[0]) {
4203 wpa_printf(MSG_ERROR
,
4204 "Line %d: Duplicate fst_group value '%s'",
4209 os_strlcpy(conf
->fst_cfg
.group_id
, pos
,
4210 sizeof(conf
->fst_cfg
.group_id
));
4211 } else if (os_strcmp(buf
, "fst_priority") == 0) {
4216 wpa_printf(MSG_ERROR
,
4217 "Line %d: fst_priority value not supplied (expected 1..%u)",
4218 line
, FST_MAX_PRIO_VALUE
);
4222 val
= strtol(pos
, &endp
, 0);
4223 if (*endp
|| val
< 1 || val
> FST_MAX_PRIO_VALUE
) {
4224 wpa_printf(MSG_ERROR
,
4225 "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)",
4226 line
, val
, pos
, FST_MAX_PRIO_VALUE
);
4229 conf
->fst_cfg
.priority
= (u8
) val
;
4230 } else if (os_strcmp(buf
, "fst_llt") == 0) {
4235 wpa_printf(MSG_ERROR
,
4236 "Line %d: fst_llt value not supplied (expected 1..%u)",
4237 line
, FST_MAX_LLT_MS
);
4240 val
= strtol(pos
, &endp
, 0);
4241 if (*endp
|| val
< 1 ||
4242 (unsigned long int) val
> FST_MAX_LLT_MS
) {
4243 wpa_printf(MSG_ERROR
,
4244 "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
4245 line
, val
, pos
, FST_MAX_LLT_MS
);
4248 conf
->fst_cfg
.llt
= (u32
) val
;
4249 #endif /* CONFIG_FST */
4250 } else if (os_strcmp(buf
, "track_sta_max_num") == 0) {
4251 conf
->track_sta_max_num
= atoi(pos
);
4252 } else if (os_strcmp(buf
, "track_sta_max_age") == 0) {
4253 conf
->track_sta_max_age
= atoi(pos
);
4254 } else if (os_strcmp(buf
, "no_probe_resp_if_seen_on") == 0) {
4255 os_free(bss
->no_probe_resp_if_seen_on
);
4256 bss
->no_probe_resp_if_seen_on
= os_strdup(pos
);
4257 } else if (os_strcmp(buf
, "no_auth_if_seen_on") == 0) {
4258 os_free(bss
->no_auth_if_seen_on
);
4259 bss
->no_auth_if_seen_on
= os_strdup(pos
);
4260 } else if (os_strcmp(buf
, "lci") == 0) {
4261 wpabuf_free(conf
->lci
);
4262 conf
->lci
= wpabuf_parse_bin(pos
);
4263 if (conf
->lci
&& wpabuf_len(conf
->lci
) == 0) {
4264 wpabuf_free(conf
->lci
);
4267 } else if (os_strcmp(buf
, "civic") == 0) {
4268 wpabuf_free(conf
->civic
);
4269 conf
->civic
= wpabuf_parse_bin(pos
);
4270 if (conf
->civic
&& wpabuf_len(conf
->civic
) == 0) {
4271 wpabuf_free(conf
->civic
);
4274 } else if (os_strcmp(buf
, "rrm_neighbor_report") == 0) {
4276 bss
->radio_measurements
[0] |=
4277 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
4278 } else if (os_strcmp(buf
, "rrm_beacon_report") == 0) {
4280 bss
->radio_measurements
[0] |=
4281 WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE
|
4282 WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE
|
4283 WLAN_RRM_CAPS_BEACON_REPORT_TABLE
;
4284 } else if (os_strcmp(buf
, "gas_address3") == 0) {
4285 bss
->gas_address3
= atoi(pos
);
4286 } else if (os_strcmp(buf
, "stationary_ap") == 0) {
4287 conf
->stationary_ap
= atoi(pos
);
4288 } else if (os_strcmp(buf
, "ftm_responder") == 0) {
4289 bss
->ftm_responder
= atoi(pos
);
4290 } else if (os_strcmp(buf
, "ftm_initiator") == 0) {
4291 bss
->ftm_initiator
= atoi(pos
);
4293 } else if (os_strcmp(buf
, "fils_cache_id") == 0) {
4294 if (hexstr2bin(pos
, bss
->fils_cache_id
, FILS_CACHE_ID_LEN
)) {
4295 wpa_printf(MSG_ERROR
,
4296 "Line %d: Invalid fils_cache_id '%s'",
4300 bss
->fils_cache_id_set
= 1;
4301 } else if (os_strcmp(buf
, "fils_realm") == 0) {
4302 if (parse_fils_realm(bss
, pos
) < 0)
4304 } else if (os_strcmp(buf
, "fils_dh_group") == 0) {
4305 bss
->fils_dh_group
= atoi(pos
);
4306 } else if (os_strcmp(buf
, "dhcp_server") == 0) {
4307 if (hostapd_parse_ip_addr(pos
, &bss
->dhcp_server
)) {
4308 wpa_printf(MSG_ERROR
,
4309 "Line %d: invalid IP address '%s'",
4313 } else if (os_strcmp(buf
, "dhcp_rapid_commit_proxy") == 0) {
4314 bss
->dhcp_rapid_commit_proxy
= atoi(pos
);
4315 } else if (os_strcmp(buf
, "fils_hlp_wait_time") == 0) {
4316 bss
->fils_hlp_wait_time
= atoi(pos
);
4317 } else if (os_strcmp(buf
, "dhcp_server_port") == 0) {
4318 bss
->dhcp_server_port
= atoi(pos
);
4319 } else if (os_strcmp(buf
, "dhcp_relay_port") == 0) {
4320 bss
->dhcp_relay_port
= atoi(pos
);
4321 #endif /* CONFIG_FILS */
4322 } else if (os_strcmp(buf
, "multicast_to_unicast") == 0) {
4323 bss
->multicast_to_unicast
= atoi(pos
);
4324 } else if (os_strcmp(buf
, "broadcast_deauth") == 0) {
4325 bss
->broadcast_deauth
= atoi(pos
);
4327 } else if (os_strcmp(buf
, "dpp_connector") == 0) {
4328 os_free(bss
->dpp_connector
);
4329 bss
->dpp_connector
= os_strdup(pos
);
4330 } else if (os_strcmp(buf
, "dpp_netaccesskey") == 0) {
4331 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_netaccesskey
, pos
))
4333 } else if (os_strcmp(buf
, "dpp_netaccesskey_expiry") == 0) {
4334 bss
->dpp_netaccesskey_expiry
= strtol(pos
, NULL
, 0);
4335 } else if (os_strcmp(buf
, "dpp_csign") == 0) {
4336 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_csign
, pos
))
4339 } else if (os_strcmp(buf
, "dpp_controller") == 0) {
4340 if (hostapd_dpp_controller_parse(bss
, pos
))
4342 #endif /* CONFIG_DPP2 */
4343 #endif /* CONFIG_DPP */
4345 } else if (os_strcmp(buf
, "owe_transition_bssid") == 0) {
4346 if (hwaddr_aton(pos
, bss
->owe_transition_bssid
)) {
4347 wpa_printf(MSG_ERROR
,
4348 "Line %d: invalid owe_transition_bssid",
4352 } else if (os_strcmp(buf
, "owe_transition_ssid") == 0) {
4354 char *str
= wpa_config_parse_string(pos
, &slen
);
4356 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
4357 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
4362 os_memcpy(bss
->owe_transition_ssid
, str
, slen
);
4363 bss
->owe_transition_ssid_len
= slen
;
4365 } else if (os_strcmp(buf
, "owe_transition_ifname") == 0) {
4366 os_strlcpy(bss
->owe_transition_ifname
, pos
,
4367 sizeof(bss
->owe_transition_ifname
));
4368 } else if (os_strcmp(buf
, "owe_groups") == 0) {
4369 if (hostapd_parse_intlist(&bss
->owe_groups
, pos
)) {
4370 wpa_printf(MSG_ERROR
,
4371 "Line %d: Invalid owe_groups value '%s'",
4375 } else if (os_strcmp(buf
, "coloc_intf_reporting") == 0) {
4376 bss
->coloc_intf_reporting
= atoi(pos
);
4377 #endif /* CONFIG_OWE */
4378 } else if (os_strcmp(buf
, "multi_ap") == 0) {
4379 int val
= atoi(pos
);
4381 if (val
< 0 || val
> 3) {
4382 wpa_printf(MSG_ERROR
, "Line %d: Invalid multi_ap '%s'",
4387 bss
->multi_ap
= val
;
4388 } else if (os_strcmp(buf
, "rssi_reject_assoc_rssi") == 0) {
4389 conf
->rssi_reject_assoc_rssi
= atoi(pos
);
4390 } else if (os_strcmp(buf
, "rssi_reject_assoc_timeout") == 0) {
4391 conf
->rssi_reject_assoc_timeout
= atoi(pos
);
4392 } else if (os_strcmp(buf
, "pbss") == 0) {
4393 bss
->pbss
= atoi(pos
);
4394 #ifdef CONFIG_AIRTIME_POLICY
4395 } else if (os_strcmp(buf
, "airtime_mode") == 0) {
4396 int val
= atoi(pos
);
4398 if (val
< 0 || val
> AIRTIME_MODE_MAX
) {
4399 wpa_printf(MSG_ERROR
, "Line %d: Unknown airtime_mode",
4403 conf
->airtime_mode
= val
;
4404 } else if (os_strcmp(buf
, "airtime_update_interval") == 0) {
4405 conf
->airtime_update_interval
= atoi(pos
);
4406 } else if (os_strcmp(buf
, "airtime_bss_weight") == 0) {
4407 bss
->airtime_weight
= atoi(pos
);
4408 } else if (os_strcmp(buf
, "airtime_bss_limit") == 0) {
4409 int val
= atoi(pos
);
4411 if (val
< 0 || val
> 1) {
4412 wpa_printf(MSG_ERROR
,
4413 "Line %d: Invalid airtime_bss_limit (must be 0 or 1)",
4417 bss
->airtime_limit
= val
;
4418 } else if (os_strcmp(buf
, "airtime_sta_weight") == 0) {
4419 if (add_airtime_weight(bss
, pos
) < 0) {
4420 wpa_printf(MSG_ERROR
,
4421 "Line %d: Invalid airtime weight '%s'",
4425 #endif /* CONFIG_AIRTIME_POLICY */
4426 #ifdef CONFIG_MACSEC
4427 } else if (os_strcmp(buf
, "macsec_policy") == 0) {
4428 int macsec_policy
= atoi(pos
);
4430 if (macsec_policy
< 0 || macsec_policy
> 1) {
4431 wpa_printf(MSG_ERROR
,
4432 "Line %d: invalid macsec_policy (%d): '%s'.",
4433 line
, macsec_policy
, pos
);
4436 bss
->macsec_policy
= macsec_policy
;
4437 } else if (os_strcmp(buf
, "macsec_integ_only") == 0) {
4438 int macsec_integ_only
= atoi(pos
);
4440 if (macsec_integ_only
< 0 || macsec_integ_only
> 1) {
4441 wpa_printf(MSG_ERROR
,
4442 "Line %d: invalid macsec_integ_only (%d): '%s'.",
4443 line
, macsec_integ_only
, pos
);
4446 bss
->macsec_integ_only
= macsec_integ_only
;
4447 } else if (os_strcmp(buf
, "macsec_replay_protect") == 0) {
4448 int macsec_replay_protect
= atoi(pos
);
4450 if (macsec_replay_protect
< 0 || macsec_replay_protect
> 1) {
4451 wpa_printf(MSG_ERROR
,
4452 "Line %d: invalid macsec_replay_protect (%d): '%s'.",
4453 line
, macsec_replay_protect
, pos
);
4456 bss
->macsec_replay_protect
= macsec_replay_protect
;
4457 } else if (os_strcmp(buf
, "macsec_replay_window") == 0) {
4458 bss
->macsec_replay_window
= atoi(pos
);
4459 } else if (os_strcmp(buf
, "macsec_port") == 0) {
4460 int macsec_port
= atoi(pos
);
4462 if (macsec_port
< 1 || macsec_port
> 65534) {
4463 wpa_printf(MSG_ERROR
,
4464 "Line %d: invalid macsec_port (%d): '%s'.",
4465 line
, macsec_port
, pos
);
4468 bss
->macsec_port
= macsec_port
;
4469 } else if (os_strcmp(buf
, "mka_priority") == 0) {
4470 int mka_priority
= atoi(pos
);
4472 if (mka_priority
< 0 || mka_priority
> 255) {
4473 wpa_printf(MSG_ERROR
,
4474 "Line %d: invalid mka_priority (%d): '%s'.",
4475 line
, mka_priority
, pos
);
4478 bss
->mka_priority
= mka_priority
;
4479 } else if (os_strcmp(buf
, "mka_cak") == 0) {
4480 size_t len
= os_strlen(pos
);
4482 if (len
> 2 * MACSEC_CAK_MAX_LEN
||
4483 (len
!= 2 * 16 && len
!= 2 * 32) ||
4484 hexstr2bin(pos
, bss
->mka_cak
, len
/ 2)) {
4485 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CAK '%s'.",
4489 bss
->mka_cak_len
= len
/ 2;
4490 bss
->mka_psk_set
|= MKA_PSK_SET_CAK
;
4491 } else if (os_strcmp(buf
, "mka_ckn") == 0) {
4492 size_t len
= os_strlen(pos
);
4494 if (len
> 2 * MACSEC_CKN_MAX_LEN
|| /* too long */
4495 len
< 2 || /* too short */
4496 len
% 2 != 0 /* not an integral number of bytes */) {
4497 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CKN '%s'.",
4501 bss
->mka_ckn_len
= len
/ 2;
4502 if (hexstr2bin(pos
, bss
->mka_ckn
, bss
->mka_ckn_len
)) {
4503 wpa_printf(MSG_ERROR
, "Line %d: Invalid MKA-CKN '%s'.",
4507 bss
->mka_psk_set
|= MKA_PSK_SET_CKN
;
4508 #endif /* CONFIG_MACSEC */
4510 wpa_printf(MSG_ERROR
,
4511 "Line %d: unknown configuration item '%s'",
4521 * hostapd_config_read - Read and parse a configuration file
4522 * @fname: Configuration file name (including path, if needed)
4523 * Returns: Allocated configuration data structure
4525 struct hostapd_config
* hostapd_config_read(const char *fname
)
4527 struct hostapd_config
*conf
;
4529 char buf
[4096], *pos
;
4534 f
= fopen(fname
, "r");
4536 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
4537 "for reading.", fname
);
4541 conf
= hostapd_config_defaults();
4547 /* set default driver based on configuration */
4548 conf
->driver
= wpa_drivers
[0];
4549 if (conf
->driver
== NULL
) {
4550 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
4551 hostapd_config_free(conf
);
4556 conf
->last_bss
= conf
->bss
[0];
4558 while (fgets(buf
, sizeof(buf
), f
)) {
4559 struct hostapd_bss_config
*bss
;
4561 bss
= conf
->last_bss
;
4567 while (*pos
!= '\0') {
4577 pos
= os_strchr(buf
, '=');
4579 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
4586 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
4591 for (i
= 0; i
< conf
->num_bss
; i
++)
4592 hostapd_set_security_params(conf
->bss
[i
], 1);
4594 if (hostapd_config_check(conf
, 1))
4597 #ifndef WPA_IGNORE_CONFIG_ERRORS
4599 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
4600 "'%s'", errors
, fname
);
4601 hostapd_config_free(conf
);
4604 #endif /* WPA_IGNORE_CONFIG_ERRORS */
4610 int hostapd_set_iface(struct hostapd_config
*conf
,
4611 struct hostapd_bss_config
*bss
, const char *field
,
4617 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
4619 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
4620 "to value '%s'", field
, value
);
4624 for (i
= 0; i
< conf
->num_bss
; i
++)
4625 hostapd_set_security_params(conf
->bss
[i
], 0);
4627 if (hostapd_config_check(conf
, 0)) {
4628 wpa_printf(MSG_ERROR
, "Configuration check failed");