Wifi-4638. update allowed channels and band in radioState

Updating the Opensync radioState allowed channels list
and the band column after a country code change.

Signed-off-by: ravi vaishnav <ravi.vaishnav@netexperience.com>
This commit is contained in:
ravi vaishnav
2021-10-06 16:00:42 -04:00
committed by Arif
parent 521f849950
commit 7fe0022505
3 changed files with 47 additions and 7 deletions

View File

@@ -33,5 +33,5 @@ bool apc_read_state(struct schema_APC_State *apcst);
int ubus_set_channel_switch(const char *if_name, uint32_t frequency,
const char *hw_mode, int channel_bandwidth,
int sec_chan_offset, int reason);
int nl80211_allowed_channels_get(char *name);
#endif

View File

@@ -415,6 +415,8 @@ static bool radio_state_update(struct uci_section *s, struct schema_Wifi_Radio_C
if (tb[WDEV_ATTR_COUNTRY])
SCHEMA_SET_STR(rstate.country, blobmsg_get_string(tb[WDEV_ATTR_COUNTRY]));
nl80211_allowed_channels_get(phy);
rstate.allowed_channels_len = phy_get_channels(phy, rstate.allowed_channels);
rstate.allowed_channels_present = true;

View File

@@ -410,12 +410,25 @@ static void nl80211_add_phy(struct nlattr **tb, char *name)
continue;
}
phy->freq[chan] = 0;
phy->channel[chan] = 0;
phy->chandfs[chan] = 0;
phy->chandisabled[chan] = 0;
phy->chanpwr[chan] = 0;
if (tb_freq[NL80211_FREQUENCY_ATTR_DISABLED]) {
phy->chandisabled[chan] = 1;
phy->chandfs[chan] = 0;
continue;
}
if (chan <= 16)
phy->band_2g = 1;
else if (chan >= 32 && chan <= 68)
phy->band_5gl = 1;
else if (chan >= 96)
phy->band_5gu = 1;
if (tb_freq[NL80211_FREQUENCY_ATTR_RADAR]) {
phy->chandfs[chan] = 1;
phy->chanpwr[chan] = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]);
@@ -423,18 +436,13 @@ static void nl80211_add_phy(struct nlattr **tb, char *name)
LOG(DEBUG, "%s: found dfs channel %d", phy->name, chan);
continue;
}
phy->freq[chan] = freq;
phy->channel[chan] = 1;
if (tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER] &&
!tb_freq[NL80211_FREQUENCY_ATTR_DISABLED])
phy->chanpwr[chan] = nla_get_u32(tb_freq[NL80211_FREQUENCY_ATTR_MAX_TX_POWER]);
if (chan <= 16)
phy->band_2g = 1;
else if (chan >= 32 && chan <= 68)
phy->band_5gl = 1;
else if (chan >= 96)
phy->band_5gu = 1;
}
}
}
@@ -651,3 +659,33 @@ int radio_nl80211_init(void)
return 0;
}
int nl80211_allowed_channels_get(char *name)
{
struct nl_msg *msg;
struct wifi_phy *phy;
struct wifi_iface *wif=NULL;
int idx = 0;
phy = avl_find_element(&phy_tree, name, phy, avl);
if (!phy)
return -1;
if (list_empty(&phy->wifs))
return -1;
wif = list_first_entry(&phy->wifs, struct wifi_iface, phy);
if (!wif)
return -1;
idx = if_nametoindex(wif->name);
if (!idx)
return -1;
msg = unl_genl_msg(&unl_req, NL80211_CMD_GET_WIPHY, true);
unl_genl_request(&unl_req, msg, nl80211_recv, NULL);
return NL_OK;
}