connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering
@ 2021-10-07 21:30 Michael Trimarchi
  2021-10-07 21:30 ` [PATCH 2/4] tethering: Add possibility to configure the access point frequency Michael Trimarchi
                   ` (4 more replies)
  0 siblings, 5 replies; 14+ messages in thread
From: Michael Trimarchi @ 2021-10-07 21:30 UTC (permalink / raw)
  To: connman, Daniel Wagner

connman_echnology is an opaque type but has all the parameters to handle
the connection. Those parameters are only used in wifi tethering
one and not in other technologies

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 include/technology.h |  8 ++++++--
 plugins/bluetooth.c  |  1 -
 plugins/ethernet.c   |  1 -
 plugins/gadget.c     |  1 -
 plugins/wifi.c       | 25 ++++++++++++-------------
 src/technology.c     | 20 ++++++++++++--------
 6 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/include/technology.h b/include/technology.h
index 7508a9a1..7febd109 100644
--- a/include/technology.h
+++ b/include/technology.h
@@ -44,8 +44,13 @@ void connman_technology_regdom_notify(struct connman_technology *technology,
 
 enum connman_service_type connman_technology_get_type
 				(struct connman_technology *technology);
+
+bool connman_get_wifi_tethering_from_technology(const struct connman_technology *technology,
+						const char **ssid, const char **psk);
+
 bool connman_technology_get_wifi_tethering(const char **ssid,
-							const char **psk);
+						const char **psk);
+
 bool connman_technology_is_tethering_allowed(enum connman_service_type type);
 
 struct connman_technology_driver {
@@ -60,7 +65,6 @@ struct connman_technology_driver {
 	void (*remove_interface) (struct connman_technology *technology,
 								int index);
 	int (*set_tethering) (struct connman_technology *technology,
-				const char *identifier, const char *passphrase,
 				const char *bridge, bool enabled);
 	int (*set_regdom) (struct connman_technology *technology,
 						const char *alpha2);
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 53361034..57cc8a29 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -882,7 +882,6 @@ static void bluetooth_tech_remove(struct connman_technology *technology)
 }
 
 static int bluetooth_tech_set_tethering(struct connman_technology *technology,
-		const char *identifier, const char *passphrase,
 		const char *bridge, bool enabled)
 {
 	GHashTableIter hash_iter;
diff --git a/plugins/ethernet.c b/plugins/ethernet.c
index 6146b1c0..0bf7fc41 100644
--- a/plugins/ethernet.c
+++ b/plugins/ethernet.c
@@ -407,7 +407,6 @@ static void eth_tech_disable_tethering(struct connman_technology *technology,
 }
 
 static int eth_tech_set_tethering(struct connman_technology *technology,
-				const char *identifier, const char *passphrase,
 				const char *bridge, bool enabled)
 {
 	if (!connman_technology_is_tethering_allowed(
diff --git a/plugins/gadget.c b/plugins/gadget.c
index 1b44bbb5..2d58df3e 100644
--- a/plugins/gadget.c
+++ b/plugins/gadget.c
@@ -294,7 +294,6 @@ static void gadget_tech_disable_tethering(struct connman_technology *technology,
 }
 
 static int gadget_tech_set_tethering(struct connman_technology *technology,
-				const char *identifier, const char *passphrase,
 				const char *bridge, bool enabled)
 {
 	DBG("bridge %s enabled %d", bridge, enabled);
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 578b4be7..cebe6886 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -183,7 +183,6 @@ static bool wfd_service_registered = false;
 
 static void start_autoscan(struct connman_device *device);
 static int tech_set_tethering(struct connman_technology *technology,
-				const char *identifier, const char *passphrase,
 				const char *bridge, bool enabled);
 
 static int p2p_tech_probe(struct connman_technology *technology)
@@ -2791,8 +2790,6 @@ static void ap_create_fail(GSupplicantInterface *interface)
 		wifi->tethering = false;
 
 		ret = tech_set_tethering(wifi->tethering_param->technology,
-				wifi->tethering_param->ssid->ssid,
-				wifi->tethering_param->ssid->passphrase,
 				wifi->bridge, true);
 
 		if ((ret == -EOPNOTSUPP) && (wifi_technology)) {
@@ -3336,14 +3333,20 @@ static void tech_remove(struct connman_technology *technology)
 	wifi_technology = NULL;
 }
 
-static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
+static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology)
 {
 	GSupplicantSSID *ap;
+	const char *ssid, *passphrase;
+	bool ret;
 
 	ap = g_try_malloc0(sizeof(GSupplicantSSID));
 	if (!ap)
 		return NULL;
 
+	ret = connman_get_wifi_tethering_from_technology(technology, &ssid, &passphrase);
+	if (ret == false)
+		return NULL;
+
 	ap->mode = G_SUPPLICANT_MODE_MASTER;
 	ap->ssid = ssid;
 	ap->ssid_len = strlen(ssid);
@@ -3458,8 +3461,7 @@ static void sta_remove_callback(int result,
 }
 
 static int enable_wifi_tethering(struct connman_technology *technology,
-				const char *bridge, const char *identifier,
-				const char *passphrase, bool available)
+				const char *bridge, bool available)
 {
 	GList *list;
 	GSupplicantInterface *interface;
@@ -3512,14 +3514,14 @@ static int enable_wifi_tethering(struct connman_technology *technology,
 		info->wifi = wifi;
 		info->technology = technology;
 		info->wifi->bridge = bridge;
-		info->ssid = ssid_ap_init(identifier, passphrase);
+		info->ssid = ssid_ap_init(technology);
 		if (!info->ssid)
 			goto failed;
 
 		info->ifname = g_strdup(ifname);
 
 		wifi->tethering_param->technology = technology;
-		wifi->tethering_param->ssid = ssid_ap_init(identifier, passphrase);
+		wifi->tethering_param->ssid = ssid_ap_init(technology);
 		if (!wifi->tethering_param->ssid)
 			goto failed;
 
@@ -3561,7 +3563,6 @@ static int enable_wifi_tethering(struct connman_technology *technology,
 }
 
 static int tech_set_tethering(struct connman_technology *technology,
-				const char *identifier, const char *passphrase,
 				const char *bridge, bool enabled)
 {
 	GList *list;
@@ -3589,13 +3590,11 @@ static int tech_set_tethering(struct connman_technology *technology,
 	}
 
 	DBG("trying tethering for available devices");
-	err = enable_wifi_tethering(technology, bridge, identifier, passphrase,
-				true);
+	err = enable_wifi_tethering(technology, bridge, true);
 
 	if (err < 0) {
 		DBG("trying tethering for any device");
-		err = enable_wifi_tethering(technology, bridge, identifier,
-					passphrase, false);
+		err = enable_wifi_tethering(technology, bridge, false);
 	}
 
 	return err;
diff --git a/src/technology.c b/src/technology.c
index 672d6ea8..e0457890 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -264,8 +264,7 @@ static int set_tethering(struct connman_technology *technology,
 		if (!driver || !driver->set_tethering)
 			continue;
 
-		err = driver->set_tethering(technology, ident, passphrase,
-				bridge, enabled);
+		err = driver->set_tethering(technology, bridge, enabled);
 
 		if (result == -EINPROGRESS)
 			continue;
@@ -356,8 +355,16 @@ enum connman_service_type connman_technology_get_type
 	return technology->type;
 }
 
-bool connman_technology_get_wifi_tethering(const char **ssid,
-							const char **psk)
+bool connman_get_wifi_tethering_from_technology(const struct connman_technology *technology,
+						const char **ssid, const char **psk)
+{
+	*ssid = technology->tethering_ident;
+	*psk = technology->tethering_passphrase;
+
+	return true;
+}
+
+bool connman_technology_get_wifi_tethering(const char **ssid, const char **psk)
 {
 	struct connman_technology *technology;
 
@@ -373,10 +380,7 @@ bool connman_technology_get_wifi_tethering(const char **ssid,
 	if (!technology->tethering)
 		return false;
 
-	*ssid = technology->tethering_ident;
-	*psk = technology->tethering_passphrase;
-
-	return true;
+	return connman_get_wifi_tethering_from_technology(technology, ssid, psk);
 }
 
 static void free_rfkill(gpointer data)
-- 
2.25.1


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

* [PATCH 2/4] tethering: Add possibility to configure the access point frequency
  2021-10-07 21:30 [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Michael Trimarchi
@ 2021-10-07 21:30 ` Michael Trimarchi
  2021-10-15  6:52   ` Daniel Wagner
  2021-10-07 21:30 ` [PATCH 3/4] tethering: Add TetheringFreq parameter documentation Michael Trimarchi
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 14+ messages in thread
From: Michael Trimarchi @ 2021-10-07 21:30 UTC (permalink / raw)
  To: connman, Daniel Wagner

When the tethering mode is started, a WiFi ap is created using the fixed
channel 1 (2412 MHz). Add a way to configure the channel

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 include/technology.h |  4 ++--
 plugins/neard.c      |  3 ++-
 plugins/wifi.c       |  9 +++++++--
 src/technology.c     | 45 +++++++++++++++++++++++++++++++++++++++++---
 4 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/include/technology.h b/include/technology.h
index 7febd109..d89c8164 100644
--- a/include/technology.h
+++ b/include/technology.h
@@ -46,10 +46,10 @@ enum connman_service_type connman_technology_get_type
 				(struct connman_technology *technology);
 
 bool connman_get_wifi_tethering_from_technology(const struct connman_technology *technology,
-						const char **ssid, const char **psk);
+						const char **ssid, const char **psk, int *freq);
 
 bool connman_technology_get_wifi_tethering(const char **ssid,
-						const char **psk);
+						const char **psk, int *freq);
 
 bool connman_technology_is_tethering_allowed(enum connman_service_type type);
 
diff --git a/plugins/neard.c b/plugins/neard.c
index 45effd44..b0cdbde0 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -222,10 +222,11 @@ static DBusMessage *create_request_oob_reply(DBusMessage *message)
 	DBusMessageIter iter;
 	DBusMessageIter dict;
 	const char *ssid, *psk;
+	int freq;
 	uint8_t *tlv_msg;
 	int length;
 
-	if (!connman_technology_get_wifi_tethering(&ssid, &psk))
+	if (!connman_technology_get_wifi_tethering(&ssid, &psk, &freq))
 		return get_reply_on_error(message, ENOTSUP);
 
 	tlv_msg = encode_to_tlv(ssid, psk, &length);
diff --git a/plugins/wifi.c b/plugins/wifi.c
index cebe6886..4f859e31 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -3337,13 +3337,15 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology
 {
 	GSupplicantSSID *ap;
 	const char *ssid, *passphrase;
+	int freq;
 	bool ret;
 
 	ap = g_try_malloc0(sizeof(GSupplicantSSID));
 	if (!ap)
 		return NULL;
 
-	ret = connman_get_wifi_tethering_from_technology(technology, &ssid, &passphrase);
+	ret = connman_get_wifi_tethering_from_technology(technology, &ssid, &passphrase,
+							 &freq);
 	if (ret == false)
 		return NULL;
 
@@ -3351,7 +3353,10 @@ static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology
 	ap->ssid = ssid;
 	ap->ssid_len = strlen(ssid);
 	ap->scan_ssid = 0;
-	ap->freq = 2412;
+	if (freq)
+		ap->freq = freq;
+	else
+		ap->freq = 2412;
 
 	if (!passphrase || strlen(passphrase) == 0) {
 		ap->security = G_SUPPLICANT_SECURITY_NONE;
diff --git a/src/technology.c b/src/technology.c
index e0457890..7d5f6a4b 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -66,6 +66,7 @@ struct connman_technology {
 					      */
 	char *tethering_ident;
 	char *tethering_passphrase;
+	int tethering_freq;
 
 	bool enable_persistent; /* Save the tech state */
 
@@ -192,6 +193,13 @@ static void technology_save(struct connman_technology *technology)
 		g_free(enc);
 	}
 
+	if (technology->tethering_freq == 0)
+		technology->tethering_freq = 2412;
+
+	g_key_file_set_integer(keyfile, identifier,
+				"Tethering.Freq",
+				technology->tethering_freq);
+
 done:
 	g_free(identifier);
 
@@ -356,15 +364,17 @@ enum connman_service_type connman_technology_get_type
 }
 
 bool connman_get_wifi_tethering_from_technology(const struct connman_technology *technology,
-						const char **ssid, const char **psk)
+						const char **ssid, const char **psk, int *freq)
 {
 	*ssid = technology->tethering_ident;
 	*psk = technology->tethering_passphrase;
+	*freq = technology->tethering_freq;
 
 	return true;
 }
 
-bool connman_technology_get_wifi_tethering(const char **ssid, const char **psk)
+bool connman_technology_get_wifi_tethering(const char **ssid,
+					const char **psk, int *freq)
 {
 	struct connman_technology *technology;
 
@@ -380,7 +390,7 @@ bool connman_technology_get_wifi_tethering(const char **ssid, const char **psk)
 	if (!technology->tethering)
 		return false;
 
-	return connman_get_wifi_tethering_from_technology(technology, ssid, psk);
+	return connman_get_wifi_tethering_from_technology(technology, ssid, psk, freq);
 }
 
 static void free_rfkill(gpointer data)
@@ -447,6 +457,10 @@ static void technology_load(struct connman_technology *technology)
 				identifier, "Tethering.Passphrase", NULL);
 	if (enc)
 		technology->tethering_passphrase = g_strcompress(enc);
+
+	technology->tethering_freq = g_key_file_get_integer(keyfile,
+				identifier, "Tethering.Freq", NULL);
+
 done:
 	g_free(identifier);
 
@@ -558,6 +572,10 @@ static void append_properties(DBusMessageIter *iter,
 					DBUS_TYPE_STRING,
 					&technology->tethering_passphrase);
 
+	connman_dbus_dict_append_basic(&dict, "TetheringFreq",
+				DBUS_TYPE_INT32,
+				&technology->tethering_freq);
+
 	connman_dbus_dict_close(iter, &dict);
 }
 
@@ -972,6 +990,27 @@ static DBusMessage *set_property(DBusConnection *conn,
 					DBUS_TYPE_STRING,
 					&technology->tethering_passphrase);
 		}
+	} else if (g_str_equal(name, "TetheringFreq")) {
+		dbus_int32_t freq;
+
+		if (type != DBUS_TYPE_INT32)
+			return __connman_error_invalid_arguments(msg);
+
+		dbus_message_iter_get_basic(&value, &freq);
+
+		if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+			return __connman_error_not_supported(msg);
+
+		if (freq >= 0) {
+			technology->tethering_freq = freq;
+			technology_save(technology);
+
+			connman_dbus_property_changed_basic(technology->path,
+					CONNMAN_TECHNOLOGY_INTERFACE,
+					"TetheringFreq",
+					DBUS_TYPE_INT32,
+					&technology->tethering_freq);
+		}
 	} else if (g_str_equal(name, "Powered")) {
 		dbus_bool_t enable;
 
-- 
2.25.1


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

* [PATCH 3/4] tethering: Add TetheringFreq parameter documentation
  2021-10-07 21:30 [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Michael Trimarchi
  2021-10-07 21:30 ` [PATCH 2/4] tethering: Add possibility to configure the access point frequency Michael Trimarchi
@ 2021-10-07 21:30 ` Michael Trimarchi
  2021-10-07 21:30 ` [PATCH 4/4] client: Update the connmactl to support optional tethering channel Michael Trimarchi
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: Michael Trimarchi @ 2021-10-07 21:30 UTC (permalink / raw)
  To: connman, Daniel Wagner

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 doc/technology-api.txt | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/doc/technology-api.txt b/doc/technology-api.txt
index f22e9b29..cdf30396 100644
--- a/doc/technology-api.txt
+++ b/doc/technology-api.txt
@@ -100,3 +100,10 @@ Properties	boolean Powered [readwrite]
 			This property is only valid for the WiFi technology,
 			and is then mapped to the WPA pre-shared key clients
 			will have to use in order to establish a connection.
+
+		int TetheringFreq [readwrite]
+
+			The tethering access point frequency
+
+			This property is only valid for the WiFi technology and it's
+			optional. Default frequency is 2412 Mhz.
-- 
2.25.1


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

* [PATCH 4/4] client: Update the connmactl to support optional tethering channel
  2021-10-07 21:30 [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Michael Trimarchi
  2021-10-07 21:30 ` [PATCH 2/4] tethering: Add possibility to configure the access point frequency Michael Trimarchi
  2021-10-07 21:30 ` [PATCH 3/4] tethering: Add TetheringFreq parameter documentation Michael Trimarchi
@ 2021-10-07 21:30 ` Michael Trimarchi
  2021-10-14  6:31 ` [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Julien Barrault
  2021-10-15  6:51 ` Daniel Wagner
  4 siblings, 0 replies; 14+ messages in thread
From: Michael Trimarchi @ 2021-10-07 21:30 UTC (permalink / raw)
  To: connman, Daniel Wagner

The tethring frequency is added as an option to activate the access
point.

Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
---
 client/commands.c | 60 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 14 deletions(-)

diff --git a/client/commands.c b/client/commands.c
index 94c375dd..53cc14c8 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -550,20 +550,23 @@ struct tether_properties {
 	int ssid_result;
 	int passphrase_result;
 	int set_tethering;
+	int freq_result;
 };
 
 static int tether_update(struct tether_properties *tether)
 {
 	int ret;
 
-	if (tether->ssid_result == 0 && tether->passphrase_result == 0) {
+	if (tether->ssid_result == 0 && tether->passphrase_result == 0 &&
+			tether->freq_result == 0) {
 		ret = tether_set("wifi", tether->set_tethering);
 		g_free(tether);
 		return ret;
 	}
 
 	if (tether->ssid_result != -EINPROGRESS &&
-			tether->passphrase_result != -EINPROGRESS) {
+			tether->passphrase_result != -EINPROGRESS &&
+			tether->freq_result != -EINPROGRESS) {
 		g_free(tether);
 		return 0;
 	}
@@ -603,9 +606,25 @@ static int tether_set_passphrase_return(DBusMessageIter *iter, int errnum,
 	return tether_update(tether);
 }
 
-static int tether_set_ssid(char *ssid, char *passphrase, int set_tethering)
+static int tether_set_freq_return(DBusMessageIter *iter, int errnum,
+				  const char *error, void *user_data)
 {
-	struct tether_properties *tether = g_new(struct tether_properties, 1);
+	struct tether_properties *tether = user_data;
+
+	if (!error) {
+		fprintf(stdout, "Wifi access point frequency set\n");
+		tether->freq_result = 0;
+	} else {
+		fprintf(stderr, "Error setting wifi frequency: %s\n", error);
+		tether->freq_result = -EINVAL;
+	}
+
+	return tether_update(tether);
+}
+
+static int tether_set_ssid(char *ssid, char *passphrase, int set_tethering, int freq)
+{
+	struct tether_properties *tether = g_new0(struct tether_properties, 1);
 
 	tether->set_tethering = set_tethering;
 
@@ -621,8 +640,17 @@ static int tether_set_ssid(char *ssid, char *passphrase, int set_tethering)
 			tether_set_passphrase_return, tether,
 			"TetheringPassphrase", DBUS_TYPE_STRING, &passphrase);
 
+	if (freq > 0) {
+		tether->freq_result =__connmanctl_dbus_set_property(connection,
+				"/net/connman/technology/wifi",
+				"net.connman.Technology",
+				tether_set_freq_return, tether,
+				"TetheringFreq", DBUS_TYPE_INT32, &freq);
+	}
+
 	if (tether->ssid_result != -EINPROGRESS &&
-			tether->passphrase_result != -EINPROGRESS) {
+			tether->passphrase_result != -EINPROGRESS &&
+			tether->freq_result != -EINPROGRESS) {
 		g_free(tether);
 		return -ENXIO;
 	}
@@ -638,24 +666,30 @@ static int cmd_tether(char *args[], int num, struct connman_option *options)
 	if (num < 3)
 		return -EINVAL;
 
-	passphrase = args[num - 1];
-	ssid = args[num - 2];
-
 	set_tethering = parse_boolean(args[2]);
 
 	if (strcmp(args[1], "wifi") == 0) {
+		int freq = 0;
 
-		if (num > 5)
+		if (num > 6)
 			return -E2BIG;
 
-		if (num == 5 && set_tethering == -1)
+		if (num >= 5 && set_tethering == -1)
 			return -EINVAL;
 
 		if (num == 4)
 			set_tethering = -1;
 
+		if (num == 6) {
+			freq = atoi(args[num - 1]);
+			num --;
+		}
+
+		passphrase = args[num - 1];
+		ssid = args[num - 2];
+
 		if (num > 3)
-			return tether_set_ssid(ssid, passphrase, set_tethering);
+			return tether_set_ssid(ssid, passphrase, set_tethering, freq);
 	}
 
 	if (num > 3)
@@ -1425,7 +1459,6 @@ static void monitor_del(char *interface)
 	int i;
 	char *rule;
 
-
 	for (i = 0; monitor[i].interface; i++) {
 		if (g_strcmp0(interface, monitor[i].interface) == 0) {
 			if (monitor[i].enabled == false)
@@ -1811,7 +1844,6 @@ static int session_connect_cb(DBusMessageIter *iter, int errnum,
 	return -EINPROGRESS;
 }
 
-
 static int session_connect(void)
 {
 	return __connmanctl_dbus_method_call(connection, "net.connman",
@@ -2768,7 +2800,7 @@ static const struct {
 	  "Disables given technology or offline mode",
 	  lookup_technology_offline },
 	{ "tether", "<technology> on|off\n"
-	            "            wifi [on|off] <ssid> <passphrase> ",
+	            "            wifi [on|off] <ssid> <passphrase> [<freq>] ",
 	                                  NULL,            cmd_tether,
 	  "Enable, disable tethering, set SSID and passphrase for wifi",
 	  lookup_tether },
-- 
2.25.1


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

* Re: [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering
  2021-10-07 21:30 [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Michael Trimarchi
                   ` (2 preceding siblings ...)
  2021-10-07 21:30 ` [PATCH 4/4] client: Update the connmactl to support optional tethering channel Michael Trimarchi
@ 2021-10-14  6:31 ` Julien Barrault
  2021-10-15  6:53   ` Daniel Wagner
  2021-10-15  6:51 ` Daniel Wagner
  4 siblings, 1 reply; 14+ messages in thread
From: Julien Barrault @ 2021-10-14  6:31 UTC (permalink / raw)
  To: Michael Trimarchi, connman, Daniel Wagner

Hi Michael,

I've tested these 4 patches, it seems to work perfectly

I'm keen to see it approved and released :)

Julien


On 07/10/2021 23:30, Michael Trimarchi wrote:
> connman_echnology is an opaque type but has all the parameters to handle
> the connection. Those parameters are only used in wifi tethering
> one and not in other technologies
>
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> ---
>   include/technology.h |  8 ++++++--
>   plugins/bluetooth.c  |  1 -
>   plugins/ethernet.c   |  1 -
>   plugins/gadget.c     |  1 -
>   plugins/wifi.c       | 25 ++++++++++++-------------
>   src/technology.c     | 20 ++++++++++++--------
>   6 files changed, 30 insertions(+), 26 deletions(-)
>
> diff --git a/include/technology.h b/include/technology.h
> index 7508a9a1..7febd109 100644
> --- a/include/technology.h
> +++ b/include/technology.h
> @@ -44,8 +44,13 @@ void connman_technology_regdom_notify(struct connman_technology *technology,
>   
>   enum connman_service_type connman_technology_get_type
>   				(struct connman_technology *technology);
> +
> +bool connman_get_wifi_tethering_from_technology(const struct connman_technology *technology,
> +						const char **ssid, const char **psk);
> +
>   bool connman_technology_get_wifi_tethering(const char **ssid,
> -							const char **psk);
> +						const char **psk);
> +
>   bool connman_technology_is_tethering_allowed(enum connman_service_type type);
>   
>   struct connman_technology_driver {
> @@ -60,7 +65,6 @@ struct connman_technology_driver {
>   	void (*remove_interface) (struct connman_technology *technology,
>   								int index);
>   	int (*set_tethering) (struct connman_technology *technology,
> -				const char *identifier, const char *passphrase,
>   				const char *bridge, bool enabled);
>   	int (*set_regdom) (struct connman_technology *technology,
>   						const char *alpha2);
> diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
> index 53361034..57cc8a29 100644
> --- a/plugins/bluetooth.c
> +++ b/plugins/bluetooth.c
> @@ -882,7 +882,6 @@ static void bluetooth_tech_remove(struct connman_technology *technology)
>   }
>   
>   static int bluetooth_tech_set_tethering(struct connman_technology *technology,
> -		const char *identifier, const char *passphrase,
>   		const char *bridge, bool enabled)
>   {
>   	GHashTableIter hash_iter;
> diff --git a/plugins/ethernet.c b/plugins/ethernet.c
> index 6146b1c0..0bf7fc41 100644
> --- a/plugins/ethernet.c
> +++ b/plugins/ethernet.c
> @@ -407,7 +407,6 @@ static void eth_tech_disable_tethering(struct connman_technology *technology,
>   }
>   
>   static int eth_tech_set_tethering(struct connman_technology *technology,
> -				const char *identifier, const char *passphrase,
>   				const char *bridge, bool enabled)
>   {
>   	if (!connman_technology_is_tethering_allowed(
> diff --git a/plugins/gadget.c b/plugins/gadget.c
> index 1b44bbb5..2d58df3e 100644
> --- a/plugins/gadget.c
> +++ b/plugins/gadget.c
> @@ -294,7 +294,6 @@ static void gadget_tech_disable_tethering(struct connman_technology *technology,
>   }
>   
>   static int gadget_tech_set_tethering(struct connman_technology *technology,
> -				const char *identifier, const char *passphrase,
>   				const char *bridge, bool enabled)
>   {
>   	DBG("bridge %s enabled %d", bridge, enabled);
> diff --git a/plugins/wifi.c b/plugins/wifi.c
> index 578b4be7..cebe6886 100644
> --- a/plugins/wifi.c
> +++ b/plugins/wifi.c
> @@ -183,7 +183,6 @@ static bool wfd_service_registered = false;
>   
>   static void start_autoscan(struct connman_device *device);
>   static int tech_set_tethering(struct connman_technology *technology,
> -				const char *identifier, const char *passphrase,
>   				const char *bridge, bool enabled);
>   
>   static int p2p_tech_probe(struct connman_technology *technology)
> @@ -2791,8 +2790,6 @@ static void ap_create_fail(GSupplicantInterface *interface)
>   		wifi->tethering = false;
>   
>   		ret = tech_set_tethering(wifi->tethering_param->technology,
> -				wifi->tethering_param->ssid->ssid,
> -				wifi->tethering_param->ssid->passphrase,
>   				wifi->bridge, true);
>   
>   		if ((ret == -EOPNOTSUPP) && (wifi_technology)) {
> @@ -3336,14 +3333,20 @@ static void tech_remove(struct connman_technology *technology)
>   	wifi_technology = NULL;
>   }
>   
> -static GSupplicantSSID *ssid_ap_init(const char *ssid, const char *passphrase)
> +static GSupplicantSSID *ssid_ap_init(const struct connman_technology *technology)
>   {
>   	GSupplicantSSID *ap;
> +	const char *ssid, *passphrase;
> +	bool ret;
>   
>   	ap = g_try_malloc0(sizeof(GSupplicantSSID));
>   	if (!ap)
>   		return NULL;
>   
> +	ret = connman_get_wifi_tethering_from_technology(technology, &ssid, &passphrase);
> +	if (ret == false)
> +		return NULL;
> +
>   	ap->mode = G_SUPPLICANT_MODE_MASTER;
>   	ap->ssid = ssid;
>   	ap->ssid_len = strlen(ssid);
> @@ -3458,8 +3461,7 @@ static void sta_remove_callback(int result,
>   }
>   
>   static int enable_wifi_tethering(struct connman_technology *technology,
> -				const char *bridge, const char *identifier,
> -				const char *passphrase, bool available)
> +				const char *bridge, bool available)
>   {
>   	GList *list;
>   	GSupplicantInterface *interface;
> @@ -3512,14 +3514,14 @@ static int enable_wifi_tethering(struct connman_technology *technology,
>   		info->wifi = wifi;
>   		info->technology = technology;
>   		info->wifi->bridge = bridge;
> -		info->ssid = ssid_ap_init(identifier, passphrase);
> +		info->ssid = ssid_ap_init(technology);
>   		if (!info->ssid)
>   			goto failed;
>   
>   		info->ifname = g_strdup(ifname);
>   
>   		wifi->tethering_param->technology = technology;
> -		wifi->tethering_param->ssid = ssid_ap_init(identifier, passphrase);
> +		wifi->tethering_param->ssid = ssid_ap_init(technology);
>   		if (!wifi->tethering_param->ssid)
>   			goto failed;
>   
> @@ -3561,7 +3563,6 @@ static int enable_wifi_tethering(struct connman_technology *technology,
>   }
>   
>   static int tech_set_tethering(struct connman_technology *technology,
> -				const char *identifier, const char *passphrase,
>   				const char *bridge, bool enabled)
>   {
>   	GList *list;
> @@ -3589,13 +3590,11 @@ static int tech_set_tethering(struct connman_technology *technology,
>   	}
>   
>   	DBG("trying tethering for available devices");
> -	err = enable_wifi_tethering(technology, bridge, identifier, passphrase,
> -				true);
> +	err = enable_wifi_tethering(technology, bridge, true);
>   
>   	if (err < 0) {
>   		DBG("trying tethering for any device");
> -		err = enable_wifi_tethering(technology, bridge, identifier,
> -					passphrase, false);
> +		err = enable_wifi_tethering(technology, bridge, false);
>   	}
>   
>   	return err;
> diff --git a/src/technology.c b/src/technology.c
> index 672d6ea8..e0457890 100644
> --- a/src/technology.c
> +++ b/src/technology.c
> @@ -264,8 +264,7 @@ static int set_tethering(struct connman_technology *technology,
>   		if (!driver || !driver->set_tethering)
>   			continue;
>   
> -		err = driver->set_tethering(technology, ident, passphrase,
> -				bridge, enabled);
> +		err = driver->set_tethering(technology, bridge, enabled);
>   
>   		if (result == -EINPROGRESS)
>   			continue;
> @@ -356,8 +355,16 @@ enum connman_service_type connman_technology_get_type
>   	return technology->type;
>   }
>   
> -bool connman_technology_get_wifi_tethering(const char **ssid,
> -							const char **psk)
> +bool connman_get_wifi_tethering_from_technology(const struct connman_technology *technology,
> +						const char **ssid, const char **psk)
> +{
> +	*ssid = technology->tethering_ident;
> +	*psk = technology->tethering_passphrase;
> +
> +	return true;
> +}
> +
> +bool connman_technology_get_wifi_tethering(const char **ssid, const char **psk)
>   {
>   	struct connman_technology *technology;
>   
> @@ -373,10 +380,7 @@ bool connman_technology_get_wifi_tethering(const char **ssid,
>   	if (!technology->tethering)
>   		return false;
>   
> -	*ssid = technology->tethering_ident;
> -	*psk = technology->tethering_passphrase;
> -
> -	return true;
> +	return connman_get_wifi_tethering_from_technology(technology, ssid, psk);
>   }
>   
>   static void free_rfkill(gpointer data)

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

* Re: [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering
  2021-10-07 21:30 [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Michael Trimarchi
                   ` (3 preceding siblings ...)
  2021-10-14  6:31 ` [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Julien Barrault
@ 2021-10-15  6:51 ` Daniel Wagner
  4 siblings, 0 replies; 14+ messages in thread
From: Daniel Wagner @ 2021-10-15  6:51 UTC (permalink / raw)
  To: Michael Trimarchi; +Cc: connman

Hi Michael,

On Thu, Oct 07, 2021 at 11:30:18PM +0200, Michael Trimarchi wrote:
> connman_echnology is an opaque type but has all the parameters to handle
> the connection. Those parameters are only used in wifi tethering
> one and not in other technologies
> 
> Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
> ---
>  include/technology.h |  8 ++++++--
>  plugins/bluetooth.c  |  1 -
>  plugins/ethernet.c   |  1 -
>  plugins/gadget.c     |  1 -
>  plugins/wifi.c       | 25 ++++++++++++-------------

plugins/iwd.c was missing. I updated it accordingly.

>  src/technology.c     | 20 ++++++++++++--------
>  6 files changed, 30 insertions(+), 26 deletions(-)
> 
> diff --git a/include/technology.h b/include/technology.h
> index 7508a9a1..7febd109 100644
> --- a/include/technology.h
> +++ b/include/technology.h
> @@ -44,8 +44,13 @@ void connman_technology_regdom_notify(struct connman_technology *technology,
>  
>  enum connman_service_type connman_technology_get_type
>  				(struct connman_technology *technology);
> +
> +bool connman_get_wifi_tethering_from_technology(const struct connman_technology *technology,
> +						const char **ssid, const char **psk);
> +
>  bool connman_technology_get_wifi_tethering(const char **ssid,
> -							const char **psk);
> +						const char **psk);
> +

I decided to not to add connman_get_wifi_tethering_from_technology() and
instead just extend connman_technology_get_wifi_tethering() as the newly
introduced function name is awkward and doesn't fit. Furthermore, it's
just a simple wrapper.

Patch applied.

Thanks,
Daniel


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

* Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency
  2021-10-07 21:30 ` [PATCH 2/4] tethering: Add possibility to configure the access point frequency Michael Trimarchi
@ 2021-10-15  6:52   ` Daniel Wagner
  2021-10-15  7:01     ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Wagner @ 2021-10-15  6:52 UTC (permalink / raw)
  To: Michael Trimarchi; +Cc: connman

Hi Michael,

On Thu, Oct 07, 2021 at 11:30:19PM +0200, Michael Trimarchi wrote:
> When the tethering mode is started, a WiFi ap is created using the fixed
> channel 1 (2412 MHz). Add a way to configure the channel

I had to update this patch because of my changes in your patch
#1. Nothing scary, so I applied it directly.

Thanks,
Daniel

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

* Re: [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering
  2021-10-14  6:31 ` [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Julien Barrault
@ 2021-10-15  6:53   ` Daniel Wagner
  2021-10-22 15:20     ` Julien Barrault
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Wagner @ 2021-10-15  6:53 UTC (permalink / raw)
  To: Julien Barrault; +Cc: Michael Trimarchi, connman

Hi Julien,

On Thu, Oct 14, 2021 at 08:31:04AM +0200, Julien Barrault wrote:
> I've tested these 4 patches, it seems to work perfectly

Thanks for testing. Could you retest the current HEAD. I've done some
stylistic changes, they should not change the patches but who knows :)

Thanks,
Daniel

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

* Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency
  2021-10-15  6:52   ` Daniel Wagner
@ 2021-10-15  7:01     ` Michael Nazzareno Trimarchi
  2021-10-15  7:04       ` Daniel Wagner
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Nazzareno Trimarchi @ 2021-10-15  7:01 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

Hi

On Fri, Oct 15, 2021 at 8:52 AM Daniel Wagner <wagi@monom.org> wrote:
>
> Hi Michael,
>
> On Thu, Oct 07, 2021 at 11:30:19PM +0200, Michael Trimarchi wrote:
> > When the tethering mode is started, a WiFi ap is created using the fixed
> > channel 1 (2412 MHz). Add a way to configure the channel
>
> I had to update this patch because of my changes in your patch
> #1. Nothing scary, so I applied it directly.

I have done git remote update. Nothing new there ;)

Michael
>
> Thanks,
> Daniel



-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency
  2021-10-15  7:01     ` Michael Nazzareno Trimarchi
@ 2021-10-15  7:04       ` Daniel Wagner
  2021-10-15  7:09         ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 14+ messages in thread
From: Daniel Wagner @ 2021-10-15  7:04 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi; +Cc: connman

On Fri, Oct 15, 2021 at 09:01:15AM +0200, Michael Nazzareno Trimarchi wrote:
> I have done git remote update. Nothing new there ;)

Try again. I wrote the email before I did the 'git push' :)

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

* Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency
  2021-10-15  7:04       ` Daniel Wagner
@ 2021-10-15  7:09         ` Michael Nazzareno Trimarchi
  2021-10-15  7:18           ` Daniel Wagner
  0 siblings, 1 reply; 14+ messages in thread
From: Michael Nazzareno Trimarchi @ 2021-10-15  7:09 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: connman

Hi Daniel

On Fri, Oct 15, 2021 at 9:04 AM Daniel Wagner <wagi@monom.org> wrote:
>
> On Fri, Oct 15, 2021 at 09:01:15AM +0200, Michael Nazzareno Trimarchi wrote:
> > I have done git remote update. Nothing new there ;)
>
> Try again. I wrote the email before I did the 'git push' :)

Can we move the tethering in iwd when the plugin is activated?

I have done some test and we can support AP+STA using iwd.

Michael

-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

* Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency
  2021-10-15  7:09         ` Michael Nazzareno Trimarchi
@ 2021-10-15  7:18           ` Daniel Wagner
  0 siblings, 0 replies; 14+ messages in thread
From: Daniel Wagner @ 2021-10-15  7:18 UTC (permalink / raw)
  To: Michael Nazzareno Trimarchi; +Cc: connman

On Fri, Oct 15, 2021 at 09:09:32AM +0200, Michael Nazzareno Trimarchi wrote:
> Can we move the tethering in iwd when the plugin is activated?

Not sure if I understand your question correctly. Do mean the changing
the parameters like the frequency when the AP mode is enabled? I've
checked what the iwd docs says and if I am not mistaken it can't be
set (at this point).

> I have done some test and we can support AP+STA using iwd.

Nice! Good to hear that we start to get some traction with iwd :)

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

* Re: [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering
  2021-10-15  6:53   ` Daniel Wagner
@ 2021-10-22 15:20     ` Julien Barrault
  2021-10-22 15:33       ` Michael Nazzareno Trimarchi
  0 siblings, 1 reply; 14+ messages in thread
From: Julien Barrault @ 2021-10-22 15:20 UTC (permalink / raw)
  To: Daniel Wagner; +Cc: Michael Trimarchi, connman

Hi Daniel,

I am using the version 1.39 on which I applied the patch

> Thanks for testing. Could you retest the current HEAD. I've done some
> stylistic changes, they should not change the patches but who knows :)

I've applied the 4 patches committed on master, but it does not work anymore

There are probably few typos in the patch ("Tethering.Freq" instead of 
"TetheringFreq" in the second patch), but not only (correcting 
Tethering.Freq twice didn't solve the problem)

Unfortunately I didn't have time yet to investigate further, I keep you 
posted if I find what went wrong

Julien


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

* Re: [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering
  2021-10-22 15:20     ` Julien Barrault
@ 2021-10-22 15:33       ` Michael Nazzareno Trimarchi
  0 siblings, 0 replies; 14+ messages in thread
From: Michael Nazzareno Trimarchi @ 2021-10-22 15:33 UTC (permalink / raw)
  To: 20211015065350.wpf6qqcdfsmvt3q2; +Cc: Daniel Wagner, connman

Hi

On Fri, Oct 22, 2021 at 5:20 PM Julien Barrault
<julien.barrault.external@overkiz.com> wrote:
>
> Hi Daniel,
>
> I am using the version 1.39 on which I applied the patch
>
> > Thanks for testing. Could you retest the current HEAD. I've done some
> > stylistic changes, they should not change the patches but who knows :)
>
> I've applied the 4 patches committed on master, but it does not work anymore
>
> There are probably few typos in the patch ("Tethering.Freq" instead of
> "TetheringFreq" in the second patch), but not only (correcting
> Tethering.Freq twice didn't solve the problem)
>
> Unfortunately I didn't have time yet to investigate further, I keep you
> posted if I find what went wrong

Sorry not have time to check them again. I will try to fix them later today

Michael
>
> Julien
>


-- 
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
michael@amarulasolutions.com
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
info@amarulasolutions.com
www.amarulasolutions.com

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

end of thread, other threads:[~2021-10-22 15:33 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-07 21:30 [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Michael Trimarchi
2021-10-07 21:30 ` [PATCH 2/4] tethering: Add possibility to configure the access point frequency Michael Trimarchi
2021-10-15  6:52   ` Daniel Wagner
2021-10-15  7:01     ` Michael Nazzareno Trimarchi
2021-10-15  7:04       ` Daniel Wagner
2021-10-15  7:09         ` Michael Nazzareno Trimarchi
2021-10-15  7:18           ` Daniel Wagner
2021-10-07 21:30 ` [PATCH 3/4] tethering: Add TetheringFreq parameter documentation Michael Trimarchi
2021-10-07 21:30 ` [PATCH 4/4] client: Update the connmactl to support optional tethering channel Michael Trimarchi
2021-10-14  6:31 ` [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering Julien Barrault
2021-10-15  6:53   ` Daniel Wagner
2021-10-22 15:20     ` Julien Barrault
2021-10-22 15:33       ` Michael Nazzareno Trimarchi
2021-10-15  6:51 ` Daniel Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).