From patchwork Fri Nov 4 10:38:04 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 123600 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 14A99B6F87 for ; Fri, 4 Nov 2011 21:43:16 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9B56F17C041; Fri, 4 Nov 2011 06:43:13 -0400 (EDT) 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 rB8-CPzYILOn; Fri, 4 Nov 2011 06:43:13 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 0FB099D23C; Fri, 4 Nov 2011 06:41:00 -0400 (EDT) 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 3D1469D228 for ; Fri, 4 Nov 2011 06:40:58 -0400 (EDT) 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 YmSa6CJSbkQK for ; Fri, 4 Nov 2011 06:40:53 -0400 (EDT) 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 9B0069D2E7 for ; Fri, 4 Nov 2011 06:39:57 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1RMHBk-0001I9-G5 for hostap@lists.shmoo.com; Fri, 04 Nov 2011 11:39:56 +0100 Message-Id: <20111104103812.394367400@sipsolutions.net> User-Agent: quilt/0.48-1 Date: Fri, 04 Nov 2011 11:38:04 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH 15/18] driver_nl80211: subscribe to spurious class3 frame events References: <20111104103749.617144560@sipsolutions.net> Content-Disposition: inline; filename=0015-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 a763bbe..3be461c 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -1735,6 +1735,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; @@ -1886,6 +1907,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); @@ -2665,6 +2689,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[] = { @@ -2696,6 +2749,9 @@ static int nl80211_mgmt_subscribe_ap(struct i802_bss *bss) } } + if (nl80211_register_spurious_class3(bss)) + goto out_err; + return 0; out_err: