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_ping_timeout
= 1000;
188 bss
->assoc_ping_attempts
= 3;
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 SET_2BIT_LE16(&conf
->ht_capab
,
262 HT_CAP_INFO_MIMO_PWR_SAVE_OFFSET
,
263 MIMO_PWR_NO_LIMIT_ON_MIMO_SEQS
);
265 conf
->ht_capab
|= HT_CAP_INFO_GREEN_FIELD
;
266 #endif /* CONFIG_IEEE80211N */
272 int hostapd_mac_comp(const void *a
, const void *b
)
274 return os_memcmp(a
, b
, sizeof(macaddr
));
278 int hostapd_mac_comp_empty(const void *a
)
280 macaddr empty
= { 0 };
281 return os_memcmp(a
, empty
, sizeof(macaddr
));
285 static int hostapd_acl_comp(const void *a
, const void *b
)
287 const struct mac_acl_entry
*aa
= a
;
288 const struct mac_acl_entry
*bb
= b
;
289 return os_memcmp(aa
->addr
, bb
->addr
, sizeof(macaddr
));
293 static int hostapd_config_read_maclist(const char *fname
,
294 struct mac_acl_entry
**acl
, int *num
)
300 struct mac_acl_entry
*newacl
;
306 f
= fopen(fname
, "r");
308 printf("MAC list file '%s' not found.\n", fname
);
312 while (fgets(buf
, sizeof(buf
), f
)) {
318 while (*pos
!= '\0') {
328 if (hwaddr_aton(buf
, addr
)) {
329 printf("Invalid MAC address '%s' at line %d in '%s'\n",
337 while (*pos
!= '\0' && *pos
!= ' ' && *pos
!= '\t')
339 while (*pos
== ' ' || *pos
== '\t')
344 newacl
= os_realloc(*acl
, (*num
+ 1) * sizeof(**acl
));
345 if (newacl
== NULL
) {
346 printf("MAC list reallocation failed\n");
352 os_memcpy((*acl
)[*num
].addr
, addr
, ETH_ALEN
);
353 (*acl
)[*num
].vlan_id
= vlan_id
;
359 qsort(*acl
, *num
, sizeof(**acl
), hostapd_acl_comp
);
365 static int hostapd_config_read_wpa_psk(const char *fname
,
366 struct hostapd_ssid
*ssid
)
370 int line
= 0, ret
= 0, len
, ok
;
372 struct hostapd_wpa_psk
*psk
;
377 f
= fopen(fname
, "r");
379 printf("WPA PSK file '%s' not found.\n", fname
);
383 while (fgets(buf
, sizeof(buf
), f
)) {
389 while (*pos
!= '\0') {
399 if (hwaddr_aton(buf
, addr
)) {
400 printf("Invalid MAC address '%s' on line %d in '%s'\n",
406 psk
= os_zalloc(sizeof(*psk
));
408 printf("WPA PSK allocation failed\n");
412 if (is_zero_ether_addr(addr
))
415 os_memcpy(psk
->addr
, addr
, ETH_ALEN
);
419 printf("No PSK on line %d in '%s'\n", line
, fname
);
427 len
= os_strlen(pos
);
428 if (len
== 64 && hexstr2bin(pos
, psk
->psk
, PMK_LEN
) == 0)
430 else if (len
>= 8 && len
< 64) {
431 pbkdf2_sha1(pos
, ssid
->ssid
, ssid
->ssid_len
,
432 4096, psk
->psk
, PMK_LEN
);
436 printf("Invalid PSK '%s' on line %d in '%s'\n",
443 psk
->next
= ssid
->wpa_psk
;
453 int hostapd_setup_wpa_psk(struct hostapd_bss_config
*conf
)
455 struct hostapd_ssid
*ssid
= &conf
->ssid
;
457 if (ssid
->wpa_passphrase
!= NULL
) {
458 if (ssid
->wpa_psk
!= NULL
) {
459 printf("Warning: both WPA PSK and passphrase set. "
460 "Using passphrase.\n");
461 os_free(ssid
->wpa_psk
);
463 ssid
->wpa_psk
= os_zalloc(sizeof(struct hostapd_wpa_psk
));
464 if (ssid
->wpa_psk
== NULL
) {
465 printf("Unable to alloc space for PSK\n");
468 wpa_hexdump_ascii(MSG_DEBUG
, "SSID",
469 (u8
*) ssid
->ssid
, ssid
->ssid_len
);
470 wpa_hexdump_ascii(MSG_DEBUG
, "PSK (ASCII passphrase)",
471 (u8
*) ssid
->wpa_passphrase
,
472 os_strlen(ssid
->wpa_passphrase
));
473 pbkdf2_sha1(ssid
->wpa_passphrase
,
474 ssid
->ssid
, ssid
->ssid_len
,
475 4096, ssid
->wpa_psk
->psk
, PMK_LEN
);
476 wpa_hexdump(MSG_DEBUG
, "PSK (from passphrase)",
477 ssid
->wpa_psk
->psk
, PMK_LEN
);
478 ssid
->wpa_psk
->group
= 1;
480 os_memset(ssid
->wpa_passphrase
, 0,
481 os_strlen(ssid
->wpa_passphrase
));
482 os_free(ssid
->wpa_passphrase
);
483 ssid
->wpa_passphrase
= NULL
;
486 if (ssid
->wpa_psk_file
) {
487 if (hostapd_config_read_wpa_psk(ssid
->wpa_psk_file
,
497 static int hostapd_config_read_eap_user(const char *fname
,
498 struct hostapd_bss_config
*conf
)
501 char buf
[512], *pos
, *start
, *pos2
;
502 int line
= 0, ret
= 0, num_methods
;
503 struct hostapd_eap_user
*user
, *tail
= NULL
;
508 f
= fopen(fname
, "r");
510 printf("EAP user file '%s' not found.\n", fname
);
514 /* Lines: "user" METHOD,METHOD2 "password" (password optional) */
515 while (fgets(buf
, sizeof(buf
), f
)) {
521 while (*pos
!= '\0') {
533 if (buf
[0] != '"' && buf
[0] != '*') {
534 printf("Invalid EAP identity (no \" in start) on "
535 "line %d in '%s'\n", line
, fname
);
539 user
= os_zalloc(sizeof(*user
));
541 printf("EAP user allocation failed\n");
544 user
->force_version
= -1;
551 while (*pos
!= '"' && *pos
!= '\0')
554 printf("Invalid EAP identity (no \" in end) on"
555 " line %d in '%s'\n", line
, fname
);
559 user
->identity
= os_malloc(pos
- start
);
560 if (user
->identity
== NULL
) {
561 printf("Failed to allocate memory for EAP "
565 os_memcpy(user
->identity
, start
, pos
- start
);
566 user
->identity_len
= pos
- start
;
568 if (pos
[0] == '"' && pos
[1] == '*') {
569 user
->wildcard_prefix
= 1;
574 while (*pos
== ' ' || *pos
== '\t')
578 printf("No EAP method on line %d in '%s'\n",
584 while (*pos
!= ' ' && *pos
!= '\t' && *pos
!= '\0')
594 char *pos3
= os_strchr(start
, ',');
598 user
->methods
[num_methods
].method
=
601 &user
->methods
[num_methods
].vendor
);
602 if (user
->methods
[num_methods
].vendor
==
604 user
->methods
[num_methods
].method
== EAP_TYPE_NONE
)
606 if (os_strcmp(start
, "TTLS-PAP") == 0) {
607 user
->ttls_auth
|= EAP_TTLS_AUTH_PAP
;
610 if (os_strcmp(start
, "TTLS-CHAP") == 0) {
611 user
->ttls_auth
|= EAP_TTLS_AUTH_CHAP
;
614 if (os_strcmp(start
, "TTLS-MSCHAP") == 0) {
616 EAP_TTLS_AUTH_MSCHAP
;
619 if (os_strcmp(start
, "TTLS-MSCHAPV2") == 0) {
621 EAP_TTLS_AUTH_MSCHAPV2
;
624 printf("Unsupported EAP type '%s' on line %d "
625 "in '%s'\n", start
, line
, fname
);
630 if (num_methods
>= EAP_USER_MAX_METHODS
)
637 if (num_methods
== 0 && user
->ttls_auth
== 0) {
638 printf("No EAP types configured on line %d in '%s'\n",
646 while (*pos
== ' ' || *pos
== '\t')
651 if (os_strncmp(pos
, "[ver=0]", 7) == 0) {
652 user
->force_version
= 0;
656 if (os_strncmp(pos
, "[ver=1]", 7) == 0) {
657 user
->force_version
= 1;
661 if (os_strncmp(pos
, "[2]", 3) == 0) {
669 while (*pos
!= '"' && *pos
!= '\0')
672 printf("Invalid EAP password (no \" in end) "
673 "on line %d in '%s'\n", line
, fname
);
677 user
->password
= os_malloc(pos
- start
);
678 if (user
->password
== NULL
) {
679 printf("Failed to allocate memory for EAP "
683 os_memcpy(user
->password
, start
, pos
- start
);
684 user
->password_len
= pos
- start
;
687 } else if (os_strncmp(pos
, "hash:", 5) == 0) {
690 while (*pos2
!= '\0' && *pos2
!= ' ' &&
691 *pos2
!= '\t' && *pos2
!= '#')
693 if (pos2
- pos
!= 32) {
694 printf("Invalid password hash on line %d in "
695 "'%s'\n", line
, fname
);
698 user
->password
= os_malloc(16);
699 if (user
->password
== NULL
) {
700 printf("Failed to allocate memory for EAP "
704 if (hexstr2bin(pos
, user
->password
, 16) < 0) {
705 printf("Invalid hash password on line %d in "
706 "'%s'\n", line
, fname
);
709 user
->password_len
= 16;
710 user
->password_hash
= 1;
714 while (*pos2
!= '\0' && *pos2
!= ' ' &&
715 *pos2
!= '\t' && *pos2
!= '#')
717 if ((pos2
- pos
) & 1) {
718 printf("Invalid hex password on line %d in "
719 "'%s'\n", line
, fname
);
722 user
->password
= os_malloc((pos2
- pos
) / 2);
723 if (user
->password
== NULL
) {
724 printf("Failed to allocate memory for EAP "
728 if (hexstr2bin(pos
, user
->password
,
729 (pos2
- pos
) / 2) < 0) {
730 printf("Invalid hex password on line %d in "
731 "'%s'\n", line
, fname
);
734 user
->password_len
= (pos2
- pos
) / 2;
738 while (*pos
== ' ' || *pos
== '\t')
740 if (os_strncmp(pos
, "[2]", 3) == 0) {
746 tail
= conf
->eap_user
= user
;
755 os_free(user
->password
);
756 os_free(user
->identity
);
767 #endif /* EAP_SERVER */
771 hostapd_config_read_radius_addr(struct hostapd_radius_server
**server
,
772 int *num_server
, const char *val
, int def_port
,
773 struct hostapd_radius_server
**curr_serv
)
775 struct hostapd_radius_server
*nserv
;
777 static int server_index
= 1;
779 nserv
= os_realloc(*server
, (*num_server
+ 1) * sizeof(*nserv
));
784 nserv
= &nserv
[*num_server
];
786 (*curr_serv
) = nserv
;
788 os_memset(nserv
, 0, sizeof(*nserv
));
789 nserv
->port
= def_port
;
790 ret
= hostapd_parse_ip_addr(val
, &nserv
->addr
);
791 nserv
->index
= server_index
++;
797 static int hostapd_config_parse_key_mgmt(int line
, const char *value
)
800 char *start
, *end
, *buf
;
802 buf
= os_strdup(value
);
807 while (start
!= '\0') {
808 while (*start
== ' ' || *start
== '\t')
813 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
817 if (os_strcmp(start
, "WPA-PSK") == 0)
818 val
|= WPA_KEY_MGMT_PSK
;
819 else if (os_strcmp(start
, "WPA-EAP") == 0)
820 val
|= WPA_KEY_MGMT_IEEE8021X
;
821 #ifdef CONFIG_IEEE80211R
822 else if (os_strcmp(start
, "FT-PSK") == 0)
823 val
|= WPA_KEY_MGMT_FT_PSK
;
824 else if (os_strcmp(start
, "FT-EAP") == 0)
825 val
|= WPA_KEY_MGMT_FT_IEEE8021X
;
826 #endif /* CONFIG_IEEE80211R */
827 #ifdef CONFIG_IEEE80211W
828 else if (os_strcmp(start
, "WPA-PSK-SHA256") == 0)
829 val
|= WPA_KEY_MGMT_PSK_SHA256
;
830 else if (os_strcmp(start
, "WPA-EAP-SHA256") == 0)
831 val
|= WPA_KEY_MGMT_IEEE8021X_SHA256
;
832 #endif /* CONFIG_IEEE80211W */
834 printf("Line %d: invalid key_mgmt '%s'\n",
847 printf("Line %d: no key_mgmt values configured.\n", line
);
855 static int hostapd_config_parse_cipher(int line
, const char *value
)
858 char *start
, *end
, *buf
;
860 buf
= os_strdup(value
);
865 while (start
!= '\0') {
866 while (*start
== ' ' || *start
== '\t')
871 while (*end
!= ' ' && *end
!= '\t' && *end
!= '\0')
875 if (os_strcmp(start
, "CCMP") == 0)
876 val
|= WPA_CIPHER_CCMP
;
877 else if (os_strcmp(start
, "TKIP") == 0)
878 val
|= WPA_CIPHER_TKIP
;
879 else if (os_strcmp(start
, "WEP104") == 0)
880 val
|= WPA_CIPHER_WEP104
;
881 else if (os_strcmp(start
, "WEP40") == 0)
882 val
|= WPA_CIPHER_WEP40
;
883 else if (os_strcmp(start
, "NONE") == 0)
884 val
|= WPA_CIPHER_NONE
;
886 printf("Line %d: invalid cipher '%s'.", line
, start
);
898 printf("Line %d: no cipher values configured.", line
);
905 static int hostapd_config_check_bss(struct hostapd_bss_config
*bss
,
906 struct hostapd_config
*conf
)
908 if (bss
->ieee802_1x
&& !bss
->eap_server
&&
909 !bss
->radius
->auth_servers
) {
910 printf("Invalid IEEE 802.1X configuration (no EAP "
911 "authenticator configured).\n");
915 if (bss
->wpa
&& (bss
->wpa_key_mgmt
& WPA_KEY_MGMT_PSK
) &&
916 bss
->ssid
.wpa_psk
== NULL
&& bss
->ssid
.wpa_passphrase
== NULL
&&
917 bss
->ssid
.wpa_psk_file
== NULL
) {
918 printf("WPA-PSK enabled, but PSK or passphrase is not "
923 if (hostapd_mac_comp_empty(bss
->bssid
) != 0) {
926 for (i
= 0; i
< conf
->num_bss
; i
++) {
927 if ((&conf
->bss
[i
] != bss
) &&
928 (hostapd_mac_comp(conf
->bss
[i
].bssid
,
930 printf("Duplicate BSSID " MACSTR
931 " on interface '%s' and '%s'.\n",
933 conf
->bss
[i
].iface
, bss
->iface
);
939 #ifdef CONFIG_IEEE80211R
940 if ((bss
->wpa_key_mgmt
&
941 (WPA_KEY_MGMT_FT_PSK
| WPA_KEY_MGMT_FT_IEEE8021X
)) &&
942 (bss
->nas_identifier
== NULL
||
943 os_strlen(bss
->nas_identifier
) < 1 ||
944 os_strlen(bss
->nas_identifier
) > FT_R0KH_ID_MAX_LEN
)) {
945 printf("FT (IEEE 802.11r) requires nas_identifier to be "
946 "configured as a 1..48 octet string\n");
949 #endif /* CONFIG_IEEE80211R */
955 static int hostapd_config_check(struct hostapd_config
*conf
)
959 for (i
= 0; i
< conf
->num_bss
; i
++) {
960 if (hostapd_config_check_bss(&conf
->bss
[i
], conf
))
968 static int hostapd_config_read_wep(struct hostapd_wep_keys
*wep
, int keyidx
,
971 size_t len
= os_strlen(val
);
973 if (keyidx
< 0 || keyidx
> 3 || wep
->key
[keyidx
] != NULL
)
977 if (len
< 2 || val
[len
- 1] != '"')
980 wep
->key
[keyidx
] = os_malloc(len
);
981 if (wep
->key
[keyidx
] == NULL
)
983 os_memcpy(wep
->key
[keyidx
], val
+ 1, len
);
984 wep
->len
[keyidx
] = len
;
989 wep
->key
[keyidx
] = os_malloc(len
);
990 if (wep
->key
[keyidx
] == NULL
)
992 wep
->len
[keyidx
] = len
;
993 if (hexstr2bin(val
, wep
->key
[keyidx
], len
) < 0)
1003 static int hostapd_parse_rates(int **rate_list
, char *val
)
1009 os_free(*rate_list
);
1014 while (*pos
!= '\0') {
1020 list
= os_malloc(sizeof(int) * (count
+ 2));
1025 while (*pos
!= '\0') {
1026 end
= os_strchr(pos
, ' ');
1030 list
[count
++] = atoi(pos
);
1042 static int hostapd_config_bss(struct hostapd_config
*conf
, const char *ifname
)
1044 struct hostapd_bss_config
*bss
;
1046 if (*ifname
== '\0')
1049 bss
= os_realloc(conf
->bss
, (conf
->num_bss
+ 1) *
1050 sizeof(struct hostapd_bss_config
));
1052 printf("Failed to allocate memory for multi-BSS entry\n");
1057 bss
= &(conf
->bss
[conf
->num_bss
]);
1058 os_memset(bss
, 0, sizeof(*bss
));
1059 bss
->radius
= os_zalloc(sizeof(*bss
->radius
));
1060 if (bss
->radius
== NULL
) {
1061 printf("Failed to allocate memory for multi-BSS RADIUS "
1067 conf
->last_bss
= bss
;
1069 hostapd_config_defaults_bss(bss
);
1070 os_strlcpy(bss
->iface
, ifname
, sizeof(bss
->iface
));
1071 os_memcpy(bss
->ssid
.vlan
, bss
->iface
, IFNAMSIZ
+ 1);
1077 static int valid_cw(int cw
)
1079 return (cw
== 1 || cw
== 3 || cw
== 7 || cw
== 15 || cw
== 31 ||
1080 cw
== 63 || cw
== 127 || cw
== 255 || cw
== 511 || cw
== 1023);
1085 IEEE80211_TX_QUEUE_DATA0
= 0, /* used for EDCA AC_VO data */
1086 IEEE80211_TX_QUEUE_DATA1
= 1, /* used for EDCA AC_VI data */
1087 IEEE80211_TX_QUEUE_DATA2
= 2, /* used for EDCA AC_BE data */
1088 IEEE80211_TX_QUEUE_DATA3
= 3, /* used for EDCA AC_BK data */
1089 IEEE80211_TX_QUEUE_DATA4
= 4,
1090 IEEE80211_TX_QUEUE_AFTER_BEACON
= 6,
1091 IEEE80211_TX_QUEUE_BEACON
= 7
1094 static int hostapd_config_tx_queue(struct hostapd_config
*conf
, char *name
,
1099 struct hostapd_tx_queue_params
*queue
;
1101 /* skip 'tx_queue_' prefix */
1103 if (os_strncmp(pos
, "data", 4) == 0 &&
1104 pos
[4] >= '0' && pos
[4] <= '9' && pos
[5] == '_') {
1107 } else if (os_strncmp(pos
, "after_beacon_", 13) == 0) {
1108 num
= IEEE80211_TX_QUEUE_AFTER_BEACON
;
1110 } else if (os_strncmp(pos
, "beacon_", 7) == 0) {
1111 num
= IEEE80211_TX_QUEUE_BEACON
;
1114 printf("Unknown tx_queue name '%s'\n", pos
);
1118 queue
= &conf
->tx_queue
[num
];
1120 if (os_strcmp(pos
, "aifs") == 0) {
1121 queue
->aifs
= atoi(val
);
1122 if (queue
->aifs
< 0 || queue
->aifs
> 255) {
1123 printf("Invalid AIFS value %d\n", queue
->aifs
);
1126 } else if (os_strcmp(pos
, "cwmin") == 0) {
1127 queue
->cwmin
= atoi(val
);
1128 if (!valid_cw(queue
->cwmin
)) {
1129 printf("Invalid cwMin value %d\n", queue
->cwmin
);
1132 } else if (os_strcmp(pos
, "cwmax") == 0) {
1133 queue
->cwmax
= atoi(val
);
1134 if (!valid_cw(queue
->cwmax
)) {
1135 printf("Invalid cwMax value %d\n", queue
->cwmax
);
1138 } else if (os_strcmp(pos
, "burst") == 0) {
1139 queue
->burst
= hostapd_config_read_int10(val
);
1141 printf("Unknown tx_queue field '%s'\n", pos
);
1145 queue
->configured
= 1;
1151 static int hostapd_config_wme_ac(struct hostapd_config
*conf
, char *name
,
1156 struct hostapd_wme_ac_params
*ac
;
1158 /* skip 'wme_ac_' prefix */
1160 if (os_strncmp(pos
, "be_", 3) == 0) {
1163 } else if (os_strncmp(pos
, "bk_", 3) == 0) {
1166 } else if (os_strncmp(pos
, "vi_", 3) == 0) {
1169 } else if (os_strncmp(pos
, "vo_", 3) == 0) {
1173 printf("Unknown wme name '%s'\n", pos
);
1177 ac
= &conf
->wme_ac_params
[num
];
1179 if (os_strcmp(pos
, "aifs") == 0) {
1181 if (v
< 1 || v
> 255) {
1182 printf("Invalid AIFS value %d\n", v
);
1186 } else if (os_strcmp(pos
, "cwmin") == 0) {
1188 if (v
< 0 || v
> 12) {
1189 printf("Invalid cwMin value %d\n", v
);
1193 } else if (os_strcmp(pos
, "cwmax") == 0) {
1195 if (v
< 0 || v
> 12) {
1196 printf("Invalid cwMax value %d\n", v
);
1200 } else if (os_strcmp(pos
, "txop_limit") == 0) {
1202 if (v
< 0 || v
> 0xffff) {
1203 printf("Invalid txop value %d\n", v
);
1207 } else if (os_strcmp(pos
, "acm") == 0) {
1209 if (v
< 0 || v
> 1) {
1210 printf("Invalid acm value %d\n", v
);
1213 ac
->admission_control_mandatory
= v
;
1215 printf("Unknown wme_ac_ field '%s'\n", pos
);
1223 #ifdef CONFIG_IEEE80211R
1224 static int add_r0kh(struct hostapd_bss_config
*bss
, char *value
)
1226 struct ft_remote_r0kh
*r0kh
;
1229 r0kh
= os_zalloc(sizeof(*r0kh
));
1233 /* 02:01:02:03:04:05 a.example.com 000102030405060708090a0b0c0d0e0f */
1235 next
= os_strchr(pos
, ' ');
1238 if (next
== NULL
|| hwaddr_aton(pos
, r0kh
->addr
)) {
1239 printf("Invalid R0KH MAC address: '%s'\n", pos
);
1245 next
= os_strchr(pos
, ' ');
1248 if (next
== NULL
|| next
- pos
> FT_R0KH_ID_MAX_LEN
) {
1249 printf("Invalid R0KH-ID: '%s'\n", pos
);
1253 r0kh
->id_len
= next
- pos
- 1;
1254 os_memcpy(r0kh
->id
, pos
, r0kh
->id_len
);
1257 if (hexstr2bin(pos
, r0kh
->key
, sizeof(r0kh
->key
))) {
1258 printf("Invalid R0KH key: '%s'\n", pos
);
1263 r0kh
->next
= bss
->r0kh_list
;
1264 bss
->r0kh_list
= r0kh
;
1270 static int add_r1kh(struct hostapd_bss_config
*bss
, char *value
)
1272 struct ft_remote_r1kh
*r1kh
;
1275 r1kh
= os_zalloc(sizeof(*r1kh
));
1279 /* 02:01:02:03:04:05 02:01:02:03:04:05
1280 * 000102030405060708090a0b0c0d0e0f */
1282 next
= os_strchr(pos
, ' ');
1285 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->addr
)) {
1286 printf("Invalid R1KH MAC address: '%s'\n", pos
);
1292 next
= os_strchr(pos
, ' ');
1295 if (next
== NULL
|| hwaddr_aton(pos
, r1kh
->id
)) {
1296 printf("Invalid R1KH-ID: '%s'\n", pos
);
1302 if (hexstr2bin(pos
, r1kh
->key
, sizeof(r1kh
->key
))) {
1303 printf("Invalid R1KH key: '%s'\n", pos
);
1308 r1kh
->next
= bss
->r1kh_list
;
1309 bss
->r1kh_list
= r1kh
;
1313 #endif /* CONFIG_IEEE80211R */
1316 struct hostapd_config
* hostapd_config_read(const char *fname
)
1318 struct hostapd_config
*conf
;
1319 struct hostapd_bss_config
*bss
;
1321 char buf
[256], *pos
;
1327 f
= fopen(fname
, "r");
1329 printf("Could not open configuration file '%s' for reading.\n",
1334 conf
= hostapd_config_defaults();
1339 bss
= conf
->last_bss
= conf
->bss
;
1341 while (fgets(buf
, sizeof(buf
), f
)) {
1342 bss
= conf
->last_bss
;
1348 while (*pos
!= '\0') {
1358 pos
= os_strchr(buf
, '=');
1360 printf("Line %d: invalid line '%s'\n", line
, buf
);
1367 if (os_strcmp(buf
, "interface") == 0) {
1368 os_strlcpy(conf
->bss
[0].iface
, pos
,
1369 sizeof(conf
->bss
[0].iface
));
1370 } else if (os_strcmp(buf
, "bridge") == 0) {
1371 os_strlcpy(bss
->bridge
, pos
, sizeof(bss
->bridge
));
1372 } else if (os_strcmp(buf
, "driver") == 0) {
1374 /* clear to get error below if setting is invalid */
1375 conf
->driver
= NULL
;
1376 for (i
= 0; hostapd_drivers
[i
]; i
++) {
1377 if (os_strcmp(pos
, hostapd_drivers
[i
]->name
) ==
1379 conf
->driver
= hostapd_drivers
[i
];
1383 if (conf
->driver
== NULL
) {
1384 printf("Line %d: invalid/unknown driver "
1385 "'%s'\n", line
, pos
);
1388 } else if (os_strcmp(buf
, "debug") == 0) {
1389 wpa_printf(MSG_DEBUG
, "Line %d: DEPRECATED: 'debug' "
1390 "configuration variable is not used "
1392 } else if (os_strcmp(buf
, "logger_syslog_level") == 0) {
1393 bss
->logger_syslog_level
= atoi(pos
);
1394 } else if (os_strcmp(buf
, "logger_stdout_level") == 0) {
1395 bss
->logger_stdout_level
= atoi(pos
);
1396 } else if (os_strcmp(buf
, "logger_syslog") == 0) {
1397 bss
->logger_syslog
= atoi(pos
);
1398 } else if (os_strcmp(buf
, "logger_stdout") == 0) {
1399 bss
->logger_stdout
= atoi(pos
);
1400 } else if (os_strcmp(buf
, "dump_file") == 0) {
1401 bss
->dump_log_name
= os_strdup(pos
);
1402 } else if (os_strcmp(buf
, "ssid") == 0) {
1403 bss
->ssid
.ssid_len
= os_strlen(pos
);
1404 if (bss
->ssid
.ssid_len
> HOSTAPD_MAX_SSID_LEN
||
1405 bss
->ssid
.ssid_len
< 1) {
1406 printf("Line %d: invalid SSID '%s'\n", line
,
1410 os_memcpy(bss
->ssid
.ssid
, pos
,
1411 bss
->ssid
.ssid_len
);
1412 bss
->ssid
.ssid
[bss
->ssid
.ssid_len
] = '\0';
1413 bss
->ssid
.ssid_set
= 1;
1415 } else if (os_strcmp(buf
, "macaddr_acl") == 0) {
1416 bss
->macaddr_acl
= atoi(pos
);
1417 if (bss
->macaddr_acl
!= ACCEPT_UNLESS_DENIED
&&
1418 bss
->macaddr_acl
!= DENY_UNLESS_ACCEPTED
&&
1419 bss
->macaddr_acl
!= USE_EXTERNAL_RADIUS_AUTH
) {
1420 printf("Line %d: unknown macaddr_acl %d\n",
1421 line
, bss
->macaddr_acl
);
1423 } else if (os_strcmp(buf
, "accept_mac_file") == 0) {
1424 if (hostapd_config_read_maclist(pos
, &bss
->accept_mac
,
1425 &bss
->num_accept_mac
))
1427 printf("Line %d: Failed to read "
1428 "accept_mac_file '%s'\n",
1432 } else if (os_strcmp(buf
, "deny_mac_file") == 0) {
1433 if (hostapd_config_read_maclist(pos
, &bss
->deny_mac
,
1434 &bss
->num_deny_mac
))
1436 printf("Line %d: Failed to read "
1437 "deny_mac_file '%s'\n",
1441 } else if (os_strcmp(buf
, "ap_max_inactivity") == 0) {
1442 bss
->ap_max_inactivity
= atoi(pos
);
1443 } else if (os_strcmp(buf
, "country_code") == 0) {
1444 os_memcpy(conf
->country
, pos
, 2);
1445 /* FIX: make this configurable */
1446 conf
->country
[2] = ' ';
1447 } else if (os_strcmp(buf
, "ieee80211d") == 0) {
1448 conf
->ieee80211d
= atoi(pos
);
1449 } else if (os_strcmp(buf
, "ieee8021x") == 0) {
1450 bss
->ieee802_1x
= atoi(pos
);
1451 } else if (os_strcmp(buf
, "eapol_version") == 0) {
1452 bss
->eapol_version
= atoi(pos
);
1453 if (bss
->eapol_version
< 1 ||
1454 bss
->eapol_version
> 2) {
1455 printf("Line %d: invalid EAPOL "
1456 "version (%d): '%s'.\n",
1457 line
, bss
->eapol_version
, pos
);
1460 wpa_printf(MSG_DEBUG
, "eapol_version=%d",
1461 bss
->eapol_version
);
1463 } else if (os_strcmp(buf
, "eap_authenticator") == 0) {
1464 bss
->eap_server
= atoi(pos
);
1465 printf("Line %d: obsolete eap_authenticator used; "
1466 "this has been renamed to eap_server\n", line
);
1467 } else if (os_strcmp(buf
, "eap_server") == 0) {
1468 bss
->eap_server
= atoi(pos
);
1469 } else if (os_strcmp(buf
, "eap_user_file") == 0) {
1470 if (hostapd_config_read_eap_user(pos
, bss
))
1472 } else if (os_strcmp(buf
, "ca_cert") == 0) {
1473 os_free(bss
->ca_cert
);
1474 bss
->ca_cert
= os_strdup(pos
);
1475 } else if (os_strcmp(buf
, "server_cert") == 0) {
1476 os_free(bss
->server_cert
);
1477 bss
->server_cert
= os_strdup(pos
);
1478 } else if (os_strcmp(buf
, "private_key") == 0) {
1479 os_free(bss
->private_key
);
1480 bss
->private_key
= os_strdup(pos
);
1481 } else if (os_strcmp(buf
, "private_key_passwd") == 0) {
1482 os_free(bss
->private_key_passwd
);
1483 bss
->private_key_passwd
= os_strdup(pos
);
1484 } else if (os_strcmp(buf
, "check_crl") == 0) {
1485 bss
->check_crl
= atoi(pos
);
1486 } else if (os_strcmp(buf
, "dh_file") == 0) {
1487 os_free(bss
->dh_file
);
1488 bss
->dh_file
= os_strdup(pos
);
1490 } else if (os_strcmp(buf
, "pac_opaque_encr_key") == 0) {
1491 os_free(bss
->pac_opaque_encr_key
);
1492 bss
->pac_opaque_encr_key
= os_malloc(16);
1493 if (bss
->pac_opaque_encr_key
== NULL
) {
1494 printf("Line %d: No memory for "
1495 "pac_opque_encr_key\n", line
);
1497 } else if (hexstr2bin(pos
, bss
->pac_opaque_encr_key
,
1499 printf("Line %d: Invalid pac_opque_encr_key\n",
1503 } else if (os_strcmp(buf
, "eap_fast_a_id") == 0) {
1504 size_t idlen
= os_strlen(pos
);
1506 printf("Line %d: Invalid eap_fast_a_id\n",
1510 os_free(bss
->eap_fast_a_id
);
1511 bss
->eap_fast_a_id
= os_malloc(idlen
/ 2);
1512 if (bss
->eap_fast_a_id
== NULL
||
1513 hexstr2bin(pos
, bss
->eap_fast_a_id
,
1515 printf("Line %d: Failed to parse "
1516 "eap_fast_a_id\n", line
);
1519 bss
->eap_fast_a_id_len
= idlen
/ 2;
1521 } else if (os_strcmp(buf
, "eap_fast_a_id_info") == 0) {
1522 os_free(bss
->eap_fast_a_id_info
);
1523 bss
->eap_fast_a_id_info
= os_strdup(pos
);
1524 } else if (os_strcmp(buf
, "eap_fast_prov") == 0) {
1525 bss
->eap_fast_prov
= atoi(pos
);
1526 } else if (os_strcmp(buf
, "pac_key_lifetime") == 0) {
1527 bss
->pac_key_lifetime
= atoi(pos
);
1528 } else if (os_strcmp(buf
, "pac_key_refresh_time") == 0) {
1529 bss
->pac_key_refresh_time
= atoi(pos
);
1530 #endif /* EAP_FAST */
1532 } else if (os_strcmp(buf
, "eap_sim_db") == 0) {
1533 os_free(bss
->eap_sim_db
);
1534 bss
->eap_sim_db
= os_strdup(pos
);
1535 } else if (os_strcmp(buf
, "eap_sim_aka_result_ind") == 0) {
1536 bss
->eap_sim_aka_result_ind
= atoi(pos
);
1537 #endif /* EAP_SIM */
1539 } else if (os_strcmp(buf
, "tnc") == 0) {
1540 bss
->tnc
= atoi(pos
);
1541 #endif /* EAP_TNC */
1542 #endif /* EAP_SERVER */
1543 } else if (os_strcmp(buf
, "eap_message") == 0) {
1545 bss
->eap_req_id_text
= os_strdup(pos
);
1546 if (bss
->eap_req_id_text
== NULL
) {
1547 printf("Line %d: Failed to allocate memory "
1548 "for eap_req_id_text\n", line
);
1552 bss
->eap_req_id_text_len
=
1553 os_strlen(bss
->eap_req_id_text
);
1554 term
= os_strstr(bss
->eap_req_id_text
, "\\0");
1557 os_memmove(term
, term
+ 1,
1558 bss
->eap_req_id_text_len
-
1559 (term
- bss
->eap_req_id_text
) - 1);
1560 bss
->eap_req_id_text_len
--;
1562 } else if (os_strcmp(buf
, "wep_key_len_broadcast") == 0) {
1563 bss
->default_wep_key_len
= atoi(pos
);
1564 if (bss
->default_wep_key_len
> 13) {
1565 printf("Line %d: invalid WEP key len %lu "
1566 "(= %lu bits)\n", line
,
1568 bss
->default_wep_key_len
,
1570 bss
->default_wep_key_len
* 8);
1573 } else if (os_strcmp(buf
, "wep_key_len_unicast") == 0) {
1574 bss
->individual_wep_key_len
= atoi(pos
);
1575 if (bss
->individual_wep_key_len
< 0 ||
1576 bss
->individual_wep_key_len
> 13) {
1577 printf("Line %d: invalid WEP key len %d "
1578 "(= %d bits)\n", line
,
1579 bss
->individual_wep_key_len
,
1580 bss
->individual_wep_key_len
* 8);
1583 } else if (os_strcmp(buf
, "wep_rekey_period") == 0) {
1584 bss
->wep_rekeying_period
= atoi(pos
);
1585 if (bss
->wep_rekeying_period
< 0) {
1586 printf("Line %d: invalid period %d\n",
1587 line
, bss
->wep_rekeying_period
);
1590 } else if (os_strcmp(buf
, "eap_reauth_period") == 0) {
1591 bss
->eap_reauth_period
= atoi(pos
);
1592 if (bss
->eap_reauth_period
< 0) {
1593 printf("Line %d: invalid period %d\n",
1594 line
, bss
->eap_reauth_period
);
1597 } else if (os_strcmp(buf
, "eapol_key_index_workaround") == 0) {
1598 bss
->eapol_key_index_workaround
= atoi(pos
);
1600 } else if (os_strcmp(buf
, "iapp_interface") == 0) {
1601 bss
->ieee802_11f
= 1;
1602 os_strlcpy(bss
->iapp_iface
, pos
,
1603 sizeof(bss
->iapp_iface
));
1604 #endif /* CONFIG_IAPP */
1605 } else if (os_strcmp(buf
, "own_ip_addr") == 0) {
1606 if (hostapd_parse_ip_addr(pos
, &bss
->own_ip_addr
)) {
1607 printf("Line %d: invalid IP address '%s'\n",
1611 } else if (os_strcmp(buf
, "nas_identifier") == 0) {
1612 bss
->nas_identifier
= os_strdup(pos
);
1613 } else if (os_strcmp(buf
, "auth_server_addr") == 0) {
1614 if (hostapd_config_read_radius_addr(
1615 &bss
->radius
->auth_servers
,
1616 &bss
->radius
->num_auth_servers
, pos
, 1812,
1617 &bss
->radius
->auth_server
)) {
1618 printf("Line %d: invalid IP address '%s'\n",
1622 } else if (bss
->radius
->auth_server
&&
1623 os_strcmp(buf
, "auth_server_port") == 0) {
1624 bss
->radius
->auth_server
->port
= atoi(pos
);
1625 } else if (bss
->radius
->auth_server
&&
1626 os_strcmp(buf
, "auth_server_shared_secret") == 0) {
1627 int len
= os_strlen(pos
);
1629 /* RFC 2865, Ch. 3 */
1630 printf("Line %d: empty shared secret is not "
1631 "allowed.\n", line
);
1634 bss
->radius
->auth_server
->shared_secret
=
1635 (u8
*) os_strdup(pos
);
1636 bss
->radius
->auth_server
->shared_secret_len
= len
;
1637 } else if (os_strcmp(buf
, "acct_server_addr") == 0) {
1638 if (hostapd_config_read_radius_addr(
1639 &bss
->radius
->acct_servers
,
1640 &bss
->radius
->num_acct_servers
, pos
, 1813,
1641 &bss
->radius
->acct_server
)) {
1642 printf("Line %d: invalid IP address '%s'\n",
1646 } else if (bss
->radius
->acct_server
&&
1647 os_strcmp(buf
, "acct_server_port") == 0) {
1648 bss
->radius
->acct_server
->port
= atoi(pos
);
1649 } else if (bss
->radius
->acct_server
&&
1650 os_strcmp(buf
, "acct_server_shared_secret") == 0) {
1651 int len
= os_strlen(pos
);
1653 /* RFC 2865, Ch. 3 */
1654 printf("Line %d: empty shared secret is not "
1655 "allowed.\n", line
);
1658 bss
->radius
->acct_server
->shared_secret
=
1659 (u8
*) os_strdup(pos
);
1660 bss
->radius
->acct_server
->shared_secret_len
= len
;
1661 } else if (os_strcmp(buf
, "radius_retry_primary_interval") ==
1663 bss
->radius
->retry_primary_interval
= atoi(pos
);
1664 } else if (os_strcmp(buf
, "radius_acct_interim_interval") == 0)
1666 bss
->radius
->acct_interim_interval
= atoi(pos
);
1667 } else if (os_strcmp(buf
, "auth_algs") == 0) {
1668 bss
->auth_algs
= atoi(pos
);
1669 if (bss
->auth_algs
== 0) {
1670 printf("Line %d: no authentication algorithms "
1675 } else if (os_strcmp(buf
, "max_num_sta") == 0) {
1676 bss
->max_num_sta
= atoi(pos
);
1677 if (bss
->max_num_sta
< 0 ||
1678 bss
->max_num_sta
> MAX_STA_COUNT
) {
1679 printf("Line %d: Invalid max_num_sta=%d; "
1680 "allowed range 0..%d\n", line
,
1681 bss
->max_num_sta
, MAX_STA_COUNT
);
1684 } else if (os_strcmp(buf
, "wpa") == 0) {
1685 bss
->wpa
= atoi(pos
);
1686 } else if (os_strcmp(buf
, "wpa_group_rekey") == 0) {
1687 bss
->wpa_group_rekey
= atoi(pos
);
1688 } else if (os_strcmp(buf
, "wpa_strict_rekey") == 0) {
1689 bss
->wpa_strict_rekey
= atoi(pos
);
1690 } else if (os_strcmp(buf
, "wpa_gmk_rekey") == 0) {
1691 bss
->wpa_gmk_rekey
= atoi(pos
);
1692 } else if (os_strcmp(buf
, "wpa_ptk_rekey") == 0) {
1693 bss
->wpa_ptk_rekey
= atoi(pos
);
1694 } else if (os_strcmp(buf
, "wpa_passphrase") == 0) {
1695 int len
= os_strlen(pos
);
1696 if (len
< 8 || len
> 63) {
1697 printf("Line %d: invalid WPA passphrase length"
1698 " %d (expected 8..63)\n", line
, len
);
1701 os_free(bss
->ssid
.wpa_passphrase
);
1702 bss
->ssid
.wpa_passphrase
= os_strdup(pos
);
1704 } else if (os_strcmp(buf
, "wpa_psk") == 0) {
1705 os_free(bss
->ssid
.wpa_psk
);
1707 os_zalloc(sizeof(struct hostapd_wpa_psk
));
1708 if (bss
->ssid
.wpa_psk
== NULL
)
1710 else if (hexstr2bin(pos
, bss
->ssid
.wpa_psk
->psk
,
1712 pos
[PMK_LEN
* 2] != '\0') {
1713 printf("Line %d: Invalid PSK '%s'.\n", line
,
1717 bss
->ssid
.wpa_psk
->group
= 1;
1719 } else if (os_strcmp(buf
, "wpa_psk_file") == 0) {
1720 os_free(bss
->ssid
.wpa_psk_file
);
1721 bss
->ssid
.wpa_psk_file
= os_strdup(pos
);
1722 if (!bss
->ssid
.wpa_psk_file
) {
1723 printf("Line %d: allocation failed\n", line
);
1726 } else if (os_strcmp(buf
, "wpa_key_mgmt") == 0) {
1728 hostapd_config_parse_key_mgmt(line
, pos
);
1729 if (bss
->wpa_key_mgmt
== -1)
1731 } else if (os_strcmp(buf
, "wpa_pairwise") == 0) {
1733 hostapd_config_parse_cipher(line
, pos
);
1734 if (bss
->wpa_pairwise
== -1 ||
1735 bss
->wpa_pairwise
== 0)
1737 else if (bss
->wpa_pairwise
&
1738 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
|
1739 WPA_CIPHER_WEP104
)) {
1740 printf("Line %d: unsupported pairwise "
1741 "cipher suite '%s'\n",
1742 bss
->wpa_pairwise
, pos
);
1745 } else if (os_strcmp(buf
, "rsn_pairwise") == 0) {
1747 hostapd_config_parse_cipher(line
, pos
);
1748 if (bss
->rsn_pairwise
== -1 ||
1749 bss
->rsn_pairwise
== 0)
1751 else if (bss
->rsn_pairwise
&
1752 (WPA_CIPHER_NONE
| WPA_CIPHER_WEP40
|
1753 WPA_CIPHER_WEP104
)) {
1754 printf("Line %d: unsupported pairwise "
1755 "cipher suite '%s'\n",
1756 bss
->rsn_pairwise
, pos
);
1759 #ifdef CONFIG_RSN_PREAUTH
1760 } else if (os_strcmp(buf
, "rsn_preauth") == 0) {
1761 bss
->rsn_preauth
= atoi(pos
);
1762 } else if (os_strcmp(buf
, "rsn_preauth_interfaces") == 0) {
1763 bss
->rsn_preauth_interfaces
= os_strdup(pos
);
1764 #endif /* CONFIG_RSN_PREAUTH */
1765 #ifdef CONFIG_PEERKEY
1766 } else if (os_strcmp(buf
, "peerkey") == 0) {
1767 bss
->peerkey
= atoi(pos
);
1768 #endif /* CONFIG_PEERKEY */
1769 #ifdef CONFIG_IEEE80211R
1770 } else if (os_strcmp(buf
, "mobility_domain") == 0) {
1771 if (os_strlen(pos
) != 2 * MOBILITY_DOMAIN_ID_LEN
||
1772 hexstr2bin(pos
, bss
->mobility_domain
,
1773 MOBILITY_DOMAIN_ID_LEN
) != 0) {
1774 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
1775 "mobility_domain '%s'", line
, pos
);
1779 } else if (os_strcmp(buf
, "r1_key_holder") == 0) {
1780 if (os_strlen(pos
) != 2 * FT_R1KH_ID_LEN
||
1781 hexstr2bin(pos
, bss
->r1_key_holder
,
1782 FT_R1KH_ID_LEN
) != 0) {
1783 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
1784 "r1_key_holder '%s'", line
, pos
);
1788 } else if (os_strcmp(buf
, "r0_key_lifetime") == 0) {
1789 bss
->r0_key_lifetime
= atoi(pos
);
1790 } else if (os_strcmp(buf
, "reassociation_deadline") == 0) {
1791 bss
->reassociation_deadline
= atoi(pos
);
1792 } else if (os_strcmp(buf
, "r0kh") == 0) {
1793 if (add_r0kh(bss
, pos
) < 0) {
1794 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
1795 "r0kh '%s'", line
, pos
);
1799 } else if (os_strcmp(buf
, "r1kh") == 0) {
1800 if (add_r1kh(bss
, pos
) < 0) {
1801 wpa_printf(MSG_DEBUG
, "Line %d: Invalid "
1802 "r1kh '%s'", line
, pos
);
1806 } else if (os_strcmp(buf
, "pmk_r1_push") == 0) {
1807 bss
->pmk_r1_push
= atoi(pos
);
1808 #endif /* CONFIG_IEEE80211R */
1809 } else if (os_strcmp(buf
, "ctrl_interface") == 0) {
1810 os_free(bss
->ctrl_interface
);
1811 bss
->ctrl_interface
= os_strdup(pos
);
1812 } else if (os_strcmp(buf
, "ctrl_interface_group") == 0) {
1813 #ifndef CONFIG_NATIVE_WINDOWS
1816 const char *group
= pos
;
1818 grp
= getgrnam(group
);
1820 bss
->ctrl_interface_gid
= grp
->gr_gid
;
1821 bss
->ctrl_interface_gid_set
= 1;
1822 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d"
1823 " (from group name '%s')",
1824 bss
->ctrl_interface_gid
, group
);
1828 /* Group name not found - try to parse this as gid */
1829 bss
->ctrl_interface_gid
= strtol(group
, &endp
, 10);
1830 if (*group
== '\0' || *endp
!= '\0') {
1831 wpa_printf(MSG_DEBUG
, "Line %d: Invalid group "
1832 "'%s'", line
, group
);
1836 bss
->ctrl_interface_gid_set
= 1;
1837 wpa_printf(MSG_DEBUG
, "ctrl_interface_group=%d",
1838 bss
->ctrl_interface_gid
);
1839 #endif /* CONFIG_NATIVE_WINDOWS */
1840 #ifdef RADIUS_SERVER
1841 } else if (os_strcmp(buf
, "radius_server_clients") == 0) {
1842 os_free(bss
->radius_server_clients
);
1843 bss
->radius_server_clients
= os_strdup(pos
);
1844 } else if (os_strcmp(buf
, "radius_server_auth_port") == 0) {
1845 bss
->radius_server_auth_port
= atoi(pos
);
1846 } else if (os_strcmp(buf
, "radius_server_ipv6") == 0) {
1847 bss
->radius_server_ipv6
= atoi(pos
);
1848 #endif /* RADIUS_SERVER */
1849 } else if (os_strcmp(buf
, "test_socket") == 0) {
1850 os_free(bss
->test_socket
);
1851 bss
->test_socket
= os_strdup(pos
);
1852 } else if (os_strcmp(buf
, "use_pae_group_addr") == 0) {
1853 bss
->use_pae_group_addr
= atoi(pos
);
1854 } else if (os_strcmp(buf
, "hw_mode") == 0) {
1855 if (os_strcmp(pos
, "a") == 0)
1856 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211A
;
1857 else if (os_strcmp(pos
, "b") == 0)
1858 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211B
;
1859 else if (os_strcmp(pos
, "g") == 0)
1860 conf
->hw_mode
= HOSTAPD_MODE_IEEE80211G
;
1862 printf("Line %d: unknown hw_mode '%s'\n",
1866 } else if (os_strcmp(buf
, "channel") == 0) {
1867 conf
->channel
= atoi(pos
);
1868 } else if (os_strcmp(buf
, "beacon_int") == 0) {
1869 int val
= atoi(pos
);
1870 /* MIB defines range as 1..65535, but very small values
1871 * cause problems with the current implementation.
1872 * Since it is unlikely that this small numbers are
1873 * useful in real life scenarios, do not allow beacon
1874 * period to be set below 15 TU. */
1875 if (val
< 15 || val
> 65535) {
1876 printf("Line %d: invalid beacon_int %d "
1877 "(expected 15..65535)\n",
1881 conf
->beacon_int
= val
;
1882 } else if (os_strcmp(buf
, "dtim_period") == 0) {
1883 bss
->dtim_period
= atoi(pos
);
1884 if (bss
->dtim_period
< 1 || bss
->dtim_period
> 255) {
1885 printf("Line %d: invalid dtim_period %d\n",
1886 line
, bss
->dtim_period
);
1889 } else if (os_strcmp(buf
, "rts_threshold") == 0) {
1890 conf
->rts_threshold
= atoi(pos
);
1891 if (conf
->rts_threshold
< 0 ||
1892 conf
->rts_threshold
> 2347) {
1893 printf("Line %d: invalid rts_threshold %d\n",
1894 line
, conf
->rts_threshold
);
1897 } else if (os_strcmp(buf
, "fragm_threshold") == 0) {
1898 conf
->fragm_threshold
= atoi(pos
);
1899 if (conf
->fragm_threshold
< 256 ||
1900 conf
->fragm_threshold
> 2346) {
1901 printf("Line %d: invalid fragm_threshold %d\n",
1902 line
, conf
->fragm_threshold
);
1905 } else if (os_strcmp(buf
, "send_probe_response") == 0) {
1906 int val
= atoi(pos
);
1907 if (val
!= 0 && val
!= 1) {
1908 printf("Line %d: invalid send_probe_response "
1909 "%d (expected 0 or 1)\n", line
, val
);
1911 conf
->send_probe_response
= val
;
1912 } else if (os_strcmp(buf
, "supported_rates") == 0) {
1913 if (hostapd_parse_rates(&conf
->supported_rates
, pos
)) {
1914 printf("Line %d: invalid rate list\n", line
);
1917 } else if (os_strcmp(buf
, "basic_rates") == 0) {
1918 if (hostapd_parse_rates(&conf
->basic_rates
, pos
)) {
1919 printf("Line %d: invalid rate list\n", line
);
1922 } else if (os_strcmp(buf
, "preamble") == 0) {
1924 conf
->preamble
= SHORT_PREAMBLE
;
1926 conf
->preamble
= LONG_PREAMBLE
;
1927 } else if (os_strcmp(buf
, "ignore_broadcast_ssid") == 0) {
1928 bss
->ignore_broadcast_ssid
= atoi(pos
);
1929 } else if (os_strcmp(buf
, "bridge_packets") == 0) {
1930 conf
->bridge_packets
= atoi(pos
);
1931 } else if (os_strcmp(buf
, "wep_default_key") == 0) {
1932 bss
->ssid
.wep
.idx
= atoi(pos
);
1933 if (bss
->ssid
.wep
.idx
> 3) {
1934 printf("Invalid wep_default_key index %d\n",
1938 } else if (os_strcmp(buf
, "wep_key0") == 0 ||
1939 os_strcmp(buf
, "wep_key1") == 0 ||
1940 os_strcmp(buf
, "wep_key2") == 0 ||
1941 os_strcmp(buf
, "wep_key3") == 0) {
1942 if (hostapd_config_read_wep(&bss
->ssid
.wep
,
1943 buf
[7] - '0', pos
)) {
1944 printf("Line %d: invalid WEP key '%s'\n",
1948 } else if (os_strcmp(buf
, "dynamic_vlan") == 0) {
1949 bss
->ssid
.dynamic_vlan
= atoi(pos
);
1950 } else if (os_strcmp(buf
, "vlan_file") == 0) {
1951 if (hostapd_config_read_vlan_file(bss
, pos
)) {
1952 printf("Line %d: failed to read VLAN file "
1953 "'%s'\n", line
, pos
);
1956 #ifdef CONFIG_FULL_DYNAMIC_VLAN
1957 } else if (os_strcmp(buf
, "vlan_tagged_interface") == 0) {
1958 bss
->ssid
.vlan_tagged_interface
= os_strdup(pos
);
1959 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
1960 } else if (os_strcmp(buf
, "passive_scan_interval") == 0) {
1961 conf
->passive_scan_interval
= atoi(pos
);
1962 } else if (os_strcmp(buf
, "passive_scan_listen") == 0) {
1963 conf
->passive_scan_listen
= atoi(pos
);
1964 } else if (os_strcmp(buf
, "passive_scan_mode") == 0) {
1965 conf
->passive_scan_mode
= atoi(pos
);
1966 } else if (os_strcmp(buf
, "ap_table_max_size") == 0) {
1967 conf
->ap_table_max_size
= atoi(pos
);
1968 } else if (os_strcmp(buf
, "ap_table_expiration_time") == 0) {
1969 conf
->ap_table_expiration_time
= atoi(pos
);
1970 } else if (os_strncmp(buf
, "tx_queue_", 9) == 0) {
1971 if (hostapd_config_tx_queue(conf
, buf
, pos
)) {
1972 printf("Line %d: invalid TX queue item\n",
1976 } else if (os_strcmp(buf
, "wme_enabled") == 0) {
1977 bss
->wme_enabled
= atoi(pos
);
1978 } else if (os_strncmp(buf
, "wme_ac_", 7) == 0) {
1979 if (hostapd_config_wme_ac(conf
, buf
, pos
)) {
1980 printf("Line %d: invalid wme ac item\n",
1984 } else if (os_strcmp(buf
, "bss") == 0) {
1985 if (hostapd_config_bss(conf
, pos
)) {
1986 printf("Line %d: invalid bss item\n", line
);
1989 } else if (os_strcmp(buf
, "bssid") == 0) {
1990 if (bss
== conf
->bss
&&
1991 (!conf
->driver
|| !conf
->driver
->init_bssid
)) {
1992 printf("Line %d: bssid item not allowed "
1993 "for the default interface and this "
1996 } else if (hwaddr_aton(pos
, bss
->bssid
)) {
1997 printf("Line %d: invalid bssid item\n", line
);
2000 #ifdef CONFIG_IEEE80211W
2001 } else if (os_strcmp(buf
, "ieee80211w") == 0) {
2002 bss
->ieee80211w
= atoi(pos
);
2003 } else if (os_strcmp(buf
, "assoc_ping_timeout") == 0) {
2004 bss
->assoc_ping_timeout
= atoi(pos
);
2005 if (bss
->assoc_ping_timeout
== 0) {
2006 printf("Line %d: invalid assoc_ping_timeout\n",
2010 } else if (os_strcmp(buf
, "assoc_ping_attempts") == 0) {
2011 bss
->assoc_ping_timeout
= atoi(pos
);
2012 if (bss
->assoc_ping_timeout
== 0) {
2013 printf("Line %d: invalid assoc_ping_attempts "
2014 "(valid range: 1..255)\n",
2018 #endif /* CONFIG_IEEE80211W */
2019 #ifdef CONFIG_IEEE80211N
2020 } else if (os_strcmp(buf
, "ieee80211n") == 0) {
2021 conf
->ieee80211n
= atoi(pos
);
2022 #endif /* CONFIG_IEEE80211N */
2023 } else if (os_strcmp(buf
, "max_listen_interval") == 0) {
2024 bss
->max_listen_interval
= atoi(pos
);
2025 } else if (os_strcmp(buf
, "okc") == 0) {
2026 bss
->okc
= atoi(pos
);
2028 } else if (os_strcmp(buf
, "wps_state") == 0) {
2029 bss
->wps_state
= atoi(pos
);
2030 if (bss
->wps_state
< 0 || bss
->wps_state
> 2) {
2031 printf("Line %d: invalid wps_state\n", line
);
2034 } else if (os_strcmp(buf
, "ap_setup_locked") == 0) {
2035 bss
->ap_setup_locked
= atoi(pos
);
2036 } else if (os_strcmp(buf
, "uuid") == 0) {
2037 if (uuid_str2bin(pos
, bss
->uuid
)) {
2038 printf("Line %d: invalid UUID\n", line
);
2041 } else if (os_strcmp(buf
, "wps_pin_requests") == 0) {
2042 bss
->wps_pin_requests
= os_strdup(pos
);
2043 } else if (os_strcmp(buf
, "device_name") == 0) {
2044 bss
->device_name
= os_strdup(pos
);
2045 } else if (os_strcmp(buf
, "manufacturer") == 0) {
2046 bss
->manufacturer
= os_strdup(pos
);
2047 } else if (os_strcmp(buf
, "model_name") == 0) {
2048 bss
->model_name
= os_strdup(pos
);
2049 } else if (os_strcmp(buf
, "model_number") == 0) {
2050 bss
->model_number
= os_strdup(pos
);
2051 } else if (os_strcmp(buf
, "serial_number") == 0) {
2052 bss
->serial_number
= os_strdup(pos
);
2053 } else if (os_strcmp(buf
, "device_type") == 0) {
2054 bss
->device_type
= os_strdup(pos
);
2055 } else if (os_strcmp(buf
, "config_methods") == 0) {
2056 bss
->config_methods
= os_strdup(pos
);
2057 } else if (os_strcmp(buf
, "os_version") == 0) {
2058 if (hexstr2bin(pos
, bss
->os_version
, 4)) {
2059 printf("Line %d: invalid os_version\n", line
);
2062 } else if (os_strcmp(buf
, "ap_pin") == 0) {
2063 bss
->ap_pin
= os_strdup(pos
);
2064 #endif /* CONFIG_WPS */
2066 printf("Line %d: unknown configuration item '%s'\n",
2074 if (bss
->individual_wep_key_len
== 0) {
2075 /* individual keys are not use; can use key idx0 for broadcast
2077 bss
->broadcast_key_idx_min
= 0;
2080 /* Select group cipher based on the enabled pairwise cipher suites */
2083 pairwise
|= bss
->wpa_pairwise
;
2085 if (bss
->rsn_pairwise
== 0)
2086 bss
->rsn_pairwise
= bss
->wpa_pairwise
;
2087 pairwise
|= bss
->rsn_pairwise
;
2089 if (pairwise
& WPA_CIPHER_TKIP
)
2090 bss
->wpa_group
= WPA_CIPHER_TKIP
;
2092 bss
->wpa_group
= WPA_CIPHER_CCMP
;
2094 for (i
= 0; i
< conf
->num_bss
; i
++) {
2095 bss
= &conf
->bss
[i
];
2097 bss
->radius
->auth_server
= bss
->radius
->auth_servers
;
2098 bss
->radius
->acct_server
= bss
->radius
->acct_servers
;
2100 if (bss
->wpa
&& bss
->ieee802_1x
) {
2101 bss
->ssid
.security_policy
= SECURITY_WPA
;
2102 } else if (bss
->wpa
) {
2103 bss
->ssid
.security_policy
= SECURITY_WPA_PSK
;
2104 } else if (bss
->ieee802_1x
) {
2105 bss
->ssid
.security_policy
= SECURITY_IEEE_802_1X
;
2106 bss
->ssid
.wep
.default_len
= bss
->default_wep_key_len
;
2107 } else if (bss
->ssid
.wep
.keys_set
)
2108 bss
->ssid
.security_policy
= SECURITY_STATIC_WEP
;
2110 bss
->ssid
.security_policy
= SECURITY_PLAINTEXT
;
2113 if (hostapd_config_check(conf
))
2117 printf("%d errors found in configuration file '%s'\n",
2119 hostapd_config_free(conf
);
2127 int hostapd_wep_key_cmp(struct hostapd_wep_keys
*a
, struct hostapd_wep_keys
*b
)
2131 if (a
->idx
!= b
->idx
|| a
->default_len
!= b
->default_len
)
2133 for (i
= 0; i
< NUM_WEP_KEYS
; i
++)
2134 if (a
->len
[i
] != b
->len
[i
] ||
2135 os_memcmp(a
->key
[i
], b
->key
[i
], a
->len
[i
]) != 0)
2141 static void hostapd_config_free_radius(struct hostapd_radius_server
*servers
,
2146 for (i
= 0; i
< num_servers
; i
++) {
2147 os_free(servers
[i
].shared_secret
);
2153 static void hostapd_config_free_eap_user(struct hostapd_eap_user
*user
)
2155 os_free(user
->identity
);
2156 os_free(user
->password
);
2161 static void hostapd_config_free_wep(struct hostapd_wep_keys
*keys
)
2164 for (i
= 0; i
< NUM_WEP_KEYS
; i
++) {
2165 os_free(keys
->key
[i
]);
2166 keys
->key
[i
] = NULL
;
2171 static void hostapd_config_free_bss(struct hostapd_bss_config
*conf
)
2173 struct hostapd_wpa_psk
*psk
, *prev
;
2174 struct hostapd_eap_user
*user
, *prev_user
;
2179 psk
= conf
->ssid
.wpa_psk
;
2186 os_free(conf
->ssid
.wpa_passphrase
);
2187 os_free(conf
->ssid
.wpa_psk_file
);
2188 #ifdef CONFIG_FULL_DYNAMIC_VLAN
2189 os_free(conf
->ssid
.vlan_tagged_interface
);
2190 #endif /* CONFIG_FULL_DYNAMIC_VLAN */
2192 user
= conf
->eap_user
;
2196 hostapd_config_free_eap_user(prev_user
);
2199 os_free(conf
->dump_log_name
);
2200 os_free(conf
->eap_req_id_text
);
2201 os_free(conf
->accept_mac
);
2202 os_free(conf
->deny_mac
);
2203 os_free(conf
->nas_identifier
);
2204 hostapd_config_free_radius(conf
->radius
->auth_servers
,
2205 conf
->radius
->num_auth_servers
);
2206 hostapd_config_free_radius(conf
->radius
->acct_servers
,
2207 conf
->radius
->num_acct_servers
);
2208 os_free(conf
->rsn_preauth_interfaces
);
2209 os_free(conf
->ctrl_interface
);
2210 os_free(conf
->ca_cert
);
2211 os_free(conf
->server_cert
);
2212 os_free(conf
->private_key
);
2213 os_free(conf
->private_key_passwd
);
2214 os_free(conf
->dh_file
);
2215 os_free(conf
->pac_opaque_encr_key
);
2216 os_free(conf
->eap_fast_a_id
);
2217 os_free(conf
->eap_fast_a_id_info
);
2218 os_free(conf
->eap_sim_db
);
2219 os_free(conf
->radius_server_clients
);
2220 os_free(conf
->test_socket
);
2221 os_free(conf
->radius
);
2222 hostapd_config_free_vlan(conf
);
2223 if (conf
->ssid
.dyn_vlan_keys
) {
2224 struct hostapd_ssid
*ssid
= &conf
->ssid
;
2226 for (i
= 0; i
<= ssid
->max_dyn_vlan_keys
; i
++) {
2227 if (ssid
->dyn_vlan_keys
[i
] == NULL
)
2229 hostapd_config_free_wep(ssid
->dyn_vlan_keys
[i
]);
2230 os_free(ssid
->dyn_vlan_keys
[i
]);
2232 os_free(ssid
->dyn_vlan_keys
);
2233 ssid
->dyn_vlan_keys
= NULL
;
2236 #ifdef CONFIG_IEEE80211R
2238 struct ft_remote_r0kh
*r0kh
, *r0kh_prev
;
2239 struct ft_remote_r1kh
*r1kh
, *r1kh_prev
;
2241 r0kh
= conf
->r0kh_list
;
2242 conf
->r0kh_list
= NULL
;
2249 r1kh
= conf
->r1kh_list
;
2250 conf
->r1kh_list
= NULL
;
2257 #endif /* CONFIG_IEEE80211R */
2260 os_free(conf
->wps_pin_requests
);
2261 os_free(conf
->device_name
);
2262 os_free(conf
->manufacturer
);
2263 os_free(conf
->model_name
);
2264 os_free(conf
->model_number
);
2265 os_free(conf
->serial_number
);
2266 os_free(conf
->device_type
);
2267 os_free(conf
->config_methods
);
2268 os_free(conf
->ap_pin
);
2269 #endif /* CONFIG_WPS */
2273 void hostapd_config_free(struct hostapd_config
*conf
)
2280 for (i
= 0; i
< conf
->num_bss
; i
++)
2281 hostapd_config_free_bss(&conf
->bss
[i
]);
2288 /* Perform a binary search for given MAC address from a pre-sorted list.
2289 * Returns 1 if address is in the list or 0 if not. */
2290 int hostapd_maclist_found(struct mac_acl_entry
*list
, int num_entries
,
2291 const u8
*addr
, int *vlan_id
)
2293 int start
, end
, middle
, res
;
2296 end
= num_entries
- 1;
2298 while (start
<= end
) {
2299 middle
= (start
+ end
) / 2;
2300 res
= os_memcmp(list
[middle
].addr
, addr
, ETH_ALEN
);
2303 *vlan_id
= list
[middle
].vlan_id
;
2316 int hostapd_rate_found(int *list
, int rate
)
2323 for (i
= 0; list
[i
] >= 0; i
++)
2324 if (list
[i
] == rate
)
2331 const char * hostapd_get_vlan_id_ifname(struct hostapd_vlan
*vlan
, int vlan_id
)
2333 struct hostapd_vlan
*v
= vlan
;
2335 if (v
->vlan_id
== vlan_id
|| v
->vlan_id
== VLAN_ID_WILDCARD
)
2343 const u8
* hostapd_get_psk(const struct hostapd_bss_config
*conf
,
2344 const u8
*addr
, const u8
*prev_psk
)
2346 struct hostapd_wpa_psk
*psk
;
2347 int next_ok
= prev_psk
== NULL
;
2349 for (psk
= conf
->ssid
.wpa_psk
; psk
!= NULL
; psk
= psk
->next
) {
2351 (psk
->group
|| os_memcmp(psk
->addr
, addr
, ETH_ALEN
) == 0))
2354 if (psk
->psk
== prev_psk
)
2362 const struct hostapd_eap_user
*
2363 hostapd_get_eap_user(const struct hostapd_bss_config
*conf
, const u8
*identity
,
2364 size_t identity_len
, int phase2
)
2366 struct hostapd_eap_user
*user
= conf
->eap_user
;
2369 if (conf
->wps_state
&& identity_len
== WSC_ID_ENROLLEE_LEN
&&
2370 os_memcmp(identity
, WSC_ID_ENROLLEE
, WSC_ID_ENROLLEE_LEN
) == 0) {
2371 static struct hostapd_eap_user wsc_enrollee
;
2372 os_memset(&wsc_enrollee
, 0, sizeof(wsc_enrollee
));
2373 wsc_enrollee
.methods
[0].method
= eap_server_get_type(
2374 "WSC", &wsc_enrollee
.methods
[0].vendor
);
2375 return &wsc_enrollee
;
2378 if (conf
->wps_state
&& conf
->ap_pin
&&
2379 identity_len
== WSC_ID_REGISTRAR_LEN
&&
2380 os_memcmp(identity
, WSC_ID_REGISTRAR
, WSC_ID_REGISTRAR_LEN
) == 0) {
2381 static struct hostapd_eap_user wsc_registrar
;
2382 os_memset(&wsc_registrar
, 0, sizeof(wsc_registrar
));
2383 wsc_registrar
.methods
[0].method
= eap_server_get_type(
2384 "WSC", &wsc_registrar
.methods
[0].vendor
);
2385 wsc_registrar
.password
= (u8
*) conf
->ap_pin
;
2386 wsc_registrar
.password_len
= os_strlen(conf
->ap_pin
);
2387 return &wsc_registrar
;
2389 #endif /* CONFIG_WPS */
2392 if (!phase2
&& user
->identity
== NULL
) {
2393 /* Wildcard match */
2397 if (user
->phase2
== !!phase2
&& user
->wildcard_prefix
&&
2398 identity_len
>= user
->identity_len
&&
2399 os_memcmp(user
->identity
, identity
, user
->identity_len
) ==
2401 /* Wildcard prefix match */
2405 if (user
->phase2
== !!phase2
&&
2406 user
->identity_len
== identity_len
&&
2407 os_memcmp(user
->identity
, identity
, identity_len
) == 0)