aboutsummaryrefslogtreecommitdiffstats
path: root/hostapd
diff options
context:
space:
mode:
authorNadim Zubidat <nadimz@ti.com>2012-11-05 11:18:26 +0800
committerArik Nemtsov <arik@wizery.com>2012-11-06 17:39:54 +0200
commit0e14818d3e4f9185d30638cb748c396c0f2b1efe (patch)
treefcea92ba7edce39da01c8cc4ea6df51d8dea38c4 /hostapd
parentfb634d7768b87e1174d2a21f4c899da3706432e8 (diff)
downloadexternal_wpa_supplicant_8_ti-0e14818d3e4f9185d30638cb748c396c0f2b1efe.zip
external_wpa_supplicant_8_ti-0e14818d3e4f9185d30638cb748c396c0f2b1efe.tar.gz
external_wpa_supplicant_8_ti-0e14818d3e4f9185d30638cb748c396c0f2b1efe.tar.bz2
hostapd: enable dynamic modification of acl policy
add APIs for dynamically changing the macaddr_acl policy and mac addresses lists. once changed, hostapd will deauth stations which do not pass the new policy. Signed-off-by: Nadim Zubidat <nadimz@ti.com>
Diffstat (limited to 'hostapd')
-rw-r--r--hostapd/config_file.c4
-rw-r--r--hostapd/config_file.h2
-rw-r--r--hostapd/ctrl_iface.c42
3 files changed, 46 insertions, 2 deletions
diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 59745fa..41dd242 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -116,8 +116,8 @@ static int hostapd_acl_comp(const void *a, const void *b)
}
-static int hostapd_config_read_maclist(const char *fname,
- struct mac_acl_entry **acl, int *num)
+int hostapd_config_read_maclist(const char *fname,
+ struct mac_acl_entry **acl, int *num)
{
FILE *f;
char buf[128], *pos;
diff --git a/hostapd/config_file.h b/hostapd/config_file.h
index fba57b8..61759f3 100644
--- a/hostapd/config_file.h
+++ b/hostapd/config_file.h
@@ -13,5 +13,7 @@ struct hostapd_config * hostapd_config_read(const char *fname);
int hostapd_set_iface(struct hostapd_config *conf,
struct hostapd_bss_config *bss, char *field,
char *value);
+int hostapd_config_read_maclist(const char *fname,
+ struct mac_acl_entry **acl, int *num);
#endif /* CONFIG_FILE_H */
diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
index 8f42f90..e6a8ced 100644
--- a/hostapd/ctrl_iface.c
+++ b/hostapd/ctrl_iface.c
@@ -514,6 +514,42 @@ static int hostapd_ctrl_iface_ess_disassoc(struct hostapd_data *hapd,
}
+static int hostapd_ctrl_iface_set_accept_mac(struct hostapd_data *hapd,
+ char *fname)
+{
+ hapd->conf->num_accept_mac = 0;
+
+ if (hostapd_config_read_maclist(fname, &hapd->conf->accept_mac,
+ &hapd->conf->num_accept_mac)) {
+ wpa_printf(MSG_ERROR, "Reading mac list from file failed");
+ return -1;
+ }
+
+ /* Accept mac list changed, check if need to deauth stations*/
+ hostapd_macaddr_acl_accept_sta(hapd);
+
+ return 0;
+}
+
+
+static int hostapd_ctrl_iface_set_deny_mac(struct hostapd_data *hapd,
+ char *fname)
+{
+ hapd->conf->num_deny_mac = 0;
+
+ if (hostapd_config_read_maclist(fname, &hapd->conf->deny_mac,
+ &hapd->conf->num_deny_mac)) {
+ wpa_printf(MSG_ERROR, "Reading mac list from file failed");
+ return -1;
+ }
+
+ /* Deny mac list changed, check if need to deauth stations*/
+ hostapd_macaddr_acl_deny_sta(hapd);
+
+ return 0;
+}
+
+
static int hostapd_ctrl_iface_get_config(struct hostapd_data *hapd,
char *buf, size_t buflen)
{
@@ -723,6 +759,12 @@ static int hostapd_ctrl_iface_set(struct hostapd_data *hapd, char *cmd)
else
hapd->gas_frag_limit = val;
#endif /* CONFIG_INTERWORKING */
+ } else if (os_strcasecmp(cmd, "macaddr_acl") == 0) {
+ ret = hostapd_macaddr_acl_command(hapd, value);
+ } else if (os_strcasecmp(cmd, "accept_mac_file") == 0) {
+ ret = hostapd_ctrl_iface_set_accept_mac(hapd, value);
+ } else if (os_strcasecmp(cmd, "deny_mac_file") == 0) {
+ ret = hostapd_ctrl_iface_set_deny_mac(hapd, value);
} else {
ret = hostapd_set_iface(hapd->iconf, hapd->conf, cmd, value);
}