mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 13:02:44 +01:00
manager: add support for [General].Country
This lets the user set a country as the global regulatory domain if the kernel/driver isn't doing it on its own.
This commit is contained in:
parent
c5874c9ab0
commit
f079444c6c
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user