From patchwork Mon Nov 28 12:11:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz.Dziedzic@tieto.com X-Patchwork-Id: 127967 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 40515B6F90 for ; Mon, 28 Nov 2011 23:12:00 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id E48979C0B2; Mon, 28 Nov 2011 07:11:57 -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 bSFoNVf6fj-W; Mon, 28 Nov 2011 07:11:57 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 175919C115; Mon, 28 Nov 2011 07:11:33 -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 7A66B9C121 for ; Mon, 28 Nov 2011 07:11:31 -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 kTt7edyJSWAC for ; Mon, 28 Nov 2011 07:11:26 -0500 (EST) 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 0989D9C10E for ; Mon, 28 Nov 2011 07:11:21 -0500 (EST) X-AuditID: 83cfa824-b7cebae0000004d2-06-4ed37a677323 Received: from FIHGA-EXHUB01.eu.tieto.com ( [131.207.136.34]) by ebb05.tieto.com (SMTP Mailer) with SMTP id 0A.53.01234.76A73DE4; Mon, 28 Nov 2011 14:11:19 +0200 (EET) Received: from EXMB01.eu.tieto.com ([131.207.136.90]) by FIHGA-EXHUB01.eu.tieto.com ([131.207.136.34]) with mapi; Mon, 28 Nov 2011 14:11:19 +0200 From: To: Date: Mon, 28 Nov 2011 14:11:36 +0200 Subject: [PATCH 2/4] P2P: Add Notice Of Absence interval param Thread-Topic: [PATCH 2/4] P2P: Add Notice Of Absence interval param Thread-Index: AcytxuBfqAujxBpoTguWJBt/CxwM4Q== Message-ID: <3078A9B976EF864C8DDD0C499FFD07911E3B76D9B1@EXMB01.eu.tieto.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: yes X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 X-Brightmail-Tracker: AAAAAQPmCRA= Cc: j@w1.fi, johannes@sipsolutions.net 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 NOA interval param is required during set_noa and NOA notification. --- src/ap/ap_drv_ops.c | 4 ++-- src/ap/ap_drv_ops.h | 2 +- src/ap/hostapd.h | 1 + src/ap/p2p_hostapd.c | 16 ++++++++++------ src/ap/p2p_hostapd.h | 2 +- src/drivers/driver.h | 4 +++- wpa_supplicant/ctrl_iface.c | 21 ++++++++++++++++----- wpa_supplicant/p2p_supplicant.c | 4 ++-- wpa_supplicant/p2p_supplicant.h | 2 +- 9 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c index 77d647b..161f411 100644 --- a/src/ap/ap_drv_ops.c +++ b/src/ap/ap_drv_ops.c @@ -549,11 +549,11 @@ struct wpa_scan_results * hostapd_driver_get_scan_results( int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start, - int duration) + int duration, int interval) { if (hapd->driver && hapd->driver->set_noa) return hapd->driver->set_noa(hapd->drv_priv, count, start, - duration); + duration, interval); return -1; } diff --git a/src/ap/ap_drv_ops.h b/src/ap/ap_drv_ops.h index c918a4a..6de375b 100644 --- a/src/ap/ap_drv_ops.h +++ b/src/ap/ap_drv_ops.h @@ -81,7 +81,7 @@ int hostapd_driver_scan(struct hostapd_data *hapd, struct wpa_scan_results * hostapd_driver_get_scan_results( struct hostapd_data *hapd); int hostapd_driver_set_noa(struct hostapd_data *hapd, u8 count, int start, - int duration); + int duration, int interval); int hostapd_drv_set_key(const char *ifname, struct hostapd_data *hapd, enum wpa_alg alg, const u8 *addr, diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h index 5401e80..a85aece 100644 --- a/src/ap/hostapd.h +++ b/src/ap/hostapd.h @@ -167,6 +167,7 @@ struct hostapd_data { int noa_enabled; int noa_start; int noa_duration; + int noa_interval; #endif /* CONFIG_P2P */ }; diff --git a/src/ap/p2p_hostapd.c b/src/ap/p2p_hostapd.c index 6f8b778..69137b8 100644 --- a/src/ap/p2p_hostapd.c +++ b/src/ap/p2p_hostapd.c @@ -37,31 +37,35 @@ int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, int hostapd_p2p_set_noa(struct hostapd_data *hapd, u8 count, int start, - int duration) + int duration, int interval) { wpa_printf(MSG_DEBUG, "P2P: Set NoA parameters: count=%u start=%d " - "duration=%d", count, start, duration); + "duration=%d interval=%d", count, start, duration, interval); if (count == 0) { hapd->noa_enabled = 0; hapd->noa_start = 0; hapd->noa_duration = 0; + hapd->noa_interval = 0; } if (count != 255) { wpa_printf(MSG_DEBUG, "P2P: Non-periodic NoA - set " "NoA parameters"); - return hostapd_driver_set_noa(hapd, count, start, duration); + return hostapd_driver_set_noa(hapd, count, start, + duration, interval); } hapd->noa_enabled = 1; hapd->noa_start = start; hapd->noa_duration = duration; + hapd->noa_interval = interval; if (hapd->num_sta_no_p2p == 0) { wpa_printf(MSG_DEBUG, "P2P: No legacy STAs connected - update " "periodic NoA parameters"); - return hostapd_driver_set_noa(hapd, count, start, duration); + return hostapd_driver_set_noa(hapd, count, start, + duration, interval); } wpa_printf(MSG_DEBUG, "P2P: Legacy STA(s) connected - do not enable " @@ -77,7 +81,7 @@ void hostapd_p2p_non_p2p_sta_connected(struct hostapd_data *hapd) if (hapd->noa_enabled) { wpa_printf(MSG_DEBUG, "P2P: Disable periodic NoA"); - hostapd_driver_set_noa(hapd, 0, 0, 0); + hostapd_driver_set_noa(hapd, 0, 0, 0, 0); } } @@ -89,7 +93,7 @@ void hostapd_p2p_non_p2p_sta_disconnected(struct hostapd_data *hapd) if (hapd->noa_enabled) { wpa_printf(MSG_DEBUG, "P2P: Enable periodic NoA"); hostapd_driver_set_noa(hapd, 255, hapd->noa_start, - hapd->noa_duration); + hapd->noa_duration, hapd->noa_interval); } } diff --git a/src/ap/p2p_hostapd.h b/src/ap/p2p_hostapd.h index 95b31d9..779c4a4 100644 --- a/src/ap/p2p_hostapd.h +++ b/src/ap/p2p_hostapd.h @@ -20,7 +20,7 @@ int hostapd_p2p_get_mib_sta(struct hostapd_data *hapd, struct sta_info *sta, char *buf, size_t buflen); int hostapd_p2p_set_noa(struct hostapd_data *hapd, u8 count, int start, - int duration); + int duration, int interval); void hostapd_p2p_non_p2p_sta_connected(struct hostapd_data *hapd); void hostapd_p2p_non_p2p_sta_disconnected(struct hostapd_data *hapd); diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 44127f4..3550cbe 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -2032,13 +2032,15 @@ struct wpa_driver_ops { * @count: Count * @start: Start time in ms from next TBTT * @duration: Duration in ms + * @interval: Interval in ms * Returns: 0 on success or -1 on failure * * This function is used to set Notice of Absence parameters for GO. It * is used only for testing. To disable NoA, all parameters are set to * 0. */ - int (*set_noa)(void *priv, u8 count, int start, int duration); + int (*set_noa)(void *priv, u8 count, int start, int duration, + int interval); /** * set_p2p_powersave - Set P2P power save options diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index b2789be..8d23029 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -2947,8 +2947,10 @@ static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd) if (os_strcmp(cmd, "noa") == 0) { char *pos; - int count, start, duration; - /* GO NoA parameters: count,start_offset(ms),duration(ms) */ + int count, start, duration, interval; + /* GO NoA parameters: + * count,start_offset(ms),duration(ms), interval(ms) + */ count = atoi(param); pos = os_strchr(param, ','); if (pos == NULL) @@ -2960,13 +2962,22 @@ static int p2p_ctrl_set(struct wpa_supplicant *wpa_s, char *cmd) return -1; pos++; duration = atoi(pos); - if (count < 0 || count > 255 || start < 0 || duration < 0) + pos = os_strchr(pos, ','); + if (pos == NULL) + return -1; + pos++; + interval = atoi(pos); + if (count < 0 || count > 255 || start < 0 || + duration < 0 || interval < 0) return -1; if (count == 0 && duration > 0) return -1; + if (interval < duration) + return -1; wpa_printf(MSG_DEBUG, "CTRL_IFACE: P2P_SET GO NoA: count=%d " - "start=%d duration=%d", count, start, duration); - return wpas_p2p_set_noa(wpa_s, count, start, duration); + "start=%d duration=%d interval=%d", count, start, + duration, interval); + return wpas_p2p_set_noa(wpa_s, count, start, duration, interval); } if (os_strcmp(cmd, "ps") == 0) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index c6484af..c82b7f8 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -3859,12 +3859,12 @@ void wpas_p2p_update_config(struct wpa_supplicant *wpa_s) int wpas_p2p_set_noa(struct wpa_supplicant *wpa_s, u8 count, int start, - int duration) + int duration, int interval) { if (!wpa_s->ap_iface) return -1; return hostapd_p2p_set_noa(wpa_s->ap_iface->bss[0], count, start, - duration); + duration, interval); } diff --git a/wpa_supplicant/p2p_supplicant.h b/wpa_supplicant/p2p_supplicant.h index 9a13f9f..3adb076 100644 --- a/wpa_supplicant/p2p_supplicant.h +++ b/wpa_supplicant/p2p_supplicant.h @@ -113,7 +113,7 @@ void wpas_p2p_disassoc_notif(struct wpa_supplicant *wpa_s, const u8 *bssid, u16 reason_code, const u8 *ie, size_t ie_len); void wpas_p2p_update_config(struct wpa_supplicant *wpa_s); int wpas_p2p_set_noa(struct wpa_supplicant *wpa_s, u8 count, int start, - int duration); + int duration, int interval); int wpas_p2p_set_cross_connect(struct wpa_supplicant *wpa_s, int enabled); void wpas_p2p_notif_connected(struct wpa_supplicant *wpa_s); void wpas_p2p_notif_disconnected(struct wpa_supplicant *wpa_s);