mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-12-22 21:22:37 +01:00
manager: Simplify manager_parse_wiphy_id
using nl80211_get_attrs
This commit is contained in:
parent
2772845a7b
commit
d400c7f303
@ -462,35 +462,24 @@ static uint32_t manager_parse_ifindex(struct l_genl_msg *msg)
|
|||||||
return ifindex;
|
return ifindex;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t manager_parse_wiphy_id(struct l_genl_attr *attr)
|
static uint32_t manager_parse_wiphy_id(struct l_genl_msg *msg)
|
||||||
{
|
{
|
||||||
uint16_t type, len;
|
uint32_t wiphy;
|
||||||
const void *data;
|
|
||||||
|
|
||||||
while (l_genl_attr_next(attr, &type, &len, &data)) {
|
if (nl80211_parse_attrs(msg, NL80211_ATTR_WIPHY, &wiphy,
|
||||||
if (type != NL80211_ATTR_WIPHY)
|
NL80211_ATTR_UNSPEC) < 0)
|
||||||
continue;
|
return -1;
|
||||||
|
|
||||||
if (len != sizeof(uint32_t))
|
return wiphy;
|
||||||
break;
|
|
||||||
|
|
||||||
return *((uint32_t *) data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void manager_del_wiphy_event(struct l_genl_msg *msg)
|
static void manager_del_wiphy_event(struct l_genl_msg *msg)
|
||||||
{
|
{
|
||||||
struct wiphy_setup_state *state;
|
struct wiphy_setup_state *state;
|
||||||
struct wiphy *wiphy;
|
struct wiphy *wiphy;
|
||||||
struct l_genl_attr attr;
|
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
|
||||||
if (!l_genl_attr_init(&attr, msg))
|
id = manager_parse_wiphy_id(msg);
|
||||||
return;
|
|
||||||
|
|
||||||
id = manager_parse_wiphy_id(&attr);
|
|
||||||
|
|
||||||
state = manager_find_pending(id);
|
state = manager_find_pending(id);
|
||||||
if (state) {
|
if (state) {
|
||||||
@ -509,14 +498,10 @@ static void manager_interface_dump_callback(struct l_genl_msg *msg,
|
|||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
struct wiphy_setup_state *state;
|
struct wiphy_setup_state *state;
|
||||||
struct l_genl_attr attr;
|
|
||||||
|
|
||||||
l_debug("");
|
l_debug("");
|
||||||
|
|
||||||
if (!l_genl_attr_init(&attr, msg))
|
state = manager_find_pending(manager_parse_wiphy_id(msg));
|
||||||
return;
|
|
||||||
|
|
||||||
state = manager_find_pending(manager_parse_wiphy_id(&attr));
|
|
||||||
if (!state)
|
if (!state)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -557,7 +542,6 @@ static void manager_wiphy_dump_callback(struct l_genl_msg *msg, void *user_data)
|
|||||||
|
|
||||||
static void manager_new_wiphy_event(struct l_genl_msg *msg)
|
static void manager_new_wiphy_event(struct l_genl_msg *msg)
|
||||||
{
|
{
|
||||||
struct l_genl_attr attr;
|
|
||||||
unsigned int wiphy_cmd_id;
|
unsigned int wiphy_cmd_id;
|
||||||
unsigned int iface_cmd_id;
|
unsigned int iface_cmd_id;
|
||||||
uint32_t wiphy_id;
|
uint32_t wiphy_id;
|
||||||
@ -565,10 +549,7 @@ static void manager_new_wiphy_event(struct l_genl_msg *msg)
|
|||||||
if (!pending_wiphys)
|
if (!pending_wiphys)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!l_genl_attr_init(&attr, msg))
|
wiphy_id = manager_parse_wiphy_id(msg);
|
||||||
return;
|
|
||||||
|
|
||||||
wiphy_id = manager_parse_wiphy_id(&attr);
|
|
||||||
/*
|
/*
|
||||||
* Until fixed, a NEW_WIPHY event will not include all the information
|
* Until fixed, a NEW_WIPHY event will not include all the information
|
||||||
* that may be available, but a dump will. Because of this we do both
|
* that may be available, but a dump will. Because of this we do both
|
||||||
|
@ -49,11 +49,24 @@ static bool extract_ifindex(const void *data, uint16_t len, void *o)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool extract_uint32(const void *data, uint16_t len, void *o)
|
||||||
|
{
|
||||||
|
uint32_t *out = o;
|
||||||
|
|
||||||
|
if (len != 4)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
*out = l_get_u32(data);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
static attr_handler handler_for_type(enum nl80211_attrs type)
|
static attr_handler handler_for_type(enum nl80211_attrs type)
|
||||||
{
|
{
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case NL80211_ATTR_IFINDEX:
|
case NL80211_ATTR_IFINDEX:
|
||||||
return extract_ifindex;
|
return extract_ifindex;
|
||||||
|
case NL80211_ATTR_WIPHY:
|
||||||
|
return extract_uint32;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user