hostapd: Update vendor branch to 0.6.10
[dragonfly.git] / contrib / hostapd / hostapd / mlme.c
blobd883931cf4146bc0e86248ff564468c1b39ded3f
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.
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.
11 * Alternatively, this software may be distributed under the terms of BSD
12 * license.
14 * See README and COPYING for more details.
17 #include "includes.h"
19 #include "hostapd.h"
20 #include "ieee802_11.h"
21 #include "wpa.h"
22 #include "mlme.h"
25 static const char * mlme_auth_alg_str(int alg)
27 switch (alg) {
28 case WLAN_AUTH_OPEN:
29 return "OPEN_SYSTEM";
30 case WLAN_AUTH_SHARED_KEY:
31 return "SHARED_KEY";
32 case WLAN_AUTH_FT:
33 return "FT";
36 return "unknown";
40 /**
41 * mlme_authenticate_indication - Report the establishment of an authentication
42 * relationship with a specific peer MAC entity
43 * @hapd: BSS data
44 * @sta: peer STA data
46 * MLME calls this function as a result of the establishment of an
47 * authentication relationship with a specific peer MAC entity that
48 * resulted from an authentication procedure that was initiated by
49 * that specific peer MAC entity.
51 * PeerSTAAddress = sta->addr
52 * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY)
54 void mlme_authenticate_indication(struct hostapd_data *hapd,
55 struct sta_info *sta)
57 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
58 HOSTAPD_LEVEL_DEBUG,
59 "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
60 MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
61 if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
62 mlme_deletekeys_request(hapd, sta);
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
73 * MLME calls this function as a result of the invalidation of an
74 * authentication relationship with a specific peer MAC entity.
76 * PeerSTAAddress = sta->addr
78 void mlme_deauthenticate_indication(struct hostapd_data *hapd,
79 struct sta_info *sta, u16 reason_code)
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);
85 mlme_deletekeys_request(hapd, sta);
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
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.
99 * PeerSTAAddress = sta->addr
101 void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
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);
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
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.
122 * PeerSTAAddress = sta->addr
124 * sta->previous_ap contains the "Current AP" information from ReassocReq.
126 void mlme_reassociate_indication(struct hostapd_data *hapd,
127 struct sta_info *sta)
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);
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
145 * MLME calls this function as a result of the invalidation of an association
146 * relationship with a specific peer MAC entity.
148 * PeerSTAAddress = sta->addr
150 void mlme_disassociate_indication(struct hostapd_data *hapd,
151 struct sta_info *sta, u16 reason_code)
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);
161 void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
162 const u8 *addr)
164 hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
165 HOSTAPD_LEVEL_DEBUG,
166 "MLME-MichaelMICFailure.indication(" MACSTR ")",
167 MAC2STR(addr));
171 void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
173 hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
174 HOSTAPD_LEVEL_DEBUG,
175 "MLME-DELETEKEYS.request(" MACSTR ")",
176 MAC2STR(sta->addr));
178 if (sta->wpa_sm)
179 wpa_remove_ptk(sta->wpa_sm);