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 "drivers/driver.h"
19 #include "eap_server/eap.h"
20 #include "radius/radius_client.h"
21 #include "ap/wpa_auth.h"
22 #include "ap/ap_config.h"
23 #include "config_file.h"
26 #ifndef CONFIG_NO_RADIUS
28 static struct hostapd_radius_attr
*
29 hostapd_parse_radius_attr(const char *value
);
30 #endif /* EAP_SERVER */
31 #endif /* CONFIG_NO_RADIUS */
34 #ifndef CONFIG_NO_VLAN
35 static int hostapd_config_read_vlan_file(struct hostapd_bss_config
*bss
,
39 char buf
[128], *pos
, *pos2
;
40 int line
= 0, vlan_id
;
41 struct hostapd_vlan
*vlan
;
43 f
= fopen(fname
, "r");
45 wpa_printf(MSG_ERROR
, "VLAN file '%s' not readable.", fname
);
49 while (fgets(buf
, sizeof(buf
), f
)) {
55 while (*pos
!= '\0') {
66 vlan_id
= VLAN_ID_WILDCARD
;
69 vlan_id
= strtol(buf
, &pos
, 10);
70 if (buf
== pos
|| vlan_id
< 1 ||
71 vlan_id
> MAX_VLAN_ID
) {
72 wpa_printf(MSG_ERROR
, "Invalid VLAN ID at "
73 "line %d in '%s'", line
, fname
);
79 while (*pos
== ' ' || *pos
== '\t')
82 while (*pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '\0')
85 if (*pos
== '\0' || os_strlen(pos
) > IFNAMSIZ
) {
86 wpa_printf(MSG_ERROR
, "Invalid VLAN ifname at line %d "
87 "in '%s'", line
, fname
);
92 vlan
= os_zalloc(sizeof(*vlan
));
94 wpa_printf(MSG_ERROR
, "Out of memory while reading "
95 "VLAN interfaces from '%s'", fname
);
100 vlan
->vlan_id
= vlan_id
;
101 vlan
->vlan_desc
.untagged
= vlan_id
;
102 vlan
->vlan_desc
.notempty
= !!vlan_id
;
103 os_strlcpy(vlan
->ifname
, pos
, sizeof(vlan
->ifname
));
104 vlan
->next
= bss
->vlan
;
112 #endif /* CONFIG_NO_VLAN */
115 static int hostapd_acl_comp(const void *a
, const void *b
)
117 const struct mac_acl_entry
*aa
= a
;
118 const struct mac_acl_entry
*bb
= b
;
119 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
123 static int hostapd_config_read_maclist(const char *fname
,
124 struct mac_acl_entry
**acl
, int *num
)
130 struct mac_acl_entry
*newacl
;
133 f
= fopen(fname
, "r");
135 wpa_printf(MSG_ERROR
, "MAC list file '%s' not found.", fname
);
139 while (fgets(buf
, sizeof(buf
), f
)) {
147 while (*pos
!= '\0') {
162 if (hwaddr_aton(pos
, addr
)) {
163 wpa_printf(MSG_ERROR
, "Invalid MAC address '%s' at "
164 "line %d in '%s'", pos
, line
, fname
);
172 if (os_memcmp((*acl
)[i
].addr
, addr
, ETH_ALEN
) ==
174 os_remove_in_array(*acl
, *num
,
184 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
186 while (*pos
== ' ' || *pos
== '\t')
191 newacl
= os_realloc_array(*acl
, *num
+ 1, sizeof(**acl
));
192 if (newacl
== NULL
) {
193 wpa_printf(MSG_ERROR
, "MAC list reallocation failed");
199 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
200 os_memset(&(*acl
)[*num
].vlan_id
, 0,
201 sizeof((*acl
)[*num
].vlan_id
));
202 (*acl
)[*num
].vlan_id
.untagged
= vlan_id
;
203 (*acl
)[*num
].vlan_id
.notempty
= !!vlan_id
;
210 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
217 static int hostapd_config_read_eap_user(const char *fname
,
218 struct hostapd_bss_config
*conf
)
221 char buf
[512], *pos
, *start
, *pos2
;
222 int line
= 0, ret
= 0, num_methods
;
223 struct hostapd_eap_user
*user
= NULL
, *tail
= NULL
, *new_user
= NULL
;
225 if (os_strncmp(fname
, "sqlite:", 7) == 0) {
227 os_free(conf
->eap_user_sqlite
);
228 conf
->eap_user_sqlite
= os_strdup(fname
+ 7);
230 #else /* CONFIG_SQLITE */
231 wpa_printf(MSG_ERROR
,
232 "EAP user file in SQLite DB, but CONFIG_SQLITE was not enabled in the build.");
234 #endif /* CONFIG_SQLITE */
237 f
= fopen(fname
, "r");
239 wpa_printf(MSG_ERROR
, "EAP user file '%s' not found.", fname
);
243 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
244 while (fgets(buf
, sizeof(buf
), f
)) {
250 while (*pos
!= '\0') {
260 #ifndef CONFIG_NO_RADIUS
261 if (user
&& os_strncmp(buf
, "radius_accept_attr=", 19) == 0) {
262 struct hostapd_radius_attr
*attr
, *a
;
263 attr
= hostapd_parse_radius_attr(buf
+ 19);
265 wpa_printf(MSG_ERROR
, "Invalid radius_auth_req_attr: %s",
267 user
= NULL
; /* already in the BSS list */
270 if (user
->accept_attr
== NULL
) {
271 user
->accept_attr
= attr
;
273 a
= user
->accept_attr
;
280 #endif /* CONFIG_NO_RADIUS */
284 if (buf
[0] != '"' && buf
[0] != '*') {
285 wpa_printf(MSG_ERROR
, "Invalid EAP identity (no \" in "
286 "start) on line %d in '%s'", line
, fname
);
290 user
= os_zalloc(sizeof(*user
));
292 wpa_printf(MSG_ERROR
, "EAP user allocation failed");
295 user
->force_version
= -1;
302 while (*pos
!= '"' && *pos
!= '\0')
305 wpa_printf(MSG_ERROR
, "Invalid EAP identity "
306 "(no \" in end) on line %d in '%s'",
311 user
->identity
= os_memdup(start
, pos
- start
);
312 if (user
->identity
== NULL
) {
313 wpa_printf(MSG_ERROR
, "Failed to allocate "
314 "memory for EAP identity");
317 user
->identity_len
= pos
- start
;
319 if (pos
[0] == '"' && pos
[1] == '*') {
320 user
->wildcard_prefix
= 1;
325 while (*pos
== ' ' || *pos
== '\t')
329 wpa_printf(MSG_ERROR
, "No EAP method on line %d in "
330 "'%s'", line
, fname
);
335 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
345 char *pos3
= os_strchr(start
, ',');
349 user
->methods
[num_methods
].method
=
352 &user
->methods
[num_methods
].vendor
);
353 if (user
->methods
[num_methods
].vendor
==
355 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
357 if (os_strcmp(start
, "TTLS-PAP") == 0) {
358 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
361 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
362 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
365 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
367 EAP_TTLS_AUTH_MSCHAP
;
370 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
372 EAP_TTLS_AUTH_MSCHAPV2
;
375 if (os_strcmp(start
, "MACACL") == 0) {
379 wpa_printf(MSG_ERROR
, "Unsupported EAP type "
380 "'%s' on line %d in '%s'",
386 if (num_methods
>= EAP_MAX_METHODS
)
393 if (num_methods
== 0 && user
->ttls_auth
== 0 && !user
->macacl
) {
394 wpa_printf(MSG_ERROR
, "No EAP types configured on "
395 "line %d in '%s'", line
, fname
);
402 while (*pos
== ' ' || *pos
== '\t')
407 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
408 user
->force_version
= 0;
412 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
413 user
->force_version
= 1;
417 if (os_strncmp(pos
, "[2]", 3) == 0) {
425 while (*pos
!= '"' && *pos
!= '\0')
428 wpa_printf(MSG_ERROR
, "Invalid EAP password "
429 "(no \" in end) on line %d in '%s'",
434 user
->password
= os_memdup(start
, pos
- start
);
435 if (user
->password
== NULL
) {
436 wpa_printf(MSG_ERROR
, "Failed to allocate "
437 "memory for EAP password");
440 user
->password_len
= pos
- start
;
443 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
446 while (*pos2
!= '\0' && *pos2
!= ' ' &&
447 *pos2
!= '\t' && *pos2
!= '#')
449 if (pos2
- pos
!= 32) {
450 wpa_printf(MSG_ERROR
, "Invalid password hash "
451 "on line %d in '%s'", line
, fname
);
454 user
->password
= os_malloc(16);
455 if (user
->password
== NULL
) {
456 wpa_printf(MSG_ERROR
, "Failed to allocate "
457 "memory for EAP password hash");
460 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
461 wpa_printf(MSG_ERROR
, "Invalid hash password "
462 "on line %d in '%s'", line
, fname
);
465 user
->password_len
= 16;
466 user
->password_hash
= 1;
470 while (*pos2
!= '\0' && *pos2
!= ' ' &&
471 *pos2
!= '\t' && *pos2
!= '#')
473 if ((pos2
- pos
) & 1) {
474 wpa_printf(MSG_ERROR
, "Invalid hex password "
475 "on line %d in '%s'", line
, fname
);
478 user
->password
= os_malloc((pos2
- pos
) / 2);
479 if (user
->password
== NULL
) {
480 wpa_printf(MSG_ERROR
, "Failed to allocate "
481 "memory for EAP password");
484 if (hexstr2bin(pos
, user
->password
,
485 (pos2
- pos
) / 2) < 0) {
486 wpa_printf(MSG_ERROR
, "Invalid hex password "
487 "on line %d in '%s'", line
, fname
);
490 user
->password_len
= (pos2
- pos
) / 2;
494 while (*pos
== ' ' || *pos
== '\t')
496 if (os_strncmp(pos
, "[2]", 3) == 0) {
502 tail
= new_user
= user
;
511 hostapd_config_free_eap_user(user
);
519 hostapd_config_free_eap_users(conf
->eap_user
);
520 conf
->eap_user
= new_user
;
522 hostapd_config_free_eap_users(new_user
);
527 #endif /* EAP_SERVER */
530 #ifndef CONFIG_NO_RADIUS
532 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
533 int *num_server
, const char *val
, int def_port
,
534 struct hostapd_radius_server
**curr_serv
)
536 struct hostapd_radius_server
*nserv
;
538 static int server_index
= 1;
540 nserv
= os_realloc_array(*server
, *num_server
+ 1, sizeof(*nserv
));
545 nserv
= &nserv
[*num_server
];
547 (*curr_serv
) = nserv
;
549 os_memset(nserv
, 0, sizeof(*nserv
));
550 nserv
->port
= def_port
;
551 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
552 nserv
->index
= server_index
++;
558 static struct hostapd_radius_attr
*
559 hostapd_parse_radius_attr(const char *value
)
563 struct hostapd_radius_attr
*attr
;
566 attr
= os_zalloc(sizeof(*attr
));
570 attr
->type
= atoi(value
);
572 pos
= os_strchr(value
, ':');
574 attr
->val
= wpabuf_alloc(1);
575 if (attr
->val
== NULL
) {
579 wpabuf_put_u8(attr
->val
, 0);
584 if (pos
[0] == '\0' || pos
[1] != ':') {
593 attr
->val
= wpabuf_alloc_copy(pos
, os_strlen(pos
));
596 len
= os_strlen(pos
);
600 attr
->val
= wpabuf_alloc(len
);
601 if (attr
->val
== NULL
)
603 if (hexstr2bin(pos
, wpabuf_put(attr
->val
, len
), len
) < 0) {
604 wpabuf_free(attr
->val
);
610 attr
->val
= wpabuf_alloc(4);
612 wpabuf_put_be32(attr
->val
, atoi(pos
));
619 if (attr
->val
== NULL
) {
628 static int hostapd_parse_das_client(struct hostapd_bss_config
*bss
, char *val
)
632 secret
= os_strchr(val
, ' ');
638 if (hostapd_parse_ip_addr(val
, &bss
->radius_das_client_addr
))
641 os_free(bss
->radius_das_shared_secret
);
642 bss
->radius_das_shared_secret
= (u8
*) os_strdup(secret
);
643 if (bss
->radius_das_shared_secret
== NULL
)
645 bss
->radius_das_shared_secret_len
= os_strlen(secret
);
649 #endif /* CONFIG_NO_RADIUS */
652 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
655 char *start
, *end
, *buf
;
657 buf
= os_strdup(value
);
662 while (*start
!= '\0') {
663 while (*start
== ' ' || *start
== '\t')
668 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
672 if (os_strcmp(start
, "WPA-PSK") == 0)
673 val
|= WPA_KEY_MGMT_PSK
;
674 else if (os_strcmp(start
, "WPA-EAP") == 0)
675 val
|= WPA_KEY_MGMT_IEEE8021X
;
676 #ifdef CONFIG_IEEE80211R_AP
677 else if (os_strcmp(start
, "FT-PSK") == 0)
678 val
|= WPA_KEY_MGMT_FT_PSK
;
679 else if (os_strcmp(start
, "FT-EAP") == 0)
680 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
681 #endif /* CONFIG_IEEE80211R_AP */
682 #ifdef CONFIG_IEEE80211W
683 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
684 val
|= WPA_KEY_MGMT_PSK_SHA256
;
685 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
686 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
687 #endif /* CONFIG_IEEE80211W */
689 else if (os_strcmp(start
, "SAE") == 0)
690 val
|= WPA_KEY_MGMT_SAE
;
691 else if (os_strcmp(start
, "FT-SAE") == 0)
692 val
|= WPA_KEY_MGMT_FT_SAE
;
693 #endif /* CONFIG_SAE */
695 else if (os_strcmp(start
, "WPA-EAP-SUITE-B") == 0)
696 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B
;
697 #endif /* CONFIG_SUITEB */
698 #ifdef CONFIG_SUITEB192
699 else if (os_strcmp(start
, "WPA-EAP-SUITE-B-192") == 0)
700 val
|= WPA_KEY_MGMT_IEEE8021X_SUITE_B_192
;
701 #endif /* CONFIG_SUITEB192 */
703 else if (os_strcmp(start
, "FILS-SHA256") == 0)
704 val
|= WPA_KEY_MGMT_FILS_SHA256
;
705 else if (os_strcmp(start
, "FILS-SHA384") == 0)
706 val
|= WPA_KEY_MGMT_FILS_SHA384
;
707 #ifdef CONFIG_IEEE80211R_AP
708 else if (os_strcmp(start
, "FT-FILS-SHA256") == 0)
709 val
|= WPA_KEY_MGMT_FT_FILS_SHA256
;
710 else if (os_strcmp(start
, "FT-FILS-SHA384") == 0)
711 val
|= WPA_KEY_MGMT_FT_FILS_SHA384
;
712 #endif /* CONFIG_IEEE80211R_AP */
713 #endif /* CONFIG_FILS */
715 else if (os_strcmp(start
, "OWE") == 0)
716 val
|= WPA_KEY_MGMT_OWE
;
717 #endif /* CONFIG_OWE */
719 else if (os_strcmp(start
, "DPP") == 0)
720 val
|= WPA_KEY_MGMT_DPP
;
721 #endif /* CONFIG_DPP */
723 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
736 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
737 "configured.", line
);
745 static int hostapd_config_parse_cipher(int line
, const char *value
)
747 int val
= wpa_parse_cipher(value
);
749 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
754 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
762 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
765 size_t len
= os_strlen(val
);
767 if (keyidx
< 0 || keyidx
> 3)
773 bin_clear_free(wep
->key
[keyidx
], wep
->len
[keyidx
]);
774 wep
->key
[keyidx
] = NULL
;
775 wep
->len
[keyidx
] = 0;
776 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
785 if (wep
->key
[keyidx
] != NULL
)
789 if (len
< 2 || val
[len
- 1] != '"')
792 wep
->key
[keyidx
] = os_memdup(val
+ 1, len
);
793 if (wep
->key
[keyidx
] == NULL
)
795 wep
->len
[keyidx
] = len
;
800 wep
->key
[keyidx
] = os_malloc(len
);
801 if (wep
->key
[keyidx
] == NULL
)
803 wep
->len
[keyidx
] = len
;
804 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
814 static int hostapd_parse_chanlist(struct hostapd_config
*conf
, char *val
)
818 /* for backwards compatibility, translate ' ' in conf str to ',' */
821 pos
= os_strchr(pos
, ' ');
825 if (freq_range_list_parse(&conf
->acs_ch_list
, val
))
832 static int hostapd_parse_intlist(int **int_list
, char *val
)
843 while (*pos
!= '\0') {
849 list
= os_malloc(sizeof(int) * (count
+ 2));
854 while (*pos
!= '\0') {
855 end
= os_strchr(pos
, ' ');
859 list
[count
++] = atoi(pos
);
871 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
873 struct hostapd_bss_config
**all
, *bss
;
878 all
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
879 sizeof(struct hostapd_bss_config
*));
881 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
887 bss
= os_zalloc(sizeof(*bss
));
890 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
891 if (bss
->radius
== NULL
) {
892 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
893 "multi-BSS RADIUS data");
898 conf
->bss
[conf
->num_bss
++] = bss
;
899 conf
->last_bss
= bss
;
901 hostapd_config_defaults_bss(bss
);
902 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
903 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
909 /* convert floats with one decimal place to value*10 int, i.e.,
910 * "1.5" will return 15 */
911 static int hostapd_config_read_int10(const char *value
)
917 pos
= os_strchr(value
, '.');
921 if (*pos
>= '0' && *pos
<= '9')
929 static int valid_cw(int cw
)
931 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
932 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023 ||
933 cw
== 2047 || cw
== 4095 || cw
== 8191 || cw
== 16383 ||
939 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
940 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
941 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
942 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
945 static int hostapd_config_tx_queue(struct hostapd_config
*conf
,
946 const char *name
, const char *val
)
950 struct hostapd_tx_queue_params
*queue
;
952 /* skip 'tx_queue_' prefix */
954 if (os_strncmp(pos
, "data", 4) == 0 &&
955 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
958 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
959 os_strncmp(pos
, "beacon_", 7) == 0) {
960 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
963 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
967 if (num
>= NUM_TX_QUEUES
) {
968 /* for backwards compatibility, do not trigger failure */
969 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
973 queue
= &conf
->tx_queue
[num
];
975 if (os_strcmp(pos
, "aifs") == 0) {
976 queue
->aifs
= atoi(val
);
977 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
978 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
982 } else if (os_strcmp(pos
, "cwmin") == 0) {
983 queue
->cwmin
= atoi(val
);
984 if (!valid_cw(queue
->cwmin
)) {
985 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
989 } else if (os_strcmp(pos
, "cwmax") == 0) {
990 queue
->cwmax
= atoi(val
);
991 if (!valid_cw(queue
->cwmax
)) {
992 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
996 } else if (os_strcmp(pos
, "burst") == 0) {
997 queue
->burst
= hostapd_config_read_int10(val
);
999 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
1007 #ifdef CONFIG_IEEE80211R_AP
1009 static int rkh_derive_key(const char *pos
, u8
*key
, size_t key_len
)
1014 if (!hexstr2bin(pos
, key
, key_len
))
1017 /* Try to use old short key for backwards compatibility */
1018 if (hexstr2bin(pos
, oldkey
, sizeof(oldkey
)))
1021 ret
= hmac_sha256_kdf(oldkey
, sizeof(oldkey
), "FT OLDKEY", NULL
, 0,
1023 os_memset(oldkey
, 0, sizeof(oldkey
));
1028 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
1030 struct ft_remote_r0kh
*r0kh
;
1033 r0kh
= os_zalloc(sizeof(*r0kh
));
1037 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1039 next
= os_strchr(pos
, ' ');
1042 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
1043 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
1049 next
= os_strchr(pos
, ' ');
1052 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
1053 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
1057 r0kh
->id_len
= next
- pos
- 1;
1058 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
1061 if (rkh_derive_key(pos
, r0kh
->key
, sizeof(r0kh
->key
)) < 0) {
1062 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
1067 r0kh
->next
= bss
->r0kh_list
;
1068 bss
->r0kh_list
= r0kh
;
1074 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
1076 struct ft_remote_r1kh
*r1kh
;
1079 r1kh
= os_zalloc(sizeof(*r1kh
));
1083 /* 02:01:02:03:04:05 02:01:02:03:04:05
1084 * 000102030405060708090a0b0c0d0e0f */
1086 next
= os_strchr(pos
, ' ');
1089 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
1090 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
1096 next
= os_strchr(pos
, ' ');
1099 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
1100 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
1106 if (rkh_derive_key(pos
, r1kh
->key
, sizeof(r1kh
->key
)) < 0) {
1107 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
1112 r1kh
->next
= bss
->r1kh_list
;
1113 bss
->r1kh_list
= r1kh
;
1117 #endif /* CONFIG_IEEE80211R_AP */
1120 #ifdef CONFIG_IEEE80211N
1121 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
1124 if (os_strstr(capab
, "[LDPC]"))
1125 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
1126 if (os_strstr(capab
, "[HT40-]")) {
1127 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1128 conf
->secondary_channel
= -1;
1130 if (os_strstr(capab
, "[HT40+]")) {
1131 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1132 conf
->secondary_channel
= 1;
1134 if (os_strstr(capab
, "[HT40+]") && os_strstr(capab
, "[HT40-]")) {
1135 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1136 conf
->ht40_plus_minus_allowed
= 1;
1138 if (os_strstr(capab
, "[SMPS-STATIC]")) {
1139 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1140 conf
->ht_capab
|= HT_CAP_INFO_SMPS_STATIC
;
1142 if (os_strstr(capab
, "[SMPS-DYNAMIC]")) {
1143 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1144 conf
->ht_capab
|= HT_CAP_INFO_SMPS_DYNAMIC
;
1146 if (os_strstr(capab
, "[GF]"))
1147 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
1148 if (os_strstr(capab
, "[SHORT-GI-20]"))
1149 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1150 if (os_strstr(capab
, "[SHORT-GI-40]"))
1151 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1152 if (os_strstr(capab
, "[TX-STBC]"))
1153 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1154 if (os_strstr(capab
, "[RX-STBC1]")) {
1155 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1156 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1158 if (os_strstr(capab
, "[RX-STBC12]")) {
1159 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1160 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1162 if (os_strstr(capab
, "[RX-STBC123]")) {
1163 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1164 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1166 if (os_strstr(capab
, "[DELAYED-BA]"))
1167 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1168 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1169 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1170 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1171 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1172 if (os_strstr(capab
, "[40-INTOLERANT]"))
1173 conf
->ht_capab
|= HT_CAP_INFO_40MHZ_INTOLERANT
;
1174 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1175 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1179 #endif /* CONFIG_IEEE80211N */
1182 #ifdef CONFIG_IEEE80211AC
1183 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1186 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1187 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1188 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1189 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1190 if (os_strstr(capab
, "[VHT160]"))
1191 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1192 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1193 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1194 if (os_strstr(capab
, "[RXLDPC]"))
1195 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1196 if (os_strstr(capab
, "[SHORT-GI-80]"))
1197 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1198 if (os_strstr(capab
, "[SHORT-GI-160]"))
1199 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1200 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1201 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1202 if (os_strstr(capab
, "[RX-STBC-1]"))
1203 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1204 if (os_strstr(capab
, "[RX-STBC-12]"))
1205 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1206 if (os_strstr(capab
, "[RX-STBC-123]"))
1207 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1208 if (os_strstr(capab
, "[RX-STBC-1234]"))
1209 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1210 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1211 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMER_CAPABLE
;
1212 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1213 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
1214 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1215 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1216 conf
->vht_capab
|= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1217 if (os_strstr(capab
, "[BF-ANTENNA-3]") &&
1218 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1219 conf
->vht_capab
|= (2 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1220 if (os_strstr(capab
, "[BF-ANTENNA-4]") &&
1221 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1222 conf
->vht_capab
|= (3 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1223 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1224 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1225 conf
->vht_capab
|= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1226 if (os_strstr(capab
, "[SOUNDING-DIMENSION-3]") &&
1227 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1228 conf
->vht_capab
|= (2 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1229 if (os_strstr(capab
, "[SOUNDING-DIMENSION-4]") &&
1230 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1231 conf
->vht_capab
|= (3 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1232 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1233 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1234 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1235 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1236 if (os_strstr(capab
, "[HTC-VHT]"))
1237 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1238 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP7]"))
1239 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MAX
;
1240 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP6]"))
1241 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_6
;
1242 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP5]"))
1243 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_5
;
1244 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP4]"))
1245 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_4
;
1246 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP3]"))
1247 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_3
;
1248 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP2]"))
1249 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_2
;
1250 else if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP1]"))
1251 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_1
;
1252 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1253 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1254 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1255 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1256 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1257 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1258 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1259 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1260 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1261 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1264 #endif /* CONFIG_IEEE80211AC */
1267 #ifdef CONFIG_INTERWORKING
1268 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1271 size_t len
= os_strlen(pos
);
1272 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1274 struct hostapd_roaming_consortium
*rc
;
1276 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1277 hexstr2bin(pos
, oi
, len
/ 2)) {
1278 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1284 rc
= os_realloc_array(bss
->roaming_consortium
,
1285 bss
->roaming_consortium_count
+ 1,
1286 sizeof(struct hostapd_roaming_consortium
));
1290 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1291 rc
[bss
->roaming_consortium_count
].len
= len
;
1293 bss
->roaming_consortium
= rc
;
1294 bss
->roaming_consortium_count
++;
1300 static int parse_lang_string(struct hostapd_lang_string
**array
,
1301 unsigned int *count
, char *pos
)
1303 char *sep
, *str
= NULL
;
1304 size_t clen
, nlen
, slen
;
1305 struct hostapd_lang_string
*ls
;
1308 if (*pos
== '"' || (*pos
== 'P' && pos
[1] == '"')) {
1309 str
= wpa_config_parse_string(pos
, &slen
);
1315 sep
= os_strchr(pos
, ':');
1320 clen
= os_strlen(pos
);
1321 if (clen
< 2 || clen
> sizeof(ls
->lang
))
1323 nlen
= os_strlen(sep
);
1327 ls
= os_realloc_array(*array
, *count
+ 1,
1328 sizeof(struct hostapd_lang_string
));
1333 ls
= &(*array
)[*count
];
1336 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1337 os_memcpy(ls
->lang
, pos
, clen
);
1338 ls
->name_len
= nlen
;
1339 os_memcpy(ls
->name
, sep
, nlen
);
1348 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1351 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1352 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1360 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1365 u8
*info
= NULL
, *ipos
;
1367 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1370 for (pos
= buf
; *pos
; pos
++) {
1371 if ((*pos
< '0' || *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1376 if (1 + count
* 3 > 0x7f)
1379 info
= os_zalloc(2 + 3 + count
* 3);
1384 *ipos
++ = 0; /* GUD - Version 1 */
1385 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1386 *ipos
++ = 0; /* PLMN List IEI */
1387 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1388 *ipos
++ = 1 + count
* 3;
1389 *ipos
++ = count
; /* Number of PLMNs */
1392 while (pos
&& *pos
) {
1397 mnc
= os_strchr(pos
, ',');
1401 pos
= os_strchr(mnc
, ';');
1405 mnc_len
= os_strlen(mnc
);
1406 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1409 /* BC coded MCC,MNC */
1410 /* MCC digit 2 | MCC digit 1 */
1411 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1412 /* MNC digit 3 | MCC digit 3 */
1413 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1415 /* MNC digit 2 | MNC digit 1 */
1416 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1419 os_free(bss
->anqp_3gpp_cell_net
);
1420 bss
->anqp_3gpp_cell_net
= info
;
1421 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1422 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1423 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1428 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1435 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1437 struct hostapd_nai_realm_data
*realm
;
1440 char *pos
, *end
, *rpos
;
1442 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1444 if (offsets
== NULL
)
1447 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1448 realm
= &bss
->nai_realm_data
[i
];
1449 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1450 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1452 realm
->realm
[j
] - realm
->realm_buf
: -1;
1456 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1457 sizeof(struct hostapd_nai_realm_data
));
1458 if (realm
== NULL
) {
1462 bss
->nai_realm_data
= realm
;
1464 /* patch the pointers after realloc */
1465 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1466 realm
= &bss
->nai_realm_data
[i
];
1467 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1468 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1470 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1472 realm
->realm
[j
] = NULL
;
1477 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1478 os_memset(realm
, 0, sizeof(*realm
));
1481 realm
->encoding
= atoi(pos
);
1482 pos
= os_strchr(pos
, ',');
1487 end
= os_strchr(pos
, ',');
1492 len
= os_strlen(pos
);
1495 if (len
> MAX_NAI_REALMLEN
) {
1496 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1497 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1500 os_memcpy(realm
->realm_buf
, pos
, len
);
1507 while (pos
&& *pos
) {
1508 struct hostapd_nai_realm_eap
*eap
;
1510 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1511 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1515 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1516 realm
->eap_method_count
++;
1518 end
= os_strchr(pos
, ',');
1520 end
= pos
+ os_strlen(pos
);
1522 eap
->eap_method
= atoi(pos
);
1524 pos
= os_strchr(pos
, '[');
1525 if (pos
== NULL
|| pos
> end
)
1528 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1529 wpa_printf(MSG_ERROR
, "Too many auth params");
1532 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1533 pos
= os_strchr(pos
, ':');
1534 if (pos
== NULL
|| pos
> end
)
1537 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1538 pos
= os_strchr(pos
, ']');
1539 if (pos
== NULL
|| pos
> end
)
1551 /* Split realm list into null terminated realms */
1552 rpos
= realm
->realm_buf
;
1555 if (i
>= MAX_NAI_REALMS
) {
1556 wpa_printf(MSG_ERROR
, "Too many realms");
1559 realm
->realm
[i
++] = rpos
;
1560 rpos
= os_strchr(rpos
, ';');
1566 bss
->nai_realm_count
++;
1571 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1576 static int parse_anqp_elem(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1581 struct wpabuf
*payload
;
1582 struct anqp_element
*elem
;
1584 delim
= os_strchr(buf
, ':');
1589 len
= os_strlen(delim
);
1593 payload
= wpabuf_alloc(len
);
1596 if (hexstr2bin(delim
, wpabuf_put(payload
, len
), len
) < 0) {
1597 wpabuf_free(payload
);
1601 dl_list_for_each(elem
, &bss
->anqp_elem
, struct anqp_element
, list
) {
1602 if (elem
->infoid
== infoid
) {
1603 /* Update existing entry */
1604 wpabuf_free(elem
->payload
);
1605 elem
->payload
= payload
;
1610 /* Add a new entry */
1611 elem
= os_zalloc(sizeof(*elem
));
1613 wpabuf_free(payload
);
1616 elem
->infoid
= infoid
;
1617 elem
->payload
= payload
;
1618 dl_list_add(&bss
->anqp_elem
, &elem
->list
);
1624 static int parse_qos_map_set(struct hostapd_bss_config
*bss
,
1625 char *buf
, int line
)
1627 u8 qos_map_set
[16 + 2 * 21], count
= 0;
1632 if (count
== sizeof(qos_map_set
)) {
1633 wpa_printf(MSG_ERROR
, "Line %d: Too many qos_map_set "
1634 "parameters '%s'", line
, buf
);
1639 if (val
> 255 || val
< 0) {
1640 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set "
1645 qos_map_set
[count
++] = val
;
1646 pos
= os_strchr(pos
, ',');
1652 if (count
< 16 || count
& 1) {
1653 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set '%s'",
1658 os_memcpy(bss
->qos_map_set
, qos_map_set
, count
);
1659 bss
->qos_map_set_len
= count
;
1664 #endif /* CONFIG_INTERWORKING */
1668 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1674 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1677 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1678 bss
->hs20_connection_capability_len
+ 4);
1679 if (conn_cap
== NULL
)
1682 bss
->hs20_connection_capability
= conn_cap
;
1683 conn_cap
+= bss
->hs20_connection_capability_len
;
1685 conn_cap
[0] = atoi(pos
);
1686 pos
= os_strchr(pos
, ':');
1690 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1691 pos
= os_strchr(pos
, ':');
1695 conn_cap
[3] = atoi(pos
);
1696 bss
->hs20_connection_capability_len
+= 4;
1702 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1708 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1710 wan_metrics
= os_zalloc(13);
1711 if (wan_metrics
== NULL
)
1716 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1723 /* Downlink Speed */
1724 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1725 pos
= os_strchr(pos
, ':');
1731 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1732 pos
= os_strchr(pos
, ':');
1738 wan_metrics
[9] = atoi(pos
);
1739 pos
= os_strchr(pos
, ':');
1745 wan_metrics
[10] = atoi(pos
);
1746 pos
= os_strchr(pos
, ':');
1752 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1754 os_free(bss
->hs20_wan_metrics
);
1755 bss
->hs20_wan_metrics
= wan_metrics
;
1760 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1762 os_free(wan_metrics
);
1767 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1768 char *pos
, int line
)
1770 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1771 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1772 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1773 "hs20_oper_friendly_name '%s'", line
, pos
);
1780 static int hs20_parse_icon(struct hostapd_bss_config
*bss
, char *pos
)
1782 struct hs20_icon
*icon
;
1785 icon
= os_realloc_array(bss
->hs20_icons
, bss
->hs20_icons_count
+ 1,
1786 sizeof(struct hs20_icon
));
1789 bss
->hs20_icons
= icon
;
1790 icon
= &bss
->hs20_icons
[bss
->hs20_icons_count
];
1791 os_memset(icon
, 0, sizeof(*icon
));
1793 icon
->width
= atoi(pos
);
1794 pos
= os_strchr(pos
, ':');
1799 icon
->height
= atoi(pos
);
1800 pos
= os_strchr(pos
, ':');
1805 end
= os_strchr(pos
, ':');
1806 if (end
== NULL
|| end
- pos
> 3)
1808 os_memcpy(icon
->language
, pos
, end
- pos
);
1811 end
= os_strchr(pos
, ':');
1812 if (end
== NULL
|| end
- pos
> 255)
1814 os_memcpy(icon
->type
, pos
, end
- pos
);
1817 end
= os_strchr(pos
, ':');
1818 if (end
== NULL
|| end
- pos
> 255)
1820 os_memcpy(icon
->name
, pos
, end
- pos
);
1823 if (os_strlen(pos
) > 255)
1825 os_memcpy(icon
->file
, pos
, os_strlen(pos
));
1827 bss
->hs20_icons_count
++;
1833 static int hs20_parse_osu_ssid(struct hostapd_bss_config
*bss
,
1834 char *pos
, int line
)
1839 str
= wpa_config_parse_string(pos
, &slen
);
1840 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
1841 wpa_printf(MSG_ERROR
, "Line %d: Invalid SSID '%s'", line
, pos
);
1846 os_memcpy(bss
->osu_ssid
, str
, slen
);
1847 bss
->osu_ssid_len
= slen
;
1854 static int hs20_parse_osu_server_uri(struct hostapd_bss_config
*bss
,
1855 char *pos
, int line
)
1857 struct hs20_osu_provider
*p
;
1859 p
= os_realloc_array(bss
->hs20_osu_providers
,
1860 bss
->hs20_osu_providers_count
+ 1, sizeof(*p
));
1864 bss
->hs20_osu_providers
= p
;
1865 bss
->last_osu
= &bss
->hs20_osu_providers
[bss
->hs20_osu_providers_count
];
1866 bss
->hs20_osu_providers_count
++;
1867 os_memset(bss
->last_osu
, 0, sizeof(*p
));
1868 bss
->last_osu
->server_uri
= os_strdup(pos
);
1874 static int hs20_parse_osu_friendly_name(struct hostapd_bss_config
*bss
,
1875 char *pos
, int line
)
1877 if (bss
->last_osu
== NULL
) {
1878 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1882 if (parse_lang_string(&bss
->last_osu
->friendly_name
,
1883 &bss
->last_osu
->friendly_name_count
, pos
)) {
1884 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_friendly_name '%s'",
1893 static int hs20_parse_osu_nai(struct hostapd_bss_config
*bss
,
1894 char *pos
, int line
)
1896 if (bss
->last_osu
== NULL
) {
1897 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1901 os_free(bss
->last_osu
->osu_nai
);
1902 bss
->last_osu
->osu_nai
= os_strdup(pos
);
1903 if (bss
->last_osu
->osu_nai
== NULL
)
1910 static int hs20_parse_osu_method_list(struct hostapd_bss_config
*bss
, char *pos
,
1913 if (bss
->last_osu
== NULL
) {
1914 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1918 if (hostapd_parse_intlist(&bss
->last_osu
->method_list
, pos
)) {
1919 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_method_list", line
);
1927 static int hs20_parse_osu_icon(struct hostapd_bss_config
*bss
, char *pos
,
1931 struct hs20_osu_provider
*p
= bss
->last_osu
;
1934 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1938 n
= os_realloc_array(p
->icons
, p
->icons_count
+ 1, sizeof(char *));
1942 p
->icons
[p
->icons_count
] = os_strdup(pos
);
1943 if (p
->icons
[p
->icons_count
] == NULL
)
1951 static int hs20_parse_osu_service_desc(struct hostapd_bss_config
*bss
,
1952 char *pos
, int line
)
1954 if (bss
->last_osu
== NULL
) {
1955 wpa_printf(MSG_ERROR
, "Line %d: Unexpected OSU field", line
);
1959 if (parse_lang_string(&bss
->last_osu
->service_desc
,
1960 &bss
->last_osu
->service_desc_count
, pos
)) {
1961 wpa_printf(MSG_ERROR
, "Line %d: Invalid osu_service_desc '%s'",
1969 #endif /* CONFIG_HS20 */
1973 static int hostapd_config_parse_acs_chan_bias(struct hostapd_config
*conf
,
1976 struct acs_bias
*bias
= NULL
, *tmp
;
1977 unsigned int num
= 0;
1981 tmp
= os_realloc_array(bias
, num
+ 1, sizeof(*bias
));
1986 bias
[num
].channel
= atoi(pos
);
1987 if (bias
[num
].channel
<= 0)
1989 pos
= os_strchr(pos
, ':');
1993 bias
[num
].bias
= strtod(pos
, &end
);
1994 if (end
== pos
|| bias
[num
].bias
< 0.0)
1997 if (*pos
!= ' ' && *pos
!= '\0')
2002 os_free(conf
->acs_chan_bias
);
2003 conf
->acs_chan_bias
= bias
;
2004 conf
->num_acs_chan_bias
= num
;
2011 #endif /* CONFIG_ACS */
2014 static int parse_wpabuf_hex(int line
, const char *name
, struct wpabuf
**buf
,
2017 struct wpabuf
*elems
;
2019 if (val
[0] == '\0') {
2025 elems
= wpabuf_parse_bin(val
);
2027 wpa_printf(MSG_ERROR
, "Line %d: Invalid %s '%s'",
2040 static int parse_fils_realm(struct hostapd_bss_config
*bss
, const char *val
)
2042 struct fils_realm
*realm
;
2045 len
= os_strlen(val
);
2046 realm
= os_zalloc(sizeof(*realm
) + len
+ 1);
2050 os_memcpy(realm
->realm
, val
, len
);
2051 if (fils_domain_name_hash(val
, realm
->hash
) < 0) {
2055 dl_list_add_tail(&bss
->fils_realms
, &realm
->list
);
2059 #endif /* CONFIG_FILS */
2062 static int hostapd_config_fill(struct hostapd_config
*conf
,
2063 struct hostapd_bss_config
*bss
,
2064 const char *buf
, char *pos
, int line
)
2066 if (os_strcmp(buf
, "interface") == 0) {
2067 os_strlcpy(conf
->bss
[0]->iface
, pos
,
2068 sizeof(conf
->bss
[0]->iface
));
2069 } else if (os_strcmp(buf
, "bridge") == 0) {
2070 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
2071 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
2072 os_strlcpy(bss
->vlan_bridge
, pos
, sizeof(bss
->vlan_bridge
));
2073 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
2074 os_strlcpy(bss
->wds_bridge
, pos
, sizeof(bss
->wds_bridge
));
2075 } else if (os_strcmp(buf
, "driver") == 0) {
2077 const struct wpa_driver_ops
*driver
= NULL
;
2079 for (j
= 0; wpa_drivers
[j
]; j
++) {
2080 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0) {
2081 driver
= wpa_drivers
[j
];
2086 wpa_printf(MSG_ERROR
,
2087 "Line %d: invalid/unknown driver '%s'",
2091 conf
->driver
= driver
;
2092 } else if (os_strcmp(buf
, "driver_params") == 0) {
2093 os_free(conf
->driver_params
);
2094 conf
->driver_params
= os_strdup(pos
);
2095 } else if (os_strcmp(buf
, "debug") == 0) {
2096 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' configuration variable is not used anymore",
2098 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
2099 bss
->logger_syslog_level
= atoi(pos
);
2100 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
2101 bss
->logger_stdout_level
= atoi(pos
);
2102 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
2103 bss
->logger_syslog
= atoi(pos
);
2104 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
2105 bss
->logger_stdout
= atoi(pos
);
2106 } else if (os_strcmp(buf
, "dump_file") == 0) {
2107 wpa_printf(MSG_INFO
, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
2109 } else if (os_strcmp(buf
, "ssid") == 0) {
2110 bss
->ssid
.ssid_len
= os_strlen(pos
);
2111 if (bss
->ssid
.ssid_len
> SSID_MAX_LEN
||
2112 bss
->ssid
.ssid_len
< 1) {
2113 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2117 os_memcpy(bss
->ssid
.ssid
, pos
, bss
->ssid
.ssid_len
);
2118 bss
->ssid
.ssid_set
= 1;
2119 } else if (os_strcmp(buf
, "ssid2") == 0) {
2121 char *str
= wpa_config_parse_string(pos
, &slen
);
2122 if (str
== NULL
|| slen
< 1 || slen
> SSID_MAX_LEN
) {
2123 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID '%s'",
2128 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
2129 bss
->ssid
.ssid_len
= slen
;
2130 bss
->ssid
.ssid_set
= 1;
2132 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
2133 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
2134 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
2135 enum macaddr_acl acl
= atoi(pos
);
2137 if (acl
!= ACCEPT_UNLESS_DENIED
&&
2138 acl
!= DENY_UNLESS_ACCEPTED
&&
2139 acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
2140 wpa_printf(MSG_ERROR
, "Line %d: unknown macaddr_acl %d",
2144 bss
->macaddr_acl
= acl
;
2145 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
2146 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
2147 &bss
->num_accept_mac
)) {
2148 wpa_printf(MSG_ERROR
, "Line %d: Failed to read accept_mac_file '%s'",
2152 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
2153 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
2154 &bss
->num_deny_mac
)) {
2155 wpa_printf(MSG_ERROR
, "Line %d: Failed to read deny_mac_file '%s'",
2159 } else if (os_strcmp(buf
, "wds_sta") == 0) {
2160 bss
->wds_sta
= atoi(pos
);
2161 } else if (os_strcmp(buf
, "start_disabled") == 0) {
2162 bss
->start_disabled
= atoi(pos
);
2163 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
2164 bss
->isolate
= atoi(pos
);
2165 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
2166 bss
->ap_max_inactivity
= atoi(pos
);
2167 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
2168 bss
->skip_inactivity_poll
= atoi(pos
);
2169 } else if (os_strcmp(buf
, "country_code") == 0) {
2170 os_memcpy(conf
->country
, pos
, 2);
2171 } else if (os_strcmp(buf
, "country3") == 0) {
2172 conf
->country
[2] = strtol(pos
, NULL
, 16);
2173 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
2174 conf
->ieee80211d
= atoi(pos
);
2175 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
2176 conf
->ieee80211h
= atoi(pos
);
2177 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
2178 bss
->ieee802_1x
= atoi(pos
);
2179 } else if (os_strcmp(buf
, "eapol_version") == 0) {
2180 int eapol_version
= atoi(pos
);
2182 if (eapol_version
< 1 || eapol_version
> 2) {
2183 wpa_printf(MSG_ERROR
,
2184 "Line %d: invalid EAPOL version (%d): '%s'.",
2185 line
, eapol_version
, pos
);
2188 bss
->eapol_version
= eapol_version
;
2189 wpa_printf(MSG_DEBUG
, "eapol_version=%d", bss
->eapol_version
);
2191 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
2192 bss
->eap_server
= atoi(pos
);
2193 wpa_printf(MSG_ERROR
, "Line %d: obsolete eap_authenticator used; this has been renamed to eap_server", line
);
2194 } else if (os_strcmp(buf
, "eap_server") == 0) {
2195 bss
->eap_server
= atoi(pos
);
2196 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
2197 if (hostapd_config_read_eap_user(pos
, bss
))
2199 } else if (os_strcmp(buf
, "ca_cert") == 0) {
2200 os_free(bss
->ca_cert
);
2201 bss
->ca_cert
= os_strdup(pos
);
2202 } else if (os_strcmp(buf
, "server_cert") == 0) {
2203 os_free(bss
->server_cert
);
2204 bss
->server_cert
= os_strdup(pos
);
2205 } else if (os_strcmp(buf
, "private_key") == 0) {
2206 os_free(bss
->private_key
);
2207 bss
->private_key
= os_strdup(pos
);
2208 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
2209 os_free(bss
->private_key_passwd
);
2210 bss
->private_key_passwd
= os_strdup(pos
);
2211 } else if (os_strcmp(buf
, "check_crl") == 0) {
2212 bss
->check_crl
= atoi(pos
);
2213 } else if (os_strcmp(buf
, "tls_session_lifetime") == 0) {
2214 bss
->tls_session_lifetime
= atoi(pos
);
2215 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
2216 os_free(bss
->ocsp_stapling_response
);
2217 bss
->ocsp_stapling_response
= os_strdup(pos
);
2218 } else if (os_strcmp(buf
, "ocsp_stapling_response_multi") == 0) {
2219 os_free(bss
->ocsp_stapling_response_multi
);
2220 bss
->ocsp_stapling_response_multi
= os_strdup(pos
);
2221 } else if (os_strcmp(buf
, "dh_file") == 0) {
2222 os_free(bss
->dh_file
);
2223 bss
->dh_file
= os_strdup(pos
);
2224 } else if (os_strcmp(buf
, "openssl_ciphers") == 0) {
2225 os_free(bss
->openssl_ciphers
);
2226 bss
->openssl_ciphers
= os_strdup(pos
);
2227 } else if (os_strcmp(buf
, "fragment_size") == 0) {
2228 bss
->fragment_size
= atoi(pos
);
2229 #ifdef EAP_SERVER_FAST
2230 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
2231 os_free(bss
->pac_opaque_encr_key
);
2232 bss
->pac_opaque_encr_key
= os_malloc(16);
2233 if (bss
->pac_opaque_encr_key
== NULL
) {
2234 wpa_printf(MSG_ERROR
,
2235 "Line %d: No memory for pac_opaque_encr_key",
2238 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
, 16)) {
2239 wpa_printf(MSG_ERROR
, "Line %d: Invalid pac_opaque_encr_key",
2243 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
2244 size_t idlen
= os_strlen(pos
);
2246 wpa_printf(MSG_ERROR
, "Line %d: Invalid eap_fast_a_id",
2250 os_free(bss
->eap_fast_a_id
);
2251 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
2252 if (bss
->eap_fast_a_id
== NULL
||
2253 hexstr2bin(pos
, bss
->eap_fast_a_id
, idlen
/ 2)) {
2254 wpa_printf(MSG_ERROR
, "Line %d: Failed to parse eap_fast_a_id",
2256 os_free(bss
->eap_fast_a_id
);
2257 bss
->eap_fast_a_id
= NULL
;
2260 bss
->eap_fast_a_id_len
= idlen
/ 2;
2262 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
2263 os_free(bss
->eap_fast_a_id_info
);
2264 bss
->eap_fast_a_id_info
= os_strdup(pos
);
2265 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
2266 bss
->eap_fast_prov
= atoi(pos
);
2267 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
2268 bss
->pac_key_lifetime
= atoi(pos
);
2269 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
2270 bss
->pac_key_refresh_time
= atoi(pos
);
2271 #endif /* EAP_SERVER_FAST */
2272 #ifdef EAP_SERVER_SIM
2273 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
2274 os_free(bss
->eap_sim_db
);
2275 bss
->eap_sim_db
= os_strdup(pos
);
2276 } else if (os_strcmp(buf
, "eap_sim_db_timeout") == 0) {
2277 bss
->eap_sim_db_timeout
= atoi(pos
);
2278 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
2279 bss
->eap_sim_aka_result_ind
= atoi(pos
);
2280 #endif /* EAP_SERVER_SIM */
2281 #ifdef EAP_SERVER_TNC
2282 } else if (os_strcmp(buf
, "tnc") == 0) {
2283 bss
->tnc
= atoi(pos
);
2284 #endif /* EAP_SERVER_TNC */
2285 #ifdef EAP_SERVER_PWD
2286 } else if (os_strcmp(buf
, "pwd_group") == 0) {
2287 bss
->pwd_group
= atoi(pos
);
2288 #endif /* EAP_SERVER_PWD */
2289 } else if (os_strcmp(buf
, "eap_server_erp") == 0) {
2290 bss
->eap_server_erp
= atoi(pos
);
2291 #endif /* EAP_SERVER */
2292 } else if (os_strcmp(buf
, "eap_message") == 0) {
2294 os_free(bss
->eap_req_id_text
);
2295 bss
->eap_req_id_text
= os_strdup(pos
);
2296 if (bss
->eap_req_id_text
== NULL
) {
2297 wpa_printf(MSG_ERROR
, "Line %d: Failed to allocate memory for eap_req_id_text",
2301 bss
->eap_req_id_text_len
= os_strlen(bss
->eap_req_id_text
);
2302 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
2305 os_memmove(term
, term
+ 1,
2306 bss
->eap_req_id_text_len
-
2307 (term
- bss
->eap_req_id_text
) - 1);
2308 bss
->eap_req_id_text_len
--;
2310 } else if (os_strcmp(buf
, "erp_send_reauth_start") == 0) {
2311 bss
->erp_send_reauth_start
= atoi(pos
);
2312 } else if (os_strcmp(buf
, "erp_domain") == 0) {
2313 os_free(bss
->erp_domain
);
2314 bss
->erp_domain
= os_strdup(pos
);
2315 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
2316 int val
= atoi(pos
);
2318 if (val
< 0 || val
> 13) {
2319 wpa_printf(MSG_ERROR
,
2320 "Line %d: invalid WEP key len %d (= %d bits)",
2321 line
, val
, val
* 8);
2324 bss
->default_wep_key_len
= val
;
2325 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
2326 int val
= atoi(pos
);
2328 if (val
< 0 || val
> 13) {
2329 wpa_printf(MSG_ERROR
,
2330 "Line %d: invalid WEP key len %d (= %d bits)",
2331 line
, val
, val
* 8);
2334 bss
->individual_wep_key_len
= val
;
2335 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
2336 bss
->wep_rekeying_period
= atoi(pos
);
2337 if (bss
->wep_rekeying_period
< 0) {
2338 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2339 line
, bss
->wep_rekeying_period
);
2342 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
2343 bss
->eap_reauth_period
= atoi(pos
);
2344 if (bss
->eap_reauth_period
< 0) {
2345 wpa_printf(MSG_ERROR
, "Line %d: invalid period %d",
2346 line
, bss
->eap_reauth_period
);
2349 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
2350 bss
->eapol_key_index_workaround
= atoi(pos
);
2352 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
2353 bss
->ieee802_11f
= 1;
2354 os_strlcpy(bss
->iapp_iface
, pos
, sizeof(bss
->iapp_iface
));
2355 #endif /* CONFIG_IAPP */
2356 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
2357 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
2358 wpa_printf(MSG_ERROR
,
2359 "Line %d: invalid IP address '%s'",
2363 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
2364 os_free(bss
->nas_identifier
);
2365 bss
->nas_identifier
= os_strdup(pos
);
2366 #ifndef CONFIG_NO_RADIUS
2367 } else if (os_strcmp(buf
, "radius_client_addr") == 0) {
2368 if (hostapd_parse_ip_addr(pos
, &bss
->radius
->client_addr
)) {
2369 wpa_printf(MSG_ERROR
,
2370 "Line %d: invalid IP address '%s'",
2374 bss
->radius
->force_client_addr
= 1;
2375 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
2376 if (hostapd_config_read_radius_addr(
2377 &bss
->radius
->auth_servers
,
2378 &bss
->radius
->num_auth_servers
, pos
, 1812,
2379 &bss
->radius
->auth_server
)) {
2380 wpa_printf(MSG_ERROR
,
2381 "Line %d: invalid IP address '%s'",
2385 } else if (bss
->radius
->auth_server
&&
2386 os_strcmp(buf
, "auth_server_addr_replace") == 0) {
2387 if (hostapd_parse_ip_addr(pos
,
2388 &bss
->radius
->auth_server
->addr
)) {
2389 wpa_printf(MSG_ERROR
,
2390 "Line %d: invalid IP address '%s'",
2394 } else if (bss
->radius
->auth_server
&&
2395 os_strcmp(buf
, "auth_server_port") == 0) {
2396 bss
->radius
->auth_server
->port
= atoi(pos
);
2397 } else if (bss
->radius
->auth_server
&&
2398 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
2399 int len
= os_strlen(pos
);
2401 /* RFC 2865, Ch. 3 */
2402 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2406 os_free(bss
->radius
->auth_server
->shared_secret
);
2407 bss
->radius
->auth_server
->shared_secret
= (u8
*) os_strdup(pos
);
2408 bss
->radius
->auth_server
->shared_secret_len
= len
;
2409 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
2410 if (hostapd_config_read_radius_addr(
2411 &bss
->radius
->acct_servers
,
2412 &bss
->radius
->num_acct_servers
, pos
, 1813,
2413 &bss
->radius
->acct_server
)) {
2414 wpa_printf(MSG_ERROR
,
2415 "Line %d: invalid IP address '%s'",
2419 } else if (bss
->radius
->acct_server
&&
2420 os_strcmp(buf
, "acct_server_addr_replace") == 0) {
2421 if (hostapd_parse_ip_addr(pos
,
2422 &bss
->radius
->acct_server
->addr
)) {
2423 wpa_printf(MSG_ERROR
,
2424 "Line %d: invalid IP address '%s'",
2428 } else if (bss
->radius
->acct_server
&&
2429 os_strcmp(buf
, "acct_server_port") == 0) {
2430 bss
->radius
->acct_server
->port
= atoi(pos
);
2431 } else if (bss
->radius
->acct_server
&&
2432 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
2433 int len
= os_strlen(pos
);
2435 /* RFC 2865, Ch. 3 */
2436 wpa_printf(MSG_ERROR
, "Line %d: empty shared secret is not allowed",
2440 os_free(bss
->radius
->acct_server
->shared_secret
);
2441 bss
->radius
->acct_server
->shared_secret
= (u8
*) os_strdup(pos
);
2442 bss
->radius
->acct_server
->shared_secret_len
= len
;
2443 } else if (os_strcmp(buf
, "radius_retry_primary_interval") == 0) {
2444 bss
->radius
->retry_primary_interval
= atoi(pos
);
2445 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0) {
2446 bss
->acct_interim_interval
= atoi(pos
);
2447 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
2448 bss
->radius_request_cui
= atoi(pos
);
2449 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
2450 struct hostapd_radius_attr
*attr
, *a
;
2451 attr
= hostapd_parse_radius_attr(pos
);
2453 wpa_printf(MSG_ERROR
,
2454 "Line %d: invalid radius_auth_req_attr",
2457 } else if (bss
->radius_auth_req_attr
== NULL
) {
2458 bss
->radius_auth_req_attr
= attr
;
2460 a
= bss
->radius_auth_req_attr
;
2465 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
2466 struct hostapd_radius_attr
*attr
, *a
;
2467 attr
= hostapd_parse_radius_attr(pos
);
2469 wpa_printf(MSG_ERROR
,
2470 "Line %d: invalid radius_acct_req_attr",
2473 } else if (bss
->radius_acct_req_attr
== NULL
) {
2474 bss
->radius_acct_req_attr
= attr
;
2476 a
= bss
->radius_acct_req_attr
;
2481 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
2482 bss
->radius_das_port
= atoi(pos
);
2483 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
2484 if (hostapd_parse_das_client(bss
, pos
) < 0) {
2485 wpa_printf(MSG_ERROR
, "Line %d: invalid DAS client",
2489 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2490 bss
->radius_das_time_window
= atoi(pos
);
2491 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp") == 0) {
2492 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2493 } else if (os_strcmp(buf
, "radius_das_require_message_authenticator") ==
2495 bss
->radius_das_require_message_authenticator
= atoi(pos
);
2496 #endif /* CONFIG_NO_RADIUS */
2497 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2498 bss
->auth_algs
= atoi(pos
);
2499 if (bss
->auth_algs
== 0) {
2500 wpa_printf(MSG_ERROR
, "Line %d: no authentication algorithms allowed",
2504 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2505 bss
->max_num_sta
= atoi(pos
);
2506 if (bss
->max_num_sta
< 0 ||
2507 bss
->max_num_sta
> MAX_STA_COUNT
) {
2508 wpa_printf(MSG_ERROR
, "Line %d: Invalid max_num_sta=%d; allowed range 0..%d",
2509 line
, bss
->max_num_sta
, MAX_STA_COUNT
);
2512 } else if (os_strcmp(buf
, "wpa") == 0) {
2513 bss
->wpa
= atoi(pos
);
2514 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2515 bss
->wpa_group_rekey
= atoi(pos
);
2516 bss
->wpa_group_rekey_set
= 1;
2517 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2518 bss
->wpa_strict_rekey
= atoi(pos
);
2519 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2520 bss
->wpa_gmk_rekey
= atoi(pos
);
2521 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2522 bss
->wpa_ptk_rekey
= atoi(pos
);
2523 } else if (os_strcmp(buf
, "wpa_group_update_count") == 0) {
2525 unsigned long val
= strtoul(pos
, &endp
, 0);
2527 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2528 wpa_printf(MSG_ERROR
,
2529 "Line %d: Invalid wpa_group_update_count=%lu; allowed range 1..4294967295",
2533 bss
->wpa_group_update_count
= (u32
) val
;
2534 } else if (os_strcmp(buf
, "wpa_pairwise_update_count") == 0) {
2536 unsigned long val
= strtoul(pos
, &endp
, 0);
2538 if (*endp
|| val
< 1 || val
> (u32
) -1) {
2539 wpa_printf(MSG_ERROR
,
2540 "Line %d: Invalid wpa_pairwise_update_count=%lu; allowed range 1..4294967295",
2544 bss
->wpa_pairwise_update_count
= (u32
) val
;
2545 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2546 int len
= os_strlen(pos
);
2547 if (len
< 8 || len
> 63) {
2548 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA passphrase length %d (expected 8..63)",
2552 os_free(bss
->ssid
.wpa_passphrase
);
2553 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2554 if (bss
->ssid
.wpa_passphrase
) {
2555 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2556 bss
->ssid
.wpa_passphrase_set
= 1;
2558 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2559 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2560 bss
->ssid
.wpa_psk
= os_zalloc(sizeof(struct hostapd_wpa_psk
));
2561 if (bss
->ssid
.wpa_psk
== NULL
)
2563 if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
, PMK_LEN
) ||
2564 pos
[PMK_LEN
* 2] != '\0') {
2565 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK '%s'.",
2567 hostapd_config_clear_wpa_psk(&bss
->ssid
.wpa_psk
);
2570 bss
->ssid
.wpa_psk
->group
= 1;
2571 os_free(bss
->ssid
.wpa_passphrase
);
2572 bss
->ssid
.wpa_passphrase
= NULL
;
2573 bss
->ssid
.wpa_psk_set
= 1;
2574 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2575 os_free(bss
->ssid
.wpa_psk_file
);
2576 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
2577 if (!bss
->ssid
.wpa_psk_file
) {
2578 wpa_printf(MSG_ERROR
, "Line %d: allocation failed",
2582 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
2583 bss
->wpa_key_mgmt
= hostapd_config_parse_key_mgmt(line
, pos
);
2584 if (bss
->wpa_key_mgmt
== -1)
2586 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
2587 bss
->wpa_psk_radius
= atoi(pos
);
2588 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
2589 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
2590 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
2591 wpa_printf(MSG_ERROR
,
2592 "Line %d: unknown wpa_psk_radius %d",
2593 line
, bss
->wpa_psk_radius
);
2596 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
2597 bss
->wpa_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2598 if (bss
->wpa_pairwise
== -1 || bss
->wpa_pairwise
== 0)
2600 if (bss
->wpa_pairwise
&
2601 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2602 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2603 bss
->wpa_pairwise
, pos
);
2606 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
2607 bss
->rsn_pairwise
= hostapd_config_parse_cipher(line
, pos
);
2608 if (bss
->rsn_pairwise
== -1 || bss
->rsn_pairwise
== 0)
2610 if (bss
->rsn_pairwise
&
2611 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
| WPA_CIPHER_WEP104
)) {
2612 wpa_printf(MSG_ERROR
, "Line %d: unsupported pairwise cipher suite '%s'",
2613 bss
->rsn_pairwise
, pos
);
2616 #ifdef CONFIG_RSN_PREAUTH
2617 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
2618 bss
->rsn_preauth
= atoi(pos
);
2619 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
2620 os_free(bss
->rsn_preauth_interfaces
);
2621 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
2622 #endif /* CONFIG_RSN_PREAUTH */
2623 #ifdef CONFIG_PEERKEY
2624 } else if (os_strcmp(buf
, "peerkey") == 0) {
2625 bss
->peerkey
= atoi(pos
);
2626 #endif /* CONFIG_PEERKEY */
2627 #ifdef CONFIG_IEEE80211R_AP
2628 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
2629 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
2630 hexstr2bin(pos
, bss
->mobility_domain
,
2631 MOBILITY_DOMAIN_ID_LEN
) != 0) {
2632 wpa_printf(MSG_ERROR
,
2633 "Line %d: Invalid mobility_domain '%s'",
2637 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
2638 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
2639 hexstr2bin(pos
, bss
->r1_key_holder
, FT_R1KH_ID_LEN
) != 0) {
2640 wpa_printf(MSG_ERROR
,
2641 "Line %d: Invalid r1_key_holder '%s'",
2645 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
2646 bss
->r0_key_lifetime
= atoi(pos
);
2647 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
2648 bss
->reassociation_deadline
= atoi(pos
);
2649 } else if (os_strcmp(buf
, "rkh_pos_timeout") == 0) {
2650 bss
->rkh_pos_timeout
= atoi(pos
);
2651 } else if (os_strcmp(buf
, "rkh_neg_timeout") == 0) {
2652 bss
->rkh_neg_timeout
= atoi(pos
);
2653 } else if (os_strcmp(buf
, "rkh_pull_timeout") == 0) {
2654 bss
->rkh_pull_timeout
= atoi(pos
);
2655 } else if (os_strcmp(buf
, "rkh_pull_retries") == 0) {
2656 bss
->rkh_pull_retries
= atoi(pos
);
2657 } else if (os_strcmp(buf
, "r0kh") == 0) {
2658 if (add_r0kh(bss
, pos
) < 0) {
2659 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r0kh '%s'",
2663 } else if (os_strcmp(buf
, "r1kh") == 0) {
2664 if (add_r1kh(bss
, pos
) < 0) {
2665 wpa_printf(MSG_DEBUG
, "Line %d: Invalid r1kh '%s'",
2669 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
2670 bss
->pmk_r1_push
= atoi(pos
);
2671 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
2672 bss
->ft_over_ds
= atoi(pos
);
2673 } else if (os_strcmp(buf
, "ft_psk_generate_local") == 0) {
2674 bss
->ft_psk_generate_local
= atoi(pos
);
2675 #endif /* CONFIG_IEEE80211R_AP */
2676 #ifndef CONFIG_NO_CTRL_IFACE
2677 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
2678 os_free(bss
->ctrl_interface
);
2679 bss
->ctrl_interface
= os_strdup(pos
);
2680 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
2681 #ifndef CONFIG_NATIVE_WINDOWS
2684 const char *group
= pos
;
2686 grp
= getgrnam(group
);
2688 bss
->ctrl_interface_gid
= grp
->gr_gid
;
2689 bss
->ctrl_interface_gid_set
= 1;
2690 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d (from group name '%s')",
2691 bss
->ctrl_interface_gid
, group
);
2695 /* Group name not found - try to parse this as gid */
2696 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
2697 if (*group
== '\0' || *endp
!= '\0') {
2698 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group '%s'",
2702 bss
->ctrl_interface_gid_set
= 1;
2703 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
2704 bss
->ctrl_interface_gid
);
2705 #endif /* CONFIG_NATIVE_WINDOWS */
2706 #endif /* CONFIG_NO_CTRL_IFACE */
2707 #ifdef RADIUS_SERVER
2708 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
2709 os_free(bss
->radius_server_clients
);
2710 bss
->radius_server_clients
= os_strdup(pos
);
2711 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
2712 bss
->radius_server_auth_port
= atoi(pos
);
2713 } else if (os_strcmp(buf
, "radius_server_acct_port") == 0) {
2714 bss
->radius_server_acct_port
= atoi(pos
);
2715 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
2716 bss
->radius_server_ipv6
= atoi(pos
);
2717 #endif /* RADIUS_SERVER */
2718 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
2719 bss
->use_pae_group_addr
= atoi(pos
);
2720 } else if (os_strcmp(buf
, "hw_mode") == 0) {
2721 if (os_strcmp(pos
, "a") == 0)
2722 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
2723 else if (os_strcmp(pos
, "b") == 0)
2724 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
2725 else if (os_strcmp(pos
, "g") == 0)
2726 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
2727 else if (os_strcmp(pos
, "ad") == 0)
2728 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
2729 else if (os_strcmp(pos
, "any") == 0)
2730 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211ANY
;
2732 wpa_printf(MSG_ERROR
, "Line %d: unknown hw_mode '%s'",
2736 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
2737 if (os_strcmp(pos
, "ad") == 0)
2738 bss
->wps_rf_bands
= WPS_RF_60GHZ
;
2739 else if (os_strcmp(pos
, "a") == 0)
2740 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
2741 else if (os_strcmp(pos
, "g") == 0 ||
2742 os_strcmp(pos
, "b") == 0)
2743 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
2744 else if (os_strcmp(pos
, "ag") == 0 ||
2745 os_strcmp(pos
, "ga") == 0)
2746 bss
->wps_rf_bands
= WPS_RF_24GHZ
| WPS_RF_50GHZ
;
2748 wpa_printf(MSG_ERROR
,
2749 "Line %d: unknown wps_rf_band '%s'",
2753 } else if (os_strcmp(buf
, "acs_exclude_dfs") == 0) {
2754 conf
->acs_exclude_dfs
= atoi(pos
);
2755 } else if (os_strcmp(buf
, "channel") == 0) {
2756 if (os_strcmp(pos
, "acs_survey") == 0) {
2758 wpa_printf(MSG_ERROR
, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
2761 #else /* CONFIG_ACS */
2764 #endif /* CONFIG_ACS */
2766 conf
->channel
= atoi(pos
);
2767 conf
->acs
= conf
->channel
== 0;
2769 } else if (os_strcmp(buf
, "chanlist") == 0) {
2770 if (hostapd_parse_chanlist(conf
, pos
)) {
2771 wpa_printf(MSG_ERROR
, "Line %d: invalid channel list",
2775 } else if (os_strcmp(buf
, "beacon_int") == 0) {
2776 int val
= atoi(pos
);
2777 /* MIB defines range as 1..65535, but very small values
2778 * cause problems with the current implementation.
2779 * Since it is unlikely that this small numbers are
2780 * useful in real life scenarios, do not allow beacon
2781 * period to be set below 15 TU. */
2782 if (val
< 15 || val
> 65535) {
2783 wpa_printf(MSG_ERROR
, "Line %d: invalid beacon_int %d (expected 15..65535)",
2787 conf
->beacon_int
= val
;
2789 } else if (os_strcmp(buf
, "acs_num_scans") == 0) {
2790 int val
= atoi(pos
);
2791 if (val
<= 0 || val
> 100) {
2792 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_num_scans %d (expected 1..100)",
2796 conf
->acs_num_scans
= val
;
2797 } else if (os_strcmp(buf
, "acs_chan_bias") == 0) {
2798 if (hostapd_config_parse_acs_chan_bias(conf
, pos
)) {
2799 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_chan_bias",
2803 #endif /* CONFIG_ACS */
2804 } else if (os_strcmp(buf
, "dtim_period") == 0) {
2805 int val
= atoi(pos
);
2807 if (val
< 1 || val
> 255) {
2808 wpa_printf(MSG_ERROR
, "Line %d: invalid dtim_period %d",
2812 bss
->dtim_period
= val
;
2813 } else if (os_strcmp(buf
, "bss_load_update_period") == 0) {
2814 bss
->bss_load_update_period
= atoi(pos
);
2815 if (bss
->bss_load_update_period
< 0 ||
2816 bss
->bss_load_update_period
> 100) {
2817 wpa_printf(MSG_ERROR
,
2818 "Line %d: invalid bss_load_update_period %d",
2819 line
, bss
->bss_load_update_period
);
2822 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
2823 conf
->rts_threshold
= atoi(pos
);
2824 if (conf
->rts_threshold
< -1 || conf
->rts_threshold
> 65535) {
2825 wpa_printf(MSG_ERROR
,
2826 "Line %d: invalid rts_threshold %d",
2827 line
, conf
->rts_threshold
);
2830 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
2831 conf
->fragm_threshold
= atoi(pos
);
2832 if (conf
->fragm_threshold
== -1) {
2833 /* allow a value of -1 */
2834 } else if (conf
->fragm_threshold
< 256 ||
2835 conf
->fragm_threshold
> 2346) {
2836 wpa_printf(MSG_ERROR
,
2837 "Line %d: invalid fragm_threshold %d",
2838 line
, conf
->fragm_threshold
);
2841 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
2842 int val
= atoi(pos
);
2843 if (val
!= 0 && val
!= 1) {
2844 wpa_printf(MSG_ERROR
, "Line %d: invalid send_probe_response %d (expected 0 or 1)",
2848 conf
->send_probe_response
= val
;
2849 } else if (os_strcmp(buf
, "supported_rates") == 0) {
2850 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
)) {
2851 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
2855 } else if (os_strcmp(buf
, "basic_rates") == 0) {
2856 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
2857 wpa_printf(MSG_ERROR
, "Line %d: invalid rate list",
2861 } else if (os_strcmp(buf
, "beacon_rate") == 0) {
2864 if (os_strncmp(pos
, "ht:", 3) == 0) {
2865 val
= atoi(pos
+ 3);
2866 if (val
< 0 || val
> 31) {
2867 wpa_printf(MSG_ERROR
,
2868 "Line %d: invalid beacon_rate HT-MCS %d",
2872 conf
->rate_type
= BEACON_RATE_HT
;
2873 conf
->beacon_rate
= val
;
2874 } else if (os_strncmp(pos
, "vht:", 4) == 0) {
2875 val
= atoi(pos
+ 4);
2876 if (val
< 0 || val
> 9) {
2877 wpa_printf(MSG_ERROR
,
2878 "Line %d: invalid beacon_rate VHT-MCS %d",
2882 conf
->rate_type
= BEACON_RATE_VHT
;
2883 conf
->beacon_rate
= val
;
2886 if (val
< 10 || val
> 10000) {
2887 wpa_printf(MSG_ERROR
,
2888 "Line %d: invalid legacy beacon_rate %d",
2892 conf
->rate_type
= BEACON_RATE_LEGACY
;
2893 conf
->beacon_rate
= val
;
2895 } else if (os_strcmp(buf
, "preamble") == 0) {
2897 conf
->preamble
= SHORT_PREAMBLE
;
2899 conf
->preamble
= LONG_PREAMBLE
;
2900 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
2901 bss
->ignore_broadcast_ssid
= atoi(pos
);
2902 } else if (os_strcmp(buf
, "no_probe_resp_if_max_sta") == 0) {
2903 bss
->no_probe_resp_if_max_sta
= atoi(pos
);
2904 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
2905 bss
->ssid
.wep
.idx
= atoi(pos
);
2906 if (bss
->ssid
.wep
.idx
> 3) {
2907 wpa_printf(MSG_ERROR
,
2908 "Invalid wep_default_key index %d",
2912 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
2913 os_strcmp(buf
, "wep_key1") == 0 ||
2914 os_strcmp(buf
, "wep_key2") == 0 ||
2915 os_strcmp(buf
, "wep_key3") == 0) {
2916 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
2917 buf
[7] - '0', pos
)) {
2918 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP key '%s'",
2922 #ifndef CONFIG_NO_VLAN
2923 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
2924 bss
->ssid
.dynamic_vlan
= atoi(pos
);
2925 } else if (os_strcmp(buf
, "per_sta_vif") == 0) {
2926 bss
->ssid
.per_sta_vif
= atoi(pos
);
2927 } else if (os_strcmp(buf
, "vlan_file") == 0) {
2928 if (hostapd_config_read_vlan_file(bss
, pos
)) {
2929 wpa_printf(MSG_ERROR
, "Line %d: failed to read VLAN file '%s'",
2933 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
2934 bss
->ssid
.vlan_naming
= atoi(pos
);
2935 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
2936 bss
->ssid
.vlan_naming
< 0) {
2937 wpa_printf(MSG_ERROR
,
2938 "Line %d: invalid naming scheme %d",
2939 line
, bss
->ssid
.vlan_naming
);
2942 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2943 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
2944 os_free(bss
->ssid
.vlan_tagged_interface
);
2945 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
2946 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2947 #endif /* CONFIG_NO_VLAN */
2948 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
2949 conf
->ap_table_max_size
= atoi(pos
);
2950 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
2951 conf
->ap_table_expiration_time
= atoi(pos
);
2952 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
2953 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
2954 wpa_printf(MSG_ERROR
, "Line %d: invalid TX queue item",
2958 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
2959 os_strcmp(buf
, "wmm_enabled") == 0) {
2960 bss
->wmm_enabled
= atoi(pos
);
2961 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
2962 bss
->wmm_uapsd
= atoi(pos
);
2963 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
2964 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
2965 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
, pos
)) {
2966 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM ac item",
2970 } else if (os_strcmp(buf
, "bss") == 0) {
2971 if (hostapd_config_bss(conf
, pos
)) {
2972 wpa_printf(MSG_ERROR
, "Line %d: invalid bss item",
2976 } else if (os_strcmp(buf
, "bssid") == 0) {
2977 if (hwaddr_aton(pos
, bss
->bssid
)) {
2978 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid item",
2982 } else if (os_strcmp(buf
, "use_driver_iface_addr") == 0) {
2983 conf
->use_driver_iface_addr
= atoi(pos
);
2984 #ifdef CONFIG_IEEE80211W
2985 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
2986 bss
->ieee80211w
= atoi(pos
);
2987 } else if (os_strcmp(buf
, "group_mgmt_cipher") == 0) {
2988 if (os_strcmp(pos
, "AES-128-CMAC") == 0) {
2989 bss
->group_mgmt_cipher
= WPA_CIPHER_AES_128_CMAC
;
2990 } else if (os_strcmp(pos
, "BIP-GMAC-128") == 0) {
2991 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_128
;
2992 } else if (os_strcmp(pos
, "BIP-GMAC-256") == 0) {
2993 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_GMAC_256
;
2994 } else if (os_strcmp(pos
, "BIP-CMAC-256") == 0) {
2995 bss
->group_mgmt_cipher
= WPA_CIPHER_BIP_CMAC_256
;
2997 wpa_printf(MSG_ERROR
, "Line %d: invalid group_mgmt_cipher: %s",
3001 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
3002 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
3003 if (bss
->assoc_sa_query_max_timeout
== 0) {
3004 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_max_timeout",
3008 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0) {
3009 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
3010 if (bss
->assoc_sa_query_retry_timeout
== 0) {
3011 wpa_printf(MSG_ERROR
, "Line %d: invalid assoc_sa_query_retry_timeout",
3015 #endif /* CONFIG_IEEE80211W */
3016 #ifdef CONFIG_IEEE80211N
3017 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
3018 conf
->ieee80211n
= atoi(pos
);
3019 } else if (os_strcmp(buf
, "ht_capab") == 0) {
3020 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
3021 wpa_printf(MSG_ERROR
, "Line %d: invalid ht_capab",
3025 } else if (os_strcmp(buf
, "require_ht") == 0) {
3026 conf
->require_ht
= atoi(pos
);
3027 } else if (os_strcmp(buf
, "obss_interval") == 0) {
3028 conf
->obss_interval
= atoi(pos
);
3029 #endif /* CONFIG_IEEE80211N */
3030 #ifdef CONFIG_IEEE80211AC
3031 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
3032 conf
->ieee80211ac
= atoi(pos
);
3033 } else if (os_strcmp(buf
, "vht_capab") == 0) {
3034 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
3035 wpa_printf(MSG_ERROR
, "Line %d: invalid vht_capab",
3039 } else if (os_strcmp(buf
, "require_vht") == 0) {
3040 conf
->require_vht
= atoi(pos
);
3041 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
3042 conf
->vht_oper_chwidth
= atoi(pos
);
3043 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0) {
3044 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
3045 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0) {
3046 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
3047 } else if (os_strcmp(buf
, "vendor_vht") == 0) {
3048 bss
->vendor_vht
= atoi(pos
);
3049 } else if (os_strcmp(buf
, "use_sta_nsts") == 0) {
3050 bss
->use_sta_nsts
= atoi(pos
);
3051 #endif /* CONFIG_IEEE80211AC */
3052 #ifdef CONFIG_IEEE80211AX
3053 } else if (os_strcmp(buf
, "ieee80211ax") == 0) {
3054 conf
->ieee80211ax
= atoi(pos
);
3055 } else if (os_strcmp(buf
, "he_su_beamformer") == 0) {
3056 conf
->he_phy_capab
.he_su_beamformer
= atoi(pos
);
3057 } else if (os_strcmp(buf
, "he_su_beamformee") == 0) {
3058 conf
->he_phy_capab
.he_su_beamformee
= atoi(pos
);
3059 } else if (os_strcmp(buf
, "he_mu_beamformer") == 0) {
3060 conf
->he_phy_capab
.he_mu_beamformer
= atoi(pos
);
3061 } else if (os_strcmp(buf
, "he_bss_color") == 0) {
3062 conf
->he_op
.he_bss_color
= atoi(pos
);
3063 } else if (os_strcmp(buf
, "he_default_pe_duration") == 0) {
3064 conf
->he_op
.he_default_pe_duration
= atoi(pos
);
3065 } else if (os_strcmp(buf
, "he_twt_required") == 0) {
3066 conf
->he_op
.he_twt_required
= atoi(pos
);
3067 } else if (os_strcmp(buf
, "he_rts_threshold") == 0) {
3068 conf
->he_op
.he_rts_threshold
= atoi(pos
);
3069 #endif /* CONFIG_IEEE80211AX */
3070 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
3071 bss
->max_listen_interval
= atoi(pos
);
3072 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
3073 bss
->disable_pmksa_caching
= atoi(pos
);
3074 } else if (os_strcmp(buf
, "okc") == 0) {
3075 bss
->okc
= atoi(pos
);
3077 } else if (os_strcmp(buf
, "wps_state") == 0) {
3078 bss
->wps_state
= atoi(pos
);
3079 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
3080 wpa_printf(MSG_ERROR
, "Line %d: invalid wps_state",
3084 } else if (os_strcmp(buf
, "wps_independent") == 0) {
3085 bss
->wps_independent
= atoi(pos
);
3086 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
3087 bss
->ap_setup_locked
= atoi(pos
);
3088 } else if (os_strcmp(buf
, "uuid") == 0) {
3089 if (uuid_str2bin(pos
, bss
->uuid
)) {
3090 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID", line
);
3093 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
3094 os_free(bss
->wps_pin_requests
);
3095 bss
->wps_pin_requests
= os_strdup(pos
);
3096 } else if (os_strcmp(buf
, "device_name") == 0) {
3097 if (os_strlen(pos
) > WPS_DEV_NAME_MAX_LEN
) {
3098 wpa_printf(MSG_ERROR
, "Line %d: Too long "
3099 "device_name", line
);
3102 os_free(bss
->device_name
);
3103 bss
->device_name
= os_strdup(pos
);
3104 } else if (os_strcmp(buf
, "manufacturer") == 0) {
3105 if (os_strlen(pos
) > 64) {
3106 wpa_printf(MSG_ERROR
, "Line %d: Too long manufacturer",
3110 os_free(bss
->manufacturer
);
3111 bss
->manufacturer
= os_strdup(pos
);
3112 } else if (os_strcmp(buf
, "model_name") == 0) {
3113 if (os_strlen(pos
) > 32) {
3114 wpa_printf(MSG_ERROR
, "Line %d: Too long model_name",
3118 os_free(bss
->model_name
);
3119 bss
->model_name
= os_strdup(pos
);
3120 } else if (os_strcmp(buf
, "model_number") == 0) {
3121 if (os_strlen(pos
) > 32) {
3122 wpa_printf(MSG_ERROR
, "Line %d: Too long model_number",
3126 os_free(bss
->model_number
);
3127 bss
->model_number
= os_strdup(pos
);
3128 } else if (os_strcmp(buf
, "serial_number") == 0) {
3129 if (os_strlen(pos
) > 32) {
3130 wpa_printf(MSG_ERROR
, "Line %d: Too long serial_number",
3134 os_free(bss
->serial_number
);
3135 bss
->serial_number
= os_strdup(pos
);
3136 } else if (os_strcmp(buf
, "device_type") == 0) {
3137 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
3139 } else if (os_strcmp(buf
, "config_methods") == 0) {
3140 os_free(bss
->config_methods
);
3141 bss
->config_methods
= os_strdup(pos
);
3142 } else if (os_strcmp(buf
, "os_version") == 0) {
3143 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
3144 wpa_printf(MSG_ERROR
, "Line %d: invalid os_version",
3148 } else if (os_strcmp(buf
, "ap_pin") == 0) {
3149 os_free(bss
->ap_pin
);
3150 bss
->ap_pin
= os_strdup(pos
);
3151 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
3152 bss
->skip_cred_build
= atoi(pos
);
3153 } else if (os_strcmp(buf
, "extra_cred") == 0) {
3154 os_free(bss
->extra_cred
);
3155 bss
->extra_cred
= (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
3156 if (bss
->extra_cred
== NULL
) {
3157 wpa_printf(MSG_ERROR
, "Line %d: could not read Credentials from '%s'",
3161 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
3162 bss
->wps_cred_processing
= atoi(pos
);
3163 } else if (os_strcmp(buf
, "ap_settings") == 0) {
3164 os_free(bss
->ap_settings
);
3166 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
3167 if (bss
->ap_settings
== NULL
) {
3168 wpa_printf(MSG_ERROR
, "Line %d: could not read AP Settings from '%s'",
3172 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
3173 os_free(bss
->upnp_iface
);
3174 bss
->upnp_iface
= os_strdup(pos
);
3175 } else if (os_strcmp(buf
, "friendly_name") == 0) {
3176 os_free(bss
->friendly_name
);
3177 bss
->friendly_name
= os_strdup(pos
);
3178 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
3179 os_free(bss
->manufacturer_url
);
3180 bss
->manufacturer_url
= os_strdup(pos
);
3181 } else if (os_strcmp(buf
, "model_description") == 0) {
3182 os_free(bss
->model_description
);
3183 bss
->model_description
= os_strdup(pos
);
3184 } else if (os_strcmp(buf
, "model_url") == 0) {
3185 os_free(bss
->model_url
);
3186 bss
->model_url
= os_strdup(pos
);
3187 } else if (os_strcmp(buf
, "upc") == 0) {
3189 bss
->upc
= os_strdup(pos
);
3190 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
3191 bss
->pbc_in_m1
= atoi(pos
);
3192 } else if (os_strcmp(buf
, "server_id") == 0) {
3193 os_free(bss
->server_id
);
3194 bss
->server_id
= os_strdup(pos
);
3195 #ifdef CONFIG_WPS_NFC
3196 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
3197 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
3198 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
3199 bss
->wps_nfc_dev_pw_id
> 0xffff) {
3200 wpa_printf(MSG_ERROR
, "Line %d: Invalid wps_nfc_dev_pw_id value",
3204 bss
->wps_nfc_pw_from_config
= 1;
3205 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
3206 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
3207 bss
->wps_nfc_dh_pubkey
= wpabuf_parse_bin(pos
);
3208 bss
->wps_nfc_pw_from_config
= 1;
3209 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
3210 wpabuf_free(bss
->wps_nfc_dh_privkey
);
3211 bss
->wps_nfc_dh_privkey
= wpabuf_parse_bin(pos
);
3212 bss
->wps_nfc_pw_from_config
= 1;
3213 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
3214 wpabuf_free(bss
->wps_nfc_dev_pw
);
3215 bss
->wps_nfc_dev_pw
= wpabuf_parse_bin(pos
);
3216 bss
->wps_nfc_pw_from_config
= 1;
3217 #endif /* CONFIG_WPS_NFC */
3218 #endif /* CONFIG_WPS */
3219 #ifdef CONFIG_P2P_MANAGER
3220 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
3222 bss
->p2p
|= P2P_MANAGE
;
3224 bss
->p2p
&= ~P2P_MANAGE
;
3225 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
3227 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
3229 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
3230 #endif /* CONFIG_P2P_MANAGER */
3231 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
3232 bss
->disassoc_low_ack
= atoi(pos
);
3233 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
3235 bss
->tdls
|= TDLS_PROHIBIT
;
3237 bss
->tdls
&= ~TDLS_PROHIBIT
;
3238 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
3240 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
3242 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
3243 #ifdef CONFIG_RSN_TESTING
3244 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
3245 extern int rsn_testing
;
3246 rsn_testing
= atoi(pos
);
3247 #endif /* CONFIG_RSN_TESTING */
3248 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
3249 bss
->time_advertisement
= atoi(pos
);
3250 } else if (os_strcmp(buf
, "time_zone") == 0) {
3251 size_t tz_len
= os_strlen(pos
);
3252 if (tz_len
< 4 || tz_len
> 255) {
3253 wpa_printf(MSG_DEBUG
, "Line %d: invalid time_zone",
3257 os_free(bss
->time_zone
);
3258 bss
->time_zone
= os_strdup(pos
);
3259 if (bss
->time_zone
== NULL
)
3262 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
3263 bss
->wnm_sleep_mode
= atoi(pos
);
3264 } else if (os_strcmp(buf
, "bss_transition") == 0) {
3265 bss
->bss_transition
= atoi(pos
);
3266 #endif /* CONFIG_WNM */
3267 #ifdef CONFIG_INTERWORKING
3268 } else if (os_strcmp(buf
, "interworking") == 0) {
3269 bss
->interworking
= atoi(pos
);
3270 } else if (os_strcmp(buf
, "access_network_type") == 0) {
3271 bss
->access_network_type
= atoi(pos
);
3272 if (bss
->access_network_type
< 0 ||
3273 bss
->access_network_type
> 15) {
3274 wpa_printf(MSG_ERROR
,
3275 "Line %d: invalid access_network_type",
3279 } else if (os_strcmp(buf
, "internet") == 0) {
3280 bss
->internet
= atoi(pos
);
3281 } else if (os_strcmp(buf
, "asra") == 0) {
3282 bss
->asra
= atoi(pos
);
3283 } else if (os_strcmp(buf
, "esr") == 0) {
3284 bss
->esr
= atoi(pos
);
3285 } else if (os_strcmp(buf
, "uesa") == 0) {
3286 bss
->uesa
= atoi(pos
);
3287 } else if (os_strcmp(buf
, "venue_group") == 0) {
3288 bss
->venue_group
= atoi(pos
);
3289 bss
->venue_info_set
= 1;
3290 } else if (os_strcmp(buf
, "venue_type") == 0) {
3291 bss
->venue_type
= atoi(pos
);
3292 bss
->venue_info_set
= 1;
3293 } else if (os_strcmp(buf
, "hessid") == 0) {
3294 if (hwaddr_aton(pos
, bss
->hessid
)) {
3295 wpa_printf(MSG_ERROR
, "Line %d: invalid hessid", line
);
3298 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
3299 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
3301 } else if (os_strcmp(buf
, "venue_name") == 0) {
3302 if (parse_venue_name(bss
, pos
, line
) < 0)
3304 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
3306 u16 redirect_url_len
;
3307 if (hexstr2bin(pos
, &auth_type
, 1)) {
3308 wpa_printf(MSG_ERROR
,
3309 "Line %d: Invalid network_auth_type '%s'",
3313 if (auth_type
== 0 || auth_type
== 2)
3314 redirect_url_len
= os_strlen(pos
+ 2);
3316 redirect_url_len
= 0;
3317 os_free(bss
->network_auth_type
);
3318 bss
->network_auth_type
= os_malloc(redirect_url_len
+ 3 + 1);
3319 if (bss
->network_auth_type
== NULL
)
3321 *bss
->network_auth_type
= auth_type
;
3322 WPA_PUT_LE16(bss
->network_auth_type
+ 1, redirect_url_len
);
3323 if (redirect_url_len
)
3324 os_memcpy(bss
->network_auth_type
+ 3, pos
+ 2,
3326 bss
->network_auth_type_len
= 3 + redirect_url_len
;
3327 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
3328 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1)) {
3329 wpa_printf(MSG_ERROR
, "Line %d: Invalid ipaddr_type_availability '%s'",
3331 bss
->ipaddr_type_configured
= 0;
3334 bss
->ipaddr_type_configured
= 1;
3335 } else if (os_strcmp(buf
, "domain_name") == 0) {
3336 int j
, num_domains
, domain_len
, domain_list_len
= 0;
3337 char *tok_start
, *tok_prev
;
3338 u8
*domain_list
, *domain_ptr
;
3340 domain_list_len
= os_strlen(pos
) + 1;
3341 domain_list
= os_malloc(domain_list_len
);
3342 if (domain_list
== NULL
)
3345 domain_ptr
= domain_list
;
3348 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
3353 for (j
= 0; j
< num_domains
; j
++) {
3354 tok_start
= os_strchr(tok_prev
, ',');
3356 domain_len
= tok_start
- tok_prev
;
3357 *domain_ptr
= domain_len
;
3358 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3359 domain_ptr
+= domain_len
+ 1;
3360 tok_prev
= ++tok_start
;
3362 domain_len
= os_strlen(tok_prev
);
3363 *domain_ptr
= domain_len
;
3364 os_memcpy(domain_ptr
+ 1, tok_prev
, domain_len
);
3365 domain_ptr
+= domain_len
+ 1;
3369 os_free(bss
->domain_name
);
3370 bss
->domain_name
= domain_list
;
3371 bss
->domain_name_len
= domain_list_len
;
3372 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
3373 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
3375 } else if (os_strcmp(buf
, "nai_realm") == 0) {
3376 if (parse_nai_realm(bss
, pos
, line
) < 0)
3378 } else if (os_strcmp(buf
, "anqp_elem") == 0) {
3379 if (parse_anqp_elem(bss
, pos
, line
) < 0)
3381 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
3382 int val
= atoi(pos
);
3385 wpa_printf(MSG_ERROR
,
3386 "Line %d: Invalid gas_frag_limit '%s'",
3390 bss
->gas_frag_limit
= val
;
3391 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
3392 bss
->gas_comeback_delay
= atoi(pos
);
3393 } else if (os_strcmp(buf
, "qos_map_set") == 0) {
3394 if (parse_qos_map_set(bss
, pos
, line
) < 0)
3396 #endif /* CONFIG_INTERWORKING */
3397 #ifdef CONFIG_RADIUS_TEST
3398 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
3399 os_free(bss
->dump_msk_file
);
3400 bss
->dump_msk_file
= os_strdup(pos
);
3401 #endif /* CONFIG_RADIUS_TEST */
3402 #ifdef CONFIG_PROXYARP
3403 } else if (os_strcmp(buf
, "proxy_arp") == 0) {
3404 bss
->proxy_arp
= atoi(pos
);
3405 #endif /* CONFIG_PROXYARP */
3407 } else if (os_strcmp(buf
, "hs20") == 0) {
3408 bss
->hs20
= atoi(pos
);
3409 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
3410 bss
->disable_dgaf
= atoi(pos
);
3411 } else if (os_strcmp(buf
, "na_mcast_to_ucast") == 0) {
3412 bss
->na_mcast_to_ucast
= atoi(pos
);
3413 } else if (os_strcmp(buf
, "osen") == 0) {
3414 bss
->osen
= atoi(pos
);
3415 } else if (os_strcmp(buf
, "anqp_domain_id") == 0) {
3416 bss
->anqp_domain_id
= atoi(pos
);
3417 } else if (os_strcmp(buf
, "hs20_deauth_req_timeout") == 0) {
3418 bss
->hs20_deauth_req_timeout
= atoi(pos
);
3419 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
3420 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
3422 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
3423 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0)
3425 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
3426 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
3429 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
3431 size_t oper_class_len
;
3432 oper_class_len
= os_strlen(pos
);
3433 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
3434 wpa_printf(MSG_ERROR
,
3435 "Line %d: Invalid hs20_operating_class '%s'",
3439 oper_class_len
/= 2;
3440 oper_class
= os_malloc(oper_class_len
);
3441 if (oper_class
== NULL
)
3443 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
3444 wpa_printf(MSG_ERROR
,
3445 "Line %d: Invalid hs20_operating_class '%s'",
3447 os_free(oper_class
);
3450 os_free(bss
->hs20_operating_class
);
3451 bss
->hs20_operating_class
= oper_class
;
3452 bss
->hs20_operating_class_len
= oper_class_len
;
3453 } else if (os_strcmp(buf
, "hs20_icon") == 0) {
3454 if (hs20_parse_icon(bss
, pos
) < 0) {
3455 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_icon '%s'",
3459 } else if (os_strcmp(buf
, "osu_ssid") == 0) {
3460 if (hs20_parse_osu_ssid(bss
, pos
, line
) < 0)
3462 } else if (os_strcmp(buf
, "osu_server_uri") == 0) {
3463 if (hs20_parse_osu_server_uri(bss
, pos
, line
) < 0)
3465 } else if (os_strcmp(buf
, "osu_friendly_name") == 0) {
3466 if (hs20_parse_osu_friendly_name(bss
, pos
, line
) < 0)
3468 } else if (os_strcmp(buf
, "osu_nai") == 0) {
3469 if (hs20_parse_osu_nai(bss
, pos
, line
) < 0)
3471 } else if (os_strcmp(buf
, "osu_method_list") == 0) {
3472 if (hs20_parse_osu_method_list(bss
, pos
, line
) < 0)
3474 } else if (os_strcmp(buf
, "osu_icon") == 0) {
3475 if (hs20_parse_osu_icon(bss
, pos
, line
) < 0)
3477 } else if (os_strcmp(buf
, "osu_service_desc") == 0) {
3478 if (hs20_parse_osu_service_desc(bss
, pos
, line
) < 0)
3480 } else if (os_strcmp(buf
, "subscr_remediation_url") == 0) {
3481 os_free(bss
->subscr_remediation_url
);
3482 bss
->subscr_remediation_url
= os_strdup(pos
);
3483 } else if (os_strcmp(buf
, "subscr_remediation_method") == 0) {
3484 bss
->subscr_remediation_method
= atoi(pos
);
3485 #endif /* CONFIG_HS20 */
3487 } else if (os_strcmp(buf
, "mbo") == 0) {
3488 bss
->mbo_enabled
= atoi(pos
);
3489 } else if (os_strcmp(buf
, "mbo_cell_data_conn_pref") == 0) {
3490 bss
->mbo_cell_data_conn_pref
= atoi(pos
);
3491 #endif /* CONFIG_MBO */
3492 #ifdef CONFIG_TESTING_OPTIONS
3493 #define PARSE_TEST_PROBABILITY(_val) \
3494 } else if (os_strcmp(buf, #_val) == 0) { \
3497 conf->_val = strtod(pos, &end); \
3498 if (*end || conf->_val < 0.0 || \
3499 conf->_val > 1.0) { \
3500 wpa_printf(MSG_ERROR, \
3501 "Line %d: Invalid value '%s'", \
3505 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
3506 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
3507 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
3508 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
3509 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
3510 } else if (os_strcmp(buf
, "ecsa_ie_only") == 0) {
3511 conf
->ecsa_ie_only
= atoi(pos
);
3512 } else if (os_strcmp(buf
, "bss_load_test") == 0) {
3513 WPA_PUT_LE16(bss
->bss_load_test
, atoi(pos
));
3514 pos
= os_strchr(pos
, ':');
3516 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
3521 bss
->bss_load_test
[2] = atoi(pos
);
3522 pos
= os_strchr(pos
, ':');
3524 wpa_printf(MSG_ERROR
, "Line %d: Invalid bss_load_test",
3529 WPA_PUT_LE16(&bss
->bss_load_test
[3], atoi(pos
));
3530 bss
->bss_load_test_set
= 1;
3531 } else if (os_strcmp(buf
, "radio_measurements") == 0) {
3533 * DEPRECATED: This parameter will be removed in the future.
3534 * Use rrm_neighbor_report instead.
3536 int val
= atoi(pos
);
3539 bss
->radio_measurements
[0] |=
3540 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
3541 } else if (os_strcmp(buf
, "own_ie_override") == 0) {
3543 size_t len
= os_strlen(pos
) / 2;
3545 tmp
= wpabuf_alloc(len
);
3549 if (hexstr2bin(pos
, wpabuf_put(tmp
, len
), len
)) {
3551 wpa_printf(MSG_ERROR
,
3552 "Line %d: Invalid own_ie_override '%s'",
3557 wpabuf_free(bss
->own_ie_override
);
3558 bss
->own_ie_override
= tmp
;
3559 #endif /* CONFIG_TESTING_OPTIONS */
3560 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
3561 if (parse_wpabuf_hex(line
, buf
, &bss
->vendor_elements
, pos
))
3563 } else if (os_strcmp(buf
, "assocresp_elements") == 0) {
3564 if (parse_wpabuf_hex(line
, buf
, &bss
->assocresp_elements
, pos
))
3566 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
3567 bss
->sae_anti_clogging_threshold
= atoi(pos
);
3568 } else if (os_strcmp(buf
, "sae_groups") == 0) {
3569 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
3570 wpa_printf(MSG_ERROR
,
3571 "Line %d: Invalid sae_groups value '%s'",
3575 } else if (os_strcmp(buf
, "local_pwr_constraint") == 0) {
3576 int val
= atoi(pos
);
3577 if (val
< 0 || val
> 255) {
3578 wpa_printf(MSG_ERROR
, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
3582 conf
->local_pwr_constraint
= val
;
3583 } else if (os_strcmp(buf
, "spectrum_mgmt_required") == 0) {
3584 conf
->spectrum_mgmt_required
= atoi(pos
);
3585 } else if (os_strcmp(buf
, "wowlan_triggers") == 0) {
3586 os_free(bss
->wowlan_triggers
);
3587 bss
->wowlan_triggers
= os_strdup(pos
);
3589 } else if (os_strcmp(buf
, "fst_group_id") == 0) {
3590 size_t len
= os_strlen(pos
);
3592 if (!len
|| len
>= sizeof(conf
->fst_cfg
.group_id
)) {
3593 wpa_printf(MSG_ERROR
,
3594 "Line %d: Invalid fst_group_id value '%s'",
3599 if (conf
->fst_cfg
.group_id
[0]) {
3600 wpa_printf(MSG_ERROR
,
3601 "Line %d: Duplicate fst_group value '%s'",
3606 os_strlcpy(conf
->fst_cfg
.group_id
, pos
,
3607 sizeof(conf
->fst_cfg
.group_id
));
3608 } else if (os_strcmp(buf
, "fst_priority") == 0) {
3613 wpa_printf(MSG_ERROR
,
3614 "Line %d: fst_priority value not supplied (expected 1..%u)",
3615 line
, FST_MAX_PRIO_VALUE
);
3619 val
= strtol(pos
, &endp
, 0);
3620 if (*endp
|| val
< 1 || val
> FST_MAX_PRIO_VALUE
) {
3621 wpa_printf(MSG_ERROR
,
3622 "Line %d: Invalid fst_priority %ld (%s) (expected 1..%u)",
3623 line
, val
, pos
, FST_MAX_PRIO_VALUE
);
3626 conf
->fst_cfg
.priority
= (u8
) val
;
3627 } else if (os_strcmp(buf
, "fst_llt") == 0) {
3632 wpa_printf(MSG_ERROR
,
3633 "Line %d: fst_llt value not supplied (expected 1..%u)",
3634 line
, FST_MAX_LLT_MS
);
3637 val
= strtol(pos
, &endp
, 0);
3638 if (*endp
|| val
< 1 ||
3639 (unsigned long int) val
> FST_MAX_LLT_MS
) {
3640 wpa_printf(MSG_ERROR
,
3641 "Line %d: Invalid fst_llt %ld (%s) (expected 1..%u)",
3642 line
, val
, pos
, FST_MAX_LLT_MS
);
3645 conf
->fst_cfg
.llt
= (u32
) val
;
3646 #endif /* CONFIG_FST */
3647 } else if (os_strcmp(buf
, "track_sta_max_num") == 0) {
3648 conf
->track_sta_max_num
= atoi(pos
);
3649 } else if (os_strcmp(buf
, "track_sta_max_age") == 0) {
3650 conf
->track_sta_max_age
= atoi(pos
);
3651 } else if (os_strcmp(buf
, "no_probe_resp_if_seen_on") == 0) {
3652 os_free(bss
->no_probe_resp_if_seen_on
);
3653 bss
->no_probe_resp_if_seen_on
= os_strdup(pos
);
3654 } else if (os_strcmp(buf
, "no_auth_if_seen_on") == 0) {
3655 os_free(bss
->no_auth_if_seen_on
);
3656 bss
->no_auth_if_seen_on
= os_strdup(pos
);
3657 } else if (os_strcmp(buf
, "lci") == 0) {
3658 wpabuf_free(conf
->lci
);
3659 conf
->lci
= wpabuf_parse_bin(pos
);
3660 if (conf
->lci
&& wpabuf_len(conf
->lci
) == 0) {
3661 wpabuf_free(conf
->lci
);
3664 } else if (os_strcmp(buf
, "civic") == 0) {
3665 wpabuf_free(conf
->civic
);
3666 conf
->civic
= wpabuf_parse_bin(pos
);
3667 if (conf
->civic
&& wpabuf_len(conf
->civic
) == 0) {
3668 wpabuf_free(conf
->civic
);
3671 } else if (os_strcmp(buf
, "rrm_neighbor_report") == 0) {
3673 bss
->radio_measurements
[0] |=
3674 WLAN_RRM_CAPS_NEIGHBOR_REPORT
;
3675 } else if (os_strcmp(buf
, "rrm_beacon_report") == 0) {
3677 bss
->radio_measurements
[0] |=
3678 WLAN_RRM_CAPS_BEACON_REPORT_PASSIVE
|
3679 WLAN_RRM_CAPS_BEACON_REPORT_ACTIVE
|
3680 WLAN_RRM_CAPS_BEACON_REPORT_TABLE
;
3681 } else if (os_strcmp(buf
, "gas_address3") == 0) {
3682 bss
->gas_address3
= atoi(pos
);
3683 } else if (os_strcmp(buf
, "stationary_ap") == 0) {
3684 conf
->stationary_ap
= atoi(pos
);
3685 } else if (os_strcmp(buf
, "ftm_responder") == 0) {
3686 bss
->ftm_responder
= atoi(pos
);
3687 } else if (os_strcmp(buf
, "ftm_initiator") == 0) {
3688 bss
->ftm_initiator
= atoi(pos
);
3690 } else if (os_strcmp(buf
, "fils_cache_id") == 0) {
3691 if (hexstr2bin(pos
, bss
->fils_cache_id
, FILS_CACHE_ID_LEN
)) {
3692 wpa_printf(MSG_ERROR
,
3693 "Line %d: Invalid fils_cache_id '%s'",
3697 bss
->fils_cache_id_set
= 1;
3698 } else if (os_strcmp(buf
, "fils_realm") == 0) {
3699 if (parse_fils_realm(bss
, pos
) < 0)
3701 } else if (os_strcmp(buf
, "fils_dh_group") == 0) {
3702 bss
->fils_dh_group
= atoi(pos
);
3703 } else if (os_strcmp(buf
, "dhcp_server") == 0) {
3704 if (hostapd_parse_ip_addr(pos
, &bss
->dhcp_server
)) {
3705 wpa_printf(MSG_ERROR
,
3706 "Line %d: invalid IP address '%s'",
3710 } else if (os_strcmp(buf
, "dhcp_rapid_commit_proxy") == 0) {
3711 bss
->dhcp_rapid_commit_proxy
= atoi(pos
);
3712 } else if (os_strcmp(buf
, "fils_hlp_wait_time") == 0) {
3713 bss
->fils_hlp_wait_time
= atoi(pos
);
3714 } else if (os_strcmp(buf
, "dhcp_server_port") == 0) {
3715 bss
->dhcp_server_port
= atoi(pos
);
3716 } else if (os_strcmp(buf
, "dhcp_relay_port") == 0) {
3717 bss
->dhcp_relay_port
= atoi(pos
);
3718 #endif /* CONFIG_FILS */
3719 } else if (os_strcmp(buf
, "multicast_to_unicast") == 0) {
3720 bss
->multicast_to_unicast
= atoi(pos
);
3721 } else if (os_strcmp(buf
, "broadcast_deauth") == 0) {
3722 bss
->broadcast_deauth
= atoi(pos
);
3724 } else if (os_strcmp(buf
, "dpp_connector") == 0) {
3725 os_free(bss
->dpp_connector
);
3726 bss
->dpp_connector
= os_strdup(pos
);
3727 } else if (os_strcmp(buf
, "dpp_netaccesskey") == 0) {
3728 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_netaccesskey
, pos
))
3730 } else if (os_strcmp(buf
, "dpp_netaccesskey_expiry") == 0) {
3731 bss
->dpp_netaccesskey_expiry
= strtol(pos
, NULL
, 0);
3732 } else if (os_strcmp(buf
, "dpp_csign") == 0) {
3733 if (parse_wpabuf_hex(line
, buf
, &bss
->dpp_csign
, pos
))
3735 } else if (os_strcmp(buf
, "dpp_csign_expiry") == 0) {
3736 bss
->dpp_csign_expiry
= strtol(pos
, NULL
, 0);
3737 #endif /* CONFIG_DPP */
3739 wpa_printf(MSG_ERROR
,
3740 "Line %d: unknown configuration item '%s'",
3750 * hostapd_config_read - Read and parse a configuration file
3751 * @fname: Configuration file name (including path, if needed)
3752 * Returns: Allocated configuration data structure
3754 struct hostapd_config
* hostapd_config_read(const char *fname
)
3756 struct hostapd_config
*conf
;
3758 char buf
[4096], *pos
;
3763 f
= fopen(fname
, "r");
3765 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
3766 "for reading.", fname
);
3770 conf
= hostapd_config_defaults();
3776 /* set default driver based on configuration */
3777 conf
->driver
= wpa_drivers
[0];
3778 if (conf
->driver
== NULL
) {
3779 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
3780 hostapd_config_free(conf
);
3785 conf
->last_bss
= conf
->bss
[0];
3787 while (fgets(buf
, sizeof(buf
), f
)) {
3788 struct hostapd_bss_config
*bss
;
3790 bss
= conf
->last_bss
;
3796 while (*pos
!= '\0') {
3806 pos
= os_strchr(buf
, '=');
3808 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
3815 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
3820 for (i
= 0; i
< conf
->num_bss
; i
++)
3821 hostapd_set_security_params(conf
->bss
[i
], 1);
3823 if (hostapd_config_check(conf
, 1))
3826 #ifndef WPA_IGNORE_CONFIG_ERRORS
3828 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
3829 "'%s'", errors
, fname
);
3830 hostapd_config_free(conf
);
3833 #endif /* WPA_IGNORE_CONFIG_ERRORS */
3839 int hostapd_set_iface(struct hostapd_config
*conf
,
3840 struct hostapd_bss_config
*bss
, const char *field
,
3846 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
3848 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
3849 "to value '%s'", field
, value
);
3853 for (i
= 0; i
< conf
->num_bss
; i
++)
3854 hostapd_set_security_params(conf
->bss
[i
], 0);
3856 if (hostapd_config_check(conf
, 0)) {
3857 wpa_printf(MSG_ERROR
, "Configuration check failed");