Re: [PATCH 1/1]: Fix Memory-map and Double-free Errors in Statistics Handling (was Re: Connman-0.67 Crashes and/or Hangs on Start-up)
On 1/28/11 6:14 PM, Samuel Ortiz wrote: > On Fri, Jan 28, 2011 at 01:39:09PM -0800, Grant Erickson wrote: >> On Jan 28, 2011, at 12:10 PM, Grant Erickson wrote: >>> On Jan 28, 2011, at 10:09 AM, Grant Erickson wrote: On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: > On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: >> FYI. I need to check against GIT top-of-tree and dig into this further; >> however, with: >> >> * Wired Ethernet connected, connman-0.67 crashes on start-up >> * Wireless 802.11 WEXT, connman-0.67 hangs on start-up >> >> Backtrace with wired: > > Please give us a gdb backtrace or run test/backtrace src/connmand > where > log is the below trace. >> >> The following patch fixes the core dump / fault issue, of which there >> were/are two core problems: >> >> 1) Trying to memory map the statistics file on armv7l-linux-unknown-gnu with >> MAP_SHARED results in a result value from mmap of MAP_FAILED. Using >> MAP_PRIVATE works >>correctly. This primary failure causes the secondary failure that >> leads to the segment fault. >> > Why does this toolchain fail to build a SHARED mapping ? Samuel: Regrets about the last post, a premature send on the phone. The package builds without issue with the toolchain, Sourcery G++ 2010q1-202. Cited above, armv7l-linux-unknown-gnu is the platform, running Linux 2.6.32. As far as I can see, the stats mapping is not published or shared outside of connman. If so, there's no reason to map it SHARED versus PRIVATE. Best, Grant ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH 1/1]: Fix Memory-map and Double-free Errors in Statistics Handling (was Re: Connman-0.67 Crashes and/or Hangs on Start-up)
On Jan 28, 2011, at 6:14 PM, Samuel Ortiz wrote: > On Fri, Jan 28, 2011 at 01:39:09PM -0800, Grant Erickson wrote: >> On Jan 28, 2011, at 12:10 PM, Grant Erickson wrote: >>> On Jan 28, 2011, at 10:09 AM, Grant Erickson wrote: On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: > On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: >> FYI. I need to check against GIT top-of-tree and dig into this further; >> however, with: >> >>* Wired Ethernet connected, connman-0.67 crashes on start-up >>* Wireless 802.11 WEXT, connman-0.67 hangs on start-up >> >> Backtrace with wired: > > Please give us a gdb backtrace or run test/backtrace src/connmand > where > log is the below trace. >> >> The following patch fixes the core dump / fault issue, of which there >> were/are two core problems: >> >>1) Trying to memory map the statistics file on armv7l-linux-unknown-gnu >> with MAP_SHARED results in a result value from mmap of MAP_FAILED. Using >> MAP_PRIVATE works >> correctly. This primary failure causes the secondary failure that >> leads to the segment fault. >> > Why does this toolchain fail to build a SHARED mapping? That's the platform: Linux-2.6.32 > >>2) The function stats_free, called indirectly from >> g_hash_table_remove(stats_hash, service), g_free(file->name) ends up >> double-freeing file->name. It had already been >> earlier freed in stats_file_setup, following the failure of >> status_file_remap. >> > This part of the patch makes sense, I'll apply it. > > 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 1/1]: Fix Memory-map and Double-free Errors in Statistics Handling (was Re: Connman-0.67 Crashes and/or Hangs on Start-up)
Hi Grant, On Fri, Jan 28, 2011 at 01:39:09PM -0800, Grant Erickson wrote: > On Jan 28, 2011, at 12:10 PM, Grant Erickson wrote: > > On Jan 28, 2011, at 10:09 AM, Grant Erickson wrote: > >> On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: > >>> On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: > FYI. I need to check against GIT top-of-tree and dig into this further; > however, with: > > * Wired Ethernet connected, connman-0.67 crashes on start-up > * Wireless 802.11 WEXT, connman-0.67 hangs on start-up > > Backtrace with wired: > >>> > >>> Please give us a gdb backtrace or run test/backtrace src/connmand > >>> where > >>> log is the below trace. > > The following patch fixes the core dump / fault issue, of which there > were/are two core problems: > > 1) Trying to memory map the statistics file on armv7l-linux-unknown-gnu > with MAP_SHARED results in a result value from mmap of MAP_FAILED. Using > MAP_PRIVATE works >correctly. This primary failure causes the secondary failure that > leads to the segment fault. > Why does this toolchain fail to build a SHARED mapping ? > 2) The function stats_free, called indirectly from > g_hash_table_remove(stats_hash, service), g_free(file->name) ends up > double-freeing file->name. It had already been >earlier freed in stats_file_setup, following the failure of > status_file_remap. > This part of the patch makes sense, I'll apply it. Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: Connman-0.67 Crashes and/or Hangs on Start-up
Hi Grant, On Fri, Jan 28, 2011 at 02:52:36PM -0800, Grant Erickson wrote: > On Jan 28, 2011, at 10:09 AM, Grant Erickson wrote: > > On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: > >> On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: > >>> FYI. I need to check against GIT top-of-tree and dig into this further; > >>> however, with: > >>> > >>> * Wireless 802.11 WEXT, connman-0.67 hangs on start-up > >>> > >>> Backtrace with wired: > >> > >> Please give us a gdb backtrace or run test/backtrace src/connmand > >> where > >> log is the below trace. > >> > >> Also, a connman -d -n log would be more useful. > > Samuel: > > With the wired Ethernet issue debugged and patched, I've done more > investigation on the wireless issue. The results are as follows: > > -- > Version / Pluginwifi.so wifi_legacy.so > == > connman-0.67FAILS SUCCEEDS > -- > connman-b1db3cb FAILS N/A > == > > So, it would appear that the non-legacy wifi plugin has issues with wireless > extension devices. > I'm testing this with my iwlagn chipset forced to run in wext mode only and that seems to work fine. Would you mind sharing the output of wpa_supplicant -ddd -t -u when running connmand on top of it ? Also could you please show us what your wpa_supplicant .config look like ? Cheers, Samuel. -- Intel Open Source Technology Centre http://oss.intel.com/ ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: Connman-0.67 Crashes and/or Hangs on Start-up
On Jan 28, 2011, at 10:09 AM, Grant Erickson wrote: > On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: >> On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: >>> FYI. I need to check against GIT top-of-tree and dig into this further; >>> however, with: >>> >>> * Wireless 802.11 WEXT, connman-0.67 hangs on start-up >>> >>> Backtrace with wired: >> >> Please give us a gdb backtrace or run test/backtrace src/connmand where >> log is the below trace. >> >> Also, a connman -d -n log would be more useful. Samuel: With the wired Ethernet issue debugged and patched, I've done more investigation on the wireless issue. The results are as follows: -- Version / Pluginwifi.so wifi_legacy.so == connman-0.67FAILS SUCCEEDS -- connman-b1db3cb FAILS N/A == So, it would appear that the non-legacy wifi plugin has issues with wireless extension devices. Regards, Grant ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: connmand 0.67 crashing while processing timeserver option during S3 resume from standby
Setting domainname to croydon.local Setting hostname to revo Timeserver 192.168.0.9 Aborting (signal 11) backtrace [0]: /lib/libpthread.so.0(+0xeac0) [0x7ffbbef59ac0] [1]: /usr/lib/libglib-2.0.so.0(g_list_prepend+0x38) [0x7ffbbf2bc058] [2]: /usr/sbin/connmand() [0x420f72] [3]: /usr/sbin/connmand(connman_timeserver_append+0xba) [0x4350aa] [4]: /usr/sbin/connmand() [0x43c8a3] [5]: /usr/sbin/connmand(connman_element_register+0x108) [0x4265e8] [6]: /usr/sbin/connmand(connman_dhcp_bound+0x44) [0x432c14] [7]: /usr/sbin/connmand() [0x418d62] [8]: /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x245) [0x7ffbbf2c0495] [9]: /usr/lib/libglib-2.0.so.0(+0x3ea50) [0x7ffbbf2c0a50] [10]: /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x13a) [0x7ffbbf2c0f8a] [11]: /usr/sbin/connmand() [0x45361a] [12]: /lib/libc.so.6(__libc_start_main+0xfe) [0x7ffbbe7e5c7e] [13]: /usr/sbin/connmand() [0x40d169] +++ That backtrace managed to get itself all mangled, here it is again: Setting domainname to croydon.local Setting hostname to revo Timeserver 192.168.0.9 Aborting (signal 11) backtrace [0]: /lib/libpthread.so.0(+0xeac0) [0x7ffbbef59ac0] [1]: /usr/lib/libglib-2.0.so.0(g_list_prepend+0x38) [0x7ffbbf2bc058] [2]: /usr/sbin/connmand() [0x420f72] [3]: /usr/sbin/connmand(connman_timeserver_append+0xba) [0x4350aa] [4]: /usr/sbin/connmand() [0x43c8a3] [5]: /usr/sbin/connmand(connman_element_register+0x108) [0x4265e8] [6]: /usr/sbin/connmand(connman_dhcp_bound+0x44) [0x432c14] [7]: /usr/sbin/connmand() [0x418d62] [8]: /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x245) [0x7ffbbf2c0495] [9]: /usr/lib/libglib-2.0.so.0(+0x3ea50) [0x7ffbbf2c0a50] [10]: /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x13a) [0x7ffbbf2c0f8a] [11]: /usr/sbin/connmand() [0x45361a] [12]: /lib/libc.so.6(__libc_start_main+0xfe) [0x7ffbbe7e5c7e] [13]: /usr/sbin/connmand() [0x40d169] +++ Regards Neil ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
connmand 0.67 crashing while processing timeserver option during S3 resume from standby
Hi I'm running OpenELEC Beta 6 (an XBMC derivative, aimed at embedded media centre devices) on a Intel Atom D545/Ion2 based Revo3700. connmand 0.67 is generating a backtrace when the Revo resumes from S3 standby, this means there is no default gateway defined for internet access. I am running a DHCP server (dnsmasq) on an Ubuntu 10.10 server with IP address 192.168.0.9. dnsmasq specifies a local DNS (192.168.0.9), gateway (192.168.0.1) and also a local time server using "dhcp-option=42,0.0.0.0" (ie. NTP server on the same address running dnsmasq). connmand is generating a backtrace while processing this time server directive, but only when resuming from S3 standby. If this dhcp time server option is disabled in dnsmasq, connmand will configure the network correctly while resuming from standby. If connmand is run manually after it has failed during resume, it will also work successfully even when the time server directive is active in dnsmasq. The full log of a suspend, resume (inc. backtrace) and manual execution cycle is here: http://paste.pocoo.org/show/328475/ The backtrace is reproduced here in case the aforementioned log becomes unavailable: Setting domainname to croydon.local Setting hostname to revo Timeserver 192.168.0.9 Aborting (signal 11) backtrace [0]: /lib/libpthread.so.0(+0xeac0) [0x7ffbbef59ac0] [1]: /usr/lib/libglib-2.0.so.0(g_list_prepend+0x38) [0x7ffbbf2bc058] [2]: /usr/sbin/connmand() [0x420f72] [3]: /usr/sbin/connmand(connman_timeserver_append+0xba) [0x4350aa] [4]: /usr/sbin/connmand() [0x43c8a3] [5]: /usr/sbin/connmand(connman_element_register+0x108) [0x4265e8] [6]: /usr/sbin/connmand(connman_dhcp_bound+0x44) [0x432c14] [7]: /usr/sbin/connmand() [0x418d62] [8]: /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x245) [0x7ffbbf2c0495] [9]: /usr/lib/libglib-2.0.so.0(+0x3ea50) [0x7ffbbf2c0a50] [10]: /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x13a) [0x7ffbbf2c0f8a] [11]: /usr/sbin/connmand() [0x45361a] [12]: /lib/libc.so.6(__libc_start_main+0xfe) [0x7ffbbe7e5c7e] [13]: /usr/sbin/connmand() [0x40d169] +++ Is connmand "resume safe" when there is a local timeserver defined? It doesn't appear to be. Also, I'm only using IPv4. Many thanks Neil ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH 1/1]: Fix Memory-map and Double-free Errors in Statistics Handling (was Re: Connman-0.67 Crashes and/or Hangs on Start-up)
On Jan 28, 2011, at 12:10 PM, Grant Erickson wrote: > On Jan 28, 2011, at 10:09 AM, Grant Erickson wrote: >> On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: >>> On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: FYI. I need to check against GIT top-of-tree and dig into this further; however, with: * Wired Ethernet connected, connman-0.67 crashes on start-up * Wireless 802.11 WEXT, connman-0.67 hangs on start-up Backtrace with wired: >>> >>> Please give us a gdb backtrace or run test/backtrace src/connmand >>> where >>> log is the below trace. The following patch fixes the core dump / fault issue, of which there were/are two core problems: 1) Trying to memory map the statistics file on armv7l-linux-unknown-gnu with MAP_SHARED results in a result value from mmap of MAP_FAILED. Using MAP_PRIVATE works correctly. This primary failure causes the secondary failure that leads to the segment fault. 2) The function stats_free, called indirectly from g_hash_table_remove(stats_hash, service), g_free(file->name) ends up double-freeing file->name. It had already been earlier freed in stats_file_setup, following the failure of status_file_remap. diff -aruN a/src/stats.c b/src/stats.c --- a/src/stats.c 2011-01-28 13:20:49.248299633 -0800 +++ b/src/stats.c 2011-01-28 13:19:44.824306025 -0800 @@ -223,10 +223,18 @@ TFR(close(file->fd)); file->fd = -1; - if (file->history_name != NULL) + if (file->history_name != NULL) { g_free(file->history_name); - g_free(file->name); - g_free(file); + file->history_name = NULL; + } + + if (file->name != NULL) { + g_free(file->name); + file->name = NULL; + } + + if (file != NULL) + g_free(file); } static void update_first(struct stats_file *file) @@ -280,7 +288,7 @@ if (file->addr == NULL) { addr = mmap(NULL, new_size, PROT_READ | PROT_WRITE, - MAP_SHARED, file->fd, 0); + MAP_PRIVATE, file->fd, 0); } else { addr = mremap(file->addr, file->len, new_size, MREMAP_MAYMOVE); } Best regards, Grant ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: Connman-0.67 Crashes and/or Hangs on Start-up
On Jan 28, 2011, at 10:09 AM, Grant Erickson wrote: > On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: >> On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: >>> FYI. I need to check against GIT top-of-tree and dig into this further; >>> however, with: >>> >>> * Wired Ethernet connected, connman-0.67 crashes on start-up >>> * Wireless 802.11 WEXT, connman-0.67 hangs on start-up >>> >>> Backtrace with wired: >> >> Please give us a gdb backtrace or run test/backtrace src/connmand where >> log is the below trace. The wired Ethernet crash GDB backtrace: #0 0x4020e2ec in raise () from /lib/libc.so.6 #1 0x40213b04 in abort () from /lib/libc.so.6 #2 0x40247ee8 in __libc_message () from /lib/libc.so.6 #3 0x4025249c in malloc_printerr () from /lib/libc.so.6 #4 0x40257db8 in free () from /lib/libc.so.6 #5 0x4006ad28 in IA__g_free (mem=0x64950) at glib/glib-2.24.2/glib/gmem.c:191 #6 0x0003e684 in stats_free (user_data=) at connman/connman-b1db3cb/src/stats.c:227 #7 0x40052c10 in g_hash_table_remove_node (hash_table=0x5bc60, node=0x61110, notify=-1097179325) at glib/glib-2.24.2/glib/ghash.c:449 #8 0x40053f44 in g_hash_table_remove_internal (hash_table=0x5bc60, key=0x64758, notify=1) at glib/glib-2.24.2/glib/ghash.c:1095 #9 0x0003edd8 in __connman_stats_service_register (service=0x64758) at connman/connman-b1db3cb/src/stats.c:671 #10 0x000288a8 in __connman_service_indicate_state (service=0x64758, state=CONNMAN_SERVICE_STATE_CONFIGURATION) at connman/connman-b1db3cb/src/service.c:3097 #11 0x00021864 in set_connected_dhcp (user_data=) at connman/connman-b1db3cb/src/network.c:723 #12 set_connected (user_data=) at connman/connman-b1db3cb/src/network.c:811 #13 0x00021b94 in connman_network_set_connected (network=0x64380, connected=1) at connman/connman-b1db3cb/src/network.c:866 #14 0x40386450 in add_network (flags=69699, change=0, user_data=) at connman/connman-b1db3cb/plugins/ethernet.c:109 #15 ethernet_newlink (flags=69699, change=0, user_data=) at connman/connman-b1db3cb/plugins/ethernet.c:132 #16 0x00036d28 in connman_rtnl_add_newlink_watch (index=2, callback=0x40386320 , user_data=0x62c00) at connman/connman-b1db3cb/src/rtnl.c:249 #17 0x403862d4 in ethernet_probe (device=0x62c00) at connman/connman-b1db3cb/plugins/ethernet.c:157 #18 0x0001f4c0 in device_probe (element=) at connman/connman-b1db3cb/src/device.c:1212 #19 0x0001c2bc in probe_element (element=0x62c00) at connman/connman-b1db3cb/src/element.c:1011 #20 0x0001d9d8 in register_element (element=0x62c00, parent=) at connman/connman-b1db3cb/src/element.c:1050 #21 connman_element_register (element=0x62c00, parent=) at connman/connman-b1db3cb/src/element.c:1121 #22 0x000336a0 in detect_newlink (type=, index=, flags=, change=) at connman/connman-b1db3cb/src/detect.c:78 #23 0x00037478 in process_newlink (type=1, index=2, flags=69699, change=0, msg=0xbe9a5ba8, bytes=229188) at connman/connman-b1db3cb/src/rtnl.c:474 #24 0x00037f44 in rtnl_newlink (chan=, cond=, data=) at connman/connman-b1db3cb/src/rtnl.c:862 #25 rtnl_message (chan=, cond=, data=) at connman/connman-b1db3cb/src/rtnl.c:1302 #26 netlink_event (chan=, cond=, data=) at connman/connman-b1db3cb/src/rtnl.c:1353 #27 0x400aa5c0 in g_io_unix_dispatch (source=0x61480, callback=0x37924 , user_data=0x0) at glib/glib-2.24.2/glib/giounix.c:162 #28 0x40062a68 in g_main_dispatch (context=0x5c200) at glib/glib-2.24.2/glib/gmain.c:1960 #29 IA__g_main_context_dispatch (context=0x5c200) at glib/glib-2.24.2/glib/gmain.c:2513 #30 0x400660ec in g_main_context_iterate (context=0x5c200, block=, dispatch=, self=) at glib/glib-2.24.2/glib/gmain.c:2591 #31 0x4006669c in IA__g_main_loop_run (loop=0x5b9b8) at glib/glib-2.24.2/glib/gmain.c:2799 #32 0x0001a7e0 in main (argc=1, argv=0xbe9a5e64) at connman/connman-b1db3cb/src/main.c:247 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH 3/3 v3] Add implementation for internal proxy framework.
Add support to call registered proxy driver and report proxy to client. Also Make sure we cancel proxy request if we got disconnected and still waiting for proxy request. Also make sure we set/clear token correctly --- include/proxy.h |1 + plugins/portal.c | 27 +--- src/proxy.c | 114 +++--- 3 files changed, 129 insertions(+), 13 deletions(-) diff --git a/include/proxy.h b/include/proxy.h index 5dd0583..d4b2148 100644 --- a/include/proxy.h +++ b/include/proxy.h @@ -37,6 +37,7 @@ extern "C" { typedef void (*connman_proxy_lookup_cb) (const char *proxy, void *user_data); unsigned int connman_proxy_lookup(const char *interface, const char *url, + struct connman_service *service, connman_proxy_lookup_cb cb, void *user_data); void connman_proxy_lookup_cancel(unsigned int token); diff --git a/plugins/portal.c b/plugins/portal.c index 043caaf..f8dbc03 100644 --- a/plugins/portal.c +++ b/plugins/portal.c @@ -39,6 +39,7 @@ #define STATUS_URL "http://www.connman.net/online/status.html"; struct server_data { + unsigned int token; GWeb *web; guint request_id; }; @@ -105,10 +106,13 @@ static void proxy_callback(const char *proxy, void *user_data) proxy = getenv("http_proxy"); if (data != NULL) { - g_web_set_proxy(data->web, proxy); + if (proxy != NULL && g_strcmp0(proxy, "DIRECT") != 0) + g_web_set_proxy(data->web, proxy); data->request_id = g_web_request_get(data->web, STATUS_URL, web_result, location); + + data->token = 0; } connman_location_unref(location); @@ -117,6 +121,7 @@ static void proxy_callback(const char *proxy, void *user_data) static int location_detect(struct connman_location *location) { struct server_data *data; + struct connman_service *service; enum connman_service_type service_type; char *interface; int err; @@ -168,13 +173,16 @@ static int location_detect(struct connman_location *location) g_web_set_user_agent(data->web, "ConnMan/%s", VERSION); g_web_set_close_connection(data->web, TRUE); - err = connman_proxy_lookup(interface, STATUS_URL, - proxy_callback, location); - if (err < 0) - goto done; + service = connman_location_get_service(location); + data->token = connman_proxy_lookup(interface, STATUS_URL, + service, proxy_callback, location); - connman_location_ref(location); - err = 0; + if (data->token == 0) + err = -EINVAL; + else { + connman_location_ref(location); + err = 0; + } done: g_free(interface); @@ -192,6 +200,11 @@ static int location_finish(struct connman_location *location) if (data->request_id > 0) g_web_cancel_request(data->web, data->request_id); + if (data->token > 0) { + connman_proxy_lookup_cancel(data->token); + connman_location_unref(location); + } + g_web_unref(data->web); g_free(data); diff --git a/src/proxy.c b/src/proxy.c index f31e9f8..a83837b 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -30,30 +30,76 @@ static unsigned int next_lookup_token = 1; static GSList *driver_list = NULL; +static GSList *lookup_list = NULL; struct proxy_lookup { unsigned int token; connman_proxy_lookup_cb cb; void *user_data; + struct connman_service *service; + char *url; guint watch; + struct connman_proxy_driver *proxy; }; +static void remove_lookup(struct proxy_lookup *lookup) +{ + lookup_list = g_slist_remove(lookup_list, lookup); + + g_free(lookup->url); + g_free(lookup); +} + +static void remove_lookups(GSList *lookups) +{ + GSList *list; + + for (list = lookups; list; list = list->next) { + struct proxy_lookup *lookup = list->data; + + remove_lookup(lookup); + } + + g_slist_free(lookups); +} + static gboolean lookup_callback(gpointer user_data) { struct proxy_lookup *lookup = user_data; + GSList *list; + + if (lookup == NULL) + return FALSE; lookup->watch = 0; - if (lookup->cb) - lookup->cb(NULL, lookup->user_data); + for (list = driver_list; list; list = list->next) { + struct connman_proxy_driver *proxy = list->data; - g_free(lookup); + if (proxy->request_lookup == NULL) + continue; + + lookup->proxy = proxy; + break; + } + + if (lookup->proxy == NULL || + lookup->proxy->request_lookup(loo
[PATCH 2/3 v3] Add pacrunner proxy driver.
Register pacrunner proxy driver, add proxy driver functions and call pacrunner daemon to find proxy. --- include/proxy.h |4 ++ plugins/pacrunner.c | 147 +++ 2 files changed, 151 insertions(+), 0 deletions(-) diff --git a/include/proxy.h b/include/proxy.h index 61117a0..5dd0583 100644 --- a/include/proxy.h +++ b/include/proxy.h @@ -43,6 +43,10 @@ void connman_proxy_lookup_cancel(unsigned int token); void connman_proxy_driver_lookup_notify(struct connman_service *service, const char *url, const char *result); +#define CONNMAN_PROXY_PRIORITY_LOW -100 +#define CONNMAN_PROXY_PRIORITY_DEFAULT 0 +#define CONNMAN_PROXY_PRIORITY_HIGH 100 + struct connman_proxy_driver { const char *name; int priority; diff --git a/plugins/pacrunner.c b/plugins/pacrunner.c index 2d0a419..44ac3c1 100644 --- a/plugins/pacrunner.c +++ b/plugins/pacrunner.c @@ -24,6 +24,7 @@ #endif #include +#include #include @@ -32,13 +33,22 @@ #include #include #include +#include #define PACRUNNER_SERVICE "org.pacrunner" #define PACRUNNER_INTERFACE"org.pacrunner.Manager" #define PACRUNNER_PATH "/org/pacrunner/manager" +#define PACRUNNER_CLIENT_INTERFACE "org.pacrunner.Client" +#define PACRUNNER_CLIENT_PATH "/org/pacrunner/client" + #define DBUS_TIMEOUT 5000 +struct proxy_data { + struct connman_service *service; + char *url; +}; + static DBusConnection *connection; static dbus_bool_t daemon_running = FALSE; @@ -295,6 +305,139 @@ static void pacrunner_disconnect(DBusConnection *conn, void *user_data) current_config = NULL; } +static char * parse_url(const char *url) +{ + char *scheme, *host, *path, *host_ret; + + scheme = g_strdup(url); + if (scheme == NULL) + return NULL; + + if (host_ret == NULL) + return NULL; + + host = strstr(scheme, "://"); + if (host != NULL) { + *host = '\0'; + host += 3; + } else + host = scheme; + + path = strchr(host, '/'); + if (path != NULL) + *(path++) = '\0'; + + host_ret = g_strdup(host); + + g_free(scheme); + + return host_ret; +} + +static void request_lookup_reply(DBusPendingCall *call, void *user_data) +{ + DBusMessage *reply = dbus_pending_call_steal_reply(call); + struct proxy_data *data = user_data; + const char *proxy; + + DBG(""); + + if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { + connman_error("Failed to find URL:%s", data->url); + proxy = NULL; + goto done; + } + + if (dbus_message_get_args(reply, NULL, DBUS_TYPE_STRING, &proxy, + DBUS_TYPE_INVALID) == FALSE) + proxy = NULL; + +done: + connman_proxy_driver_lookup_notify(data->service, data->url, proxy); + + connman_service_unref(data->service); + + g_free(data->url); + g_free(data); + + dbus_message_unref(reply); +} + +static int request_lookup(struct connman_service *service, const char *url) +{ + DBusMessage *msg; + DBusPendingCall *call; + dbus_bool_t result; + char *host; + struct proxy_data *data; + + DBG(""); + + if (daemon_running == FALSE) + return -EINVAL; + + msg = dbus_message_new_method_call(PACRUNNER_SERVICE, + PACRUNNER_CLIENT_PATH, + PACRUNNER_CLIENT_INTERFACE, + "FindProxyForURL"); + if (msg == NULL) + return -1; + + host = parse_url(url); + if (host == NULL) { + dbus_message_unref(msg); + return -EINVAL; + } + + data = g_try_new0(struct proxy_data, 1); + if (data == NULL) { + dbus_message_unref(msg); + g_free(host); + return -ENOMEM; + } + + data->url = g_strdup(url); + data->service = connman_service_ref(service); + + dbus_message_set_auto_start(msg, FALSE); + + dbus_message_append_args(msg, DBUS_TYPE_STRING, &url, + DBUS_TYPE_STRING, &host, + DBUS_TYPE_INVALID); + + result = dbus_connection_send_with_reply(connection, msg, + &call, DBUS_TIMEOUT); + + dbus_message_unref(msg); + + if (result == FALSE || call == NULL) { + g_free(host); + g_free(data->url); + g_free(data); + return -EINVAL; + } + + dbus_pending_call_set_notify(call, request_lookup_reply, + data, NULL); + +
[PATCH 1/3 v3] allow to get the service for a location.
Add new function to return the service for a location. --- include/location.h |3 +++ src/location.c |5 + 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/include/location.h b/include/location.h index 662d8cd..e4efaaf 100644 --- a/include/location.h +++ b/include/location.h @@ -57,6 +57,9 @@ void connman_location_report_result(struct connman_location *location, void *connman_location_get_data(struct connman_location *location); void connman_location_set_data(struct connman_location *location, void *data); +struct connman_service *connman_location_get_service( + struct connman_location *location); + struct connman_location_driver { const char *name; enum connman_service_type type; diff --git a/src/location.c b/src/location.c index e7bfdc0..820011f 100644 --- a/src/location.c +++ b/src/location.c @@ -94,6 +94,11 @@ char *connman_location_get_interface(struct connman_location *location) return connman_service_get_interface(location->service); } +struct connman_service *connman_location_get_service( + struct connman_location *location) +{ + return location->service; +} /** * connman_location_get_data: * @location: Location structure -- 1.7.3.4 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: Connman-0.67 Crashes and/or Hangs on Start-up
On Jan 28, 2011, at 9:06 AM, Grant Erickson wrote: > FYI. I need to check against GIT top-of-tree and dig into this further; > however, with: > > * Wired Ethernet connected, connman-0.67 crashes on start-up > * Wireless 802.11 WEXT, connman-0.67 hangs on start-up Confirmed identical behavior with commit b1db3cb. Best, Grant ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: Connman-0.67 Crashes and/or Hangs on Start-up
On Jan 28, 2011, at 9:44 AM, Samuel Ortiz wrote: > On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: >> FYI. I need to check against GIT top-of-tree and dig into this further; >> however, with: >> >> * Wired Ethernet connected, connman-0.67 crashes on start-up >> * Wireless 802.11 WEXT, connman-0.67 hangs on start-up >> >> Backtrace with wired: > > Please give us a gdb backtrace or run test/backtrace src/connmand where > log is the below trace. > > Also, a connman -d -n log would be more useful. Samuel: First, the debug log for the Ethernet crash and wireless hang cases. Stay tuned for GDB back traces for each as well: Wired Ethernet crash: connmand[491]: Connection Manager version 0.67 connmand[491]: connman-0.67/src/storage.c:__connman_storage_init() connmand[491]: connman-0.67/src/element.c:__connman_element_init() connmand[491]: connman-0.67/src/element.c:connman_element_create() element 0x5ae20 connmand[491]: connman-0.67/src/element.c:__connman_element_initialize() element 0x5ae20 connmand[491]: connman-0.67/src/technology.c:__connman_technology_init() connmand[491]: connman-0.67/src/notifier.c:__connman_notifier_init() connmand[491]: connman-0.67/src/service.c:__connman_service_init() connmand[491]: connman-0.67/src/storage.c:connman_storage_register() storage 0x53fe0 name service connmand[491]: connman-0.67/src/provider.c:__connman_provider_init() connmand[491]: connman-0.67/src/notifier.c:connman_notifier_register() notifier 0x54114 name provider connmand[491]: connman-0.67/src/network.c:__connman_network_init() connmand[491]: connman-0.67/src/element.c:connman_driver_register() driver 0x53c88 name network connmand[491]: connman-0.67/src/device.c:__connman_device_init() connmand[491]: connman-0.67/src/storage.c:connman_storage_register() storage 0x53c5c name device connmand[491]: connman-0.67/src/element.c:connman_driver_register() driver 0x53c40 name device connmand[491]: connman-0.67/src/agent.c:__connman_agent_init() connmand[491]: connman-0.67/src/iptables.c:__connman_iptables_init() connmand[491]: connman-0.67/src/tethering.c:__connman_tethering_init() connmand[491]: connman-0.67/src/counter.c:__connman_counter_init() connmand[491]: connman-0.67/src/notifier.c:connman_notifier_register() notifier 0x54224 name ondemand connmand[491]: connman-0.67/src/manager.c:__connman_manager_init() connmand[491]: connman-0.67/src/notifier.c:connman_notifier_register() notifier 0x53cd8 name manager connmand[491]: connman-0.67/src/profile.c:__connman_profile_init() connmand[491]: connman-0.67/src/storage.c:connman_storage_register() storage 0x53f54 name profile connmand[491]: connman-0.67/src/config.c:__connman_config_init() connmand[491]: connman-0.67/src/config.c:read_configs() connmand[491]: connman-0.67/src/stats.c:__connman_stats_init() connmand[491]: connman-0.67/src/resolver.c:__connman_resolver_init() connmand[491]: connman-0.67/src/resolver.c:connman_resolver_register() resolver 0x5412c name resolvfile connmand[491]: connman-0.67/src/ipconfig.c:__connman_ipconfig_init() connmand[491]: connman-0.67/src/rtnl.c:__connman_rtnl_init() connmand[491]: connman-0.67/src/task.c:__connman_task_init() connmand[491]: connman-0.67/src/proxy.c:__connman_proxy_init() connmand[491]: connman-0.67/src/detect.c:__connman_detect_init() connmand[491]: connman-0.67/src/rtnl.c:connman_rtnl_register() rtnl 0x54140 name detect connmand[491]: connman-0.67/src/session.c:__connman_session_init() connmand[491]: connman-0.67/src/timeserver.c:__connman_timeserver_init() connmand[491]: connman-0.67/src/plugin.c:__connman_plugin_init() connmand[491]: Checking loopback interface settings connmand[491]: System hostname is salmon.local connmand[491]: connman-0.67/src/utsname.c:connman_utsname_driver_register() driver 0x403a2340 name loopback connmand[491]: connman-0.67/src/network.c:connman_network_driver_register() driver 0x403acd4c name cable connmand[491]: connman-0.67/src/device.c:connman_device_driver_register() driver 0x403acd6c name ethernet connmand[491]: connman-0.67/src/element.c:__connman_element_foreach() connmand[491]: connman-0.67/src/element.c:foreach_callback() element 0x5ae20 name root connmand[491]: connman-0.67/src/technology.c:connman_technology_driver_register() driver 0x403acd28 name cdc_ethernet connmand[491]: connman-0.67/src/timeserver.c:connman_timeserver_driver_register() driver 0x40398658 name ntpd connmand[491]: connman-0.67/src/network.c:connman_network_driver_register() driver 0x4038e400 name wifi connmand[491]: connman-0.67/src/technology.c:connman_technology_driver_register() driver 0x4038e3dc name wifi connmand[491]: connman-0.67/src/resolver.c:connman_resolver_append() interface lo domain (null) server 127.0.0.1 connmand[491]: connman-0.67/src/resolver.c:append_resolver() interface lo domain (null) server 127.0.0.1 lifetime 0 flags 0 connmand[491]: connman-0.67/src/resolver.c:resolvfile_append() interface lo server
Re: Connman-0.67 Crashes and/or Hangs on Start-up
Hi Grant, On Fri, Jan 28, 2011 at 09:06:12AM -0800, Grant Erickson wrote: > FYI. I need to check against GIT top-of-tree and dig into this further; > however, with: > > * Wired Ethernet connected, connman-0.67 crashes on start-up > * Wireless 802.11 WEXT, connman-0.67 hangs on start-up > > Backtrace with wired: Please give us a gdb backtrace or run test/backtrace src/connmand where log is the below trace. Also, a connman -d -n log would be more useful. Cheers, Samuel. > root@10784311-00016.local# /usr/sbin/connmand -n > connmand[444]: Connection Manager version 0.67 > connmand[444]: Checking loopback interface settings > connmand[444]: System hostname is salmon.local > connmand[444]: Adding profile default > connmand[444]: Failed to open RFKILL control device > connmand[444]: lo {newlink} index 1 operstate 0 > connmand[444]: eth0 {create} index 2 type 1 > connmand[444]: eth0 {RX} 431 packets 60468 bytes > connmand[444]: eth0 {TX} 61 packets 7521 bytes > connmand[444]: eth0 {update} flags 69699 > connmand[444]: eth0 {newlink} index 2 address 00:0c:29:4c:56:a2 mtu 1500 > connmand[444]: eth0 {newlink} index 2 operstate 6 > connmand[444]: Create interface eth0 [ ethernet ] > connmand[444]: mmap error Invalid argument for > /var/lib/connman/stats/ethernet_000c294c56a2_cable.data > *** glibc detected *** /usr/sbin/connmand: double free or corruption > (fasttop): 0x00062a80 *** > === Backtrace: = > /lib/libc.so.6(+0x7049c)[0x4025249c] > /lib/libc.so.6(cfree+0x98)[0x40257db8] > /lib/libglib-2.0.so.0(g_free+0x44)[0x4006ad28] > /usr/sbin/connmand[0x3e594] > /lib/libglib-2.0.so.0(+0x2ac10)[0x40052c10] > /lib/libglib-2.0.so.0(+0x2bf44)[0x40053f44] > /usr/sbin/connmand[0x3ece8] > /usr/sbin/connmand[0x2972c] > /usr/sbin/connmand[0x21dc4] > /usr/sbin/connmand(connman_network_set_connected+0x5c)[0x220f4] > /usr/lib/connman/plugins/ethernet.so(+0x1450)[0x403a4450] > /usr/sbin/connmand(connman_rtnl_add_newlink_watch+0xa4)[0x36ba4] > /usr/lib/connman/plugins/ethernet.so(+0x12d4)[0x403a42d4] > /usr/sbin/connmand[0x1fae8] > /usr/sbin/connmand[0x1c908] > /usr/sbin/connmand(connman_element_register+0xe8)[0x1e024] > /usr/sbin/connmand[0x337ac] > /usr/sbin/connmand[0x372f4] > /usr/sbin/connmand[0x37dc0] > /lib/libglib-2.0.so.0(+0x825c0)[0x400aa5c0] > /lib/libglib-2.0.so.0(g_main_context_dispatch+0x1ec)[0x40062a68] > /lib/libglib-2.0.so.0(+0x3e0ec)[0x400660ec] > /lib/libglib-2.0.so.0(g_main_loop_run+0x174)[0x4006669c] > /usr/sbin/connmand[0x1add4] > /lib/libc.so.6(__libc_start_main+0x118)[0x401f74c4] > === Memory map: > 8000-0004c000 r-xp 1f:07 904/usr/sbin/connmand > 00053000-00057000 rwxp 00043000 1f:07 904/usr/sbin/connmand > 00057000-00078000 rwxp 00:00 0 [heap] > 4000-4001f000 r-xp 1f:07 343/lib/ld-2.11.1.so > 4001f000-4002 rwxp 00:00 0 > 40024000-40026000 rwxp 00:00 0 > 40026000-40027000 r-xp 0001e000 1f:07 343/lib/ld-2.11.1.so > 40027000-40028000 rwxp 0001f000 1f:07 343/lib/ld-2.11.1.so > 40028000-40117000 r-xp 1f:07 364/lib/libglib-2.0.so.0.2400.2 > 40117000-4011f000 ---p 000ef000 1f:07 364/lib/libglib-2.0.so.0.2400.2 > 4011f000-4012 rwxp 000ef000 1f:07 364/lib/libglib-2.0.so.0.2400.2 > 4012-40124000 r-xp 1f:07 797 > /usr/lib/libgthread-2.0.so.0.2400.2 > 40124000-4012b000 ---p 4000 1f:07 797 > /usr/lib/libgthread-2.0.so.0.2400.2 > 4012b000-4012c000 rwxp 3000 1f:07 797 > /usr/lib/libgthread-2.0.so.0.2400.2 > 4012c000-40189000 r-xp 1f:07 356/lib/libdbus-1.so.3.5.1 > 40189000-40191000 ---p 0005d000 1f:07 356/lib/libdbus-1.so.3.5.1 > 40191000-40192000 r-xp 0005d000 1f:07 356/lib/libdbus-1.so.3.5.1 > 40192000-40193000 rwxp 0005e000 1f:07 356/lib/libdbus-1.so.3.5.1 > 40193000-4019b000 r-xp 1f:07 421/lib/libxtables.so.5.0.0 > 4019b000-401a2000 ---p 8000 1f:07 421/lib/libxtables.so.5.0.0 > 401a2000-401a3000 rwxp 7000 1f:07 421/lib/libxtables.so.5.0.0 > 401a3000-401b7000 r-xp 1f:07 408/lib/libresolv-2.11.1.so > 401b7000-401be000 ---p 00014000 1f:07 408/lib/libresolv-2.11.1.so > 401be000-401bf000 r-xp 00013000 1f:07 408/lib/libresolv-2.11.1.so > 401bf000-401c rwxp 00014000 1f:07 408/lib/libresolv-2.11.1.so > 401c-401c2000 rwxp 00:00 0 > 401c2000-401c6000 r-xp 1f:07 357/lib/libdl-2.11.1.so > 401c6000-401cd000 ---p 4000 1f:07 357/lib/libdl-2.11.1.so > 401cd000-401ce000 r-xp 3000 1f:07 357/lib/libdl-2.11.1.so > 401ce000-401cf000 rwxp 4000 1f:07 357/lib/libdl-2.11.1.so > 401cf000-401da000 r-xp 1f:07 776/usr/lib/libgcc_s.so.1 > 401da000-401e1000 ---p b000 1f:07 776/usr/lib/libgcc_s.so.1 > 401e1000-401e2000 rwxp a000 1f:07 776/usr/lib/libgcc_s.so.1 > 401e2000-4031d000 r-x
Connman-0.67 Crashes and/or Hangs on Start-up
FYI. I need to check against GIT top-of-tree and dig into this further; however, with: * Wired Ethernet connected, connman-0.67 crashes on start-up * Wireless 802.11 WEXT, connman-0.67 hangs on start-up Backtrace with wired: root@10784311-00016.local# /usr/sbin/connmand -n connmand[444]: Connection Manager version 0.67 connmand[444]: Checking loopback interface settings connmand[444]: System hostname is salmon.local connmand[444]: Adding profile default connmand[444]: Failed to open RFKILL control device connmand[444]: lo {newlink} index 1 operstate 0 connmand[444]: eth0 {create} index 2 type 1 connmand[444]: eth0 {RX} 431 packets 60468 bytes connmand[444]: eth0 {TX} 61 packets 7521 bytes connmand[444]: eth0 {update} flags 69699 connmand[444]: eth0 {newlink} index 2 address 00:0c:29:4c:56:a2 mtu 1500 connmand[444]: eth0 {newlink} index 2 operstate 6 connmand[444]: Create interface eth0 [ ethernet ] connmand[444]: mmap error Invalid argument for /var/lib/connman/stats/ethernet_000c294c56a2_cable.data *** glibc detected *** /usr/sbin/connmand: double free or corruption (fasttop): 0x00062a80 *** === Backtrace: = /lib/libc.so.6(+0x7049c)[0x4025249c] /lib/libc.so.6(cfree+0x98)[0x40257db8] /lib/libglib-2.0.so.0(g_free+0x44)[0x4006ad28] /usr/sbin/connmand[0x3e594] /lib/libglib-2.0.so.0(+0x2ac10)[0x40052c10] /lib/libglib-2.0.so.0(+0x2bf44)[0x40053f44] /usr/sbin/connmand[0x3ece8] /usr/sbin/connmand[0x2972c] /usr/sbin/connmand[0x21dc4] /usr/sbin/connmand(connman_network_set_connected+0x5c)[0x220f4] /usr/lib/connman/plugins/ethernet.so(+0x1450)[0x403a4450] /usr/sbin/connmand(connman_rtnl_add_newlink_watch+0xa4)[0x36ba4] /usr/lib/connman/plugins/ethernet.so(+0x12d4)[0x403a42d4] /usr/sbin/connmand[0x1fae8] /usr/sbin/connmand[0x1c908] /usr/sbin/connmand(connman_element_register+0xe8)[0x1e024] /usr/sbin/connmand[0x337ac] /usr/sbin/connmand[0x372f4] /usr/sbin/connmand[0x37dc0] /lib/libglib-2.0.so.0(+0x825c0)[0x400aa5c0] /lib/libglib-2.0.so.0(g_main_context_dispatch+0x1ec)[0x40062a68] /lib/libglib-2.0.so.0(+0x3e0ec)[0x400660ec] /lib/libglib-2.0.so.0(g_main_loop_run+0x174)[0x4006669c] /usr/sbin/connmand[0x1add4] /lib/libc.so.6(__libc_start_main+0x118)[0x401f74c4] === Memory map: 8000-0004c000 r-xp 1f:07 904/usr/sbin/connmand 00053000-00057000 rwxp 00043000 1f:07 904/usr/sbin/connmand 00057000-00078000 rwxp 00:00 0 [heap] 4000-4001f000 r-xp 1f:07 343/lib/ld-2.11.1.so 4001f000-4002 rwxp 00:00 0 40024000-40026000 rwxp 00:00 0 40026000-40027000 r-xp 0001e000 1f:07 343/lib/ld-2.11.1.so 40027000-40028000 rwxp 0001f000 1f:07 343/lib/ld-2.11.1.so 40028000-40117000 r-xp 1f:07 364/lib/libglib-2.0.so.0.2400.2 40117000-4011f000 ---p 000ef000 1f:07 364/lib/libglib-2.0.so.0.2400.2 4011f000-4012 rwxp 000ef000 1f:07 364/lib/libglib-2.0.so.0.2400.2 4012-40124000 r-xp 1f:07 797 /usr/lib/libgthread-2.0.so.0.2400.2 40124000-4012b000 ---p 4000 1f:07 797 /usr/lib/libgthread-2.0.so.0.2400.2 4012b000-4012c000 rwxp 3000 1f:07 797 /usr/lib/libgthread-2.0.so.0.2400.2 4012c000-40189000 r-xp 1f:07 356/lib/libdbus-1.so.3.5.1 40189000-40191000 ---p 0005d000 1f:07 356/lib/libdbus-1.so.3.5.1 40191000-40192000 r-xp 0005d000 1f:07 356/lib/libdbus-1.so.3.5.1 40192000-40193000 rwxp 0005e000 1f:07 356/lib/libdbus-1.so.3.5.1 40193000-4019b000 r-xp 1f:07 421/lib/libxtables.so.5.0.0 4019b000-401a2000 ---p 8000 1f:07 421/lib/libxtables.so.5.0.0 401a2000-401a3000 rwxp 7000 1f:07 421/lib/libxtables.so.5.0.0 401a3000-401b7000 r-xp 1f:07 408/lib/libresolv-2.11.1.so 401b7000-401be000 ---p 00014000 1f:07 408/lib/libresolv-2.11.1.so 401be000-401bf000 r-xp 00013000 1f:07 408/lib/libresolv-2.11.1.so 401bf000-401c rwxp 00014000 1f:07 408/lib/libresolv-2.11.1.so 401c-401c2000 rwxp 00:00 0 401c2000-401c6000 r-xp 1f:07 357/lib/libdl-2.11.1.so 401c6000-401cd000 ---p 4000 1f:07 357/lib/libdl-2.11.1.so 401cd000-401ce000 r-xp 3000 1f:07 357/lib/libdl-2.11.1.so 401ce000-401cf000 rwxp 4000 1f:07 357/lib/libdl-2.11.1.so 401cf000-401da000 r-xp 1f:07 776/usr/lib/libgcc_s.so.1 401da000-401e1000 ---p b000 1f:07 776/usr/lib/libgcc_s.so.1 401e1000-401e2000 rwxp a000 1f:07 776/usr/lib/libgcc_s.so.1 401e2000-4031d000 r-xp 1f:07 350/lib/libc-2.11.1.so 4031d000-40325000 ---p 0013b000 1f:07 350/lib/libc-2.11.1.so 40325000-40327000 r-xp 0013b000 1f:07 350/lib/libc-2.11.1.so 40327000-40328000 rwxp 0013d000 connmand[444]: Aborting (signal 6) connmand[444]: backtrace connmand[444]: [0]: /lib/libc.so.6(__default_sa_restorer_v2+0) [0x4020f630] connmand[444]: [1]: /lib/libc.so.6(gsigna
Re: [PATCH v3 0/4] nmcompat plugin
Hi Kalle, On Fri, Jan 28, 2011 at 05:02:23PM +0200, Kalle Valo wrote: > Based on discussion on IRC, here are patches to move all nm code to > a plugin. This way it doesn't affect core code but still applications get > network state events. > > Tested with pidgin and empathy from Ubuntu 10.10. Thanks, all patches applied now. 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 v3 0/4] nmcompat plugin
Kalle Valo writes: > Based on discussion on IRC, here are patches to move all nm code to > a plugin. This way it doesn't affect core code but still applications get > network state events. > > Tested with pidgin and empathy from Ubuntu 10.10. > > v3: > o fix nm_state() to use correct variable > o separate dbus configuration file > > v2: more error checking in init() and fixed one too long line [...] > plugins/connman-nmcompat.conf | 14 ++ > plugins/nmcompat.c| 282 > + > 2 files changed, 296 insertions(+), 0 deletions(-) It seems stgit is playing tricks on me and diffstats are wrong in almost of the patches I sent. -- Kalle Valo ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH v3 4/4] nmcompat: dbus configuration file
Add separate dbus configuration file for nmcompat plugin. It will installed only when the plugin is enabled. --- plugins/connman-nmcompat.conf | 14 ++ 1 files changed, 14 insertions(+), 0 deletions(-) create mode 100644 plugins/connman-nmcompat.conf diff --git a/Makefile.am b/Makefile.am index 67b2c29..144fcc5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,9 +32,14 @@ gweb_sources = gweb/gweb.h gweb/gweb.c gweb/gresolv.h gweb/gresolv.c \ gweb/giognutls.h gweb/giognutls.c if DATAFILES + +if NMCOMPAT +nmcompat_conf = plugins/connman-nmcompat.conf +endif + dbusconfdir = @DBUS_CONFDIR@ -dbusconf_DATA = src/connman.conf +dbusconf_DATA = src/connman.conf $(nmcompat_conf) if SYSTEMD systemdunitdir = @SYSTEMD_UNITDIR@ @@ -109,7 +114,8 @@ AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPNG_CFLAGS@ @XTABLES_CFLAGS@ \ INCLUDES = -I$(builddir)/include -I$(builddir)/src -I$(srcdir)/gdbus -EXTRA_DIST = src/genbuiltin src/connman-dbus.conf src/connman-polkit.conf +EXTRA_DIST = src/genbuiltin src/connman-dbus.conf src/connman-polkit.conf \ + plugins/connman-nmcompat.conf script_DATA = diff --git a/plugins/connman-nmcompat.conf b/plugins/connman-nmcompat.conf new file mode 100644 index 000..5887a34 --- /dev/null +++ b/plugins/connman-nmcompat.conf @@ -0,0 +1,14 @@ +http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd";> + + + + + + + + + + + + ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH v3 3/4] nmcompat: support nm dbus properties
After some investigation I found that network-manager also provides the network state through properties and libnm-glib library uses this instead of the GetState() method. Add Get() method call retrieve the property and a PropertyChanged signal to notify state changes. Now empathy, which uses libnm-glib, properly detects network state changes. I deliberately omitted GetAll() method because libnm-glib doesn't seem to need it. --- plugins/nmcompat.c | 94 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c index 876c00f..2b74a40 100644 --- a/plugins/nmcompat.c +++ b/plugins/nmcompat.c @@ -43,6 +43,8 @@ enum { #define NM_PATH "/org/freedesktop/NetworkManager" #define NM_INTERFACE NM_SERVICE +#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties" + static DBusConnection *connection = NULL; static dbus_uint32_t state = NM_STATE_UNKNOWN; @@ -61,6 +63,45 @@ static void nm_send_signal(const char *name, dbus_uint32_t state) g_dbus_send_message(connection, signal); } +static void nm_send_prop_signal(dbus_uint32_t state) +{ + const char *key = "State"; + DBusMessageIter iter, dict, dict_entry, dict_val; + DBusMessage *signal; + + signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, + "PropertiesChanged"); + if (signal == NULL) + return; + + dbus_message_iter_init_append(signal, &iter); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, + &dict); + + dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, + NULL, &dict_entry); + + dbus_message_iter_append_basic(&dict_entry, DBUS_TYPE_STRING, + &key); + + dbus_message_iter_open_container(&dict_entry, + DBUS_TYPE_VARIANT, + DBUS_TYPE_UINT32_AS_STRING, &dict_val); + + dbus_message_iter_append_basic(&dict_val, DBUS_TYPE_UINT32, &state); + + dbus_message_iter_close_container(&dict_entry, &dict_val); + dbus_message_iter_close_container(&dict, &dict_entry); + dbus_message_iter_close_container(&iter, &dict); + + g_dbus_send_message(connection, signal); +} + static void default_changed(struct connman_service *service) { if (service != NULL) @@ -75,6 +116,8 @@ static void default_changed(struct connman_service *service) /* the preferred current signal */ nm_send_signal("StateChanged", state); + + nm_send_prop_signal(state); } static struct connman_notifier notifier = { @@ -139,6 +182,47 @@ static GDBusMethodTable nm_methods[] = { { }, }; +static DBusMessage *nm_prop_get(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessageIter iter, value; + const char *interface, *key; + DBusMessage *reply; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &interface, + DBUS_TYPE_STRING, &key, + DBUS_TYPE_INVALID); + + if (g_strcmp0(key, "State") == 0) { + dbus_message_iter_init_append(reply, &iter); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, + DBUS_TYPE_UINT32_AS_STRING, + &value); + dbus_message_iter_append_basic(&value, DBUS_TYPE_UINT32, + &state); + dbus_message_iter_close_container(&iter, &value); + } else { + dbus_message_unref(reply); + return dbus_message_new_error(msg, DBUS_ERROR_FAILED, + "Unsupported property"); + } + + return reply; +} + +static GDBusMethodTable nm_prop_methods[] = { + { "Get", "ss", "v", nm_prop_get }, + { }, +}; + static int nmcompat_init(void) { gboolean ret; @@ -166,6 +250,16 @@ static int nmcompat_init(void) return -1; } + ret = g_dbus_register_interface(connection, NM_PATH, + DBUS_PROPERTIES_INTERFACE, + nm_prop_methods, NULL, NULL, + NULL, NULL); + i
[PATCH v3 2/4] nmcompat: add plugin
Add plugin which provides network-manager state interface to applications. This is a direct copy of what was in src/manager.c, just copied all into a plugin. --- plugins/nmcompat.c | 188 1 files changed, 188 insertions(+), 0 deletions(-) create mode 100644 plugins/nmcompat.c diff --git a/Makefile.plugins b/Makefile.plugins index 1841697..af3cfa0 100644 --- a/Makefile.plugins +++ b/Makefile.plugins @@ -269,6 +269,18 @@ plugins_ntpd_la_LDFLAGS = $(plugin_ldflags) endif endif +if NMCOMPAT +if NMCOMPAT_BUILTIN +builtin_modules += nmcompat +builtin_sources += plugins/nmcompat.c +else +plugin_LTLIBRARIES += plugins/nmcompat.la +plugin_objects += $(plugins_nmcompat_la_OBJECTS) +plugins_nmcompat_la_CFLAGS = $(plugin_cflags) +plugins_nmcompat_la_LDFLAGS = $(plugin_ldflags) +endif +endif + EXTRA_DIST += plugins/polkit.policy plugins/net.connman.policy: plugins/polkit.policy diff --git a/configure.ac b/configure.ac index 66bee66..38aa4b4 100644 --- a/configure.ac +++ b/configure.ac @@ -274,6 +274,12 @@ fi AM_CONDITIONAL(NTPD, test "${enable_ntpd}" != "no") AM_CONDITIONAL(NTPD_BUILTIN, test "${enable_ntpd}" = "builtin") +AC_ARG_ENABLE(nmcompat, + AC_HELP_STRING([--enable-nmcompat], [enable nmcompat support]), + [enable_nmcompat=${enableval}], [enable_nmcompat="no"]) +AM_CONDITIONAL(NMCOMPAT, test "${enable_nmcompat}" != "no") +AM_CONDITIONAL(NMCOMPAT_BUILTIN, test "${enable_nmcompat}" = "builtin") + AC_ARG_WITH(stats-max-file-size, AC_HELP_STRING([--with-stats-max-file-size=SIZE], [Maximal size of a statistics round robin file]), [stats_max_file_size=${withval}]) diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c new file mode 100644 index 000..876c00f --- /dev/null +++ b/plugins/nmcompat.c @@ -0,0 +1,188 @@ +/* + * + * Connection Manager + * + * Copyright (C) 2007-2010 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#define CONNMAN_API_SUBJECT_TO_CHANGE +#include +#include +#include +#include + +enum { + NM_STATE_UNKNOWN = 0, + NM_STATE_ASLEEP, + NM_STATE_CONNECTING, + NM_STATE_CONNECTED, + NM_STATE_DISCONNECTED +}; + +#define NM_SERVICE"org.freedesktop.NetworkManager" +#define NM_PATH "/org/freedesktop/NetworkManager" +#define NM_INTERFACE NM_SERVICE + +static DBusConnection *connection = NULL; +static dbus_uint32_t state = NM_STATE_UNKNOWN; + + +static void nm_send_signal(const char *name, dbus_uint32_t state) +{ + DBusMessage *signal; + + signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name); + if (signal == NULL) + return; + + dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state, + DBUS_TYPE_INVALID); + + g_dbus_send_message(connection, signal); +} + +static void default_changed(struct connman_service *service) +{ + if (service != NULL) + state = NM_STATE_CONNECTED; + else + state = NM_STATE_DISCONNECTED; + + DBG("%p %d", service, state); + + /* older deprecated signal, in case applications still use this */ + nm_send_signal("StateChange", state); + + /* the preferred current signal */ + nm_send_signal("StateChanged", state); +} + +static struct connman_notifier notifier = { + .name = "nmcompat", + .priority = CONNMAN_NOTIFIER_PRIORITY_DEFAULT, + .default_changed= default_changed, +}; + +static DBusMessage *nm_sleep(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + return reply; +} + +static DBusMessage *nm_wake(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_
[PATCH v3 1/4] manager: remove network-manager compatibility code
Remove the network-manager compatibility code from src/manager.c so that all this can be implemented as a plugin. -c command line switch is still left but marked as obsole to avoid breaking current start scripts. By removing the switch connman would not start at all if -c is used. --- 0 files changed, 0 insertions(+), 0 deletions(-) diff --git a/src/connman.h b/src/connman.h index 972c435..979c564 100644 --- a/src/connman.h +++ b/src/connman.h @@ -25,10 +25,6 @@ #include -#define NM_SERVICE"org.freedesktop.NetworkManager" -#define NM_PATH "/org/freedesktop/NetworkManager" -#define NM_INTERFACE NM_SERVICE - int __connman_dbus_init(DBusConnection *conn); void __connman_dbus_cleanup(void); @@ -55,7 +51,7 @@ DBusMessage *__connman_error_invalid_property(DBusMessage *msg); #include -int __connman_manager_init(gboolean compat); +int __connman_manager_init(void); void __connman_manager_cleanup(void); int __connman_agent_init(void); diff --git a/src/main.c b/src/main.c index 08f2555..d8cc8ea 100644 --- a/src/main.c +++ b/src/main.c @@ -99,7 +99,7 @@ static GOptionEntry options[] = { G_OPTION_ARG_NONE, &option_dnsproxy, "Don't enable DNS Proxy" }, { "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat, - "Enable Network Manager compatibility" }, + "(obsolete)" }, { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version, "Show version information and exit" }, { NULL }, @@ -204,13 +204,6 @@ int main(int argc, char *argv[]) g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); - if (option_compat == TRUE) { - if (g_dbus_request_name(conn, NM_SERVICE, NULL) == FALSE) { - fprintf(stderr, "Can't register compat service\n"); - option_compat = FALSE; - } - } - __connman_log_init(option_debug, option_detach); __connman_dbus_init(conn); @@ -222,7 +215,7 @@ int main(int argc, char *argv[]) __connman_iptables_init(); __connman_tethering_init(); __connman_counter_init(); - __connman_manager_init(option_compat); + __connman_manager_init(); __connman_profile_init(); __connman_config_init(); __connman_stats_init(); diff --git a/src/manager.c b/src/manager.c index 6fb54e1..9705b05 100644 --- a/src/manager.c +++ b/src/manager.c @@ -27,16 +27,6 @@ #include "connman.h" -enum { - NM_STATE_UNKNOWN = 0, - NM_STATE_ASLEEP, - NM_STATE_CONNECTING, - NM_STATE_CONNECTED, - NM_STATE_DISCONNECTED -}; - -static gboolean nm_compat = FALSE; - static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -313,46 +303,10 @@ static void technology_notify(enum connman_service_type type, technology_reply(0); } -static void nm_send_signal(const char *name, dbus_uint32_t state) -{ - DBusMessage *signal; - - signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name); - if (signal == NULL) - return; - - dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state, - DBUS_TYPE_INVALID); - - g_dbus_send_message(connection, signal); -} - -static void default_changed(struct connman_service *service) -{ - dbus_uint32_t state; - - if (!nm_compat) - return; - - if (service != NULL) - state = NM_STATE_CONNECTED; - else - state = NM_STATE_DISCONNECTED; - - DBG("%p %d", service, state); - - /* older deprecated signal, in case applications still use this */ - nm_send_signal("StateChange", state); - - /* the preferred current signal */ - nm_send_signal("StateChanged", state); -} - static struct connman_notifier technology_notifier = { .name = "manager", .priority = CONNMAN_NOTIFIER_PRIORITY_HIGH, .service_enabled= technology_notify, - .default_changed= default_changed, }; static DBusMessage *enable_technology(DBusConnection *conn, @@ -698,69 +652,7 @@ static GDBusSignalTable manager_signals[] = { { }, }; -static DBusMessage *nm_sleep(DBusConnection *conn, - DBusMessage *msg, void *data) -{ - DBusMessage *reply; - - DBG("conn %p", conn); - - reply = dbus_message_new_method_return(msg); - if (reply == NULL) - return NULL; - - dbus_message_append_args(reply, DBUS_TYPE_INVALID); - - return reply; -} - -static DBusMessage *nm_wake(DBusConnection *conn, - DBusMessage *msg, void *data) -{ - DBusMessage *reply; - - DBG("conn %p", conn); - - reply = dbus_message_new_method_return(msg); -
[PATCH v3 0/4] nmcompat plugin
Based on discussion on IRC, here are patches to move all nm code to a plugin. This way it doesn't affect core code but still applications get network state events. Tested with pidgin and empathy from Ubuntu 10.10. v3: o fix nm_state() to use correct variable o separate dbus configuration file v2: more error checking in init() and fixed one too long line --- Kalle Valo (4): manager: remove network-manager compatibility code nmcompat: add plugin nmcompat: support nm dbus properties nmcompat: dbus configuration file plugins/connman-nmcompat.conf | 14 ++ plugins/nmcompat.c| 282 + 2 files changed, 296 insertions(+), 0 deletions(-) create mode 100644 plugins/connman-nmcompat.conf create mode 100644 plugins/nmcompat.c ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH] TODO: Remove DNS Proxy entry
Hi Daniel, On Fri, Jan 28, 2011 at 09:48:26AM +0100, Daniel Wagner wrote: > From: Daniel Wagner Thanks for that, 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: [RFC v2 1/2] dhcp: Move plugins/dhcp in to core
Hi Daniel, On Thu, Jan 27, 2011 at 01:34:51PM +0100, Daniel Wagner wrote: > From: Daniel Wagner It looks fine, I applied it. Thanks for that. 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 1/5 v3] A fix for the task exit definition.
Hi Mohamed, On Thu, Jan 27, 2011 at 08:55:32PM -0800, Mohamed Abbas wrote: > Pass task exit code value to task exit callback. After applying this patch: plugins/openconnect.c: In function ‘oc_connect’: plugins/openconnect.c:148: error: passing argument 2 of ‘connman_task_run’ from incompatible pointer type I fixed that up for you and applied the whole patch set. In the future, please make sure ConnMan builds properly for each path you 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 4/4 v2] Add proxy cancel support and use token correctly.
Hi Mohamed, On Thu, Jan 27, 2011 at 08:53:21PM -0800, Mohamed Abbas wrote: > @@ -168,13 +171,14 @@ static int location_detect(struct connman_location > *location) > g_web_set_user_agent(data->web, "ConnMan/%s", VERSION); > g_web_set_close_connection(data->web, TRUE); > > - err = connman_proxy_lookup(interface, STATUS_URL, > - proxy_callback, location); > - if (err < 0) > - goto done; > + service = connman_location_get_service(location); > + data->token = connman_proxy_lookup(interface, STATUS_URL, > + service, proxy_callback, location); > > - connman_location_ref(location); We still want to refcount the location. 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 1/4 v2] Add pacrunner proxy driver.
Hi Mohamed, On Thu, Jan 27, 2011 at 08:53:18PM -0800, Mohamed Abbas wrote: > Register pacrunner proxy driver, add proxy driver functions and > call pacrunner daemon to find proxy. After applying this patch, I got: CC plugins/pacrunner.o plugins/pacrunner.c:436: error: ‘CONNMAN_PROXY_PRIORITY_HIGH’ undeclared here (not in a function) So you need patch #2 to be the first one of the serie, and include a fix for the connman_proxy_lookup() call into it. 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 v2 4/4] dbus: allow owning org.freedesktop.NetworkManager
Marcel Holtmann writes: > Hi Kalle, Hi Marcel, >> The network-manager compatibility interface doesn't start unless >> we allow connman to own the interface in the dbus configuration. >> --- >> src/connman-dbus.conf |1 + >> 1 files changed, 1 insertions(+), 0 deletions(-) > > you need to create a separate one that belongs to the plugin. Only when > the plugin is compiled in or selected we should punch this whole in the > policy. Ok, will do. -- Kalle Valo ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
Re: [PATCH v2 4/4] dbus: allow owning org.freedesktop.NetworkManager
Hi Kalle, > The network-manager compatibility interface doesn't start unless > we allow connman to own the interface in the dbus configuration. > --- > src/connman-dbus.conf |1 + > 1 files changed, 1 insertions(+), 0 deletions(-) you need to create a separate one that belongs to the plugin. Only when the plugin is compiled in or selected we should punch this whole in the policy. Regards Marcel ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH] TODO: Remove DNS Proxy entry
From: Daniel Wagner --- TODO | 12 1 files changed, 0 insertions(+), 12 deletions(-) diff --git a/TODO b/TODO index ea90f08..fcb21d3 100644 --- a/TODO +++ b/TODO @@ -24,18 +24,6 @@ Core Complexity: C2 -- Moving DNS proxy code to ConnMan core - - Priority: Medium - Complexity: C2 - - Supporting DNS proxy or resolv.conf direct editing seems more than - plenty as far as resolving is concerned. So the idea is to move the - dnsproxy plugin code to ConnMan core and have an additional command - line option in case one would like to stick with the current - resolver.c code for editing resolv.conf. - - - WiFi tethering Priority: Medium Complexity: C4 -- 1.7.3.5 ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH v2 4/4] dbus: allow owning org.freedesktop.NetworkManager
The network-manager compatibility interface doesn't start unless we allow connman to own the interface in the dbus configuration. --- src/connman-dbus.conf |1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/src/connman-dbus.conf b/src/connman-dbus.conf index 311f28c..fa70297 100644 --- a/src/connman-dbus.conf +++ b/src/connman-dbus.conf @@ -3,6 +3,7 @@ + ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman
[PATCH v2 3/4] nmcompat: support nm dbus properties
After some investigation I found that network-manager also provides the network state through properties and libnm-glib library uses this instead of the GetState() method. Add Get() method call retrieve the property and a PropertyChanged signal to notify state changes. Now empathy, which uses libnm-glib, properly detects network state changes. I deliberately omitted GetAll() method because libnm-glib doesn't seem to need it. --- plugins/nmcompat.c | 94 1 files changed, 94 insertions(+), 0 deletions(-) diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c index 0135d03..2aec1d8 100644 --- a/plugins/nmcompat.c +++ b/plugins/nmcompat.c @@ -43,6 +43,8 @@ enum { #define NM_PATH "/org/freedesktop/NetworkManager" #define NM_INTERFACE NM_SERVICE +#define DBUS_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties" + static DBusConnection *connection = NULL; static dbus_uint32_t state = NM_STATE_UNKNOWN; @@ -61,6 +63,45 @@ static void nm_send_signal(const char *name, dbus_uint32_t state) g_dbus_send_message(connection, signal); } +static void nm_send_prop_signal(dbus_uint32_t state) +{ + const char *key = "State"; + DBusMessageIter iter, dict, dict_entry, dict_val; + DBusMessage *signal; + + signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, + "PropertiesChanged"); + if (signal == NULL) + return; + + dbus_message_iter_init_append(signal, &iter); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY, + DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_DICT_ENTRY_END_CHAR_AS_STRING, + &dict); + + dbus_message_iter_open_container(&dict, DBUS_TYPE_DICT_ENTRY, + NULL, &dict_entry); + + dbus_message_iter_append_basic(&dict_entry, DBUS_TYPE_STRING, + &key); + + dbus_message_iter_open_container(&dict_entry, + DBUS_TYPE_VARIANT, + DBUS_TYPE_UINT32_AS_STRING, &dict_val); + + dbus_message_iter_append_basic(&dict_val, DBUS_TYPE_UINT32, &state); + + dbus_message_iter_close_container(&dict_entry, &dict_val); + dbus_message_iter_close_container(&dict, &dict_entry); + dbus_message_iter_close_container(&iter, &dict); + + g_dbus_send_message(connection, signal); +} + static void default_changed(struct connman_service *service) { if (service != NULL) @@ -75,6 +116,8 @@ static void default_changed(struct connman_service *service) /* the preferred current signal */ nm_send_signal("StateChanged", state); + + nm_send_prop_signal(state); } static struct connman_notifier notifier = { @@ -140,6 +183,47 @@ static GDBusMethodTable nm_methods[] = { { }, }; +static DBusMessage *nm_prop_get(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessageIter iter, value; + const char *interface, *key; + DBusMessage *reply; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &interface, + DBUS_TYPE_STRING, &key, + DBUS_TYPE_INVALID); + + if (g_strcmp0(key, "State") == 0) { + dbus_message_iter_init_append(reply, &iter); + + dbus_message_iter_open_container(&iter, DBUS_TYPE_VARIANT, + DBUS_TYPE_UINT32_AS_STRING, + &value); + dbus_message_iter_append_basic(&value, DBUS_TYPE_UINT32, + &state); + dbus_message_iter_close_container(&iter, &value); + } else { + dbus_message_unref(reply); + return dbus_message_new_error(msg, DBUS_ERROR_FAILED, + "Unsupported property"); + } + + return reply; +} + +static GDBusMethodTable nm_prop_methods[] = { + { "Get", "ss", "v", nm_prop_get }, + { }, +}; + static int nmcompat_init(void) { gboolean ret; @@ -167,6 +251,16 @@ static int nmcompat_init(void) return -1; } + ret = g_dbus_register_interface(connection, NM_PATH, + DBUS_PROPERTIES_INTERFACE, + nm_prop_methods, NULL, NULL, + NULL, NULL); + i
[PATCH v2 2/4] nmcompat: add plugin
Add plugin which provides network-manager state interface to applications. This is a direct copy of what was in src/manager.c, just copied all into a plugin. --- Makefile.plugins | 12 +++ configure.ac |6 ++ plugins/nmcompat.c | 189 3 files changed, 207 insertions(+), 0 deletions(-) create mode 100644 plugins/nmcompat.c diff --git a/Makefile.plugins b/Makefile.plugins index e87f10b..eb317f3 100644 --- a/Makefile.plugins +++ b/Makefile.plugins @@ -272,6 +272,18 @@ plugins_ntpd_la_LDFLAGS = $(plugin_ldflags) endif endif +if NMCOMPAT +if NMCOMPAT_BUILTIN +builtin_modules += nmcompat +builtin_sources += plugins/nmcompat.c +else +plugin_LTLIBRARIES += plugins/nmcompat.la +plugin_objects += $(plugins_nmcompat_la_OBJECTS) +plugins_nmcompat_la_CFLAGS = $(plugin_cflags) +plugins_nmcompat_la_LDFLAGS = $(plugin_ldflags) +endif +endif + EXTRA_DIST += plugins/polkit.policy plugins/net.connman.policy: plugins/polkit.policy diff --git a/configure.ac b/configure.ac index 951b7a3..f2d401f 100644 --- a/configure.ac +++ b/configure.ac @@ -274,6 +274,12 @@ fi AM_CONDITIONAL(NTPD, test "${enable_ntpd}" != "no") AM_CONDITIONAL(NTPD_BUILTIN, test "${enable_ntpd}" = "builtin") +AC_ARG_ENABLE(nmcompat, + AC_HELP_STRING([--enable-nmcompat], [enable nmcompat support]), + [enable_nmcompat=${enableval}], [enable_nmcompat="no"]) +AM_CONDITIONAL(NMCOMPAT, test "${enable_nmcompat}" != "no") +AM_CONDITIONAL(NMCOMPAT_BUILTIN, test "${enable_nmcompat}" = "builtin") + AC_ARG_WITH(stats-max-file-size, AC_HELP_STRING([--with-stats-max-file-size=SIZE], [Maximal size of a statistics round robin file]), [stats_max_file_size=${withval}]) diff --git a/plugins/nmcompat.c b/plugins/nmcompat.c new file mode 100644 index 000..0135d03 --- /dev/null +++ b/plugins/nmcompat.c @@ -0,0 +1,189 @@ +/* + * + * Connection Manager + * + * Copyright (C) 2007-2010 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#define CONNMAN_API_SUBJECT_TO_CHANGE +#include +#include +#include +#include + +enum { + NM_STATE_UNKNOWN = 0, + NM_STATE_ASLEEP, + NM_STATE_CONNECTING, + NM_STATE_CONNECTED, + NM_STATE_DISCONNECTED +}; + +#define NM_SERVICE"org.freedesktop.NetworkManager" +#define NM_PATH "/org/freedesktop/NetworkManager" +#define NM_INTERFACE NM_SERVICE + +static DBusConnection *connection = NULL; +static dbus_uint32_t state = NM_STATE_UNKNOWN; + + +static void nm_send_signal(const char *name, dbus_uint32_t state) +{ + DBusMessage *signal; + + signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name); + if (signal == NULL) + return; + + dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state, + DBUS_TYPE_INVALID); + + g_dbus_send_message(connection, signal); +} + +static void default_changed(struct connman_service *service) +{ + if (service != NULL) + state = NM_STATE_CONNECTED; + else + state = NM_STATE_DISCONNECTED; + + DBG("%p %d", service, state); + + /* older deprecated signal, in case applications still use this */ + nm_send_signal("StateChange", state); + + /* the preferred current signal */ + nm_send_signal("StateChanged", state); +} + +static struct connman_notifier notifier = { + .name = "nmcompat", + .priority = CONNMAN_NOTIFIER_PRIORITY_DEFAULT, + .default_changed= default_changed, +}; + +static DBusMessage *nm_sleep(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + return NULL; + + dbus_message_append_args(reply, DBUS_TYPE_INVALID); + + return reply; +} + +static DBusMessage *nm_wake(DBusConnection *conn, + DBusMessage *msg, void *data) +{ + DBusMessage *reply; + + DBG("conn %p", conn); + + reply = dbus_message_new_method_return(msg); + if (reply == NULL) + retu
[PATCH v2 1/4] manager: remove network-manager compatibility code
Remove the network-manager compatibility code from src/manager.c so that all this can be implemented as a plugin. -c command line switch is still left but marked as obsole to avoid breaking current start scripts. By removing the switch connman would not start at all if -c is used. --- src/connman.h |6 --- src/main.c| 11 + src/manager.c | 121 - 3 files changed, 4 insertions(+), 134 deletions(-) diff --git a/src/connman.h b/src/connman.h index 5bcda43..6e3b3ba 100644 --- a/src/connman.h +++ b/src/connman.h @@ -25,10 +25,6 @@ #include -#define NM_SERVICE"org.freedesktop.NetworkManager" -#define NM_PATH "/org/freedesktop/NetworkManager" -#define NM_INTERFACE NM_SERVICE - int __connman_dbus_init(DBusConnection *conn); void __connman_dbus_cleanup(void); @@ -55,7 +51,7 @@ DBusMessage *__connman_error_invalid_property(DBusMessage *msg); #include -int __connman_manager_init(gboolean compat); +int __connman_manager_init(void); void __connman_manager_cleanup(void); int __connman_agent_init(void); diff --git a/src/main.c b/src/main.c index 08f2555..d8cc8ea 100644 --- a/src/main.c +++ b/src/main.c @@ -99,7 +99,7 @@ static GOptionEntry options[] = { G_OPTION_ARG_NONE, &option_dnsproxy, "Don't enable DNS Proxy" }, { "compat", 'c', 0, G_OPTION_ARG_NONE, &option_compat, - "Enable Network Manager compatibility" }, + "(obsolete)" }, { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version, "Show version information and exit" }, { NULL }, @@ -204,13 +204,6 @@ int main(int argc, char *argv[]) g_dbus_set_disconnect_function(conn, disconnect_callback, NULL, NULL); - if (option_compat == TRUE) { - if (g_dbus_request_name(conn, NM_SERVICE, NULL) == FALSE) { - fprintf(stderr, "Can't register compat service\n"); - option_compat = FALSE; - } - } - __connman_log_init(option_debug, option_detach); __connman_dbus_init(conn); @@ -222,7 +215,7 @@ int main(int argc, char *argv[]) __connman_iptables_init(); __connman_tethering_init(); __connman_counter_init(); - __connman_manager_init(option_compat); + __connman_manager_init(); __connman_profile_init(); __connman_config_init(); __connman_stats_init(); diff --git a/src/manager.c b/src/manager.c index 6fb54e1..9705b05 100644 --- a/src/manager.c +++ b/src/manager.c @@ -27,16 +27,6 @@ #include "connman.h" -enum { - NM_STATE_UNKNOWN = 0, - NM_STATE_ASLEEP, - NM_STATE_CONNECTING, - NM_STATE_CONNECTED, - NM_STATE_DISCONNECTED -}; - -static gboolean nm_compat = FALSE; - static DBusMessage *get_properties(DBusConnection *conn, DBusMessage *msg, void *data) { @@ -313,46 +303,10 @@ static void technology_notify(enum connman_service_type type, technology_reply(0); } -static void nm_send_signal(const char *name, dbus_uint32_t state) -{ - DBusMessage *signal; - - signal = dbus_message_new_signal(NM_PATH, NM_INTERFACE, name); - if (signal == NULL) - return; - - dbus_message_append_args(signal, DBUS_TYPE_UINT32, &state, - DBUS_TYPE_INVALID); - - g_dbus_send_message(connection, signal); -} - -static void default_changed(struct connman_service *service) -{ - dbus_uint32_t state; - - if (!nm_compat) - return; - - if (service != NULL) - state = NM_STATE_CONNECTED; - else - state = NM_STATE_DISCONNECTED; - - DBG("%p %d", service, state); - - /* older deprecated signal, in case applications still use this */ - nm_send_signal("StateChange", state); - - /* the preferred current signal */ - nm_send_signal("StateChanged", state); -} - static struct connman_notifier technology_notifier = { .name = "manager", .priority = CONNMAN_NOTIFIER_PRIORITY_HIGH, .service_enabled= technology_notify, - .default_changed= default_changed, }; static DBusMessage *enable_technology(DBusConnection *conn, @@ -698,69 +652,7 @@ static GDBusSignalTable manager_signals[] = { { }, }; -static DBusMessage *nm_sleep(DBusConnection *conn, - DBusMessage *msg, void *data) -{ - DBusMessage *reply; - - DBG("conn %p", conn); - - reply = dbus_message_new_method_return(msg); - if (reply == NULL) - return NULL; - - dbus_message_append_args(reply, DBUS_TYPE_INVALID); - - return reply; -} - -static DBusMessage *nm_wake(DBusConnection *conn, - DBusMessage *
[PATCH v2 0/4] nmcompat plugin
Based on discussion on IRC, here are patches to move all nm code to a plugin. This way it doesn't affect core code but still applications get network state events. Tested with pidgin and empathy from Ubuntu 10.10. v2: more error checking in init() and fixed one too long line --- Kalle Valo (4): manager: remove network-manager compatibility code nmcompat: add plugin nmcompat: support nm dbus properties dbus: allow owning org.freedesktop.NetworkManager Makefile.plugins | 12 ++ configure.ac |6 + plugins/nmcompat.c| 283 + src/connman-dbus.conf |1 src/connman.h |6 - src/main.c| 11 -- src/manager.c | 121 - 7 files changed, 306 insertions(+), 134 deletions(-) create mode 100644 plugins/nmcompat.c ___ connman mailing list connman@connman.net http://lists.connman.net/listinfo/connman