From patchwork Thu Jul 25 11:11:45 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 261669 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]) by ozlabs.org (Postfix) with ESMTP id E82B52C0096 for ; Thu, 25 Jul 2013 21:12:32 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2A85E9D2A2; Thu, 25 Jul 2013 07:12:28 -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 D7mBZ56gt3RA; Thu, 25 Jul 2013 07:12:27 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 94F539D2A3; Thu, 25 Jul 2013 07:12:07 -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 A6C5F9D29F for ; Thu, 25 Jul 2013 07:12:05 -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 CmfTf5ex4djT for ; Thu, 25 Jul 2013 07:11:59 -0400 (EDT) Received: from ebb05.tieto.com (ebb05.tieto.com [131.207.168.36]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "ebb05.tieto.com", Issuer "VeriSign Class 3 Secure Server CA - G3" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 162EC9D29B for ; Thu, 25 Jul 2013 07:11:58 -0400 (EDT) X-AuditID: 83cfa824-b7f2e6d000003d95-a4-51f107fc5433 Received: from FIHGA-EXHUB01.eu.tieto.com ( [131.207.136.34]) by ebb05.tieto.com (SMTP Mailer) with SMTP id C9.D6.15765.CF701F15; Thu, 25 Jul 2013 14:11:56 +0300 (EEST) Received: from uw001058.eu.tieto.com (10.28.19.57) by inbound.tieto.com (131.207.136.49) with Microsoft SMTP Server id 8.3.298.1; Thu, 25 Jul 2013 14:11:55 +0300 From: Michal Kazior To: Subject: [RFC 2/4] hostapd: Add offchannel support Date: Thu, 25 Jul 2013 13:11:45 +0200 Message-ID: <1374750707-8187-3-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1374750707-8187-1-git-send-email-michal.kazior@tieto.com> References: <1374750707-8187-1-git-send-email-michal.kazior@tieto.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrHIsWRmVeSWpSXmKPExsXSfL5DSfcP+8dAg0NLNC0WNT1gsvi29QGb A5PH55l32Tx2n9rHEsAUxWWTkpqTWZZapG+XwJVxf8tnloI5shWvJ5xnaWDcIt7FyMkhIWAi 0b17HTuELSZx4d56NhBbSGAVo8STu6YQ9lJGiRcnNUFsNgFdiVeNZ1lBbBEBGYmXm3+xgNjM AtoS7W+ug8WFBYwkXh2+CzaHRUBVYmL7NCYQm1fATaJzxy2geg6gXQoScybZgIQ5Bdwl3vZ0 s4OEhYBKZq5VhqgWlDg58wnUdAmJgy9eMENcoyJxcP1+5gmMArOQlM1CUraAkWkVI39qUpKB qV5JZmpJvl5yfu4mRnCwrVDZwXj2gdQhRgEORiUe3hXf3wcKsSaWFVfmHmKU5GBSEuU1Z/sY KMSXlJ9SmZFYnBFfVJqTWnyIUYKDWUmEN7biQ6AQb0piZVVqUT5MSpqDRUmc13D9vUAhgfTE ktTs1NSC1CKYrAwHh5IE7wmQoYJFqempFWmZOSUIaSYOTpDhPEDDJUBqeIsLEnOLM9Mh8qcY FaXEeS+DJARAEhmleXC9sGTwilEc6BVh3nMgVTzARALX/QpoMBPQYNeG9yCDSxIRUlINjMmM c97uc/bcdeIEN/vcgoibnkYWKz4lHfjlFOGzZf1+6bDfvW0R6zhZD5V/sNtyrmDpjsWFpseO GF/2uWjau/g/7zwljw2uAi1HP19zPLo/XvWNV82ha4cWBnpoHIqrP3Q0aynLwkq+8OZfMSu+ rLlX2NLafoC523OZdf3+bbeiFyTv/L2o8IYSS3FGoqEWc1FxIgAIb6zi4QIAAA== X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 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 Although unused at the moment, this will be used later by ACS code. Signed-hostap: Michal Kazior --- src/ap/ap_drv_ops.h | 11 ++++++++ src/ap/drv_callbacks.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ src/ap/hostapd.h | 4 +++ 3 files changed, 85 insertions(+) diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index cfc30ce..6d2b343 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -225,4 +225,15 @@ static inline void hostapd_drv_poll_client(struct hostapd_data *hapd, hapd->driver->poll_client(hapd->drv_priv, own_addr, addr, qos); } +static inline int hostapd_drv_remain_on_channel(struct hostapd_data *hapd, + unsigned int freq, + unsigned int duration) +{ + if (hapd->driver == NULL) + return -1; + if (!hapd->driver->remain_on_channel) + return -1; + return hapd->driver->remain_on_channel(hapd->drv_priv, freq, duration); +} + #endif /* AP_DRV_OPS */ diff --git a/src/ap/drv_callbacks.c b/src/ap/drv_callbacks.c index fa4b5e4..2851f4d 100644 --- a/src/ap/drv_callbacks.c +++ b/src/ap/drv_callbacks.c @@ -715,6 +715,68 @@ static void hostapd_event_eapol_rx(struct hostapd_data *hapd, const u8 *src, } +static int hostapd_roc_channel_check(struct hostapd_iface *iface) +{ + struct hostapd_channel_data *chan = NULL, *offchan; + int i; + int found = 0; + + offchan = &iface->current_mode->channels[iface->off_channel_freq_idx]; + + for (i = 0; i < iface->current_mode->num_channels; i++) { + chan = &iface->current_mode->channels[i]; + if (offchan != chan) + continue; + found = 1; + break; + } + + if (!found || !chan) { + wpa_printf(MSG_ERROR, "Channel requested to go offchannel " + "on freq %d MHz disappeared", + chan->freq); + goto fail; + } + + if (chan->flag & HOSTAPD_CHAN_DISABLED) { + wpa_printf(MSG_ERROR, "Channel requested to go offchannel " + "on freq %d MHz became disabled", + chan->freq); + goto fail; + } + + + return 0; +fail: + return -1; +} + + +static void hostapd_event_roc(struct hostapd_data *hapd, unsigned int freq, + unsigned int duration) +{ + struct hostapd_iface *iface = hapd->iface; + int err; + + err = hostapd_roc_channel_check(iface); + (void)err; + /* XXX: pass err to listeners, no one yet */ +} + + +static void hostapd_event_roc_cancel(struct hostapd_data *hapd, + unsigned int freq, + unsigned int duration) +{ + struct hostapd_iface *iface = hapd->iface; + int err; + + err = hostapd_roc_channel_check(iface); + (void)err; + /* XXX: pass err to listeners, no one yet */ +} + + void wpa_supplicant_event(void *ctx, enum wpa_event_type event, union wpa_event_data *data) { @@ -811,6 +873,14 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, data->eapol_rx.data, data->eapol_rx.data_len); break; + case EVENT_REMAIN_ON_CHANNEL: + hostapd_event_roc(hapd, data->remain_on_channel.freq, + data->remain_on_channel.duration); + break; + case EVENT_CANCEL_REMAIN_ON_CHANNEL: + hostapd_event_roc_cancel(hapd, data->remain_on_channel.freq, + data->remain_on_channel.duration); + break; case EVENT_ASSOC: hostapd_notif_assoc(hapd, data->assoc_info.addr, data->assoc_info.req_ies, diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index c0b1306..2fc2a04 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -280,6 +280,10 @@ struct hostapd_iface { int olbc_ht; u16 ht_op_mode; + + /* Offchannel operation helper */ + unsigned int off_channel_freq_idx; + void (*scan_cb)(struct hostapd_iface *iface); };