Line data Source code
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
23 4788 : static const char * mlme_auth_alg_str(int alg)
24 : {
25 4788 : switch (alg) {
26 : case WLAN_AUTH_OPEN:
27 4501 : return "OPEN_SYSTEM";
28 : case WLAN_AUTH_SHARED_KEY:
29 26 : return "SHARED_KEY";
30 : case WLAN_AUTH_FT:
31 123 : return "FT";
32 : }
33 :
34 138 : 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 : */
53 4788 : void mlme_authenticate_indication(struct hostapd_data *hapd,
54 : struct sta_info *sta)
55 : {
56 33516 : hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
57 : HOSTAPD_LEVEL_DEBUG,
58 : "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
59 33516 : MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
60 4788 : if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
61 4589 : mlme_deletekeys_request(hapd, sta);
62 4788 : ap_sta_clear_disconnect_timeouts(hapd, sta);
63 4788 : }
64 :
65 :
66 : /**
67 : * mlme_deauthenticate_indication - Report the invalidation of an
68 : * authentication relationship with a specific peer MAC entity
69 : * @hapd: BSS data
70 : * @sta: Peer STA data
71 : * @reason_code: ReasonCode from Deauthentication frame
72 : *
73 : * MLME calls this function as a result of the invalidation of an
74 : * authentication relationship with a specific peer MAC entity.
75 : *
76 : * PeerSTAAddress = sta->addr
77 : */
78 4571 : void mlme_deauthenticate_indication(struct hostapd_data *hapd,
79 : struct sta_info *sta, u16 reason_code)
80 : {
81 31997 : hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
82 : HOSTAPD_LEVEL_DEBUG,
83 : "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
84 27426 : MAC2STR(sta->addr), reason_code);
85 4571 : if (!hapd->iface->driver_ap_teardown)
86 4263 : mlme_deletekeys_request(hapd, sta);
87 4571 : }
88 :
89 :
90 : /**
91 : * mlme_associate_indication - Report the establishment of an association with
92 : * a specific peer MAC entity
93 : * @hapd: BSS data
94 : * @sta: peer STA data
95 : *
96 : * MLME calls this function as a result of the establishment of an
97 : * association with a specific peer MAC entity that resulted from an
98 : * association procedure that was initiated by that specific peer MAC entity.
99 : *
100 : * PeerSTAAddress = sta->addr
101 : */
102 4420 : void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
103 : {
104 26520 : hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
105 : HOSTAPD_LEVEL_DEBUG,
106 : "MLME-ASSOCIATE.indication(" MACSTR ")",
107 26520 : MAC2STR(sta->addr));
108 4420 : if (sta->auth_alg != WLAN_AUTH_FT)
109 4420 : mlme_deletekeys_request(hapd, sta);
110 4420 : ap_sta_clear_disconnect_timeouts(hapd, sta);
111 4420 : }
112 :
113 :
114 : /**
115 : * mlme_reassociate_indication - Report the establishment of an reassociation
116 : * with a specific peer MAC entity
117 : * @hapd: BSS data
118 : * @sta: peer STA data
119 : *
120 : * MLME calls this function as a result of the establishment of an
121 : * reassociation with a specific peer MAC entity that resulted from a
122 : * reassociation procedure that was initiated by that specific peer MAC entity.
123 : *
124 : * PeerSTAAddress = sta->addr
125 : */
126 336 : void mlme_reassociate_indication(struct hostapd_data *hapd,
127 : struct sta_info *sta)
128 : {
129 2016 : hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
130 : HOSTAPD_LEVEL_DEBUG,
131 : "MLME-REASSOCIATE.indication(" MACSTR ")",
132 2016 : MAC2STR(sta->addr));
133 336 : if (sta->auth_alg != WLAN_AUTH_FT)
134 109 : mlme_deletekeys_request(hapd, sta);
135 336 : ap_sta_clear_disconnect_timeouts(hapd, sta);
136 336 : }
137 :
138 :
139 : /**
140 : * mlme_disassociate_indication - Report disassociation with a specific peer
141 : * MAC entity
142 : * @hapd: BSS data
143 : * @sta: Peer STA data
144 : * @reason_code: ReasonCode from Disassociation frame
145 : *
146 : * MLME calls this function as a result of the invalidation of an association
147 : * relationship with a specific peer MAC entity.
148 : *
149 : * PeerSTAAddress = sta->addr
150 : */
151 18 : void mlme_disassociate_indication(struct hostapd_data *hapd,
152 : struct sta_info *sta, u16 reason_code)
153 : {
154 126 : hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
155 : HOSTAPD_LEVEL_DEBUG,
156 : "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
157 108 : MAC2STR(sta->addr), reason_code);
158 18 : mlme_deletekeys_request(hapd, sta);
159 18 : }
160 :
161 :
162 2 : void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
163 : const u8 *addr)
164 : {
165 12 : hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
166 : HOSTAPD_LEVEL_DEBUG,
167 : "MLME-MichaelMICFailure.indication(" MACSTR ")",
168 12 : MAC2STR(addr));
169 2 : }
170 :
171 :
172 13399 : void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
173 : {
174 80394 : hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
175 : HOSTAPD_LEVEL_DEBUG,
176 : "MLME-DELETEKEYS.request(" MACSTR ")",
177 80394 : MAC2STR(sta->addr));
178 :
179 13399 : if (sta->wpa_sm)
180 6497 : wpa_remove_ptk(sta->wpa_sm);
181 13399 : }
|