From patchwork Sat Nov 19 12:39:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 126577 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "maxx.shmoo.com", Issuer "CA Cert Signing Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C8FF7B722D for ; Sat, 19 Nov 2011 23:43:49 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 75E219C2E5; Sat, 19 Nov 2011 07:43:47 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZJAg9LyTEhYz; Sat, 19 Nov 2011 07:43:47 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 078BA9D210; Sat, 19 Nov 2011 07:42:05 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 0CBC89D210 for ; Sat, 19 Nov 2011 07:42:03 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3yLldFvhaVhA for ; Sat, 19 Nov 2011 07:41:59 -0500 (EST) Received: from sipsolutions.net (he.sipsolutions.net [78.46.109.217]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 932939CD9E for ; Sat, 19 Nov 2011 07:41:20 -0500 (EST) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1RRkER-0002cf-Hf for hostap@lists.shmoo.com; Sat, 19 Nov 2011 13:41:19 +0100 Message-Id: <20111119123952.689550679@sipsolutions.net> User-Agent: quilt/0.48-1 Date: Sat, 19 Nov 2011 13:39:21 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH v3 11/15] driver_nl80211: subscribe to spurious class3 frame events References: <20111119123910.783418920@sipsolutions.net> Content-Disposition: inline; filename=0011-driver_nl80211-subscribe-to-spurious-class3-frame-ev.patch Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg These events are necessary to send deauth frames to stations sending spurious data frames. Subscribe to them on the per-BSS event socket. Signed-hostap: Johannes Berg --- src/drivers/driver_nl80211.c | 56 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 985d161..8d67dd8 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -1716,6 +1716,27 @@ static void nl80211_client_probe_event(struct wpa_driver_nl80211_data *drv, } +static void nl80211_spurious_class3_frame(struct i802_bss *bss, + struct nlattr **tb) +{ + struct wpa_driver_nl80211_data *drv = bss->drv; + union wpa_event_data event; + u8 bssid[ETH_ALEN]; + + if (!tb[NL80211_ATTR_MAC]) + return; + + if (linux_get_ifhwaddr(drv->global->ioctl_sock, bss->ifname, bssid) < 0) + return; + + os_memset(&event, 0, sizeof(event)); + event.rx_from_unknown.bssid = bssid; + event.rx_from_unknown.addr = nla_data(tb[NL80211_ATTR_MAC]); + + wpa_supplicant_event(drv->ctx, EVENT_RX_FROM_UNKNOWN, &event); +} + + static int process_drv_event(struct nl_msg *msg, void *arg) { struct wpa_driver_nl80211_data *drv = arg; @@ -1867,6 +1888,9 @@ static int process_bss_event(struct nl_msg *msg, void *arg) tb[NL80211_ATTR_WIPHY_FREQ], tb[NL80211_ATTR_ACK], tb[NL80211_ATTR_COOKIE]); break; + case NL80211_CMD_UNEXPECTED_FRAME: + nl80211_spurious_class3_frame(bss, tb); + break; default: wpa_printf(MSG_DEBUG, "nl80211: Ignored unknown event " "(cmd=%d)", gnlh->cmd); @@ -2648,6 +2672,35 @@ static int nl80211_mgmt_subscribe_non_ap(struct i802_bss *bss) } +static int nl80211_register_spurious_class3(struct i802_bss *bss) +{ + struct wpa_driver_nl80211_data *drv = bss->drv; + struct nl_msg *msg; + int ret = -1; + + msg = nlmsg_alloc(); + if (!msg) + return -1; + + nl80211_cmd(drv, msg, 0, NL80211_CMD_UNEXPECTED_FRAME); + + NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, bss->ifindex); + + ret = send_and_recv(drv, bss->nl_mgmt.handle, msg, NULL, NULL); + msg = NULL; + if (ret) { + wpa_printf(MSG_DEBUG, "nl80211: Register spurious class3 " + "failed: ret=%d (%s)", + ret, strerror(-ret)); + goto nla_put_failure; + } + ret = 0; +nla_put_failure: + nlmsg_free(msg); + return ret; +} + + static int nl80211_mgmt_subscribe_ap(struct i802_bss *bss) { static const int stypes[] = { @@ -2679,6 +2732,9 @@ static int nl80211_mgmt_subscribe_ap(struct i802_bss *bss) } } + if (nl80211_register_spurious_class3(bss)) + goto out_err; + return 0; out_err: