xref: /dflybsd-src/contrib/wpa_supplicant/src/ap/ap_mlme.c (revision 3a84a4273475ed07d0ab1c2dfeffdfedef35d9cd)
13ff40c12SJohn Marino /*
23ff40c12SJohn Marino  * hostapd / IEEE 802.11 MLME
33ff40c12SJohn Marino  * Copyright 2003-2006, Jouni Malinen <j@w1.fi>
43ff40c12SJohn Marino  * Copyright 2003-2004, Instant802 Networks, Inc.
53ff40c12SJohn Marino  * Copyright 2005-2006, Devicescape Software, Inc.
63ff40c12SJohn Marino  *
73ff40c12SJohn Marino  * This software may be distributed under the terms of the BSD license.
83ff40c12SJohn Marino  * See README for more details.
93ff40c12SJohn Marino  */
103ff40c12SJohn Marino 
113ff40c12SJohn Marino #include "utils/includes.h"
123ff40c12SJohn Marino 
133ff40c12SJohn Marino #include "utils/common.h"
143ff40c12SJohn Marino #include "common/ieee802_11_defs.h"
153ff40c12SJohn Marino #include "ieee802_11.h"
163ff40c12SJohn Marino #include "wpa_auth.h"
173ff40c12SJohn Marino #include "sta_info.h"
183ff40c12SJohn Marino #include "ap_mlme.h"
19*a1157835SDaniel Fojt #include "hostapd.h"
203ff40c12SJohn Marino 
213ff40c12SJohn Marino 
223ff40c12SJohn Marino #ifndef CONFIG_NO_HOSTAPD_LOGGER
mlme_auth_alg_str(int alg)233ff40c12SJohn Marino static const char * mlme_auth_alg_str(int alg)
243ff40c12SJohn Marino {
253ff40c12SJohn Marino 	switch (alg) {
263ff40c12SJohn Marino 	case WLAN_AUTH_OPEN:
273ff40c12SJohn Marino 		return "OPEN_SYSTEM";
283ff40c12SJohn Marino 	case WLAN_AUTH_SHARED_KEY:
293ff40c12SJohn Marino 		return "SHARED_KEY";
303ff40c12SJohn Marino 	case WLAN_AUTH_FT:
313ff40c12SJohn Marino 		return "FT";
323ff40c12SJohn Marino 	}
333ff40c12SJohn Marino 
343ff40c12SJohn Marino 	return "unknown";
353ff40c12SJohn Marino }
363ff40c12SJohn Marino #endif /* CONFIG_NO_HOSTAPD_LOGGER */
373ff40c12SJohn Marino 
383ff40c12SJohn Marino 
393ff40c12SJohn Marino /**
403ff40c12SJohn Marino  * mlme_authenticate_indication - Report the establishment of an authentication
413ff40c12SJohn Marino  * relationship with a specific peer MAC entity
423ff40c12SJohn Marino  * @hapd: BSS data
433ff40c12SJohn Marino  * @sta: peer STA data
443ff40c12SJohn Marino  *
453ff40c12SJohn Marino  * MLME calls this function as a result of the establishment of an
463ff40c12SJohn Marino  * authentication relationship with a specific peer MAC entity that
473ff40c12SJohn Marino  * resulted from an authentication procedure that was initiated by
483ff40c12SJohn Marino  * that specific peer MAC entity.
493ff40c12SJohn Marino  *
503ff40c12SJohn Marino  * PeerSTAAddress = sta->addr
513ff40c12SJohn Marino  * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY)
523ff40c12SJohn Marino  */
mlme_authenticate_indication(struct hostapd_data * hapd,struct sta_info * sta)533ff40c12SJohn Marino void mlme_authenticate_indication(struct hostapd_data *hapd,
543ff40c12SJohn Marino 				  struct sta_info *sta)
553ff40c12SJohn Marino {
563ff40c12SJohn Marino 	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
573ff40c12SJohn Marino 		       HOSTAPD_LEVEL_DEBUG,
583ff40c12SJohn Marino 		       "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
593ff40c12SJohn Marino 		       MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
60*a1157835SDaniel Fojt 	if (sta->auth_alg != WLAN_AUTH_FT &&
61*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_SK &&
62*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_SK_PFS &&
63*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_PK &&
64*a1157835SDaniel Fojt 	    !(sta->flags & WLAN_STA_MFP))
653ff40c12SJohn Marino 		mlme_deletekeys_request(hapd, sta);
66*a1157835SDaniel Fojt 	ap_sta_clear_disconnect_timeouts(hapd, sta);
673ff40c12SJohn Marino }
683ff40c12SJohn Marino 
693ff40c12SJohn Marino 
703ff40c12SJohn Marino /**
713ff40c12SJohn Marino  * mlme_deauthenticate_indication - Report the invalidation of an
723ff40c12SJohn Marino  * authentication relationship with a specific peer MAC entity
733ff40c12SJohn Marino  * @hapd: BSS data
743ff40c12SJohn Marino  * @sta: Peer STA data
753ff40c12SJohn Marino  * @reason_code: ReasonCode from Deauthentication frame
763ff40c12SJohn Marino  *
773ff40c12SJohn Marino  * MLME calls this function as a result of the invalidation of an
783ff40c12SJohn Marino  * authentication relationship with a specific peer MAC entity.
793ff40c12SJohn Marino  *
803ff40c12SJohn Marino  * PeerSTAAddress = sta->addr
813ff40c12SJohn Marino  */
mlme_deauthenticate_indication(struct hostapd_data * hapd,struct sta_info * sta,u16 reason_code)823ff40c12SJohn Marino void mlme_deauthenticate_indication(struct hostapd_data *hapd,
833ff40c12SJohn Marino 				    struct sta_info *sta, u16 reason_code)
843ff40c12SJohn Marino {
853ff40c12SJohn Marino 	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
863ff40c12SJohn Marino 		       HOSTAPD_LEVEL_DEBUG,
873ff40c12SJohn Marino 		       "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
883ff40c12SJohn Marino 		       MAC2STR(sta->addr), reason_code);
89*a1157835SDaniel Fojt 	if (!hapd->iface->driver_ap_teardown)
903ff40c12SJohn Marino 		mlme_deletekeys_request(hapd, sta);
913ff40c12SJohn Marino }
923ff40c12SJohn Marino 
933ff40c12SJohn Marino 
943ff40c12SJohn Marino /**
953ff40c12SJohn Marino  * mlme_associate_indication - Report the establishment of an association with
963ff40c12SJohn Marino  * a specific peer MAC entity
973ff40c12SJohn Marino  * @hapd: BSS data
983ff40c12SJohn Marino  * @sta: peer STA data
993ff40c12SJohn Marino  *
1003ff40c12SJohn Marino  * MLME calls this function as a result of the establishment of an
1013ff40c12SJohn Marino  * association with a specific peer MAC entity that resulted from an
1023ff40c12SJohn Marino  * association procedure that was initiated by that specific peer MAC entity.
1033ff40c12SJohn Marino  *
1043ff40c12SJohn Marino  * PeerSTAAddress = sta->addr
1053ff40c12SJohn Marino  */
mlme_associate_indication(struct hostapd_data * hapd,struct sta_info * sta)1063ff40c12SJohn Marino void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
1073ff40c12SJohn Marino {
1083ff40c12SJohn Marino 	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
1093ff40c12SJohn Marino 		       HOSTAPD_LEVEL_DEBUG,
1103ff40c12SJohn Marino 		       "MLME-ASSOCIATE.indication(" MACSTR ")",
1113ff40c12SJohn Marino 		       MAC2STR(sta->addr));
112*a1157835SDaniel Fojt 	if (sta->auth_alg != WLAN_AUTH_FT &&
113*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_SK &&
114*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_SK_PFS &&
115*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_PK)
1163ff40c12SJohn Marino 		mlme_deletekeys_request(hapd, sta);
117*a1157835SDaniel Fojt 	ap_sta_clear_disconnect_timeouts(hapd, sta);
1183ff40c12SJohn Marino }
1193ff40c12SJohn Marino 
1203ff40c12SJohn Marino 
1213ff40c12SJohn Marino /**
1223ff40c12SJohn Marino  * mlme_reassociate_indication - Report the establishment of an reassociation
1233ff40c12SJohn Marino  * with a specific peer MAC entity
1243ff40c12SJohn Marino  * @hapd: BSS data
1253ff40c12SJohn Marino  * @sta: peer STA data
1263ff40c12SJohn Marino  *
1273ff40c12SJohn Marino  * MLME calls this function as a result of the establishment of an
1283ff40c12SJohn Marino  * reassociation with a specific peer MAC entity that resulted from a
1293ff40c12SJohn Marino  * reassociation procedure that was initiated by that specific peer MAC entity.
1303ff40c12SJohn Marino  *
1313ff40c12SJohn Marino  * PeerSTAAddress = sta->addr
1323ff40c12SJohn Marino  */
mlme_reassociate_indication(struct hostapd_data * hapd,struct sta_info * sta)1333ff40c12SJohn Marino void mlme_reassociate_indication(struct hostapd_data *hapd,
1343ff40c12SJohn Marino 				 struct sta_info *sta)
1353ff40c12SJohn Marino {
1363ff40c12SJohn Marino 	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
1373ff40c12SJohn Marino 		       HOSTAPD_LEVEL_DEBUG,
1383ff40c12SJohn Marino 		       "MLME-REASSOCIATE.indication(" MACSTR ")",
1393ff40c12SJohn Marino 		       MAC2STR(sta->addr));
140*a1157835SDaniel Fojt 	if (sta->auth_alg != WLAN_AUTH_FT &&
141*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_SK &&
142*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_SK_PFS &&
143*a1157835SDaniel Fojt 	    sta->auth_alg != WLAN_AUTH_FILS_PK)
1443ff40c12SJohn Marino 		mlme_deletekeys_request(hapd, sta);
145*a1157835SDaniel Fojt 	ap_sta_clear_disconnect_timeouts(hapd, sta);
1463ff40c12SJohn Marino }
1473ff40c12SJohn Marino 
1483ff40c12SJohn Marino 
1493ff40c12SJohn Marino /**
1503ff40c12SJohn Marino  * mlme_disassociate_indication - Report disassociation with a specific peer
1513ff40c12SJohn Marino  * MAC entity
1523ff40c12SJohn Marino  * @hapd: BSS data
1533ff40c12SJohn Marino  * @sta: Peer STA data
1543ff40c12SJohn Marino  * @reason_code: ReasonCode from Disassociation frame
1553ff40c12SJohn Marino  *
1563ff40c12SJohn Marino  * MLME calls this function as a result of the invalidation of an association
1573ff40c12SJohn Marino  * relationship with a specific peer MAC entity.
1583ff40c12SJohn Marino  *
1593ff40c12SJohn Marino  * PeerSTAAddress = sta->addr
1603ff40c12SJohn Marino  */
mlme_disassociate_indication(struct hostapd_data * hapd,struct sta_info * sta,u16 reason_code)1613ff40c12SJohn Marino void mlme_disassociate_indication(struct hostapd_data *hapd,
1623ff40c12SJohn Marino 				  struct sta_info *sta, u16 reason_code)
1633ff40c12SJohn Marino {
1643ff40c12SJohn Marino 	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
1653ff40c12SJohn Marino 		       HOSTAPD_LEVEL_DEBUG,
1663ff40c12SJohn Marino 		       "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
1673ff40c12SJohn Marino 		       MAC2STR(sta->addr), reason_code);
1683ff40c12SJohn Marino 	mlme_deletekeys_request(hapd, sta);
1693ff40c12SJohn Marino }
1703ff40c12SJohn Marino 
1713ff40c12SJohn Marino 
mlme_michaelmicfailure_indication(struct hostapd_data * hapd,const u8 * addr)1723ff40c12SJohn Marino void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
1733ff40c12SJohn Marino 				       const u8 *addr)
1743ff40c12SJohn Marino {
1753ff40c12SJohn Marino 	hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
1763ff40c12SJohn Marino 		       HOSTAPD_LEVEL_DEBUG,
1773ff40c12SJohn Marino 		       "MLME-MichaelMICFailure.indication(" MACSTR ")",
1783ff40c12SJohn Marino 		       MAC2STR(addr));
1793ff40c12SJohn Marino }
1803ff40c12SJohn Marino 
1813ff40c12SJohn Marino 
mlme_deletekeys_request(struct hostapd_data * hapd,struct sta_info * sta)1823ff40c12SJohn Marino void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
1833ff40c12SJohn Marino {
1843ff40c12SJohn Marino 	hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
1853ff40c12SJohn Marino 		       HOSTAPD_LEVEL_DEBUG,
1863ff40c12SJohn Marino 		       "MLME-DELETEKEYS.request(" MACSTR ")",
1873ff40c12SJohn Marino 		       MAC2STR(sta->addr));
1883ff40c12SJohn Marino 
1893ff40c12SJohn Marino 	if (sta->wpa_sm)
1903ff40c12SJohn Marino 		wpa_remove_ptk(sta->wpa_sm);
1913ff40c12SJohn Marino }
192