From patchwork Mon Jun 2 14:42:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Bursztyka X-Patchwork-Id: 354942 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 ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4AB20140083 for ; Tue, 3 Jun 2014 00:43:40 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 2C4F29D2E6; Mon, 2 Jun 2014 10:43:33 -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 nW+Ynd697Xol; Mon, 2 Jun 2014 10:43:32 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 90E029D2F3; Mon, 2 Jun 2014 10:42:38 -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 73AD99D2F0 for ; Mon, 2 Jun 2014 10:42:35 -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 HIM6FJd8z4zj for ; Mon, 2 Jun 2014 10:42:28 -0400 (EDT) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id CDFEA9D291 for ; Mon, 2 Jun 2014 10:42:17 -0400 (EDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 02 Jun 2014 07:42:17 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,957,1392192000"; d="scan'208";a="548530367" Received: from ldsaruwe-mobl.gar.corp.intel.com (HELO rd-190.ger.corp.intel.com) ([10.252.123.160]) by fmsmga002.fm.intel.com with ESMTP; 02 Jun 2014 07:42:15 -0700 From: Tomasz Bursztyka To: hostap@lists.shmoo.com Subject: [PATCH 2/7] p2p: Add a utility to run a callback on all available groups Date: Mon, 2 Jun 2014 17:42:03 +0300 Message-Id: <1401720128-3545-3-git-send-email-tomasz.bursztyka@linux.intel.com> X-Mailer: git-send-email 1.8.5.5 In-Reply-To: <1401720128-3545-1-git-send-email-tomasz.bursztyka@linux.intel.com> References: <1401720128-3545-1-git-send-email-tomasz.bursztyka@linux.intel.com> Cc: eduardoabinader@gmail.com 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: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com This will be useful in wpa_supplicant to match group's ssids against a specific one. Signed-off-by: Tomasz Bursztyka --- src/p2p/p2p.h | 13 +++++++++++++ src/p2p/p2p_group.c | 17 +++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/p2p/p2p.h b/src/p2p/p2p.h index 3c11a45..6c399a0 100644 --- a/src/p2p/p2p.h +++ b/src/p2p/p2p.h @@ -1800,6 +1800,19 @@ int p2p_group_is_client_connected(struct p2p_group *group, const u8 *dev_addr); const struct p2p_group_config *p2p_group_get_config(struct p2p_group *group); /** + * p2p_loop_on_all_group - Run the given callback on all groups + * @p2p: P2P module context from p2p_init() + * @group_callback: The callback function pointer + * @user_data: Some user data pointer which can be %NULL + * Returns: Once the group list has been entirely gone through or when the + * callback has returned 0. + */ +void p2p_loop_on_all_group(struct p2p_data *p2p, + int (*group_callback) (struct p2p_group *group, + void *user_data), + void *user_data); + +/** * p2p_get_peer_found - Get P2P peer info structure of a found peer * @p2p: P2P module context from p2p_init() * @addr: P2P Device Address of the peer or %NULL to indicate the first peer diff --git a/src/p2p/p2p_group.c b/src/p2p/p2p_group.c index 07ce655..2f8565b 100644 --- a/src/p2p/p2p_group.c +++ b/src/p2p/p2p_group.c @@ -1019,3 +1019,20 @@ const struct p2p_group_config *p2p_group_get_config(struct p2p_group *group) { return group->cfg; } + + +void p2p_loop_on_all_group(struct p2p_data *p2p, + int (*group_callback) (struct p2p_group *, + void *), + void *user_data) +{ + int i; + + if (group_callback == NULL) + return; + + for (i = 0; i < p2p->num_groups; i++) { + if (!group_callback(p2p->groups[i], user_data)) + break; + } +}