Wireless Daemon for Linux
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.01.org
Subject: [PATCH 4/5] ap: add StartWithConfig DBus method
Date: Fri, 30 Oct 2020 09:34:12 -0700	[thread overview]
Message-ID: <20201030163413.2446645-4-prestwoj@gmail.com> (raw)
In-Reply-To: <20201030163413.2446645-1-prestwoj@gmail.com>

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

Users can now start an AP from settings based off a config file
on disk. The only argument is the SSID which will be used to
lookup the ap_config loaded during ap_init.
---
 src/ap.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/src/ap.c b/src/ap.c
index 956b7be9..92e8ce62 100644
--- a/src/ap.c
+++ b/src/ap.c
@@ -2711,6 +2711,44 @@ static struct l_dbus_message *ap_dbus_stop(struct l_dbus *dbus,
 	return NULL;
 }
 
+static bool match_ssid(const void *a, const void *data)
+{
+	const struct ap_config *config = a;
+	const char *ssid = data;
+
+	return !strcmp(config->ssid, ssid);
+}
+
+static struct l_dbus_message *ap_dbus_start_with_config(struct l_dbus *dbus,
+						struct l_dbus_message *message,
+						void *user_data)
+{
+	struct ap_if_data *ap_if = user_data;
+	const char *ssid;
+	struct ap_config *config;
+	int err;
+
+	if (ap_if->ap && ap_if->ap->started)
+		return dbus_error_already_exists(message);
+
+	if (ap_if->ap || ap_if->pending)
+		return dbus_error_busy(message);
+
+	if (!l_dbus_message_get_arguments(message, "s", &ssid))
+		return dbus_error_invalid_args(message);
+
+	config = l_queue_find(ap_configs, match_ssid, ssid);
+	if (!config)
+		return dbus_error_not_found(message);
+
+	ap_if->ap = ap_start(ap_if->netdev, config, &ap_dbus_ops, &err, ap_if);
+	if (!ap_if->ap)
+		return dbus_error_from_errno(err, message);
+
+	ap_if->pending = l_dbus_message_ref(message);
+	return NULL;
+}
+
 static bool ap_dbus_property_get_started(struct l_dbus *dbus,
 					struct l_dbus_message *message,
 					struct l_dbus_message_builder *builder,
@@ -2729,6 +2767,9 @@ static void ap_setup_interface(struct l_dbus_interface *interface)
 	l_dbus_interface_method(interface, "Start", 0, ap_dbus_start, "",
 			"ss", "ssid", "wpa2_passphrase");
 	l_dbus_interface_method(interface, "Stop", 0, ap_dbus_stop, "", "");
+	l_dbus_interface_method(interface, "StartWithConfig", 0,
+					ap_dbus_start_with_config, "", "s",
+					"ssid");
 
 	l_dbus_interface_property(interface, "Started", 0, "b",
 					ap_dbus_property_get_started, NULL);
-- 
2.26.2

  parent reply	other threads:[~2020-10-30 16:34 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-30 16:34 [PATCH 1/5] storage: add storage_network_filename_from_path James Prestwood
2020-10-30 16:34 ` [PATCH 2/5] storage: add storage_get_ap_path James Prestwood
2020-10-30 18:41   ` Denis Kenzior
2020-10-30 18:48     ` James Prestwood
2020-10-30 16:34 ` [PATCH 3/5] ap: add provisioning file parsing James Prestwood
2020-10-30 16:34 ` James Prestwood [this message]
2020-10-30 18:37   ` [PATCH 4/5] ap: add StartWithConfig DBus method Denis Kenzior
2020-10-30 18:42     ` James Prestwood
2020-10-30 16:34 ` [PATCH 5/5] ap: allow DHCP settings in provisioning files 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=20201030163413.2446645-4-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