Skip to contentSkip to conversation

tethering: Reduce the number of parameters of tech_set_tethering

PATCH In review Michael Trimarchi 3 participants 14 messages Oct 7, 2021 – Oct 22, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 tethering: Reduce the number of parameters of tech_set_tethering

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

---
 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(-)
include/technology.h +6 -2
index 7508a9a1..7febd109 100644
@@ -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);
plugins/bluetooth.c +0 -1
index 53361034..57cc8a29 100644
@@ -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;
plugins/ethernet.c +0 -1
index 6146b1c0..0bf7fc41 100644
@@ -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(
plugins/gadget.c +0 -1
index 1b44bbb5..2d58df3e 100644
@@ -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);
plugins/wifi.c +12 -13
index 578b4be7..cebe6886 100644
@@ -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;
src/technology.c +12 -8
index 672d6ea8..e0457890 100644
@@ -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)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/4 tethering: Add possibility to configure the access point frequency

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

---
 include/technology.h |  4 ++--
 plugins/neard.c      |  3 ++-
 plugins/wifi.c       |  9 +++++++--
 src/technology.c     | 45 +++++++++++++++++++++++++++++++++++++++++---
 4 files changed, 53 insertions(+), 8 deletions(-)
include/technology.h +2 -2
index 7febd109..d89c8164 100644
@@ -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);
 
plugins/neard.c +2 -1
index 45effd44..b0cdbde0 100644
@@ -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);
plugins/wifi.c +7 -2
index cebe6886..4f859e31 100644
@@ -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;
src/technology.c +42 -3

94 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency

Hi Michael,

Quoted 2 lines · Michael Trimarchi

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

#3 lore raw

Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency

Hi

Quoted 9 lines · Daniel Wagner

Hi Michael,

Quoted 2 lines · Michael Trimarchi

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

Quoted 3 lines

Thanks,
Daniel

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#4 lore raw

Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency

Quoted 1 line · Michael Nazzareno Trimarchi

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

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

#5 lore raw

Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency

Hi Daniel

Quoted 5 lines · Daniel Wagner
Quoted 1 line · Michael Nazzareno Trimarchi

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

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#6 lore raw

Re: [PATCH 2/4] tethering: Add possibility to configure the access point frequency

Quoted 1 line · Michael Nazzareno Trimarchi

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).

Quoted 1 line

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 :)

#7 lore raw

PATCH 3/4 tethering: Add TetheringFreq parameter documentation

In reply to Michael Trimarchi
---
 doc/technology-api.txt | 7 +++++++
 1 file changed, 7 insertions(+)
doc/technology-api.txt +7 -0
index f22e9b29..cdf30396 100644
@@ -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.
Signature · 1 line
2.25.1
#8 lore raw

PATCH 4/4 client: Update the connmactl to support optional tethering channel

In reply to Michael Trimarchi

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

---
 client/commands.c | 60 ++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 46 insertions(+), 14 deletions(-)
client/commands.c +46 -14
index 94c375dd..53cc14c8 100644
@@ -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 },
Signature · 1 line
2.25.1
#9 lore raw
In reply to Michael Trimarchi

Hi Michael,

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

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

Julien

Quoted 216 lines · Michael Trimarchi

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

---
  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(-)
include/technology.h +6 -2
index 7508a9a1..7febd109 100644
@@ -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);
plugins/bluetooth.c +0 -1
index 53361034..57cc8a29 100644
@@ -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;
plugins/ethernet.c +0 -1
index 6146b1c0..0bf7fc41 100644
@@ -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(
plugins/gadget.c +0 -1
index 1b44bbb5..2d58df3e 100644
@@ -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);
plugins/wifi.c +12 -13
index 578b4be7..cebe6886 100644
@@ -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;
src/technology.c +12 -8
index 672d6ea8..e0457890 100644
@@ -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)
#10 lore raw

Hi Julien,

Quoted 1 line · Julien Barrault

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

#11 lore raw

Hi Daniel,

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

Quoted 2 lines

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

#12 lore raw

Hi

Quoted 8 lines · Julien Barrault

Hi Daniel,

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

Quoted 2 lines

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

Quoted 8 lines

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

Quoted 3 lines

Julien

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com
#13 lore raw
In reply to Michael Trimarchi

Hi Michael,

Quoted 11 lines · Michael Trimarchi

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

---
 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.

Quoted 9 lines
 src/technology.c     | 20 ++++++++++++--------
 6 files changed, 30 insertions(+), 26 deletions(-)
include/technology.h +0 -0
index 7508a9a1..7febd109 100644
@@ -44,8 +44,13 @@ void connman_technology_regdom_notify(struct connman_technology *technology,
 

include/technology.h void connman_technology_regdom_notify(struct connman_technology *technology, · line 53

Quoted 10 lines
include/technology.h +6 -1
 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