When enabling tethering, try to first find a device without a network
connection that supports AP mode. If none is found, try again but this
time ignoring the network connection.
Factor out tethering enabling adding a boolea parameter that tells
whether to consider a connected network or not.
Reported by citylight2.
---
plugins/wifi.c | 66 ++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 43 insertions(+), 23 deletions(-)
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 587dee2..f2b6ab2 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -3062,9 +3062,9 @@ static void sta_remove_callback(int result,
info);
}
-static int tech_set_tethering(struct connman_technology *technology,
- const char *identifier, const char *passphrase,
- const char *bridge, bool enabled)
+static int enable_wifi_tethering(struct connman_technology *technology,
+ const char *bridge, const char *identifier,
+ const char *passphrase, bool available)
{
GList *list;
GSupplicantInterface *interface;
@@ -3074,26 +3074,6 @@ static int tech_set_tethering(struct connman_technology
*technology,
unsigned int mode;
int err;
- DBG("");
-
- if (!enabled) {
- for (list = iface_list; list; list = list->next) {
- wifi = list->data;
-
- if (wifi->tethering) {
- wifi->tethering = false;
-
- connman_inet_remove_from_bridge(wifi->index,
- bridge);
- wifi->bridged = false;
- }
- }
-
- connman_technology_tethering_notify(technology, false);
-
- return 0;
- }
-
for (list = iface_list; list; list = list->next) {
wifi = list->data;
@@ -3114,6 +3094,9 @@ static int tech_set_tethering(struct connman_technology
*technology,
continue;
}
+ if (wifi->network && available)
+ continue;
+
info = g_try_malloc0(sizeof(struct wifi_tethering_info));
if (!info)
return -ENOMEM;
@@ -3167,6 +3150,43 @@ static int tech_set_tethering(struct connman_technology
*technology,
return -EOPNOTSUPP;
}
+static int tech_set_tethering(struct connman_technology *technology,
+ const char *identifier, const char *passphrase,
+ const char *bridge, bool enabled)
+{
+ GList *list;
+ struct wifi_data *wifi;
+ int err;
+
+ DBG("");
+
+ if (!enabled) {
+ for (list = iface_list; list; list = list->next) {
+ wifi = list->data;
+
+ if (wifi->tethering) {
+ wifi->tethering = false;
+
+ connman_inet_remove_from_bridge(wifi->index,
+ bridge);
+ wifi->bridged = false;
+ }
+ }
+
+ connman_technology_tethering_notify(technology, false);
+
+ return 0;
+ }
+
+ err = enable_wifi_tethering(technology, bridge, identifier, passphrase,
+ true);
+ if (err < 0)
+ err = enable_wifi_tethering(technology, bridge, identifier,
+ passphrase, false);
+
+ return err;
+}
+
static void regdom_callback(int result, const char *alpha2, void *user_data)
{
DBG("");
--
2.1.4
_______________________________________________
connman mailing list
[email protected]
https://lists.connman.net/mailman/listinfo/connman