diff mbox series

[v2,09/13] wiphy: add wiphy_country_is_unknown

Message ID 20220803213644.277534-9-prestwoj@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series [v2,01/13] wiphy: fix runtime error from bit shift | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-ci-gitlint success GitLint

Commit Message

James Prestwood Aug. 3, 2022, 9:36 p.m. UTC
A helper to check whether the country code corresponds to a
real country, or some special code indicating the country isn't
yet set. For now, the special codes are OO (world roaming) and
XX (unknown entity).
---
 src/wiphy.c | 16 ++++++++++++++++
 src/wiphy.h |  1 +
 2 files changed, 17 insertions(+)

Comments

Denis Kenzior Aug. 4, 2022, 4:48 p.m. UTC | #1
Hi James,

On 8/3/22 16:36, James Prestwood wrote:
> A helper to check whether the country code corresponds to a
> real country, or some special code indicating the country isn't
> yet set. For now, the special codes are OO (world roaming) and
> XX (unknown entity).
> ---
>   src/wiphy.c | 16 ++++++++++++++++
>   src/wiphy.h |  1 +
>   2 files changed, 17 insertions(+)
> 

Applied, thanks.

Regards,
-Denis
diff mbox series

Patch

diff --git a/src/wiphy.c b/src/wiphy.c
index 6a109655..dec4b15e 100644
--- a/src/wiphy.c
+++ b/src/wiphy.c
@@ -800,6 +800,22 @@  void wiphy_get_reg_domain_country(struct wiphy *wiphy, char *out)
 	out[1] = country[1];
 }
 
+bool wiphy_country_is_unknown(struct wiphy *wiphy)
+{
+	char cc[2];
+
+	wiphy_get_reg_domain_country(wiphy, cc);
+
+	/*
+	 * Treat OO and XX as an unknown country. Additional codes could be
+	 * added here if needed. The purpose of this is to know if we can
+	 * expect the disabled frequency list to be updated once a country is
+	 * known.
+	 */
+	return ((cc[0] == 'O' && cc[1] == 'O') ||
+			(cc[0] == 'X' && cc[1] == 'X'));
+}
+
 int wiphy_estimate_data_rate(struct wiphy *wiphy,
 				const void *ies, uint16_t ies_len,
 				const struct scan_bss *bss,
diff --git a/src/wiphy.h b/src/wiphy.h
index 1fea6c23..2159fc00 100644
--- a/src/wiphy.h
+++ b/src/wiphy.h
@@ -124,6 +124,7 @@  const uint8_t *wiphy_get_extended_capabilities(struct wiphy *wiphy,
 const uint8_t *wiphy_get_rm_enabled_capabilities(struct wiphy *wiphy);
 bool wiphy_get_rsnxe(const struct wiphy *wiphy, uint8_t *buf, size_t len);
 void wiphy_get_reg_domain_country(struct wiphy *wiphy, char *out);
+bool wiphy_country_is_unknown(struct wiphy *wiphy);
 
 void wiphy_generate_random_address(struct wiphy *wiphy, uint8_t addr[static 6]);
 void wiphy_generate_address_from_ssid(struct wiphy *wiphy, const char *ssid,