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. [PATCHv2] client: Fix Memory Leak (Niraj Kumar Goit)
   2. [PATCHv2] client: Fix Memory Leak (Niraj Kumar Goit)
   3. Re: [PATCHv2] client: Fix Memory Leak (Jukka Rissanen)
   4. [PATCHv2] client: Fix Memory Leak (Patrik Flykt)
   5. Re: [PATCHv3] gdhcp: Don't try to remove timer again
      (Patrik Flykt)
   6. [RFC 1/2] Storage based service retrieval (MANIEZZO Marco (MM))


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

Message: 1
Date: Fri, 29 Jan 2016 10:10:43 +0530
From: Niraj Kumar Goit <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCHv2] client: Fix Memory Leak
Message-ID: <[email protected]>

Allocate memory to services structure after error checks to fix memory
leak.

---
v2: To fix memory leak instead of free memory in case of error, allocate
memory to services after all error checks.

 client/commands.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/client/commands.c b/client/commands.c
index db24d16..95343e3 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -795,7 +795,6 @@ static int cmd_service_move_before(char *args[], int num,
                struct connman_option *options)
 {
        const char *iface = "net.connman.Service";
-       struct move_service *services = g_new(struct move_service, 1);
 
        if (num > 3)
                return -E2BIG;
@@ -806,6 +805,8 @@ static int cmd_service_move_before(char *args[], int num,
        if (check_dbus_name(args[1]) == false)
                return -EINVAL;
 
+       struct move_service *services = g_new(struct move_service, 1);
+
        services->service = g_strdup_printf("/net/connman/service/%s", args[1]);
        services->target = g_strdup_printf("/net/connman/service/%s", args[2]);
 
-- 
1.7.9.5




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

Message: 2
Date: Fri, 29 Jan 2016 10:21:59 +0530
From: Niraj Kumar Goit <[email protected]>
To: [email protected]
Cc: [email protected]
Subject: [PATCHv2] client: Fix Memory Leak
Message-ID: <[email protected]>

In cmd_service_move_after() function, allocate memory to services
structure after error checks to fix memory leak.

---
v2: To fix memory leak instead of free memory in case of error, allocate
memory to services after all error checks.

 client/commands.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/client/commands.c b/client/commands.c
index 95343e3..6606baf 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -854,7 +854,6 @@ static int cmd_service_move_after(char *args[], int num,
                struct connman_option *options)
 {
        const char *iface = "net.connman.Service";
-       struct move_service *services = g_new(struct move_service, 1);
 
        if (num > 3)
                return -E2BIG;
@@ -865,6 +864,8 @@ static int cmd_service_move_after(char *args[], int num,
        if (check_dbus_name(args[1]) == false)
                return -EINVAL;
 
+       struct move_service *services = g_new(struct move_service, 1);
+
        services->service = g_strdup_printf("/net/connman/service/%s", args[1]);
        services->target = g_strdup_printf("/net/connman/service/%s", args[2]);
 
-- 
1.7.9.5




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

Message: 3
Date: Fri, 29 Jan 2016 09:27:11 +0200
From: Jukka Rissanen <[email protected]>
To: Niraj Kumar Goit <[email protected]>, [email protected]
Cc: [email protected]
Subject: Re: [PATCHv2] client: Fix Memory Leak
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"

Hi,

On Fri, 2016-01-29 at 10:21 +0530, Niraj Kumar Goit wrote:
> In cmd_service_move_after() function, allocate memory to services
> structure after error checks to fix memory leak.
> 
> ---
> v2: To fix memory leak instead of free memory in case of error,
> allocate
> memory to services after all error checks.
> 
> ?client/commands.c |????3 ++-
> ?1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/client/commands.c b/client/commands.c
> index 95343e3..6606baf 100644
> --- a/client/commands.c
> +++ b/client/commands.c
> @@ -854,7 +854,6 @@ static int cmd_service_move_after(char *args[],
> int num,
> ?             struct connman_option *options)
> ?{
> ?     const char *iface = "net.connman.Service";
> -     struct move_service *services = g_new(struct move_service,
> 1);
> ?
> ?     if (num > 3)
> ?             return -E2BIG;
> @@ -865,6 +864,8 @@ static int cmd_service_move_after(char *args[],
> int num,
> ?     if (check_dbus_name(args[1]) == false)
> ?             return -EINVAL;
> ?
> +     struct move_service *services = g_new(struct move_service,
> 1);
> +

You need to introduce the services variable at the beginning of the
function and not here.

> ?     services->service =
> g_strdup_printf("/net/connman/service/%s", args[1]);
> ?     services->target =
> g_strdup_printf("/net/connman/service/%s", args[2]);
> ?

Cheers,
Jukka



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

Message: 4
Date: Fri, 29 Jan 2016 09:40:59 +0200
From: Patrik Flykt <[email protected]>
To: Niraj Kumar Goit <[email protected]>
Cc: [email protected], [email protected]
Subject: [PATCHv2] client: Fix Memory Leak
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"

On Fri, 2016-01-29 at 10:10 +0530, Niraj Kumar Goit wrote:
> Allocate memory to services structure after error checks to fix memory
> leak.
> 
> ---
> v2: To fix memory leak instead of free memory in case of error, allocate
> memory to services after all error checks.
> 
>  client/commands.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/client/commands.c b/client/commands.c
> index db24d16..95343e3 100644
> --- a/client/commands.c
> +++ b/client/commands.c
> @@ -795,7 +795,6 @@ static int cmd_service_move_before(char *args[], int num,
>               struct connman_option *options)
>  {
>       const char *iface = "net.connman.Service";
> -     struct move_service *services = g_new(struct move_service, 1);
>  
>       if (num > 3)
>               return -E2BIG;
> @@ -806,6 +805,8 @@ static int cmd_service_move_before(char *args[], int num,
>       if (check_dbus_name(args[1]) == false)
>               return -EINVAL;
>  
> +     struct move_service *services = g_new(struct move_service, 1);
> +

This will not compile cleanly as the struct definition is in the middle
of the code. Definitions are in the beginning of the code block, always.

>       services->service = g_strdup_printf("/net/connman/service/%s", args[1]);
>       services->target = g_strdup_printf("/net/connman/service/%s", args[2]);
>  




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

Message: 5
Date: Fri, 29 Jan 2016 12:40:36 +0200
From: Patrik Flykt <[email protected]>
To: Saurav Babu <[email protected]>
Cc: [email protected], [email protected]
Subject: Re: [PATCHv3] gdhcp: Don't try to remove timer again
Message-ID: <[email protected]>
Content-Type: text/plain; charset="UTF-8"

On Thu, 2016-01-28 at 18:24 +0530, Saurav Babu wrote:
> GLib-CRITICAL warning message is obtained in below scenario:
> 1. service is connected and link local address is obtained.
> 2. Try to disconnect service.
> 
> (connmand:8377): GLib-CRITICAL **: Source ID 289 was not found when
> attempting to remove it
> 
> (connmand:8377): GLib-CRITICAL **: Source ID 303 was not found when
> attempting to remove it
> 
> When Link Local IP address is obtained then both dhcp_client->timeout
> assigned for DISCOVER_TIMEOUT and ANNOUNCE_INTERVAL are already removed
> when discover_timeout() and ipv4ll_announce_timeout() function returns
> FALSE but the dhcp_client->timeout is not assigned to 0. Now when
> dhcp_release() calls remove_timeouts() function then
> dhcp_client->timeout is tried to remove again resulting in GLib-CRITICAL
> warning. This patch removes all possible remaing timeouts in
> g_dhcp_client_start() and explicitly sets dhcp_client->timeout to 0 in
> ipv4ll_announce_timeout() function.
> ---
> 
> v3: Removes any possible remaining timeouts in g_dhcp_client_start() instead 
> of
> assigning dhcp_client->timeout to 0 just before calling g_dhcp_client_start()
> in discover_timeout

Applied, thanks!

        Patrik



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

Message: 6
Date: Fri, 29 Jan 2016 16:36:11 +0000
From: "MANIEZZO Marco (MM)" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [RFC 1/2] Storage based service retrieval
Message-ID: <[email protected]>
Content-Type: text/plain; charset="us-ascii"

Hello,

I'm proposing changes related to the attached discussion, on retrieval of 
stored services information, in two RFC proposals:

RFC (1): Add a method GetKnownServices to the Manager that has similar behavior 
of GetServices but the source is not the active services list but the services 
stored in STORAGEDIR.

RFC (2): Deletion of stored service: as far as I understood, provisioned 
services (the one with a .config file) cannot be deleted with Remove method of 
Service, but after testing of the WiFi technology I saw that it is not possible 
to remove (STORAGEDIR)/service_folder/settings even if there is no .config 
file, with the Remove method of a Service. This will lead to an increasing 
storage unless manually file deletion is done. The RFC then is to change the 
_connman_service_remove  function to actually delete folders and files, when 
possible, meaning I would preserve current conditions to return false in 
_connman_service_remove and moreover the .config files in (STORAGEDIR) won't be 
touched.

This email is to start with the RFC (1) modifications and see if my ideas are 
approved, because I made some assumptions that I hope are not a 
misunderstanding:


a)      currently from Service component, using Storage component it is 
possible to access only information stored in 
(STORAGEDIR)/service_folder/settings and not (STORAGEDIR)/files.config. The 
latter is only accessed by Config component

b)      the user can create a .config file in STORAGEDIR containing the 
information of connection (including passphrase for WiFi) of the services he 
already knows, so connman can connect (or autoconnect) to them without 
interaction. If a connection is made to these services with success, then a 
corresponding folder with a settings file will be created in (STORAGEDIR)/, 
that will reflects the .config file. Until a connection is done, only the 
.config file will exists. For services that don't have a .config file, after 
the user succeeds to connect to them the (STORAGEDIR)/service_folder/settings 
will be created.

Basing on the above assumption, mainly for (a) which would require further 
modifications, the GetKnownServices only retrieves the services that have 
(STORAGEDIR)/service_folder/settings; it will not read the content of the 
.config files. For our personal usage this is not a limitation because we won't 
have .config files, moreover the Remove method won't be able to remove them, 
but I'm open to change if you have suggestions.

Here's my proposal for RFC (1):

client/commands.c   | 13 ++++++++++++
doc/connmanctl.1.in | 11 ++++++++++
doc/manager-api.txt | 18 ++++++++++++++++
src/connman.h       |  1 +
src/manager.c       | 23 +++++++++++++++++++++
src/service.c       | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++
tools/manager-api.c | 33 ++++++++++++++++++++++++++++++
7 files changed, 158 insertions(+)


diff --git a/client/commands.c b/client/commands.c
index db24d16..313174a 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -348,6 +348,17 @@ static int object_properties(DBusMessageIter *iter,
               return 0;
}
+static int cmd_known_services(char *args[], int num, struct connman_option 
*options)
+{
+             if (num > 1)
+                             return -E2BIG;
+
+             return __connmanctl_dbus_method_call(connection,
+                                             CONNMAN_SERVICE, CONNMAN_PATH,
+                                             "net.connman.Manager", 
"GetKnownServices",
+                                             services_list, NULL, NULL, NULL);
+}
+
static int cmd_services(char *args[], int num, struct connman_option *options)
{
               char *service_name = NULL;
@@ -2549,6 +2560,8 @@ static const struct {
                 lookup_tether },
               { "services",     "[<service>]",  service_options, cmd_services,
                 "Display services", lookup_service_arg },
+             { "known-services",     NULL,  NULL, cmd_known_services,
+                               "Display known services", NULL },
               { "peers",        "[peer]",       NULL,            cmd_peers,
                 "Display peers", lookup_peer_arg },
               { "scan",         "<technology>", NULL,            cmd_scan,
diff --git a/doc/connmanctl.1.in b/doc/connmanctl.1.in
index 0f891bd..fe7359c 100644
--- a/doc/connmanctl.1.in
+++ b/doc/connmanctl.1.in
@@ -12,6 +12,7 @@ SYNOPSIS
.BI tether \ technology\ \fRon|off\ |
.BI tether\fR\ wifi\ on|off\  ssid\ passphrase\fR\ |
.BR services \ [\fIservice\fR]\ |
+.BR known-services\fR\ |
.BI peers \ peer\fR\ |
.BI scan \ technology\fR\ |
.RI \fBconnect \ service | peer \ |
@@ -103,6 +104,16 @@ Only the service path (e.g. 
wifi_6834534139723_managed_none)
is accepted as a parameter.
.PP
.TP
+.B known-services
+Returns a sorted list of tuples with service object path and dictionary of 
service
+properties, for the known services having their own directory in STORAGEDIR; it
+does not read .config files in root STORAGEDIR. With this principle, it will 
return
+only services that have been connected at least one time.
+This list will not contain sensitive information like passphrases etc.
+The object path can be used as string to retrieve main properties concatenated
+(for WiFi it includes SSID an security of the AP).
+.PP
+.TP
.BI scan \ technology
Scans for new services on the given technology.
.PP
diff --git a/doc/manager-api.txt b/doc/manager-api.txt
index 31e137c..509eac9 100644
--- a/doc/manager-api.txt
+++ b/doc/manager-api.txt
@@ -45,6 +45,24 @@ Methods                 dict GetProperties()
                                               and dictionary of peer properties
                                                Possible Errors: 
[service].Error.InvalidArguments
+
+                             array{object,dict} GetKnownServices() 
[experimental]
+
+                                             Returns a sorted list of tuples 
with service
+                                             object path and dictionary of 
service properties,
+                                             for the known services having 
their own directory in
+                                             STORAGEDIR; it does not read 
.config files in root STORAGEDIR.
+                                             With this principle, it will 
return only services that
+                                             have been connected at least one 
time.
+
+                                             This list will not contain 
sensitive information
+                                             like passphrases etc.
+
+                                             The object path can be used as 
string to retrieve main
+                                             properties concatenated (for WiFi 
it includes SSID an
+                                             security of the   AP).
+
+                                             Possible Errors: 
[service].Error.InvalidArguments
                                object ConnectProvider(dict provider)   
[deprecated]
diff --git a/src/connman.h b/src/connman.h
index 447bdd7..041b191 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -654,6 +654,7 @@ int __connman_service_init(void);
void __connman_service_cleanup(void);
int __connman_service_load_modifiable(struct connman_service *service);
+void __connman_known_service_list_struct(DBusMessageIter *iter);
void __connman_service_list_struct(DBusMessageIter *iter);
 int __connman_service_compare(const struct connman_service *a,
diff --git a/src/manager.c b/src/manager.c
index d15ce20..1f59644 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -175,6 +175,11 @@ static struct connman_notifier technology_notifier = {
               .idle_state          = idle_state,
};
+static void append_known_service_structs(DBusMessageIter *iter, void 
*user_data)
+{
+             __connman_known_service_list_struct(iter);
+}
+
static void append_service_structs(DBusMessageIter *iter, void *user_data)
{
               __connman_service_list_struct(iter);
@@ -195,6 +200,21 @@ static DBusMessage *get_services(DBusConnection *conn,
               return reply;
}
+static DBusMessage *get_known_services(DBusConnection *conn,
+                                                                             
DBusMessage *msg, void *data)
+{
+             DBusMessage *reply;
+
+             reply = dbus_message_new_method_return(msg);
+             if (!reply)
+                             return NULL;
+
+             __connman_dbus_append_objpath_dict_array(reply,
+                                             append_known_service_structs, 
NULL);
+
+             return reply;
+}
+
static void append_peer_structs(DBusMessageIter *iter, void *user_data)
{
               __connman_peer_list_struct(iter);
@@ -513,6 +533,9 @@ static const GDBusMethodTable manager_methods[] = {
               { GDBUS_DEPRECATED_METHOD("RemoveProvider",
                                               GDBUS_ARGS({ "provider", "o" }), 
NULL,
                                               remove_provider) },
+             { GDBUS_METHOD("GetKnownServices",
+                                             NULL, GDBUS_ARGS({ 
"knownServices", "a(oa{sv})" }),
+                                             get_known_services) },
               { GDBUS_METHOD("GetServices",
                                               NULL, GDBUS_ARGS({ "services", 
"a(oa{sv})" }),
                                               get_services) },
diff --git a/src/service.c b/src/service.c
index a93aebf..e18caa0 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2431,6 +2431,65 @@ static void append_struct(gpointer value, gpointer 
user_data)
               append_struct_service(iter, append_dict_properties, service);
}
+void __connman_known_service_list_struct(DBusMessageIter *iter)
+{
+             gchar **services = NULL;
+             gchar **serviceIDParts = NULL;
+             int i = 0;
+             struct connman_service *service = NULL;
+
+             DBG("listing known services");
+
+             services = connman_storage_get_services();
+             if (services == NULL)
+                             return;
+
+             for (i = 0; i < g_strv_length(services); i++)
+             {
+                             service = connman_service_create();
+                             if (service == NULL)
+                             {
+                                             
connman_error("connman_service_create() allocation failed");
+                                             return ;
+                             }
+                             service->identifier = g_strdup(services[i]);
+                             serviceIDParts = g_strsplit(services[i], "_", -1);
+                             if(serviceIDParts != NULL)
+                             {
+                                             service->type = 
__connman_service_string2type(serviceIDParts[0]);
+                                             service->path = 
g_strdup_printf("%s/service/%s", CONNMAN_PATH, service->identifier);
+                                             if(service->type == 
CONNMAN_SERVICE_TYPE_WIFI)
+                                                             service->security 
= 
__connman_service_string2security(serviceIDParts[g_strv_length(serviceIDParts)-1]);
+
+                                             if(service->path != NULL)
+                                             {
+                                                             
if(find_service(service->path) != NULL)
+                                                                             
service->state = (find_service(service->path))->state;
+                                                             if(service->type 
== CONNMAN_SERVICE_TYPE_ETHERNET && find_service(service->path) != NULL)
+                                                                             
service->name = (find_service(service->path))->name;
+
+                                                             if (0 != 
service_load(service))
+                                                             {
+                                                                             
connman_error("service_load() returned error");
+                                                                             
g_free(service);
+                                                                             
g_strfreev(serviceIDParts);
+                                                                             
g_strfreev(services);
+                                                                             
return;
+                                                             }
+
+                                                             
append_struct_service(iter, append_dict_properties, service);
+                                             }
+
+                                             g_strfreev(serviceIDParts);
+                             }
+                             g_free(service);
+
+             }
+
+             g_strfreev(services);
+}
+
+
void __connman_service_list_struct(DBusMessageIter *iter)
{
               g_list_foreach(service_list, append_struct, iter);
diff --git a/tools/manager-api.c b/tools/manager-api.c
index e082962..9e97f70 100644
--- a/tools/manager-api.c
+++ b/tools/manager-api.c
@@ -64,6 +64,39 @@ static DBusMessage *set_property(DBusConnection *connection,
               return reply;
}
+DBusMessage *manager_get_known_services(DBusConnection *connection)
+{
+             DBusMessage *message, *reply;
+             DBusError error;
+
+             message = dbus_message_new_method_call(CONNMAN_SERVICE,
+                                                                               
              CONNMAN_MANAGER_PATH,
+                                                                               
              CONNMAN_MANAGER_INTERFACE,
+                                                                               
                              "GetKnownServices");
+
+             if (!message)
+                             return NULL;
+
+             dbus_error_init(&error);
+
+             reply = dbus_connection_send_with_reply_and_block(connection,
+                                                                               
                              message, -1, &error);
+             if (!reply) {
+                             if (dbus_error_is_set(&error)) {
+                                             LOG("%s", error.message);
+                                             dbus_error_free(&error);
+                             } else {
+                                             LOG("Failed to get known 
services");
+                             }
+                             dbus_message_unref(message);
+                             return NULL;
+             }
+
+             dbus_message_unref(message);
+
+             return reply;
+}
+
DBusMessage *manager_get_services(DBusConnection *connection)
{
               DBusMessage *message, *reply;

--
1.9.1

Regards,
Marco







________________________________

VISITA IL NOSTRO NUOVO SITO WEB! - VISIT OUR NEW WEB SITE! 
www.magnetimarelli.com

Confidential Notice: This message - including its attachments - may contain 
proprietary, confidential and/or legally protected information and is intended 
solely for the use of the designated addressee(s) above. If you are not the 
intended recipient be aware that any downloading, copying, disclosure, 
distribution or use of the contents of the above information is strictly 
prohibited.
If you have received this communication by mistake, please forward the message 
back to the sender at the email address above, delete the message from all 
mailboxes and any other electronic storage medium and destroy all copies.
Disclaimer Notice: Internet communications cannot be guaranteed to be safe or 
error-free. Therefore we do not assure that this message is complete or 
accurate and we do not accept liability for any errors or omissions in the 
contents of this message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://lists.01.org/pipermail/connman/attachments/20160129/4992cddc/attachment.html>
-------------- next part --------------
An embedded message was scrubbed...
From: Marcel Holtmann <[email protected]>
Subject: Re: RFC: Storage based service retrieval
Date: Mon, 10 Aug 2015 22:49:34 +0000
Size: 5853
URL: 
<http://lists.01.org/pipermail/connman/attachments/20160129/4992cddc/attachment.mht>

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

Subject: Digest Footer

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


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

End of connman Digest, Vol 3, Issue 23
**************************************

Reply via email to