[PATCH] 6to4: No need to initialize variable unnecessarily

2015-09-07 Thread Saurav Babu
docs/coding-style.txt M7: Don't initialize variable unnecessarily
socket function will always return a valid file descriptor for the new
socket or -1 on failure, so no need to explicitly initalize fd with -1.
---
 src/6to4.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/6to4.c b/src/6to4.c
index 0e3a7a1..71a2882 100644
--- a/src/6to4.c
+++ b/src/6to4.c
@@ -63,7 +63,7 @@ static int tunnel_create(struct in_addr *addr)
 {
struct ip_tunnel_parm p;
struct ifreq ifr;
-   int fd = -1;
+   int fd;
int ret;
 
/* ip tunnel add tun6to4 mode sit remote any local 1.2.3.4 ttl 64 */
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] inet: Remove unnecessary variable

2015-09-02 Thread Saurav Babu
---
 src/inet.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/inet.c b/src/inet.c
index e06d9c8..dc788ea 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -2291,13 +2291,12 @@ int __connman_inet_rtnl_talk(struct 
__connman_inet_rtnl_handle *rtnl,
 {
struct sockaddr_nl nladdr;
struct inet_rtnl_cb_data *data;
-   unsigned seq;
int err;
 
memset(, 0, sizeof(nladdr));
nladdr.nl_family = AF_NETLINK;
 
-   n->nlmsg_seq = seq = ++rtnl->seq;
+   n->nlmsg_seq = ++rtnl->seq;
 
if (callback) {
data = g_try_malloc0(sizeof(struct inet_rtnl_cb_data));
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] gsupplicant: Properly check for callbacks_pointer

2015-06-25 Thread Saurav Babu
callbacks_pointer for ap_create_fail should be checked at time of
calling callback of ap_create_fail instead of checking callbacks_pointer
for scan_started.
---
 gsupplicant/supplicant.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 38cbad1..78bcb9c 100755
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -437,7 +437,7 @@ static void callback_ap_create_fail(GSupplicantInterface 
*interface)
if (!callbacks_pointer)
return;
 
-   if (!callbacks_pointer-scan_started)
+   if (!callbacks_pointer-ap_create_fail)
return;
 
callbacks_pointer-ap_create_fail(interface);
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] wifi: Fix Possible memory leak

2015-06-23 Thread Saurav Babu
This patch frees peer_params-path and peer_params-wps_pin also when
peer_params is freed. Both peer_params-path and peer_params-wps_pin
are allocated memory using g_strdup() and needs to be freed when
g_supplicant_interface_p2p_connect() return is less than 0.
---
 plugins/wifi.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/plugins/wifi.c b/plugins/wifi.c
index 587dee2..513e577 100644
--- a/plugins/wifi.c
+++ b/plugins/wifi.c
@@ -356,8 +356,11 @@ static int peer_connect(struct connman_peer *peer,
wifi-pending_peer = connman_peer_ref(peer);
wifi-peer = gs_peer;
wifi-p2p_connecting = true;
-   } else if (ret  0)
+   } else if (ret  0) {
+   g_free(peer_params-path);
+   g_free(peer_params-wps_pin);
g_free(peer_params);
+   }
 
return ret;
 }
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv4 0/2] client: Add support of MoveBefore/MoveAfter method from Service API

2015-06-18 Thread Saurav Babu
Fixed help text to remove ambiguity
Saurav Babu (2):
  client: Add support of MoveBefore Service API
  client: Add support of MoveAfter Service API

 client/commands.c | 127 ++
 1 file changed, 127 insertions(+)

-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv3 0/2] client: Add support of MoveBefore/MoveAfter method from Service API

2015-06-15 Thread Saurav Babu
Fixed Compilation Warning

Saurav Babu (2):
  client: Add support of MoveBefore Service API
  client: Add support of MoveAfter Service API

 client/commands.c | 127 ++
 1 file changed, 127 insertions(+)

-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv3 1/2] client: Add support of MoveBefore Service API

2015-06-15 Thread Saurav Babu
This patch handles MoveBefore() method from Service API in connman client.
This can be used to move any VPN service before any other VPN Service. For
Connman services this won't be much useful as the order is not remembered
after service list sort.
---
 client/commands.c | 66 +++
 1 file changed, 66 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 9208016..74b287b 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -725,6 +725,69 @@ static int cmd_disconnect(char *args[], int num, struct 
connman_option *options)
disconnect_return, path, NULL, NULL);
 }
 
+struct move_service {
+   char *service;
+   char *target;
+};
+
+static int move_before_return(DBusMessageIter *iter, const char *error,
+   void *user_data)
+{
+   struct move_service *services = user_data;
+   char *service;
+   char *target;
+
+   if (!error) {
+   service = strrchr(services-service, '/');
+   service++;
+   target = strrchr(services-target, '/');
+   target++;
+   fprintf(stdout, Moved %s before %s\n, service, target);
+   } else
+   fprintf(stderr, Error %s: %s\n, services-service, error);
+
+   g_free(services-service);
+   g_free(services-target);
+   g_free(user_data);
+
+   return 0;
+}
+
+static void move_before_append_args(DBusMessageIter *iter, void *user_data)
+{
+   char *path = user_data;
+
+   dbus_message_iter_append_basic(iter,
+   DBUS_TYPE_OBJECT_PATH, path);
+
+   return;
+}
+
+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;
+
+   if (num  3)
+   return -EINVAL;
+
+   if (check_dbus_name(args[1]) == false)
+   return -EINVAL;
+
+   services-service = g_strdup_printf(/net/connman/service/%s, args[1]);
+   services-target = g_strdup_printf(/net/connman/service/%s, args[2]);
+
+   return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+   services-service, iface, MoveBefore,
+   move_before_return, services,
+   move_before_append_args,
+   services-target);
+}
+
 static int config_return(DBusMessageIter *iter, const char *error,
void *user_data)
 {
@@ -2398,6 +2461,9 @@ static const struct {
  Connect a given service or peer, lookup_service_arg },
{ disconnect,   service/peer, NULL,  cmd_disconnect,
  Disconnect a given service or peer, lookup_service_arg },
+   { move-before,   service target service  , NULL,
+ cmd_service_move_before, Move a service before another service,
+ lookup_service_arg },
{ config,   service,config_options,  cmd_config,
  Set service configuration options, lookup_config },
{ monitor,  [off],monitor_options, cmd_monitor,
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCHv2 1/2] client: Add support of MoveBefore Service API

2015-06-14 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

Hi,

 Compilation still fails...
Can you let me know what error are you getting while compilation. As I've not
got any compilation error on my setup.

 This patch handles MoveBefore() method from Service API in connman client.
 This can be used to move any VPN service before any other VPN Service. For
 Connman services this won't be much useful as the order is not remembered
 after service list sort.
 ---
  client/commands.c | 64 
 +++
  1 file changed, 64 insertions(+)
 
 diff --git a/client/commands.c b/client/commands.c
 index 9208016..5e342a5 100644
 --- a/client/commands.c
 +++ b/client/commands.c
 @@ -725,6 +725,67 @@ static int cmd_disconnect(char *args[], int num, struct 
 connman_option *options)
  disconnect_return, path, NULL, NULL);
  }
  
 +struct move_service {
 +char *service;
 +char *target;
 +};
 +
 +static int move_before_return(DBusMessageIter *iter, const char *error,
 +void *user_data)
 +{
 +struct move_service *services = user_data;
 +
 +if (!error) {
 +char *service = strrchr(services-service, '/');
 +service++;
 +char *target = strrchr(services-target, '/');
 +target++;
 +fprintf(stdout, Moved %s before %s\n, service, target);
 +} else
 +fprintf(stderr, Error %s: %s\n, services-service, error);
 +
 +g_free(services-service);
 +g_free(services-target);
 +g_free(user_data);
 +
 +return 0;
 +}
 +
 +static void move_before_append_args(DBusMessageIter *iter, void *user_data)
 +{
 +char *path = user_data;
 +
 +dbus_message_iter_append_basic(iter,
 +DBUS_TYPE_OBJECT_PATH, path);
 +
 +return;
 +}
 +
 +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;
 +
 +if (num  3)
 +return -EINVAL;
 +
 +if (check_dbus_name(args[1]) == false)
 +return -EINVAL;
 +
 +services-service = g_strdup_printf(/net/connman/service/%s, args[1]);
 +services-target = g_strdup_printf(/net/connman/service/%s, args[2]);
 +
 +return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
 +services-service, iface, MoveBefore,
 +move_before_return, services,
 +move_before_append_args,
 +services-target);
 +}
 +
  static int config_return(DBusMessageIter *iter, const char *error,
  void *user_data)
  {
 @@ -2398,6 +2459,9 @@ static const struct {
Connect a given service or peer, lookup_service_arg },
  { disconnect,   service/peer, NULL,  cmd_disconnect,
Disconnect a given service or peer, lookup_service_arg },
 +{ move-before,   service target service  , NULL,
 +  cmd_service_move_before, Move a service before another service,
 +  lookup_service_arg },
  { config,   service,config_options,  cmd_config,
Set service configuration options, lookup_config },
  { monitor,  [off],monitor_options, cmd_monitor,
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2 0/2] client: Add support of MoveBefore/MoveAfter method from Service API

2015-06-11 Thread Saurav Babu
Saurav Babu (2):
  client: Add support of MoveBefore Service API
  client: Add support of MoveAfter Service API

 client/commands.c | 123 ++
 1 file changed, 123 insertions(+)

-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2 1/2] client: Add support of MoveBefore Service API

2015-06-11 Thread Saurav Babu
This patch handles MoveBefore() method from Service API in connman client.
This can be used to move any VPN service before any other VPN Service. For
Connman services this won't be much useful as the order is not remembered
after service list sort.
---
 client/commands.c | 64 +++
 1 file changed, 64 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 9208016..5e342a5 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -725,6 +725,67 @@ static int cmd_disconnect(char *args[], int num, struct 
connman_option *options)
disconnect_return, path, NULL, NULL);
 }
 
+struct move_service {
+   char *service;
+   char *target;
+};
+
+static int move_before_return(DBusMessageIter *iter, const char *error,
+   void *user_data)
+{
+   struct move_service *services = user_data;
+
+   if (!error) {
+   char *service = strrchr(services-service, '/');
+   service++;
+   char *target = strrchr(services-target, '/');
+   target++;
+   fprintf(stdout, Moved %s before %s\n, service, target);
+   } else
+   fprintf(stderr, Error %s: %s\n, services-service, error);
+
+   g_free(services-service);
+   g_free(services-target);
+   g_free(user_data);
+
+   return 0;
+}
+
+static void move_before_append_args(DBusMessageIter *iter, void *user_data)
+{
+   char *path = user_data;
+
+   dbus_message_iter_append_basic(iter,
+   DBUS_TYPE_OBJECT_PATH, path);
+
+   return;
+}
+
+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;
+
+   if (num  3)
+   return -EINVAL;
+
+   if (check_dbus_name(args[1]) == false)
+   return -EINVAL;
+
+   services-service = g_strdup_printf(/net/connman/service/%s, args[1]);
+   services-target = g_strdup_printf(/net/connman/service/%s, args[2]);
+
+   return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+   services-service, iface, MoveBefore,
+   move_before_return, services,
+   move_before_append_args,
+   services-target);
+}
+
 static int config_return(DBusMessageIter *iter, const char *error,
void *user_data)
 {
@@ -2398,6 +2459,9 @@ static const struct {
  Connect a given service or peer, lookup_service_arg },
{ disconnect,   service/peer, NULL,  cmd_disconnect,
  Disconnect a given service or peer, lookup_service_arg },
+   { move-before,   service target service  , NULL,
+ cmd_service_move_before, Move a service before another service,
+ lookup_service_arg },
{ config,   service,config_options,  cmd_config,
  Set service configuration options, lookup_config },
{ monitor,  [off],monitor_options, cmd_monitor,
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2 0/2] client: Add support of MoveBefore/MoveAfter method from Service API

2015-06-10 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

Saurav Babu (2):
  client: Add support of MoveBefore Service API
  client: Add support of MoveAfter Service API

 client/commands.c | 123 ++
 1 file changed, 123 insertions(+)

-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2 2/2] client: Add support of MoveAfter Service API

2015-06-10 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

This patch handles MoveAfter() method from Service API in connman client.
This can be used to move any VPN service after any other VPN Service. For
Connman services this won't be much useful as the order is not remembered
after service list sort.
---
 client/commands.c | 59 +++
 1 file changed, 59 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 5e342a5..2397883 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -786,6 +786,62 @@ static int cmd_service_move_before(char *args[], int num,
services-target);
 }
 
+static int move_after_return(DBusMessageIter *iter, const char *error,
+   void *user_data)
+{
+   struct move_service *services = user_data;
+
+   if (!error) {
+   char *service = strrchr(services-service, '/');
+   service++;
+   char *target = strrchr(services-target, '/');
+   target++;
+   fprintf(stdout, Moved %s after %s\n, service, target);
+   } else
+   fprintf(stderr, Error %s: %s\n, services-service, error);
+
+   g_free(services-service);
+   g_free(services-target);
+   g_free(user_data);
+
+   return 0;
+}
+
+static void move_after_append_args(DBusMessageIter *iter, void *user_data)
+{
+   char *path = user_data;
+
+   dbus_message_iter_append_basic(iter,
+   DBUS_TYPE_OBJECT_PATH, path);
+
+   return;
+}
+
+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;
+
+   if (num  3)
+   return -EINVAL;
+
+   if (check_dbus_name(args[1]) == false)
+   return -EINVAL;
+
+   services-service = g_strdup_printf(/net/connman/service/%s, args[1]);
+   services-target = g_strdup_printf(/net/connman/service/%s, args[2]);
+
+   return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+   services-service, iface, MoveAfter,
+   move_after_return, services,
+   move_after_append_args,
+   services-target);
+}
+
 static int config_return(DBusMessageIter *iter, const char *error,
void *user_data)
 {
@@ -2462,6 +2518,9 @@ static const struct {
{ move-before,   service target service  , NULL,
  cmd_service_move_before, Move a service before another service,
  lookup_service_arg },
+   { move-after,   service target service   , NULL,
+ cmd_service_move_after, Move a service after another service,
+ lookup_service_arg },
{ config,   service,config_options,  cmd_config,
  Set service configuration options, lookup_config },
{ monitor,  [off],monitor_options, cmd_monitor,
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2 1/2] client: Add support of MoveBefore Service API

2015-06-10 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

This patch handles MoveBefore() method from Service API in connman client.
This can be used to move any VPN service before any other VPN Service. For
Connman services this won't be much useful as the order is not remembered
after service list sort.
---
 client/commands.c | 64 +++
 1 file changed, 64 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 9208016..5e342a5 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -725,6 +725,67 @@ static int cmd_disconnect(char *args[], int num, struct 
connman_option *options)
disconnect_return, path, NULL, NULL);
 }
 
+struct move_service {
+   char *service;
+   char *target;
+};
+
+static int move_before_return(DBusMessageIter *iter, const char *error,
+   void *user_data)
+{
+   struct move_service *services = user_data;
+
+   if (!error) {
+   char *service = strrchr(services-service, '/');
+   service++;
+   char *target = strrchr(services-target, '/');
+   target++;
+   fprintf(stdout, Moved %s before %s\n, service, target);
+   } else
+   fprintf(stderr, Error %s: %s\n, services-service, error);
+
+   g_free(services-service);
+   g_free(services-target);
+   g_free(user_data);
+
+   return 0;
+}
+
+static void move_before_append_args(DBusMessageIter *iter, void *user_data)
+{
+   char *path = user_data;
+
+   dbus_message_iter_append_basic(iter,
+   DBUS_TYPE_OBJECT_PATH, path);
+
+   return;
+}
+
+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;
+
+   if (num  3)
+   return -EINVAL;
+
+   if (check_dbus_name(args[1]) == false)
+   return -EINVAL;
+
+   services-service = g_strdup_printf(/net/connman/service/%s, args[1]);
+   services-target = g_strdup_printf(/net/connman/service/%s, args[2]);
+
+   return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+   services-service, iface, MoveBefore,
+   move_before_return, services,
+   move_before_append_args,
+   services-target);
+}
+
 static int config_return(DBusMessageIter *iter, const char *error,
void *user_data)
 {
@@ -2398,6 +2459,9 @@ static const struct {
  Connect a given service or peer, lookup_service_arg },
{ disconnect,   service/peer, NULL,  cmd_disconnect,
  Disconnect a given service or peer, lookup_service_arg },
+   { move-before,   service target service  , NULL,
+ cmd_service_move_before, Move a service before another service,
+ lookup_service_arg },
{ config,   service,config_options,  cmd_config,
  Set service configuration options, lookup_config },
{ monitor,  [off],monitor_options, cmd_monitor,
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2] client: Add support for ClearProperty Service API

2015-06-08 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42
Adding Descriptive commit message

This will be used by connman to clear the value of specified property of
a service. This patch adds a new config_option clear in the Service
Configuration option.
---
 client/commands.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 2397883..ca8ceaa 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -1161,6 +1161,14 @@ static int cmd_config(char *args[], int num, struct 
connman_option *options)
config_return, g_strdup(service_name),
NULL, NULL);
break;
+   case 'c':
+   res = __connmanctl_dbus_method_call(connection,
+   CONNMAN_SERVICE, path,
+   net.connman.Service, ClearProperty,
+   config_return, g_strdup(service_name),
+   config_append_str, append);
+   index += append.values;
+   break;
default:
res = -EINVAL;
break;
@@ -2142,6 +2150,7 @@ static struct connman_option config_options[] = {
{autoconnect, 'a', yes|no},
{ipv4, 'i', off|dhcp|manual address netmask gateway},
{remove, 'r',  Remove service},
+   {clear, 'c', property Clear service property},
{ NULL, }
 };
 
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 0/2] client: Add Service API MoveBefore/MoveAfter

2015-06-08 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

 Saurav Babu (2):
   client: Add MoveBefore Service API
   client: Add MoveAfter Service API

 Even though ConnMan supports any services to be moved before/after
 arbitrary services, the order is not remembered. A VPN can be moved, but
 the order for the other services are not remembered after a service list
 sort.
I added these patches because I found connman client didn?t have support for 
these
Service APIs. I think if the order is not remembered then it would require a 
different
patch in Connman. Do you think that support of MoveBefore/MoveAfter is not 
required to be
added in connman client.

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 2/2] client: Add MoveAfter Service API

2015-06-03 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42
---
 client/commands.c | 59 +++
 1 file changed, 59 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 5e342a5..2397883 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -786,6 +786,62 @@ static int cmd_service_move_before(char *args[], int num,
services-target);
 }
 
+static int move_after_return(DBusMessageIter *iter, const char *error,
+   void *user_data)
+{
+   struct move_service *services = user_data;
+
+   if (!error) {
+   char *service = strrchr(services-service, '/');
+   service++;
+   char *target = strrchr(services-target, '/');
+   target++;
+   fprintf(stdout, Moved %s after %s\n, service, target);
+   } else
+   fprintf(stderr, Error %s: %s\n, services-service, error);
+
+   g_free(services-service);
+   g_free(services-target);
+   g_free(user_data);
+
+   return 0;
+}
+
+static void move_after_append_args(DBusMessageIter *iter, void *user_data)
+{
+   char *path = user_data;
+
+   dbus_message_iter_append_basic(iter,
+   DBUS_TYPE_OBJECT_PATH, path);
+
+   return;
+}
+
+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;
+
+   if (num  3)
+   return -EINVAL;
+
+   if (check_dbus_name(args[1]) == false)
+   return -EINVAL;
+
+   services-service = g_strdup_printf(/net/connman/service/%s, args[1]);
+   services-target = g_strdup_printf(/net/connman/service/%s, args[2]);
+
+   return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+   services-service, iface, MoveAfter,
+   move_after_return, services,
+   move_after_append_args,
+   services-target);
+}
+
 static int config_return(DBusMessageIter *iter, const char *error,
void *user_data)
 {
@@ -2462,6 +2518,9 @@ static const struct {
{ move-before,   service target service  , NULL,
  cmd_service_move_before, Move a service before another service,
  lookup_service_arg },
+   { move-after,   service target service   , NULL,
+ cmd_service_move_after, Move a service after another service,
+ lookup_service_arg },
{ config,   service,config_options,  cmd_config,
  Set service configuration options, lookup_config },
{ monitor,  [off],monitor_options, cmd_monitor,
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 0/2] client: Add Service API MoveBefore/MoveAfter

2015-06-03 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

Saurav Babu (2):
  client: Add MoveBefore Service API
  client: Add MoveAfter Service API

 client/commands.c | 123 ++
 1 file changed, 123 insertions(+)

-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 1/2] client: Add MoveBefore Service API

2015-06-03 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42
---
 client/commands.c | 64 +++
 1 file changed, 64 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 9208016..5e342a5 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -725,6 +725,67 @@ static int cmd_disconnect(char *args[], int num, struct 
connman_option *options)
disconnect_return, path, NULL, NULL);
 }
 
+struct move_service {
+   char *service;
+   char *target;
+};
+
+static int move_before_return(DBusMessageIter *iter, const char *error,
+   void *user_data)
+{
+   struct move_service *services = user_data;
+
+   if (!error) {
+   char *service = strrchr(services-service, '/');
+   service++;
+   char *target = strrchr(services-target, '/');
+   target++;
+   fprintf(stdout, Moved %s before %s\n, service, target);
+   } else
+   fprintf(stderr, Error %s: %s\n, services-service, error);
+
+   g_free(services-service);
+   g_free(services-target);
+   g_free(user_data);
+
+   return 0;
+}
+
+static void move_before_append_args(DBusMessageIter *iter, void *user_data)
+{
+   char *path = user_data;
+
+   dbus_message_iter_append_basic(iter,
+   DBUS_TYPE_OBJECT_PATH, path);
+
+   return;
+}
+
+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;
+
+   if (num  3)
+   return -EINVAL;
+
+   if (check_dbus_name(args[1]) == false)
+   return -EINVAL;
+
+   services-service = g_strdup_printf(/net/connman/service/%s, args[1]);
+   services-target = g_strdup_printf(/net/connman/service/%s, args[2]);
+
+   return __connmanctl_dbus_method_call(connection, CONNMAN_SERVICE,
+   services-service, iface, MoveBefore,
+   move_before_return, services,
+   move_before_append_args,
+   services-target);
+}
+
 static int config_return(DBusMessageIter *iter, const char *error,
void *user_data)
 {
@@ -2398,6 +2459,9 @@ static const struct {
  Connect a given service or peer, lookup_service_arg },
{ disconnect,   service/peer, NULL,  cmd_disconnect,
  Disconnect a given service or peer, lookup_service_arg },
+   { move-before,   service target service  , NULL,
+ cmd_service_move_before, Move a service before another service,
+ lookup_service_arg },
{ config,   service,config_options,  cmd_config,
  Set service configuration options, lookup_config },
{ monitor,  [off],monitor_options, cmd_monitor,
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] client: Add ClearProperty Service API

2015-06-03 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42
---
 client/commands.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/client/commands.c b/client/commands.c
index 2397883..ca8ceaa 100644
--- a/client/commands.c
+++ b/client/commands.c
@@ -1161,6 +1161,14 @@ static int cmd_config(char *args[], int num, struct 
connman_option *options)
config_return, g_strdup(service_name),
NULL, NULL);
break;
+   case 'c':
+   res = __connmanctl_dbus_method_call(connection,
+   CONNMAN_SERVICE, path,
+   net.connman.Service, ClearProperty,
+   config_return, g_strdup(service_name),
+   config_append_str, append);
+   index += append.values;
+   break;
default:
res = -EINVAL;
break;
@@ -2142,6 +2150,7 @@ static struct connman_option config_options[] = {
{autoconnect, 'a', yes|no},
{ipv4, 'i', off|dhcp|manual address netmask gateway},
{remove, 'r',  Remove service},
+   {clear, 'c', property Clear service property},
{ NULL, }
 };
 
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] gitignore: Remove files which are not created now

2015-06-02 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42
---
 .gitignore | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 9c22e4a..7a0af9c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -54,12 +54,10 @@ tools/dnsproxy-test
 tools/supplicant-test
 tools/dbus-test
 tools/stats-tool
-tools/stats-ringbuffer-dump
 tools/private-network-test
 tools/session-test
 tools/netlink-test
 unit/test-ippool
-unit/test-nat
 
 doc/*.bak
 doc/*.stamp
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] ipconfig: Remove unused function __connman_ipconfig_clear_address()

2015-05-29 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42
---
 src/connman.h  | 1 -
 src/ipconfig.c | 8 
 2 files changed, 9 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index aac6a0b..5ec47bb 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -315,7 +315,6 @@ __connman_ipconfig_ref_debug(struct connman_ipconfig 
*ipconfig,
 void __connman_ipconfig_unref_debug(struct connman_ipconfig *ipconfig,
const char *file, int line, const char *caller);
 
-void __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig);
 void *__connman_ipconfig_get_data(struct connman_ipconfig *ipconfig);
 void __connman_ipconfig_set_data(struct connman_ipconfig *ipconfig, void 
*data);
 
diff --git a/src/ipconfig.c b/src/ipconfig.c
index f8c148b..2b64ec0 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -90,14 +90,6 @@ static GHashTable *ipdevice_hash = NULL;
 static GList *ipconfig_list = NULL;
 static bool is_ipv6_supported = false;
 
-void __connman_ipconfig_clear_address(struct connman_ipconfig *ipconfig)
-{
-   if (!ipconfig)
-   return;
-
-   connman_ipaddress_clear(ipconfig-address);
-}
-
 static void free_address_list(struct connman_ipdevice *ipdevice)
 {
GSList *list;
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] ipconfig: Update device address when modified

2015-05-21 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

 So, in which cases does this issue manifest itself? From the code we can
 read what it does, but what is causing an IP address to change to
 something else? What's the use case and environment for this to happen?

Here MAC Address is changing. Below is scenario:
 1. Ethernet is up with some MAC Address and connman creates ipdevice with that 
address
 2. After some time if MAC Address is changed then MAC Address is not updated 
in connman
 3. When Ethernet property of service is obtained then it returns initial MAC 
address,
not the updated one.

 I'm not sure if it is a valid case where device's MAC Address is changed but 
in Ubuntu
 you can cross check by updating MAC address for ethernet using ifconfig and 
then
 getting service property using connmanctl.

 In my case there is a device where MAC Address is set by some other process 
which sometimes
 starts after connman is started. Initially MAC Address for ethernet is set as
 FF:FF:FF:FF:FF:FF by kernel. But after MAC Address is updated by other process 
it is not
 reflected in connman's service.

 ---
  src/ipconfig.c | 4 
  1 file changed, 4 insertions(+)
 
 diff --git a/src/ipconfig.c b/src/ipconfig.c
 index f8c148b..eb18533 100644
 --- a/src/ipconfig.c
 +++ b/src/ipconfig.c
 @@ -508,6 +508,10 @@ void __connman_ipconfig_newlink(int index, unsigned 
 short type,
  index, type, type2str(type));
  
  update:
 +if (g_strcmp0(ipdevice-address, address) != 0) {
 +g_free(ipdevice-address);
 +ipdevice-address = g_strdup(address);
 +}
  ipdevice-mtu = mtu;
  
  update_stats(ipdevice, ifname, stats);

 Should something happen if DHCP is in use and a a different address gets
 set...?

  Here MAC Address of device is getting changed. I didn't observed any issue 
with DHCP or
  manual configuration.

  Thanks,
  Saurav
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] ipconfig: Update device address when modified

2015-05-21 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

  So, in which cases does this issue manifest itself? From the code we can
  read what it does, but what is causing an IP address to change to
  something else? What's the use case and environment for this to happen?
 
 Here MAC Address is changing. Below is scenario:
  1. Ethernet is up with some MAC Address and connman creates ipdevice
 with that address
  2. After some time if MAC Address is changed then MAC Address is not
 updated in connman
  3. When Ethernet property of service is obtained then it returns
 initial MAC address, not the updated one.
 
  I'm not sure if it is a valid case where device's MAC Address is
 changed but in Ubuntu  you can cross check by updating MAC address for
 ethernet using ifconfig and then  getting service property using
 connmanctl.
 
  In my case there is a device where MAC Address is set by some other
 process which sometimes  starts after connman is started. Initially
 MAC Address for ethernet is set as FF:FF:FF:FF:FF:FF by kernel. But
 after MAC Address is updated by other process it is not reflected in
 connman's service.

 If the MAC address changes, the current service needs to be
 disconnected, as another one may have a different IP address
 configuration method defined based on the MAC address. Either that other
 service exists saved to disk or matched from another
 pre-provisioned .config file.

 So once the MAC address changes, one needs to disconnect the existing
 service and have ConnMan apply the correct settings according to that
 new MAC address.

 Disconnecting the service doesn't change the Ethernet property of service.
 I had a service named ethernet_e8039a65a6fc_cable with MAC Address 
E8:03:9A:65:A6:FC
 Service's ethernet property was
 Ethernet = [ Method=auto, Interface=eth0, Address=E8:03:9A:65:A6:FC, MTU=1500 
]
 Now when I changed the MAC Address for ethernet using ifconfig
 ifconfig eth0 hw ether 00:11:22:33:44:55
 Service's ethernet property remained same
 Ethernet = [ Method=auto, Interface=eth0, Address=E8:03:9A:65:A6:FC, MTU=1500 
]

 Even after I disconnected the service using connmanctl then also it remained 
the same

 I even tried to disable and enable ethernet but with no success, Address in 
Ethernet
 property was never updated to the newer one.

 Am I missing any step here?

  ---
   src/ipconfig.c | 4 
   1 file changed, 4 insertions(+)
  
  diff --git a/src/ipconfig.c b/src/ipconfig.c
  index f8c148b..eb18533 100644
  --- a/src/ipconfig.c
  +++ b/src/ipconfig.c
  @@ -508,6 +508,10 @@ void __connman_ipconfig_newlink(int index, unsigned 
  short type,
index, type, type2str(type));
   
   update:
  + if (g_strcmp0(ipdevice-address, address) != 0) {
  + g_free(ipdevice-address);
  + ipdevice-address = g_strdup(address);
  + }
ipdevice-mtu = mtu;
   
update_stats(ipdevice, ifname, stats);
 
  Should something happen if DHCP is in use and a a different address gets
  set...?
 
   Here MAC Address of device is getting changed. I didn't observed any issue 
 with DHCP or
   manual configuration.

My bad, I thought ipdevice-address was pointing at an IP address...

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] ipconfig: Update device address when modified

2015-05-20 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42

---
 src/ipconfig.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/src/ipconfig.c b/src/ipconfig.c
index f8c148b..eb18533 100644
--- a/src/ipconfig.c
+++ b/src/ipconfig.c
@@ -508,6 +508,10 @@ void __connman_ipconfig_newlink(int index, unsigned short 
type,
index, type, type2str(type));
 
 update:
+   if (g_strcmp0(ipdevice-address, address) != 0) {
+   g_free(ipdevice-address);
+   ipdevice-address = g_strdup(address);
+   }
ipdevice-mtu = mtu;
 
update_stats(ipdevice, ifname, stats);
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] gsupplicant: Add interface DisconnectReason Property

2015-05-13 Thread Saurav Babu
EP-584CD5AB95AE4A3A879836122994DB42
WPA Supplicant DisconnectReason carries the IEEE 802.11 reason
code of the most recent disassociation or deauthentication event.
---
 gsupplicant/supplicant.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 81fcadc..a9128dc 100755
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -182,6 +182,7 @@ struct _GSupplicantInterface {
GHashTable *bss_mapping;
void *data;
const char *pending_peer_path;
+   int disconnect_reason;
 };
 
 struct g_supplicant_bss {
@@ -2107,6 +2108,12 @@ static void interface_property(const char *key, 
DBusMessageIter *iter,
} else if (g_strcmp0(key, Networks) == 0) {
supplicant_dbus_array_foreach(iter, interface_network_added,
interface);
+   } else if (g_strcmp0(key, DisconnectReason) == 0) {
+   int reason = 0;
+
+   dbus_message_iter_get_basic(iter, reason);
+   SUPPLICANT_DBG(Disconnect Reason %d, reason);
+   interface-disconnect_reason = reason;
} else
SUPPLICANT_DBG(key %s type %c,
key, dbus_message_iter_get_arg_type(iter));
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] inet: Remove unnecessary break statement

2015-04-27 Thread Saurav Babu
---
 src/inet.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/inet.c b/src/inet.c
index cd220ff..e06d9c8 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -2229,10 +2229,8 @@ static int inet_rtnl_recv(GIOChannel *chan, gpointer 
user_data)
 
h = ptr;
 
-   if (!NLMSG_OK(h, len)) {
+   if (!NLMSG_OK(h, len))
return -1;
-   break;
-   }
 
if (h-nlmsg_seq != rth-seq) {
/* Skip this msg */
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH v2] service: Clean up nameserver and search domain handling

2015-04-25 Thread Saurav Babu

+  return connman_resolver_remove(index, nameserver, NULL);

This one should also be changed to connman_resolver_remove(index, NULL, 
nameserver);

After these changes nameservers are properly getting removed both from service
structure and resolv.conf. Thanks for the modified patches and sorry for the
late reply

Thanks,
Saurav

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH 2/2] service: Properly remove Nameservers when DHCP lease is invalidated

2015-04-21 Thread Saurav Babu
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Re: [PATCH 2/2] service: Properly remove Nameservers when DHCP lease is invalidated

2015-04-21 Thread Saurav Babu
 ---
  src/service.c | 14 --
  1 file changed, 8 insertions(+), 6 deletions(-)
 
 diff --git a/src/service.c b/src/service.c
 index 09c2c75..40c9382 100644
 --- a/src/service.c
 +++ b/src/service.c
 @@ -1130,8 +1130,9 @@ int __connman_service_nameserver_remove(struct 
 connman_service *service,
   const char *nameserver, bool is_auto)
  {
   char **servers, **nameservers;
 + char *servers_remove[2] = {(char *) nameserver, NULL};
   bool found = false;
 - int len, i, j;
 + int len, i, j, index;
  
   DBG(service %p nameserver %s auto %d, service, nameserver, is_auto);
  
 @@ -1159,12 +1160,9 @@ int __connman_service_nameserver_remove(struct 
 connman_service *service,
  
   if (len == 1) {
   g_strfreev(nameservers);
 - if (is_auto)
 - service-nameservers_auto = NULL;
 - else
 - service-nameservers = NULL;
 + nameservers = NULL;
  
 - return 0;
 + goto remove;
   }
  
   servers = g_try_new0(char *, len);
 @@ -1184,6 +1182,10 @@ int __connman_service_nameserver_remove(struct 
 connman_service *service,
   g_strfreev(nameservers);
   nameservers = servers;
  
 +remove:
 + index = __connman_service_get_index(service);
 + remove_nameservers(service, index, servers_remove);

The index may be set, but does this service still own/use the interface
and not some other service? Can this setting be omitted, and instead let
update_nameservers() reset all nameservers?

update_nameservers() also uses __connman_service_get_index() to get index but
as the service's nameserver structure is updated so nameserver which was 
actually
required to be removed from both resolv.conf and service's nameserver structure
was not getting removed.

 +
   if (is_auto) {
   service-nameservers_auto = nameservers;
   } else {


Thanks,
Saurav
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 2/2] service: Properly remove Nameservers when DHCP lease is invalidated

2015-04-17 Thread Saurav Babu
---
 src/service.c | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/service.c b/src/service.c
index 09c2c75..40c9382 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1130,8 +1130,9 @@ int __connman_service_nameserver_remove(struct 
connman_service *service,
const char *nameserver, bool is_auto)
 {
char **servers, **nameservers;
+   char *servers_remove[2] = {(char *) nameserver, NULL};
bool found = false;
-   int len, i, j;
+   int len, i, j, index;
 
DBG(service %p nameserver %s auto %d, service, nameserver, is_auto);
 
@@ -1159,12 +1160,9 @@ int __connman_service_nameserver_remove(struct 
connman_service *service,
 
if (len == 1) {
g_strfreev(nameservers);
-   if (is_auto)
-   service-nameservers_auto = NULL;
-   else
-   service-nameservers = NULL;
+   nameservers = NULL;
 
-   return 0;
+   goto remove;
}
 
servers = g_try_new0(char *, len);
@@ -1184,6 +1182,10 @@ int __connman_service_nameserver_remove(struct 
connman_service *service,
g_strfreev(nameservers);
nameservers = servers;
 
+remove:
+   index = __connman_service_get_index(service);
+   remove_nameservers(service, index, servers_remove);
+
if (is_auto) {
service-nameservers_auto = nameservers;
} else {
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH 1/2] service: Properly remove older configured Nameservers

2015-04-17 Thread Saurav Babu
When Nameservers and IP Configurations are changed from manual to DHCP
simultaneously then in few scenarios connman's service was in
Configuration state while trying to remove nameservers_config from
service, so nameservers_config were not removed from resolv.conf. This
patch removes the nameservers_config with the index of service rather
than checking the service's connection state.
---
 src/service.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/service.c b/src/service.c
index 29a632e..09c2c75 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3207,6 +3207,7 @@ static DBusMessage *set_property(DBusConnection *conn,
GString *str;
int index;
const char *gw;
+   DBG(%s, name);
 
if (__connman_provider_is_immutable(service-provider) ||
service-immutable)
@@ -3241,7 +3242,7 @@ static DBusMessage *set_property(DBusConnection *conn,
}
}
 
-   remove_nameservers(service, -1, service-nameservers_config);
+   remove_nameservers(service, index, service-nameservers_config);
g_strfreev(service-nameservers_config);
 
if (str-len  0) {
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2 0/2] service: Properly remove nameservers from resolv.conf

2015-04-17 Thread Saurav Babu
These patches properly removes nameservers from resolv.conf before clearing
nameservers in service structure when IPv4.Configurations and
Nameservers.Configurations are changed simultaneously.

Connman was being run with nodnsproxy flag enabled.
Checked using scripts of connman's test directory:
set-ipv4-method profile manual ip subnet gw; set-nameservers profile 
dns dns
set-ipv4-method profile dhcp; set-nameservers profile

There are two possible cases:
CASE 1: Nameservers and IP Configurations are changed from manual to DHCP
In this case there were few scenarios where connman's service was in
Configuration state while trying to remove nameservers_config from
service, and nameservers_config were not removed from resolv.conf. This
patch removes the nameservers_config with the index of service rather
than checking the service's connection state.
Fixed by [Patchv2 1/2]

CASE 2: Nameservers and IP Configurations are changed from DHCP to manual
In this case nameservers in service structure was cleared without
removing from resolv.conf in function __connman_service_nameserver_remove()
if there was only one nameservers. When there were more than one nameservers
then nameservers structure was updated with the nameserver passed in
argument of __connman_service_nameserver_remove() so other nameservers
were not getting removed. This patch updates nameservers structure with
all the other nameservers which are not passed to this function and the
one passed to this function is removed from both service's nameservers
structure and resolv.conf.
Fixed by [Patchv2 2/2]


Saurav Babu (2):
  service: Properly remove older configured Nameservers
  service: Properly remove Nameservers when DHCP lease is invalidated

 src/service.c | 17 ++---
 1 file changed, 10 insertions(+), 7 deletions(-)

-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] gdhcp: Don't try to remove timer again

2015-04-17 Thread Saurav Babu
dhcp_client-t1_timeout was getting removed when continue_renew()
returned FALSE and was tried to remove again in remove_timeouts() in
listener_event() when dhcp state was RENEWING and dhcp_client-T1 was
less than 60 resulting in GLIB Error

(connmand:4076): GLib-CRITICAL **: Source ID 196 was not found when
attempting to remove it

This patch explicitly sets dhcp_client-t1_timeout to 0 so that it is
not removed again.
---
 gdhcp/client.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gdhcp/client.c b/gdhcp/client.c
index 5a4a89c..084cd7e 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -1723,6 +1723,8 @@ static gboolean continue_renew (gpointer user_data)
if (dhcp_client-t1_timeout  0)
g_source_remove(dhcp_client-t1_timeout);
 
+   dhcp_client-t1_timeout = 0;
+
dhcp_client-T1 = 1;
 
if (dhcp_client-T1  60) {
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] service: Properly remove nameservers from resolv.conf

2015-04-09 Thread Saurav Babu
This patch properly removes nameservers from resolv.conf before clearing
nameservers in service structure when IPv4.Configurations and
Nameservers.Configurations are changed simultaneously.

Connman was being run with nodnsproxy flag enabled.
Checked using scripts of connman's test directory:
set-ipv4-method profile manual ip subnet gw; set-nameservers profile 
dns dns
set-ipv4-method profile dhcp; set-nameservers profile

There are two possible cases:
CASE 1: Nameservers and IP Configurations are changed from manual to DHCP
In this case nameservers in service structure was cleared without
removing from resolv.conf in function __connman_service_nameserver_remove()
if there was only one nameservers. When there were more than one nameservers
then nameservers structure was updated with the nameserver passed in
argument of __connman_service_nameserver_remove() so other nameservers
were not getting removed. This patch updates nameservers structure with
all the other nameservers which are not passed to this function and the
one passed to this function is removed from both service's nameservers
structure and resolv.conf.

CASE 2: Nameservers and IP Configurations are changed from DHCP to manual
In this case there were few scenarios where connman's service was in
Configuration state while trying to remove nameservers_config from
service, and nameservers_config were not removed from resolv.conf. This
patch removes the nameservers_config with the index of service rather
than checking the service's connection state.
---
 src/service.c | 36 ++--
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/src/service.c b/src/service.c
index 7538bdd..c36f9e3 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1129,9 +1129,9 @@ int __connman_service_nameserver_append(struct 
connman_service *service,
 int __connman_service_nameserver_remove(struct connman_service *service,
const char *nameserver, bool is_auto)
 {
-   char **servers, **nameservers;
+   char **servers, **nameservers, **servers_remove;
bool found = false;
-   int len, i, j;
+   int len, i, j, k, index;
 
DBG(service %p nameserver %s auto %d, service, nameserver, is_auto);
 
@@ -1157,30 +1157,37 @@ int __connman_service_nameserver_remove(struct 
connman_service *service,
 
len = g_strv_length(nameservers);
 
-   if (len == 1) {
-   g_strfreev(nameservers);
-   if (is_auto)
-   service-nameservers_auto = NULL;
-   else
-   service-nameservers = NULL;
-
-   return 0;
-   }
-
servers = g_try_new0(char *, len);
if (!servers)
return -ENOMEM;
 
-   for (i = 0, j = 0; i  len; i++) {
+   servers_remove = g_try_new0(char *, len);
+   if (!servers_remove)
+   return -ENOMEM;
+
+   for (i = 0, j = 0, k = 0; i  len; i++) {
if (g_strcmp0(nameservers[i], nameserver) != 0) {
servers[j] = g_strdup(nameservers[i]);
if (!servers[j])
return -ENOMEM;
j++;
+   } else {
+   servers_remove[k] = g_strdup(nameservers[i]);
+   if (!servers_remove[k])
+   return -ENOMEM;
+   k++;
}
}
servers[len - 1] = NULL;
+   servers_remove[k] = NULL;
+
+   index = __connman_service_get_index(service);
+   if (index  0)
+   return 0;
 
+   remove_nameservers(service, index, servers_remove);
+
+   g_strfreev(servers_remove);
g_strfreev(nameservers);
nameservers = servers;
 
@@ -3217,6 +3224,7 @@ static DBusMessage *set_property(DBusConnection *conn,
GString *str;
int index;
const char *gw;
+   DBG(%s, name);
 
if (__connman_provider_is_immutable(service-provider) ||
service-immutable)
@@ -3251,7 +3259,7 @@ static DBusMessage *set_property(DBusConnection *conn,
}
}
 
-   remove_nameservers(service, -1, service-nameservers_config);
+   remove_nameservers(service, index, service-nameservers_config);
g_strfreev(service-nameservers_config);
 
if (str-len  0) {
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] gdhcp: Avoid freeing of NULL variable

2015-01-05 Thread Saurav Babu
---
 gdhcp/client.c | 17 +
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/gdhcp/client.c b/gdhcp/client.c
index ec61731..e4577b2 100644
--- a/gdhcp/client.c
+++ b/gdhcp/client.c
@@ -2233,17 +2233,18 @@ static void get_request(GDHCPClient *dhcp_client, 
struct dhcp_packet *packet)
if (!option_value)
g_hash_table_remove(dhcp_client-code_value_hash,
GINT_TO_POINTER((int) code));
+   else {
+   value_list = get_option_value_list(option_value, type);
 
-   value_list = get_option_value_list(option_value, type);
+   g_free(option_value);
 
-   g_free(option_value);
-
-   if (!value_list)
-   g_hash_table_remove(dhcp_client-code_value_hash,
+   if (!value_list)
+   
g_hash_table_remove(dhcp_client-code_value_hash,
GINT_TO_POINTER((int) code));
-   else
-   g_hash_table_insert(dhcp_client-code_value_hash,
-   GINT_TO_POINTER((int) code), value_list);
+   else
+   
g_hash_table_insert(dhcp_client-code_value_hash,
+   GINT_TO_POINTER((int) code), 
value_list);
+   }
}
 }
 
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCHv2] connection: Set default gateway for a type if not active

2014-09-25 Thread Saurav Babu
In Dual Network where both IPv4 and IPv6 networks are available,
gateway address should be set for both network types.
Currently in following scenario:
- Gateway Address for IPv6 is already available
- IPv4 gateway address is obtained using DHCP.
active_gateway is not NULL as IPv6 gateway was set previously and was
made active so IPv4 Gateway Address is never set. So we should set
active_gateway only if gateway address of type given in
__connman_connection_gateway_add() is active, if gateway address
of other type is active then also active_gateway should be NULL
and we should set gateway address for that type.
---
 src/connection.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/connection.c b/src/connection.c
index 8fe9725..5abb143 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -733,7 +733,7 @@ static struct connman_rtnl connection_rtnl = {
.delgateway = connection_delgateway,
 };
 
-static struct gateway_data *find_active_gateway(void)
+static struct gateway_data *find_active_gateway(enum connman_ipconfig_type 
type)
 {
GHashTableIter iter;
gpointer value, key;
@@ -745,11 +745,13 @@ static struct gateway_data *find_active_gateway(void)
while (g_hash_table_iter_next(iter, key, value)) {
struct gateway_data *data = value;
 
-   if (data-ipv4_gateway 
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV4 
+   data-ipv4_gateway 
data-ipv4_gateway-active)
return data;
 
-   if (data-ipv6_gateway 
+   if (type == CONNMAN_IPCONFIG_TYPE_IPV6 
+   data-ipv6_gateway 
data-ipv6_gateway-active)
return data;
}
@@ -872,7 +874,7 @@ int __connman_connection_gateway_add(struct connman_service 
*service,
if (!new_gateway)
return -EINVAL;
 
-   active_gateway = find_active_gateway();
+   active_gateway = find_active_gateway(type);
 
DBG(active %p index %d new %p, active_gateway,
active_gateway ? active_gateway-index : -1, new_gateway);
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] connection: Set default gateway for a type if not active

2014-09-23 Thread Saurav Babu
In Dual Network where both IPv4 and IPv6 networks are available,
gateway address should be set for both network types.
Currently in following scenario:
- Gateway Address for IPv6 is already available
- IPv4 gateway address is obtained using DHCP.
active_gateway is not NULL as IPv6 gateway was set previously and was
made active so IPv4 Gateway Address is never set. So we should check if
gateway address of the type is active or not, if it is not active then
we should set that gateway address for that type.
---
 src/connection.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/connection.c b/src/connection.c
index 8fe9725..03adbd1 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -908,7 +908,8 @@ int __connman_connection_gateway_add(struct connman_service 
*service,
new_gateway-ipv6_gateway-vpn = false;
}
 
-   if (!active_gateway) {
+   if (!active_gateway || !active_gateway-ipv4_gateway-active ||
+   !active_gateway-ipv6_gateway-active) {
set_default_gateway(new_gateway, type);
goto done;
}
-- 
1.9.1

___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


[PATCH] dhcp: Fixed Crash on Switching Network

2014-08-06 Thread Saurav Babu
Sometimes while switching network dhcp_initialize() fails because
interface is not up and hence dhcp-dhcp_client remains NULL. Here we
don't check return type of dhcp_initialize() and go on to call function
g_dhcp_client_start() and crash occurs.
Below trace is obtained when connman crashes:
connmand[19034]: Aborting (signal 11) [/usr/local/sbin/connmand]
connmand[19034]:  backtrace 
connmand[19034]: #0  0xb7630f38 in /lib/i386-linux-gnu/libpthread.so.0
connmand[19034]: #1  0x8055a22 in debug() at client.c:0
connmand[19034]: #2  0x8058837 in g_dhcp_client_start() at polkit.c:0
connmand[19034]: #3  0x80a4772 in __connman_dhcp_start() at polkit.c:0
connmand[19034]: #4  0x8082a80 in set_connected.part.8() at network.c:0
connmand[19034]: #5  0x8082f7f in connman_network_set_connected() at
??:0
connmand[19034]: #6  0x805f921 in eth_network_connect() at ethernet.c:0
connmand[19034]: #7  0x8082dc3 in __connman_network_connect() at
polkit.c:0
connmand[19034]: #8  0x808e7e4 in __connman_service_connect() at
polkit.c:0
connmand[19034]: #9  0x808eef0 in auto_connect_service() at service.c:0
connmand[19034]: #10 0x808efde in run_auto_connect() at service.c:0
connmand[19034]: #11 0xb76cea3f in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #12 0xb76cdd46 in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #13 0xb76ce0e5 in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #14 0xb76ce52b in /lib/i386-linux-gnu/libglib-2.0.so.0
connmand[19034]: #15 0x80544cd in main() at polkit.c:0
connmand[19034]: #16 0xb739b4d3 in /lib/i386-linux-gnu/libc.so.6
connmand[19034]: +++
---
 src/dhcp.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index d714f99..3e6ca3b 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -590,6 +590,7 @@ int __connman_dhcp_start(struct connman_ipconfig *ipconfig,
 {
const char *last_addr = NULL;
struct connman_dhcp *dhcp;
+   int err;
 
DBG();
 
@@ -618,9 +619,15 @@ int __connman_dhcp_start(struct connman_ipconfig *ipconfig,
connman_network_ref(network);
}
 
-   g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
+   err = dhcp_initialize(dhcp);
 
-   dhcp_initialize(dhcp);
+   if(err  0) {
+   connman_network_unref(network);
+   g_free(dhcp);
+   return err;
+   }
+
+   g_hash_table_insert(ipconfig_table, ipconfig, dhcp);
}
 
dhcp-callback = callback;
-- 
1.9.1


Incorporated Patrik's Comments

Thanks,
Saurav
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: Re: [PATCH] dhcp: Fixed Crash on Switching Network

2014-08-04 Thread Saurav Babu


0001-dhcp-Fixed-Crash-on-Switching-Network.patch
Description: Binary data
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Re: Re: [PATCH] dhcp: Fixed Crash on Switching Network

2014-07-30 Thread Saurav Babu
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Re: Re: [PATCH] dhcp: Fixed Crash on Switching Network

2014-07-30 Thread Saurav Babu


0001-dhcp-Fixed-Crash-on-Switching-Network.patch
Description: Binary data
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Re: Re: [PATCH] dhcp: Fixed Crash on Switching Network

2014-07-30 Thread Saurav Babu
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

Re: Re: [PATCH] dhcp: Fixed Crash on Switching Network

2014-07-30 Thread Saurav Babu
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman

[PATCH] dhcp: Fixed Crash on Switching Network

2014-07-28 Thread Saurav Babu
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman