Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 5/5] client: ap: show SSID in 'ap <wlan> show'
Date: Mon, 01 Feb 2021 14:05:18 -0800	[thread overview]
Message-ID: <20210201220518.36975-5-prestwoj@gmail.com> (raw)
In-Reply-To: <20210201220518.36975-1-prestwoj@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2467 bytes --]

This will show some basic AP information like Started and
SSID. Some cleanup was done to make the AP interface and
client table columns line up.
---
 client/ap.c | 39 ++++++++++++++++++++++++++++++++++++---
 1 file changed, 36 insertions(+), 3 deletions(-)

diff --git a/client/ap.c b/client/ap.c
index 9a7f8642..783f1e19 100644
--- a/client/ap.c
+++ b/client/ap.c
@@ -34,6 +34,7 @@
 
 struct ap {
 	bool started;
+	char *ssid;
 };
 
 static void *ap_create(void)
@@ -74,8 +75,35 @@ static void update_started(void *data, struct l_dbus_message_iter *variant)
 	ap->started = value;
 }
 
+static const char *get_ssid_tostr(const void *data)
+{
+	const struct ap *ap = data;
+
+	if (!ap->ssid)
+		return "";
+
+	return ap->ssid;
+}
+
+static void update_ssid(void *data, struct l_dbus_message_iter *variant)
+{
+	struct ap *ap = data;
+	const char *ssid;
+
+	if (ap->ssid)
+		l_free(ap->ssid);
+
+	if (!l_dbus_message_iter_get_variant(variant, "s", &ssid)) {
+		ap->ssid = NULL;
+		return;
+	}
+
+	ap->ssid = l_strdup(ssid);
+}
+
 static const struct proxy_interface_property ap_properties[] = {
 	{ "Started",  "b", update_started,  get_started_tostr },
+	{ "SSID",     "s", update_ssid, get_ssid_tostr },
 	{ }
 };
 
@@ -221,9 +249,9 @@ static void ap_get_diagnostics_callback(struct l_dbus_message *message,
 
 	while (l_dbus_message_iter_next_entry(&array, &iter)) {
 		sprintf(client_num, "Client %u", idx++);
-		display_table_header(client_num, "%-*s%-*s",
+		display_table_header(client_num, "            %-*s%-*s",
 					20, "Property", 20, "Value");
-		diagnostic_display(&iter, "", 20, 20);
+		diagnostic_display(&iter, "            ", 20, 20);
 		display_table_footer();
 	}
 }
@@ -232,12 +260,17 @@ static enum cmd_status cmd_show(const char *device_name, char **argv, int argc)
 {
 	const struct proxy_interface *ap_diagnostic =
 		device_proxy_find(device_name, IWD_AP_DIAGNOSTIC_INTERFACE);
+	const struct proxy_interface *ap_i =
+		device_proxy_find(device_name, IWD_ACCESS_POINT_INTERFACE);
 
-	if (!ap_diagnostic) {
+	if (!ap_diagnostic || !ap_i) {
 		display("No ap on device: '%s'\n", device_name);
 		return CMD_STATUS_INVALID_VALUE;
 	}
 
+	proxy_properties_display(ap_i, "Access Point Interface", MARGIN, 20, 20);
+	display_table_footer();
+
 	proxy_interface_method_call(ap_diagnostic, "GetDiagnostics", "",
 					ap_get_diagnostics_callback);
 
-- 
2.26.2

  parent reply	other threads:[~2021-02-01 22:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-01 22:05 [PATCH 1/5] ap: return error from GetDiagnostics if not started James Prestwood
2021-02-01 22:05 ` [PATCH 2/5] client: ap: handle NotFound on diagnostic interface James Prestwood
2021-02-01 22:05 ` [PATCH 3/5] ap: add SSID property James Prestwood
2021-02-01 22:05 ` [PATCH 4/5] doc: document SSID property on AP interface James Prestwood
2021-02-01 22:21   ` Denis Kenzior
2021-02-01 22:05 ` James Prestwood [this message]
2021-02-01 22:10   ` [PATCH 5/5] client: ap: show SSID in 'ap <wlan> show' James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210201220518.36975-5-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox