From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH 01/10] ap: make supported rates a common builder.
Date: Tue, 20 Dec 2022 13:43:09 -0800 [thread overview]
Message-ID: <20221220214318.2041986-1-prestwoj@gmail.com> (raw)
The supported rates IE was being built in two places. This makes that
code common. Unfortunately it needs to support both an ie builder
and using a pointer directly which is why it only builds the contents
of the IE and the caller must set the type/length.
---
src/ap.c | 68 +++++++++++++++++++++++++-------------------------------
1 file changed, 30 insertions(+), 38 deletions(-)
diff --git a/src/ap.c b/src/ap.c
index a9027f79..595c71c9 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -802,6 +802,29 @@ static size_t ap_write_wsc_ie(struct ap_state *ap,
return len;
}
+static size_t ap_build_supported_rates(struct ap_state *ap,
+ uint8_t *rates)
+{
+ uint32_t minr, maxr, count, r;
+
+ minr = l_uintset_find_min(ap->rates);
+ maxr = l_uintset_find_max(ap->rates);
+ count = 0;
+ for (r = minr; r <= maxr && count < 8; r++)
+ if (l_uintset_contains(ap->rates, r)) {
+ uint8_t flag = 0;
+
+ /* Mark only the lowest rate as Basic Rate */
+ if (count == 0)
+ flag = 0x80;
+
+ *rates++ = r | flag;
+ count++;
+ }
+
+ return count;
+}
+
static size_t ap_get_extra_ies_len(struct ap_state *ap,
enum mpdu_management_subtype type,
const struct mmpdu_header *client_frame,
@@ -858,8 +881,7 @@ static size_t ap_build_beacon_pr_head(struct ap_state *ap,
struct mmpdu_header *mpdu = (void *) out_buf;
uint16_t capability = IE_BSS_CAP_ESS | IE_BSS_CAP_PRIVACY;
const uint8_t *bssid = netdev_get_address(ap->netdev);
- uint32_t minr, maxr, count, r;
- uint8_t *rates;
+ size_t len;
struct ie_tlv_builder builder;
memset(mpdu, 0, 36); /* Zero out header + non-IE fields */
@@ -884,24 +906,8 @@ static size_t ap_build_beacon_pr_head(struct ap_state *ap,
/* Supported Rates IE */
ie_tlv_builder_next(&builder, IE_TYPE_SUPPORTED_RATES);
- rates = ie_tlv_builder_get_data(&builder);
-
- minr = l_uintset_find_min(ap->rates);
- maxr = l_uintset_find_max(ap->rates);
- count = 0;
- for (r = minr; r <= maxr && count < 8; r++)
- if (l_uintset_contains(ap->rates, r)) {
- uint8_t flag = 0;
-
- /* Mark only the lowest rate as Basic Rate */
- if (count == 0)
- flag = 0x80;
-
- *rates++ = r | flag;
- count++;
- }
-
- ie_tlv_builder_set_length(&builder, count);
+ len = ap_build_supported_rates(ap, ie_tlv_builder_get_data(&builder));
+ ie_tlv_builder_set_length(&builder, len);
/* DSSS Parameter Set IE for DSSS, HR, ERP and HT PHY rates */
ie_tlv_builder_next(&builder, IE_TYPE_DSSS_PARAMETER_SET);
@@ -1540,8 +1546,8 @@ static uint32_t ap_assoc_resp(struct ap_state *ap, struct sta_state *sta,
struct mmpdu_header *mpdu = (void *) mpdu_buf;
struct mmpdu_association_response *resp;
size_t ies_len = 0;
+ size_t len;
uint16_t capability = IE_BSS_CAP_ESS | IE_BSS_CAP_PRIVACY;
- uint32_t r, minr, maxr, count;
memset(mpdu, 0, sizeof(*mpdu));
@@ -1561,23 +1567,9 @@ static uint32_t ap_assoc_resp(struct ap_state *ap, struct sta_state *sta,
/* Supported Rates IE */
resp->ies[ies_len++] = IE_TYPE_SUPPORTED_RATES;
-
- minr = l_uintset_find_min(ap->rates);
- maxr = l_uintset_find_max(ap->rates);
- count = 0;
- for (r = minr; r <= maxr && count < 8; r++)
- if (l_uintset_contains(ap->rates, r)) {
- uint8_t flag = 0;
-
- /* Mark only the lowest rate as Basic Rate */
- if (count == 0)
- flag = 0x80;
-
- resp->ies[ies_len + 1 + count++] = r | flag;
- }
-
- resp->ies[ies_len++] = count;
- ies_len += count;
+ len = ap_build_supported_rates(ap, resp->ies + ies_len + 1);
+ resp->ies[ies_len++] = len;
+ ies_len += len;
ies_len += ap_write_extra_ies(ap, stype, req, req_len,
resp->ies + ies_len);
--
2.34.3
next reply other threads:[~2022-12-20 21:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-20 21:43 James Prestwood [this message]
2022-12-20 21:43 ` [PATCH 02/10] nl80211util: parse additional channel restriction flags James Prestwood
2022-12-20 21:43 ` [PATCH 03/10] band: add ampdu_params value James Prestwood
2022-12-20 21:43 ` [PATCH 04/10] wiphy: add getter for HT capabilities James Prestwood
2022-12-27 17:22 ` Denis Kenzior
2022-12-20 21:43 ` [PATCH 05/10] band: add APIs to generate a chandef from frequency James Prestwood
2022-12-27 18:07 ` Denis Kenzior
2022-12-28 19:50 ` James Prestwood
2022-12-28 21:10 ` Denis Kenzior
2022-12-20 21:43 ` [PATCH 06/10] band: add band_chandef_width_to_string James Prestwood
2022-12-27 17:33 ` Denis Kenzior
2022-12-20 21:43 ` [PATCH 07/10] wiphy: add wiphy_supports_uapsd James Prestwood
2022-12-20 21:43 ` [PATCH 08/10] ap: include WMM parameter IE James Prestwood
2022-12-27 18:09 ` Denis Kenzior
2022-12-20 21:43 ` [PATCH 09/10] ap: build HT Capabilities/Operation elements James Prestwood
2022-12-20 21:43 ` [PATCH 10/10] ap: generate chandef for starting AP James Prestwood
2022-12-27 16:59 ` [PATCH 01/10] ap: make supported rates a common builder Denis Kenzior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221220214318.2041986-1-prestwoj@gmail.com \
--to=prestwoj@gmail.com \
--cc=iwd@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).