mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2025-02-18 09:10:38 +01:00
client: add "dpp <wlan> show" command
This will show the newly added DPP properties
This commit is contained in:
parent
2c92a5e137
commit
030251e78d
117
client/dpp.c
117
client/dpp.c
@ -34,8 +34,111 @@
|
|||||||
#include "client/device.h"
|
#include "client/device.h"
|
||||||
#include "client/display.h"
|
#include "client/display.h"
|
||||||
|
|
||||||
|
struct dpp {
|
||||||
|
bool started;
|
||||||
|
char *role;
|
||||||
|
char *uri;
|
||||||
|
};
|
||||||
|
|
||||||
|
static void *dpp_create(void)
|
||||||
|
{
|
||||||
|
return l_new(struct dpp, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dpp_destroy(void *data)
|
||||||
|
{
|
||||||
|
struct dpp *dpp = data;
|
||||||
|
|
||||||
|
if (dpp->role)
|
||||||
|
l_free(dpp->role);
|
||||||
|
if (dpp->uri)
|
||||||
|
l_free(dpp->uri);
|
||||||
|
|
||||||
|
l_free(dpp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_started(void *data, struct l_dbus_message_iter *variant)
|
||||||
|
{
|
||||||
|
struct dpp *dpp = data;
|
||||||
|
bool value;
|
||||||
|
|
||||||
|
if (!l_dbus_message_iter_get_variant(variant, "b", &value)) {
|
||||||
|
dpp->started = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpp->started = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *started_tostr(const void *data)
|
||||||
|
{
|
||||||
|
const struct dpp *dpp = data;
|
||||||
|
|
||||||
|
return dpp->started ? "yes" : "no";
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_role(void *data, struct l_dbus_message_iter *variant)
|
||||||
|
{
|
||||||
|
struct dpp *dpp = data;
|
||||||
|
const char *value;
|
||||||
|
|
||||||
|
if (dpp->role)
|
||||||
|
l_free(dpp->role);
|
||||||
|
|
||||||
|
if (!l_dbus_message_iter_get_variant(variant, "s", &value)) {
|
||||||
|
dpp->role = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpp->role = l_strdup(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *role_tostr(const void *data)
|
||||||
|
{
|
||||||
|
const struct dpp *dpp = data;
|
||||||
|
|
||||||
|
return dpp->role;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void update_uri(void *data, struct l_dbus_message_iter *variant)
|
||||||
|
{
|
||||||
|
struct dpp *dpp = data;
|
||||||
|
const char *value;
|
||||||
|
|
||||||
|
if (dpp->uri)
|
||||||
|
l_free(dpp->uri);
|
||||||
|
|
||||||
|
if (!l_dbus_message_iter_get_variant(variant, "s", &value)) {
|
||||||
|
dpp->uri = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dpp->uri = l_strdup(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *uri_tostr(const void *data)
|
||||||
|
{
|
||||||
|
const struct dpp *dpp = data;
|
||||||
|
|
||||||
|
return dpp->uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct proxy_interface_property dpp_properties[] = {
|
||||||
|
{ "Started", "b", update_started, started_tostr },
|
||||||
|
{ "Role", "s", update_role, role_tostr },
|
||||||
|
{ "URI", "s", update_uri, uri_tostr },
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct proxy_interface_type_ops dpp_ops = {
|
||||||
|
.create = dpp_create,
|
||||||
|
.destroy = dpp_destroy,
|
||||||
|
};
|
||||||
|
|
||||||
static struct proxy_interface_type dpp_interface_type = {
|
static struct proxy_interface_type dpp_interface_type = {
|
||||||
.interface = IWD_DPP_INTERFACE,
|
.interface = IWD_DPP_INTERFACE,
|
||||||
|
.properties = dpp_properties,
|
||||||
|
.ops = &dpp_ops,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void check_errors_method_callback(struct l_dbus_message *message,
|
static void check_errors_method_callback(struct l_dbus_message *message,
|
||||||
@ -174,6 +277,19 @@ static enum cmd_status cmd_stop(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 *proxy =
|
||||||
|
device_proxy_find(device_name, IWD_DPP_INTERFACE);
|
||||||
|
char *caption = l_strdup_printf("%s: %s", "DPP", device_name);
|
||||||
|
|
||||||
|
proxy_properties_display(proxy, caption, MARGIN, 20, 47);
|
||||||
|
l_free(caption);
|
||||||
|
|
||||||
|
return CMD_STATUS_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
static const struct command dpp_commands[] = {
|
static const struct command dpp_commands[] = {
|
||||||
{ NULL, "list", NULL, cmd_list, "List DPP-capable devices", true },
|
{ NULL, "list", NULL, cmd_list, "List DPP-capable devices", true },
|
||||||
{ "<wlan>", "start-enrollee", NULL, cmd_start_enrollee,
|
{ "<wlan>", "start-enrollee", NULL, cmd_start_enrollee,
|
||||||
@ -181,6 +297,7 @@ static const struct command dpp_commands[] = {
|
|||||||
{ "<wlan>", "start-configurator", NULL, cmd_start_configurator,
|
{ "<wlan>", "start-configurator", NULL, cmd_start_configurator,
|
||||||
"Starts a DPP Configurator" },
|
"Starts a DPP Configurator" },
|
||||||
{ "<wlan>", "stop", NULL, cmd_stop, "Aborts DPP operations" },
|
{ "<wlan>", "stop", NULL, cmd_stop, "Aborts DPP operations" },
|
||||||
|
{ "<wlan>", "show", NULL, cmd_show, "Shows the DPP state" },
|
||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user