3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-26 18:59:22 +01:00

netdev: add a channel switch event

If the connected BSS announces that it is switching operating channel,
the kernel may emit the NL80211_CMD_CH_SWTICH_NOTIFY event when the
switch is complete. Add a new netdev event NETDEV_EVENT_CHANNEL_SWITCHED
to signal to interested modules that the connected BSS has changed
channel. The event carries a pointer to the new channel's frequency.
This commit is contained in:
Alvin Šipraga 2021-05-27 16:22:28 +02:00 committed by Denis Kenzior
parent f50a51d943
commit 5eb0b7ca8e
2 changed files with 40 additions and 0 deletions

View File

@ -4536,6 +4536,42 @@ failed:
}
static void netdev_channel_switch_event(struct l_genl_msg *msg,
struct netdev *netdev)
{
struct l_genl_attr attr;
uint16_t type, len;
const void *data;
uint32_t *freq = NULL;
l_debug("");
if (!l_genl_attr_init(&attr, msg))
return;
while (l_genl_attr_next(&attr, &type, &len, &data)) {
switch (type) {
case NL80211_ATTR_WIPHY_FREQ:
if (len != 4)
continue;
freq = (uint32_t *) data;
break;
}
}
if (!freq)
return;
l_debug("Channel switch event, frequency: %u", *freq);
if (!netdev->event_filter)
return;
netdev->event_filter(netdev, NETDEV_EVENT_CHANNEL_SWITCHED, freq,
netdev->user_data);
}
static void netdev_mlme_notify(struct l_genl_msg *msg, void *user_data)
{
struct netdev *netdev = NULL;
@ -4561,6 +4597,9 @@ static void netdev_mlme_notify(struct l_genl_msg *msg, void *user_data)
case NL80211_CMD_ROAM:
netdev_roam_event(msg, netdev);
break;
case NL80211_CMD_CH_SWITCH_NOTIFY:
netdev_channel_switch_event(msg, netdev);
break;
case NL80211_CMD_CONNECT:
netdev_connect_event(msg, netdev);
break;

View File

@ -43,6 +43,7 @@ enum netdev_event {
NETDEV_EVENT_ASSOCIATING,
NETDEV_EVENT_ROAMING,
NETDEV_EVENT_ROAMED,
NETDEV_EVENT_CHANNEL_SWITCHED,
NETDEV_EVENT_DISCONNECT_BY_AP,
NETDEV_EVENT_DISCONNECT_BY_SME,
NETDEV_EVENT_RSSI_THRESHOLD_LOW,