1
6
7
8
9
16
17
18
19
20
21
22
23
24
25
26
27
28
31
32
33
34
35
36
37
38
39
44
45
48
49
50
51
52
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
84
85
86
87
88
89
90
91
92
93
94
95
96
100
101
102
103
104
105
106
109
110
111
117
118
119
122
123
124
127
128
129
130
131
135
136
140
141
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
171
172
175
179
180
181
182
183
184
185
186
187
188
192
/* ... */
#ifdef ESP_SUPPLICANT
#include "utils/includes.h"
#include "utils/common.h"
#include "common/eapol_common.h"
#include "rsn_supp/wpa.h"
#include "rsn_supp/pmksa_cache.h"
#include "esp_wpas_glue.h"
#include "esp_private/wifi.h"7 includes
u8 *wpa_alloc_eapol(void *sm, u8 type,
const void *data, u16 data_len,
size_t *msg_len, void **data_pos)
{
void *buffer;
struct ieee802_1x_hdr *hdr;
*msg_len = sizeof(struct ieee802_1x_hdr) + data_len;
buffer = os_malloc(*msg_len + sizeof(struct l2_ethhdr));
if (buffer == NULL) {
return NULL;
}{...}
hdr = (struct ieee802_1x_hdr *)((char *)buffer + sizeof(struct l2_ethhdr));
hdr->version = DEFAULT_EAPOL_VERSION;
hdr->type = type;
hdr->length = host_to_be16(data_len);
if (data) {
memcpy(hdr + 1, data, data_len);
}{...} else {
memset(hdr + 1, 0, data_len);
}{...}
if (data_pos) {
*data_pos = hdr + 1;
}{...}
return (u8 *) hdr;
}{ ... }
void wpa_free_eapol(u8 *buffer)
{
if (!buffer) {
return;
}{...}
buffer = buffer - sizeof(struct l2_ethhdr);
os_free(buffer);
}{ ... }
int wpa_ether_send(void *ctx, const u8 *dest, u16 proto,
const u8 *data, size_t data_len)
{
void *buffer = (void *)(data - sizeof(struct l2_ethhdr));
struct l2_ethhdr *eth = (struct l2_ethhdr *)buffer;
os_memcpy(eth->h_dest, dest, ETH_ALEN);
os_memcpy(eth->h_source, gWpaSm.own_addr, ETH_ALEN);
eth->h_proto = host_to_be16(proto);
return esp_wifi_internal_tx(WIFI_IF_STA, buffer, sizeof(struct l2_ethhdr) + data_len);
}{ ... }
int hostapd_send_eapol(const u8 *source, const u8 *sta_addr,
const u8 *data, size_t data_len)
{
void *buffer = os_malloc(data_len + sizeof(struct l2_ethhdr));
struct l2_ethhdr *eth = buffer;
if (!buffer) {
wpa_printf(MSG_DEBUG, "send_eapol, buffer=%p", buffer);
return -1;
}{...}
memcpy(eth->h_dest, sta_addr, ETH_ALEN);
memcpy(eth->h_source, source, ETH_ALEN);
eth->h_proto = host_to_be16(ETH_P_EAPOL);
memcpy((char *)buffer + sizeof(struct l2_ethhdr), data, data_len);
esp_wifi_internal_tx(WIFI_IF_AP, buffer, sizeof(struct l2_ethhdr) + data_len);
os_free(buffer);
return 0;
}{ ... }
static void disable_wpa_wpa2(void)
{
esp_wifi_sta_disable_wpa2_authmode_internal();
}{ ... }
void wpa_supplicant_transition_disable(struct wpa_sm *sm, u8 bitmap)
{
wpa_printf(MSG_DEBUG, "TRANSITION_DISABLE %02x", bitmap);
if ((bitmap & TRANSITION_DISABLE_WPA3_PERSONAL) &&
wpa_key_mgmt_sae(sm->key_mgmt)) {
disable_wpa_wpa2();
}{...}
if ((bitmap & TRANSITION_DISABLE_SAE_PK) &&
wpa_key_mgmt_sae(sm->key_mgmt)) {
wpa_printf(MSG_INFO,
"SAE-PK: SAE authentication without PK disabled based on AP notification");
disable_wpa_wpa2();
esp_wifi_enable_sae_pk_only_mode_internal();
}{...}
if ((bitmap & TRANSITION_DISABLE_WPA3_ENTERPRISE) &&
wpa_key_mgmt_wpa_ieee8021x(sm->key_mgmt)) {
disable_wpa_wpa2();
}{...}
if ((bitmap & TRANSITION_DISABLE_ENHANCED_OPEN) &&
wpa_key_mgmt_owe(sm->key_mgmt)) {
esp_wifi_sta_disable_owe_trans_internal();
}{...}
}{ ... }
u8 *wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
const void *data, u16 data_len,
size_t *msg_len, void **data_pos)
{
return wpa_alloc_eapol(sm, type, data, data_len, msg_len, data_pos);
}{ ... }
void wpa_sm_free_eapol(u8 *buffer)
{
return wpa_free_eapol(buffer);
}{ ... }
void wpa_sm_deauthenticate(struct wpa_sm *sm, u8 reason_code)
{
if (WPA_SM_STATE(sm) >= WPA_ASSOCIATED) {
pmksa_cache_clear_current(sm);
wpa_deauthenticate(reason_code);
}{...}
}{ ... }
/* ... */
int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,
int protect_type, int key_type)
{
return 0;
}{ ... }
/* ... */
int wpa_sm_get_beacon_ie(struct wpa_sm *sm)
{
return 0;
}{ ... }
/* ... */
void wpa_sm_disassociate(struct wpa_sm *sm, int reason_code)
{
}{ ... }
#endif/* ... */