3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-29 22:19: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 (type != NL80211_ATTR_IFINDEX)
continue;
if (len != sizeof(uint32_t))
break;
return *((uint32_t *) data);
}
if (nl80211_parse_attrs(msg, NL80211_ATTR_IFINDEX, &ifindex,
NL80211_ATTR_UNSPEC) < 0)
return -1; return -1;
return ifindex;
} }
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;