From patchwork Fri Nov 4 10:38:02 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 123598 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 4774BB6F87 for ; Fri, 4 Nov 2011 21:42:48 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id C79CB17C02F; Fri, 4 Nov 2011 06:42:45 -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 r1nSf70+9sxi; Fri, 4 Nov 2011 06:42:45 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 9130017C042; Fri, 4 Nov 2011 06:40:49 -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 21D5A9D2E1 for ; Fri, 4 Nov 2011 06:40:48 -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 HFwdUyEHsEfN for ; Fri, 4 Nov 2011 06:40:43 -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 2EB369D301 for ; Fri, 4 Nov 2011 06:39:50 -0400 (EDT) Received: by sipsolutions.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.77) (envelope-from ) id 1RMHBd-0001Hj-4x for hostap@lists.shmoo.com; Fri, 04 Nov 2011 11:39:49 +0100 Message-Id: <20111104103811.804081760@sipsolutions.net> User-Agent: quilt/0.48-1 Date: Fri, 04 Nov 2011 11:38:02 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH 13/18] driver_nl80211: allocate nl CB for BSS RX References: <20111104103749.617144560@sipsolutions.net> Content-Disposition: inline; filename=0013-driver_nl80211-allocate-nl-CB-for-BSS-RX.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 In preparation for things that receive on a BSS-specific handle, allocate a CB for it and hook it up to receive functions. Signed-hostap: Johannes Berg --- src/drivers/driver_nl80211.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index 6f6529c..c7c2801 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -211,6 +211,7 @@ struct i802_bss { int freq; struct nl80211_handles nl_preq; + struct nl_cb *nl_cb; }; struct wpa_driver_nl80211_data { @@ -1865,6 +1866,25 @@ static int process_drv_event(struct nl_msg *msg, void *arg) } +static int process_bss_event(struct nl_msg *msg, void *arg) +{ + struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); + struct nlattr *tb[NL80211_ATTR_MAX + 1]; + + nla_parse(tb, NL80211_ATTR_MAX, genlmsg_attrdata(gnlh, 0), + genlmsg_attrlen(gnlh, 0), NULL); + + switch (gnlh->cmd) { + default: + wpa_printf(MSG_DEBUG, "nl80211: Ignored unknown event " + "(cmd=%d)", gnlh->cmd); + break; + } + + return NL_SKIP; +} + + static void wpa_driver_nl80211_event_receive(int sock, void *eloop_ctx, void *handle) { @@ -2384,6 +2404,28 @@ static void wpa_driver_nl80211_handle_eapol_tx_status(int sock, void *eloop_ctx, } +static int nl80211_init_bss(struct i802_bss *bss) +{ + bss->nl_cb = nl_cb_alloc(NL_CB_DEFAULT); + if (!bss->nl_cb) + return -1; + + nl_cb_set(bss->nl_cb, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, + no_seq_check, NULL); + nl_cb_set(bss->nl_cb, NL_CB_VALID, NL_CB_CUSTOM, + process_bss_event, bss); + + return 0; +} + + +static void nl80211_destroy_bss(struct i802_bss *bss) +{ + nl_cb_put(bss->nl_cb); + bss->nl_cb = NULL; +} + + /** * wpa_driver_nl80211_init - Initialize nl80211 driver interface * @ctx: context to be used when calling wpa_supplicant functions, @@ -2416,6 +2458,9 @@ static void * wpa_driver_nl80211_init(void *ctx, const char *ifname, return NULL; } + if (nl80211_init_bss(bss)) + goto failed; + nl80211_get_phy_name(drv); rcfg = os_zalloc(sizeof(*rcfg)); @@ -2727,6 +2772,8 @@ static void wpa_driver_nl80211_deinit(void *priv) nl_destroy_handles(&drv->nl_event); nl_cb_put(drv->nl_cb); + nl80211_destroy_bss(&drv->first_bss); + os_free(drv->filter_ssids); if (drv->in_interface_list) @@ -6919,6 +6966,7 @@ static int wpa_driver_nl80211_if_add(void *priv, enum wpa_driver_if_type type, drv->first_bss.next = new_bss; if (drv_priv) *drv_priv = new_bss; + nl80211_init_bss(new_bss); } #endif /* HOSTAPD */ @@ -6970,6 +7018,7 @@ static int wpa_driver_nl80211_if_remove(void *priv, for (tbss = &drv->first_bss; tbss; tbss = tbss->next) { if (tbss->next == bss) { tbss->next = bss->next; + nl80211_destroy_bss(bss); os_free(bss); bss = NULL; break;