Send connman mailing list submissions to
        [email protected]

To subscribe or unsubscribe 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 v3 02/11] iwd: Parse SupportedModes from adapter proxy
      (Daniel Wagner)
   2. [PATCH v3 00/11]  Update iwd plugin (Daniel Wagner)
   3. [PATCH v3 01/11] gitignore: Ignore TAGS and cscope files
      (Daniel Wagner)
   4. [PATCH v3 04/11] iwd: Add KnownNetwork support (Daniel Wagner)
   5. [PATCH v3 03/11] iwd: Update device object (Daniel Wagner)
   6. [PATCH v3 05/11] iwd: Add KnownNetwork property to struct iwd_network
      (Daniel Wagner)
   7. [PATCH v3 08/11] iwd: Re-add update_signal_strenght()
      (Daniel Wagner)


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

Date: Mon, 13 Jan 2020 09:47:46 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v3 02/11] iwd: Parse SupportedModes from adapter proxy
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

The daemon supports more several operation modes. Extract the
information and store it in struct iwd_adapter.
---
 plugins/iwd.c | 46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 44 insertions(+), 2 deletions(-)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index ddc9201d03bc..4850dbf553a4 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -61,6 +61,9 @@ struct iwd_adapter {
        char *vendor;
        char *model;
        bool powered;
+       bool ad_hoc;
+       bool station;
+       bool ap;
 };
 
 struct iwd_device {
@@ -100,6 +103,27 @@ static const char *proxy_get_string(GDBusProxy *proxy, 
const char *property)
        return str;
 }
 
+static GSList *proxy_get_strings(GDBusProxy *proxy, const char *property)
+{
+       DBusMessageIter array, entry;
+       GSList *list = NULL;
+
+       if (!g_dbus_proxy_get_property(proxy, property, &array))
+               return NULL;
+
+       dbus_message_iter_recurse(&array, &entry);
+
+       while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRING){
+               const char *val;
+
+               dbus_message_iter_get_basic(&entry, &val);
+               list = g_slist_prepend(list, g_strdup(val));
+               dbus_message_iter_next(&entry);
+       }
+
+       return list;
+}
+
 static bool proxy_get_bool(GDBusProxy *proxy, const char *property)
 {
        DBusMessageIter iter;
@@ -725,6 +749,7 @@ static void create_adapter(GDBusProxy *proxy)
 {
        const char *path = g_dbus_proxy_get_path(proxy);
        struct iwd_adapter *iwda;
+       GSList *modes, *list;
 
        iwda = g_try_new0(struct iwd_adapter, 1);
 
@@ -748,8 +773,25 @@ static void create_adapter(GDBusProxy *proxy)
        iwda->model = g_strdup(proxy_get_string(proxy, "Model"));
        iwda->powered = proxy_get_bool(proxy, "Powered");
 
-       DBG("%s vendor '%s' model '%s' powered %d", path, iwda->vendor,
-               iwda->model, iwda->powered);
+       modes = proxy_get_strings(proxy, "SupportedModes");
+       for (list = modes; list; list = list->next) {
+               char *m = list->data;
+
+               if (!m)
+                       continue;
+
+               if (!strcmp(m, "ad-hoc"))
+                       iwda->ad_hoc = true;
+               else if (!strcmp(m, "station"))
+                       iwda->station = true;
+               else if (!strcmp(m, "ap"))
+                       iwda->ap = true;
+       }
+       g_slist_free_full(modes, g_free);
+
+       DBG("%s vendor '%s' model '%s' powered %d ad-hoc %d station %d ap %d",
+               path, iwda->vendor, iwda->model, iwda->powered,
+               iwda->ad_hoc, iwda->station, iwda->ap);
 
        g_dbus_proxy_set_property_watch(iwda->proxy,
                        adapter_property_change, NULL);
-- 
2.24.1

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

Date: Mon, 13 Jan 2020 09:47:44 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v3 00/11]  Update iwd plugin
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

I was looking at the agent API for a while. Due to the many
limitations of wpa_supplicant our code base is infested with hacks for
it. service.c handles the credentials and the agent code for
wpa_supplicant. This is not needed with iwd. Instead we should forward
the agent requests to the user directly from iwd.c.

After a few attemps to bypass the upper layers I gave up. The only
valid way forward is to push down the 802.11 related agent code into
wifi.c (or thereabout) and make the upper layers generic (read they
should not care about credentials). This is a mayor refactoring and I
wont do this right now. Instead I concentrat to finish the update of
the iwd plugin. Please test!

After this stuff I think it's soon time for a new release. 

changes since v2:
 - Disconnect via station API

changes since v1:
 - Added manual scan suppprt
 - Added tethering support
 - Fixed handling of KnownNetwork when disconnecting

Daniel Wagner (11):
  gitignore: Ignore TAGS and cscope files
  iwd: Parse SupportedModes from adapter proxy
  iwd: Update device object
  iwd: Add KnownNetwork support
  iwd: Add KnownNetwork property to struct iwd_network
  iwd: Add Station API support
  iwd: Add AccessPoint API support
  iwd: Re-add update_signal_strenght()
  iwd: Hookup manual scan trigger
  iwd: Add support for tethering
  iwd: Disconnect from network via station API

 .gitignore    |   2 +
 plugins/iwd.c | 770 +++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 694 insertions(+), 78 deletions(-)

-- 
2.24.1

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

Date: Mon, 13 Jan 2020 09:47:45 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v3 01/11] gitignore: Ignore TAGS and cscope files
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 3088a92fc203..cd7d88104fd7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,8 @@ autom4te.cache
 test-driver
 m4/
 !m4/configmake.m4
+TAGS
+cscope.*
 
 connman.pc
 include/connman
-- 
2.24.1

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

Date: Mon, 13 Jan 2020 09:47:48 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v3 04/11] iwd: Add KnownNetwork support
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

iwd exports all network it has been connected in the past via the
KnowNetwork interface. Add basic support to extract the information
from D-Bus.
---
 plugins/iwd.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 7222dd80e89d..82e0b6c794e2 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -42,6 +42,7 @@ static GDBusProxy *agent_proxy;
 static GHashTable *adapters;
 static GHashTable *devices;
 static GHashTable *networks;
+static GHashTable *known_networks;
 static bool agent_registered;
 
 #define IWD_SERVICE                    "net.connman.iwd"
@@ -50,6 +51,7 @@ static bool agent_registered;
 #define IWD_ADAPTER_INTERFACE          "net.connman.iwd.Adapter"
 #define IWD_DEVICE_INTERFACE           "net.connman.iwd.Device"
 #define IWD_NETWORK_INTERFACE          "net.connman.iwd.Network"
+#define IWD_KNOWN_NETWORK_INTERFACE    "net.connman.iwd.KnownNetwork"
 
 #define IWD_AGENT_INTERFACE            "net.connman.iwd.Agent"
 #define IWD_AGENT_ERROR_INTERFACE      "net.connman.iwd.Agent.Error"
@@ -90,6 +92,16 @@ struct iwd_network {
        struct connman_network *network;
 };
 
+struct iwd_known_network {
+       GDBusProxy *proxy;
+       char *path;
+       char *name;
+       char *type;
+       bool hidden;
+       char *last_connected_time;
+       bool auto_connect;
+};
+
 static const char *proxy_get_string(GDBusProxy *proxy, const char *property)
 {
        DBusMessageIter iter;
@@ -663,6 +675,22 @@ static void network_free(gpointer data)
        g_free(iwdn);
 }
 
+static void known_network_free(gpointer data)
+{
+       struct iwd_known_network *iwdkn = data;
+
+       if (iwdkn->proxy) {
+               g_dbus_proxy_unref(iwdkn->proxy);
+               iwdkn->proxy = NULL;
+       }
+
+       g_free(iwdkn->path);
+       g_free(iwdkn->name);
+       g_free(iwdkn->type);
+       g_free(iwdkn->last_connected_time);
+       g_free(iwdkn);
+}
+
 static void create_adapter(GDBusProxy *proxy)
 {
        const char *path = g_dbus_proxy_get_path(proxy);
@@ -928,6 +956,40 @@ static void create_network(GDBusProxy *proxy)
        add_network(path, iwdn);
 }
 
+static void create_know_network(GDBusProxy *proxy)
+{
+       const char *path = g_dbus_proxy_get_path(proxy);
+       struct iwd_known_network *iwdkn;
+
+       iwdkn = g_try_new0(struct iwd_known_network, 1);
+       if (!iwdkn) {
+               connman_error("Out of memory creating IWD known network");
+               return;
+       }
+
+       iwdkn->path = g_strdup(path);
+       g_hash_table_replace(known_networks, iwdkn->path, iwdkn);
+
+       iwdkn->proxy = g_dbus_proxy_ref(proxy);
+
+       if (!iwdkn->proxy) {
+               connman_error("Cannot create IWD known network watcher %s", 
path);
+               g_hash_table_remove(known_networks, path);
+               return;
+       }
+
+       iwdkn->name = g_strdup(proxy_get_string(proxy, "Name"));
+       iwdkn->type = g_strdup(proxy_get_string(proxy, "Type"));
+       iwdkn->hidden = proxy_get_bool(proxy, "Hidden");
+       iwdkn->last_connected_time =
+               g_strdup(proxy_get_string(proxy, "LastConnectedTime"));
+       iwdkn->auto_connect = proxy_get_bool(proxy, "AutoConnec");
+
+       DBG("name '%s' type %s hidden %d, last_connection_time %s auto_connect 
%d",
+               iwdkn->name, iwdkn->type, iwdkn->hidden,
+               iwdkn->last_connected_time, iwdkn->auto_connect);
+}
+
 static void object_added(GDBusProxy *proxy, void *user_data)
 {
        const char *interface;
@@ -949,6 +1011,8 @@ static void object_added(GDBusProxy *proxy, void 
*user_data)
                create_device(proxy);
        else if (!strcmp(interface, IWD_NETWORK_INTERFACE))
                create_network(proxy);
+       else if (!strcmp(interface, IWD_KNOWN_NETWORK_INTERFACE))
+               create_know_network(proxy);
 }
 
 static void object_removed(GDBusProxy *proxy, void *user_data)
@@ -973,6 +1037,8 @@ static void object_removed(GDBusProxy *proxy, void 
*user_data)
                g_hash_table_remove(devices, path);
        else if (!strcmp(interface, IWD_NETWORK_INTERFACE))
                g_hash_table_remove(networks, path);
+       else if (!strcmp(interface, IWD_KNOWN_NETWORK_INTERFACE))
+               g_hash_table_remove(known_networks, path);
 }
 
 static int iwd_init(void)
@@ -990,6 +1056,9 @@ static int iwd_init(void)
        networks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
                        network_free);
 
+       known_networks = g_hash_table_new_full(g_str_hash, g_str_equal, NULL,
+                       known_network_free);
+
        if (connman_technology_driver_register(&tech_driver) < 0) {
                connman_warn("Failed to initialize technology for IWD");
                goto out;
@@ -1029,6 +1098,9 @@ static int iwd_init(void)
        if (networks)
                g_hash_table_destroy(networks);
 
+       if (known_networks)
+               g_hash_table_destroy(known_networks);
+
        if (adapters)
                g_hash_table_destroy(adapters);
 
@@ -1046,6 +1118,7 @@ static void iwd_exit(void)
 
        g_dbus_client_unref(client);
 
+       g_hash_table_destroy(known_networks);
        g_hash_table_destroy(networks);
        g_hash_table_destroy(devices);
        g_hash_table_destroy(adapters);
-- 
2.24.1

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

Date: Mon, 13 Jan 2020 09:47:47 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v3 03/11] iwd: Update device object
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

iwd moved the scanning property from the device API to a new
API. Therefore just drop it here and add back when we introduce the
new station API.

Add the device mode property which tells us how the device is
operated.
---
 plugins/iwd.c | 102 +++++---------------------------------------------
 1 file changed, 10 insertions(+), 92 deletions(-)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 4850dbf553a4..7222dd80e89d 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -73,7 +73,7 @@ struct iwd_device {
        char *name;
        char *address;
        bool powered;
-       bool scanning;
+       char *mode;
 
        struct connman_device *device;
 };
@@ -388,85 +388,6 @@ static struct connman_technology_driver tech_driver = {
        .remove         = cm_tech_remove,
 };
 
-static unsigned char calculate_strength(int strength)
-{
-       unsigned char res;
-
-       /*
-        * Network's maximum signal strength expressed in 100 * dBm.
-        * The value is the range of 0 (strongest signal) to -10000
-        * (weakest signal)
-        *
-        * ConnMan expects it in the range from 100 (strongest) to 0
-        * (weakest).
-        */
-       res = (unsigned char)((strength * -10000) / 100);
-
-       return res;
-}
-
-static void _update_signal_strength(const char *path, int16_t signal_strength)
-{
-       struct iwd_network *iwdn;
-
-       iwdn = g_hash_table_lookup(networks, path);
-       if (!iwdn)
-               return;
-
-       if (!iwdn->network)
-               return;
-
-       connman_network_set_strength(iwdn->network,
-                                       calculate_strength(signal_strength));
-}
-
-static void ordered_networks_cb(DBusMessage *message, void *user_data)
-{
-       DBusMessageIter array, entry;
-
-       DBG("");
-
-       if (!dbus_message_iter_init(message, &array))
-               return;
-
-       if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
-               return;
-
-       dbus_message_iter_recurse(&array, &entry);
-       while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRUCT) {
-               DBusMessageIter value;
-               const char *path, *name, *type;
-               int16_t signal_strength;
-
-
-               dbus_message_iter_recurse(&entry, &value);
-
-               dbus_message_iter_get_basic(&value, &path);
-
-               dbus_message_iter_next(&value);
-               dbus_message_iter_get_basic(&value, &name);
-
-               dbus_message_iter_next(&value);
-               dbus_message_iter_get_basic(&value, &signal_strength);
-
-               dbus_message_iter_next(&value);
-               dbus_message_iter_get_basic(&value, &type);
-
-               _update_signal_strength(path, signal_strength);
-
-               dbus_message_iter_next(&entry);
-       }
-}
-
-static void update_signal_strength(struct iwd_device *iwdd)
-{
-       if (!g_dbus_proxy_method_call(iwdd->proxy,
-                                       "GetOrderedNetworks",
-                                       NULL, ordered_networks_cb,
-                                       NULL, NULL))
-               DBG("GetOrderedNetworks() failed");
-}
-
 static const char *security_remap(const char *security)
 {
        if (!g_strcmp0(security, "open"))
@@ -654,17 +575,14 @@ static void device_property_change(GDBusProxy *proxy, 
const char *name,
                iwdd->powered = powered;
 
                DBG("%s powered %d", path, iwdd->powered);
-       } else if (!strcmp(name, "Scanning")) {
-               dbus_bool_t scanning;
-
-               dbus_message_iter_get_basic(iter, &scanning);
-               iwdd->scanning = scanning;
-
-               DBG("%s scanning %d", path, iwdd->scanning);
+       } else if (!strcmp(name, "Mode")) {
+               const char *mode;
 
-               if (!iwdd->scanning)
-                       update_signal_strength(iwdd);
+               dbus_message_iter_get_basic(iter, &mode);
+               g_free(iwdd->mode);
+               iwdd->mode = g_strdup(mode);
 
+               DBG("%s mode %s", path, iwdd->mode);
        }
 }
 
@@ -824,11 +742,11 @@ static void create_device(GDBusProxy *proxy)
        iwdd->name = g_strdup(proxy_get_string(proxy, "Name"));
        iwdd->address = g_strdup(proxy_get_string(proxy, "Address"));
        iwdd->powered = proxy_get_bool(proxy, "Powered");
-       iwdd->scanning = proxy_get_bool(proxy, "Scanning");
+       iwdd->mode = g_strdup(proxy_get_string(proxy, "Mode"));
 
-       DBG("adapter %s name %s address %s powered %d scanning %d",
+       DBG("adapter %s name %s address %s powered %d mode %s",
                iwdd->adapter, iwdd->name, iwdd->address,
-               iwdd->powered, iwdd->scanning);
+               iwdd->powered, iwdd->mode);
 
        g_dbus_proxy_set_property_watch(iwdd->proxy,
                        device_property_change, NULL);
-- 
2.24.1

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

Date: Mon, 13 Jan 2020 09:47:49 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v3 05/11] iwd: Add KnownNetwork property to struct
        iwd_network
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

Parse the KnownNetwork property and add it to struct iwd_network.
---
 plugins/iwd.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 82e0b6c794e2..94284996a6bb 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -87,6 +87,7 @@ struct iwd_network {
        char *name;
        char *type;
        bool connected;
+       char *known_network;
 
        struct iwd_device *iwdd;
        struct connman_network *network;
@@ -672,6 +673,7 @@ static void network_free(gpointer data)
        g_free(iwdn->device);
        g_free(iwdn->name);
        g_free(iwdn->type);
+       g_free(iwdn->known_network);
        g_free(iwdn);
 }
 
@@ -943,12 +945,11 @@ static void create_network(GDBusProxy *proxy)
        iwdn->name = g_strdup(proxy_get_string(proxy, "Name"));
        iwdn->type = g_strdup(proxy_get_string(proxy, "Type"));
        iwdn->connected = proxy_get_bool(proxy, "Connected");
+       iwdn->known_network = g_strdup(proxy_get_string(proxy, "KnownNetwork"));
 
-       DBG("device %s name '%s' type %s connected %d",
-               iwdn->device,
-               iwdn->name,
-               iwdn->type,
-               iwdn->connected);
+       DBG("device %s name '%s' type %s connected %d known_network %s",
+               iwdn->device, iwdn->name, iwdn->type, iwdn->connected,
+               iwdn->known_network);
 
        g_dbus_proxy_set_property_watch(iwdn->proxy,
                        network_property_change, NULL);
-- 
2.24.1

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

Date: Mon, 13 Jan 2020 09:47:52 +0100
From: Daniel Wagner <[email protected]>
Subject: [PATCH v3 08/11] iwd: Re-add update_signal_strenght()
To: [email protected]
Cc: Daniel Wagner <[email protected]>
Message-ID: <[email protected]>

Bring back the update_signal_strenght() code.
---
 plugins/iwd.c | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/plugins/iwd.c b/plugins/iwd.c
index 6e2b9672beb5..8b4a2b387daa 100644
--- a/plugins/iwd.c
+++ b/plugins/iwd.c
@@ -643,6 +643,84 @@ static void network_property_change(GDBusProxy *proxy, 
const char *name,
        }
 }
 
+static unsigned char calculate_strength(int strength)
+{
+       unsigned char res;
+
+       /*
+        * Network's maximum signal strength expressed in 100 * dBm.
+        * The value is the range of 0 (strongest signal) to -10000
+        * (weakest signal)
+        *
+        * ConnMan expects it in the range from 100 (strongest) to 0
+        * (weakest).
+        */
+       res = (unsigned char)((strength * -10000) / 100);
+
+       return res;
+}
+
+static void _update_signal_strength(const char *path, int16_t signal_strength)
+{
+       struct iwd_station *iwds;
+       struct iwd_network *iwdn;
+
+       iwds = g_hash_table_lookup(stations, path);
+       if (!iwds)
+               return;
+
+       if (!iwds->connected_network)
+               return;
+
+       iwdn = g_hash_table_lookup(networks, iwds->connected_network);
+       if (!iwdn)
+               return;
+
+       connman_network_set_strength(iwdn->network,
+                                       calculate_strength(signal_strength));
+}
+
+static void ordered_networks_cb(DBusMessage *message, void *user_data)
+{
+       DBusMessageIter array, entry;
+
+       DBG("");
+
+       if (!dbus_message_iter_init(message, &array))
+               return;
+
+       if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_ARRAY)
+               return;
+
+       dbus_message_iter_recurse(&array, &entry);
+       while (dbus_message_iter_get_arg_type(&entry) == DBUS_TYPE_STRUCT) {
+               DBusMessageIter value;
+               const char *path;
+               int16_t signal_strength;
+
+
+               dbus_message_iter_recurse(&entry, &value);
+
+               dbus_message_iter_get_basic(&value, &path);
+
+               dbus_message_iter_next(&value);
+               dbus_message_iter_get_basic(&value, &signal_strength);
+
+               _update_signal_strength(path, signal_strength);
+
+               dbus_message_iter_next(&entry);
+       }
+}
+
+static void update_signal_strength(struct iwd_station *iwds)
+{
+       if (!g_dbus_proxy_method_call(iwds->proxy,
+                                       "GetOrderedNetworks",
+                                       NULL, ordered_networks_cb,
+                                       NULL, NULL))
+               DBG("GetOrderedNetworks() failed");
+}
+
 static void station_property_change(GDBusProxy *proxy, const char *name,
                DBusMessageIter *iter, void *user_data)
 {
@@ -680,6 +758,9 @@ static void station_property_change(GDBusProxy *proxy, 
const char *name,
                dbus_message_iter_get_basic(iter, &scanning);
                iwds->scanning = scanning;
 
+               if (!iwds->scanning)
+                       update_signal_strength(iwds);
+
                DBG("%s scanning %d", path, iwds->scanning);
        }
 }
-- 
2.24.1

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

Subject: Digest Footer

_______________________________________________
connman mailing list -- [email protected]
To unsubscribe send an email to [email protected]


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

End of connman Digest, Vol 51, Issue 16
***************************************

Reply via email to