Functional test suite for connman

2014-03-24 Thread Simon Busch
Hey everybody,

I know there was once ago a functional test suite for connman as part of
the Meego project. By searching through the web I just found the old
meego references. Is there still a up to date and used functional test
suite for connman available somehwere?

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


Re: [PATCH] plugins: Check IPv4 and IPv6 address when connecting oFono context

2014-03-24 Thread Jukka Rissanen
Hi Ismail,

On ma, 2014-03-24 at 13:01 +, Ismail YILDIZ wrote:
> Hi,
> 
> My modem is a Sierra MC7710 (DIP), drivers are provided by Linux kernel 
> (sierra and sierra_net).
> As you can see in the log, in extract_ipv4_settings method, the IP 
> configuration method is set as DHCP.
> Which means that it will try using DHCP to obtain IPv4 address.

I just sent some additional ofono plugin fixes to ml, could you try if
they fix the issues you are seeing.

Cheers,
Jukka


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


[PATCH 4/4] ofono: Possible memory leak when setting IPv6 name servers

2014-03-24 Thread Jukka Rissanen
---
 plugins/ofono.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index 97761ce..9377a24 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -915,6 +915,7 @@ static void extract_ipv6_settings(DBusMessageIter *array,
connman_ipaddress_set_ipv6(context->ipv6_address, address,
prefix_length, gateway);
 
+   g_free(context->ipv6_nameservers);
context->ipv6_nameservers = nameservers;
 
 out:
-- 
1.8.3.1

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


[PATCH 1/4] ofono: Do not break loop too early if IPv4 method is dhcp

2014-03-24 Thread Jukka Rissanen
If oFono sends IPv4 properties in different order, then we might
miss the index value.
---
 plugins/ofono.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index c5c1ed7..8a29d24 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -782,12 +782,11 @@ static void extract_ipv4_settings(DBusMessageIter *array,
 
DBG("Method %s", val);
 
-   if (g_strcmp0(val, "static") == 0) {
+   if (g_strcmp0(val, "static") == 0)
context->ipv4_method = 
CONNMAN_IPCONFIG_METHOD_FIXED;
-   } else if (g_strcmp0(val, "dhcp") == 0) {
+   else if (g_strcmp0(val, "dhcp") == 0)
context->ipv4_method = 
CONNMAN_IPCONFIG_METHOD_DHCP;
-   break;
-   }
+
} else if (g_str_equal(key, "Address")) {
dbus_message_iter_get_basic(&value, &val);
 
-- 
1.8.3.1

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


[PATCH 0/4] Misc ofono plugin fixes

2014-03-24 Thread Jukka Rissanen
Hi,

the fixes are needed when IPv4 method is set to DHCP by oFono.

In patch 1, we do not break too soon as if the oFono starts to
send the properties in different order, then we might miss the
index value if method is dhcp.

Patch 2 fixes the issue where index is not set if method is dhcp.

Patches 3 and 4 fix possible memory leak issue if the IPv4 or IPv6
properties change.


Cheers,
Jukka


Jukka Rissanen (4):
  ofono: Do not break loop too early if IPv4 method is dhcp
  ofono: IPv4 index was set too late if method is set to dhcp
  ofono: Possible memory leak when setting IPv4 name servers
  ofono: Possible memory leak when setting IPv6 name servers

 plugins/ofono.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

-- 
1.8.3.1

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


[PATCH 3/4] ofono: Possible memory leak when setting IPv4 name servers

2014-03-24 Thread Jukka Rissanen
---
 plugins/ofono.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index e1088c5..97761ce 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -831,6 +831,7 @@ static void extract_ipv4_settings(DBusMessageIter *array,
connman_ipaddress_set_ipv4(context->ipv4_address, address,
netmask, gateway);
 
+   g_free(context->ipv4_nameservers);
context->ipv4_nameservers = nameservers;
 
 out:
-- 
1.8.3.1

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


[PATCH 2/4] ofono: IPv4 index was set too late if method is set to dhcp

2014-03-24 Thread Jukka Rissanen
If IPv4 method is dhcp, then context index is not set correctly.
---
 plugins/ofono.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/plugins/ofono.c b/plugins/ofono.c
index 8a29d24..e1088c5 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -817,14 +817,17 @@ static void extract_ipv4_settings(DBusMessageIter *array,
if (index < 0)
goto out;
 
+   context->index = index;
+
if (context->ipv4_method != CONNMAN_IPCONFIG_METHOD_FIXED)
goto out;
 
context->ipv4_address = 
connman_ipaddress_alloc(CONNMAN_IPCONFIG_TYPE_IPV4);
-   if (!context->ipv4_address)
+   if (!context->ipv4_address) {
+   context->index = -1;
goto out;
+   }
 
-   context->index = index;
connman_ipaddress_set_ipv4(context->ipv4_address, address,
netmask, gateway);
 
-- 
1.8.3.1

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


RE: [PATCH] plugins: Check IPv4 and IPv6 address when connecting oFono context

2014-03-24 Thread Ismail YILDIZ
Hi,

My modem is a Sierra MC7710 (DIP), drivers are provided by Linux kernel (sierra 
and sierra_net).
As you can see in the log, in extract_ipv4_settings method, the IP 
configuration method is set as DHCP.
Which means that it will try using DHCP to obtain IPv4 address.

BR
-Original Message-
From: connman [mailto:connman-boun...@connman.net] On Behalf Of Patrik Flykt
Sent: Monday, March 24, 2014 1:40 PM
To: connman@connman.net
Subject: Re: [PATCH] plugins: Check IPv4 and IPv6 address when connecting oFono 
context


Hi,

On Mon, 2014-03-24 at 12:31 +, Ismail YILDIZ wrote:
> I have an issue with the DHCP address retrieval.

What DHCP address retrieval? AFAIK cellular connections come configured via 
oFono and should just work.

There was a peculiar thing in your log, though. How is the cellular modem 
exposing itself to the system, what brand is it exactly and who has provided 
the driver?


Cheers,

Patrik


___
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


Re: [PATCH 22/24] client: Add basic support for P2P peers related signal and method

2014-03-24 Thread Jukka Rissanen
Hi Tomasz,

On pe, 2014-03-21 at 14:06 +0200, Tomasz Bursztyka wrote:
> Handle PeersChanged() signal and GetPeers() method from Manager API
> relevantly.
> ---
>  Makefile.am   |   1 +
>  client/commands.c | 140 
> --
>  client/peers.c| 123 +++
>  client/peers.h|  39 +++
>  4 files changed, 288 insertions(+), 15 deletions(-)
>  create mode 100644 client/peers.c
>  create mode 100644 client/peers.h
> 
> diff --git a/Makefile.am b/Makefile.am
> index c0f6c97..382bf2a 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -243,6 +243,7 @@ client_connmanctl_SOURCES = client/dbus_helpers.h 
> client/dbus_helpers.c \
>   client/commands.h client/commands.c \
>   client/input.h client/input.c \
>   client/agent.h client/agent.c \
> + client/peers.h client/peers.c \
>   client/vpnconnections.h client/vpnconnections.c \
>   client/main.c
>  
> diff --git a/client/commands.c b/client/commands.c
> index 1797323..b670563 100644
> --- a/client/commands.c
> +++ b/client/commands.c
> @@ -38,12 +38,14 @@
>  #include "dbus_helpers.h"
>  #include "input.h"
>  #include "services.h"
> +#include "peers.h"
>  #include "commands.h"
>  #include "agent.h"
>  #include "vpnconnections.h"
>  
>  static DBusConnection *connection;
>  static GHashTable *service_hash;
> +static GHashTable *peer_hash;
>  static GHashTable *technology_hash;
>  static char *session_notify_path;
>  static char *session_path;
> @@ -262,21 +264,32 @@ static int cmd_state(char *args[], int num, struct 
> connman_option *options)
>   state_print, NULL, NULL, NULL);
>  }
>  
> -static int services_list(DBusMessageIter *iter, const char *error,
> - void *user_data)
> +static int services_list(DBusMessageIter *iter,
> + const char *error, void *user_data)
>  {
>   if (!error) {
>   __connmanctl_services_list(iter);
>   fprintf(stdout, "\n");
> - } else {
> + } else
>   fprintf(stderr, "Error: %s\n", error);
> - }
>  
>   return 0;
>  }

The above are just cosmetic changes and would probably be in separate
patch.

>  
> -static int services_properties(DBusMessageIter *iter, const char *error,
> - void *user_data)
> +static int peers_list(DBusMessageIter *iter,
> + const char *error, void *user_data)
> +{
> + if (!error) {
> + __connmanctl_peers_list(iter);
> + fprintf(stdout, "\n");
> + } else
> + fprintf(stderr, "Error: %s\n", error);
> +
> + return 0;
> +}
> +
> +static int services_properties(DBusMessageIter *iter,
> + const char *error, void *user_data)
>  {
>   char *path = user_data;
>   char *str;
> @@ -346,8 +359,19 @@ static int cmd_services(char *args[], int num, struct 
> connman_option *options)
>   services_properties, path, NULL, NULL);
>  }
>  
> -static int technology_print(DBusMessageIter *iter, const char *error,
> - void *user_data)
> +static int cmd_peers(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", "GetPeers",
> + peers_list, NULL, NULL, NULL);
> +}
> +
> +static int technology_print(DBusMessageIter *iter,
> + const char *error, void *user_data)
>  {
>   DBusMessageIter array;
>  
> @@ -1043,10 +1067,10 @@ static DBusHandlerResult 
> monitor_changed(DBusConnection *connection,
>   __connmanctl_save_rl();
>  
>   if (dbus_message_is_signal(message, "net.connman.Manager",
> - "ServicesChanged")) {
> + "ServicesChanged")) {
>  
>   fprintf(stdout, "%-12s %-20s = {\n", interface,
> - "ServicesChanged");
> + "ServicesChanged");

These ones above look also style issue patches.


>   dbus_message_iter_init(message, &iter);
>   __connmanctl_services_list(&iter);
>   fprintf(stdout, "\n}\n");
> @@ -1054,10 +1078,18 @@ static DBusHandlerResult 
> monitor_changed(DBusConnection *connection,
>   __connmanctl_redraw_rl();
>  
>   return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
> - }
> + } else if (dbus_message_is_signal(message, "net.connman.Manager",
> + "PeersChanged")) {
> + fprintf(stdout, "%-12s %-20s = {\n", interface,
> +

Re: [PATCH] plugins: Check IPv4 and IPv6 address when connecting oFono context

2014-03-24 Thread Patrik Flykt

Hi,

On Mon, 2014-03-24 at 12:31 +, Ismail YILDIZ wrote:
> I have an issue with the DHCP address retrieval.

What DHCP address retrieval? AFAIK cellular connections come configured
via oFono and should just work.

There was a peculiar thing in your log, though. How is the cellular
modem exposing itself to the system, what brand is it exactly and who
has provided the driver?


Cheers,

Patrik


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


RE: [PATCH] plugins: Check IPv4 and IPv6 address when connecting oFono context

2014-03-24 Thread Ismail YILDIZ
Hi,

Thanks you for helping, I applied your patch but same issue. I avoid the return 
after "invalid address ..." and I have an issue with the DHCP address retrieval.

BR

-Original Message-
From: connman [mailto:connman-boun...@connman.net] On Behalf Of Patrik Flykt
Sent: Monday, March 24, 2014 11:58 AM
To: connman@connman.net
Subject: [PATCH] plugins: Check IPv4 and IPv6 address when connecting oFono 
context

Add a check also for an IPv6 address before stating that the interface has an 
invalid index or address.
---

Hi,

Adding a check also for IPv6 address. Only if neither IPv4 or IPv6 addresses 
are present, consider the connection failed.

Ismail, please test,

   Patrik


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

diff --git a/plugins/ofono.c b/plugins/ofono.c index c5c1ed7..7d49c57 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -266,7 +266,8 @@ static void set_connected(struct modem_data *modem)
 
index = modem->context->index;
 
-   if (index < 0 || !modem->context->ipv4_address) {
+   if (index < 0 || (!modem->context->ipv4_address &&
+   !modem->context->ipv6_address)) {
connman_error("Invalid index and/or address");
return;
}
--
1.8.5.3

___
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


Re: [PATCH 13/24] wifi: Handling P2P find when relevant service type is given to scan

2014-03-24 Thread Jukka Rissanen
Hi Tomasz,

On pe, 2014-03-21 at 14:06 +0200, Tomasz Bursztyka wrote:
> Once started, wifi plugin will run a timeout to trigger a stop by
> itself.
> ---
>  plugins/wifi.c | 83 
> ++
>  1 file changed, 83 insertions(+)
> 
> diff --git a/plugins/wifi.c b/plugins/wifi.c
> index d43a74e..6d21577 100644
> --- a/plugins/wifi.c
> +++ b/plugins/wifi.c
> @@ -63,6 +63,8 @@
>  #define BGSCAN_DEFAULT "simple:30:-45:300"
>  #define AUTOSCAN_DEFAULT "exponential:3:300"
>  
> +#define P2P_FIND_TIMEOUT 30
> +
>  static struct connman_technology *wifi_technology = NULL;
>  static struct connman_technology *p2p_technology = NULL;
>  
> @@ -113,6 +115,7 @@ struct wifi_data {
>   struct autoscan_params *autoscan;
>  
>   GSupplicantScanParams *scan_params;
> + unsigned int p2p_find_timeout;
>  };
>  
>  static GList *iface_list = NULL;
> @@ -293,6 +296,9 @@ static void wifi_remove(struct connman_device *device)
>  
>   check_p2p_technology();
>  
> + if (wifi->p2p_find_timeout)
> + g_source_remove(wifi->p2p_find_timeout);

Is the device now still reffed? Should we have a cleanup function that
would remove device ref etc when the timer is removed.

> +
>   remove_networks(device, wifi);
>  
>   connman_device_set_powered(device, false);
> @@ -926,6 +932,11 @@ static int wifi_disable(struct connman_device *device)
>  
>   stop_autoscan(device);
>  
> + if (wifi->p2p_find_timeout) {
> + g_source_remove(wifi->p2p_find_timeout);
> + wifi->p2p_find_timeout = 0;

Ditto.

> + }
> +
>   /* In case of a user scan, device is still referenced */
>   if (connman_device_get_scanning(device)) {
>   connman_device_set_scanning(device, false);
> @@ -1080,6 +1091,75 @@ static int wifi_scan_simple(struct connman_device 
> *device)
>   return throw_wifi_scan(device, scan_callback_hidden);
>  }
>  
> +static gboolean p2p_find_stop(gpointer data)
> +{
> + struct connman_device *device = data;
> + struct wifi_data *wifi = connman_device_get_data(device);
> +
> + DBG("");
> +
> + wifi->p2p_find_timeout = 0;
> +
> + connman_device_set_scanning(device, false);
> +
> + g_supplicant_interface_p2p_stop_find(wifi->interface);
> +
> + connman_device_unref(device);
> + reset_autoscan(device);
> +
> + return FALSE;
> +}
> +
> +static void p2p_find_callback(int result, GSupplicantInterface *interface,
> + void *user_data)
> +{
> + struct connman_device *device = user_data;
> + struct wifi_data *wifi = connman_device_get_data(device);
> +
> + DBG("result %d wifi %p", result, wifi);
> +
> + if (wifi->p2p_find_timeout) {
> + g_source_remove(wifi->p2p_find_timeout);
> + wifi->p2p_find_timeout = 0;
> + }
> +
> + if (result)
> + goto error;
> +
> + wifi->p2p_find_timeout = g_timeout_add_seconds(P2P_FIND_TIMEOUT,
> + p2p_find_stop, device);
> + if (!wifi->p2p_find_timeout)
> + goto error;
> +
> + return;
> +error:
> + p2p_find_stop(device);
> +}
> +
> +static int p2p_find(struct connman_device *device)
> +{
> + struct wifi_data *wifi = connman_device_get_data(device);
> + int ret;
> +
> + DBG("");
> +
> + if (!p2p_technology)
> + return -ENOTSUP;
> +
> + reset_autoscan(device);
> + connman_device_ref(device);
> +
> + ret = g_supplicant_interface_p2p_find(wifi->interface,
> + p2p_find_callback, device);
> + if (ret) {
> + connman_device_unref(device);
> + start_autoscan(device);
> + } else
> + connman_device_set_scanning(device, true);
> +
> + return ret;
> +}
> +
>  /*
>   * Note that the hidden scan is only used when connecting to this specific
>   * hidden AP first time. It is not used when system autoconnects to hidden 
> AP.
> @@ -1102,6 +1182,9 @@ static int wifi_scan(enum connman_service_type type,
>   if (!wifi)
>   return -ENODEV;
>  
> + if (type == CONNMAN_SERVICE_TYPE_P2P)
> + return p2p_find(device);
> +
>   DBG("device %p wifi %p hidden ssid %s", device, wifi->interface, ssid);
>  
>   if (wifi->tethering)


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


Re: [PATCH 12/24] device: Detail the service type to the scanning method

2014-03-24 Thread Jukka Rissanen
Hi Tomasz,

On pe, 2014-03-21 at 14:06 +0200, Tomasz Bursztyka wrote:
> It's actually about differentiating the technology, which will be
> useful when requesting a scan from P2P technology. Since this technology
> is the child of wifi technology, it will get a scan triggered through
> the same scanning method. It will be up to the wifi plugin to
> differentiate what to do according on the given type.
> ---
>  include/device.h |  4 +++-
>  plugins/wifi.c   |  9 +
>  src/device.c | 22 ++
>  3 files changed, 22 insertions(+), 13 deletions(-)
> 
> diff --git a/include/device.h b/include/device.h
> index 721cc84..d2bc1f3 100644
> --- a/include/device.h
> +++ b/include/device.h
> @@ -23,6 +23,7 @@
>  #define __CONNMAN_DEVICE_H
>  
>  #include 
> +#include 
>  
>  #ifdef __cplusplus
>  extern "C" {
> @@ -124,7 +125,8 @@ struct connman_device_driver {
>   void (*remove) (struct connman_device *device);
>   int (*enable) (struct connman_device *device);
>   int (*disable) (struct connman_device *device);
> - int (*scan)(struct connman_device *device,
> + int (*scan)(enum connman_service_type type,
> + struct connman_device *device,
>   const char *ssid, unsigned int ssid_len,
>   const char *identity, const char* passphrase,
>   const char *security, void *user_data);
> diff --git a/plugins/wifi.c b/plugins/wifi.c
> index f19dd34..d43a74e 100644
> --- a/plugins/wifi.c
> +++ b/plugins/wifi.c
> @@ -1084,10 +1084,11 @@ static int wifi_scan_simple(struct connman_device 
> *device)
>   * Note that the hidden scan is only used when connecting to this specific
>   * hidden AP first time. It is not used when system autoconnects to hidden 
> AP.
>   */
> -static int wifi_scan(struct connman_device *device,
> - const char *ssid, unsigned int ssid_len,
> - const char *identity, const char* passphrase,
> - const char *security, void *user_data)
> +static int wifi_scan(enum connman_service_type type,
> + struct connman_device *device,
> + const char *ssid, unsigned int ssid_len,
> + const char *identity, const char* passphrase,
> + const char *security, void *user_data)
>  {
>   struct wifi_data *wifi = connman_device_get_data(device);
>   GSupplicantScanParams *scan_params = NULL;
> diff --git a/src/device.c b/src/device.c
> index bc835be..8306617 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -591,7 +591,8 @@ int connman_device_set_powered(struct connman_device 
> *device,
>   device->scanning = false;
>  
>   if (device->driver && device->driver->scan)
> - device->driver->scan(device, NULL, 0, NULL, NULL, NULL, NULL);
> + device->driver->scan(0, device, NULL, 0,

Perhaps CONNMAN_SERVICE_TYPE_UNKNOWN instead of 0?

> + NULL, NULL, NULL, NULL);

Also could we use the service type to notice who did the scan, instead
of hackish looking scan_pending check in patch #08.

>  
>   return 0;
>  }
> @@ -601,7 +602,8 @@ bool connman_device_get_powered(struct connman_device 
> *device)
>   return device->powered;
>  }
>  
> -static int device_scan(struct connman_device *device)
> +static int device_scan(enum connman_service_type type,
> + struct connman_device *device)
>  {
>   if (!device->driver || !device->driver->scan)
>   return -EOPNOTSUPP;
> @@ -609,7 +611,8 @@ static int device_scan(struct connman_device *device)
>   if (!device->powered)
>   return -ENOLINK;
>  
> - return device->driver->scan(device, NULL, 0, NULL, NULL, NULL, NULL);
> + return device->driver->scan(type, device, NULL, 0,
> + NULL, NULL, NULL, NULL);
>  }
>  
>  int __connman_device_disconnect(struct connman_device *device)
> @@ -1122,12 +1125,15 @@ int __connman_device_request_scan(enum 
> connman_service_type type)
>   enum connman_service_type service_type =
>   __connman_device_get_service_type(device);
>  
> - if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN &&
> - service_type != type) {
> - continue;
> + if (service_type != CONNMAN_SERVICE_TYPE_UNKNOWN) {
> + if (type == CONNMAN_SERVICE_TYPE_P2P) {
> + if (service_type != CONNMAN_SERVICE_TYPE_WIFI)
> + continue;
> + } else if (service_type != type)
> + continue;
>   }
>  
> - err = device_scan(device);
> + err = device_scan(type, device);
>   if (err == 0 || err == -EALREADY || err == -EINPROGRESS) {
>   success = true;
>   } else {
> @@ -1153,7 +1159,7 @@ in

Re: [PATCH 10/24] wifi: Add support for (un)registering P2P technology if present

2014-03-24 Thread Jukka Rissanen
Hi Tomasz,

On pe, 2014-03-21 at 14:06 +0200, Tomasz Bursztyka wrote:
> Since P2P is dependent over wifi technology, it will get its technology
> registered by this one if only one of the interface supports it.
> Following the same logic, once an interface is removed the wifi
> technology will check if the P2P technology is still supported by - at
> least one of - the other interfaces, if any. If not, the P2P technology
> will be then unregistered.
> ---
>  plugins/wifi.c | 50 ++
>  1 file changed, 50 insertions(+)
> 
> diff --git a/plugins/wifi.c b/plugins/wifi.c
> index 6da3c53..f19dd34 100644
> --- a/plugins/wifi.c
> +++ b/plugins/wifi.c
> @@ -64,6 +64,7 @@
>  #define AUTOSCAN_DEFAULT "exponential:3:300"
>  
>  static struct connman_technology *wifi_technology = NULL;
> +static struct connman_technology *p2p_technology = NULL;
>  
>  struct hidden_params {
>   char ssid[32];
> @@ -118,6 +119,25 @@ static GList *iface_list = NULL;
>  
>  static void start_autoscan(struct connman_device *device);
>  
> +static int p2p_tech_probe(struct connman_technology *technology)
> +{
> + p2p_technology = technology;
> +
> + return 0;
> +}
> +
> +static void p2p_tech_remove(struct connman_technology *technology)
> +{
> + p2p_technology = NULL;
> +}
> +
> +static struct connman_technology_driver p2p_tech_driver = {
> + .name   = "p2p",
> + .type   = CONNMAN_SERVICE_TYPE_P2P,
> + .probe  = p2p_tech_probe,
> + .remove = p2p_tech_remove,
> +};
> +
>  static void handle_tethering(struct wifi_data *wifi)
>  {
>   if (!wifi->tethering)
> @@ -243,6 +263,23 @@ static void stop_autoscan(struct connman_device *device)
>   connman_device_set_scanning(device, false);
>  }
>  
> +static void check_p2p_technology(void)
> +{
> + bool p2p_still_supported = false;

The variable name is confusing, what about naming it p2p_exists or
similar.

> + GList *list;
> +
> + for (list = iface_list; list; list = list->next) {
> + struct wifi_data *w = list->data;
> +
> + if (w->interface &&
> + g_supplicant_interface_has_p2p(w->interface))
> + p2p_still_supported = true;
> + }
> +
> + if (!p2p_still_supported)
> + connman_technology_driver_unregister(&p2p_tech_driver);
> +}
> +
>  static void wifi_remove(struct connman_device *device)
>  {
>   struct wifi_data *wifi = connman_device_get_data(device);
> @@ -254,6 +291,8 @@ static void wifi_remove(struct connman_device *device)
>  
>   iface_list = g_list_remove(iface_list, wifi);
>  
> + check_p2p_technology();
> +
>   remove_networks(device, wifi);
>  
>   connman_device_set_powered(device, false);
> @@ -1743,6 +1782,16 @@ static void interface_removed(GSupplicantInterface 
> *interface)
>  
>   wifi->interface = NULL;
>   connman_device_set_powered(wifi->device, false);
> +
> + check_p2p_technology();
> +}
> +
> +static void p2p_support(GSupplicantInterface *interface)
> +{
> + DBG("");
> +
> + if (g_supplicant_interface_has_p2p(interface))
> + connman_technology_driver_register(&p2p_tech_driver);
>  }
>  
>  static void scan_started(GSupplicantInterface *interface)
> @@ -1930,6 +1979,7 @@ static const GSupplicantCallbacks callbacks = {
>   .interface_added= interface_added,
>   .interface_state= interface_state,
>   .interface_removed  = interface_removed,
> + .p2p_support= p2p_support,
>   .scan_started   = scan_started,
>   .scan_finished  = scan_finished,
>   .network_added  = network_added,


Cheers,
Jukka


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


Re: [PATCH 09/24] gsupplicant: Add a mechanism to know whether P2P is supported or not

2014-03-24 Thread Jukka Rissanen
Hi Tomasz,

On pe, 2014-03-21 at 14:05 +0200, Tomasz Bursztyka wrote:
> By default, support is false but if P2P "Flush()" method gets a
> non-erroneous reply: it will be set to true.
> 
> This tests at once if:
> - wpa_supplicant has been built with p2p support, then Flush() should
>   exist so no error should come as a reply.
> - the device supports p2p, then Flush() should not reply with an error.
> 
> Whatever comes as a result will be notified through a callback to the
> upper wifi plugin (which has to provide one) then it will be able to get
> the value through a getter.
> ---
>  gsupplicant/gsupplicant.h |  2 ++
>  gsupplicant/supplicant.c  | 35 +++
>  2 files changed, 37 insertions(+)
> 
> diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
> index a279cd8..d0775c3 100644
> --- a/gsupplicant/gsupplicant.h
> +++ b/gsupplicant/gsupplicant.h
> @@ -222,6 +222,7 @@ int 
> g_supplicant_interface_set_country(GSupplicantInterface *interface,
>   GSupplicantCountryCallback callback,
>   const char *alpha2,
>   void *user_data);
> +bool g_supplicant_interface_has_p2p(GSupplicantInterface *interface);
>  
>  /* Network API */
>  struct _GSupplicantNetwork;
> @@ -249,6 +250,7 @@ struct _GSupplicantCallbacks {
>   void (*interface_added) (GSupplicantInterface *interface);
>   void (*interface_state) (GSupplicantInterface *interface);
>   void (*interface_removed) (GSupplicantInterface *interface);
> + void (*p2p_support) (GSupplicantInterface *interface);
>   void (*scan_started) (GSupplicantInterface *interface);
>   void (*scan_finished) (GSupplicantInterface *interface);
>   void (*network_added) (GSupplicantNetwork *network);
> diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
> index ab6462f..9ffc541 100644
> --- a/gsupplicant/supplicant.c
> +++ b/gsupplicant/supplicant.c
> @@ -153,6 +153,8 @@ struct _GSupplicantInterface {
>   unsigned int scan_capa;
>   unsigned int mode_capa;
>   unsigned int max_scan_ssids;
> + bool p2p_checked;
> + bool p2p_support;
>   dbus_bool_t ready;
>   GSupplicantState state;
>   dbus_bool_t scanning;
> @@ -376,6 +378,19 @@ static void 
> callback_interface_removed(GSupplicantInterface *interface)
>   callbacks_pointer->interface_removed(interface);
>  }
>  
> +static void callback_p2p_support(GSupplicantInterface *interface)
> +{
> + SUPPLICANT_DBG("");
> +
> + if (interface->p2p_checked)
> + return;
> +
> + if (callbacks_pointer && callbacks_pointer->p2p_support)
> + callbacks_pointer->p2p_support(interface);
> +
> + interface->p2p_checked = true;

Minor thing but would it be better to move the "p2p_checked=true" line
before the callback call? Then regardless of what the callback does, we
would not be able to call this callback twice because the p2p_checked
would already be set.


> +}
> +
>  static void callback_scan_started(GSupplicantInterface *interface)
>  {
>   if (!callbacks_pointer)
> @@ -1828,6 +1843,17 @@ static GSupplicantInterface *interface_alloc(const 
> char *path)
>   return interface;
>  }
>  
> +static void interface_p2p_flush(const char *error,
> + DBusMessageIter *iter, void *user_data)
> +{
> + GSupplicantInterface *interface = user_data;
> +
> + if (!error)
> + interface->p2p_support = true;
> +
> + callback_p2p_support(interface);
> +}
> +
>  static void interface_added(DBusMessageIter *iter, void *user_data)
>  {
>   GSupplicantInterface *interface;
> @@ -1850,6 +1876,10 @@ static void interface_added(DBusMessageIter *iter, 
> void *user_data)
>   if (!interface)
>   return;
>  
> + supplicant_dbus_method_call(path,
> + SUPPLICANT_INTERFACE ".Interface.P2PDevice", "Flush",
> + NULL, interface_p2p_flush, interface, NULL, NULL);
> +
>   dbus_message_iter_next(iter);
>   if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INVALID) {
>   supplicant_dbus_property_foreach(iter, interface_property,
> @@ -2430,6 +2460,11 @@ int 
> g_supplicant_interface_set_country(GSupplicantInterface *interface,
>   regdom);
>  }
>  
> +bool g_supplicant_interface_has_p2p(GSupplicantInterface *interface)
> +{
> + return interface->p2p_support;
> +}
> +
>  struct interface_data {
>   GSupplicantInterface *interface;
>   char *path; /* Interface path cannot be taken from interface (above) as


Cheers,
Jukka


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


Re: [PATCH 05/24] technology: Add P2P technology support

2014-03-24 Thread Patrik Flykt

Hi,

On Fri, 2014-03-21 at 14:05 +0200, Tomasz Bursztyka wrote:
 
> @@ -1093,6 +1096,9 @@ static struct connman_technology *technology_get(enum 
> connman_service_type type)
>   technology->type = type;
>   technology->path = g_strdup_printf("%s/technology/%s",
>   CONNMAN_PATH, str);
> + if (type == CONNMAN_SERVICE_TYPE_P2P)
> + technology->enabled = true;
> +

Should the state of WiFi technology be checked before enabling P2P?

Cheers,

Patrik


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


[PATCH] plugins: Check IPv4 and IPv6 address when connecting oFono context

2014-03-24 Thread Patrik Flykt
Add a check also for an IPv6 address before stating that the interface
has an invalid index or address.
---

Hi,

Adding a check also for IPv6 address. Only if neither IPv4 or IPv6 addresses
are present, consider the connection failed.

Ismail, please test,

   Patrik


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

diff --git a/plugins/ofono.c b/plugins/ofono.c
index c5c1ed7..7d49c57 100644
--- a/plugins/ofono.c
+++ b/plugins/ofono.c
@@ -266,7 +266,8 @@ static void set_connected(struct modem_data *modem)
 
index = modem->context->index;
 
-   if (index < 0 || !modem->context->ipv4_address) {
+   if (index < 0 || (!modem->context->ipv4_address &&
+   !modem->context->ipv6_address)) {
connman_error("Invalid index and/or address");
return;
}
-- 
1.8.5.3

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


Re: [PATCH 07/24] technology: Handle enabling/disabling P2P technology properly

2014-03-24 Thread Jukka Rissanen
Hi Tomasz,

On pe, 2014-03-21 at 14:05 +0200, Tomasz Bursztyka wrote:
> P2P is not tight to any devices, thus the need of automatically
> triggering the proper enabling/disabling function which will in turn
> send the signal about Powered being changed accordingly.
> ---
>  src/technology.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/technology.c b/src/technology.c
> index 63b7067..e1609c4 100644
> --- a/src/technology.c
> +++ b/src/technology.c
> @@ -704,6 +704,10 @@ static int technology_enable(struct connman_technology 
> *technology)
>   DBG("technology %p enable", technology);
>  
>   __sync_synchronize();
> +
> + if (technology->type == CONNMAN_SERVICE_TYPE_P2P)
> + return technology_enabled(technology);

I think we need to check whether the wifi technology is enabled before
enabling p2p technology.

> +
>   if (technology->enabled)
>   return -EALREADY;
>  
> @@ -745,6 +749,10 @@ static int technology_disable(struct connman_technology 
> *technology)
>   DBG("technology %p disable", technology);
>  
>   __sync_synchronize();
> +
> + if (technology->type == CONNMAN_SERVICE_TYPE_P2P)
> + return technology_disabled(technology);
> +
>   if (!technology->enabled)
>   return -EALREADY;
>  


Cheers,
Jukka


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


Re: How to set the hardware clock from the current system time.

2014-03-24 Thread Patrik Flykt

Hi,

On Mon, 2014-03-24 at 18:20 +0800, Chengyi Zhao wrote:
> ConnMan can't set the hardware clock from the current system time,
> when user has modified the system time, the time is unable to be saved
> after reboot.

That is correct.

> Can the functionality of setting the hardware clock be added to
> ConnMan? (It is similar to the shell "hwclock -w".)

No. ConnMan has nothing to do with any variants of hardware clocks.
Using NTP, ConnMan keeps the system time properly synchronized to UTC.
It's up to the rest of the operating system to synchronize system time
with the hardware clock when booting and shutting down.


Cheers,

Patrik

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


How to set the hardware clock from the current system time.

2014-03-24 Thread Chengyi Zhao
Hi,

ConnMan can't set the hardware clock from the current system time, when
user has modified the system time,
the time is unable to be saved after reboot.

Can the functionality of setting the hardware clock be added to ConnMan?
(It is similar to the shell "hwclock -w".)

Cheers,

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


RE: Connection on cellular network timeout

2014-03-24 Thread Ismail YILDIZ
Hi all,

I applied a patch on the sierra.c from ofono source (v 1.14) but I have still 
the same error " Invalid index and/or address". 
I attached connman -nd plugins/ofono.c log.

BR
-Original Message-
From: connman [mailto:connman-boun...@connman.net] On Behalf Of Ismail YILDIZ
Sent: Friday, March 21, 2014 10:09 AM
To: connman@connman.net
Subject: RE: Connection on cellular network timeout

Actually my platform is Tizen. I was able to disable connman with systemctl and 
run it back in foreground with plugin/ofono.c argument.
Now the result is "Invalid index and/or address" which means we did one more 
step further. Thank you for this.
Do you need some output ?

BR

-Original Message-
From: connman [mailto:connman-boun...@connman.net] On Behalf Of Patrik Flykt
Sent: Thursday, March 20, 2014 4:08 PM
To: connman@connman.net
Subject: Re: Connection on cellular network timeout

On Thu, 2014-03-20 at 14:19 +, Ismail YILDIZ wrote:
> Thanks you for your reply. Do you know which process launch again 
> connman when I kill it ?

Depends on your system and how it's configured. Perhaps systemd, if that's in 
use, perhaps it can also have been configured not to restart.
In the latter case just start it from command line or use your system's service 
(re)starting commands, e.g. '/etc/init.d/connmman start' or something 
systemd'ish that I don't remember right now.


Cheers,

Patrik

___
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


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

[PATCH 3/5] service: Clear up connect logic when called from D-Bus

2014-03-24 Thread Patrik Flykt
When connected via D-Bus, iterate only over the beginning of the list
where the services are either connected or connecting. If the interface
is not available, disconnect the other service(s) which use the
interface. Once all disconnections are progressing, bail out if any
of them was asynchronous. Do not force the service to idle, as it will
not be possible to do an anychronous disconnect otherwise.
---
 src/service.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/service.c b/src/service.c
index b215bfd..cfc9cd1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3953,8 +3953,8 @@ static DBusMessage *connect_service(DBusConnection *conn,
DBusMessage *msg, void *user_data)
 {
struct connman_service *service = user_data;
+   int err = 0;
GList *list;
-   int err;
 
DBG("service %p", service);
 
@@ -3969,15 +3969,19 @@ static DBusMessage *connect_service(DBusConnection 
*conn,
 * interfaces for a given technology type (like having
 * more than one wifi card).
 */
-   if (service->type == temp->type &&
-   is_connecting(temp) &&
-   !is_interface_available(service, temp)) {
-
-   __connman_service_disconnect(temp);
-   set_idle(temp);
+   if (!is_connecting(temp) && !is_connected(temp))
break;
+
+   if (service->type != temp->type)
+   continue;
+
+   if(!is_interface_available(service, temp)) {
+   if (__connman_service_disconnect(temp) == -EINPROGRESS)
+   err = -EINPROGRESS;
}
}
+   if (err == -EINPROGRESS)
+   return __connman_error_in_progress(msg);
 
service->ignore = false;
 
-- 
1.8.5.3

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


[PATCH 0/5] Major and minor fixes

2014-03-24 Thread Patrik Flykt
Hi,

A potential crash has been fixed on DHCPv4 expiry.

In addition to that, network disconnection and service connection have
been updated. Network such that a missing driver disconnect function is
considered indicating an immediate disconnect and service connection
such that all other services utilizing the same interface are
disconnected. If any of those other services signal -EINPROGRESS,
consider this a temporary failure and return an error to the caller.

Finally, get rid of forcefully setting the service to idle. This
functionality is to be provided by service disconnection. On clearing
the 'Error' property it is not considered good behavior to force the
service states to idle either...

Cheers,

Patrik


Patrik Flykt (5):
  dhcp: Release dhcp structure before freeing it
  network: A network is disconnected except on -EINPROGRESS
  service: Clear up connect logic when called from D-Bus
  service: Clear up error path when connecting a service
  service: Don't force a service to idle state

 src/dhcp.c|  4 +---
 src/network.c | 11 +--
 src/service.c | 39 +++
 3 files changed, 21 insertions(+), 33 deletions(-)

-- 
1.8.5.3

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


[PATCH 4/5] service: Clear up error path when connecting a service

2014-03-24 Thread Patrik Flykt
If an error happens at connect time and there is still a pending call
present indicating the error has not been handled, return error. With
no pending call present, the error has already been signalled.
---
 src/service.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/service.c b/src/service.c
index cfc9cd1..b98b1de 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3989,11 +3989,9 @@ static DBusMessage *connect_service(DBusConnection *conn,
 
err = __connman_service_connect(service,
CONNMAN_SERVICE_CONNECT_REASON_USER);
-   if (err < 0) {
-   if (!service->pending)
-   return NULL;
 
-   if (err != -EINPROGRESS) {
+   if (err < 0 && err != -EINPROGRESS) {
+   if (service->pending) {
dbus_message_unref(service->pending);
service->pending = NULL;
 
-- 
1.8.5.3

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


[PATCH 2/5] network: A network is disconnected except on -EINPROGRESS

2014-03-24 Thread Patrik Flykt
If the driver does not have a disconnect function or the disconnect
function returns anything else than -EINPROGRESS, consider the
network to be disconnected.
---
 src/network.c | 11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/src/network.c b/src/network.c
index 1d5a13b..ce6fa85 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1539,7 +1539,7 @@ int __connman_network_connect(struct connman_network 
*network)
  */
 int __connman_network_disconnect(struct connman_network *network)
 {
-   int err;
+   int err = 0;
 
DBG("network %p", network);
 
@@ -1550,13 +1550,12 @@ int __connman_network_disconnect(struct connman_network 
*network)
if (!network->driver)
return -EUNATCH;
 
-   if (!network->driver->disconnect)
-   return -ENOSYS;
-
network->connecting = false;
 
-   err = network->driver->disconnect(network);
-   if (err == 0)
+   if (network->driver->disconnect)
+   err = network->driver->disconnect(network);
+
+   if (err != -EINPROGRESS)
set_disconnected(network);
 
return err;
-- 
1.8.5.3

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


[PATCH 5/5] service: Don't force a service to idle state

2014-03-24 Thread Patrik Flykt
When removing a service, let the service disconnect take the service
to the idle state. Also, when unsetting the 'Error' property, don't
force the service to idle.
---
 src/service.c | 15 ++-
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/src/service.c b/src/service.c
index b98b1de..b5e1eff 100644
--- a/src/service.c
+++ b/src/service.c
@@ -3420,17 +3420,6 @@ static void set_error(struct connman_service *service,
DBUS_TYPE_STRING, &str);
 }
 
-static void set_idle(struct connman_service *service)
-{
-   if (service->state == CONNMAN_SERVICE_STATE_IDLE)
-   return;
-
-   service->state = service->state_ipv4 = service->state_ipv6 =
-   CONNMAN_SERVICE_STATE_IDLE;
-   set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
-   state_changed(service);
-}
-
 static DBusMessage *clear_property(DBusConnection *conn,
DBusMessage *msg, void *user_data)
 {
@@ -3443,7 +3432,7 @@ static DBusMessage *clear_property(DBusConnection *conn,
DBUS_TYPE_INVALID);
 
if (g_str_equal(name, "Error")) {
-   set_idle(service);
+   set_error(service, CONNMAN_SERVICE_ERROR_UNKNOWN);
 
g_get_current_time(&service->modified);
service_save(service);
@@ -4051,7 +4040,7 @@ bool __connman_service_remove(struct connman_service 
*service)
g_free(service->eap);
service->eap = NULL;
 
-   set_idle(service);
+   service->error = CONNMAN_SERVICE_ERROR_UNKNOWN;
 
__connman_service_set_favorite(service, false);
 
-- 
1.8.5.3

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


[PATCH 1/5] dhcp: Release dhcp structure before freeing it

2014-03-24 Thread Patrik Flykt
Call dhcp_release() before dhcp_invalidate(), as the latter function
frees the dhcp struct. Also do not free the structure twice.
---
 src/dhcp.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/dhcp.c b/src/dhcp.c
index d98f42d..c1dc5ec 100644
--- a/src/dhcp.c
+++ b/src/dhcp.c
@@ -590,10 +590,8 @@ static void remove_network(gpointer user_data)
 
DBG("dhcp %p", dhcp);
 
-   dhcp_invalidate(dhcp, false);
dhcp_release(dhcp);
-
-   g_free(dhcp);
+   dhcp_invalidate(dhcp, false);
 }
 
 int __connman_dhcp_start(struct connman_network *network, dhcp_cb callback)
-- 
1.8.5.3

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