Coverage Report

Created: 2026-10-16 06:12

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