blob: a7129f14b26beea58f4eac56c8988556d04afd29 [file] [log] [blame]
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07001/*
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 *
Dmitry Shmidtc5ec7f52012-03-06 16:33:24 -08007 * This software may be distributed under the terms of the BSD license.
8 * See README for more details.
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -07009 */
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"
Dmitry Shmidta38abf92014-03-06 13:38:44 -080019#include "hostapd.h"
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070020
21
22#ifndef CONFIG_NO_HOSTAPD_LOGGER
23static 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 */
53void 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 && !(sta->flags & WLAN_STA_MFP))
61 mlme_deletekeys_request(hapd, sta);
62}
63
64
65/**
66 * mlme_deauthenticate_indication - Report the invalidation of an
67 * authentication relationship with a specific peer MAC entity
68 * @hapd: BSS data
69 * @sta: Peer STA data
70 * @reason_code: ReasonCode from Deauthentication frame
71 *
72 * MLME calls this function as a result of the invalidation of an
73 * authentication relationship with a specific peer MAC entity.
74 *
75 * PeerSTAAddress = sta->addr
76 */
77void mlme_deauthenticate_indication(struct hostapd_data *hapd,
78 struct sta_info *sta, u16 reason_code)
79{
80 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
81 HOSTAPD_LEVEL_DEBUG,
82 "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
83 MAC2STR(sta->addr), reason_code);
Dmitry Shmidta38abf92014-03-06 13:38:44 -080084 if (!hapd->iface->driver_ap_teardown)
85 mlme_deletekeys_request(hapd, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070086}
87
88
89/**
90 * mlme_associate_indication - Report the establishment of an association with
91 * a specific peer MAC entity
92 * @hapd: BSS data
93 * @sta: peer STA data
94 *
95 * MLME calls this function as a result of the establishment of an
96 * association with a specific peer MAC entity that resulted from an
97 * association procedure that was initiated by that specific peer MAC entity.
98 *
99 * PeerSTAAddress = sta->addr
100 */
101void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
102{
103 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
104 HOSTAPD_LEVEL_DEBUG,
105 "MLME-ASSOCIATE.indication(" MACSTR ")",
106 MAC2STR(sta->addr));
107 if (sta->auth_alg != WLAN_AUTH_FT)
108 mlme_deletekeys_request(hapd, sta);
109}
110
111
112/**
113 * mlme_reassociate_indication - Report the establishment of an reassociation
114 * with a specific peer MAC entity
115 * @hapd: BSS data
116 * @sta: peer STA data
117 *
118 * MLME calls this function as a result of the establishment of an
119 * reassociation with a specific peer MAC entity that resulted from a
120 * reassociation procedure that was initiated by that specific peer MAC entity.
121 *
122 * PeerSTAAddress = sta->addr
123 *
124 * sta->previous_ap contains the "Current AP" information from ReassocReq.
125 */
126void mlme_reassociate_indication(struct hostapd_data *hapd,
127 struct sta_info *sta)
128{
129 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
130 HOSTAPD_LEVEL_DEBUG,
131 "MLME-REASSOCIATE.indication(" MACSTR ")",
132 MAC2STR(sta->addr));
133 if (sta->auth_alg != WLAN_AUTH_FT)
134 mlme_deletekeys_request(hapd, sta);
135}
136
137
138/**
139 * mlme_disassociate_indication - Report disassociation with a specific peer
140 * MAC entity
141 * @hapd: BSS data
142 * @sta: Peer STA data
143 * @reason_code: ReasonCode from Disassociation frame
144 *
145 * MLME calls this function as a result of the invalidation of an association
146 * relationship with a specific peer MAC entity.
147 *
148 * PeerSTAAddress = sta->addr
149 */
150void mlme_disassociate_indication(struct hostapd_data *hapd,
151 struct sta_info *sta, u16 reason_code)
152{
153 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
154 HOSTAPD_LEVEL_DEBUG,
155 "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
156 MAC2STR(sta->addr), reason_code);
157 mlme_deletekeys_request(hapd, sta);
158}
159
160
161void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
162 const u8 *addr)
163{
164 hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
165 HOSTAPD_LEVEL_DEBUG,
166 "MLME-MichaelMICFailure.indication(" MACSTR ")",
167 MAC2STR(addr));
168}
169
170
171void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
172{
173 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
174 HOSTAPD_LEVEL_DEBUG,
175 "MLME-DELETEKEYS.request(" MACSTR ")",
176 MAC2STR(sta->addr));
177
178 if (sta->wpa_sm)
179 wpa_remove_ptk(sta->wpa_sm);
180}