Introduced new helper function is_zero_ether_addr()
Use this inline function to replace os_memcmp(addr, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0.
This commit is contained in:
parent
957ed801e9
commit
a8e16edc86
12 changed files with 18 additions and 26 deletions
|
@ -369,7 +369,7 @@ static int hostapd_config_read_wpa_psk(const char *fname,
|
||||||
ret = -1;
|
ret = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (os_memcmp(addr, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
|
if (is_zero_ether_addr(addr))
|
||||||
psk->group = 1;
|
psk->group = 1;
|
||||||
else
|
else
|
||||||
os_memcpy(psk->addr, addr, ETH_ALEN);
|
os_memcpy(psk->addr, addr, ETH_ALEN);
|
||||||
|
|
|
@ -1317,8 +1317,7 @@ static void wpa_driver_ndis_poll_timeout(void *eloop_ctx, void *timeout_ctx)
|
||||||
|
|
||||||
if (wpa_driver_ndis_get_bssid(drv, bssid)) {
|
if (wpa_driver_ndis_get_bssid(drv, bssid)) {
|
||||||
/* Disconnected */
|
/* Disconnected */
|
||||||
if (os_memcmp(drv->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN)
|
if (!is_zero_ether_addr(drv->bssid)) {
|
||||||
!= 0) {
|
|
||||||
os_memset(drv->bssid, 0, ETH_ALEN);
|
os_memset(drv->bssid, 0, ETH_ALEN);
|
||||||
wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
|
wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -631,9 +631,8 @@ static void wpa_driver_wext_event_wireless(struct wpa_driver_wext_data *drv,
|
||||||
wpa_printf(MSG_DEBUG, "Wireless event: new AP: "
|
wpa_printf(MSG_DEBUG, "Wireless event: new AP: "
|
||||||
MACSTR,
|
MACSTR,
|
||||||
MAC2STR((u8 *) iwe->u.ap_addr.sa_data));
|
MAC2STR((u8 *) iwe->u.ap_addr.sa_data));
|
||||||
if (os_memcmp(iwe->u.ap_addr.sa_data,
|
if (is_zero_ether_addr(
|
||||||
"\x00\x00\x00\x00\x00\x00", ETH_ALEN) ==
|
(const u8 *) iwe->u.ap_addr.sa_data) ||
|
||||||
0 ||
|
|
||||||
os_memcmp(iwe->u.ap_addr.sa_data,
|
os_memcmp(iwe->u.ap_addr.sa_data,
|
||||||
"\x44\x44\x44\x44\x44\x44", ETH_ALEN) ==
|
"\x44\x44\x44\x44\x44\x44", ETH_ALEN) ==
|
||||||
0) {
|
0) {
|
||||||
|
|
|
@ -68,8 +68,7 @@ static void rsn_preauth_receive(void *ctx, const u8 *src_addr,
|
||||||
wpa_hexdump(MSG_MSGDUMP, "RX pre-auth", buf, len);
|
wpa_hexdump(MSG_MSGDUMP, "RX pre-auth", buf, len);
|
||||||
|
|
||||||
if (sm->preauth_eapol == NULL ||
|
if (sm->preauth_eapol == NULL ||
|
||||||
os_memcmp(sm->preauth_bssid, "\x00\x00\x00\x00\x00\x00",
|
is_zero_ether_addr(sm->preauth_bssid) ||
|
||||||
ETH_ALEN) == 0 ||
|
|
||||||
os_memcmp(sm->preauth_bssid, src_addr, ETH_ALEN) != 0) {
|
os_memcmp(sm->preauth_bssid, src_addr, ETH_ALEN) != 0) {
|
||||||
wpa_printf(MSG_WARNING, "RSN pre-auth frame received from "
|
wpa_printf(MSG_WARNING, "RSN pre-auth frame received from "
|
||||||
"unexpected source " MACSTR " - dropped",
|
"unexpected source " MACSTR " - dropped",
|
||||||
|
|
|
@ -98,8 +98,7 @@ void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck,
|
||||||
int ver, const u8 *dest, u16 proto,
|
int ver, const u8 *dest, u16 proto,
|
||||||
u8 *msg, size_t msg_len, u8 *key_mic)
|
u8 *msg, size_t msg_len, u8 *key_mic)
|
||||||
{
|
{
|
||||||
if (os_memcmp(dest, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0 &&
|
if (is_zero_ether_addr(dest) && is_zero_ether_addr(sm->bssid)) {
|
||||||
os_memcmp(sm->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0) {
|
|
||||||
/*
|
/*
|
||||||
* Association event was not yet received; try to fetch
|
* Association event was not yet received; try to fetch
|
||||||
* BSSID from the driver.
|
* BSSID from the driver.
|
||||||
|
|
|
@ -428,6 +428,10 @@ TCHAR * wpa_strdup_tchar(const char *str);
|
||||||
|
|
||||||
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
|
const char * wpa_ssid_txt(const u8 *ssid, size_t ssid_len);
|
||||||
|
|
||||||
|
static inline int is_zero_ether_addr(const u8 *a)
|
||||||
|
{
|
||||||
|
return !(a[0] | a[1] | a[2] | a[3] | a[4] | a[5]);
|
||||||
|
}
|
||||||
|
|
||||||
#include "wpa_debug.h"
|
#include "wpa_debug.h"
|
||||||
|
|
||||||
|
|
|
@ -330,9 +330,7 @@ static int wpa_supplicant_ctrl_iface_bssid(struct wpa_supplicant *wpa_s,
|
||||||
}
|
}
|
||||||
|
|
||||||
os_memcpy(ssid->bssid, bssid, ETH_ALEN);
|
os_memcpy(ssid->bssid, bssid, ETH_ALEN);
|
||||||
ssid->bssid_set =
|
ssid->bssid_set = !is_zero_ether_addr(bssid);
|
||||||
os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) != 0;
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -805,7 +805,7 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s)
|
||||||
if (wpa_s->wpa_state >= WPA_ASSOCIATED)
|
if (wpa_s->wpa_state >= WPA_ASSOCIATED)
|
||||||
wpa_supplicant_req_scan(wpa_s, 0, 100000);
|
wpa_supplicant_req_scan(wpa_s, 0, 100000);
|
||||||
bssid = wpa_s->bssid;
|
bssid = wpa_s->bssid;
|
||||||
if (os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
|
if (is_zero_ether_addr(bssid))
|
||||||
bssid = wpa_s->pending_bssid;
|
bssid = wpa_s->pending_bssid;
|
||||||
wpa_blacklist_add(wpa_s, bssid);
|
wpa_blacklist_add(wpa_s, bssid);
|
||||||
wpa_sm_notify_disassoc(wpa_s->wpa);
|
wpa_sm_notify_disassoc(wpa_s->wpa);
|
||||||
|
|
|
@ -2455,8 +2455,7 @@ int ieee80211_sta_associate(struct wpa_supplicant *wpa_s,
|
||||||
wpa_s->mlme.freq = params->freq;
|
wpa_s->mlme.freq = params->freq;
|
||||||
if (params->bssid) {
|
if (params->bssid) {
|
||||||
os_memcpy(wpa_s->bssid, params->bssid, ETH_ALEN);
|
os_memcpy(wpa_s->bssid, params->bssid, ETH_ALEN);
|
||||||
if (os_memcmp(params->bssid, "\x00\x00\x00\x00\x00\x00",
|
if (!is_zero_ether_addr(params->bssid))
|
||||||
ETH_ALEN))
|
|
||||||
wpa_s->mlme.bssid_set = 1;
|
wpa_s->mlme.bssid_set = 1;
|
||||||
bss = ieee80211_bss_get(wpa_s, wpa_s->bssid);
|
bss = ieee80211_bss_get(wpa_s, wpa_s->bssid);
|
||||||
if (bss) {
|
if (bss) {
|
||||||
|
|
|
@ -59,7 +59,6 @@ To do:
|
||||||
could very well be done before EAP has been started
|
could very well be done before EAP has been started
|
||||||
- try to work around race in receiving association event and first EAPOL
|
- try to work around race in receiving association event and first EAPOL
|
||||||
message
|
message
|
||||||
- helper function to do memcmp(addr, "\x00\x00\x00\x00\x00\x00", ETH_ALEN)
|
|
||||||
- add wpa_secure_memzero() macro and secure implementation (volatile u8*) to
|
- add wpa_secure_memzero() macro and secure implementation (volatile u8*) to
|
||||||
clear memory; this would be used to clear temporary buffers containing
|
clear memory; this would be used to clear temporary buffers containing
|
||||||
private data (e.g., keys); the macro can be defined to NOP in order to save
|
private data (e.g., keys); the macro can be defined to NOP in order to save
|
||||||
|
|
|
@ -187,7 +187,7 @@ static void wpa_supplicant_timeout(void *eloop_ctx, void *timeout_ctx)
|
||||||
{
|
{
|
||||||
struct wpa_supplicant *wpa_s = eloop_ctx;
|
struct wpa_supplicant *wpa_s = eloop_ctx;
|
||||||
const u8 *bssid = wpa_s->bssid;
|
const u8 *bssid = wpa_s->bssid;
|
||||||
if (os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
|
if (is_zero_ether_addr(bssid))
|
||||||
bssid = wpa_s->pending_bssid;
|
bssid = wpa_s->pending_bssid;
|
||||||
wpa_msg(wpa_s, MSG_INFO, "Authentication with " MACSTR " timed out.",
|
wpa_msg(wpa_s, MSG_INFO, "Authentication with " MACSTR " timed out.",
|
||||||
MAC2STR(bssid));
|
MAC2STR(bssid));
|
||||||
|
@ -1131,8 +1131,7 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
|
||||||
int reason_code)
|
int reason_code)
|
||||||
{
|
{
|
||||||
u8 *addr = NULL;
|
u8 *addr = NULL;
|
||||||
if (os_memcmp(wpa_s->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) != 0)
|
if (!is_zero_ether_addr(wpa_s->bssid)) {
|
||||||
{
|
|
||||||
if (wpa_s->use_client_mlme)
|
if (wpa_s->use_client_mlme)
|
||||||
ieee80211_sta_disassociate(wpa_s, reason_code);
|
ieee80211_sta_disassociate(wpa_s, reason_code);
|
||||||
else
|
else
|
||||||
|
@ -1160,8 +1159,7 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
|
||||||
{
|
{
|
||||||
u8 *addr = NULL;
|
u8 *addr = NULL;
|
||||||
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
|
wpa_supplicant_set_state(wpa_s, WPA_DISCONNECTED);
|
||||||
if (os_memcmp(wpa_s->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) != 0)
|
if (!is_zero_ether_addr(wpa_s->bssid)) {
|
||||||
{
|
|
||||||
if (wpa_s->use_client_mlme)
|
if (wpa_s->use_client_mlme)
|
||||||
ieee80211_sta_deauthenticate(wpa_s, reason_code);
|
ieee80211_sta_deauthenticate(wpa_s, reason_code);
|
||||||
else
|
else
|
||||||
|
|
|
@ -143,13 +143,11 @@ static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (os_memcmp(wpa_s->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
|
if (is_zero_ether_addr(wpa_s->bssid)) {
|
||||||
{
|
|
||||||
wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
|
wpa_printf(MSG_DEBUG, "BSSID not set when trying to send an "
|
||||||
"EAPOL frame");
|
"EAPOL frame");
|
||||||
if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
|
if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
|
||||||
os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) !=
|
!is_zero_ether_addr(bssid)) {
|
||||||
0) {
|
|
||||||
dst = bssid;
|
dst = bssid;
|
||||||
wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
|
wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
|
||||||
" from the driver as the EAPOL destination",
|
" from the driver as the EAPOL destination",
|
||||||
|
|
Loading…
Reference in a new issue