2 * hostapd / Configuration file parser
3 * Copyright (c) 2003-2015, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
9 #include "utils/includes.h"
10 #ifndef CONFIG_NATIVE_WINDOWS
12 #endif /* CONFIG_NATIVE_WINDOWS */
14 #include "utils/common.h"
15 #include "utils/uuid.h"
16 #include "common/ieee802_11_defs.h"
17 #include "crypto/sha256.h"
18 #include "crypto/tls.h"
19 #include "drivers/driver.h"
20 #include "eap_server/eap.h"
21 #include "radius/radius_client.h"
22 #include "ap/wpa_auth.h"
23 #include "ap/ap_config.h"
24 #include "config_file.h"
27 #ifndef CONFIG_NO_RADIUS
29 static struct hostapd_radius_attr
*
30 hostapd_parse_radius_attr(const char *value
);
31 #endif /* EAP_SERVER */
32 #endif /* CONFIG_NO_RADIUS */
35 #ifndef CONFIG_NO_VLAN
36 static int hostapd_config_read_vlan_file(struct hostapd_bss_config
*bss
,
40 char buf
[128], *pos
, *pos2
;
41 int line
= 0, vlan_id
;
42 struct hostapd_vlan
*vlan
;
44 f
= fopen(fname
, "r");
46 wpa_printf(MSG_ERROR
, "VLAN file '%s' not readable.", fname
);
50 while (fgets(buf
, sizeof(buf
), f
)) {
56 while (*pos
!= '\0') {
67 vlan_id
= VLAN_ID_WILDCARD
;
70 vlan_id
= strtol(buf
, &pos
, 10);
71 if (buf
== pos
|| vlan_id
< 1 ||
72 vlan_id
> MAX_VLAN_ID
) {
73 wpa_printf(MSG_ERROR
, "Invalid VLAN ID at "
74 "line %d in '%s'", line
, fname
);
80 while (*pos
== ' ' || *pos
== '\t')
83 while (*pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '\0')
86 if (*pos
== '\0' || os_strlen(pos
) > IFNAMSIZ
) {
87 wpa_printf(MSG_ERROR
, "Invalid VLAN ifname at line %d "
88 "in '%s'", line
, fname
);
93 vlan
= os_zalloc(sizeof(*vlan
));
95 wpa_printf(MSG_ERROR
, "Out of memory while reading "
96 "VLAN interfaces from '%s'", fname
);
101 vlan
->vlan_id
= vlan_id
;
102 vlan
->vlan_desc
.untagged
= vlan_id
;
103 vlan
->vlan_desc
.notempty
= !!vlan_id
;
104 os_strlcpy(vlan
->ifname
, pos
, sizeof(vlan
->ifname
));
105 vlan
->next
= bss
->vlan
;
113 #endif /* CONFIG_NO_VLAN */
116 int hostapd_acl_comp(const void *a
, const void *b
)
118 const struct mac_acl_entry
*aa
= a
;
119 const struct mac_acl_entry
*bb
= b
;
120 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
124 int hostapd_add_acl_maclist(struct mac_acl_entry
**acl
, int *num
,
125 int vlan_id
, const u8
*addr
)
127 struct mac_acl_entry
*newacl
;
129 newacl
= os_realloc_array(*acl
, *num
+ 1, sizeof(**acl
));
131 wpa_printf(MSG_ERROR
, "MAC list reallocation failed");
136 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
137 os_memset(&(*acl
)[*num
].vlan_id
, 0, sizeof((*acl
)[*num
].vlan_id
));
138 (*acl
)[*num
].vlan_id
.untagged
= vlan_id
;
139 (*acl
)[*num
].vlan_id
.notempty
= !!vlan_id
;
146 void hostapd_remove_acl_mac(struct mac_acl_entry
**acl
, int *num
,
152 if (os_memcmp((*acl
)[i
].addr
, addr
, ETH_ALEN
) == 0) {
153 os_remove_in_array(*acl
, *num
, sizeof(**acl
), i
);
162 static int hostapd_config_read_maclist(const char *fname
,
163 struct mac_acl_entry
**acl
, int *num
)
171 f
= fopen(fname
, "r");
173 wpa_printf(MSG_ERROR
, "MAC list file '%s' not found.", fname
);
177 while (fgets(buf
, sizeof(buf
), f
)) {
185 while (*pos
!= '\0') {
200 if (hwaddr_aton(pos
, addr
)) {
201 wpa_printf(MSG_ERROR
, "Invalid MAC address '%s' at "
202 "line %d in '%s'", pos
, line
, fname
);
208 hostapd_remove_acl_mac(acl
, num
, addr
);
213 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
215 while (*pos
== ' ' || *pos
== '\t')
220 if (hostapd_add_acl_maclist(acl
, num
, vlan_id
, addr
) < 0) {
229 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
236 static int hostapd_config_read_eap_user(const char *fname
,
237 struct hostapd_bss_config
*conf
)
240 char buf
[512], *pos
, *start
, *pos2
;
241 int line
= 0, ret
= 0, num_methods
;
242 struct hostapd_eap_user
*user
= NULL
, *tail
= NULL
, *new_user
= NULL
;
244 if (os_strncmp(fname
, "sqlite:", 7) == 0) {
246 os_free(conf
->eap_user_sqlite
);
247 conf
->eap_user_sqlite
= os_strdup(fname
+ 7);
249 #else /* CONFIG_SQLITE */
250 wpa_printf(MSG_ERROR
,
251 "EAP user file in SQLite DB, but CONFIG_SQLITE was not enabled in the build.");
253 #endif /* CONFIG_SQLITE */
256 f
= fopen(fname
, "r");
258 wpa_printf(MSG_ERROR
, "EAP user file '%s' not found.", fname
);
262 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
263 while (fgets(buf
, sizeof(buf
), f
)) {
269 while (*pos
!= '\0') {
279 #ifndef CONFIG_NO_RADIUS
280 if (user
&& os_strncmp(buf
, "radius_accept_attr=", 19) == 0) {
281 struct hostapd_radius_attr
*attr
, *a
;
282 attr
= hostapd_parse_radius_attr(buf
+ 19);
284 wpa_printf(MSG_ERROR
, "Invalid radius_auth_req_attr: %s",
286 user
= NULL
; /* already in the BSS list */
289 if (user
->accept_attr
== NULL
) {
290 user
->accept_attr
= attr
;
292 a
= user
->accept_attr
;
299 #endif /* CONFIG_NO_RADIUS */
303 if (buf
[0] != '"' && buf
[0] != '*') {
304 wpa_printf(MSG_ERROR
, "Invalid EAP identity (no \" in "
305 "start) on line %d in '%s'", line
, fname
);
309 user
= os_zalloc(sizeof(*user
));
311 wpa_printf(MSG_ERROR
, "EAP user allocation failed");
314 user
->force_version
= -1;
321 while (*pos
!= '"' && *pos
!= '\0')
324 wpa_printf(MSG_ERROR
, "Invalid EAP identity "
325 "(no \" in end) on line %d in '%s'",
330 user
->identity
= os_memdup(start
, pos
- start
);
331 if (user
->identity
== NULL
) {
332 wpa_printf(MSG_ERROR
, "Failed to allocate "
333 "memory for EAP identity");
336 user
->identity_len
= pos
- start
;
338 if (pos
[0] == '"' && pos
[1] == '*') {
339 user
->wildcard_prefix
= 1;
344 while (*pos
== ' ' || *pos
== '\t')
348 wpa_printf(MSG_ERROR
, "No EAP method on line %d in "
349 "'%s'", line
, fname
);
354 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
364 char *pos3
= os_strchr(start
, ',');
368 user
->methods
[num_methods
].method
=
371 &user
->methods
[num_methods
].vendor
);
372 if (user
->methods
[num_methods
].vendor
==
374 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
376 if (os_strcmp(start
, "TTLS-PAP") == 0) {
377 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
380 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
381 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
384 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
386 EAP_TTLS_AUTH_MSCHAP
;
389 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
391 EAP_TTLS_AUTH_MSCHAPV2
;
394 if (os_strcmp(start
, "MACACL") == 0) {
398 wpa_printf(MSG_ERROR
, "Unsupported EAP type "
399 "'%s' on line %d in '%s'",
405 if (num_methods
>= EAP_MAX_METHODS
)
412 if (num_methods
== 0 && user
->ttls_auth
== 0 && !user
->macacl
) {
413 wpa_printf(MSG_ERROR
, "No EAP types configured on "
414 "line %d in '%s'", line
, fname
);
421 while (*pos
== ' ' || *pos
== '\t')
426 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
427 user
->force_version
= 0;
431 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
432 user
->force_version
= 1;
436 if (os_strncmp(pos
, "[2]", 3) == 0) {
444 while (*pos
!= '"' && *pos
!= '\0')
447 wpa_printf(MSG_ERROR
, "Invalid EAP password "
448 "(no \" in end) on line %d in '%s'",
453 user
->password
= os_memdup(start
, pos
- start
);
454 if (user
->password
== NULL
) {
455 wpa_printf(MSG_ERROR
, "Failed to allocate "
456 "memory for EAP password");
459 user
->password_len
= pos
- start
;
462 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
465 while (*pos2
!= '\0' && *pos2
!= ' ' &&
466 *pos2
!= '\t' && *pos2
!= '#')
468 if (pos2
- pos
!= 32) {
469 wpa_printf(MSG_ERROR
, "Invalid password hash "
470 "on line %d in '%s'", line
, fname
);
473 user
->password
= os_malloc(16);
474 if (user
->password
== NULL
) {
475 wpa_printf(MSG_ERROR
, "Failed to allocate "
476 "memory for EAP password hash");
479 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
480 wpa_printf(MSG_ERROR
, "Invalid hash password "
481 "on line %d in '%s'", line
, fname
);
484 user
->password_len
= 16;
485 user
->password_hash
= 1;
489 while (*pos2
!= '\0' && *pos2
!= ' ' &&
490 *pos2
!= '\t' && *pos2
!= '#')
492 if ((pos2
- pos
) & 1) {
493 wpa_printf(MSG_ERROR
, "Invalid hex password "
494 "on line %d in '%s'", line
, fname
);
497 user
->password
= os_malloc((pos2
- pos
) / 2);
498 if (user
->password
== NULL
) {
499 wpa_printf(MSG_ERROR
, "Failed to allocate "
500 "memory for EAP password");
503 if (hexstr2bin(pos
, user
->password
,
504 (pos2
- pos
) / 2) < 0) {
505 wpa_printf(MSG_ERROR
, "Invalid hex password "
506 "on line %d in '%s'", line
, fname
);
509 user
->password_len
= (pos2
- pos
) / 2;
513 while (*pos
== ' ' || *pos
== '\t')
515 if (os_strncmp(pos
, "[2]", 3) == 0) {
521 tail
= new_user
= user
;
530 hostapd_config_free_eap_user(user
);
538 hostapd_config_free_eap_users(conf
->eap_user
);
539 conf
->eap_user
= new_user
;
541 hostapd_config_free_eap_users(new_user
);
546 #endif /* EAP_SERVER */
549 #ifndef CONFIG_NO_RADIUS
551 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
552 int *num_server
, const char *val
, int def_port
,
553 struct hostapd_radius_server
**curr_serv
)
555 struct hostapd_radius_server
*nserv
;
557 static int server_index
= 1;
559 nserv
= os_realloc_array(*server
, *num_server
+ 1, sizeof(*nserv
));
564 nserv
= &nserv
[*num_server
];
566 (*curr_serv
) = nserv
;
568 os_memset(nserv
, 0, sizeof(*nserv
));
569 nserv
->port
= def_port
;
570 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
571 nserv
->index
= server_index
++;
577 static struct hostapd_radius_attr
*
578 hostapd_parse_radius_attr(const char *value
)
582 struct hostapd_radius_attr
*attr
;
585 attr
= os_zalloc(sizeof(*attr
));
589 attr
->type
= atoi(value
);
591 pos
= os_strchr(value
, ':');
593 attr
->val
= wpabuf_alloc(1);
594 if (attr
->val
== NULL
) {
598 wpabuf_put_u8(attr
->val
, 0);
603 if (pos
[0] == '\0' || pos
[1] != ':') {
612 attr
->val
= wpabuf_alloc_copy(pos
, os_strlen(pos
));
615 len
= os_strlen(pos
);
619 attr
->val
= wpabuf_alloc(len
);
620 if (attr
->val
== NULL
)
622 if (hexstr2bin(pos
, wpabuf_put(attr
->val
, len
), len
) < 0) {
623 wpabuf_free(attr
->val
);
629 attr
->val
= wpabuf_alloc(4);
631 wpabuf_put_be32(attr
->val
, atoi(pos
));
638 if (attr
->val
== NULL
) {
647 static int hostapd_parse_das_client(struct hostapd_bss_config
*bss
, char *val
)
651 secret
= os_strchr(val
, ' ');
657 if (hostapd_parse_ip_addr(val
, &bss
->radius_das_client_addr
))
660 os_free(bss
->radius_das_shared_secret
);
661 bss
->radius_das_shared_secret
= (u8
*) os_strdup(secret
);
662 if (bss
->radius_das_shared_secret
== NULL
)
664 bss
->radius_das_shared_secret_len
= os_strlen(secret
);
668 #endif /* CONFIG_NO_RADIUS */
671 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
674 char *start
, *end
, *buf
;
676 buf
= os_strdup(value
);
681 while (*start
!= '\0') {
682 while (*start
== ' ' || *start
== '\t')
687 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
691 if (os_strcmp(start
, "WPA-PSK") == 0)
692 val
|= WPA_KEY_MGMT_PSK
;
693 else if (os_strcmp(start
, "WPA-EAP") == 0)
694 val
|= WPA_KEY_MGMT_IEEE8021X
;
695 #ifdef CONFIG_IEEE80211R_AP
696 else if (os_strcmp(start
, "FT-PSK") == 0)
697 val
|= WPA_KEY_MGMT_FT_PSK
;
698 else if (os_strcmp(start
, "FT-EAP") == 0)
699 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
700 #endif /* CONFIG_IEEE80211R_AP */
701 #ifdef CONFIG_IEEE80211W
702 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
703 val
|= WPA_KEY_MGMT_PSK_SHA256
;
704 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
705 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
706 #endif /* CONFIG_IEEE80211W */
708 else if (os_strcmp(start
, "SAE") == 0)
709 val
|= WPA_KEY_MGMT_SAE
;
710 else if (os_strcmp(start
, "FT-SAE") == 0)
711 val
|= WPA_KEY_MGMT_FT_SAE
;
712 #endif /* CONFIG_SAE */
714 else if (os_strcmp(start
, "WPA-EAP-SUITE-B") == 0)
715 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B
;
716 #endif /* CONFIG_SUITEB */
717 #ifdef CONFIG_SUITEB192
718 else if (os_strcmp(start
, "WPA-EAP-SUITE-B-192") == 0)
719 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192
;
720 #endif /* CONFIG_SUITEB192 */
722 else if (os_strcmp(start
, "FILS-SHA256") == 0)
723 val
|= WPA_KEY_MGMT_FILS_SHA256
;
724 else if (os_strcmp(start
, "FILS-SHA384") == 0)
725 val
|= WPA_KEY_MGMT_FILS_SHA384
;
726 #ifdef CONFIG_IEEE80211R_AP
727 else if (os_strcmp(start
, "FT-FILS-SHA256") == 0)
728 val
|= WPA_KEY_MGMT_FT_FILS_SHA256
;
729 else if (os_strcmp(start
, "FT-FILS-SHA384") == 0)
730 val
|= WPA_KEY_MGMT_FT_FILS_SHA384
;
731 #endif /* CONFIG_IEEE80211R_AP */
732 #endif /* CONFIG_FILS */
734 else if (os_strcmp(start
, "OWE") == 0)
735 val
|= WPA_KEY_MGMT_OWE
;
736 #endif /* CONFIG_OWE */
738 else if (os_strcmp(start
, "DPP") == 0)
739 val
|= WPA_KEY_MGMT_DPP
;
740 #endif /* CONFIG_DPP */
742 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
755 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
756 "configured.", line
);
764 static int hostapd_config_parse_cipher(int line
, const char *value
)
766 int val
= wpa_parse_cipher(value
);
768 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
773 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
781 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
784 size_t len
= os_strlen(val
);
786 if (keyidx
< 0 || keyidx
> 3)
792 bin_clear_free(wep
->key
[keyidx
], wep
->len
[keyidx
]);
793 wep
->key
[keyidx
] = NULL
;
794 wep
->len
[keyidx
] = 0;
795 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
804 if (wep
->key
[keyidx
] != NULL
)
808 if (len
< 2 || val
[len
- 1] != '"')
811 wep
->key
[keyidx
] = os_memdup(val
+ 1, len
);
812 if (wep
->key
[keyidx
] == NULL
)
814 wep
->len
[keyidx
] = len
;
819 wep
->key
[keyidx
] = os_malloc(len
);
820 if (wep
->key
[keyidx
] == NULL
)
822 wep
->len
[keyidx
] = len
;
823 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
833 static int hostapd_parse_chanlist(struct hostapd_config
*conf
, char *val
)
837 /* for backwards compatibility, translate ' ' in conf str to ',' */
840 pos
= os_strchr(pos
, ' ');
844 if (freq_range_list_parse(&conf
->acs_ch_list
, val
))
851 static int hostapd_parse_intlist(int **int_list
, char *val
)
862 while (*pos
!= '\0') {
868 list
= os_malloc(sizeof(int) * (count
+ 2));
873 while (*pos
!= '\0') {
874 end
= os_strchr(pos
, ' ');
878 list
[count
++] = atoi(pos
);
890 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
892 struct hostapd_bss_config
**all
, *bss
;
897 all
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
898 sizeof(struct hostapd_bss_config
*));
900 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
906 bss
= os_zalloc(sizeof(*bss
));
909 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
910 if (bss
->radius
== NULL
) {
911 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
912 "multi-BSS RADIUS data");
917 conf
->bss
[conf
->num_bss
++] = bss
;
918 conf
->last_bss
= bss
;
920 hostapd_config_defaults_bss(bss
);
921 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
922 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
928 /* convert floats with one decimal place to value*10 int, i.e.,
929 * "1.5" will return 15 */
930 static int hostapd_config_read_int10(const char *value
)
936 pos
= os_strchr(value
, '.');
940 if (*pos
>= '0' && *pos
<= '9')
948 static int valid_cw(int cw
)
950 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
951 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023 ||
952 cw
== 2047 || cw
== 4095 || cw
== 8191 || cw
== 16383 ||
958 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
959 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
960 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
961 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
964 static int hostapd_config_tx_queue(struct hostapd_config
*conf
,
965 const char *name
, const char *val
)
969 struct hostapd_tx_queue_params
*queue
;
971 /* skip 'tx_queue_' prefix */
973 if (os_strncmp(pos
, "data", 4) == 0 &&
974 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
977 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
978 os_strncmp(pos
, "beacon_", 7) == 0) {
979 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
982 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
986 if (num
>= NUM_TX_QUEUES
) {
987 /* for backwards compatibility, do not trigger failure */
988 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
992 queue
= &conf
->tx_queue
[num
];
994 if (os_strcmp(pos
, "aifs") == 0) {
995 queue
->aifs
= atoi(val
);
996 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
997 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
1001 } else if (os_strcmp(pos
, "cwmin") == 0) {
1002 queue
->cwmin
= atoi(val
);
1003 if (!valid_cw(queue
->cwmin
)) {
1004 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
1008 } else if (os_strcmp(pos
, "cwmax") == 0) {
1009 queue
->cwmax
= atoi(val
);
1010 if (!valid_cw(queue
->cwmax
)) {
1011 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
1015 } else if (os_strcmp(pos
, "burst") == 0) {
1016 queue
->burst
= hostapd_config_read_int10(val
);
1018 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
1026 #ifdef CONFIG_IEEE80211R_AP
1028 static int rkh_derive_key(const char *pos
, u8
*key
, size_t key_len
)
1033 if (!hexstr2bin(pos
, key
, key_len
))
1036 /* Try to use old short key for backwards compatibility */
1037 if (hexstr2bin(pos
, oldkey
, sizeof(oldkey
)))
1040 ret
= hmac_sha256_kdf(oldkey
, sizeof(oldkey
), "FT OLDKEY", NULL
, 0,
1042 os_memset(oldkey
, 0, sizeof(oldkey
));
1047 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
1049 struct ft_remote_r0kh
*r0kh
;
1052 r0kh
= os_zalloc(sizeof(*r0kh
));
1056 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1058 next
= os_strchr(pos
, ' ');
1061 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
1062 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
1068 next
= os_strchr(pos
, ' ');
1071 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
1072 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
1076 r0kh
->id_len
= next
- pos
- 1;
1077 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
1080 if (rkh_derive_key(pos
, r0kh
->key
, sizeof(r0kh
->key
)) < 0) {
1081 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
1086 r0kh
->next
= bss
->r0kh_list
;
1087 bss
->r0kh_list
= r0kh
;
1093 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
1095 struct ft_remote_r1kh
*r1kh
;
1098 r1kh
= os_zalloc(sizeof(*r1kh
));
1102 /* 02:01:02:03:04:05 02:01:02:03:04:05
1103 * 000102030405060708090a0b0c0d0e0f */
1105 next
= os_strchr(pos
, ' ');
1108 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
1109 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
1115 next
= os_strchr(pos
, ' ');
1118 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
1119 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
1125 if (rkh_derive_key(pos
, r1kh
->key
, sizeof(r1kh
->key
)) < 0) {
1126 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
1131 r1kh
->next
= bss
->r1kh_list
;
1132 bss
->r1kh_list
= r1kh
;
1136 #endif /* CONFIG_IEEE80211R_AP */
1139 #ifdef CONFIG_IEEE80211N
1140 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
1143 if (os_strstr(capab
, "[LDPC]"))
1144 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
1145 if (os_strstr(capab
, "[HT40-]")) {
1146 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1147 conf
->secondary_channel
= -1;
1149 if (os_strstr(capab
, "[HT40+]")) {
1150 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1151 conf
->secondary_channel
= 1;
1153 if (os_strstr(capab
, "[HT40+]") && os_strstr(capab
, "[HT40-]")) {
1154 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1155 conf
->ht40_plus_minus_allowed
= 1;
1157 if (os_strstr(capab
, "[SMPS-STATIC]")) {
1158 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1159 conf
->ht_capab
|= HT_CAP_INFO_SMPS_STATIC
;
1161 if (os_strstr(capab
, "[SMPS-DYNAMIC]")) {
1162 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1163 conf
->ht_capab
|= HT_CAP_INFO_SMPS_DYNAMIC
;
1165 if (os_strstr(capab
, "[GF]"))
1166 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
1167 if (os_strstr(capab
, "[SHORT-GI-20]"))
1168 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1169 if (os_strstr(capab
, "[SHORT-GI-40]"))
1170 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1171 if (os_strstr(capab
, "[TX-STBC]"))
1172 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1173 if (os_strstr(capab
, "[RX-STBC1]")) {
1174 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1175 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1177 if (os_strstr(capab
, "[RX-STBC12]")) {
1178 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1179 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1181 if (os_strstr(capab
, "[RX-STBC123]")) {
1182 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1183 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1185 if (os_strstr(capab
, "[DELAYED-BA]"))
1186 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1187 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1188 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1189 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1190 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1191 if (os_strstr(capab
, "[40-INTOLERANT]"))
1192 conf
->ht_capab
|= HT_CAP_INFO_40MHZ_INTOLERANT
;
1193 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1194 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1198 #endif /* CONFIG_IEEE80211N */
1201 #ifdef CONFIG_IEEE80211AC
1202 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1205 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1206 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1207 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1208 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1209 if (os_strstr(capab
, "[VHT160]"))
1210 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1211 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1212 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1213 if (os_strstr(capab
, "[RXLDPC]"))
1214 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1215 if (os_strstr(capab
, "[SHORT-GI-80]"))
1216 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1217 if (os_strstr(capab
, "[SHORT-GI-160]"))
1218 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1219 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1220 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1221 if (os_strstr(capab
, "[RX-STBC-1]"))
1222 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1223 if (os_strstr(capab
, "[RX-STBC-12]"))
1224 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1225 if (os_strstr(capab
, "[RX-STBC-123]"))
1226 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1227 if (os_strstr(capab
, "[RX-STBC-1234]"))
1228 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1229 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1230 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMER_CAPABLE
;
1231 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1232 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
1233 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1234 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1235 conf
->vht_capab
|= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1236 if (os_strstr(capab
, "[BF-ANTENNA-3]") &&
1237 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1238 conf
->vht_capab
|= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1239 if (os_strstr(capab
, "[BF-ANTENNA-4]") &&
1240 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1241 conf
->vht_capab
|= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1242 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1243 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1244 conf
->vht_capab
|= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1245 if (os_strstr(capab
, "[SOUNDING-DIMENSION-3]") &&
1246 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1247 conf
->vht_capab
|= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1248 if (os_strstr(capab
, "[SOUNDING-DIMENSION-4]") &&
1249 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1250 conf
->vht_capab
|= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1251 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1252 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1253 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1254 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1255 if (os_strstr(capab
, "[HTC-VHT]"))
1256 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1257 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP7]"))
1258 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX
;
1259 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP6]"))
1260 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6
;
1261 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP5]"))
1262 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5
;
1263 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP4]"))
1264 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4
;
1265 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP3]"))
1266 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3
;
1267 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP2]"))
1268 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2
;
1269 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP1]"))
1270 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1
;
1271 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1272 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1273 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1274 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1275 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1276 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1277 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1278 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1279 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1280 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1283 #endif /* CONFIG_IEEE80211AC */
1286 #ifdef CONFIG_INTERWORKING
1287 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1290 size_t len
= os_strlen(pos
);
1291 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1293 struct hostapd_roaming_consortium
*rc
;
1295 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1296 hexstr2bin(pos
, oi
, len
/ 2)) {
1297 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1303 rc
= os_realloc_array(bss
->roaming_consortium
,
1304 bss
->roaming_consortium_count
+ 1,
1305 sizeof(struct hostapd_roaming_consortium
));
1309 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1310 rc
[bss
->roaming_consortium_count
].len
= len
;
1312 bss
->roaming_consortium
= rc
;
1313 bss
->roaming_consortium_count
++;
1319 static int parse_lang_string(struct hostapd_lang_string
**array
,
1320 unsigned int *count
, char *pos
)
1322 char *sep
, *str
= NULL
;
1323 size_t clen
, nlen
, slen
;
1324 struct hostapd_lang_string
*ls
;
1327 if (*pos
== '"' || (*pos
== 'P' && pos
[1] == '"')) {
1328 str
= wpa_config_parse_string(pos
, &slen
);
1334 sep
= os_strchr(pos
, ':');
1339 clen
= os_strlen(pos
);
1340 if (clen
< 2 || clen
> sizeof(ls
->lang
))
1342 nlen
= os_strlen(sep
);
1346 ls
= os_realloc_array(*array
, *count
+ 1,
1347 sizeof(struct hostapd_lang_string
));
1352 ls
= &(*array
)[*count
];
1355 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1356 os_memcpy(ls
->lang
, pos
, clen
);
1357 ls
->name_len
= nlen
;
1358 os_memcpy(ls
->name
, sep
, nlen
);
1367 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1370 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1371 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1379 static int parse_venue_url(struct hostapd_bss_config
*bss
, char *pos
,
1384 struct hostapd_venue_url
*url
;
1387 sep
= os_strchr(pos
, ':');
1392 nlen
= os_strlen(sep
);
1396 url
= os_realloc_array(bss
->venue_url
, bss
->venue_url_count
+ 1,
1397 sizeof(struct hostapd_venue_url
));
1401 bss
->venue_url
= url
;
1402 url
= &bss
->venue_url
[bss
->venue_url_count
++];
1404 url
->venue_number
= atoi(pos
);
1405 url
->url_len
= nlen
;
1406 os_memcpy(url
->url
, sep
, nlen
);
1411 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_url '%s'",
1417 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1422 u8
*info
= NULL
, *ipos
;
1424 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1427 for (pos
= buf
; *pos
; pos
++) {
1428 if ((*pos
< '0' || *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1433 if (1 + count
* 3 > 0x7f)
1436 info
= os_zalloc(2 + 3 + count
* 3);
1441 *ipos
++ = 0; /* GUD - Version 1 */
1442 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1443 *ipos
++ = 0; /* PLMN List IEI */
1444 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1445 *ipos
++ = 1 + count
* 3;
1446 *ipos
++ = count
; /* Number of PLMNs */
1449 while (pos
&& *pos
) {
1454 mnc
= os_strchr(pos
, ',');
1458 pos
= os_strchr(mnc
, ';');
1462 mnc_len
= os_strlen(mnc
);
1463 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1466 /* BC coded MCC,MNC */
1467 /* MCC digit 2 | MCC digit 1 */
1468 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1469 /* MNC digit 3 | MCC digit 3 */
1470 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1472 /* MNC digit 2 | MNC digit 1 */
1473 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1476 os_free(bss
->anqp_3gpp_cell_net
);
1477 bss
->anqp_3gpp_cell_net
= info
;
1478 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1479 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1480 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1485 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1492 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1494 struct hostapd_nai_realm_data
*realm
;
1497 char *pos
, *end
, *rpos
;
1499 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1501 if (offsets
== NULL
)
1504 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1505 realm
= &bss
->nai_realm_data
[i
];
1506 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1507 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1509 realm
->realm
[j
] - realm
->realm_buf
: -1;
1513 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1514 sizeof(struct hostapd_nai_realm_data
));
1515 if (realm
== NULL
) {
1519 bss
->nai_realm_data
= realm
;
1521 /* patch the pointers after realloc */
1522 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1523 realm
= &bss
->nai_realm_data
[i
];
1524 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1525 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1527 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1529 realm
->realm
[j
] = NULL
;
1534 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1535 os_memset(realm
, 0, sizeof(*realm
));
1538 realm
->encoding
= atoi(pos
);
1539 pos
= os_strchr(pos
, ',');
1544 end
= os_strchr(pos
, ',');
1549 len
= os_strlen(pos
);
1552 if (len
> MAX_NAI_REALMLEN
) {
1553 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1554 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1557 os_memcpy(realm
->realm_buf
, pos
, len
);
1564 while (pos
&& *pos
) {
1565 struct hostapd_nai_realm_eap
*eap
;
1567 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1568 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1572 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1573 realm
->eap_method_count
++;
1575 end
= os_strchr(pos
, ',');
1577 end
= pos
+ os_strlen(pos
);
1579 eap
->eap_method
= atoi(pos
);
1581 pos
= os_strchr(pos
, '[');
1582 if (pos
== NULL
|| pos
> end
)
1585 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1586 wpa_printf(MSG_ERROR
, "Too many auth params");
1589 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1590 pos
= os_strchr(pos
, ':');
1591 if (pos
== NULL
|| pos
> end
)
1594 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1595 pos
= os_strchr(pos
, ']');
1596 if (pos
== NULL
|| pos
> end
)
1608 /* Split realm list into null terminated realms */
1609 rpos
= realm
->realm_buf
;
1612 if (i
>= MAX_NAI_REALMS
) {
1613 wpa_printf(MSG_ERROR
, "Too many realms");
1616 realm
->realm
[i
++] = rpos
;
1617 rpos
= os_strchr(rpos
, ';');
1623 bss
->nai_realm_count
++;
1628 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1633 static int parse_anqp_elem(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1638 struct wpabuf
*payload
;
1639 struct anqp_element
*elem
;
1641 delim
= os_strchr(buf
, ':');
1646 len
= os_strlen(delim
);
1650 payload
= wpabuf_alloc(len
);
1653 if (hexstr2bin(delim
, wpabuf_put(payload
, len
), len
) < 0) {
1654 wpabuf_free(payload
);
1658 dl_list_for_each(elem
, &bss
->anqp_elem
, struct anqp_element
, list
) {
1659 if (elem
->infoid
== infoid
) {
1660 /* Update existing entry */
1661 wpabuf_free(elem
->payload
);
1662 elem
->payload
= payload
;
1667 /* Add a new entry */
1668 elem
= os_zalloc(sizeof(*elem
));
1670 wpabuf_free(payload
);
1673 elem
->infoid
= infoid
;
1674 elem
->payload
= payload
;
1675 dl_list_add(&bss
->anqp_elem
, &elem
->list
);
1681 static int parse_qos_map_set(struct hostapd_bss_config
*bss
,
1682 char *buf
, int line
)
1684 u8 qos_map_set
[16 + 2 * 21], count
= 0;
1689 if (count
== sizeof(qos_map_set
)) {
1690 wpa_printf(MSG_ERROR
, "Line %d: Too many qos_map_set "
1691 "parameters '%s'", line
, buf
);
1696 if (val
> 255 || val
< 0) {
1697 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set "
1702 qos_map_set
[count
++] = val
;
1703 pos
= os_strchr(pos
, ',');
1709 if (count
< 16 || count
& 1) {
1710 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set '%s'",
1715 os_memcpy(bss
->qos_map_set
, qos_map_set
, count
);
1716 bss
->qos_map_set_len
= count
;
1721 #endif /* CONFIG_INTERWORKING */
1725 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1731 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1734 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1735 bss
->hs20_connection_capability_len
+ 4);
1736 if (conn_cap
== NULL
)
1739 bss
->hs20_connection_capability
= conn_cap
;
1740 conn_cap
+= bss
->hs20_connection_capability_len
;
1742 conn_cap
[0] = atoi(pos
);
1743 pos
= os_strchr(pos
, ':');
1747 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1748 pos
= os_strchr(pos
, ':');
1752 conn_cap
[3] = atoi(pos
);
1753 bss
->hs20_connection_capability_len
+= 4;
1759 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1765 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1767 wan_metrics
= os_zalloc(13);
1768 if (wan_metrics
== NULL
)
1773 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1780 /* Downlink Speed */
1781 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1782 pos
= os_strchr(pos
, ':');
1788 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1789 pos
= os_strchr(pos
, ':');
1795 wan_metrics
[9] = atoi(pos
);
1796 pos
= os_strchr(pos
, ':');
1802 wan_metrics
[10] = atoi(pos
);
1803 pos
= os_strchr(pos
, ':');
1809 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1811 os_free(bss
->hs20_wan_metrics
);
1812 bss
->hs20_wan_metrics
= wan_metrics
;
1817 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1819 os_free(wan_metrics
);
1824 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1825 char *pos
, int line
)
1827 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1828 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1829 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1830 "hs20_oper_friendly_name '%s'", line
, pos
);
1837 static int hs20_parse_icon(struct hostapd_bss_config
*bss
, char *pos
)
1839 struct hs20_icon
*icon
;
1842 icon
= os_realloc_array(bss
->hs20_icons
, bss
->hs20_icons_count
+ 1,
1843 sizeof(struct hs20_icon
));
1846 bss
->hs20_icons
= icon
;
1847 icon
= &bss
->hs20_icons
[bss
->hs20_icons_count
];
1848 os_memset(icon
, 0, sizeof(*icon
));
1850 icon
->width
= atoi(pos
);
1851 pos
= os_strchr(pos
, ':');
1856 icon
->height
= atoi(pos
);
1857 pos
= os_strchr(pos
, ':');
1862 end
= os_strchr(pos
, ':');
1863 if (end
== NULL
|| end
- pos
> 3)
1865 os_memcpy(icon
->language
, pos
, end
- pos
);
1868 end
= os_strchr(pos
, ':');
1869 if (end
== NULL
|| end
- pos
> 255)
1871 os_memcpy(icon
->type
, pos
, end
- pos
);
1874 end
= os_strchr(pos
, ':');
1875 if (end
== NULL
|| end
- pos
> 255)
1877 os_memcpy(icon
->name
, pos
, end
- pos
);
1880 if (os_strlen(pos
) > 255)
1882 os_memcpy(icon
->file
, pos
, os_strlen(pos
));
1884 bss
->hs20_icons_count
++;
1890 static int hs20_parse_osu_ssid(struct hostapd_bss_config
*bss
,
1891 char *pos
, int line
)
1896 str
= wpa_config_parse_string(pos
, &slen
);
1897 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
1898 wpa_printf(MSG_ERROR
, "Line %d: Invalid SSID '%s'", line
, pos
);
1903 os_memcpy(bss
->osu_ssid
, str
, slen
);
1904 bss
->osu_ssid_len
= slen
;
1911 static int hs20_parse_osu_server_uri(struct hostapd_bss_config
*bss
,
1912 char *pos
, int line
)
1914 struct hs20_osu_provider
*p
;
1916 p
= os_realloc_array(bss
->hs20_osu_providers
,
1917 bss
->hs20_osu_providers_count
+ 1, sizeof(*p
));
1921 bss
->hs20_osu_providers
= p
;
1922 bss
->last_osu
= &bss
->hs20_osu_providers
[bss
->hs20_osu_providers_count
];
1923 bss
->hs20_osu_providers_count
++;
1924 os_memset(bss
->last_osu
, 0, sizeof(*p
));
1925 bss
->last_osu
->server_uri
= os_strdup(pos
);
1931 static int hs20_parse_osu_friendly_name(struct hostapd_bss_config
*bss
,
1932 char *pos
, int line
)
1934 if (bss
->last_osu
== NULL
) {
1935 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1939 if (parse_lang_string(&bss
->last_osu
->friendly_name
,
1940 &bss
->last_osu
->friendly_name_count
, pos
)) {
1941 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_friendly_name '%s'",
1950 static int hs20_parse_osu_nai(struct hostapd_bss_config
*bss
,
1951 char *pos
, int line
)
1953 if (bss
->last_osu
== NULL
) {
1954 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1958 os_free(bss
->last_osu
->osu_nai
);
1959 bss
->last_osu
->osu_nai
= os_strdup(pos
);
1960 if (bss
->last_osu
->osu_nai
== NULL
)
1967 static int hs20_parse_osu_method_list(struct hostapd_bss_config
*bss
, char *pos
,
1970 if (bss
->last_osu
== NULL
) {
1971 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1975 if (hostapd_parse_intlist(&bss
->last_osu
->method_list
, pos
)) {
1976 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_method_list", line
);
1984 static int hs20_parse_osu_icon(struct hostapd_bss_config
*bss
, char *pos
,
1988 struct hs20_osu_provider
*p
= bss
->last_osu
;
1991 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1995 n
= os_realloc_array(p
->icons
, p
->icons_count
+ 1, sizeof(char *));
1999 p
->icons
[p
->icons_count
] = os_strdup(pos
);
2000 if (p
->icons
[p
->icons_count
] == NULL
)
2008 static int hs20_parse_osu_service_desc(struct hostapd_bss_config
*bss
,
2009 char *pos
, int line
)
2011 if (bss
->last_osu
== NULL
) {
2012 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
2016 if (parse_lang_string(&bss
->last_osu
->service_desc
,
2017 &bss
->last_osu
->service_desc_count
, pos
)) {
2018 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_service_desc '%s'",
2027 static int hs20_parse_operator_icon(struct hostapd_bss_config
*bss
, char *pos
,
2032 n
= os_realloc_array(bss
->hs20_operator_icon
,
2033 bss
->hs20_operator_icon_count
+ 1, sizeof(char *));
2036 bss
->hs20_operator_icon
= n
;
2037 bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
] = os_strdup(pos
);
2038 if (!bss
->hs20_operator_icon
[bss
->hs20_operator_icon_count
])
2040 bss
->hs20_operator_icon_count
++;
2045 #endif /* CONFIG_HS20 */
2049 static int hostapd_config_parse_acs_chan_bias(struct hostapd_config
*conf
,
2052 struct acs_bias
*bias
= NULL
, *tmp
;
2053 unsigned int num
= 0;
2057 tmp
= os_realloc_array(bias
, num
+ 1, sizeof(*bias
));
2062 bias
[num
].channel
= atoi(pos
);
2063 if (bias
[num
].channel
<= 0)
2065 pos
= os_strchr(pos
, ':');
2069 bias
[num
].bias
= strtod(pos
, &end
);
2070 if (end
== pos
|| bias
[num
].bias
< 0.0)
2073 if (*pos
!= ' ' && *pos
!= '\0')
2078 os_free(conf
->acs_chan_bias
);
2079 conf
->acs_chan_bias
= bias
;
2080 conf
->num_acs_chan_bias
= num
;
2087 #endif /* CONFIG_ACS */
2090 static int parse_wpabuf_hex(int line
, const char *name
, struct wpabuf
**buf
,
2093 struct wpabuf
*elems
;
2095 if (val
[0] == '\0') {
2101 elems
= wpabuf_parse_bin(val
);
2103 wpa_printf(MSG_ERROR
, "Line %d: Invalid %s '%s'",
2116 static int parse_fils_realm(struct hostapd_bss_config
*bss
, const char *val
)
2118 struct fils_realm
*realm
;
2121 len
= os_strlen(val
);
2122 realm
= os_zalloc(sizeof(*realm
) + len
+ 1);
2126 os_memcpy(realm
->realm
, val
, len
);
2127 if (fils_domain_name_hash(val
, realm
->hash
) < 0) {
2131 dl_list_add_tail(&bss
->fils_realms
, &realm
->list
);
2135 #endif /* CONFIG_FILS */
2139 static unsigned int parse_tls_flags(const char *val
)
2141 unsigned int flags
= 0;
2143 /* Disable TLS v1.3 by default for now to avoid interoperability issue.
2144 * This can be enabled by default once the implementation has been fully
2145 * completed and tested with other implementations. */
2146 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2148 if (os_strstr(val
, "[ALLOW-SIGN-RSA-MD5]"))
2149 flags
|= TLS_CONN_ALLOW_SIGN_RSA_MD5
;
2150 if (os_strstr(val
, "[DISABLE-TIME-CHECKS]"))
2151 flags
|= TLS_CONN_DISABLE_TIME_CHECKS
;
2152 if (os_strstr(val
, "[DISABLE-TLSv1.0]"))
2153 flags
|= TLS_CONN_DISABLE_TLSv1_0
;
2154 if (os_strstr(val
, "[DISABLE-TLSv1.1]"))
2155 flags
|= TLS_CONN_DISABLE_TLSv1_1
;
2156 if (os_strstr(val
, "[DISABLE-TLSv1.2]"))
2157 flags
|= TLS_CONN_DISABLE_TLSv1_2
;
2158 if (os_strstr(val
, "[DISABLE-TLSv1.3]"))
2159 flags
|= TLS_CONN_DISABLE_TLSv1_3
;
2160 if (os_strstr(val
, "[ENABLE-TLSv1.3]"))
2161 flags
&= ~TLS_CONN_DISABLE_TLSv1_3
;
2162 if (os_strstr(val
, "[SUITEB]"))
2163 flags
|= TLS_CONN_SUITEB
;
2164 if (os_strstr(val
, "[SUITEB-NO-ECDH]"))
2165 flags
|= TLS_CONN_SUITEB_NO_ECDH
| TLS_CONN_SUITEB
;
2169 #endif /* EAP_SERVER */
2173 static int parse_sae_password(struct hostapd_bss_config
*bss
, const char *val
)
2175 struct sae_password_entry
*pw
;
2176 const char *pos
= val
, *pos2
, *end
= NULL
;
2178 pw
= os_zalloc(sizeof(*pw
));
2181 os_memset(pw
->peer_addr
, 0xff, ETH_ALEN
); /* default to wildcard */
2183 pos2
= os_strstr(pos
, "|mac=");
2187 if (hwaddr_aton(pos2
, pw
->peer_addr
) < 0)
2189 pos
= pos2
+ ETH_ALEN
* 3 - 1;
2192 pos2
= os_strstr(pos
, "|id=");
2197 pw
->identifier
= os_strdup(pos2
);
2198 if (!pw
->identifier
)
2203 pw
->password
= os_strdup(val
);
2207 pw
->password
= os_malloc(end
- val
+ 1);
2210 os_memcpy(pw
->password
, val
, end
- val
);
2211 pw
->password
[end
- val
] = '\0';
2214 pw
->next
= bss
->sae_passwords
;
2215 bss
->sae_passwords
= pw
;
2219 str_clear_free(pw
->password
);
2220 os_free(pw
->identifier
);
2224 #endif /* CONFIG_SAE */
2227 static int hostapd_config_fill(struct hostapd_config
*conf
,
2228 struct hostapd_bss_config
*bss
,
2229 const char *buf
, char *pos
, int line
)
2231 if (os_strcmp(buf
, "interface") == 0) {
2232 os_strlcpy(conf
->bss
[0]->iface
, pos
,
2233 sizeof(conf
->bss
[0]->iface
));
2234 } else if (os_strcmp(buf
, "bridge") == 0) {
2235 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
2236 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
2237 os_strlcpy(bss
->vlan_bridge
, pos
, sizeof(bss
->vlan_bridge
));
2238 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
2239 os_strlcpy(bss
->wds_bridge
, pos
, sizeof(bss
->wds_bridge
));
2240 } else if (os_strcmp(buf
, "driver") == 0) {
2242 const struct wpa_driver_ops
*driver
= NULL
;
2244 for (j
= 0; wpa_drivers
[j
]; j
++) {
2245 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0) {
2246 driver
= wpa_drivers
[j
];
2251 wpa_printf(MSG_ERROR
,
2252 "Line %d: invalid/unknown driver '%s'",
2256 conf
->driver
= driver
;
2257 } else if (os_strcmp(buf
, "driver_params") == 0) {
2258 os_free(conf
->driver_params
);
2259 conf
->driver_params
= os_strdup(pos
);
2260 } else if (os_strcmp(buf
, "debug") == 0) {
2261 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore",
2263 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
2264 bss
->logger_syslog_level
= atoi(pos
);
2265 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
2266 bss
->logger_stdout_level
= atoi(pos
);
2267 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
2268 bss
->logger_syslog
= atoi(pos
);
2269 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
2270 bss
->logger_stdout
= atoi(pos
);
2271 } else if (os_strcmp(buf
, "dump_file") == 0) {
2272 wpa_printf(MSG_INFO
, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
2274 } else if (os_strcmp(buf
, "ssid") == 0) {
2275 bss
->ssid
.ssid_len
= os_strlen(pos
);
2276 if (bss
->ssid
.ssid_len
> SSID_MAX_LEN
||
2277 bss
->ssid
.ssid_len
< 1) {
2278 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2282 os_memcpy(bss
->ssid
.ssid
, pos
, bss
->ssid
.ssid_len
);
2283 bss
->ssid
.ssid_set
= 1;
2284 } else if (os_strcmp(buf
, "ssid2") == 0) {
2286 char *str
= wpa_config_parse_string(pos
, &slen
);
2287 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
2288 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2293 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
2294 bss
->ssid
.ssid_len
= slen
;
2295 bss
->ssid
.ssid_set
= 1;
2297 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
2298 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
2299 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
2300 enum macaddr_acl acl
= atoi(pos
);
2302 if (acl
!= ACCEPT_UNLESS_DENIED
&&
2303 acl
!= DENY_UNLESS_ACCEPTED
&&
2304 acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
2305 wpa_printf(MSG_ERROR
, "Line %d: unknown macaddr_acl %d",
2309 bss
->macaddr_acl
= acl
;
2310 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
2311 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
2312 &bss
->num_accept_mac
)) {
2313 wpa_printf(MSG_ERROR
, "Line %d: Failed to read accept_mac_file '%s'",
2317 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
2318 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
2319 &bss
->num_deny_mac
)) {
2320 wpa_printf(MSG_ERROR
, "Line %d: Failed to read deny_mac_file '%s'",
2324 } else if (os_strcmp(buf
, "wds_sta") == 0) {
2325 bss
->wds_sta
= atoi(pos
);
2326 } else if (os_strcmp(buf
, "start_disabled") == 0) {
2327 bss
->start_disabled
= atoi(pos
);
2328 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
2329 bss
->isolate
= atoi(pos
);
2330 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
2331 bss
->ap_max_inactivity
= atoi(pos
);
2332 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
2333 bss
->skip_inactivity_poll
= atoi(pos
);
2334 } else if (os_strcmp(buf
, "country_code") == 0) {
2335 os_memcpy(conf
->country
, pos
, 2);
2336 } else if (os_strcmp(buf
, "country3") == 0) {
2337 conf
->country
[2] = strtol(pos
, NULL
, 16);
2338 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
2339 conf
->ieee80211d
= atoi(pos
);
2340 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
2341 conf
->ieee80211h
= atoi(pos
);
2342 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
2343 bss
->ieee802_1x
= atoi(pos
);
2344 } else if (os_strcmp(buf
, "eapol_version") == 0) {
2345 int eapol_version
= atoi(pos
);
2347 if (eapol_version
< 1 || eapol_version
> 2) {
2348 wpa_printf(MSG_ERROR
,
2349 "Line %d: invalid EAPOL version (%d): '%s'.",
2350 line
, eapol_version
, pos
);
2353 bss
->eapol_version
= eapol_version
;
2354 wpa_printf(MSG_DEBUG
, "eapol_version=%d", bss
->eapol_version
);
2356 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
2357 bss
->eap_server
= atoi(pos
);
2358 wpa_printf(MSG_ERROR
, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line
);
2359 } else if (os_strcmp(buf
, "eap_server") == 0) {
2360 bss
->eap_server
= atoi(pos
);
2361 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
2362 if (hostapd_config_read_eap_user(pos
, bss
))
2364 } else if (os_strcmp(buf
, "ca_cert") == 0) {
2365 os_free(bss
->ca_cert
);
2366 bss
->ca_cert
= os_strdup(pos
);
2367 } else if (os_strcmp(buf
, "server_cert") == 0) {
2368 os_free(bss
->server_cert
);
2369 bss
->server_cert
= os_strdup(pos
);
2370 } else if (os_strcmp(buf
, "private_key") == 0) {
2371 os_free(bss
->private_key
);
2372 bss
->private_key
= os_strdup(pos
);
2373 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
2374 os_free(bss
->private_key_passwd
);
2375 bss
->private_key_passwd
= os_strdup(pos
);
2376 } else if (os_strcmp(buf
, "check_crl") == 0) {
2377 bss
->check_crl
= atoi(pos
);
2378 } else if (os_strcmp(buf
, "tls_session_lifetime") == 0) {
2379 bss
->tls_session_lifetime
= atoi(pos
);
2380 } else if (os_strcmp(buf
, "tls_flags") == 0) {
2381 bss
->tls_flags
= parse_tls_flags(pos
);
2382 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
2383 os_free(bss
->ocsp_stapling_response
);
2384 bss
->ocsp_stapling_response
= os_strdup(pos
);
2385 } else if (os_strcmp(buf
, "ocsp_stapling_response_multi") == 0) {
2386 os_free(bss
->ocsp_stapling_response_multi
);
2387 bss
->ocsp_stapling_response_multi
= os_strdup(pos
);
2388 } else if (os_strcmp(buf
, "dh_file") == 0) {
2389 os_free(bss
->dh_file
);
2390 bss
->dh_file
= os_strdup(pos
);
2391 } else if (os_strcmp(buf
, "openssl_ciphers") == 0) {
2392 os_free(bss
->openssl_ciphers
);
2393 bss
->openssl_ciphers
= os_strdup(pos
);
2394 } else if (os_strcmp(buf
, "fragment_size") == 0) {
2395 bss
->fragment_size
= atoi(pos
);
2396 #ifdef EAP_SERVER_FAST
2397 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
2398 os_free(bss
->pac_opaque_encr_key
);
2399 bss
->pac_opaque_encr_key
= os_malloc(16);
2400 if (bss
->pac_opaque_encr_key
== NULL
) {
2401 wpa_printf(MSG_ERROR
,
2402 "Line %d: No memory for pac_opaque_encr_key",
2405 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
, 16)) {
2406 wpa_printf(MSG_ERROR
, "Line %d: Invalid pac_opaque_encr_key",
2410 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
2411 size_t idlen
= os_strlen(pos
);
2413 wpa_printf(MSG_ERROR
, "Line %d: Invalid eap_fast_a_id",
2417 os_free(bss
->eap_fast_a_id
);
2418 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
2419 if (bss
->eap_fast_a_id
== NULL
||
2420 hexstr2bin(pos
, bss
->eap_fast_a_id
, idlen
/ 2)) {
2421 wpa_printf(MSG_ERROR
, "Line %d: Failed to parse eap_fast_a_id",
2423 os_free(bss
->eap_fast_a_id
);
2424 bss
->eap_fast_a_id
= NULL
;
2427 bss
->eap_fast_a_id_len
= idlen
/ 2;
2429 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
2430 os_free(bss
->eap_fast_a_id_info
);
2431 bss
->eap_fast_a_id_info
= os_strdup(pos
);
2432 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
2433 bss
->eap_fast_prov
= atoi(pos
);
2434 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
2435 bss
->pac_key_lifetime
= atoi(pos
);
2436 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
2437 bss
->pac_key_refresh_time
= atoi(pos
);
2438 #endif /* EAP_SERVER_FAST */
2439 #ifdef EAP_SERVER_SIM
2440 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
2441 os_free(bss
->eap_sim_db
);
2442 bss
->eap_sim_db
= os_strdup(pos
);
2443 } else if (os_strcmp(buf
, "eap_sim_db_timeout") == 0) {
2444 bss
->eap_sim_db_timeout
= atoi(pos
);
2445 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
2446 bss
->eap_sim_aka_result_ind
= atoi(pos
);
2447 #endif /* EAP_SERVER_SIM */
2448 #ifdef EAP_SERVER_TNC
2449 } else if (os_strcmp(buf
, "tnc") == 0) {
2450 bss
->tnc
= atoi(pos
);
2451 #endif /* EAP_SERVER_TNC */
2452 #ifdef EAP_SERVER_PWD
2453 } else if (os_strcmp(buf
, "pwd_group") == 0) {
2454 bss
->pwd_group
= atoi(pos
);
2455 #endif /* EAP_SERVER_PWD */
2457 } else if (os_strcmp(buf
, "eap_server_erp") == 0) {
2458 bss
->eap_server_erp
= atoi(pos
);
2459 #endif /* CONFIG_ERP */
2460 #endif /* EAP_SERVER */
2461 } else if (os_strcmp(buf
, "eap_message") == 0) {
2463 os_free(bss
->eap_req_id_text
);
2464 bss
->eap_req_id_text
= os_strdup(pos
);
2465 if (bss
->eap_req_id_text
== NULL
) {
2466 wpa_printf(MSG_ERROR
, "Line %d: Failed to allocate memory for eap_req_id_text",
2470 bss
->eap_req_id_text_len
= os_strlen(bss
->eap_req_id_text
);
2471 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
2474 os_memmove(term
, term
+ 1,
2475 bss
->eap_req_id_text_len
-
2476 (term
- bss
->eap_req_id_text
) - 1);
2477 bss
->eap_req_id_text_len
--;
2479 } else if (os_strcmp(buf
, "erp_send_reauth_start") == 0) {
2480 bss
->erp_send_reauth_start
= atoi(pos
);
2481 } else if (os_strcmp(buf
, "erp_domain") == 0) {
2482 os_free(bss
->erp_domain
);
2483 bss
->erp_domain
= os_strdup(pos
);
2484 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
2485 int val
= atoi(pos
);
2487 if (val
< 0 || val
> 13) {
2488 wpa_printf(MSG_ERROR
,
2489 "Line %d: invalid WEP key len %d (= %d bits)",
2490 line
, val
, val
* 8);
2493 bss
->default_wep_key_len
= val
;
2494 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
2495 int val
= atoi(pos
);
2497 if (val
< 0 || val
> 13) {
2498 wpa_printf(MSG_ERROR
,
2499 "Line %d: invalid WEP key len %d (= %d bits)",
2500 line
, val
, val
* 8);
2503 bss
->individual_wep_key_len
= val
;
2504 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
2505 bss
->wep_rekeying_period
= atoi(pos
);
2506 if (bss
->wep_rekeying_period
< 0) {
2507 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2508 line
, bss
->wep_rekeying_period
);
2511 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
2512 bss
->eap_reauth_period
= atoi(pos
);
2513 if (bss
->eap_reauth_period
< 0) {
2514 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2515 line
, bss
->eap_reauth_period
);
2518 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
2519 bss
->eapol_key_index_workaround
= atoi(pos
);
2521 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
2522 bss
->ieee802_11f
= 1;
2523 os_strlcpy(bss
->iapp_iface
, pos
, sizeof(bss
->iapp_iface
));
2524 #endif /* CONFIG_IAPP */
2525 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
2526 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
2527 wpa_printf(MSG_ERROR
,
2528 "Line %d: invalid IP address '%s'",
2532 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
2533 os_free(bss
->nas_identifier
);
2534 bss
->nas_identifier
= os_strdup(pos
);
2535 #ifndef CONFIG_NO_RADIUS
2536 } else if (os_strcmp(buf
, "radius_client_addr") == 0) {
2537 if (hostapd_parse_ip_addr(pos
, &bss
->radius
->client_addr
)) {
2538 wpa_printf(MSG_ERROR
,
2539 "Line %d: invalid IP address '%s'",
2543 bss
->radius
->force_client_addr
= 1;
2544 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
2545 if (hostapd_config_read_radius_addr(
2546 &bss
->radius
->auth_servers
,
2547 &bss
->radius
->num_auth_servers
, pos
, 1812,
2548 &bss
->radius
->auth_server
)) {
2549 wpa_printf(MSG_ERROR
,
2550 "Line %d: invalid IP address '%s'",
2554 } else if (bss
->radius
->auth_server
&&
2555 os_strcmp(buf
, "auth_server_addr_replace") == 0) {
2556 if (hostapd_parse_ip_addr(pos
,
2557 &bss
->radius
->auth_server
->addr
)) {
2558 wpa_printf(MSG_ERROR
,
2559 "Line %d: invalid IP address '%s'",
2563 } else if (bss
->radius
->auth_server
&&
2564 os_strcmp(buf
, "auth_server_port") == 0) {
2565 bss
->radius
->auth_server
->port
= atoi(pos
);
2566 } else if (bss
->radius
->auth_server
&&
2567 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
2568 int len
= os_strlen(pos
);
2570 /* RFC 2865, Ch. 3 */
2571 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2575 os_free(bss
->radius
->auth_server
->shared_secret
);
2576 bss
->radius
->auth_server
->shared_secret
= (u8
*) os_strdup(pos
);
2577 bss
->radius
->auth_server
->shared_secret_len
= len
;
2578 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
2579 if (hostapd_config_read_radius_addr(
2580 &bss
->radius
->acct_servers
,
2581 &bss
->radius
->num_acct_servers
, pos
, 1813,
2582 &bss
->radius
->acct_server
)) {
2583 wpa_printf(MSG_ERROR
,
2584 "Line %d: invalid IP address '%s'",
2588 } else if (bss
->radius
->acct_server
&&
2589 os_strcmp(buf
, "acct_server_addr_replace") == 0) {
2590 if (hostapd_parse_ip_addr(pos
,
2591 &bss
->radius
->acct_server
->addr
)) {
2592 wpa_printf(MSG_ERROR
,
2593 "Line %d: invalid IP address '%s'",
2597 } else if (bss
->radius
->acct_server
&&
2598 os_strcmp(buf
, "acct_server_port") == 0) {
2599 bss
->radius
->acct_server
->port
= atoi(pos
);
2600 } else if (bss
->radius
->acct_server
&&
2601 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
2602 int len
= os_strlen(pos
);
2604 /* RFC 2865, Ch. 3 */
2605 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2609 os_free(bss
->radius
->acct_server
->shared_secret
);
2610 bss
->radius
->acct_server
->shared_secret
= (u8
*) os_strdup(pos
);
2611 bss
->radius
->acct_server
->shared_secret_len
= len
;
2612 } else if (os_strcmp(buf
, "radius_retry_primary_interval") == 0) {
2613 bss
->radius
->retry_primary_interval
= atoi(pos
);
2614 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0) {
2615 bss
->acct_interim_interval
= atoi(pos
);
2616 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
2617 bss
->radius_request_cui
= atoi(pos
);
2618 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
2619 struct hostapd_radius_attr
*attr
, *a
;
2620 attr
= hostapd_parse_radius_attr(pos
);
2622 wpa_printf(MSG_ERROR
,
2623 "Line %d: invalid radius_auth_req_attr",
2626 } else if (bss
->radius_auth_req_attr
== NULL
) {
2627 bss
->radius_auth_req_attr
= attr
;
2629 a
= bss
->radius_auth_req_attr
;
2634 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
2635 struct hostapd_radius_attr
*attr
, *a
;
2636 attr
= hostapd_parse_radius_attr(pos
);
2638 wpa_printf(MSG_ERROR
,
2639 "Line %d: invalid radius_acct_req_attr",
2642 } else if (bss
->radius_acct_req_attr
== NULL
) {
2643 bss
->radius_acct_req_attr
= attr
;
2645 a
= bss
->radius_acct_req_attr
;
2650 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
2651 bss
->radius_das_port
= atoi(pos
);
2652 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
2653 if (hostapd_parse_das_client(bss
, pos
) < 0) {
2654 wpa_printf(MSG_ERROR
, "Line %d: invalid DAS client",
2658 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2659 bss
->radius_das_time_window
= atoi(pos
);
2660 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp") == 0) {
2661 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2662 } else if (os_strcmp(buf
, "radius_das_require_message_authenticator") ==
2664 bss
->radius_das_require_message_authenticator
= atoi(pos
);
2665 #endif /* CONFIG_NO_RADIUS */
2666 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2667 bss
->auth_algs
= atoi(pos
);
2668 if (bss
->auth_algs
== 0) {
2669 wpa_printf(MSG_ERROR
, "Line %d: no authentication algorithms allowed",
2673 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2674 bss
->max_num_sta
= atoi(pos
);
2675 if (bss
->max_num_sta
< 0 ||
2676 bss
->max_num_sta
> MAX_STA_COUNT
) {
2677 wpa_printf(MSG_ERROR
, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2678 line
, bss
->max_num_sta
, MAX_STA_COUNT
);
2681 } else if (os_strcmp(buf
, "wpa") == 0) {
2682 bss
->wpa
= atoi(pos
);
2683 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2684 bss
->wpa_group_rekey
= atoi(pos
);
2685 bss
->wpa_group_rekey_set
= 1;
2686 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2687 bss
->wpa_strict_rekey
= atoi(pos
);
2688 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2689 bss
->wpa_gmk_rekey
= atoi(pos
);
2690 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2691 bss
->wpa_ptk_rekey
= atoi(pos
);
2692 } else if (os_strcmp(buf
, "wpa_group_update_count") == 0) {
2694 unsigned long val
= strtoul(pos
, &endp
, 0);
2696 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2697 wpa_printf(MSG_ERROR
,
2698 "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295",
2702 bss
->wpa_group_update_count
= (u32
) val
;
2703 } else if (os_strcmp(buf
, "wpa_pairwise_update_count") == 0) {
2705 unsigned long val
= strtoul(pos
, &endp
, 0);
2707 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2708 wpa_printf(MSG_ERROR
,
2709 "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295",
2713 bss
->wpa_pairwise_update_count
= (u32
) val
;
2714 } else if (os_strcmp(buf
, "wpa_disable_eapol_key_retries") == 0) {
2715 bss
->wpa_disable_eapol_key_retries
= atoi(pos
);
2716 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2717 int len
= os_strlen(pos
);
2718 if (len
< 8 || len
> 63) {
2719 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA passphrase length %d (expected 8..63)",
2723 os_free(bss
->ssid
.wpa_passphrase
);
2724 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2725 if (bss
->ssid
.wpa_passphrase
) {
2726 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2727 bss
->ssid
.wpa_passphrase_set
= 1;
2729 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2730 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2731 bss
->ssid
.wpa_psk
= os_zalloc(sizeof(struct hostapd_wpa_psk
));
2732 if (bss
->ssid
.wpa_psk
== NULL
)
2734 if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
, PMK_LEN
) ||
2735 pos
[PMK_LEN
* 2] != '\0') {
2736 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
2738 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2741 bss
->ssid
.wpa_psk
->group
= 1;
2742 os_free(bss
->ssid
.wpa_passphrase
);
2743 bss
->ssid
.wpa_passphrase
= NULL
;
2744 bss
->ssid
.wpa_psk_set
= 1;
2745 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2746 os_free(bss
->ssid
.wpa_psk_file
);
2747 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
2748 if (!bss
->ssid
.wpa_psk_file
) {
2749 wpa_printf(MSG_ERROR
, "Line %d: allocation failed",
2753 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
2754 bss
->wpa_key_mgmt
= hostapd_config_parse_key_mgmt(line
, pos
);
2755 if (bss
->wpa_key_mgmt
== -1)
2757 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
2758 bss
->wpa_psk_radius
= atoi(pos
);
2759 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
2760 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
2761 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
2762 wpa_printf(MSG_ERROR
,
2763 "Line %d: unknown wpa_psk_radius %d",
2764 line
, bss
->wpa_psk_radius
);
2767 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
2768 bss
->wpa_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2769 if (bss
->wpa_pairwise
== -1 || bss
->wpa_pairwise
== 0)
2771 if (bss
->wpa_pairwise
&
2772 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2773 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2777 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
2778 bss
->rsn_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2779 if (bss
->rsn_pairwise
== -1 || bss
->rsn_pairwise
== 0)
2781 if (bss
->rsn_pairwise
&
2782 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2783 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2787 } else if (os_strcmp(buf
, "group_cipher") == 0) {
2788 bss
->group_cipher
= hostapd_config_parse_cipher(line
, pos
);
2789 if (bss
->group_cipher
== -1 || bss
->group_cipher
== 0)
2791 if (bss
->group_cipher
!= WPA_CIPHER_TKIP
&&
2792 bss
->group_cipher
!= WPA_CIPHER_CCMP
&&
2793 bss
->group_cipher
!= WPA_CIPHER_GCMP
&&
2794 bss
->group_cipher
!= WPA_CIPHER_GCMP_256
&&
2795 bss
->group_cipher
!= WPA_CIPHER_CCMP_256
) {
2796 wpa_printf(MSG_ERROR
,
2797 "Line %d: unsupported group cipher suite '%s'",
2801 #ifdef CONFIG_RSN_PREAUTH
2802 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
2803 bss
->rsn_preauth
= atoi(pos
);
2804 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
2805 os_free(bss
->rsn_preauth_interfaces
);
2806 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
2807 #endif /* CONFIG_RSN_PREAUTH */
2808 } else if (os_strcmp(buf
, "peerkey") == 0) {
2809 wpa_printf(MSG_INFO
,
2810 "Line %d: Obsolete peerkey parameter ignored", line
);
2811 #ifdef CONFIG_IEEE80211R_AP
2812 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
2813 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
2814 hexstr2bin(pos
, bss
->mobility_domain
,
2815 MOBILITY_DOMAIN_ID_LEN
) != 0) {
2816 wpa_printf(MSG_ERROR
,
2817 "Line %d: Invalid mobility_domain '%s'",
2821 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
2822 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
2823 hexstr2bin(pos
, bss
->r1_key_holder
, FT_R1KH_ID_LEN
) != 0) {
2824 wpa_printf(MSG_ERROR
,
2825 "Line %d: Invalid r1_key_holder '%s'",
2829 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
2830 /* DEPRECATED: Use ft_r0_key_lifetime instead. */
2831 bss
->r0_key_lifetime
= atoi(pos
) * 60;
2832 } else if (os_strcmp(buf
, "ft_r0_key_lifetime") == 0) {
2833 bss
->r0_key_lifetime
= atoi(pos
);
2834 } else if (os_strcmp(buf
, "r1_max_key_lifetime") == 0) {
2835 bss
->r1_max_key_lifetime
= atoi(pos
);
2836 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
2837 bss
->reassociation_deadline
= atoi(pos
);
2838 } else if (os_strcmp(buf
, "rkh_pos_timeout") == 0) {
2839 bss
->rkh_pos_timeout
= atoi(pos
);
2840 } else if (os_strcmp(buf
, "rkh_neg_timeout") == 0) {
2841 bss
->rkh_neg_timeout
= atoi(pos
);
2842 } else if (os_strcmp(buf
, "rkh_pull_timeout") == 0) {
2843 bss
->rkh_pull_timeout
= atoi(pos
);
2844 } else if (os_strcmp(buf
, "rkh_pull_retries") == 0) {
2845 bss
->rkh_pull_retries
= atoi(pos
);
2846 } else if (os_strcmp(buf
, "r0kh") == 0) {
2847 if (add_r0kh(bss
, pos
) < 0) {
2848 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r0kh '%s'",
2852 } else if (os_strcmp(buf
, "r1kh") == 0) {
2853 if (add_r1kh(bss
, pos
) < 0) {
2854 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r1kh '%s'",
2858 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
2859 bss
->pmk_r1_push
= atoi(pos
);
2860 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
2861 bss
->ft_over_ds
= atoi(pos
);
2862 } else if (os_strcmp(buf
, "ft_psk_generate_local") == 0) {
2863 bss
->ft_psk_generate_local
= atoi(pos
);
2864 #endif /* CONFIG_IEEE80211R_AP */
2865 #ifndef CONFIG_NO_CTRL_IFACE
2866 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
2867 os_free(bss
->ctrl_interface
);
2868 bss
->ctrl_interface
= os_strdup(pos
);
2869 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
2870 #ifndef CONFIG_NATIVE_WINDOWS
2873 const char *group
= pos
;
2875 grp
= getgrnam(group
);
2877 bss
->ctrl_interface_gid
= grp
->gr_gid
;
2878 bss
->ctrl_interface_gid_set
= 1;
2879 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d (from group name '%s')",
2880 bss
->ctrl_interface_gid
, group
);
2884 /* Group name not found - try to parse this as gid */
2885 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
2886 if (*group
== '\0' || *endp
!= '\0') {
2887 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group '%s'",
2891 bss
->ctrl_interface_gid_set
= 1;
2892 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
2893 bss
->ctrl_interface_gid
);
2894 #endif /* CONFIG_NATIVE_WINDOWS */
2895 #endif /* CONFIG_NO_CTRL_IFACE */
2896 #ifdef RADIUS_SERVER
2897 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
2898 os_free(bss
->radius_server_clients
);
2899 bss
->radius_server_clients
= os_strdup(pos
);
2900 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
2901 bss
->radius_server_auth_port
= atoi(pos
);
2902 } else if (os_strcmp(buf
, "radius_server_acct_port") == 0) {
2903 bss
->radius_server_acct_port
= atoi(pos
);
2904 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
2905 bss
->radius_server_ipv6
= atoi(pos
);
2906 #endif /* RADIUS_SERVER */
2907 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
2908 bss
->use_pae_group_addr
= atoi(pos
);
2909 } else if (os_strcmp(buf
, "hw_mode") == 0) {
2910 if (os_strcmp(pos
, "a") == 0)
2911 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
2912 else if (os_strcmp(pos
, "b") == 0)
2913 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
2914 else if (os_strcmp(pos
, "g") == 0)
2915 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
2916 else if (os_strcmp(pos
, "ad") == 0)
2917 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
2918 else if (os_strcmp(pos
, "any") == 0)
2919 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211ANY
;
2921 wpa_printf(MSG_ERROR
, "Line %d: unknown hw_mode '%s'",
2925 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
2926 if (os_strcmp(pos
, "ad") == 0)
2927 bss
->wps_rf_bands
= WPS_RF_60GHZ
;
2928 else if (os_strcmp(pos
, "a") == 0)
2929 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
2930 else if (os_strcmp(pos
, "g") == 0 ||
2931 os_strcmp(pos
, "b") == 0)
2932 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
2933 else if (os_strcmp(pos
, "ag") == 0 ||
2934 os_strcmp(pos
, "ga") == 0)
2935 bss
->wps_rf_bands
= WPS_RF_24GHZ
| WPS_RF_50GHZ
;
2937 wpa_printf(MSG_ERROR
,
2938 "Line %d: unknown wps_rf_band '%s'",
2942 } else if (os_strcmp(buf
, "acs_exclude_dfs") == 0) {
2943 conf
->acs_exclude_dfs
= atoi(pos
);
2944 } else if (os_strcmp(buf
, "channel") == 0) {
2945 if (os_strcmp(pos
, "acs_survey") == 0) {
2947 wpa_printf(MSG_ERROR
, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
2950 #else /* CONFIG_ACS */
2953 #endif /* CONFIG_ACS */
2955 conf
->channel
= atoi(pos
);
2956 conf
->acs
= conf
->channel
== 0;
2958 } else if (os_strcmp(buf
, "chanlist") == 0) {
2959 if (hostapd_parse_chanlist(conf
, pos
)) {
2960 wpa_printf(MSG_ERROR
, "Line %d: invalid channel list",
2964 } else if (os_strcmp(buf
, "beacon_int") == 0) {
2965 int val
= atoi(pos
);
2966 /* MIB defines range as 1..65535, but very small values
2967 * cause problems with the current implementation.
2968 * Since it is unlikely that this small numbers are
2969 * useful in real life scenarios, do not allow beacon
2970 * period to be set below 15 TU. */
2971 if (val
< 15 || val
> 65535) {
2972 wpa_printf(MSG_ERROR
, "Line %d: invalid beacon_int %d (expected 15..65535)",
2976 conf
->beacon_int
= val
;
2978 } else if (os_strcmp(buf
, "acs_num_scans") == 0) {
2979 int val
= atoi(pos
);
2980 if (val
<= 0 || val
> 100) {
2981 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_num_scans %d (expected 1..100)",
2985 conf
->acs_num_scans
= val
;
2986 } else if (os_strcmp(buf
, "acs_chan_bias") == 0) {
2987 if (hostapd_config_parse_acs_chan_bias(conf
, pos
)) {
2988 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_chan_bias",
2992 #endif /* CONFIG_ACS */
2993 } else if (os_strcmp(buf
, "dtim_period") == 0) {
2994 int val
= atoi(pos
);
2996 if (val
< 1 || val
> 255) {
2997 wpa_printf(MSG_ERROR
, "Line %d: invalid dtim_period %d",
3001 bss
->dtim_period
= val
;
3002 } else if (os_strcmp(buf
, "bss_load_update_period") == 0) {
3003 int val
= atoi(pos
);
3005 if (val
< 0 || val
> 100) {
3006 wpa_printf(MSG_ERROR
,
3007 "Line %d: invalid bss_load_update_period %d",
3011 bss
->bss_load_update_period
= val
;
3012 } else if (os_strcmp(buf
, "chan_util_avg_period") == 0) {
3013 int val
= atoi(pos
);
3016 wpa_printf(MSG_ERROR
,
3017 "Line %d: invalid chan_util_avg_period",
3021 bss
->chan_util_avg_period
= val
;
3022 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
3023 conf
->rts_threshold
= atoi(pos
);
3024 if (conf
->rts_threshold
< -1 || conf
->rts_threshold
> 65535) {
3025 wpa_printf(MSG_ERROR
,
3026 "Line %d: invalid rts_threshold %d",
3027 line
, conf
->rts_threshold
);
3030 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
3031 conf
->fragm_threshold
= atoi(pos
);
3032 if (conf
->fragm_threshold
== -1) {
3033 /* allow a value of -1 */
3034 } else if (conf
->fragm_threshold
< 256 ||
3035 conf
->fragm_threshold
> 2346) {
3036 wpa_printf(MSG_ERROR
,
3037 "Line %d: invalid fragm_threshold %d",
3038 line
, conf
->fragm_threshold
);
3041 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
3042 int val
= atoi(pos
);
3043 if (val
!= 0 && val
!= 1) {
3044 wpa_printf(MSG_ERROR
, "Line %d: invalid send_probe_response %d (expected 0 or 1)",
3048 conf
->send_probe_response
= val
;
3049 } else if (os_strcmp(buf
, "supported_rates") == 0) {
3050 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
)) {
3051 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3055 } else if (os_strcmp(buf
, "basic_rates") == 0) {
3056 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
3057 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
3061 } else if (os_strcmp(buf
, "beacon_rate") == 0) {
3064 if (os_strncmp(pos
, "ht:", 3) == 0) {
3065 val
= atoi(pos
+ 3);
3066 if (val
< 0 || val
> 31) {
3067 wpa_printf(MSG_ERROR
,
3068 "Line %d: invalid beacon_rate HT-MCS %d",
3072 conf
->rate_type
= BEACON_RATE_HT
;
3073 conf
->beacon_rate
= val
;
3074 } else if (os_strncmp(pos
, "vht:", 4) == 0) {
3075 val
= atoi(pos
+ 4);
3076 if (val
< 0 || val
> 9) {
3077 wpa_printf(MSG_ERROR
,
3078 "Line %d: invalid beacon_rate VHT-MCS %d",
3082 conf
->rate_type
= BEACON_RATE_VHT
;
3083 conf
->beacon_rate
= val
;
3086 if (val
< 10 || val
> 10000) {
3087 wpa_printf(MSG_ERROR
,
3088 "Line %d: invalid legacy beacon_rate %d",
3092 conf
->rate_type
= BEACON_RATE_LEGACY
;
3093 conf
->beacon_rate
= val
;
3095 } else if (os_strcmp(buf
, "preamble") == 0) {
3097 conf
->preamble
= SHORT_PREAMBLE
;
3099 conf
->preamble
= LONG_PREAMBLE
;
3100 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
3101 bss
->ignore_broadcast_ssid
= atoi(pos
);
3102 } else if (os_strcmp(buf
, "no_probe_resp_if_max_sta") == 0) {
3103 bss
->no_probe_resp_if_max_sta
= atoi(pos
);
3104 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
3105 bss
->ssid
.wep
.idx
= atoi(pos
);
3106 if (bss
->ssid
.wep
.idx
> 3) {
3107 wpa_printf(MSG_ERROR
,
3108 "Invalid wep_default_key index %d",
3112 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
3113 os_strcmp(buf
, "wep_key1") == 0 ||
3114 os_strcmp(buf
, "wep_key2") == 0 ||
3115 os_strcmp(buf
, "wep_key3") == 0) {
3116 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
3117 buf
[7] - '0', pos
)) {
3118 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP key '%s'",
3122 #ifndef CONFIG_NO_VLAN
3123 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
3124 bss
->ssid
.dynamic_vlan
= atoi(pos
);
3125 } else if (os_strcmp(buf
, "per_sta_vif") == 0) {
3126 bss
->ssid
.per_sta_vif
= atoi(pos
);
3127 } else if (os_strcmp(buf
, "vlan_file") == 0) {
3128 if (hostapd_config_read_vlan_file(bss
, pos
)) {
3129 wpa_printf(MSG_ERROR
, "Line %d: failed to read VLAN file '%s'",
3133 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
3134 bss
->ssid
.vlan_naming
= atoi(pos
);
3135 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
3136 bss
->ssid
.vlan_naming
< 0) {
3137 wpa_printf(MSG_ERROR
,
3138 "Line %d: invalid naming scheme %d",
3139 line
, bss
->ssid
.vlan_naming
);
3142 #ifdef CONFIG_FULL_DYNAMIC_VLAN
3143 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
3144 os_free(bss
->ssid
.vlan_tagged_interface
);
3145 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
3146 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
3147 #endif /* CONFIG_NO_VLAN */
3148 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
3149 conf
->ap_table_max_size
= atoi(pos
);
3150 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
3151 conf
->ap_table_expiration_time
= atoi(pos
);
3152 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
3153 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
3154 wpa_printf(MSG_ERROR
, "Line %d: invalid TX queue item",
3158 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
3159 os_strcmp(buf
, "wmm_enabled") == 0) {
3160 bss
->wmm_enabled
= atoi(pos
);
3161 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
3162 bss
->wmm_uapsd
= atoi(pos
);
3163 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
3164 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
3165 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
, pos
)) {
3166 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM ac item",
3170 } else if (os_strcmp(buf
, "bss") == 0) {
3171 if (hostapd_config_bss(conf
, pos
)) {
3172 wpa_printf(MSG_ERROR
, "Line %d: invalid bss item",
3176 } else if (os_strcmp(buf
, "bssid") == 0) {
3177 if (hwaddr_aton(pos
, bss
->bssid
)) {
3178 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid item",
3182 } else if (os_strcmp(buf
, "use_driver_iface_addr") == 0) {
3183 conf
->use_driver_iface_addr
= atoi(pos
);
3184 #ifdef CONFIG_IEEE80211W
3185 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
3186 bss
->ieee80211w
= atoi(pos
);
3187 } else if (os_strcmp(buf
, "group_mgmt_cipher") == 0) {
3188 if (os_strcmp(pos
, "AES-128-CMAC") == 0) {
3189 bss
->group_mgmt_cipher
= WPA_CIPHER_AES_128_CMAC
;
3190 } else if (os_strcmp(pos
, "BIP-GMAC-128") == 0) {
3191 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_128
;
3192 } else if (os_strcmp(pos
, "BIP-GMAC-256") == 0) {
3193 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_256
;
3194 } else if (os_strcmp(pos
, "BIP-CMAC-256") == 0) {
3195 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_CMAC_256
;
3197 wpa_printf(MSG_ERROR
, "Line %d: invalid group_mgmt_cipher: %s",
3201 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
3202 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
3203 if (bss
->assoc_sa_query_max_timeout
== 0) {
3204 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_max_timeout",
3208 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0) {
3209 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
3210 if (bss
->assoc_sa_query_retry_timeout
== 0) {
3211 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_retry_timeout",
3215 #endif /* CONFIG_IEEE80211W */
3216 #ifdef CONFIG_IEEE80211N
3217 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
3218 conf
->ieee80211n
= atoi(pos
);
3219 } else if (os_strcmp(buf
, "ht_capab") == 0) {
3220 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
3221 wpa_printf(MSG_ERROR
, "Line %d: invalid ht_capab",
3225 } else if (os_strcmp(buf
, "require_ht") == 0) {
3226 conf
->require_ht
= atoi(pos
);
3227 } else if (os_strcmp(buf
, "obss_interval") == 0) {
3228 conf
->obss_interval
= atoi(pos
);
3229 #endif /* CONFIG_IEEE80211N */
3230 #ifdef CONFIG_IEEE80211AC
3231 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
3232 conf
->ieee80211ac
= atoi(pos
);
3233 } else if (os_strcmp(buf
, "vht_capab") == 0) {
3234 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
3235 wpa_printf(MSG_ERROR
, "Line %d: invalid vht_capab",
3239 } else if (os_strcmp(buf
, "require_vht") == 0) {
3240 conf
->require_vht
= atoi(pos
);
3241 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
3242 conf
->vht_oper_chwidth
= atoi(pos
);
3243 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0) {
3244 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
3245 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0) {
3246 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
3247 } else if (os_strcmp(buf
, "vendor_vht") == 0) {
3248 bss
->vendor_vht
= atoi(pos
);
3249 } else if (os_strcmp(buf
, "use_sta_nsts") == 0) {
3250 bss
->use_sta_nsts
= atoi(pos
);
3251 #endif /* CONFIG_IEEE80211AC */
3252 #ifdef CONFIG_IEEE80211AX
3253 } else if (os_strcmp(buf
, "ieee80211ax") == 0) {
3254 conf
->ieee80211ax
= atoi(pos
);
3255 } else if (os_strcmp(buf
, "he_su_beamformer") == 0) {
3256 conf
->he_phy_capab
.he_su_beamformer
= atoi(pos
);
3257 } else if (os_strcmp(buf
, "he_su_beamformee") == 0) {
3258 conf
->he_phy_capab
.he_su_beamformee
= atoi(pos
);
3259 } else if (os_strcmp(buf
, "he_mu_beamformer") == 0) {
3260 conf
->he_phy_capab
.he_mu_beamformer
= atoi(pos
);
3261 } else if (os_strcmp(buf
, "he_bss_color") == 0) {
3262 conf
->he_op
.he_bss_color
= atoi(pos
);
3263 } else if (os_strcmp(buf
, "he_default_pe_duration") == 0) {
3264 conf
->he_op
.he_default_pe_duration
= atoi(pos
);
3265 } else if (os_strcmp(buf
, "he_twt_required") == 0) {
3266 conf
->he_op
.he_twt_required
= atoi(pos
);
3267 } else if (os_strcmp(buf
, "he_rts_threshold") == 0) {
3268 conf
->he_op
.he_rts_threshold
= atoi(pos
);
3269 #endif /* CONFIG_IEEE80211AX */
3270 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
3271 bss
->max_listen_interval
= atoi(pos
);
3272 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
3273 bss
->disable_pmksa_caching
= atoi(pos
);
3274 } else if (os_strcmp(buf
, "okc") == 0) {
3275 bss
->okc
= atoi(pos
);
3277 } else if (os_strcmp(buf
, "wps_state") == 0) {
3278 bss
->wps_state
= atoi(pos
);
3279 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
3280 wpa_printf(MSG_ERROR
, "Line %d: invalid wps_state",
3284 } else if (os_strcmp(buf
, "wps_independent") == 0) {
3285 bss
->wps_independent
= atoi(pos
);
3286 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
3287 bss
->ap_setup_locked
= atoi(pos
);
3288 } else if (os_strcmp(buf
, "uuid") == 0) {
3289 if (uuid_str2bin(pos
, bss
->uuid
)) {
3290 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID", line
);
3293 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
3294 os_free(bss
->wps_pin_requests
);
3295 bss
->wps_pin_requests
= os_strdup(pos
);
3296 } else if (os_strcmp(buf
, "device_name") == 0) {
3297 if (os_strlen(pos
) > WPS_DEV_NAME_MAX_LEN
) {
3298 wpa_printf(MSG_ERROR
, "Line %d: Too long "
3299 "device_name", line
);
3302 os_free(bss
->device_name
);
3303 bss
->device_name
= os_strdup(pos
);
3304 } else if (os_strcmp(buf
, "manufacturer") == 0) {
3305 if (os_strlen(pos
) > 64) {
3306 wpa_printf(MSG_ERROR
, "Line %d: Too long manufacturer",
3310 os_free(bss
->manufacturer
);
3311 bss
->manufacturer
= os_strdup(pos
);
3312 } else if (os_strcmp(buf
, "model_name") == 0) {
3313 if (os_strlen(pos
) > 32) {
3314 wpa_printf(MSG_ERROR
, "Line %d: Too long model_name",
3318 os_free(bss
->model_name
);
3319 bss
->model_name
= os_strdup(pos
);
3320 } else if (os_strcmp(buf
, "model_number") == 0) {
3321 if (os_strlen(pos
) > 32) {
3322 wpa_printf(MSG_ERROR
, "Line %d: Too long model_number",
3326 os_free(bss
->model_number
);
3327 bss
->model_number
= os_strdup(pos
);
3328 } else if (os_strcmp(buf
, "serial_number") == 0) {
3329 if (os_strlen(pos
) > 32) {
3330 wpa_printf(MSG_ERROR
, "Line %d: Too long serial_number",
3334 os_free(bss
->serial_number
);
3335 bss
->serial_number
= os_strdup(pos
);
3336 } else if (os_strcmp(buf
, "device_type") == 0) {
3337 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
3339 } else if (os_strcmp(buf
, "config_methods") == 0) {
3340 os_free(bss
->config_methods
);
3341 bss
->config_methods
= os_strdup(pos
);
3342 } else if (os_strcmp(buf
, "os_version") == 0) {
3343 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
3344 wpa_printf(MSG_ERROR
, "Line %d: invalid os_version",
3348 } else if (os_strcmp(buf
, "ap_pin") == 0) {
3349 os_free(bss
->ap_pin
);
3353 bss
->ap_pin
= os_strdup(pos
);
3354 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
3355 bss
->skip_cred_build
= atoi(pos
);
3356 } else if (os_strcmp(buf
, "extra_cred") == 0) {
3357 os_free(bss
->extra_cred
);
3358 bss
->extra_cred
= (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
3359 if (bss
->extra_cred
== NULL
) {
3360 wpa_printf(MSG_ERROR
, "Line %d: could not read Credentials from '%s'",
3364 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
3365 bss
->wps_cred_processing
= atoi(pos
);
3366 } else if (os_strcmp(buf
, "ap_settings") == 0) {
3367 os_free(bss
->ap_settings
);
3369 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
3370 if (bss
->ap_settings
== NULL
) {
3371 wpa_printf(MSG_ERROR
, "Line %d: could not read AP Settings from '%s'",
3375 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
3376 os_free(bss
->upnp_iface
);
3377 bss
->upnp_iface
= os_strdup(pos
);
3378 } else if (os_strcmp(buf
, "friendly_name") == 0) {
3379 os_free(bss
->friendly_name
);
3380 bss
->friendly_name
= os_strdup(pos
);
3381 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
3382 os_free(bss
->manufacturer_url
);
3383 bss
->manufacturer_url
= os_strdup(pos
);
3384 } else if (os_strcmp(buf
, "model_description") == 0) {
3385 os_free(bss
->model_description
);
3386 bss
->model_description
= os_strdup(pos
);
3387 } else if (os_strcmp(buf
, "model_url") == 0) {
3388 os_free(bss
->model_url
);
3389 bss
->model_url
= os_strdup(pos
);
3390 } else if (os_strcmp(buf
, "upc") == 0) {
3392 bss
->upc
= os_strdup(pos
);
3393 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
3394 bss
->pbc_in_m1
= atoi(pos
);
3395 } else if (os_strcmp(buf
, "server_id") == 0) {
3396 os_free(bss
->server_id
);
3397 bss
->server_id
= os_strdup(pos
);
3398 #ifdef CONFIG_WPS_NFC
3399 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
3400 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
3401 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
3402 bss
->wps_nfc_dev_pw_id
> 0xffff) {
3403 wpa_printf(MSG_ERROR
, "Line %d: Invalid wps_nfc_dev_pw_id value",
3407 bss
->wps_nfc_pw_from_config
= 1;
3408 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
3409 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
3410 bss
->wps_nfc_dh_pubkey
= wpabuf_parse_bin(pos
);
3411 bss
->wps_nfc_pw_from_config
= 1;
3412 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
3413 wpabuf_free(bss
->wps_nfc_dh_privkey
);
3414 bss
->wps_nfc_dh_privkey
= wpabuf_parse_bin(pos
);
3415 bss
->wps_nfc_pw_from_config
= 1;
3416 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
3417 wpabuf_free(bss
->wps_nfc_dev_pw
);
3418 bss
->wps_nfc_dev_pw
= wpabuf_parse_bin(pos
);
3419 bss
->wps_nfc_pw_from_config
= 1;
3420 #endif /* CONFIG_WPS_NFC */
3421 #endif /* CONFIG_WPS */
3422 #ifdef CONFIG_P2P_MANAGER
3423 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
3425 bss
->p2p
|= P2P_MANAGE
;
3427 bss
->p2p
&= ~P2P_MANAGE
;
3428 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
3430 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
3432 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
3433 #endif /* CONFIG_P2P_MANAGER */
3434 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
3435 bss
->disassoc_low_ack
= atoi(pos
);
3436 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
3438 bss
->tdls
|= TDLS_PROHIBIT
;
3440 bss
->tdls
&= ~TDLS_PROHIBIT
;
3441 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
3443 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
3445 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
3446 #ifdef CONFIG_RSN_TESTING
3447 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
3448 extern int rsn_testing
;
3449 rsn_testing
= atoi(pos
);
3450 #endif /* CONFIG_RSN_TESTING */
3451 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
3452 bss
->time_advertisement
= atoi(pos
);
3453 } else if (os_strcmp(buf
, "time_zone") == 0) {
3454 size_t tz_len
= os_strlen(pos
);
3455 if (tz_len
< 4 || tz_len
> 255) {
3456 wpa_printf(MSG_DEBUG
, "Line %d: invalid time_zone",
3460 os_free(bss
->time_zone
);
3461 bss
->time_zone
= os_strdup(pos
);
3462 if (bss
->time_zone
== NULL
)
3464 #ifdef CONFIG_WNM_AP
3465 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
3466 bss
->wnm_sleep_mode
= atoi(pos
);
3467 } else if (os_strcmp(buf
, "wnm_sleep_mode_no_keys") == 0) {
3468 bss
->wnm_sleep_mode_no_keys
= atoi(pos
);
3469 } else if (os_strcmp(buf
, "bss_transition") == 0) {
3470 bss
->bss_transition
= atoi(pos
);
3471 #endif /* CONFIG_WNM_AP */
3472 #ifdef CONFIG_INTERWORKING
3473 } else if (os_strcmp(buf
, "interworking") == 0) {
3474 bss
->interworking
= atoi(pos
);
3475 } else if (os_strcmp(buf
, "access_network_type") == 0) {
3476 bss
->access_network_type
= atoi(pos
);
3477 if (bss
->access_network_type
< 0 ||
3478 bss
->access_network_type
> 15) {
3479 wpa_printf(MSG_ERROR
,
3480 "Line %d: invalid access_network_type",
3484 } else if (os_strcmp(buf
, "internet") == 0) {
3485 bss
->internet
= atoi(pos
);
3486 } else if (os_strcmp(buf
, "asra") == 0) {
3487 bss
->asra
= atoi(pos
);
3488 } else if (os_strcmp(buf
, "esr") == 0) {
3489 bss
->esr
= atoi(pos
);
3490 } else if (os_strcmp(buf
, "uesa") == 0) {
3491 bss
->uesa
= atoi(pos
);
3492 } else if (os_strcmp(buf
, "venue_group") == 0) {
3493 bss
->venue_group
= atoi(pos
);
3494 bss
->venue_info_set
= 1;
3495 } else if (os_strcmp(buf
, "venue_type") == 0) {
3496 bss
->venue_type
= atoi(pos
);
3497 bss
->venue_info_set
= 1;
3498 } else if (os_strcmp(buf
, "hessid") == 0) {
3499 if (hwaddr_aton(pos
, bss
->hessid
)) {
3500 wpa_printf(MSG_ERROR
, "Line %d: invalid hessid", line
);
3503 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
3504 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
3506 } else if (os_strcmp(buf
, "venue_name") == 0) {
3507 if (parse_venue_name(bss
, pos
, line
) < 0)
3509 } else if (os_strcmp(buf
, "venue_url") == 0) {
3510 if (parse_venue_url(bss
, pos
, line
) < 0)
3512 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
3514 u16 redirect_url_len
;
3515 if (hexstr2bin(pos
, &auth_type
, 1)) {
3516 wpa_printf(MSG_ERROR
,
3517 "Line %d: Invalid network_auth_type '%s'",
3521 if (auth_type
== 0 || auth_type
== 2)
3522 redirect_url_len
= os_strlen(pos
+ 2);
3524 redirect_url_len
= 0;
3525 os_free(bss
->network_auth_type
);
3526 bss
->network_auth_type
= os_malloc(redirect_url_len
+ 3 + 1);
3527 if (bss
->network_auth_type
== NULL
)
3529 *bss
->network_auth_type
= auth_type
;
3530 WPA_PUT_LE16(bss
->network_auth_type
+ 1, redirect_url_len
);
3531 if (redirect_url_len
)
3532 os_memcpy(bss
->network_auth_type
+ 3, pos
+ 2,
3534 bss
->network_auth_type_len
= 3 + redirect_url_len
;
3535 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
3536 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1)) {
3537 wpa_printf(MSG_ERROR
, "Line %d: Invalid ipaddr_type_availability '%s'",
3539 bss
->ipaddr_type_configured
= 0;
3542 bss
->ipaddr_type_configured
= 1;
3543 } else if (os_strcmp(buf
, "domain_name") == 0) {
3544 int j
, num_domains
, domain_len
, domain_list_len
= 0;
3545 char *tok_start
, *tok_prev
;
3546 u8
*domain_list
, *domain_ptr
;
3548 domain_list_len
= os_strlen(pos
) + 1;
3549 domain_list
= os_malloc(domain_list_len
);
3550 if (domain_list
== NULL
)
3553 domain_ptr
= domain_list
;
3556 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
3561 for (j
= 0; j
< num_domains
; j
++) {
3562 tok_start
= os_strchr(tok_prev
, ',');
3564 domain_len
= tok_start
- tok_prev
;
3565 *domain_ptr
= domain_len
;
3566 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3567 domain_ptr
+= domain_len
+ 1;
3568 tok_prev
= ++tok_start
;
3570 domain_len
= os_strlen(tok_prev
);
3571 *domain_ptr
= domain_len
;
3572 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3573 domain_ptr
+= domain_len
+ 1;
3577 os_free(bss
->domain_name
);
3578 bss
->domain_name
= domain_list
;
3579 bss
->domain_name_len
= domain_list_len
;
3580 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
3581 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
3583 } else if (os_strcmp(buf
, "nai_realm") == 0) {
3584 if (parse_nai_realm(bss
, pos
, line
) < 0)
3586 } else if (os_strcmp(buf
, "anqp_elem") == 0) {
3587 if (parse_anqp_elem(bss
, pos
, line
) < 0)
3589 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
3590 int val
= atoi(pos
);
3593 wpa_printf(MSG_ERROR
,
3594 "Line %d: Invalid gas_frag_limit '%s'",
3598 bss
->gas_frag_limit
= val
;
3599 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
3600 bss
->gas_comeback_delay
= atoi(pos
);
3601 } else if (os_strcmp(buf
, "qos_map_set") == 0) {
3602 if (parse_qos_map_set(bss
, pos
, line
) < 0)
3604 #endif /* CONFIG_INTERWORKING */
3605 #ifdef CONFIG_RADIUS_TEST
3606 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
3607 os_free(bss
->dump_msk_file
);
3608 bss
->dump_msk_file
= os_strdup(pos
);
3609 #endif /* CONFIG_RADIUS_TEST */
3610 #ifdef CONFIG_PROXYARP
3611 } else if (os_strcmp(buf
, "proxy_arp") == 0) {
3612 bss
->proxy_arp
= atoi(pos
);
3613 #endif /* CONFIG_PROXYARP */
3615 } else if (os_strcmp(buf
, "hs20") == 0) {
3616 bss
->hs20
= atoi(pos
);
3617 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
3618 bss
->disable_dgaf
= atoi(pos
);
3619 } else if (os_strcmp(buf
, "na_mcast_to_ucast") == 0) {
3620 bss
->na_mcast_to_ucast
= atoi(pos
);
3621 } else if (os_strcmp(buf
, "osen") == 0) {
3622 bss
->osen
= atoi(pos
);
3623 } else if (os_strcmp(buf
, "anqp_domain_id") == 0) {
3624 bss
->anqp_domain_id
= atoi(pos
);
3625 } else if (os_strcmp(buf
, "hs20_deauth_req_timeout") == 0) {
3626 bss
->hs20_deauth_req_timeout
= atoi(pos
);
3627 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
3628 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
3630 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
3631 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0)
3633 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
3634 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
3637 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
3639 size_t oper_class_len
;
3640 oper_class_len
= os_strlen(pos
);
3641 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
3642 wpa_printf(MSG_ERROR
,
3643 "Line %d: Invalid hs20_operating_class '%s'",
3647 oper_class_len
/= 2;
3648 oper_class
= os_malloc(oper_class_len
);
3649 if (oper_class
== NULL
)
3651 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
3652 wpa_printf(MSG_ERROR
,
3653 "Line %d: Invalid hs20_operating_class '%s'",
3655 os_free(oper_class
);
3658 os_free(bss
->hs20_operating_class
);
3659 bss
->hs20_operating_class
= oper_class
;
3660 bss
->hs20_operating_class_len
= oper_class_len
;
3661 } else if (os_strcmp(buf
, "hs20_icon") == 0) {
3662 if (hs20_parse_icon(bss
, pos
) < 0) {
3663 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_icon '%s'",
3667 } else if (os_strcmp(buf
, "osu_ssid") == 0) {
3668 if (hs20_parse_osu_ssid(bss
, pos
, line
) < 0)
3670 } else if (os_strcmp(buf
, "osu_server_uri") == 0) {
3671 if (hs20_parse_osu_server_uri(bss
, pos
, line
) < 0)
3673 } else if (os_strcmp(buf
, "osu_friendly_name") == 0) {
3674 if (hs20_parse_osu_friendly_name(bss
, pos
, line
) < 0)
3676 } else if (os_strcmp(buf
, "osu_nai") == 0) {
3677 if (hs20_parse_osu_nai(bss
, pos
, line
) < 0)
3679 } else if (os_strcmp(buf
, "osu_method_list") == 0) {
3680 if (hs20_parse_osu_method_list(bss
, pos
, line
) < 0)
3682 } else if (os_strcmp(buf
, "osu_icon") == 0) {
3683 if (hs20_parse_osu_icon(bss
, pos
, line
) < 0)
3685 } else if (os_strcmp(buf
, "osu_service_desc") == 0) {
3686 if (hs20_parse_osu_service_desc(bss
, pos
, line
) < 0)
3688 } else if (os_strcmp(buf
, "operator_icon") == 0) {
3689 if (hs20_parse_operator_icon(bss
, pos
, line
) < 0)
3691 } else if (os_strcmp(buf
, "subscr_remediation_url") == 0) {
3692 os_free(bss
->subscr_remediation_url
);
3693 bss
->subscr_remediation_url
= os_strdup(pos
);
3694 } else if (os_strcmp(buf
, "subscr_remediation_method") == 0) {
3695 bss
->subscr_remediation_method
= atoi(pos
);
3696 } else if (os_strcmp(buf
, "hs20_t_c_filename") == 0) {
3697 os_free(bss
->t_c_filename
);
3698 bss
->t_c_filename
= os_strdup(pos
);
3699 } else if (os_strcmp(buf
, "hs20_t_c_timestamp") == 0) {
3700 bss
->t_c_timestamp
= strtol(pos
, NULL
, 0);
3701 } else if (os_strcmp(buf
, "hs20_t_c_server_url") == 0) {
3702 os_free(bss
->t_c_server_url
);
3703 bss
->t_c_server_url
= os_strdup(pos
);
3704 #endif /* CONFIG_HS20 */
3706 } else if (os_strcmp(buf
, "mbo") == 0) {
3707 bss
->mbo_enabled
= atoi(pos
);
3708 } else if (os_strcmp(buf
, "mbo_cell_data_conn_pref") == 0) {
3709 bss
->mbo_cell_data_conn_pref
= atoi(pos
);
3710 } else if (os_strcmp(buf
, "oce") == 0) {
3711 bss
->oce
= atoi(pos
);
3712 #endif /* CONFIG_MBO */
3713 #ifdef CONFIG_TESTING_OPTIONS
3714 #define PARSE_TEST_PROBABILITY(_val) \
3715 } else if (os_strcmp(buf, #_val) == 0) { \
3718 conf->_val = strtod(pos, &end); \
3719 if (*end || conf->_val < 0.0 || \
3720 conf->_val > 1.0) { \
3721 wpa_printf(MSG_ERROR, \
3722 "Line %d: Invalid value '%s'", \
3726 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
3727 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
3728 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
3729 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
3730 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
3731 } else if (os_strcmp(buf
, "ecsa_ie_only") == 0) {
3732 conf
->ecsa_ie_only
= atoi(pos
);
3733 } else if (os_strcmp(buf
, "bss_load_test") == 0) {
3734 WPA_PUT_LE16(bss
->bss_load_test
, atoi(pos
));
3735 pos
= os_strchr(pos
, ':');
3737 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
3742 bss
->bss_load_test
[2] = atoi(pos
);
3743 pos
= os_strchr(pos
, ':');
3745 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
3750 WPA_PUT_LE16(&bss
->bss_load_test
[3], atoi(pos
));
3751 bss
->bss_load_test_set
= 1;
3752 } else if (os_strcmp(buf
, "radio_measurements") == 0) {
3754 * DEPRECATED: This parameter will be removed in the future.
3755 * Use rrm_neighbor_report instead.
3757 int val
= atoi(pos
);
3760 bss
->radio_measurements
[0] |=
3761 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
3762 } else if (os_strcmp(buf
, "own_ie_override") == 0) {
3764 size_t len
= os_strlen(pos
) / 2;
3766 tmp
= wpabuf_alloc(len
);
3770 if (hexstr2bin(pos
, wpabuf_put(tmp
, len
), len
)) {
3772 wpa_printf(MSG_ERROR
,
3773 "Line %d: Invalid own_ie_override '%s'",
3778 wpabuf_free(bss
->own_ie_override
);
3779 bss
->own_ie_override
= tmp
;
3780 } else if (os_strcmp(buf
, "sae_reflection_attack") == 0) {
3781 bss
->sae_reflection_attack
= atoi(pos
);
3782 } else if (os_strcmp(buf
, "sae_commit_override") == 0) {
3783 wpabuf_free(bss
->sae_commit_override
);
3784 bss
->sae_commit_override
= wpabuf_parse_bin(pos
);
3786 } else if (os_strcmp(buf
, "sae_password") == 0) {
3787 if (parse_sae_password(bss
, pos
) < 0) {
3788 wpa_printf(MSG_ERROR
, "Line %d: Invalid sae_password",
3792 #endif /* CONFIG_SAE */
3793 #endif /* CONFIG_TESTING_OPTIONS */
3794 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
3795 if (parse_wpabuf_hex(line
, buf
, &bss
->vendor_elements
, pos
))
3797 } else if (os_strcmp(buf
, "assocresp_elements") == 0) {
3798 if (parse_wpabuf_hex(line
, buf
, &bss
->assocresp_elements
, pos
))
3800 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
3801 bss
->sae_anti_clogging_threshold
= atoi(pos
);
3802 } else if (os_strcmp(buf
, "sae_sync") == 0) {
3803 bss
->sae_sync
= atoi(pos
);
3804 } else if (os_strcmp(buf
, "sae_groups") == 0) {
3805 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
3806 wpa_printf(MSG_ERROR
,
3807 "Line %d: Invalid sae_groups value '%s'",
3811 } else if (os_strcmp(buf
, "sae_require_mfp") == 0) {
3812 bss
->sae_require_mfp
= atoi(pos
);
3813 } else if (os_strcmp(buf
, "local_pwr_constraint") == 0) {
3814 int val
= atoi(pos
);
3815 if (val
< 0 || val
> 255) {
3816 wpa_printf(MSG_ERROR
, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
3820 conf
->local_pwr_constraint
= val
;
3821 } else if (os_strcmp(buf
, "spectrum_mgmt_required") == 0) {
3822 conf
->spectrum_mgmt_required
= atoi(pos
);
3823 } else if (os_strcmp(buf
, "wowlan_triggers") == 0) {
3824 os_free(bss
->wowlan_triggers
);
3825 bss
->wowlan_triggers
= os_strdup(pos
);
3827 } else if (os_strcmp(buf
, "fst_group_id") == 0) {
3828 size_t len
= os_strlen(pos
);
3830 if (!len
|| len
>= sizeof(conf
->fst_cfg
.group_id
)) {
3831 wpa_printf(MSG_ERROR
,
3832 "Line %d: Invalid fst_group_id value '%s'",
3837 if (conf
->fst_cfg
.group_id
[0]) {
3838 wpa_printf(MSG_ERROR
,
3839 "Line %d: Duplicate fst_group value '%s'",
3844 os_strlcpy(conf
->fst_cfg
.group_id
, pos
,
3845 sizeof(conf
->fst_cfg
.group_id
));
3846 } else if (os_strcmp(buf
, "fst_priority") == 0) {
3851 wpa_printf(MSG_ERROR
,
3852 "Line %d: fst_priority value not supplied (expected 1..%u)",
3853 line
, FST_MAX_PRIO_VALUE
);
3857 val
= strtol(pos
, &endp
, 0);
3858 if (*endp
|| val
< 1 || val
> FST_MAX_PRIO_VALUE
) {
3859 wpa_printf(MSG_ERROR
,
3860 "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)",
3861 line
, val
, pos
, FST_MAX_PRIO_VALUE
);
3864 conf
->fst_cfg
.priority
= (u8
) val
;
3865 } else if (os_strcmp(buf
, "fst_llt") == 0) {
3870 wpa_printf(MSG_ERROR
,
3871 "Line %d: fst_llt value not supplied (expected 1..%u)",
3872 line
, FST_MAX_LLT_MS
);
3875 val
= strtol(pos
, &endp
, 0);
3876 if (*endp
|| val
< 1 ||
3877 (unsigned long int) val
> FST_MAX_LLT_MS
) {
3878 wpa_printf(MSG_ERROR
,
3879 "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
3880 line
, val
, pos
, FST_MAX_LLT_MS
);
3883 conf
->fst_cfg
.llt
= (u32
) val
;
3884 #endif /* CONFIG_FST */
3885 } else if (os_strcmp(buf
, "track_sta_max_num") == 0) {
3886 conf
->track_sta_max_num
= atoi(pos
);
3887 } else if (os_strcmp(buf
, "track_sta_max_age") == 0) {
3888 conf
->track_sta_max_age
= atoi(pos
);
3889 } else if (os_strcmp(buf
, "no_probe_resp_if_seen_on") == 0) {
3890 os_free(bss
->no_probe_resp_if_seen_on
);
3891 bss
->no_probe_resp_if_seen_on
= os_strdup(pos
);
3892 } else if (os_strcmp(buf
, "no_auth_if_seen_on") == 0) {
3893 os_free(bss
->no_auth_if_seen_on
);
3894 bss
->no_auth_if_seen_on
= os_strdup(pos
);
3895 } else if (os_strcmp(buf
, "lci") == 0) {
3896 wpabuf_free(conf
->lci
);
3897 conf
->lci
= wpabuf_parse_bin(pos
);
3898 if (conf
->lci
&& wpabuf_len(conf
->lci
) == 0) {
3899 wpabuf_free(conf
->lci
);
3902 } else if (os_strcmp(buf
, "civic") == 0) {
3903 wpabuf_free(conf
->civic
);
3904 conf
->civic
= wpabuf_parse_bin(pos
);
3905 if (conf
->civic
&& wpabuf_len(conf
->civic
) == 0) {
3906 wpabuf_free(conf
->civic
);
3909 } else if (os_strcmp(buf
, "rrm_neighbor_report") == 0) {
3911 bss
->radio_measurements
[0] |=
3912 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
3913 } else if (os_strcmp(buf
, "rrm_beacon_report") == 0) {
3915 bss
->radio_measurements
[0] |=
3916 WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE
|
3917 WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE
|
3918 WLAN_RRM_CAPS_BEACON_REPORT_TABLE
;
3919 } else if (os_strcmp(buf
, "gas_address3") == 0) {
3920 bss
->gas_address3
= atoi(pos
);
3921 } else if (os_strcmp(buf
, "stationary_ap") == 0) {
3922 conf
->stationary_ap
= atoi(pos
);
3923 } else if (os_strcmp(buf
, "ftm_responder") == 0) {
3924 bss
->ftm_responder
= atoi(pos
);
3925 } else if (os_strcmp(buf
, "ftm_initiator") == 0) {
3926 bss
->ftm_initiator
= atoi(pos
);
3928 } else if (os_strcmp(buf
, "fils_cache_id") == 0) {
3929 if (hexstr2bin(pos
, bss
->fils_cache_id
, FILS_CACHE_ID_LEN
)) {
3930 wpa_printf(MSG_ERROR
,
3931 "Line %d: Invalid fils_cache_id '%s'",
3935 bss
->fils_cache_id_set
= 1;
3936 } else if (os_strcmp(buf
, "fils_realm") == 0) {
3937 if (parse_fils_realm(bss
, pos
) < 0)
3939 } else if (os_strcmp(buf
, "fils_dh_group") == 0) {
3940 bss
->fils_dh_group
= atoi(pos
);
3941 } else if (os_strcmp(buf
, "dhcp_server") == 0) {
3942 if (hostapd_parse_ip_addr(pos
, &bss
->dhcp_server
)) {
3943 wpa_printf(MSG_ERROR
,
3944 "Line %d: invalid IP address '%s'",
3948 } else if (os_strcmp(buf
, "dhcp_rapid_commit_proxy") == 0) {
3949 bss
->dhcp_rapid_commit_proxy
= atoi(pos
);
3950 } else if (os_strcmp(buf
, "fils_hlp_wait_time") == 0) {
3951 bss
->fils_hlp_wait_time
= atoi(pos
);
3952 } else if (os_strcmp(buf
, "dhcp_server_port") == 0) {
3953 bss
->dhcp_server_port
= atoi(pos
);
3954 } else if (os_strcmp(buf
, "dhcp_relay_port") == 0) {
3955 bss
->dhcp_relay_port
= atoi(pos
);
3956 #endif /* CONFIG_FILS */
3957 } else if (os_strcmp(buf
, "multicast_to_unicast") == 0) {
3958 bss
->multicast_to_unicast
= atoi(pos
);
3959 } else if (os_strcmp(buf
, "broadcast_deauth") == 0) {
3960 bss
->broadcast_deauth
= atoi(pos
);
3962 } else if (os_strcmp(buf
, "dpp_connector") == 0) {
3963 os_free(bss
->dpp_connector
);
3964 bss
->dpp_connector
= os_strdup(pos
);
3965 } else if (os_strcmp(buf
, "dpp_netaccesskey") == 0) {
3966 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_netaccesskey
, pos
))
3968 } else if (os_strcmp(buf
, "dpp_netaccesskey_expiry") == 0) {
3969 bss
->dpp_netaccesskey_expiry
= strtol(pos
, NULL
, 0);
3970 } else if (os_strcmp(buf
, "dpp_csign") == 0) {
3971 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_csign
, pos
))
3973 #endif /* CONFIG_DPP */
3975 } else if (os_strcmp(buf
, "owe_transition_bssid") == 0) {
3976 if (hwaddr_aton(pos
, bss
->owe_transition_bssid
)) {
3977 wpa_printf(MSG_ERROR
,
3978 "Line %d: invalid owe_transition_bssid",
3982 } else if (os_strcmp(buf
, "owe_transition_ssid") == 0) {
3984 char *str
= wpa_config_parse_string(pos
, &slen
);
3986 if (!str
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
3987 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
3992 os_memcpy(bss
->owe_transition_ssid
, str
, slen
);
3993 bss
->owe_transition_ssid_len
= slen
;
3995 } else if (os_strcmp(buf
, "owe_transition_ifname") == 0) {
3996 os_strlcpy(bss
->owe_transition_ifname
, pos
,
3997 sizeof(bss
->owe_transition_ifname
));
3998 } else if (os_strcmp(buf
, "owe_groups") == 0) {
3999 if (hostapd_parse_intlist(&bss
->owe_groups
, pos
)) {
4000 wpa_printf(MSG_ERROR
,
4001 "Line %d: Invalid owe_groups value '%s'",
4005 #endif /* CONFIG_OWE */
4007 wpa_printf(MSG_ERROR
,
4008 "Line %d: unknown configuration item '%s'",
4018 * hostapd_config_read - Read and parse a configuration file
4019 * @fname: Configuration file name (including path, if needed)
4020 * Returns: Allocated configuration data structure
4022 struct hostapd_config
* hostapd_config_read(const char *fname
)
4024 struct hostapd_config
*conf
;
4026 char buf
[4096], *pos
;
4031 f
= fopen(fname
, "r");
4033 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
4034 "for reading.", fname
);
4038 conf
= hostapd_config_defaults();
4044 /* set default driver based on configuration */
4045 conf
->driver
= wpa_drivers
[0];
4046 if (conf
->driver
== NULL
) {
4047 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
4048 hostapd_config_free(conf
);
4053 conf
->last_bss
= conf
->bss
[0];
4055 while (fgets(buf
, sizeof(buf
), f
)) {
4056 struct hostapd_bss_config
*bss
;
4058 bss
= conf
->last_bss
;
4064 while (*pos
!= '\0') {
4074 pos
= os_strchr(buf
, '=');
4076 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
4083 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
4088 for (i
= 0; i
< conf
->num_bss
; i
++)
4089 hostapd_set_security_params(conf
->bss
[i
], 1);
4091 if (hostapd_config_check(conf
, 1))
4094 #ifndef WPA_IGNORE_CONFIG_ERRORS
4096 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
4097 "'%s'", errors
, fname
);
4098 hostapd_config_free(conf
);
4101 #endif /* WPA_IGNORE_CONFIG_ERRORS */
4107 int hostapd_set_iface(struct hostapd_config
*conf
,
4108 struct hostapd_bss_config
*bss
, const char *field
,
4114 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
4116 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
4117 "to value '%s'", field
, value
);
4121 for (i
= 0; i
< conf
->num_bss
; i
++)
4122 hostapd_set_security_params(conf
->bss
[i
], 0);
4124 if (hostapd_config_check(conf
, 0)) {
4125 wpa_printf(MSG_ERROR
, "Configuration check failed");