Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.0/patches/2218834/?format=api
{ "id": 2218834, "url": "http://patchwork.ozlabs.org/api/1.0/patches/2218834/?format=api", "project": { "id": 22, "url": "http://patchwork.ozlabs.org/api/1.0/projects/22/?format=api", "name": "HostAP Development", "link_name": "hostap", "list_id": "hostap.lists.infradead.org", "list_email": "hostap@lists.infradead.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260401220220.4418-43-andrei.otcheretianski@intel.com>", "date": "2026-04-01T22:01:51", "name": "[42/71] NAN: Move some functions to nan_util.c", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "c47d01528c6e0d0368b7401a3c3b7a92a5928e65", "submitter": { "id": 62065, "url": "http://patchwork.ozlabs.org/api/1.0/people/62065/?format=api", "name": "Andrei Otcheretianski", "email": "andrei.otcheretianski@intel.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/hostap/patch/20260401220220.4418-43-andrei.otcheretianski@intel.com/mbox/", "series": [ { "id": 498402, "url": "http://patchwork.ozlabs.org/api/1.0/series/498402/?format=api", "date": "2026-04-01T22:01:09", "name": "NAN Data Path and Bootstrapping support", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/498402/mbox/" } ], "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2218834/checks/", "tags": {}, "headers": { "Return-Path": "\n <hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Ehd1x0BG;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256\n header.s=Intel header.b=XiD8Ocpq;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fmJzM6YQTz1yFv\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 02 Apr 2026 09:08:47 +1100 (AEDT)", "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w83jI-0000000GDNt-1FUo;\n\tWed, 01 Apr 2026 22:08:04 +0000", "from mgamail.intel.com ([198.175.65.20])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1w83hM-0000000G9is-0tG1\n\tfor hostap@lists.infradead.org;\n\tWed, 01 Apr 2026 22:06:09 +0000", "from fmviesa003.fm.intel.com ([10.60.135.143])\n by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 01 Apr 2026 15:05:57 -0700", "from iapp347.iil.intel.com (HELO 87c02287900a.iil.intel.com)\n ([10.167.28.6])\n by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 01 Apr 2026 15:05:56 -0700" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:\n\tContent-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post:\n\tList-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=7eb+YYltLxcx7cnJ/wOJmZzhP682r5sjvdreHc/nels=; b=Ehd1x0BGysF1s3\n\txSo90oL5rjcYuf0/CWgppHnE1HNc5N3adj1auj4xO1UK+Gp4dwvQa+W5+s0zB6vN075yoF1PweJWN\n\tgVaIYWRR2YHBUoYD7HC8IQqFmYu9Rt9BUd/cl2jZ5m25Ne6S3iRTpttHnU1nHQNhN1FZHC34p4aDm\n\tNdf3IGeo8RFmCmPWVRUah8se2/Ct6TNUDStCvXsAZsQ54lmEI9QlgQKGJgyLXJsUTSVUak+bL1k7F\n\t6D3Mbi0F+qxcqOY4nnZFs4KMNye4LauVKCWv8AhXnfWDKlAHRvrOf6s6rMuAF11kBT7d3E4rjQ+65\n\tDPwzs5Db/omdOZyfkkMA==;", "v=1; a=rsa-sha256; c=relaxed/simple;\n d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n t=1775081164; x=1806617164;\n h=from:to:subject:date:message-id:in-reply-to:references:\n mime-version:content-transfer-encoding;\n bh=C6/oCgYOsWdD4hl3OrdtvbGuODiYebE5mbKly/hdbvw=;\n b=XiD8OcpqHeNwcyufCSvTSB6hfCGjt3eiFTiWCt0KvjYtbOQ8MoUZehR7\n k9rmVp1spGnqtZ8WkV2Q4biBi1WxLzC0eh31zoIiASUiwMxqRkmJGDTSn\n ac/jxWgH9AfUaD/NYH2gyU2zcUlUUE/JTRDc2k0kxSAJLmlxOOmi+UG2P\n G0Z+us5vZyWnPkyezVUFP/dIlX5qxW43MpuIwFck94lriHjjkBgGcnRyS\n yUIREbrDB0So7GfGXvU3lqR9csp+34gXeBa0BoiO9TqSBeTfTcnNfsHvH\n 4U5woX9r21eJnmkNC78VS7cnvL0noRcHXyiSq86aYOrDMRR6BDZMUlqev\n w==;" ], "X-CSE-ConnectionGUID": [ "p1Bm/bphT3yLSzsvDmUe0A==", "sDVSrta0Qpm+mJkuiwZX0w==" ], "X-CSE-MsgGUID": [ "0z9gQQfCQuSwiCGsFkfJHA==", "ym8oWD33RYeOclqfyU9yMw==" ], "X-IronPort-AV": [ "E=McAfee;i=\"6800,10657,11746\"; a=\"75851634\"", "E=Sophos;i=\"6.23,153,1770624000\";\n d=\"scan'208\";a=\"75851634\"" ], "X-ExtLoop1": "1", "From": "Andrei Otcheretianski <andrei.otcheretianski@intel.com>", "To": "hostap@lists.infradead.org", "Subject": "[PATCH 42/71] NAN: Move some functions to nan_util.c", "Date": "Thu, 2 Apr 2026 01:01:51 +0300", "Message-ID": "<20260401220220.4418-43-andrei.otcheretianski@intel.com>", "X-Mailer": "git-send-email 2.53.0", "In-Reply-To": "<20260401220220.4418-1-andrei.otcheretianski@intel.com>", "References": "<20260401220220.4418-1-andrei.otcheretianski@intel.com>", "MIME-Version": "1.0", "X-CRM114-Version": "20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ", "X-CRM114-CacheID": "sfid-20260401_150604_489968_C5AF1E36 ", "X-CRM114-Status": "GOOD ( 21.37 )", "X-Spam-Score": "-1.9 (-)", "X-Spam-Report": "Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam. The original\n message has been attached to this so you can view it or label\n similar future email. If you have any questions, see\n the administrator of that system for details.\n Content preview: From: Avraham Stern <avraham.stern@intel.com> Move the\n function\n to check if a peer schedule intersects with the local schedule and the\n function\n to convert a channel schedule to abitfield from nan_ndl.c to nan_util.c as\n these functions are not NDP [...]\n Content analysis details: (-1.9 points, 5.0 required)\n pts rule name description\n ---- ----------------------\n --------------------------------------------------\n -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at https://www.dnswl.org/,\n medium trust\n [198.175.65.20 listed in list.dnswl.org]\n 1.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to\n Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [198.175.65.20 listed in\n bl.score.senderscore.com]\n 1.0 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED RBL: ADMINISTRATOR NOTICE: The\n query to Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [198.175.65.20 listed in\n sa-trusted.bondedsender.org]\n 1.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to\n Validity was blocked. See\n https://knowledge.validity.com/hc/en-us/articles/20961730681243\n for more information.\n [198.175.65.20 listed in sa-accredit.habeas.com]\n 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record\n -0.0 SPF_PASS SPF: sender matches SPF record\n 0.1 DKIM_SIGNED Message has a DKIM or DK signature,\n not necessarily valid\n -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from\n envelope-from domain\n -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from\n author's\n domain\n -0.1 DKIM_VALID Message has at least one valid DKIM or DK\n signature\n -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1%\n [score: 0.0000]\n -0.5 DKIMWL_WL_HIGH DKIMwl.org - High trust sender", "X-BeenThere": "hostap@lists.infradead.org", "X-Mailman-Version": "2.1.34", "Precedence": "list", "List-Id": "<hostap.lists.infradead.org>", "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/hostap>,\n <mailto:hostap-request@lists.infradead.org?subject=unsubscribe>", "List-Archive": "<http://lists.infradead.org/pipermail/hostap/>", "List-Post": "<mailto:hostap@lists.infradead.org>", "List-Help": "<mailto:hostap-request@lists.infradead.org?subject=help>", "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/hostap>,\n <mailto:hostap-request@lists.infradead.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "\"Hostap\" <hostap-bounces@lists.infradead.org>", "Errors-To": "hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org" }, "content": "From: Avraham Stern <avraham.stern@intel.com>\n\nMove the function to check if a peer schedule intersects with the\nlocal schedule and the function to convert a channel schedule to\nabitfield from nan_ndl.c to nan_util.c as these functions are not\nNDP related.\n\nSigned-off-by: Avraham Stern <avraham.stern@intel.com>\n---\n src/nan/nan.c | 8 ++-\n src/nan/nan_i.h | 9 ++-\n src/nan/nan_ndl.c | 149 +--------------------------------------------\n src/nan/nan_util.c | 134 ++++++++++++++++++++++++++++++++++++++++\n 4 files changed, 151 insertions(+), 149 deletions(-)", "diff": "diff --git a/src/nan/nan.c b/src/nan/nan.c\nindex bc497f1377..22d321ad17 100644\n--- a/src/nan/nan.c\n+++ b/src/nan/nan.c\n@@ -1201,7 +1201,13 @@ static int nan_configure_peer_schedule(struct nan_data *nan,\n \n \twpa_printf(MSG_DEBUG, \"NAN: Configure peer schedule\");\n \n-\tif (!nan_ndl_peer_schedule_intersects(nan, peer)) {\n+\tif (!peer->ndl) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t \"NAN: Cannot configure peer NMI STA - no schedule\");\n+\t\treturn 0;\n+\t}\n+\n+\tif (!nan_peer_schedule_intersects(nan, peer, &peer->ndl->sched)) {\n \t\twpa_printf(MSG_DEBUG,\n \t\t\t \"NAN: Cannot configure peer NMI STA - no intersecting schedule\");\n \t\treturn 0;\ndiff --git a/src/nan/nan_i.h b/src/nan/nan_i.h\nindex ef062c08b1..16dabada7d 100644\n--- a/src/nan/nan_i.h\n+++ b/src/nan/nan_i.h\n@@ -14,6 +14,7 @@\n #include \"common/nan_defs.h\"\n #include \"common/wpa_common.h\"\n #include \"nan.h\"\n+#include \"bitfield.h\"\n \n struct nan_config;\n \n@@ -567,8 +568,12 @@ int nan_ndl_add_avail_attrs(struct nan_data *nan, const struct nan_peer *peer,\n void nan_ndl_add_elem_container_attr(const struct nan_data *nan,\n \t\t\t\t const struct nan_peer *peer,\n \t\t\t\t struct wpabuf *buf);\n-bool nan_ndl_peer_schedule_intersects(struct nan_data *nan,\n-\t\t\t\t struct nan_peer *peer);\n+bool nan_peer_schedule_intersects(struct nan_data *nan, struct nan_peer *peer,\n+\t\t\t\t struct nan_schedule *sched);\n+int nan_convert_chan_sched_to_bf(struct nan_data *nan,\n+\t\t\t\t struct nan_chan_schedule *chan,\n+\t\t\t\t struct bitfield **avail_bf, u8 *map_id,\n+\t\t\t\t u8 *op_class, u16 *cbm, u16 *pcbm);\n int nan_get_chan_bm(struct nan_data *nan, const struct nan_sched_chan *chan,\n \t\t u8 *op_class, u16 *chan_bm, u16 *pri_chan_bm);\n int nan_add_avail_attrs(struct nan_data *nan, u8 sequence_id,\ndiff --git a/src/nan/nan_ndl.c b/src/nan/nan_ndl.c\nindex 701aed18e0..aa0a8137e6 100644\n--- a/src/nan/nan_ndl.c\n+++ b/src/nan/nan_ndl.c\n@@ -232,74 +232,6 @@ static bool nan_ndl_validate_peer_avail(struct nan_data *nan,\n }\n \n \n-/**\n- * nan_ndl_convert_chan_sched_to_bf - Convert channel schedule to bitfield\n- * and get the channel information.\n- *\n- * @nan: NAN module context from nan_init()\n- * @chan: Channel schedule to convert\n- * @avail_bf: On successful return holds the availability bitmap of the given\n- * channel schedule\n- * @map_id: On successful return holds the map ID for the schedule\n- * @op_class: On successful return holds the operating class for the schedule\n- * with the peer\n- * @cbm: On successful return holds the channel bitmap for the operating class\n- * @pcbm: On successful return holds the primary channel bitmap for the\n- * channel in case of bandwidth greater than 40 MHz\n- * Returns: 0 on success; -1 on failure\n- */\n-static int nan_ndl_convert_chan_sched_to_bf(struct nan_data *nan,\n-\t\t\t\t\t struct nan_chan_schedule *chan,\n-\t\t\t\t\t struct bitfield **avail_bf,\n-\t\t\t\t\t u8 *map_id, u8 *op_class,\n-\t\t\t\t\t u16 *cbm, u16 *pcbm)\n-{\n-\tstruct bitfield *committed_bf, *conditional_bf;\n-\tint ret;\n-\n-\t*op_class = 0;\n-\t*cbm = 0;\n-\t*pcbm = 0;\n-\t*map_id = chan->map_id;\n-\n-\tret = nan_get_chan_bm(nan, &chan->chan, op_class, cbm, pcbm);\n-\tif (ret) {\n-\t\twpa_printf(MSG_DEBUG,\n-\t\t\t \"NAN: NDL: Failed to convert channel info\");\n-\t\treturn -1;\n-\t}\n-\n-\tcommitted_bf = nan_tbm_to_bf(nan, &chan->committed);\n-\tif (!committed_bf) {\n-\t\twpa_printf(MSG_DEBUG,\n-\t\t\t \"NAN: NDL: Failed to build committed bitfield\");\n-\t\treturn -1;\n-\t}\n-\n-\tconditional_bf = nan_tbm_to_bf(nan, &chan->conditional);\n-\tif (!conditional_bf) {\n-\t\twpa_printf(MSG_DEBUG,\n-\t\t\t \"NAN: NDL: Failed to build conditional bitfield\");\n-\t\tbitfield_free(committed_bf);\n-\t\treturn -1;\n-\t}\n-\n-\t*avail_bf = bitfield_union(committed_bf, conditional_bf);\n-\tbitfield_free(committed_bf);\n-\tbitfield_free(conditional_bf);\n-\n-\tif (!*avail_bf) {\n-\t\twpa_printf(MSG_DEBUG,\n-\t\t\t \"NAN: NDL: Failed to unify committed and conditional bitfields\");\n-\t\treturn -1;\n-\t}\n-\n-\twpa_printf(MSG_DEBUG, \"NAN: NDL: map_id=%u, op_class=%u, cbm=0x%x\",\n-\t\t *map_id, *op_class, *cbm);\n-\treturn 0;\n-}\n-\n-\n /**\n * enum nan_ndl_ver - Verdict of comparing local availability to given schedule\n * @NAN_NDL_VER_SCHED_SUBSET_OF_LOCAL: The schedule is a subset of the local one\n@@ -463,10 +395,9 @@ static enum nan_ndl_status nan_ndl_determine_status(struct nan_data *nan,\n \t\tu8 map_id, op_class;\n \n \t\t/* Convert the schedule for the current channel to bitfield */\n-\t\tret = nan_ndl_convert_chan_sched_to_bf(nan, &sched->chans[i],\n-\t\t\t\t\t\t &own_chan_bf, &map_id,\n-\t\t\t\t\t\t &op_class, &cbm,\n-\t\t\t\t\t\t &pri_cbm);\n+\t\tret = nan_convert_chan_sched_to_bf(nan, &sched->chans[i],\n+\t\t\t\t\t\t &own_chan_bf, &map_id,\n+\t\t\t\t\t\t &op_class, &cbm, &pri_cbm);\n \t\tif (ret) {\n \t\t\twpa_printf(MSG_DEBUG,\n \t\t\t\t \"NAN: NDL: Failed to convert chan sched to bitfield\");\n@@ -1758,77 +1689,3 @@ void nan_ndl_add_elem_container_attr(const struct nan_data *nan,\n \twpabuf_put_u8(buf, 0);\n \twpabuf_put_buf(buf, ndl->sched.elems);\n }\n-\n-\n-/*\n- * nan_ndl_peer_schedule_intersects - Check if local and peer schedules\n- * intersect\n- *\n- * @nan: NAN module context from nan_init()\n- * @peer: The peer with whom the NDL is being setup\n- * Returns: True if schedules intersect, false otherwise\n- *\n- * The function checks if the local device schedule intersects with the peer\n- * device schedule.\n- */\n-bool nan_ndl_peer_schedule_intersects(struct nan_data *nan,\n-\t\t\t\t struct nan_peer *peer)\n-{\n-\tstruct nan_schedule *sched;\n-\tsize_t i;\n-\n-\tif (!peer->ndl)\n-\t\treturn false;\n-\n-\tsched = &peer->ndl->sched;\n-\n-\t/*\n-\t * Iterate over all the channels included in the local schedule. For\n-\t * each channel convert the committed and conditional slots to a\n-\t * bitfield object and extract the operating class and channel bitmap.\n-\t *\n-\t * Using the operating class and channel bitmap find the peer\n-\t * availability on that channel and check if it intersect with the\n-\t * local one.\n-\t */\n-\twpa_printf(MSG_DEBUG, \"NAN: n_chans=%u, ndc_map_id=%u\",\n-\t\t sched->n_chans, sched->ndc_map_id);\n-\n-\tfor (i = 0; i < sched->n_chans; i++) {\n-\t\tstruct bitfield *own_chan_bf = NULL, *peer_chan_bf = NULL;\n-\t\tu16 cbm, pri_cbm;\n-\t\tu8 map_id, op_class;\n-\t\tint ret;\n-\n-\t\t/* Convert the schedule for the current channel to bitfield */\n-\t\tret = nan_ndl_convert_chan_sched_to_bf(nan, &sched->chans[i],\n-\t\t\t\t\t\t &own_chan_bf, &map_id,\n-\t\t\t\t\t\t &op_class, &cbm,\n-\t\t\t\t\t\t &pri_cbm);\n-\t\tif (ret) {\n-\t\t\twpa_printf(MSG_DEBUG,\n-\t\t\t\t \"NAN: NDL: Failed to convert chan sched to bitfield\");\n-\t\t\treturn false;\n-\t\t}\n-\n-\t\t/* Get the peer availability for the current channel */\n-\t\tpeer_chan_bf =\n-\t\t\tnan_avail_entries_to_bf(nan,\n-\t\t\t\t\t\t&peer->info.avail_entries,\n-\t\t\t\t\t\top_class, cbm, pri_cbm);\n-\t\tif (!peer_chan_bf) {\n-\t\t\tbitfield_free(own_chan_bf);\n-\t\t\tcontinue;\n-\t\t}\n-\n-\t\tret = bitfield_intersects(own_chan_bf, peer_chan_bf);\n-\n-\t\tbitfield_free(peer_chan_bf);\n-\t\tbitfield_free(own_chan_bf);\n-\n-\t\tif (ret == 1)\n-\t\t\treturn true;\n-\t}\n-\n-\treturn false;\n-}\ndiff --git a/src/nan/nan_util.c b/src/nan/nan_util.c\nindex 05630464d6..e736ea8510 100644\n--- a/src/nan/nan_util.c\n+++ b/src/nan/nan_util.c\n@@ -1762,3 +1762,137 @@ int nan_get_chan_entry(struct nan_data *nan, const struct nan_sched_chan *chan,\n \n \treturn 0;\n }\n+\n+\n+/**\n+ * nan_convert_chan_sched_to_bf - Convert channel schedule to bitfield\n+ * and get the channel information.\n+ *\n+ * @nan: NAN module context from nan_init()\n+ * @chan: Channel schedule to convert\n+ * @avail_bf: On successful return holds the availability bitmap of the given\n+ * \tchannel schedule\n+ * @map_id: On successful return holds the map ID for the schedule\n+ * @op_class: On successful return holds the operating class for the\n+ * schedule with the peer\n+ * @cbm: On successful return holds the channel bitmap for the operating class\n+ * @pcbm: On successful return holds the primary channel bitmap for the\n+ * channel in case of bandwidth greater than 40 MHz\n+ * Returns: 0 on success; -1 on failure\n+ */\n+int nan_convert_chan_sched_to_bf(struct nan_data *nan,\n+\t\t\t\t struct nan_chan_schedule *chan,\n+\t\t\t\t struct bitfield **avail_bf, u8 *map_id,\n+\t\t\t\t u8 *op_class, u16 *cbm, u16 *pcbm)\n+{\n+\tstruct bitfield *committed_bf, *conditional_bf;\n+\tint ret;\n+\n+\t*op_class = 0;\n+\t*cbm = 0;\n+\t*pcbm = 0;\n+\t*map_id = chan->map_id;\n+\n+\tret = nan_get_chan_bm(nan, &chan->chan, op_class, cbm, pcbm);\n+\tif (ret) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t \"NAN: NDL: Failed to convert channel info\");\n+\t\treturn -1;\n+\t}\n+\n+\tcommitted_bf = nan_tbm_to_bf(nan, &chan->committed);\n+\tif (!committed_bf) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t \"NAN: NDL: Failed to build committed bitfield\");\n+\t\treturn -1;\n+\t}\n+\n+\tconditional_bf = nan_tbm_to_bf(nan, &chan->conditional);\n+\tif (!conditional_bf) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t \"NAN: NDL: Failed to build conditional bitfield\");\n+\t\tbitfield_free(committed_bf);\n+\t\treturn -1;\n+\t}\n+\n+\t*avail_bf = bitfield_union(committed_bf, conditional_bf);\n+\tbitfield_free(committed_bf);\n+\tbitfield_free(conditional_bf);\n+\n+\tif (!*avail_bf) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t \"NAN: NDL: Failed to unify committed and conditional bitfields\");\n+\t\treturn -1;\n+\t}\n+\n+\twpa_printf(MSG_DEBUG, \"NAN: NDL: map_id=%u, op_class=%u, cbm=0x%x\",\n+\t\t *map_id, *op_class, *cbm);\n+\treturn 0;\n+}\n+\n+\n+/*\n+ * nan_peer_schedule_intersects - Check if local and peer schedules intersect\n+ *\n+ * @nan: NAN module context from nan_init()\n+ * @peer: The peer with whom to intersect the schedule\n+ * @sched: Local device schedule\n+ * Returns: True if schedules intersect, false otherwise\n+ *\n+ * The function checks if the local device schedule intersects with the peer\n+ * device schedule.\n+ */\n+bool nan_peer_schedule_intersects(struct nan_data *nan, struct nan_peer *peer,\n+\t\t\t\t struct nan_schedule *sched)\n+{\n+\tsize_t i;\n+\n+\t/*\n+\t * Iterate over all the channels included in the local schedule. For\n+\t * each channel convert the committed and conditional slots to a\n+\t * bitfield object and extract the operating class and channel bitmap.\n+\t *\n+\t * Using the operating class and channel bitmap find the peer\n+\t * availability on that channel and check if it intersect with the\n+\t * local one.\n+\t */\n+\twpa_printf(MSG_DEBUG, \"NAN: n_chans=%u, ndc_map_id=%u\",\n+\t\t sched->n_chans, sched->ndc_map_id);\n+\n+\tfor (i = 0; i < sched->n_chans; i++) {\n+\t\tstruct bitfield *own_chan_bf = NULL, *peer_chan_bf = NULL;\n+\t\tu16 cbm, pri_cbm;\n+\t\tu8 map_id, op_class;\n+\t\tint ret;\n+\n+\t\t/* Convert the schedule for the current channel to bitfield */\n+\t\tret = nan_convert_chan_sched_to_bf(nan, &sched->chans[i],\n+\t\t\t\t\t\t &own_chan_bf, &map_id,\n+\t\t\t\t\t\t &op_class, &cbm, &pri_cbm);\n+\t\tif (ret) {\n+\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t \"NAN: NDL: Failed to convert chan sched to bitfield\");\n+\t\t\treturn false;\n+\t\t}\n+\n+\t\t/* Get the peer availability for the current channel */\n+\t\tpeer_chan_bf =\n+\t\t\tnan_avail_entries_to_bf(nan,\n+\t\t\t\t\t\t&peer->info.avail_entries,\n+\t\t\t\t\t\top_class, cbm, pri_cbm);\n+\t\tif (!peer_chan_bf) {\n+\t\t\tbitfield_free(own_chan_bf);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tret = bitfield_intersects(own_chan_bf, peer_chan_bf);\n+\n+\t\tbitfield_free(peer_chan_bf);\n+\t\tbitfield_free(own_chan_bf);\n+\n+\t\tif (ret == 1)\n+\t\t\treturn true;\n+\t}\n+\n+\treturn false;\n+}\n", "prefixes": [ "42/71" ] }