2 * hostapd / Configuration file parser
3 * Copyright (c) 2003-2014, 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 "drivers/driver.h"
18 #include "eap_server/eap.h"
19 #include "radius/radius_client.h"
20 #include "ap/wpa_auth.h"
21 #include "ap/ap_config.h"
22 #include "config_file.h"
25 #ifndef CONFIG_NO_VLAN
26 static int hostapd_config_read_vlan_file(struct hostapd_bss_config
*bss
,
30 char buf
[128], *pos
, *pos2
;
31 int line
= 0, vlan_id
;
32 struct hostapd_vlan
*vlan
;
34 f
= fopen(fname
, "r");
36 wpa_printf(MSG_ERROR
, "VLAN file '%s' not readable.", fname
);
40 while (fgets(buf
, sizeof(buf
), f
)) {
46 while (*pos
!= '\0') {
57 vlan_id
= VLAN_ID_WILDCARD
;
60 vlan_id
= strtol(buf
, &pos
, 10);
61 if (buf
== pos
|| vlan_id
< 1 ||
62 vlan_id
> MAX_VLAN_ID
) {
63 wpa_printf(MSG_ERROR
, "Invalid VLAN ID at "
64 "line %d in '%s'", line
, fname
);
70 while (*pos
== ' ' || *pos
== '\t')
73 while (*pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '\0')
76 if (*pos
== '\0' || os_strlen(pos
) > IFNAMSIZ
) {
77 wpa_printf(MSG_ERROR
, "Invalid VLAN ifname at line %d "
78 "in '%s'", line
, fname
);
83 vlan
= os_zalloc(sizeof(*vlan
));
85 wpa_printf(MSG_ERROR
, "Out of memory while reading "
86 "VLAN interfaces from '%s'", fname
);
91 vlan
->vlan_id
= vlan_id
;
92 os_strlcpy(vlan
->ifname
, pos
, sizeof(vlan
->ifname
));
93 vlan
->next
= bss
->vlan
;
101 #endif /* CONFIG_NO_VLAN */
104 static int hostapd_acl_comp(const void *a
, const void *b
)
106 const struct mac_acl_entry
*aa
= a
;
107 const struct mac_acl_entry
*bb
= b
;
108 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
112 static int hostapd_config_read_maclist(const char *fname
,
113 struct mac_acl_entry
**acl
, int *num
)
119 struct mac_acl_entry
*newacl
;
125 f
= fopen(fname
, "r");
127 wpa_printf(MSG_ERROR
, "MAC list file '%s' not found.", fname
);
131 while (fgets(buf
, sizeof(buf
), f
)) {
139 while (*pos
!= '\0') {
154 if (hwaddr_aton(pos
, addr
)) {
155 wpa_printf(MSG_ERROR
, "Invalid MAC address '%s' at "
156 "line %d in '%s'", pos
, line
, fname
);
164 if (os_memcmp((*acl
)[i
].addr
, addr
, ETH_ALEN
) ==
166 os_remove_in_array(*acl
, *num
,
176 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
178 while (*pos
== ' ' || *pos
== '\t')
183 newacl
= os_realloc_array(*acl
, *num
+ 1, sizeof(**acl
));
184 if (newacl
== NULL
) {
185 wpa_printf(MSG_ERROR
, "MAC list reallocation failed");
191 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
192 (*acl
)[*num
].vlan_id
= vlan_id
;
198 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
205 static int hostapd_config_read_eap_user(const char *fname
,
206 struct hostapd_bss_config
*conf
)
209 char buf
[512], *pos
, *start
, *pos2
;
210 int line
= 0, ret
= 0, num_methods
;
211 struct hostapd_eap_user
*user
, *tail
= NULL
;
216 if (os_strncmp(fname
, "sqlite:", 7) == 0) {
217 os_free(conf
->eap_user_sqlite
);
218 conf
->eap_user_sqlite
= os_strdup(fname
+ 7);
222 f
= fopen(fname
, "r");
224 wpa_printf(MSG_ERROR
, "EAP user file '%s' not found.", fname
);
228 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
229 while (fgets(buf
, sizeof(buf
), f
)) {
235 while (*pos
!= '\0') {
247 if (buf
[0] != '"' && buf
[0] != '*') {
248 wpa_printf(MSG_ERROR
, "Invalid EAP identity (no \" in "
249 "start) on line %d in '%s'", line
, fname
);
253 user
= os_zalloc(sizeof(*user
));
255 wpa_printf(MSG_ERROR
, "EAP user allocation failed");
258 user
->force_version
= -1;
265 while (*pos
!= '"' && *pos
!= '\0')
268 wpa_printf(MSG_ERROR
, "Invalid EAP identity "
269 "(no \" in end) on line %d in '%s'",
274 user
->identity
= os_malloc(pos
- start
);
275 if (user
->identity
== NULL
) {
276 wpa_printf(MSG_ERROR
, "Failed to allocate "
277 "memory for EAP identity");
280 os_memcpy(user
->identity
, start
, pos
- start
);
281 user
->identity_len
= pos
- start
;
283 if (pos
[0] == '"' && pos
[1] == '*') {
284 user
->wildcard_prefix
= 1;
289 while (*pos
== ' ' || *pos
== '\t')
293 wpa_printf(MSG_ERROR
, "No EAP method on line %d in "
294 "'%s'", line
, fname
);
299 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
309 char *pos3
= os_strchr(start
, ',');
313 user
->methods
[num_methods
].method
=
316 &user
->methods
[num_methods
].vendor
);
317 if (user
->methods
[num_methods
].vendor
==
319 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
321 if (os_strcmp(start
, "TTLS-PAP") == 0) {
322 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
325 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
326 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
329 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
331 EAP_TTLS_AUTH_MSCHAP
;
334 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
336 EAP_TTLS_AUTH_MSCHAPV2
;
339 wpa_printf(MSG_ERROR
, "Unsupported EAP type "
340 "'%s' on line %d in '%s'",
346 if (num_methods
>= EAP_MAX_METHODS
)
353 if (num_methods
== 0 && user
->ttls_auth
== 0) {
354 wpa_printf(MSG_ERROR
, "No EAP types configured on "
355 "line %d in '%s'", line
, fname
);
362 while (*pos
== ' ' || *pos
== '\t')
367 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
368 user
->force_version
= 0;
372 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
373 user
->force_version
= 1;
377 if (os_strncmp(pos
, "[2]", 3) == 0) {
385 while (*pos
!= '"' && *pos
!= '\0')
388 wpa_printf(MSG_ERROR
, "Invalid EAP password "
389 "(no \" in end) on line %d in '%s'",
394 user
->password
= os_malloc(pos
- start
);
395 if (user
->password
== NULL
) {
396 wpa_printf(MSG_ERROR
, "Failed to allocate "
397 "memory for EAP password");
400 os_memcpy(user
->password
, start
, pos
- start
);
401 user
->password_len
= pos
- start
;
404 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
407 while (*pos2
!= '\0' && *pos2
!= ' ' &&
408 *pos2
!= '\t' && *pos2
!= '#')
410 if (pos2
- pos
!= 32) {
411 wpa_printf(MSG_ERROR
, "Invalid password hash "
412 "on line %d in '%s'", line
, fname
);
415 user
->password
= os_malloc(16);
416 if (user
->password
== NULL
) {
417 wpa_printf(MSG_ERROR
, "Failed to allocate "
418 "memory for EAP password hash");
421 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
422 wpa_printf(MSG_ERROR
, "Invalid hash password "
423 "on line %d in '%s'", line
, fname
);
426 user
->password_len
= 16;
427 user
->password_hash
= 1;
431 while (*pos2
!= '\0' && *pos2
!= ' ' &&
432 *pos2
!= '\t' && *pos2
!= '#')
434 if ((pos2
- pos
) & 1) {
435 wpa_printf(MSG_ERROR
, "Invalid hex password "
436 "on line %d in '%s'", line
, fname
);
439 user
->password
= os_malloc((pos2
- pos
) / 2);
440 if (user
->password
== NULL
) {
441 wpa_printf(MSG_ERROR
, "Failed to allocate "
442 "memory for EAP password");
445 if (hexstr2bin(pos
, user
->password
,
446 (pos2
- pos
) / 2) < 0) {
447 wpa_printf(MSG_ERROR
, "Invalid hex password "
448 "on line %d in '%s'", line
, fname
);
451 user
->password_len
= (pos2
- pos
) / 2;
455 while (*pos
== ' ' || *pos
== '\t')
457 if (os_strncmp(pos
, "[2]", 3) == 0) {
463 tail
= conf
->eap_user
= user
;
472 os_free(user
->password
);
473 os_free(user
->identity
);
484 #endif /* EAP_SERVER */
487 #ifndef CONFIG_NO_RADIUS
489 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
490 int *num_server
, const char *val
, int def_port
,
491 struct hostapd_radius_server
**curr_serv
)
493 struct hostapd_radius_server
*nserv
;
495 static int server_index
= 1;
497 nserv
= os_realloc_array(*server
, *num_server
+ 1, sizeof(*nserv
));
502 nserv
= &nserv
[*num_server
];
504 (*curr_serv
) = nserv
;
506 os_memset(nserv
, 0, sizeof(*nserv
));
507 nserv
->port
= def_port
;
508 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
509 nserv
->index
= server_index
++;
515 static struct hostapd_radius_attr
*
516 hostapd_parse_radius_attr(const char *value
)
520 struct hostapd_radius_attr
*attr
;
523 attr
= os_zalloc(sizeof(*attr
));
527 attr
->type
= atoi(value
);
529 pos
= os_strchr(value
, ':');
531 attr
->val
= wpabuf_alloc(1);
532 if (attr
->val
== NULL
) {
536 wpabuf_put_u8(attr
->val
, 0);
541 if (pos
[0] == '\0' || pos
[1] != ':') {
550 attr
->val
= wpabuf_alloc_copy(pos
, os_strlen(pos
));
553 len
= os_strlen(pos
);
557 attr
->val
= wpabuf_alloc(len
);
558 if (attr
->val
== NULL
)
560 if (hexstr2bin(pos
, wpabuf_put(attr
->val
, len
), len
) < 0) {
561 wpabuf_free(attr
->val
);
567 attr
->val
= wpabuf_alloc(4);
569 wpabuf_put_be32(attr
->val
, atoi(pos
));
576 if (attr
->val
== NULL
) {
585 static int hostapd_parse_das_client(struct hostapd_bss_config
*bss
,
590 secret
= os_strchr(val
, ' ');
596 if (hostapd_parse_ip_addr(val
, &bss
->radius_das_client_addr
))
599 os_free(bss
->radius_das_shared_secret
);
600 bss
->radius_das_shared_secret
= (u8
*) os_strdup(secret
);
601 if (bss
->radius_das_shared_secret
== NULL
)
603 bss
->radius_das_shared_secret_len
= os_strlen(secret
);
607 #endif /* CONFIG_NO_RADIUS */
610 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
613 char *start
, *end
, *buf
;
615 buf
= os_strdup(value
);
620 while (*start
!= '\0') {
621 while (*start
== ' ' || *start
== '\t')
626 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
630 if (os_strcmp(start
, "WPA-PSK") == 0)
631 val
|= WPA_KEY_MGMT_PSK
;
632 else if (os_strcmp(start
, "WPA-EAP") == 0)
633 val
|= WPA_KEY_MGMT_IEEE8021X
;
634 #ifdef CONFIG_IEEE80211R
635 else if (os_strcmp(start
, "FT-PSK") == 0)
636 val
|= WPA_KEY_MGMT_FT_PSK
;
637 else if (os_strcmp(start
, "FT-EAP") == 0)
638 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
639 #endif /* CONFIG_IEEE80211R */
640 #ifdef CONFIG_IEEE80211W
641 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
642 val
|= WPA_KEY_MGMT_PSK_SHA256
;
643 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
644 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
645 #endif /* CONFIG_IEEE80211W */
647 else if (os_strcmp(start
, "SAE") == 0)
648 val
|= WPA_KEY_MGMT_SAE
;
649 else if (os_strcmp(start
, "FT-SAE") == 0)
650 val
|= WPA_KEY_MGMT_FT_SAE
;
651 #endif /* CONFIG_SAE */
653 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
666 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
667 "configured.", line
);
675 static int hostapd_config_parse_cipher(int line
, const char *value
)
677 int val
= wpa_parse_cipher(value
);
679 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
684 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
692 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
695 size_t len
= os_strlen(val
);
697 if (keyidx
< 0 || keyidx
> 3 || wep
->key
[keyidx
] != NULL
)
701 if (len
< 2 || val
[len
- 1] != '"')
704 wep
->key
[keyidx
] = os_malloc(len
);
705 if (wep
->key
[keyidx
] == NULL
)
707 os_memcpy(wep
->key
[keyidx
], val
+ 1, len
);
708 wep
->len
[keyidx
] = len
;
713 wep
->key
[keyidx
] = os_malloc(len
);
714 if (wep
->key
[keyidx
] == NULL
)
716 wep
->len
[keyidx
] = len
;
717 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
727 static int hostapd_parse_intlist(int **int_list
, char *val
)
738 while (*pos
!= '\0') {
744 list
= os_malloc(sizeof(int) * (count
+ 2));
749 while (*pos
!= '\0') {
750 end
= os_strchr(pos
, ' ');
754 list
[count
++] = atoi(pos
);
766 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
768 struct hostapd_bss_config
**all
, *bss
;
773 all
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
774 sizeof(struct hostapd_bss_config
*));
776 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
782 bss
= os_zalloc(sizeof(*bss
));
785 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
786 if (bss
->radius
== NULL
) {
787 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
788 "multi-BSS RADIUS data");
793 conf
->bss
[conf
->num_bss
++] = bss
;
794 conf
->last_bss
= bss
;
796 hostapd_config_defaults_bss(bss
);
797 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
798 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
804 /* convert floats with one decimal place to value*10 int, i.e.,
805 * "1.5" will return 15 */
806 static int hostapd_config_read_int10(const char *value
)
812 pos
= os_strchr(value
, '.');
816 if (*pos
>= '0' && *pos
<= '9')
824 static int valid_cw(int cw
)
826 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
827 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023);
832 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
833 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
834 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
835 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
838 static int hostapd_config_tx_queue(struct hostapd_config
*conf
, char *name
,
843 struct hostapd_tx_queue_params
*queue
;
845 /* skip 'tx_queue_' prefix */
847 if (os_strncmp(pos
, "data", 4) == 0 &&
848 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
851 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
852 os_strncmp(pos
, "beacon_", 7) == 0) {
853 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
856 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
860 if (num
>= NUM_TX_QUEUES
) {
861 /* for backwards compatibility, do not trigger failure */
862 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
866 queue
= &conf
->tx_queue
[num
];
868 if (os_strcmp(pos
, "aifs") == 0) {
869 queue
->aifs
= atoi(val
);
870 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
871 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
875 } else if (os_strcmp(pos
, "cwmin") == 0) {
876 queue
->cwmin
= atoi(val
);
877 if (!valid_cw(queue
->cwmin
)) {
878 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
882 } else if (os_strcmp(pos
, "cwmax") == 0) {
883 queue
->cwmax
= atoi(val
);
884 if (!valid_cw(queue
->cwmax
)) {
885 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
889 } else if (os_strcmp(pos
, "burst") == 0) {
890 queue
->burst
= hostapd_config_read_int10(val
);
892 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
900 #ifdef CONFIG_IEEE80211R
901 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
903 struct ft_remote_r0kh
*r0kh
;
906 r0kh
= os_zalloc(sizeof(*r0kh
));
910 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
912 next
= os_strchr(pos
, ' ');
915 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
916 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
922 next
= os_strchr(pos
, ' ');
925 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
926 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
930 r0kh
->id_len
= next
- pos
- 1;
931 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
934 if (hexstr2bin(pos
, r0kh
->key
, sizeof(r0kh
->key
))) {
935 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
940 r0kh
->next
= bss
->r0kh_list
;
941 bss
->r0kh_list
= r0kh
;
947 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
949 struct ft_remote_r1kh
*r1kh
;
952 r1kh
= os_zalloc(sizeof(*r1kh
));
956 /* 02:01:02:03:04:05 02:01:02:03:04:05
957 * 000102030405060708090a0b0c0d0e0f */
959 next
= os_strchr(pos
, ' ');
962 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
963 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
969 next
= os_strchr(pos
, ' ');
972 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
973 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
979 if (hexstr2bin(pos
, r1kh
->key
, sizeof(r1kh
->key
))) {
980 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
985 r1kh
->next
= bss
->r1kh_list
;
986 bss
->r1kh_list
= r1kh
;
990 #endif /* CONFIG_IEEE80211R */
993 #ifdef CONFIG_IEEE80211N
994 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
997 if (os_strstr(capab
, "[LDPC]"))
998 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
999 if (os_strstr(capab
, "[HT40-]")) {
1000 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1001 conf
->secondary_channel
= -1;
1003 if (os_strstr(capab
, "[HT40+]")) {
1004 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
1005 conf
->secondary_channel
= 1;
1007 if (os_strstr(capab
, "[SMPS-STATIC]")) {
1008 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1009 conf
->ht_capab
|= HT_CAP_INFO_SMPS_STATIC
;
1011 if (os_strstr(capab
, "[SMPS-DYNAMIC]")) {
1012 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
1013 conf
->ht_capab
|= HT_CAP_INFO_SMPS_DYNAMIC
;
1015 if (os_strstr(capab
, "[GF]"))
1016 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
1017 if (os_strstr(capab
, "[SHORT-GI-20]"))
1018 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1019 if (os_strstr(capab
, "[SHORT-GI-40]"))
1020 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1021 if (os_strstr(capab
, "[TX-STBC]"))
1022 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1023 if (os_strstr(capab
, "[RX-STBC1]")) {
1024 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1025 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1027 if (os_strstr(capab
, "[RX-STBC12]")) {
1028 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1029 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1031 if (os_strstr(capab
, "[RX-STBC123]")) {
1032 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1033 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1035 if (os_strstr(capab
, "[DELAYED-BA]"))
1036 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1037 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1038 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1039 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1040 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1041 if (os_strstr(capab
, "[PSMP]"))
1042 conf
->ht_capab
|= HT_CAP_INFO_PSMP_SUPP
;
1043 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1044 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1048 #endif /* CONFIG_IEEE80211N */
1051 #ifdef CONFIG_IEEE80211AC
1052 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1055 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1056 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1057 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1058 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1059 if (os_strstr(capab
, "[VHT160]"))
1060 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1061 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1062 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1063 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1064 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1065 if (os_strstr(capab
, "[RXLDPC]"))
1066 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1067 if (os_strstr(capab
, "[SHORT-GI-80]"))
1068 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1069 if (os_strstr(capab
, "[SHORT-GI-160]"))
1070 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1071 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1072 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1073 if (os_strstr(capab
, "[RX-STBC-1]"))
1074 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1075 if (os_strstr(capab
, "[RX-STBC-12]"))
1076 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1077 if (os_strstr(capab
, "[RX-STBC-123]"))
1078 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1079 if (os_strstr(capab
, "[RX-STBC-1234]"))
1080 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1081 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1082 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMER_CAPABLE
;
1083 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1084 conf
->vht_capab
|= VHT_CAP_SU_BEAMFORMEE_CAPABLE
;
1085 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1086 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMEE_CAPABLE
))
1087 conf
->vht_capab
|= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET
);
1088 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1089 (conf
->vht_capab
& VHT_CAP_SU_BEAMFORMER_CAPABLE
))
1090 conf
->vht_capab
|= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET
);
1091 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1092 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1093 if (os_strstr(capab
, "[MU-BEAMFORMEE]"))
1094 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMEE_CAPABLE
;
1095 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1096 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1097 if (os_strstr(capab
, "[HTC-VHT]"))
1098 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1099 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP0]"))
1100 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT
;
1101 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1102 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1103 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1104 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1105 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1106 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1107 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1108 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1109 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1110 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1113 #endif /* CONFIG_IEEE80211AC */
1116 #ifdef CONFIG_INTERWORKING
1117 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1120 size_t len
= os_strlen(pos
);
1121 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1123 struct hostapd_roaming_consortium
*rc
;
1125 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1126 hexstr2bin(pos
, oi
, len
/ 2)) {
1127 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1133 rc
= os_realloc_array(bss
->roaming_consortium
,
1134 bss
->roaming_consortium_count
+ 1,
1135 sizeof(struct hostapd_roaming_consortium
));
1139 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1140 rc
[bss
->roaming_consortium_count
].len
= len
;
1142 bss
->roaming_consortium
= rc
;
1143 bss
->roaming_consortium_count
++;
1149 static int parse_lang_string(struct hostapd_lang_string
**array
,
1150 unsigned int *count
, char *pos
)
1152 char *sep
, *str
= NULL
;
1153 size_t clen
, nlen
, slen
;
1154 struct hostapd_lang_string
*ls
;
1157 if (*pos
== '"' || (*pos
== 'P' && pos
[1] == '"')) {
1158 str
= wpa_config_parse_string(pos
, &slen
);
1164 sep
= os_strchr(pos
, ':');
1169 clen
= os_strlen(pos
);
1170 if (clen
< 2 || clen
> sizeof(ls
->lang
))
1172 nlen
= os_strlen(sep
);
1176 ls
= os_realloc_array(*array
, *count
+ 1,
1177 sizeof(struct hostapd_lang_string
));
1182 ls
= &(*array
)[*count
];
1185 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1186 os_memcpy(ls
->lang
, pos
, clen
);
1187 ls
->name_len
= nlen
;
1188 os_memcpy(ls
->name
, sep
, nlen
);
1197 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1200 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1201 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1209 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1214 u8
*info
= NULL
, *ipos
;
1216 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1219 for (pos
= buf
; *pos
; pos
++) {
1220 if ((*pos
< '0' && *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1225 if (1 + count
* 3 > 0x7f)
1228 info
= os_zalloc(2 + 3 + count
* 3);
1233 *ipos
++ = 0; /* GUD - Version 1 */
1234 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1235 *ipos
++ = 0; /* PLMN List IEI */
1236 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1237 *ipos
++ = 1 + count
* 3;
1238 *ipos
++ = count
; /* Number of PLMNs */
1241 while (pos
&& *pos
) {
1246 mnc
= os_strchr(pos
, ',');
1250 pos
= os_strchr(mnc
, ';');
1254 mnc_len
= os_strlen(mnc
);
1255 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1258 /* BC coded MCC,MNC */
1259 /* MCC digit 2 | MCC digit 1 */
1260 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1261 /* MNC digit 3 | MCC digit 3 */
1262 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1264 /* MNC digit 2 | MNC digit 1 */
1265 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1268 os_free(bss
->anqp_3gpp_cell_net
);
1269 bss
->anqp_3gpp_cell_net
= info
;
1270 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1271 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1272 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1277 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1284 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1286 struct hostapd_nai_realm_data
*realm
;
1289 char *pos
, *end
, *rpos
;
1291 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1293 if (offsets
== NULL
)
1296 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1297 realm
= &bss
->nai_realm_data
[i
];
1298 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1299 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1301 realm
->realm
[j
] - realm
->realm_buf
: -1;
1305 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1306 sizeof(struct hostapd_nai_realm_data
));
1307 if (realm
== NULL
) {
1311 bss
->nai_realm_data
= realm
;
1313 /* patch the pointers after realloc */
1314 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1315 realm
= &bss
->nai_realm_data
[i
];
1316 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1317 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1319 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1321 realm
->realm
[j
] = NULL
;
1326 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1327 os_memset(realm
, 0, sizeof(*realm
));
1330 realm
->encoding
= atoi(pos
);
1331 pos
= os_strchr(pos
, ',');
1336 end
= os_strchr(pos
, ',');
1341 len
= os_strlen(pos
);
1344 if (len
> MAX_NAI_REALMLEN
) {
1345 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1346 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1349 os_memcpy(realm
->realm_buf
, pos
, len
);
1356 while (pos
&& *pos
) {
1357 struct hostapd_nai_realm_eap
*eap
;
1359 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1360 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1364 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1365 realm
->eap_method_count
++;
1367 end
= os_strchr(pos
, ',');
1369 end
= pos
+ os_strlen(pos
);
1371 eap
->eap_method
= atoi(pos
);
1373 pos
= os_strchr(pos
, '[');
1374 if (pos
== NULL
|| pos
> end
)
1377 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1378 wpa_printf(MSG_ERROR
, "Too many auth params");
1381 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1382 pos
= os_strchr(pos
, ':');
1383 if (pos
== NULL
|| pos
> end
)
1386 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1387 pos
= os_strchr(pos
, ']');
1388 if (pos
== NULL
|| pos
> end
)
1400 /* Split realm list into null terminated realms */
1401 rpos
= realm
->realm_buf
;
1404 if (i
>= MAX_NAI_REALMS
) {
1405 wpa_printf(MSG_ERROR
, "Too many realms");
1408 realm
->realm
[i
++] = rpos
;
1409 rpos
= os_strchr(rpos
, ';');
1415 bss
->nai_realm_count
++;
1420 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1425 static int parse_qos_map_set(struct hostapd_bss_config
*bss
,
1426 char *buf
, int line
)
1428 u8 qos_map_set
[16 + 2 * 21], count
= 0;
1433 if (count
== sizeof(qos_map_set
)) {
1434 wpa_printf(MSG_ERROR
, "Line %d: Too many qos_map_set "
1435 "parameters '%s'", line
, buf
);
1440 if (val
> 255 || val
< 0) {
1441 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set "
1446 qos_map_set
[count
++] = val
;
1447 pos
= os_strchr(pos
, ',');
1453 if (count
< 16 || count
& 1) {
1454 wpa_printf(MSG_ERROR
, "Line %d: Invalid qos_map_set '%s'",
1459 os_memcpy(bss
->qos_map_set
, qos_map_set
, count
);
1460 bss
->qos_map_set_len
= count
;
1465 #endif /* CONFIG_INTERWORKING */
1469 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1475 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1478 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1479 bss
->hs20_connection_capability_len
+ 4);
1480 if (conn_cap
== NULL
)
1483 bss
->hs20_connection_capability
= conn_cap
;
1484 conn_cap
+= bss
->hs20_connection_capability_len
;
1486 conn_cap
[0] = atoi(pos
);
1487 pos
= os_strchr(pos
, ':');
1491 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1492 pos
= os_strchr(pos
, ':');
1496 conn_cap
[3] = atoi(pos
);
1497 bss
->hs20_connection_capability_len
+= 4;
1503 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1509 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1511 wan_metrics
= os_zalloc(13);
1512 if (wan_metrics
== NULL
)
1517 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1524 /* Downlink Speed */
1525 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1526 pos
= os_strchr(pos
, ':');
1532 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1533 pos
= os_strchr(pos
, ':');
1539 wan_metrics
[9] = atoi(pos
);
1540 pos
= os_strchr(pos
, ':');
1546 wan_metrics
[10] = atoi(pos
);
1547 pos
= os_strchr(pos
, ':');
1553 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1555 os_free(bss
->hs20_wan_metrics
);
1556 bss
->hs20_wan_metrics
= wan_metrics
;
1561 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1563 os_free(wan_metrics
);
1568 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1569 char *pos
, int line
)
1571 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1572 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1573 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1574 "hs20_oper_friendly_name '%s'", line
, pos
);
1579 #endif /* CONFIG_HS20 */
1582 #ifdef CONFIG_WPS_NFC
1583 static struct wpabuf
* hostapd_parse_bin(const char *buf
)
1588 len
= os_strlen(buf
);
1593 ret
= wpabuf_alloc(len
);
1597 if (hexstr2bin(buf
, wpabuf_put(ret
, len
), len
)) {
1604 #endif /* CONFIG_WPS_NFC */
1607 static int hostapd_config_fill(struct hostapd_config
*conf
,
1608 struct hostapd_bss_config
*bss
,
1609 char *buf
, char *pos
, int line
)
1614 if (os_strcmp(buf
, "interface") == 0) {
1615 os_strlcpy(conf
->bss
[0]->iface
, pos
,
1616 sizeof(conf
->bss
[0]->iface
));
1617 } else if (os_strcmp(buf
, "bridge") == 0) {
1618 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
1619 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
1620 os_strlcpy(bss
->vlan_bridge
, pos
,
1621 sizeof(bss
->vlan_bridge
));
1622 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
1623 os_strlcpy(bss
->wds_bridge
, pos
,
1624 sizeof(bss
->wds_bridge
));
1625 } else if (os_strcmp(buf
, "driver") == 0) {
1627 /* clear to get error below if setting is invalid */
1628 conf
->driver
= NULL
;
1629 for (j
= 0; wpa_drivers
[j
]; j
++) {
1630 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0)
1632 conf
->driver
= wpa_drivers
[j
];
1636 if (conf
->driver
== NULL
) {
1637 wpa_printf(MSG_ERROR
, "Line %d: invalid/"
1638 "unknown driver '%s'", line
, pos
);
1641 } else if (os_strcmp(buf
, "debug") == 0) {
1642 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' "
1643 "configuration variable is not used "
1645 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
1646 bss
->logger_syslog_level
= atoi(pos
);
1647 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
1648 bss
->logger_stdout_level
= atoi(pos
);
1649 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
1650 bss
->logger_syslog
= atoi(pos
);
1651 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
1652 bss
->logger_stdout
= atoi(pos
);
1653 } else if (os_strcmp(buf
, "dump_file") == 0) {
1654 wpa_printf(MSG_INFO
, "Line %d: DEPRECATED: 'dump_file' configuration variable is not used anymore",
1656 } else if (os_strcmp(buf
, "ssid") == 0) {
1657 bss
->ssid
.ssid_len
= os_strlen(pos
);
1658 if (bss
->ssid
.ssid_len
> HOSTAPD_MAX_SSID_LEN
||
1659 bss
->ssid
.ssid_len
< 1) {
1660 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID "
1664 os_memcpy(bss
->ssid
.ssid
, pos
,
1665 bss
->ssid
.ssid_len
);
1666 bss
->ssid
.ssid_set
= 1;
1668 } else if (os_strcmp(buf
, "ssid2") == 0) {
1670 char *str
= wpa_config_parse_string(pos
, &slen
);
1671 if (str
== NULL
|| slen
< 1 ||
1672 slen
> HOSTAPD_MAX_SSID_LEN
) {
1673 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID "
1677 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
1678 bss
->ssid
.ssid_len
= slen
;
1679 bss
->ssid
.ssid_set
= 1;
1682 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
1683 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
1684 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
1685 bss
->macaddr_acl
= atoi(pos
);
1686 if (bss
->macaddr_acl
!= ACCEPT_UNLESS_DENIED
&&
1687 bss
->macaddr_acl
!= DENY_UNLESS_ACCEPTED
&&
1688 bss
->macaddr_acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
1689 wpa_printf(MSG_ERROR
, "Line %d: unknown "
1691 line
, bss
->macaddr_acl
);
1693 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
1694 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
1695 &bss
->num_accept_mac
))
1697 wpa_printf(MSG_ERROR
, "Line %d: Failed to "
1698 "read accept_mac_file '%s'",
1702 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
1703 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
1704 &bss
->num_deny_mac
)) {
1705 wpa_printf(MSG_ERROR
, "Line %d: Failed to "
1706 "read deny_mac_file '%s'",
1710 } else if (os_strcmp(buf
, "wds_sta") == 0) {
1711 bss
->wds_sta
= atoi(pos
);
1712 } else if (os_strcmp(buf
, "start_disabled") == 0) {
1713 bss
->start_disabled
= atoi(pos
);
1714 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
1715 bss
->isolate
= atoi(pos
);
1716 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
1717 bss
->ap_max_inactivity
= atoi(pos
);
1718 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
1719 bss
->skip_inactivity_poll
= atoi(pos
);
1720 } else if (os_strcmp(buf
, "country_code") == 0) {
1721 os_memcpy(conf
->country
, pos
, 2);
1722 /* FIX: make this configurable */
1723 conf
->country
[2] = ' ';
1724 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
1725 conf
->ieee80211d
= atoi(pos
);
1726 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
1727 conf
->ieee80211h
= atoi(pos
);
1728 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
1729 bss
->ieee802_1x
= atoi(pos
);
1730 } else if (os_strcmp(buf
, "eapol_version") == 0) {
1731 bss
->eapol_version
= atoi(pos
);
1732 if (bss
->eapol_version
< 1 ||
1733 bss
->eapol_version
> 2) {
1734 wpa_printf(MSG_ERROR
, "Line %d: invalid EAPOL "
1735 "version (%d): '%s'.",
1736 line
, bss
->eapol_version
, pos
);
1739 wpa_printf(MSG_DEBUG
, "eapol_version=%d",
1740 bss
->eapol_version
);
1742 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
1743 bss
->eap_server
= atoi(pos
);
1744 wpa_printf(MSG_ERROR
, "Line %d: obsolete "
1745 "eap_authenticator used; this has been "
1746 "renamed to eap_server", line
);
1747 } else if (os_strcmp(buf
, "eap_server") == 0) {
1748 bss
->eap_server
= atoi(pos
);
1749 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
1750 if (hostapd_config_read_eap_user(pos
, bss
))
1752 } else if (os_strcmp(buf
, "ca_cert") == 0) {
1753 os_free(bss
->ca_cert
);
1754 bss
->ca_cert
= os_strdup(pos
);
1755 } else if (os_strcmp(buf
, "server_cert") == 0) {
1756 os_free(bss
->server_cert
);
1757 bss
->server_cert
= os_strdup(pos
);
1758 } else if (os_strcmp(buf
, "private_key") == 0) {
1759 os_free(bss
->private_key
);
1760 bss
->private_key
= os_strdup(pos
);
1761 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
1762 os_free(bss
->private_key_passwd
);
1763 bss
->private_key_passwd
= os_strdup(pos
);
1764 } else if (os_strcmp(buf
, "check_crl") == 0) {
1765 bss
->check_crl
= atoi(pos
);
1766 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
1767 os_free(bss
->ocsp_stapling_response
);
1768 bss
->ocsp_stapling_response
= os_strdup(pos
);
1769 } else if (os_strcmp(buf
, "dh_file") == 0) {
1770 os_free(bss
->dh_file
);
1771 bss
->dh_file
= os_strdup(pos
);
1772 } else if (os_strcmp(buf
, "fragment_size") == 0) {
1773 bss
->fragment_size
= atoi(pos
);
1774 #ifdef EAP_SERVER_FAST
1775 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
1776 os_free(bss
->pac_opaque_encr_key
);
1777 bss
->pac_opaque_encr_key
= os_malloc(16);
1778 if (bss
->pac_opaque_encr_key
== NULL
) {
1779 wpa_printf(MSG_ERROR
, "Line %d: No memory for "
1780 "pac_opaque_encr_key", line
);
1782 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
,
1784 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1785 "pac_opaque_encr_key", line
);
1788 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
1789 size_t idlen
= os_strlen(pos
);
1791 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1792 "eap_fast_a_id", line
);
1795 os_free(bss
->eap_fast_a_id
);
1796 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
1797 if (bss
->eap_fast_a_id
== NULL
||
1798 hexstr2bin(pos
, bss
->eap_fast_a_id
,
1800 wpa_printf(MSG_ERROR
, "Line %d: "
1802 "eap_fast_a_id", line
);
1805 bss
->eap_fast_a_id_len
= idlen
/ 2;
1807 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
1808 os_free(bss
->eap_fast_a_id_info
);
1809 bss
->eap_fast_a_id_info
= os_strdup(pos
);
1810 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
1811 bss
->eap_fast_prov
= atoi(pos
);
1812 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
1813 bss
->pac_key_lifetime
= atoi(pos
);
1814 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
1815 bss
->pac_key_refresh_time
= atoi(pos
);
1816 #endif /* EAP_SERVER_FAST */
1817 #ifdef EAP_SERVER_SIM
1818 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
1819 os_free(bss
->eap_sim_db
);
1820 bss
->eap_sim_db
= os_strdup(pos
);
1821 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
1822 bss
->eap_sim_aka_result_ind
= atoi(pos
);
1823 #endif /* EAP_SERVER_SIM */
1824 #ifdef EAP_SERVER_TNC
1825 } else if (os_strcmp(buf
, "tnc") == 0) {
1826 bss
->tnc
= atoi(pos
);
1827 #endif /* EAP_SERVER_TNC */
1828 #ifdef EAP_SERVER_PWD
1829 } else if (os_strcmp(buf
, "pwd_group") == 0) {
1830 bss
->pwd_group
= atoi(pos
);
1831 #endif /* EAP_SERVER_PWD */
1832 #endif /* EAP_SERVER */
1833 } else if (os_strcmp(buf
, "eap_message") == 0) {
1835 bss
->eap_req_id_text
= os_strdup(pos
);
1836 if (bss
->eap_req_id_text
== NULL
) {
1837 wpa_printf(MSG_ERROR
, "Line %d: Failed to "
1838 "allocate memory for "
1839 "eap_req_id_text", line
);
1843 bss
->eap_req_id_text_len
=
1844 os_strlen(bss
->eap_req_id_text
);
1845 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
1848 os_memmove(term
, term
+ 1,
1849 bss
->eap_req_id_text_len
-
1850 (term
- bss
->eap_req_id_text
) - 1);
1851 bss
->eap_req_id_text_len
--;
1853 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
1854 bss
->default_wep_key_len
= atoi(pos
);
1855 if (bss
->default_wep_key_len
> 13) {
1856 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP "
1857 "key len %lu (= %lu bits)", line
,
1859 bss
->default_wep_key_len
,
1861 bss
->default_wep_key_len
* 8);
1864 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
1865 bss
->individual_wep_key_len
= atoi(pos
);
1866 if (bss
->individual_wep_key_len
< 0 ||
1867 bss
->individual_wep_key_len
> 13) {
1868 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP "
1869 "key len %d (= %d bits)", line
,
1870 bss
->individual_wep_key_len
,
1871 bss
->individual_wep_key_len
* 8);
1874 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
1875 bss
->wep_rekeying_period
= atoi(pos
);
1876 if (bss
->wep_rekeying_period
< 0) {
1877 wpa_printf(MSG_ERROR
, "Line %d: invalid "
1879 line
, bss
->wep_rekeying_period
);
1882 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
1883 bss
->eap_reauth_period
= atoi(pos
);
1884 if (bss
->eap_reauth_period
< 0) {
1885 wpa_printf(MSG_ERROR
, "Line %d: invalid "
1887 line
, bss
->eap_reauth_period
);
1890 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
1891 bss
->eapol_key_index_workaround
= atoi(pos
);
1893 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
1894 bss
->ieee802_11f
= 1;
1895 os_strlcpy(bss
->iapp_iface
, pos
,
1896 sizeof(bss
->iapp_iface
));
1897 #endif /* CONFIG_IAPP */
1898 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
1899 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
1900 wpa_printf(MSG_ERROR
, "Line %d: invalid IP "
1901 "address '%s'", line
, pos
);
1904 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
1905 bss
->nas_identifier
= os_strdup(pos
);
1906 #ifndef CONFIG_NO_RADIUS
1907 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
1908 if (hostapd_config_read_radius_addr(
1909 &bss
->radius
->auth_servers
,
1910 &bss
->radius
->num_auth_servers
, pos
, 1812,
1911 &bss
->radius
->auth_server
)) {
1912 wpa_printf(MSG_ERROR
, "Line %d: invalid IP "
1913 "address '%s'", line
, pos
);
1916 } else if (bss
->radius
->auth_server
&&
1917 os_strcmp(buf
, "auth_server_port") == 0) {
1918 bss
->radius
->auth_server
->port
= atoi(pos
);
1919 } else if (bss
->radius
->auth_server
&&
1920 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
1921 int len
= os_strlen(pos
);
1923 /* RFC 2865, Ch. 3 */
1924 wpa_printf(MSG_ERROR
, "Line %d: empty shared "
1925 "secret is not allowed.", line
);
1928 bss
->radius
->auth_server
->shared_secret
=
1929 (u8
*) os_strdup(pos
);
1930 bss
->radius
->auth_server
->shared_secret_len
= len
;
1931 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
1932 if (hostapd_config_read_radius_addr(
1933 &bss
->radius
->acct_servers
,
1934 &bss
->radius
->num_acct_servers
, pos
, 1813,
1935 &bss
->radius
->acct_server
)) {
1936 wpa_printf(MSG_ERROR
, "Line %d: invalid IP "
1937 "address '%s'", line
, pos
);
1940 } else if (bss
->radius
->acct_server
&&
1941 os_strcmp(buf
, "acct_server_port") == 0) {
1942 bss
->radius
->acct_server
->port
= atoi(pos
);
1943 } else if (bss
->radius
->acct_server
&&
1944 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
1945 int len
= os_strlen(pos
);
1947 /* RFC 2865, Ch. 3 */
1948 wpa_printf(MSG_ERROR
, "Line %d: empty shared "
1949 "secret is not allowed.", line
);
1952 bss
->radius
->acct_server
->shared_secret
=
1953 (u8
*) os_strdup(pos
);
1954 bss
->radius
->acct_server
->shared_secret_len
= len
;
1955 } else if (os_strcmp(buf
, "radius_retry_primary_interval") ==
1957 bss
->radius
->retry_primary_interval
= atoi(pos
);
1958 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0)
1960 bss
->acct_interim_interval
= atoi(pos
);
1961 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
1962 bss
->radius_request_cui
= atoi(pos
);
1963 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
1964 struct hostapd_radius_attr
*attr
, *a
;
1965 attr
= hostapd_parse_radius_attr(pos
);
1967 wpa_printf(MSG_ERROR
, "Line %d: invalid "
1968 "radius_auth_req_attr", line
);
1970 } else if (bss
->radius_auth_req_attr
== NULL
) {
1971 bss
->radius_auth_req_attr
= attr
;
1973 a
= bss
->radius_auth_req_attr
;
1978 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
1979 struct hostapd_radius_attr
*attr
, *a
;
1980 attr
= hostapd_parse_radius_attr(pos
);
1982 wpa_printf(MSG_ERROR
, "Line %d: invalid "
1983 "radius_acct_req_attr", line
);
1985 } else if (bss
->radius_acct_req_attr
== NULL
) {
1986 bss
->radius_acct_req_attr
= attr
;
1988 a
= bss
->radius_acct_req_attr
;
1993 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
1994 bss
->radius_das_port
= atoi(pos
);
1995 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
1996 if (hostapd_parse_das_client(bss
, pos
) < 0) {
1997 wpa_printf(MSG_ERROR
, "Line %d: invalid "
1998 "DAS client", line
);
2001 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2002 bss
->radius_das_time_window
= atoi(pos
);
2003 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp")
2005 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2006 #endif /* CONFIG_NO_RADIUS */
2007 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2008 bss
->auth_algs
= atoi(pos
);
2009 if (bss
->auth_algs
== 0) {
2010 wpa_printf(MSG_ERROR
, "Line %d: no "
2011 "authentication algorithms allowed",
2015 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2016 bss
->max_num_sta
= atoi(pos
);
2017 if (bss
->max_num_sta
< 0 ||
2018 bss
->max_num_sta
> MAX_STA_COUNT
) {
2019 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2020 "max_num_sta=%d; allowed range "
2021 "0..%d", line
, bss
->max_num_sta
,
2025 } else if (os_strcmp(buf
, "wpa") == 0) {
2026 bss
->wpa
= atoi(pos
);
2027 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2028 bss
->wpa_group_rekey
= atoi(pos
);
2029 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2030 bss
->wpa_strict_rekey
= atoi(pos
);
2031 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2032 bss
->wpa_gmk_rekey
= atoi(pos
);
2033 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2034 bss
->wpa_ptk_rekey
= atoi(pos
);
2035 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2036 int len
= os_strlen(pos
);
2037 if (len
< 8 || len
> 63) {
2038 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA "
2039 "passphrase length %d (expected "
2040 "8..63)", line
, len
);
2043 os_free(bss
->ssid
.wpa_passphrase
);
2044 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2045 if (bss
->ssid
.wpa_passphrase
) {
2046 os_free(bss
->ssid
.wpa_psk
);
2047 bss
->ssid
.wpa_psk
= NULL
;
2048 bss
->ssid
.wpa_passphrase_set
= 1;
2051 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2052 os_free(bss
->ssid
.wpa_psk
);
2054 os_zalloc(sizeof(struct hostapd_wpa_psk
));
2055 if (bss
->ssid
.wpa_psk
== NULL
)
2057 else if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
,
2059 pos
[PMK_LEN
* 2] != '\0') {
2060 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK "
2061 "'%s'.", line
, pos
);
2064 bss
->ssid
.wpa_psk
->group
= 1;
2065 os_free(bss
->ssid
.wpa_passphrase
);
2066 bss
->ssid
.wpa_passphrase
= NULL
;
2067 bss
->ssid
.wpa_psk_set
= 1;
2069 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2070 os_free(bss
->ssid
.wpa_psk_file
);
2071 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
2072 if (!bss
->ssid
.wpa_psk_file
) {
2073 wpa_printf(MSG_ERROR
, "Line %d: allocation "
2077 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
2079 hostapd_config_parse_key_mgmt(line
, pos
);
2080 if (bss
->wpa_key_mgmt
== -1)
2082 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
2083 bss
->wpa_psk_radius
= atoi(pos
);
2084 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
2085 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
2086 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
2087 wpa_printf(MSG_ERROR
, "Line %d: unknown "
2088 "wpa_psk_radius %d",
2089 line
, bss
->wpa_psk_radius
);
2092 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
2094 hostapd_config_parse_cipher(line
, pos
);
2095 if (bss
->wpa_pairwise
== -1 ||
2096 bss
->wpa_pairwise
== 0)
2098 else if (bss
->wpa_pairwise
&
2099 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
|
2100 WPA_CIPHER_WEP104
)) {
2101 wpa_printf(MSG_ERROR
, "Line %d: unsupported "
2102 "pairwise cipher suite '%s'",
2103 bss
->wpa_pairwise
, pos
);
2106 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
2108 hostapd_config_parse_cipher(line
, pos
);
2109 if (bss
->rsn_pairwise
== -1 ||
2110 bss
->rsn_pairwise
== 0)
2112 else if (bss
->rsn_pairwise
&
2113 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
|
2114 WPA_CIPHER_WEP104
)) {
2115 wpa_printf(MSG_ERROR
, "Line %d: unsupported "
2116 "pairwise cipher suite '%s'",
2117 bss
->rsn_pairwise
, pos
);
2120 #ifdef CONFIG_RSN_PREAUTH
2121 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
2122 bss
->rsn_preauth
= atoi(pos
);
2123 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
2124 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
2125 #endif /* CONFIG_RSN_PREAUTH */
2126 #ifdef CONFIG_PEERKEY
2127 } else if (os_strcmp(buf
, "peerkey") == 0) {
2128 bss
->peerkey
= atoi(pos
);
2129 #endif /* CONFIG_PEERKEY */
2130 #ifdef CONFIG_IEEE80211R
2131 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
2132 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
2133 hexstr2bin(pos
, bss
->mobility_domain
,
2134 MOBILITY_DOMAIN_ID_LEN
) != 0) {
2135 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2136 "mobility_domain '%s'", line
, pos
);
2140 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
2141 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
2142 hexstr2bin(pos
, bss
->r1_key_holder
,
2143 FT_R1KH_ID_LEN
) != 0) {
2144 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2145 "r1_key_holder '%s'", line
, pos
);
2149 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
2150 bss
->r0_key_lifetime
= atoi(pos
);
2151 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
2152 bss
->reassociation_deadline
= atoi(pos
);
2153 } else if (os_strcmp(buf
, "r0kh") == 0) {
2154 if (add_r0kh(bss
, pos
) < 0) {
2155 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2156 "r0kh '%s'", line
, pos
);
2160 } else if (os_strcmp(buf
, "r1kh") == 0) {
2161 if (add_r1kh(bss
, pos
) < 0) {
2162 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2163 "r1kh '%s'", line
, pos
);
2167 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
2168 bss
->pmk_r1_push
= atoi(pos
);
2169 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
2170 bss
->ft_over_ds
= atoi(pos
);
2171 #endif /* CONFIG_IEEE80211R */
2172 #ifndef CONFIG_NO_CTRL_IFACE
2173 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
2174 os_free(bss
->ctrl_interface
);
2175 bss
->ctrl_interface
= os_strdup(pos
);
2176 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
2177 #ifndef CONFIG_NATIVE_WINDOWS
2180 const char *group
= pos
;
2182 grp
= getgrnam(group
);
2184 bss
->ctrl_interface_gid
= grp
->gr_gid
;
2185 bss
->ctrl_interface_gid_set
= 1;
2186 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d"
2187 " (from group name '%s')",
2188 bss
->ctrl_interface_gid
, group
);
2192 /* Group name not found - try to parse this as gid */
2193 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
2194 if (*group
== '\0' || *endp
!= '\0') {
2195 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group "
2196 "'%s'", line
, group
);
2200 bss
->ctrl_interface_gid_set
= 1;
2201 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
2202 bss
->ctrl_interface_gid
);
2203 #endif /* CONFIG_NATIVE_WINDOWS */
2204 #endif /* CONFIG_NO_CTRL_IFACE */
2205 #ifdef RADIUS_SERVER
2206 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
2207 os_free(bss
->radius_server_clients
);
2208 bss
->radius_server_clients
= os_strdup(pos
);
2209 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
2210 bss
->radius_server_auth_port
= atoi(pos
);
2211 } else if (os_strcmp(buf
, "radius_server_acct_port") == 0) {
2212 bss
->radius_server_acct_port
= atoi(pos
);
2213 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
2214 bss
->radius_server_ipv6
= atoi(pos
);
2215 #endif /* RADIUS_SERVER */
2216 } else if (os_strcmp(buf
, "test_socket") == 0) {
2217 os_free(bss
->test_socket
);
2218 bss
->test_socket
= os_strdup(pos
);
2219 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
2220 bss
->use_pae_group_addr
= atoi(pos
);
2221 } else if (os_strcmp(buf
, "hw_mode") == 0) {
2222 if (os_strcmp(pos
, "a") == 0)
2223 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
2224 else if (os_strcmp(pos
, "b") == 0)
2225 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
2226 else if (os_strcmp(pos
, "g") == 0)
2227 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
2228 else if (os_strcmp(pos
, "ad") == 0)
2229 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
2231 wpa_printf(MSG_ERROR
, "Line %d: unknown "
2232 "hw_mode '%s'", line
, pos
);
2235 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
2236 if (os_strcmp(pos
, "a") == 0)
2237 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
2238 else if (os_strcmp(pos
, "g") == 0 ||
2239 os_strcmp(pos
, "b") == 0)
2240 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
2241 else if (os_strcmp(pos
, "ag") == 0 ||
2242 os_strcmp(pos
, "ga") == 0)
2244 WPS_RF_24GHZ
| WPS_RF_50GHZ
;
2246 wpa_printf(MSG_ERROR
, "Line %d: unknown "
2247 "wps_rf_band '%s'", line
, pos
);
2250 } else if (os_strcmp(buf
, "channel") == 0) {
2251 if (os_strcmp(pos
, "acs_survey") == 0) {
2253 wpa_printf(MSG_ERROR
, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
2256 #endif /* CONFIG_ACS */
2259 conf
->channel
= atoi(pos
);
2260 } else if (os_strcmp(buf
, "beacon_int") == 0) {
2261 int val
= atoi(pos
);
2262 /* MIB defines range as 1..65535, but very small values
2263 * cause problems with the current implementation.
2264 * Since it is unlikely that this small numbers are
2265 * useful in real life scenarios, do not allow beacon
2266 * period to be set below 15 TU. */
2267 if (val
< 15 || val
> 65535) {
2268 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2269 "beacon_int %d (expected "
2270 "15..65535)", line
, val
);
2273 conf
->beacon_int
= val
;
2275 } else if (os_strcmp(buf
, "acs_num_scans") == 0) {
2276 int val
= atoi(pos
);
2277 if (val
<= 0 || val
> 100) {
2278 wpa_printf(MSG_ERROR
, "Line %d: invalid acs_num_scans %d (expected 1..100)",
2282 conf
->acs_num_scans
= val
;
2283 #endif /* CONFIG_ACS */
2284 } else if (os_strcmp(buf
, "dtim_period") == 0) {
2285 bss
->dtim_period
= atoi(pos
);
2286 if (bss
->dtim_period
< 1 || bss
->dtim_period
> 255) {
2287 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2289 line
, bss
->dtim_period
);
2292 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
2293 conf
->rts_threshold
= atoi(pos
);
2294 if (conf
->rts_threshold
< 0 ||
2295 conf
->rts_threshold
> 2347) {
2296 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2298 line
, conf
->rts_threshold
);
2301 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
2302 conf
->fragm_threshold
= atoi(pos
);
2303 if (conf
->fragm_threshold
< 256 ||
2304 conf
->fragm_threshold
> 2346) {
2305 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2306 "fragm_threshold %d",
2307 line
, conf
->fragm_threshold
);
2310 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
2311 int val
= atoi(pos
);
2312 if (val
!= 0 && val
!= 1) {
2313 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2314 "send_probe_response %d (expected "
2315 "0 or 1)", line
, val
);
2317 conf
->send_probe_response
= val
;
2318 } else if (os_strcmp(buf
, "supported_rates") == 0) {
2319 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
))
2321 wpa_printf(MSG_ERROR
, "Line %d: invalid rate "
2325 } else if (os_strcmp(buf
, "basic_rates") == 0) {
2326 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
2327 wpa_printf(MSG_ERROR
, "Line %d: invalid rate "
2331 } else if (os_strcmp(buf
, "preamble") == 0) {
2333 conf
->preamble
= SHORT_PREAMBLE
;
2335 conf
->preamble
= LONG_PREAMBLE
;
2336 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
2337 bss
->ignore_broadcast_ssid
= atoi(pos
);
2338 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
2339 bss
->ssid
.wep
.idx
= atoi(pos
);
2340 if (bss
->ssid
.wep
.idx
> 3) {
2341 wpa_printf(MSG_ERROR
, "Invalid "
2342 "wep_default_key index %d",
2346 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
2347 os_strcmp(buf
, "wep_key1") == 0 ||
2348 os_strcmp(buf
, "wep_key2") == 0 ||
2349 os_strcmp(buf
, "wep_key3") == 0) {
2350 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
2351 buf
[7] - '0', pos
)) {
2352 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP "
2353 "key '%s'", line
, buf
);
2356 #ifndef CONFIG_NO_VLAN
2357 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
2358 bss
->ssid
.dynamic_vlan
= atoi(pos
);
2359 } else if (os_strcmp(buf
, "vlan_file") == 0) {
2360 if (hostapd_config_read_vlan_file(bss
, pos
)) {
2361 wpa_printf(MSG_ERROR
, "Line %d: failed to "
2362 "read VLAN file '%s'", line
, pos
);
2365 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
2366 bss
->ssid
.vlan_naming
= atoi(pos
);
2367 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
2368 bss
->ssid
.vlan_naming
< 0) {
2369 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2370 "naming scheme %d", line
,
2371 bss
->ssid
.vlan_naming
);
2374 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2375 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
2376 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
2377 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2378 #endif /* CONFIG_NO_VLAN */
2379 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
2380 conf
->ap_table_max_size
= atoi(pos
);
2381 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
2382 conf
->ap_table_expiration_time
= atoi(pos
);
2383 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
2384 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
2385 wpa_printf(MSG_ERROR
, "Line %d: invalid TX "
2386 "queue item", line
);
2389 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
2390 os_strcmp(buf
, "wmm_enabled") == 0) {
2391 bss
->wmm_enabled
= atoi(pos
);
2392 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
2393 bss
->wmm_uapsd
= atoi(pos
);
2394 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
2395 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
2396 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
,
2398 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM "
2402 } else if (os_strcmp(buf
, "bss") == 0) {
2403 if (hostapd_config_bss(conf
, pos
)) {
2404 wpa_printf(MSG_ERROR
, "Line %d: invalid bss "
2408 } else if (os_strcmp(buf
, "bssid") == 0) {
2409 if (hwaddr_aton(pos
, bss
->bssid
)) {
2410 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid "
2414 #ifdef CONFIG_IEEE80211W
2415 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
2416 bss
->ieee80211w
= atoi(pos
);
2417 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
2418 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
2419 if (bss
->assoc_sa_query_max_timeout
== 0) {
2420 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2421 "assoc_sa_query_max_timeout", line
);
2424 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0)
2426 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
2427 if (bss
->assoc_sa_query_retry_timeout
== 0) {
2428 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2429 "assoc_sa_query_retry_timeout",
2433 #endif /* CONFIG_IEEE80211W */
2434 #ifdef CONFIG_IEEE80211N
2435 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
2436 conf
->ieee80211n
= atoi(pos
);
2437 } else if (os_strcmp(buf
, "ht_capab") == 0) {
2438 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
2439 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2443 } else if (os_strcmp(buf
, "require_ht") == 0) {
2444 conf
->require_ht
= atoi(pos
);
2445 } else if (os_strcmp(buf
, "obss_interval") == 0) {
2446 conf
->obss_interval
= atoi(pos
);
2447 #endif /* CONFIG_IEEE80211N */
2448 #ifdef CONFIG_IEEE80211AC
2449 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
2450 conf
->ieee80211ac
= atoi(pos
);
2451 } else if (os_strcmp(buf
, "vht_capab") == 0) {
2452 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
2453 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2457 } else if (os_strcmp(buf
, "require_vht") == 0) {
2458 conf
->require_vht
= atoi(pos
);
2459 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
2460 conf
->vht_oper_chwidth
= atoi(pos
);
2461 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0)
2463 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
2464 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0)
2466 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
2467 #endif /* CONFIG_IEEE80211AC */
2468 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
2469 bss
->max_listen_interval
= atoi(pos
);
2470 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
2471 bss
->disable_pmksa_caching
= atoi(pos
);
2472 } else if (os_strcmp(buf
, "okc") == 0) {
2473 bss
->okc
= atoi(pos
);
2475 } else if (os_strcmp(buf
, "wps_state") == 0) {
2476 bss
->wps_state
= atoi(pos
);
2477 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
2478 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2482 } else if (os_strcmp(buf
, "wps_independent") == 0) {
2483 bss
->wps_independent
= atoi(pos
);
2484 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
2485 bss
->ap_setup_locked
= atoi(pos
);
2486 } else if (os_strcmp(buf
, "uuid") == 0) {
2487 if (uuid_str2bin(pos
, bss
->uuid
)) {
2488 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID",
2492 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
2493 os_free(bss
->wps_pin_requests
);
2494 bss
->wps_pin_requests
= os_strdup(pos
);
2495 } else if (os_strcmp(buf
, "device_name") == 0) {
2496 if (os_strlen(pos
) > 32) {
2497 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2498 "device_name", line
);
2501 os_free(bss
->device_name
);
2502 bss
->device_name
= os_strdup(pos
);
2503 } else if (os_strcmp(buf
, "manufacturer") == 0) {
2504 if (os_strlen(pos
) > 64) {
2505 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2506 "manufacturer", line
);
2509 os_free(bss
->manufacturer
);
2510 bss
->manufacturer
= os_strdup(pos
);
2511 } else if (os_strcmp(buf
, "model_name") == 0) {
2512 if (os_strlen(pos
) > 32) {
2513 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2514 "model_name", line
);
2517 os_free(bss
->model_name
);
2518 bss
->model_name
= os_strdup(pos
);
2519 } else if (os_strcmp(buf
, "model_number") == 0) {
2520 if (os_strlen(pos
) > 32) {
2521 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2522 "model_number", line
);
2525 os_free(bss
->model_number
);
2526 bss
->model_number
= os_strdup(pos
);
2527 } else if (os_strcmp(buf
, "serial_number") == 0) {
2528 if (os_strlen(pos
) > 32) {
2529 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2530 "serial_number", line
);
2533 os_free(bss
->serial_number
);
2534 bss
->serial_number
= os_strdup(pos
);
2535 } else if (os_strcmp(buf
, "device_type") == 0) {
2536 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
2538 } else if (os_strcmp(buf
, "config_methods") == 0) {
2539 os_free(bss
->config_methods
);
2540 bss
->config_methods
= os_strdup(pos
);
2541 } else if (os_strcmp(buf
, "os_version") == 0) {
2542 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
2543 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2544 "os_version", line
);
2547 } else if (os_strcmp(buf
, "ap_pin") == 0) {
2548 os_free(bss
->ap_pin
);
2549 bss
->ap_pin
= os_strdup(pos
);
2550 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
2551 bss
->skip_cred_build
= atoi(pos
);
2552 } else if (os_strcmp(buf
, "extra_cred") == 0) {
2553 os_free(bss
->extra_cred
);
2555 (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
2556 if (bss
->extra_cred
== NULL
) {
2557 wpa_printf(MSG_ERROR
, "Line %d: could not "
2558 "read Credentials from '%s'",
2562 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
2563 bss
->wps_cred_processing
= atoi(pos
);
2564 } else if (os_strcmp(buf
, "ap_settings") == 0) {
2565 os_free(bss
->ap_settings
);
2567 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
2568 if (bss
->ap_settings
== NULL
) {
2569 wpa_printf(MSG_ERROR
, "Line %d: could not "
2570 "read AP Settings from '%s'",
2574 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
2575 bss
->upnp_iface
= os_strdup(pos
);
2576 } else if (os_strcmp(buf
, "friendly_name") == 0) {
2577 os_free(bss
->friendly_name
);
2578 bss
->friendly_name
= os_strdup(pos
);
2579 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
2580 os_free(bss
->manufacturer_url
);
2581 bss
->manufacturer_url
= os_strdup(pos
);
2582 } else if (os_strcmp(buf
, "model_description") == 0) {
2583 os_free(bss
->model_description
);
2584 bss
->model_description
= os_strdup(pos
);
2585 } else if (os_strcmp(buf
, "model_url") == 0) {
2586 os_free(bss
->model_url
);
2587 bss
->model_url
= os_strdup(pos
);
2588 } else if (os_strcmp(buf
, "upc") == 0) {
2590 bss
->upc
= os_strdup(pos
);
2591 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
2592 bss
->pbc_in_m1
= atoi(pos
);
2593 } else if (os_strcmp(buf
, "server_id") == 0) {
2594 os_free(bss
->server_id
);
2595 bss
->server_id
= os_strdup(pos
);
2596 #ifdef CONFIG_WPS_NFC
2597 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
2598 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
2599 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
2600 bss
->wps_nfc_dev_pw_id
> 0xffff) {
2601 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2602 "wps_nfc_dev_pw_id value", line
);
2605 bss
->wps_nfc_pw_from_config
= 1;
2606 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
2607 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
2608 bss
->wps_nfc_dh_pubkey
= hostapd_parse_bin(pos
);
2609 bss
->wps_nfc_pw_from_config
= 1;
2610 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
2611 wpabuf_free(bss
->wps_nfc_dh_privkey
);
2612 bss
->wps_nfc_dh_privkey
= hostapd_parse_bin(pos
);
2613 bss
->wps_nfc_pw_from_config
= 1;
2614 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
2615 wpabuf_free(bss
->wps_nfc_dev_pw
);
2616 bss
->wps_nfc_dev_pw
= hostapd_parse_bin(pos
);
2617 bss
->wps_nfc_pw_from_config
= 1;
2618 #endif /* CONFIG_WPS_NFC */
2619 #endif /* CONFIG_WPS */
2620 #ifdef CONFIG_P2P_MANAGER
2621 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
2622 int manage
= atoi(pos
);
2624 bss
->p2p
|= P2P_MANAGE
;
2626 bss
->p2p
&= ~P2P_MANAGE
;
2627 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
2629 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
2631 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
2632 #endif /* CONFIG_P2P_MANAGER */
2633 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
2634 bss
->disassoc_low_ack
= atoi(pos
);
2635 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
2636 int val
= atoi(pos
);
2638 bss
->tdls
|= TDLS_PROHIBIT
;
2640 bss
->tdls
&= ~TDLS_PROHIBIT
;
2641 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
2642 int val
= atoi(pos
);
2644 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
2646 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
2647 #ifdef CONFIG_RSN_TESTING
2648 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
2649 extern int rsn_testing
;
2650 rsn_testing
= atoi(pos
);
2651 #endif /* CONFIG_RSN_TESTING */
2652 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
2653 bss
->time_advertisement
= atoi(pos
);
2654 } else if (os_strcmp(buf
, "time_zone") == 0) {
2655 size_t tz_len
= os_strlen(pos
);
2656 if (tz_len
< 4 || tz_len
> 255) {
2657 wpa_printf(MSG_DEBUG
, "Line %d: invalid "
2662 os_free(bss
->time_zone
);
2663 bss
->time_zone
= os_strdup(pos
);
2664 if (bss
->time_zone
== NULL
)
2667 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
2668 bss
->wnm_sleep_mode
= atoi(pos
);
2669 } else if (os_strcmp(buf
, "bss_transition") == 0) {
2670 bss
->bss_transition
= atoi(pos
);
2671 #endif /* CONFIG_WNM */
2672 #ifdef CONFIG_INTERWORKING
2673 } else if (os_strcmp(buf
, "interworking") == 0) {
2674 bss
->interworking
= atoi(pos
);
2675 } else if (os_strcmp(buf
, "access_network_type") == 0) {
2676 bss
->access_network_type
= atoi(pos
);
2677 if (bss
->access_network_type
< 0 ||
2678 bss
->access_network_type
> 15) {
2679 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2680 "access_network_type", line
);
2683 } else if (os_strcmp(buf
, "internet") == 0) {
2684 bss
->internet
= atoi(pos
);
2685 } else if (os_strcmp(buf
, "asra") == 0) {
2686 bss
->asra
= atoi(pos
);
2687 } else if (os_strcmp(buf
, "esr") == 0) {
2688 bss
->esr
= atoi(pos
);
2689 } else if (os_strcmp(buf
, "uesa") == 0) {
2690 bss
->uesa
= atoi(pos
);
2691 } else if (os_strcmp(buf
, "venue_group") == 0) {
2692 bss
->venue_group
= atoi(pos
);
2693 bss
->venue_info_set
= 1;
2694 } else if (os_strcmp(buf
, "venue_type") == 0) {
2695 bss
->venue_type
= atoi(pos
);
2696 bss
->venue_info_set
= 1;
2697 } else if (os_strcmp(buf
, "hessid") == 0) {
2698 if (hwaddr_aton(pos
, bss
->hessid
)) {
2699 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2703 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
2704 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
2706 } else if (os_strcmp(buf
, "venue_name") == 0) {
2707 if (parse_venue_name(bss
, pos
, line
) < 0)
2709 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
2711 u16 redirect_url_len
;
2712 if (hexstr2bin(pos
, &auth_type
, 1)) {
2713 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2714 "network_auth_type '%s'",
2719 if (auth_type
== 0 || auth_type
== 2)
2720 redirect_url_len
= os_strlen(pos
+ 2);
2722 redirect_url_len
= 0;
2723 os_free(bss
->network_auth_type
);
2724 bss
->network_auth_type
=
2725 os_malloc(redirect_url_len
+ 3 + 1);
2726 if (bss
->network_auth_type
== NULL
) {
2730 *bss
->network_auth_type
= auth_type
;
2731 WPA_PUT_LE16(bss
->network_auth_type
+ 1,
2733 if (redirect_url_len
)
2734 os_memcpy(bss
->network_auth_type
+ 3,
2735 pos
+ 2, redirect_url_len
);
2736 bss
->network_auth_type_len
= 3 + redirect_url_len
;
2737 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
2738 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1))
2740 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2741 "ipaddr_type_availability '%s'",
2743 bss
->ipaddr_type_configured
= 0;
2747 bss
->ipaddr_type_configured
= 1;
2748 } else if (os_strcmp(buf
, "domain_name") == 0) {
2749 int j
, num_domains
, domain_len
, domain_list_len
= 0;
2750 char *tok_start
, *tok_prev
;
2751 u8
*domain_list
, *domain_ptr
;
2753 domain_list_len
= os_strlen(pos
) + 1;
2754 domain_list
= os_malloc(domain_list_len
);
2755 if (domain_list
== NULL
) {
2760 domain_ptr
= domain_list
;
2763 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
2768 for (j
= 0; j
< num_domains
; j
++) {
2769 tok_start
= os_strchr(tok_prev
, ',');
2771 domain_len
= tok_start
- tok_prev
;
2772 *domain_ptr
= domain_len
;
2773 os_memcpy(domain_ptr
+ 1, tok_prev
,
2775 domain_ptr
+= domain_len
+ 1;
2776 tok_prev
= ++tok_start
;
2778 domain_len
= os_strlen(tok_prev
);
2779 *domain_ptr
= domain_len
;
2780 os_memcpy(domain_ptr
+ 1, tok_prev
,
2782 domain_ptr
+= domain_len
+ 1;
2786 os_free(bss
->domain_name
);
2787 bss
->domain_name
= domain_list
;
2788 bss
->domain_name_len
= domain_list_len
;
2789 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
2790 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
2792 } else if (os_strcmp(buf
, "nai_realm") == 0) {
2793 if (parse_nai_realm(bss
, pos
, line
) < 0)
2795 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
2796 bss
->gas_frag_limit
= atoi(pos
);
2797 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
2798 bss
->gas_comeback_delay
= atoi(pos
);
2799 } else if (os_strcmp(buf
, "qos_map_set") == 0) {
2800 if (parse_qos_map_set(bss
, pos
, line
) < 0)
2802 #endif /* CONFIG_INTERWORKING */
2803 #ifdef CONFIG_RADIUS_TEST
2804 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
2805 os_free(bss
->dump_msk_file
);
2806 bss
->dump_msk_file
= os_strdup(pos
);
2807 #endif /* CONFIG_RADIUS_TEST */
2809 } else if (os_strcmp(buf
, "hs20") == 0) {
2810 bss
->hs20
= atoi(pos
);
2811 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
2812 bss
->disable_dgaf
= atoi(pos
);
2813 } else if (os_strcmp(buf
, "osen") == 0) {
2814 bss
->osen
= atoi(pos
);
2815 } else if (os_strcmp(buf
, "anqp_domain_id") == 0) {
2816 bss
->anqp_domain_id
= atoi(pos
);
2817 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
2818 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
2820 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
2821 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0) {
2825 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
2826 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
2830 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
2832 size_t oper_class_len
;
2833 oper_class_len
= os_strlen(pos
);
2834 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
2835 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2836 "hs20_operating_class '%s'",
2841 oper_class_len
/= 2;
2842 oper_class
= os_malloc(oper_class_len
);
2843 if (oper_class
== NULL
) {
2847 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
2848 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2849 "hs20_operating_class '%s'",
2851 os_free(oper_class
);
2855 os_free(bss
->hs20_operating_class
);
2856 bss
->hs20_operating_class
= oper_class
;
2857 bss
->hs20_operating_class_len
= oper_class_len
;
2858 #endif /* CONFIG_HS20 */
2859 #ifdef CONFIG_TESTING_OPTIONS
2860 #define PARSE_TEST_PROBABILITY(_val) \
2861 } else if (os_strcmp(buf, #_val) == 0) { \
2864 conf->_val = strtod(pos, &end); \
2865 if (*end || conf->_val < 0.0d || \
2866 conf->_val > 1.0d) { \
2867 wpa_printf(MSG_ERROR, \
2868 "Line %d: Invalid value '%s'", \
2873 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
2874 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
2875 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
2876 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
2877 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
2878 } else if (os_strcmp(buf
, "bss_load_test") == 0) {
2879 WPA_PUT_LE16(bss
->bss_load_test
, atoi(pos
));
2880 pos
= os_strchr(pos
, ':');
2882 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2883 "bss_load_test", line
);
2887 bss
->bss_load_test
[2] = atoi(pos
);
2888 pos
= os_strchr(pos
, ':');
2890 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2891 "bss_load_test", line
);
2895 WPA_PUT_LE16(&bss
->bss_load_test
[3], atoi(pos
));
2896 bss
->bss_load_test_set
= 1;
2897 #endif /* CONFIG_TESTING_OPTIONS */
2898 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
2899 struct wpabuf
*elems
;
2900 size_t len
= os_strlen(pos
);
2902 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2903 "vendor_elements '%s'", line
, pos
);
2908 wpabuf_free(bss
->vendor_elements
);
2909 bss
->vendor_elements
= NULL
;
2913 elems
= wpabuf_alloc(len
);
2917 if (hexstr2bin(pos
, wpabuf_put(elems
, len
), len
)) {
2919 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2920 "vendor_elements '%s'", line
, pos
);
2924 wpabuf_free(bss
->vendor_elements
);
2925 bss
->vendor_elements
= elems
;
2926 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
2927 bss
->sae_anti_clogging_threshold
= atoi(pos
);
2928 } else if (os_strcmp(buf
, "sae_groups") == 0) {
2929 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
2930 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2931 "sae_groups value '%s'", line
, pos
);
2934 } else if (os_strcmp(buf
, "local_pwr_constraint") == 0) {
2935 int val
= atoi(pos
);
2936 if (val
< 0 || val
> 255) {
2937 wpa_printf(MSG_ERROR
, "Line %d: Invalid local_pwr_constraint %d (expected 0..255)",
2941 conf
->local_pwr_constraint
= val
;
2942 } else if (os_strcmp(buf
, "spectrum_mgmt_required") == 0) {
2943 conf
->spectrum_mgmt_required
= atoi(pos
);
2945 wpa_printf(MSG_ERROR
, "Line %d: unknown configuration "
2946 "item '%s'", line
, buf
);
2956 * hostapd_config_read - Read and parse a configuration file
2957 * @fname: Configuration file name (including path, if needed)
2958 * Returns: Allocated configuration data structure
2960 struct hostapd_config
* hostapd_config_read(const char *fname
)
2962 struct hostapd_config
*conf
;
2963 struct hostapd_bss_config
*bss
;
2965 char buf
[512], *pos
;
2970 f
= fopen(fname
, "r");
2972 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
2973 "for reading.", fname
);
2977 conf
= hostapd_config_defaults();
2983 /* set default driver based on configuration */
2984 conf
->driver
= wpa_drivers
[0];
2985 if (conf
->driver
== NULL
) {
2986 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
2987 hostapd_config_free(conf
);
2992 bss
= conf
->last_bss
= conf
->bss
[0];
2994 while (fgets(buf
, sizeof(buf
), f
)) {
2995 bss
= conf
->last_bss
;
3001 while (*pos
!= '\0') {
3011 pos
= os_strchr(buf
, '=');
3013 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
3020 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
3025 for (i
= 0; i
< conf
->num_bss
; i
++)
3026 hostapd_set_security_params(conf
->bss
[i
]);
3028 if (hostapd_config_check(conf
, 1))
3031 #ifndef WPA_IGNORE_CONFIG_ERRORS
3033 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
3034 "'%s'", errors
, fname
);
3035 hostapd_config_free(conf
);
3038 #endif /* WPA_IGNORE_CONFIG_ERRORS */
3044 int hostapd_set_iface(struct hostapd_config
*conf
,
3045 struct hostapd_bss_config
*bss
, char *field
, char *value
)
3050 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
3052 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
3053 "to value '%s'", field
, value
);
3057 for (i
= 0; i
< conf
->num_bss
; i
++)
3058 hostapd_set_security_params(conf
->bss
[i
]);
3060 if (hostapd_config_check(conf
, 0)) {
3061 wpa_printf(MSG_ERROR
, "Configuration check failed");