From patchwork Mon Nov 28 12:11:41 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: 127968 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 D6BD4B6F90 for ; Mon, 28 Nov 2011 23:12:16 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7CD379C124; Mon, 28 Nov 2011 07:12:14 -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 eKz4eBQMvyuw; Mon, 28 Nov 2011 07:12:14 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id A03129C125; 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 DCA109C10E 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 oLADXI9QVsmc for ; Mon, 28 Nov 2011 07:11:27 -0500 (EST) Received: from ebb06.tieto.com (ebb06.tieto.com [131.207.168.38]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "ebb06.tieto.com", Issuer "VeriSign Class 3 Secure Server CA - G3" (not verified)) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 2FBDE9C115 for ; Mon, 28 Nov 2011 07:11:25 -0500 (EST) X-AuditID: 83cfa826-b7b5bae000001ca6-71-4ed37a6cb2d8 Received: from FIVLA-EXHUB02.eu.tieto.com ( [131.207.136.42]) by ebb06.tieto.com (SMTP Mailer) with SMTP id 7F.74.07334.C6A73DE4; Mon, 28 Nov 2011 14:11:24 +0200 (EET) Received: from EXMB01.eu.tieto.com ([131.207.136.90]) by FIVLA-EXHUB02.eu.tieto.com ([131.207.136.42]) with mapi; Mon, 28 Nov 2011 14:11:23 +0200 From: To: Date: Mon, 28 Nov 2011 14:11:41 +0200 Subject: [PATCH 3/4] P2P: use wpabuf when notif NOA change Thread-Topic: [PATCH 3/4] P2P: use wpabuf when notif NOA change Thread-Index: AcytxuMQWd9iVSlDTPObFofrPIBVPQ== Message-ID: <3078A9B976EF864C8DDD0C499FFD07911E3B76D9B2@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: AAAAAgPmCRAZdrPo 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 In case we build NOA attr via p2p_buf_add_noa() as a result we get wpabuf. Next it is much easier to use wpabuf also in p2p_group_notif_noa(). --- src/p2p/p2p.h | 4 +--- src/p2p/p2p_group.c | 11 ++++------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 1501a20..51a46c8 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1274,15 +1274,13 @@ void p2p_group_notif_formation_done(struct p2p_group *group); * p2p_group_notif_noa - Notification of NoA change * @group: P2P group context from p2p_group_init() * @noa: Notice of Absence attribute payload, %NULL if none - * @noa_len: Length of noa buffer in octets * Returns: 0 on success, -1 on failure * * Notify the P2P group management about a new NoA contents. This will be * inserted into the P2P IEs in Beacon and Probe Response frames with rest of * the group information. */ -int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, - size_t noa_len); +int p2p_group_notif_noa(struct p2p_group *group, struct wpabuf *noa); /** * p2p_group_match_dev_type - Match device types in group with requested type diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c index c34a92f..be5075a 100644 --- a/src/p2p/p2p_group.c +++ b/src/p2p/p2p_group.c @@ -169,8 +169,6 @@ static void p2p_group_add_noa(struct wpabuf *ie, struct wpabuf *noa) if (noa == NULL) return; /* Notice of Absence */ - wpabuf_put_u8(ie, P2P_ATTR_NOTICE_OF_ABSENCE); - wpabuf_put_le16(ie, wpabuf_len(noa)); wpabuf_put_buf(ie, noa); } @@ -500,17 +498,16 @@ void p2p_group_notif_formation_done(struct p2p_group *group) } -int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, - size_t noa_len) +int p2p_group_notif_noa(struct p2p_group *group, struct wpabuf *noa) { if (noa == NULL) { wpabuf_free(group->noa); group->noa = NULL; } else { if (group->noa) { - if (wpabuf_size(group->noa) >= noa_len) { + if (wpabuf_size(group->noa) >= wpabuf_len(noa)) { group->noa->used = 0; - wpabuf_put_data(group->noa, noa, noa_len); + wpabuf_put_buf(group->noa, noa); } else { wpabuf_free(group->noa); group->noa = NULL; @@ -518,7 +515,7 @@ int p2p_group_notif_noa(struct p2p_group *group, const u8 *noa, } if (!group->noa) { - group->noa = wpabuf_alloc_copy(noa, noa_len); + group->noa = wpabuf_dup(noa); if (group->noa == NULL) return -1; }