3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-26 09:32:34 +01:00

nl80211util: move CMD_FRAME builder into nl80211util

This will be needed outside of netdev
This commit is contained in:
James Prestwood 2019-06-26 15:15:53 -07:00 committed by Denis Kenzior
parent 53d6a3b8da
commit be9e926c6a
3 changed files with 45 additions and 35 deletions

View File

@ -2655,37 +2655,6 @@ int netdev_leave_adhoc(struct netdev *netdev, netdev_command_cb_t cb,
return 0;
}
static struct l_genl_msg *netdev_build_cmd_frame(struct netdev *netdev,
const uint8_t *to,
uint32_t freq,
struct iovec *iov,
size_t iov_len)
{
struct l_genl_msg *msg;
struct iovec iovs[iov_len + 1];
const uint16_t frame_type = 0x00d0;
uint8_t action_frame[24];
memset(action_frame, 0, 24);
l_put_le16(frame_type, action_frame + 0);
memcpy(action_frame + 4, to, 6);
memcpy(action_frame + 10, netdev->addr, 6);
memcpy(action_frame + 16, to, 6);
iovs[0].iov_base = action_frame;
iovs[0].iov_len = sizeof(action_frame);
memcpy(iovs + 1, iov, sizeof(*iov) * iov_len);
msg = l_genl_msg_new_sized(NL80211_CMD_FRAME, 128 + 512);
l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY_FREQ, 4, &freq);
l_genl_msg_append_attrv(msg, NL80211_ATTR_FRAME, iovs, iov_len + 1);
return msg;
}
static uint32_t netdev_send_action_framev(struct netdev *netdev,
const uint8_t *to,
struct iovec *iov, size_t iov_len,
@ -2693,8 +2662,10 @@ static uint32_t netdev_send_action_framev(struct netdev *netdev,
l_genl_msg_func_t callback)
{
uint32_t id;
struct l_genl_msg *msg = netdev_build_cmd_frame(netdev, to, freq,
iov, iov_len);
struct l_genl_msg *msg = nl80211_build_cmd_frame(netdev->index,
netdev->addr,
to, freq,
iov, iov_len);
id = l_genl_family_send(nl80211, msg, callback, netdev, NULL);
@ -2947,8 +2918,8 @@ uint32_t netdev_anqp_request(struct netdev *netdev, struct scan_bss *bss,
iov[1].iov_base = (void *)anqp;
iov[1].iov_len = len;
msg = netdev_build_cmd_frame(netdev, bss->addr, bss->frequency,
iov, 2);
msg = nl80211_build_cmd_frame(netdev->index, netdev->addr, bss->addr,
bss->frequency, iov, 2);
l_genl_msg_append_attr(msg, NL80211_ATTR_OFFCHANNEL_TX_OK, 0, "");
l_genl_msg_append_attr(msg, NL80211_ATTR_DURATION, 4, &duration);

View File

@ -194,3 +194,35 @@ const void *nl80211_parse_get_key_seq(struct l_genl_msg *msg)
return data;
}
struct l_genl_msg *nl80211_build_cmd_frame(uint32_t ifindex,
const uint8_t *addr,
const uint8_t *to,
uint32_t freq,
struct iovec *iov,
size_t iov_len)
{
struct l_genl_msg *msg;
struct iovec iovs[iov_len + 1];
const uint16_t frame_type = 0x00d0;
uint8_t action_frame[24];
memset(action_frame, 0, 24);
l_put_le16(frame_type, action_frame + 0);
memcpy(action_frame + 4, to, 6);
memcpy(action_frame + 10, addr, 6);
memcpy(action_frame + 16, to, 6);
iovs[0].iov_base = action_frame;
iovs[0].iov_len = sizeof(action_frame);
memcpy(iovs + 1, iov, sizeof(*iov) * iov_len);
msg = l_genl_msg_new_sized(NL80211_CMD_FRAME, 128 + 512);
l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex);
l_genl_msg_append_attr(msg, NL80211_ATTR_WIPHY_FREQ, 4, &freq);
l_genl_msg_append_attrv(msg, NL80211_ATTR_FRAME, iovs, iov_len + 1);
return msg;
}

View File

@ -42,3 +42,10 @@ struct l_genl_msg *nl80211_build_set_key(uint32_t ifindex, uint8_t key_index);
struct l_genl_msg *nl80211_build_get_key(uint32_t ifindex, uint8_t key_index);
const void *nl80211_parse_get_key_seq(struct l_genl_msg *msg);
struct l_genl_msg *nl80211_build_cmd_frame(uint32_t ifindex,
const uint8_t *addr,
const uint8_t *to,
uint32_t freq,
struct iovec *iov,
size_t iov_len);