2 * hostapd / Configuration file
3 * Copyright (c) 2003-2008, Jouni Malinen <j@w1.fi>
4 * Copyright (c) 2007-2008, Intel Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * Alternatively, this software may be distributed under the terms of BSD
13 * See README and COPYING for more details.
17 #ifndef CONFIG_NATIVE_WINDOWS
19 #endif /* CONFIG_NATIVE_WINDOWS */
24 #include "eap_server/eap.h"
25 #include "radius/radius_client.h"
26 #include "wpa_common.h"
29 #include "eap_common/eap_wsc_common.h"
32 #define MAX_STA_COUNT 2007
34 extern struct wpa_driver_ops *hostapd_drivers[];
37 static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
41 char buf[128], *pos, *pos2;
42 int line = 0, vlan_id;
43 struct hostapd_vlan *vlan;
45 f = fopen(fname, "r");
47 printf("VLAN file '%s' not readable.\n", fname);
51 while (fgets(buf, sizeof(buf), f)) {
57 while (*pos != '\0') {
68 vlan_id = VLAN_ID_WILDCARD;
71 vlan_id = strtol(buf, &pos, 10);
72 if (buf == pos || vlan_id < 1 ||
73 vlan_id > MAX_VLAN_ID) {
74 printf("Invalid VLAN ID at line %d in '%s'\n",
81 while (*pos == ' ' || *pos == '\t')
84 while (*pos2 != ' ' && *pos2 != '\t' && *pos2 != '\0')
87 if (*pos == '\0' || os_strlen(pos) > IFNAMSIZ) {
88 printf("Invalid VLAN ifname at line %d in '%s'\n",
94 vlan = os_malloc(sizeof(*vlan));
96 printf("Out of memory while reading VLAN interfaces "
97 "from '%s'\n", fname);
102 os_memset(vlan, 0, sizeof(*vlan));
103 vlan->vlan_id = vlan_id;
104 os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname));
106 bss->vlan_tail->next = vlan;
109 bss->vlan_tail = vlan;
118 static void hostapd_config_free_vlan(struct hostapd_bss_config *bss)
120 struct hostapd_vlan *vlan, *prev;
134 /* convert floats with one decimal place to value*10 int, i.e.,
135 * "1.5" will return 15 */
136 static int hostapd_config_read_int10(const char *value)
142 pos = os_strchr(value, '.');
146 if (*pos >= '0' && *pos <= '9')
154 static void hostapd_config_defaults_bss(struct hostapd_bss_config *bss)
156 bss->logger_syslog_level = HOSTAPD_LEVEL_INFO;
157 bss->logger_stdout_level = HOSTAPD_LEVEL_INFO;
158 bss->logger_syslog = (unsigned int) -1;
159 bss->logger_stdout = (unsigned int) -1;
161 bss->auth_algs = WPA_AUTH_ALG_OPEN | WPA_AUTH_ALG_SHARED;
163 bss->wep_rekeying_period = 300;
164 /* use key0 in individual key and key1 in broadcast key */
165 bss->broadcast_key_idx_min = 1;
166 bss->broadcast_key_idx_max = 2;
167 bss->eap_reauth_period = 3600;
169 bss->wpa_group_rekey = 600;
170 bss->wpa_gmk_rekey = 86400;
171 bss->wpa_key_mgmt = WPA_KEY_MGMT_PSK;
172 bss->wpa_pairwise = WPA_CIPHER_TKIP;
173 bss->wpa_group = WPA_CIPHER_TKIP;
174 bss->rsn_pairwise = 0;
176 bss->max_num_sta = MAX_STA_COUNT;
178 bss->dtim_period = 2;
180 bss->radius_server_auth_port = 1812;
181 bss->ap_max_inactivity = AP_MAX_INACTIVITY;
182 bss->eapol_version = EAPOL_VERSION;
184 bss->max_listen_interval = 65535;
186 #ifdef CONFIG_IEEE80211W
187 bss->assoc_sa_query_max_timeout = 1000;
188 bss->assoc_sa_query_retry_timeout = 201;
189 #endif /* CONFIG_IEEE80211W */
191 /* both anonymous and authenticated provisioning */
192 bss->eap_fast_prov = 3;
193 bss->pac_key_lifetime = 7 * 24 * 60 * 60;
194 bss->pac_key_refresh_time = 1 * 24 * 60 * 60;
195 #endif /* EAP_FAST */
199 static struct hostapd_config * hostapd_config_defaults(void)
201 struct hostapd_config *conf;
202 struct hostapd_bss_config *bss;
204 const int aCWmin = 15, aCWmax = 1024;
205 const struct hostapd_wme_ac_params ac_bk =
206 { aCWmin, aCWmax, 7, 0, 0 }; /* background traffic */
207 const struct hostapd_wme_ac_params ac_be =
208 { aCWmin, aCWmax, 3, 0, 0 }; /* best effort traffic */
209 const struct hostapd_wme_ac_params ac_vi = /* video traffic */
210 { aCWmin >> 1, aCWmin, 2, 3000 / 32, 1 };
211 const struct hostapd_wme_ac_params ac_vo = /* voice traffic */
212 { aCWmin >> 2, aCWmin >> 1, 2, 1500 / 32, 1 };
214 conf = os_zalloc(sizeof(*conf));
215 bss = os_zalloc(sizeof(*bss));
216 if (conf == NULL || bss == NULL) {
217 printf("Failed to allocate memory for configuration data.\n");
223 /* set default driver based on configuration */
224 conf->driver = hostapd_drivers[0];
225 if (conf->driver == NULL) {
226 printf("No driver wrappers registered!\n");
232 bss->radius = os_zalloc(sizeof(*bss->radius));
233 if (bss->radius == NULL) {
239 hostapd_config_defaults_bss(bss);
244 conf->beacon_int = 100;
245 conf->rts_threshold = -1; /* use driver default: 2347 */
246 conf->fragm_threshold = -1; /* user driver default: 2346 */
247 conf->send_probe_response = 1;
248 conf->bridge_packets = INTERNAL_BRIDGE_DO_NOT_CONTROL;
250 os_memcpy(conf->country, "US ", 3);
252 for (i = 0; i < NUM_TX_QUEUES; i++)
253 conf->tx_queue[i].aifs = -1; /* use hw default */
255 conf->wme_ac_params[0] = ac_be;
256 conf->wme_ac_params[1] = ac_bk;
257 conf->wme_ac_params[2] = ac_vi;
258 conf->wme_ac_params[3] = ac_vo;
260 #ifdef CONFIG_IEEE80211N
261 conf->ht_capab = HT_CAP_INFO_SMPS_DISABLED;
262 #endif /* CONFIG_IEEE80211N */
268 int hostapd_mac_comp(const void *a, const void *b)
270 return os_memcmp(a, b, sizeof(macaddr));
274 int hostapd_mac_comp_empty(const void *a)
276 macaddr empty = { 0 };
277 return os_memcmp(a, empty, sizeof(macaddr));
281 static int hostapd_acl_comp(const void *a, const void *b)
283 const struct mac_acl_entry *aa = a;
284 const struct mac_acl_entry *bb = b;
285 return os_memcmp(aa->addr, bb->addr, sizeof(macaddr));
289 static int hostapd_config_read_maclist(const char *fname,
290 struct mac_acl_entry **acl, int *num)
296 struct mac_acl_entry *newacl;
302 f = fopen(fname, "r");
304 printf("MAC list file '%s' not found.\n", fname);
308 while (fgets(buf, sizeof(buf), f)) {
314 while (*pos != '\0') {
324 if (hwaddr_aton(buf, addr)) {
325 printf("Invalid MAC address '%s' at line %d in '%s'\n",
333 while (*pos != '\0' && *pos != ' ' && *pos != '\t')
335 while (*pos == ' ' || *pos == '\t')
340 newacl = os_realloc(*acl, (*num + 1) * sizeof(**acl));
341 if (newacl == NULL) {
342 printf("MAC list reallocation failed\n");
348 os_memcpy((*acl)[*num].addr, addr, ETH_ALEN);
349 (*acl)[*num].vlan_id = vlan_id;
355 qsort(*acl, *num, sizeof(**acl), hostapd_acl_comp);
361 static int hostapd_config_read_wpa_psk(const char *fname,
362 struct hostapd_ssid *ssid)
366 int line = 0, ret = 0, len, ok;
368 struct hostapd_wpa_psk *psk;
373 f = fopen(fname, "r");
375 printf("WPA PSK file '%s' not found.\n", fname);
379 while (fgets(buf, sizeof(buf), f)) {
385 while (*pos != '\0') {
395 if (hwaddr_aton(buf, addr)) {
396 printf("Invalid MAC address '%s' on line %d in '%s'\n",
402 psk = os_zalloc(sizeof(*psk));
404 printf("WPA PSK allocation failed\n");
408 if (is_zero_ether_addr(addr))
411 os_memcpy(psk->addr, addr, ETH_ALEN);
415 printf("No PSK on line %d in '%s'\n", line, fname);
423 len = os_strlen(pos);
424 if (len == 64 && hexstr2bin(pos, psk->psk, PMK_LEN) == 0)
426 else if (len >= 8 && len < 64) {
427 pbkdf2_sha1(pos, ssid->ssid, ssid->ssid_len,
428 4096, psk->psk, PMK_LEN);
432 printf("Invalid PSK '%s' on line %d in '%s'\n",
439 psk->next = ssid->wpa_psk;
449 int hostapd_setup_wpa_psk(struct hostapd_bss_config *conf)
451 struct hostapd_ssid *ssid = &conf->ssid;
453 if (ssid->wpa_passphrase != NULL) {
454 if (ssid->wpa_psk != NULL) {
455 printf("Warning: both WPA PSK and passphrase set. "
456 "Using passphrase.\n");
457 os_free(ssid->wpa_psk);
459 ssid->wpa_psk = os_zalloc(sizeof(struct hostapd_wpa_psk));
460 if (ssid->wpa_psk == NULL) {
461 printf("Unable to alloc space for PSK\n");
464 wpa_hexdump_ascii(MSG_DEBUG, "SSID",
465 (u8 *) ssid->ssid, ssid->ssid_len);
466 wpa_hexdump_ascii(MSG_DEBUG, "PSK (ASCII passphrase)",
467 (u8 *) ssid->wpa_passphrase,
468 os_strlen(ssid->wpa_passphrase));
469 pbkdf2_sha1(ssid->wpa_passphrase,
470 ssid->ssid, ssid->ssid_len,
471 4096, ssid->wpa_psk->psk, PMK_LEN);
472 wpa_hexdump(MSG_DEBUG, "PSK (from passphrase)",
473 ssid->wpa_psk->psk, PMK_LEN);
474 ssid->wpa_psk->group = 1;
476 os_memset(ssid->wpa_passphrase, 0,
477 os_strlen(ssid->wpa_passphrase));
478 os_free(ssid->wpa_passphrase);
479 ssid->wpa_passphrase = NULL;
482 if (ssid->wpa_psk_file) {
483 if (hostapd_config_read_wpa_psk(ssid->wpa_psk_file,
493 static int hostapd_config_read_eap_user(const char *fname,
494 struct hostapd_bss_config *conf)
497 char buf[512], *pos, *start, *pos2;
498 int line = 0, ret = 0, num_methods;
499 struct hostapd_eap_user *user, *tail = NULL;
504 f = fopen(fname, "r");
506 printf("EAP user file '%s' not found.\n", fname);
510 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
511 while (fgets(buf, sizeof(buf), f)) {
517 while (*pos != '\0') {
529 if (buf[0] != '"' && buf[0] != '*') {
530 printf("Invalid EAP identity (no \" in start) on "
531 "line %d in '%s'\n", line, fname);
535 user = os_zalloc(sizeof(*user));
537 printf("EAP user allocation failed\n");
540 user->force_version = -1;
547 while (*pos != '"' && *pos != '\0')
550 printf("Invalid EAP identity (no \" in end) on"
551 " line %d in '%s'\n", line, fname);
555 user->identity = os_malloc(pos - start);
556 if (user->identity == NULL) {
557 printf("Failed to allocate memory for EAP "
561 os_memcpy(user->identity, start, pos - start);
562 user->identity_len = pos - start;
564 if (pos[0] == '"' && pos[1] == '*') {
565 user->wildcard_prefix = 1;
570 while (*pos == ' ' || *pos == '\t')
574 printf("No EAP method on line %d in '%s'\n",
580 while (*pos != ' ' && *pos != '\t' && *pos != '\0')
590 char *pos3 = os_strchr(start, ',');
594 user->methods[num_methods].method =
597 &user->methods[num_methods].vendor);
598 if (user->methods[num_methods].vendor ==
600 user->methods[num_methods].method == EAP_TYPE_NONE)
602 if (os_strcmp(start, "TTLS-PAP") == 0) {
603 user->ttls_auth |= EAP_TTLS_AUTH_PAP;
606 if (os_strcmp(start, "TTLS-CHAP") == 0) {
607 user->ttls_auth |= EAP_TTLS_AUTH_CHAP;
610 if (os_strcmp(start, "TTLS-MSCHAP") == 0) {
612 EAP_TTLS_AUTH_MSCHAP;
615 if (os_strcmp(start, "TTLS-MSCHAPV2") == 0) {
617 EAP_TTLS_AUTH_MSCHAPV2;
620 printf("Unsupported EAP type '%s' on line %d "
621 "in '%s'\n", start, line, fname);
626 if (num_methods >= EAP_USER_MAX_METHODS)
633 if (num_methods == 0 && user->ttls_auth == 0) {
634 printf("No EAP types configured on line %d in '%s'\n",
642 while (*pos == ' ' || *pos == '\t')
647 if (os_strncmp(pos, "[ver=0]", 7) == 0) {
648 user->force_version = 0;
652 if (os_strncmp(pos, "[ver=1]", 7) == 0) {
653 user->force_version = 1;
657 if (os_strncmp(pos, "[2]", 3) == 0) {
665 while (*pos != '"' && *pos != '\0')
668 printf("Invalid EAP password (no \" in end) "
669 "on line %d in '%s'\n", line, fname);
673 user->password = os_malloc(pos - start);
674 if (user->password == NULL) {
675 printf("Failed to allocate memory for EAP "
679 os_memcpy(user->password, start, pos - start);
680 user->password_len = pos - start;
683 } else if (os_strncmp(pos, "hash:", 5) == 0) {
686 while (*pos2 != '\0' && *pos2 != ' ' &&
687 *pos2 != '\t' && *pos2 != '#')
689 if (pos2 - pos != 32) {
690 printf("Invalid password hash on line %d in "
691 "'%s'\n", line, fname);
694 user->password = os_malloc(16);
695 if (user->password == NULL) {
696 printf("Failed to allocate memory for EAP "
700 if (hexstr2bin(pos, user->password, 16) < 0) {
701 printf("Invalid hash password on line %d in "
702 "'%s'\n", line, fname);
705 user->password_len = 16;
706 user->password_hash = 1;
710 while (*pos2 != '\0' && *pos2 != ' ' &&
711 *pos2 != '\t' && *pos2 != '#')
713 if ((pos2 - pos) & 1) {
714 printf("Invalid hex password on line %d in "
715 "'%s'\n", line, fname);
718 user->password = os_malloc((pos2 - pos) / 2);
719 if (user->password == NULL) {
720 printf("Failed to allocate memory for EAP "
724 if (hexstr2bin(pos, user->password,
725 (pos2 - pos) / 2) < 0) {
726 printf("Invalid hex password on line %d in "
727 "'%s'\n", line, fname);
730 user->password_len = (pos2 - pos) / 2;
734 while (*pos == ' ' || *pos == '\t')
736 if (os_strncmp(pos, "[2]", 3) == 0) {
742 tail = conf->eap_user = user;
751 os_free(user->password);
752 os_free(user->identity);
763 #endif /* EAP_SERVER */
767 hostapd_config_read_radius_addr(struct hostapd_radius_server **server,
768 int *num_server, const char *val, int def_port,
769 struct hostapd_radius_server **curr_serv)
771 struct hostapd_radius_server *nserv;
773 static int server_index = 1;
775 nserv = os_realloc(*server, (*num_server + 1) * sizeof(*nserv));
780 nserv = &nserv[*num_server];
782 (*curr_serv) = nserv;
784 os_memset(nserv, 0, sizeof(*nserv));
785 nserv->port = def_port;
786 ret = hostapd_parse_ip_addr(val, &nserv->addr);
787 nserv->index = server_index++;
793 static int hostapd_config_parse_key_mgmt(int line, const char *value)
796 char *start, *end, *buf;
798 buf = os_strdup(value);
803 while (start != '\0') {
804 while (*start == ' ' || *start == '\t')
809 while (*end != ' ' && *end != '\t' && *end != '\0')
813 if (os_strcmp(start, "WPA-PSK") == 0)
814 val |= WPA_KEY_MGMT_PSK;
815 else if (os_strcmp(start, "WPA-EAP") == 0)
816 val |= WPA_KEY_MGMT_IEEE8021X;
817 #ifdef CONFIG_IEEE80211R
818 else if (os_strcmp(start, "FT-PSK") == 0)
819 val |= WPA_KEY_MGMT_FT_PSK;
820 else if (os_strcmp(start, "FT-EAP") == 0)
821 val |= WPA_KEY_MGMT_FT_IEEE8021X;
822 #endif /* CONFIG_IEEE80211R */
823 #ifdef CONFIG_IEEE80211W
824 else if (os_strcmp(start, "WPA-PSK-SHA256") == 0)
825 val |= WPA_KEY_MGMT_PSK_SHA256;
826 else if (os_strcmp(start, "WPA-EAP-SHA256") == 0)
827 val |= WPA_KEY_MGMT_IEEE8021X_SHA256;
828 #endif /* CONFIG_IEEE80211W */
830 printf("Line %d: invalid key_mgmt '%s'\n",
843 printf("Line %d: no key_mgmt values configured.\n", line);
851 static int hostapd_config_parse_cipher(int line, const char *value)
854 char *start, *end, *buf;
856 buf = os_strdup(value);
861 while (start != '\0') {
862 while (*start == ' ' || *start == '\t')
867 while (*end != ' ' && *end != '\t' && *end != '\0')
871 if (os_strcmp(start, "CCMP") == 0)
872 val |= WPA_CIPHER_CCMP;
873 else if (os_strcmp(start, "TKIP") == 0)
874 val |= WPA_CIPHER_TKIP;
875 else if (os_strcmp(start, "WEP104") == 0)
876 val |= WPA_CIPHER_WEP104;
877 else if (os_strcmp(start, "WEP40") == 0)
878 val |= WPA_CIPHER_WEP40;
879 else if (os_strcmp(start, "NONE") == 0)
880 val |= WPA_CIPHER_NONE;
882 printf("Line %d: invalid cipher '%s'.", line, start);
894 printf("Line %d: no cipher values configured.", line);
901 static int hostapd_config_check_bss(struct hostapd_bss_config *bss,
902 struct hostapd_config *conf)
904 if (bss->ieee802_1x && !bss->eap_server &&
905 !bss->radius->auth_servers) {
906 printf("Invalid IEEE 802.1X configuration (no EAP "
907 "authenticator configured).\n");
911 if (bss->wpa && (bss->wpa_key_mgmt & WPA_KEY_MGMT_PSK) &&
912 bss->ssid.wpa_psk == NULL && bss->ssid.wpa_passphrase == NULL &&
913 bss->ssid.wpa_psk_file == NULL) {
914 printf("WPA-PSK enabled, but PSK or passphrase is not "
919 if (hostapd_mac_comp_empty(bss->bssid) != 0) {
922 for (i = 0; i < conf->num_bss; i++) {
923 if ((&conf->bss[i] != bss) &&
924 (hostapd_mac_comp(conf->bss[i].bssid,
926 printf("Duplicate BSSID " MACSTR
927 " on interface '%s' and '%s'.\n",
929 conf->bss[i].iface, bss->iface);
935 #ifdef CONFIG_IEEE80211R
936 if ((bss->wpa_key_mgmt &
937 (WPA_KEY_MGMT_FT_PSK | WPA_KEY_MGMT_FT_IEEE8021X)) &&
938 (bss->nas_identifier == NULL ||
939 os_strlen(bss->nas_identifier) < 1 ||
940 os_strlen(bss->nas_identifier) > FT_R0KH_ID_MAX_LEN)) {
941 printf("FT (IEEE 802.11r) requires nas_identifier to be "
942 "configured as a 1..48 octet string\n");
945 #endif /* CONFIG_IEEE80211R */
947 #ifdef CONFIG_IEEE80211N
948 if (conf->ieee80211n && bss->wpa &&
949 !(bss->wpa_pairwise & WPA_CIPHER_CCMP) &&
950 !(bss->rsn_pairwise & WPA_CIPHER_CCMP)) {
951 printf("HT (IEEE 802.11n) with WPA/WPA2 requires CCMP to be "
955 #endif /* CONFIG_IEEE80211N */
961 static int hostapd_config_check(struct hostapd_config *conf)
965 for (i = 0; i < conf->num_bss; i++) {
966 if (hostapd_config_check_bss(&conf->bss[i], conf))
974 static int hostapd_config_read_wep(struct hostapd_wep_keys *wep, int keyidx,
977 size_t len = os_strlen(val);
979 if (keyidx < 0 || keyidx > 3 || wep->key[keyidx] != NULL)
983 if (len < 2 || val[len - 1] != '"')
986 wep->key[keyidx] = os_malloc(len);
987 if (wep->key[keyidx] == NULL)
989 os_memcpy(wep->key[keyidx], val + 1, len);
990 wep->len[keyidx] = len;
995 wep->key[keyidx] = os_malloc(len);
996 if (wep->key[keyidx] == NULL)
998 wep->len[keyidx] = len;
999 if (hexstr2bin(val, wep->key[keyidx], len) < 0)
1009 static int hostapd_parse_rates(int **rate_list, char *val)
1015 os_free(*rate_list);
1020 while (*pos != '\0') {
1026 list = os_malloc(sizeof(int) * (count + 2));
1031 while (*pos != '\0') {
1032 end = os_strchr(pos, ' ');
1036 list[count++] = atoi(pos);
1048 static int hostapd_config_bss(struct hostapd_config *conf, const char *ifname)
1050 struct hostapd_bss_config *bss;
1052 if (*ifname == '\0')
1055 bss = os_realloc(conf->bss, (conf->num_bss + 1) *
1056 sizeof(struct hostapd_bss_config));
1058 printf("Failed to allocate memory for multi-BSS entry\n");
1063 bss = &(conf->bss[conf->num_bss]);
1064 os_memset(bss, 0, sizeof(*bss));
1065 bss->radius = os_zalloc(sizeof(*bss->radius));
1066 if (bss->radius == NULL) {
1067 printf("Failed to allocate memory for multi-BSS RADIUS "
1073 conf->last_bss = bss;
1075 hostapd_config_defaults_bss(bss);
1076 os_strlcpy(bss->iface, ifname, sizeof(bss->iface));
1077 os_memcpy(bss->ssid.vlan, bss->iface, IFNAMSIZ + 1);
1083 static int valid_cw(int cw)
1085 return (cw == 1 || cw == 3 || cw == 7 || cw == 15 || cw == 31 ||
1086 cw == 63 || cw == 127 || cw == 255 || cw == 511 || cw == 1023);
1091 IEEE80211_TX_QUEUE_DATA0 = 0, /* used for EDCA AC_VO data */
1092 IEEE80211_TX_QUEUE_DATA1 = 1, /* used for EDCA AC_VI data */
1093 IEEE80211_TX_QUEUE_DATA2 = 2, /* used for EDCA AC_BE data */
1094 IEEE80211_TX_QUEUE_DATA3 = 3, /* used for EDCA AC_BK data */
1095 IEEE80211_TX_QUEUE_DATA4 = 4,
1096 IEEE80211_TX_QUEUE_AFTER_BEACON = 6,
1097 IEEE80211_TX_QUEUE_BEACON = 7
1100 static int hostapd_config_tx_queue(struct hostapd_config *conf, char *name,
1105 struct hostapd_tx_queue_params *queue;
1107 /* skip 'tx_queue_' prefix */
1109 if (os_strncmp(pos, "data", 4) == 0 &&
1110 pos[4] >= '0' && pos[4] <= '9' && pos[5] == '_') {
1113 } else if (os_strncmp(pos, "after_beacon_", 13) == 0) {
1114 num = IEEE80211_TX_QUEUE_AFTER_BEACON;
1116 } else if (os_strncmp(pos, "beacon_", 7) == 0) {
1117 num = IEEE80211_TX_QUEUE_BEACON;
1120 printf("Unknown tx_queue name '%s'\n", pos);
1124 queue = &conf->tx_queue[num];
1126 if (os_strcmp(pos, "aifs") == 0) {
1127 queue->aifs = atoi(val);
1128 if (queue->aifs < 0 || queue->aifs > 255) {
1129 printf("Invalid AIFS value %d\n", queue->aifs);
1132 } else if (os_strcmp(pos, "cwmin") == 0) {
1133 queue->cwmin = atoi(val);
1134 if (!valid_cw(queue->cwmin)) {
1135 printf("Invalid cwMin value %d\n", queue->cwmin);
1138 } else if (os_strcmp(pos, "cwmax") == 0) {
1139 queue->cwmax = atoi(val);
1140 if (!valid_cw(queue->cwmax)) {
1141 printf("Invalid cwMax value %d\n", queue->cwmax);
1144 } else if (os_strcmp(pos, "burst") == 0) {
1145 queue->burst = hostapd_config_read_int10(val);
1147 printf("Unknown tx_queue field '%s'\n", pos);
1151 queue->configured = 1;
1157 static int hostapd_config_wme_ac(struct hostapd_config *conf, char *name,
1162 struct hostapd_wme_ac_params *ac;
1164 /* skip 'wme_ac_' prefix */
1166 if (os_strncmp(pos, "be_", 3) == 0) {
1169 } else if (os_strncmp(pos, "bk_", 3) == 0) {
1172 } else if (os_strncmp(pos, "vi_", 3) == 0) {
1175 } else if (os_strncmp(pos, "vo_", 3) == 0) {
1179 printf("Unknown wme name '%s'\n", pos);
1183 ac = &conf->wme_ac_params[num];
1185 if (os_strcmp(pos, "aifs") == 0) {
1187 if (v < 1 || v > 255) {
1188 printf("Invalid AIFS value %d\n", v);
1192 } else if (os_strcmp(pos, "cwmin") == 0) {
1194 if (v < 0 || v > 12) {
1195 printf("Invalid cwMin value %d\n", v);
1199 } else if (os_strcmp(pos, "cwmax") == 0) {
1201 if (v < 0 || v > 12) {
1202 printf("Invalid cwMax value %d\n", v);
1206 } else if (os_strcmp(pos, "txop_limit") == 0) {
1208 if (v < 0 || v > 0xffff) {
1209 printf("Invalid txop value %d\n", v);
1213 } else if (os_strcmp(pos, "acm") == 0) {
1215 if (v < 0 || v > 1) {
1216 printf("Invalid acm value %d\n", v);
1219 ac->admission_control_mandatory = v;
1221 printf("Unknown wme_ac_ field '%s'\n", pos);
1229 #ifdef CONFIG_IEEE80211R
1230 static int add_r0kh(struct hostapd_bss_config *bss, char *value)
1232 struct ft_remote_r0kh *r0kh;
1235 r0kh = os_zalloc(sizeof(*r0kh));
1239 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1241 next = os_strchr(pos, ' ');
1244 if (next == NULL || hwaddr_aton(pos, r0kh->addr)) {
1245 printf("Invalid R0KH MAC address: '%s'\n", pos);
1251 next = os_strchr(pos, ' ');
1254 if (next == NULL || next - pos > FT_R0KH_ID_MAX_LEN) {
1255 printf("Invalid R0KH-ID: '%s'\n", pos);
1259 r0kh->id_len = next - pos - 1;
1260 os_memcpy(r0kh->id, pos, r0kh->id_len);
1263 if (hexstr2bin(pos, r0kh->key, sizeof(r0kh->key))) {
1264 printf("Invalid R0KH key: '%s'\n", pos);
1269 r0kh->next = bss->r0kh_list;
1270 bss->r0kh_list = r0kh;
1276 static int add_r1kh(struct hostapd_bss_config *bss, char *value)
1278 struct ft_remote_r1kh *r1kh;
1281 r1kh = os_zalloc(sizeof(*r1kh));
1285 /* 02:01:02:03:04:05 02:01:02:03:04:05
1286 * 000102030405060708090a0b0c0d0e0f */
1288 next = os_strchr(pos, ' ');
1291 if (next == NULL || hwaddr_aton(pos, r1kh->addr)) {
1292 printf("Invalid R1KH MAC address: '%s'\n", pos);
1298 next = os_strchr(pos, ' ');
1301 if (next == NULL || hwaddr_aton(pos, r1kh->id)) {
1302 printf("Invalid R1KH-ID: '%s'\n", pos);
1308 if (hexstr2bin(pos, r1kh->key, sizeof(r1kh->key))) {
1309 printf("Invalid R1KH key: '%s'\n", pos);
1314 r1kh->next = bss->r1kh_list;
1315 bss->r1kh_list = r1kh;
1319 #endif /* CONFIG_IEEE80211R */
1322 #ifdef CONFIG_IEEE80211N
1323 static int hostapd_config_ht_capab(struct hostapd_config *conf,
1326 if (os_strstr(capab, "[LDPC]"))
1327 conf->ht_capab |= HT_CAP_INFO_LDPC_CODING_CAP;
1328 if (os_strstr(capab, "[HT40-]")) {
1329 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
1330 conf->secondary_channel = -1;
1332 if (os_strstr(capab, "[HT40+]")) {
1333 conf->ht_capab |= HT_CAP_INFO_SUPP_CHANNEL_WIDTH_SET;
1334 conf->secondary_channel = 1;
1336 if (os_strstr(capab, "[SMPS-STATIC]")) {
1337 conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
1338 conf->ht_capab |= HT_CAP_INFO_SMPS_STATIC;
1340 if (os_strstr(capab, "[SMPS-DYNAMIC]")) {
1341 conf->ht_capab &= ~HT_CAP_INFO_SMPS_MASK;
1342 conf->ht_capab |= HT_CAP_INFO_SMPS_DYNAMIC;
1344 if (os_strstr(capab, "[GF]"))
1345 conf->ht_capab |= HT_CAP_INFO_GREEN_FIELD;
1346 if (os_strstr(capab, "[SHORT-GI-20]"))
1347 conf->ht_capab |= HT_CAP_INFO_SHORT_GI20MHZ;
1348 if (os_strstr(capab, "[SHORT-GI-40]"))
1349 conf->ht_capab |= HT_CAP_INFO_SHORT_GI40MHZ;
1350 if (os_strstr(capab, "[TX-STBC]"))
1351 conf->ht_capab |= HT_CAP_INFO_TX_STBC;
1352 if (os_strstr(capab, "[RX-STBC1]")) {
1353 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1354 conf->ht_capab |= HT_CAP_INFO_RX_STBC_1;
1356 if (os_strstr(capab, "[RX-STBC12]")) {
1357 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1358 conf->ht_capab |= HT_CAP_INFO_RX_STBC_12;
1360 if (os_strstr(capab, "[RX-STBC123]")) {
1361 conf->ht_capab &= ~HT_CAP_INFO_RX_STBC_MASK;
1362 conf->ht_capab |= HT_CAP_INFO_RX_STBC_123;
1364 if (os_strstr(capab, "[DELAYED-BA]"))
1365 conf->ht_capab |= HT_CAP_INFO_DELAYED_BA;
1366 if (os_strstr(capab, "[MAX-AMSDU-7935]"))
1367 conf->ht_capab |= HT_CAP_INFO_MAX_AMSDU_SIZE;
1368 if (os_strstr(capab, "[DSSS_CCK-40]"))
1369 conf->ht_capab |= HT_CAP_INFO_DSSS_CCK40MHZ;
1370 if (os_strstr(capab, "[PSMP]"))
1371 conf->ht_capab |= HT_CAP_INFO_PSMP_SUPP;
1372 if (os_strstr(capab, "[LSIG-TXOP-PROT]"))
1373 conf->ht_capab |= HT_CAP_INFO_LSIG_TXOP_PROTECT_SUPPORT;
1377 #endif /* CONFIG_IEEE80211N */
1380 struct hostapd_config * hostapd_config_read(const char *fname)
1382 struct hostapd_config *conf;
1383 struct hostapd_bss_config *bss;
1385 char buf[256], *pos;
1391 f = fopen(fname, "r");
1393 printf("Could not open configuration file '%s' for reading.\n",
1398 conf = hostapd_config_defaults();
1403 bss = conf->last_bss = conf->bss;
1405 while (fgets(buf, sizeof(buf), f)) {
1406 bss = conf->last_bss;
1412 while (*pos != '\0') {
1422 pos = os_strchr(buf, '=');
1424 printf("Line %d: invalid line '%s'\n", line, buf);
1431 if (os_strcmp(buf, "interface") == 0) {
1432 os_strlcpy(conf->bss[0].iface, pos,
1433 sizeof(conf->bss[0].iface));
1434 } else if (os_strcmp(buf, "bridge") == 0) {
1435 os_strlcpy(bss->bridge, pos, sizeof(bss->bridge));
1436 } else if (os_strcmp(buf, "driver") == 0) {
1438 /* clear to get error below if setting is invalid */
1439 conf->driver = NULL;
1440 for (i = 0; hostapd_drivers[i]; i++) {
1441 if (os_strcmp(pos, hostapd_drivers[i]->name) ==
1443 conf->driver = hostapd_drivers[i];
1447 if (conf->driver == NULL) {
1448 printf("Line %d: invalid/unknown driver "
1449 "'%s'\n", line, pos);
1452 } else if (os_strcmp(buf, "debug") == 0) {
1453 wpa_printf(MSG_DEBUG, "Line %d: DEPRECATED: 'debug' "
1454 "configuration variable is not used "
1456 } else if (os_strcmp(buf, "logger_syslog_level") == 0) {
1457 bss->logger_syslog_level = atoi(pos);
1458 } else if (os_strcmp(buf, "logger_stdout_level") == 0) {
1459 bss->logger_stdout_level = atoi(pos);
1460 } else if (os_strcmp(buf, "logger_syslog") == 0) {
1461 bss->logger_syslog = atoi(pos);
1462 } else if (os_strcmp(buf, "logger_stdout") == 0) {
1463 bss->logger_stdout = atoi(pos);
1464 } else if (os_strcmp(buf, "dump_file") == 0) {
1465 bss->dump_log_name = os_strdup(pos);
1466 } else if (os_strcmp(buf, "ssid") == 0) {
1467 bss->ssid.ssid_len = os_strlen(pos);
1468 if (bss->ssid.ssid_len > HOSTAPD_MAX_SSID_LEN ||
1469 bss->ssid.ssid_len < 1) {
1470 printf("Line %d: invalid SSID '%s'\n", line,
1474 os_memcpy(bss->ssid.ssid, pos,
1475 bss->ssid.ssid_len);
1476 bss->ssid.ssid[bss->ssid.ssid_len] = '\0';
1477 bss->ssid.ssid_set = 1;
1479 } else if (os_strcmp(buf, "macaddr_acl") == 0) {
1480 bss->macaddr_acl = atoi(pos);
1481 if (bss->macaddr_acl != ACCEPT_UNLESS_DENIED &&
1482 bss->macaddr_acl != DENY_UNLESS_ACCEPTED &&
1483 bss->macaddr_acl != USE_EXTERNAL_RADIUS_AUTH) {
1484 printf("Line %d: unknown macaddr_acl %d\n",
1485 line, bss->macaddr_acl);
1487 } else if (os_strcmp(buf, "accept_mac_file") == 0) {
1488 if (hostapd_config_read_maclist(pos, &bss->accept_mac,
1489 &bss->num_accept_mac))
1491 printf("Line %d: Failed to read "
1492 "accept_mac_file '%s'\n",
1496 } else if (os_strcmp(buf, "deny_mac_file") == 0) {
1497 if (hostapd_config_read_maclist(pos, &bss->deny_mac,
1498 &bss->num_deny_mac))
1500 printf("Line %d: Failed to read "
1501 "deny_mac_file '%s'\n",
1505 } else if (os_strcmp(buf, "ap_max_inactivity") == 0) {
1506 bss->ap_max_inactivity = atoi(pos);
1507 } else if (os_strcmp(buf, "country_code") == 0) {
1508 os_memcpy(conf->country, pos, 2);
1509 /* FIX: make this configurable */
1510 conf->country[2] = ' ';
1511 } else if (os_strcmp(buf, "ieee80211d") == 0) {
1512 conf->ieee80211d = atoi(pos);
1513 } else if (os_strcmp(buf, "ieee8021x") == 0) {
1514 bss->ieee802_1x = atoi(pos);
1515 } else if (os_strcmp(buf, "eapol_version") == 0) {
1516 bss->eapol_version = atoi(pos);
1517 if (bss->eapol_version < 1 ||
1518 bss->eapol_version > 2) {
1519 printf("Line %d: invalid EAPOL "
1520 "version (%d): '%s'.\n",
1521 line, bss->eapol_version, pos);
1524 wpa_printf(MSG_DEBUG, "eapol_version=%d",
1525 bss->eapol_version);
1527 } else if (os_strcmp(buf, "eap_authenticator") == 0) {
1528 bss->eap_server = atoi(pos);
1529 printf("Line %d: obsolete eap_authenticator used; "
1530 "this has been renamed to eap_server\n", line);
1531 } else if (os_strcmp(buf, "eap_server") == 0) {
1532 bss->eap_server = atoi(pos);
1533 } else if (os_strcmp(buf, "eap_user_file") == 0) {
1534 if (hostapd_config_read_eap_user(pos, bss))
1536 } else if (os_strcmp(buf, "ca_cert") == 0) {
1537 os_free(bss->ca_cert);
1538 bss->ca_cert = os_strdup(pos);
1539 } else if (os_strcmp(buf, "server_cert") == 0) {
1540 os_free(bss->server_cert);
1541 bss->server_cert = os_strdup(pos);
1542 } else if (os_strcmp(buf, "private_key") == 0) {
1543 os_free(bss->private_key);
1544 bss->private_key = os_strdup(pos);
1545 } else if (os_strcmp(buf, "private_key_passwd") == 0) {
1546 os_free(bss->private_key_passwd);
1547 bss->private_key_passwd = os_strdup(pos);
1548 } else if (os_strcmp(buf, "check_crl") == 0) {
1549 bss->check_crl = atoi(pos);
1550 } else if (os_strcmp(buf, "dh_file") == 0) {
1551 os_free(bss->dh_file);
1552 bss->dh_file = os_strdup(pos);
1554 } else if (os_strcmp(buf, "pac_opaque_encr_key") == 0) {
1555 os_free(bss->pac_opaque_encr_key);
1556 bss->pac_opaque_encr_key = os_malloc(16);
1557 if (bss->pac_opaque_encr_key == NULL) {
1558 printf("Line %d: No memory for "
1559 "pac_opque_encr_key\n", line);
1561 } else if (hexstr2bin(pos, bss->pac_opaque_encr_key,
1563 printf("Line %d: Invalid pac_opque_encr_key\n",
1567 } else if (os_strcmp(buf, "eap_fast_a_id") == 0) {
1568 size_t idlen = os_strlen(pos);
1570 printf("Line %d: Invalid eap_fast_a_id\n",
1574 os_free(bss->eap_fast_a_id);
1575 bss->eap_fast_a_id = os_malloc(idlen / 2);
1576 if (bss->eap_fast_a_id == NULL ||
1577 hexstr2bin(pos, bss->eap_fast_a_id,
1579 printf("Line %d: Failed to parse "
1580 "eap_fast_a_id\n", line);
1583 bss->eap_fast_a_id_len = idlen / 2;
1585 } else if (os_strcmp(buf, "eap_fast_a_id_info") == 0) {
1586 os_free(bss->eap_fast_a_id_info);
1587 bss->eap_fast_a_id_info = os_strdup(pos);
1588 } else if (os_strcmp(buf, "eap_fast_prov") == 0) {
1589 bss->eap_fast_prov = atoi(pos);
1590 } else if (os_strcmp(buf, "pac_key_lifetime") == 0) {
1591 bss->pac_key_lifetime = atoi(pos);
1592 } else if (os_strcmp(buf, "pac_key_refresh_time") == 0) {
1593 bss->pac_key_refresh_time = atoi(pos);
1594 #endif /* EAP_FAST */
1596 } else if (os_strcmp(buf, "eap_sim_db") == 0) {
1597 os_free(bss->eap_sim_db);
1598 bss->eap_sim_db = os_strdup(pos);
1599 } else if (os_strcmp(buf, "eap_sim_aka_result_ind") == 0) {
1600 bss->eap_sim_aka_result_ind = atoi(pos);
1601 #endif /* EAP_SIM */
1603 } else if (os_strcmp(buf, "tnc") == 0) {
1604 bss->tnc = atoi(pos);
1605 #endif /* EAP_TNC */
1606 #endif /* EAP_SERVER */
1607 } else if (os_strcmp(buf, "eap_message") == 0) {
1609 bss->eap_req_id_text = os_strdup(pos);
1610 if (bss->eap_req_id_text == NULL) {
1611 printf("Line %d: Failed to allocate memory "
1612 "for eap_req_id_text\n", line);
1616 bss->eap_req_id_text_len =
1617 os_strlen(bss->eap_req_id_text);
1618 term = os_strstr(bss->eap_req_id_text, "\\0");
1621 os_memmove(term, term + 1,
1622 bss->eap_req_id_text_len -
1623 (term - bss->eap_req_id_text) - 1);
1624 bss->eap_req_id_text_len--;
1626 } else if (os_strcmp(buf, "wep_key_len_broadcast") == 0) {
1627 bss->default_wep_key_len = atoi(pos);
1628 if (bss->default_wep_key_len > 13) {
1629 printf("Line %d: invalid WEP key len %lu "
1630 "(= %lu bits)\n", line,
1632 bss->default_wep_key_len,
1634 bss->default_wep_key_len * 8);
1637 } else if (os_strcmp(buf, "wep_key_len_unicast") == 0) {
1638 bss->individual_wep_key_len = atoi(pos);
1639 if (bss->individual_wep_key_len < 0 ||
1640 bss->individual_wep_key_len > 13) {
1641 printf("Line %d: invalid WEP key len %d "
1642 "(= %d bits)\n", line,
1643 bss->individual_wep_key_len,
1644 bss->individual_wep_key_len * 8);
1647 } else if (os_strcmp(buf, "wep_rekey_period") == 0) {
1648 bss->wep_rekeying_period = atoi(pos);
1649 if (bss->wep_rekeying_period < 0) {
1650 printf("Line %d: invalid period %d\n",
1651 line, bss->wep_rekeying_period);
1654 } else if (os_strcmp(buf, "eap_reauth_period") == 0) {
1655 bss->eap_reauth_period = atoi(pos);
1656 if (bss->eap_reauth_period < 0) {
1657 printf("Line %d: invalid period %d\n",
1658 line, bss->eap_reauth_period);
1661 } else if (os_strcmp(buf, "eapol_key_index_workaround") == 0) {
1662 bss->eapol_key_index_workaround = atoi(pos);
1664 } else if (os_strcmp(buf, "iapp_interface") == 0) {
1665 bss->ieee802_11f = 1;
1666 os_strlcpy(bss->iapp_iface, pos,
1667 sizeof(bss->iapp_iface));
1668 #endif /* CONFIG_IAPP */
1669 } else if (os_strcmp(buf, "own_ip_addr") == 0) {
1670 if (hostapd_parse_ip_addr(pos, &bss->own_ip_addr)) {
1671 printf("Line %d: invalid IP address '%s'\n",
1675 } else if (os_strcmp(buf, "nas_identifier") == 0) {
1676 bss->nas_identifier = os_strdup(pos);
1677 } else if (os_strcmp(buf, "auth_server_addr") == 0) {
1678 if (hostapd_config_read_radius_addr(
1679 &bss->radius->auth_servers,
1680 &bss->radius->num_auth_servers, pos, 1812,
1681 &bss->radius->auth_server)) {
1682 printf("Line %d: invalid IP address '%s'\n",
1686 } else if (bss->radius->auth_server &&
1687 os_strcmp(buf, "auth_server_port") == 0) {
1688 bss->radius->auth_server->port = atoi(pos);
1689 } else if (bss->radius->auth_server &&
1690 os_strcmp(buf, "auth_server_shared_secret") == 0) {
1691 int len = os_strlen(pos);
1693 /* RFC 2865, Ch. 3 */
1694 printf("Line %d: empty shared secret is not "
1695 "allowed.\n", line);
1698 bss->radius->auth_server->shared_secret =
1699 (u8 *) os_strdup(pos);
1700 bss->radius->auth_server->shared_secret_len = len;
1701 } else if (os_strcmp(buf, "acct_server_addr") == 0) {
1702 if (hostapd_config_read_radius_addr(
1703 &bss->radius->acct_servers,
1704 &bss->radius->num_acct_servers, pos, 1813,
1705 &bss->radius->acct_server)) {
1706 printf("Line %d: invalid IP address '%s'\n",
1710 } else if (bss->radius->acct_server &&
1711 os_strcmp(buf, "acct_server_port") == 0) {
1712 bss->radius->acct_server->port = atoi(pos);
1713 } else if (bss->radius->acct_server &&
1714 os_strcmp(buf, "acct_server_shared_secret") == 0) {
1715 int len = os_strlen(pos);
1717 /* RFC 2865, Ch. 3 */
1718 printf("Line %d: empty shared secret is not "
1719 "allowed.\n", line);
1722 bss->radius->acct_server->shared_secret =
1723 (u8 *) os_strdup(pos);
1724 bss->radius->acct_server->shared_secret_len = len;
1725 } else if (os_strcmp(buf, "radius_retry_primary_interval") ==
1727 bss->radius->retry_primary_interval = atoi(pos);
1728 } else if (os_strcmp(buf, "radius_acct_interim_interval") == 0)
1730 bss->radius->acct_interim_interval = atoi(pos);
1731 } else if (os_strcmp(buf, "auth_algs") == 0) {
1732 bss->auth_algs = atoi(pos);
1733 if (bss->auth_algs == 0) {
1734 printf("Line %d: no authentication algorithms "
1739 } else if (os_strcmp(buf, "max_num_sta") == 0) {
1740 bss->max_num_sta = atoi(pos);
1741 if (bss->max_num_sta < 0 ||
1742 bss->max_num_sta > MAX_STA_COUNT) {
1743 printf("Line %d: Invalid max_num_sta=%d; "
1744 "allowed range 0..%d\n", line,
1745 bss->max_num_sta, MAX_STA_COUNT);
1748 } else if (os_strcmp(buf, "wpa") == 0) {
1749 bss->wpa = atoi(pos);
1750 } else if (os_strcmp(buf, "wpa_group_rekey") == 0) {
1751 bss->wpa_group_rekey = atoi(pos);
1752 } else if (os_strcmp(buf, "wpa_strict_rekey") == 0) {
1753 bss->wpa_strict_rekey = atoi(pos);
1754 } else if (os_strcmp(buf, "wpa_gmk_rekey") == 0) {
1755 bss->wpa_gmk_rekey = atoi(pos);
1756 } else if (os_strcmp(buf, "wpa_ptk_rekey") == 0) {
1757 bss->wpa_ptk_rekey = atoi(pos);
1758 } else if (os_strcmp(buf, "wpa_passphrase") == 0) {
1759 int len = os_strlen(pos);
1760 if (len < 8 || len > 63) {
1761 printf("Line %d: invalid WPA passphrase length"
1762 " %d (expected 8..63)\n", line, len);
1765 os_free(bss->ssid.wpa_passphrase);
1766 bss->ssid.wpa_passphrase = os_strdup(pos);
1768 } else if (os_strcmp(buf, "wpa_psk") == 0) {
1769 os_free(bss->ssid.wpa_psk);
1771 os_zalloc(sizeof(struct hostapd_wpa_psk));
1772 if (bss->ssid.wpa_psk == NULL)
1774 else if (hexstr2bin(pos, bss->ssid.wpa_psk->psk,
1776 pos[PMK_LEN * 2] != '\0') {
1777 printf("Line %d: Invalid PSK '%s'.\n", line,
1781 bss->ssid.wpa_psk->group = 1;
1783 } else if (os_strcmp(buf, "wpa_psk_file") == 0) {
1784 os_free(bss->ssid.wpa_psk_file);
1785 bss->ssid.wpa_psk_file = os_strdup(pos);
1786 if (!bss->ssid.wpa_psk_file) {
1787 printf("Line %d: allocation failed\n", line);
1790 } else if (os_strcmp(buf, "wpa_key_mgmt") == 0) {
1792 hostapd_config_parse_key_mgmt(line, pos);
1793 if (bss->wpa_key_mgmt == -1)
1795 } else if (os_strcmp(buf, "wpa_pairwise") == 0) {
1797 hostapd_config_parse_cipher(line, pos);
1798 if (bss->wpa_pairwise == -1 ||
1799 bss->wpa_pairwise == 0)
1801 else if (bss->wpa_pairwise &
1802 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
1803 WPA_CIPHER_WEP104)) {
1804 printf("Line %d: unsupported pairwise "
1805 "cipher suite '%s'\n",
1806 bss->wpa_pairwise, pos);
1809 } else if (os_strcmp(buf, "rsn_pairwise") == 0) {
1811 hostapd_config_parse_cipher(line, pos);
1812 if (bss->rsn_pairwise == -1 ||
1813 bss->rsn_pairwise == 0)
1815 else if (bss->rsn_pairwise &
1816 (WPA_CIPHER_NONE | WPA_CIPHER_WEP40 |
1817 WPA_CIPHER_WEP104)) {
1818 printf("Line %d: unsupported pairwise "
1819 "cipher suite '%s'\n",
1820 bss->rsn_pairwise, pos);
1823 #ifdef CONFIG_RSN_PREAUTH
1824 } else if (os_strcmp(buf, "rsn_preauth") == 0) {
1825 bss->rsn_preauth = atoi(pos);
1826 } else if (os_strcmp(buf, "rsn_preauth_interfaces") == 0) {
1827 bss->rsn_preauth_interfaces = os_strdup(pos);
1828 #endif /* CONFIG_RSN_PREAUTH */
1829 #ifdef CONFIG_PEERKEY
1830 } else if (os_strcmp(buf, "peerkey") == 0) {
1831 bss->peerkey = atoi(pos);
1832 #endif /* CONFIG_PEERKEY */
1833 #ifdef CONFIG_IEEE80211R
1834 } else if (os_strcmp(buf, "mobility_domain") == 0) {
1835 if (os_strlen(pos) != 2 * MOBILITY_DOMAIN_ID_LEN ||
1836 hexstr2bin(pos, bss->mobility_domain,
1837 MOBILITY_DOMAIN_ID_LEN) != 0) {
1838 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
1839 "mobility_domain '%s'", line, pos);
1843 } else if (os_strcmp(buf, "r1_key_holder") == 0) {
1844 if (os_strlen(pos) != 2 * FT_R1KH_ID_LEN ||
1845 hexstr2bin(pos, bss->r1_key_holder,
1846 FT_R1KH_ID_LEN) != 0) {
1847 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
1848 "r1_key_holder '%s'", line, pos);
1852 } else if (os_strcmp(buf, "r0_key_lifetime") == 0) {
1853 bss->r0_key_lifetime = atoi(pos);
1854 } else if (os_strcmp(buf, "reassociation_deadline") == 0) {
1855 bss->reassociation_deadline = atoi(pos);
1856 } else if (os_strcmp(buf, "r0kh") == 0) {
1857 if (add_r0kh(bss, pos) < 0) {
1858 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
1859 "r0kh '%s'", line, pos);
1863 } else if (os_strcmp(buf, "r1kh") == 0) {
1864 if (add_r1kh(bss, pos) < 0) {
1865 wpa_printf(MSG_DEBUG, "Line %d: Invalid "
1866 "r1kh '%s'", line, pos);
1870 } else if (os_strcmp(buf, "pmk_r1_push") == 0) {
1871 bss->pmk_r1_push = atoi(pos);
1872 #endif /* CONFIG_IEEE80211R */
1873 } else if (os_strcmp(buf, "ctrl_interface") == 0) {
1874 os_free(bss->ctrl_interface);
1875 bss->ctrl_interface = os_strdup(pos);
1876 } else if (os_strcmp(buf, "ctrl_interface_group") == 0) {
1877 #ifndef CONFIG_NATIVE_WINDOWS
1880 const char *group = pos;
1882 grp = getgrnam(group);
1884 bss->ctrl_interface_gid = grp->gr_gid;
1885 bss->ctrl_interface_gid_set = 1;
1886 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d"
1887 " (from group name '%s')",
1888 bss->ctrl_interface_gid, group);
1892 /* Group name not found - try to parse this as gid */
1893 bss->ctrl_interface_gid = strtol(group, &endp, 10);
1894 if (*group == '\0' || *endp != '\0') {
1895 wpa_printf(MSG_DEBUG, "Line %d: Invalid group "
1896 "'%s'", line, group);
1900 bss->ctrl_interface_gid_set = 1;
1901 wpa_printf(MSG_DEBUG, "ctrl_interface_group=%d",
1902 bss->ctrl_interface_gid);
1903 #endif /* CONFIG_NATIVE_WINDOWS */
1904 #ifdef RADIUS_SERVER
1905 } else if (os_strcmp(buf, "radius_server_clients") == 0) {
1906 os_free(bss->radius_server_clients);
1907 bss->radius_server_clients = os_strdup(pos);
1908 } else if (os_strcmp(buf, "radius_server_auth_port") == 0) {
1909 bss->radius_server_auth_port = atoi(pos);
1910 } else if (os_strcmp(buf, "radius_server_ipv6") == 0) {
1911 bss->radius_server_ipv6 = atoi(pos);
1912 #endif /* RADIUS_SERVER */
1913 } else if (os_strcmp(buf, "test_socket") == 0) {
1914 os_free(bss->test_socket);
1915 bss->test_socket = os_strdup(pos);
1916 } else if (os_strcmp(buf, "use_pae_group_addr") == 0) {
1917 bss->use_pae_group_addr = atoi(pos);
1918 } else if (os_strcmp(buf, "hw_mode") == 0) {
1919 if (os_strcmp(pos, "a") == 0)
1920 conf->hw_mode = HOSTAPD_MODE_IEEE80211A;
1921 else if (os_strcmp(pos, "b") == 0)
1922 conf->hw_mode = HOSTAPD_MODE_IEEE80211B;
1923 else if (os_strcmp(pos, "g") == 0)
1924 conf->hw_mode = HOSTAPD_MODE_IEEE80211G;
1926 printf("Line %d: unknown hw_mode '%s'\n",
1930 } else if (os_strcmp(buf, "channel") == 0) {
1931 conf->channel = atoi(pos);
1932 } else if (os_strcmp(buf, "beacon_int") == 0) {
1933 int val = atoi(pos);
1934 /* MIB defines range as 1..65535, but very small values
1935 * cause problems with the current implementation.
1936 * Since it is unlikely that this small numbers are
1937 * useful in real life scenarios, do not allow beacon
1938 * period to be set below 15 TU. */
1939 if (val < 15 || val > 65535) {
1940 printf("Line %d: invalid beacon_int %d "
1941 "(expected 15..65535)\n",
1945 conf->beacon_int = val;
1946 } else if (os_strcmp(buf, "dtim_period") == 0) {
1947 bss->dtim_period = atoi(pos);
1948 if (bss->dtim_period < 1 || bss->dtim_period > 255) {
1949 printf("Line %d: invalid dtim_period %d\n",
1950 line, bss->dtim_period);
1953 } else if (os_strcmp(buf, "rts_threshold") == 0) {
1954 conf->rts_threshold = atoi(pos);
1955 if (conf->rts_threshold < 0 ||
1956 conf->rts_threshold > 2347) {
1957 printf("Line %d: invalid rts_threshold %d\n",
1958 line, conf->rts_threshold);
1961 } else if (os_strcmp(buf, "fragm_threshold") == 0) {
1962 conf->fragm_threshold = atoi(pos);
1963 if (conf->fragm_threshold < 256 ||
1964 conf->fragm_threshold > 2346) {
1965 printf("Line %d: invalid fragm_threshold %d\n",
1966 line, conf->fragm_threshold);
1969 } else if (os_strcmp(buf, "send_probe_response") == 0) {
1970 int val = atoi(pos);
1971 if (val != 0 && val != 1) {
1972 printf("Line %d: invalid send_probe_response "
1973 "%d (expected 0 or 1)\n", line, val);
1975 conf->send_probe_response = val;
1976 } else if (os_strcmp(buf, "supported_rates") == 0) {
1977 if (hostapd_parse_rates(&conf->supported_rates, pos)) {
1978 printf("Line %d: invalid rate list\n", line);
1981 } else if (os_strcmp(buf, "basic_rates") == 0) {
1982 if (hostapd_parse_rates(&conf->basic_rates, pos)) {
1983 printf("Line %d: invalid rate list\n", line);
1986 } else if (os_strcmp(buf, "preamble") == 0) {
1988 conf->preamble = SHORT_PREAMBLE;
1990 conf->preamble = LONG_PREAMBLE;
1991 } else if (os_strcmp(buf, "ignore_broadcast_ssid") == 0) {
1992 bss->ignore_broadcast_ssid = atoi(pos);
1993 } else if (os_strcmp(buf, "bridge_packets") == 0) {
1994 conf->bridge_packets = atoi(pos);
1995 } else if (os_strcmp(buf, "wep_default_key") == 0) {
1996 bss->ssid.wep.idx = atoi(pos);
1997 if (bss->ssid.wep.idx > 3) {
1998 printf("Invalid wep_default_key index %d\n",
2002 } else if (os_strcmp(buf, "wep_key0") == 0 ||
2003 os_strcmp(buf, "wep_key1") == 0 ||
2004 os_strcmp(buf, "wep_key2") == 0 ||
2005 os_strcmp(buf, "wep_key3") == 0) {
2006 if (hostapd_config_read_wep(&bss->ssid.wep,
2007 buf[7] - '0', pos)) {
2008 printf("Line %d: invalid WEP key '%s'\n",
2012 } else if (os_strcmp(buf, "dynamic_vlan") == 0) {
2013 bss->ssid.dynamic_vlan = atoi(pos);
2014 } else if (os_strcmp(buf, "vlan_file") == 0) {
2015 if (hostapd_config_read_vlan_file(bss, pos)) {
2016 printf("Line %d: failed to read VLAN file "
2017 "'%s'\n", line, pos);
2020 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2021 } else if (os_strcmp(buf, "vlan_tagged_interface") == 0) {
2022 bss->ssid.vlan_tagged_interface = os_strdup(pos);
2023 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2024 } else if (os_strcmp(buf, "passive_scan_interval") == 0) {
2025 conf->passive_scan_interval = atoi(pos);
2026 } else if (os_strcmp(buf, "passive_scan_listen") == 0) {
2027 conf->passive_scan_listen = atoi(pos);
2028 } else if (os_strcmp(buf, "passive_scan_mode") == 0) {
2029 conf->passive_scan_mode = atoi(pos);
2030 } else if (os_strcmp(buf, "ap_table_max_size") == 0) {
2031 conf->ap_table_max_size = atoi(pos);
2032 } else if (os_strcmp(buf, "ap_table_expiration_time") == 0) {
2033 conf->ap_table_expiration_time = atoi(pos);
2034 } else if (os_strncmp(buf, "tx_queue_", 9) == 0) {
2035 if (hostapd_config_tx_queue(conf, buf, pos)) {
2036 printf("Line %d: invalid TX queue item\n",
2040 } else if (os_strcmp(buf, "wme_enabled") == 0) {
2041 bss->wme_enabled = atoi(pos);
2042 } else if (os_strncmp(buf, "wme_ac_", 7) == 0) {
2043 if (hostapd_config_wme_ac(conf, buf, pos)) {
2044 printf("Line %d: invalid wme ac item\n",
2048 } else if (os_strcmp(buf, "bss") == 0) {
2049 if (hostapd_config_bss(conf, pos)) {
2050 printf("Line %d: invalid bss item\n", line);
2053 } else if (os_strcmp(buf, "bssid") == 0) {
2054 if (bss == conf->bss &&
2055 (!conf->driver || !conf->driver->init_bssid)) {
2056 printf("Line %d: bssid item not allowed "
2057 "for the default interface and this "
2060 } else if (hwaddr_aton(pos, bss->bssid)) {
2061 printf("Line %d: invalid bssid item\n", line);
2064 #ifdef CONFIG_IEEE80211W
2065 } else if (os_strcmp(buf, "ieee80211w") == 0) {
2066 bss->ieee80211w = atoi(pos);
2067 } else if (os_strcmp(buf, "assoc_sa_query_max_timeout") == 0) {
2068 bss->assoc_sa_query_max_timeout = atoi(pos);
2069 if (bss->assoc_sa_query_max_timeout == 0) {
2070 printf("Line %d: invalid "
2071 "assoc_sa_query_max_timeout\n",
2075 } else if (os_strcmp(buf, "assoc_sa_query_retry_timeout") == 0)
2077 bss->assoc_sa_query_retry_timeout = atoi(pos);
2078 if (bss->assoc_sa_query_retry_timeout == 0) {
2079 printf("Line %d: invalid "
2080 "assoc_sa_query_retry_timeout\n",
2084 #endif /* CONFIG_IEEE80211W */
2085 #ifdef CONFIG_IEEE80211N
2086 } else if (os_strcmp(buf, "ieee80211n") == 0) {
2087 conf->ieee80211n = atoi(pos);
2088 } else if (os_strcmp(buf, "ht_capab") == 0) {
2089 if (hostapd_config_ht_capab(conf, pos) < 0) {
2090 printf("Line %d: invalid ht_capab\n", line);
2093 #endif /* CONFIG_IEEE80211N */
2094 } else if (os_strcmp(buf, "max_listen_interval") == 0) {
2095 bss->max_listen_interval = atoi(pos);
2096 } else if (os_strcmp(buf, "okc") == 0) {
2097 bss->okc = atoi(pos);
2099 } else if (os_strcmp(buf, "wps_state") == 0) {
2100 bss->wps_state = atoi(pos);
2101 if (bss->wps_state < 0 || bss->wps_state > 2) {
2102 printf("Line %d: invalid wps_state\n", line);
2105 } else if (os_strcmp(buf, "ap_setup_locked") == 0) {
2106 bss->ap_setup_locked = atoi(pos);
2107 } else if (os_strcmp(buf, "uuid") == 0) {
2108 if (uuid_str2bin(pos, bss->uuid)) {
2109 printf("Line %d: invalid UUID\n", line);
2112 } else if (os_strcmp(buf, "wps_pin_requests") == 0) {
2113 bss->wps_pin_requests = os_strdup(pos);
2114 } else if (os_strcmp(buf, "device_name") == 0) {
2115 if (os_strlen(pos) > 32) {
2116 printf("Line %d: Too long device_name\n",
2120 bss->device_name = os_strdup(pos);
2121 } else if (os_strcmp(buf, "manufacturer") == 0) {
2122 if (os_strlen(pos) > 64) {
2123 printf("Line %d: Too long manufacturer\n",
2127 bss->manufacturer = os_strdup(pos);
2128 } else if (os_strcmp(buf, "model_name") == 0) {
2129 if (os_strlen(pos) > 32) {
2130 printf("Line %d: Too long model_name\n",
2134 bss->model_name = os_strdup(pos);
2135 } else if (os_strcmp(buf, "model_number") == 0) {
2136 if (os_strlen(pos) > 32) {
2137 printf("Line %d: Too long model_number\n",
2141 bss->model_number = os_strdup(pos);
2142 } else if (os_strcmp(buf, "serial_number") == 0) {
2143 if (os_strlen(pos) > 32) {
2144 printf("Line %d: Too long serial_number\n",
2148 bss->serial_number = os_strdup(pos);
2149 } else if (os_strcmp(buf, "device_type") == 0) {
2150 bss->device_type = os_strdup(pos);
2151 } else if (os_strcmp(buf, "config_methods") == 0) {
2152 bss->config_methods = os_strdup(pos);
2153 } else if (os_strcmp(buf, "os_version") == 0) {
2154 if (hexstr2bin(pos, bss->os_version, 4)) {
2155 printf("Line %d: invalid os_version\n", line);
2158 } else if (os_strcmp(buf, "ap_pin") == 0) {
2159 bss->ap_pin = os_strdup(pos);
2160 #endif /* CONFIG_WPS */
2162 printf("Line %d: unknown configuration item '%s'\n",
2170 if (bss->individual_wep_key_len == 0) {
2171 /* individual keys are not use; can use key idx0 for broadcast
2173 bss->broadcast_key_idx_min = 0;
2176 /* Select group cipher based on the enabled pairwise cipher suites */
2179 pairwise |= bss->wpa_pairwise;
2181 if (bss->rsn_pairwise == 0)
2182 bss->rsn_pairwise = bss->wpa_pairwise;
2183 pairwise |= bss->rsn_pairwise;
2185 if (pairwise & WPA_CIPHER_TKIP)
2186 bss->wpa_group = WPA_CIPHER_TKIP;
2188 bss->wpa_group = WPA_CIPHER_CCMP;
2190 for (i = 0; i < conf->num_bss; i++) {
2191 bss = &conf->bss[i];
2193 bss->radius->auth_server = bss->radius->auth_servers;
2194 bss->radius->acct_server = bss->radius->acct_servers;
2196 if (bss->wpa && bss->ieee802_1x) {
2197 bss->ssid.security_policy = SECURITY_WPA;
2198 } else if (bss->wpa) {
2199 bss->ssid.security_policy = SECURITY_WPA_PSK;
2200 } else if (bss->ieee802_1x) {
2201 bss->ssid.security_policy = SECURITY_IEEE_802_1X;
2202 bss->ssid.wep.default_len = bss->default_wep_key_len;
2203 } else if (bss->ssid.wep.keys_set)
2204 bss->ssid.security_policy = SECURITY_STATIC_WEP;
2206 bss->ssid.security_policy = SECURITY_PLAINTEXT;
2209 if (hostapd_config_check(conf))
2213 printf("%d errors found in configuration file '%s'\n",
2215 hostapd_config_free(conf);
2223 int hostapd_wep_key_cmp(struct hostapd_wep_keys *a, struct hostapd_wep_keys *b)
2227 if (a->idx != b->idx || a->default_len != b->default_len)
2229 for (i = 0; i < NUM_WEP_KEYS; i++)
2230 if (a->len[i] != b->len[i] ||
2231 os_memcmp(a->key[i], b->key[i], a->len[i]) != 0)
2237 static void hostapd_config_free_radius(struct hostapd_radius_server *servers,
2242 for (i = 0; i < num_servers; i++) {
2243 os_free(servers[i].shared_secret);
2249 static void hostapd_config_free_eap_user(struct hostapd_eap_user *user)
2251 os_free(user->identity);
2252 os_free(user->password);
2257 static void hostapd_config_free_wep(struct hostapd_wep_keys *keys)
2260 for (i = 0; i < NUM_WEP_KEYS; i++) {
2261 os_free(keys->key[i]);
2262 keys->key[i] = NULL;
2267 static void hostapd_config_free_bss(struct hostapd_bss_config *conf)
2269 struct hostapd_wpa_psk *psk, *prev;
2270 struct hostapd_eap_user *user, *prev_user;
2275 psk = conf->ssid.wpa_psk;
2282 os_free(conf->ssid.wpa_passphrase);
2283 os_free(conf->ssid.wpa_psk_file);
2284 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2285 os_free(conf->ssid.vlan_tagged_interface);
2286 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2288 user = conf->eap_user;
2292 hostapd_config_free_eap_user(prev_user);
2295 os_free(conf->dump_log_name);
2296 os_free(conf->eap_req_id_text);
2297 os_free(conf->accept_mac);
2298 os_free(conf->deny_mac);
2299 os_free(conf->nas_identifier);
2300 hostapd_config_free_radius(conf->radius->auth_servers,
2301 conf->radius->num_auth_servers);
2302 hostapd_config_free_radius(conf->radius->acct_servers,
2303 conf->radius->num_acct_servers);
2304 os_free(conf->rsn_preauth_interfaces);
2305 os_free(conf->ctrl_interface);
2306 os_free(conf->ca_cert);
2307 os_free(conf->server_cert);
2308 os_free(conf->private_key);
2309 os_free(conf->private_key_passwd);
2310 os_free(conf->dh_file);
2311 os_free(conf->pac_opaque_encr_key);
2312 os_free(conf->eap_fast_a_id);
2313 os_free(conf->eap_fast_a_id_info);
2314 os_free(conf->eap_sim_db);
2315 os_free(conf->radius_server_clients);
2316 os_free(conf->test_socket);
2317 os_free(conf->radius);
2318 hostapd_config_free_vlan(conf);
2319 if (conf->ssid.dyn_vlan_keys) {
2320 struct hostapd_ssid *ssid = &conf->ssid;
2322 for (i = 0; i <= ssid->max_dyn_vlan_keys; i++) {
2323 if (ssid->dyn_vlan_keys[i] == NULL)
2325 hostapd_config_free_wep(ssid->dyn_vlan_keys[i]);
2326 os_free(ssid->dyn_vlan_keys[i]);
2328 os_free(ssid->dyn_vlan_keys);
2329 ssid->dyn_vlan_keys = NULL;
2332 #ifdef CONFIG_IEEE80211R
2334 struct ft_remote_r0kh *r0kh, *r0kh_prev;
2335 struct ft_remote_r1kh *r1kh, *r1kh_prev;
2337 r0kh = conf->r0kh_list;
2338 conf->r0kh_list = NULL;
2345 r1kh = conf->r1kh_list;
2346 conf->r1kh_list = NULL;
2353 #endif /* CONFIG_IEEE80211R */
2356 os_free(conf->wps_pin_requests);
2357 os_free(conf->device_name);
2358 os_free(conf->manufacturer);
2359 os_free(conf->model_name);
2360 os_free(conf->model_number);
2361 os_free(conf->serial_number);
2362 os_free(conf->device_type);
2363 os_free(conf->config_methods);
2364 os_free(conf->ap_pin);
2365 #endif /* CONFIG_WPS */
2369 void hostapd_config_free(struct hostapd_config *conf)
2376 for (i = 0; i < conf->num_bss; i++)
2377 hostapd_config_free_bss(&conf->bss[i]);
2384 /* Perform a binary search for given MAC address from a pre-sorted list.
2385 * Returns 1 if address is in the list or 0 if not. */
2386 int hostapd_maclist_found(struct mac_acl_entry *list, int num_entries,
2387 const u8 *addr, int *vlan_id)
2389 int start, end, middle, res;
2392 end = num_entries - 1;
2394 while (start <= end) {
2395 middle = (start + end) / 2;
2396 res = os_memcmp(list[middle].addr, addr, ETH_ALEN);
2399 *vlan_id = list[middle].vlan_id;
2412 int hostapd_rate_found(int *list, int rate)
2419 for (i = 0; list[i] >= 0; i++)
2420 if (list[i] == rate)
2427 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan *vlan, int vlan_id)
2429 struct hostapd_vlan *v = vlan;
2431 if (v->vlan_id == vlan_id || v->vlan_id == VLAN_ID_WILDCARD)
2439 const u8 * hostapd_get_psk(const struct hostapd_bss_config *conf,
2440 const u8 *addr, const u8 *prev_psk)
2442 struct hostapd_wpa_psk *psk;
2443 int next_ok = prev_psk == NULL;
2445 for (psk = conf->ssid.wpa_psk; psk != NULL; psk = psk->next) {
2447 (psk->group || os_memcmp(psk->addr, addr, ETH_ALEN) == 0))
2450 if (psk->psk == prev_psk)
2458 const struct hostapd_eap_user *
2459 hostapd_get_eap_user(const struct hostapd_bss_config *conf, const u8 *identity,
2460 size_t identity_len, int phase2)
2462 struct hostapd_eap_user *user = conf->eap_user;
2465 if (conf->wps_state && identity_len == WSC_ID_ENROLLEE_LEN &&
2466 os_memcmp(identity, WSC_ID_ENROLLEE, WSC_ID_ENROLLEE_LEN) == 0) {
2467 static struct hostapd_eap_user wsc_enrollee;
2468 os_memset(&wsc_enrollee, 0, sizeof(wsc_enrollee));
2469 wsc_enrollee.methods[0].method = eap_server_get_type(
2470 "WSC", &wsc_enrollee.methods[0].vendor);
2471 return &wsc_enrollee;
2474 if (conf->wps_state && conf->ap_pin &&
2475 identity_len == WSC_ID_REGISTRAR_LEN &&
2476 os_memcmp(identity, WSC_ID_REGISTRAR, WSC_ID_REGISTRAR_LEN) == 0) {
2477 static struct hostapd_eap_user wsc_registrar;
2478 os_memset(&wsc_registrar, 0, sizeof(wsc_registrar));
2479 wsc_registrar.methods[0].method = eap_server_get_type(
2480 "WSC", &wsc_registrar.methods[0].vendor);
2481 wsc_registrar.password = (u8 *) conf->ap_pin;
2482 wsc_registrar.password_len = os_strlen(conf->ap_pin);
2483 return &wsc_registrar;
2485 #endif /* CONFIG_WPS */
2488 if (!phase2 && user->identity == NULL) {
2489 /* Wildcard match */
2493 if (user->phase2 == !!phase2 && user->wildcard_prefix &&
2494 identity_len >= user->identity_len &&
2495 os_memcmp(user->identity, identity, user->identity_len) ==
2497 /* Wildcard prefix match */
2501 if (user->phase2 == !!phase2 &&
2502 user->identity_len == identity_len &&
2503 os_memcmp(user->identity, identity, identity_len) == 0)