From 544aafb675dabb95a76999bc817b631c1b3a8127 Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 3 Aug 2022 14:36:40 -0700 Subject: [PATCH] wiphy: add wiphy_country_is_unknown 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(+) diff --git a/src/wiphy.c b/src/wiphy.c index 3a6cd48c..8cb9eb39 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -790,6 +790,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 070c8aea..da2eca20 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,