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. [PATCHv6 6/6] wps: add new WPS API for technology
      ([email protected])
   2. RE: [PATCHv3 1/6] wps: add new WPS API ([email protected])


----------------------------------------------------------------------

Message: 1
Date: Thu, 11 Oct 2018 16:07:38 +0000
From: <[email protected]>
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>
Subject: [PATCHv6 6/6] wps: add new WPS API for technology
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Add new WPS APIs, but this APIs are under discution...

Signed-off-by: n-itaya <[email protected]>
---
 include/technology.h |   5 +
 src/technology.c     | 231 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 236 insertions(+)

diff --git a/include/technology.h b/include/technology.h
index 97db6607..830f1d0e 100644
--- a/include/technology.h
+++ b/include/technology.h
@@ -34,6 +34,11 @@ extern "C" {
  * @short_description: Functions for handling technology details
  */
 
+enum connman_technology_wps_mode {
+       CONNMAN_TECHNOLOGY_WPS_STA_MODE = 0,
+       CONNMAN_TECHNOLOGY_WPS_AP_MODE  = 1,
+};
+
 struct connman_technology;
 
 int connman_technology_tethering_notify(struct connman_technology *technology,
diff --git a/src/technology.c b/src/technology.c
index 4c1cbbbb..4b72f4b4 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -74,6 +74,14 @@ struct connman_technology {
        DBusMessage *pending_reply;
        guint pending_timeout;
 
+       /*
+        * Used to handle WPS errors within the two-minute interval.
+        * It is done only for WPS in STA mode, because for AP the
+        * wpa_supplicant does not report any events/errors.
+        */
+       DBusMessage *wps_reply;
+       GSList *wps_offered;
+
        GSList *scan_pending;
 
        bool rfkill_driven;
@@ -277,6 +285,15 @@ static int set_tethering(struct connman_technology 
*technology,
        return result;
 }
 
+void connman_technology_wps_state_change_notify(
+       struct connman_technology *technology,
+       const char *state)
+{
+       connman_dbus_property_changed_basic(technology->path,
+                               CONNMAN_TECHNOLOGY_INTERFACE, "WpsState",
+                                               DBUS_TYPE_STRING, &state);
+}
+
 void connman_technology_regdom_notify(struct connman_technology *technology,
                                                        const char *alpha2)
 {
@@ -576,6 +593,212 @@ static void technology_removed_signal(struct 
connman_technology *technology)
                        DBUS_TYPE_INVALID);
 }
 
+void connman_technology_add_wps_offered(struct connman_technology *technology,
+                                       const char *path)
+{
+       char *dup_path = g_strdup(path);
+
+       if (!dup_path)
+               return;
+       technology->wps_offered =
+               g_slist_append(technology->wps_offered, dup_path);
+}
+
+static void append_wps_service_structs(DBusMessageIter *iter, void *user_data)
+{
+       struct connman_technology *technology = user_data;
+       GSList *list;
+
+       for (list = technology->wps_offered; list; list = list->next) {
+               const char *ident = list->data;
+               struct connman_service *service;
+
+               service = __connman_service_lookup_from_ident(ident);
+               if (!service)
+                       continue;
+               __connman_service_append_struct(service, iter);
+       }
+}
+
+static DBusMessage
+*create_reply_start_sta_wps_success(
+                                   struct connman_technology *technology,
+                                   DBusMessage *reply)
+{
+       DBusMessage *msg;
+
+       msg = dbus_message_new_method_return(reply);
+       if (!msg)
+               return NULL;
+
+       __connman_dbus_append_objpath_dict_array(msg,
+                                                append_wps_service_structs,
+                                                technology);
+
+       return msg;
+}
+
+static void free_wps_offered(gpointer data, gpointer user_data)
+{
+       if (!data)
+               return;
+
+       g_free(data);
+}
+
+void
+connman_technology_reply_start_sta_wps(struct connman_technology *technology,
+                                      int error)
+{
+       DBusMessage *reply;
+
+       if (!technology->wps_reply)
+               return;
+
+       if (!error) {
+               reply = create_reply_start_sta_wps_success(technology,
+                                                       technology->wps_reply);
+       } else
+               reply = __connman_error_failed(technology->wps_reply, -error);
+
+       g_dbus_send_message(connection, reply);
+
+       dbus_message_unref(technology->wps_reply);
+       technology->wps_reply = NULL;
+
+       g_slist_foreach(technology->wps_offered, free_wps_offered, NULL);
+       g_slist_free(technology->wps_offered);
+       technology->wps_offered = NULL;
+}
+
+static int start_wps(struct connman_technology *technology,
+                    DBusMessage *msg, enum connman_technology_wps_mode mode)
+{
+       GSList *tech_drivers;
+       DBusMessageIter iter;
+       enum connman_peer_wps_method wps_method;
+       const char *auth;
+       int err, result = -EOPNOTSUPP;
+
+       if (technology->type != CONNMAN_SERVICE_TYPE_WIFI)
+               return -EOPNOTSUPP;
+
+       __sync_synchronize();
+       if (!technology->enabled)
+               return -EACCES;
+
+       if (!dbus_message_iter_init(msg, &iter))
+               return -EINVAL;
+
+       if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+               return -EINVAL;
+
+       dbus_message_iter_get_basic(&iter, &auth);
+
+       wps_method = __connman_check_wps_method(auth);
+       if (wps_method == CONNMAN_PEER_WPS_UNKNOWN)
+               return -EINVAL;
+       if (wps_method == CONNMAN_PEER_WPS_PBC)
+               auth = NULL;
+
+       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->start_wps ||
+                       driver->type != CONNMAN_SERVICE_TYPE_WIFI)
+                       continue;
+
+               err = driver->start_wps(technology, mode, auth);
+
+               if (result == -EINPROGRESS)
+                       continue;
+
+               if (err == -EINPROGRESS)
+                       result = err;
+       }
+
+       return result;
+}
+
+static DBusMessage *start_ap_wps(DBusConnection *conn, DBusMessage *msg,
+                                                       void *user_data)
+{
+       struct connman_technology *technology = user_data;
+       int err;
+
+       /* It is required to enable tethering before starting WPS in AP mode */
+       if (!technology->tethering) {
+               DBG("Error: Tethering is required");
+               return __connman_error_permission_denied(msg);
+       }
+
+       err = start_wps(technology, msg, CONNMAN_TECHNOLOGY_WPS_AP_MODE);
+       if (err == -EINPROGRESS)
+               return g_dbus_create_reply(msg, DBUS_TYPE_INVALID);
+
+       return __connman_error_failed(msg, -err);
+}
+
+static DBusMessage *start_sta_wps(DBusConnection *conn, DBusMessage *msg,
+                                                       void *user_data)
+{
+       struct connman_technology *technology = user_data;
+       int err;
+
+       if (technology->wps_reply)
+               connman_technology_reply_start_sta_wps(technology,
+                                                      -ECONNABORTED);
+
+       err = start_wps(technology, msg, CONNMAN_TECHNOLOGY_WPS_STA_MODE);
+       if (err == -EINPROGRESS) {
+               technology->wps_reply = dbus_message_ref(msg);
+               return NULL;
+       }
+
+       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);
+
+       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)
 {
@@ -1098,6 +1321,14 @@ static const GDBusMethodTable technology_methods[] = {
                        GDBUS_ARGS({ "name", "s" }, { "value", "v" }),
                        NULL, set_property) },
        { GDBUS_ASYNC_METHOD("Scan", NULL, NULL, scan) },
+       { GDBUS_ASYNC_METHOD("StartApWps",
+                       GDBUS_ARGS({ "authentication", "s" }),
+                       NULL, start_ap_wps) },
+       { GDBUS_ASYNC_METHOD("StartStaWps",
+                       GDBUS_ARGS({ "authentication", "s" }),
+                       NULL, start_sta_wps) },
+       { GDBUS_ASYNC_METHOD("CancelWps",
+                       NULL, NULL, cancel_wps) },
        { },
 };
 
-- 
2.17.1



------------------------------

Message: 2
Date: Thu, 11 Oct 2018 16:09:02 +0000
From: <[email protected]>
To: <[email protected]>
Cc: <[email protected]>, <[email protected]>
Subject: RE: [PATCHv3 1/6] wps: add new WPS API
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-2022-jp"

Hi Daniel-san,

Thank you for your comment for my previous patch.
Sorry my late reply.

I know currently my API implementation are under discussion,
but I send new patch series which reflect your comment.

Best regards,
n-itaya

--
?? ?? / ITAYA Natsuki
mailto:[email protected]




------------------------------

Subject: Digest Footer

_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman


------------------------------

End of connman Digest, Vol 36, Issue 14
***************************************

Reply via email to