Re: [PATCH] service: Fix config file passphrase setting

2014-09-09 Thread Jukka Rissanen
Hi Patrik,

On ma, 2014-09-08 at 13:38 +0300, Patrik Flykt wrote:
 Create a local passphrase setting function as config files would
 otherwise use the internal passphrase setting function which disallows
 modifications to immutable .config files.

Perhaps it would be more logical to set the immutable flag in config.c
after we have set the passphrase, now it is set before which causes
these problems. Then we do not need to tweak the set passphrase function
at all.

 ---
  src/service.c | 18 ++
  1 file changed, 14 insertions(+), 4 deletions(-)
 
 diff --git a/src/service.c b/src/service.c
 index d96713d..e6a5240 100644
 --- a/src/service.c
 +++ b/src/service.c
 @@ -2876,12 +2876,12 @@ static int check_passphrase(enum 
 connman_service_security security,
   return 0;
  }
  
 -int __connman_service_set_passphrase(struct connman_service *service,
 - const char *passphrase)
 +static int set_passphrase(struct connman_service *service,
 + const char *passphrase)
  {
   int err;
  
 - if (service-immutable || service-hidden)
 + if (service-hidden)
   return -EINVAL;
  
   err = check_passphrase(service-security, passphrase);
 @@ -2900,6 +2900,15 @@ int __connman_service_set_passphrase(struct 
 connman_service *service,
   return 0;
  }
  
 +int __connman_service_set_passphrase(struct connman_service *service,
 + const char *passphrase)
 +{
 + if (service-immutable)
 + return -EINVAL;
 +
 + return set_passphrase(service, passphrase);
 +}
 +
  const char *__connman_service_get_passphrase(struct connman_service *service)
  {
   if (!service)
 @@ -4973,7 +4982,8 @@ void __connman_service_set_string(struct 
 connman_service *service,
   g_free(service-phase2);
   service-phase2 = g_strdup(value);
   } else if (g_str_equal(key, Passphrase))
 - __connman_service_set_passphrase(service, value);
 + set_passphrase(service, value);
 +
  }
  
  void __connman_service_set_search_domains(struct connman_service *service,


Cheers,
Jukka


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


Help with tethering using RTL8188CUS

2014-09-09 Thread Frederik Lotter
Hi guys,

I posted for some assistance on the IRC channel. I did not see any reply.
Could anyone kindly have a look at my issue have give me a pointers if
possible?

I am using RTL8188CUS chip. I took a working driver from Raspberry Pi
kernel and patched it into our 3.14 kernel. The WIFI works fine. I know
this chip supports tethering using (custom built) hostapd as I have used in
on the PI before. Now I am trying to use connman. I had to add kernel
CONFIG_BRIDGE however, I still get a NOT SUPPORTED dbus error suggesting
the driver/interface does not support this feature.

What other dependancies exist ? Do I need a special wpa_supplicant?


Apart from the RTL8192 driver (used for RTL8188CUS) I have not changed any
other userspace components I used the enable-tethering script to test it.
( DRIVER:
https://github.com/raspberrypi/linux/tree/rpi-3.12.y/drivers/net/wireless/rtl8192cu
 )

I am using connman 1.20.

Any pointers will be very much appreciated.

Regards,
Frederik

Firmware Engiener
Mix Telematics, South Africa
___
connman mailing list
connman@connman.net
https://lists.connman.net/mailman/listinfo/connman


Re: [PATCH] service: Fix config file passphrase setting

2014-09-09 Thread Patrik Flykt

Hi,

On Tue, 2014-09-09 at 10:01 +0300, Jukka Rissanen wrote:
 Hi Patrik,
 
 On ma, 2014-09-08 at 13:38 +0300, Patrik Flykt wrote:
  Create a local passphrase setting function as config files would
  otherwise use the internal passphrase setting function which disallows
  modifications to immutable .config files.
 
 Perhaps it would be more logical to set the immutable flag in config.c
 after we have set the passphrase, now it is set before which causes
 these problems. Then we do not need to tweak the set passphrase function
 at all.

Yes, this is a better approach. Just a sec and I'll send a patch set
along these lines.

Cheers,

Patrik

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


Re: Help with tethering using RTL8188CUS

2014-09-09 Thread Patrik Flykt

Hi,

On Tue, 2014-09-09 at 11:33 +0200, Frederik Lotter wrote:
 Hi guys,
 
 I posted for some assistance on the IRC channel. I did not see any reply.
 Could anyone kindly have a look at my issue have give me a pointers if
 possible?

Sorry, must have been off the channel when you posted. We're mostly
available during daytime GMT+0 to GMT+2.

 I am using RTL8188CUS chip. I took a working driver from Raspberry Pi
 kernel and patched it into our 3.14 kernel. The WIFI works fine. I know
 this chip supports tethering using (custom built) hostapd as I have used in
 on the PI before. Now I am trying to use connman. I had to add kernel
 CONFIG_BRIDGE however, I still get a NOT SUPPORTED dbus error suggesting
 the driver/interface does not support this feature.
 
 What other dependancies exist ? Do I need a special wpa_supplicant?

Latest and greatest wpa_supplicant should do just fine. wpa_supplicant
1.x does also work, but not as well.

The README says that the kernel needs CONFIG_BRIDGE and
CONFIG_IP_NF_TARGET_MASQUERADE, and wpa_supplicant must be compiled with
CONFIG_AP=y.

Run ConnMan with 'connmand -n -d src/tethering.c,src/bridge.c' and see
what errors it might print out.

 Apart from the RTL8192 driver (used for RTL8188CUS) I have not changed any
 other userspace components I used the enable-tethering script to test it.

Here you can also use 'connmanctl tether technology on' as it does not
require python on the device. connmanctl only adds a dependency to
readline in addition to the connman ones.

 I am using connman 1.20.

That's somewhat old. In 1.23 there were a few fixes to tethering, but
they are not related to enabling tethering. I'd recommend to upgrade if
possible, all later releases have fixed quite a few issues that will
bite your system at some later point.


HTH,

Patrik

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


[PATCH 1/3] config: Refactor checks for configuration file type

2014-09-09 Thread Patrik Flykt
In case of WiFi networks continue with SSID and security method checks
after verifying the configuration file type. For ethernet and gadget
the configuration file type checking can be combined. This change also
delegates one more instance of explicit service type string checks to
service.c where these strings belong. Once the type is correct, the
additional wifi string comparison can be omitted.
---
 src/config.c | 83 ++--
 1 file changed, 47 insertions(+), 36 deletions(-)

diff --git a/src/config.c b/src/config.c
index cce3c60..276e06b 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1100,22 +1100,6 @@ static int try_provision_service(struct 
connman_config_service *config,
unsigned int ssid_len;
const char *str;
 
-   type = connman_service_get_type(service);
-   if (type == CONNMAN_SERVICE_TYPE_WIFI 
-   g_strcmp0(config-type, wifi) != 0)
-   return -ENOENT;
-
-   if (type == CONNMAN_SERVICE_TYPE_ETHERNET 
-   g_strcmp0(config-type, ethernet) != 0)
-   return -ENOENT;
-
-   if (type == CONNMAN_SERVICE_TYPE_GADGET 
-   g_strcmp0(config-type, gadget) != 0)
-   return -ENOENT;
-
-   DBG(service %p ident %s, service,
-   __connman_service_get_ident(service));
-
network = __connman_service_get_network(service);
if (!network) {
connman_error(Service has no network set);
@@ -1125,26 +1109,13 @@ static int try_provision_service(struct 
connman_config_service *config,
DBG(network %p ident %s, network,
connman_network_get_identifier(network));
 
-   if (config-mac) {
-   struct connman_device *device;
-   const char *device_addr;
-
-   device = connman_network_get_device(network);
-   if (!device) {
-   connman_error(Network device is missing);
-   return -ENODEV;
-   }
-
-   device_addr = connman_device_get_string(device, Address);
-
-   DBG(wants %s has %s, config-mac, device_addr);
+   type = connman_service_get_type(service);
 
-   if (g_ascii_strcasecmp(device_addr, config-mac) != 0)
+   switch(type) {
+   case CONNMAN_SERVICE_TYPE_WIFI:
+   if (__connman_service_string2type(config-type) != type)
return -ENOENT;
-   }
 
-   if (g_strcmp0(config-type, wifi) == 0 
-   type == CONNMAN_SERVICE_TYPE_WIFI) {
ssid = connman_network_get_blob(network, WiFi.SSID,
ssid_len);
if (!ssid) {
@@ -1155,12 +1126,53 @@ static int try_provision_service(struct 
connman_config_service *config,
if (!config-ssid || ssid_len != config-ssid_len)
return -ENOENT;
 
-   if (memcmp(config-ssid, ssid, ssid_len) != 0)
+   if (memcmp(config-ssid, ssid, ssid_len))
return -ENOENT;
 
str = connman_network_get_string(network, WiFi.Security);
if (config-security != __connman_service_string2security(str))
return -ENOENT;
+
+   break;
+
+   case CONNMAN_SERVICE_TYPE_ETHERNET:
+   case CONNMAN_SERVICE_TYPE_GADGET:
+
+   if (__connman_service_string2type(config-type) != type)
+   return -ENOENT;
+
+   break;
+
+   case CONNMAN_SERVICE_TYPE_UNKNOWN:
+   case CONNMAN_SERVICE_TYPE_SYSTEM:
+   case CONNMAN_SERVICE_TYPE_BLUETOOTH:
+   case CONNMAN_SERVICE_TYPE_CELLULAR:
+   case CONNMAN_SERVICE_TYPE_GPS:
+   case CONNMAN_SERVICE_TYPE_VPN:
+   case CONNMAN_SERVICE_TYPE_P2P:
+
+   return -ENOENT;
+   }
+
+   DBG(service %p ident %s, service,
+   __connman_service_get_ident(service));
+
+   if (config-mac) {
+   struct connman_device *device;
+   const char *device_addr;
+
+   device = connman_network_get_device(network);
+   if (!device) {
+   connman_error(Network device is missing);
+   return -ENODEV;
+   }
+
+   device_addr = connman_device_get_string(device, Address);
+
+   DBG(wants %s has %s, config-mac, device_addr);
+
+   if (g_ascii_strcasecmp(device_addr, config-mac) != 0)
+   return -ENOENT;
}
 
if (!config-ipv6_address) {
@@ -1281,8 +1293,7 @@ static int try_provision_service(struct 
connman_config_service *config,
__connman_service_set_timeservers(service,
config-timeservers);
 
-   if 

[PATCH 0/3] Fix setting of passphrase

2014-09-09 Thread Patrik Flykt

Hi,

Patch 03 fixes the issue with not being able to set a passphrase when
it is defined in a .config file. The fix is to simply set the immutable
flag after configuring the service.

In order to come this far, patch 02 moves around the part where a service
is connected, directly or by running autoconnect. Also to not is that
virtual, i.e. currently NFC provisioned WiFi networks, are not immutable.

While investigatin the issue, it was noticed that the configuration was
checking for the service type in more than one place. With this patch all
the service matching is now collected into one place and the literal
service type names are replaced with the helper function from service.c.


Cheers,

Patrik


Patrik Flykt (3):
  config: Refactor checks for configuration file type
  config: Refactor connecting after service provisioning
  config: Set service to immutable after completed configuration

 src/config.c | 107 +++
 1 file changed, 63 insertions(+), 44 deletions(-)

-- 
1.9.1

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


[PATCH 2/3] config: Refactor connecting after service provisioning

2014-09-09 Thread Patrik Flykt
Refactor the code that implicitely called __connman_service_connect()
for ethernet and gadget services and __connman_service_autoconnect()
for a non-NFC provisioned wifi service to do this explicitely.

Ethernet and gadget services are to be connected immediately when
provisioned as the services only exist while a cable is attached. For
a non-NFC provisioned wifi service autoconnect is used, as the
provisioned wifi might not be the best one in range. An NFC
provisioned wifi, i.e. the only category that currently has a virtual
config,  will be connected explicitely after the exiting to the main
loop.
---
 src/config.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/config.c b/src/config.c
index 276e06b..9d1759f 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1296,9 +1296,7 @@ static int try_provision_service(struct 
connman_config_service *config,
if (type == CONNMAN_SERVICE_TYPE_WIFI) {
provision_service_wifi(config, service, network,
ssid, ssid_len);
-   } else
-   __connman_service_connect(service,
-   CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+   }
 
__connman_service_mark_dirty();
 
@@ -1312,8 +1310,19 @@ static int try_provision_service(struct 
connman_config_service *config,
virtual-vfile = config-virtual_file;
 
g_timeout_add(0, remove_virtual_config, virtual);
-   } else
-   
__connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+
+   return 0;
+   }
+
+   if (type == CONNMAN_SERVICE_TYPE_ETHERNET ||
+   type == CONNMAN_SERVICE_TYPE_GADGET) {
+   __connman_service_connect(service,
+   CONNMAN_SERVICE_CONNECT_REASON_AUTO);
+
+   return 0;
+   }
+
+   __connman_service_auto_connect(CONNMAN_SERVICE_CONNECT_REASON_AUTO);
 
return 0;
 }
-- 
1.9.1

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


[PATCH 3/3] config: Set service to immutable after completed configuration

2014-09-09 Thread Patrik Flykt
A service that has been provisioned via other means than NFC is marked
immutable and no further modifications are allowed except those
specified in __connman_service_load_modifiable().

Setting a service to immutable needs to happen after all necessary
configuration is done as generic configuration functions which also
check the immutable status are used.
---
 src/config.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/src/config.c b/src/config.c
index 9d1759f..93a788a 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1263,9 +1263,6 @@ static int try_provision_service(struct 
connman_config_service *config,
g_slist_prepend(config-service_identifiers,
g_strdup(service_id));
 
-   if (!config-virtual)
-   __connman_service_set_immutable(service, true);
-
__connman_service_set_favorite_delayed(service, true, true);
 
__connman_service_set_config(service, config-config_ident,
@@ -1314,6 +1311,8 @@ static int try_provision_service(struct 
connman_config_service *config,
return 0;
}
 
+   __connman_service_set_immutable(service, true);
+
if (type == CONNMAN_SERVICE_TYPE_ETHERNET ||
type == CONNMAN_SERVICE_TYPE_GADGET) {
__connman_service_connect(service,
-- 
1.9.1

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


Re: Help with tethering using RTL8188CUS

2014-09-09 Thread Frederik Lotter
On 9 September 2014 12:33, Patrik Flykt patrik.fl...@linux.intel.com
wrote:


 Hi,

 On Tue, 2014-09-09 at 11:33 +0200, Frederik Lotter wrote:
  Hi guys,
 
  I posted for some assistance on the IRC channel. I did not see any reply.
  Could anyone kindly have a look at my issue have give me a pointers if
  possible?

 Sorry, must have been off the channel when you posted. We're mostly
 available during daytime GMT+0 to GMT+2.

  I am using RTL8188CUS chip. I took a working driver from Raspberry Pi
  kernel and patched it into our 3.14 kernel. The WIFI works fine. I know
  this chip supports tethering using (custom built) hostapd as I have used
 in
  on the PI before. Now I am trying to use connman. I had to add kernel
  CONFIG_BRIDGE however, I still get a NOT SUPPORTED dbus error suggesting
  the driver/interface does not support this feature.
 
  What other dependancies exist ? Do I need a special wpa_supplicant?

 Latest and greatest wpa_supplicant should do just fine. wpa_supplicant
 1.x does also work, but not as well.

 The README says that the kernel needs CONFIG_BRIDGE and
 CONFIG_IP_NF_TARGET_MASQUERADE, and wpa_supplicant must be compiled with
 CONFIG_AP=y.

 Run ConnMan with 'connmand -n -d src/tethering.c,src/bridge.c' and see
 what errors it might print out.

  Apart from the RTL8192 driver (used for RTL8188CUS) I have not changed
 any
  other userspace components I used the enable-tethering script to test
 it.

 Here you can also use 'connmanctl tether technology on' as it does not
 require python on the device. connmanctl only adds a dependency to
 readline in addition to the connman ones.

  I am using connman 1.20.

 That's somewhat old. In 1.23 there were a few fixes to tethering, but
 they are not related to enabling tethering. I'd recommend to upgrade if
 possible, all later releases have fixed quite a few issues that will
 bite your system at some later point.


 HTH,

 Patrik

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



Thank you so much for the quick reply. Your suggestions sound very useful.
I will try and report back asap.

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


[PATCH 0/2] Code cleanup in inet

2014-09-09 Thread Eduardo Abinader
Remove two unused functions in inet.

Eduardo Abinader (2):
  Remove unused function connman_inet_ifflags
  Remove unused function connman_inet_is_cfg80211

 include/inet.h |  4 
 src/inet.c | 60 --
 2 files changed, 64 deletions(-)

-- 
1.9.1

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


[PATCH 2/2] Remove unused function connman_inet_is_cfg80211

2014-09-09 Thread Eduardo Abinader
Removing as this function is no longer being used.
---
 include/inet.h |  2 --
 src/inet.c | 30 --
 2 files changed, 32 deletions(-)

diff --git a/include/inet.h b/include/inet.h
index 807febb..6482934 100644
--- a/include/inet.h
+++ b/include/inet.h
@@ -39,8 +39,6 @@ char *connman_inet_ifname(int index);
 int connman_inet_ifup(int index);
 int connman_inet_ifdown(int index);
 
-bool connman_inet_is_cfg80211(int index);
-
 int connman_inet_set_address(int index, struct connman_ipaddress *ipaddress);
 int connman_inet_clear_address(int index, struct connman_ipaddress *ipaddress);
 int connman_inet_add_host_route(int index, const char *host, const char 
*gateway);
diff --git a/src/inet.c b/src/inet.c
index f0144de..cd220ff 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -330,36 +330,6 @@ done:
return err;
 }
 
-bool connman_inet_is_cfg80211(int index)
-{
-   bool result = false;
-   char phy80211_path[PATH_MAX];
-   struct stat st;
-   struct ifreq ifr;
-   int sk;
-
-   sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-   if (sk  0)
-   return false;
-
-   memset(ifr, 0, sizeof(ifr));
-   ifr.ifr_ifindex = index;
-
-   if (ioctl(sk, SIOCGIFNAME, ifr)  0)
-   goto done;
-
-   snprintf(phy80211_path, PATH_MAX,
-   /sys/class/net/%s/phy80211, ifr.ifr_name);
-
-   if (stat(phy80211_path, st) == 0  (st.st_mode  S_IFDIR))
-   result = true;
-
-done:
-   close(sk);
-
-   return result;
-}
-
 struct in6_ifreq {
struct in6_addr ifr6_addr;
__u32 ifr6_prefixlen;
-- 
1.9.1

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


[PATCH 1/2] Remove unused function connman_inet_ifflags

2014-09-09 Thread Eduardo Abinader
As the referred function is no longer called in code,
it should be removed as well.
---
 include/inet.h |  2 --
 src/inet.c | 30 --
 2 files changed, 32 deletions(-)

diff --git a/include/inet.h b/include/inet.h
index a836a5b..807febb 100644
--- a/include/inet.h
+++ b/include/inet.h
@@ -36,8 +36,6 @@ extern C {
 int connman_inet_ifindex(const char *name);
 char *connman_inet_ifname(int index);
 
-short int connman_inet_ifflags(int index);
-
 int connman_inet_ifup(int index);
 int connman_inet_ifdown(int index);
 
diff --git a/src/inet.c b/src/inet.c
index fb37143..f0144de 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -240,36 +240,6 @@ char *connman_inet_ifname(int index)
return g_strdup(ifr.ifr_name);
 }
 
-short int connman_inet_ifflags(int index)
-{
-   struct ifreq ifr;
-   int sk, err;
-
-   sk = socket(PF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0);
-   if (sk  0)
-   return -errno;
-
-   memset(ifr, 0, sizeof(ifr));
-   ifr.ifr_ifindex = index;
-
-   if (ioctl(sk, SIOCGIFNAME, ifr)  0) {
-   err = -errno;
-   goto done;
-   }
-
-   if (ioctl(sk, SIOCGIFFLAGS, ifr)  0) {
-   err = -errno;
-   goto done;
-   }
-
-   err = ifr.ifr_flags;
-
-done:
-   close(sk);
-
-   return err;
-}
-
 int connman_inet_ifup(int index)
 {
struct ifreq ifr;
-- 
1.9.1

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