Re: [PATCH 1/5] gsupplicant: Add an helper to know if a peer is connected as client or not

2014-08-01 Thread leonew

Hi Tomasz,

I met a wifi direct issue when use latest connman.

I'm not sure whether I catch your point, if I'm wrong , please correct 
me, thanks:-)


This patch seem that connman will use peer's */Group/* member to check 
whether local side is GC.
and peer's group will updata when peer property changed, and it may come 
after group started signal arrival,

so here will get a wrong role. you can find it in attached log.

In my case, local side is GC, but connman start a dhcp server :(

On 07/17/2014 07:00 PM, Tomasz Bursztyka wrote:

+bool g_supplicant_peer_is_client(GSupplicantPeer *peer)
+{
+   GSupplicantGroup *group;
+   GSList *list;
+
+   if (!peer)
+   return false;
+
+   for (list = peer-groups; list; list = list-next) {
+   group = list-data;
+

Whether we need consider the case peer-groups= NULL?

+   if (group-role != G_SUPPLICANT_GROUP_ROLE_CLIENT ||
+   group-orig_interface != peer-interface)
+   continue;
+
+   if (group-interface == peer-current_group_iface)
+   return true;
+   }
+
+   return false;
+}
+


connmand[4448]: gsupplicant/supplicant.c:signal_group_started() 
connmand[4448]: plugins/wifi.c:peer_changed() ident: 2208eddaee3e
connmand[4448]: plugins/wifi.c:peer_changed() name: HUAWEI, state 1
connmand[4448]: src/peer.c:connman_peer_unref_debug() 0x8bfc250 ref 1 by plugins/wifi.c:200:peer_cancel_timeout()
connmand[4448]: gsupplicant/supplicant.c:g_supplicant_peer_is_client() peer 0x8c02570
connmand[4448]: gsupplicant/supplicant.c:g_supplicant_peer_is_client() peer-groups (nil)
connmand[4448]: plugins/wifi.c:peer_changed() local side client 0
connmand[4448]: gsupplicant/supplicant.c:g_supplicant_peer_is_client() peer 0x8c02570
connmand[4448]: gsupplicant/supplicant.c:g_supplicant_peer_is_client() peer-groups (nil)
connmand[4448]: src/peer.c:start_dhcp_server() 
connmand[4448]: src/ippool.c:__connman_ippool_create() 
connmand[4448]: src/inet.c:__connman_inet_modify_address() cmd 0x14 flags 0x104 index 3 family 2 address 192.168.0.1 peer (null) prefixlen 24 broadcast 192.168.0.255
connmand[4448]: Peer DHCP server: option_code 1 option_value 255.255.255.0
connmand[4448]: Peer DHCP server: option_code 3 option_value 192.168.0.1
connmand[4448]: src/peer.c:connman_peer_ref_debug() 0x8bfc250 ref 2 by src/peer.c:143:start_dhcp_server()
connmand[4448]: src/rtnl.c:rtnl_message() buf 0xbffa42d0 len 60
connmand[4448]: src/rtnl.c:rtnl_message() NEWADDR len 60 type 20 flags 0x seq 1 pid -4737
connmand[4448]: src/ipconfig.c:__connman_ipconfig_newaddr() index 3
connmand[4448]: wlan0 {add} address 192.168.0.1/24 label wlan0 family 2
connmand[4448]: src/rtnl.c:rtnl_message() buf 0xbffa42d0 len 60
connmand[4448]: src/rtnl.c:rtnl_message() NEWROUTE len 60 type 24 flags 0x seq 0 pid 0
connmand[4448]: src/rtnl.c:rtnl_message() buf 0xbffa42d0 len 60
connmand[4448]: src/rtnl.c:rtnl_message() NEWROUTE len 60 type 24 flags 0x seq 0 pid 0
connmand[4448]: src/rtnl.c:rtnl_message() buf 0xbffa42d0 len 60
connmand[4448]: src/rtnl.c:rtnl_message() NEWROUTE len 60 type 24 flags 0x seq 0 pid 0
connmand[4448]: src/ipconfig.c:__connman_ipconfig_newroute() index 3
connmand[4448]: wlan0 {add} route 192.168.0.0 gw 0.0.0.0 scope 253 LINK
connmand[4448]: src/rtnl.c:rtnl_message() buf 0xbffa42d0 len 60
connmand[4448]: src/rtnl.c:rtnl_message() NEWROUTE len 60 type 24 flags 0x seq 0 pid 0
connmand[4448]: gsupplicant/supplicant.c:signal_interface_changed() 
connmand[4448]: gsupplicant/supplicant.c:interface_property() State
connmand[4448]: plugins/wifi.c:interface_state() wifi 0x8bf0468 interface state 10
connmand[4448]: gsupplicant/supplicant.c:interface_property() state completed (10)
connmand[4448]: gsupplicant/supplicant.c:interface_property() CurrentAuthMode
connmand[4448]: gsupplicant/supplicant.c:interface_property() key CurrentAuthMode type s
connmand[4448]: gsupplicant/supplicant.c:signal_peer_changed() 
connmand[4448]: gsupplicant/supplicant.c:peer_property() key: Groups
connmand[4448]: gsupplicant/supplicant.c:peer_property() key: Groups
connmand[4448]: gsupplicant/supplicant.c:peer_property() key: Groups, signal ao
connmand[4448]: gsupplicant/supplicant.c:peer_property() 97
connmand[4448]: gsupplicant/supplicant.c:peer_groups_relation() 
connmand[4448]: gsupplicant/supplicant.c:peer_groups_relation() str: /fi/w1/wpa_supplicant1/Interfaces/1/Groups/SE
connmand[4448]: gsupplicant/supplicant.c:peer_groups_relation() group: 0x8bf6720
connmand[4448]: gsupplicant/supplicant.c:peer_groups_relation() peer-group: 0x8bff3e0

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

Re: [PATCH 1/5] gsupplicant: Add an helper to know if a peer is connected as client or not

2014-08-01 Thread Tomasz Bursztyka

Hi,



I met a wifi direct issue when use latest connman.

I'm not sure whether I catch your point, if I'm wrong , please correct 
me, thanks:-)


This patch seem that connman will use peer's */Group/* member to check 
whether local side is GC.
and peer's group will updata when peer property changed, and it may 
come after group started signal arrival,

so here will get a wrong role. you can find it in attached log.

In my case, local side is GC, but connman start a dhcp server :(



Yep, looks like I broke something in my latest patch-set, and the 
gsupplicant logic is wrong...

What was working before on GC context is no longer valid.

I'll fix this right away

Thanks for the report!

Tomasz

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


[PATCH 1/5] gsupplicant: Add an helper to know if a peer is connected as client or not

2014-07-17 Thread Tomasz Bursztyka
This is will be useful for wifi plugin and peer core code to run dhcp as
a client or as a server.
---
 gsupplicant/gsupplicant.h |  1 +
 gsupplicant/supplicant.c  | 22 ++
 2 files changed, 23 insertions(+)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 82c9bc6..387a3aa 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -296,6 +296,7 @@ bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer);
 bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer);
 bool g_supplicant_peer_is_in_a_group(GSupplicantPeer *peer);
 GSupplicantInterface *g_supplicant_peer_get_group_interface(GSupplicantPeer 
*peer);
+bool g_supplicant_peer_is_client(GSupplicantPeer *peer);
 
 struct _GSupplicantCallbacks {
void (*system_ready) (void);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 8324cc2..c6342d5 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -1098,6 +1098,28 @@ GSupplicantInterface 
*g_supplicant_peer_get_group_interface(GSupplicantPeer *pee
return (GSupplicantInterface *) peer-current_group_iface;
 }
 
+bool g_supplicant_peer_is_client(GSupplicantPeer *peer)
+{
+   GSupplicantGroup *group;
+   GSList *list;
+
+   if (!peer)
+   return false;
+
+   for (list = peer-groups; list; list = list-next) {
+   group = list-data;
+
+   if (group-role != G_SUPPLICANT_GROUP_ROLE_CLIENT ||
+   group-orig_interface != peer-interface)
+   continue;
+
+   if (group-interface == peer-current_group_iface)
+   return true;
+   }
+
+   return false;
+}
+
 static void merge_network(GSupplicantNetwork *network)
 {
GString *str;
-- 
1.8.5.5

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


[PATCH 1/5] gsupplicant: Add an helper to know if a peer is connected as client or not

2014-07-16 Thread Tomasz Bursztyka
This is will be useful for wifi plugin and peer core code to run dhcp as
a client or as a server.
---
 gsupplicant/gsupplicant.h |  1 +
 gsupplicant/supplicant.c  | 22 ++
 2 files changed, 23 insertions(+)

diff --git a/gsupplicant/gsupplicant.h b/gsupplicant/gsupplicant.h
index 82c9bc6..387a3aa 100644
--- a/gsupplicant/gsupplicant.h
+++ b/gsupplicant/gsupplicant.h
@@ -296,6 +296,7 @@ bool g_supplicant_peer_is_wps_pbc(GSupplicantPeer *peer);
 bool g_supplicant_peer_is_wps_pin(GSupplicantPeer *peer);
 bool g_supplicant_peer_is_in_a_group(GSupplicantPeer *peer);
 GSupplicantInterface *g_supplicant_peer_get_group_interface(GSupplicantPeer 
*peer);
+bool g_supplicant_peer_is_client(GSupplicantPeer *peer);
 
 struct _GSupplicantCallbacks {
void (*system_ready) (void);
diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 8324cc2..c6342d5 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -1098,6 +1098,28 @@ GSupplicantInterface 
*g_supplicant_peer_get_group_interface(GSupplicantPeer *pee
return (GSupplicantInterface *) peer-current_group_iface;
 }
 
+bool g_supplicant_peer_is_client(GSupplicantPeer *peer)
+{
+   GSupplicantGroup *group;
+   GSList *list;
+
+   if (!peer)
+   return false;
+
+   for (list = peer-groups; list; list = list-next) {
+   group = list-data;
+
+   if (group-role != G_SUPPLICANT_GROUP_ROLE_CLIENT ||
+   group-orig_interface != peer-interface)
+   continue;
+
+   if (group-interface == peer-current_group_iface)
+   return true;
+   }
+
+   return false;
+}
+
 static void merge_network(GSupplicantNetwork *network)
 {
GString *str;
-- 
1.8.5.5

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