commit c3e160880f32f8e7ce7e3aa10b7a8dd9bf6bbe34
parent 6ced1ec9def9c7e265f631aba4700962a247b912
Author: James Prestwood <prestwoj@gmail.com>
Date: Wed, 3 Feb 2021 11:07:04 -0800
station: only add diagnostic interface when connected
The diagnostic interface returns an error anyways if station is
not connected so it makes more sense to only bring the interface
up when its actually usable. This also removes the interface
when station disconnects, which was never done before (the
interface stayed up indefinitely due to a forgotten remove call).
Diffstat:
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/src/station.c b/src/station.c
@@ -1255,11 +1255,21 @@ static void station_enter_state(struct station *station,
l_dbus_property_changed(dbus,
network_get_path(station->connected_network),
IWD_NETWORK_INTERFACE, "Connected");
- /* fall through */
+
+ periodic_scan_stop(station);
+ break;
case STATION_STATE_DISCONNECTED:
+ l_dbus_object_remove_interface(dbus_get_bus(),
+ netdev_get_path(station->netdev),
+ IWD_STATION_DIAGNOSTIC_INTERFACE);
+ periodic_scan_stop(station);
+ break;
case STATION_STATE_CONNECTED:
+ l_dbus_object_add_interface(dbus,
+ netdev_get_path(station->netdev),
+ IWD_STATION_DIAGNOSTIC_INTERFACE,
+ station);
periodic_scan_stop(station);
-
break;
case STATION_STATE_DISCONNECTING:
case STATION_STATE_ROAMING:
@@ -3451,9 +3461,6 @@ static struct station *station_create(struct netdev *netdev)
l_dbus_object_add_interface(dbus, netdev_get_path(netdev),
IWD_STATION_INTERFACE, station);
- l_dbus_object_add_interface(dbus, netdev_get_path(netdev),
- IWD_STATION_DIAGNOSTIC_INTERFACE,
- station);
if (netconfig_enabled)
station->netconfig = netconfig_new(netdev_get_ifindex(netdev));
@@ -3628,12 +3635,6 @@ static struct l_dbus_message *station_get_diagnostics(struct l_dbus *dbus,
struct station *station = user_data;
int ret;
- /*
- * At this time all values depend on a connected state.
- */
- if (station->state != STATION_STATE_CONNECTED)
- return dbus_error_not_connected(message);
-
ret = netdev_get_current_station(station->netdev,
station_get_diagnostic_cb, station,
station_get_diagnostic_destroy);