* [PATCH v2 1/2] doc: document [General].Country main.conf option
@ 2022-09-08 23:06 James Prestwood
2022-09-08 23:06 ` [PATCH v2 2/2] manager: add support for [General].Country James Prestwood
2022-09-09 14:13 ` [PATCH v2 1/2] doc: document [General].Country main.conf option Denis Kenzior
0 siblings, 2 replies; 3+ messages in thread
From: James Prestwood @ 2022-09-08 23:06 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This lets the user set a country code explicitly.
---
src/iwd.config.rst | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/src/iwd.config.rst b/src/iwd.config.rst
index 422d4c03..bafb6b85 100644
--- a/src/iwd.config.rst
+++ b/src/iwd.config.rst
@@ -206,6 +206,16 @@ The group ``[General]`` contains general settings.
required are LoadCredentialEncrypted or SetCredentialEncrypted, and the
secret identifier should be named whatever SystemdEncrypt is set to.
+ * - Country
+ - Value: Country Code (ISO Alpha-2)
+
+ Requests the country be set for the system. Note that setting this is
+ simply a **request** to set the country, and does not guarantee the
+ country will be set. For a self-managed wiphy it is never possible to set
+ the country from userspace. For other devices any regulatory domain
+ request is just a 'hint' and ultimately left up to the kernel to set the
+ country.
+
Network
-------
--
2.34.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] manager: add support for [General].Country
2022-09-08 23:06 [PATCH v2 1/2] doc: document [General].Country main.conf option James Prestwood
@ 2022-09-08 23:06 ` James Prestwood
2022-09-09 14:13 ` [PATCH v2 1/2] doc: document [General].Country main.conf option Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: James Prestwood @ 2022-09-08 23:06 UTC (permalink / raw)
To: iwd; +Cc: James Prestwood
This lets the user set a country as the global regulatory
domain if the kernel/driver isn't doing it on its own.
---
src/manager.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/manager.c b/src/manager.c
index 6ff642f1..fed02777 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -800,6 +800,14 @@ static void manager_config_notify(struct l_genl_msg *msg, void *user_data)
}
}
+static void manager_set_reg_cb(struct l_genl_msg *msg, void *user_data)
+{
+ int err = l_genl_msg_get_error(msg);
+
+ if (err < 0)
+ l_error("Failed to set country (%d)", err);
+}
+
static int manager_init(void)
{
struct l_genl *genl = iwd_get_genl();
@@ -810,6 +818,7 @@ static int manager_init(void)
const char *randomize_str;
const char *if_whitelist = iwd_get_iface_whitelist();
const char *if_blacklist = iwd_get_iface_blacklist();
+ const char *cc;
nl80211 = l_genl_family_new(genl, NL80211_GENL_NAME);
@@ -853,6 +862,23 @@ static int manager_init(void)
goto error;
}
+ cc = l_settings_get_value(config, "General", "Country");
+ if (cc) {
+ if (strlen(cc) != 2 || !l_ascii_isalpha(cc[0]) ||
+ !l_ascii_isalpha(cc[1])) {
+ l_warn("[General].Country=%s is invalid. Country will "
+ "not be set", cc);
+ } else {
+ msg = l_genl_msg_new(NL80211_CMD_REQ_SET_REG);
+ l_genl_msg_append_attr(msg, NL80211_ATTR_REG_ALPHA2,
+ 2, cc);
+ if (!l_genl_family_send(nl80211, msg,
+ manager_set_reg_cb,
+ NULL, NULL))
+ l_warn("Failed to set country");
+ }
+ }
+
randomize_str = l_settings_get_value(config, "General",
"AddressRandomization");
if (randomize_str) {
--
2.34.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] doc: document [General].Country main.conf option
2022-09-08 23:06 [PATCH v2 1/2] doc: document [General].Country main.conf option James Prestwood
2022-09-08 23:06 ` [PATCH v2 2/2] manager: add support for [General].Country James Prestwood
@ 2022-09-09 14:13 ` Denis Kenzior
1 sibling, 0 replies; 3+ messages in thread
From: Denis Kenzior @ 2022-09-09 14:13 UTC (permalink / raw)
To: James Prestwood, iwd
Hi James,
On 9/8/22 18:06, James Prestwood wrote:
> This lets the user set a country code explicitly.
> ---
> src/iwd.config.rst | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
Both applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-09 14:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-08 23:06 [PATCH v2 1/2] doc: document [General].Country main.conf option James Prestwood
2022-09-08 23:06 ` [PATCH v2 2/2] manager: add support for [General].Country James Prestwood
2022-09-09 14:13 ` [PATCH v2 1/2] doc: document [General].Country main.conf option Denis Kenzior
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox