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

manager: Simplify manager_parse_ifindex

using nl80211_parse_attrs
This commit is contained in:
Denis Kenzior 2019-09-19 21:32:52 -05:00
parent 2dbcad3185
commit 2772845a7b

View File

@ -34,6 +34,7 @@
#include "linux/nl80211.h" #include "linux/nl80211.h"
#include "src/nl80211util.h"
#include "src/iwd.h" #include "src/iwd.h"
#include "src/netdev.h" #include "src/netdev.h"
#include "src/wiphy.h" #include "src/wiphy.h"
@ -450,22 +451,15 @@ static struct wiphy_setup_state *manager_find_pending(uint32_t id)
L_UINT_TO_PTR(id)); L_UINT_TO_PTR(id));
} }
static uint32_t manager_parse_ifindex(struct l_genl_attr *attr) static uint32_t manager_parse_ifindex(struct l_genl_msg *msg)
{ {
uint16_t type, len; uint32_t ifindex;
const void *data;
while (l_genl_attr_next(attr, &type, &len, &data)) { if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex,
if (type != NL80211_ATTR_IFINDEX) NL80211_ATTR_UNSPEC) < 0)
continue; return -1;
if (len != sizeof(uint32_t)) return ifindex;
break;
return *((uint32_t *) data);
}
return -1;
} }
static uint32_t manager_parse_wiphy_id(struct l_genl_attr *attr) static uint32_t manager_parse_wiphy_id(struct l_genl_attr *attr)
@ -623,7 +617,6 @@ static void manager_new_wiphy_event(struct l_genl_msg *msg)
static void manager_config_notify(struct l_genl_msg *msg, void *user_data) static void manager_config_notify(struct l_genl_msg *msg, void *user_data)
{ {
uint8_t cmd; uint8_t cmd;
struct l_genl_attr attr;
struct netdev *netdev; struct netdev *netdev;
cmd = l_genl_msg_get_command(msg); cmd = l_genl_msg_get_command(msg);
@ -650,10 +643,7 @@ static void manager_config_notify(struct l_genl_msg *msg, void *user_data)
break; break;
case NL80211_CMD_DEL_INTERFACE: case NL80211_CMD_DEL_INTERFACE:
if (!l_genl_attr_init(&attr, msg)) netdev = netdev_find(manager_parse_ifindex(msg));
break;
netdev = netdev_find(manager_parse_ifindex(&attr));
if (!netdev) if (!netdev)
break; break;