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] service: Avoid a round trip when security information
      is already known (Jose Blanquicet)
   2. [PATCH] Remove old ip/gateway address if different addresses
      are assigned during DHCP renewal to avoid two ip addresses added
      to the interface. (Feng Wang)


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

Message: 1
Date: Mon, 18 Apr 2016 17:11:10 +0200
From: Jose Blanquicet <[email protected]>
To: [email protected]
Subject: [PATCH] service: Avoid a round trip when security information
        is already known
Message-ID: <[email protected]>

Hi, 

This patch aims to avoid the use of the Agent when the security information 
is already known. For example, if the GUI has knowledge about service 
security, it could inmediatly ask to user to insert the passphrase when
user tries to connect to a service which uses PSK as security method and 
send the connection request and the passphrase in a single call. In that 
way we are avoiding a round trip (Added by Agent) and making easier/faster 
the connection mechanism. This idea could also be extended for Connect 
method of net.connman.Peer Interface.

The current Connect method without input arguments would remain there 
in order to mantain backward compatibility.

The connmanctl update is missing in this patch because we first would 
like to know what do you think about this idea before performing the 
full implementation of the patch.

Best Regards,

Jose Blanquicet

---
 src/service.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 768426b..194ddee 100644
--- a/src/service.c
+++ b/src/service.c
@@ -4007,12 +4007,29 @@ static gboolean connect_timeout(gpointer user_data)
        return FALSE;
 }
 
+static int extract_passphrase(DBusMessage *msg, const char **passphrase)
+{
+       DBusMessageIter iter;
+
+       if (!dbus_message_iter_init(msg, &iter))
+               return 0; // Passphrase wasn't specified but it's not an error
+
+       if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_STRING)
+               return -EINVAL;
+
+       dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, passphrase,
+                                       DBUS_TYPE_INVALID);
+
+       return 0;
+}
+
 static DBusMessage *connect_service(DBusConnection *conn,
                                        DBusMessage *msg, void *user_data)
 {
        struct connman_service *service = user_data;
        int index, err = 0;
        GList *list;
+       const char *passphrase = NULL;

        DBG("service %p", service);
 
@@ -4041,6 +4058,28 @@ static DBusMessage *connect_service(DBusConnection *conn,
        if (err == -EINPROGRESS)
                return __connman_error_operation_timeout(msg);
 
+       err = extract_passphrase(msg, &passphrase);
+       if (err < 0) {
+               DBG("Error: Invalid parameters for Service Connection");
+               return __connman_error_invalid_arguments(msg);
+       }
+
+       if (passphrase) {
+               if (g_strcmp0(passphrase, service->passphrase)) {
+                       err = __connman_service_set_passphrase(service, 
passphrase);
+                       if (err < 0) {
+                               if (err == -ENOKEY)
+                                       
__connman_service_indicate_error(service,
+                                                       
CONNMAN_SERVICE_ERROR_INVALID_KEY);
+
+                               return __connman_error_failed(msg, -err);
+                       }
+
+                       /* We forget any previous error. */
+                       set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
+               }
+       }
+       
        service->ignore = false;
 
        service->pending = dbus_message_ref(msg);
@@ -4467,7 +4506,10 @@ static const GDBusMethodTable service_methods[] = {
                        GDBUS_ARGS({ "name", "s" }), NULL,
                        clear_property) },
        { GDBUS_ASYNC_METHOD("Connect", NULL, NULL,
-                             connect_service) },
+                       connect_service) },
+       { GDBUS_ASYNC_METHOD("Connect",
+                       GDBUS_ARGS({ "passphrase", "s" }), NULL, 
+                       connect_service) },
        { GDBUS_METHOD("Disconnect", NULL, NULL,
                        disconnect_service) },
        { GDBUS_METHOD("Remove", NULL, NULL, remove_service) },
-- 
1.9.1



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

Message: 2
Date: Mon, 18 Apr 2016 10:46:13 -0700
From: Feng Wang <[email protected]>
To: [email protected]
Subject: [PATCH] Remove old ip/gateway address if different addresses
        are assigned during DHCP renewal to avoid two ip addresses added to
        the interface.
Message-ID: <[email protected]>

---
 src/dhcp.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index 1d2cd48..54d98db 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -435,7 +435,7 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
        char *address, *netmask = NULL, *gateway = NULL;
        const char *c_address, *c_gateway;
        unsigned char prefixlen, c_prefixlen;
-       bool ip_change;
+       bool ip_change = false;
 
        DBG("Lease available");
 
@@ -467,14 +467,21 @@ static void lease_available_cb(GDHCPClient *dhcp_client, 
gpointer user_data)
 
        DBG("c_address %s", c_address);
 
-       if (g_strcmp0(address, c_address))
+       if (g_strcmp0(address, c_address)) {
                ip_change = true;
-       else if (g_strcmp0(gateway, c_gateway))
+               if (c_address) {
+                       /* Remove old ip address */
+                       __connman_ipconfig_address_remove(dhcp->ipconfig);
+               }
+       }
+       if (g_strcmp0(gateway, c_gateway)) {
                ip_change = true;
-       else if (prefixlen != c_prefixlen)
+               if (c_gateway) {
+                       /* Remove gateway ip address */
+                       __connman_ipconfig_gateway_remove(dhcp->ipconfig);
+               }
+       } else if (prefixlen != c_prefixlen)
                ip_change = true;
-       else
-               ip_change = false;
 
        __connman_ipconfig_set_method(dhcp->ipconfig,
                                                CONNMAN_IPCONFIG_METHOD_DHCP);
-- 
2.8.0.rc3.226.g39d4020



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

Subject: Digest Footer

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


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

End of connman Digest, Vol 6, Issue 13
**************************************

Reply via email to