eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit 7498eaae6241b43d9917efd4b242ad94b1d11e4f
parent d12d8bec85739bfb7ef7aea88e221cb15427605a
Author: Denis Kenzior <denkenz@gmail.com>
Date:   Tue, 14 Nov 2023 09:20:16 -0600

netdev: Move CMD_DISCONNECT builder to nl80211util

Diffstat:
Msrc/netdev.c | 22+++++-----------------
Msrc/nl80211util.c | 12++++++++++++
Msrc/nl80211util.h | 3+++
3 files changed, 20 insertions(+), 17 deletions(-)

diff --git a/src/netdev.c b/src/netdev.c @@ -1245,18 +1245,6 @@ static void netdev_cmd_disconnect_cb(struct l_genl_msg *msg, void *user_data) disconnect_cb(netdev, r, disconnect_data); } -static struct l_genl_msg *netdev_build_cmd_disconnect(struct netdev *netdev, - uint16_t reason_code) -{ - struct l_genl_msg *msg; - - msg = l_genl_msg_new_sized(NL80211_CMD_DISCONNECT, 64); - 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); - - return msg; -} - static void netdev_deauthenticate_event(struct l_genl_msg *msg, struct netdev *netdev) { @@ -1460,7 +1448,7 @@ static void netdev_setting_keys_failed(struct netdev_handshake_state *nhs, return; } - msg = netdev_build_cmd_disconnect(netdev, + msg = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_UNSPECIFIED); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, netdev_disconnect_cb, @@ -2246,7 +2234,7 @@ void netdev_handshake_failed(struct handshake_state *hs, uint16_t reason_code) switch (netdev->type) { case NL80211_IFTYPE_STATION: case NL80211_IFTYPE_P2P_CLIENT: - msg = netdev_build_cmd_disconnect(netdev, reason_code); + msg = nl80211_build_disconnect(netdev->index, reason_code); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, netdev_disconnect_cb, netdev, NULL); @@ -2989,7 +2977,7 @@ error: deauth: netdev->result = NETDEV_RESULT_ASSOCIATION_FAILED; netdev->last_code = MMPDU_STATUS_CODE_UNSPECIFIED; - msg = netdev_build_cmd_disconnect(netdev, + msg = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_UNSPECIFIED); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, @@ -4159,7 +4147,7 @@ int netdev_disconnect(struct netdev *netdev, } if (send_disconnect) { - disconnect = netdev_build_cmd_disconnect(netdev, + disconnect = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_DEAUTH_LEAVING); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, disconnect, netdev_cmd_disconnect_cb, @@ -4695,7 +4683,7 @@ static void netdev_sa_query_timeout(struct l_timeout *timeout, l_timeout_remove(netdev->sa_query_timeout); netdev->sa_query_timeout = NULL; - msg = netdev_build_cmd_disconnect(netdev, + msg = nl80211_build_disconnect(netdev->index, MMPDU_REASON_CODE_PREV_AUTH_NOT_VALID); netdev->disconnect_cmd_id = l_genl_family_send(nl80211, msg, netdev_disconnect_cb, netdev, NULL); diff --git a/src/nl80211util.c b/src/nl80211util.c @@ -284,6 +284,18 @@ done: return ret; } +struct l_genl_msg *nl80211_build_disconnect(uint32_t ifindex, + uint16_t reason_code) +{ + struct l_genl_msg *msg; + + msg = l_genl_msg_new_sized(NL80211_CMD_DISCONNECT, 64); + l_genl_msg_append_attr(msg, NL80211_ATTR_IFINDEX, 4, &ifindex); + l_genl_msg_append_attr(msg, NL80211_ATTR_REASON_CODE, 2, &reason_code); + + return msg; +} + struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher, uint8_t key_id, const uint8_t *key, size_t key_len, const uint8_t *ctr, diff --git 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_disconnect(uint32_t ifindex, + uint16_t reason_code); + struct l_genl_msg *nl80211_build_new_key_group(uint32_t ifindex, uint32_t cipher, uint8_t key_id, const uint8_t *key, size_t key_len,