1 /*
2 * hostapd / IEEE 802.11 MLME
3 * Copyright 2003-2006, Jouni Malinen <j@w1.fi>
4 * Copyright 2003-2004, Instant802 Networks, Inc.
5 * Copyright 2005-2006, Devicescape Software, Inc.
6 *
7 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
9 */
10
11 #include "utils/includes.h"
12
13 #include "utils/common.h"
14 #include "common/ieee802_11_defs.h"
15 #include "ieee802_11.h"
16 #include "wpa_auth.h"
17 #include "sta_info.h"
18 #include "ap_mlme.h"
19 #include "hostapd.h"
20
21
22 #ifndef CONFIG_NO_HOSTAPD_LOGGER
mlme_auth_alg_str(int alg)23 static const char * mlme_auth_alg_str(int alg)
24 {
25 switch (alg) {
26 case WLAN_AUTH_OPEN:
27 return "OPEN_SYSTEM";
28 case WLAN_AUTH_SHARED_KEY:
29 return "SHARED_KEY";
30 case WLAN_AUTH_FT:
31 return "FT";
32 }
33
34 return "unknown";
35 }
36 #endif /* CONFIG_NO_HOSTAPD_LOGGER */
37
38
39 /**
40 * mlme_authenticate_indication - Report the establishment of an authentication
41 * relationship with a specific peer MAC entity
42 * @hapd: BSS data
43 * @sta: peer STA data
44 *
45 * MLME calls this function as a result of the establishment of an
46 * authentication relationship with a specific peer MAC entity that
47 * resulted from an authentication procedure that was initiated by
48 * that specific peer MAC entity.
49 *
50 * PeerSTAAddress = sta->addr
51 * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY)
52 */
mlme_authenticate_indication(struct hostapd_data * hapd,struct sta_info * sta)53 void mlme_authenticate_indication(struct hostapd_data *hapd,
54 struct sta_info *sta)
55 {
56 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
57 HOSTAPD_LEVEL_DEBUG,
58 "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
59 MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
60 if (sta->auth_alg != WLAN_AUTH_FT &&
61 sta->auth_alg != WLAN_AUTH_FILS_SK &&
62 sta->auth_alg != WLAN_AUTH_FILS_SK_PFS &&
63 sta->auth_alg != WLAN_AUTH_FILS_PK &&
64 !(sta->flags & WLAN_STA_MFP))
65 mlme_deletekeys_request(hapd, sta);
66 ap_sta_clear_disconnect_timeouts(hapd, sta);
67 }
68
69
70 /**
71 * mlme_deauthenticate_indication - Report the invalidation of an
72 * authentication relationship with a specific peer MAC entity
73 * @hapd: BSS data
74 * @sta: Peer STA data
75 * @reason_code: ReasonCode from Deauthentication frame
76 *
77 * MLME calls this function as a result of the invalidation of an
78 * authentication relationship with a specific peer MAC entity.
79 *
80 * PeerSTAAddress = sta->addr
81 */
mlme_deauthenticate_indication(struct hostapd_data * hapd,struct sta_info * sta,u16 reason_code)82 void mlme_deauthenticate_indication(struct hostapd_data *hapd,
83 struct sta_info *sta, u16 reason_code)
84 {
85 #ifndef EXT_CODE_CROP
86 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
87 HOSTAPD_LEVEL_DEBUG,
88 "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
89 MAC2STR(sta->addr), reason_code);
90 if (!hapd->iface->driver_ap_teardown)
91 #endif /* EXT_CODE_CROP */
92 mlme_deletekeys_request(hapd, sta);
93 }
94
95
96 /**
97 * mlme_associate_indication - Report the establishment of an association with
98 * a specific peer MAC entity
99 * @hapd: BSS data
100 * @sta: peer STA data
101 *
102 * MLME calls this function as a result of the establishment of an
103 * association with a specific peer MAC entity that resulted from an
104 * association procedure that was initiated by that specific peer MAC entity.
105 *
106 * PeerSTAAddress = sta->addr
107 */
mlme_associate_indication(struct hostapd_data * hapd,struct sta_info * sta)108 void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
109 {
110 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
111 HOSTAPD_LEVEL_DEBUG,
112 "MLME-ASSOCIATE.indication(" MACSTR ")",
113 MAC2STR(sta->addr));
114 if (sta->auth_alg != WLAN_AUTH_FT &&
115 sta->auth_alg != WLAN_AUTH_FILS_SK &&
116 sta->auth_alg != WLAN_AUTH_FILS_SK_PFS &&
117 sta->auth_alg != WLAN_AUTH_FILS_PK)
118 mlme_deletekeys_request(hapd, sta);
119 ap_sta_clear_disconnect_timeouts(hapd, sta);
120 }
121
122
123 /**
124 * mlme_reassociate_indication - Report the establishment of an reassociation
125 * with a specific peer MAC entity
126 * @hapd: BSS data
127 * @sta: peer STA data
128 *
129 * MLME calls this function as a result of the establishment of an
130 * reassociation with a specific peer MAC entity that resulted from a
131 * reassociation procedure that was initiated by that specific peer MAC entity.
132 *
133 * PeerSTAAddress = sta->addr
134 */
mlme_reassociate_indication(struct hostapd_data * hapd,struct sta_info * sta)135 void mlme_reassociate_indication(struct hostapd_data *hapd,
136 struct sta_info *sta)
137 {
138 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
139 HOSTAPD_LEVEL_DEBUG,
140 "MLME-REASSOCIATE.indication(" MACSTR ")",
141 MAC2STR(sta->addr));
142 if (sta->auth_alg != WLAN_AUTH_FT &&
143 sta->auth_alg != WLAN_AUTH_FILS_SK &&
144 sta->auth_alg != WLAN_AUTH_FILS_SK_PFS &&
145 sta->auth_alg != WLAN_AUTH_FILS_PK)
146 mlme_deletekeys_request(hapd, sta);
147 ap_sta_clear_disconnect_timeouts(hapd, sta);
148 }
149
150
151 /**
152 * mlme_disassociate_indication - Report disassociation with a specific peer
153 * MAC entity
154 * @hapd: BSS data
155 * @sta: Peer STA data
156 * @reason_code: ReasonCode from Disassociation frame
157 *
158 * MLME calls this function as a result of the invalidation of an association
159 * relationship with a specific peer MAC entity.
160 *
161 * PeerSTAAddress = sta->addr
162 */
mlme_disassociate_indication(struct hostapd_data * hapd,struct sta_info * sta,u16 reason_code)163 void mlme_disassociate_indication(struct hostapd_data *hapd,
164 struct sta_info *sta, u16 reason_code)
165 {
166 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
167 HOSTAPD_LEVEL_DEBUG,
168 "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
169 MAC2STR(sta->addr), reason_code);
170 mlme_deletekeys_request(hapd, sta);
171 }
172
173
mlme_michaelmicfailure_indication(struct hostapd_data * hapd,const u8 * addr)174 void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
175 const u8 *addr)
176 {
177 hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
178 HOSTAPD_LEVEL_DEBUG,
179 "MLME-MichaelMICFailure.indication(" MACSTR ")",
180 MAC2STR(addr));
181 }
182
183
mlme_deletekeys_request(struct hostapd_data * hapd,struct sta_info * sta)184 void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
185 {
186 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
187 HOSTAPD_LEVEL_DEBUG,
188 "MLME-DELETEKEYS.request(" MACSTR ")",
189 MAC2STR(sta->addr));
190
191 if (sta->wpa_sm)
192 wpa_remove_ptk(sta->wpa_sm);
193 }
194