aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hostapd/config.c2
-rw-r--r--src/drivers/driver_ndis.c3
-rw-r--r--src/drivers/driver_wext.c5
-rw-r--r--src/rsn_supp/preauth.c3
-rw-r--r--src/rsn_supp/wpa.c3
-rw-r--r--src/utils/common.h4
-rw-r--r--wpa_supplicant/ctrl_iface.c4
-rw-r--r--wpa_supplicant/events.c2
-rw-r--r--wpa_supplicant/mlme.c3
-rw-r--r--wpa_supplicant/todo.txt1
-rw-r--r--wpa_supplicant/wpa_supplicant.c8
-rw-r--r--wpa_supplicant/wpas_glue.c6
12 files changed, 18 insertions, 26 deletions
diff --git a/hostapd/config.c b/hostapd/config.c
index 725e7ed..dd805c1 100644
--- a/hostapd/config.c
+++ b/hostapd/config.c
@@ -369,7 +369,7 @@ static int hostapd_config_read_wpa_psk(const char *fname,
ret = -1;
break;
}
- if (os_memcmp(addr, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0)
+ if (is_zero_ether_addr(addr))
psk->group = 1;
else
os_memcpy(psk->addr, addr, ETH_ALEN);
diff --git a/src/drivers/driver_ndis.c b/src/drivers/driver_ndis.c
index f306a52..baa95e6 100644
--- a/src/drivers/driver_ndis.c
+++ b/src/drivers/driver_ndis.c
@@ -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)) {
/* Disconnected */
- if (os_memcmp(drv->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN)
- != 0) {
+ if (!is_zero_ether_addr(drv->bssid)) {
os_memset(drv->bssid, 0, ETH_ALEN);
wpa_supplicant_event(drv->ctx, EVENT_DISASSOC, NULL);
}
diff --git a/src/drivers/driver_wext.c b/src/drivers/driver_wext.c
index efa88a8..1226b94 100644
--- a/src/drivers/driver_wext.c
+++ b/src/drivers/driver_wext.c
@@ -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: "
MACSTR,
MAC2STR((u8 *) iwe->u.ap_addr.sa_data));
- if (os_memcmp(iwe->u.ap_addr.sa_data,
- "\x00\x00\x00\x00\x00\x00", ETH_ALEN) ==
- 0 ||
+ if (is_zero_ether_addr(
+ (const u8 *) iwe->u.ap_addr.sa_data) ||
os_memcmp(iwe->u.ap_addr.sa_data,
"\x44\x44\x44\x44\x44\x44", ETH_ALEN) ==
0) {
diff --git a/src/rsn_supp/preauth.c b/src/rsn_supp/preauth.c
index e9bf7c6..7bc3c04 100644
--- a/src/rsn_supp/preauth.c
+++ b/src/rsn_supp/preauth.c
@@ -68,8 +68,7 @@ static void rsn_preauth_receive(void *ctx, const u8 *src_addr,
wpa_hexdump(MSG_MSGDUMP, "RX pre-auth", buf, len);
if (sm->preauth_eapol == NULL ||
- os_memcmp(sm->preauth_bssid, "\x00\x00\x00\x00\x00\x00",
- ETH_ALEN) == 0 ||
+ is_zero_ether_addr(sm->preauth_bssid) ||
os_memcmp(sm->preauth_bssid, src_addr, ETH_ALEN) != 0) {
wpa_printf(MSG_WARNING, "RSN pre-auth frame received from "
"unexpected source " MACSTR " - dropped",
diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index 1dada92..cb511e0 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -98,8 +98,7 @@ void wpa_eapol_key_send(struct wpa_sm *sm, const u8 *kck,
int ver, const u8 *dest, u16 proto,
u8 *msg, size_t msg_len, u8 *key_mic)
{
- if (os_memcmp(dest, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0 &&
- os_memcmp(sm->bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) == 0) {
+ if (is_zero_ether_addr(dest) && is_zero_ether_addr(sm->bssid)) {
/*
* Association event was not yet received; try to fetch
* BSSID from the driver.
diff --git a/src/utils/common.h b/src/utils/common.h
index d495a2e..d0a2eb3 100644
--- a/src/utils/common.h
+++ b/src/utils/common.h
@@ -428,6 +428,10 @@ TCHAR * wpa_strdup_tchar(const char *str);
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"
diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c
index 2e10f80..98ac08f 100644
--- a/wpa_supplicant/ctrl_iface.c
+++ b/wpa_supplicant/ctrl_iface.c
@@ -330,9 +330,7 @@ static int wpa_supplicant_ctrl_iface_bssid(struct wpa_supplicant *wpa_s,
}
os_memcpy(ssid->bssid, bssid, ETH_ALEN);
- ssid->bssid_set =
- os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) != 0;
-
+ ssid->bssid_set = !is_zero_ether_addr(bssid);
return 0;
}
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index ca559c8..66a98c2 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -805,7 +805,7 @@ static void wpa_supplicant_event_disassoc(struct wpa_supplicant *wpa_s)
if (wpa_s->wpa_state >= WPA_ASSOCIATED)
wpa_supplicant_req_scan(wpa_s, 0, 100000);
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;
wpa_blacklist_add(wpa_s, bssid);
wpa_sm_notify_disassoc(wpa_s->wpa);
diff --git a/wpa_supplicant/mlme.c b/wpa_supplicant/mlme.c
index 4d169e4..20f2701 100644
--- a/wpa_supplicant/mlme.c
+++ b/wpa_supplicant/mlme.c
@@ -2455,8 +2455,7 @@ int ieee80211_sta_associate(struct wpa_supplicant *wpa_s,
wpa_s->mlme.freq = params->freq;
if (params->bssid) {
os_memcpy(wpa_s->bssid, params->bssid, ETH_ALEN);
- if (os_memcmp(params->bssid, "\x00\x00\x00\x00\x00\x00",
- ETH_ALEN))
+ if (!is_zero_ether_addr(params->bssid))
wpa_s->mlme.bssid_set = 1;
bss = ieee80211_bss_get(wpa_s, wpa_s->bssid);
if (bss) {
diff --git a/wpa_supplicant/todo.txt b/wpa_supplicant/todo.txt
index e6487b0..a02a937 100644
--- a/wpa_supplicant/todo.txt
+++ b/wpa_supplicant/todo.txt
@@ -59,7 +59,6 @@ To do:
could very well be done before EAP has been started
- try to work around race in receiving association event and first EAPOL
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
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
diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c
index 9bd5435..5487212 100644
--- a/wpa_supplicant/wpa_supplicant.c
+++ b/wpa_supplicant/wpa_supplicant.c
@@ -187,7 +187,7 @@ static void wpa_supplicant_timeout(void *eloop_ctx, void *timeout_ctx)
{
struct wpa_supplicant *wpa_s = eloop_ctx;
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;
wpa_msg(wpa_s, MSG_INFO, "Authentication with " MACSTR " timed out.",
MAC2STR(bssid));
@@ -1131,8 +1131,7 @@ void wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s,
int reason_code)
{
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)
ieee80211_sta_disassociate(wpa_s, reason_code);
else
@@ -1160,8 +1159,7 @@ void wpa_supplicant_deauthenticate(struct wpa_supplicant *wpa_s,
{
u8 *addr = NULL;
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)
ieee80211_sta_deauthenticate(wpa_s, reason_code);
else
diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c
index 3a87d06..eb422cb 100644
--- a/wpa_supplicant/wpas_glue.c
+++ b/wpa_supplicant/wpas_glue.c
@@ -143,13 +143,11 @@ static int wpa_supplicant_eapol_send(void *ctx, int type, const u8 *buf,
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 "
"EAPOL frame");
if (wpa_drv_get_bssid(wpa_s, bssid) == 0 &&
- os_memcmp(bssid, "\x00\x00\x00\x00\x00\x00", ETH_ALEN) !=
- 0) {
+ !is_zero_ether_addr(bssid)) {
dst = bssid;
wpa_printf(MSG_DEBUG, "Using current BSSID " MACSTR
" from the driver as the EAPOL destination",