2 * hostapd / IEEE 802.1X Authenticator
3 * Copyright (c) 2002-2006, Jouni Malinen <j@w1.fi>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
9 * Alternatively, this software may be distributed under the terms of BSD
12 * See README and COPYING for more details.
19 #include "ieee802_1x.h"
20 #include "accounting.h"
22 #include "radius_client.h"
30 #include "pmksa_cache.h"
32 #include "hw_features.h"
36 static void ieee802_1x_new_auth_session(struct hostapd_data
*hapd
,
37 struct sta_info
*sta
);
40 static void ieee802_1x_send(struct hostapd_data
*hapd
, struct sta_info
*sta
,
41 u8 type
, u8
*data
, size_t datalen
)
44 struct ieee802_1x_hdr
*xhdr
;
48 len
= sizeof(*xhdr
) + datalen
;
49 buf
= wpa_zalloc(len
);
51 printf("malloc() failed for ieee802_1x_send(len=%lu)\n",
58 * According to IEEE 802.1aa/D4 EAPOL-Key should be sent before any
59 * remaining EAP frames, if possible. This would allow rest of the
60 * frames to be encrypted. This code could be used to request
61 * encryption from the kernel driver. */
63 sta
->eapol_sm
->be_auth
.state
== BE_AUTH_SUCCESS
&&
64 sta
->eapol_sm
->keyTxEnabled
)
68 xhdr
= (struct ieee802_1x_hdr
*) buf
;
69 xhdr
->version
= hapd
->conf
->eapol_version
;
71 xhdr
->length
= htons(datalen
);
73 if (datalen
> 0 && data
!= NULL
)
74 memcpy(xhdr
+ 1, data
, datalen
);
76 if (wpa_auth_pairwise_set(sta
->wpa_sm
))
78 if (sta
->flags
& WLAN_STA_PREAUTH
) {
79 rsn_preauth_send(hapd
, sta
, buf
, len
);
81 hostapd_send_eapol(hapd
, sta
->addr
, buf
, len
, encrypt
);
88 void ieee802_1x_set_sta_authorized(struct hostapd_data
*hapd
,
89 struct sta_info
*sta
, int authorized
)
93 if (sta
->flags
& WLAN_STA_PREAUTH
)
97 sta
->flags
|= WLAN_STA_AUTHORIZED
;
98 res
= hostapd_sta_set_flags(hapd
, sta
->addr
,
99 WLAN_STA_AUTHORIZED
, ~0);
100 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
101 HOSTAPD_LEVEL_DEBUG
, "authorizing port");
103 sta
->flags
&= ~WLAN_STA_AUTHORIZED
;
104 res
= hostapd_sta_set_flags(hapd
, sta
->addr
,
105 0, ~WLAN_STA_AUTHORIZED
);
106 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
107 HOSTAPD_LEVEL_DEBUG
, "unauthorizing port");
110 if (res
&& errno
!= ENOENT
) {
111 printf("Could not set station " MACSTR
" flags for kernel "
112 "driver (errno=%d).\n", MAC2STR(sta
->addr
), errno
);
116 accounting_sta_start(hapd
, sta
);
120 static void ieee802_1x_eap_timeout(void *eloop_ctx
, void *timeout_ctx
)
122 struct sta_info
*sta
= eloop_ctx
;
123 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
126 hostapd_logger(sm
->hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
127 HOSTAPD_LEVEL_DEBUG
, "EAP timeout");
128 sm
->eapTimeout
= TRUE
;
133 void ieee802_1x_request_identity(struct hostapd_data
*hapd
,
134 struct sta_info
*sta
)
140 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
142 if (hapd
->conf
->eap_server
) {
143 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
144 "IEEE 802.1X: Integrated EAP server in "
145 "use - do not generate EAP-Request/Identity\n");
149 if (sm
== NULL
|| !sm
->eapRestart
)
152 ieee802_1x_new_auth_session(hapd
, sta
);
154 tlen
= sizeof(*eap
) + 1 + hapd
->conf
->eap_req_id_text_len
;
156 buf
= wpa_zalloc(tlen
);
158 printf("Could not allocate memory for identity request\n");
162 eap
= (struct eap_hdr
*) buf
;
163 eap
->code
= EAP_CODE_REQUEST
;
164 eap
->identifier
= ++sm
->currentId
;
165 eap
->length
= htons(tlen
);
166 pos
= (u8
*) (eap
+ 1);
167 *pos
++ = EAP_TYPE_IDENTITY
;
168 if (hapd
->conf
->eap_req_id_text
) {
169 memcpy(pos
, hapd
->conf
->eap_req_id_text
,
170 hapd
->conf
->eap_req_id_text_len
);
174 free(sm
->last_eap_radius
);
175 sm
->last_eap_radius
= buf
;
176 sm
->last_eap_radius_len
= tlen
;
178 eloop_cancel_timeout(ieee802_1x_eap_timeout
, sta
, NULL
);
179 eloop_register_timeout(30, 0, ieee802_1x_eap_timeout
, sta
, NULL
);
180 sm
->eapTimeout
= FALSE
;
182 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
183 "IEEE 802.1X: Generated EAP Request-Identity for " MACSTR
184 " (identifier %d, timeout 30)\n", MAC2STR(sta
->addr
),
187 sm
->eapRestart
= FALSE
;
191 void ieee802_1x_tx_canned_eap(struct hostapd_data
*hapd
, struct sta_info
*sta
,
195 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
197 memset(&eap
, 0, sizeof(eap
));
199 eap
.code
= success
? EAP_CODE_SUCCESS
: EAP_CODE_FAILURE
;
201 if (sm
&& sm
->last_eap_radius
) {
202 struct eap_hdr
*hdr
= (struct eap_hdr
*) sm
->last_eap_radius
;
203 eap
.identifier
= hdr
->identifier
+ 1;
205 eap
.length
= htons(sizeof(eap
));
207 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
208 "IEEE 802.1X: Sending canned EAP packet %s to " MACSTR
209 " (identifier %d)\n", success
? "SUCCESS" : "FAILURE",
210 MAC2STR(sta
->addr
), eap
.identifier
);
211 ieee802_1x_send(hapd
, sta
, IEEE802_1X_TYPE_EAP_PACKET
, (u8
*) &eap
,
214 sm
->dot1xAuthEapolFramesTx
++;
218 void ieee802_1x_tx_req(struct hostapd_data
*hapd
, struct sta_info
*sta
)
221 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
226 if (sm
->last_eap_radius
== NULL
) {
227 printf("Error: TxReq called for station " MACSTR
", but there "
228 "is no EAP request from the authentication server\n",
233 eap
= (struct eap_hdr
*) sm
->last_eap_radius
;
234 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
235 "IEEE 802.1X: Sending EAP Packet to " MACSTR
236 " (identifier %d)\n", MAC2STR(sm
->addr
),
238 sm
->currentId
= eap
->identifier
;
239 ieee802_1x_send(hapd
, sta
, IEEE802_1X_TYPE_EAP_PACKET
,
240 sm
->last_eap_radius
, sm
->last_eap_radius_len
);
241 sm
->dot1xAuthEapolFramesTx
++;
242 type
= (u8
*) (eap
+ 1);
243 if (sm
->last_eap_radius_len
> sizeof(*eap
) &&
244 *type
== EAP_TYPE_IDENTITY
)
245 sm
->dot1xAuthEapolReqIdFramesTx
++;
247 sm
->dot1xAuthEapolReqFramesTx
++;
251 static void ieee802_1x_tx_key_one(struct hostapd_data
*hapd
,
252 struct sta_info
*sta
,
253 int idx
, int broadcast
,
254 u8
*key_data
, size_t key_len
)
257 struct ieee802_1x_hdr
*hdr
;
258 struct ieee802_1x_eapol_key
*key
;
259 size_t len
, ekey_len
;
260 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
265 len
= sizeof(*key
) + key_len
;
266 buf
= wpa_zalloc(sizeof(*hdr
) + len
);
270 hdr
= (struct ieee802_1x_hdr
*) buf
;
271 key
= (struct ieee802_1x_eapol_key
*) (hdr
+ 1);
272 key
->type
= EAPOL_KEY_TYPE_RC4
;
273 key
->key_length
= htons(key_len
);
274 wpa_get_ntp_timestamp(key
->replay_counter
);
276 if (hostapd_get_rand(key
->key_iv
, sizeof(key
->key_iv
))) {
277 printf("Could not get random numbers\n");
282 key
->key_index
= idx
| (broadcast
? 0 : BIT(7));
283 if (hapd
->conf
->eapol_key_index_workaround
) {
284 /* According to some information, WinXP Supplicant seems to
285 * interpret bit7 as an indication whether the key is to be
286 * activated, so make it possible to enable workaround that
287 * sets this bit for all keys. */
288 key
->key_index
|= BIT(7);
291 /* Key is encrypted using "Key-IV + sm->eapol_key_crypt" as the
293 memcpy((u8
*) (key
+ 1), key_data
, key_len
);
294 ekey_len
= sizeof(key
->key_iv
) + sm
->eapol_key_crypt_len
;
295 ekey
= malloc(ekey_len
);
297 printf("Could not encrypt key\n");
301 memcpy(ekey
, key
->key_iv
, sizeof(key
->key_iv
));
302 memcpy(ekey
+ sizeof(key
->key_iv
), sm
->eapol_key_crypt
,
303 sm
->eapol_key_crypt_len
);
304 rc4((u8
*) (key
+ 1), key_len
, ekey
, ekey_len
);
307 /* This header is needed here for HMAC-MD5, but it will be regenerated
308 * in ieee802_1x_send() */
309 hdr
->version
= hapd
->conf
->eapol_version
;
310 hdr
->type
= IEEE802_1X_TYPE_EAPOL_KEY
;
311 hdr
->length
= htons(len
);
312 hmac_md5(sm
->eapol_key_sign
, sm
->eapol_key_sign_len
,
313 buf
, sizeof(*hdr
) + len
,
316 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
317 "IEEE 802.1X: Sending EAPOL-Key to " MACSTR
318 " (%s index=%d)\n", MAC2STR(sm
->addr
),
319 broadcast
? "broadcast" : "unicast", idx
);
320 ieee802_1x_send(hapd
, sta
, IEEE802_1X_TYPE_EAPOL_KEY
, (u8
*) key
, len
);
322 sta
->eapol_sm
->dot1xAuthEapolFramesTx
++;
327 static struct hostapd_wep_keys
*
328 ieee802_1x_group_alloc(struct hostapd_data
*hapd
, const char *ifname
)
330 struct hostapd_wep_keys
*key
;
332 key
= wpa_zalloc(sizeof(*key
));
336 key
->default_len
= hapd
->conf
->default_wep_key_len
;
338 if (key
->idx
>= hapd
->conf
->broadcast_key_idx_max
||
339 key
->idx
< hapd
->conf
->broadcast_key_idx_min
)
340 key
->idx
= hapd
->conf
->broadcast_key_idx_min
;
344 if (!key
->key
[key
->idx
])
345 key
->key
[key
->idx
] = malloc(key
->default_len
);
346 if (key
->key
[key
->idx
] == NULL
||
347 hostapd_get_rand(key
->key
[key
->idx
], key
->default_len
)) {
348 printf("Could not generate random WEP key (dynamic VLAN).\n");
349 free(key
->key
[key
->idx
]);
350 key
->key
[key
->idx
] = NULL
;
354 key
->len
[key
->idx
] = key
->default_len
;
356 if (HOSTAPD_DEBUG_COND(HOSTAPD_DEBUG_MINIMAL
)) {
357 printf("%s: Default WEP idx %d for dynamic VLAN\n",
359 wpa_hexdump_key(MSG_DEBUG
, "Default WEP key (dynamic VLAN)",
360 key
->key
[key
->idx
], key
->len
[key
->idx
]);
363 if (hostapd_set_encryption(ifname
, hapd
, "WEP", NULL
, key
->idx
,
364 key
->key
[key
->idx
], key
->len
[key
->idx
], 1))
365 printf("Could not set dynamic VLAN WEP encryption key.\n");
367 hostapd_set_ieee8021x(ifname
, hapd
, 1);
373 static struct hostapd_wep_keys
*
374 ieee802_1x_get_group(struct hostapd_data
*hapd
, struct hostapd_ssid
*ssid
,
382 if (vlan_id
<= ssid
->max_dyn_vlan_keys
&& ssid
->dyn_vlan_keys
&&
383 ssid
->dyn_vlan_keys
[vlan_id
])
384 return ssid
->dyn_vlan_keys
[vlan_id
];
386 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, "IEEE 802.1X: Creating new group "
387 "state machine for VLAN ID %lu\n",
388 (unsigned long) vlan_id
);
390 ifname
= hostapd_get_vlan_id_ifname(hapd
->conf
->vlan
, vlan_id
);
391 if (ifname
== NULL
) {
392 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, "IEEE 802.1X: Unknown "
393 "VLAN ID %lu - cannot create group key state "
394 "machine\n", (unsigned long) vlan_id
);
398 if (ssid
->dyn_vlan_keys
== NULL
) {
399 int size
= (vlan_id
+ 1) * sizeof(ssid
->dyn_vlan_keys
[0]);
400 ssid
->dyn_vlan_keys
= wpa_zalloc(size
);
401 if (ssid
->dyn_vlan_keys
== NULL
)
403 ssid
->max_dyn_vlan_keys
= vlan_id
;
406 if (ssid
->max_dyn_vlan_keys
< vlan_id
) {
407 struct hostapd_wep_keys
**na
;
408 int size
= (vlan_id
+ 1) * sizeof(ssid
->dyn_vlan_keys
[0]);
409 na
= realloc(ssid
->dyn_vlan_keys
, size
);
412 ssid
->dyn_vlan_keys
= na
;
413 memset(&ssid
->dyn_vlan_keys
[ssid
->max_dyn_vlan_keys
+ 1], 0,
414 (vlan_id
- ssid
->max_dyn_vlan_keys
) *
415 sizeof(ssid
->dyn_vlan_keys
[0]));
416 ssid
->max_dyn_vlan_keys
= vlan_id
;
419 ssid
->dyn_vlan_keys
[vlan_id
] = ieee802_1x_group_alloc(hapd
, ifname
);
421 return ssid
->dyn_vlan_keys
[vlan_id
];
425 void ieee802_1x_tx_key(struct hostapd_data
*hapd
, struct sta_info
*sta
)
427 struct hostapd_wep_keys
*key
= NULL
;
428 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
431 if (sm
== NULL
|| !sm
->eapol_key_sign
|| !sm
->eapol_key_crypt
)
434 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
435 "IEEE 802.1X: Sending EAPOL-Key(s) to " MACSTR
"\n",
438 vlan_id
= sta
->vlan_id
;
439 if (vlan_id
< 0 || vlan_id
> MAX_VLAN_ID
)
443 key
= ieee802_1x_get_group(hapd
, sta
->ssid
, vlan_id
);
444 if (key
&& key
->key
[key
->idx
])
445 ieee802_1x_tx_key_one(hapd
, sta
, key
->idx
, 1,
448 } else if (hapd
->default_wep_key
) {
449 ieee802_1x_tx_key_one(hapd
, sta
, hapd
->default_wep_key_idx
, 1,
450 hapd
->default_wep_key
,
451 hapd
->conf
->default_wep_key_len
);
454 if (hapd
->conf
->individual_wep_key_len
> 0) {
456 ikey
= malloc(hapd
->conf
->individual_wep_key_len
);
458 hostapd_get_rand(ikey
,
459 hapd
->conf
->individual_wep_key_len
)) {
460 printf("Could not generate random individual WEP "
466 wpa_hexdump_key(MSG_DEBUG
, "Individual WEP key",
467 ikey
, hapd
->conf
->individual_wep_key_len
);
469 ieee802_1x_tx_key_one(hapd
, sta
, 0, 0, ikey
,
470 hapd
->conf
->individual_wep_key_len
);
472 /* TODO: set encryption in TX callback, i.e., only after STA
473 * has ACKed EAPOL-Key frame */
474 if (hostapd_set_encryption(hapd
->conf
->iface
, hapd
, "WEP",
476 hapd
->conf
->individual_wep_key_len
,
478 printf("Could not set individual WEP encryption.\n");
486 const char *radius_mode_txt(struct hostapd_data
*hapd
)
488 if (hapd
->iface
->current_mode
== NULL
)
491 switch (hapd
->iface
->current_mode
->mode
) {
492 case HOSTAPD_MODE_IEEE80211A
:
494 case HOSTAPD_MODE_IEEE80211G
:
496 case HOSTAPD_MODE_IEEE80211B
:
503 int radius_sta_rate(struct hostapd_data
*hapd
, struct sta_info
*sta
)
508 for (i
= 0; i
< sta
->supported_rates_len
; i
++)
509 if ((sta
->supported_rates
[i
] & 0x7f) > rate
)
510 rate
= sta
->supported_rates
[i
] & 0x7f;
516 static void ieee802_1x_encapsulate_radius(struct hostapd_data
*hapd
,
517 struct sta_info
*sta
,
520 struct radius_msg
*msg
;
522 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
527 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
528 "Encapsulating EAP message into a RADIUS packet\n");
530 sm
->radius_identifier
= radius_client_get_id(hapd
->radius
);
531 msg
= radius_msg_new(RADIUS_CODE_ACCESS_REQUEST
,
532 sm
->radius_identifier
);
534 printf("Could not create net RADIUS packet\n");
538 radius_msg_make_authenticator(msg
, (u8
*) sta
, sizeof(*sta
));
541 !radius_msg_add_attr(msg
, RADIUS_ATTR_USER_NAME
,
542 sm
->identity
, sm
->identity_len
)) {
543 printf("Could not add User-Name\n");
547 if (hapd
->conf
->own_ip_addr
.af
== AF_INET
&&
548 !radius_msg_add_attr(msg
, RADIUS_ATTR_NAS_IP_ADDRESS
,
549 (u8
*) &hapd
->conf
->own_ip_addr
.u
.v4
, 4)) {
550 printf("Could not add NAS-IP-Address\n");
555 if (hapd
->conf
->own_ip_addr
.af
== AF_INET6
&&
556 !radius_msg_add_attr(msg
, RADIUS_ATTR_NAS_IPV6_ADDRESS
,
557 (u8
*) &hapd
->conf
->own_ip_addr
.u
.v6
, 16)) {
558 printf("Could not add NAS-IPv6-Address\n");
561 #endif /* CONFIG_IPV6 */
563 if (hapd
->conf
->nas_identifier
&&
564 !radius_msg_add_attr(msg
, RADIUS_ATTR_NAS_IDENTIFIER
,
565 (u8
*) hapd
->conf
->nas_identifier
,
566 strlen(hapd
->conf
->nas_identifier
))) {
567 printf("Could not add NAS-Identifier\n");
571 if (!radius_msg_add_attr_int32(msg
, RADIUS_ATTR_NAS_PORT
, sta
->aid
)) {
572 printf("Could not add NAS-Port\n");
576 snprintf(buf
, sizeof(buf
), RADIUS_802_1X_ADDR_FORMAT
":%s",
577 MAC2STR(hapd
->own_addr
), hapd
->conf
->ssid
.ssid
);
578 buf
[sizeof(buf
) - 1] = '\0';
579 if (!radius_msg_add_attr(msg
, RADIUS_ATTR_CALLED_STATION_ID
,
580 (u8
*) buf
, strlen(buf
))) {
581 printf("Could not add Called-Station-Id\n");
585 snprintf(buf
, sizeof(buf
), RADIUS_802_1X_ADDR_FORMAT
,
587 buf
[sizeof(buf
) - 1] = '\0';
588 if (!radius_msg_add_attr(msg
, RADIUS_ATTR_CALLING_STATION_ID
,
589 (u8
*) buf
, strlen(buf
))) {
590 printf("Could not add Calling-Station-Id\n");
594 /* TODO: should probably check MTU from driver config; 2304 is max for
595 * IEEE 802.11, but use 1400 to avoid problems with too large packets
597 if (!radius_msg_add_attr_int32(msg
, RADIUS_ATTR_FRAMED_MTU
, 1400)) {
598 printf("Could not add Framed-MTU\n");
602 if (!radius_msg_add_attr_int32(msg
, RADIUS_ATTR_NAS_PORT_TYPE
,
603 RADIUS_NAS_PORT_TYPE_IEEE_802_11
)) {
604 printf("Could not add NAS-Port-Type\n");
608 if (sta
->flags
& WLAN_STA_PREAUTH
) {
609 snprintf(buf
, sizeof(buf
), "IEEE 802.11i Pre-Authentication");
611 snprintf(buf
, sizeof(buf
), "CONNECT %d%sMbps %s",
612 radius_sta_rate(hapd
, sta
) / 2,
613 (radius_sta_rate(hapd
, sta
) & 1) ? ".5" : "",
614 radius_mode_txt(hapd
));
616 buf
[sizeof(buf
) - 1] = '\0';
617 if (!radius_msg_add_attr(msg
, RADIUS_ATTR_CONNECT_INFO
,
618 (u8
*) buf
, strlen(buf
))) {
619 printf("Could not add Connect-Info\n");
623 if (eap
&& !radius_msg_add_eap(msg
, eap
, len
)) {
624 printf("Could not add EAP-Message\n");
628 /* State attribute must be copied if and only if this packet is
629 * Access-Request reply to the previous Access-Challenge */
630 if (sm
->last_recv_radius
&& sm
->last_recv_radius
->hdr
->code
==
631 RADIUS_CODE_ACCESS_CHALLENGE
) {
632 int res
= radius_msg_copy_attr(msg
, sm
->last_recv_radius
,
635 printf("Could not copy State attribute from previous "
636 "Access-Challenge\n");
640 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
641 " Copied RADIUS State Attribute\n");
645 radius_client_send(hapd
->radius
, msg
, RADIUS_AUTH
, sta
->addr
);
649 radius_msg_free(msg
);
654 char *eap_type_text(u8 type
)
657 case EAP_TYPE_IDENTITY
: return "Identity";
658 case EAP_TYPE_NOTIFICATION
: return "Notification";
659 case EAP_TYPE_NAK
: return "Nak";
660 case EAP_TYPE_MD5
: return "MD5-Challenge";
661 case EAP_TYPE_OTP
: return "One-Time Password";
662 case EAP_TYPE_GTC
: return "Generic Token Card";
663 case EAP_TYPE_TLS
: return "TLS";
664 case EAP_TYPE_TTLS
: return "TTLS";
665 case EAP_TYPE_PEAP
: return "PEAP";
666 case EAP_TYPE_SIM
: return "SIM";
667 case EAP_TYPE_FAST
: return "FAST";
668 case EAP_TYPE_SAKE
: return "SAKE";
669 case EAP_TYPE_PSK
: return "PSK";
670 default: return "Unknown";
675 static void handle_eap_response(struct hostapd_data
*hapd
,
676 struct sta_info
*sta
, struct eap_hdr
*eap
,
677 u8
*data
, size_t len
)
680 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
684 if (eap
->identifier
!= sm
->currentId
) {
685 hostapd_logger(hapd
, sm
->addr
, HOSTAPD_MODULE_IEEE8021X
,
687 "EAP Identifier of the Response-Identity does "
688 "not match (was %d, expected %d) - ignored",
689 eap
->identifier
, sm
->currentId
);
694 printf("handle_eap_response: too short response data\n");
698 eloop_cancel_timeout(ieee802_1x_eap_timeout
, sta
, NULL
);
700 free(sm
->last_eap_supp
);
701 sm
->last_eap_supp_len
= sizeof(*eap
) + len
;
702 sm
->last_eap_supp
= (u8
*) malloc(sm
->last_eap_supp_len
);
703 if (sm
->last_eap_supp
== NULL
) {
704 printf("Could not alloc memory for last EAP Response\n");
707 memcpy(sm
->last_eap_supp
, eap
, sizeof(*eap
));
708 memcpy(sm
->last_eap_supp
+ sizeof(*eap
), data
, len
);
710 sm
->eap_type_supp
= type
= data
[0];
714 hostapd_logger(hapd
, sm
->addr
, HOSTAPD_MODULE_IEEE8021X
,
715 HOSTAPD_LEVEL_DEBUG
, "received EAP packet (code=%d "
716 "id=%d len=%d) from STA: EAP Response-%s (%d)",
717 eap
->code
, eap
->identifier
, ntohs(eap
->length
),
718 eap_type_text(type
), type
);
720 if (type
== EAP_TYPE_IDENTITY
) {
723 buf
= malloc(4 * len
+ 1);
726 for (i
= 0; i
< len
; i
++) {
727 if (data
[i
] >= 32 && data
[i
] < 127)
730 snprintf(pos
, 5, "{%02x}", data
[i
]);
735 hostapd_logger(hapd
, sm
->addr
,
736 HOSTAPD_MODULE_IEEE8021X
,
738 "STA identity '%s'", buf
);
742 sm
->rx_identity
= TRUE
;
743 sm
->dot1xAuthEapolRespIdFramesRx
++;
745 /* Save station identity for future RADIUS packets */
747 sm
->identity
= malloc(len
+ 1);
749 memcpy(sm
->identity
, data
, len
);
750 sm
->identity
[len
] = '\0';
751 sm
->identity_len
= len
;
754 sm
->dot1xAuthEapolRespFramesRx
++;
760 /* Process incoming EAP packet from Supplicant */
761 static void handle_eap(struct hostapd_data
*hapd
, struct sta_info
*sta
,
767 if (len
< sizeof(*eap
)) {
768 printf(" too short EAP packet\n");
772 eap
= (struct eap_hdr
*) buf
;
774 eap_len
= ntohs(eap
->length
);
775 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
776 " EAP: code=%d identifier=%d length=%d",
777 eap
->code
, eap
->identifier
, eap_len
);
778 if (eap_len
< sizeof(*eap
)) {
779 printf(" Invalid EAP length\n");
781 } else if (eap_len
> len
) {
782 printf(" Too short frame to contain this EAP packet\n");
784 } else if (eap_len
< len
) {
785 printf(" Ignoring %lu extra bytes after EAP packet\n",
786 (unsigned long) len
- eap_len
);
789 eap_len
-= sizeof(*eap
);
792 case EAP_CODE_REQUEST
:
793 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, " (request)\n");
795 case EAP_CODE_RESPONSE
:
796 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, " (response)\n");
797 handle_eap_response(hapd
, sta
, eap
, (u8
*) (eap
+ 1), eap_len
);
799 case EAP_CODE_SUCCESS
:
800 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, " (success)\n");
802 case EAP_CODE_FAILURE
:
803 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, " (failure)\n");
806 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, " (unknown code)\n");
812 /* Process the EAPOL frames from the Supplicant */
813 void ieee802_1x_receive(struct hostapd_data
*hapd
, const u8
*sa
, const u8
*buf
,
816 struct sta_info
*sta
;
817 struct ieee802_1x_hdr
*hdr
;
818 struct ieee802_1x_eapol_key
*key
;
820 struct rsn_pmksa_cache_entry
*pmksa
;
822 if (!hapd
->conf
->ieee802_1x
&& !hapd
->conf
->wpa
)
825 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
826 "IEEE 802.1X: %lu bytes from " MACSTR
"\n",
827 (unsigned long) len
, MAC2STR(sa
));
828 sta
= ap_get_sta(hapd
, sa
);
830 printf(" no station information available\n");
834 if (len
< sizeof(*hdr
)) {
835 printf(" too short IEEE 802.1X packet\n");
839 hdr
= (struct ieee802_1x_hdr
*) buf
;
840 datalen
= ntohs(hdr
->length
);
841 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
842 " IEEE 802.1X: version=%d type=%d length=%d\n",
843 hdr
->version
, hdr
->type
, datalen
);
845 if (len
- sizeof(*hdr
) < datalen
) {
846 printf(" frame too short for this IEEE 802.1X packet\n");
848 sta
->eapol_sm
->dot1xAuthEapLengthErrorFramesRx
++;
851 if (len
- sizeof(*hdr
) > datalen
) {
852 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
853 " ignoring %lu extra octets after IEEE 802.1X "
855 (unsigned long) len
- sizeof(*hdr
) - datalen
);
859 sta
->eapol_sm
->dot1xAuthLastEapolFrameVersion
= hdr
->version
;
860 sta
->eapol_sm
->dot1xAuthEapolFramesRx
++;
863 key
= (struct ieee802_1x_eapol_key
*) (hdr
+ 1);
864 if (datalen
>= sizeof(struct ieee802_1x_eapol_key
) &&
865 hdr
->type
== IEEE802_1X_TYPE_EAPOL_KEY
&&
866 (key
->type
== EAPOL_KEY_TYPE_WPA
||
867 key
->type
== EAPOL_KEY_TYPE_RSN
)) {
868 wpa_receive(hapd
->wpa_auth
, sta
->wpa_sm
, (u8
*) hdr
,
869 sizeof(*hdr
) + datalen
);
873 if (!hapd
->conf
->ieee802_1x
||
874 wpa_auth_sta_key_mgmt(sta
->wpa_sm
) == WPA_KEY_MGMT_PSK
)
877 if (!sta
->eapol_sm
) {
878 sta
->eapol_sm
= eapol_sm_alloc(hapd
, sta
);
883 /* since we support version 1, we can ignore version field and proceed
884 * as specified in version 1 standard [IEEE Std 802.1X-2001, 7.5.5] */
885 /* TODO: actually, we are not version 1 anymore.. However, Version 2
886 * does not change frame contents, so should be ok to process frames
887 * more or less identically. Some changes might be needed for
888 * verification of fields. */
891 case IEEE802_1X_TYPE_EAP_PACKET
:
892 handle_eap(hapd
, sta
, (u8
*) (hdr
+ 1), datalen
);
895 case IEEE802_1X_TYPE_EAPOL_START
:
896 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
897 HOSTAPD_LEVEL_DEBUG
, "received EAPOL-Start "
899 pmksa
= wpa_auth_sta_get_pmksa(sta
->wpa_sm
);
901 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_WPA
,
902 HOSTAPD_LEVEL_DEBUG
, "cached PMKSA "
903 "available - ignore it since "
904 "STA sent EAPOL-Start");
905 wpa_auth_sta_clear_pmksa(sta
->wpa_sm
, pmksa
);
907 sta
->eapol_sm
->eapolStart
= TRUE
;
908 sta
->eapol_sm
->dot1xAuthEapolStartFramesRx
++;
909 wpa_auth_sm_event(sta
->wpa_sm
, WPA_REAUTH_EAPOL
);
912 case IEEE802_1X_TYPE_EAPOL_LOGOFF
:
913 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
914 HOSTAPD_LEVEL_DEBUG
, "received EAPOL-Logoff "
916 sta
->acct_terminate_cause
=
917 RADIUS_ACCT_TERMINATE_CAUSE_USER_REQUEST
;
918 sta
->eapol_sm
->eapolLogoff
= TRUE
;
919 sta
->eapol_sm
->dot1xAuthEapolLogoffFramesRx
++;
922 case IEEE802_1X_TYPE_EAPOL_KEY
:
923 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, " EAPOL-Key\n");
924 if (!(sta
->flags
& WLAN_STA_AUTHORIZED
)) {
925 printf(" Dropped key data from unauthorized "
931 case IEEE802_1X_TYPE_EAPOL_ENCAPSULATED_ASF_ALERT
:
932 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
933 " EAPOL-Encapsulated-ASF-Alert\n");
934 /* TODO: implement support for this; show data */
938 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
939 " unknown IEEE 802.1X packet type\n");
940 sta
->eapol_sm
->dot1xAuthInvalidEapolFramesRx
++;
944 eapol_sm_step(sta
->eapol_sm
);
948 void ieee802_1x_new_station(struct hostapd_data
*hapd
, struct sta_info
*sta
)
950 struct rsn_pmksa_cache_entry
*pmksa
;
953 if (!hapd
->conf
->ieee802_1x
||
954 wpa_auth_sta_key_mgmt(sta
->wpa_sm
) == WPA_KEY_MGMT_PSK
)
957 if (sta
->eapol_sm
== NULL
) {
958 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
959 HOSTAPD_LEVEL_DEBUG
, "start authentication");
960 sta
->eapol_sm
= eapol_sm_alloc(hapd
, sta
);
961 if (sta
->eapol_sm
== NULL
) {
962 hostapd_logger(hapd
, sta
->addr
,
963 HOSTAPD_MODULE_IEEE8021X
,
965 "failed to allocate state machine");
971 sta
->eapol_sm
->portEnabled
= TRUE
;
973 pmksa
= wpa_auth_sta_get_pmksa(sta
->wpa_sm
);
977 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
979 "PMK from PMKSA cache - skip IEEE 802.1X/EAP");
980 /* Setup EAPOL state machines to already authenticated state
981 * because of existing PMKSA information in the cache. */
982 sta
->eapol_sm
->keyRun
= TRUE
;
983 sta
->eapol_sm
->keyAvailable
= TRUE
;
984 sta
->eapol_sm
->auth_pae_state
= AUTH_PAE_AUTHENTICATING
;
985 sta
->eapol_sm
->be_auth_state
= BE_AUTH_SUCCESS
;
986 sta
->eapol_sm
->authSuccess
= TRUE
;
987 if (sta
->eapol_sm
->eap
)
988 eap_sm_notify_cached(sta
->eapol_sm
->eap
);
989 old_vlanid
= sta
->vlan_id
;
990 pmksa_cache_to_eapol_data(pmksa
, sta
->eapol_sm
);
991 if (sta
->ssid
->dynamic_vlan
== DYNAMIC_VLAN_DISABLED
)
993 ap_sta_bind_vlan(hapd
, sta
, old_vlanid
);
997 * Force EAPOL state machines to start
998 * re-authentication without having to wait for the
999 * Supplicant to send EAPOL-Start.
1001 sta
->eapol_sm
->reAuthenticate
= TRUE
;
1003 eapol_sm_step(sta
->eapol_sm
);
1008 void ieee802_1x_free_radius_class(struct radius_class_data
*class)
1013 for (i
= 0; i
< class->count
; i
++)
1014 free(class->attr
[i
].data
);
1021 int ieee802_1x_copy_radius_class(struct radius_class_data
*dst
,
1022 struct radius_class_data
*src
)
1026 if (src
->attr
== NULL
)
1029 dst
->attr
= wpa_zalloc(src
->count
* sizeof(struct radius_attr_data
));
1030 if (dst
->attr
== NULL
)
1035 for (i
= 0; i
< src
->count
; i
++) {
1036 dst
->attr
[i
].data
= malloc(src
->attr
[i
].len
);
1037 if (dst
->attr
[i
].data
== NULL
)
1040 memcpy(dst
->attr
[i
].data
, src
->attr
[i
].data
, src
->attr
[i
].len
);
1041 dst
->attr
[i
].len
= src
->attr
[i
].len
;
1048 void ieee802_1x_free_station(struct sta_info
*sta
)
1050 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1052 eloop_cancel_timeout(ieee802_1x_eap_timeout
, sta
, NULL
);
1057 sta
->eapol_sm
= NULL
;
1059 if (sm
->last_recv_radius
) {
1060 radius_msg_free(sm
->last_recv_radius
);
1061 free(sm
->last_recv_radius
);
1064 free(sm
->last_eap_supp
);
1065 free(sm
->last_eap_radius
);
1067 ieee802_1x_free_radius_class(&sm
->radius_class
);
1068 free(sm
->eapol_key_sign
);
1069 free(sm
->eapol_key_crypt
);
1074 static void ieee802_1x_decapsulate_radius(struct hostapd_data
*hapd
,
1075 struct sta_info
*sta
)
1079 struct eap_hdr
*hdr
;
1082 struct radius_msg
*msg
;
1083 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1085 if (sm
== NULL
|| sm
->last_recv_radius
== NULL
) {
1087 sm
->eapNoReq
= TRUE
;
1091 msg
= sm
->last_recv_radius
;
1093 eap
= radius_msg_get_eap(msg
, &len
);
1095 /* draft-aboba-radius-rfc2869bis-20.txt, Chap. 2.6.3:
1096 * RADIUS server SHOULD NOT send Access-Reject/no EAP-Message
1098 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
1099 HOSTAPD_LEVEL_WARNING
, "could not extract "
1100 "EAP-Message from RADIUS message");
1101 free(sm
->last_eap_radius
);
1102 sm
->last_eap_radius
= NULL
;
1103 sm
->last_eap_radius_len
= 0;
1104 sm
->eapNoReq
= TRUE
;
1108 if (len
< sizeof(*hdr
)) {
1109 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
1110 HOSTAPD_LEVEL_WARNING
, "too short EAP packet "
1111 "received from authentication server");
1113 sm
->eapNoReq
= TRUE
;
1117 if (len
> sizeof(*hdr
))
1118 eap_type
= eap
[sizeof(*hdr
)];
1120 hdr
= (struct eap_hdr
*) eap
;
1121 switch (hdr
->code
) {
1122 case EAP_CODE_REQUEST
:
1124 sm
->eap_type_authsrv
= eap_type
;
1125 snprintf(buf
, sizeof(buf
), "EAP-Request-%s (%d)",
1126 eap_type
>= 0 ? eap_type_text(eap_type
) : "??",
1129 case EAP_CODE_RESPONSE
:
1130 snprintf(buf
, sizeof(buf
), "EAP Response-%s (%d)",
1131 eap_type
>= 0 ? eap_type_text(eap_type
) : "??",
1134 case EAP_CODE_SUCCESS
:
1135 snprintf(buf
, sizeof(buf
), "EAP Success");
1137 case EAP_CODE_FAILURE
:
1138 snprintf(buf
, sizeof(buf
), "EAP Failure");
1141 snprintf(buf
, sizeof(buf
), "unknown EAP code");
1144 buf
[sizeof(buf
) - 1] = '\0';
1145 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
1146 HOSTAPD_LEVEL_DEBUG
, "decapsulated EAP packet (code=%d "
1147 "id=%d len=%d) from RADIUS server: %s",
1148 hdr
->code
, hdr
->identifier
, ntohs(hdr
->length
), buf
);
1151 free(sm
->last_eap_radius
);
1152 sm
->last_eap_radius
= eap
;
1153 sm
->last_eap_radius_len
= len
;
1157 static void ieee802_1x_get_keys(struct hostapd_data
*hapd
,
1158 struct sta_info
*sta
, struct radius_msg
*msg
,
1159 struct radius_msg
*req
,
1160 u8
*shared_secret
, size_t shared_secret_len
)
1162 struct radius_ms_mppe_keys
*keys
;
1163 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1167 keys
= radius_msg_get_ms_keys(msg
, req
, shared_secret
,
1172 wpa_hexdump_key(MSG_DEBUG
, "MS-MPPE-Send-Key",
1173 keys
->send
, keys
->send_len
);
1176 wpa_hexdump_key(MSG_DEBUG
, "MS-MPPE-Recv-Key",
1177 keys
->recv
, keys
->recv_len
);
1180 if (keys
->send
&& keys
->recv
) {
1181 free(sm
->eapol_key_sign
);
1182 free(sm
->eapol_key_crypt
);
1183 sm
->eapol_key_sign
= keys
->send
;
1184 sm
->eapol_key_sign_len
= keys
->send_len
;
1185 sm
->eapol_key_crypt
= keys
->recv
;
1186 sm
->eapol_key_crypt_len
= keys
->recv_len
;
1187 if (hapd
->default_wep_key
||
1188 hapd
->conf
->individual_wep_key_len
> 0 ||
1190 sta
->eapol_sm
->keyAvailable
= TRUE
;
1200 static void ieee802_1x_store_radius_class(struct hostapd_data
*hapd
,
1201 struct sta_info
*sta
,
1202 struct radius_msg
*msg
)
1206 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1208 struct radius_attr_data
*nclass
;
1209 size_t nclass_count
;
1211 if (!hapd
->conf
->radius
->acct_server
|| hapd
->radius
== NULL
||
1215 ieee802_1x_free_radius_class(&sm
->radius_class
);
1216 count
= radius_msg_count_attr(msg
, RADIUS_ATTR_CLASS
, 1);
1220 nclass
= wpa_zalloc(count
* sizeof(struct radius_attr_data
));
1227 for (i
= 0; i
< count
; i
++) {
1229 if (radius_msg_get_attr_ptr(msg
, RADIUS_ATTR_CLASS
,
1235 } while (class_len
< 1);
1237 nclass
[nclass_count
].data
= malloc(class_len
);
1238 if (nclass
[nclass_count
].data
== NULL
)
1241 memcpy(nclass
[nclass_count
].data
, class, class_len
);
1242 nclass
[nclass_count
].len
= class_len
;
1246 sm
->radius_class
.attr
= nclass
;
1247 sm
->radius_class
.count
= nclass_count
;
1248 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, "IEEE 802.1X: Stored %lu RADIUS "
1249 "Class attributes for " MACSTR
"\n",
1250 (unsigned long) sm
->radius_class
.count
,
1251 MAC2STR(sta
->addr
));
1255 /* Update sta->identity based on User-Name attribute in Access-Accept */
1256 static void ieee802_1x_update_sta_identity(struct hostapd_data
*hapd
,
1257 struct sta_info
*sta
,
1258 struct radius_msg
*msg
)
1262 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1267 if (radius_msg_get_attr_ptr(msg
, RADIUS_ATTR_USER_NAME
, &buf
, &len
,
1271 identity
= malloc(len
+ 1);
1272 if (identity
== NULL
)
1275 memcpy(identity
, buf
, len
);
1276 identity
[len
] = '\0';
1278 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
1279 HOSTAPD_LEVEL_DEBUG
, "old identity '%s' updated with "
1280 "User-Name from Access-Accept '%s'",
1281 sm
->identity
? (char *) sm
->identity
: "N/A",
1285 sm
->identity
= identity
;
1286 sm
->identity_len
= len
;
1290 struct sta_id_search
{
1292 struct eapol_state_machine
*sm
;
1296 static int ieee802_1x_select_radius_identifier(struct hostapd_data
*hapd
,
1297 struct sta_info
*sta
,
1300 struct sta_id_search
*id_search
= ctx
;
1301 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1303 if (sm
&& sm
->radius_identifier
>= 0 &&
1304 sm
->radius_identifier
== id_search
->identifier
) {
1312 static struct eapol_state_machine
*
1313 ieee802_1x_search_radius_identifier(struct hostapd_data
*hapd
, u8 identifier
)
1315 struct sta_id_search id_search
;
1316 id_search
.identifier
= identifier
;
1317 id_search
.sm
= NULL
;
1318 ap_for_each_sta(hapd
, ieee802_1x_select_radius_identifier
, &id_search
);
1319 return id_search
.sm
;
1323 /* Process the RADIUS frames from Authentication Server */
1324 static RadiusRxResult
1325 ieee802_1x_receive_auth(struct radius_msg
*msg
, struct radius_msg
*req
,
1326 u8
*shared_secret
, size_t shared_secret_len
,
1329 struct hostapd_data
*hapd
= data
;
1330 struct sta_info
*sta
;
1331 u32 session_timeout
= 0, termination_action
, acct_interim_interval
;
1332 int session_timeout_set
, old_vlanid
= 0;
1334 struct eapol_state_machine
*sm
;
1335 int override_eapReq
= 0;
1337 sm
= ieee802_1x_search_radius_identifier(hapd
, msg
->hdr
->identifier
);
1339 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, "IEEE 802.1X: Could not "
1340 "find matching station for this RADIUS "
1342 return RADIUS_RX_UNKNOWN
;
1346 /* RFC 2869, Ch. 5.13: valid Message-Authenticator attribute MUST be
1347 * present when packet contains an EAP-Message attribute */
1348 if (msg
->hdr
->code
== RADIUS_CODE_ACCESS_REJECT
&&
1349 radius_msg_get_attr(msg
, RADIUS_ATTR_MESSAGE_AUTHENTICATOR
, NULL
,
1351 radius_msg_get_attr(msg
, RADIUS_ATTR_EAP_MESSAGE
, NULL
, 0) < 0) {
1352 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, "Allowing RADIUS "
1353 "Access-Reject without Message-Authenticator "
1354 "since it does not include EAP-Message\n");
1355 } else if (radius_msg_verify(msg
, shared_secret
, shared_secret_len
,
1357 printf("Incoming RADIUS packet did not have correct "
1358 "Message-Authenticator - dropped\n");
1359 return RADIUS_RX_INVALID_AUTHENTICATOR
;
1362 if (msg
->hdr
->code
!= RADIUS_CODE_ACCESS_ACCEPT
&&
1363 msg
->hdr
->code
!= RADIUS_CODE_ACCESS_REJECT
&&
1364 msg
->hdr
->code
!= RADIUS_CODE_ACCESS_CHALLENGE
) {
1365 printf("Unknown RADIUS message code\n");
1366 return RADIUS_RX_UNKNOWN
;
1369 sm
->radius_identifier
= -1;
1370 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
1371 "RADIUS packet matching with station " MACSTR
"\n",
1372 MAC2STR(sta
->addr
));
1374 if (sm
->last_recv_radius
) {
1375 radius_msg_free(sm
->last_recv_radius
);
1376 free(sm
->last_recv_radius
);
1379 sm
->last_recv_radius
= msg
;
1381 session_timeout_set
=
1382 !radius_msg_get_attr_int32(msg
, RADIUS_ATTR_SESSION_TIMEOUT
,
1384 if (radius_msg_get_attr_int32(msg
, RADIUS_ATTR_TERMINATION_ACTION
,
1385 &termination_action
))
1386 termination_action
= RADIUS_TERMINATION_ACTION_DEFAULT
;
1388 if (hapd
->conf
->radius
->acct_interim_interval
== 0 &&
1389 msg
->hdr
->code
== RADIUS_CODE_ACCESS_ACCEPT
&&
1390 radius_msg_get_attr_int32(msg
, RADIUS_ATTR_ACCT_INTERIM_INTERVAL
,
1391 &acct_interim_interval
) == 0) {
1392 if (acct_interim_interval
< 60) {
1393 hostapd_logger(hapd
, sta
->addr
,
1394 HOSTAPD_MODULE_IEEE8021X
,
1396 "ignored too small "
1397 "Acct-Interim-Interval %d",
1398 acct_interim_interval
);
1400 sta
->acct_interim_interval
= acct_interim_interval
;
1404 switch (msg
->hdr
->code
) {
1405 case RADIUS_CODE_ACCESS_ACCEPT
:
1406 if (sta
->ssid
->dynamic_vlan
== DYNAMIC_VLAN_DISABLED
)
1409 old_vlanid
= sta
->vlan_id
;
1410 sta
->vlan_id
= radius_msg_get_vlanid(msg
);
1412 if (sta
->vlan_id
> 0 &&
1413 hostapd_get_vlan_id_ifname(hapd
->conf
->vlan
,
1415 hostapd_logger(hapd
, sta
->addr
,
1416 HOSTAPD_MODULE_RADIUS
,
1418 "VLAN ID %d", sta
->vlan_id
);
1419 } else if (sta
->ssid
->dynamic_vlan
== DYNAMIC_VLAN_REQUIRED
) {
1420 sta
->eapol_sm
->authFail
= TRUE
;
1421 hostapd_logger(hapd
, sta
->addr
,
1422 HOSTAPD_MODULE_IEEE8021X
,
1423 HOSTAPD_LEVEL_INFO
, "authentication "
1424 "server did not include required VLAN "
1425 "ID in Access-Accept");
1429 ap_sta_bind_vlan(hapd
, sta
, old_vlanid
);
1431 /* RFC 3580, Ch. 3.17 */
1432 if (session_timeout_set
&& termination_action
==
1433 RADIUS_TERMINATION_ACTION_RADIUS_REQUEST
) {
1434 sm
->reAuthPeriod
= session_timeout
;
1435 } else if (session_timeout_set
)
1436 ap_sta_session_timeout(hapd
, sta
, session_timeout
);
1438 sm
->eapSuccess
= TRUE
;
1439 override_eapReq
= 1;
1440 ieee802_1x_get_keys(hapd
, sta
, msg
, req
, shared_secret
,
1442 ieee802_1x_store_radius_class(hapd
, sta
, msg
);
1443 ieee802_1x_update_sta_identity(hapd
, sta
, msg
);
1444 if (sm
->keyAvailable
&&
1445 wpa_auth_pmksa_add(sta
->wpa_sm
, sm
->eapol_key_crypt
,
1446 session_timeout_set
?
1447 (int) session_timeout
: -1, sm
) == 0) {
1448 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_WPA
,
1449 HOSTAPD_LEVEL_DEBUG
,
1450 "Added PMKSA cache entry");
1453 case RADIUS_CODE_ACCESS_REJECT
:
1455 override_eapReq
= 1;
1457 case RADIUS_CODE_ACCESS_CHALLENGE
:
1458 if (session_timeout_set
) {
1459 /* RFC 2869, Ch. 2.3.2; RFC 3580, Ch. 3.17 */
1460 eap_timeout
= session_timeout
;
1463 hostapd_logger(hapd
, sm
->addr
, HOSTAPD_MODULE_IEEE8021X
,
1464 HOSTAPD_LEVEL_DEBUG
,
1465 "using EAP timeout of %d seconds%s",
1467 session_timeout_set
? " (from RADIUS)" : "");
1468 eloop_cancel_timeout(ieee802_1x_eap_timeout
, sta
, NULL
);
1469 eloop_register_timeout(eap_timeout
, 0, ieee802_1x_eap_timeout
,
1471 sm
->eapTimeout
= FALSE
;
1475 ieee802_1x_decapsulate_radius(hapd
, sta
);
1476 if (override_eapReq
)
1481 return RADIUS_RX_QUEUED
;
1485 /* Handler for EAPOL Backend Authentication state machine sendRespToServer.
1486 * Forward the EAP Response from Supplicant to Authentication Server. */
1487 void ieee802_1x_send_resp_to_server(struct hostapd_data
*hapd
,
1488 struct sta_info
*sta
)
1490 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1494 if (hapd
->conf
->eap_server
) {
1495 eap_set_eapRespData(sm
->eap
, sm
->last_eap_supp
,
1496 sm
->last_eap_supp_len
);
1498 ieee802_1x_encapsulate_radius(hapd
, sta
, sm
->last_eap_supp
,
1499 sm
->last_eap_supp_len
);
1504 void ieee802_1x_abort_auth(struct hostapd_data
*hapd
, struct sta_info
*sta
)
1506 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1510 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
1511 HOSTAPD_LEVEL_DEBUG
, "aborting authentication");
1513 if (sm
->last_recv_radius
) {
1514 radius_msg_free(sm
->last_recv_radius
);
1515 free(sm
->last_recv_radius
);
1516 sm
->last_recv_radius
= NULL
;
1518 free(sm
->last_eap_supp
);
1519 sm
->last_eap_supp
= NULL
;
1520 sm
->last_eap_supp_len
= 0;
1521 free(sm
->last_eap_radius
);
1522 sm
->last_eap_radius
= NULL
;
1523 sm
->last_eap_radius_len
= 0;
1527 #ifdef HOSTAPD_DUMP_STATE
1528 static void fprint_char(FILE *f
, char c
)
1530 if (c
>= 32 && c
< 127)
1531 fprintf(f
, "%c", c
);
1533 fprintf(f
, "<%02x>", c
);
1537 void ieee802_1x_dump_state(FILE *f
, const char *prefix
, struct sta_info
*sta
)
1539 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1543 fprintf(f
, "%sIEEE 802.1X:\n", prefix
);
1547 fprintf(f
, "%sidentity=", prefix
);
1548 for (i
= 0; i
< sm
->identity_len
; i
++)
1549 fprint_char(f
, sm
->identity
[i
]);
1553 fprintf(f
, "%slast EAP type: Authentication Server: %d (%s) "
1554 "Supplicant: %d (%s)\n", prefix
,
1555 sm
->eap_type_authsrv
, eap_type_text(sm
->eap_type_authsrv
),
1556 sm
->eap_type_supp
, eap_type_text(sm
->eap_type_supp
));
1558 fprintf(f
, "%scached_packets=%s%s%s\n", prefix
,
1559 sm
->last_recv_radius
? "[RX RADIUS]" : "",
1560 sm
->last_eap_radius
? "[EAP RADIUS]" : "",
1561 sm
->last_eap_supp
? "[EAP SUPPLICANT]" : "");
1563 eapol_sm_dump_state(f
, prefix
, sm
);
1565 #endif /* HOSTAPD_DUMP_STATE */
1568 static int ieee802_1x_rekey_broadcast(struct hostapd_data
*hapd
)
1570 if (hapd
->conf
->default_wep_key_len
< 1)
1573 free(hapd
->default_wep_key
);
1574 hapd
->default_wep_key
= malloc(hapd
->conf
->default_wep_key_len
);
1575 if (hapd
->default_wep_key
== NULL
||
1576 hostapd_get_rand(hapd
->default_wep_key
,
1577 hapd
->conf
->default_wep_key_len
)) {
1578 printf("Could not generate random WEP key.\n");
1579 free(hapd
->default_wep_key
);
1580 hapd
->default_wep_key
= NULL
;
1584 wpa_hexdump_key(MSG_DEBUG
, "IEEE 802.1X: New default WEP key",
1585 hapd
->default_wep_key
,
1586 hapd
->conf
->default_wep_key_len
);
1592 static int ieee802_1x_sta_key_available(struct hostapd_data
*hapd
,
1593 struct sta_info
*sta
, void *ctx
)
1595 if (sta
->eapol_sm
) {
1596 sta
->eapol_sm
->keyAvailable
= TRUE
;
1597 eapol_sm_step(sta
->eapol_sm
);
1603 static void ieee802_1x_rekey(void *eloop_ctx
, void *timeout_ctx
)
1605 struct hostapd_data
*hapd
= eloop_ctx
;
1607 if (hapd
->default_wep_key_idx
>= 3)
1608 hapd
->default_wep_key_idx
=
1609 hapd
->conf
->individual_wep_key_len
> 0 ? 1 : 0;
1611 hapd
->default_wep_key_idx
++;
1613 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, "IEEE 802.1X: New default WEP "
1614 "key index %d\n", hapd
->default_wep_key_idx
);
1616 if (ieee802_1x_rekey_broadcast(hapd
)) {
1617 hostapd_logger(hapd
, NULL
, HOSTAPD_MODULE_IEEE8021X
,
1618 HOSTAPD_LEVEL_WARNING
, "failed to generate a "
1619 "new broadcast key");
1620 free(hapd
->default_wep_key
);
1621 hapd
->default_wep_key
= NULL
;
1625 /* TODO: Could setup key for RX here, but change default TX keyid only
1626 * after new broadcast key has been sent to all stations. */
1627 if (hostapd_set_encryption(hapd
->conf
->iface
, hapd
, "WEP", NULL
,
1628 hapd
->default_wep_key_idx
,
1629 hapd
->default_wep_key
,
1630 hapd
->conf
->default_wep_key_len
, 1)) {
1631 hostapd_logger(hapd
, NULL
, HOSTAPD_MODULE_IEEE8021X
,
1632 HOSTAPD_LEVEL_WARNING
, "failed to configure a "
1633 "new broadcast key");
1634 free(hapd
->default_wep_key
);
1635 hapd
->default_wep_key
= NULL
;
1639 ap_for_each_sta(hapd
, ieee802_1x_sta_key_available
, NULL
);
1641 if (hapd
->conf
->wep_rekeying_period
> 0) {
1642 eloop_register_timeout(hapd
->conf
->wep_rekeying_period
, 0,
1643 ieee802_1x_rekey
, hapd
, NULL
);
1648 int ieee802_1x_init(struct hostapd_data
*hapd
)
1652 if ((hapd
->conf
->ieee802_1x
|| hapd
->conf
->wpa
) &&
1653 hostapd_set_ieee8021x(hapd
->conf
->iface
, hapd
, 1))
1656 if (radius_client_register(hapd
->radius
, RADIUS_AUTH
,
1657 ieee802_1x_receive_auth
, hapd
))
1660 if (hapd
->conf
->default_wep_key_len
) {
1661 hostapd_set_privacy(hapd
, 1);
1663 for (i
= 0; i
< 4; i
++)
1664 hostapd_set_encryption(hapd
->conf
->iface
, hapd
,
1665 "none", NULL
, i
, NULL
, 0, 0);
1667 ieee802_1x_rekey(hapd
, NULL
);
1669 if (hapd
->default_wep_key
== NULL
)
1677 void ieee802_1x_deinit(struct hostapd_data
*hapd
)
1679 if (hapd
->driver
!= NULL
&&
1680 (hapd
->conf
->ieee802_1x
|| hapd
->conf
->wpa
))
1681 hostapd_set_ieee8021x(hapd
->conf
->iface
, hapd
, 0);
1685 int ieee802_1x_reconfig(struct hostapd_data
*hapd
,
1686 struct hostapd_config
*oldconf
,
1687 struct hostapd_bss_config
*oldbss
)
1689 ieee802_1x_deinit(hapd
);
1690 return ieee802_1x_init(hapd
);
1694 static void ieee802_1x_new_auth_session(struct hostapd_data
*hapd
,
1695 struct sta_info
*sta
)
1697 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1701 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
,
1702 "IEEE 802.1X: station " MACSTR
" - new auth session, "
1703 "clearing State\n", MAC2STR(sta
->addr
));
1705 if (sm
->last_recv_radius
) {
1706 radius_msg_free(sm
->last_recv_radius
);
1707 free(sm
->last_recv_radius
);
1708 sm
->last_recv_radius
= NULL
;
1711 sm
->eapSuccess
= FALSE
;
1712 sm
->eapFail
= FALSE
;
1716 int ieee802_1x_tx_status(struct hostapd_data
*hapd
, struct sta_info
*sta
,
1717 u8
*buf
, size_t len
, int ack
)
1719 struct ieee80211_hdr
*hdr
;
1720 struct ieee802_1x_hdr
*xhdr
;
1721 struct ieee802_1x_eapol_key
*key
;
1726 if (len
< sizeof(*hdr
) + sizeof(rfc1042_header
) + 2 + sizeof(*xhdr
))
1729 hdr
= (struct ieee80211_hdr
*) buf
;
1730 pos
= (u8
*) (hdr
+ 1);
1731 if (memcmp(pos
, rfc1042_header
, sizeof(rfc1042_header
)) != 0)
1733 pos
+= sizeof(rfc1042_header
);
1734 if (((pos
[0] << 8) | pos
[1]) != ETH_P_PAE
)
1738 xhdr
= (struct ieee802_1x_hdr
*) pos
;
1739 pos
+= sizeof(*xhdr
);
1741 HOSTAPD_DEBUG(HOSTAPD_DEBUG_MINIMAL
, "IEEE 802.1X: " MACSTR
1742 " TX status - version=%d type=%d length=%d - ack=%d\n",
1743 MAC2STR(sta
->addr
), xhdr
->version
, xhdr
->type
,
1744 ntohs(xhdr
->length
), ack
);
1746 /* EAPOL EAP-Packet packets are eventually re-sent by either Supplicant
1747 * or Authenticator state machines, but EAPOL-Key packets are not
1748 * retransmitted in case of failure. Try to re-sent failed EAPOL-Key
1749 * packets couple of times because otherwise STA keys become
1750 * unsynchronized with AP. */
1751 if (xhdr
->type
== IEEE802_1X_TYPE_EAPOL_KEY
&& !ack
&&
1752 pos
+ sizeof(*key
) <= buf
+ len
) {
1753 key
= (struct ieee802_1x_eapol_key
*) pos
;
1754 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_IEEE8021X
,
1755 HOSTAPD_LEVEL_DEBUG
, "did not Ack EAPOL-Key "
1756 "frame (%scast index=%d)",
1757 key
->key_index
& BIT(7) ? "uni" : "broad",
1758 key
->key_index
& ~BIT(7));
1759 /* TODO: re-send EAPOL-Key couple of times (with short delay
1760 * between them?). If all attempt fail, report error and
1761 * deauthenticate STA so that it will get new keys when
1762 * authenticating again (e.g., after returning in range).
1763 * Separate limit/transmit state needed both for unicast and
1764 * broadcast keys(?) */
1766 /* TODO: could move unicast key configuration from ieee802_1x_tx_key()
1767 * to here and change the key only if the EAPOL-Key packet was Acked.
1774 u8
* ieee802_1x_get_identity(struct eapol_state_machine
*sm
, size_t *len
)
1776 if (sm
== NULL
|| sm
->identity
== NULL
)
1779 *len
= sm
->identity_len
;
1780 return sm
->identity
;
1784 u8
* ieee802_1x_get_radius_class(struct eapol_state_machine
*sm
, size_t *len
,
1787 if (sm
== NULL
|| sm
->radius_class
.attr
== NULL
||
1788 idx
>= (int) sm
->radius_class
.count
)
1791 *len
= sm
->radius_class
.attr
[idx
].len
;
1792 return sm
->radius_class
.attr
[idx
].data
;
1796 u8
* ieee802_1x_get_key_crypt(struct eapol_state_machine
*sm
, size_t *len
)
1801 *len
= sm
->eapol_key_crypt_len
;
1802 return sm
->eapol_key_crypt
;
1806 void ieee802_1x_notify_port_enabled(struct eapol_state_machine
*sm
,
1811 sm
->portEnabled
= enabled
? TRUE
: FALSE
;
1816 void ieee802_1x_notify_port_valid(struct eapol_state_machine
*sm
,
1821 sm
->portValid
= valid
? TRUE
: FALSE
;
1826 void ieee802_1x_notify_pre_auth(struct eapol_state_machine
*sm
, int pre_auth
)
1831 sm
->flags
|= EAPOL_SM_PREAUTH
;
1833 sm
->flags
&= ~EAPOL_SM_PREAUTH
;
1837 static const char * bool_txt(Boolean
bool)
1839 return bool ? "TRUE" : "FALSE";
1843 int ieee802_1x_get_mib(struct hostapd_data
*hapd
, char *buf
, size_t buflen
)
1850 int ieee802_1x_get_mib_sta(struct hostapd_data
*hapd
, struct sta_info
*sta
,
1851 char *buf
, size_t buflen
)
1854 struct eapol_state_machine
*sm
= sta
->eapol_sm
;
1859 ret
= snprintf(buf
+ len
, buflen
- len
,
1860 "dot1xPaePortNumber=%d\n"
1861 "dot1xPaePortProtocolVersion=%d\n"
1862 "dot1xPaePortCapabilities=1\n"
1863 "dot1xPaePortInitialize=%d\n"
1864 "dot1xPaePortReauthenticate=FALSE\n",
1868 if (ret
< 0 || (size_t) ret
>= buflen
- len
)
1872 /* dot1xAuthConfigTable */
1873 ret
= snprintf(buf
+ len
, buflen
- len
,
1874 "dot1xAuthPaeState=%d\n"
1875 "dot1xAuthBackendAuthState=%d\n"
1876 "dot1xAuthAdminControlledDirections=%d\n"
1877 "dot1xAuthOperControlledDirections=%d\n"
1878 "dot1xAuthAuthControlledPortStatus=%d\n"
1879 "dot1xAuthAuthControlledPortControl=%d\n"
1880 "dot1xAuthQuietPeriod=%u\n"
1881 "dot1xAuthServerTimeout=%u\n"
1882 "dot1xAuthReAuthPeriod=%u\n"
1883 "dot1xAuthReAuthEnabled=%s\n"
1884 "dot1xAuthKeyTxEnabled=%s\n",
1885 sm
->auth_pae_state
+ 1,
1886 sm
->be_auth_state
+ 1,
1887 sm
->adminControlledDirections
,
1888 sm
->operControlledDirections
,
1894 bool_txt(sm
->reAuthEnabled
),
1895 bool_txt(sm
->keyTxEnabled
));
1896 if (ret
< 0 || (size_t) ret
>= buflen
- len
)
1900 /* dot1xAuthStatsTable */
1901 ret
= snprintf(buf
+ len
, buflen
- len
,
1902 "dot1xAuthEapolFramesRx=%u\n"
1903 "dot1xAuthEapolFramesTx=%u\n"
1904 "dot1xAuthEapolStartFramesRx=%u\n"
1905 "dot1xAuthEapolLogoffFramesRx=%u\n"
1906 "dot1xAuthEapolRespIdFramesRx=%u\n"
1907 "dot1xAuthEapolRespFramesRx=%u\n"
1908 "dot1xAuthEapolReqIdFramesTx=%u\n"
1909 "dot1xAuthEapolReqFramesTx=%u\n"
1910 "dot1xAuthInvalidEapolFramesRx=%u\n"
1911 "dot1xAuthEapLengthErrorFramesRx=%u\n"
1912 "dot1xAuthLastEapolFrameVersion=%u\n"
1913 "dot1xAuthLastEapolFrameSource=" MACSTR
"\n",
1914 sm
->dot1xAuthEapolFramesRx
,
1915 sm
->dot1xAuthEapolFramesTx
,
1916 sm
->dot1xAuthEapolStartFramesRx
,
1917 sm
->dot1xAuthEapolLogoffFramesRx
,
1918 sm
->dot1xAuthEapolRespIdFramesRx
,
1919 sm
->dot1xAuthEapolRespFramesRx
,
1920 sm
->dot1xAuthEapolReqIdFramesTx
,
1921 sm
->dot1xAuthEapolReqFramesTx
,
1922 sm
->dot1xAuthInvalidEapolFramesRx
,
1923 sm
->dot1xAuthEapLengthErrorFramesRx
,
1924 sm
->dot1xAuthLastEapolFrameVersion
,
1926 if (ret
< 0 || (size_t) ret
>= buflen
- len
)
1930 /* dot1xAuthDiagTable */
1931 ret
= snprintf(buf
+ len
, buflen
- len
,
1932 "dot1xAuthEntersConnecting=%u\n"
1933 "dot1xAuthEapLogoffsWhileConnecting=%u\n"
1934 "dot1xAuthEntersAuthenticating=%u\n"
1935 "dot1xAuthAuthSuccessesWhileAuthenticating=%u\n"
1936 "dot1xAuthAuthTimeoutsWhileAuthenticating=%u\n"
1937 "dot1xAuthAuthFailWhileAuthenticating=%u\n"
1938 "dot1xAuthAuthEapStartsWhileAuthenticating=%u\n"
1939 "dot1xAuthAuthEapLogoffWhileAuthenticating=%u\n"
1940 "dot1xAuthAuthReauthsWhileAuthenticated=%u\n"
1941 "dot1xAuthAuthEapStartsWhileAuthenticated=%u\n"
1942 "dot1xAuthAuthEapLogoffWhileAuthenticated=%u\n"
1943 "dot1xAuthBackendResponses=%u\n"
1944 "dot1xAuthBackendAccessChallenges=%u\n"
1945 "dot1xAuthBackendOtherRequestsToSupplicant=%u\n"
1946 "dot1xAuthBackendAuthSuccesses=%u\n"
1947 "dot1xAuthBackendAuthFails=%u\n",
1948 sm
->authEntersConnecting
,
1949 sm
->authEapLogoffsWhileConnecting
,
1950 sm
->authEntersAuthenticating
,
1951 sm
->authAuthSuccessesWhileAuthenticating
,
1952 sm
->authAuthTimeoutsWhileAuthenticating
,
1953 sm
->authAuthFailWhileAuthenticating
,
1954 sm
->authAuthEapStartsWhileAuthenticating
,
1955 sm
->authAuthEapLogoffWhileAuthenticating
,
1956 sm
->authAuthReauthsWhileAuthenticated
,
1957 sm
->authAuthEapStartsWhileAuthenticated
,
1958 sm
->authAuthEapLogoffWhileAuthenticated
,
1959 sm
->backendResponses
,
1960 sm
->backendAccessChallenges
,
1961 sm
->backendOtherRequestsToSupplicant
,
1962 sm
->backendAuthSuccesses
,
1963 sm
->backendAuthFails
);
1964 if (ret
< 0 || (size_t) ret
>= buflen
- len
)
1968 /* dot1xAuthSessionStatsTable */
1969 ret
= snprintf(buf
+ len
, buflen
- len
,
1970 /* TODO: dot1xAuthSessionOctetsRx */
1971 /* TODO: dot1xAuthSessionOctetsTx */
1972 /* TODO: dot1xAuthSessionFramesRx */
1973 /* TODO: dot1xAuthSessionFramesTx */
1974 "dot1xAuthSessionId=%08X-%08X\n"
1975 "dot1xAuthSessionAuthenticMethod=%d\n"
1976 "dot1xAuthSessionTime=%u\n"
1977 "dot1xAuthSessionTerminateCause=999\n"
1978 "dot1xAuthSessionUserName=%s\n",
1979 sta
->acct_session_id_hi
, sta
->acct_session_id_lo
,
1980 wpa_auth_sta_key_mgmt(sta
->wpa_sm
) ==
1981 WPA_KEY_MGMT_IEEE8021X
? 1 : 2,
1982 (unsigned int) (time(NULL
) - sta
->acct_session_start
),
1984 if (ret
< 0 || (size_t) ret
>= buflen
- len
)
1992 void ieee802_1x_finished(struct hostapd_data
*hapd
, struct sta_info
*sta
,
1997 /* TODO: get PMKLifetime from WPA parameters */
1998 static const int dot11RSNAConfigPMKLifetime
= 43200;
2000 key
= ieee802_1x_get_key_crypt(sta
->eapol_sm
, &len
);
2001 if (success
&& key
&&
2002 wpa_auth_pmksa_add(sta
->wpa_sm
, key
, dot11RSNAConfigPMKLifetime
,
2003 sta
->eapol_sm
) == 0) {
2004 hostapd_logger(hapd
, sta
->addr
, HOSTAPD_MODULE_WPA
,
2005 HOSTAPD_LEVEL_DEBUG
,
2006 "Added PMKSA cache entry (IEEE 802.1X)");