From: "VAUTRIN Emmanuel (Canal Plus Prestataire)" <Emmanuel.VAUTRIN@cpexterne.org>
To: "connman@lists.linux.dev" <connman@lists.linux.dev>
Subject: [PATCH 3/3] iwd: Ensure hidden services connectable after removed
Date: Fri, 1 Oct 2021 15:29:16 +0000 [thread overview]
Message-ID: <MRZP264MB154491FD5A024CBCF0147E5B93AB9@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM> (raw)
Hidden services shall always be connectable, even after been removed.
When a hidden service is removed, the associated iwd network stays as
known and thus shall be connected as a visible network.
---
plugins/iwd.c | 71 +++++++++++++++++++++++++++++++++++++++------------
1 file changed, 54 insertions(+), 17 deletions(-)
diff --git a/plugins/iwd.c b/plugins/iwd.c
index 961d53196207..9bd27e90c346 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -140,6 +140,7 @@ struct iwd_station {
bool scanning;
GHashTable *hidden_aps;
+ GHashTable *hidden_networks;
struct hidden_params *hidden;
bool postpone_hidden;
};
@@ -646,6 +647,37 @@ static void hidden_params_free(gpointer data)
g_free(hidden);
}
+static int connect_hidden(struct iwd_station *iwds)
+{
+ struct iwd_network *iwdn;
+ char *ssid_security;
+ int err = 0;
+
+ ssid_security = g_strdup_printf("%s_%s",
+ iwds->hidden->ssid, iwds->hidden->security);
+ iwdn = g_hash_table_lookup(iwds->hidden_networks, ssid_security);
+ if (iwdn) {
+ err = connman_network_connect_hidden(iwdn->network,
+ iwds->hidden->identity,
+ iwds->hidden->passphrase,
+ iwds->hidden->user_data);
+ iwds->hidden->user_data = NULL;
+ if (err == -EINPROGRESS)
+ err = 0;
+ } else if (!g_dbus_proxy_method_call(iwds->proxy,
+ "ConnectHiddenNetwork",
+ hidden_network_connect_append,
+ cm_hidden_network_connect_cb,
+ iwds->hidden, hidden_params_free)) {
+ err = -EIO;
+ }
+
+ if (err)
+ iwds->hidden = NULL;
+
+ return err;
+}
+
static void cm_device_scan_cb(DBusMessage *message, void *user_data)
{
const char *path = user_data;
@@ -669,13 +701,7 @@ static void cm_device_scan_cb(DBusMessage *message, void *user_data)
iwds->hidden = NULL;
} else {
iwds->postpone_hidden = false;
- if (!g_dbus_proxy_method_call(iwds->proxy,
- "ConnectHiddenNetwork",
- hidden_network_connect_append,
- cm_hidden_network_connect_cb,
- iwds->hidden, hidden_params_free)) {
- iwds->hidden = NULL;
- }
+ connect_hidden(iwds);
}
}
@@ -740,15 +766,7 @@ static int cm_device_scan(struct connman_device *device,
return 0;
}
- if (!g_dbus_proxy_method_call(iwds->proxy,
- "ConnectHiddenNetwork",
- hidden_network_connect_append,
- cm_hidden_network_connect_cb,
- hidden, hidden_params_free)) {
- iwds->hidden = NULL;
- return -EIO;
- }
- return 0;
+ return connect_hidden(iwds);
}
}
@@ -1298,8 +1316,23 @@ static void network_property_change(GDBusProxy *proxy, const char *name,
iwdkn = g_hash_table_lookup(known_networks,
iwdn->known_network);
- if (iwdkn)
+ if (iwdkn) {
update_auto_connect(iwdkn);
+
+ if (iwdkn->hidden) {
+ struct iwd_station *iwds;
+ char *ssid_security;
+
+ iwds = g_hash_table_lookup(stations, iwdn->iwdd->path);
+ if (!iwds)
+ return;
+
+ ssid_security = g_strdup_printf("%s_%s",
+ iwdkn->name, security_remap(iwdkn->type));
+ g_hash_table_replace(iwds->hidden_networks,
+ ssid_security, iwdn);
+ }
+ }
}
}
@@ -1659,6 +1692,7 @@ static void station_free(gpointer data)
g_free(iwds->path);
g_free(iwds->connected_network);
g_hash_table_destroy(iwds->hidden_aps);
+ g_hash_table_destroy(iwds->hidden_networks);
g_free(iwds->hidden);
g_free(iwds);
}
@@ -2042,6 +2076,9 @@ static void create_station(GDBusProxy *proxy)
iwds->hidden_aps = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
hidden_ap_free);
+ iwds->hidden_networks = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+
iwds->hidden = NULL;
iwds->postpone_hidden = false;
--
2.25.1
next reply other threads:[~2021-10-01 15:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-01 15:29 VAUTRIN Emmanuel (Canal Plus Prestataire) [this message]
2021-10-04 7:06 ` [PATCH 3/3] iwd: Ensure hidden services connectable after removed Daniel Wagner
2021-10-04 9:22 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
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=MRZP264MB154491FD5A024CBCF0147E5B93AB9@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM \
--to=emmanuel.vautrin@cpexterne.org \
--cc=connman@lists.linux.dev \
/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;
as well as URLs for NNTP newsgroup(s).