]>
Commit | Line | Data |
---|---|---|
6fc6879b JM |
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 program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License version 2 as | |
9 | * published by the Free Software Foundation. | |
10 | * | |
11 | * Alternatively, this software may be distributed under the terms of BSD | |
12 | * license. | |
13 | * | |
14 | * See README and COPYING for more details. | |
15 | */ | |
16 | ||
6226e38d | 17 | #include "utils/includes.h" |
6fc6879b | 18 | |
6226e38d | 19 | #include "utils/common.h" |
6fc6879b | 20 | #include "ieee802_11.h" |
6226e38d | 21 | #include "wpa_auth.h" |
97234b50 | 22 | #include "sta_info.h" |
6226e38d | 23 | #include "ap_mlme.h" |
6fc6879b JM |
24 | |
25 | ||
71f04b3c | 26 | #ifndef CONFIG_NO_HOSTAPD_LOGGER |
6fc6879b JM |
27 | static const char * mlme_auth_alg_str(int alg) |
28 | { | |
29 | switch (alg) { | |
30 | case WLAN_AUTH_OPEN: | |
31 | return "OPEN_SYSTEM"; | |
32 | case WLAN_AUTH_SHARED_KEY: | |
33 | return "SHARED_KEY"; | |
34 | case WLAN_AUTH_FT: | |
35 | return "FT"; | |
36 | } | |
37 | ||
38 | return "unknown"; | |
39 | } | |
71f04b3c | 40 | #endif /* CONFIG_NO_HOSTAPD_LOGGER */ |
6fc6879b JM |
41 | |
42 | ||
43 | /** | |
44 | * mlme_authenticate_indication - Report the establishment of an authentication | |
45 | * relationship with a specific peer MAC entity | |
46 | * @hapd: BSS data | |
47 | * @sta: peer STA data | |
48 | * | |
49 | * MLME calls this function as a result of the establishment of an | |
50 | * authentication relationship with a specific peer MAC entity that | |
51 | * resulted from an authentication procedure that was initiated by | |
52 | * that specific peer MAC entity. | |
53 | * | |
54 | * PeerSTAAddress = sta->addr | |
55 | * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY) | |
56 | */ | |
57 | void mlme_authenticate_indication(struct hostapd_data *hapd, | |
58 | struct sta_info *sta) | |
59 | { | |
60 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, | |
61 | HOSTAPD_LEVEL_DEBUG, | |
62 | "MLME-AUTHENTICATE.indication(" MACSTR ", %s)", | |
63 | MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg)); | |
5d22a1d5 | 64 | if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP)) |
6fc6879b JM |
65 | mlme_deletekeys_request(hapd, sta); |
66 | } | |
67 | ||
68 | ||
69 | /** | |
70 | * mlme_deauthenticate_indication - Report the invalidation of an | |
71 | * authentication relationship with a specific peer MAC entity | |
72 | * @hapd: BSS data | |
73 | * @sta: Peer STA data | |
74 | * @reason_code: ReasonCode from Deauthentication frame | |
75 | * | |
76 | * MLME calls this function as a result of the invalidation of an | |
77 | * authentication relationship with a specific peer MAC entity. | |
78 | * | |
79 | * PeerSTAAddress = sta->addr | |
80 | */ | |
81 | void mlme_deauthenticate_indication(struct hostapd_data *hapd, | |
82 | struct sta_info *sta, u16 reason_code) | |
83 | { | |
84 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, | |
85 | HOSTAPD_LEVEL_DEBUG, | |
86 | "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)", | |
87 | MAC2STR(sta->addr), reason_code); | |
88 | mlme_deletekeys_request(hapd, sta); | |
89 | } | |
90 | ||
91 | ||
92 | /** | |
93 | * mlme_associate_indication - Report the establishment of an association with | |
94 | * a specific peer MAC entity | |
95 | * @hapd: BSS data | |
96 | * @sta: peer STA data | |
97 | * | |
98 | * MLME calls this function as a result of the establishment of an | |
99 | * association with a specific peer MAC entity that resulted from an | |
100 | * association procedure that was initiated by that specific peer MAC entity. | |
101 | * | |
102 | * PeerSTAAddress = sta->addr | |
103 | */ | |
104 | void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta) | |
105 | { | |
106 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, | |
107 | HOSTAPD_LEVEL_DEBUG, | |
108 | "MLME-ASSOCIATE.indication(" MACSTR ")", | |
109 | MAC2STR(sta->addr)); | |
110 | if (sta->auth_alg != WLAN_AUTH_FT) | |
111 | mlme_deletekeys_request(hapd, sta); | |
112 | } | |
113 | ||
114 | ||
115 | /** | |
116 | * mlme_reassociate_indication - Report the establishment of an reassociation | |
117 | * with a specific peer MAC entity | |
118 | * @hapd: BSS data | |
119 | * @sta: peer STA data | |
120 | * | |
121 | * MLME calls this function as a result of the establishment of an | |
122 | * reassociation with a specific peer MAC entity that resulted from a | |
123 | * reassociation procedure that was initiated by that specific peer MAC entity. | |
124 | * | |
125 | * PeerSTAAddress = sta->addr | |
126 | * | |
127 | * sta->previous_ap contains the "Current AP" information from ReassocReq. | |
128 | */ | |
129 | void mlme_reassociate_indication(struct hostapd_data *hapd, | |
130 | struct sta_info *sta) | |
131 | { | |
132 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, | |
133 | HOSTAPD_LEVEL_DEBUG, | |
134 | "MLME-REASSOCIATE.indication(" MACSTR ")", | |
135 | MAC2STR(sta->addr)); | |
136 | if (sta->auth_alg != WLAN_AUTH_FT) | |
137 | mlme_deletekeys_request(hapd, sta); | |
138 | } | |
139 | ||
140 | ||
141 | /** | |
142 | * mlme_disassociate_indication - Report disassociation with a specific peer | |
143 | * MAC entity | |
144 | * @hapd: BSS data | |
145 | * @sta: Peer STA data | |
146 | * @reason_code: ReasonCode from Disassociation frame | |
147 | * | |
148 | * MLME calls this function as a result of the invalidation of an association | |
149 | * relationship with a specific peer MAC entity. | |
150 | * | |
151 | * PeerSTAAddress = sta->addr | |
152 | */ | |
153 | void mlme_disassociate_indication(struct hostapd_data *hapd, | |
154 | struct sta_info *sta, u16 reason_code) | |
155 | { | |
156 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, | |
157 | HOSTAPD_LEVEL_DEBUG, | |
158 | "MLME-DISASSOCIATE.indication(" MACSTR ", %d)", | |
159 | MAC2STR(sta->addr), reason_code); | |
160 | mlme_deletekeys_request(hapd, sta); | |
161 | } | |
162 | ||
163 | ||
164 | void mlme_michaelmicfailure_indication(struct hostapd_data *hapd, | |
165 | const u8 *addr) | |
166 | { | |
167 | hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME, | |
168 | HOSTAPD_LEVEL_DEBUG, | |
169 | "MLME-MichaelMICFailure.indication(" MACSTR ")", | |
170 | MAC2STR(addr)); | |
171 | } | |
172 | ||
173 | ||
174 | void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta) | |
175 | { | |
176 | hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME, | |
177 | HOSTAPD_LEVEL_DEBUG, | |
178 | "MLME-DELETEKEYS.request(" MACSTR ")", | |
179 | MAC2STR(sta->addr)); | |
180 | ||
181 | if (sta->wpa_sm) | |
182 | wpa_remove_ptk(sta->wpa_sm); | |
183 | } |