get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.0/patches/2198424/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2198424,
    "url": "http://patchwork.ozlabs.org/api/1.0/patches/2198424/?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": "<20260219202514.5781-27-andrei.otcheretianski@intel.com>",
    "date": "2026-02-19T20:24:42",
    "name": "[26/58] NAN: Properly set the NDL status in a response and confirm",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "d1dc907270b5db5cdef907abcfc6da96a14a3fde",
    "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/20260219202514.5781-27-andrei.otcheretianski@intel.com/mbox/",
    "series": [
        {
            "id": 492721,
            "url": "http://patchwork.ozlabs.org/api/1.0/series/492721/?format=api",
            "date": "2026-02-19T20:24:21",
            "name": "NAN: Add NAN Data Path (NDP) support",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/492721/mbox/"
        }
    ],
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2198424/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=Y9f2oLvm;\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=UPBj4DPP;\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 4fH4gx24cDz1xpY\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 20 Feb 2026 07:27:57 +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 1vtAcS-0000000By1F-1hUp;\n\tThu, 19 Feb 2026 20:27:28 +0000",
            "from mgamail.intel.com ([198.175.65.10])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1vtAbs-0000000BwCB-3d0m\n\tfor hostap@lists.infradead.org;\n\tThu, 19 Feb 2026 20:27:08 +0000",
            "from orviesa004.jf.intel.com ([10.64.159.144])\n  by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 19 Feb 2026 12:26:46 -0800",
            "from aotchere-mobl1.ger.corp.intel.com (HELO\n aotchere-mobl1.intel.com) ([10.245.246.171])\n  by orviesa004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n 19 Feb 2026 12:26:42 -0800"
        ],
        "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:Cc:To:From:Reply-To:Content-ID:Content-Description:\n\tResent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:\n\tList-Owner; bh=M+Y0uN80OcTss2SoRG77cC9Uvh7+dEXalAjK+kF74LE=; b=Y9f2oLvmsj9kfw\n\t9/3eahdh5OpHP2jL0+GFPVPbSHytUXJ/U4TJRJN8Xgy3ULwlrnHaUHrRQuyNcGbWm4s/5WjnDwAa+\n\tY+n9u3uXZ7oU67VxvM35WDS3wLyi3BaL6UHceQLaSKB5SsW+7QbLL5fqTcxfescOjVcztD1YOa5v0\n\tIrOw2gn2O8+UaZsz+X+ENsWNHWiQxRdY766HTj6wAQ1g4f3AN2uAObvcbWgN5LnCWkQssqLmKijLD\n\tbHgRNxgm0ZlZuQcUNn+1lHR945iAhhooxCmoZv8f9gN9Gu1teJIBfP1NeCOQ8o+Lcfa5J+ihWrjNm\n\te8nC4fG2vBSi8RQ2eXCw==;",
            "v=1; a=rsa-sha256; c=relaxed/simple;\n  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n  t=1771532813; x=1803068813;\n  h=from:to:cc:subject:date:message-id:in-reply-to:\n   references:mime-version:content-transfer-encoding;\n  bh=LPaKOliA2nFsg65wMI4btuo8p8X0PZnSMowpNee7FPE=;\n  b=UPBj4DPPo785/2u+9d0Ie5lKAT9ujRXeVk8+1YFtUK4IV3eKeOKLri3Q\n   A76L2WNzGPBkiflv7t4SFFDM6nEvBqK+EM8qyWoJDW/+B6gKssX22kTiV\n   alHPfQ0t8V87cv7RcXyFVtiw8ZWsEb08IZnDTX1lp+lYfYzbqcUe4esdP\n   nBqgfyHQW395i8jbbZyEdh65MG9xgsXxtuCgoBcRAbxwlRSQZbNlDX1hi\n   92L1DucLaIexDF3vVrAVXfJ7ZCTuu1d1gvPH01UJfWcWGS3DYJr0DU+ze\n   o1ONd03BNzQH0tfwF+blBwAdWK6uMIofhzZ+DFyec08NMq3JOBv5s6efs\n   A==;"
        ],
        "X-CSE-ConnectionGUID": [
            "UvrJCZj6R7KvvleA26P29w==",
            "yzLzxtEQTtyPNz9Y96cqJQ=="
        ],
        "X-CSE-MsgGUID": [
            "lI5dRQ/PTh+aW+4vuteAFA==",
            "FIiEfddESgiBVRKFgBsbmg=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6800,10657,11706\"; a=\"90040046\"",
            "E=Sophos;i=\"6.21,300,1763452800\";\n   d=\"scan'208\";a=\"90040046\"",
            "E=Sophos;i=\"6.21,300,1763452800\";\n   d=\"scan'208\";a=\"219153868\""
        ],
        "X-ExtLoop1": "1",
        "From": "Andrei Otcheretianski <andrei.otcheretianski@intel.com>",
        "To": "hostap@lists.infradead.org,\n\tvamsin@qti.qualcomm.com,\n\tvganneva@qti.qualcomm.com,\n\tmaheshkkv@google.com",
        "Cc": "Ilan Peer <ilan.peer@intel.com>",
        "Subject": "[PATCH 26/58] NAN: Properly set the NDL status in a response and\n confirm",
        "Date": "Thu, 19 Feb 2026 22:24:42 +0200",
        "Message-ID": "<20260219202514.5781-27-andrei.otcheretianski@intel.com>",
        "X-Mailer": "git-send-email 2.52.0",
        "In-Reply-To": "<20260219202514.5781-1-andrei.otcheretianski@intel.com>",
        "References": "<20260219202514.5781-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-20260219_122653_273029_4036F410 ",
        "X-CRM114-Status": "GOOD (  29.96  )",
        "X-Spam-Score": "-4.4 (----)",
        "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: Ilan Peer <ilan.peer@intel.com> Validate the local\n schedule\n    versus the peer's schedule, and determine the status of the NDL setup: -\n   Check if the intersection of the local availability and the peer\n availability\n    is not empty and adheres to the peer QoS requirements. - Check if local\n NDC\n    is a subset of the local schedule. - Check i [...]\n Content analysis details:   (-4.4 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.10 listed in list.dnswl.org]\n  0.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.10 listed in sa-accredit.habeas.com]\n  0.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.10 listed in\n sa-trusted.bondedsender.org]\n  0.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.10 listed in\n bl.score.senderscore.com]\n -0.0 SPF_PASS               SPF: sender matches SPF record\n  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record\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_EF          Message has a valid DKIM or DK signature from\n                             envelope-from domain\n -0.1 DKIM_VALID             Message has at least one valid DKIM or DK\n signature\n  0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n not necessarily valid\n -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n -0.0 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: Ilan Peer <ilan.peer@intel.com>\n\nValidate the local schedule versus the peer's schedule,\nand determine the status of the NDL setup:\n\n- Check if the intersection of the local availability and the peer\n  availability is not empty and adheres to the peer QoS\n  requirements.\n- Check if local NDC is a subset of the local schedule.\n- Check if local NDC is identical to the peer NDC.\n- Check if peer's immutable is covered by the local schedule.\n\nIf these conditions are met, accept the NDL. Otherwise:\n\n- If the frame is a response frame, continue the NDL establishment.\n- If the frame is a confirm frame, reject the NDL establishment.\n\nSigned-off-by: Ilan Peer <ilan.peer@intel.com>\n---\n src/nan/nan_i.h    |  16 +-\n src/nan/nan_ndl.c  | 465 ++++++++++++++++++++++++++++++++++++++++++++-\n src/nan/nan_util.c | 253 +++++++++++++++++++++---\n 3 files changed, 697 insertions(+), 37 deletions(-)",
    "diff": "diff --git a/src/nan/nan_i.h b/src/nan/nan_i.h\nindex 9314575d30..f5448fb55e 100644\n--- a/src/nan/nan_i.h\n+++ b/src/nan/nan_i.h\n@@ -460,8 +460,16 @@ bool nan_sched_covered_by_avail_entry(struct nan_data *nan,\n \t\t\t\t      struct nan_avail_entry *avail,\n \t\t\t\t      struct bitfield *sched_bf,\n \t\t\t\t      u8 map_id);\n-int nan_sched_covered_by_avail_entries(struct nan_data *nan,\n-\t\t\t\t       struct dl_list *avail_entries,\n-\t\t\t\t       u8 *sched,\n-\t\t\t\t       u8 sched_len);\n+bool nan_sched_covered_by_avail_entries(struct nan_data *nan,\n+\t\t\t\t\tstruct dl_list *avail_entries,\n+\t\t\t\t\tu8 *sched, u8 sched_len);\n+bool\n+nan_sched_bf_covered_by_avail_entries_and_chan(struct nan_data *nan,\n+\t\t\t\t\t       const struct dl_list *avail_entries,\n+\t\t\t\t\t       struct bitfield *sched_bf,\n+\t\t\t\t\t       u8 map_id,\n+\t\t\t\t\t       u8 op_class, u16 cbm);\n+struct bitfield * nan_avail_entries_to_bf(struct nan_data *nan,\n+\t\t\t\t\t  const struct dl_list *avail_entries,\n+\t\t\t\t\t  u8 op_class, u16 cbm, u16 pri_cbm);\n #endif /* NAN_I_H */\ndiff --git a/src/nan/nan_ndl.c b/src/nan/nan_ndl.c\nindex 6f247df5f5..28e7a73d9e 100644\n--- a/src/nan/nan_ndl.c\n+++ b/src/nan/nan_ndl.c\n@@ -10,6 +10,7 @@\n #include \"common.h\"\n #include \"common/ieee802_11_common.h\"\n #include \"nan_i.h\"\n+#include \"bitfield.h\"\n \n struct ndl_attr_params {\n \tu8 dialog_token;\n@@ -222,11 +223,460 @@ static int nan_ndl_validate_peer_avail(struct nan_data *nan,\n }\n \n \n-static enum nan_ndl_status nan_ndl_res_status(struct nan_data *nan,\n-\t\t\t\t\t      struct nan_peer *peer)\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 would hold the availability bit map of the\n+ *     given channel schedule\n+ * @map_id: On successful return would hold the map ID for the schedule\n+ * @op_class: On successful return would hold the operating class for the\n+ *     schedule with the peer\n+ * @cbm: On successful return holds the channel bitmap for the operating\n+ *     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+ *\n+ * @NAN_NDL_VER_SCHED_SUBSET_OF_LOCAL: The schedule is a subset of the local one\n+ * @NAN_NDL_VER_SCHED_SUPERSET_OF_LOCAL: The schedule is a superset of the local\n+ *     one\n+ * @NAN_NDL_VER_SCHED_IDENTICAL_OF_LOCAL: The schedule is identical to the local\n+ * @NAN_NDL_VER_SCHED_NONE: None of the above. This means that there was no\n+ *     match or an error occurred.\n+ */\n+enum nan_ndl_ver {\n+\tNAN_NDL_VER_SCHED_SUBSET_OF_LOCAL,\n+\tNAN_NDL_VER_SCHED_SUPERSET_OF_LOCAL,\n+\tNAN_NDL_VER_SCHED_IDENTICAL_OF_LOCAL,\n+\tNAN_NDL_VER_SCHED_NONE,\n+};\n+\n+\n+/*\n+ * nan_ndl_match_sched_vs_common - Compare the given schedule to the common\n+ * availability of the local device and the peer device, comparing channel\n+ * configuration and bitmap.\n+ *\n+ * @nan: NAN module context from nan_init()\n+ * @avail_entries: Peer availability entries\n+ * @sched: A byte array with 0 or more &struct nan_sched_entry entries\n+ * @sched_len: Length of the &sched array\n+ * @common_bf: Bitfield representing the intersection of local and peer\n+ *     availability\n+ * @op_class: Local operating class\n+ * @cbm: Local channel bitmap\n+ *\n+ * Returns one of enum nan_ndl_ver. In case of on an error\n+ * NAN_NDL_VER_SCHED_NONE is returned.\n+ *\n+ * The function first verifies that the given schedule is covered by the peer\n+ * availability. Then, the function verifies that the schedule is covered by\n+ * the common availability between local and peer.\n+ *\n+ * The function can (and should be used) to check the schedule constraints of\n+ * an NDC schedule and/or immutable schedule.\n+ *\n+ * Note: In case that &sched is NULL or &sched_len is 0, returns\n+ * NAN_NDL_VER_SCHED_IDENTICAL_OF_LOCAL, meaning no constraints.\n+ */\n+static enum nan_ndl_ver\n+nan_ndl_match_sched_vs_common(struct nan_data *nan,\n+\t\t\t      struct dl_list *avail_entries,\n+\t\t\t      u8 *sched, u8 sched_len,\n+\t\t\t      struct bitfield *common_bf,\n+\t\t\t      u8 op_class, u16 cbm)\n+{\n+\tstruct dl_list sched_entries;\n+\tstruct bitfield *sched_bf;\n+\tu8 map_id;\n+\tenum nan_ndl_ver verdict;\n+\tint ret;\n+\n+\t/* No constraints */\n+\tif (!sched || !sched_len)\n+\t\treturn NAN_NDL_VER_SCHED_IDENTICAL_OF_LOCAL;\n+\n+\t/* Convert the schedule entries to availability entries  */\n+\tret = nan_sched_entries_to_avail_entries(nan,\n+\t\t\t\t\t\t &sched_entries,\n+\t\t\t\t\t\t sched,\n+\t\t\t\t\t\t sched_len);\n+\tif (ret)\n+\t\treturn NAN_NDL_VER_SCHED_NONE;\n+\n+\t/* Convert the schedule availability entries to map ID and bitfield */\n+\tsched_bf = nan_sched_to_bf(nan, &sched_entries, &map_id);\n+\tnan_flush_avail_entries(&sched_entries);\n+\n+\t/*\n+\t * Now that the schedule is represented as bitfield and the map ID is\n+\t * obtained, compare these against the peer availability entries and\n+\t * channel configuration. A successful match means that the schedule is\n+\t * covered by the peer availability entries for the given channel.\n+\t */\n+\tret = nan_sched_bf_covered_by_avail_entries_and_chan(nan,\n+\t\t\t\t\t\t\t     avail_entries,\n+\t\t\t\t\t\t\t     sched_bf,\n+\t\t\t\t\t\t\t     map_id,\n+\t\t\t\t\t\t\t     op_class,\n+\t\t\t\t\t\t\t     cbm);\n+\tif (ret) {\n+\t\tint ret2;\n+\n+\t\t/*\n+\t\t * After validating the schedule against the peer availability,\n+\t\t * match the peer availability with the local one.\n+\t\t */\n+\t\tret = bitfield_is_subset(common_bf, sched_bf);\n+\t\tret2 = bitfield_is_subset(sched_bf, common_bf);\n+\n+\t\tif (ret < 0 || ret2 < 0)\n+\t\t\tverdict = NAN_NDL_VER_SCHED_NONE;\n+\t\telse if (ret == 1 && ret2 == 1)\n+\t\t\tverdict = NAN_NDL_VER_SCHED_IDENTICAL_OF_LOCAL;\n+\t\telse if (ret == 1)\n+\t\t\tverdict = NAN_NDL_VER_SCHED_SUBSET_OF_LOCAL;\n+\t\telse\n+\t\t\tverdict = NAN_NDL_VER_SCHED_SUPERSET_OF_LOCAL;\n+\t} else {\n+\t\tverdict = NAN_NDL_VER_SCHED_NONE;\n+\t}\n+\n+\tbitfield_free(sched_bf);\n+\treturn verdict;\n+}\n+\n+\n+static enum nan_ndl_status nan_ndl_determine_status(struct nan_data *nan,\n+\t\t\t\t\t\t    struct nan_peer *peer,\n+\t\t\t\t\t\t    bool can_counter,\n+\t\t\t\t\t\t    enum nan_reason *reason)\n {\n-\t/* TODO: properly set the status */\n-\treturn NAN_NDL_STATUS_ACCEPTED;\n+\tstruct nan_schedule *sched = &peer->ndl->sched;\n+\tstruct bitfield *common_bf = NULL, *ndc_bf = NULL, *track_ndc_bf = NULL;\n+\tenum nan_ndl_ver verdict;\n+\tsize_t size, max_latency, i;\n+\tu16 crbs;\n+\tint ret;\n+\n+\t*reason = NAN_REASON_RESERVED;\n+\n+\tndc_bf = nan_tbm_to_bf(nan, &sched->ndc);\n+\tif (!ndc_bf) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: NDL: Failed to build NDC bitfield from schedule\");\n+\n+\t\t*reason = NAN_REASON_UNSPECIFIED_REASON;\n+\t\treturn NAN_NDL_STATUS_REJECTED;\n+\t}\n+\n+\ttrack_ndc_bf = bitfield_alloc(bitfield_size(ndc_bf));\n+\tif (!track_ndc_bf) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: NDL: Failed to allocate bitfield for tracking NDC\");\n+\n+\t\tbitfield_free(ndc_bf);\n+\t\t*reason = NAN_REASON_UNSPECIFIED_REASON;\n+\t\treturn NAN_NDL_STATUS_REJECTED;\n+\t}\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 intersect it with the local one:\n+\t *\n+\t * - Accumulate the intersection of the NDC bitmap with the bitmap all\n+\t *   channels with the same map ID as the NDC, so later it can be\n+\t *   verified that the NDC is covered by the local availability.\n+\t * - Accumulate the intersection of local and peer availability for\n+\t *   all channels, so later the QoS requirements can be verified.\n+\t */\n+\twpa_printf(MSG_DEBUG, \"NAN: NDL: 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+\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+\n+\t\t\t*reason = NAN_REASON_UNSPECIFIED_REASON;\n+\t\t\tret = NAN_NDL_STATUS_REJECTED;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\tif (sched->ndc_map_id == map_id) {\n+\t\t\tstruct bitfield *tmp = bitfield_dup(ndc_bf);\n+\n+\t\t\tif (tmp) {\n+\t\t\t\tbitfield_intersect_in_place(tmp, own_chan_bf);\n+\t\t\t\tbitfield_union_in_place(track_ndc_bf, tmp);\n+\t\t\t\tbitfield_free(tmp);\n+\t\t\t}\n+\t\t}\n+\n+\t\t/* Get the peer availability for the current channel */\n+\t\tpeer_chan_bf = nan_avail_entries_to_bf(nan,\n+\t\t\t\t\t\t       &peer->info.avail_entries,\n+\t\t\t\t\t\t       op_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_intersect_in_place(own_chan_bf, peer_chan_bf);\n+\t\tbitfield_free(peer_chan_bf);\n+\t\tpeer_chan_bf = NULL;\n+\n+\t\tif (ret < 0) {\n+\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t   \"NAN: NDL: Failed to intersect own and peer chan bitfields\");\n+\n+\t\t\tbitfield_free(own_chan_bf);\n+\n+\t\t\t*reason = NAN_REASON_INVALID_AVAILABILITY;\n+\t\t\tret = NAN_NDL_STATUS_REJECTED;\n+\t\t\tgoto out;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Accumulate schedule common for local and peer device, so it\n+\t\t * can later be used to verify QoS requirements etc.\n+\t\t */\n+\t\tif (common_bf) {\n+\t\t\tret = bitfield_union_in_place(common_bf, own_chan_bf);\n+\t\t\tif (ret) {\n+\t\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t\t   \"NAN: NDL: Failed to unify own chan bitfields\");\n+\n+\t\t\t\tbitfield_free(own_chan_bf);\n+\n+\t\t\t\t*reason = NAN_REASON_UNSPECIFIED_REASON;\n+\t\t\t\tret = NAN_NDL_STATUS_REJECTED;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t} else {\n+\t\t\tcommon_bf = bitfield_dup(own_chan_bf);\n+\t\t\tif (!common_bf) {\n+\t\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t\t   \"NAN: NDL: Failed to dup own chan bitfield\");\n+\n+\t\t\t\tbitfield_free(own_chan_bf);\n+\n+\t\t\t\t*reason = NAN_REASON_UNSPECIFIED_REASON;\n+\t\t\t\tret = NAN_NDL_STATUS_REJECTED;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t}\n+\n+\t\tbitfield_free(own_chan_bf);\n+\t\town_chan_bf = NULL;\n+\t}\n+\n+\tif (!common_bf) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: NDL: No common availability between local and peer\");\n+\n+\t\t*reason = NAN_REASON_INVALID_AVAILABILITY;\n+\t\tret = NAN_NDL_STATUS_CONTINUED;\n+\t\tgoto out;\n+\t}\n+\n+\t/*\n+\t * Verify that the schedule NDC bitmap is covered by the local\n+\t * availability for the map used for the NDC.\n+\t */\n+\tif (!bitfield_is_subset(ndc_bf, track_ndc_bf)) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: NDL: NDC bitmap is not covered by local availability on NDC channel\");\n+\n+\t\t*reason = NAN_REASON_UNSPECIFIED_REASON;\n+\t\tret = NAN_NDL_STATUS_REJECTED;\n+\t\tgoto out;\n+\t}\n+\n+\n+\tbitfield_free(ndc_bf);\n+\tndc_bf = track_ndc_bf;\n+\ttrack_ndc_bf = NULL;\n+\n+\t/*\n+\t * In case the peer included an immutable, the immutable must be\n+\t * covered by the common schedule. If not reject.\n+\t */\n+\tverdict = nan_ndl_match_sched_vs_common(nan,\n+\t\t\t\t\t\t&peer->info.avail_entries,\n+\t\t\t\t\t\tpeer->ndl->immut_sched,\n+\t\t\t\t\t\tpeer->ndl->immut_sched_len,\n+\t\t\t\t\t\tcommon_bf, 0, 0);\n+\tif (verdict != NAN_NDL_VER_SCHED_IDENTICAL_OF_LOCAL &&\n+\t    verdict != NAN_NDL_VER_SCHED_SUBSET_OF_LOCAL) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: Schedule does not cover immutable. Reject\");\n+\n+\t\t*reason = NAN_REASON_IMMUTABLE_UNACCEPTABLE;\n+\t\tret = NAN_NDL_STATUS_REJECTED;\n+\t\tgoto out;\n+\t}\n+\n+\t/*\n+\t * In case the peer included an NDC, check if it is identical to\n+\t * the locally generated one.\n+\t *\n+\t * Note: the list of peer availability entries needs to be iterated\n+\t * again, as the NDC map ID must also be matched.\n+\t */\n+\tverdict = nan_ndl_match_sched_vs_common(nan,\n+\t\t\t\t\t\t&peer->info.avail_entries,\n+\t\t\t\t\t\tpeer->ndl->ndc_sched,\n+\t\t\t\t\t\tpeer->ndl->ndc_sched_len,\n+\t\t\t\t\t\tndc_bf, 0, 0);\n+\tif (verdict != NAN_NDL_VER_SCHED_IDENTICAL_OF_LOCAL) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: Response NDC does not match req NDC\");\n+\n+\t\t*reason = NAN_REASON_INVALID_AVAILABILITY;\n+\t\tret = NAN_NDL_STATUS_CONTINUED;\n+\t\tgoto out;\n+\t}\n+\n+\t/* No QoS requirements. Accept */\n+\tif (peer->ndl->peer_qos.min_slots == NAN_QOS_MIN_SLOTS_NO_PREF &&\n+\t    peer->ndl->peer_qos.max_latency == NAN_QOS_MAX_LATENCY_NO_PREF) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: No QoS requirements from Peer. Accept\");\n+\n+\t\tret = NAN_NDL_STATUS_ACCEPTED;\n+\t\tgoto out;\n+\t}\n+\n+\tsize = bitfield_size(common_bf);\n+\twpa_printf(MSG_DEBUG,\n+\t\t   \"NAN: size of avail intersection map=%zu\", size);\n+\n+\t/*\n+\t * The common map covers an entire 8192 period with 16 TU slots. For\n+\t * minimal time slots need to only consider the first 32 slots\n+\t */\n+\tfor (i = 0, crbs = 0, max_latency = 0; i < size; i++) {\n+\t\tif (bitfield_is_set(common_bf, i)) {\n+\t\t\tif (i < 32)\n+\t\t\t\tcrbs++;\n+\n+\t\t\tmax_latency = 0;\n+\t\t} else if (peer->ndl->peer_qos.max_latency !=\n+\t\t\t   NAN_QOS_MAX_LATENCY_NO_PREF) {\n+\t\t\tmax_latency++;\n+\t\t\tif (max_latency > peer->ndl->peer_qos.max_latency) {\n+\t\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t\t   \"NAN: failed to meet max latency\");\n+\n+\t\t\t\t*reason = NAN_REASON_QOS_UNACCEPTABLE;\n+\t\t\t\tret = NAN_NDL_STATUS_CONTINUED;\n+\t\t\t\tgoto out;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\tif (peer->ndl->peer_qos.min_slots != NAN_QOS_MIN_SLOTS_NO_PREF &&\n+\t    peer->ndl->peer_qos.min_slots >= crbs) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: failed to meet min slots\");\n+\n+\t\t*reason = NAN_REASON_QOS_UNACCEPTABLE;\n+\t\tret = NAN_NDL_STATUS_CONTINUED;\n+\t\tgoto out;\n+\t}\n+\n+\tret = NAN_NDL_STATUS_ACCEPTED;\n+out:\n+\tbitfield_free(common_bf);\n+\tbitfield_free(ndc_bf);\n+\tbitfield_free(track_ndc_bf);\n+\n+\twpa_printf(MSG_DEBUG,\n+\t\t   \"NAN: NDL: Response status=%s (%u)\",\n+\t\t   ret == NAN_NDL_STATUS_ACCEPTED ? \"ACCEPTED\" :\n+\t\t   ret == NAN_NDL_STATUS_CONTINUED ? \"CONTINUED\" :\n+\t\t   \"REJECTED\",\n+\t\t   ret);\n+\n+\tif (ret == NAN_NDL_STATUS_CONTINUED && !can_counter) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: Cannot counter, change verdict to REJECTED\");\n+\t\tret = NAN_NDL_STATUS_REJECTED;\n+\t}\n+\n+\treturn ret;\n }\n \n \n@@ -328,7 +778,12 @@ int nan_ndl_setup(struct nan_data *nan, struct nan_peer *peer,\n \t\tnan_ndl_set_state(nan, ndl, NAN_NDL_STATE_START);\n \t\tndl->status = NAN_NDL_STATUS_CONTINUED;\n \t} else {\n-\t\tndl->status = nan_ndl_res_status(nan, peer);\n+\t\tndl->status = nan_ndl_determine_status(nan, peer,\n+\t\t\t\t\t\t       ndl->state ==\n+\t\t\t\t\t\t       NAN_NDL_STATE_REQ_RECV,\n+\t\t\t\t\t\t       &reason);\n+\t\tif (ndl->status == NAN_NDL_STATUS_REJECTED)\n+\t\t\tgoto out_fail;\n \t}\n \n \tndl->setup_reason = NAN_NDL_SETUP_REASON_NDP;\ndiff --git a/src/nan/nan_util.c b/src/nan/nan_util.c\nindex a3edb4ed23..8bee05c50e 100644\n--- a/src/nan/nan_util.c\n+++ b/src/nan/nan_util.c\n@@ -1153,14 +1153,14 @@ bool nan_sched_covered_by_avail_entry(struct nan_data *nan,\n }\n \n \n-static int nan_sched_bf_covered_by_avail_entries(struct nan_data *nan,\n-\t\t\t\t\t\t struct dl_list *avail_entries,\n-\t\t\t\t\t\t struct bitfield *sched_bf,\n-\t\t\t\t\t\t u8 map_id)\n+static struct bitfield *\n+nan_sched_bf_from_avail_and_chan(struct nan_data *nan,\n+\t\t\t\t const struct dl_list *avail_entries,\n+\t\t\t\t u8 map_id,\n+\t\t\t\t u8 op_class, u16 cbm)\n {\n \tstruct nan_avail_entry *avail;\n \tstruct bitfield *res_bf = NULL;\n-\tint ret = 0;\n \n \tdl_list_for_each(avail, avail_entries, struct nan_avail_entry,\n \t\t\t list) {\n@@ -1174,12 +1174,19 @@ static int nan_sched_bf_covered_by_avail_entries(struct nan_data *nan,\n \t\t    avail->type != NAN_AVAIL_ENTRY_CTRL_TYPE_COND)\n \t\t\tcontinue;\n \n+\t\t/* Now check channel, if it is given */\n+\t\tif (op_class && cbm) {\n+\t\t\tif (avail->n_band_chan < 1 ||\n+\t\t\t    avail->band_chan_type != NAN_TYPE_CHANNEL ||\n+\t\t\t    avail->band_chan[0].u.chan.op_class != op_class ||\n+\t\t\t    !(avail->band_chan[0].u.chan.chan_bitmap & cbm))\n+\t\t\t\tcontinue;\n+\t\t}\n+\n \t\t/* convert the availability entry to bf */\n \t\tavail_bf = nan_tbm_to_bf(nan, &avail->tbm);\n-\t\tif (!avail_bf) {\n-\t\t\tret = -1;\n+\t\tif (!avail_bf)\n \t\t\tgoto fail;\n-\t\t}\n \n \t\tbitfield_dump(avail_bf, \"NAN: Availability entry bitmap\");\n \t\tif (!res_bf) {\n@@ -1190,22 +1197,18 @@ static int nan_sched_bf_covered_by_avail_entries(struct nan_data *nan,\n \t\t\ttmp_bf = bitfield_union(res_bf, avail_bf);\n \t\t\tbitfield_free(avail_bf);\n \n-\t\t\tif (!tmp_bf) {\n-\t\t\t\tret = -1;\n+\t\t\tif (!tmp_bf)\n \t\t\t\tgoto fail;\n-\t\t\t}\n \n \t\t\tbitfield_free(res_bf);\n \t\t\tres_bf = tmp_bf;\n \t\t}\n \t}\n \n-\tret = bitfield_is_subset(res_bf, sched_bf);\n+\treturn res_bf;\n fail:\n-\twpa_printf(MSG_DEBUG,\n-\t\t   \"NAN: Is bitfield schedule subset of entries=%d\", ret);\n \tbitfield_free(res_bf);\n-\treturn ret;\n+\treturn NULL;\n }\n \n \n@@ -1217,20 +1220,19 @@ fail:\n  * @avail_entries: A list of availability entries (see &struct nan_avail_entry)\n  * @sched: An array with 0 or more &struct nan_sched_entry entries\n  * @sched_len: Length of the &sched array\n- * Returns 1 of schedule is covered by the entries; 0 if not and -1 on error\n+ * Returns true if schedule is covered by the entries; otherwise false.\n  */\n-int nan_sched_covered_by_avail_entries(struct nan_data *nan,\n-\t\t\t\t       struct dl_list *avail_entries,\n-\t\t\t\t       u8 *sched,\n-\t\t\t\t       u8 sched_len)\n+bool nan_sched_covered_by_avail_entries(struct nan_data *nan,\n+\t\t\t\t\tstruct dl_list *avail_entries,\n+\t\t\t\t\tu8 *sched, u8 sched_len)\n {\n \tstruct dl_list sched_entries;\n-\tstruct bitfield *sched_bf;\n+\tstruct bitfield *sched_bf, *avail_bf;\n \tu8 map_id;\n-\tint ret;\n+\tbool ret = false;\n \n \tif (!sched || !sched_len)\n-\t\treturn 1;\n+\t\treturn true;\n \n \tdl_list_init(&sched_entries);\n \tret = nan_sched_entries_to_avail_entries(nan,\n@@ -1240,12 +1242,207 @@ int nan_sched_covered_by_avail_entries(struct nan_data *nan,\n \tsched_bf = nan_sched_to_bf(nan, &sched_entries, &map_id);\n \tnan_flush_avail_entries(&sched_entries);\n \n-\tret = nan_sched_bf_covered_by_avail_entries(nan, avail_entries,\n-\t\t\t\t\t\t    sched_bf, map_id);\n+\tavail_bf = nan_sched_bf_from_avail_and_chan(nan, avail_entries,\n+\t\t\t\t\t\t    map_id, 0, 0);\n+\tif (avail_bf)\n+\t\tret = bitfield_is_subset(avail_bf, sched_bf) ? true : false;\n \n-\twpa_printf(MSG_DEBUG,\n-\t\t   \"NAN: NDC schedule is %s a subset of entries\",\n-\t\t   ret == 1 ? \"\" : \"NOT\");\n+\twpa_printf(MSG_DEBUG, \"NAN: Schedule is %s a subset of entries\",\n+\t\t   ret ? \"\" : \"NOT\");\n+\n+\tbitfield_free(avail_bf);\n \tbitfield_free(sched_bf);\n+\n+\treturn ret;\n+}\n+\n+\n+/**\n+ * nan_sched_bf_covered_by_avail_entries_and_chan - Check if schedule is covered\n+ * by the list of availability attributes matching the channel configurations\n+ *\n+ * @nan: NAN module context from nan_init()\n+ * @avail_entries: A list of availability entries. See &struct nan_avail_entry\n+ * @sched_bf: the bitfield representing the schedule\n+ * @map_id: Map ID associated with the schedule\n+ * @op_class: Operating class to match against\n+ * @cbm: Channel bit map to match against\n+ * Returns true of schedule is covered by the entries; otherwise false\n+ */\n+bool\n+nan_sched_bf_covered_by_avail_entries_and_chan(struct nan_data *nan,\n+\t\t\t\t\t       const struct dl_list *avail_entries,\n+\t\t\t\t\t       struct bitfield *sched_bf,\n+\t\t\t\t\t       u8 map_id,\n+\t\t\t\t\t       u8 op_class, u16 cbm)\n+{\n+\tstruct bitfield *avail_bf;\n+\tbool ret = false;\n+\n+\t/*\n+\t * Build a schedule bitfield from all the availability entries matching\n+\t * the map id and channel configuration\n+\t */\n+\tavail_bf = nan_sched_bf_from_avail_and_chan(nan, avail_entries,\n+\t\t\t\t\t\t    map_id,\n+\t\t\t\t\t\t    op_class, cbm);\n+\n+\t/*\n+\t * If there is such schedule, verify that it is a superset of the given\n+\t * schedule\n+\t */\n+\tif (avail_bf && bitfield_is_subset(avail_bf, sched_bf))\n+\t\tret = true;\n+\n+\twpa_printf(MSG_DEBUG,\n+\t\t   \"NAN: Is schedule covered by entries and chan=%u\", ret);\n+\n+\tbitfield_free(avail_bf);\n \treturn ret;\n }\n+\n+\n+static int nan_get_control_channel(struct nan_data *nan, u8 op_class,\n+\t\t\t\t   u16 cbm, u16 pri_cbm)\n+{\n+\tconst struct oper_class_map *op = get_oper_class(NULL, op_class);\n+\tint freq = 0, idx;\n+\tu8 chan_id;\n+\n+\tif (!op || op_class > 130)\n+\t\treturn -1;\n+\n+\tidx = ffs(cbm) - 1;\n+\tif (idx < 0) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: No channel found in chan_bitmap 0x%04x for oper_class %u\",\n+\t\t\t   cbm, op_class);\n+\t\treturn -1;\n+\t}\n+\n+\tchan_id = op_class_idx_to_chan(op, idx);\n+\tif (!chan_id) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: No channel found for oper_class %u idx %u\",\n+\t\t\t   op_class, idx);\n+\t\treturn -1;\n+\t}\n+\n+\tfreq = ieee80211_chan_to_freq(NULL, op_class, chan_id);\n+\n+\t/*\n+\t * For operating classes with bandwidth < 80 the frequency is the\n+\t * control channel frequency. For operating classes with\n+\t * bandwidth >= 80, the frequency is the center frequency of the\n+\t * primary segment, so we need to derive the control channel frequency\n+\t * from the primary channel bitmap.\n+\t */\n+\tif (op->bw == BW20 || op->bw == BW40 ||\n+\t    op->bw == BW40PLUS || op->bw == BW40MINUS)\n+\t\treturn freq;\n+\n+\tif (!pri_cbm) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: No primary channel bitmap provided for oper_class %u\",\n+\t\t\t   op_class);\n+\t\treturn -1;\n+\t}\n+\n+\tidx = ffs(pri_cbm) - 1;\n+\n+\tif (op->bw == BW80 || op->bw == BW80P80)\n+\t\treturn freq - 30 + idx * 20;\n+\n+\tif (op->bw == BW160)\n+\t\treturn freq - 70 + idx * 20;\n+\n+\treturn -1;\n+}\n+\n+\n+/**\n+ * nan_avail_entries_to_bf - Convert availability entries that match the given\n+ * channel configuration to a bitfield.\n+ *\n+ * @nan: NAN module context from nan_init()\n+ * @avail_entries: A list of availability entries. See &struct nan_avail_entry\n+ * @op_class: Operating class to match against\n+ * @cbm: Channel bit map to match against\n+ * @pri_cbm: Primary channel bit map to match against\n+ * Returns NULL on error or no match; otherwise returns a bitfield describing\n+ * all the available slots.\n+ */\n+struct bitfield * nan_avail_entries_to_bf(struct nan_data *nan,\n+\t\t\t\t\t  const struct dl_list *avail_entries,\n+\t\t\t\t\t  u8 op_class, u16 cbm, u16 pri_cbm)\n+{\n+\tstruct nan_avail_entry *avail;\n+\tstruct bitfield *res_bf = NULL;\n+\n+\tdl_list_for_each(avail, avail_entries, struct nan_avail_entry,\n+\t\t\t list) {\n+\t\tstruct bitfield *avail_bf;\n+\n+\t\t/* Schedule can only be covered by committed/conditional */\n+\t\tif (avail->type != NAN_AVAIL_ENTRY_CTRL_TYPE_COMMITTED &&\n+\t\t    avail->type != NAN_AVAIL_ENTRY_CTRL_TYPE_COND)\n+\t\t\tcontinue;\n+\n+\t\t/*\n+\t\t * Committed/conditional entries should only have a single\n+\t\t * channel entry\n+\t\t */\n+\t\tif (avail->n_band_chan != 1 ||\n+\t\t    avail->band_chan_type != NAN_TYPE_CHANNEL)\n+\t\t\tcontinue;\n+\n+\t\t/*\n+\t\t * Check that the availability entry channel matches. If it does\n+\t\t * not match, check if the channels are compatible, i.e., have\n+\t\t * the same control channel\n+\t\t */\n+\t\tif (avail->band_chan[0].u.chan.op_class != op_class ||\n+\t\t    avail->band_chan[0].u.chan.chan_bitmap != cbm ||\n+\t\t    avail->band_chan[0].u.chan.pri_chan_bitmap != pri_cbm) {\n+\t\t\tint freq1, freq2;\n+\n+\t\t\tfreq1 = nan_get_control_channel(nan, op_class,\n+\t\t\t\t\t\t\tcbm, pri_cbm);\n+\t\t\tfreq2 = nan_get_control_channel(nan,\n+\t\t\t\t\t\t\tavail->band_chan[0].u.chan.op_class,\n+\t\t\t\t\t\t\tle_to_host16(avail->band_chan[0].u.chan.chan_bitmap),\n+\t\t\t\t\t\t\tle_to_host16(avail->band_chan[0].u.chan.pri_chan_bitmap));\n+\n+\t\t\tif (freq2 == -1 || freq1 != freq2)\n+\t\t\t\tcontinue;\n+\n+\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t   \"NAN: Availability entry channel is compatible. Control channel freq=%d MHz\",\n+\t\t\t\t   freq1);\n+\t\t}\n+\n+\t\t/* Convert the availability entry to bf */\n+\t\tavail_bf = nan_tbm_to_bf(nan, &avail->tbm);\n+\t\tif (!avail_bf)\n+\t\t\tgoto fail;\n+\n+\t\tif (!res_bf) {\n+\t\t\tres_bf = avail_bf;\n+\t\t} else {\n+\t\t\tstruct bitfield *tmp_bf;\n+\n+\t\t\ttmp_bf = bitfield_union(res_bf, avail_bf);\n+\t\t\tif (!tmp_bf)\n+\t\t\t\tgoto fail;\n+\n+\t\t\tbitfield_free(res_bf);\n+\t\t\tbitfield_free(avail_bf);\n+\t\t\tres_bf = tmp_bf;\n+\t\t}\n+\t}\n+\n+\treturn res_bf;\n+fail:\n+\tbitfield_free(res_bf);\n+\treturn NULL;\n+}\n",
    "prefixes": [
        "26/58"
    ]
}