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 #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)) {
137 while (*pos != '\0') {
147 if (hwaddr_aton(buf, addr)) {
148 wpa_printf(MSG_ERROR, "Invalid MAC address '%s' at "
149 "line %d in '%s'", buf, line, fname);
156 while (*pos != '\0' && *pos != ' ' && *pos != '\t')
158 while (*pos == ' ' || *pos == '\t')
163 newacl = os_realloc_array(*acl, *num + 1, sizeof(**acl));
164 if (newacl == NULL) {
165 wpa_printf(MSG_ERROR, "MAC list reallocation failed");
171 os_memcpy((*acl)[*num].addr, addr, ETH_ALEN);
172 (*acl)[*num].vlan_id = vlan_id;
178 qsort(*acl, *num, sizeof(**acl), hostapd_acl_comp);
185 static int hostapd_config_read_eap_user(const char *fname,
186 struct hostapd_bss_config *conf)
189 char buf[512], *pos, *start, *pos2;
190 int line = 0, ret = 0, num_methods;
191 struct hostapd_eap_user *user, *tail = NULL;
196 if (os_strncmp(fname, "sqlite:", 7) == 0) {
197 os_free(conf->eap_user_sqlite);
198 conf->eap_user_sqlite = os_strdup(fname + 7);
202 f = fopen(fname, "r");
204 wpa_printf(MSG_ERROR, "EAP user file '%s' not found.", fname);
208 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
209 while (fgets(buf, sizeof(buf), f)) {
215 while (*pos != '\0') {
227 if (buf[0] != '"' && buf[0] != '*') {
228 wpa_printf(MSG_ERROR, "Invalid EAP identity (no \" in "
229 "start) on line %d in '%s'", line, fname);
233 user = os_zalloc(sizeof(*user));
235 wpa_printf(MSG_ERROR, "EAP user allocation failed");
238 user->force_version = -1;
245 while (*pos != '"' && *pos != '\0')
248 wpa_printf(MSG_ERROR, "Invalid EAP identity "
249 "(no \" in end) on line %d in '%s'",
254 user->identity = os_malloc(pos - start);
255 if (user->identity == NULL) {
256 wpa_printf(MSG_ERROR, "Failed to allocate "
257 "memory for EAP identity");
260 os_memcpy(user->identity, start, pos - start);
261 user->identity_len = pos - start;
263 if (pos[0] == '"' && pos[1] == '*') {
264 user->wildcard_prefix = 1;
269 while (*pos == ' ' || *pos == '\t')
273 wpa_printf(MSG_ERROR, "No EAP method on line %d in "
274 "'%s'", line, fname);
279 while (*pos != ' ' && *pos != '\t' && *pos != '\0')
289 char *pos3 = os_strchr(start, ',');
293 user->methods[num_methods].method =
296 &user->methods[num_methods].vendor);
297 if (user->methods[num_methods].vendor ==
299 user->methods[num_methods].method == EAP_TYPE_NONE)
301 if (os_strcmp(start, "TTLS-PAP") == 0) {
302 user->ttls_auth |= EAP_TTLS_AUTH_PAP;
305 if (os_strcmp(start, "TTLS-CHAP") == 0) {
306 user->ttls_auth |= EAP_TTLS_AUTH_CHAP;
309 if (os_strcmp(start, "TTLS-MSCHAP") == 0) {
311 EAP_TTLS_AUTH_MSCHAP;
314 if (os_strcmp(start, "TTLS-MSCHAPV2") == 0) {
316 EAP_TTLS_AUTH_MSCHAPV2;
319 wpa_printf(MSG_ERROR, "Unsupported EAP type "
320 "'%s' on line %d in '%s'",
326 if (num_methods >= EAP_MAX_METHODS)
333 if (num_methods == 0 && user->ttls_auth == 0) {
334 wpa_printf(MSG_ERROR, "No EAP types configured on "
335 "line %d in '%s'", line, fname);
342 while (*pos == ' ' || *pos == '\t')
347 if (os_strncmp(pos, "[ver=0]", 7) == 0) {
348 user->force_version = 0;
352 if (os_strncmp(pos, "[ver=1]", 7) == 0) {
353 user->force_version = 1;
357 if (os_strncmp(pos, "[2]", 3) == 0) {
365 while (*pos != '"' && *pos != '\0')
368 wpa_printf(MSG_ERROR, "Invalid EAP password "
369 "(no \" in end) on line %d in '%s'",
374 user->password = os_malloc(pos - start);
375 if (user->password == NULL) {
376 wpa_printf(MSG_ERROR, "Failed to allocate "
377 "memory for EAP password");
380 os_memcpy(user->password, start, pos - start);
381 user->password_len = pos - start;
384 } else if (os_strncmp(pos, "hash:", 5) == 0) {
387 while (*pos2 != '\0' && *pos2 != ' ' &&
388 *pos2 != '\t' && *pos2 != '#')
390 if (pos2 - pos != 32) {
391 wpa_printf(MSG_ERROR, "Invalid password hash "
392 "on line %d in '%s'", line, fname);
395 user->password = os_malloc(16);
396 if (user->password == NULL) {
397 wpa_printf(MSG_ERROR, "Failed to allocate "
398 "memory for EAP password hash");
401 if (hexstr2bin(pos, user->password, 16) < 0) {
402 wpa_printf(MSG_ERROR, "Invalid hash password "
403 "on line %d in '%s'", line, fname);
406 user->password_len = 16;
407 user->password_hash = 1;
411 while (*pos2 != '\0' && *pos2 != ' ' &&
412 *pos2 != '\t' && *pos2 != '#')
414 if ((pos2 - pos) & 1) {
415 wpa_printf(MSG_ERROR, "Invalid hex password "
416 "on line %d in '%s'", line, fname);
419 user->password = os_malloc((pos2 - pos) / 2);
420 if (user->password == NULL) {
421 wpa_printf(MSG_ERROR, "Failed to allocate "
422 "memory for EAP password");
425 if (hexstr2bin(pos, user->password,
426 (pos2 - pos) / 2) < 0) {
427 wpa_printf(MSG_ERROR, "Invalid hex password "
428 "on line %d in '%s'", line, fname);
431 user->password_len = (pos2 - pos) / 2;
435 while (*pos == ' ' || *pos == '\t')
437 if (os_strncmp(pos, "[2]", 3) == 0) {
443 tail = conf->eap_user = user;
452 os_free(user->password);
453 os_free(user->identity);
464 #endif /* EAP_SERVER */
467 #ifndef CONFIG_NO_RADIUS
469 hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
470 int *num_server, const char *val, int def_port,
471 struct hostapd_radius_server **curr_serv)
473 struct hostapd_radius_server *nserv;
475 static int server_index = 1;
477 nserv = os_realloc_array(*server, *num_server + 1, sizeof(*nserv));
482 nserv = &nserv[*num_server];
484 (*curr_serv) = nserv;
486 os_memset(nserv, 0, sizeof(*nserv));
487 nserv->port = def_port;
488 ret = hostapd_parse_ip_addr(val, &nserv->addr);
489 nserv->index = server_index++;
495 static struct hostapd_radius_attr *
496 hostapd_parse_radius_attr(const char *value)
500 struct hostapd_radius_attr *attr;
503 attr = os_zalloc(sizeof(*attr));
507 attr->type = atoi(value);
509 pos = os_strchr(value, ':');
511 attr->val = wpabuf_alloc(1);
512 if (attr->val == NULL) {
516 wpabuf_put_u8(attr->val, 0);
521 if (pos[0] == '\0' || pos[1] != ':') {
530 attr->val = wpabuf_alloc_copy(pos, os_strlen(pos));
533 len = os_strlen(pos);
537 attr->val = wpabuf_alloc(len);
538 if (attr->val == NULL)
540 if (hexstr2bin(pos, wpabuf_put(attr->val, len), len) < 0) {
541 wpabuf_free(attr->val);
547 attr->val = wpabuf_alloc(4);
549 wpabuf_put_be32(attr->val, atoi(pos));
556 if (attr->val == NULL) {
565 static int hostapd_parse_das_client(struct hostapd_bss_config *bss,
570 secret = os_strchr(val, ' ');
576 if (hostapd_parse_ip_addr(val, &bss->radius_das_client_addr))
579 os_free(bss->radius_das_shared_secret);
580 bss->radius_das_shared_secret = (u8 *) os_strdup(secret);
581 if (bss->radius_das_shared_secret == NULL)
583 bss->radius_das_shared_secret_len = os_strlen(secret);
587 #endif /* CONFIG_NO_RADIUS */
590 static int hostapd_config_parse_key_mgmt(int line, const char *value)
593 char *start, *end, *buf;
595 buf = os_strdup(value);
600 while (*start != '\0') {
601 while (*start == ' ' || *start == '\t')
606 while (*end != ' ' && *end != '\t' && *end != '\0')
610 if (os_strcmp(start, "WPA-PSK") == 0)
611 val |= WPA_KEY_MGMT_PSK;
612 else if (os_strcmp(start, "WPA-EAP") == 0)
613 val |= WPA_KEY_MGMT_IEEE8021X;
614 #ifdef CONFIG_IEEE80211R
615 else if (os_strcmp(start, "FT-PSK") == 0)
616 val |= WPA_KEY_MGMT_FT_PSK;
617 else if (os_strcmp(start, "FT-EAP") == 0)
618 val |= WPA_KEY_MGMT_FT_IEEE8021X;
619 #endif /* CONFIG_IEEE80211R */
620 #ifdef CONFIG_IEEE80211W
621 else if (os_strcmp(start, "WPA-PSK-SHA256") == 0)
622 val |= WPA_KEY_MGMT_PSK_SHA256;
623 else if (os_strcmp(start, "WPA-EAP-SHA256") == 0)
624 val |= WPA_KEY_MGMT_IEEE8021X_SHA256;
625 #endif /* CONFIG_IEEE80211W */
627 else if (os_strcmp(start, "SAE") == 0)
628 val |= WPA_KEY_MGMT_SAE;
629 else if (os_strcmp(start, "FT-SAE") == 0)
630 val |= WPA_KEY_MGMT_FT_SAE;
631 #endif /* CONFIG_SAE */
633 wpa_printf(MSG_ERROR, "Line %d: invalid key_mgmt '%s'",
646 wpa_printf(MSG_ERROR, "Line %d: no key_mgmt values "
647 "configured.", line);
655 static int hostapd_config_parse_cipher(int line, const char *value)
657 int val = wpa_parse_cipher(value);
659 wpa_printf(MSG_ERROR, "Line %d: invalid cipher '%s'.",
664 wpa_printf(MSG_ERROR, "Line %d: no cipher values configured.",
672 static int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx,
675 size_t len = os_strlen(val);
677 if (keyidx < 0 || keyidx > 3 || wep->key[keyidx] != NULL)
681 if (len < 2 || val[len - 1] != '"')
684 wep->key[keyidx] = os_malloc(len);
685 if (wep->key[keyidx] == NULL)
687 os_memcpy(wep->key[keyidx], val + 1, len);
688 wep->len[keyidx] = len;
693 wep->key[keyidx] = os_malloc(len);
694 if (wep->key[keyidx] == NULL)
696 wep->len[keyidx] = len;
697 if (hexstr2bin(val, wep->key[keyidx], len) < 0)
707 static int hostapd_parse_intlist(int **int_list, char *val)
718 while (*pos != '\0') {
724 list = os_malloc(sizeof(int) * (count + 2));
729 while (*pos != '\0') {
730 end = os_strchr(pos, ' ');
734 list[count++] = atoi(pos);
746 static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
748 struct hostapd_bss_config **all, *bss;
753 all = os_realloc_array(conf->bss, conf->num_bss + 1,
754 sizeof(struct hostapd_bss_config *));
756 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
762 bss = os_zalloc(sizeof(*bss));
765 bss->radius = os_zalloc(sizeof(*bss->radius));
766 if (bss->radius == NULL) {
767 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
768 "multi-BSS RADIUS data");
773 conf->bss[conf->num_bss++] = bss;
774 conf->last_bss = bss;
776 hostapd_config_defaults_bss(bss);
777 os_strlcpy(bss->iface, ifname, sizeof(bss->iface));
778 os_memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1);
784 /* convert floats with one decimal place to value*10 int, i.e.,
785 * "1.5" will return 15 */
786 static int hostapd_config_read_int10(const char *value)
792 pos = os_strchr(value, '.');
796 if (*pos >= '0' && *pos <= '9')
804 static int valid_cw(int cw)
806 return (cw == 1 || cw == 3 || cw == 7 || cw == 15 || cw == 31 ||
807 cw == 63 || cw == 127 || cw == 255 || cw == 511 || cw == 1023);
812 IEEE80211_TX_QUEUE_DATA0 = 0, /* used for EDCA AC_VO data */
813 IEEE80211_TX_QUEUE_DATA1 = 1, /* used for EDCA AC_VI data */
814 IEEE80211_TX_QUEUE_DATA2 = 2, /* used for EDCA AC_BE data */
815 IEEE80211_TX_QUEUE_DATA3 = 3 /* used for EDCA AC_BK data */
818 static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
823 struct hostapd_tx_queue_params *queue;
825 /* skip 'tx_queue_' prefix */
827 if (os_strncmp(pos, "data", 4) == 0 &&
828 pos[4] >= '0' && pos[4] <= '9' && pos[5] == '_') {
831 } else if (os_strncmp(pos, "after_beacon_", 13) == 0 ||
832 os_strncmp(pos, "beacon_", 7) == 0) {
833 wpa_printf(MSG_INFO, "DEPRECATED: '%s' not used", name);
836 wpa_printf(MSG_ERROR, "Unknown tx_queue name '%s'", pos);
840 if (num >= NUM_TX_QUEUES) {
841 /* for backwards compatibility, do not trigger failure */
842 wpa_printf(MSG_INFO, "DEPRECATED: '%s' not used", name);
846 queue = &conf->tx_queue[num];
848 if (os_strcmp(pos, "aifs") == 0) {
849 queue->aifs = atoi(val);
850 if (queue->aifs < 0 || queue->aifs > 255) {
851 wpa_printf(MSG_ERROR, "Invalid AIFS value %d",
855 } else if (os_strcmp(pos, "cwmin") == 0) {
856 queue->cwmin = atoi(val);
857 if (!valid_cw(queue->cwmin)) {
858 wpa_printf(MSG_ERROR, "Invalid cwMin value %d",
862 } else if (os_strcmp(pos, "cwmax") == 0) {
863 queue->cwmax = atoi(val);
864 if (!valid_cw(queue->cwmax)) {
865 wpa_printf(MSG_ERROR, "Invalid cwMax value %d",
869 } else if (os_strcmp(pos, "burst") == 0) {
870 queue->burst = hostapd_config_read_int10(val);
872 wpa_printf(MSG_ERROR, "Unknown tx_queue field '%s'", pos);
880 #ifdef CONFIG_IEEE80211R
881 static int add_r0kh(struct hostapd_bss_config *bss, char *value)
883 struct ft_remote_r0kh *r0kh;
886 r0kh = os_zalloc(sizeof(*r0kh));
890 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
892 next = os_strchr(pos, ' ');
895 if (next == NULL || hwaddr_aton(pos, r0kh->addr)) {
896 wpa_printf(MSG_ERROR, "Invalid R0KH MAC address: '%s'", pos);
902 next = os_strchr(pos, ' ');
905 if (next == NULL || next - pos > FT_R0KH_ID_MAX_LEN) {
906 wpa_printf(MSG_ERROR, "Invalid R0KH-ID: '%s'", pos);
910 r0kh->id_len = next - pos - 1;
911 os_memcpy(r0kh->id, pos, r0kh->id_len);
914 if (hexstr2bin(pos, r0kh->key, sizeof(r0kh->key))) {
915 wpa_printf(MSG_ERROR, "Invalid R0KH key: '%s'", pos);
920 r0kh->next = bss->r0kh_list;
921 bss->r0kh_list = r0kh;
927 static int add_r1kh(struct hostapd_bss_config *bss, char *value)
929 struct ft_remote_r1kh *r1kh;
932 r1kh = os_zalloc(sizeof(*r1kh));
936 /* 02:01:02:03:04:05 02:01:02:03:04:05
937 * 000102030405060708090a0b0c0d0e0f */
939 next = os_strchr(pos, ' ');
942 if (next == NULL || hwaddr_aton(pos, r1kh->addr)) {
943 wpa_printf(MSG_ERROR, "Invalid R1KH MAC address: '%s'", pos);
949 next = os_strchr(pos, ' ');
952 if (next == NULL || hwaddr_aton(pos, r1kh->id)) {
953 wpa_printf(MSG_ERROR, "Invalid R1KH-ID: '%s'", pos);
959 if (hexstr2bin(pos, r1kh->key, sizeof(r1kh->key))) {
960 wpa_printf(MSG_ERROR, "Invalid R1KH key: '%s'", pos);
965 r1kh->next = bss->r1kh_list;
966 bss->r1kh_list = r1kh;
970 #endif /* CONFIG_IEEE80211R */
973 #ifdef CONFIG_IEEE80211N
974 static int hostapd_config_ht_capab(struct hostapd_config *conf,
977 if (os_strstr(capab, "[LDPC]"))
978 conf->ht_capab |= HT_CAP_INFO_LDPC_CODING_CAP;
979 if (os_strstr(capab, "[HT40-]")) {
980 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
981 conf->secondary_channel = -1;
983 if (os_strstr(capab, "[HT40+]")) {
984 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
985 conf->secondary_channel = 1;
987 if (os_strstr(capab, "[SMPS-STATIC]")) {
988 conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
989 conf->ht_capab |= HT_CAP_INFO_SMPS_STATIC;
991 if (os_strstr(capab, "[SMPS-DYNAMIC]")) {
992 conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
993 conf->ht_capab |= HT_CAP_INFO_SMPS_DYNAMIC;
995 if (os_strstr(capab, "[GF]"))
996 conf->ht_capab |= HT_CAP_INFO_GREEN_FIELD;
997 if (os_strstr(capab, "[SHORT-GI-20]"))
998 conf->ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ;
999 if (os_strstr(capab, "[SHORT-GI-40]"))
1000 conf->ht_capab |= HT_CAP_INFO_SHORT_GI40MHZ;
1001 if (os_strstr(capab, "[TX-STBC]"))
1002 conf->ht_capab |= HT_CAP_INFO_TX_STBC;
1003 if (os_strstr(capab, "[RX-STBC1]")) {
1004 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1005 conf->ht_capab |= HT_CAP_INFO_RX_STBC_1;
1007 if (os_strstr(capab, "[RX-STBC12]")) {
1008 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1009 conf->ht_capab |= HT_CAP_INFO_RX_STBC_12;
1011 if (os_strstr(capab, "[RX-STBC123]")) {
1012 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1013 conf->ht_capab |= HT_CAP_INFO_RX_STBC_123;
1015 if (os_strstr(capab, "[DELAYED-BA]"))
1016 conf->ht_capab |= HT_CAP_INFO_DELAYED_BA;
1017 if (os_strstr(capab, "[MAX-AMSDU-7935]"))
1018 conf->ht_capab |= HT_CAP_INFO_MAX_AMSDU_SIZE;
1019 if (os_strstr(capab, "[DSSS_CCK-40]"))
1020 conf->ht_capab |= HT_CAP_INFO_DSSS_CCK40MHZ;
1021 if (os_strstr(capab, "[PSMP]"))
1022 conf->ht_capab |= HT_CAP_INFO_PSMP_SUPP;
1023 if (os_strstr(capab, "[LSIG-TXOP-PROT]"))
1024 conf->ht_capab |= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT;
1028 #endif /* CONFIG_IEEE80211N */
1031 #ifdef CONFIG_IEEE80211AC
1032 static int hostapd_config_vht_capab(struct hostapd_config *conf,
1035 if (os_strstr(capab, "[MAX-MPDU-7991]"))
1036 conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_7991;
1037 if (os_strstr(capab, "[MAX-MPDU-11454]"))
1038 conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_11454;
1039 if (os_strstr(capab, "[VHT160]"))
1040 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
1041 if (os_strstr(capab, "[VHT160-80PLUS80]"))
1042 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
1043 if (os_strstr(capab, "[VHT160-80PLUS80]"))
1044 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
1045 if (os_strstr(capab, "[RXLDPC]"))
1046 conf->vht_capab |= VHT_CAP_RXLDPC;
1047 if (os_strstr(capab, "[SHORT-GI-80]"))
1048 conf->vht_capab |= VHT_CAP_SHORT_GI_80;
1049 if (os_strstr(capab, "[SHORT-GI-160]"))
1050 conf->vht_capab |= VHT_CAP_SHORT_GI_160;
1051 if (os_strstr(capab, "[TX-STBC-2BY1]"))
1052 conf->vht_capab |= VHT_CAP_TXSTBC;
1053 if (os_strstr(capab, "[RX-STBC-1]"))
1054 conf->vht_capab |= VHT_CAP_RXSTBC_1;
1055 if (os_strstr(capab, "[RX-STBC-12]"))
1056 conf->vht_capab |= VHT_CAP_RXSTBC_2;
1057 if (os_strstr(capab, "[RX-STBC-123]"))
1058 conf->vht_capab |= VHT_CAP_RXSTBC_3;
1059 if (os_strstr(capab, "[RX-STBC-1234]"))
1060 conf->vht_capab |= VHT_CAP_RXSTBC_4;
1061 if (os_strstr(capab, "[SU-BEAMFORMER]"))
1062 conf->vht_capab |= VHT_CAP_SU_BEAMFORMER_CAPABLE;
1063 if (os_strstr(capab, "[SU-BEAMFORMEE]"))
1064 conf->vht_capab |= VHT_CAP_SU_BEAMFORMEE_CAPABLE;
1065 if (os_strstr(capab, "[BF-ANTENNA-2]") &&
1066 (conf->vht_capab & VHT_CAP_SU_BEAMFORMEE_CAPABLE))
1067 conf->vht_capab |= (1 << VHT_CAP_BEAMFORMEE_STS_OFFSET);
1068 if (os_strstr(capab, "[SOUNDING-DIMENSION-2]") &&
1069 (conf->vht_capab & VHT_CAP_SU_BEAMFORMER_CAPABLE))
1070 conf->vht_capab |= (1 << VHT_CAP_SOUNDING_DIMENSION_OFFSET);
1071 if (os_strstr(capab, "[MU-BEAMFORMER]"))
1072 conf->vht_capab |= VHT_CAP_MU_BEAMFORMER_CAPABLE;
1073 if (os_strstr(capab, "[MU-BEAMFORMEE]"))
1074 conf->vht_capab |= VHT_CAP_MU_BEAMFORMEE_CAPABLE;
1075 if (os_strstr(capab, "[VHT-TXOP-PS]"))
1076 conf->vht_capab |= VHT_CAP_VHT_TXOP_PS;
1077 if (os_strstr(capab, "[HTC-VHT]"))
1078 conf->vht_capab |= VHT_CAP_HTC_VHT;
1079 if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP0]"))
1080 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT;
1081 if (os_strstr(capab, "[VHT-LINK-ADAPT2]") &&
1082 (conf->vht_capab & VHT_CAP_HTC_VHT))
1083 conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB;
1084 if (os_strstr(capab, "[VHT-LINK-ADAPT3]") &&
1085 (conf->vht_capab & VHT_CAP_HTC_VHT))
1086 conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB;
1087 if (os_strstr(capab, "[RX-ANTENNA-PATTERN]"))
1088 conf->vht_capab |= VHT_CAP_RX_ANTENNA_PATTERN;
1089 if (os_strstr(capab, "[TX-ANTENNA-PATTERN]"))
1090 conf->vht_capab |= VHT_CAP_TX_ANTENNA_PATTERN;
1093 #endif /* CONFIG_IEEE80211AC */
1096 #ifdef CONFIG_INTERWORKING
1097 static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos,
1100 size_t len = os_strlen(pos);
1101 u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
1103 struct hostapd_roaming_consortium *rc;
1105 if ((len & 1) || len < 2 * 3 || len / 2 > MAX_ROAMING_CONSORTIUM_LEN ||
1106 hexstr2bin(pos, oi, len / 2)) {
1107 wpa_printf(MSG_ERROR, "Line %d: invalid roaming_consortium "
1113 rc = os_realloc_array(bss->roaming_consortium,
1114 bss->roaming_consortium_count + 1,
1115 sizeof(struct hostapd_roaming_consortium));
1119 os_memcpy(rc[bss->roaming_consortium_count].oi, oi, len);
1120 rc[bss->roaming_consortium_count].len = len;
1122 bss->roaming_consortium = rc;
1123 bss->roaming_consortium_count++;
1129 static int parse_lang_string(struct hostapd_lang_string **array,
1130 unsigned int *count, char *pos)
1132 char *sep, *str = NULL;
1133 size_t clen, nlen, slen;
1134 struct hostapd_lang_string *ls;
1137 if (*pos == '"' || (*pos == 'P' && pos[1] == '"')) {
1138 str = wpa_config_parse_string(pos, &slen);
1144 sep = os_strchr(pos, ':');
1149 clen = os_strlen(pos);
1150 if (clen < 2 || clen > sizeof(ls->lang))
1152 nlen = os_strlen(sep);
1156 ls = os_realloc_array(*array, *count + 1,
1157 sizeof(struct hostapd_lang_string));
1162 ls = &(*array)[*count];
1165 os_memset(ls->lang, 0, sizeof(ls->lang));
1166 os_memcpy(ls->lang, pos, clen);
1167 ls->name_len = nlen;
1168 os_memcpy(ls->name, sep, nlen);
1177 static int parse_venue_name(struct hostapd_bss_config *bss, char *pos,
1180 if (parse_lang_string(&bss->venue_name, &bss->venue_name_count, pos)) {
1181 wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'",
1189 static int parse_3gpp_cell_net(struct hostapd_bss_config *bss, char *buf,
1194 u8 *info = NULL, *ipos;
1196 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1199 for (pos = buf; *pos; pos++) {
1200 if ((*pos < '0' && *pos > '9') && *pos != ';' && *pos != ',')
1205 if (1 + count * 3 > 0x7f)
1208 info = os_zalloc(2 + 3 + count * 3);
1213 *ipos++ = 0; /* GUD - Version 1 */
1214 *ipos++ = 3 + count * 3; /* User Data Header Length (UDHL) */
1215 *ipos++ = 0; /* PLMN List IEI */
1216 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1217 *ipos++ = 1 + count * 3;
1218 *ipos++ = count; /* Number of PLMNs */
1221 while (pos && *pos) {
1226 mnc = os_strchr(pos, ',');
1230 pos = os_strchr(mnc, ';');
1234 mnc_len = os_strlen(mnc);
1235 if (os_strlen(mcc) != 3 || (mnc_len != 2 && mnc_len != 3))
1238 /* BC coded MCC,MNC */
1239 /* MCC digit 2 | MCC digit 1 */
1240 *ipos++ = ((mcc[1] - '0') << 4) | (mcc[0] - '0');
1241 /* MNC digit 3 | MCC digit 3 */
1242 *ipos++ = (((mnc_len == 2) ? 0xf0 : ((mnc[2] - '0') << 4))) |
1244 /* MNC digit 2 | MNC digit 1 */
1245 *ipos++ = ((mnc[1] - '0') << 4) | (mnc[0] - '0');
1248 os_free(bss->anqp_3gpp_cell_net);
1249 bss->anqp_3gpp_cell_net = info;
1250 bss->anqp_3gpp_cell_net_len = 2 + 3 + 3 * count;
1251 wpa_hexdump(MSG_MSGDUMP, "3GPP Cellular Network information",
1252 bss->anqp_3gpp_cell_net, bss->anqp_3gpp_cell_net_len);
1257 wpa_printf(MSG_ERROR, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1264 static int parse_nai_realm(struct hostapd_bss_config *bss, char *buf, int line)
1266 struct hostapd_nai_realm_data *realm;
1269 char *pos, *end, *rpos;
1271 offsets = os_calloc(bss->nai_realm_count * MAX_NAI_REALMS,
1273 if (offsets == NULL)
1276 for (i = 0; i < bss->nai_realm_count; i++) {
1277 realm = &bss->nai_realm_data[i];
1278 for (j = 0; j < MAX_NAI_REALMS; j++) {
1279 offsets[i * MAX_NAI_REALMS + j] =
1281 realm->realm[j] - realm->realm_buf : -1;
1285 realm = os_realloc_array(bss->nai_realm_data, bss->nai_realm_count + 1,
1286 sizeof(struct hostapd_nai_realm_data));
1287 if (realm == NULL) {
1291 bss->nai_realm_data = realm;
1293 /* patch the pointers after realloc */
1294 for (i = 0; i < bss->nai_realm_count; i++) {
1295 realm = &bss->nai_realm_data[i];
1296 for (j = 0; j < MAX_NAI_REALMS; j++) {
1297 int offs = offsets[i * MAX_NAI_REALMS + j];
1299 realm->realm[j] = realm->realm_buf + offs;
1301 realm->realm[j] = NULL;
1306 realm = &bss->nai_realm_data[bss->nai_realm_count];
1307 os_memset(realm, 0, sizeof(*realm));
1310 realm->encoding = atoi(pos);
1311 pos = os_strchr(pos, ',');
1316 end = os_strchr(pos, ',');
1321 len = os_strlen(pos);
1324 if (len > MAX_NAI_REALMLEN) {
1325 wpa_printf(MSG_ERROR, "Too long a realm string (%d > max %d "
1326 "characters)", (int) len, MAX_NAI_REALMLEN);
1329 os_memcpy(realm->realm_buf, pos, len);
1336 while (pos && *pos) {
1337 struct hostapd_nai_realm_eap *eap;
1339 if (realm->eap_method_count >= MAX_NAI_EAP_METHODS) {
1340 wpa_printf(MSG_ERROR, "Too many EAP methods");
1344 eap = &realm->eap_method[realm->eap_method_count];
1345 realm->eap_method_count++;
1347 end = os_strchr(pos, ',');
1349 end = pos + os_strlen(pos);
1351 eap->eap_method = atoi(pos);
1353 pos = os_strchr(pos, '[');
1354 if (pos == NULL || pos > end)
1357 if (eap->num_auths >= MAX_NAI_AUTH_TYPES) {
1358 wpa_printf(MSG_ERROR, "Too many auth params");
1361 eap->auth_id[eap->num_auths] = atoi(pos);
1362 pos = os_strchr(pos, ':');
1363 if (pos == NULL || pos > end)
1366 eap->auth_val[eap->num_auths] = atoi(pos);
1367 pos = os_strchr(pos, ']');
1368 if (pos == NULL || pos > end)
1380 /* Split realm list into null terminated realms */
1381 rpos = realm->realm_buf;
1384 if (i >= MAX_NAI_REALMS) {
1385 wpa_printf(MSG_ERROR, "Too many realms");
1388 realm->realm[i++] = rpos;
1389 rpos = os_strchr(rpos, ';');
1395 bss->nai_realm_count++;
1400 wpa_printf(MSG_ERROR, "Line %d: invalid nai_realm '%s'", line, buf);
1405 static int parse_qos_map_set(struct hostapd_bss_config *bss,
1406 char *buf, int line)
1408 u8 qos_map_set[16 + 2 * 21], count = 0;
1413 if (count == sizeof(qos_map_set)) {
1414 wpa_printf(MSG_ERROR, "Line %d: Too many qos_map_set "
1415 "parameters '%s'", line, buf);
1420 if (val > 255 || val < 0) {
1421 wpa_printf(MSG_ERROR, "Line %d: Invalid qos_map_set "
1426 qos_map_set[count++] = val;
1427 pos = os_strchr(pos, ',');
1433 if (count < 16 || count & 1) {
1434 wpa_printf(MSG_ERROR, "Line %d: Invalid qos_map_set '%s'",
1439 os_memcpy(bss->qos_map_set, qos_map_set, count);
1440 bss->qos_map_set_len = count;
1445 #endif /* CONFIG_INTERWORKING */
1449 static int hs20_parse_conn_capab(struct hostapd_bss_config *bss, char *buf,
1455 if (bss->hs20_connection_capability_len >= 0xfff0)
1458 conn_cap = os_realloc(bss->hs20_connection_capability,
1459 bss->hs20_connection_capability_len + 4);
1460 if (conn_cap == NULL)
1463 bss->hs20_connection_capability = conn_cap;
1464 conn_cap += bss->hs20_connection_capability_len;
1466 conn_cap[0] = atoi(pos);
1467 pos = os_strchr(pos, ':');
1471 WPA_PUT_LE16(conn_cap + 1, atoi(pos));
1472 pos = os_strchr(pos, ':');
1476 conn_cap[3] = atoi(pos);
1477 bss->hs20_connection_capability_len += 4;
1483 static int hs20_parse_wan_metrics(struct hostapd_bss_config *bss, char *buf,
1489 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1491 wan_metrics = os_zalloc(13);
1492 if (wan_metrics == NULL)
1497 if (hexstr2bin(pos, wan_metrics, 1) < 0)
1504 /* Downlink Speed */
1505 WPA_PUT_LE32(wan_metrics + 1, atoi(pos));
1506 pos = os_strchr(pos, ':');
1512 WPA_PUT_LE32(wan_metrics + 5, atoi(pos));
1513 pos = os_strchr(pos, ':');
1519 wan_metrics[9] = atoi(pos);
1520 pos = os_strchr(pos, ':');
1526 wan_metrics[10] = atoi(pos);
1527 pos = os_strchr(pos, ':');
1533 WPA_PUT_LE16(wan_metrics + 11, atoi(pos));
1535 os_free(bss->hs20_wan_metrics);
1536 bss->hs20_wan_metrics = wan_metrics;
1541 wpa_printf(MSG_ERROR, "Line %d: Invalid hs20_wan_metrics '%s'",
1543 os_free(wan_metrics);
1548 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config *bss,
1549 char *pos, int line)
1551 if (parse_lang_string(&bss->hs20_oper_friendly_name,
1552 &bss->hs20_oper_friendly_name_count, pos)) {
1553 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1554 "hs20_oper_friendly_name '%s'", line, pos);
1559 #endif /* CONFIG_HS20 */
1562 #ifdef CONFIG_WPS_NFC
1563 static struct wpabuf * hostapd_parse_bin(const char *buf)
1568 len = os_strlen(buf);
1573 ret = wpabuf_alloc(len);
1577 if (hexstr2bin(buf, wpabuf_put(ret, len), len)) {
1584 #endif /* CONFIG_WPS_NFC */
1587 static int hostapd_config_fill(struct hostapd_config *conf,
1588 struct hostapd_bss_config *bss,
1589 char *buf, char *pos, int line)
1594 if (os_strcmp(buf, "interface") == 0) {
1595 os_strlcpy(conf->bss[0]->iface, pos,
1596 sizeof(conf->bss[0]->iface));
1597 } else if (os_strcmp(buf, "bridge") == 0) {
1598 os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
1599 } else if (os_strcmp(buf, "vlan_bridge") == 0) {
1600 os_strlcpy(bss->vlan_bridge, pos,
1601 sizeof(bss->vlan_bridge));
1602 } else if (os_strcmp(buf, "wds_bridge") == 0) {
1603 os_strlcpy(bss->wds_bridge, pos,
1604 sizeof(bss->wds_bridge));
1605 } else if (os_strcmp(buf, "driver") == 0) {
1607 /* clear to get error below if setting is invalid */
1608 conf->driver = NULL;
1609 for (j = 0; wpa_drivers[j]; j++) {
1610 if (os_strcmp(pos, wpa_drivers[j]->name) == 0)
1612 conf->driver = wpa_drivers[j];
1616 if (conf->driver == NULL) {
1617 wpa_printf(MSG_ERROR, "Line %d: invalid/"
1618 "unknown driver '%s'", line, pos);
1621 } else if (os_strcmp(buf, "debug") == 0) {
1622 wpa_printf(MSG_DEBUG, "Line %d: DEPRECATED: 'debug' "
1623 "configuration variable is not used "
1625 } else if (os_strcmp(buf, "logger_syslog_level") == 0) {
1626 bss->logger_syslog_level = atoi(pos);
1627 } else if (os_strcmp(buf, "logger_stdout_level") == 0) {
1628 bss->logger_stdout_level = atoi(pos);
1629 } else if (os_strcmp(buf, "logger_syslog") == 0) {
1630 bss->logger_syslog = atoi(pos);
1631 } else if (os_strcmp(buf, "logger_stdout") == 0) {
1632 bss->logger_stdout = atoi(pos);
1633 } else if (os_strcmp(buf, "dump_file") == 0) {
1634 bss->dump_log_name = os_strdup(pos);
1635 } else if (os_strcmp(buf, "ssid") == 0) {
1636 bss->ssid.ssid_len = os_strlen(pos);
1637 if (bss->ssid.ssid_len > HOSTAPD_MAX_SSID_LEN ||
1638 bss->ssid.ssid_len < 1) {
1639 wpa_printf(MSG_ERROR, "Line %d: invalid SSID "
1643 os_memcpy(bss->ssid.ssid, pos,
1644 bss->ssid.ssid_len);
1645 bss->ssid.ssid_set = 1;
1647 } else if (os_strcmp(buf, "ssid2") == 0) {
1649 char *str = wpa_config_parse_string(pos, &slen);
1650 if (str == NULL || slen < 1 ||
1651 slen > HOSTAPD_MAX_SSID_LEN) {
1652 wpa_printf(MSG_ERROR, "Line %d: invalid SSID "
1656 os_memcpy(bss->ssid.ssid, str, slen);
1657 bss->ssid.ssid_len = slen;
1658 bss->ssid.ssid_set = 1;
1661 } else if (os_strcmp(buf, "utf8_ssid") == 0) {
1662 bss->ssid.utf8_ssid = atoi(pos) > 0;
1663 } else if (os_strcmp(buf, "macaddr_acl") == 0) {
1664 bss->macaddr_acl = atoi(pos);
1665 if (bss->macaddr_acl != ACCEPT_UNLESS_DENIED &&
1666 bss->macaddr_acl != DENY_UNLESS_ACCEPTED &&
1667 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
1668 wpa_printf(MSG_ERROR, "Line %d: unknown "
1670 line, bss->macaddr_acl);
1672 } else if (os_strcmp(buf, "accept_mac_file") == 0) {
1673 if (hostapd_config_read_maclist(pos, &bss->accept_mac,
1674 &bss->num_accept_mac))
1676 wpa_printf(MSG_ERROR, "Line %d: Failed to "
1677 "read accept_mac_file '%s'",
1681 } else if (os_strcmp(buf, "deny_mac_file") == 0) {
1682 if (hostapd_config_read_maclist(pos, &bss->deny_mac,
1683 &bss->num_deny_mac)) {
1684 wpa_printf(MSG_ERROR, "Line %d: Failed to "
1685 "read deny_mac_file '%s'",
1689 } else if (os_strcmp(buf, "wds_sta") == 0) {
1690 bss->wds_sta = atoi(pos);
1691 } else if (os_strcmp(buf, "start_disabled") == 0) {
1692 bss->start_disabled = atoi(pos);
1693 } else if (os_strcmp(buf, "ap_isolate") == 0) {
1694 bss->isolate = atoi(pos);
1695 } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
1696 bss->ap_max_inactivity = atoi(pos);
1697 } else if (os_strcmp(buf, "skip_inactivity_poll") == 0) {
1698 bss->skip_inactivity_poll = atoi(pos);
1699 } else if (os_strcmp(buf, "country_code") == 0) {
1700 os_memcpy(conf->country, pos, 2);
1701 /* FIX: make this configurable */
1702 conf->country[2] = ' ';
1703 } else if (os_strcmp(buf, "ieee80211d") == 0) {
1704 conf->ieee80211d = atoi(pos);
1705 } else if (os_strcmp(buf, "ieee80211h") == 0) {
1706 conf->ieee80211h = atoi(pos);
1707 } else if (os_strcmp(buf, "ieee8021x") == 0) {
1708 bss->ieee802_1x = atoi(pos);
1709 } else if (os_strcmp(buf, "eapol_version") == 0) {
1710 bss->eapol_version = atoi(pos);
1711 if (bss->eapol_version < 1 ||
1712 bss->eapol_version > 2) {
1713 wpa_printf(MSG_ERROR, "Line %d: invalid EAPOL "
1714 "version (%d): '%s'.",
1715 line, bss->eapol_version, pos);
1718 wpa_printf(MSG_DEBUG, "eapol_version=%d",
1719 bss->eapol_version);
1721 } else if (os_strcmp(buf, "eap_authenticator") == 0) {
1722 bss->eap_server = atoi(pos);
1723 wpa_printf(MSG_ERROR, "Line %d: obsolete "
1724 "eap_authenticator used; this has been "
1725 "renamed to eap_server", line);
1726 } else if (os_strcmp(buf, "eap_server") == 0) {
1727 bss->eap_server = atoi(pos);
1728 } else if (os_strcmp(buf, "eap_user_file") == 0) {
1729 if (hostapd_config_read_eap_user(pos, bss))
1731 } else if (os_strcmp(buf, "ca_cert") == 0) {
1732 os_free(bss->ca_cert);
1733 bss->ca_cert = os_strdup(pos);
1734 } else if (os_strcmp(buf, "server_cert") == 0) {
1735 os_free(bss->server_cert);
1736 bss->server_cert = os_strdup(pos);
1737 } else if (os_strcmp(buf, "private_key") == 0) {
1738 os_free(bss->private_key);
1739 bss->private_key = os_strdup(pos);
1740 } else if (os_strcmp(buf, "private_key_passwd") == 0) {
1741 os_free(bss->private_key_passwd);
1742 bss->private_key_passwd = os_strdup(pos);
1743 } else if (os_strcmp(buf, "check_crl") == 0) {
1744 bss->check_crl = atoi(pos);
1745 } else if (os_strcmp(buf, "ocsp_stapling_response") == 0) {
1746 os_free(bss->ocsp_stapling_response);
1747 bss->ocsp_stapling_response = os_strdup(pos);
1748 } else if (os_strcmp(buf, "dh_file") == 0) {
1749 os_free(bss->dh_file);
1750 bss->dh_file = os_strdup(pos);
1751 } else if (os_strcmp(buf, "fragment_size") == 0) {
1752 bss->fragment_size = atoi(pos);
1753 #ifdef EAP_SERVER_FAST
1754 } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
1755 os_free(bss->pac_opaque_encr_key);
1756 bss->pac_opaque_encr_key = os_malloc(16);
1757 if (bss->pac_opaque_encr_key == NULL) {
1758 wpa_printf(MSG_ERROR, "Line %d: No memory for "
1759 "pac_opaque_encr_key", line);
1761 } else if (hexstr2bin(pos, bss->pac_opaque_encr_key,
1763 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1764 "pac_opaque_encr_key", line);
1767 } else if (os_strcmp(buf, "eap_fast_a_id") == 0) {
1768 size_t idlen = os_strlen(pos);
1770 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1771 "eap_fast_a_id", line);
1774 os_free(bss->eap_fast_a_id);
1775 bss->eap_fast_a_id = os_malloc(idlen / 2);
1776 if (bss->eap_fast_a_id == NULL ||
1777 hexstr2bin(pos, bss->eap_fast_a_id,
1779 wpa_printf(MSG_ERROR, "Line %d: "
1781 "eap_fast_a_id", line);
1784 bss->eap_fast_a_id_len = idlen / 2;
1786 } else if (os_strcmp(buf, "eap_fast_a_id_info") == 0) {
1787 os_free(bss->eap_fast_a_id_info);
1788 bss->eap_fast_a_id_info = os_strdup(pos);
1789 } else if (os_strcmp(buf, "eap_fast_prov") == 0) {
1790 bss->eap_fast_prov = atoi(pos);
1791 } else if (os_strcmp(buf, "pac_key_lifetime") == 0) {
1792 bss->pac_key_lifetime = atoi(pos);
1793 } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) {
1794 bss->pac_key_refresh_time = atoi(pos);
1795 #endif /* EAP_SERVER_FAST */
1796 #ifdef EAP_SERVER_SIM
1797 } else if (os_strcmp(buf, "eap_sim_db") == 0) {
1798 os_free(bss->eap_sim_db);
1799 bss->eap_sim_db = os_strdup(pos);
1800 } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) {
1801 bss->eap_sim_aka_result_ind = atoi(pos);
1802 #endif /* EAP_SERVER_SIM */
1803 #ifdef EAP_SERVER_TNC
1804 } else if (os_strcmp(buf, "tnc") == 0) {
1805 bss->tnc = atoi(pos);
1806 #endif /* EAP_SERVER_TNC */
1807 #ifdef EAP_SERVER_PWD
1808 } else if (os_strcmp(buf, "pwd_group") == 0) {
1809 bss->pwd_group = atoi(pos);
1810 #endif /* EAP_SERVER_PWD */
1811 #endif /* EAP_SERVER */
1812 } else if (os_strcmp(buf, "eap_message") == 0) {
1814 bss->eap_req_id_text = os_strdup(pos);
1815 if (bss->eap_req_id_text == NULL) {
1816 wpa_printf(MSG_ERROR, "Line %d: Failed to "
1817 "allocate memory for "
1818 "eap_req_id_text", line);
1822 bss->eap_req_id_text_len =
1823 os_strlen(bss->eap_req_id_text);
1824 term = os_strstr(bss->eap_req_id_text, "\\0");
1827 os_memmove(term, term + 1,
1828 bss->eap_req_id_text_len -
1829 (term - bss->eap_req_id_text) - 1);
1830 bss->eap_req_id_text_len--;
1832 } else if (os_strcmp(buf, "wep_key_len_broadcast") == 0) {
1833 bss->default_wep_key_len = atoi(pos);
1834 if (bss->default_wep_key_len > 13) {
1835 wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
1836 "key len %lu (= %lu bits)", line,
1838 bss->default_wep_key_len,
1840 bss->default_wep_key_len * 8);
1843 } else if (os_strcmp(buf, "wep_key_len_unicast") == 0) {
1844 bss->individual_wep_key_len = atoi(pos);
1845 if (bss->individual_wep_key_len < 0 ||
1846 bss->individual_wep_key_len > 13) {
1847 wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
1848 "key len %d (= %d bits)", line,
1849 bss->individual_wep_key_len,
1850 bss->individual_wep_key_len * 8);
1853 } else if (os_strcmp(buf, "wep_rekey_period") == 0) {
1854 bss->wep_rekeying_period = atoi(pos);
1855 if (bss->wep_rekeying_period < 0) {
1856 wpa_printf(MSG_ERROR, "Line %d: invalid "
1858 line, bss->wep_rekeying_period);
1861 } else if (os_strcmp(buf, "eap_reauth_period") == 0) {
1862 bss->eap_reauth_period = atoi(pos);
1863 if (bss->eap_reauth_period < 0) {
1864 wpa_printf(MSG_ERROR, "Line %d: invalid "
1866 line, bss->eap_reauth_period);
1869 } else if (os_strcmp(buf, "eapol_key_index_workaround") == 0) {
1870 bss->eapol_key_index_workaround = atoi(pos);
1872 } else if (os_strcmp(buf, "iapp_interface") == 0) {
1873 bss->ieee802_11f = 1;
1874 os_strlcpy(bss->iapp_iface, pos,
1875 sizeof(bss->iapp_iface));
1876 #endif /* CONFIG_IAPP */
1877 } else if (os_strcmp(buf, "own_ip_addr") == 0) {
1878 if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
1879 wpa_printf(MSG_ERROR, "Line %d: invalid IP "
1880 "address '%s'", line, pos);
1883 } else if (os_strcmp(buf, "nas_identifier") == 0) {
1884 bss->nas_identifier = os_strdup(pos);
1885 #ifndef CONFIG_NO_RADIUS
1886 } else if (os_strcmp(buf, "auth_server_addr") == 0) {
1887 if (hostapd_config_read_radius_addr(
1888 &bss->radius->auth_servers,
1889 &bss->radius->num_auth_servers, pos, 1812,
1890 &bss->radius->auth_server)) {
1891 wpa_printf(MSG_ERROR, "Line %d: invalid IP "
1892 "address '%s'", line, pos);
1895 } else if (bss->radius->auth_server &&
1896 os_strcmp(buf, "auth_server_port") == 0) {
1897 bss->radius->auth_server->port = atoi(pos);
1898 } else if (bss->radius->auth_server &&
1899 os_strcmp(buf, "auth_server_shared_secret") == 0) {
1900 int len = os_strlen(pos);
1902 /* RFC 2865, Ch. 3 */
1903 wpa_printf(MSG_ERROR, "Line %d: empty shared "
1904 "secret is not allowed.", line);
1907 bss->radius->auth_server->shared_secret =
1908 (u8 *) os_strdup(pos);
1909 bss->radius->auth_server->shared_secret_len = len;
1910 } else if (os_strcmp(buf, "acct_server_addr") == 0) {
1911 if (hostapd_config_read_radius_addr(
1912 &bss->radius->acct_servers,
1913 &bss->radius->num_acct_servers, pos, 1813,
1914 &bss->radius->acct_server)) {
1915 wpa_printf(MSG_ERROR, "Line %d: invalid IP "
1916 "address '%s'", line, pos);
1919 } else if (bss->radius->acct_server &&
1920 os_strcmp(buf, "acct_server_port") == 0) {
1921 bss->radius->acct_server->port = atoi(pos);
1922 } else if (bss->radius->acct_server &&
1923 os_strcmp(buf, "acct_server_shared_secret") == 0) {
1924 int len = os_strlen(pos);
1926 /* RFC 2865, Ch. 3 */
1927 wpa_printf(MSG_ERROR, "Line %d: empty shared "
1928 "secret is not allowed.", line);
1931 bss->radius->acct_server->shared_secret =
1932 (u8 *) os_strdup(pos);
1933 bss->radius->acct_server->shared_secret_len = len;
1934 } else if (os_strcmp(buf, "radius_retry_primary_interval") ==
1936 bss->radius->retry_primary_interval = atoi(pos);
1937 } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0)
1939 bss->acct_interim_interval = atoi(pos);
1940 } else if (os_strcmp(buf, "radius_request_cui") == 0) {
1941 bss->radius_request_cui = atoi(pos);
1942 } else if (os_strcmp(buf, "radius_auth_req_attr") == 0) {
1943 struct hostapd_radius_attr *attr, *a;
1944 attr = hostapd_parse_radius_attr(pos);
1946 wpa_printf(MSG_ERROR, "Line %d: invalid "
1947 "radius_auth_req_attr", line);
1949 } else if (bss->radius_auth_req_attr == NULL) {
1950 bss->radius_auth_req_attr = attr;
1952 a = bss->radius_auth_req_attr;
1957 } else if (os_strcmp(buf, "radius_acct_req_attr") == 0) {
1958 struct hostapd_radius_attr *attr, *a;
1959 attr = hostapd_parse_radius_attr(pos);
1961 wpa_printf(MSG_ERROR, "Line %d: invalid "
1962 "radius_acct_req_attr", line);
1964 } else if (bss->radius_acct_req_attr == NULL) {
1965 bss->radius_acct_req_attr = attr;
1967 a = bss->radius_acct_req_attr;
1972 } else if (os_strcmp(buf, "radius_das_port") == 0) {
1973 bss->radius_das_port = atoi(pos);
1974 } else if (os_strcmp(buf, "radius_das_client") == 0) {
1975 if (hostapd_parse_das_client(bss, pos) < 0) {
1976 wpa_printf(MSG_ERROR, "Line %d: invalid "
1977 "DAS client", line);
1980 } else if (os_strcmp(buf, "radius_das_time_window") == 0) {
1981 bss->radius_das_time_window = atoi(pos);
1982 } else if (os_strcmp(buf, "radius_das_require_event_timestamp")
1984 bss->radius_das_require_event_timestamp = atoi(pos);
1985 #endif /* CONFIG_NO_RADIUS */
1986 } else if (os_strcmp(buf, "auth_algs") == 0) {
1987 bss->auth_algs = atoi(pos);
1988 if (bss->auth_algs == 0) {
1989 wpa_printf(MSG_ERROR, "Line %d: no "
1990 "authentication algorithms allowed",
1994 } else if (os_strcmp(buf, "max_num_sta") == 0) {
1995 bss->max_num_sta = atoi(pos);
1996 if (bss->max_num_sta < 0 ||
1997 bss->max_num_sta > MAX_STA_COUNT) {
1998 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1999 "max_num_sta=%d; allowed range "
2000 "0..%d", line, bss->max_num_sta,
2004 } else if (os_strcmp(buf, "wpa") == 0) {
2005 bss->wpa = atoi(pos);
2006 } else if (os_strcmp(buf, "wpa_group_rekey") == 0) {
2007 bss->wpa_group_rekey = atoi(pos);
2008 } else if (os_strcmp(buf, "wpa_strict_rekey") == 0) {
2009 bss->wpa_strict_rekey = atoi(pos);
2010 } else if (os_strcmp(buf, "wpa_gmk_rekey") == 0) {
2011 bss->wpa_gmk_rekey = atoi(pos);
2012 } else if (os_strcmp(buf, "wpa_ptk_rekey") == 0) {
2013 bss->wpa_ptk_rekey = atoi(pos);
2014 } else if (os_strcmp(buf, "wpa_passphrase") == 0) {
2015 int len = os_strlen(pos);
2016 if (len < 8 || len > 63) {
2017 wpa_printf(MSG_ERROR, "Line %d: invalid WPA "
2018 "passphrase length %d (expected "
2019 "8..63)", line, len);
2022 os_free(bss->ssid.wpa_passphrase);
2023 bss->ssid.wpa_passphrase = os_strdup(pos);
2024 if (bss->ssid.wpa_passphrase) {
2025 os_free(bss->ssid.wpa_psk);
2026 bss->ssid.wpa_psk = NULL;
2027 bss->ssid.wpa_passphrase_set = 1;
2030 } else if (os_strcmp(buf, "wpa_psk") == 0) {
2031 os_free(bss->ssid.wpa_psk);
2033 os_zalloc(sizeof(struct hostapd_wpa_psk));
2034 if (bss->ssid.wpa_psk == NULL)
2036 else if (hexstr2bin(pos, bss->ssid.wpa_psk->psk,
2038 pos[PMK_LEN * 2] != '\0') {
2039 wpa_printf(MSG_ERROR, "Line %d: Invalid PSK "
2040 "'%s'.", line, pos);
2043 bss->ssid.wpa_psk->group = 1;
2044 os_free(bss->ssid.wpa_passphrase);
2045 bss->ssid.wpa_passphrase = NULL;
2046 bss->ssid.wpa_psk_set = 1;
2048 } else if (os_strcmp(buf, "wpa_psk_file") == 0) {
2049 os_free(bss->ssid.wpa_psk_file);
2050 bss->ssid.wpa_psk_file = os_strdup(pos);
2051 if (!bss->ssid.wpa_psk_file) {
2052 wpa_printf(MSG_ERROR, "Line %d: allocation "
2056 } else if (os_strcmp(buf, "wpa_key_mgmt") == 0) {
2058 hostapd_config_parse_key_mgmt(line, pos);
2059 if (bss->wpa_key_mgmt == -1)
2061 } else if (os_strcmp(buf, "wpa_psk_radius") == 0) {
2062 bss->wpa_psk_radius = atoi(pos);
2063 if (bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
2064 bss->wpa_psk_radius != PSK_RADIUS_ACCEPTED &&
2065 bss->wpa_psk_radius != PSK_RADIUS_REQUIRED) {
2066 wpa_printf(MSG_ERROR, "Line %d: unknown "
2067 "wpa_psk_radius %d",
2068 line, bss->wpa_psk_radius);
2071 } else if (os_strcmp(buf, "wpa_pairwise") == 0) {
2073 hostapd_config_parse_cipher(line, pos);
2074 if (bss->wpa_pairwise == -1 ||
2075 bss->wpa_pairwise == 0)
2077 else if (bss->wpa_pairwise &
2078 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
2079 WPA_CIPHER_WEP104)) {
2080 wpa_printf(MSG_ERROR, "Line %d: unsupported "
2081 "pairwise cipher suite '%s'",
2082 bss->wpa_pairwise, pos);
2085 } else if (os_strcmp(buf, "rsn_pairwise") == 0) {
2087 hostapd_config_parse_cipher(line, pos);
2088 if (bss->rsn_pairwise == -1 ||
2089 bss->rsn_pairwise == 0)
2091 else if (bss->rsn_pairwise &
2092 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
2093 WPA_CIPHER_WEP104)) {
2094 wpa_printf(MSG_ERROR, "Line %d: unsupported "
2095 "pairwise cipher suite '%s'",
2096 bss->rsn_pairwise, pos);
2099 #ifdef CONFIG_RSN_PREAUTH
2100 } else if (os_strcmp(buf, "rsn_preauth") == 0) {
2101 bss->rsn_preauth = atoi(pos);
2102 } else if (os_strcmp(buf, "rsn_preauth_interfaces") == 0) {
2103 bss->rsn_preauth_interfaces = os_strdup(pos);
2104 #endif /* CONFIG_RSN_PREAUTH */
2105 #ifdef CONFIG_PEERKEY
2106 } else if (os_strcmp(buf, "peerkey") == 0) {
2107 bss->peerkey = atoi(pos);
2108 #endif /* CONFIG_PEERKEY */
2109 #ifdef CONFIG_IEEE80211R
2110 } else if (os_strcmp(buf, "mobility_domain") == 0) {
2111 if (os_strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN ||
2112 hexstr2bin(pos, bss->mobility_domain,
2113 MOBILITY_DOMAIN_ID_LEN) != 0) {
2114 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2115 "mobility_domain '%s'", line, pos);
2119 } else if (os_strcmp(buf, "r1_key_holder") == 0) {
2120 if (os_strlen(pos) != 2 * FT_R1KH_ID_LEN ||
2121 hexstr2bin(pos, bss->r1_key_holder,
2122 FT_R1KH_ID_LEN) != 0) {
2123 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2124 "r1_key_holder '%s'", line, pos);
2128 } else if (os_strcmp(buf, "r0_key_lifetime") == 0) {
2129 bss->r0_key_lifetime = atoi(pos);
2130 } else if (os_strcmp(buf, "reassociation_deadline") == 0) {
2131 bss->reassociation_deadline = atoi(pos);
2132 } else if (os_strcmp(buf, "r0kh") == 0) {
2133 if (add_r0kh(bss, pos) < 0) {
2134 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2135 "r0kh '%s'", line, pos);
2139 } else if (os_strcmp(buf, "r1kh") == 0) {
2140 if (add_r1kh(bss, pos) < 0) {
2141 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2142 "r1kh '%s'", line, pos);
2146 } else if (os_strcmp(buf, "pmk_r1_push") == 0) {
2147 bss->pmk_r1_push = atoi(pos);
2148 } else if (os_strcmp(buf, "ft_over_ds") == 0) {
2149 bss->ft_over_ds = atoi(pos);
2150 #endif /* CONFIG_IEEE80211R */
2151 #ifndef CONFIG_NO_CTRL_IFACE
2152 } else if (os_strcmp(buf, "ctrl_interface") == 0) {
2153 os_free(bss->ctrl_interface);
2154 bss->ctrl_interface = os_strdup(pos);
2155 } else if (os_strcmp(buf, "ctrl_interface_group") == 0) {
2156 #ifndef CONFIG_NATIVE_WINDOWS
2159 const char *group = pos;
2161 grp = getgrnam(group);
2163 bss->ctrl_interface_gid = grp->gr_gid;
2164 bss->ctrl_interface_gid_set = 1;
2165 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d"
2166 " (from group name '%s')",
2167 bss->ctrl_interface_gid, group);
2171 /* Group name not found - try to parse this as gid */
2172 bss->ctrl_interface_gid = strtol(group, &endp, 10);
2173 if (*group == '\0' || *endp != '\0') {
2174 wpa_printf(MSG_DEBUG, "Line %d: Invalid group "
2175 "'%s'", line, group);
2179 bss->ctrl_interface_gid_set = 1;
2180 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d",
2181 bss->ctrl_interface_gid);
2182 #endif /* CONFIG_NATIVE_WINDOWS */
2183 #endif /* CONFIG_NO_CTRL_IFACE */
2184 #ifdef RADIUS_SERVER
2185 } else if (os_strcmp(buf, "radius_server_clients") == 0) {
2186 os_free(bss->radius_server_clients);
2187 bss->radius_server_clients = os_strdup(pos);
2188 } else if (os_strcmp(buf, "radius_server_auth_port") == 0) {
2189 bss->radius_server_auth_port = atoi(pos);
2190 } else if (os_strcmp(buf, "radius_server_ipv6") == 0) {
2191 bss->radius_server_ipv6 = atoi(pos);
2192 #endif /* RADIUS_SERVER */
2193 } else if (os_strcmp(buf, "test_socket") == 0) {
2194 os_free(bss->test_socket);
2195 bss->test_socket = os_strdup(pos);
2196 } else if (os_strcmp(buf, "use_pae_group_addr") == 0) {
2197 bss->use_pae_group_addr = atoi(pos);
2198 } else if (os_strcmp(buf, "hw_mode") == 0) {
2199 if (os_strcmp(pos, "a") == 0)
2200 conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
2201 else if (os_strcmp(pos, "b") == 0)
2202 conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
2203 else if (os_strcmp(pos, "g") == 0)
2204 conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
2205 else if (os_strcmp(pos, "ad") == 0)
2206 conf->hw_mode = HOSTAPD_MODE_IEEE80211AD;
2208 wpa_printf(MSG_ERROR, "Line %d: unknown "
2209 "hw_mode '%s'", line, pos);
2212 } else if (os_strcmp(buf, "wps_rf_bands") == 0) {
2213 if (os_strcmp(pos, "a") == 0)
2214 bss->wps_rf_bands = WPS_RF_50GHZ;
2215 else if (os_strcmp(pos, "g") == 0 ||
2216 os_strcmp(pos, "b") == 0)
2217 bss->wps_rf_bands = WPS_RF_24GHZ;
2218 else if (os_strcmp(pos, "ag") == 0 ||
2219 os_strcmp(pos, "ga") == 0)
2221 WPS_RF_24GHZ | WPS_RF_50GHZ;
2223 wpa_printf(MSG_ERROR, "Line %d: unknown "
2224 "wps_rf_band '%s'", line, pos);
2227 } else if (os_strcmp(buf, "channel") == 0) {
2228 if (os_strcmp(pos, "acs_survey") == 0) {
2230 wpa_printf(MSG_ERROR, "Line %d: tries to enable ACS but CONFIG_ACS disabled",
2233 #endif /* CONFIG_ACS */
2236 conf->channel = atoi(pos);
2237 } else if (os_strcmp(buf, "beacon_int") == 0) {
2238 int val = atoi(pos);
2239 /* MIB defines range as 1..65535, but very small values
2240 * cause problems with the current implementation.
2241 * Since it is unlikely that this small numbers are
2242 * useful in real life scenarios, do not allow beacon
2243 * period to be set below 15 TU. */
2244 if (val < 15 || val > 65535) {
2245 wpa_printf(MSG_ERROR, "Line %d: invalid "
2246 "beacon_int %d (expected "
2247 "15..65535)", line, val);
2250 conf->beacon_int = val;
2252 } else if (os_strcmp(buf, "acs_num_scans") == 0) {
2253 int val = atoi(pos);
2254 if (val <= 0 || val > 100) {
2255 wpa_printf(MSG_ERROR, "Line %d: invalid acs_num_scans %d (expected 1..100)",
2259 conf->acs_num_scans = val;
2260 #endif /* CONFIG_ACS */
2261 } else if (os_strcmp(buf, "dtim_period") == 0) {
2262 bss->dtim_period = atoi(pos);
2263 if (bss->dtim_period < 1 || bss->dtim_period > 255) {
2264 wpa_printf(MSG_ERROR, "Line %d: invalid "
2266 line, bss->dtim_period);
2269 } else if (os_strcmp(buf, "rts_threshold") == 0) {
2270 conf->rts_threshold = atoi(pos);
2271 if (conf->rts_threshold < 0 ||
2272 conf->rts_threshold > 2347) {
2273 wpa_printf(MSG_ERROR, "Line %d: invalid "
2275 line, conf->rts_threshold);
2278 } else if (os_strcmp(buf, "fragm_threshold") == 0) {
2279 conf->fragm_threshold = atoi(pos);
2280 if (conf->fragm_threshold < 256 ||
2281 conf->fragm_threshold > 2346) {
2282 wpa_printf(MSG_ERROR, "Line %d: invalid "
2283 "fragm_threshold %d",
2284 line, conf->fragm_threshold);
2287 } else if (os_strcmp(buf, "send_probe_response") == 0) {
2288 int val = atoi(pos);
2289 if (val != 0 && val != 1) {
2290 wpa_printf(MSG_ERROR, "Line %d: invalid "
2291 "send_probe_response %d (expected "
2292 "0 or 1)", line, val);
2294 conf->send_probe_response = val;
2295 } else if (os_strcmp(buf, "supported_rates") == 0) {
2296 if (hostapd_parse_intlist(&conf->supported_rates, pos))
2298 wpa_printf(MSG_ERROR, "Line %d: invalid rate "
2302 } else if (os_strcmp(buf, "basic_rates") == 0) {
2303 if (hostapd_parse_intlist(&conf->basic_rates, pos)) {
2304 wpa_printf(MSG_ERROR, "Line %d: invalid rate "
2308 } else if (os_strcmp(buf, "preamble") == 0) {
2310 conf->preamble = SHORT_PREAMBLE;
2312 conf->preamble = LONG_PREAMBLE;
2313 } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) {
2314 bss->ignore_broadcast_ssid = atoi(pos);
2315 } else if (os_strcmp(buf, "wep_default_key") == 0) {
2316 bss->ssid.wep.idx = atoi(pos);
2317 if (bss->ssid.wep.idx > 3) {
2318 wpa_printf(MSG_ERROR, "Invalid "
2319 "wep_default_key index %d",
2323 } else if (os_strcmp(buf, "wep_key0") == 0 ||
2324 os_strcmp(buf, "wep_key1") == 0 ||
2325 os_strcmp(buf, "wep_key2") == 0 ||
2326 os_strcmp(buf, "wep_key3") == 0) {
2327 if (hostapd_config_read_wep(&bss->ssid.wep,
2328 buf[7] - '0', pos)) {
2329 wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
2330 "key '%s'", line, buf);
2333 #ifndef CONFIG_NO_VLAN
2334 } else if (os_strcmp(buf, "dynamic_vlan") == 0) {
2335 bss->ssid.dynamic_vlan = atoi(pos);
2336 } else if (os_strcmp(buf, "vlan_file") == 0) {
2337 if (hostapd_config_read_vlan_file(bss, pos)) {
2338 wpa_printf(MSG_ERROR, "Line %d: failed to "
2339 "read VLAN file '%s'", line, pos);
2342 } else if (os_strcmp(buf, "vlan_naming") == 0) {
2343 bss->ssid.vlan_naming = atoi(pos);
2344 if (bss->ssid.vlan_naming >= DYNAMIC_VLAN_NAMING_END ||
2345 bss->ssid.vlan_naming < 0) {
2346 wpa_printf(MSG_ERROR, "Line %d: invalid "
2347 "naming scheme %d", line,
2348 bss->ssid.vlan_naming);
2351 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2352 } else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
2353 bss->ssid.vlan_tagged_interface = os_strdup(pos);
2354 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2355 #endif /* CONFIG_NO_VLAN */
2356 } else if (os_strcmp(buf, "ap_table_max_size") == 0) {
2357 conf->ap_table_max_size = atoi(pos);
2358 } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) {
2359 conf->ap_table_expiration_time = atoi(pos);
2360 } else if (os_strncmp(buf, "tx_queue_", 9) == 0) {
2361 if (hostapd_config_tx_queue(conf, buf, pos)) {
2362 wpa_printf(MSG_ERROR, "Line %d: invalid TX "
2363 "queue item", line);
2366 } else if (os_strcmp(buf, "wme_enabled") == 0 ||
2367 os_strcmp(buf, "wmm_enabled") == 0) {
2368 bss->wmm_enabled = atoi(pos);
2369 } else if (os_strcmp(buf, "uapsd_advertisement_enabled") == 0) {
2370 bss->wmm_uapsd = atoi(pos);
2371 } else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
2372 os_strncmp(buf, "wmm_ac_", 7) == 0) {
2373 if (hostapd_config_wmm_ac(conf->wmm_ac_params, buf,
2375 wpa_printf(MSG_ERROR, "Line %d: invalid WMM "
2379 } else if (os_strcmp(buf, "bss") == 0) {
2380 if (hostapd_config_bss(conf, pos)) {
2381 wpa_printf(MSG_ERROR, "Line %d: invalid bss "
2385 } else if (os_strcmp(buf, "bssid") == 0) {
2386 if (hwaddr_aton(pos, bss->bssid)) {
2387 wpa_printf(MSG_ERROR, "Line %d: invalid bssid "
2391 #ifdef CONFIG_IEEE80211W
2392 } else if (os_strcmp(buf, "ieee80211w") == 0) {
2393 bss->ieee80211w = atoi(pos);
2394 } else if (os_strcmp(buf, "assoc_sa_query_max_timeout") == 0) {
2395 bss->assoc_sa_query_max_timeout = atoi(pos);
2396 if (bss->assoc_sa_query_max_timeout == 0) {
2397 wpa_printf(MSG_ERROR, "Line %d: invalid "
2398 "assoc_sa_query_max_timeout", line);
2401 } else if (os_strcmp(buf, "assoc_sa_query_retry_timeout") == 0)
2403 bss->assoc_sa_query_retry_timeout = atoi(pos);
2404 if (bss->assoc_sa_query_retry_timeout == 0) {
2405 wpa_printf(MSG_ERROR, "Line %d: invalid "
2406 "assoc_sa_query_retry_timeout",
2410 #endif /* CONFIG_IEEE80211W */
2411 #ifdef CONFIG_IEEE80211N
2412 } else if (os_strcmp(buf, "ieee80211n") == 0) {
2413 conf->ieee80211n = atoi(pos);
2414 } else if (os_strcmp(buf, "ht_capab") == 0) {
2415 if (hostapd_config_ht_capab(conf, pos) < 0) {
2416 wpa_printf(MSG_ERROR, "Line %d: invalid "
2420 } else if (os_strcmp(buf, "require_ht") == 0) {
2421 conf->require_ht = atoi(pos);
2422 } else if (os_strcmp(buf, "obss_interval") == 0) {
2423 conf->obss_interval = atoi(pos);
2424 #endif /* CONFIG_IEEE80211N */
2425 #ifdef CONFIG_IEEE80211AC
2426 } else if (os_strcmp(buf, "ieee80211ac") == 0) {
2427 conf->ieee80211ac = atoi(pos);
2428 } else if (os_strcmp(buf, "vht_capab") == 0) {
2429 if (hostapd_config_vht_capab(conf, pos) < 0) {
2430 wpa_printf(MSG_ERROR, "Line %d: invalid "
2434 } else if (os_strcmp(buf, "require_vht") == 0) {
2435 conf->require_vht = atoi(pos);
2436 } else if (os_strcmp(buf, "vht_oper_chwidth") == 0) {
2437 conf->vht_oper_chwidth = atoi(pos);
2438 } else if (os_strcmp(buf, "vht_oper_centr_freq_seg0_idx") == 0)
2440 conf->vht_oper_centr_freq_seg0_idx = atoi(pos);
2441 } else if (os_strcmp(buf, "vht_oper_centr_freq_seg1_idx") == 0)
2443 conf->vht_oper_centr_freq_seg1_idx = atoi(pos);
2444 #endif /* CONFIG_IEEE80211AC */
2445 } else if (os_strcmp(buf, "max_listen_interval") == 0) {
2446 bss->max_listen_interval = atoi(pos);
2447 } else if (os_strcmp(buf, "disable_pmksa_caching") == 0) {
2448 bss->disable_pmksa_caching = atoi(pos);
2449 } else if (os_strcmp(buf, "okc") == 0) {
2450 bss->okc = atoi(pos);
2452 } else if (os_strcmp(buf, "wps_state") == 0) {
2453 bss->wps_state = atoi(pos);
2454 if (bss->wps_state < 0 || bss->wps_state > 2) {
2455 wpa_printf(MSG_ERROR, "Line %d: invalid "
2459 } else if (os_strcmp(buf, "wps_independent") == 0) {
2460 bss->wps_independent = atoi(pos);
2461 } else if (os_strcmp(buf, "ap_setup_locked") == 0) {
2462 bss->ap_setup_locked = atoi(pos);
2463 } else if (os_strcmp(buf, "uuid") == 0) {
2464 if (uuid_str2bin(pos, bss->uuid)) {
2465 wpa_printf(MSG_ERROR, "Line %d: invalid UUID",
2469 } else if (os_strcmp(buf, "wps_pin_requests") == 0) {
2470 os_free(bss->wps_pin_requests);
2471 bss->wps_pin_requests = os_strdup(pos);
2472 } else if (os_strcmp(buf, "device_name") == 0) {
2473 if (os_strlen(pos) > 32) {
2474 wpa_printf(MSG_ERROR, "Line %d: Too long "
2475 "device_name", line);
2478 os_free(bss->device_name);
2479 bss->device_name = os_strdup(pos);
2480 } else if (os_strcmp(buf, "manufacturer") == 0) {
2481 if (os_strlen(pos) > 64) {
2482 wpa_printf(MSG_ERROR, "Line %d: Too long "
2483 "manufacturer", line);
2486 os_free(bss->manufacturer);
2487 bss->manufacturer = os_strdup(pos);
2488 } else if (os_strcmp(buf, "model_name") == 0) {
2489 if (os_strlen(pos) > 32) {
2490 wpa_printf(MSG_ERROR, "Line %d: Too long "
2491 "model_name", line);
2494 os_free(bss->model_name);
2495 bss->model_name = os_strdup(pos);
2496 } else if (os_strcmp(buf, "model_number") == 0) {
2497 if (os_strlen(pos) > 32) {
2498 wpa_printf(MSG_ERROR, "Line %d: Too long "
2499 "model_number", line);
2502 os_free(bss->model_number);
2503 bss->model_number = os_strdup(pos);
2504 } else if (os_strcmp(buf, "serial_number") == 0) {
2505 if (os_strlen(pos) > 32) {
2506 wpa_printf(MSG_ERROR, "Line %d: Too long "
2507 "serial_number", line);
2510 os_free(bss->serial_number);
2511 bss->serial_number = os_strdup(pos);
2512 } else if (os_strcmp(buf, "device_type") == 0) {
2513 if (wps_dev_type_str2bin(pos, bss->device_type))
2515 } else if (os_strcmp(buf, "config_methods") == 0) {
2516 os_free(bss->config_methods);
2517 bss->config_methods = os_strdup(pos);
2518 } else if (os_strcmp(buf, "os_version") == 0) {
2519 if (hexstr2bin(pos, bss->os_version, 4)) {
2520 wpa_printf(MSG_ERROR, "Line %d: invalid "
2521 "os_version", line);
2524 } else if (os_strcmp(buf, "ap_pin") == 0) {
2525 os_free(bss->ap_pin);
2526 bss->ap_pin = os_strdup(pos);
2527 } else if (os_strcmp(buf, "skip_cred_build") == 0) {
2528 bss->skip_cred_build = atoi(pos);
2529 } else if (os_strcmp(buf, "extra_cred") == 0) {
2530 os_free(bss->extra_cred);
2532 (u8 *) os_readfile(pos, &bss->extra_cred_len);
2533 if (bss->extra_cred == NULL) {
2534 wpa_printf(MSG_ERROR, "Line %d: could not "
2535 "read Credentials from '%s'",
2539 } else if (os_strcmp(buf, "wps_cred_processing") == 0) {
2540 bss->wps_cred_processing = atoi(pos);
2541 } else if (os_strcmp(buf, "ap_settings") == 0) {
2542 os_free(bss->ap_settings);
2544 (u8 *) os_readfile(pos, &bss->ap_settings_len);
2545 if (bss->ap_settings == NULL) {
2546 wpa_printf(MSG_ERROR, "Line %d: could not "
2547 "read AP Settings from '%s'",
2551 } else if (os_strcmp(buf, "upnp_iface") == 0) {
2552 bss->upnp_iface = os_strdup(pos);
2553 } else if (os_strcmp(buf, "friendly_name") == 0) {
2554 os_free(bss->friendly_name);
2555 bss->friendly_name = os_strdup(pos);
2556 } else if (os_strcmp(buf, "manufacturer_url") == 0) {
2557 os_free(bss->manufacturer_url);
2558 bss->manufacturer_url = os_strdup(pos);
2559 } else if (os_strcmp(buf, "model_description") == 0) {
2560 os_free(bss->model_description);
2561 bss->model_description = os_strdup(pos);
2562 } else if (os_strcmp(buf, "model_url") == 0) {
2563 os_free(bss->model_url);
2564 bss->model_url = os_strdup(pos);
2565 } else if (os_strcmp(buf, "upc") == 0) {
2567 bss->upc = os_strdup(pos);
2568 } else if (os_strcmp(buf, "pbc_in_m1") == 0) {
2569 bss->pbc_in_m1 = atoi(pos);
2570 } else if (os_strcmp(buf, "server_id") == 0) {
2571 os_free(bss->server_id);
2572 bss->server_id = os_strdup(pos);
2573 #ifdef CONFIG_WPS_NFC
2574 } else if (os_strcmp(buf, "wps_nfc_dev_pw_id") == 0) {
2575 bss->wps_nfc_dev_pw_id = atoi(pos);
2576 if (bss->wps_nfc_dev_pw_id < 0x10 ||
2577 bss->wps_nfc_dev_pw_id > 0xffff) {
2578 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2579 "wps_nfc_dev_pw_id value", line);
2582 bss->wps_nfc_pw_from_config = 1;
2583 } else if (os_strcmp(buf, "wps_nfc_dh_pubkey") == 0) {
2584 wpabuf_free(bss->wps_nfc_dh_pubkey);
2585 bss->wps_nfc_dh_pubkey = hostapd_parse_bin(pos);
2586 bss->wps_nfc_pw_from_config = 1;
2587 } else if (os_strcmp(buf, "wps_nfc_dh_privkey") == 0) {
2588 wpabuf_free(bss->wps_nfc_dh_privkey);
2589 bss->wps_nfc_dh_privkey = hostapd_parse_bin(pos);
2590 bss->wps_nfc_pw_from_config = 1;
2591 } else if (os_strcmp(buf, "wps_nfc_dev_pw") == 0) {
2592 wpabuf_free(bss->wps_nfc_dev_pw);
2593 bss->wps_nfc_dev_pw = hostapd_parse_bin(pos);
2594 bss->wps_nfc_pw_from_config = 1;
2595 #endif /* CONFIG_WPS_NFC */
2596 #endif /* CONFIG_WPS */
2597 #ifdef CONFIG_P2P_MANAGER
2598 } else if (os_strcmp(buf, "manage_p2p") == 0) {
2599 int manage = atoi(pos);
2601 bss->p2p |= P2P_MANAGE;
2603 bss->p2p &= ~P2P_MANAGE;
2604 } else if (os_strcmp(buf, "allow_cross_connection") == 0) {
2606 bss->p2p |= P2P_ALLOW_CROSS_CONNECTION;
2608 bss->p2p &= ~P2P_ALLOW_CROSS_CONNECTION;
2609 #endif /* CONFIG_P2P_MANAGER */
2610 } else if (os_strcmp(buf, "disassoc_low_ack") == 0) {
2611 bss->disassoc_low_ack = atoi(pos);
2612 } else if (os_strcmp(buf, "tdls_prohibit") == 0) {
2613 int val = atoi(pos);
2615 bss->tdls |= TDLS_PROHIBIT;
2617 bss->tdls &= ~TDLS_PROHIBIT;
2618 } else if (os_strcmp(buf, "tdls_prohibit_chan_switch") == 0) {
2619 int val = atoi(pos);
2621 bss->tdls |= TDLS_PROHIBIT_CHAN_SWITCH;
2623 bss->tdls &= ~TDLS_PROHIBIT_CHAN_SWITCH;
2624 #ifdef CONFIG_RSN_TESTING
2625 } else if (os_strcmp(buf, "rsn_testing") == 0) {
2626 extern int rsn_testing;
2627 rsn_testing = atoi(pos);
2628 #endif /* CONFIG_RSN_TESTING */
2629 } else if (os_strcmp(buf, "time_advertisement") == 0) {
2630 bss->time_advertisement = atoi(pos);
2631 } else if (os_strcmp(buf, "time_zone") == 0) {
2632 size_t tz_len = os_strlen(pos);
2633 if (tz_len < 4 || tz_len > 255) {
2634 wpa_printf(MSG_DEBUG, "Line %d: invalid "
2639 os_free(bss->time_zone);
2640 bss->time_zone = os_strdup(pos);
2641 if (bss->time_zone == NULL)
2644 } else if (os_strcmp(buf, "wnm_sleep_mode") == 0) {
2645 bss->wnm_sleep_mode = atoi(pos);
2646 } else if (os_strcmp(buf, "bss_transition") == 0) {
2647 bss->bss_transition = atoi(pos);
2648 #endif /* CONFIG_WNM */
2649 #ifdef CONFIG_INTERWORKING
2650 } else if (os_strcmp(buf, "interworking") == 0) {
2651 bss->interworking = atoi(pos);
2652 } else if (os_strcmp(buf, "access_network_type") == 0) {
2653 bss->access_network_type = atoi(pos);
2654 if (bss->access_network_type < 0 ||
2655 bss->access_network_type > 15) {
2656 wpa_printf(MSG_ERROR, "Line %d: invalid "
2657 "access_network_type", line);
2660 } else if (os_strcmp(buf, "internet") == 0) {
2661 bss->internet = atoi(pos);
2662 } else if (os_strcmp(buf, "asra") == 0) {
2663 bss->asra = atoi(pos);
2664 } else if (os_strcmp(buf, "esr") == 0) {
2665 bss->esr = atoi(pos);
2666 } else if (os_strcmp(buf, "uesa") == 0) {
2667 bss->uesa = atoi(pos);
2668 } else if (os_strcmp(buf, "venue_group") == 0) {
2669 bss->venue_group = atoi(pos);
2670 bss->venue_info_set = 1;
2671 } else if (os_strcmp(buf, "venue_type") == 0) {
2672 bss->venue_type = atoi(pos);
2673 bss->venue_info_set = 1;
2674 } else if (os_strcmp(buf, "hessid") == 0) {
2675 if (hwaddr_aton(pos, bss->hessid)) {
2676 wpa_printf(MSG_ERROR, "Line %d: invalid "
2680 } else if (os_strcmp(buf, "roaming_consortium") == 0) {
2681 if (parse_roaming_consortium(bss, pos, line) < 0)
2683 } else if (os_strcmp(buf, "venue_name") == 0) {
2684 if (parse_venue_name(bss, pos, line) < 0)
2686 } else if (os_strcmp(buf, "network_auth_type") == 0) {
2688 u16 redirect_url_len;
2689 if (hexstr2bin(pos, &auth_type, 1)) {
2690 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2691 "network_auth_type '%s'",
2696 if (auth_type == 0 || auth_type == 2)
2697 redirect_url_len = os_strlen(pos + 2);
2699 redirect_url_len = 0;
2700 os_free(bss->network_auth_type);
2701 bss->network_auth_type =
2702 os_malloc(redirect_url_len + 3 + 1);
2703 if (bss->network_auth_type == NULL) {
2707 *bss->network_auth_type = auth_type;
2708 WPA_PUT_LE16(bss->network_auth_type + 1,
2710 if (redirect_url_len)
2711 os_memcpy(bss->network_auth_type + 3,
2712 pos + 2, redirect_url_len);
2713 bss->network_auth_type_len = 3 + redirect_url_len;
2714 } else if (os_strcmp(buf, "ipaddr_type_availability") == 0) {
2715 if (hexstr2bin(pos, &bss->ipaddr_type_availability, 1))
2717 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2718 "ipaddr_type_availability '%s'",
2720 bss->ipaddr_type_configured = 0;
2724 bss->ipaddr_type_configured = 1;
2725 } else if (os_strcmp(buf, "domain_name") == 0) {
2726 int j, num_domains, domain_len, domain_list_len = 0;
2727 char *tok_start, *tok_prev;
2728 u8 *domain_list, *domain_ptr;
2730 domain_list_len = os_strlen(pos) + 1;
2731 domain_list = os_malloc(domain_list_len);
2732 if (domain_list == NULL) {
2737 domain_ptr = domain_list;
2740 while ((tok_prev = os_strchr(tok_prev, ','))) {
2745 for (j = 0; j < num_domains; j++) {
2746 tok_start = os_strchr(tok_prev, ',');
2748 domain_len = tok_start - tok_prev;
2749 *domain_ptr = domain_len;
2750 os_memcpy(domain_ptr + 1, tok_prev,
2752 domain_ptr += domain_len + 1;
2753 tok_prev = ++tok_start;
2755 domain_len = os_strlen(tok_prev);
2756 *domain_ptr = domain_len;
2757 os_memcpy(domain_ptr + 1, tok_prev,
2759 domain_ptr += domain_len + 1;
2763 os_free(bss->domain_name);
2764 bss->domain_name = domain_list;
2765 bss->domain_name_len = domain_list_len;
2766 } else if (os_strcmp(buf, "anqp_3gpp_cell_net") == 0) {
2767 if (parse_3gpp_cell_net(bss, pos, line) < 0)
2769 } else if (os_strcmp(buf, "nai_realm") == 0) {
2770 if (parse_nai_realm(bss, pos, line) < 0)
2772 } else if (os_strcmp(buf, "gas_frag_limit") == 0) {
2773 bss->gas_frag_limit = atoi(pos);
2774 } else if (os_strcmp(buf, "gas_comeback_delay") == 0) {
2775 bss->gas_comeback_delay = atoi(pos);
2776 } else if (os_strcmp(buf, "qos_map_set") == 0) {
2777 if (parse_qos_map_set(bss, pos, line) < 0)
2779 #endif /* CONFIG_INTERWORKING */
2780 #ifdef CONFIG_RADIUS_TEST
2781 } else if (os_strcmp(buf, "dump_msk_file") == 0) {
2782 os_free(bss->dump_msk_file);
2783 bss->dump_msk_file = os_strdup(pos);
2784 #endif /* CONFIG_RADIUS_TEST */
2786 } else if (os_strcmp(buf, "hs20") == 0) {
2787 bss->hs20 = atoi(pos);
2788 } else if (os_strcmp(buf, "disable_dgaf") == 0) {
2789 bss->disable_dgaf = atoi(pos);
2790 } else if (os_strcmp(buf, "hs20_oper_friendly_name") == 0) {
2791 if (hs20_parse_oper_friendly_name(bss, pos, line) < 0)
2793 } else if (os_strcmp(buf, "hs20_wan_metrics") == 0) {
2794 if (hs20_parse_wan_metrics(bss, pos, line) < 0) {
2798 } else if (os_strcmp(buf, "hs20_conn_capab") == 0) {
2799 if (hs20_parse_conn_capab(bss, pos, line) < 0) {
2803 } else if (os_strcmp(buf, "hs20_operating_class") == 0) {
2805 size_t oper_class_len;
2806 oper_class_len = os_strlen(pos);
2807 if (oper_class_len < 2 || (oper_class_len & 0x01)) {
2808 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2809 "hs20_operating_class '%s'",
2814 oper_class_len /= 2;
2815 oper_class = os_malloc(oper_class_len);
2816 if (oper_class == NULL) {
2820 if (hexstr2bin(pos, oper_class, oper_class_len)) {
2821 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2822 "hs20_operating_class '%s'",
2824 os_free(oper_class);
2828 os_free(bss->hs20_operating_class);
2829 bss->hs20_operating_class = oper_class;
2830 bss->hs20_operating_class_len = oper_class_len;
2831 #endif /* CONFIG_HS20 */
2832 #ifdef CONFIG_TESTING_OPTIONS
2833 #define PARSE_TEST_PROBABILITY(_val) \
2834 } else if (os_strcmp(buf, #_val) == 0) { \
2837 conf->_val = strtod(pos, &end); \
2838 if (*end || conf->_val < 0.0d || \
2839 conf->_val > 1.0d) { \
2840 wpa_printf(MSG_ERROR, \
2841 "Line %d: Invalid value '%s'", \
2846 PARSE_TEST_PROBABILITY(ignore_probe_probability)
2847 PARSE_TEST_PROBABILITY(ignore_auth_probability)
2848 PARSE_TEST_PROBABILITY(ignore_assoc_probability)
2849 PARSE_TEST_PROBABILITY(ignore_reassoc_probability)
2850 PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability)
2851 } else if (os_strcmp(buf, "bss_load_test") == 0) {
2852 WPA_PUT_LE16(bss->bss_load_test, atoi(pos));
2853 pos = os_strchr(pos, ':');
2855 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2856 "bss_load_test", line);
2860 bss->bss_load_test[2] = atoi(pos);
2861 pos = os_strchr(pos, ':');
2863 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2864 "bss_load_test", line);
2868 WPA_PUT_LE16(&bss->bss_load_test[3], atoi(pos));
2869 bss->bss_load_test_set = 1;
2870 #endif /* CONFIG_TESTING_OPTIONS */
2871 } else if (os_strcmp(buf, "vendor_elements") == 0) {
2872 struct wpabuf *elems;
2873 size_t len = os_strlen(pos);
2875 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2876 "vendor_elements '%s'", line, pos);
2881 wpabuf_free(bss->vendor_elements);
2882 bss->vendor_elements = NULL;
2886 elems = wpabuf_alloc(len);
2890 if (hexstr2bin(pos, wpabuf_put(elems, len), len)) {
2892 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2893 "vendor_elements '%s'", line, pos);
2897 wpabuf_free(bss->vendor_elements);
2898 bss->vendor_elements = elems;
2899 } else if (os_strcmp(buf, "sae_anti_clogging_threshold") == 0) {
2900 bss->sae_anti_clogging_threshold = atoi(pos);
2901 } else if (os_strcmp(buf, "sae_groups") == 0) {
2902 if (hostapd_parse_intlist(&bss->sae_groups, pos)) {
2903 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2904 "sae_groups value '%s'", line, pos);
2908 wpa_printf(MSG_ERROR, "Line %d: unknown configuration "
2909 "item '%s'", line, buf);
2919 * hostapd_config_read - Read and parse a configuration file
2920 * @fname: Configuration file name (including path, if needed)
2921 * Returns: Allocated configuration data structure
2923 struct hostapd_config * hostapd_config_read(const char *fname)
2925 struct hostapd_config *conf;
2926 struct hostapd_bss_config *bss;
2928 char buf[512], *pos;
2933 f = fopen(fname, "r");
2935 wpa_printf(MSG_ERROR, "Could not open configuration file '%s' "
2936 "for reading.", fname);
2940 conf = hostapd_config_defaults();
2946 /* set default driver based on configuration */
2947 conf->driver = wpa_drivers[0];
2948 if (conf->driver == NULL) {
2949 wpa_printf(MSG_ERROR, "No driver wrappers registered!");
2950 hostapd_config_free(conf);
2955 bss = conf->last_bss = conf->bss[0];
2957 while (fgets(buf, sizeof(buf), f)) {
2958 bss = conf->last_bss;
2964 while (*pos != '\0') {
2974 pos = os_strchr(buf, '=');
2976 wpa_printf(MSG_ERROR, "Line %d: invalid line '%s'",
2983 errors += hostapd_config_fill(conf, bss, buf, pos, line);
2988 for (i = 0; i < conf->num_bss; i++)
2989 hostapd_set_security_params(conf->bss[i]);
2991 if (hostapd_config_check(conf))
2994 #ifndef WPA_IGNORE_CONFIG_ERRORS
2996 wpa_printf(MSG_ERROR, "%d errors found in configuration file "
2997 "'%s'", errors, fname);
2998 hostapd_config_free(conf);
3001 #endif /* WPA_IGNORE_CONFIG_ERRORS */
3007 int hostapd_set_iface(struct hostapd_config *conf,
3008 struct hostapd_bss_config *bss, char *field, char *value)
3013 errors = hostapd_config_fill(conf, bss, field, value, 0);
3015 wpa_printf(MSG_INFO, "Failed to set configuration field '%s' "
3016 "to value '%s'", field, value);
3020 for (i = 0; i < conf->num_bss; i++)
3021 hostapd_set_security_params(conf->bss[i]);
3023 if (hostapd_config_check(conf)) {
3024 wpa_printf(MSG_ERROR, "Configuration check failed");