Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [PATCH 2/3] technology: Add WPS Cancel feature (Jose Blanquicet)
2. [PATCH 3/3] client: Add commands for new specific WPS D-Bus
methods (Jose Blanquicet)
----------------------------------------------------------------------
Message: 1
Date: Fri, 22 Jul 2016 15:54:07 +0200
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH 2/3] technology: Add WPS Cancel feature
Message-ID: <[email protected]>
Add WPS Cancel feature by creating new D-Bus method to Technology named
Cancel_WPS(void).
This operation is done over all interfaces (Except the connected ones)
because wpa_supplicant does not provide enough information that allows
to have a tracking of the interface currently running WPS in AP mode.
Technology documentation was also updated.
---
doc/technology-api.txt | 8 ++++++++
gsupplicant/gsupplicant.h | 3 +++
gsupplicant/supplicant.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++
include/technology.h | 1 +
plugins/wifi.c | 42 ++++++++++++++++++++++++++++++++++++++++
src/technology.c | 41 +++++++++++++++++++++++++++++++++++++++
6 files changed, 144 insertions(+)
diff --git a/doc/technology-api.txt b/doc/technology-api.txt
index b008374..75c1091 100644
--- a/doc/technology-api.txt
+++ b/doc/technology-api.txt
@@ -75,6 +75,14 @@ Methods dict GetProperties() [deprecated]
[service].Error.NotConnected
[service].Error.NotSupported
+ void Cancel_WPS()
+
+ Cancel ongoing WPS session.
+
+ This method is supported only by WiFi technology.
+
+ Possible Errors: [service].Error.NotSupported
+
Signals PropertyChanged(string name, variant value)
This signal indicates a changed value of the given
diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 9944efd..a42c597 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -262,6 +262,9 @@ int g_supplicant_set_widi_ies(GSupplicantP2PServiceParams
*p2p_service_params,
GSupplicantInterfaceCallback callback,
void *user_data);
+int g_supplicant_interface_wps_cancel(GSupplicantInterface *interface,
+ GSupplicantInterfaceCallback callback,
void * user_data);
+
int g_supplicant_interface_wps_start(GSupplicantInterface *interface,
GSupplicantWPSParams *wps,
GSupplicantInterfaceCallback callback,
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 21342a0..065bf0e 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4756,6 +4756,55 @@ static void interface_add_network_params(DBusMessageIter
*iter, void *user_data)
supplicant_dbus_dict_close(iter, &dict);
}
+static void interface_wps_cancel_result(const char *error,
+ DBusMessageIter *iter, void *user_data)
+{
+ int err;
+ struct interface_connect_data *data = user_data;
+
+ SUPPLICANT_DBG("");
+
+ err = 0;
+ if (error) {
+ SUPPLICANT_DBG("WPS-Error: %s", error);
+
+ if (g_strcmp0(SUPPLICANT_INTERFACE ".InvalidArgs", error) == 0)
+ err = -EINVAL;
+ }
+
+ if (data->callback)
+ data->callback(err, data->interface, data->user_data);
+
+ g_free(data->path);
+ dbus_free(data);
+}
+
+int g_supplicant_interface_wps_cancel(GSupplicantInterface *interface,
+ GSupplicantInterfaceCallback callback,
void * user_data)
+{
+ struct interface_connect_data *data;
+ int ret;
+
+ data = dbus_malloc0(sizeof(*data));
+ data->interface = interface;
+ data->path = g_strdup(interface->path);
+ data->callback = callback;
+ data->user_data = user_data;
+
+ ret = supplicant_dbus_method_call(data->path,
+ SUPPLICANT_INTERFACE ".Interface.WPS", "Cancel",
+ NULL, interface_wps_cancel_result, data, NULL);
+
+ if (ret < 0) {
+ SUPPLICANT_DBG("WPS-Error: %d", ret);
+ g_free(data->path);
+ dbus_free(data);
+ return ret;
+ }
+
+ return -EINPROGRESS;
+}
+
static void interface_wps_start_result(const char *error,
DBusMessageIter *iter, void *user_data)
{
diff --git a/include/technology.h b/include/technology.h
index 771cbb6..e3f5623 100644
--- a/include/technology.h
+++ b/include/technology.h
@@ -72,6 +72,7 @@ struct connman_technology_driver {
int (*start_wps) (struct connman_technology *technology,
enum
connman_technology_wps_mode mode,
const char *wps_pin);
+ int (*cancel_wps) (struct connman_technology *technology);
};
int connman_technology_driver_register(struct connman_technology_driver
*driver);
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 53e826a..1bf4995 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -3591,6 +3591,47 @@ static int tech_start_wps(struct connman_technology
*technology,
return -EOPNOTSUPP;
}
+static void cancel_wps_callback(int result, GSupplicantInterface *interface,
+ void *user_data)
+{
+ if (result < 0)
+ DBG("Error canceling WPS session on %s: %d",
+
g_supplicant_interface_get_ifname(interface), result);
+}
+
+static int tech_cancel_wps(struct connman_technology *technology)
+{
+ GList *list;
+ struct wifi_data *wifi;
+ GSupplicantInterface *interface;
+ int err;
+
+ DBG("");
+
+ for (list = iface_list; list; list = list->next) {
+ wifi = list->data;
+
+ interface = wifi->interface;
+
+ if (!g_supplicant_interface_support_wps(interface))
+ continue;
+
+ /*
+ * Do not perform WPS Cancel on an interface already connected
to a
+ * service or p2p device because it will result in an undesired
+ * disconnection.
+ */
+ if (wifi->connected || wifi->p2p_connected)
+ continue;
+
+ err = g_supplicant_interface_wps_cancel(interface,
+ cancel_wps_callback, NULL);
+ if (err != -EINPROGRESS)
+ break;
+ }
+
+ return err;
+}
static struct connman_technology_driver tech_driver = {
.name = "wifi",
@@ -3600,6 +3641,7 @@ static struct connman_technology_driver tech_driver = {
.set_tethering = tech_set_tethering,
.set_regdom = tech_set_regdom,
.start_wps = tech_start_wps,
+ .cancel_wps = tech_cancel_wps,
};
static int wifi_init(void)
diff --git a/src/technology.c b/src/technology.c
index 89b3130..447f201 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -670,6 +670,45 @@ static DBusMessage *start_sta_wps(DBusConnection *conn,
DBusMessage *msg,
return __connman_error_failed(msg, -err);
}
+static DBusMessage *cancel_wps(DBusConnection *conn, DBusMessage *msg,
+ void *user_data)
+{
+ struct connman_technology *technology = user_data;
+ GSList *tech_drivers;
+ int err = 0, result = -EOPNOTSUPP;
+
+ if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+ return __connman_error_not_supported(msg);
+
+ __sync_synchronize();
+ if (!technology->enabled)
+ return __connman_error_permission_denied(msg);
+
+ if (technology->wps_reply)
+ connman_technology_reply_start_sta_wps(technology,
-ECONNABORTED);
+
+ for (tech_drivers = technology->driver_list; tech_drivers;
+ tech_drivers = g_slist_next(tech_drivers)) {
+ struct connman_technology_driver *driver = tech_drivers->data;
+
+ if (!driver || !driver->cancel_wps ||
+ driver->type != CONNMAN_SERVICE_TYPE_WIFI)
+ continue;
+
+ err = driver->cancel_wps(technology);
+ if (result == -EINPROGRESS)
+ continue;
+
+ if (err == -EINPROGRESS)
+ result = err;
+ }
+
+ if (result == -EINPROGRESS)
+ return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+
+ return __connman_error_failed(msg, -result);
+}
+
static DBusMessage *get_properties(DBusConnection *conn,
DBusMessage *message, void *user_data)
{
@@ -1196,6 +1235,8 @@ static const GDBusMethodTable technology_methods[] = {
{ GDBUS_ASYNC_METHOD("Start_STA_WPS",
GDBUS_ARGS({ "authentication", "s" }),
NULL, start_sta_wps) },
+ { GDBUS_ASYNC_METHOD("Cancel_WPS",
+ NULL, NULL, cancel_wps) },
{ },
};
--
1.9.1
------------------------------
Message: 2
Date: Fri, 22 Jul 2016 15:54:08 +0200
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH 3/3] client: Add commands for new specific WPS D-Bus
methods
Message-ID: <[email protected]>
- Add commands to use new methods: Start_STA_WPS, Start_AP_WPS and
Cancel_WPS
- Increate TIMEOUT up to 125000 in order to avoid D-Bus timer triggers
before WPS-TIMEOUT arrives (120000).
- Update manuals with new features
---
client/commands.c | 125 ++++++++++++++++++++++++++++++++++++++++++++++++++
client/dbus_helpers.c | 2 +-
doc/connmanctl.1.in | 14 +++++-
3 files changed, 139 insertions(+), 2 deletions(-)
diff --git a/client/commands.c b/client/commands.c
index d7f59ef..569aea0 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -639,6 +639,85 @@ static int cmd_tether(char *args[], int num, struct
connman_option *options)
return tether_set(args[1], set_tethering);
}
+static int wps_cb(DBusMessageIter *iter, const char *error,
+ void *user_data)
+{
+ bool sta = GPOINTER_TO_UINT(user_data);
+
+ if (error) {
+ fprintf(stderr, "WPS Error: %s\n", error);
+ return 1;
+ }
+
+ if (sta)
+ fprintf(stdout, "WPS: Success\n");
+ else
+ fprintf(stdout, "WPS: Started\n");
+
+ return 0;
+}
+
+static void set_wps_authentication(DBusMessageIter *iter, void *user_data)
+{
+ const char *auth = user_data;
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &auth);
+
+ return;
+}
+
+static int cmd_wps_start(char *args[], int num, struct connman_option *options)
+{
+ char *auth = "";
+ char *method = "Start_STA_WPS";
+ bool sta = true;
+
+ if (num > 3)
+ return -E2BIG;
+
+ if (num < 3)
+ return -EINVAL;
+
+ if (g_strcmp0(args[2], "pbc") != 0)
+ auth = args[2];
+
+ if (g_strcmp0(args[1], "ap") == 0) {
+ method = "Start_AP_WPS";
+ sta = false;
+ } else if (g_strcmp0(args[1], "sta") != 0) {
+ fprintf(stdout, "Incorrect mode %s. Correct options: ap "
+ " or sta\n", args[1]);
+ return -EINVAL;
+ }
+
+ return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+ "/net/connman/technology/wifi",
"net.connman.Technology",
+ method, wps_cb, GUINT_TO_POINTER(sta),
+ set_wps_authentication, auth);
+}
+
+static int wps_cancel_cb(DBusMessageIter *iter, const char *error,
+ void *user_data)
+{
+ if (!error) {
+ fprintf(stdout, "Ongoing WPS session cancelled\n");
+ } else
+ fprintf(stdout, "WPS Error: %s\n", error);
+
+ return 0;
+}
+
+static int cmd_wps_cancel(char *args[], int num, struct connman_option
*options)
+{
+ if (num > 1)
+ return -E2BIG;
+
+ return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+ "/net/connman/technology/wifi",
+ "net.connman.Technology", "Cancel_WPS",
+ wps_cancel_cb, NULL, NULL, NULL);
+}
+
static int scan_return(DBusMessageIter *iter, const char *error,
void *user_data)
{
@@ -2156,6 +2235,46 @@ static char *lookup_tether(const char *text, int state)
return NULL;
}
+static char *lookup_wps_option(const char *text, int state, char **opt)
+{
+ static int idx = 0;
+ static int len = 0;
+ char *str;
+
+ if (!state) {
+ idx = 0;
+ len = strlen(text);
+ }
+
+ while (opt[idx]) {
+ str = opt[idx];
+ idx++;
+
+ if (!strncmp(text, str, len))
+ return strdup(str);
+ }
+
+ return NULL;
+}
+
+static char *lookup_wps(const char *text, int state)
+{
+ int level;
+ char *action[] = { "ap", "sta", NULL };
+ char *type[] = { "pbc", NULL };
+
+ level = __connmanctl_input_calc_level();
+
+ if (level == 1)
+ return lookup_wps_option(text, state, action);
+ if (level == 2)
+ return lookup_wps_option(text, state, type);
+
+ __connmanctl_input_lookup_end();
+
+ return NULL;
+}
+
static char *lookup_agent(const char *text, int state)
{
if (__connmanctl_input_calc_level() > 1) {
@@ -2556,6 +2675,12 @@ static const struct {
NULL, cmd_tether,
"Enable, disable tethering, set SSID and passphrase for wifi",
lookup_tether },
+ { "wps", "ap|sta <pbc/PIN>", NULL, cmd_wps_start,
+ "Start WPS in AP or STA mode with PBC or indicating the PIN to be
used",
+ lookup_wps },
+ { "wps_cancel", NULL, NULL, cmd_wps_cancel,
+ "Cancel ongoing WPS Session",
+ lookup_wps },
{ "services", "[<service>]", service_options, cmd_services,
"Display services", lookup_service_arg },
{ "peers", "[peer]", NULL, cmd_peers,
diff --git a/client/dbus_helpers.c b/client/dbus_helpers.c
index 6ca407d..1a8eea1 100644
--- a/client/dbus_helpers.c
+++ b/client/dbus_helpers.c
@@ -28,7 +28,7 @@
#include "input.h"
#include "dbus_helpers.h"
-#define TIMEOUT 120000
+#define TIMEOUT 125000
void __connmanctl_dbus_print(DBusMessageIter *iter, const char *pre,
const char *dict, const char *sep)
diff --git a/doc/connmanctl.1.in b/doc/connmanctl.1.in
index 0f891bd..8aa6ebd 100644
--- a/doc/connmanctl.1.in
+++ b/doc/connmanctl.1.in
@@ -1,4 +1,4 @@
-.TH connmanctl 1 "2015-10-15" ""
+.TH connmanctl 1 "2016-07-22" ""
.SH
NAME
connmanctl \- Connman CLI
@@ -11,6 +11,8 @@ SYNOPSIS
.BI disable \ technology\fR|offline\ |
.BI tether \ technology\ \fRon|off\ |
.BI tether\fR\ wifi\ on|off\ ssid\ passphrase\fR\ |
+.BI wps\fR\ ap|sta\ pbc|\fIpin\fR\ |
+.BI wps_cancel\fR\ |
.BR services \ [\fIservice\fR]\ |
.BI peers \ peer\fR\ |
.BI scan \ technology\fR\ |
@@ -90,6 +92,16 @@ for enabling.
Enable or disable wireless tethering, as well set the SSID and passphrase.
.PP
.TP
+.BI wps\ ap \fR| \fBsta\ pbc \fR| \fIpin
+Start a WPS Session in \fBap\fR mode (\fBTethering\fR) or \fBsta\fR mode. The
+authentication method can be either \fBpbc\fR or \fIpin\fR, where \fIpin\fR is
+the eigth digits number itself.
+.PP
+.TP
+.BI wps_cancel
+Cancel the ongoing WPS Session.
+.PP
+.TP
.B services
Shows a list of all available services. This includes the
nearby wifi networks, the wired ethernet connections, bluetooth devices, etc.
--
1.9.1
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 9, Issue 14
**************************************