From: Michael Trimarchi <michael@amarulasolutions.com>
To: connman@lists.linux.dev, Daniel Wagner <wagi@monom.org>
Subject: [PATCH 1/4] tethering: Reduce the number of parameters of tech_set_tethering
Date: Thu, 7 Oct 2021 23:30:18 +0200 [thread overview]
Message-ID: <20211007213021.58712-1-michael@amarulasolutions.com> (raw)
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
next reply other threads:[~2021-10-07 21:30 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-07 21:30 Michael Trimarchi [this message]
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
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=20211007213021.58712-1-michael@amarulasolutions.com \
--to=michael@amarulasolutions.com \
--cc=connman@lists.linux.dev \
--cc=wagi@monom.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