All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/3] main: add a --developer,-E option
@ 2021-05-05 18:23 James Prestwood
  2021-05-05 18:23 ` [PATCH v2 2/3] station: add Roam() diagnostics method James Prestwood
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: James Prestwood @ 2021-05-05 18:23 UTC (permalink / raw)
  To: iwd

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

This will enable developer features to be used. Currently the
only user of this will be StationDiagnostics.Roam() method which
should only be exposed in this mode.
---
 src/iwd.h  |  1 +
 src/main.c | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

v2:
 * Added this patch to replace the dbus config changes

diff --git a/src/iwd.h b/src/iwd.h
index 51548cbb..1be20df3 100644
--- a/src/iwd.h
+++ b/src/iwd.h
@@ -41,3 +41,4 @@ const char *iwd_get_iface_blacklist(void);
 
 const char *iwd_get_phy_whitelist(void);
 const char *iwd_get_phy_blacklist(void);
+bool iwd_is_developer_mode(void);
diff --git a/src/main.c b/src/main.c
index 2ee6188c..8e965341 100644
--- a/src/main.c
+++ b/src/main.c
@@ -54,6 +54,7 @@ static const char *nointerfaces;
 static const char *phys;
 static const char *nophys;
 static const char *debugopt;
+static bool developeropt;
 static bool terminating;
 static bool nl80211_complete;
 
@@ -126,6 +127,11 @@ const char *iwd_get_phy_blacklist(void)
 	return nophys;
 }
 
+bool iwd_is_developer_mode(void)
+{
+	return developeropt;
+}
+
 static void usage(void)
 {
 	printf("iwd - Wireless daemon\n"
@@ -143,6 +149,7 @@ static void usage(void)
 }
 
 static const struct option main_options[] = {
+	{ "developer",    no_argument,       NULL, 'E' },
 	{ "dbus-debug",   no_argument,       NULL, 'B' },
 	{ "version",      no_argument,       NULL, 'v' },
 	{ "interfaces",   required_argument, NULL, 'i' },
@@ -363,7 +370,7 @@ int main(int argc, char *argv[])
 	for (;;) {
 		int opt;
 
-		opt = getopt_long(argc, argv, "Bi:I:p:P:d::vh",
+		opt = getopt_long(argc, argv, "EBi:I:p:P:d::vh",
 							main_options, NULL);
 		if (opt < 0)
 			break;
@@ -372,6 +379,9 @@ int main(int argc, char *argv[])
 		case 'B':
 			enable_dbus_debug = true;
 			break;
+		case 'E':
+			developeropt = true;
+			break;
 		case 'i':
 			interfaces = optarg;
 			break;
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] station: add Roam() diagnostics method
  2021-05-05 18:23 [PATCH v2 1/3] main: add a --developer,-E option James Prestwood
@ 2021-05-05 18:23 ` James Prestwood
  2021-05-05 18:23 ` [PATCH v2 3/3] test: add test utility for Roam() method James Prestwood
  2021-05-07 13:47 ` [PATCH v2 1/3] main: add a --developer,-E option Denis Kenzior
  2 siblings, 0 replies; 4+ messages in thread
From: James Prestwood @ 2021-05-05 18:23 UTC (permalink / raw)
  To: iwd

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

This is being added as a developer method and should not be used
in production. For testing purposes though, it is quite useful as
it forces IWD to roam to a provided BSS and bypasses IWD's roaming
and ranking logic for choosing a roam candidate.

To use this a BSSID is provided as the only parameter. If this
BSS is not in IWD's current scan results -EINVAL will be returned.
If IWD knows about the BSS it will attempt to roam to it whether
that is via FT, FT-over-DS, or Reassociation. These details are
still sorted out in IWDs station_transition_start() logic.
---
 src/station.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

v2:
 * Check developer mode before adding Roam method

diff --git a/src/station.c b/src/station.c
index d2234e15..479f81f5 100644
--- a/src/station.c
+++ b/src/station.c
@@ -3721,12 +3721,49 @@ static struct l_dbus_message *station_get_diagnostics(struct l_dbus *dbus,
 	return NULL;
 }
 
+static struct l_dbus_message *station_force_roam(struct l_dbus *dbus,
+						struct l_dbus_message *message,
+						void *user_data)
+{
+	struct station *station = user_data;
+	struct scan_bss *target;
+	struct l_dbus_message_iter iter;
+	uint8_t *mac;
+	uint32_t mac_len;
+
+	if (!l_dbus_message_get_arguments(message, "ay", &iter))
+		goto invalid_args;
+
+	if (!l_dbus_message_iter_get_fixed_array(&iter, &mac, &mac_len))
+		goto invalid_args;
+
+	if (mac_len != 6)
+		return dbus_error_invalid_args(message);
+
+	target = network_bss_find_by_addr(station->connected_network, mac);
+	if (!target || target == station->connected_bss)
+		return dbus_error_invalid_args(message);
+
+	l_debug("Attempting forced roam to BSS "MAC, MAC_STR(mac));
+
+	station_transition_start(station, target);
+
+	return l_dbus_message_new_method_return(message);
+
+invalid_args:
+	return dbus_error_invalid_args(message);
+}
+
 static void station_setup_diagnostic_interface(
 					struct l_dbus_interface *interface)
 {
 	l_dbus_interface_method(interface, "GetDiagnostics", 0,
 				station_get_diagnostics, "a{sv}", "",
 				"diagnostics");
+
+	if (iwd_is_developer_mode())
+		l_dbus_interface_method(interface, "Roam", 0,
+					station_force_roam, "", "ay", "mac");
 }
 
 static void station_destroy_diagnostic_interface(void *user_data)
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] test: add test utility for Roam() method
  2021-05-05 18:23 [PATCH v2 1/3] main: add a --developer,-E option James Prestwood
  2021-05-05 18:23 ` [PATCH v2 2/3] station: add Roam() diagnostics method James Prestwood
@ 2021-05-05 18:23 ` James Prestwood
  2021-05-07 13:47 ` [PATCH v2 1/3] main: add a --developer,-E option Denis Kenzior
  2 siblings, 0 replies; 4+ messages in thread
From: James Prestwood @ 2021-05-05 18:23 UTC (permalink / raw)
  To: iwd

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

---
 test/force-roam | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100755 test/force-roam

diff --git a/test/force-roam b/test/force-roam
new file mode 100755
index 00000000..b590c84a
--- /dev/null
+++ b/test/force-roam
@@ -0,0 +1,16 @@
+#!/usr/bin/python3
+
+import sys
+import dbus
+
+if (len(sys.argv) != 3):
+    print("Usage: %s <device> <mac>" % (sys.argv[0]))
+    sys.exit(1)
+
+bus = dbus.SystemBus()
+device = dbus.Interface(bus.get_object("net.connman.iwd", sys.argv[1]),
+                                    "net.connman.iwd.StationDiagnostic")
+
+mac = sys.argv[2].replace(':', '')
+
+device.Roam(dbus.ByteArray.fromhex(mac))
-- 
2.26.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/3] main: add a --developer,-E option
  2021-05-05 18:23 [PATCH v2 1/3] main: add a --developer,-E option James Prestwood
  2021-05-05 18:23 ` [PATCH v2 2/3] station: add Roam() diagnostics method James Prestwood
  2021-05-05 18:23 ` [PATCH v2 3/3] test: add test utility for Roam() method James Prestwood
@ 2021-05-07 13:47 ` Denis Kenzior
  2 siblings, 0 replies; 4+ messages in thread
From: Denis Kenzior @ 2021-05-07 13:47 UTC (permalink / raw)
  To: iwd

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

Hi James,

On 5/5/21 1:23 PM, James Prestwood wrote:
> This will enable developer features to be used. Currently the
> only user of this will be StationDiagnostics.Roam() method which
> should only be exposed in this mode.
> ---
>   src/iwd.h  |  1 +
>   src/main.c | 12 +++++++++++-
>   2 files changed, 12 insertions(+), 1 deletion(-)
> 
> v2:
>   * Added this patch to replace the dbus config changes
> 

All applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-07 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 18:23 [PATCH v2 1/3] main: add a --developer,-E option James Prestwood
2021-05-05 18:23 ` [PATCH v2 2/3] station: add Roam() diagnostics method James Prestwood
2021-05-05 18:23 ` [PATCH v2 3/3] test: add test utility for Roam() method James Prestwood
2021-05-07 13:47 ` [PATCH v2 1/3] main: add a --developer,-E option Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.