2 * hostapd / Configuration file parser
3 * Copyright (c) 2003-2013, 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 extern struct wpa_driver_ops
*wpa_drivers
[];
28 #ifndef CONFIG_NO_VLAN
29 static int hostapd_config_read_vlan_file(struct hostapd_bss_config
*bss
,
33 char buf
[128], *pos
, *pos2
;
34 int line
= 0, vlan_id
;
35 struct hostapd_vlan
*vlan
;
37 f
= fopen(fname
, "r");
39 wpa_printf(MSG_ERROR
, "VLAN file '%s' not readable.", fname
);
43 while (fgets(buf
, sizeof(buf
), f
)) {
49 while (*pos
!= '\0') {
60 vlan_id
= VLAN_ID_WILDCARD
;
63 vlan_id
= strtol(buf
, &pos
, 10);
64 if (buf
== pos
|| vlan_id
< 1 ||
65 vlan_id
> MAX_VLAN_ID
) {
66 wpa_printf(MSG_ERROR
, "Invalid VLAN ID at "
67 "line %d in '%s'", line
, fname
);
73 while (*pos
== ' ' || *pos
== '\t')
76 while (*pos2
!= ' ' && *pos2
!= '\t' && *pos2
!= '\0')
79 if (*pos
== '\0' || os_strlen(pos
) > IFNAMSIZ
) {
80 wpa_printf(MSG_ERROR
, "Invalid VLAN ifname at line %d "
81 "in '%s'", line
, fname
);
86 vlan
= os_zalloc(sizeof(*vlan
));
88 wpa_printf(MSG_ERROR
, "Out of memory while reading "
89 "VLAN interfaces from '%s'", fname
);
94 vlan
->vlan_id
= vlan_id
;
95 os_strlcpy(vlan
->ifname
, pos
, sizeof(vlan
->ifname
));
96 vlan
->next
= bss
->vlan
;
104 #endif /* CONFIG_NO_VLAN */
107 static int hostapd_acl_comp(const void *a
, const void *b
)
109 const struct mac_acl_entry
*aa
= a
;
110 const struct mac_acl_entry
*bb
= b
;
111 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
115 static int hostapd_config_read_maclist(const char *fname
,
116 struct mac_acl_entry
**acl
, int *num
)
122 struct mac_acl_entry
*newacl
;
128 f
= fopen(fname
, "r");
130 wpa_printf(MSG_ERROR
, "MAC list file '%s' not found.", fname
);
134 while (fgets(buf
, sizeof(buf
), f
)) {
140 while (*pos
!= '\0') {
150 if (hwaddr_aton(buf
, addr
)) {
151 wpa_printf(MSG_ERROR
, "Invalid MAC address '%s' at "
152 "line %d in '%s'", buf
, line
, fname
);
159 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
161 while (*pos
== ' ' || *pos
== '\t')
166 newacl
= os_realloc_array(*acl
, *num
+ 1, sizeof(**acl
));
167 if (newacl
== NULL
) {
168 wpa_printf(MSG_ERROR
, "MAC list reallocation failed");
174 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
175 (*acl
)[*num
].vlan_id
= vlan_id
;
181 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
188 static int hostapd_config_read_eap_user(const char *fname
,
189 struct hostapd_bss_config
*conf
)
192 char buf
[512], *pos
, *start
, *pos2
;
193 int line
= 0, ret
= 0, num_methods
;
194 struct hostapd_eap_user
*user
, *tail
= NULL
;
199 if (os_strncmp(fname
, "sqlite:", 7) == 0) {
200 os_free(conf
->eap_user_sqlite
);
201 conf
->eap_user_sqlite
= os_strdup(fname
+ 7);
205 f
= fopen(fname
, "r");
207 wpa_printf(MSG_ERROR
, "EAP user file '%s' not found.", fname
);
211 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
212 while (fgets(buf
, sizeof(buf
), f
)) {
218 while (*pos
!= '\0') {
230 if (buf
[0] != '"' && buf
[0] != '*') {
231 wpa_printf(MSG_ERROR
, "Invalid EAP identity (no \" in "
232 "start) on line %d in '%s'", line
, fname
);
236 user
= os_zalloc(sizeof(*user
));
238 wpa_printf(MSG_ERROR
, "EAP user allocation failed");
241 user
->force_version
= -1;
248 while (*pos
!= '"' && *pos
!= '\0')
251 wpa_printf(MSG_ERROR
, "Invalid EAP identity "
252 "(no \" in end) on line %d in '%s'",
257 user
->identity
= os_malloc(pos
- start
);
258 if (user
->identity
== NULL
) {
259 wpa_printf(MSG_ERROR
, "Failed to allocate "
260 "memory for EAP identity");
263 os_memcpy(user
->identity
, start
, pos
- start
);
264 user
->identity_len
= pos
- start
;
266 if (pos
[0] == '"' && pos
[1] == '*') {
267 user
->wildcard_prefix
= 1;
272 while (*pos
== ' ' || *pos
== '\t')
276 wpa_printf(MSG_ERROR
, "No EAP method on line %d in "
277 "'%s'", line
, fname
);
282 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
292 char *pos3
= os_strchr(start
, ',');
296 user
->methods
[num_methods
].method
=
299 &user
->methods
[num_methods
].vendor
);
300 if (user
->methods
[num_methods
].vendor
==
302 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
304 if (os_strcmp(start
, "TTLS-PAP") == 0) {
305 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
308 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
309 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
312 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
314 EAP_TTLS_AUTH_MSCHAP
;
317 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
319 EAP_TTLS_AUTH_MSCHAPV2
;
322 wpa_printf(MSG_ERROR
, "Unsupported EAP type "
323 "'%s' on line %d in '%s'",
329 if (num_methods
>= EAP_MAX_METHODS
)
336 if (num_methods
== 0 && user
->ttls_auth
== 0) {
337 wpa_printf(MSG_ERROR
, "No EAP types configured on "
338 "line %d in '%s'", line
, fname
);
345 while (*pos
== ' ' || *pos
== '\t')
350 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
351 user
->force_version
= 0;
355 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
356 user
->force_version
= 1;
360 if (os_strncmp(pos
, "[2]", 3) == 0) {
368 while (*pos
!= '"' && *pos
!= '\0')
371 wpa_printf(MSG_ERROR
, "Invalid EAP password "
372 "(no \" in end) on line %d in '%s'",
377 user
->password
= os_malloc(pos
- start
);
378 if (user
->password
== NULL
) {
379 wpa_printf(MSG_ERROR
, "Failed to allocate "
380 "memory for EAP password");
383 os_memcpy(user
->password
, start
, pos
- start
);
384 user
->password_len
= pos
- start
;
387 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
390 while (*pos2
!= '\0' && *pos2
!= ' ' &&
391 *pos2
!= '\t' && *pos2
!= '#')
393 if (pos2
- pos
!= 32) {
394 wpa_printf(MSG_ERROR
, "Invalid password hash "
395 "on line %d in '%s'", line
, fname
);
398 user
->password
= os_malloc(16);
399 if (user
->password
== NULL
) {
400 wpa_printf(MSG_ERROR
, "Failed to allocate "
401 "memory for EAP password hash");
404 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
405 wpa_printf(MSG_ERROR
, "Invalid hash password "
406 "on line %d in '%s'", line
, fname
);
409 user
->password_len
= 16;
410 user
->password_hash
= 1;
414 while (*pos2
!= '\0' && *pos2
!= ' ' &&
415 *pos2
!= '\t' && *pos2
!= '#')
417 if ((pos2
- pos
) & 1) {
418 wpa_printf(MSG_ERROR
, "Invalid hex password "
419 "on line %d in '%s'", line
, fname
);
422 user
->password
= os_malloc((pos2
- pos
) / 2);
423 if (user
->password
== NULL
) {
424 wpa_printf(MSG_ERROR
, "Failed to allocate "
425 "memory for EAP password");
428 if (hexstr2bin(pos
, user
->password
,
429 (pos2
- pos
) / 2) < 0) {
430 wpa_printf(MSG_ERROR
, "Invalid hex password "
431 "on line %d in '%s'", line
, fname
);
434 user
->password_len
= (pos2
- pos
) / 2;
438 while (*pos
== ' ' || *pos
== '\t')
440 if (os_strncmp(pos
, "[2]", 3) == 0) {
446 tail
= conf
->eap_user
= user
;
455 os_free(user
->password
);
456 os_free(user
->identity
);
467 #endif /* EAP_SERVER */
470 #ifndef CONFIG_NO_RADIUS
472 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
473 int *num_server
, const char *val
, int def_port
,
474 struct hostapd_radius_server
**curr_serv
)
476 struct hostapd_radius_server
*nserv
;
478 static int server_index
= 1;
480 nserv
= os_realloc_array(*server
, *num_server
+ 1, sizeof(*nserv
));
485 nserv
= &nserv
[*num_server
];
487 (*curr_serv
) = nserv
;
489 os_memset(nserv
, 0, sizeof(*nserv
));
490 nserv
->port
= def_port
;
491 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
492 nserv
->index
= server_index
++;
498 static struct hostapd_radius_attr
*
499 hostapd_parse_radius_attr(const char *value
)
503 struct hostapd_radius_attr
*attr
;
506 attr
= os_zalloc(sizeof(*attr
));
510 attr
->type
= atoi(value
);
512 pos
= os_strchr(value
, ':');
514 attr
->val
= wpabuf_alloc(1);
515 if (attr
->val
== NULL
) {
519 wpabuf_put_u8(attr
->val
, 0);
524 if (pos
[0] == '\0' || pos
[1] != ':') {
533 attr
->val
= wpabuf_alloc_copy(pos
, os_strlen(pos
));
536 len
= os_strlen(pos
);
540 attr
->val
= wpabuf_alloc(len
);
541 if (attr
->val
== NULL
)
543 if (hexstr2bin(pos
, wpabuf_put(attr
->val
, len
), len
) < 0) {
544 wpabuf_free(attr
->val
);
550 attr
->val
= wpabuf_alloc(4);
552 wpabuf_put_be32(attr
->val
, atoi(pos
));
559 if (attr
->val
== NULL
) {
568 static int hostapd_parse_das_client(struct hostapd_bss_config
*bss
,
573 secret
= os_strchr(val
, ' ');
579 if (hostapd_parse_ip_addr(val
, &bss
->radius_das_client_addr
))
582 os_free(bss
->radius_das_shared_secret
);
583 bss
->radius_das_shared_secret
= (u8
*) os_strdup(secret
);
584 if (bss
->radius_das_shared_secret
== NULL
)
586 bss
->radius_das_shared_secret_len
= os_strlen(secret
);
590 #endif /* CONFIG_NO_RADIUS */
593 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
596 char *start
, *end
, *buf
;
598 buf
= os_strdup(value
);
603 while (*start
!= '\0') {
604 while (*start
== ' ' || *start
== '\t')
609 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
613 if (os_strcmp(start
, "WPA-PSK") == 0)
614 val
|= WPA_KEY_MGMT_PSK
;
615 else if (os_strcmp(start
, "WPA-EAP") == 0)
616 val
|= WPA_KEY_MGMT_IEEE8021X
;
617 #ifdef CONFIG_IEEE80211R
618 else if (os_strcmp(start
, "FT-PSK") == 0)
619 val
|= WPA_KEY_MGMT_FT_PSK
;
620 else if (os_strcmp(start
, "FT-EAP") == 0)
621 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
622 #endif /* CONFIG_IEEE80211R */
623 #ifdef CONFIG_IEEE80211W
624 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
625 val
|= WPA_KEY_MGMT_PSK_SHA256
;
626 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
627 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
628 #endif /* CONFIG_IEEE80211W */
630 else if (os_strcmp(start
, "SAE") == 0)
631 val
|= WPA_KEY_MGMT_SAE
;
632 else if (os_strcmp(start
, "FT-SAE") == 0)
633 val
|= WPA_KEY_MGMT_FT_SAE
;
634 #endif /* CONFIG_SAE */
636 wpa_printf(MSG_ERROR
, "Line %d: invalid key_mgmt '%s'",
649 wpa_printf(MSG_ERROR
, "Line %d: no key_mgmt values "
650 "configured.", line
);
658 static int hostapd_config_parse_cipher(int line
, const char *value
)
660 int val
= wpa_parse_cipher(value
);
662 wpa_printf(MSG_ERROR
, "Line %d: invalid cipher '%s'.",
667 wpa_printf(MSG_ERROR
, "Line %d: no cipher values configured.",
675 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
678 size_t len
= os_strlen(val
);
680 if (keyidx
< 0 || keyidx
> 3 || wep
->key
[keyidx
] != NULL
)
684 if (len
< 2 || val
[len
- 1] != '"')
687 wep
->key
[keyidx
] = os_malloc(len
);
688 if (wep
->key
[keyidx
] == NULL
)
690 os_memcpy(wep
->key
[keyidx
], val
+ 1, len
);
691 wep
->len
[keyidx
] = len
;
696 wep
->key
[keyidx
] = os_malloc(len
);
697 if (wep
->key
[keyidx
] == NULL
)
699 wep
->len
[keyidx
] = len
;
700 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
710 static int hostapd_parse_intlist(int **int_list
, char *val
)
721 while (*pos
!= '\0') {
727 list
= os_malloc(sizeof(int) * (count
+ 2));
732 while (*pos
!= '\0') {
733 end
= os_strchr(pos
, ' ');
737 list
[count
++] = atoi(pos
);
749 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
751 struct hostapd_bss_config
*bss
;
756 bss
= os_realloc_array(conf
->bss
, conf
->num_bss
+ 1,
757 sizeof(struct hostapd_bss_config
));
759 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
765 bss
= &(conf
->bss
[conf
->num_bss
]);
766 os_memset(bss
, 0, sizeof(*bss
));
767 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
768 if (bss
->radius
== NULL
) {
769 wpa_printf(MSG_ERROR
, "Failed to allocate memory for "
770 "multi-BSS RADIUS data");
775 conf
->last_bss
= bss
;
777 hostapd_config_defaults_bss(bss
);
778 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
779 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
785 /* convert floats with one decimal place to value*10 int, i.e.,
786 * "1.5" will return 15 */
787 static int hostapd_config_read_int10(const char *value
)
793 pos
= os_strchr(value
, '.');
797 if (*pos
>= '0' && *pos
<= '9')
805 static int valid_cw(int cw
)
807 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
808 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023);
813 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
814 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
815 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
816 IEEE80211_TX_QUEUE_DATA3
= 3 /* used for EDCA AC_BK data */
819 static int hostapd_config_tx_queue(struct hostapd_config
*conf
, char *name
,
824 struct hostapd_tx_queue_params
*queue
;
826 /* skip 'tx_queue_' prefix */
828 if (os_strncmp(pos
, "data", 4) == 0 &&
829 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
832 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0 ||
833 os_strncmp(pos
, "beacon_", 7) == 0) {
834 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
837 wpa_printf(MSG_ERROR
, "Unknown tx_queue name '%s'", pos
);
841 if (num
>= NUM_TX_QUEUES
) {
842 /* for backwards compatibility, do not trigger failure */
843 wpa_printf(MSG_INFO
, "DEPRECATED: '%s' not used", name
);
847 queue
= &conf
->tx_queue
[num
];
849 if (os_strcmp(pos
, "aifs") == 0) {
850 queue
->aifs
= atoi(val
);
851 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
852 wpa_printf(MSG_ERROR
, "Invalid AIFS value %d",
856 } else if (os_strcmp(pos
, "cwmin") == 0) {
857 queue
->cwmin
= atoi(val
);
858 if (!valid_cw(queue
->cwmin
)) {
859 wpa_printf(MSG_ERROR
, "Invalid cwMin value %d",
863 } else if (os_strcmp(pos
, "cwmax") == 0) {
864 queue
->cwmax
= atoi(val
);
865 if (!valid_cw(queue
->cwmax
)) {
866 wpa_printf(MSG_ERROR
, "Invalid cwMax value %d",
870 } else if (os_strcmp(pos
, "burst") == 0) {
871 queue
->burst
= hostapd_config_read_int10(val
);
873 wpa_printf(MSG_ERROR
, "Unknown tx_queue field '%s'", pos
);
881 #ifdef CONFIG_IEEE80211R
882 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
884 struct ft_remote_r0kh
*r0kh
;
887 r0kh
= os_zalloc(sizeof(*r0kh
));
891 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
893 next
= os_strchr(pos
, ' ');
896 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
897 wpa_printf(MSG_ERROR
, "Invalid R0KH MAC address: '%s'", pos
);
903 next
= os_strchr(pos
, ' ');
906 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
907 wpa_printf(MSG_ERROR
, "Invalid R0KH-ID: '%s'", pos
);
911 r0kh
->id_len
= next
- pos
- 1;
912 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
915 if (hexstr2bin(pos
, r0kh
->key
, sizeof(r0kh
->key
))) {
916 wpa_printf(MSG_ERROR
, "Invalid R0KH key: '%s'", pos
);
921 r0kh
->next
= bss
->r0kh_list
;
922 bss
->r0kh_list
= r0kh
;
928 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
930 struct ft_remote_r1kh
*r1kh
;
933 r1kh
= os_zalloc(sizeof(*r1kh
));
937 /* 02:01:02:03:04:05 02:01:02:03:04:05
938 * 000102030405060708090a0b0c0d0e0f */
940 next
= os_strchr(pos
, ' ');
943 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
944 wpa_printf(MSG_ERROR
, "Invalid R1KH MAC address: '%s'", pos
);
950 next
= os_strchr(pos
, ' ');
953 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
954 wpa_printf(MSG_ERROR
, "Invalid R1KH-ID: '%s'", pos
);
960 if (hexstr2bin(pos
, r1kh
->key
, sizeof(r1kh
->key
))) {
961 wpa_printf(MSG_ERROR
, "Invalid R1KH key: '%s'", pos
);
966 r1kh
->next
= bss
->r1kh_list
;
967 bss
->r1kh_list
= r1kh
;
971 #endif /* CONFIG_IEEE80211R */
974 #ifdef CONFIG_IEEE80211N
975 static int hostapd_config_ht_capab(struct hostapd_config
*conf
,
978 if (os_strstr(capab
, "[LDPC]"))
979 conf
->ht_capab
|= HT_CAP_INFO_LDPC_CODING_CAP
;
980 if (os_strstr(capab
, "[HT40-]")) {
981 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
982 conf
->secondary_channel
= -1;
984 if (os_strstr(capab
, "[HT40+]")) {
985 conf
->ht_capab
|= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET
;
986 conf
->secondary_channel
= 1;
988 if (os_strstr(capab
, "[SMPS-STATIC]")) {
989 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
990 conf
->ht_capab
|= HT_CAP_INFO_SMPS_STATIC
;
992 if (os_strstr(capab
, "[SMPS-DYNAMIC]")) {
993 conf
->ht_capab
&= ~HT_CAP_INFO_SMPS_MASK
;
994 conf
->ht_capab
|= HT_CAP_INFO_SMPS_DYNAMIC
;
996 if (os_strstr(capab
, "[GF]"))
997 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
998 if (os_strstr(capab
, "[SHORT-GI-20]"))
999 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI20MHZ
;
1000 if (os_strstr(capab
, "[SHORT-GI-40]"))
1001 conf
->ht_capab
|= HT_CAP_INFO_SHORT_GI40MHZ
;
1002 if (os_strstr(capab
, "[TX-STBC]"))
1003 conf
->ht_capab
|= HT_CAP_INFO_TX_STBC
;
1004 if (os_strstr(capab
, "[RX-STBC1]")) {
1005 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1006 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_1
;
1008 if (os_strstr(capab
, "[RX-STBC12]")) {
1009 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1010 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_12
;
1012 if (os_strstr(capab
, "[RX-STBC123]")) {
1013 conf
->ht_capab
&= ~HT_CAP_INFO_RX_STBC_MASK
;
1014 conf
->ht_capab
|= HT_CAP_INFO_RX_STBC_123
;
1016 if (os_strstr(capab
, "[DELAYED-BA]"))
1017 conf
->ht_capab
|= HT_CAP_INFO_DELAYED_BA
;
1018 if (os_strstr(capab
, "[MAX-AMSDU-7935]"))
1019 conf
->ht_capab
|= HT_CAP_INFO_MAX_AMSDU_SIZE
;
1020 if (os_strstr(capab
, "[DSSS_CCK-40]"))
1021 conf
->ht_capab
|= HT_CAP_INFO_DSSS_CCK40MHZ
;
1022 if (os_strstr(capab
, "[PSMP]"))
1023 conf
->ht_capab
|= HT_CAP_INFO_PSMP_SUPP
;
1024 if (os_strstr(capab
, "[LSIG-TXOP-PROT]"))
1025 conf
->ht_capab
|= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT
;
1029 #endif /* CONFIG_IEEE80211N */
1032 #ifdef CONFIG_IEEE80211AC
1033 static int hostapd_config_vht_capab(struct hostapd_config
*conf
,
1036 if (os_strstr(capab
, "[MAX-MPDU-7991]"))
1037 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_7991
;
1038 if (os_strstr(capab
, "[MAX-MPDU-11454]"))
1039 conf
->vht_capab
|= VHT_CAP_MAX_MPDU_LENGTH_11454
;
1040 if (os_strstr(capab
, "[VHT160]"))
1041 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ
;
1042 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1043 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1044 if (os_strstr(capab
, "[VHT160-80PLUS80]"))
1045 conf
->vht_capab
|= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ
;
1046 if (os_strstr(capab
, "[RXLDPC]"))
1047 conf
->vht_capab
|= VHT_CAP_RXLDPC
;
1048 if (os_strstr(capab
, "[SHORT-GI-80]"))
1049 conf
->vht_capab
|= VHT_CAP_SHORT_GI_80
;
1050 if (os_strstr(capab
, "[SHORT-GI-160]"))
1051 conf
->vht_capab
|= VHT_CAP_SHORT_GI_160
;
1052 if (os_strstr(capab
, "[TX-STBC-2BY1]"))
1053 conf
->vht_capab
|= VHT_CAP_TXSTBC
;
1054 if (os_strstr(capab
, "[RX-STBC-1]"))
1055 conf
->vht_capab
|= VHT_CAP_RXSTBC_1
;
1056 if (os_strstr(capab
, "[RX-STBC-12]"))
1057 conf
->vht_capab
|= VHT_CAP_RXSTBC_2
;
1058 if (os_strstr(capab
, "[RX-STBC-123]"))
1059 conf
->vht_capab
|= VHT_CAP_RXSTBC_3
;
1060 if (os_strstr(capab
, "[RX-STBC-1234]"))
1061 conf
->vht_capab
|= VHT_CAP_RXSTBC_4
;
1062 if (os_strstr(capab
, "[SU-BEAMFORMER]"))
1063 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1064 if (os_strstr(capab
, "[SU-BEAMFORMEE]"))
1065 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMEE_CAPABLE
;
1066 if (os_strstr(capab
, "[BF-ANTENNA-2]") &&
1067 (conf
->vht_capab
& VHT_CAP_MU_BEAMFORMER_CAPABLE
))
1068 conf
->vht_capab
|= VHT_CAP_BEAMFORMER_ANTENNAS_MAX
;
1069 if (os_strstr(capab
, "[SOUNDING-DIMENSION-2]") &&
1070 (conf
->vht_capab
& VHT_CAP_MU_BEAMFORMER_CAPABLE
))
1071 conf
->vht_capab
|= VHT_CAP_SOUNDING_DIMENTION_MAX
;
1072 if (os_strstr(capab
, "[MU-BEAMFORMER]"))
1073 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMER_CAPABLE
;
1074 if (os_strstr(capab
, "[MU-BEAMFORMEE]"))
1075 conf
->vht_capab
|= VHT_CAP_MU_BEAMFORMEE_CAPABLE
;
1076 if (os_strstr(capab
, "[VHT-TXOP-PS]"))
1077 conf
->vht_capab
|= VHT_CAP_VHT_TXOP_PS
;
1078 if (os_strstr(capab
, "[HTC-VHT]"))
1079 conf
->vht_capab
|= VHT_CAP_HTC_VHT
;
1080 if (os_strstr(capab
, "[MAX-A-MPDU-LEN-EXP0]"))
1081 conf
->vht_capab
|= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT
;
1082 if (os_strstr(capab
, "[VHT-LINK-ADAPT2]") &&
1083 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1084 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB
;
1085 if (os_strstr(capab
, "[VHT-LINK-ADAPT3]") &&
1086 (conf
->vht_capab
& VHT_CAP_HTC_VHT
))
1087 conf
->vht_capab
|= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB
;
1088 if (os_strstr(capab
, "[RX-ANTENNA-PATTERN]"))
1089 conf
->vht_capab
|= VHT_CAP_RX_ANTENNA_PATTERN
;
1090 if (os_strstr(capab
, "[TX-ANTENNA-PATTERN]"))
1091 conf
->vht_capab
|= VHT_CAP_TX_ANTENNA_PATTERN
;
1094 #endif /* CONFIG_IEEE80211AC */
1097 static int hostapd_config_check_bss(struct hostapd_bss_config
*bss
,
1098 struct hostapd_config
*conf
)
1100 if (bss
->ieee802_1x
&& !bss
->eap_server
&&
1101 !bss
->radius
->auth_servers
) {
1102 wpa_printf(MSG_ERROR
, "Invalid IEEE 802.1X configuration (no "
1103 "EAP authenticator configured).");
1107 if (bss
->wpa
&& bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
1108 bss
->macaddr_acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
1109 wpa_printf(MSG_ERROR
, "WPA-PSK using RADIUS enabled, but no "
1110 "RADIUS checking (macaddr_acl=2) enabled.");
1114 if (bss
->wpa
&& (bss
->wpa_key_mgmt
& WPA_KEY_MGMT_PSK
) &&
1115 bss
->ssid
.wpa_psk
== NULL
&& bss
->ssid
.wpa_passphrase
== NULL
&&
1116 bss
->ssid
.wpa_psk_file
== NULL
&&
1117 (bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
||
1118 bss
->macaddr_acl
!= USE_EXTERNAL_RADIUS_AUTH
)) {
1119 wpa_printf(MSG_ERROR
, "WPA-PSK enabled, but PSK or passphrase "
1120 "is not configured.");
1124 if (hostapd_mac_comp_empty(bss
->bssid
) != 0) {
1127 for (i
= 0; i
< conf
->num_bss
; i
++) {
1128 if ((&conf
->bss
[i
] != bss
) &&
1129 (hostapd_mac_comp(conf
->bss
[i
].bssid
,
1130 bss
->bssid
) == 0)) {
1131 wpa_printf(MSG_ERROR
, "Duplicate BSSID " MACSTR
1132 " on interface '%s' and '%s'.",
1133 MAC2STR(bss
->bssid
),
1134 conf
->bss
[i
].iface
, bss
->iface
);
1140 #ifdef CONFIG_IEEE80211R
1141 if (wpa_key_mgmt_ft(bss
->wpa_key_mgmt
) &&
1142 (bss
->nas_identifier
== NULL
||
1143 os_strlen(bss
->nas_identifier
) < 1 ||
1144 os_strlen(bss
->nas_identifier
) > FT_R0KH_ID_MAX_LEN
)) {
1145 wpa_printf(MSG_ERROR
, "FT (IEEE 802.11r) requires "
1146 "nas_identifier to be configured as a 1..48 octet "
1150 #endif /* CONFIG_IEEE80211R */
1152 #ifdef CONFIG_IEEE80211N
1153 if (conf
->ieee80211n
&& conf
->hw_mode
== HOSTAPD_MODE_IEEE80211B
) {
1154 bss
->disable_11n
= 1;
1155 wpa_printf(MSG_ERROR
, "HT (IEEE 802.11n) in 11b mode is not "
1156 "allowed, disabling HT capabilites");
1159 if (conf
->ieee80211n
&&
1160 bss
->ssid
.security_policy
== SECURITY_STATIC_WEP
) {
1161 bss
->disable_11n
= 1;
1162 wpa_printf(MSG_ERROR
, "HT (IEEE 802.11n) with WEP is not "
1163 "allowed, disabling HT capabilities");
1166 if (conf
->ieee80211n
&& bss
->wpa
&&
1167 !(bss
->wpa_pairwise
& WPA_CIPHER_CCMP
) &&
1168 !(bss
->rsn_pairwise
& (WPA_CIPHER_CCMP
| WPA_CIPHER_GCMP
))) {
1169 bss
->disable_11n
= 1;
1170 wpa_printf(MSG_ERROR
, "HT (IEEE 802.11n) with WPA/WPA2 "
1171 "requires CCMP/GCMP to be enabled, disabling HT "
1174 #endif /* CONFIG_IEEE80211N */
1177 if (bss
->wps_state
&& bss
->ignore_broadcast_ssid
) {
1178 wpa_printf(MSG_INFO
, "WPS: ignore_broadcast_ssid "
1179 "configuration forced WPS to be disabled");
1183 if (bss
->wps_state
&& bss
->ssid
.wep
.keys_set
&& bss
->wpa
== 0) {
1184 wpa_printf(MSG_INFO
, "WPS: WEP configuration forced WPS to be "
1189 if (bss
->wps_state
&& bss
->wpa
&&
1191 !(bss
->rsn_pairwise
& WPA_CIPHER_CCMP
))) {
1192 wpa_printf(MSG_INFO
, "WPS: WPA/TKIP configuration without "
1193 "WPA2/CCMP forced WPS to be disabled");
1196 #endif /* CONFIG_WPS2 */
1201 !(bss
->rsn_pairwise
& (WPA_CIPHER_CCMP
| WPA_CIPHER_GCMP
)))) {
1202 wpa_printf(MSG_ERROR
, "HS 2.0: WPA2-Enterprise/CCMP "
1203 "configuration is required for Hotspot 2.0 "
1207 #endif /* CONFIG_HS20 */
1213 static int hostapd_config_check(struct hostapd_config
*conf
)
1217 if (conf
->ieee80211d
&& (!conf
->country
[0] || !conf
->country
[1])) {
1218 wpa_printf(MSG_ERROR
, "Cannot enable IEEE 802.11d without "
1219 "setting the country_code");
1223 if (conf
->ieee80211h
&& !conf
->ieee80211d
) {
1224 wpa_printf(MSG_ERROR
, "Cannot enable IEEE 802.11h without "
1225 "IEEE 802.11d enabled");
1229 for (i
= 0; i
< conf
->num_bss
; i
++) {
1230 if (hostapd_config_check_bss(&conf
->bss
[i
], conf
))
1238 #ifdef CONFIG_INTERWORKING
1239 static int parse_roaming_consortium(struct hostapd_bss_config
*bss
, char *pos
,
1242 size_t len
= os_strlen(pos
);
1243 u8 oi
[MAX_ROAMING_CONSORTIUM_LEN
];
1245 struct hostapd_roaming_consortium
*rc
;
1247 if ((len
& 1) || len
< 2 * 3 || len
/ 2 > MAX_ROAMING_CONSORTIUM_LEN
||
1248 hexstr2bin(pos
, oi
, len
/ 2)) {
1249 wpa_printf(MSG_ERROR
, "Line %d: invalid roaming_consortium "
1255 rc
= os_realloc_array(bss
->roaming_consortium
,
1256 bss
->roaming_consortium_count
+ 1,
1257 sizeof(struct hostapd_roaming_consortium
));
1261 os_memcpy(rc
[bss
->roaming_consortium_count
].oi
, oi
, len
);
1262 rc
[bss
->roaming_consortium_count
].len
= len
;
1264 bss
->roaming_consortium
= rc
;
1265 bss
->roaming_consortium_count
++;
1271 static int parse_lang_string(struct hostapd_lang_string
**array
,
1272 unsigned int *count
, char *pos
)
1276 struct hostapd_lang_string
*ls
;
1278 sep
= os_strchr(pos
, ':');
1283 clen
= os_strlen(pos
);
1286 nlen
= os_strlen(sep
);
1290 ls
= os_realloc_array(*array
, *count
+ 1,
1291 sizeof(struct hostapd_lang_string
));
1296 ls
= &(*array
)[*count
];
1299 os_memset(ls
->lang
, 0, sizeof(ls
->lang
));
1300 os_memcpy(ls
->lang
, pos
, clen
);
1301 ls
->name_len
= nlen
;
1302 os_memcpy(ls
->name
, sep
, nlen
);
1308 static int parse_venue_name(struct hostapd_bss_config
*bss
, char *pos
,
1311 if (parse_lang_string(&bss
->venue_name
, &bss
->venue_name_count
, pos
)) {
1312 wpa_printf(MSG_ERROR
, "Line %d: Invalid venue_name '%s'",
1320 static int parse_3gpp_cell_net(struct hostapd_bss_config
*bss
, char *buf
,
1325 u8
*info
= NULL
, *ipos
;
1327 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1330 for (pos
= buf
; *pos
; pos
++) {
1331 if ((*pos
< '0' && *pos
> '9') && *pos
!= ';' && *pos
!= ',')
1336 if (1 + count
* 3 > 0x7f)
1339 info
= os_zalloc(2 + 3 + count
* 3);
1344 *ipos
++ = 0; /* GUD - Version 1 */
1345 *ipos
++ = 3 + count
* 3; /* User Data Header Length (UDHL) */
1346 *ipos
++ = 0; /* PLMN List IEI */
1347 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1348 *ipos
++ = 1 + count
* 3;
1349 *ipos
++ = count
; /* Number of PLMNs */
1352 while (pos
&& *pos
) {
1357 mnc
= os_strchr(pos
, ',');
1361 pos
= os_strchr(mnc
, ';');
1365 mnc_len
= os_strlen(mnc
);
1366 if (os_strlen(mcc
) != 3 || (mnc_len
!= 2 && mnc_len
!= 3))
1369 /* BC coded MCC,MNC */
1370 /* MCC digit 2 | MCC digit 1 */
1371 *ipos
++ = ((mcc
[1] - '0') << 4) | (mcc
[0] - '0');
1372 /* MNC digit 3 | MCC digit 3 */
1373 *ipos
++ = (((mnc_len
== 2) ? 0xf0 : ((mnc
[2] - '0') << 4))) |
1375 /* MNC digit 2 | MNC digit 1 */
1376 *ipos
++ = ((mnc
[1] - '0') << 4) | (mnc
[0] - '0');
1379 os_free(bss
->anqp_3gpp_cell_net
);
1380 bss
->anqp_3gpp_cell_net
= info
;
1381 bss
->anqp_3gpp_cell_net_len
= 2 + 3 + 3 * count
;
1382 wpa_hexdump(MSG_MSGDUMP
, "3GPP Cellular Network information",
1383 bss
->anqp_3gpp_cell_net
, bss
->anqp_3gpp_cell_net_len
);
1388 wpa_printf(MSG_ERROR
, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1395 static int parse_nai_realm(struct hostapd_bss_config
*bss
, char *buf
, int line
)
1397 struct hostapd_nai_realm_data
*realm
;
1400 char *pos
, *end
, *rpos
;
1402 offsets
= os_calloc(bss
->nai_realm_count
* MAX_NAI_REALMS
,
1404 if (offsets
== NULL
)
1407 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1408 realm
= &bss
->nai_realm_data
[i
];
1409 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1410 offsets
[i
* MAX_NAI_REALMS
+ j
] =
1412 realm
->realm
[j
] - realm
->realm_buf
: -1;
1416 realm
= os_realloc_array(bss
->nai_realm_data
, bss
->nai_realm_count
+ 1,
1417 sizeof(struct hostapd_nai_realm_data
));
1418 if (realm
== NULL
) {
1422 bss
->nai_realm_data
= realm
;
1424 /* patch the pointers after realloc */
1425 for (i
= 0; i
< bss
->nai_realm_count
; i
++) {
1426 realm
= &bss
->nai_realm_data
[i
];
1427 for (j
= 0; j
< MAX_NAI_REALMS
; j
++) {
1428 int offs
= offsets
[i
* MAX_NAI_REALMS
+ j
];
1430 realm
->realm
[j
] = realm
->realm_buf
+ offs
;
1432 realm
->realm
[j
] = NULL
;
1437 realm
= &bss
->nai_realm_data
[bss
->nai_realm_count
];
1438 os_memset(realm
, 0, sizeof(*realm
));
1441 realm
->encoding
= atoi(pos
);
1442 pos
= os_strchr(pos
, ',');
1447 end
= os_strchr(pos
, ',');
1452 len
= os_strlen(pos
);
1455 if (len
> MAX_NAI_REALMLEN
) {
1456 wpa_printf(MSG_ERROR
, "Too long a realm string (%d > max %d "
1457 "characters)", (int) len
, MAX_NAI_REALMLEN
);
1460 os_memcpy(realm
->realm_buf
, pos
, len
);
1467 while (pos
&& *pos
) {
1468 struct hostapd_nai_realm_eap
*eap
;
1470 if (realm
->eap_method_count
>= MAX_NAI_EAP_METHODS
) {
1471 wpa_printf(MSG_ERROR
, "Too many EAP methods");
1475 eap
= &realm
->eap_method
[realm
->eap_method_count
];
1476 realm
->eap_method_count
++;
1478 end
= os_strchr(pos
, ',');
1480 end
= pos
+ os_strlen(pos
);
1482 eap
->eap_method
= atoi(pos
);
1484 pos
= os_strchr(pos
, '[');
1485 if (pos
== NULL
|| pos
> end
)
1488 if (eap
->num_auths
>= MAX_NAI_AUTH_TYPES
) {
1489 wpa_printf(MSG_ERROR
, "Too many auth params");
1492 eap
->auth_id
[eap
->num_auths
] = atoi(pos
);
1493 pos
= os_strchr(pos
, ':');
1494 if (pos
== NULL
|| pos
> end
)
1497 eap
->auth_val
[eap
->num_auths
] = atoi(pos
);
1498 pos
= os_strchr(pos
, ']');
1499 if (pos
== NULL
|| pos
> end
)
1511 /* Split realm list into null terminated realms */
1512 rpos
= realm
->realm_buf
;
1515 if (i
>= MAX_NAI_REALMS
) {
1516 wpa_printf(MSG_ERROR
, "Too many realms");
1519 realm
->realm
[i
++] = rpos
;
1520 rpos
= os_strchr(rpos
, ';');
1526 bss
->nai_realm_count
++;
1531 wpa_printf(MSG_ERROR
, "Line %d: invalid nai_realm '%s'", line
, buf
);
1535 #endif /* CONFIG_INTERWORKING */
1539 static int hs20_parse_conn_capab(struct hostapd_bss_config
*bss
, char *buf
,
1545 if (bss
->hs20_connection_capability_len
>= 0xfff0)
1548 conn_cap
= os_realloc(bss
->hs20_connection_capability
,
1549 bss
->hs20_connection_capability_len
+ 4);
1550 if (conn_cap
== NULL
)
1553 bss
->hs20_connection_capability
= conn_cap
;
1554 conn_cap
+= bss
->hs20_connection_capability_len
;
1556 conn_cap
[0] = atoi(pos
);
1557 pos
= os_strchr(pos
, ':');
1561 WPA_PUT_LE16(conn_cap
+ 1, atoi(pos
));
1562 pos
= os_strchr(pos
, ':');
1566 conn_cap
[3] = atoi(pos
);
1567 bss
->hs20_connection_capability_len
+= 4;
1573 static int hs20_parse_wan_metrics(struct hostapd_bss_config
*bss
, char *buf
,
1579 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1581 wan_metrics
= os_zalloc(13);
1582 if (wan_metrics
== NULL
)
1587 if (hexstr2bin(pos
, wan_metrics
, 1) < 0)
1594 /* Downlink Speed */
1595 WPA_PUT_LE32(wan_metrics
+ 1, atoi(pos
));
1596 pos
= os_strchr(pos
, ':');
1602 WPA_PUT_LE32(wan_metrics
+ 5, atoi(pos
));
1603 pos
= os_strchr(pos
, ':');
1609 wan_metrics
[9] = atoi(pos
);
1610 pos
= os_strchr(pos
, ':');
1616 wan_metrics
[10] = atoi(pos
);
1617 pos
= os_strchr(pos
, ':');
1623 WPA_PUT_LE16(wan_metrics
+ 11, atoi(pos
));
1625 os_free(bss
->hs20_wan_metrics
);
1626 bss
->hs20_wan_metrics
= wan_metrics
;
1631 wpa_printf(MSG_ERROR
, "Line %d: Invalid hs20_wan_metrics '%s'",
1633 os_free(wan_metrics
);
1638 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config
*bss
,
1639 char *pos
, int line
)
1641 if (parse_lang_string(&bss
->hs20_oper_friendly_name
,
1642 &bss
->hs20_oper_friendly_name_count
, pos
)) {
1643 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1644 "hs20_oper_friendly_name '%s'", line
, pos
);
1649 #endif /* CONFIG_HS20 */
1652 #ifdef CONFIG_WPS_NFC
1653 static struct wpabuf
* hostapd_parse_bin(const char *buf
)
1658 len
= os_strlen(buf
);
1663 ret
= wpabuf_alloc(len
);
1667 if (hexstr2bin(buf
, wpabuf_put(ret
, len
), len
)) {
1674 #endif /* CONFIG_WPS_NFC */
1677 static int hostapd_config_fill(struct hostapd_config
*conf
,
1678 struct hostapd_bss_config
*bss
,
1679 char *buf
, char *pos
, int line
)
1684 if (os_strcmp(buf
, "interface") == 0) {
1685 os_strlcpy(conf
->bss
[0].iface
, pos
,
1686 sizeof(conf
->bss
[0].iface
));
1687 } else if (os_strcmp(buf
, "bridge") == 0) {
1688 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
1689 } else if (os_strcmp(buf
, "vlan_bridge") == 0) {
1690 os_strlcpy(bss
->vlan_bridge
, pos
,
1691 sizeof(bss
->vlan_bridge
));
1692 } else if (os_strcmp(buf
, "wds_bridge") == 0) {
1693 os_strlcpy(bss
->wds_bridge
, pos
,
1694 sizeof(bss
->wds_bridge
));
1695 } else if (os_strcmp(buf
, "driver") == 0) {
1697 /* clear to get error below if setting is invalid */
1698 conf
->driver
= NULL
;
1699 for (j
= 0; wpa_drivers
[j
]; j
++) {
1700 if (os_strcmp(pos
, wpa_drivers
[j
]->name
) == 0)
1702 conf
->driver
= wpa_drivers
[j
];
1706 if (conf
->driver
== NULL
) {
1707 wpa_printf(MSG_ERROR
, "Line %d: invalid/"
1708 "unknown driver '%s'", line
, pos
);
1711 } else if (os_strcmp(buf
, "debug") == 0) {
1712 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' "
1713 "configuration variable is not used "
1715 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
1716 bss
->logger_syslog_level
= atoi(pos
);
1717 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
1718 bss
->logger_stdout_level
= atoi(pos
);
1719 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
1720 bss
->logger_syslog
= atoi(pos
);
1721 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
1722 bss
->logger_stdout
= atoi(pos
);
1723 } else if (os_strcmp(buf
, "dump_file") == 0) {
1724 bss
->dump_log_name
= os_strdup(pos
);
1725 } else if (os_strcmp(buf
, "ssid") == 0) {
1726 bss
->ssid
.ssid_len
= os_strlen(pos
);
1727 if (bss
->ssid
.ssid_len
> HOSTAPD_MAX_SSID_LEN
||
1728 bss
->ssid
.ssid_len
< 1) {
1729 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID "
1733 os_memcpy(bss
->ssid
.ssid
, pos
,
1734 bss
->ssid
.ssid_len
);
1735 bss
->ssid
.ssid_set
= 1;
1737 } else if (os_strcmp(buf
, "ssid2") == 0) {
1739 char *str
= wpa_config_parse_string(pos
, &slen
);
1740 if (str
== NULL
|| slen
< 1 ||
1741 slen
> HOSTAPD_MAX_SSID_LEN
) {
1742 wpa_printf(MSG_ERROR
, "Line %d: invalid SSID "
1746 os_memcpy(bss
->ssid
.ssid
, str
, slen
);
1747 bss
->ssid
.ssid_len
= slen
;
1748 bss
->ssid
.ssid_set
= 1;
1751 } else if (os_strcmp(buf
, "utf8_ssid") == 0) {
1752 bss
->ssid
.utf8_ssid
= atoi(pos
) > 0;
1753 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
1754 bss
->macaddr_acl
= atoi(pos
);
1755 if (bss
->macaddr_acl
!= ACCEPT_UNLESS_DENIED
&&
1756 bss
->macaddr_acl
!= DENY_UNLESS_ACCEPTED
&&
1757 bss
->macaddr_acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
1758 wpa_printf(MSG_ERROR
, "Line %d: unknown "
1760 line
, bss
->macaddr_acl
);
1762 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
1763 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
1764 &bss
->num_accept_mac
))
1766 wpa_printf(MSG_ERROR
, "Line %d: Failed to "
1767 "read accept_mac_file '%s'",
1771 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
1772 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
1773 &bss
->num_deny_mac
)) {
1774 wpa_printf(MSG_ERROR
, "Line %d: Failed to "
1775 "read deny_mac_file '%s'",
1779 } else if (os_strcmp(buf
, "wds_sta") == 0) {
1780 bss
->wds_sta
= atoi(pos
);
1781 } else if (os_strcmp(buf
, "start_disabled") == 0) {
1782 bss
->start_disabled
= atoi(pos
);
1783 } else if (os_strcmp(buf
, "ap_isolate") == 0) {
1784 bss
->isolate
= atoi(pos
);
1785 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
1786 bss
->ap_max_inactivity
= atoi(pos
);
1787 } else if (os_strcmp(buf
, "skip_inactivity_poll") == 0) {
1788 bss
->skip_inactivity_poll
= atoi(pos
);
1789 } else if (os_strcmp(buf
, "country_code") == 0) {
1790 os_memcpy(conf
->country
, pos
, 2);
1791 /* FIX: make this configurable */
1792 conf
->country
[2] = ' ';
1793 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
1794 conf
->ieee80211d
= atoi(pos
);
1795 } else if (os_strcmp(buf
, "ieee80211h") == 0) {
1796 conf
->ieee80211h
= atoi(pos
);
1797 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
1798 bss
->ieee802_1x
= atoi(pos
);
1799 } else if (os_strcmp(buf
, "eapol_version") == 0) {
1800 bss
->eapol_version
= atoi(pos
);
1801 if (bss
->eapol_version
< 1 ||
1802 bss
->eapol_version
> 2) {
1803 wpa_printf(MSG_ERROR
, "Line %d: invalid EAPOL "
1804 "version (%d): '%s'.",
1805 line
, bss
->eapol_version
, pos
);
1808 wpa_printf(MSG_DEBUG
, "eapol_version=%d",
1809 bss
->eapol_version
);
1811 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
1812 bss
->eap_server
= atoi(pos
);
1813 wpa_printf(MSG_ERROR
, "Line %d: obsolete "
1814 "eap_authenticator used; this has been "
1815 "renamed to eap_server", line
);
1816 } else if (os_strcmp(buf
, "eap_server") == 0) {
1817 bss
->eap_server
= atoi(pos
);
1818 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
1819 if (hostapd_config_read_eap_user(pos
, bss
))
1821 } else if (os_strcmp(buf
, "ca_cert") == 0) {
1822 os_free(bss
->ca_cert
);
1823 bss
->ca_cert
= os_strdup(pos
);
1824 } else if (os_strcmp(buf
, "server_cert") == 0) {
1825 os_free(bss
->server_cert
);
1826 bss
->server_cert
= os_strdup(pos
);
1827 } else if (os_strcmp(buf
, "private_key") == 0) {
1828 os_free(bss
->private_key
);
1829 bss
->private_key
= os_strdup(pos
);
1830 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
1831 os_free(bss
->private_key_passwd
);
1832 bss
->private_key_passwd
= os_strdup(pos
);
1833 } else if (os_strcmp(buf
, "check_crl") == 0) {
1834 bss
->check_crl
= atoi(pos
);
1835 } else if (os_strcmp(buf
, "ocsp_stapling_response") == 0) {
1836 os_free(bss
->ocsp_stapling_response
);
1837 bss
->ocsp_stapling_response
= os_strdup(pos
);
1838 } else if (os_strcmp(buf
, "dh_file") == 0) {
1839 os_free(bss
->dh_file
);
1840 bss
->dh_file
= os_strdup(pos
);
1841 } else if (os_strcmp(buf
, "fragment_size") == 0) {
1842 bss
->fragment_size
= atoi(pos
);
1843 #ifdef EAP_SERVER_FAST
1844 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
1845 os_free(bss
->pac_opaque_encr_key
);
1846 bss
->pac_opaque_encr_key
= os_malloc(16);
1847 if (bss
->pac_opaque_encr_key
== NULL
) {
1848 wpa_printf(MSG_ERROR
, "Line %d: No memory for "
1849 "pac_opaque_encr_key", line
);
1851 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
,
1853 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1854 "pac_opaque_encr_key", line
);
1857 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
1858 size_t idlen
= os_strlen(pos
);
1860 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
1861 "eap_fast_a_id", line
);
1864 os_free(bss
->eap_fast_a_id
);
1865 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
1866 if (bss
->eap_fast_a_id
== NULL
||
1867 hexstr2bin(pos
, bss
->eap_fast_a_id
,
1869 wpa_printf(MSG_ERROR
, "Line %d: "
1871 "eap_fast_a_id", line
);
1874 bss
->eap_fast_a_id_len
= idlen
/ 2;
1876 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
1877 os_free(bss
->eap_fast_a_id_info
);
1878 bss
->eap_fast_a_id_info
= os_strdup(pos
);
1879 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
1880 bss
->eap_fast_prov
= atoi(pos
);
1881 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
1882 bss
->pac_key_lifetime
= atoi(pos
);
1883 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
1884 bss
->pac_key_refresh_time
= atoi(pos
);
1885 #endif /* EAP_SERVER_FAST */
1886 #ifdef EAP_SERVER_SIM
1887 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
1888 os_free(bss
->eap_sim_db
);
1889 bss
->eap_sim_db
= os_strdup(pos
);
1890 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
1891 bss
->eap_sim_aka_result_ind
= atoi(pos
);
1892 #endif /* EAP_SERVER_SIM */
1893 #ifdef EAP_SERVER_TNC
1894 } else if (os_strcmp(buf
, "tnc") == 0) {
1895 bss
->tnc
= atoi(pos
);
1896 #endif /* EAP_SERVER_TNC */
1897 #ifdef EAP_SERVER_PWD
1898 } else if (os_strcmp(buf
, "pwd_group") == 0) {
1899 bss
->pwd_group
= atoi(pos
);
1900 #endif /* EAP_SERVER_PWD */
1901 #endif /* EAP_SERVER */
1902 } else if (os_strcmp(buf
, "eap_message") == 0) {
1904 bss
->eap_req_id_text
= os_strdup(pos
);
1905 if (bss
->eap_req_id_text
== NULL
) {
1906 wpa_printf(MSG_ERROR
, "Line %d: Failed to "
1907 "allocate memory for "
1908 "eap_req_id_text", line
);
1912 bss
->eap_req_id_text_len
=
1913 os_strlen(bss
->eap_req_id_text
);
1914 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
1917 os_memmove(term
, term
+ 1,
1918 bss
->eap_req_id_text_len
-
1919 (term
- bss
->eap_req_id_text
) - 1);
1920 bss
->eap_req_id_text_len
--;
1922 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
1923 bss
->default_wep_key_len
= atoi(pos
);
1924 if (bss
->default_wep_key_len
> 13) {
1925 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP "
1926 "key len %lu (= %lu bits)", line
,
1928 bss
->default_wep_key_len
,
1930 bss
->default_wep_key_len
* 8);
1933 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
1934 bss
->individual_wep_key_len
= atoi(pos
);
1935 if (bss
->individual_wep_key_len
< 0 ||
1936 bss
->individual_wep_key_len
> 13) {
1937 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP "
1938 "key len %d (= %d bits)", line
,
1939 bss
->individual_wep_key_len
,
1940 bss
->individual_wep_key_len
* 8);
1943 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
1944 bss
->wep_rekeying_period
= atoi(pos
);
1945 if (bss
->wep_rekeying_period
< 0) {
1946 wpa_printf(MSG_ERROR
, "Line %d: invalid "
1948 line
, bss
->wep_rekeying_period
);
1951 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
1952 bss
->eap_reauth_period
= atoi(pos
);
1953 if (bss
->eap_reauth_period
< 0) {
1954 wpa_printf(MSG_ERROR
, "Line %d: invalid "
1956 line
, bss
->eap_reauth_period
);
1959 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
1960 bss
->eapol_key_index_workaround
= atoi(pos
);
1962 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
1963 bss
->ieee802_11f
= 1;
1964 os_strlcpy(bss
->iapp_iface
, pos
,
1965 sizeof(bss
->iapp_iface
));
1966 #endif /* CONFIG_IAPP */
1967 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
1968 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
1969 wpa_printf(MSG_ERROR
, "Line %d: invalid IP "
1970 "address '%s'", line
, pos
);
1973 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
1974 bss
->nas_identifier
= os_strdup(pos
);
1975 #ifndef CONFIG_NO_RADIUS
1976 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
1977 if (hostapd_config_read_radius_addr(
1978 &bss
->radius
->auth_servers
,
1979 &bss
->radius
->num_auth_servers
, pos
, 1812,
1980 &bss
->radius
->auth_server
)) {
1981 wpa_printf(MSG_ERROR
, "Line %d: invalid IP "
1982 "address '%s'", line
, pos
);
1985 } else if (bss
->radius
->auth_server
&&
1986 os_strcmp(buf
, "auth_server_port") == 0) {
1987 bss
->radius
->auth_server
->port
= atoi(pos
);
1988 } else if (bss
->radius
->auth_server
&&
1989 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
1990 int len
= os_strlen(pos
);
1992 /* RFC 2865, Ch. 3 */
1993 wpa_printf(MSG_ERROR
, "Line %d: empty shared "
1994 "secret is not allowed.", line
);
1997 bss
->radius
->auth_server
->shared_secret
=
1998 (u8
*) os_strdup(pos
);
1999 bss
->radius
->auth_server
->shared_secret_len
= len
;
2000 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
2001 if (hostapd_config_read_radius_addr(
2002 &bss
->radius
->acct_servers
,
2003 &bss
->radius
->num_acct_servers
, pos
, 1813,
2004 &bss
->radius
->acct_server
)) {
2005 wpa_printf(MSG_ERROR
, "Line %d: invalid IP "
2006 "address '%s'", line
, pos
);
2009 } else if (bss
->radius
->acct_server
&&
2010 os_strcmp(buf
, "acct_server_port") == 0) {
2011 bss
->radius
->acct_server
->port
= atoi(pos
);
2012 } else if (bss
->radius
->acct_server
&&
2013 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
2014 int len
= os_strlen(pos
);
2016 /* RFC 2865, Ch. 3 */
2017 wpa_printf(MSG_ERROR
, "Line %d: empty shared "
2018 "secret is not allowed.", line
);
2021 bss
->radius
->acct_server
->shared_secret
=
2022 (u8
*) os_strdup(pos
);
2023 bss
->radius
->acct_server
->shared_secret_len
= len
;
2024 } else if (os_strcmp(buf
, "radius_retry_primary_interval") ==
2026 bss
->radius
->retry_primary_interval
= atoi(pos
);
2027 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0)
2029 bss
->acct_interim_interval
= atoi(pos
);
2030 } else if (os_strcmp(buf
, "radius_request_cui") == 0) {
2031 bss
->radius_request_cui
= atoi(pos
);
2032 } else if (os_strcmp(buf
, "radius_auth_req_attr") == 0) {
2033 struct hostapd_radius_attr
*attr
, *a
;
2034 attr
= hostapd_parse_radius_attr(pos
);
2036 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2037 "radius_auth_req_attr", line
);
2039 } else if (bss
->radius_auth_req_attr
== NULL
) {
2040 bss
->radius_auth_req_attr
= attr
;
2042 a
= bss
->radius_auth_req_attr
;
2047 } else if (os_strcmp(buf
, "radius_acct_req_attr") == 0) {
2048 struct hostapd_radius_attr
*attr
, *a
;
2049 attr
= hostapd_parse_radius_attr(pos
);
2051 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2052 "radius_acct_req_attr", line
);
2054 } else if (bss
->radius_acct_req_attr
== NULL
) {
2055 bss
->radius_acct_req_attr
= attr
;
2057 a
= bss
->radius_acct_req_attr
;
2062 } else if (os_strcmp(buf
, "radius_das_port") == 0) {
2063 bss
->radius_das_port
= atoi(pos
);
2064 } else if (os_strcmp(buf
, "radius_das_client") == 0) {
2065 if (hostapd_parse_das_client(bss
, pos
) < 0) {
2066 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2067 "DAS client", line
);
2070 } else if (os_strcmp(buf
, "radius_das_time_window") == 0) {
2071 bss
->radius_das_time_window
= atoi(pos
);
2072 } else if (os_strcmp(buf
, "radius_das_require_event_timestamp")
2074 bss
->radius_das_require_event_timestamp
= atoi(pos
);
2075 #endif /* CONFIG_NO_RADIUS */
2076 } else if (os_strcmp(buf
, "auth_algs") == 0) {
2077 bss
->auth_algs
= atoi(pos
);
2078 if (bss
->auth_algs
== 0) {
2079 wpa_printf(MSG_ERROR
, "Line %d: no "
2080 "authentication algorithms allowed",
2084 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
2085 bss
->max_num_sta
= atoi(pos
);
2086 if (bss
->max_num_sta
< 0 ||
2087 bss
->max_num_sta
> MAX_STA_COUNT
) {
2088 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2089 "max_num_sta=%d; allowed range "
2090 "0..%d", line
, bss
->max_num_sta
,
2094 } else if (os_strcmp(buf
, "wpa") == 0) {
2095 bss
->wpa
= atoi(pos
);
2096 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
2097 bss
->wpa_group_rekey
= atoi(pos
);
2098 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
2099 bss
->wpa_strict_rekey
= atoi(pos
);
2100 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
2101 bss
->wpa_gmk_rekey
= atoi(pos
);
2102 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
2103 bss
->wpa_ptk_rekey
= atoi(pos
);
2104 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
2105 int len
= os_strlen(pos
);
2106 if (len
< 8 || len
> 63) {
2107 wpa_printf(MSG_ERROR
, "Line %d: invalid WPA "
2108 "passphrase length %d (expected "
2109 "8..63)", line
, len
);
2112 os_free(bss
->ssid
.wpa_passphrase
);
2113 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
2114 os_free(bss
->ssid
.wpa_psk
);
2115 bss
->ssid
.wpa_psk
= NULL
;
2117 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
2118 os_free(bss
->ssid
.wpa_psk
);
2120 os_zalloc(sizeof(struct hostapd_wpa_psk
));
2121 if (bss
->ssid
.wpa_psk
== NULL
)
2123 else if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
,
2125 pos
[PMK_LEN
* 2] != '\0') {
2126 wpa_printf(MSG_ERROR
, "Line %d: Invalid PSK "
2127 "'%s'.", line
, pos
);
2130 bss
->ssid
.wpa_psk
->group
= 1;
2131 os_free(bss
->ssid
.wpa_passphrase
);
2132 bss
->ssid
.wpa_passphrase
= NULL
;
2134 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
2135 os_free(bss
->ssid
.wpa_psk_file
);
2136 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
2137 if (!bss
->ssid
.wpa_psk_file
) {
2138 wpa_printf(MSG_ERROR
, "Line %d: allocation "
2142 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
2144 hostapd_config_parse_key_mgmt(line
, pos
);
2145 if (bss
->wpa_key_mgmt
== -1)
2147 } else if (os_strcmp(buf
, "wpa_psk_radius") == 0) {
2148 bss
->wpa_psk_radius
= atoi(pos
);
2149 if (bss
->wpa_psk_radius
!= PSK_RADIUS_IGNORED
&&
2150 bss
->wpa_psk_radius
!= PSK_RADIUS_ACCEPTED
&&
2151 bss
->wpa_psk_radius
!= PSK_RADIUS_REQUIRED
) {
2152 wpa_printf(MSG_ERROR
, "Line %d: unknown "
2153 "wpa_psk_radius %d",
2154 line
, bss
->wpa_psk_radius
);
2157 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
2159 hostapd_config_parse_cipher(line
, pos
);
2160 if (bss
->wpa_pairwise
== -1 ||
2161 bss
->wpa_pairwise
== 0)
2163 else if (bss
->wpa_pairwise
&
2164 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
|
2165 WPA_CIPHER_WEP104
)) {
2166 wpa_printf(MSG_ERROR
, "Line %d: unsupported "
2167 "pairwise cipher suite '%s'",
2168 bss
->wpa_pairwise
, pos
);
2171 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
2173 hostapd_config_parse_cipher(line
, pos
);
2174 if (bss
->rsn_pairwise
== -1 ||
2175 bss
->rsn_pairwise
== 0)
2177 else if (bss
->rsn_pairwise
&
2178 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
|
2179 WPA_CIPHER_WEP104
)) {
2180 wpa_printf(MSG_ERROR
, "Line %d: unsupported "
2181 "pairwise cipher suite '%s'",
2182 bss
->rsn_pairwise
, pos
);
2185 #ifdef CONFIG_RSN_PREAUTH
2186 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
2187 bss
->rsn_preauth
= atoi(pos
);
2188 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
2189 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
2190 #endif /* CONFIG_RSN_PREAUTH */
2191 #ifdef CONFIG_PEERKEY
2192 } else if (os_strcmp(buf
, "peerkey") == 0) {
2193 bss
->peerkey
= atoi(pos
);
2194 #endif /* CONFIG_PEERKEY */
2195 #ifdef CONFIG_IEEE80211R
2196 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
2197 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
2198 hexstr2bin(pos
, bss
->mobility_domain
,
2199 MOBILITY_DOMAIN_ID_LEN
) != 0) {
2200 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2201 "mobility_domain '%s'", line
, pos
);
2205 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
2206 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
2207 hexstr2bin(pos
, bss
->r1_key_holder
,
2208 FT_R1KH_ID_LEN
) != 0) {
2209 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2210 "r1_key_holder '%s'", line
, pos
);
2214 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
2215 bss
->r0_key_lifetime
= atoi(pos
);
2216 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
2217 bss
->reassociation_deadline
= atoi(pos
);
2218 } else if (os_strcmp(buf
, "r0kh") == 0) {
2219 if (add_r0kh(bss
, pos
) < 0) {
2220 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2221 "r0kh '%s'", line
, pos
);
2225 } else if (os_strcmp(buf
, "r1kh") == 0) {
2226 if (add_r1kh(bss
, pos
) < 0) {
2227 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
2228 "r1kh '%s'", line
, pos
);
2232 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
2233 bss
->pmk_r1_push
= atoi(pos
);
2234 } else if (os_strcmp(buf
, "ft_over_ds") == 0) {
2235 bss
->ft_over_ds
= atoi(pos
);
2236 #endif /* CONFIG_IEEE80211R */
2237 #ifndef CONFIG_NO_CTRL_IFACE
2238 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
2239 os_free(bss
->ctrl_interface
);
2240 bss
->ctrl_interface
= os_strdup(pos
);
2241 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
2242 #ifndef CONFIG_NATIVE_WINDOWS
2245 const char *group
= pos
;
2247 grp
= getgrnam(group
);
2249 bss
->ctrl_interface_gid
= grp
->gr_gid
;
2250 bss
->ctrl_interface_gid_set
= 1;
2251 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d"
2252 " (from group name '%s')",
2253 bss
->ctrl_interface_gid
, group
);
2257 /* Group name not found - try to parse this as gid */
2258 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
2259 if (*group
== '\0' || *endp
!= '\0') {
2260 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group "
2261 "'%s'", line
, group
);
2265 bss
->ctrl_interface_gid_set
= 1;
2266 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
2267 bss
->ctrl_interface_gid
);
2268 #endif /* CONFIG_NATIVE_WINDOWS */
2269 #endif /* CONFIG_NO_CTRL_IFACE */
2270 #ifdef RADIUS_SERVER
2271 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
2272 os_free(bss
->radius_server_clients
);
2273 bss
->radius_server_clients
= os_strdup(pos
);
2274 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
2275 bss
->radius_server_auth_port
= atoi(pos
);
2276 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
2277 bss
->radius_server_ipv6
= atoi(pos
);
2278 #endif /* RADIUS_SERVER */
2279 } else if (os_strcmp(buf
, "test_socket") == 0) {
2280 os_free(bss
->test_socket
);
2281 bss
->test_socket
= os_strdup(pos
);
2282 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
2283 bss
->use_pae_group_addr
= atoi(pos
);
2284 } else if (os_strcmp(buf
, "hw_mode") == 0) {
2285 if (os_strcmp(pos
, "a") == 0)
2286 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
2287 else if (os_strcmp(pos
, "b") == 0)
2288 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
2289 else if (os_strcmp(pos
, "g") == 0)
2290 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
2291 else if (os_strcmp(pos
, "ad") == 0)
2292 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211AD
;
2294 wpa_printf(MSG_ERROR
, "Line %d: unknown "
2295 "hw_mode '%s'", line
, pos
);
2298 } else if (os_strcmp(buf
, "wps_rf_bands") == 0) {
2299 if (os_strcmp(pos
, "a") == 0)
2300 bss
->wps_rf_bands
= WPS_RF_50GHZ
;
2301 else if (os_strcmp(pos
, "g") == 0 ||
2302 os_strcmp(pos
, "b") == 0)
2303 bss
->wps_rf_bands
= WPS_RF_24GHZ
;
2304 else if (os_strcmp(pos
, "ag") == 0 ||
2305 os_strcmp(pos
, "ga") == 0)
2307 WPS_RF_24GHZ
| WPS_RF_50GHZ
;
2309 wpa_printf(MSG_ERROR
, "Line %d: unknown "
2310 "wps_rf_band '%s'", line
, pos
);
2313 } else if (os_strcmp(buf
, "channel") == 0) {
2314 conf
->channel
= atoi(pos
);
2315 } else if (os_strcmp(buf
, "beacon_int") == 0) {
2316 int val
= atoi(pos
);
2317 /* MIB defines range as 1..65535, but very small values
2318 * cause problems with the current implementation.
2319 * Since it is unlikely that this small numbers are
2320 * useful in real life scenarios, do not allow beacon
2321 * period to be set below 15 TU. */
2322 if (val
< 15 || val
> 65535) {
2323 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2324 "beacon_int %d (expected "
2325 "15..65535)", line
, val
);
2328 conf
->beacon_int
= val
;
2329 } else if (os_strcmp(buf
, "dtim_period") == 0) {
2330 bss
->dtim_period
= atoi(pos
);
2331 if (bss
->dtim_period
< 1 || bss
->dtim_period
> 255) {
2332 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2334 line
, bss
->dtim_period
);
2337 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
2338 conf
->rts_threshold
= atoi(pos
);
2339 if (conf
->rts_threshold
< 0 ||
2340 conf
->rts_threshold
> 2347) {
2341 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2343 line
, conf
->rts_threshold
);
2346 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
2347 conf
->fragm_threshold
= atoi(pos
);
2348 if (conf
->fragm_threshold
< 256 ||
2349 conf
->fragm_threshold
> 2346) {
2350 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2351 "fragm_threshold %d",
2352 line
, conf
->fragm_threshold
);
2355 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
2356 int val
= atoi(pos
);
2357 if (val
!= 0 && val
!= 1) {
2358 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2359 "send_probe_response %d (expected "
2360 "0 or 1)", line
, val
);
2362 conf
->send_probe_response
= val
;
2363 } else if (os_strcmp(buf
, "supported_rates") == 0) {
2364 if (hostapd_parse_intlist(&conf
->supported_rates
, pos
))
2366 wpa_printf(MSG_ERROR
, "Line %d: invalid rate "
2370 } else if (os_strcmp(buf
, "basic_rates") == 0) {
2371 if (hostapd_parse_intlist(&conf
->basic_rates
, pos
)) {
2372 wpa_printf(MSG_ERROR
, "Line %d: invalid rate "
2376 } else if (os_strcmp(buf
, "preamble") == 0) {
2378 conf
->preamble
= SHORT_PREAMBLE
;
2380 conf
->preamble
= LONG_PREAMBLE
;
2381 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
2382 bss
->ignore_broadcast_ssid
= atoi(pos
);
2383 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
2384 bss
->ssid
.wep
.idx
= atoi(pos
);
2385 if (bss
->ssid
.wep
.idx
> 3) {
2386 wpa_printf(MSG_ERROR
, "Invalid "
2387 "wep_default_key index %d",
2391 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
2392 os_strcmp(buf
, "wep_key1") == 0 ||
2393 os_strcmp(buf
, "wep_key2") == 0 ||
2394 os_strcmp(buf
, "wep_key3") == 0) {
2395 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
2396 buf
[7] - '0', pos
)) {
2397 wpa_printf(MSG_ERROR
, "Line %d: invalid WEP "
2398 "key '%s'", line
, buf
);
2401 #ifndef CONFIG_NO_VLAN
2402 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
2403 bss
->ssid
.dynamic_vlan
= atoi(pos
);
2404 } else if (os_strcmp(buf
, "vlan_file") == 0) {
2405 if (hostapd_config_read_vlan_file(bss
, pos
)) {
2406 wpa_printf(MSG_ERROR
, "Line %d: failed to "
2407 "read VLAN file '%s'", line
, pos
);
2410 } else if (os_strcmp(buf
, "vlan_naming") == 0) {
2411 bss
->ssid
.vlan_naming
= atoi(pos
);
2412 if (bss
->ssid
.vlan_naming
>= DYNAMIC_VLAN_NAMING_END
||
2413 bss
->ssid
.vlan_naming
< 0) {
2414 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2415 "naming scheme %d", line
,
2416 bss
->ssid
.vlan_naming
);
2419 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2420 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
2421 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
2422 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2423 #endif /* CONFIG_NO_VLAN */
2424 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
2425 conf
->ap_table_max_size
= atoi(pos
);
2426 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
2427 conf
->ap_table_expiration_time
= atoi(pos
);
2428 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
2429 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
2430 wpa_printf(MSG_ERROR
, "Line %d: invalid TX "
2431 "queue item", line
);
2434 } else if (os_strcmp(buf
, "wme_enabled") == 0 ||
2435 os_strcmp(buf
, "wmm_enabled") == 0) {
2436 bss
->wmm_enabled
= atoi(pos
);
2437 } else if (os_strcmp(buf
, "uapsd_advertisement_enabled") == 0) {
2438 bss
->wmm_uapsd
= atoi(pos
);
2439 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0 ||
2440 os_strncmp(buf
, "wmm_ac_", 7) == 0) {
2441 if (hostapd_config_wmm_ac(conf
->wmm_ac_params
, buf
,
2443 wpa_printf(MSG_ERROR
, "Line %d: invalid WMM "
2447 } else if (os_strcmp(buf
, "bss") == 0) {
2448 if (hostapd_config_bss(conf
, pos
)) {
2449 wpa_printf(MSG_ERROR
, "Line %d: invalid bss "
2453 } else if (os_strcmp(buf
, "bssid") == 0) {
2454 if (hwaddr_aton(pos
, bss
->bssid
)) {
2455 wpa_printf(MSG_ERROR
, "Line %d: invalid bssid "
2459 #ifdef CONFIG_IEEE80211W
2460 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
2461 bss
->ieee80211w
= atoi(pos
);
2462 } else if (os_strcmp(buf
, "assoc_sa_query_max_timeout") == 0) {
2463 bss
->assoc_sa_query_max_timeout
= atoi(pos
);
2464 if (bss
->assoc_sa_query_max_timeout
== 0) {
2465 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2466 "assoc_sa_query_max_timeout", line
);
2469 } else if (os_strcmp(buf
, "assoc_sa_query_retry_timeout") == 0)
2471 bss
->assoc_sa_query_retry_timeout
= atoi(pos
);
2472 if (bss
->assoc_sa_query_retry_timeout
== 0) {
2473 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2474 "assoc_sa_query_retry_timeout",
2478 #endif /* CONFIG_IEEE80211W */
2479 #ifdef CONFIG_IEEE80211N
2480 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
2481 conf
->ieee80211n
= atoi(pos
);
2482 } else if (os_strcmp(buf
, "ht_capab") == 0) {
2483 if (hostapd_config_ht_capab(conf
, pos
) < 0) {
2484 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2488 } else if (os_strcmp(buf
, "require_ht") == 0) {
2489 conf
->require_ht
= atoi(pos
);
2490 #endif /* CONFIG_IEEE80211N */
2491 #ifdef CONFIG_IEEE80211AC
2492 } else if (os_strcmp(buf
, "ieee80211ac") == 0) {
2493 conf
->ieee80211ac
= atoi(pos
);
2494 } else if (os_strcmp(buf
, "vht_capab") == 0) {
2495 if (hostapd_config_vht_capab(conf
, pos
) < 0) {
2496 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2500 } else if (os_strcmp(buf
, "require_vht") == 0) {
2501 conf
->require_vht
= atoi(pos
);
2502 } else if (os_strcmp(buf
, "vht_oper_chwidth") == 0) {
2503 conf
->vht_oper_chwidth
= atoi(pos
);
2504 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg0_idx") == 0)
2506 conf
->vht_oper_centr_freq_seg0_idx
= atoi(pos
);
2507 } else if (os_strcmp(buf
, "vht_oper_centr_freq_seg1_idx") == 0)
2509 conf
->vht_oper_centr_freq_seg1_idx
= atoi(pos
);
2510 #endif /* CONFIG_IEEE80211AC */
2511 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
2512 bss
->max_listen_interval
= atoi(pos
);
2513 } else if (os_strcmp(buf
, "disable_pmksa_caching") == 0) {
2514 bss
->disable_pmksa_caching
= atoi(pos
);
2515 } else if (os_strcmp(buf
, "okc") == 0) {
2516 bss
->okc
= atoi(pos
);
2518 } else if (os_strcmp(buf
, "wps_state") == 0) {
2519 bss
->wps_state
= atoi(pos
);
2520 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
2521 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2525 } else if (os_strcmp(buf
, "wps_independent") == 0) {
2526 bss
->wps_independent
= atoi(pos
);
2527 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
2528 bss
->ap_setup_locked
= atoi(pos
);
2529 } else if (os_strcmp(buf
, "uuid") == 0) {
2530 if (uuid_str2bin(pos
, bss
->uuid
)) {
2531 wpa_printf(MSG_ERROR
, "Line %d: invalid UUID",
2535 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
2536 os_free(bss
->wps_pin_requests
);
2537 bss
->wps_pin_requests
= os_strdup(pos
);
2538 } else if (os_strcmp(buf
, "device_name") == 0) {
2539 if (os_strlen(pos
) > 32) {
2540 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2541 "device_name", line
);
2544 os_free(bss
->device_name
);
2545 bss
->device_name
= os_strdup(pos
);
2546 } else if (os_strcmp(buf
, "manufacturer") == 0) {
2547 if (os_strlen(pos
) > 64) {
2548 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2549 "manufacturer", line
);
2552 os_free(bss
->manufacturer
);
2553 bss
->manufacturer
= os_strdup(pos
);
2554 } else if (os_strcmp(buf
, "model_name") == 0) {
2555 if (os_strlen(pos
) > 32) {
2556 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2557 "model_name", line
);
2560 os_free(bss
->model_name
);
2561 bss
->model_name
= os_strdup(pos
);
2562 } else if (os_strcmp(buf
, "model_number") == 0) {
2563 if (os_strlen(pos
) > 32) {
2564 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2565 "model_number", line
);
2568 os_free(bss
->model_number
);
2569 bss
->model_number
= os_strdup(pos
);
2570 } else if (os_strcmp(buf
, "serial_number") == 0) {
2571 if (os_strlen(pos
) > 32) {
2572 wpa_printf(MSG_ERROR
, "Line %d: Too long "
2573 "serial_number", line
);
2576 os_free(bss
->serial_number
);
2577 bss
->serial_number
= os_strdup(pos
);
2578 } else if (os_strcmp(buf
, "device_type") == 0) {
2579 if (wps_dev_type_str2bin(pos
, bss
->device_type
))
2581 } else if (os_strcmp(buf
, "config_methods") == 0) {
2582 os_free(bss
->config_methods
);
2583 bss
->config_methods
= os_strdup(pos
);
2584 } else if (os_strcmp(buf
, "os_version") == 0) {
2585 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
2586 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2587 "os_version", line
);
2590 } else if (os_strcmp(buf
, "ap_pin") == 0) {
2591 os_free(bss
->ap_pin
);
2592 bss
->ap_pin
= os_strdup(pos
);
2593 } else if (os_strcmp(buf
, "skip_cred_build") == 0) {
2594 bss
->skip_cred_build
= atoi(pos
);
2595 } else if (os_strcmp(buf
, "extra_cred") == 0) {
2596 os_free(bss
->extra_cred
);
2598 (u8
*) os_readfile(pos
, &bss
->extra_cred_len
);
2599 if (bss
->extra_cred
== NULL
) {
2600 wpa_printf(MSG_ERROR
, "Line %d: could not "
2601 "read Credentials from '%s'",
2605 } else if (os_strcmp(buf
, "wps_cred_processing") == 0) {
2606 bss
->wps_cred_processing
= atoi(pos
);
2607 } else if (os_strcmp(buf
, "ap_settings") == 0) {
2608 os_free(bss
->ap_settings
);
2610 (u8
*) os_readfile(pos
, &bss
->ap_settings_len
);
2611 if (bss
->ap_settings
== NULL
) {
2612 wpa_printf(MSG_ERROR
, "Line %d: could not "
2613 "read AP Settings from '%s'",
2617 } else if (os_strcmp(buf
, "upnp_iface") == 0) {
2618 bss
->upnp_iface
= os_strdup(pos
);
2619 } else if (os_strcmp(buf
, "friendly_name") == 0) {
2620 os_free(bss
->friendly_name
);
2621 bss
->friendly_name
= os_strdup(pos
);
2622 } else if (os_strcmp(buf
, "manufacturer_url") == 0) {
2623 os_free(bss
->manufacturer_url
);
2624 bss
->manufacturer_url
= os_strdup(pos
);
2625 } else if (os_strcmp(buf
, "model_description") == 0) {
2626 os_free(bss
->model_description
);
2627 bss
->model_description
= os_strdup(pos
);
2628 } else if (os_strcmp(buf
, "model_url") == 0) {
2629 os_free(bss
->model_url
);
2630 bss
->model_url
= os_strdup(pos
);
2631 } else if (os_strcmp(buf
, "upc") == 0) {
2633 bss
->upc
= os_strdup(pos
);
2634 } else if (os_strcmp(buf
, "pbc_in_m1") == 0) {
2635 bss
->pbc_in_m1
= atoi(pos
);
2636 } else if (os_strcmp(buf
, "server_id") == 0) {
2637 os_free(bss
->server_id
);
2638 bss
->server_id
= os_strdup(pos
);
2639 #ifdef CONFIG_WPS_NFC
2640 } else if (os_strcmp(buf
, "wps_nfc_dev_pw_id") == 0) {
2641 bss
->wps_nfc_dev_pw_id
= atoi(pos
);
2642 if (bss
->wps_nfc_dev_pw_id
< 0x10 ||
2643 bss
->wps_nfc_dev_pw_id
> 0xffff) {
2644 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2645 "wps_nfc_dev_pw_id value", line
);
2648 bss
->wps_nfc_pw_from_config
= 1;
2649 } else if (os_strcmp(buf
, "wps_nfc_dh_pubkey") == 0) {
2650 wpabuf_free(bss
->wps_nfc_dh_pubkey
);
2651 bss
->wps_nfc_dh_pubkey
= hostapd_parse_bin(pos
);
2652 bss
->wps_nfc_pw_from_config
= 1;
2653 } else if (os_strcmp(buf
, "wps_nfc_dh_privkey") == 0) {
2654 wpabuf_free(bss
->wps_nfc_dh_privkey
);
2655 bss
->wps_nfc_dh_privkey
= hostapd_parse_bin(pos
);
2656 bss
->wps_nfc_pw_from_config
= 1;
2657 } else if (os_strcmp(buf
, "wps_nfc_dev_pw") == 0) {
2658 wpabuf_free(bss
->wps_nfc_dev_pw
);
2659 bss
->wps_nfc_dev_pw
= hostapd_parse_bin(pos
);
2660 bss
->wps_nfc_pw_from_config
= 1;
2661 #endif /* CONFIG_WPS_NFC */
2662 #endif /* CONFIG_WPS */
2663 #ifdef CONFIG_P2P_MANAGER
2664 } else if (os_strcmp(buf
, "manage_p2p") == 0) {
2665 int manage
= atoi(pos
);
2667 bss
->p2p
|= P2P_MANAGE
;
2669 bss
->p2p
&= ~P2P_MANAGE
;
2670 } else if (os_strcmp(buf
, "allow_cross_connection") == 0) {
2672 bss
->p2p
|= P2P_ALLOW_CROSS_CONNECTION
;
2674 bss
->p2p
&= ~P2P_ALLOW_CROSS_CONNECTION
;
2675 #endif /* CONFIG_P2P_MANAGER */
2676 } else if (os_strcmp(buf
, "disassoc_low_ack") == 0) {
2677 bss
->disassoc_low_ack
= atoi(pos
);
2678 } else if (os_strcmp(buf
, "tdls_prohibit") == 0) {
2679 int val
= atoi(pos
);
2681 bss
->tdls
|= TDLS_PROHIBIT
;
2683 bss
->tdls
&= ~TDLS_PROHIBIT
;
2684 } else if (os_strcmp(buf
, "tdls_prohibit_chan_switch") == 0) {
2685 int val
= atoi(pos
);
2687 bss
->tdls
|= TDLS_PROHIBIT_CHAN_SWITCH
;
2689 bss
->tdls
&= ~TDLS_PROHIBIT_CHAN_SWITCH
;
2690 #ifdef CONFIG_RSN_TESTING
2691 } else if (os_strcmp(buf
, "rsn_testing") == 0) {
2692 extern int rsn_testing
;
2693 rsn_testing
= atoi(pos
);
2694 #endif /* CONFIG_RSN_TESTING */
2695 } else if (os_strcmp(buf
, "time_advertisement") == 0) {
2696 bss
->time_advertisement
= atoi(pos
);
2697 } else if (os_strcmp(buf
, "time_zone") == 0) {
2698 size_t tz_len
= os_strlen(pos
);
2699 if (tz_len
< 4 || tz_len
> 255) {
2700 wpa_printf(MSG_DEBUG
, "Line %d: invalid "
2705 os_free(bss
->time_zone
);
2706 bss
->time_zone
= os_strdup(pos
);
2707 if (bss
->time_zone
== NULL
)
2710 } else if (os_strcmp(buf
, "wnm_sleep_mode") == 0) {
2711 bss
->wnm_sleep_mode
= atoi(pos
);
2712 } else if (os_strcmp(buf
, "bss_transition") == 0) {
2713 bss
->bss_transition
= atoi(pos
);
2714 #endif /* CONFIG_WNM */
2715 #ifdef CONFIG_INTERWORKING
2716 } else if (os_strcmp(buf
, "interworking") == 0) {
2717 bss
->interworking
= atoi(pos
);
2718 } else if (os_strcmp(buf
, "access_network_type") == 0) {
2719 bss
->access_network_type
= atoi(pos
);
2720 if (bss
->access_network_type
< 0 ||
2721 bss
->access_network_type
> 15) {
2722 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2723 "access_network_type", line
);
2726 } else if (os_strcmp(buf
, "internet") == 0) {
2727 bss
->internet
= atoi(pos
);
2728 } else if (os_strcmp(buf
, "asra") == 0) {
2729 bss
->asra
= atoi(pos
);
2730 } else if (os_strcmp(buf
, "esr") == 0) {
2731 bss
->esr
= atoi(pos
);
2732 } else if (os_strcmp(buf
, "uesa") == 0) {
2733 bss
->uesa
= atoi(pos
);
2734 } else if (os_strcmp(buf
, "venue_group") == 0) {
2735 bss
->venue_group
= atoi(pos
);
2736 bss
->venue_info_set
= 1;
2737 } else if (os_strcmp(buf
, "venue_type") == 0) {
2738 bss
->venue_type
= atoi(pos
);
2739 bss
->venue_info_set
= 1;
2740 } else if (os_strcmp(buf
, "hessid") == 0) {
2741 if (hwaddr_aton(pos
, bss
->hessid
)) {
2742 wpa_printf(MSG_ERROR
, "Line %d: invalid "
2746 } else if (os_strcmp(buf
, "roaming_consortium") == 0) {
2747 if (parse_roaming_consortium(bss
, pos
, line
) < 0)
2749 } else if (os_strcmp(buf
, "venue_name") == 0) {
2750 if (parse_venue_name(bss
, pos
, line
) < 0)
2752 } else if (os_strcmp(buf
, "network_auth_type") == 0) {
2754 u16 redirect_url_len
;
2755 if (hexstr2bin(pos
, &auth_type
, 1)) {
2756 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2757 "network_auth_type '%s'",
2762 if (auth_type
== 0 || auth_type
== 2)
2763 redirect_url_len
= os_strlen(pos
+ 2);
2765 redirect_url_len
= 0;
2766 os_free(bss
->network_auth_type
);
2767 bss
->network_auth_type
=
2768 os_malloc(redirect_url_len
+ 3 + 1);
2769 if (bss
->network_auth_type
== NULL
) {
2773 *bss
->network_auth_type
= auth_type
;
2774 WPA_PUT_LE16(bss
->network_auth_type
+ 1,
2776 if (redirect_url_len
)
2777 os_memcpy(bss
->network_auth_type
+ 3,
2778 pos
+ 2, redirect_url_len
);
2779 bss
->network_auth_type_len
= 3 + redirect_url_len
;
2780 } else if (os_strcmp(buf
, "ipaddr_type_availability") == 0) {
2781 if (hexstr2bin(pos
, &bss
->ipaddr_type_availability
, 1))
2783 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2784 "ipaddr_type_availability '%s'",
2786 bss
->ipaddr_type_configured
= 0;
2790 bss
->ipaddr_type_configured
= 1;
2791 } else if (os_strcmp(buf
, "domain_name") == 0) {
2792 int j
, num_domains
, domain_len
, domain_list_len
= 0;
2793 char *tok_start
, *tok_prev
;
2794 u8
*domain_list
, *domain_ptr
;
2796 domain_list_len
= os_strlen(pos
) + 1;
2797 domain_list
= os_malloc(domain_list_len
);
2798 if (domain_list
== NULL
) {
2803 domain_ptr
= domain_list
;
2806 while ((tok_prev
= os_strchr(tok_prev
, ','))) {
2811 for (j
= 0; j
< num_domains
; j
++) {
2812 tok_start
= os_strchr(tok_prev
, ',');
2814 domain_len
= tok_start
- tok_prev
;
2815 *domain_ptr
= domain_len
;
2816 os_memcpy(domain_ptr
+ 1, tok_prev
,
2818 domain_ptr
+= domain_len
+ 1;
2819 tok_prev
= ++tok_start
;
2821 domain_len
= os_strlen(tok_prev
);
2822 *domain_ptr
= domain_len
;
2823 os_memcpy(domain_ptr
+ 1, tok_prev
,
2825 domain_ptr
+= domain_len
+ 1;
2829 os_free(bss
->domain_name
);
2830 bss
->domain_name
= domain_list
;
2831 bss
->domain_name_len
= domain_list_len
;
2832 } else if (os_strcmp(buf
, "anqp_3gpp_cell_net") == 0) {
2833 if (parse_3gpp_cell_net(bss
, pos
, line
) < 0)
2835 } else if (os_strcmp(buf
, "nai_realm") == 0) {
2836 if (parse_nai_realm(bss
, pos
, line
) < 0)
2838 } else if (os_strcmp(buf
, "gas_frag_limit") == 0) {
2839 bss
->gas_frag_limit
= atoi(pos
);
2840 } else if (os_strcmp(buf
, "gas_comeback_delay") == 0) {
2841 bss
->gas_comeback_delay
= atoi(pos
);
2842 #endif /* CONFIG_INTERWORKING */
2843 #ifdef CONFIG_RADIUS_TEST
2844 } else if (os_strcmp(buf
, "dump_msk_file") == 0) {
2845 os_free(bss
->dump_msk_file
);
2846 bss
->dump_msk_file
= os_strdup(pos
);
2847 #endif /* CONFIG_RADIUS_TEST */
2849 } else if (os_strcmp(buf
, "hs20") == 0) {
2850 bss
->hs20
= atoi(pos
);
2851 } else if (os_strcmp(buf
, "disable_dgaf") == 0) {
2852 bss
->disable_dgaf
= atoi(pos
);
2853 } else if (os_strcmp(buf
, "hs20_oper_friendly_name") == 0) {
2854 if (hs20_parse_oper_friendly_name(bss
, pos
, line
) < 0)
2856 } else if (os_strcmp(buf
, "hs20_wan_metrics") == 0) {
2857 if (hs20_parse_wan_metrics(bss
, pos
, line
) < 0) {
2861 } else if (os_strcmp(buf
, "hs20_conn_capab") == 0) {
2862 if (hs20_parse_conn_capab(bss
, pos
, line
) < 0) {
2866 } else if (os_strcmp(buf
, "hs20_operating_class") == 0) {
2868 size_t oper_class_len
;
2869 oper_class_len
= os_strlen(pos
);
2870 if (oper_class_len
< 2 || (oper_class_len
& 0x01)) {
2871 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2872 "hs20_operating_class '%s'",
2877 oper_class_len
/= 2;
2878 oper_class
= os_malloc(oper_class_len
);
2879 if (oper_class
== NULL
) {
2883 if (hexstr2bin(pos
, oper_class
, oper_class_len
)) {
2884 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2885 "hs20_operating_class '%s'",
2887 os_free(oper_class
);
2891 os_free(bss
->hs20_operating_class
);
2892 bss
->hs20_operating_class
= oper_class
;
2893 bss
->hs20_operating_class_len
= oper_class_len
;
2894 #endif /* CONFIG_HS20 */
2895 #ifdef CONFIG_TESTING_OPTIONS
2896 #define PARSE_TEST_PROBABILITY(_val) \
2897 } else if (os_strcmp(buf, #_val) == 0) { \
2900 conf->_val = strtod(pos, &end); \
2901 if (*end || conf->_val < 0.0d || \
2902 conf->_val > 1.0d) { \
2903 wpa_printf(MSG_ERROR, \
2904 "Line %d: Invalid value '%s'", \
2909 PARSE_TEST_PROBABILITY(ignore_probe_probability
)
2910 PARSE_TEST_PROBABILITY(ignore_auth_probability
)
2911 PARSE_TEST_PROBABILITY(ignore_assoc_probability
)
2912 PARSE_TEST_PROBABILITY(ignore_reassoc_probability
)
2913 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability
)
2914 #endif /* CONFIG_TESTING_OPTIONS */
2915 } else if (os_strcmp(buf
, "vendor_elements") == 0) {
2916 struct wpabuf
*elems
;
2917 size_t len
= os_strlen(pos
);
2919 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2920 "vendor_elements '%s'", line
, pos
);
2925 wpabuf_free(bss
->vendor_elements
);
2926 bss
->vendor_elements
= NULL
;
2930 elems
= wpabuf_alloc(len
);
2934 if (hexstr2bin(pos
, wpabuf_put(elems
, len
), len
)) {
2936 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2937 "vendor_elements '%s'", line
, pos
);
2941 wpabuf_free(bss
->vendor_elements
);
2942 bss
->vendor_elements
= elems
;
2943 } else if (os_strcmp(buf
, "sae_anti_clogging_threshold") == 0) {
2944 bss
->sae_anti_clogging_threshold
= atoi(pos
);
2945 } else if (os_strcmp(buf
, "sae_groups") == 0) {
2946 if (hostapd_parse_intlist(&bss
->sae_groups
, pos
)) {
2947 wpa_printf(MSG_ERROR
, "Line %d: Invalid "
2948 "sae_groups value '%s'", line
, pos
);
2952 wpa_printf(MSG_ERROR
, "Line %d: unknown configuration "
2953 "item '%s'", line
, buf
);
2962 static void hostapd_set_security_params(struct hostapd_bss_config
*bss
)
2964 if (bss
->individual_wep_key_len
== 0) {
2965 /* individual keys are not use; can use key idx0 for
2967 bss
->broadcast_key_idx_min
= 0;
2970 if ((bss
->wpa
& 2) && bss
->rsn_pairwise
== 0)
2971 bss
->rsn_pairwise
= bss
->wpa_pairwise
;
2972 bss
->wpa_group
= wpa_select_ap_group_cipher(bss
->wpa
, bss
->wpa_pairwise
,
2975 bss
->radius
->auth_server
= bss
->radius
->auth_servers
;
2976 bss
->radius
->acct_server
= bss
->radius
->acct_servers
;
2978 if (bss
->wpa
&& bss
->ieee802_1x
) {
2979 bss
->ssid
.security_policy
= SECURITY_WPA
;
2980 } else if (bss
->wpa
) {
2981 bss
->ssid
.security_policy
= SECURITY_WPA_PSK
;
2982 } else if (bss
->ieee802_1x
) {
2983 int cipher
= WPA_CIPHER_NONE
;
2984 bss
->ssid
.security_policy
= SECURITY_IEEE_802_1X
;
2985 bss
->ssid
.wep
.default_len
= bss
->default_wep_key_len
;
2986 if (bss
->default_wep_key_len
)
2987 cipher
= bss
->default_wep_key_len
>= 13 ?
2988 WPA_CIPHER_WEP104
: WPA_CIPHER_WEP40
;
2989 bss
->wpa_group
= cipher
;
2990 bss
->wpa_pairwise
= cipher
;
2991 bss
->rsn_pairwise
= cipher
;
2992 } else if (bss
->ssid
.wep
.keys_set
) {
2993 int cipher
= WPA_CIPHER_WEP40
;
2994 if (bss
->ssid
.wep
.len
[0] >= 13)
2995 cipher
= WPA_CIPHER_WEP104
;
2996 bss
->ssid
.security_policy
= SECURITY_STATIC_WEP
;
2997 bss
->wpa_group
= cipher
;
2998 bss
->wpa_pairwise
= cipher
;
2999 bss
->rsn_pairwise
= cipher
;
3001 bss
->ssid
.security_policy
= SECURITY_PLAINTEXT
;
3002 bss
->wpa_group
= WPA_CIPHER_NONE
;
3003 bss
->wpa_pairwise
= WPA_CIPHER_NONE
;
3004 bss
->rsn_pairwise
= WPA_CIPHER_NONE
;
3010 * hostapd_config_read - Read and parse a configuration file
3011 * @fname: Configuration file name (including path, if needed)
3012 * Returns: Allocated configuration data structure
3014 struct hostapd_config
* hostapd_config_read(const char *fname
)
3016 struct hostapd_config
*conf
;
3017 struct hostapd_bss_config
*bss
;
3019 char buf
[512], *pos
;
3024 f
= fopen(fname
, "r");
3026 wpa_printf(MSG_ERROR
, "Could not open configuration file '%s' "
3027 "for reading.", fname
);
3031 conf
= hostapd_config_defaults();
3037 /* set default driver based on configuration */
3038 conf
->driver
= wpa_drivers
[0];
3039 if (conf
->driver
== NULL
) {
3040 wpa_printf(MSG_ERROR
, "No driver wrappers registered!");
3041 hostapd_config_free(conf
);
3046 bss
= conf
->last_bss
= conf
->bss
;
3048 while (fgets(buf
, sizeof(buf
), f
)) {
3049 bss
= conf
->last_bss
;
3055 while (*pos
!= '\0') {
3065 pos
= os_strchr(buf
, '=');
3067 wpa_printf(MSG_ERROR
, "Line %d: invalid line '%s'",
3074 errors
+= hostapd_config_fill(conf
, bss
, buf
, pos
, line
);
3079 for (i
= 0; i
< conf
->num_bss
; i
++)
3080 hostapd_set_security_params(&conf
->bss
[i
]);
3082 if (hostapd_config_check(conf
))
3085 #ifndef WPA_IGNORE_CONFIG_ERRORS
3087 wpa_printf(MSG_ERROR
, "%d errors found in configuration file "
3088 "'%s'", errors
, fname
);
3089 hostapd_config_free(conf
);
3092 #endif /* WPA_IGNORE_CONFIG_ERRORS */
3098 int hostapd_set_iface(struct hostapd_config
*conf
,
3099 struct hostapd_bss_config
*bss
, char *field
, char *value
)
3104 errors
= hostapd_config_fill(conf
, bss
, field
, value
, 0);
3106 wpa_printf(MSG_INFO
, "Failed to set configuration field '%s' "
3107 "to value '%s'", field
, value
);
3111 for (i
= 0; i
< conf
->num_bss
; i
++)
3112 hostapd_set_security_params(&conf
->bss
[i
]);
3114 if (hostapd_config_check(conf
)) {
3115 wpa_printf(MSG_ERROR
, "Configuration check failed");