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 1/2] Refactoring: Simplify scan cb of struct
      connman_device_driver. Use a structure instead of many
      parameters. The reason for refactoring is the need to have even
      more parameters for scan cb in future. (Volodymyr Ostap)
   2. [PATCH 2/2] Force full wifi scan if it is a request over
      dbus. (Volodymyr Ostap)
   3. [PATCH] Fix gsupplicant not to include empty entry "SSIDs" in
      dbus message to wpa_supplicant (Volodymyr Ostap)


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

Message: 1
Date: Tue, 11 Dec 2018 10:14:05 -0800
From: Volodymyr Ostap <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>, Vasyl Vavrychuk
        <[email protected]>, Volodymyr Ostap
        <[email protected]>
Subject: [PATCH 1/2] Refactoring: Simplify scan cb of struct
        connman_device_driver. Use a structure instead of many parameters. The
        reason for refactoring is the need to have even more parameters for
        scan cb in future.
Message-ID: <[email protected]>

---
 include/device.h | 17 ++++++++++++-----
 plugins/wifi.c   | 31 +++++++++++++++----------------
 src/device.c     | 29 +++++++++++++++++++++--------
 3 files changed, 48 insertions(+), 29 deletions(-)

diff --git a/include/device.h b/include/device.h
index 5a3ddc22..ebc9df00 100644
--- a/include/device.h
+++ b/include/device.h
@@ -50,6 +50,16 @@ enum connman_device_type {
 #define CONNMAN_DEVICE_PRIORITY_DEFAULT     0
 #define CONNMAN_DEVICE_PRIORITY_HIGH      100
 
+struct scan_parameters {
+       enum connman_service_type type;
+       const char *ssid;
+       unsigned int ssid_len;
+       const char *identity;
+       const char* passphrase;
+       const char *security;
+       void *user_data;
+};
+
 struct connman_device;
 
 struct connman_device *connman_device_create(const char *node,
@@ -120,11 +130,8 @@ struct connman_device_driver {
        void (*remove) (struct connman_device *device);
        int (*enable) (struct connman_device *device);
        int (*disable) (struct connman_device *device);
-       int (*scan)(enum connman_service_type type,
-                       struct connman_device *device,
-                       const char *ssid, unsigned int ssid_len,
-                       const char *identity, const char* passphrase,
-                       const char *security, void *user_data);
+       int (*scan)(struct connman_device *device,
+                       struct scan_parameters *parameters);
        void (*stop_scan) (enum connman_service_type type,
                        struct connman_device *device);
        int (*set_regdom) (struct connman_device *device,
diff --git a/plugins/wifi.c b/plugins/wifi.c
index 6fa20312..f41e8ae1 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1853,11 +1853,8 @@ static int p2p_find(struct connman_device *device)
  * Note that the hidden scan is only used when connecting to this specific
  * hidden AP first time. It is not used when system autoconnects to hidden AP.
  */
-static int wifi_scan(enum connman_service_type type,
-                       struct connman_device *device,
-                       const char *ssid, unsigned int ssid_len,
-                       const char *identity, const char* passphrase,
-                       const char *security, void *user_data)
+static int wifi_scan(struct connman_device *device,
+                       struct scan_parameters *parameters)
 {
        struct wifi_data *wifi = connman_device_get_data(device);
        GSupplicantScanParams *scan_params = NULL;
@@ -1877,14 +1874,16 @@ static int wifi_scan(enum connman_service_type type,
        if (wifi->tethering)
                return -EBUSY;
 
-       if (type == CONNMAN_SERVICE_TYPE_P2P)
+       if (parameters->type == CONNMAN_SERVICE_TYPE_P2P)
                return p2p_find(device);
 
-       DBG("device %p wifi %p hidden ssid %s", device, wifi->interface, ssid);
+       DBG("device %p wifi %p hidden ssid %s", device, wifi->interface,
+               parameters->ssid);
 
        scanning = connman_device_get_scanning(device, 
CONNMAN_SERVICE_TYPE_WIFI);
 
-       if (!ssid || ssid_len == 0 || ssid_len > 32) {
+       if (!parameters->ssid || parameters->ssid_len == 0 ||
+                       parameters->ssid_len > 32) {
                if (scanning)
                        return -EALREADY;
 
@@ -1913,8 +1912,8 @@ static int wifi_scan(enum connman_service_type type,
                        return -ENOMEM;
                }
 
-               memcpy(scan_ssid->ssid, ssid, ssid_len);
-               scan_ssid->ssid_len = ssid_len;
+               memcpy(scan_ssid->ssid, parameters->ssid, parameters->ssid_len);
+               scan_ssid->ssid_len = parameters->ssid_len;
                scan_params->ssids = g_slist_prepend(scan_params->ssids,
                                                                scan_ssid);
                scan_params->num_ssids = 1;
@@ -1930,12 +1929,12 @@ static int wifi_scan(enum connman_service_type type,
                        wifi->hidden = NULL;
                }
 
-               memcpy(hidden->ssid, ssid, ssid_len);
-               hidden->ssid_len = ssid_len;
-               hidden->identity = g_strdup(identity);
-               hidden->passphrase = g_strdup(passphrase);
-               hidden->security = g_strdup(security);
-               hidden->user_data = user_data;
+               memcpy(hidden->ssid, parameters->ssid, parameters->ssid_len);
+               hidden->ssid_len = parameters->ssid_len;
+               hidden->identity = g_strdup(parameters->identity);
+               hidden->passphrase = g_strdup(parameters->passphrase);
+               hidden->security = g_strdup(parameters->security);
+               hidden->user_data = parameters->user_data;
                wifi->hidden = hidden;
 
                if (scanning) {
diff --git a/src/device.c b/src/device.c
index 5d343ae8..f0994035 100644
--- a/src/device.c
+++ b/src/device.c
@@ -613,10 +613,13 @@ int connman_device_set_powered(struct connman_device 
*device,
        for (i = 0; i < MAX_CONNMAN_SERVICE_TYPES; i++)
                device->scanning[i] = false;
 
-       if (device->driver && device->driver->scan)
-               device->driver->scan(CONNMAN_SERVICE_TYPE_UNKNOWN, device,
-                                       NULL, 0, NULL, NULL, NULL, NULL);
+       if (device->driver && device->driver->scan) {
+               struct scan_parameters parameters;
+               memset(&parameters, 0, sizeof(parameters));
+               parameters.type = CONNMAN_SERVICE_TYPE_UNKNOWN;
 
+               device->driver->scan(device, &parameters);
+       }
        return 0;
 }
 
@@ -634,8 +637,11 @@ static int device_scan(enum connman_service_type type,
        if (!device->powered)
                return -ENOLINK;
 
-       return device->driver->scan(type, device, NULL, 0,
-                                       NULL, NULL, NULL, NULL);
+       struct scan_parameters parameters;
+       memset(&parameters, 0, sizeof(parameters));
+       parameters.type = type;
+
+       return device->driver->scan(device, &parameters);
 }
 
 int __connman_device_disconnect(struct connman_device *device)
@@ -1134,9 +1140,16 @@ int __connman_device_request_hidden_scan(struct 
connman_device *device,
                        !device->driver->scan)
                return -EINVAL;
 
-       return device->driver->scan(CONNMAN_SERVICE_TYPE_UNKNOWN,
-                                       device, ssid, ssid_len, identity,
-                                       passphrase, security, user_data);
+       struct scan_parameters parameters;
+       parameters.type = CONNMAN_SERVICE_TYPE_UNKNOWN;
+       parameters.ssid = ssid;
+       parameters.ssid_len = ssid_len;
+       parameters.identity = identity;
+       parameters.passphrase = passphrase;
+       parameters.security = security;
+       parameters.user_data = user_data;
+
+       return device->driver->scan(device, &parameters);
 }
 
 void __connman_device_stop_scan(enum connman_service_type type)
-- 
2.17.1



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

Message: 2
Date: Tue, 11 Dec 2018 10:18:03 -0800
From: Volodymyr Ostap <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>, Vasyl Vavrychuk
        <[email protected]>, Volodymyr Ostap
        <[email protected]>
Subject: [PATCH 2/2] Force full wifi scan if it is a request over
        dbus.
Message-ID: <[email protected]>

If there are stored connections and wifi is not connected
the scan used to fall into scan on stored channels even it is
a manually requested scan over dbus from an application.
The application used to receive only APs on these channels.

Now, if it is a scan request over dbus it scans on all channels and
an application gets a full list of APs.
---
 include/device.h |  1 +
 plugins/wifi.c   |  7 ++++---
 src/connman.h    |  1 +
 src/device.c     | 19 ++++++++++++++++---
 src/technology.c |  2 +-
 5 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/include/device.h b/include/device.h
index ebc9df00..bd611366 100644
--- a/include/device.h
+++ b/include/device.h
@@ -57,6 +57,7 @@ struct scan_parameters {
        const char *identity;
        const char* passphrase;
        const char *security;
+       bool force_full_scan;
        void *user_data;
 };
 
diff --git a/plugins/wifi.c b/plugins/wifi.c
index f41e8ae1..c23a9968 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -1877,8 +1877,9 @@ static int wifi_scan(struct connman_device *device,
        if (parameters->type == CONNMAN_SERVICE_TYPE_P2P)
                return p2p_find(device);
 
-       DBG("device %p wifi %p hidden ssid %s", device, wifi->interface,
-               parameters->ssid);
+       DBG("device %p wifi %p hidden ssid %s forced full scan %s", device,
+               wifi->interface, parameters->ssid, parameters->force_full_scan ?
+               "forced" : "normal");
 
        scanning = connman_device_get_scanning(device, 
CONNMAN_SERVICE_TYPE_WIFI);
 
@@ -1948,7 +1949,7 @@ static int wifi_scan(struct connman_device *device,
        } else if (wifi->connected) {
                g_supplicant_free_scan_params(scan_params);
                return wifi_scan_simple(device);
-       } else {
+       } else if (!parameters->force_full_scan) {
                ret = get_latest_connections(driver_max_ssids, scan_params);
                if (ret <= 0) {
                        g_supplicant_free_scan_params(scan_params);
diff --git a/src/connman.h b/src/connman.h
index 52805bec..8101c7b2 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -566,6 +566,7 @@ void __connman_device_list(DBusMessageIter *iter, void 
*user_data);
 enum connman_service_type __connman_device_get_service_type(struct 
connman_device *device);
 struct connman_device *__connman_device_find_device(enum connman_service_type 
type);
 int __connman_device_request_scan(enum connman_service_type type);
+int __connman_device_request_scan_full(enum connman_service_type type);
 int __connman_device_request_hidden_scan(struct connman_device *device,
                                const char *ssid, unsigned int ssid_len,
                                const char *identity, const char *passphrase,
diff --git a/src/device.c b/src/device.c
index f0994035..f1c05d49 100644
--- a/src/device.c
+++ b/src/device.c
@@ -629,7 +629,8 @@ bool connman_device_get_powered(struct connman_device 
*device)
 }
 
 static int device_scan(enum connman_service_type type,
-                               struct connman_device *device)
+                               struct connman_device *device,
+                               bool force_full_scan)
 {
        if (!device->driver || !device->driver->scan)
                return -EOPNOTSUPP;
@@ -640,6 +641,7 @@ static int device_scan(enum connman_service_type type,
        struct scan_parameters parameters;
        memset(&parameters, 0, sizeof(parameters));
        parameters.type = type;
+       parameters.force_full_scan = force_full_scan;
 
        return device->driver->scan(device, &parameters);
 }
@@ -1086,7 +1088,8 @@ void connman_device_regdom_notify(struct connman_device 
*device,
        __connman_technology_notify_regdom_by_device(device, result, alpha2);
 }
 
-int __connman_device_request_scan(enum connman_service_type type)
+static int connman_device_request_scan(enum connman_service_type type,
+       bool force_full_scan)
 {
        bool success = false;
        int last_err = -ENOSYS;
@@ -1114,7 +1117,7 @@ int __connman_device_request_scan(enum 
connman_service_type type)
                if (!device_has_service_type(device, type))
                        continue;
 
-               err = device_scan(type, device);
+               err = device_scan(type, device, force_full_scan);
                if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
                        success = true;
                } else {
@@ -1129,6 +1132,16 @@ int __connman_device_request_scan(enum 
connman_service_type type)
        return last_err;
 }
 
+int __connman_device_request_scan(enum connman_service_type type)
+{
+       return connman_device_request_scan(type, false);
+}
+
+int __connman_device_request_scan_full(enum connman_service_type type)
+{
+       return connman_device_request_scan(type, true);
+}
+
 int __connman_device_request_hidden_scan(struct connman_device *device,
                                const char *ssid, unsigned int ssid_len,
                                const char *identity, const char *passphrase,
diff --git a/src/technology.c b/src/technology.c
index 78550f48..4e053fc9 100644
--- a/src/technology.c
+++ b/src/technology.c
@@ -1087,7 +1087,7 @@ static DBusMessage *scan(DBusConnection *conn, 
DBusMessage *msg, void *data)
        technology->scan_pending =
                g_slist_prepend(technology->scan_pending, msg);
 
-       err = __connman_device_request_scan(technology->type);
+       err = __connman_device_request_scan_full(technology->type);
        if (err < 0)
                reply_scan_pending(technology, err);
 
-- 
2.17.1



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

Message: 3
Date: Tue, 11 Dec 2018 10:20:14 -0800
From: Volodymyr Ostap <[email protected]>
To: [email protected]
Cc: Daniel Wagner <[email protected]>, Vasyl Vavrychuk
        <[email protected]>, Volodymyr Ostap
        <[email protected]>
Subject: [PATCH] Fix gsupplicant not to include empty entry "SSIDs" in
        dbus message to wpa_supplicant
Message-ID: <[email protected]>

To to an active wifi scan on all channels connman calls gsupplicant's
g_supplicant_interface_scan() with empty list of frequencies and empty
list of SSIDs. gsupplicant used to send an empty entry of "SSIDs" in this case.
Sending the empty entry "SSIDs" to wpa_supplicant 2.6 triggers an error in
wpas_dbus_get_scan_ssids() called from wpas_dbus_handler_scan().
The function does not expect the empty list and fails with the error:
"wpas_dbus_get_scan_ssids[dbus]: ssids must be an array of arrays of bytes"
---
 gsupplicant/supplicant.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index be2deaa5..b814b320 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -4303,11 +4303,13 @@ static void interface_scan_params(DBusMessageIter 
*iter, void *user_data)
                supplicant_dbus_dict_append_basic(&dict, "Type",
                                        DBUS_TYPE_STRING, &type);
 
-               supplicant_dbus_dict_append_array(&dict, "SSIDs",
-                                               DBUS_TYPE_STRING,
-                                               append_ssids,
-                                               data->scan_params);
 
+               if (data->scan_params->ssids) {
+                       supplicant_dbus_dict_append_array(&dict, "SSIDs",
+                                                       DBUS_TYPE_STRING,
+                                                       append_ssids,
+                                                       data->scan_params);
+               }
                supplicant_add_scan_frequency(&dict, add_scan_frequencies,
                                                data->scan_params);
        } else
-- 
2.17.1



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

Subject: Digest Footer

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


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

End of connman Digest, Vol 38, Issue 2
**************************************

Reply via email to