diff options
author | Jouni Malinen <jouni.malinen@atheros.com> | 2010-04-11 20:08:00 +0300 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2010-04-11 20:08:00 +0300 |
commit | f90ceeaabf8a00a84152195f6c1cacbfcaa2ca57 (patch) | |
tree | f994baa2a2b78d74b8f50fb864e165cd935a90e0 /wpa_supplicant/ap.c | |
parent | 48b357a989dcf7123f84461e164e66e37132f7bc (diff) | |
download | external_wpa_supplicant_8_ti-f90ceeaabf8a00a84152195f6c1cacbfcaa2ca57.zip external_wpa_supplicant_8_ti-f90ceeaabf8a00a84152195f6c1cacbfcaa2ca57.tar.gz external_wpa_supplicant_8_ti-f90ceeaabf8a00a84152195f6c1cacbfcaa2ca57.tar.bz2 |
wpa_supplicant AP mode: Add function for enabling MAC address filtering
This can be used to allow only a specific station to associate.
Diffstat (limited to 'wpa_supplicant/ap.c')
-rw-r--r-- | wpa_supplicant/ap.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/wpa_supplicant/ap.c b/wpa_supplicant/ap.c index 7621512..5d79503 100644 --- a/wpa_supplicant/ap.c +++ b/wpa_supplicant/ap.c @@ -414,3 +414,44 @@ int ap_ctrl_iface_wpa_get_status(struct wpa_supplicant *wpa_s, char *buf, } #endif /* CONFIG_CTRL_IFACE */ + + +int wpa_supplicant_ap_mac_addr_filter(struct wpa_supplicant *wpa_s, + const u8 *addr) +{ + struct hostapd_data *hapd; + struct hostapd_bss_config *conf; + + if (!wpa_s->ap_iface) + return -1; + + if (addr) + wpa_printf(MSG_DEBUG, "AP: Set MAC address filter: " MACSTR, + MAC2STR(addr)); + else + wpa_printf(MSG_DEBUG, "AP: Clear MAC address filter"); + + hapd = wpa_s->ap_iface->bss[0]; + conf = hapd->conf; + + os_free(conf->accept_mac); + conf->accept_mac = NULL; + conf->num_accept_mac = 0; + os_free(conf->deny_mac); + conf->deny_mac = NULL; + conf->num_deny_mac = 0; + + if (addr == NULL) { + conf->macaddr_acl = ACCEPT_UNLESS_DENIED; + return 0; + } + + conf->macaddr_acl = DENY_UNLESS_ACCEPTED; + conf->accept_mac = os_zalloc(sizeof(struct mac_acl_entry)); + if (conf->accept_mac == NULL) + return -1; + os_memcpy(conf->accept_mac[0].addr, addr, ETH_ALEN); + conf->num_accept_mac = 1; + + return 0; +} |