mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-11-01 19:07:47 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user