Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/hostapd/config_file.c b/hostapd/config_file.c
- index 32e3c49..f42186e 100644
- --- a/hostapd/config_file.c
- +++ b/hostapd/config_file.c
- @@ -109,7 +109,7 @@ static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
- #endif /* CONFIG_NO_VLAN */
- -static int hostapd_acl_comp(const void *a, const void *b)
- +int hostapd_acl_comp(const void *a, const void *b)
- {
- const struct mac_acl_entry *aa = a;
- const struct mac_acl_entry *bb = b;
- diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
- index 9ce7829..3986040 100644
- --- a/hostapd/ctrl_iface.c
- +++ b/hostapd/ctrl_iface.c
- @@ -1455,6 +1455,9 @@ static void hostapd_ctrl_iface_receive(int sock, void *eloop_ctx,
- } else if (os_strncmp(buf, "DISASSOCIATE ", 13) == 0) {
- if (hostapd_ctrl_iface_disassociate(hapd, buf + 13))
- reply_len = -1;
- + } else if (os_strncmp(buf, "BAN ", 4) == 0) {
- + if (hostapd_ctrl_iface_ban(hapd, buf + 4))
- + reply_len = -1;
- #ifdef CONFIG_IEEE80211W
- #ifdef NEED_AP_MLME
- } else if (os_strncmp(buf, "SA_QUERY ", 9) == 0) {
- diff --git a/hostapd/hostapd_cli.c b/hostapd/hostapd_cli.c
- index 09b7284..b0a7520 100644
- --- a/hostapd/hostapd_cli.c
- +++ b/hostapd/hostapd_cli.c
- @@ -64,6 +64,7 @@ static const char *commands_help =
- " new_sta <addr> add a new station\n"
- " deauthenticate <addr> deauthenticate a station\n"
- " disassociate <addr> disassociate a station\n"
- +" ban <addr> ban a station\n"
- #ifdef CONFIG_IEEE80211W
- " sa_query <addr> send SA Query to a station\n"
- #endif /* CONFIG_IEEE80211W */
- @@ -346,6 +347,23 @@ static int hostapd_cli_cmd_disassociate(struct wpa_ctrl *ctrl, int argc,
- }
- +static int hostapd_cli_cmd_ban(struct wpa_ctrl *ctrl, int argc,
- + char *argv[])
- +{
- + char buf[64];
- + if (argc < 1) {
- + printf("Invalid 'ban' command - exactly one "
- + "argument, STA address, is required.\n");
- + return -1;
- + }
- + if (argc > 1)
- + os_snprintf(buf, sizeof(buf), "BAN %s %s",
- + argv[0], argv[1]);
- + else
- + os_snprintf(buf, sizeof(buf), "BAN %s", argv[0]);
- + return wpa_ctrl_command(ctrl, buf);
- +}
- +
- #ifdef CONFIG_IEEE80211W
- static int hostapd_cli_cmd_sa_query(struct wpa_ctrl *ctrl, int argc,
- char *argv[])
- @@ -978,6 +996,7 @@ static struct hostapd_cli_cmd hostapd_cli_commands[] = {
- { "new_sta", hostapd_cli_cmd_new_sta },
- { "deauthenticate", hostapd_cli_cmd_deauthenticate },
- { "disassociate", hostapd_cli_cmd_disassociate },
- + { "ban", hostapd_cli_cmd_ban },
- #ifdef CONFIG_IEEE80211W
- { "sa_query", hostapd_cli_cmd_sa_query },
- #endif /* CONFIG_IEEE80211W */
- diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
- index 39edbd7..84bd589 100644
- --- a/src/ap/ctrl_iface_ap.c
- +++ b/src/ap/ctrl_iface_ap.c
- @@ -387,6 +387,33 @@ int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
- return 0;
- }
- +extern int hostapd_acl_comp(const void *a, const void *b);
- +
- +int hostapd_ctrl_iface_ban(struct hostapd_data *hapd,
- + const char *txtaddr)
- +{
- + u8 addr[ETH_ALEN];
- + struct mac_acl_entry *acl = hapd->conf->deny_mac;
- + int num_acl = hapd->conf->num_deny_mac + 1;
- +
- + wpa_dbg(hapd->msg_ctx, MSG_DEBUG, "CTRL_IFACE BAN %s",
- + txtaddr);
- +
- + if (hwaddr_aton(txtaddr, addr))
- + return -1;
- +
- + hapd->conf->macaddr_acl = 0;
- +
- + acl = os_realloc_array(acl, num_acl, sizeof(*acl));
- + os_memcpy(acl[num_acl - 1].addr, addr, ETH_ALEN);
- + acl[num_acl - 1].vlan_id = 0;
- + qsort(acl, num_acl, sizeof(*acl), hostapd_acl_comp);
- +
- + hapd->conf->deny_mac = acl;
- + hapd->conf->num_deny_mac = num_acl;
- +
- + return hostapd_ctrl_iface_disassociate(hapd, txtaddr);
- +}
- int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
- size_t buflen)
- diff --git a/src/ap/ctrl_iface_ap.h b/src/ap/ctrl_iface_ap.h
- index ee58b4c..5544b70 100644
- --- a/src/ap/ctrl_iface_ap.h
- +++ b/src/ap/ctrl_iface_ap.h
- @@ -19,6 +19,8 @@ int hostapd_ctrl_iface_deauthenticate(struct hostapd_data *hapd,
- const char *txtaddr);
- int hostapd_ctrl_iface_disassociate(struct hostapd_data *hapd,
- const char *txtaddr);
- +int hostapd_ctrl_iface_ban(struct hostapd_data *hapd,
- + const char *txtaddr);
- int hostapd_ctrl_iface_status(struct hostapd_data *hapd, char *buf,
- size_t buflen);
- int hostapd_parse_csa_settings(const char *pos,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement