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_malloc(sizeof(*vlan));
88 wpa_printf(MSG_ERROR, "Out of memory while reading "
89 "VLAN interfaces from '%s'", fname);
94 os_memset(vlan, 0, sizeof(*vlan));
95 vlan->vlan_id = vlan_id;
96 os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname));
98 bss->vlan_tail->next = vlan;
101 bss->vlan_tail = vlan;
108 #endif /* CONFIG_NO_VLAN */
111 static int hostapd_acl_comp(const void *a, const void *b)
113 const struct mac_acl_entry *aa = a;
114 const struct mac_acl_entry *bb = b;
115 return os_memcmp(aa->addr, bb->addr, sizeof(macaddr));
119 static int hostapd_config_read_maclist(const char *fname,
120 struct mac_acl_entry **acl, int *num)
126 struct mac_acl_entry *newacl;
132 f = fopen(fname, "r");
134 wpa_printf(MSG_ERROR, "MAC list file '%s' not found.", fname);
138 while (fgets(buf, sizeof(buf), f)) {
144 while (*pos != '\0') {
154 if (hwaddr_aton(buf, addr)) {
155 wpa_printf(MSG_ERROR, "Invalid MAC address '%s' at "
156 "line %d in '%s'", buf, line, fname);
163 while (*pos != '\0' && *pos != ' ' && *pos != '\t')
165 while (*pos == ' ' || *pos == '\t')
170 newacl = os_realloc_array(*acl, *num + 1, sizeof(**acl));
171 if (newacl == NULL) {
172 wpa_printf(MSG_ERROR, "MAC list reallocation failed");
178 os_memcpy((*acl)[*num].addr, addr, ETH_ALEN);
179 (*acl)[*num].vlan_id = vlan_id;
185 qsort(*acl, *num, sizeof(**acl), hostapd_acl_comp);
192 static int hostapd_config_read_eap_user(const char *fname,
193 struct hostapd_bss_config *conf)
196 char buf[512], *pos, *start, *pos2;
197 int line = 0, ret = 0, num_methods;
198 struct hostapd_eap_user *user, *tail = NULL;
203 if (os_strncmp(fname, "sqlite:", 7) == 0) {
204 os_free(conf->eap_user_sqlite);
205 conf->eap_user_sqlite = os_strdup(fname + 7);
209 f = fopen(fname, "r");
211 wpa_printf(MSG_ERROR, "EAP user file '%s' not found.", fname);
215 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
216 while (fgets(buf, sizeof(buf), f)) {
222 while (*pos != '\0') {
234 if (buf[0] != '"' && buf[0] != '*') {
235 wpa_printf(MSG_ERROR, "Invalid EAP identity (no \" in "
236 "start) on line %d in '%s'", line, fname);
240 user = os_zalloc(sizeof(*user));
242 wpa_printf(MSG_ERROR, "EAP user allocation failed");
245 user->force_version = -1;
252 while (*pos != '"' && *pos != '\0')
255 wpa_printf(MSG_ERROR, "Invalid EAP identity "
256 "(no \" in end) on line %d in '%s'",
261 user->identity = os_malloc(pos - start);
262 if (user->identity == NULL) {
263 wpa_printf(MSG_ERROR, "Failed to allocate "
264 "memory for EAP identity");
267 os_memcpy(user->identity, start, pos - start);
268 user->identity_len = pos - start;
270 if (pos[0] == '"' && pos[1] == '*') {
271 user->wildcard_prefix = 1;
276 while (*pos == ' ' || *pos == '\t')
280 wpa_printf(MSG_ERROR, "No EAP method on line %d in "
281 "'%s'", line, fname);
286 while (*pos != ' ' && *pos != '\t' && *pos != '\0')
296 char *pos3 = os_strchr(start, ',');
300 user->methods[num_methods].method =
303 &user->methods[num_methods].vendor);
304 if (user->methods[num_methods].vendor ==
306 user->methods[num_methods].method == EAP_TYPE_NONE)
308 if (os_strcmp(start, "TTLS-PAP") == 0) {
309 user->ttls_auth |= EAP_TTLS_AUTH_PAP;
312 if (os_strcmp(start, "TTLS-CHAP") == 0) {
313 user->ttls_auth |= EAP_TTLS_AUTH_CHAP;
316 if (os_strcmp(start, "TTLS-MSCHAP") == 0) {
318 EAP_TTLS_AUTH_MSCHAP;
321 if (os_strcmp(start, "TTLS-MSCHAPV2") == 0) {
323 EAP_TTLS_AUTH_MSCHAPV2;
326 wpa_printf(MSG_ERROR, "Unsupported EAP type "
327 "'%s' on line %d in '%s'",
333 if (num_methods >= EAP_MAX_METHODS)
340 if (num_methods == 0 && user->ttls_auth == 0) {
341 wpa_printf(MSG_ERROR, "No EAP types configured on "
342 "line %d in '%s'", line, fname);
349 while (*pos == ' ' || *pos == '\t')
354 if (os_strncmp(pos, "[ver=0]", 7) == 0) {
355 user->force_version = 0;
359 if (os_strncmp(pos, "[ver=1]", 7) == 0) {
360 user->force_version = 1;
364 if (os_strncmp(pos, "[2]", 3) == 0) {
372 while (*pos != '"' && *pos != '\0')
375 wpa_printf(MSG_ERROR, "Invalid EAP password "
376 "(no \" in end) on line %d in '%s'",
381 user->password = os_malloc(pos - start);
382 if (user->password == NULL) {
383 wpa_printf(MSG_ERROR, "Failed to allocate "
384 "memory for EAP password");
387 os_memcpy(user->password, start, pos - start);
388 user->password_len = pos - start;
391 } else if (os_strncmp(pos, "hash:", 5) == 0) {
394 while (*pos2 != '\0' && *pos2 != ' ' &&
395 *pos2 != '\t' && *pos2 != '#')
397 if (pos2 - pos != 32) {
398 wpa_printf(MSG_ERROR, "Invalid password hash "
399 "on line %d in '%s'", line, fname);
402 user->password = os_malloc(16);
403 if (user->password == NULL) {
404 wpa_printf(MSG_ERROR, "Failed to allocate "
405 "memory for EAP password hash");
408 if (hexstr2bin(pos, user->password, 16) < 0) {
409 wpa_printf(MSG_ERROR, "Invalid hash password "
410 "on line %d in '%s'", line, fname);
413 user->password_len = 16;
414 user->password_hash = 1;
418 while (*pos2 != '\0' && *pos2 != ' ' &&
419 *pos2 != '\t' && *pos2 != '#')
421 if ((pos2 - pos) & 1) {
422 wpa_printf(MSG_ERROR, "Invalid hex password "
423 "on line %d in '%s'", line, fname);
426 user->password = os_malloc((pos2 - pos) / 2);
427 if (user->password == NULL) {
428 wpa_printf(MSG_ERROR, "Failed to allocate "
429 "memory for EAP password");
432 if (hexstr2bin(pos, user->password,
433 (pos2 - pos) / 2) < 0) {
434 wpa_printf(MSG_ERROR, "Invalid hex password "
435 "on line %d in '%s'", line, fname);
438 user->password_len = (pos2 - pos) / 2;
442 while (*pos == ' ' || *pos == '\t')
444 if (os_strncmp(pos, "[2]", 3) == 0) {
450 tail = conf->eap_user = user;
459 os_free(user->password);
460 os_free(user->identity);
471 #endif /* EAP_SERVER */
474 #ifndef CONFIG_NO_RADIUS
476 hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
477 int *num_server, const char *val, int def_port,
478 struct hostapd_radius_server **curr_serv)
480 struct hostapd_radius_server *nserv;
482 static int server_index = 1;
484 nserv = os_realloc_array(*server, *num_server + 1, sizeof(*nserv));
489 nserv = &nserv[*num_server];
491 (*curr_serv) = nserv;
493 os_memset(nserv, 0, sizeof(*nserv));
494 nserv->port = def_port;
495 ret = hostapd_parse_ip_addr(val, &nserv->addr);
496 nserv->index = server_index++;
502 static struct hostapd_radius_attr *
503 hostapd_parse_radius_attr(const char *value)
507 struct hostapd_radius_attr *attr;
510 attr = os_zalloc(sizeof(*attr));
514 attr->type = atoi(value);
516 pos = os_strchr(value, ':');
518 attr->val = wpabuf_alloc(1);
519 if (attr->val == NULL) {
523 wpabuf_put_u8(attr->val, 0);
528 if (pos[0] == '\0' || pos[1] != ':') {
537 attr->val = wpabuf_alloc_copy(pos, os_strlen(pos));
540 len = os_strlen(pos);
544 attr->val = wpabuf_alloc(len);
545 if (attr->val == NULL)
547 if (hexstr2bin(pos, wpabuf_put(attr->val, len), len) < 0) {
548 wpabuf_free(attr->val);
554 attr->val = wpabuf_alloc(4);
556 wpabuf_put_be32(attr->val, atoi(pos));
563 if (attr->val == NULL) {
572 static int hostapd_parse_das_client(struct hostapd_bss_config *bss,
577 secret = os_strchr(val, ' ');
583 if (hostapd_parse_ip_addr(val, &bss->radius_das_client_addr))
586 os_free(bss->radius_das_shared_secret);
587 bss->radius_das_shared_secret = (u8 *) os_strdup(secret);
588 if (bss->radius_das_shared_secret == NULL)
590 bss->radius_das_shared_secret_len = os_strlen(secret);
594 #endif /* CONFIG_NO_RADIUS */
597 static int hostapd_config_parse_key_mgmt(int line, const char *value)
600 char *start, *end, *buf;
602 buf = os_strdup(value);
607 while (*start != '\0') {
608 while (*start == ' ' || *start == '\t')
613 while (*end != ' ' && *end != '\t' && *end != '\0')
617 if (os_strcmp(start, "WPA-PSK") == 0)
618 val |= WPA_KEY_MGMT_PSK;
619 else if (os_strcmp(start, "WPA-EAP") == 0)
620 val |= WPA_KEY_MGMT_IEEE8021X;
621 #ifdef CONFIG_IEEE80211R
622 else if (os_strcmp(start, "FT-PSK") == 0)
623 val |= WPA_KEY_MGMT_FT_PSK;
624 else if (os_strcmp(start, "FT-EAP") == 0)
625 val |= WPA_KEY_MGMT_FT_IEEE8021X;
626 #endif /* CONFIG_IEEE80211R */
627 #ifdef CONFIG_IEEE80211W
628 else if (os_strcmp(start, "WPA-PSK-SHA256") == 0)
629 val |= WPA_KEY_MGMT_PSK_SHA256;
630 else if (os_strcmp(start, "WPA-EAP-SHA256") == 0)
631 val |= WPA_KEY_MGMT_IEEE8021X_SHA256;
632 #endif /* CONFIG_IEEE80211W */
634 else if (os_strcmp(start, "SAE") == 0)
635 val |= WPA_KEY_MGMT_SAE;
636 else if (os_strcmp(start, "FT-SAE") == 0)
637 val |= WPA_KEY_MGMT_FT_SAE;
638 #endif /* CONFIG_SAE */
640 wpa_printf(MSG_ERROR, "Line %d: invalid key_mgmt '%s'",
653 wpa_printf(MSG_ERROR, "Line %d: no key_mgmt values "
654 "configured.", line);
662 static int hostapd_config_parse_cipher(int line, const char *value)
664 int val = wpa_parse_cipher(value);
666 wpa_printf(MSG_ERROR, "Line %d: invalid cipher '%s'.",
671 wpa_printf(MSG_ERROR, "Line %d: no cipher values configured.",
679 static int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx,
682 size_t len = os_strlen(val);
684 if (keyidx < 0 || keyidx > 3 || wep->key[keyidx] != NULL)
688 if (len < 2 || val[len - 1] != '"')
691 wep->key[keyidx] = os_malloc(len);
692 if (wep->key[keyidx] == NULL)
694 os_memcpy(wep->key[keyidx], val + 1, len);
695 wep->len[keyidx] = len;
700 wep->key[keyidx] = os_malloc(len);
701 if (wep->key[keyidx] == NULL)
703 wep->len[keyidx] = len;
704 if (hexstr2bin(val, wep->key[keyidx], len) < 0)
714 static int hostapd_parse_rates(int **rate_list, char *val)
725 while (*pos != '\0') {
731 list = os_malloc(sizeof(int) * (count + 2));
736 while (*pos != '\0') {
737 end = os_strchr(pos, ' ');
741 list[count++] = atoi(pos);
753 static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
755 struct hostapd_bss_config *bss;
760 bss = os_realloc_array(conf->bss, conf->num_bss + 1,
761 sizeof(struct hostapd_bss_config));
763 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
769 bss = &(conf->bss[conf->num_bss]);
770 os_memset(bss, 0, sizeof(*bss));
771 bss->radius = os_zalloc(sizeof(*bss->radius));
772 if (bss->radius == NULL) {
773 wpa_printf(MSG_ERROR, "Failed to allocate memory for "
774 "multi-BSS RADIUS data");
779 conf->last_bss = bss;
781 hostapd_config_defaults_bss(bss);
782 os_strlcpy(bss->iface, ifname, sizeof(bss->iface));
783 os_memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1);
789 /* convert floats with one decimal place to value*10 int, i.e.,
790 * "1.5" will return 15 */
791 static int hostapd_config_read_int10(const char *value)
797 pos = os_strchr(value, '.');
801 if (*pos >= '0' && *pos <= '9')
809 static int valid_cw(int cw)
811 return (cw == 1 || cw == 3 || cw == 7 || cw == 15 || cw == 31 ||
812 cw == 63 || cw == 127 || cw == 255 || cw == 511 || cw == 1023);
817 IEEE80211_TX_QUEUE_DATA0 = 0, /* used for EDCA AC_VO data */
818 IEEE80211_TX_QUEUE_DATA1 = 1, /* used for EDCA AC_VI data */
819 IEEE80211_TX_QUEUE_DATA2 = 2, /* used for EDCA AC_BE data */
820 IEEE80211_TX_QUEUE_DATA3 = 3 /* used for EDCA AC_BK data */
823 static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
828 struct hostapd_tx_queue_params *queue;
830 /* skip 'tx_queue_' prefix */
832 if (os_strncmp(pos, "data", 4) == 0 &&
833 pos[4] >= '0' && pos[4] <= '9' && pos[5] == '_') {
836 } else if (os_strncmp(pos, "after_beacon_", 13) == 0 ||
837 os_strncmp(pos, "beacon_", 7) == 0) {
838 wpa_printf(MSG_INFO, "DEPRECATED: '%s' not used", name);
841 wpa_printf(MSG_ERROR, "Unknown tx_queue name '%s'", pos);
845 if (num >= NUM_TX_QUEUES) {
846 /* for backwards compatibility, do not trigger failure */
847 wpa_printf(MSG_INFO, "DEPRECATED: '%s' not used", name);
851 queue = &conf->tx_queue[num];
853 if (os_strcmp(pos, "aifs") == 0) {
854 queue->aifs = atoi(val);
855 if (queue->aifs < 0 || queue->aifs > 255) {
856 wpa_printf(MSG_ERROR, "Invalid AIFS value %d",
860 } else if (os_strcmp(pos, "cwmin") == 0) {
861 queue->cwmin = atoi(val);
862 if (!valid_cw(queue->cwmin)) {
863 wpa_printf(MSG_ERROR, "Invalid cwMin value %d",
867 } else if (os_strcmp(pos, "cwmax") == 0) {
868 queue->cwmax = atoi(val);
869 if (!valid_cw(queue->cwmax)) {
870 wpa_printf(MSG_ERROR, "Invalid cwMax value %d",
874 } else if (os_strcmp(pos, "burst") == 0) {
875 queue->burst = hostapd_config_read_int10(val);
877 wpa_printf(MSG_ERROR, "Unknown tx_queue field '%s'", pos);
885 #ifdef CONFIG_IEEE80211R
886 static int add_r0kh(struct hostapd_bss_config *bss, char *value)
888 struct ft_remote_r0kh *r0kh;
891 r0kh = os_zalloc(sizeof(*r0kh));
895 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
897 next = os_strchr(pos, ' ');
900 if (next == NULL || hwaddr_aton(pos, r0kh->addr)) {
901 wpa_printf(MSG_ERROR, "Invalid R0KH MAC address: '%s'", pos);
907 next = os_strchr(pos, ' ');
910 if (next == NULL || next - pos > FT_R0KH_ID_MAX_LEN) {
911 wpa_printf(MSG_ERROR, "Invalid R0KH-ID: '%s'", pos);
915 r0kh->id_len = next - pos - 1;
916 os_memcpy(r0kh->id, pos, r0kh->id_len);
919 if (hexstr2bin(pos, r0kh->key, sizeof(r0kh->key))) {
920 wpa_printf(MSG_ERROR, "Invalid R0KH key: '%s'", pos);
925 r0kh->next = bss->r0kh_list;
926 bss->r0kh_list = r0kh;
932 static int add_r1kh(struct hostapd_bss_config *bss, char *value)
934 struct ft_remote_r1kh *r1kh;
937 r1kh = os_zalloc(sizeof(*r1kh));
941 /* 02:01:02:03:04:05 02:01:02:03:04:05
942 * 000102030405060708090a0b0c0d0e0f */
944 next = os_strchr(pos, ' ');
947 if (next == NULL || hwaddr_aton(pos, r1kh->addr)) {
948 wpa_printf(MSG_ERROR, "Invalid R1KH MAC address: '%s'", pos);
954 next = os_strchr(pos, ' ');
957 if (next == NULL || hwaddr_aton(pos, r1kh->id)) {
958 wpa_printf(MSG_ERROR, "Invalid R1KH-ID: '%s'", pos);
964 if (hexstr2bin(pos, r1kh->key, sizeof(r1kh->key))) {
965 wpa_printf(MSG_ERROR, "Invalid R1KH key: '%s'", pos);
970 r1kh->next = bss->r1kh_list;
971 bss->r1kh_list = r1kh;
975 #endif /* CONFIG_IEEE80211R */
978 #ifdef CONFIG_IEEE80211N
979 static int hostapd_config_ht_capab(struct hostapd_config *conf,
982 if (os_strstr(capab, "[LDPC]"))
983 conf->ht_capab |= HT_CAP_INFO_LDPC_CODING_CAP;
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, "[HT40+]")) {
989 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
990 conf->secondary_channel = 1;
992 if (os_strstr(capab, "[SMPS-STATIC]")) {
993 conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
994 conf->ht_capab |= HT_CAP_INFO_SMPS_STATIC;
996 if (os_strstr(capab, "[SMPS-DYNAMIC]")) {
997 conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
998 conf->ht_capab |= HT_CAP_INFO_SMPS_DYNAMIC;
1000 if (os_strstr(capab, "[GF]"))
1001 conf->ht_capab |= HT_CAP_INFO_GREEN_FIELD;
1002 if (os_strstr(capab, "[SHORT-GI-20]"))
1003 conf->ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ;
1004 if (os_strstr(capab, "[SHORT-GI-40]"))
1005 conf->ht_capab |= HT_CAP_INFO_SHORT_GI40MHZ;
1006 if (os_strstr(capab, "[TX-STBC]"))
1007 conf->ht_capab |= HT_CAP_INFO_TX_STBC;
1008 if (os_strstr(capab, "[RX-STBC1]")) {
1009 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1010 conf->ht_capab |= HT_CAP_INFO_RX_STBC_1;
1012 if (os_strstr(capab, "[RX-STBC12]")) {
1013 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1014 conf->ht_capab |= HT_CAP_INFO_RX_STBC_12;
1016 if (os_strstr(capab, "[RX-STBC123]")) {
1017 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1018 conf->ht_capab |= HT_CAP_INFO_RX_STBC_123;
1020 if (os_strstr(capab, "[DELAYED-BA]"))
1021 conf->ht_capab |= HT_CAP_INFO_DELAYED_BA;
1022 if (os_strstr(capab, "[MAX-AMSDU-7935]"))
1023 conf->ht_capab |= HT_CAP_INFO_MAX_AMSDU_SIZE;
1024 if (os_strstr(capab, "[DSSS_CCK-40]"))
1025 conf->ht_capab |= HT_CAP_INFO_DSSS_CCK40MHZ;
1026 if (os_strstr(capab, "[PSMP]"))
1027 conf->ht_capab |= HT_CAP_INFO_PSMP_SUPP;
1028 if (os_strstr(capab, "[LSIG-TXOP-PROT]"))
1029 conf->ht_capab |= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT;
1033 #endif /* CONFIG_IEEE80211N */
1036 #ifdef CONFIG_IEEE80211AC
1037 static int hostapd_config_vht_capab(struct hostapd_config *conf,
1040 if (os_strstr(capab, "[MAX-MPDU-7991]"))
1041 conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_7991;
1042 if (os_strstr(capab, "[MAX-MPDU-11454]"))
1043 conf->vht_capab |= VHT_CAP_MAX_MPDU_LENGTH_11454;
1044 if (os_strstr(capab, "[VHT160]"))
1045 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
1046 if (os_strstr(capab, "[VHT160-80PLUS80]"))
1047 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
1048 if (os_strstr(capab, "[VHT160-80PLUS80]"))
1049 conf->vht_capab |= VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
1050 if (os_strstr(capab, "[RXLDPC]"))
1051 conf->vht_capab |= VHT_CAP_RXLDPC;
1052 if (os_strstr(capab, "[SHORT-GI-80]"))
1053 conf->vht_capab |= VHT_CAP_SHORT_GI_80;
1054 if (os_strstr(capab, "[SHORT-GI-160]"))
1055 conf->vht_capab |= VHT_CAP_SHORT_GI_160;
1056 if (os_strstr(capab, "[TX-STBC-2BY1]"))
1057 conf->vht_capab |= VHT_CAP_TXSTBC;
1058 if (os_strstr(capab, "[RX-STBC-1]"))
1059 conf->vht_capab |= VHT_CAP_RXSTBC_1;
1060 if (os_strstr(capab, "[RX-STBC-12]"))
1061 conf->vht_capab |= VHT_CAP_RXSTBC_2;
1062 if (os_strstr(capab, "[RX-STBC-123]"))
1063 conf->vht_capab |= VHT_CAP_RXSTBC_3;
1064 if (os_strstr(capab, "[RX-STBC-1234]"))
1065 conf->vht_capab |= VHT_CAP_RXSTBC_4;
1066 if (os_strstr(capab, "[SU-BEAMFORMER]"))
1067 conf->vht_capab |= VHT_CAP_MU_BEAMFORMER_CAPABLE;
1068 if (os_strstr(capab, "[SU-BEAMFORMEE]"))
1069 conf->vht_capab |= VHT_CAP_MU_BEAMFORMEE_CAPABLE;
1070 if (os_strstr(capab, "[BF-ANTENNA-2]") &&
1071 (conf->vht_capab & VHT_CAP_MU_BEAMFORMER_CAPABLE))
1072 conf->vht_capab |= VHT_CAP_BEAMFORMER_ANTENNAS_MAX;
1073 if (os_strstr(capab, "[SOUNDING-DIMENSION-2]") &&
1074 (conf->vht_capab & VHT_CAP_MU_BEAMFORMER_CAPABLE))
1075 conf->vht_capab |= VHT_CAP_SOUNDING_DIMENTION_MAX;
1076 if (os_strstr(capab, "[MU-BEAMFORMER]"))
1077 conf->vht_capab |= VHT_CAP_MU_BEAMFORMER_CAPABLE;
1078 if (os_strstr(capab, "[MU-BEAMFORMEE]"))
1079 conf->vht_capab |= VHT_CAP_MU_BEAMFORMEE_CAPABLE;
1080 if (os_strstr(capab, "[VHT-TXOP-PS]"))
1081 conf->vht_capab |= VHT_CAP_VHT_TXOP_PS;
1082 if (os_strstr(capab, "[HTC-VHT]"))
1083 conf->vht_capab |= VHT_CAP_HTC_VHT;
1084 if (os_strstr(capab, "[MAX-A-MPDU-LEN-EXP0]"))
1085 conf->vht_capab |= VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT;
1086 if (os_strstr(capab, "[VHT-LINK-ADAPT2]") &&
1087 (conf->vht_capab & VHT_CAP_HTC_VHT))
1088 conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_UNSOL_MFB;
1089 if (os_strstr(capab, "[VHT-LINK-ADAPT3]") &&
1090 (conf->vht_capab & VHT_CAP_HTC_VHT))
1091 conf->vht_capab |= VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB;
1092 if (os_strstr(capab, "[RX-ANTENNA-PATTERN]"))
1093 conf->vht_capab |= VHT_CAP_RX_ANTENNA_PATTERN;
1094 if (os_strstr(capab, "[TX-ANTENNA-PATTERN]"))
1095 conf->vht_capab |= VHT_CAP_TX_ANTENNA_PATTERN;
1098 #endif /* CONFIG_IEEE80211AC */
1101 static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
1102 struct hostapd_config *conf)
1104 if (bss->ieee802_1x && !bss->eap_server &&
1105 !bss->radius->auth_servers) {
1106 wpa_printf(MSG_ERROR, "Invalid IEEE 802.1X configuration (no "
1107 "EAP authenticator configured).");
1111 if (bss->wpa && bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
1112 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
1113 wpa_printf(MSG_ERROR, "WPA-PSK using RADIUS enabled, but no "
1114 "RADIUS checking (macaddr_acl=2) enabled.");
1118 if (bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
1119 bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
1120 bss->ssid.wpa_psk_file == NULL &&
1121 (bss->wpa_psk_radius != PSK_RADIUS_REQUIRED ||
1122 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH)) {
1123 wpa_printf(MSG_ERROR, "WPA-PSK enabled, but PSK or passphrase "
1124 "is not configured.");
1128 if (hostapd_mac_comp_empty(bss->bssid) != 0) {
1131 for (i = 0; i < conf->num_bss; i++) {
1132 if ((&conf->bss[i] != bss) &&
1133 (hostapd_mac_comp(conf->bss[i].bssid,
1134 bss->bssid) == 0)) {
1135 wpa_printf(MSG_ERROR, "Duplicate BSSID " MACSTR
1136 " on interface '%s' and '%s'.",
1137 MAC2STR(bss->bssid),
1138 conf->bss[i].iface, bss->iface);
1144 #ifdef CONFIG_IEEE80211R
1145 if (wpa_key_mgmt_ft(bss->wpa_key_mgmt) &&
1146 (bss->nas_identifier == NULL ||
1147 os_strlen(bss->nas_identifier) < 1 ||
1148 os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
1149 wpa_printf(MSG_ERROR, "FT (IEEE 802.11r) requires "
1150 "nas_identifier to be configured as a 1..48 octet "
1154 #endif /* CONFIG_IEEE80211R */
1156 #ifdef CONFIG_IEEE80211N
1157 if (conf->ieee80211n && conf->hw_mode == HOSTAPD_MODE_IEEE80211B) {
1158 bss->disable_11n = 1;
1159 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) in 11b mode is not "
1160 "allowed, disabling HT capabilites");
1163 if (conf->ieee80211n &&
1164 bss->ssid.security_policy == SECURITY_STATIC_WEP) {
1165 bss->disable_11n = 1;
1166 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WEP is not "
1167 "allowed, disabling HT capabilities");
1170 if (conf->ieee80211n && bss->wpa &&
1171 !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
1172 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP))) {
1173 bss->disable_11n = 1;
1174 wpa_printf(MSG_ERROR, "HT (IEEE 802.11n) with WPA/WPA2 "
1175 "requires CCMP/GCMP to be enabled, disabling HT "
1178 #endif /* CONFIG_IEEE80211N */
1181 if (bss->wps_state && bss->ignore_broadcast_ssid) {
1182 wpa_printf(MSG_INFO, "WPS: ignore_broadcast_ssid "
1183 "configuration forced WPS to be disabled");
1187 if (bss->wps_state && bss->ssid.wep.keys_set && bss->wpa == 0) {
1188 wpa_printf(MSG_INFO, "WPS: WEP configuration forced WPS to be "
1193 if (bss->wps_state && bss->wpa &&
1195 !(bss->rsn_pairwise & WPA_CIPHER_CCMP))) {
1196 wpa_printf(MSG_INFO, "WPS: WPA/TKIP configuration without "
1197 "WPA2/CCMP forced WPS to be disabled");
1200 #endif /* CONFIG_WPS2 */
1205 !(bss->rsn_pairwise & (WPA_CIPHER_CCMP | WPA_CIPHER_GCMP)))) {
1206 wpa_printf(MSG_ERROR, "HS 2.0: WPA2-Enterprise/CCMP "
1207 "configuration is required for Hotspot 2.0 "
1211 #endif /* CONFIG_HS20 */
1217 static int hostapd_config_check(struct hostapd_config *conf)
1221 if (conf->ieee80211d && (!conf->country[0] || !conf->country[1])) {
1222 wpa_printf(MSG_ERROR, "Cannot enable IEEE 802.11d without "
1223 "setting the country_code");
1227 for (i = 0; i < conf->num_bss; i++) {
1228 if (hostapd_config_check_bss(&conf->bss[i], conf))
1236 #ifdef CONFIG_INTERWORKING
1237 static int parse_roaming_consortium(struct hostapd_bss_config *bss, char *pos,
1240 size_t len = os_strlen(pos);
1241 u8 oi[MAX_ROAMING_CONSORTIUM_LEN];
1243 struct hostapd_roaming_consortium *rc;
1245 if ((len & 1) || len < 2 * 3 || len / 2 > MAX_ROAMING_CONSORTIUM_LEN ||
1246 hexstr2bin(pos, oi, len / 2)) {
1247 wpa_printf(MSG_ERROR, "Line %d: invalid roaming_consortium "
1253 rc = os_realloc_array(bss->roaming_consortium,
1254 bss->roaming_consortium_count + 1,
1255 sizeof(struct hostapd_roaming_consortium));
1259 os_memcpy(rc[bss->roaming_consortium_count].oi, oi, len);
1260 rc[bss->roaming_consortium_count].len = len;
1262 bss->roaming_consortium = rc;
1263 bss->roaming_consortium_count++;
1269 static int parse_lang_string(struct hostapd_lang_string **array,
1270 unsigned int *count, char *pos)
1274 struct hostapd_lang_string *ls;
1276 sep = os_strchr(pos, ':');
1281 clen = os_strlen(pos);
1284 nlen = os_strlen(sep);
1288 ls = os_realloc_array(*array, *count + 1,
1289 sizeof(struct hostapd_lang_string));
1294 ls = &(*array)[*count];
1297 os_memset(ls->lang, 0, sizeof(ls->lang));
1298 os_memcpy(ls->lang, pos, clen);
1299 ls->name_len = nlen;
1300 os_memcpy(ls->name, sep, nlen);
1306 static int parse_venue_name(struct hostapd_bss_config *bss, char *pos,
1309 if (parse_lang_string(&bss->venue_name, &bss->venue_name_count, pos)) {
1310 wpa_printf(MSG_ERROR, "Line %d: Invalid venue_name '%s'",
1318 static int parse_3gpp_cell_net(struct hostapd_bss_config *bss, char *buf,
1323 u8 *info = NULL, *ipos;
1325 /* format: <MCC1,MNC1>[;<MCC2,MNC2>][;...] */
1328 for (pos = buf; *pos; pos++) {
1329 if ((*pos < '0' && *pos > '9') && *pos != ';' && *pos != ',')
1334 if (1 + count * 3 > 0x7f)
1337 info = os_zalloc(2 + 3 + count * 3);
1342 *ipos++ = 0; /* GUD - Version 1 */
1343 *ipos++ = 3 + count * 3; /* User Data Header Length (UDHL) */
1344 *ipos++ = 0; /* PLMN List IEI */
1345 /* ext(b8) | Length of PLMN List value contents(b7..1) */
1346 *ipos++ = 1 + count * 3;
1347 *ipos++ = count; /* Number of PLMNs */
1350 while (pos && *pos) {
1355 mnc = os_strchr(pos, ',');
1359 pos = os_strchr(mnc, ';');
1363 mnc_len = os_strlen(mnc);
1364 if (os_strlen(mcc) != 3 || (mnc_len != 2 && mnc_len != 3))
1367 /* BC coded MCC,MNC */
1368 /* MCC digit 2 | MCC digit 1 */
1369 *ipos++ = ((mcc[1] - '0') << 4) | (mcc[0] - '0');
1370 /* MNC digit 3 | MCC digit 3 */
1371 *ipos++ = (((mnc_len == 2) ? 0xf0 : ((mnc[2] - '0') << 4))) |
1373 /* MNC digit 2 | MNC digit 1 */
1374 *ipos++ = ((mnc[1] - '0') << 4) | (mnc[0] - '0');
1377 os_free(bss->anqp_3gpp_cell_net);
1378 bss->anqp_3gpp_cell_net = info;
1379 bss->anqp_3gpp_cell_net_len = 2 + 3 + 3 * count;
1380 wpa_hexdump(MSG_MSGDUMP, "3GPP Cellular Network information",
1381 bss->anqp_3gpp_cell_net, bss->anqp_3gpp_cell_net_len);
1386 wpa_printf(MSG_ERROR, "Line %d: Invalid anqp_3gpp_cell_net: %s",
1393 static int parse_nai_realm(struct hostapd_bss_config *bss, char *buf, int line)
1395 struct hostapd_nai_realm_data *realm;
1398 char *pos, *end, *rpos;
1400 offsets = os_calloc(bss->nai_realm_count * MAX_NAI_REALMS,
1402 if (offsets == NULL)
1405 for (i = 0; i < bss->nai_realm_count; i++) {
1406 realm = &bss->nai_realm_data[i];
1407 for (j = 0; j < MAX_NAI_REALMS; j++) {
1408 offsets[i * MAX_NAI_REALMS + j] =
1410 realm->realm[j] - realm->realm_buf : -1;
1414 realm = os_realloc_array(bss->nai_realm_data, bss->nai_realm_count + 1,
1415 sizeof(struct hostapd_nai_realm_data));
1416 if (realm == NULL) {
1420 bss->nai_realm_data = realm;
1422 /* patch the pointers after realloc */
1423 for (i = 0; i < bss->nai_realm_count; i++) {
1424 realm = &bss->nai_realm_data[i];
1425 for (j = 0; j < MAX_NAI_REALMS; j++) {
1426 int offs = offsets[i * MAX_NAI_REALMS + j];
1428 realm->realm[j] = realm->realm_buf + offs;
1430 realm->realm[j] = NULL;
1435 realm = &bss->nai_realm_data[bss->nai_realm_count];
1436 os_memset(realm, 0, sizeof(*realm));
1439 realm->encoding = atoi(pos);
1440 pos = os_strchr(pos, ',');
1445 end = os_strchr(pos, ',');
1450 len = os_strlen(pos);
1453 if (len > MAX_NAI_REALMLEN) {
1454 wpa_printf(MSG_ERROR, "Too long a realm string (%d > max %d "
1455 "characters)", (int) len, MAX_NAI_REALMLEN);
1458 os_memcpy(realm->realm_buf, pos, len);
1465 while (pos && *pos) {
1466 struct hostapd_nai_realm_eap *eap;
1468 if (realm->eap_method_count >= MAX_NAI_EAP_METHODS) {
1469 wpa_printf(MSG_ERROR, "Too many EAP methods");
1473 eap = &realm->eap_method[realm->eap_method_count];
1474 realm->eap_method_count++;
1476 end = os_strchr(pos, ',');
1478 end = pos + os_strlen(pos);
1480 eap->eap_method = atoi(pos);
1482 pos = os_strchr(pos, '[');
1483 if (pos == NULL || pos > end)
1486 if (eap->num_auths >= MAX_NAI_AUTH_TYPES) {
1487 wpa_printf(MSG_ERROR, "Too many auth params");
1490 eap->auth_id[eap->num_auths] = atoi(pos);
1491 pos = os_strchr(pos, ':');
1492 if (pos == NULL || pos > end)
1495 eap->auth_val[eap->num_auths] = atoi(pos);
1496 pos = os_strchr(pos, ']');
1497 if (pos == NULL || pos > end)
1509 /* Split realm list into null terminated realms */
1510 rpos = realm->realm_buf;
1513 if (i >= MAX_NAI_REALMS) {
1514 wpa_printf(MSG_ERROR, "Too many realms");
1517 realm->realm[i++] = rpos;
1518 rpos = os_strchr(rpos, ';');
1524 bss->nai_realm_count++;
1529 wpa_printf(MSG_ERROR, "Line %d: invalid nai_realm '%s'", line, buf);
1533 #endif /* CONFIG_INTERWORKING */
1537 static int hs20_parse_conn_capab(struct hostapd_bss_config *bss, char *buf,
1543 if (bss->hs20_connection_capability_len >= 0xfff0)
1546 conn_cap = os_realloc(bss->hs20_connection_capability,
1547 bss->hs20_connection_capability_len + 4);
1548 if (conn_cap == NULL)
1551 bss->hs20_connection_capability = conn_cap;
1552 conn_cap += bss->hs20_connection_capability_len;
1554 conn_cap[0] = atoi(pos);
1555 pos = os_strchr(pos, ':');
1559 WPA_PUT_LE16(conn_cap + 1, atoi(pos));
1560 pos = os_strchr(pos, ':');
1564 conn_cap[3] = atoi(pos);
1565 bss->hs20_connection_capability_len += 4;
1571 static int hs20_parse_wan_metrics(struct hostapd_bss_config *bss, char *buf,
1577 /* <WAN Info>:<DL Speed>:<UL Speed>:<DL Load>:<UL Load>:<LMD> */
1579 wan_metrics = os_zalloc(13);
1580 if (wan_metrics == NULL)
1585 if (hexstr2bin(pos, wan_metrics, 1) < 0)
1592 /* Downlink Speed */
1593 WPA_PUT_LE32(wan_metrics + 1, atoi(pos));
1594 pos = os_strchr(pos, ':');
1600 WPA_PUT_LE32(wan_metrics + 5, atoi(pos));
1601 pos = os_strchr(pos, ':');
1607 wan_metrics[9] = atoi(pos);
1608 pos = os_strchr(pos, ':');
1614 wan_metrics[10] = atoi(pos);
1615 pos = os_strchr(pos, ':');
1621 WPA_PUT_LE16(wan_metrics + 11, atoi(pos));
1623 os_free(bss->hs20_wan_metrics);
1624 bss->hs20_wan_metrics = wan_metrics;
1629 wpa_printf(MSG_ERROR, "Line %d: Invalid hs20_wan_metrics '%s'",
1631 os_free(wan_metrics);
1636 static int hs20_parse_oper_friendly_name(struct hostapd_bss_config *bss,
1637 char *pos, int line)
1639 if (parse_lang_string(&bss->hs20_oper_friendly_name,
1640 &bss->hs20_oper_friendly_name_count, pos)) {
1641 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1642 "hs20_oper_friendly_name '%s'", line, pos);
1647 #endif /* CONFIG_HS20 */
1650 #ifdef CONFIG_WPS_NFC
1651 static struct wpabuf * hostapd_parse_bin(const char *buf)
1656 len = os_strlen(buf);
1661 ret = wpabuf_alloc(len);
1665 if (hexstr2bin(buf, wpabuf_put(ret, len), len)) {
1672 #endif /* CONFIG_WPS_NFC */
1675 static int hostapd_config_fill(struct hostapd_config *conf,
1676 struct hostapd_bss_config *bss,
1677 char *buf, char *pos, int line)
1682 if (os_strcmp(buf, "interface") == 0) {
1683 os_strlcpy(conf->bss[0].iface, pos,
1684 sizeof(conf->bss[0].iface));
1685 } else if (os_strcmp(buf, "bridge") == 0) {
1686 os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
1687 } else if (os_strcmp(buf, "wds_bridge") == 0) {
1688 os_strlcpy(bss->wds_bridge, pos,
1689 sizeof(bss->wds_bridge));
1690 } else if (os_strcmp(buf, "driver") == 0) {
1692 /* clear to get error below if setting is invalid */
1693 conf->driver = NULL;
1694 for (j = 0; wpa_drivers[j]; j++) {
1695 if (os_strcmp(pos, wpa_drivers[j]->name) == 0)
1697 conf->driver = wpa_drivers[j];
1701 if (conf->driver == NULL) {
1702 wpa_printf(MSG_ERROR, "Line %d: invalid/"
1703 "unknown driver '%s'", line, pos);
1706 } else if (os_strcmp(buf, "debug") == 0) {
1707 wpa_printf(MSG_DEBUG, "Line %d: DEPRECATED: 'debug' "
1708 "configuration variable is not used "
1710 } else if (os_strcmp(buf, "logger_syslog_level") == 0) {
1711 bss->logger_syslog_level = atoi(pos);
1712 } else if (os_strcmp(buf, "logger_stdout_level") == 0) {
1713 bss->logger_stdout_level = atoi(pos);
1714 } else if (os_strcmp(buf, "logger_syslog") == 0) {
1715 bss->logger_syslog = atoi(pos);
1716 } else if (os_strcmp(buf, "logger_stdout") == 0) {
1717 bss->logger_stdout = atoi(pos);
1718 } else if (os_strcmp(buf, "dump_file") == 0) {
1719 bss->dump_log_name = os_strdup(pos);
1720 } else if (os_strcmp(buf, "ssid") == 0) {
1721 bss->ssid.ssid_len = os_strlen(pos);
1722 if (bss->ssid.ssid_len > HOSTAPD_MAX_SSID_LEN ||
1723 bss->ssid.ssid_len < 1) {
1724 wpa_printf(MSG_ERROR, "Line %d: invalid SSID "
1728 os_memcpy(bss->ssid.ssid, pos,
1729 bss->ssid.ssid_len);
1730 bss->ssid.ssid_set = 1;
1732 } else if (os_strcmp(buf, "ssid2") == 0) {
1734 char *str = wpa_config_parse_string(pos, &slen);
1735 if (str == NULL || slen < 1 ||
1736 slen > HOSTAPD_MAX_SSID_LEN) {
1737 wpa_printf(MSG_ERROR, "Line %d: invalid SSID "
1741 os_memcpy(bss->ssid.ssid, str, slen);
1742 bss->ssid.ssid_len = slen;
1743 bss->ssid.ssid_set = 1;
1746 } else if (os_strcmp(buf, "utf8_ssid") == 0) {
1747 bss->ssid.utf8_ssid = atoi(pos) > 0;
1748 } else if (os_strcmp(buf, "macaddr_acl") == 0) {
1749 bss->macaddr_acl = atoi(pos);
1750 if (bss->macaddr_acl != ACCEPT_UNLESS_DENIED &&
1751 bss->macaddr_acl != DENY_UNLESS_ACCEPTED &&
1752 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
1753 wpa_printf(MSG_ERROR, "Line %d: unknown "
1755 line, bss->macaddr_acl);
1757 } else if (os_strcmp(buf, "accept_mac_file") == 0) {
1758 if (hostapd_config_read_maclist(pos, &bss->accept_mac,
1759 &bss->num_accept_mac))
1761 wpa_printf(MSG_ERROR, "Line %d: Failed to "
1762 "read accept_mac_file '%s'",
1766 } else if (os_strcmp(buf, "deny_mac_file") == 0) {
1767 if (hostapd_config_read_maclist(pos, &bss->deny_mac,
1768 &bss->num_deny_mac)) {
1769 wpa_printf(MSG_ERROR, "Line %d: Failed to "
1770 "read deny_mac_file '%s'",
1774 } else if (os_strcmp(buf, "wds_sta") == 0) {
1775 bss->wds_sta = atoi(pos);
1776 } else if (os_strcmp(buf, "ap_isolate") == 0) {
1777 bss->isolate = atoi(pos);
1778 } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
1779 bss->ap_max_inactivity = atoi(pos);
1780 } else if (os_strcmp(buf, "skip_inactivity_poll") == 0) {
1781 bss->skip_inactivity_poll = atoi(pos);
1782 } else if (os_strcmp(buf, "country_code") == 0) {
1783 os_memcpy(conf->country, pos, 2);
1784 /* FIX: make this configurable */
1785 conf->country[2] = ' ';
1786 } else if (os_strcmp(buf, "ieee80211d") == 0) {
1787 conf->ieee80211d = atoi(pos);
1788 } else if (os_strcmp(buf, "ieee8021x") == 0) {
1789 bss->ieee802_1x = atoi(pos);
1790 } else if (os_strcmp(buf, "eapol_version") == 0) {
1791 bss->eapol_version = atoi(pos);
1792 if (bss->eapol_version < 1 ||
1793 bss->eapol_version > 2) {
1794 wpa_printf(MSG_ERROR, "Line %d: invalid EAPOL "
1795 "version (%d): '%s'.",
1796 line, bss->eapol_version, pos);
1799 wpa_printf(MSG_DEBUG, "eapol_version=%d",
1800 bss->eapol_version);
1802 } else if (os_strcmp(buf, "eap_authenticator") == 0) {
1803 bss->eap_server = atoi(pos);
1804 wpa_printf(MSG_ERROR, "Line %d: obsolete "
1805 "eap_authenticator used; this has been "
1806 "renamed to eap_server", line);
1807 } else if (os_strcmp(buf, "eap_server") == 0) {
1808 bss->eap_server = atoi(pos);
1809 } else if (os_strcmp(buf, "eap_user_file") == 0) {
1810 if (hostapd_config_read_eap_user(pos, bss))
1812 } else if (os_strcmp(buf, "ca_cert") == 0) {
1813 os_free(bss->ca_cert);
1814 bss->ca_cert = os_strdup(pos);
1815 } else if (os_strcmp(buf, "server_cert") == 0) {
1816 os_free(bss->server_cert);
1817 bss->server_cert = os_strdup(pos);
1818 } else if (os_strcmp(buf, "private_key") == 0) {
1819 os_free(bss->private_key);
1820 bss->private_key = os_strdup(pos);
1821 } else if (os_strcmp(buf, "private_key_passwd") == 0) {
1822 os_free(bss->private_key_passwd);
1823 bss->private_key_passwd = os_strdup(pos);
1824 } else if (os_strcmp(buf, "check_crl") == 0) {
1825 bss->check_crl = atoi(pos);
1826 } else if (os_strcmp(buf, "dh_file") == 0) {
1827 os_free(bss->dh_file);
1828 bss->dh_file = os_strdup(pos);
1829 } else if (os_strcmp(buf, "fragment_size") == 0) {
1830 bss->fragment_size = atoi(pos);
1831 #ifdef EAP_SERVER_FAST
1832 } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
1833 os_free(bss->pac_opaque_encr_key);
1834 bss->pac_opaque_encr_key = os_malloc(16);
1835 if (bss->pac_opaque_encr_key == NULL) {
1836 wpa_printf(MSG_ERROR, "Line %d: No memory for "
1837 "pac_opaque_encr_key", line);
1839 } else if (hexstr2bin(pos, bss->pac_opaque_encr_key,
1841 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1842 "pac_opaque_encr_key", line);
1845 } else if (os_strcmp(buf, "eap_fast_a_id") == 0) {
1846 size_t idlen = os_strlen(pos);
1848 wpa_printf(MSG_ERROR, "Line %d: Invalid "
1849 "eap_fast_a_id", line);
1852 os_free(bss->eap_fast_a_id);
1853 bss->eap_fast_a_id = os_malloc(idlen / 2);
1854 if (bss->eap_fast_a_id == NULL ||
1855 hexstr2bin(pos, bss->eap_fast_a_id,
1857 wpa_printf(MSG_ERROR, "Line %d: "
1859 "eap_fast_a_id", line);
1862 bss->eap_fast_a_id_len = idlen / 2;
1864 } else if (os_strcmp(buf, "eap_fast_a_id_info") == 0) {
1865 os_free(bss->eap_fast_a_id_info);
1866 bss->eap_fast_a_id_info = os_strdup(pos);
1867 } else if (os_strcmp(buf, "eap_fast_prov") == 0) {
1868 bss->eap_fast_prov = atoi(pos);
1869 } else if (os_strcmp(buf, "pac_key_lifetime") == 0) {
1870 bss->pac_key_lifetime = atoi(pos);
1871 } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) {
1872 bss->pac_key_refresh_time = atoi(pos);
1873 #endif /* EAP_SERVER_FAST */
1874 #ifdef EAP_SERVER_SIM
1875 } else if (os_strcmp(buf, "eap_sim_db") == 0) {
1876 os_free(bss->eap_sim_db);
1877 bss->eap_sim_db = os_strdup(pos);
1878 } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) {
1879 bss->eap_sim_aka_result_ind = atoi(pos);
1880 #endif /* EAP_SERVER_SIM */
1881 #ifdef EAP_SERVER_TNC
1882 } else if (os_strcmp(buf, "tnc") == 0) {
1883 bss->tnc = atoi(pos);
1884 #endif /* EAP_SERVER_TNC */
1885 #ifdef EAP_SERVER_PWD
1886 } else if (os_strcmp(buf, "pwd_group") == 0) {
1887 bss->pwd_group = atoi(pos);
1888 #endif /* EAP_SERVER_PWD */
1889 #endif /* EAP_SERVER */
1890 } else if (os_strcmp(buf, "eap_message") == 0) {
1892 bss->eap_req_id_text = os_strdup(pos);
1893 if (bss->eap_req_id_text == NULL) {
1894 wpa_printf(MSG_ERROR, "Line %d: Failed to "
1895 "allocate memory for "
1896 "eap_req_id_text", line);
1900 bss->eap_req_id_text_len =
1901 os_strlen(bss->eap_req_id_text);
1902 term = os_strstr(bss->eap_req_id_text, "\\0");
1905 os_memmove(term, term + 1,
1906 bss->eap_req_id_text_len -
1907 (term - bss->eap_req_id_text) - 1);
1908 bss->eap_req_id_text_len--;
1910 } else if (os_strcmp(buf, "wep_key_len_broadcast") == 0) {
1911 bss->default_wep_key_len = atoi(pos);
1912 if (bss->default_wep_key_len > 13) {
1913 wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
1914 "key len %lu (= %lu bits)", line,
1916 bss->default_wep_key_len,
1918 bss->default_wep_key_len * 8);
1921 } else if (os_strcmp(buf, "wep_key_len_unicast") == 0) {
1922 bss->individual_wep_key_len = atoi(pos);
1923 if (bss->individual_wep_key_len < 0 ||
1924 bss->individual_wep_key_len > 13) {
1925 wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
1926 "key len %d (= %d bits)", line,
1927 bss->individual_wep_key_len,
1928 bss->individual_wep_key_len * 8);
1931 } else if (os_strcmp(buf, "wep_rekey_period") == 0) {
1932 bss->wep_rekeying_period = atoi(pos);
1933 if (bss->wep_rekeying_period < 0) {
1934 wpa_printf(MSG_ERROR, "Line %d: invalid "
1936 line, bss->wep_rekeying_period);
1939 } else if (os_strcmp(buf, "eap_reauth_period") == 0) {
1940 bss->eap_reauth_period = atoi(pos);
1941 if (bss->eap_reauth_period < 0) {
1942 wpa_printf(MSG_ERROR, "Line %d: invalid "
1944 line, bss->eap_reauth_period);
1947 } else if (os_strcmp(buf, "eapol_key_index_workaround") == 0) {
1948 bss->eapol_key_index_workaround = atoi(pos);
1950 } else if (os_strcmp(buf, "iapp_interface") == 0) {
1951 bss->ieee802_11f = 1;
1952 os_strlcpy(bss->iapp_iface, pos,
1953 sizeof(bss->iapp_iface));
1954 #endif /* CONFIG_IAPP */
1955 } else if (os_strcmp(buf, "own_ip_addr") == 0) {
1956 if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
1957 wpa_printf(MSG_ERROR, "Line %d: invalid IP "
1958 "address '%s'", line, pos);
1961 } else if (os_strcmp(buf, "nas_identifier") == 0) {
1962 bss->nas_identifier = os_strdup(pos);
1963 #ifndef CONFIG_NO_RADIUS
1964 } else if (os_strcmp(buf, "auth_server_addr") == 0) {
1965 if (hostapd_config_read_radius_addr(
1966 &bss->radius->auth_servers,
1967 &bss->radius->num_auth_servers, pos, 1812,
1968 &bss->radius->auth_server)) {
1969 wpa_printf(MSG_ERROR, "Line %d: invalid IP "
1970 "address '%s'", line, pos);
1973 } else if (bss->radius->auth_server &&
1974 os_strcmp(buf, "auth_server_port") == 0) {
1975 bss->radius->auth_server->port = atoi(pos);
1976 } else if (bss->radius->auth_server &&
1977 os_strcmp(buf, "auth_server_shared_secret") == 0) {
1978 int len = os_strlen(pos);
1980 /* RFC 2865, Ch. 3 */
1981 wpa_printf(MSG_ERROR, "Line %d: empty shared "
1982 "secret is not allowed.", line);
1985 bss->radius->auth_server->shared_secret =
1986 (u8 *) os_strdup(pos);
1987 bss->radius->auth_server->shared_secret_len = len;
1988 } else if (os_strcmp(buf, "acct_server_addr") == 0) {
1989 if (hostapd_config_read_radius_addr(
1990 &bss->radius->acct_servers,
1991 &bss->radius->num_acct_servers, pos, 1813,
1992 &bss->radius->acct_server)) {
1993 wpa_printf(MSG_ERROR, "Line %d: invalid IP "
1994 "address '%s'", line, pos);
1997 } else if (bss->radius->acct_server &&
1998 os_strcmp(buf, "acct_server_port") == 0) {
1999 bss->radius->acct_server->port = atoi(pos);
2000 } else if (bss->radius->acct_server &&
2001 os_strcmp(buf, "acct_server_shared_secret") == 0) {
2002 int len = os_strlen(pos);
2004 /* RFC 2865, Ch. 3 */
2005 wpa_printf(MSG_ERROR, "Line %d: empty shared "
2006 "secret is not allowed.", line);
2009 bss->radius->acct_server->shared_secret =
2010 (u8 *) os_strdup(pos);
2011 bss->radius->acct_server->shared_secret_len = len;
2012 } else if (os_strcmp(buf, "radius_retry_primary_interval") ==
2014 bss->radius->retry_primary_interval = atoi(pos);
2015 } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0)
2017 bss->acct_interim_interval = atoi(pos);
2018 } else if (os_strcmp(buf, "radius_request_cui") == 0) {
2019 bss->radius_request_cui = atoi(pos);
2020 } else if (os_strcmp(buf, "radius_auth_req_attr") == 0) {
2021 struct hostapd_radius_attr *attr, *a;
2022 attr = hostapd_parse_radius_attr(pos);
2024 wpa_printf(MSG_ERROR, "Line %d: invalid "
2025 "radius_auth_req_attr", line);
2027 } else if (bss->radius_auth_req_attr == NULL) {
2028 bss->radius_auth_req_attr = attr;
2030 a = bss->radius_auth_req_attr;
2035 } else if (os_strcmp(buf, "radius_acct_req_attr") == 0) {
2036 struct hostapd_radius_attr *attr, *a;
2037 attr = hostapd_parse_radius_attr(pos);
2039 wpa_printf(MSG_ERROR, "Line %d: invalid "
2040 "radius_acct_req_attr", line);
2042 } else if (bss->radius_acct_req_attr == NULL) {
2043 bss->radius_acct_req_attr = attr;
2045 a = bss->radius_acct_req_attr;
2050 } else if (os_strcmp(buf, "radius_das_port") == 0) {
2051 bss->radius_das_port = atoi(pos);
2052 } else if (os_strcmp(buf, "radius_das_client") == 0) {
2053 if (hostapd_parse_das_client(bss, pos) < 0) {
2054 wpa_printf(MSG_ERROR, "Line %d: invalid "
2055 "DAS client", line);
2058 } else if (os_strcmp(buf, "radius_das_time_window") == 0) {
2059 bss->radius_das_time_window = atoi(pos);
2060 } else if (os_strcmp(buf, "radius_das_require_event_timestamp")
2062 bss->radius_das_require_event_timestamp = atoi(pos);
2063 #endif /* CONFIG_NO_RADIUS */
2064 } else if (os_strcmp(buf, "auth_algs") == 0) {
2065 bss->auth_algs = atoi(pos);
2066 if (bss->auth_algs == 0) {
2067 wpa_printf(MSG_ERROR, "Line %d: no "
2068 "authentication algorithms allowed",
2072 } else if (os_strcmp(buf, "max_num_sta") == 0) {
2073 bss->max_num_sta = atoi(pos);
2074 if (bss->max_num_sta < 0 ||
2075 bss->max_num_sta > MAX_STA_COUNT) {
2076 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2077 "max_num_sta=%d; allowed range "
2078 "0..%d", line, bss->max_num_sta,
2082 } else if (os_strcmp(buf, "wpa") == 0) {
2083 bss->wpa = atoi(pos);
2084 } else if (os_strcmp(buf, "wpa_group_rekey") == 0) {
2085 bss->wpa_group_rekey = atoi(pos);
2086 } else if (os_strcmp(buf, "wpa_strict_rekey") == 0) {
2087 bss->wpa_strict_rekey = atoi(pos);
2088 } else if (os_strcmp(buf, "wpa_gmk_rekey") == 0) {
2089 bss->wpa_gmk_rekey = atoi(pos);
2090 } else if (os_strcmp(buf, "wpa_ptk_rekey") == 0) {
2091 bss->wpa_ptk_rekey = atoi(pos);
2092 } else if (os_strcmp(buf, "wpa_passphrase") == 0) {
2093 int len = os_strlen(pos);
2094 if (len < 8 || len > 63) {
2095 wpa_printf(MSG_ERROR, "Line %d: invalid WPA "
2096 "passphrase length %d (expected "
2097 "8..63)", line, len);
2100 os_free(bss->ssid.wpa_passphrase);
2101 bss->ssid.wpa_passphrase = os_strdup(pos);
2102 os_free(bss->ssid.wpa_psk);
2103 bss->ssid.wpa_psk = NULL;
2105 } else if (os_strcmp(buf, "wpa_psk") == 0) {
2106 os_free(bss->ssid.wpa_psk);
2108 os_zalloc(sizeof(struct hostapd_wpa_psk));
2109 if (bss->ssid.wpa_psk == NULL)
2111 else if (hexstr2bin(pos, bss->ssid.wpa_psk->psk,
2113 pos[PMK_LEN * 2] != '\0') {
2114 wpa_printf(MSG_ERROR, "Line %d: Invalid PSK "
2115 "'%s'.", line, pos);
2118 bss->ssid.wpa_psk->group = 1;
2119 os_free(bss->ssid.wpa_passphrase);
2120 bss->ssid.wpa_passphrase = NULL;
2122 } else if (os_strcmp(buf, "wpa_psk_file") == 0) {
2123 os_free(bss->ssid.wpa_psk_file);
2124 bss->ssid.wpa_psk_file = os_strdup(pos);
2125 if (!bss->ssid.wpa_psk_file) {
2126 wpa_printf(MSG_ERROR, "Line %d: allocation "
2130 } else if (os_strcmp(buf, "wpa_key_mgmt") == 0) {
2132 hostapd_config_parse_key_mgmt(line, pos);
2133 if (bss->wpa_key_mgmt == -1)
2135 } else if (os_strcmp(buf, "wpa_psk_radius") == 0) {
2136 bss->wpa_psk_radius = atoi(pos);
2137 if (bss->wpa_psk_radius != PSK_RADIUS_IGNORED &&
2138 bss->wpa_psk_radius != PSK_RADIUS_ACCEPTED &&
2139 bss->wpa_psk_radius != PSK_RADIUS_REQUIRED) {
2140 wpa_printf(MSG_ERROR, "Line %d: unknown "
2141 "wpa_psk_radius %d",
2142 line, bss->wpa_psk_radius);
2145 } else if (os_strcmp(buf, "wpa_pairwise") == 0) {
2147 hostapd_config_parse_cipher(line, pos);
2148 if (bss->wpa_pairwise == -1 ||
2149 bss->wpa_pairwise == 0)
2151 else if (bss->wpa_pairwise &
2152 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
2153 WPA_CIPHER_WEP104)) {
2154 wpa_printf(MSG_ERROR, "Line %d: unsupported "
2155 "pairwise cipher suite '%s'",
2156 bss->wpa_pairwise, pos);
2159 } else if (os_strcmp(buf, "rsn_pairwise") == 0) {
2161 hostapd_config_parse_cipher(line, pos);
2162 if (bss->rsn_pairwise == -1 ||
2163 bss->rsn_pairwise == 0)
2165 else if (bss->rsn_pairwise &
2166 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
2167 WPA_CIPHER_WEP104)) {
2168 wpa_printf(MSG_ERROR, "Line %d: unsupported "
2169 "pairwise cipher suite '%s'",
2170 bss->rsn_pairwise, pos);
2173 #ifdef CONFIG_RSN_PREAUTH
2174 } else if (os_strcmp(buf, "rsn_preauth") == 0) {
2175 bss->rsn_preauth = atoi(pos);
2176 } else if (os_strcmp(buf, "rsn_preauth_interfaces") == 0) {
2177 bss->rsn_preauth_interfaces = os_strdup(pos);
2178 #endif /* CONFIG_RSN_PREAUTH */
2179 #ifdef CONFIG_PEERKEY
2180 } else if (os_strcmp(buf, "peerkey") == 0) {
2181 bss->peerkey = atoi(pos);
2182 #endif /* CONFIG_PEERKEY */
2183 #ifdef CONFIG_IEEE80211R
2184 } else if (os_strcmp(buf, "mobility_domain") == 0) {
2185 if (os_strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN ||
2186 hexstr2bin(pos, bss->mobility_domain,
2187 MOBILITY_DOMAIN_ID_LEN) != 0) {
2188 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2189 "mobility_domain '%s'", line, pos);
2193 } else if (os_strcmp(buf, "r1_key_holder") == 0) {
2194 if (os_strlen(pos) != 2 * FT_R1KH_ID_LEN ||
2195 hexstr2bin(pos, bss->r1_key_holder,
2196 FT_R1KH_ID_LEN) != 0) {
2197 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2198 "r1_key_holder '%s'", line, pos);
2202 } else if (os_strcmp(buf, "r0_key_lifetime") == 0) {
2203 bss->r0_key_lifetime = atoi(pos);
2204 } else if (os_strcmp(buf, "reassociation_deadline") == 0) {
2205 bss->reassociation_deadline = atoi(pos);
2206 } else if (os_strcmp(buf, "r0kh") == 0) {
2207 if (add_r0kh(bss, pos) < 0) {
2208 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2209 "r0kh '%s'", line, pos);
2213 } else if (os_strcmp(buf, "r1kh") == 0) {
2214 if (add_r1kh(bss, pos) < 0) {
2215 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
2216 "r1kh '%s'", line, pos);
2220 } else if (os_strcmp(buf, "pmk_r1_push") == 0) {
2221 bss->pmk_r1_push = atoi(pos);
2222 } else if (os_strcmp(buf, "ft_over_ds") == 0) {
2223 bss->ft_over_ds = atoi(pos);
2224 #endif /* CONFIG_IEEE80211R */
2225 #ifndef CONFIG_NO_CTRL_IFACE
2226 } else if (os_strcmp(buf, "ctrl_interface") == 0) {
2227 os_free(bss->ctrl_interface);
2228 bss->ctrl_interface = os_strdup(pos);
2229 } else if (os_strcmp(buf, "ctrl_interface_group") == 0) {
2230 #ifndef CONFIG_NATIVE_WINDOWS
2233 const char *group = pos;
2235 grp = getgrnam(group);
2237 bss->ctrl_interface_gid = grp->gr_gid;
2238 bss->ctrl_interface_gid_set = 1;
2239 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d"
2240 " (from group name '%s')",
2241 bss->ctrl_interface_gid, group);
2245 /* Group name not found - try to parse this as gid */
2246 bss->ctrl_interface_gid = strtol(group, &endp, 10);
2247 if (*group == '\0' || *endp != '\0') {
2248 wpa_printf(MSG_DEBUG, "Line %d: Invalid group "
2249 "'%s'", line, group);
2253 bss->ctrl_interface_gid_set = 1;
2254 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d",
2255 bss->ctrl_interface_gid);
2256 #endif /* CONFIG_NATIVE_WINDOWS */
2257 #endif /* CONFIG_NO_CTRL_IFACE */
2258 #ifdef RADIUS_SERVER
2259 } else if (os_strcmp(buf, "radius_server_clients") == 0) {
2260 os_free(bss->radius_server_clients);
2261 bss->radius_server_clients = os_strdup(pos);
2262 } else if (os_strcmp(buf, "radius_server_auth_port") == 0) {
2263 bss->radius_server_auth_port = atoi(pos);
2264 } else if (os_strcmp(buf, "radius_server_ipv6") == 0) {
2265 bss->radius_server_ipv6 = atoi(pos);
2266 #endif /* RADIUS_SERVER */
2267 } else if (os_strcmp(buf, "test_socket") == 0) {
2268 os_free(bss->test_socket);
2269 bss->test_socket = os_strdup(pos);
2270 } else if (os_strcmp(buf, "use_pae_group_addr") == 0) {
2271 bss->use_pae_group_addr = atoi(pos);
2272 } else if (os_strcmp(buf, "hw_mode") == 0) {
2273 if (os_strcmp(pos, "a") == 0)
2274 conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
2275 else if (os_strcmp(pos, "b") == 0)
2276 conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
2277 else if (os_strcmp(pos, "g") == 0)
2278 conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
2279 else if (os_strcmp(pos, "ad") == 0)
2280 conf->hw_mode = HOSTAPD_MODE_IEEE80211AD;
2282 wpa_printf(MSG_ERROR, "Line %d: unknown "
2283 "hw_mode '%s'", line, pos);
2286 } else if (os_strcmp(buf, "wps_rf_bands") == 0) {
2287 if (os_strcmp(pos, "a") == 0)
2288 bss->wps_rf_bands = WPS_RF_50GHZ;
2289 else if (os_strcmp(pos, "g") == 0 ||
2290 os_strcmp(pos, "b") == 0)
2291 bss->wps_rf_bands = WPS_RF_24GHZ;
2292 else if (os_strcmp(pos, "ag") == 0 ||
2293 os_strcmp(pos, "ga") == 0)
2295 WPS_RF_24GHZ | WPS_RF_50GHZ;
2297 wpa_printf(MSG_ERROR, "Line %d: unknown "
2298 "wps_rf_band '%s'", line, pos);
2301 } else if (os_strcmp(buf, "channel") == 0) {
2302 conf->channel = atoi(pos);
2303 } else if (os_strcmp(buf, "beacon_int") == 0) {
2304 int val = atoi(pos);
2305 /* MIB defines range as 1..65535, but very small values
2306 * cause problems with the current implementation.
2307 * Since it is unlikely that this small numbers are
2308 * useful in real life scenarios, do not allow beacon
2309 * period to be set below 15 TU. */
2310 if (val < 15 || val > 65535) {
2311 wpa_printf(MSG_ERROR, "Line %d: invalid "
2312 "beacon_int %d (expected "
2313 "15..65535)", line, val);
2316 conf->beacon_int = val;
2317 } else if (os_strcmp(buf, "dtim_period") == 0) {
2318 bss->dtim_period = atoi(pos);
2319 if (bss->dtim_period < 1 || bss->dtim_period > 255) {
2320 wpa_printf(MSG_ERROR, "Line %d: invalid "
2322 line, bss->dtim_period);
2325 } else if (os_strcmp(buf, "rts_threshold") == 0) {
2326 conf->rts_threshold = atoi(pos);
2327 if (conf->rts_threshold < 0 ||
2328 conf->rts_threshold > 2347) {
2329 wpa_printf(MSG_ERROR, "Line %d: invalid "
2331 line, conf->rts_threshold);
2334 } else if (os_strcmp(buf, "fragm_threshold") == 0) {
2335 conf->fragm_threshold = atoi(pos);
2336 if (conf->fragm_threshold < 256 ||
2337 conf->fragm_threshold > 2346) {
2338 wpa_printf(MSG_ERROR, "Line %d: invalid "
2339 "fragm_threshold %d",
2340 line, conf->fragm_threshold);
2343 } else if (os_strcmp(buf, "send_probe_response") == 0) {
2344 int val = atoi(pos);
2345 if (val != 0 && val != 1) {
2346 wpa_printf(MSG_ERROR, "Line %d: invalid "
2347 "send_probe_response %d (expected "
2348 "0 or 1)", line, val);
2350 conf->send_probe_response = val;
2351 } else if (os_strcmp(buf, "supported_rates") == 0) {
2352 if (hostapd_parse_rates(&conf->supported_rates, pos)) {
2353 wpa_printf(MSG_ERROR, "Line %d: invalid rate "
2357 } else if (os_strcmp(buf, "basic_rates") == 0) {
2358 if (hostapd_parse_rates(&conf->basic_rates, pos)) {
2359 wpa_printf(MSG_ERROR, "Line %d: invalid rate "
2363 } else if (os_strcmp(buf, "preamble") == 0) {
2365 conf->preamble = SHORT_PREAMBLE;
2367 conf->preamble = LONG_PREAMBLE;
2368 } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) {
2369 bss->ignore_broadcast_ssid = atoi(pos);
2370 } else if (os_strcmp(buf, "wep_default_key") == 0) {
2371 bss->ssid.wep.idx = atoi(pos);
2372 if (bss->ssid.wep.idx > 3) {
2373 wpa_printf(MSG_ERROR, "Invalid "
2374 "wep_default_key index %d",
2378 } else if (os_strcmp(buf, "wep_key0") == 0 ||
2379 os_strcmp(buf, "wep_key1") == 0 ||
2380 os_strcmp(buf, "wep_key2") == 0 ||
2381 os_strcmp(buf, "wep_key3") == 0) {
2382 if (hostapd_config_read_wep(&bss->ssid.wep,
2383 buf[7] - '0', pos)) {
2384 wpa_printf(MSG_ERROR, "Line %d: invalid WEP "
2385 "key '%s'", line, buf);
2388 #ifndef CONFIG_NO_VLAN
2389 } else if (os_strcmp(buf, "dynamic_vlan") == 0) {
2390 bss->ssid.dynamic_vlan = atoi(pos);
2391 } else if (os_strcmp(buf, "vlan_file") == 0) {
2392 if (hostapd_config_read_vlan_file(bss, pos)) {
2393 wpa_printf(MSG_ERROR, "Line %d: failed to "
2394 "read VLAN file '%s'", line, pos);
2397 } else if (os_strcmp(buf, "vlan_naming") == 0) {
2398 bss->ssid.vlan_naming = atoi(pos);
2399 if (bss->ssid.vlan_naming >= DYNAMIC_VLAN_NAMING_END ||
2400 bss->ssid.vlan_naming < 0) {
2401 wpa_printf(MSG_ERROR, "Line %d: invalid "
2402 "naming scheme %d", line,
2403 bss->ssid.vlan_naming);
2406 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2407 } else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
2408 bss->ssid.vlan_tagged_interface = os_strdup(pos);
2409 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2410 #endif /* CONFIG_NO_VLAN */
2411 } else if (os_strcmp(buf, "ap_table_max_size") == 0) {
2412 conf->ap_table_max_size = atoi(pos);
2413 } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) {
2414 conf->ap_table_expiration_time = atoi(pos);
2415 } else if (os_strncmp(buf, "tx_queue_", 9) == 0) {
2416 if (hostapd_config_tx_queue(conf, buf, pos)) {
2417 wpa_printf(MSG_ERROR, "Line %d: invalid TX "
2418 "queue item", line);
2421 } else if (os_strcmp(buf, "wme_enabled") == 0 ||
2422 os_strcmp(buf, "wmm_enabled") == 0) {
2423 bss->wmm_enabled = atoi(pos);
2424 } else if (os_strcmp(buf, "uapsd_advertisement_enabled") == 0) {
2425 bss->wmm_uapsd = atoi(pos);
2426 } else if (os_strncmp(buf, "wme_ac_", 7) == 0 ||
2427 os_strncmp(buf, "wmm_ac_", 7) == 0) {
2428 if (hostapd_config_wmm_ac(conf->wmm_ac_params, buf,
2430 wpa_printf(MSG_ERROR, "Line %d: invalid WMM "
2434 } else if (os_strcmp(buf, "bss") == 0) {
2435 if (hostapd_config_bss(conf, pos)) {
2436 wpa_printf(MSG_ERROR, "Line %d: invalid bss "
2440 } else if (os_strcmp(buf, "bssid") == 0) {
2441 if (hwaddr_aton(pos, bss->bssid)) {
2442 wpa_printf(MSG_ERROR, "Line %d: invalid bssid "
2446 #ifdef CONFIG_IEEE80211W
2447 } else if (os_strcmp(buf, "ieee80211w") == 0) {
2448 bss->ieee80211w = atoi(pos);
2449 } else if (os_strcmp(buf, "assoc_sa_query_max_timeout") == 0) {
2450 bss->assoc_sa_query_max_timeout = atoi(pos);
2451 if (bss->assoc_sa_query_max_timeout == 0) {
2452 wpa_printf(MSG_ERROR, "Line %d: invalid "
2453 "assoc_sa_query_max_timeout", line);
2456 } else if (os_strcmp(buf, "assoc_sa_query_retry_timeout") == 0)
2458 bss->assoc_sa_query_retry_timeout = atoi(pos);
2459 if (bss->assoc_sa_query_retry_timeout == 0) {
2460 wpa_printf(MSG_ERROR, "Line %d: invalid "
2461 "assoc_sa_query_retry_timeout",
2465 #endif /* CONFIG_IEEE80211W */
2466 #ifdef CONFIG_IEEE80211N
2467 } else if (os_strcmp(buf, "ieee80211n") == 0) {
2468 conf->ieee80211n = atoi(pos);
2469 } else if (os_strcmp(buf, "ht_capab") == 0) {
2470 if (hostapd_config_ht_capab(conf, pos) < 0) {
2471 wpa_printf(MSG_ERROR, "Line %d: invalid "
2475 } else if (os_strcmp(buf, "require_ht") == 0) {
2476 conf->require_ht = atoi(pos);
2477 #endif /* CONFIG_IEEE80211N */
2478 #ifdef CONFIG_IEEE80211AC
2479 } else if (os_strcmp(buf, "ieee80211ac") == 0) {
2480 conf->ieee80211ac = atoi(pos);
2481 } else if (os_strcmp(buf, "vht_capab") == 0) {
2482 if (hostapd_config_vht_capab(conf, pos) < 0) {
2483 wpa_printf(MSG_ERROR, "Line %d: invalid "
2487 } else if (os_strcmp(buf, "require_vht") == 0) {
2488 conf->require_vht = atoi(pos);
2489 } else if (os_strcmp(buf, "vht_oper_chwidth") == 0) {
2490 conf->vht_oper_chwidth = atoi(pos);
2491 } else if (os_strcmp(buf, "vht_oper_centr_freq_seg0_idx") == 0)
2493 conf->vht_oper_centr_freq_seg0_idx = atoi(pos);
2494 } else if (os_strcmp(buf, "vht_oper_centr_freq_seg1_idx") == 0)
2496 conf->vht_oper_centr_freq_seg1_idx = atoi(pos);
2497 #endif /* CONFIG_IEEE80211AC */
2498 } else if (os_strcmp(buf, "max_listen_interval") == 0) {
2499 bss->max_listen_interval = atoi(pos);
2500 } else if (os_strcmp(buf, "disable_pmksa_caching") == 0) {
2501 bss->disable_pmksa_caching = atoi(pos);
2502 } else if (os_strcmp(buf, "okc") == 0) {
2503 bss->okc = atoi(pos);
2505 } else if (os_strcmp(buf, "wps_state") == 0) {
2506 bss->wps_state = atoi(pos);
2507 if (bss->wps_state < 0 || bss->wps_state > 2) {
2508 wpa_printf(MSG_ERROR, "Line %d: invalid "
2512 } else if (os_strcmp(buf, "ap_setup_locked") == 0) {
2513 bss->ap_setup_locked = atoi(pos);
2514 } else if (os_strcmp(buf, "uuid") == 0) {
2515 if (uuid_str2bin(pos, bss->uuid)) {
2516 wpa_printf(MSG_ERROR, "Line %d: invalid UUID",
2520 } else if (os_strcmp(buf, "wps_pin_requests") == 0) {
2521 os_free(bss->wps_pin_requests);
2522 bss->wps_pin_requests = os_strdup(pos);
2523 } else if (os_strcmp(buf, "device_name") == 0) {
2524 if (os_strlen(pos) > 32) {
2525 wpa_printf(MSG_ERROR, "Line %d: Too long "
2526 "device_name", line);
2529 os_free(bss->device_name);
2530 bss->device_name = os_strdup(pos);
2531 } else if (os_strcmp(buf, "manufacturer") == 0) {
2532 if (os_strlen(pos) > 64) {
2533 wpa_printf(MSG_ERROR, "Line %d: Too long "
2534 "manufacturer", line);
2537 os_free(bss->manufacturer);
2538 bss->manufacturer = os_strdup(pos);
2539 } else if (os_strcmp(buf, "model_name") == 0) {
2540 if (os_strlen(pos) > 32) {
2541 wpa_printf(MSG_ERROR, "Line %d: Too long "
2542 "model_name", line);
2545 os_free(bss->model_name);
2546 bss->model_name = os_strdup(pos);
2547 } else if (os_strcmp(buf, "model_number") == 0) {
2548 if (os_strlen(pos) > 32) {
2549 wpa_printf(MSG_ERROR, "Line %d: Too long "
2550 "model_number", line);
2553 os_free(bss->model_number);
2554 bss->model_number = os_strdup(pos);
2555 } else if (os_strcmp(buf, "serial_number") == 0) {
2556 if (os_strlen(pos) > 32) {
2557 wpa_printf(MSG_ERROR, "Line %d: Too long "
2558 "serial_number", line);
2561 os_free(bss->serial_number);
2562 bss->serial_number = os_strdup(pos);
2563 } else if (os_strcmp(buf, "device_type") == 0) {
2564 if (wps_dev_type_str2bin(pos, bss->device_type))
2566 } else if (os_strcmp(buf, "config_methods") == 0) {
2567 os_free(bss->config_methods);
2568 bss->config_methods = os_strdup(pos);
2569 } else if (os_strcmp(buf, "os_version") == 0) {
2570 if (hexstr2bin(pos, bss->os_version, 4)) {
2571 wpa_printf(MSG_ERROR, "Line %d: invalid "
2572 "os_version", line);
2575 } else if (os_strcmp(buf, "ap_pin") == 0) {
2576 os_free(bss->ap_pin);
2577 bss->ap_pin = os_strdup(pos);
2578 } else if (os_strcmp(buf, "skip_cred_build") == 0) {
2579 bss->skip_cred_build = atoi(pos);
2580 } else if (os_strcmp(buf, "extra_cred") == 0) {
2581 os_free(bss->extra_cred);
2583 (u8 *) os_readfile(pos, &bss->extra_cred_len);
2584 if (bss->extra_cred == NULL) {
2585 wpa_printf(MSG_ERROR, "Line %d: could not "
2586 "read Credentials from '%s'",
2590 } else if (os_strcmp(buf, "wps_cred_processing") == 0) {
2591 bss->wps_cred_processing = atoi(pos);
2592 } else if (os_strcmp(buf, "ap_settings") == 0) {
2593 os_free(bss->ap_settings);
2595 (u8 *) os_readfile(pos, &bss->ap_settings_len);
2596 if (bss->ap_settings == NULL) {
2597 wpa_printf(MSG_ERROR, "Line %d: could not "
2598 "read AP Settings from '%s'",
2602 } else if (os_strcmp(buf, "upnp_iface") == 0) {
2603 bss->upnp_iface = os_strdup(pos);
2604 } else if (os_strcmp(buf, "friendly_name") == 0) {
2605 os_free(bss->friendly_name);
2606 bss->friendly_name = os_strdup(pos);
2607 } else if (os_strcmp(buf, "manufacturer_url") == 0) {
2608 os_free(bss->manufacturer_url);
2609 bss->manufacturer_url = os_strdup(pos);
2610 } else if (os_strcmp(buf, "model_description") == 0) {
2611 os_free(bss->model_description);
2612 bss->model_description = os_strdup(pos);
2613 } else if (os_strcmp(buf, "model_url") == 0) {
2614 os_free(bss->model_url);
2615 bss->model_url = os_strdup(pos);
2616 } else if (os_strcmp(buf, "upc") == 0) {
2618 bss->upc = os_strdup(pos);
2619 } else if (os_strcmp(buf, "pbc_in_m1") == 0) {
2620 bss->pbc_in_m1 = atoi(pos);
2621 #ifdef CONFIG_WPS_NFC
2622 } else if (os_strcmp(buf, "wps_nfc_dev_pw_id") == 0) {
2623 bss->wps_nfc_dev_pw_id = atoi(pos);
2624 if (bss->wps_nfc_dev_pw_id < 0x10 ||
2625 bss->wps_nfc_dev_pw_id > 0xffff) {
2626 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2627 "wps_nfc_dev_pw_id value", line);
2630 } else if (os_strcmp(buf, "wps_nfc_dh_pubkey") == 0) {
2631 wpabuf_free(bss->wps_nfc_dh_pubkey);
2632 bss->wps_nfc_dh_pubkey = hostapd_parse_bin(pos);
2633 } else if (os_strcmp(buf, "wps_nfc_dh_privkey") == 0) {
2634 wpabuf_free(bss->wps_nfc_dh_privkey);
2635 bss->wps_nfc_dh_privkey = hostapd_parse_bin(pos);
2636 } else if (os_strcmp(buf, "wps_nfc_dev_pw") == 0) {
2637 wpabuf_free(bss->wps_nfc_dev_pw);
2638 bss->wps_nfc_dev_pw = hostapd_parse_bin(pos);
2639 #endif /* CONFIG_WPS_NFC */
2640 #endif /* CONFIG_WPS */
2641 #ifdef CONFIG_P2P_MANAGER
2642 } else if (os_strcmp(buf, "manage_p2p") == 0) {
2643 int manage = atoi(pos);
2645 bss->p2p |= P2P_MANAGE;
2647 bss->p2p &= ~P2P_MANAGE;
2648 } else if (os_strcmp(buf, "allow_cross_connection") == 0) {
2650 bss->p2p |= P2P_ALLOW_CROSS_CONNECTION;
2652 bss->p2p &= ~P2P_ALLOW_CROSS_CONNECTION;
2653 #endif /* CONFIG_P2P_MANAGER */
2654 } else if (os_strcmp(buf, "disassoc_low_ack") == 0) {
2655 bss->disassoc_low_ack = atoi(pos);
2656 } else if (os_strcmp(buf, "tdls_prohibit") == 0) {
2657 int val = atoi(pos);
2659 bss->tdls |= TDLS_PROHIBIT;
2661 bss->tdls &= ~TDLS_PROHIBIT;
2662 } else if (os_strcmp(buf, "tdls_prohibit_chan_switch") == 0) {
2663 int val = atoi(pos);
2665 bss->tdls |= TDLS_PROHIBIT_CHAN_SWITCH;
2667 bss->tdls &= ~TDLS_PROHIBIT_CHAN_SWITCH;
2668 #ifdef CONFIG_RSN_TESTING
2669 } else if (os_strcmp(buf, "rsn_testing") == 0) {
2670 extern int rsn_testing;
2671 rsn_testing = atoi(pos);
2672 #endif /* CONFIG_RSN_TESTING */
2673 } else if (os_strcmp(buf, "time_advertisement") == 0) {
2674 bss->time_advertisement = atoi(pos);
2675 } else if (os_strcmp(buf, "time_zone") == 0) {
2676 size_t tz_len = os_strlen(pos);
2677 if (tz_len < 4 || tz_len > 255) {
2678 wpa_printf(MSG_DEBUG, "Line %d: invalid "
2683 os_free(bss->time_zone);
2684 bss->time_zone = os_strdup(pos);
2685 if (bss->time_zone == NULL)
2688 } else if (os_strcmp(buf, "wnm_sleep_mode") == 0) {
2689 bss->wnm_sleep_mode = atoi(pos);
2690 } else if (os_strcmp(buf, "bss_transition") == 0) {
2691 bss->bss_transition = atoi(pos);
2692 #endif /* CONFIG_WNM */
2693 #ifdef CONFIG_INTERWORKING
2694 } else if (os_strcmp(buf, "interworking") == 0) {
2695 bss->interworking = atoi(pos);
2696 } else if (os_strcmp(buf, "access_network_type") == 0) {
2697 bss->access_network_type = atoi(pos);
2698 if (bss->access_network_type < 0 ||
2699 bss->access_network_type > 15) {
2700 wpa_printf(MSG_ERROR, "Line %d: invalid "
2701 "access_network_type", line);
2704 } else if (os_strcmp(buf, "internet") == 0) {
2705 bss->internet = atoi(pos);
2706 } else if (os_strcmp(buf, "asra") == 0) {
2707 bss->asra = atoi(pos);
2708 } else if (os_strcmp(buf, "esr") == 0) {
2709 bss->esr = atoi(pos);
2710 } else if (os_strcmp(buf, "uesa") == 0) {
2711 bss->uesa = atoi(pos);
2712 } else if (os_strcmp(buf, "venue_group") == 0) {
2713 bss->venue_group = atoi(pos);
2714 bss->venue_info_set = 1;
2715 } else if (os_strcmp(buf, "venue_type") == 0) {
2716 bss->venue_type = atoi(pos);
2717 bss->venue_info_set = 1;
2718 } else if (os_strcmp(buf, "hessid") == 0) {
2719 if (hwaddr_aton(pos, bss->hessid)) {
2720 wpa_printf(MSG_ERROR, "Line %d: invalid "
2724 } else if (os_strcmp(buf, "roaming_consortium") == 0) {
2725 if (parse_roaming_consortium(bss, pos, line) < 0)
2727 } else if (os_strcmp(buf, "venue_name") == 0) {
2728 if (parse_venue_name(bss, pos, line) < 0)
2730 } else if (os_strcmp(buf, "network_auth_type") == 0) {
2732 u16 redirect_url_len;
2733 if (hexstr2bin(pos, &auth_type, 1)) {
2734 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2735 "network_auth_type '%s'",
2740 if (auth_type == 0 || auth_type == 2)
2741 redirect_url_len = os_strlen(pos + 2);
2743 redirect_url_len = 0;
2744 os_free(bss->network_auth_type);
2745 bss->network_auth_type =
2746 os_malloc(redirect_url_len + 3 + 1);
2747 if (bss->network_auth_type == NULL) {
2751 *bss->network_auth_type = auth_type;
2752 WPA_PUT_LE16(bss->network_auth_type + 1,
2754 if (redirect_url_len)
2755 os_memcpy(bss->network_auth_type + 3,
2756 pos + 2, redirect_url_len);
2757 bss->network_auth_type_len = 3 + redirect_url_len;
2758 } else if (os_strcmp(buf, "ipaddr_type_availability") == 0) {
2759 if (hexstr2bin(pos, &bss->ipaddr_type_availability, 1))
2761 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2762 "ipaddr_type_availability '%s'",
2764 bss->ipaddr_type_configured = 0;
2768 bss->ipaddr_type_configured = 1;
2769 } else if (os_strcmp(buf, "domain_name") == 0) {
2770 int j, num_domains, domain_len, domain_list_len = 0;
2771 char *tok_start, *tok_prev;
2772 u8 *domain_list, *domain_ptr;
2774 domain_list_len = os_strlen(pos) + 1;
2775 domain_list = os_malloc(domain_list_len);
2776 if (domain_list == NULL) {
2781 domain_ptr = domain_list;
2784 while ((tok_prev = os_strchr(tok_prev, ','))) {
2789 for (j = 0; j < num_domains; j++) {
2790 tok_start = os_strchr(tok_prev, ',');
2792 domain_len = tok_start - tok_prev;
2793 *domain_ptr = domain_len;
2794 os_memcpy(domain_ptr + 1, tok_prev,
2796 domain_ptr += domain_len + 1;
2797 tok_prev = ++tok_start;
2799 domain_len = os_strlen(tok_prev);
2800 *domain_ptr = domain_len;
2801 os_memcpy(domain_ptr + 1, tok_prev,
2803 domain_ptr += domain_len + 1;
2807 os_free(bss->domain_name);
2808 bss->domain_name = domain_list;
2809 bss->domain_name_len = domain_list_len;
2810 } else if (os_strcmp(buf, "anqp_3gpp_cell_net") == 0) {
2811 if (parse_3gpp_cell_net(bss, pos, line) < 0)
2813 } else if (os_strcmp(buf, "nai_realm") == 0) {
2814 if (parse_nai_realm(bss, pos, line) < 0)
2816 } else if (os_strcmp(buf, "gas_frag_limit") == 0) {
2817 bss->gas_frag_limit = atoi(pos);
2818 } else if (os_strcmp(buf, "gas_comeback_delay") == 0) {
2819 bss->gas_comeback_delay = atoi(pos);
2820 #endif /* CONFIG_INTERWORKING */
2821 #ifdef CONFIG_RADIUS_TEST
2822 } else if (os_strcmp(buf, "dump_msk_file") == 0) {
2823 os_free(bss->dump_msk_file);
2824 bss->dump_msk_file = os_strdup(pos);
2825 #endif /* CONFIG_RADIUS_TEST */
2827 } else if (os_strcmp(buf, "hs20") == 0) {
2828 bss->hs20 = atoi(pos);
2829 } else if (os_strcmp(buf, "disable_dgaf") == 0) {
2830 bss->disable_dgaf = atoi(pos);
2831 } else if (os_strcmp(buf, "hs20_oper_friendly_name") == 0) {
2832 if (hs20_parse_oper_friendly_name(bss, pos, line) < 0)
2834 } else if (os_strcmp(buf, "hs20_wan_metrics") == 0) {
2835 if (hs20_parse_wan_metrics(bss, pos, line) < 0) {
2839 } else if (os_strcmp(buf, "hs20_conn_capab") == 0) {
2840 if (hs20_parse_conn_capab(bss, pos, line) < 0) {
2844 } else if (os_strcmp(buf, "hs20_operating_class") == 0) {
2846 size_t oper_class_len;
2847 oper_class_len = os_strlen(pos);
2848 if (oper_class_len < 2 || (oper_class_len & 0x01)) {
2849 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2850 "hs20_operating_class '%s'",
2855 oper_class_len /= 2;
2856 oper_class = os_malloc(oper_class_len);
2857 if (oper_class == NULL) {
2861 if (hexstr2bin(pos, oper_class, oper_class_len)) {
2862 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2863 "hs20_operating_class '%s'",
2865 os_free(oper_class);
2869 os_free(bss->hs20_operating_class);
2870 bss->hs20_operating_class = oper_class;
2871 bss->hs20_operating_class_len = oper_class_len;
2872 #endif /* CONFIG_HS20 */
2873 } else if (os_strcmp(buf, "vendor_elements") == 0) {
2874 struct wpabuf *elems;
2875 size_t len = os_strlen(pos);
2877 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2878 "vendor_elements '%s'", line, pos);
2883 wpabuf_free(bss->vendor_elements);
2884 bss->vendor_elements = NULL;
2888 elems = wpabuf_alloc(len);
2892 if (hexstr2bin(pos, wpabuf_put(elems, len), len)) {
2894 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2895 "vendor_elements '%s'", line, pos);
2899 wpabuf_free(bss->vendor_elements);
2900 bss->vendor_elements = elems;
2901 } else if (os_strcmp(buf, "sae_anti_clogging_threshold") == 0) {
2902 bss->sae_anti_clogging_threshold = atoi(pos);
2903 } else if (os_strcmp(buf, "sae_groups") == 0) {
2904 if (hostapd_parse_rates(&bss->sae_groups, pos)) {
2905 wpa_printf(MSG_ERROR, "Line %d: Invalid "
2906 "sae_groups value '%s'", line, pos);
2910 wpa_printf(MSG_ERROR, "Line %d: unknown configuration "
2911 "item '%s'", line, buf);
2920 static void hostapd_set_security_params(struct hostapd_bss_config *bss)
2922 if (bss->individual_wep_key_len == 0) {
2923 /* individual keys are not use; can use key idx0 for
2925 bss->broadcast_key_idx_min = 0;
2928 if ((bss->wpa & 2) && bss->rsn_pairwise == 0)
2929 bss->rsn_pairwise = bss->wpa_pairwise;
2930 bss->wpa_group = wpa_select_ap_group_cipher(bss->wpa, bss->wpa_pairwise,
2933 bss->radius->auth_server = bss->radius->auth_servers;
2934 bss->radius->acct_server = bss->radius->acct_servers;
2936 if (bss->wpa && bss->ieee802_1x) {
2937 bss->ssid.security_policy = SECURITY_WPA;
2938 } else if (bss->wpa) {
2939 bss->ssid.security_policy = SECURITY_WPA_PSK;
2940 } else if (bss->ieee802_1x) {
2941 int cipher = WPA_CIPHER_NONE;
2942 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
2943 bss->ssid.wep.default_len = bss->default_wep_key_len;
2944 if (bss->default_wep_key_len)
2945 cipher = bss->default_wep_key_len >= 13 ?
2946 WPA_CIPHER_WEP104 : WPA_CIPHER_WEP40;
2947 bss->wpa_group = cipher;
2948 bss->wpa_pairwise = cipher;
2949 bss->rsn_pairwise = cipher;
2950 } else if (bss->ssid.wep.keys_set) {
2951 int cipher = WPA_CIPHER_WEP40;
2952 if (bss->ssid.wep.len[0] >= 13)
2953 cipher = WPA_CIPHER_WEP104;
2954 bss->ssid.security_policy = SECURITY_STATIC_WEP;
2955 bss->wpa_group = cipher;
2956 bss->wpa_pairwise = cipher;
2957 bss->rsn_pairwise = cipher;
2959 bss->ssid.security_policy = SECURITY_PLAINTEXT;
2960 bss->wpa_group = WPA_CIPHER_NONE;
2961 bss->wpa_pairwise = WPA_CIPHER_NONE;
2962 bss->rsn_pairwise = WPA_CIPHER_NONE;
2968 * hostapd_config_read - Read and parse a configuration file
2969 * @fname: Configuration file name (including path, if needed)
2970 * Returns: Allocated configuration data structure
2972 struct hostapd_config * hostapd_config_read(const char *fname)
2974 struct hostapd_config *conf;
2975 struct hostapd_bss_config *bss;
2977 char buf[512], *pos;
2982 f = fopen(fname, "r");
2984 wpa_printf(MSG_ERROR, "Could not open configuration file '%s' "
2985 "for reading.", fname);
2989 conf = hostapd_config_defaults();
2995 /* set default driver based on configuration */
2996 conf->driver = wpa_drivers[0];
2997 if (conf->driver == NULL) {
2998 wpa_printf(MSG_ERROR, "No driver wrappers registered!");
2999 hostapd_config_free(conf);
3004 bss = conf->last_bss = conf->bss;
3006 while (fgets(buf, sizeof(buf), f)) {
3007 bss = conf->last_bss;
3013 while (*pos != '\0') {
3023 pos = os_strchr(buf, '=');
3025 wpa_printf(MSG_ERROR, "Line %d: invalid line '%s'",
3032 errors += hostapd_config_fill(conf, bss, buf, pos, line);
3037 for (i = 0; i < conf->num_bss; i++)
3038 hostapd_set_security_params(&conf->bss[i]);
3040 if (hostapd_config_check(conf))
3043 #ifndef WPA_IGNORE_CONFIG_ERRORS
3045 wpa_printf(MSG_ERROR, "%d errors found in configuration file "
3046 "'%s'", errors, fname);
3047 hostapd_config_free(conf);
3050 #endif /* WPA_IGNORE_CONFIG_ERRORS */
3056 int hostapd_set_iface(struct hostapd_config *conf,
3057 struct hostapd_bss_config *bss, char *field, char *value)
3062 errors = hostapd_config_fill(conf, bss, field, value, 0);
3064 wpa_printf(MSG_INFO, "Failed to set configuration field '%s' "
3065 "to value '%s'", field, value);
3069 for (i = 0; i < conf->num_bss; i++)
3070 hostapd_set_security_params(&conf->bss[i]);
3072 if (hostapd_config_check(conf)) {
3073 wpa_printf(MSG_ERROR, "Configuration check failed");