station: only add diagnostic interface when connected
PATCH 1/2 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).
--- src/station.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
src/station.c +12 -11
@@ -1217,11 +1217,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 :
@@ -3411,9 +3421,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));
@@ -3588,12 +3595,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);
Signature · 1 line
2.26.2
PATCH 2/2 client: update to work with diagnostic changes
The diagnostic interface will now only come up when station is connected. This avoids the need for display station to return a 'connected' out parameter. We can instead just see that the diagnostic interface doesn't exist.
--- client/station.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
client/station.c +9 -10
@@ -142,8 +142,7 @@ static void check_errors_method_callback(struct l_dbus_message *message, }static void display_station (const char *device_name, -const struct proxy_interface *proxy, -bool *connected) +const struct proxy_interface *proxy) {const struct station *station =proxy_interface_get_data (proxy);char *caption =l_strdup_printf ("%s: %s" ,"Station" , device_name);
@@ -155,12 +154,13 @@ static void display_station(const char *device_name,display ("%s%*s %-*s%-*s\n" ,MARGIN ,8 ,"" ,20 ,"Connected network" ,47 ,network_get_name (station->connected_network)); - *connected = true; +/* +* If connected the diagnostic interface is presumably up so +* don't add the table footer just yet. +*/ return ; } - *connected = false; -display_table_footer (); }
@@ -623,20 +623,19 @@ static enum cmd_status cmd_show(const char *device_name,const struct proxy_interface *diagnostic =device_proxy_find (device_name,IWD_STATION_DIAGNOSTIC_INTERFACE ); -bool connected;if (!station) {display ("No station on device: '%s'\n" , device_name);return CMD_STATUS_INVALID_VALUE ; } -display_station (device_name, station, &connected); +display_station (device_name, station);/* -* No need to query additional diagnostic information if not connected, -* or IWD has no diagnostic interface. +* No need to query additional diagnostic information if IWD has +* no diagnostic interface. */ -if (!connected || !diagnostic) { +if (!diagnostic) {display_table_footer ();display_refresh_reset ();return CMD_STATUS_DONE ;
Signature · 1 line
2.26.2
Hi James,
Quoted 9 lines · James Prestwood
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).
--- src/station.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
Both applied, thanks.
Regards,
-Denis