3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-22 21:22:37 +01:00

anqp: Use nl80211_parse_attrs

This commit is contained in:
Denis Kenzior 2019-09-19 23:03:10 -05:00
parent 91784425ec
commit 73f6e0b43b
2 changed files with 7 additions and 36 deletions

View File

@ -70,27 +70,14 @@ static void anqp_destroy(void *user_data)
static void netdev_gas_request_cb(struct l_genl_msg *msg, void *user_data) static void netdev_gas_request_cb(struct l_genl_msg *msg, void *user_data)
{ {
struct anqp_request *request = user_data; struct anqp_request *request = user_data;
struct l_genl_attr attr;
uint16_t type, len;
const void *data;
if (l_genl_msg_get_error(msg) != 0) if (l_genl_msg_get_error(msg) != 0)
goto error; goto error;
if (!l_genl_attr_init(&attr, msg)) if (nl80211_parse_attrs(msg, NL80211_ATTR_COOKIE, &request->anqp_cookie,
return; NL80211_ATTR_UNSPEC) < 0)
while (l_genl_attr_next(&attr, &type, &len, &data)) {
switch (type) {
case NL80211_ATTR_COOKIE:
if (len != 8)
goto error; goto error;
request->anqp_cookie = l_get_u64(data);
break;
}
}
return; return;
error: error:
@ -261,10 +248,7 @@ static bool match_cookie(const void *a, const void *b)
static void anqp_frame_wait_cancel_event(struct l_genl_msg *msg, static void anqp_frame_wait_cancel_event(struct l_genl_msg *msg,
uint32_t ifindex) uint32_t ifindex)
{ {
struct l_genl_attr attr; uint64_t cookie;
uint16_t type, len;
const void *data;
uint64_t cookie = 0;
struct anqp_request *request; struct anqp_request *request;
struct cookie_match { struct cookie_match {
uint64_t cookie; uint64_t cookie;
@ -273,22 +257,8 @@ static void anqp_frame_wait_cancel_event(struct l_genl_msg *msg,
l_debug(""); l_debug("");
if (!l_genl_attr_init(&attr, msg)) if (nl80211_parse_attrs(msg, NL80211_ATTR_COOKIE, &cookie,
return; NL80211_ATTR_UNSPEC) < 0)
while (l_genl_attr_next(&attr, &type, &len, &data)) {
switch (type) {
case NL80211_ATTR_COOKIE:
if (len != 8)
return;
cookie = l_get_u64(data);
break;
}
}
if (!cookie)
return; return;
match.cookie = cookie; match.cookie = cookie;

View File

@ -94,6 +94,7 @@ static attr_handler handler_for_type(enum nl80211_attrs type)
case NL80211_ATTR_IFTYPE: case NL80211_ATTR_IFTYPE:
return extract_uint32; return extract_uint32;
case NL80211_ATTR_WDEV: case NL80211_ATTR_WDEV:
case NL80211_ATTR_COOKIE:
return extract_uint64; return extract_uint64;
case NL80211_ATTR_IFNAME: case NL80211_ATTR_IFNAME:
case NL80211_ATTR_WIPHY_NAME: case NL80211_ATTR_WIPHY_NAME: