[PATCH] Fix BMC 8075 AP list gone when turning hotkey on and off

2010-10-27 Thread ying . an . deng
From: DengYingAn ying.an.d...@intel.com

With wireless on booting, APs list is gone after turnning off and on. Back 
ported from upstream with commit id 57536b8359c5c99f015cd97c597e2de82ce9144f
---
 src/connman.h |2 ++
 src/device.c  |2 ++
 src/element.c |   22 ++
 3 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/connman.h b/src/connman.h
index f5b03c8..e24ba2a 100644
--- a/src/connman.h
+++ b/src/connman.h
@@ -198,6 +198,8 @@ int __connman_element_disable_technology(enum 
connman_service_type type);
 
 gboolean __connman_element_device_isfiltered(const char *devname);
 
+void __connman_element_set_driver(struct connman_element *element);
+
 #include connman/ipconfig.h
 
 int __connman_ipconfig_init(void);
diff --git a/src/device.c b/src/device.c
index 22cf300..4ea24d1 100644
--- a/src/device.c
+++ b/src/device.c
@@ -597,6 +597,8 @@ static void probe_driver(struct connman_element *element, 
gpointer user_data)
 
element-device-driver = driver;
 
+   __connman_element_set_driver(element);
+
setup_device(element-device);
 }
 
diff --git a/src/element.c b/src/element.c
index 759d3e4..54b636d 100644
--- a/src/element.c
+++ b/src/element.c
@@ -1320,6 +1320,28 @@ void connman_element_set_error(struct connman_element 
*element,
__connman_service_indicate_error(service, convert_error(error));
 }
 
+void __connman_element_set_driver(struct connman_element *element)
+{
+   GSList *list;
+
+   DBG(element %p name %s driver %p, element, element-name,
+   element-driver);
+
+   if (element-driver)
+   return;
+
+   for (list = driver_list; list; list = list-next) {
+   struct connman_driver *driver = list-data;
+
+   if (match_driver(element, driver) == FALSE)
+   continue;
+
+   element-driver = driver;
+
+   break;
+   }
+}
+
 int __connman_element_init(const char *device, const char *nodevice)
 {
struct connman_element *element;
-- 
1.7.2.2

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: Add OpenVPN Support

2010-10-27 Thread Daniel Wagner
Good Morning Samuel,

On Wed, Oct 27, 2010 at 02:05:49AM +0200, Samuel Ortiz wrote:
 Hi Daniel,
 
 On Tue, Oct 26, 2010 at 03:54:23PM +0200, Daniel Wagner wrote:
  Hi,
  
  yet another update on this patch. OpenVPN is now running, but I'm
  struggling with the settings. The OpenVPN server settings seems
  broken. I can ping the server address (10.1.0.1) from my client
  (10.1.0.6). But everything else doesn't work yet. Some more debugging
  needed here :)
  
  Another thing I found out is that if there is no netmask set on the
  provider, connman does not setup the route. Don't know if this a bug
  in connman or in my setup.
 Although your OpenVPN server should probably provide you with a proper
 netmask, I just pushed a patch to have ConnMan being less pedantic about the
 netmask. So your routes should be set now (Which might also fix the problem
 you're describing in the first paragraph), could you please try ?

OpenVPN only pushes a netmask for tap devices not for tun devices:

 --up cmd
  Shell command to run after successful TUN/TAP device open (pre 
--user UID change).  The up script is useful for specifying
  route commands which route IP traffic destined for private 
subnets which exist at the other end of the VPN connection into
  the tunnel.

For --dev tun execute as:

  cmd tun_dev tun_mtu link_mtu ifconfig_local_ip ifconfig_remote_ip 
[ init | restart ]

For --dev tap execute as:

  cmd tap_dev tap_mtu link_mtu ifconfig_local_ip ifconfig_netmask [ 
init | restart ]

and vpn.c sets up a tun device. 

 The patch looks good to me otherwise, except for the Makefile.plugins hack.
 Marcel told me he will try to find out why we're linking twice when a source
 file is defined twice in builtin_sources.

Thanks. Most likely I would have to spend a week to figure out what's
going on. So any help is highly appreciated.

cheers,
daniel
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH] Fix BMC 8074 fail to enable technology after rfkill

2010-10-27 Thread ying . an . deng
From: DengYingAn ying.an.d...@intel.com

Fix the issue cannot enable technologies if devices are rfkilled. The 
unregistered device should not be powered down.
---
 src/device.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/device.c b/src/device.c
index 4ea24d1..9d34079 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1001,6 +1001,9 @@ int connman_device_set_powered(struct connman_device 
*device,
 {
DBG(driver %p powered %d, device, powered);
 
+   if ((powered == FALSE)  (device-registered == FALSE))
+   return -EOPNOTSUPP;
+
if (device-timeout  0) {
g_source_remove(device-timeout);
device-timeout = 0;
-- 
1.7.2.2

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Add vpn.h into Makefile.plugin

2010-10-27 Thread Samuel Ortiz
Hi Martin,

On Wed, Oct 27, 2010 at 11:00:36AM +0800, martin...@intel.com wrote:
 From: Martin Xu martin...@intel.com
 
 So the file can be included into dist tarball, otherwise, the file
 can not be found, and will block the building.
Thanks, patch applied.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Fix BMC7915 Connman stucks by few rfkill key pressing

2010-10-27 Thread Samuel Ortiz
Hi Ying,

On Thu, Oct 28, 2010 at 11:07:03AM +0800, ying.an.d...@intel.com wrote:
 From: DengYingAn ying.an.d...@intel.com
 
 Connman will be stuck after press few times of hotkey for wireless.
So this one applies against connman-stable, and I applied it.
If you want it to be applied against connman-stable-0.60, you'll have to have
bug #7915 upgraded to a 1.1 update blocker.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Fix BMC7915 Connman stucks by few rfkill key pressing

2010-10-27 Thread Samuel Ortiz
On Wed, Oct 27, 2010 at 11:09:47AM +0200, Samuel Ortiz wrote:
 Hi Ying,
 
 On Thu, Oct 28, 2010 at 11:07:03AM +0800, ying.an.d...@intel.com wrote:
  From: DengYingAn ying.an.d...@intel.com
  
  Connman will be stuck after press few times of hotkey for wireless.
 So this one applies against connman-stable, and I applied it.
Oh, one more thing: According to the bug report, this patch is from Joey Lee,
at Novell. So I changed the author field accordingly.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Fix BMC 8075 AP list gone when turning hotkey on and off

2010-10-27 Thread Samuel Ortiz
Hi Ying,

On Thu, Oct 28, 2010 at 01:10:33PM +0800, ying.an.d...@intel.com wrote:
 From: DengYingAn ying.an.d...@intel.com
 
 With wireless on booting, APs list is gone after turnning off and on. Back 
 ported from upstream with commit id 57536b8359c5c99f015cd97c597e2de82ce9144f

Patch applied to connman-stable, again with Joey Lee as the author.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: Add OpenVPN Support

2010-10-27 Thread Daniel Wagner
Hi Samuel,

On Wed, Oct 27, 2010 at 02:05:49AM +0200, Samuel Ortiz wrote:
 Hi Daniel,
 
 On Tue, Oct 26, 2010 at 03:54:23PM +0200, Daniel Wagner wrote:
  Hi,
  
  yet another update on this patch. OpenVPN is now running, but I'm
  struggling with the settings. The OpenVPN server settings seems
  broken. I can ping the server address (10.1.0.1) from my client
  (10.1.0.6). But everything else doesn't work yet. Some more debugging
  needed here :)
  
  Another thing I found out is that if there is no netmask set on the
  provider, connman does not setup the route. Don't know if this a bug
  in connman or in my setup.
 Although your OpenVPN server should probably provide you with a proper
 netmask, I just pushed a patch to have ConnMan being less pedantic about the
 netmask. So your routes should be set now (Which might also fix the problem
 you're describing in the first paragraph), could you please try ?

The netmask problem is solved.

I fixed my server setup, so all the traffic is routed to the openvpn
server and the server acts as default gateway. On the server I have
following configuration:

  dev tun0
  ca /etc/openvpn/keys/ca.crt
  cert /etc/openvpn/keys/server.crt
  key /etc/openvpn/keys/server.key
  dh /etc/openvpn/keys/dh1024.pem
  server 10.1.0.0 255.255.255.0
  push redirect-gateway def1
  push dhcp-option DNS 85.25.128.10
  push dhcp-option DNS 85.25.255.10

On the client side I have:

  client
  dev tun
  remote hotel311.server4you.de
  resolv-retry infinite
  nobind
  persist-key
  persist-tun
  ca ca.crt
  cert freakazoid.crt
  key freakazoid.key

The def1 flag does:

 def1 -- Use this flag to override the default gateway by using
 0.0.0.0/1 and 128.0.0.0/1 rather than 0.0.0.0/0.  This
 has the benefit of overriding but not wiping out the
 original default gateway

So starting openvpn without connman (just fetch local IP address with
dhclient), the routing table looks like this:

  $ ip r
  85.25.146.15 via 192.168.0.254 dev eth0 
  10.1.0.5 dev tun0  proto kernel  scope link  src 10.1.0.6 
  10.1.0.1 via 10.1.0.5 dev tun0 
  192.168.0.0/16 dev eth0  proto kernel  scope link  src 192.168.101.14 
  0.0.0.0/1 via 10.1.0.5 dev tun0 
  128.0.0.0/1 via 10.1.0.5 dev tun0 
  default via 192.168.0.254 dev eth0 

and everthing works fine. I have to admit I haven't really understood
the 0.0.0.0/1 and 128.0.0.0/1 magic but it helped in my case :)

If I use connman with openvpn together then the routing looks like
this:

  $ ip r
  10.1.0.5 via 192.168.0.254 dev eth0 
  10.1.0.5 dev vpn0  scope link 
  192.168.0.0/16 dev eth0  proto kernel  scope link  src 192.168.101.14 
  default via 10.1.0.6 dev vpn0  scope link

and openvpn complains about not finding the openvpn server:

connmand[10724]: vpn0 {create} index 17 type 65534 NONE
connmand[10724]: vpn0 {update} flags 4240 DOWN
connmand[10724]: vpn0 {newlink} index 17 operstate 2 DOWN
openvpn[10730]: OpenVPN 2.1.1 x86_64-redhat-linux-gnu [SSL] [LZO2] [EPOLL] 
[PKCS11] built on Jan  5 2010
openvpn[10730]: WARNING: No server certificate verification method has been 
enabled.  See http://openvpn.net/howto.html#mitm for more info.
openvpn[10730]: NOTE: the current --script-security setting may allow this 
configuration to call user-defined scripts
openvpn[10730]: UDPv4 link local: [undef]
openvpn[10730]: UDPv4 link remote: 85.25.146.15:1194
openvpn[10730]: [toronto053.server4you.de] Peer Connection Initiated with 
85.25.146.15:1194
openvpn[10730]: TUN/TAP device vpn0 opened
openvpn[10730]: /home/wagi/src/connman/scripts/openvpn-script vpn0 1500 1541 
10.1.0.6 10.1.0.5 init
openvpn[10730]: Initialization Sequence Completed
connmand[10724]: vpn0 {newlink} index 17 operstate 2 DOWN
connmand[10724]: vpn0 {update} flags 69841 UP,RUNNING,LOWER_UP
connmand[10724]: vpn0 {newlink} index 17 operstate 0 UNKNOWN
connmand[10724]: vpn0 up
connmand[10724]: vpn0 lower up
connmand[10724]: Deleting host route failed (No such process)
connmand[10724]: Removing default gateway route failed (No such process)
connmand[10724]: Enabling DNS server 192.168.100.4
connmand[10724]: Deleting host route failed (No such process)
connmand[10724]: Removing default gateway route failed (No such process)
connmand[10724]: Adding DNS server 85.25.128.10
connmand[10724]: vpn0 {add} address 10.1.0.6/32 label vpn0
connmand[10724]: vpn0 ip bound
openvpn[10730]: write UDPv4 []: Network is unreachable (code=101)
connmand[10724]: vpn0 {add} route 10.1.0.5 gw 0.0.0.0 scope 253 LINK
connmand[10724]: eth0 {add} route 10.1.0.5 gw 192.168.0.254 scope 0 UNIVERSE
connmand[10724]: eth0 {del} route 192.168.0.254 gw 0.0.0.0 scope 253 LINK
connmand[10724]: eth0 ip release
connmand[10724]: eth0 {del} route 0.0.0.0 gw 192.168.0.254 scope 0 UNIVERSE
connmand[10724]: Enabling DNS server 192.168.100.4
connmand[10724]: Disabling DNS server 85.25.128.10
connmand[10724]: Disabling DNS server 192.168.100.4
connmand[10724]: Enabling DNS server 85.25.128.10
connmand[10724]: vpn0 {add} route 0.0.0.0 

Re: [PATCH] Start wpa_supplican is service not running.

2010-10-27 Thread Kalle Valo
leena.gu...@wipro.com writes:

 Hi Kalle,

 + reply = dbus_connection_send_with_reply_and_block(connection,
 + message, -1, error);

 connman must never block, instead we need to use async interfaces.

 I intentionally made the call blocking since the system_available will
 be set to TRUE only if we get a reply from Introspect method. This
 also indicates that wpa_supplicant was indeed started in case it was
 not already running.

Still it's wrong, connman should not block anywhere. When it's blocking
on something no other events are handled and that's bound to create
problems.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 1/2] wifi: add a disconnected timer

2010-10-27 Thread Kalle Valo
Samuel Ortiz sa...@linux.intel.com writes:

 Hi Kalle,

Hi Samuel,

 On Tue, Oct 26, 2010 at 07:30:53PM +0300, Kalle Valo wrote:
 In a big network, for example at Ubuntu Developer Summit which has 10 APs,
 connman and wpasupplicant got out of sync very easily. connman claimed it
 was connected even though wpasupplicant (and the kernel driver) was actually
 connected to the AP.

 Did you mean connman claimed it was _disconnected_ ?

Yes, that's what I mean. Sorry for the confusion.

Just to be clear: connman claimed that wifi connection was disconnected,
but 'iw wlan0 link' showed that I was connected to Ubuntu network.

 The problem is that while roaming between APs inside ESS
 wpasupplicant states go like this:
 
 COMPLETED - DISCONNECTED - SCANNING - AUTHENTICATING ... - COMPLETED
 
 So what happens is that connman unnecessarily marks the network disconnected
 even though wpasupplicant is just roaming to a different AP within ESS.

 Well it really got disconnected from the AP, so ConnMan should just track
 that.

Well, it depends how we want to handle intra-ESS roaming. I see two
choises:

1) wpasupplicant manages roaming, connman just provides SSID and other settings
2) connman manages roaming

We should definitely go with option 1, it's faster and wpasupplicant has
the best information to choose which AP to connect to. So roaming between
APs on an ESS would be transparent from connman point of view.

 I'm really not a big fan of trying to be smarter than wpa_supplicant. In my
 experience, it's the shortest paths to new bugs

The problem here is that when wpasupplicant is roaming between APs it
goes to the disconnected state and then immediately to the scanning
state. The connman wifi plugin doesn't handle this properly.

 To fix this add a timer which waits 10 seconds after a disconnected state.
 If wpasupplicant hasn't connected to a network at time only then set the
 network disconnected.

 It looks a bit like a hack to me, the fundamental issue (ConnMan not tracking
 the wpa_supplicant states properly, it seems) is not fixed.

I agree my patch is a bit hackish, but it makes a huge difference here
at UDS. Without these two patches (and Mohamed's busy loop fix) connman
is unusable with a large wifi network.

Currently wifi plugin makes wrong assumptions how wpasupplicant works
and what the different wpasupplicant states mean. The proper fix would
be to change wpasupplicant to not use disconnected state when roaming.
The disconnected state should be used only when wpasupplicant is certain
that it cannot connect to the ESS anymore, for example after scanning
two times and not finding any suitable APs.

I think I can work on changing wpasupplicant at some point, but it will
take few months before I can find the time. My short term goal is to
make connman wifi reliable enough for the users.

Thank you for the comments.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 0/2] gsupplicant: remove disconnected networks from wpa_s

2010-10-27 Thread Kalle Valo
Here are two simple patches to remove disconnected networks from
wpasupplicant. I had few patches on top of master branch, but rebasing to
master should be easy.

Please comment.

Kalle Valo (2):
  gsupplicant: store network path
  gsupplicant: remove network from wpa_s when disconnecting

 gsupplicant/supplicant.c |   69 --
 1 files changed, 60 insertions(+), 9 deletions(-)

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH] Fix string array memory leaks during plugin loading

2010-10-27 Thread johan . hedberg
From: Johan Hedberg johan.hedb...@nokia.com

---
 src/plugin.c |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/src/plugin.c b/src/plugin.c
index 6aa8278..fa861ec 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -190,6 +190,9 @@ int __connman_plugin_init(const char *pattern, const char 
*exclude)
plugin-active = TRUE;
}
 
+   g_strfreev(patterns);
+   g_strfreev(excludes);
+
return 0;
 }
 
-- 
1.7.1

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 2/5] Support chunk encoding in http response body.

2010-10-27 Thread mabbas
From: Mohamed Abbas mab...@linux.intel.com

Add support to handle chunk encoding in response data.
---
 gweb/gweb.c |  152 +++
 1 files changed, 152 insertions(+), 0 deletions(-)

diff --git a/gweb/gweb.c b/gweb/gweb.c
index 6280c89..eea6276 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -37,6 +37,18 @@
 
 #define WEB_FLAG_HEADER_READY  (0x1)
 #define WEB_FLAG_DOWNLOAD_DONE (0x2)
+#define WEB_FLAG_USE_CHUNK (0x4)
+
+#define MAX_CHUNK_LEN  17
+
+enum chunk_state {
+   CHUNK_SIZE,
+   CHUNK_R,
+   CHUNK_R_BODY,
+   CHUNK_N,
+   CHUNK_N_BODY,
+   CHUNK_DATA,
+};
 
 struct web_session {
GWeb *web;
@@ -52,6 +64,10 @@ struct web_session {
guint resolv_action;
char *request;
 
+   enum chunk_state chunck_state;
+   int chunk_size;
+   int chunk_left;
+
GByteArray *line;
 
long int total_len;
@@ -222,9 +238,20 @@ gboolean g_web_add_nameserver(GWeb *web, const char 
*address)
return TRUE;
 }
 
+static void init_chunk_data(struct web_session *session)
+{
+   session-line-len = 0;
+
+   session-chunck_state = CHUNK_SIZE;
+   session-chunk_size = 0;
+   session-chunk_left = 0;
+}
+
 static void init_download_data(struct web_session *session)
 {
 
+   init_chunk_data(session);
+
session-http_status = 0;
session-total_len = 0;
session-content_len = -1;
@@ -240,6 +267,15 @@ static int append_to_line(struct web_session *session,
return 0;
 }
 
+static int append_to_chunk_size(struct web_session *session,
+   unsigned char *buf, int len)
+{
+   if ((session-line-len + len) = MAX_CHUNK_LEN)
+   return -EXFULL;
+
+   return append_to_line(session, buf, len);
+}
+
 static gboolean send_client_payload(struct web_session *session,
unsigned char *buf, int len)
 {
@@ -261,10 +297,113 @@ static gboolean send_client_header_line(struct 
web_session *session,
return TRUE;
 }
 
+static int decode_chunked(struct web_session *session,
+   unsigned char *buf, int len)
+{
+   int counter;
+   int err;
+
+   while (len  0) {
+   switch (session-chunck_state) {
+   case CHUNK_SIZE:
+   if (g_ascii_isxdigit(*buf) == TRUE) {
+   err = append_to_chunk_size(session, buf, 1);
+   if (err  0)
+   return err;
+   } else {
+   char *end = NULL;
+
+   g_byte_array_append(session-line,
+   (unsigned char *)\0, 1);
+   counter = strtol((char *)session-line-data,
+   end, 16);
+   if (end == NULL)
+   return -EILSEQ;
+
+   session-chunk_size = counter;
+   session-chunk_left = counter;
+
+   session-chunck_state = CHUNK_R;
+   break;
+   }
+   buf++;
+   len--;
+   break;
+   case CHUNK_R:
+   case CHUNK_R_BODY:
+   if (*buf == ' ') {
+   buf++;
+   len--;
+   break;
+   }
+
+   if (*buf != '\r')
+   return -EILSEQ;
+
+   if (session-chunck_state == CHUNK_R)
+   session-chunck_state = CHUNK_N;
+   else
+   session-chunck_state = CHUNK_N_BODY;
+   buf++;
+   len--;
+   break;
+   case CHUNK_N:
+   case CHUNK_N_BODY:
+   if (*buf != '\n')
+   return -EILSEQ;
+
+   if (session-chunck_state == CHUNK_N)
+   session-chunck_state = CHUNK_DATA;
+   else
+   session-chunck_state = CHUNK_SIZE;
+   buf++;
+   len--;
+   break;
+   case CHUNK_DATA:
+   if (session-chunk_size == 0) {
+   set_flag(session, WEB_FLAG_DOWNLOAD_DONE);
+   debug(session-web, Download Done in chunk);
+   return 0;
+   }
+
+   if (session-chunk_left = len) {
+   if (send_client_payload(session, buf,
+   

[PATCH 1/5] Extract content from HTTP response basic.

2010-10-27 Thread mabbas
From: Mohamed Abbas mab...@linux.intel.com

Add basic http response parsing, iclude header and basic body.
It also add user to receive notification on header line and
body arrival.
---
 gweb/gweb.c |  208 ++-
 1 files changed, 206 insertions(+), 2 deletions(-)

diff --git a/gweb/gweb.c b/gweb/gweb.c
index 39f8ecf..6280c89 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -35,6 +35,9 @@
 #include gresolv.h
 #include gweb.h
 
+#define WEB_FLAG_HEADER_READY  (0x1)
+#define WEB_FLAG_DOWNLOAD_DONE (0x2)
+
 struct web_session {
GWeb *web;
 
@@ -49,6 +52,13 @@ struct web_session {
guint resolv_action;
char *request;
 
+   GByteArray *line;
+
+   long int total_len;
+   long int content_len;
+   size_t http_status;
+
+   GWebReceivedFunc received_func;
GWebResultFunc result_func;
gpointer result_data;
 };
@@ -58,6 +68,7 @@ struct _GWeb {
 
guint next_query_id;
 
+   gboolean send_header;
int index;
GList *session_list;
 
@@ -67,6 +78,19 @@ struct _GWeb {
gpointer debug_data;
 };
 
+static inline void set_flag(struct web_session *session, unsigned long bit)
+{
+   session-flags |= bit;
+}
+
+static gboolean is_set(struct web_session *session, unsigned long bit)
+{
+   if (session-flags  bit)
+   return TRUE;
+
+   return FALSE;
+}
+
 static inline void debug(GWeb *web, const char *format, ...)
 {
char str[256];
@@ -101,6 +125,7 @@ static void free_session(struct web_session *session)
if (session-transport_channel != NULL)
g_io_channel_unref(session-transport_channel);
 
+   g_byte_array_free(session-line, TRUE);
g_free(session-host);
g_free(session-address);
g_free(session);
@@ -170,6 +195,12 @@ void g_web_unref(GWeb *web)
g_free(web);
 }
 
+void g_web_allow_header(GWeb *web, gboolean allow)
+{
+
+   web-send_header = allow;
+}
+
 void g_web_set_debug(GWeb *web, GWebDebugFunc func, gpointer user_data)
 {
if (web == NULL)
@@ -191,12 +222,163 @@ gboolean g_web_add_nameserver(GWeb *web, const char 
*address)
return TRUE;
 }
 
+static void init_download_data(struct web_session *session)
+{
+
+   session-http_status = 0;
+   session-total_len = 0;
+   session-content_len = -1;
+
+   session-flags = 0;
+}
+
+static int append_to_line(struct web_session *session,
+   unsigned char *buf, int len)
+{
+   g_byte_array_append(session-line, buf, len);
+
+   return 0;
+}
+
+static gboolean send_client_payload(struct web_session *session,
+   unsigned char *buf, int len)
+{
+   if (session-received_func != NULL)
+   return session-received_func(buf, len, G_WEB_DATA_BODY,
+   session-result_data);
+
+   return TRUE;
+}
+
+static gboolean send_client_header_line(struct web_session *session,
+   unsigned char *buf, int len)
+{
+   if (session-web-send_header == TRUE 
+   session-received_func != NULL)
+   return session-received_func(buf, len, G_WEB_DATA_HEADER,
+   session-result_data);
+
+   return TRUE;
+}
+
+static int decode_header(struct web_session *session,
+   unsigned char *buf, int len)
+{
+   unsigned char *ptr, *end_line;
+   int line_len;
+   int err;
+
+   ptr = buf;
+   while (len  0) {
+   end_line = memchr(ptr, '\n', len);
+   if (end_line == NULL) {
+   if (append_to_line(session, ptr, len)  0)
+   return -EXFULL;
+   return 0;
+   }
+
+   line_len = end_line - ptr;
+   line_len += 1;
+
+   if (append_to_line(session, ptr, line_len)  0)
+   return -EXFULL;
+
+   if (send_client_header_line(session, session-line-data,
+   len) == FALSE)
+   return -1;
+
+   /* we have full header line append \0 and process line */
+   g_byte_array_append(session-line, (unsigned char *)\0, 1);
+
+   if (session-line-data[0] == '\r' ||
+   session-line-data[0] == '\n') {
+   /* empty line http header is done */
+   session-line-len = 0;
+
+   set_flag(session, WEB_FLAG_HEADER_READY);
+   debug(session-web, content len:%lu http status%lu,
+   session-content_len,
+   session-http_status);
+
+   if (session-http_status != 0)
+   return 

[PATCH 3/5] Change header files to support gweb.

2010-10-27 Thread mabbas
From: Mohamed Abbas mab...@linux.intel.com

Add new API to support http download.
---
 gweb/gweb.h |   12 
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/gweb/gweb.h b/gweb/gweb.h
index 1ab2a9f..61e488c 100644
--- a/gweb/gweb.h
+++ b/gweb/gweb.h
@@ -38,10 +38,19 @@ typedef enum {
G_WEB_METHOD_GET,
 } GWebMethod;
 
+typedef enum {
+   G_WEB_DATA_HEADER,
+   G_WEB_DATA_BODY,
+} GWebDataType;
+
 typedef void (*GWebResultFunc)(uint16_t status, gpointer user_data);
 
 typedef void (*GWebDebugFunc)(const char *str, gpointer user_data);
 
+typedef gboolean (*GWebReceivedFunc)(const guint8 *str, int len,
+   GWebDataType data_type,
+   gpointer user_data);
+
 GWeb *g_web_new(int index);
 
 GWeb *g_web_ref(GWeb *web);
@@ -51,7 +60,10 @@ void g_web_set_debug(GWeb *web, GWebDebugFunc func, gpointer 
user_data);
 
 gboolean g_web_add_nameserver(GWeb *web, const char *address);
 
+void g_web_allow_header(GWeb *web, gboolean allow);
+
 guint g_web_request(GWeb *web, GWebMethod method, const char *url,
+   GWebReceivedFunc rec_func,
GWebResultFunc func, gpointer user_data);
 
 gboolean g_web_cancel(GWeb *web, guint id);
-- 
1.7.2.3

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 4/5] Add support new gweb in web_test.

2010-10-27 Thread mabbas
From: Mohamed Abbas mab...@linux.intel.com

Support new GWeb format.
---
 tools/web-test.c |   21 -
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/tools/web-test.c b/tools/web-test.c
index 253948f..3f88a2d 100644
--- a/tools/web-test.c
+++ b/tools/web-test.c
@@ -34,6 +34,8 @@ static GTimer *timer;
 
 static GMainLoop *main_loop;
 
+static GString *content;
+
 static void web_debug(const char *str, void *data)
 {
g_print(%s: %s\n, (const char *) data, str);
@@ -50,6 +52,7 @@ static void web_result(uint16_t status, gpointer user_data)
 
elapsed = g_timer_elapsed(timer, NULL);
 
+   g_print(%s, content-str);
g_print(elapse: %f seconds\n, elapsed);
 
g_print(status: %03u\n, status);
@@ -57,6 +60,14 @@ static void web_result(uint16_t status, gpointer user_data)
g_main_loop_quit(main_loop);
 }
 
+static gboolean received_data(const unsigned char *str, int len,
+   GWebDataType data_type,
+   gpointer user_data)
+{
+   g_string_append_len(content, (gchar *)str, len);
+   return TRUE;
+}
+
 static gboolean option_debug = FALSE;
 static gchar *option_nameserver = NULL;
 
@@ -95,6 +106,12 @@ int main(int argc, char *argv[])
return 1;
}
 
+   content = g_string_sized_new(1024);
+   if (content == NULL) {
+   printf(failed to allocate buf\n);
+   return 1;
+   }
+
web = g_web_new(index);
if (web == NULL) {
printf(failed to web service\n);
@@ -114,7 +131,7 @@ int main(int argc, char *argv[])
timer = g_timer_new();
 
if (g_web_request(web, G_WEB_METHOD_GET, argv[1],
-   web_result, NULL) == 0) {
+   received_data, web_result, NULL) == 0) {
printf(failed to start request\n);
return 1;
}
@@ -130,6 +147,8 @@ int main(int argc, char *argv[])
 
g_web_unref(web);
 
+   g_string_free(content, TRUE);
+
g_main_loop_unref(main_loop);
 
return 0;
-- 
1.7.2.3

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


[PATCH 5/5] Add proxy API support.

2010-10-27 Thread mabbas
From: Mohamed Abbas mab...@linux.intel.com

Add the API needed to support proxy when request a page.
---
 gweb/gweb.c  |5 -
 gweb/gweb.h  |2 +-
 tools/web-test.c |2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gweb/gweb.c b/gweb/gweb.c
index eea6276..004f33a 100644
--- a/gweb/gweb.c
+++ b/gweb/gweb.c
@@ -159,13 +159,16 @@ static void flush_sessions(GWeb *web)
web-session_list = NULL;
 }
 
-GWeb *g_web_new(int index)
+GWeb *g_web_new(int index, const char *proxy)
 {
GWeb *web;
 
if (index  0)
return NULL;
 
+   if (proxy != NULL)
+   return NULL;
+
web = g_try_new0(GWeb, 1);
if (web == NULL)
return NULL;
diff --git a/gweb/gweb.h b/gweb/gweb.h
index 61e488c..ada1434 100644
--- a/gweb/gweb.h
+++ b/gweb/gweb.h
@@ -51,7 +51,7 @@ typedef gboolean (*GWebReceivedFunc)(const guint8 *str, int 
len,
GWebDataType data_type,
gpointer user_data);
 
-GWeb *g_web_new(int index);
+GWeb *g_web_new(int index, const char *proxy);
 
 GWeb *g_web_ref(GWeb *web);
 void g_web_unref(GWeb *web);
diff --git a/tools/web-test.c b/tools/web-test.c
index 3f88a2d..2a7409b 100644
--- a/tools/web-test.c
+++ b/tools/web-test.c
@@ -112,7 +112,7 @@ int main(int argc, char *argv[])
return 1;
}
 
-   web = g_web_new(index);
+   web = g_web_new(index, NULL);
if (web == NULL) {
printf(failed to web service\n);
return 1;
-- 
1.7.2.3

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 1/1] Fix deadlock when disassociate while associating.

2010-10-27 Thread Kalle Valo
Hi Mohamed,

Mohamed Abbas mohamed.ab...@intel.com writes:

 while associating then the user disconnect the network this will
 cause the following:
 1- __connman_service_disconnect() which will call
 2-__connman_network_disconnect() which call
 3 err = network-driver-disconnect(network); 
 4-connman_network_set_connected(network, FALSE);

I noticed this patch breaks the first automatic connection to a wifi
network when connman is started. The wpa_s connects to the AP but dhcp
client is not run.

-- 
Kalle Valo
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH 1/1] Fix deadlock when disassociate while associating.

2010-10-27 Thread mohamed abbas
Hi Kalle

On Thu, 2010-10-28 at 00:39 +0300, Kalle Valo wrote:
 Hi Mohamed,
 
 Mohamed Abbas mohamed.ab...@intel.com writes:
 
  while associating then the user disconnect the network this will
  cause the following:
  1- __connman_service_disconnect() which will call
  2-  __connman_network_disconnect() which call
  3   err = network-driver-disconnect(network); 
  4-  connman_network_set_connected(network, FALSE);
 
 I noticed this patch breaks the first automatic connection to a wifi
 network when connman is started. The wpa_s connects to the AP but dhcp
 client is not run.
 
I just resend this patch with some changes can you check it out.
Mohamed

___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman


Re: [PATCH] Fix string array memory leaks during plugin loading

2010-10-27 Thread Samuel Ortiz
Hi Johan,

On Wed, Oct 27, 2010 at 04:23:10PM -0400, johan.hedb...@gmail.com wrote:
 From: Johan Hedberg johan.hedb...@nokia.com
Patch applied, thanks for spotting that.

Cheers,
Samuel.


 ---
  src/plugin.c |3 +++
  1 files changed, 3 insertions(+), 0 deletions(-)
 
 diff --git a/src/plugin.c b/src/plugin.c
 index 6aa8278..fa861ec 100644
 --- a/src/plugin.c
 +++ b/src/plugin.c
 @@ -190,6 +190,9 @@ int __connman_plugin_init(const char *pattern, const char 
 *exclude)
   plugin-active = TRUE;
   }
  
 + g_strfreev(patterns);
 + g_strfreev(excludes);
 +
   return 0;
  }
  
 -- 
 1.7.1
 
 ___
 connman mailing list
 connman@connman.net
 http://lists.connman.net/listinfo/connman

-- 
Intel Open Source Technology Centre
http://oss.intel.com/
___
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman