mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-23 07:29:28 +01:00
netdev: Move netdev finding to a common function
This commit is contained in:
parent
9bbe14e7a3
commit
d3eef8b56a
35
src/netdev.c
35
src/netdev.c
@ -4176,16 +4176,22 @@ static void netdev_station_event(struct l_genl_msg *msg,
|
|||||||
netdev_station_watch_func_t, netdev, mac, added);
|
netdev_station_watch_func_t, netdev, mac, added);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void netdev_scan_notify(struct l_genl_msg *msg, void *user_data)
|
static struct netdev *netdev_from_message(struct l_genl_msg *msg)
|
||||||
{
|
{
|
||||||
struct netdev *netdev = NULL;
|
|
||||||
uint32_t ifindex;
|
uint32_t ifindex;
|
||||||
|
|
||||||
if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex,
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex,
|
||||||
NL80211_ATTR_UNSPEC) < 0)
|
NL80211_ATTR_UNSPEC) < 0)
|
||||||
return;
|
return NULL;
|
||||||
|
|
||||||
netdev = netdev_find(ifindex);
|
return netdev_find(ifindex);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void netdev_scan_notify(struct l_genl_msg *msg, void *user_data)
|
||||||
|
{
|
||||||
|
struct netdev *netdev;
|
||||||
|
|
||||||
|
netdev = netdev_from_message(msg);
|
||||||
if (!netdev)
|
if (!netdev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -4334,31 +4340,12 @@ failed:
|
|||||||
static void netdev_mlme_notify(struct l_genl_msg *msg, void *user_data)
|
static void netdev_mlme_notify(struct l_genl_msg *msg, void *user_data)
|
||||||
{
|
{
|
||||||
struct netdev *netdev = NULL;
|
struct netdev *netdev = NULL;
|
||||||
struct l_genl_attr attr;
|
|
||||||
uint16_t type, len;
|
|
||||||
const void *data;
|
|
||||||
uint8_t cmd;
|
uint8_t cmd;
|
||||||
|
|
||||||
cmd = l_genl_msg_get_command(msg);
|
cmd = l_genl_msg_get_command(msg);
|
||||||
|
|
||||||
l_debug("MLME notification %s(%u)", nl80211cmd_to_string(cmd), cmd);
|
l_debug("MLME notification %s(%u)", nl80211cmd_to_string(cmd), cmd);
|
||||||
|
|
||||||
if (!l_genl_attr_init(&attr, msg))
|
netdev = netdev_from_message(msg);
|
||||||
return;
|
|
||||||
|
|
||||||
while (l_genl_attr_next(&attr, &type, &len, &data)) {
|
|
||||||
switch (type) {
|
|
||||||
case NL80211_ATTR_IFINDEX:
|
|
||||||
if (len != sizeof(uint32_t)) {
|
|
||||||
l_warn("Invalid interface index attribute");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
netdev = netdev_find(*((uint32_t *) data));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!netdev)
|
if (!netdev)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user