get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 2198418,
    "url": "http://patchwork.ozlabs.org/api/1.0/patches/2198418/?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-22-andrei.otcheretianski@intel.com>",
    "date": "2026-02-19T20:24:37",
    "name": "[21/58] NAN: Add support for adding availability attributes",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "d411cc10baf4a1d6eeb23322d277fd6c236ad25c",
    "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-22-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/2198418/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=4FdGP59l;\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=jLt5sgi/;\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 4fH4g46KHvz1xxN\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 20 Feb 2026 07:27:12 +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 1vtAbk-0000000Bx4N-0PjF;\n\tThu, 19 Feb 2026 20:26:44 +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 1vtAbY-0000000Bwog-0sLL\n\tfor hostap@lists.infradead.org;\n\tThu, 19 Feb 2026 20:26:38 +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:32 -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:28 -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=f85550adrBpV05MpS1m1bR1vtqBQXvD37ONPFbhhOPs=; b=4FdGP59lnWFjq6\n\t6uCjdxZpTeLth+VEotyj8yjekaMxXVFuVeNey2Ce7Ft7xdv0UPBRZ1/l4w3qrJfwNtWFsgrrRvpOm\n\tWY8diRYUij7Zj/fwjIKiZ6C2bLsIzqXIJmSMy/q23mob3OL8CBCn/UfipHvR6rrgwvbJ48/AS/Kap\n\txfh5+cZf2w0XHrKRuzYtSdqbD879RR7zw6FoZLFk/ngsoQy0ZgOK/UUOFv4OhZUHzCJpcoVDMdvxf\n\tJH0FgE7NUVGFcaFPiNFly8IGoVi2yXbsetJ0BOE0MDlzcGWMZu8tgdsbcNB0JWbjUkDVmKsMtlf7y\n\tqhzcpLz7oX5vwAJFZWog==;",
            "v=1; a=rsa-sha256; c=relaxed/simple;\n  d=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n  t=1771532793; x=1803068793;\n  h=from:to:cc:subject:date:message-id:in-reply-to:\n   references:mime-version:content-transfer-encoding;\n  bh=Vu+a3nGquuhleVf5R/iy/mQbId1pNF7u/fG8Vh1PApM=;\n  b=jLt5sgi/tw2DjLSJAxoDLDD4jaD1ETm6tD9HNk4xQ6YD71qQoOyQjFZu\n   4f3GRdw0YLay3crmwV3XWu8cpL50iaDAAbPxk55eaw1OO++FTiOoYAthu\n   gBS9SfZf8lkk0caLU1nvc7+fRDAXXeP6cb5GiCEADXJfoyBJvIKAb1wU7\n   nmHsjqRRf0awMyE3rII1eg3SoN8Zur86putjo+Lm5OItjgQCJ+RaqQGaZ\n   f8jjmO4KwY4E5Uu2cfqMYcDeP0HB4WfedlTz7NyF4Np3ikQ1YJQX4FJm9\n   aF6i7tRzxARhExq1D4Pv/DflC8EH2sCxD9pr+TyGSZewRcqBoHM4xHsVx\n   A==;"
        ],
        "X-CSE-ConnectionGUID": [
            "mqToMhtXRairBD6cCWrJwQ==",
            "F3n6WIXOTuWUHsoNn/+sXg=="
        ],
        "X-CSE-MsgGUID": [
            "o6db9k3PQNSL5TOz2NWf2g==",
            "wgHPsKKQQr6KnUAFPfU1bg=="
        ],
        "X-IronPort-AV": [
            "E=McAfee;i=\"6800,10657,11706\"; a=\"90040010\"",
            "E=Sophos;i=\"6.21,300,1763452800\";\n   d=\"scan'208\";a=\"90040010\"",
            "E=Sophos;i=\"6.21,300,1763452800\";\n   d=\"scan'208\";a=\"219153843\""
        ],
        "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 21/58] NAN: Add support for adding availability attributes",
        "Date": "Thu, 19 Feb 2026 22:24:37 +0200",
        "Message-ID": "<20260219202514.5781-22-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_122634_489649_870B4866 ",
        "X-CRM114-Status": "GOOD (  27.43  )",
        "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> Add support for\n constructing\n    NAN availability attributes from the NAN schedule. --- src/nan/nan_i.h |\n   17 +++ src/nan/nan_ndl.c | 59 ++++++++++ src/nan/nan_util.c | 262\n ++++++++++++++++++++++++++++++++\n    [...]\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\nAdd support for constructing NAN availability attributes\nfrom the NAN schedule.\n---\n src/nan/nan_i.h    |  17 +++\n src/nan/nan_ndl.c  |  59 ++++++++++\n src/nan/nan_util.c | 262 +++++++++++++++++++++++++++++++++++++++++++++\n 3 files changed, 338 insertions(+)",
    "diff": "diff --git a/src/nan/nan_i.h b/src/nan/nan_i.h\nindex a6dd06677c..16292a01de 100644\n--- a/src/nan/nan_i.h\n+++ b/src/nan/nan_i.h\n@@ -16,6 +16,8 @@\n \n struct nan_config;\n \n+#define NAN_INVALID_MAP_ID 0xff\n+\n /*\n  * enum nan_ndp_state - State of NDP establishment\n  * @NAN_NDP_STATE_NONE: No NDP establishment in progress.\n@@ -124,6 +126,11 @@ enum nan_band_chan_type {\n \tNAN_TYPE_CHANNEL,\n };\n \n+/* Default availability entry parameter values */\n+#define NAN_AVAIL_ENTRY_DEF_UTIL NAN_AVAIL_ENTRY_CTRL_UTIL_UNKNOWN\n+#define NAN_AVAIL_ENTRY_DEF_NSS  2\n+#define NAN_AVAIL_ENTRY_DEF_PREF 3\n+\n /*\n  * struct nan_avail_entry - NAN availability entry\n  *\n@@ -428,4 +435,14 @@ int nan_chan_to_chan_idx_map(struct nan_data *nan,\n \t\t\t     u8 op_class, u8 channel, u16 *chan_idx_map);\n int nan_ndl_naf_sent(struct nan_data *nan, struct nan_peer *peer,\n \t\t     enum nan_subtype subtype);\n+int nan_ndl_add_avail_attrs(struct nan_data *nan,\n+\t\t\t    const struct nan_peer *peer,\n+\t\t\t    struct wpabuf *buf);\n+int nan_get_chan_bm(struct nan_data *nan, 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,\n+\t\t\tu32 map_ids_bitmap,\n+\t\t\tu8 type_for_conditional,\n+\t\t\tsize_t n_chans, struct nan_chan_schedule *chans,\n+\t\t\tstruct wpabuf *buf);\n #endif /* NAN_I_H */\ndiff --git a/src/nan/nan_ndl.c b/src/nan/nan_ndl.c\nindex 64dce3f329..90ffd77b90 100644\n--- a/src/nan/nan_ndl.c\n+++ b/src/nan/nan_ndl.c\n@@ -8,6 +8,7 @@\n \n #include \"includes.h\"\n #include \"common.h\"\n+#include \"common/ieee802_11_common.h\"\n #include \"nan_i.h\"\n \n struct ndl_attr_params {\n@@ -879,6 +880,64 @@ int nan_ndl_handle_ndl_attr(struct nan_data *nan, struct nan_peer *peer,\n \t}\n }\n \n+/*\n+ * nan_ndl_add_avail_attrs - Add availability attributes\n+ *\n+ * @nan: NAN module context from nan_init()\n+ * @peer: NAN peer for NDL establishment\n+ * @buf: Frame buffer to which the attribute would be added\n+ * Returns: 0 on success, negative on failure.\n+ *\n+ * An availability attribute is added for each map (identified by map ID) in the\n+ * NDL schedule. Each attribute would hold an availability entry for committed\n+ * slots and an availability entry for conditional slots.\n+ */\n+int nan_ndl_add_avail_attrs(struct nan_data *nan,\n+\t\t\t    const struct nan_peer *peer,\n+\t\t\t    struct wpabuf *buf)\n+{\n+\tstruct nan_schedule *sched;\n+\tu8 type_for_conditional = NAN_AVAIL_ENTRY_CTRL_TYPE_COND;\n+\n+\tif (!peer || !peer->ndl)\n+\t\treturn -1;\n+\n+\tsched = &peer->ndl->sched;\n+\n+\twpa_printf(MSG_DEBUG,\n+\t\t   \"NAN: NDL: Add Avail attribute. state=%s, status=%u\",\n+\t\t   nan_ndl_state_str(peer->ndl->state), peer->ndl->status);\n+\n+\tif (sched->n_chans < 1) {\n+\t\tif (peer->ndl->status == NAN_NDL_STATUS_REJECTED) {\n+\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t   \"NAN: NDL: Rejected. Not adding availability attributes\");\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: NDL: Cannot build availability without channels\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* In case that NDL exchange was complete successfully,\n+\t * consider the conditional entries as committed, as\n+\t * this is expected by the spec.\n+\t */\n+\tif (peer->ndl->status == NAN_NDL_STATUS_ACCEPTED) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: NDL: Add conditional entry as committed\");\n+\t\ttype_for_conditional = NAN_AVAIL_ENTRY_CTRL_TYPE_COMMITTED;\n+\t}\n+\n+\treturn nan_add_avail_attrs(nan, sched->sequence_id,\n+\t\t\t\t   sched->map_ids_bitmap,\n+\t\t\t\t   type_for_conditional,\n+\t\t\t\t   sched->n_chans,\n+\t\t\t\t   sched->chans, buf);\n+\n+}\n+\n \n /*\n  * nan_ndl_add_ndl_attr - Add NDL attribute to frame\ndiff --git a/src/nan/nan_util.c b/src/nan/nan_util.c\nindex 74b611ebd2..afcb28121f 100644\n--- a/src/nan/nan_util.c\n+++ b/src/nan/nan_util.c\n@@ -378,3 +378,265 @@ int nan_chan_to_chan_idx_map(struct nan_data *nan,\n \t*chan_idx_map = BIT(ret);\n \treturn 0;\n }\n+\n+\n+static u16 nan_add_avail_entry(struct nan_data *nan,\n+\t\t\t       struct nan_time_bitmap *tbm,\n+\t\t\t       u8 type, u8 op_class,\n+\t\t\t       u16 chan_bm, u8 prim_chan_bm,\n+\t\t\t       struct wpabuf *buf)\n+{\n+\tu16 ctrl;\n+\tu8 chan_ctrl;\n+\tu8 *len_ptr;\n+\tu8 nss = BITS(nan->cfg->dev_capa.n_antennas, NAN_DEV_CAPA_RX_ANT_MASK,\n+\t\t      NAN_DEV_CAPA_RX_ANT_POS);\n+\n+\tlen_ptr = wpabuf_put(buf, 2);\n+\n+\t/*\n+\t * TODO: Need to also add potential entries as otherwise the peer would\n+\t * not be able to counter\n+\t */\n+\tif (type != NAN_AVAIL_ENTRY_CTRL_TYPE_COMMITTED &&\n+\t    type != NAN_AVAIL_ENTRY_CTRL_TYPE_COND) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: Cannot add non committed/conditional entry\");\n+\t\treturn 0;\n+\t}\n+\n+\t/*\n+\t * Add the entry control field\n+\t * - usage preference is not set for committed and conditional\n+\t * - utilization is max.\n+\t */\n+\tctrl = type;\n+\tctrl |= NAN_AVAIL_ENTRY_DEF_UTIL << NAN_AVAIL_ENTRY_CTRL_UTIL_POS;\n+\tctrl |= nss << NAN_AVAIL_ENTRY_CTRL_RX_NSS_POS;\n+\tctrl |= NAN_AVAIL_ENTRY_CTRL_TBM_PRESENT;\n+\twpabuf_put_le16(buf, ctrl);\n+\n+\t/* Add the time bitmap control field */\n+\tctrl = tbm->duration << NAN_TIME_BM_CTRL_BIT_DURATION_POS;\n+\tctrl |= tbm->period << NAN_TIME_BM_CTRL_PERIOD_POS;\n+\tctrl |= tbm->offset << NAN_TIME_BM_CTRL_START_OFFSET_POS;\n+\twpabuf_put_le16(buf, ctrl);\n+\n+\twpabuf_put_u8(buf, tbm->len);\n+\n+\twpabuf_put_data(buf, tbm->bitmap, tbm->len);\n+\n+\t/* Add the channel entry: single contiguous channel entry */\n+\tchan_ctrl = NAN_BAND_CHAN_CTRL_TYPE;\n+\tchan_ctrl |= 1 << NAN_BAND_CHAN_CTRL_NUM_ENTRIES_POS;\n+\twpabuf_put_u8(buf, chan_ctrl);\n+\twpabuf_put_u8(buf, op_class);\n+\twpabuf_put_le16(buf, chan_bm);\n+\twpabuf_put_u8(buf, prim_chan_bm);\n+\n+\tWPA_PUT_LE16(len_ptr, (u8 *)wpabuf_put(buf, 0) - len_ptr - 2);\n+\treturn (u8 *)wpabuf_put(buf, 0) - len_ptr;\n+}\n+\n+\n+int nan_get_chan_bm(struct nan_data *nan, struct nan_sched_chan *chan,\n+\t\t    u8 *op_class, u16 *chan_bm, u16 *pri_chan_bm)\n+{\n+\tu8 channel;\n+\tenum hostapd_hw_mode mode;\n+\tint ret, sec_channel_offset;\n+\tint freq_offsset = chan->freq - chan->center_freq1;\n+\tu32 idx;\n+\tenum oper_chan_width bandwidth;\n+\n+\tswitch (chan->bandwidth) {\n+\tcase 20:\n+\tcase 40:\n+\tdefault:\n+\t\tbandwidth = CONF_OPER_CHWIDTH_USE_HT;\n+\t\tbreak;\n+\tcase 80:\n+\t\tbandwidth = CONF_OPER_CHWIDTH_80MHZ;\n+\n+\t\tidx = (freq_offsset + 30) / 20;\n+\t\t*pri_chan_bm = BIT(idx);\n+\t\tbreak;\n+\tcase 160:\n+\t\tif (chan->center_freq2) {\n+\t\t\tbandwidth = CONF_OPER_CHWIDTH_80P80MHZ;\n+\n+\t\t\t/* TODO: Need to support auxiliary channel bitmap */\n+\t\t\tidx = (freq_offsset + 30) / 20;\n+\t\t\t*pri_chan_bm = BIT(idx);\n+\t\t} else {\n+\t\t\tbandwidth = CONF_OPER_CHWIDTH_160MHZ;\n+\t\t\tidx = (freq_offsset + 70) / 20;\n+\t\t\t*pri_chan_bm = BIT(idx);\n+\t\t}\n+\t\tbreak;\n+\t}\n+\n+\tif (freq_offsset > 0)\n+\t\tsec_channel_offset = 1;\n+\telse if (freq_offsset < 0)\n+\t\tsec_channel_offset = -1;\n+\telse\n+\t\tsec_channel_offset = 0;\n+\n+\twpa_printf(MSG_DEBUG,\n+\t\t   \"NAN: Get chan bm: freq=%d, center_freq1=%d, bandwidth=%u, sec_channel_offset=%d\",\n+\t\t   chan->freq, chan->center_freq1, chan->bandwidth,\n+\t\t   freq_offsset);\n+\n+\t/* For bandwidths >= 80 need to use the center frequency */\n+\tmode = ieee80211_freq_to_channel_ext(bandwidth == CONF_OPER_CHWIDTH_USE_HT ?\n+\t\t\t\t\t     chan->freq : chan->center_freq1,\n+\t\t\t\t\t     sec_channel_offset,\n+\t\t\t\t\t     bandwidth,\n+\t\t\t\t\t     op_class, &channel);\n+\tif (mode == NUM_HOSTAPD_MODES) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: Cannot get channel and op_class\");\n+\t\treturn -1;\n+\t}\n+\n+\twpa_printf(MSG_DEBUG, \"NAN: Derived op_class=%u, channel=%u\",\n+\t\t   *op_class, channel);\n+\n+\tret = nan_chan_to_chan_idx_map(nan, *op_class, channel, chan_bm);\n+\tif (ret) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: Failed to derive channel bitmap\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+\n+/**\n+ * nan_add_avail_attrs - Add NAN availability attributes\n+ * @nan: NAN module context from nan_init()\n+ * @sequence_id: Sequence ID to be used in the availability attributes\n+ * @map_ids_bitmap: Bitmap of map IDs to be included in the availability\n+ *\tattributes\n+ * @type_for_conditional: Type field to be used for conditional entries\n+ * @n_chans: Number of channels in chans\n+ * @chans: Channel schedules\n+ * @buf: Frame buffer to which the attribute would be added\n+ * Returns: 0 on success, negative on failure.\n+ *\n+ * An availability attribute is added for each map (identified by map ID) in the\n+ * schedule. All channels with the same map ID are added to the same\n+ * availability attribute. Each attribute will hold an availability entry for\n+ * committed slots and an availability entry for conditional slots.\n+ */\n+int nan_add_avail_attrs(struct nan_data *nan, u8 sequence_id,\n+\t\t\tu32 map_ids_bitmap,\n+\t\t\tu8 type_for_conditional,\n+\t\t\tsize_t n_chans, struct nan_chan_schedule *chans,\n+\t\t\tstruct wpabuf *buf)\n+{\n+\tu8 last_map_id = NAN_INVALID_MAP_ID;\n+\tu8 *len_ptr = NULL;\n+\tu8 i;\n+\n+\twpa_printf(MSG_DEBUG, \"NAN: Add availability attrs. n_chans=%zu\",\n+\t\t   n_chans);\n+\n+\tfor (i = 0; i < n_chans; i++) {\n+\t\tstruct nan_chan_schedule *chan = &chans[i];\n+\t\tu8 op_class;\n+\t\tu16 chan_bm, pri_chan_bm;\n+\t\tint ret;\n+\n+\t\tif (!chan->conditional.len && !chan->committed.len) {\n+\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t   \"NAN: committed and conditional are empty\");\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tret = nan_get_chan_bm(nan, &chan->chan, &op_class,\n+\t\t\t\t      &chan_bm, &pri_chan_bm);\n+\t\tif (ret)\n+\t\t\tcontinue;\n+\n+\t\t/*\n+\t\t * All channels with the same map ID should be added to the same\n+\t\t * availability attribute, so verify that the map IDs are\n+\t\t * sorted.\n+\t\t */\n+\t\tif (last_map_id != NAN_INVALID_MAP_ID &&\n+\t\t    last_map_id > chan->map_id) {\n+\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t   \"NAN: map IDs not sorted properly\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tif (!(map_ids_bitmap & BIT(chan->map_id))) {\n+\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t   \"NAN: skip adding availability for map_id=%u\",\n+\t\t\t\t   chan->map_id);\n+\t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (last_map_id != chan->map_id) {\n+\t\t\tu16 ctrl;\n+\n+\t\t\tif (last_map_id != NAN_INVALID_MAP_ID) {\n+\t\t\t\twpa_printf(MSG_DEBUG,\n+\t\t\t\t\t   \"NAN: Add avail attr done: map_id=%u\",\n+\t\t\t\t\t   last_map_id);\n+\n+\t\t\t\tWPA_PUT_LE16(len_ptr,\n+\t\t\t\t\t     (u8 *)wpabuf_put(buf, 0) - len_ptr - 2);\n+\t\t\t}\n+\n+\t\t\tlast_map_id = chan->map_id;\n+\t\t\tmap_ids_bitmap &= ~BIT(last_map_id);\n+\n+\t\t\twpa_printf(MSG_DEBUG, \"NAN: Add avail attr map_id=%u\",\n+\t\t\t\t   last_map_id);\n+\n+\t\t\twpabuf_put_u8(buf, NAN_ATTR_NAN_AVAILABILITY);\n+\t\t\tlen_ptr = wpabuf_put(buf, 2);\n+\t\t\twpabuf_put_u8(buf, sequence_id);\n+\n+\t\t\tctrl = last_map_id << NAN_AVAIL_CTRL_MAP_ID_POS;\n+\n+\t\t\t/*\n+\t\t\t * The spec states that this bit should be set if the\n+\t\t\t * committed changed or if conditional is included. Set\n+\t\t\t * it anyway, as it is not known what information the\n+\t\t\t * peer has on our schedule.\n+\t\t\t */\n+\t\t\tctrl |= NAN_AVAIL_CTRL_COMMITTED_CHANGED;\n+\t\t\twpabuf_put_le16(buf, ctrl);\n+\t\t}\n+\n+\t\t/* TODO: handle primary channel configuration */\n+\t\tif (chan->committed.len)\n+\t\t\tnan_add_avail_entry(nan, &chan->committed,\n+\t\t\t\t\t    NAN_AVAIL_ENTRY_CTRL_TYPE_COMMITTED,\n+\t\t\t\t\t    op_class, chan_bm, pri_chan_bm,\n+\t\t\t\t\t    buf);\n+\n+\t\tif (chan->conditional.len)\n+\t\t\tnan_add_avail_entry(nan, &chan->conditional,\n+\t\t\t\t\t    type_for_conditional,\n+\t\t\t\t\t    op_class, chan_bm, 0, buf);\n+\t}\n+\n+\tif (last_map_id == NAN_INVALID_MAP_ID) {\n+\t\twpa_printf(MSG_DEBUG,\n+\t\t\t   \"NAN: No valid availability entries added\");\n+\t\treturn -1;\n+\t}\n+\n+\twpa_printf(MSG_DEBUG, \"NAN: Add avail attr done: map_id=%u\",\n+\t\t   last_map_id);\n+\n+\tWPA_PUT_LE16(len_ptr, (u8 *)wpabuf_put(buf, 0) - len_ptr - 2);\n+\n+\treturn 0;\n+}\n",
    "prefixes": [
        "21/58"
    ]
}