3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-22 14:49:24 +01:00

client: Add 'show' command to device in station mode

This commit is contained in:
Tim Kourt 2019-02-26 09:51:31 -08:00 committed by Denis Kenzior
parent d47e31954b
commit 569ffdd508

View File

@ -136,6 +136,23 @@ static void check_errors_method_callback(struct l_dbus_message *message,
dbus_message_has_error(message); dbus_message_has_error(message);
} }
static void display_station(const char *device_name,
const struct proxy_interface *proxy)
{
const struct station *station = proxy_interface_get_data(proxy);
char *caption = l_strdup_printf("%s: %s", "Station", device_name);
proxy_properties_display(proxy, caption, MARGIN, 20, 47);
l_free(caption);
if (station->connected_network)
display("%s%*s %-*s%-*s\n", MARGIN, 8, "", 20,
"Connected network", 47,
network_get_name(station->connected_network));
display_table_footer();
}
static void display_station_inline(const char *margin, const void *data) static void display_station_inline(const char *margin, const void *data)
{ {
const struct proxy_interface *station_i = data; const struct proxy_interface *station_i = data;
@ -578,6 +595,22 @@ static enum cmd_status cmd_scan(const char *device_name,
return CMD_STATUS_TRIGGERED; return CMD_STATUS_TRIGGERED;
} }
static enum cmd_status cmd_show(const char *device_name,
char **argv, int argc)
{
const struct proxy_interface *station =
device_proxy_find(device_name, IWD_STATION_INTERFACE);
if (!station) {
display("No station on device: '%s'\n", device_name);
return CMD_STATUS_INVALID_VALUE;
}
display_station(device_name, station);
return CMD_STATUS_DONE;
}
static const struct command station_commands[] = { static const struct command station_commands[] = {
{ NULL, "list", NULL, cmd_list, "List devices in Station mode", true }, { NULL, "list", NULL, cmd_list, "List devices in Station mode", true },
{ "<wlan>", "connect", { "<wlan>", "connect",
@ -601,6 +634,7 @@ static const struct command station_commands[] = {
cmd_get_hidden_access_points, cmd_get_hidden_access_points,
"Get hidden APs", true }, "Get hidden APs", true },
{ "<wlan>", "scan", NULL, cmd_scan, "Scan for networks" }, { "<wlan>", "scan", NULL, cmd_scan, "Scan for networks" },
{ "<wlan>", "show", NULL, cmd_show, "Show station info", true },
{ } { }
}; };