eiwd

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

commit 00763fde0d6c752612ff723b78430fdfb6a06b8b
parent e265f95f4514ffc6aa3a62346ddbb66033f6146c
Author: Denis Kenzior <denkenz@gmail.com>
Date:   Mon, 24 May 2021 16:02:58 -0500

station: Break up station_connect_cb

Break this up into two parts, one handling the successful connect case,
the other for handling error conditions

Diffstat:
Msrc/station.c | 118++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 57 insertions(+), 61 deletions(-)

diff --git a/src/station.c b/src/station.c @@ -2429,27 +2429,6 @@ static bool station_retry_with_status(struct station *station, return station_try_next_bss(station); } -static void station_connect_dbus_reply(struct station *station, - enum netdev_result result) -{ - struct l_dbus_message *reply; - - switch (result) { - case NETDEV_RESULT_ABORTED: - reply = dbus_error_aborted(station->connect_pending); - break; - case NETDEV_RESULT_OK: - reply = l_dbus_message_new_method_return( - station->connect_pending); - break; - default: - reply = dbus_error_failed(station->connect_pending); - break; - } - - dbus_pending_reply(&station->connect_pending, reply); -} - static void station_ft_ds_action_start(struct station *station, uint16_t mdid) { const struct l_queue_entry *entry; @@ -2480,49 +2459,17 @@ static void station_ft_ds_action_start(struct station *station, uint16_t mdid) } } -static void station_connect_cb(struct netdev *netdev, enum netdev_result result, - void *event_data, void *user_data) +static void station_connect_ok(struct station *station) { - struct station *station = user_data; - struct handshake_state *hs = netdev_get_handshake(netdev); - - l_debug("%u, result: %d", netdev_get_ifindex(station->netdev), result); - - switch (result) { - case NETDEV_RESULT_OK: - blacklist_remove_bss(station->connected_bss->addr); - break; - case NETDEV_RESULT_HANDSHAKE_FAILED: - /* reason code in this case */ - if (station_retry_with_reason(station, l_get_u16(event_data))) - return; - - break; - case NETDEV_RESULT_AUTHENTICATION_FAILED: - case NETDEV_RESULT_ASSOCIATION_FAILED: - /* status code in this case */ - if (station_retry_with_status(station, l_get_u16(event_data))) - return; - - break; - default: - break; - } - - if (station->connect_pending) - station_connect_dbus_reply(station, result); - - if (result != NETDEV_RESULT_OK) { - if (result != NETDEV_RESULT_ABORTED) { - bool in_handshake = - result == NETDEV_RESULT_HANDSHAKE_FAILED; + struct handshake_state *hs = netdev_get_handshake(station->netdev); - network_connect_failed(station->connected_network, - in_handshake); - station_disassociated(station); - } + l_debug(""); - return; + if (station->connect_pending) { + struct l_dbus_message *reply = + l_dbus_message_new_method_return( + station->connect_pending); + dbus_pending_reply(&station->connect_pending, reply); } /* @@ -2563,6 +2510,55 @@ static void station_connect_cb(struct netdev *netdev, enum netdev_result result, station_enter_state(station, STATION_STATE_CONNECTED); } +static void station_connect_cb(struct netdev *netdev, enum netdev_result result, + void *event_data, void *user_data) +{ + struct station *station = user_data; + bool during_eapol; + + l_debug("%u, result: %d", netdev_get_ifindex(station->netdev), result); + + switch (result) { + case NETDEV_RESULT_OK: + blacklist_remove_bss(station->connected_bss->addr); + station_connect_ok(station); + return; + case NETDEV_RESULT_HANDSHAKE_FAILED: + /* reason code in this case */ + if (station_retry_with_reason(station, l_get_u16(event_data))) + return; + + break; + case NETDEV_RESULT_AUTHENTICATION_FAILED: + case NETDEV_RESULT_ASSOCIATION_FAILED: + /* status code in this case */ + if (station_retry_with_status(station, l_get_u16(event_data))) + return; + + break; + default: + break; + } + + if (station->connect_pending) { + struct l_dbus_message *reply; + + if (result == NETDEV_RESULT_ABORTED) + reply = dbus_error_aborted(station->connect_pending); + else + reply = dbus_error_failed(station->connect_pending); + + dbus_pending_reply(&station->connect_pending, reply); + } + + if (result == NETDEV_RESULT_ABORTED) + return; + + during_eapol = result == NETDEV_RESULT_HANDSHAKE_FAILED; + network_connect_failed(station->connected_network, during_eapol); + station_disassociated(station); +} + int __station_connect_network(struct station *station, struct network *network, struct scan_bss *bss) {