aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2023-11-14 09:26:49 -0600
committerDenis Kenzior <denkenz@gmail.com>2023-11-14 09:26:49 -0600
commit904373eee73902917c6f17445ab582974a540eb0 (patch)
tree50bdf3341bde8abb8cba32c49de43c33a85b877d
parent7498eaae6241b43d9917efd4b242ad94b1d11e4f (diff)
netdev: Move CMD_DEAUTHENTICATE builder to nl80211util
-rw-r--r--src/netdev.c20
-rw-r--r--src/nl80211util.c14
-rw-r--r--src/nl80211util.h3
3 files changed, 21 insertions, 16 deletions
diff --git a/src/netdev.c b/src/netdev.c
index 1f6920028..6c35cd1b7 100644
--- a/src/netdev.c
+++ b/src/netdev.c
@@ -1298,20 +1298,6 @@ static void netdev_deauthenticate_event(struct l_genl_msg *msg,
MMPDU_STATUS_CODE_UNSPECIFIED);
}
-static struct l_genl_msg *netdev_build_cmd_deauthenticate(struct netdev *netdev,
- uint16_t reason_code)
-{
- struct l_genl_msg *msg;
-
- msg = l_genl_msg_new_sized(NL80211_CMD_DEAUTHENTICATE, 128);
- l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &netdev->index);
- l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code);
- l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN,
- netdev->handshake->aa);
-
- return msg;
-}
-
static struct l_genl_msg *netdev_build_cmd_del_station(struct netdev *netdev,
const uint8_t *sta,
uint16_t reason_code,
@@ -3028,7 +3014,8 @@ static void netdev_cmd_ft_reassociate_cb(struct l_genl_msg *msg,
netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED;
netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED;
- cmd_deauth = netdev_build_cmd_deauthenticate(netdev,
+ cmd_deauth = nl80211_build_deauthenticate(netdev->index,
+ netdev->handshake->aa,
MMPDU_REASON_CODE_UNSPECIFIED);
netdev->disconnect_cmd_id = l_genl_family_send(nl80211,
cmd_deauth,
@@ -3163,7 +3150,8 @@ static void netdev_authenticate_event(struct l_genl_msg *msg,
netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED;
netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED;
- cmd_deauth = netdev_build_cmd_deauthenticate(netdev,
+ cmd_deauth = nl80211_build_deauthenticate(netdev->index,
+ netdev->handshake->aa,
MMPDU_REASON_CODE_UNSPECIFIED);
netdev->disconnect_cmd_id = l_genl_family_send(nl80211,
cmd_deauth,
diff --git a/src/nl80211util.c b/src/nl80211util.c
index 44a8ebe50..8ed260ad6 100644
--- a/src/nl80211util.c
+++ b/src/nl80211util.c
@@ -284,6 +284,20 @@ done:
return ret;
}
+struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex,
+ const uint8_t addr[static 6],
+ uint16_t reason_code)
+{
+ struct l_genl_msg *msg;
+
+ msg = l_genl_msg_new_sized(NL80211_CMD_DEAUTHENTICATE, 128);
+ l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex);
+ l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code);
+ l_genl_msg_append_attr(msg, NL80211_ATTR_MAC, ETH_ALEN, addr);
+
+ return msg;
+}
+
struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex,
uint16_t reason_code)
{
diff --git a/src/nl80211util.h b/src/nl80211util.h
index 9eb868190..1553047d1 100644
--- a/src/nl80211util.h
+++ b/src/nl80211util.h
@@ -28,6 +28,9 @@ struct band_freq_attrs;
int nl80211_parse_attrs(struct l_genl_msg *msg, int tag, ...);
+struct l_genl_msg *nl80211_build_deauthenticate(uint32_t ifindex,
+ const uint8_t addr[static 6],
+ uint16_t reason_code);
struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex,
uint16_t reason_code);