blob: e7308a01d7432f3fb5ea0d6bcda4a7f4bdb412ee [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));
Dmitry Shmidtfe31a9a2016-11-09 13:43:31 -080060 if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070061 mlme_deletekeys_request(hapd, sta);
Dmitry Shmidt1d6bf422016-01-19 15:51:35 -080062 ap_sta_clear_disconnect_timeouts(hapd, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070063}
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 */
78void mlme_deauthenticate_indication(struct hostapd_data *hapd,
79 struct sta_info *sta, u16 reason_code)
80{
81 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
82 HOSTAPD_LEVEL_DEBUG,
83 "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
84 MAC2STR(sta->addr), reason_code);
Dmitry Shmidta38abf92014-03-06 13:38:44 -080085 if (!hapd->iface->driver_ap_teardown)
86 mlme_deletekeys_request(hapd, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -070087}
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 */
102void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
103{
104 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
105 HOSTAPD_LEVEL_DEBUG,
106 "MLME-ASSOCIATE.indication(" MACSTR ")",
107 MAC2STR(sta->addr));
Dmitry Shmidtfe31a9a2016-11-09 13:43:31 -0800108 if (sta->auth_alg != WLAN_AUTH_FT)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700109 mlme_deletekeys_request(hapd, sta);
Dmitry Shmidt1d6bf422016-01-19 15:51:35 -0800110 ap_sta_clear_disconnect_timeouts(hapd, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700111}
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
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700125 */
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));
Dmitry Shmidtfe31a9a2016-11-09 13:43:31 -0800133 if (sta->auth_alg != WLAN_AUTH_FT)
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700134 mlme_deletekeys_request(hapd, sta);
Dmitry Shmidt1d6bf422016-01-19 15:51:35 -0800135 ap_sta_clear_disconnect_timeouts(hapd, sta);
Dmitry Shmidt8d520ff2011-05-09 14:06:53 -0700136}
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 */
151void mlme_disassociate_indication(struct hostapd_data *hapd,
152 struct sta_info *sta, u16 reason_code)
153{
154 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
155 HOSTAPD_LEVEL_DEBUG,
156 "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
157 MAC2STR(sta->addr), reason_code);
158 mlme_deletekeys_request(hapd, sta);
159}
160
161
162void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
163 const u8 *addr)
164{
165 hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
166 HOSTAPD_LEVEL_DEBUG,
167 "MLME-MichaelMICFailure.indication(" MACSTR ")",
168 MAC2STR(addr));
169}
170
171
172void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
173{
174 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
175 HOSTAPD_LEVEL_DEBUG,
176 "MLME-DELETEKEYS.request(" MACSTR ")",
177 MAC2STR(sta->addr));
178
179 if (sta->wpa_sm)
180 wpa_remove_ptk(sta->wpa_sm);
181}