diff mbox series

[01/10] ap: make supported rates a common builder.

Message ID 20221220214318.2041986-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [01/10] ap: make supported rates a common builder. | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
prestwoj/iwd-alpine-ci-incremental_build fail Make FAIL (patch 8): src/ap.c: In function 'ap_build_ht_operation': src/ap.c:949:17: error: 'struct ap_state' has no member named 'chandef'; did you mean 'channel'? 949 | if (ap->chandef.channel_width == BAND_CHANDEF_WIDTH_20) | ^~~~~~~ | channel src/ap.c:951:22: error: 'struct ap_state' has no member named 'chandef'; did you mean 'channel'? 951 | else if (ap->chandef.frequency < ap->chandef.center1_frequency) | ^~~~~~~ | channel src/ap.c:951:46: error: 'struct ap_state' has no member named 'chandef'; did you mean 'channel'? 951 | else if (ap->chandef.frequency < ap->chandef.center1_frequency) | ^~~~~~~ | channel make[1]: *** [Makefile:2408: src/ap.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1587: all] Error 2
prestwoj/iwd-ci-incremental_build fail Make FAIL (patch 8): src/ap.c: In function ‘ap_build_ht_operation’: src/ap.c:949:17: error: ‘struct ap_state’ has no member named ‘chandef’; did you mean ‘channel’? 949 | if (ap->chandef.channel_width == BAND_CHANDEF_WIDTH_20) | ^~~~~~~ | channel src/ap.c:951:22: error: ‘struct ap_state’ has no member named ‘chandef’; did you mean ‘channel’? 951 | else if (ap->chandef.frequency < ap->chandef.center1_frequency) | ^~~~~~~ | channel src/ap.c:951:46: error: ‘struct ap_state’ has no member named ‘chandef’; did you mean ‘channel’? 951 | else if (ap->chandef.frequency < ap->chandef.center1_frequency) | ^~~~~~~ | channel make[1]: *** [Makefile:2407: src/ap.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1586: all] Error 2
prestwoj/iwd-ci-testrunner success test-runner PASS
prestwoj/iwd-ci-makedistcheck success Make Distcheck

Commit Message

James Prestwood Dec. 20, 2022, 9:43 p.m. UTC
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(-)

Comments

Denis Kenzior Dec. 27, 2022, 4:59 p.m. UTC | #1
Hi James,

On 12/20/22 15:43, James Prestwood wrote:
> 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(-)
> 

Patch 1-3 applied, thanks.

Regards,
-Denis
diff mbox series

Patch

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);