aboutsummaryrefslogtreecommitdiffstats
path: root/wpa_supplicant/events.c
diff options
context:
space:
mode:
authorStefan Tomanek <stefan.tomanek@wertarbyte.de>2015-01-05 20:10:16 (GMT)
committerJouni Malinen <j@w1.fi>2015-01-10 15:35:53 (GMT)
commit79cd993a623e101952b81fa6a29c674cd858504f (patch)
treef1ff8efd459085ee332c411b8f87eb48bda96a4e /wpa_supplicant/events.c
parentb83e455451a875ba233b3b8ac29aff8b62f064f2 (diff)
downloadhostap-79cd993a623e101952b81fa6a29c674cd858504f.zip
hostap-79cd993a623e101952b81fa6a29c674cd858504f.tar.gz
hostap-79cd993a623e101952b81fa6a29c674cd858504f.tar.bz2
Add address masks to BSSID lists
In many applications it is useful not just to enumerate a group of well known access points, but to use a address/mask notation to match an entire set of addresses (ca:ff:ee:00:00:00/ff:ff:ff:00:00:00). This change expands the data structures used by MAC lists to include a mask indicating the significant (non-masked) portions of an address and extends the list parser to recognize mask suffixes. Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
Diffstat (limited to 'wpa_supplicant/events.c')
-rw-r--r--wpa_supplicant/events.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c
index 4dd9bc6..0e78ea2 100644
--- a/wpa_supplicant/events.c
+++ b/wpa_supplicant/events.c
@@ -698,14 +698,27 @@ static int bss_is_ess(struct wpa_bss *bss)
}
+static int match_mac_mask(const u8 *addr_a, const u8 *addr_b, const u8 *mask)
+{
+ size_t i;
+
+ for (i = 0; i < ETH_ALEN; i++) {
+ if ((addr_a[i] & mask[i]) != (addr_b[i] & mask[i]))
+ return 0;
+ }
+ return 1;
+}
+
+
static int addr_in_list(const u8 *addr, const u8 *list, size_t num)
{
size_t i;
for (i = 0; i < num; i++) {
- const u8 *a = list + (i * ETH_ALEN);
+ const u8 *a = list + i * ETH_ALEN * 2;
+ const u8 *m = a + ETH_ALEN;
- if (os_memcmp(a, addr, ETH_ALEN) == 0)
+ if (match_mac_mask(a, addr, m))
return 1;
}
return 0;