From edf556cc7bb9a323e1df0cec6e35654ceffb5f8f Mon Sep 17 00:00:00 2001 From: James Prestwood Date: Wed, 28 Sep 2022 11:33:50 -0700 Subject: [PATCH] station: add two new roaming states (FT/FW) This adds two new station states to differentiate between reassociation (ROAMING), Fast transition (FT_ROAMING) or a firmare based roam (FW_ROAMING). --- src/station.c | 33 +++++++++++++++++++++++++-------- src/station.h | 4 +++- src/wsc.c | 2 ++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/station.c b/src/station.c index 372e23c1..6bd66ffc 100644 --- a/src/station.c +++ b/src/station.c @@ -197,6 +197,13 @@ static bool station_is_autoconnecting(struct station *station) station->state == STATION_STATE_AUTOCONNECT_QUICK; } +static bool station_is_roaming(struct station *station) +{ + return station->state == STATION_STATE_ROAMING || + station->state == STATION_STATE_FT_ROAMING || + station->state == STATION_STATE_FW_ROAMING; +} + static bool station_debug_event(struct station *station, const char *name) { struct l_dbus_message *signal; @@ -1461,6 +1468,10 @@ static const char *station_state_to_string(enum station_state state) return "disconnecting"; case STATION_STATE_ROAMING: return "roaming"; + case STATION_STATE_FT_ROAMING: + return "ft-roaming"; + case STATION_STATE_FW_ROAMING: + return "fw-roaming"; } return "invalid"; @@ -1599,6 +1610,8 @@ static void station_enter_state(struct station *station, case STATION_STATE_DISCONNECTING: break; case STATION_STATE_ROAMING: + case STATION_STATE_FT_ROAMING: + case STATION_STATE_FW_ROAMING: station_set_evict_nocarrier(station, false); break; } @@ -1722,7 +1735,7 @@ static void station_reset_connection_state(struct station *station) if (station->state == STATION_STATE_CONNECTED || station->state == STATION_STATE_CONNECTING || station->state == STATION_STATE_CONNECTING_AUTO || - station->state == STATION_STATE_ROAMING) + station_is_roaming(station)) network_disconnected(network); } @@ -2055,7 +2068,7 @@ static void station_roam_failed(struct station *station) * If we attempted a reassociation or a fast transition, and ended up * here then we are now disconnected. */ - if (station->state == STATION_STATE_ROAMING) { + if (station_is_roaming(station)) { station_disassociated(station); return; } @@ -2245,7 +2258,7 @@ try_next: station->connected_bss = bss; station->preparing_roam = false; - station_enter_state(station, STATION_STATE_ROAMING); + station_enter_state(station, STATION_STATE_FT_ROAMING); return true; @@ -2288,7 +2301,7 @@ static bool station_fast_transition(struct station *station, station->connected_bss = bss; station->preparing_roam = false; - station_enter_state(station, STATION_STATE_ROAMING); + station_enter_state(station, STATION_STATE_FT_ROAMING); return true; } else { @@ -2742,7 +2755,8 @@ static bool station_cannot_roam(struct station *station) disabled = false; return disabled || station->preparing_roam || - station->state == STATION_STATE_ROAMING; + station->state == STATION_STATE_ROAMING || + station->state == STATION_STATE_FT_ROAMING; } #define WNM_REQUEST_MODE_PREFERRED_CANDIDATE_LIST (1 << 0) @@ -3180,7 +3194,8 @@ static void station_disconnect_event(struct station *station, void *event_data) event_data, station); return; case STATION_STATE_CONNECTED: - case STATION_STATE_ROAMING: + case STATION_STATE_FT_ROAMING: + case STATION_STATE_FW_ROAMING: station_disassociated(station); return; default: @@ -3234,7 +3249,7 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event, station_signal_agent_notify(station); break; case NETDEV_EVENT_ROAMING: - station_enter_state(station, STATION_STATE_ROAMING); + station_enter_state(station, STATION_STATE_FW_ROAMING); break; case NETDEV_EVENT_ROAMED: station_event_roamed(station, (struct scan_bss *) event_data); @@ -3246,7 +3261,7 @@ static void station_netdev_event(struct netdev *netdev, enum netdev_event event, station_packets_lost(station, l_get_u32(event_data)); break; case NETDEV_EVENT_FT_ROAMED: - if (station->state != STATION_STATE_ROAMING) + if (L_WARN_ON(station->state != STATION_STATE_FT_ROAMING)) return; station_roamed(station); @@ -4069,6 +4084,8 @@ static bool station_property_get_state(struct l_dbus *dbus, statestr = "disconnecting"; break; case STATION_STATE_ROAMING: + case STATION_STATE_FT_ROAMING: + case STATION_STATE_FW_ROAMING: statestr = "roaming"; break; } diff --git a/src/station.h b/src/station.h index 67d22f03..24fab321 100644 --- a/src/station.h +++ b/src/station.h @@ -42,7 +42,9 @@ enum station_state { STATION_STATE_CONNECTING_AUTO, STATION_STATE_CONNECTED, STATION_STATE_DISCONNECTING, - STATION_STATE_ROAMING + STATION_STATE_ROAMING, /* Reassociation */ + STATION_STATE_FT_ROAMING, /* Fast transition */ + STATION_STATE_FW_ROAMING, /* Firmware roamed by itself */ }; enum station_event { diff --git a/src/wsc.c b/src/wsc.c index bb9f663b..cb2e2c3e 100644 --- a/src/wsc.c +++ b/src/wsc.c @@ -665,6 +665,8 @@ static void wsc_check_can_connect(struct wsc_station_dbus *wsc, case STATION_STATE_AUTOCONNECT_QUICK: case STATION_STATE_AUTOCONNECT_FULL: case STATION_STATE_ROAMING: + case STATION_STATE_FT_ROAMING: + case STATION_STATE_FW_ROAMING: l_warn("%s: invalid station state", __func__); break; }