Send connman mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
https://lists.01.org/mailman/listinfo/connman
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of connman digest..."
Today's Topics:
1. [PATCH v2] Port pacrunner to mozjs24 (Jeremy Linton)
2. [PATCH v2] Pull pacrunner forward to mozjs24 (Jeremy Linton)
3. Re: Connman on Android/Brillo (Naveen Singh)
4. Re: [PATCH 1/3] technology: Add specific D-Bus methods for
WPS connections (Eunok Lee)
----------------------------------------------------------------------
Message: 1
Date: Wed, 31 Aug 2016 14:36:12 -0500
From: Jeremy Linton <[email protected]>
To: [email protected]
Subject: [PATCH v2] Port pacrunner to mozjs24
Message-ID: <[email protected]>
This patch moves pacrunner to mozjs24. This is still
a little behind the times, but gnome/etc are using mozjs24
so the distro's are on the hook for supporting it.
v1->v2 Change automake script so that --disable-mozjs doesn't require
pacrunner to depend on the C++ support libraries.
Jeremy Linton (1):
Pull pacrunner forward to mozjs24
Makefile.am | 20 +++++++++++++-------
configure.ac | 4 ++--
plugins/{mozjs.c => mozjs.cpp} | 36 +++++++++++++++++++-----------------
3 files changed, 34 insertions(+), 26 deletions(-)
rename plugins/{mozjs.c => mozjs.cpp} (82%)
--
2.9.2
------------------------------
Message: 2
Date: Wed, 31 Aug 2016 14:36:13 -0500
From: Jeremy Linton <[email protected]>
To: [email protected]
Subject: [PATCH v2] Pull pacrunner forward to mozjs24
Message-ID: <[email protected]>
Mozjs185 is getting really old and unsupported. Newer versions
of the mozjs JSAPI are C++ based. Start the conversion to more recent
JSAPI's by updating pacrunner to use mozjs24 which is a common version
being used by a number of distributions. It also happens to be the first
C++ only version of JSAPI.
Signed-off-by: Jeremy Linton <[email protected]>
---
Makefile.am | 20 +++++++++++++-------
configure.ac | 4 ++--
plugins/{mozjs.c => mozjs.cpp} | 36 +++++++++++++++++++-----------------
3 files changed, 34 insertions(+), 26 deletions(-)
rename plugins/{mozjs.c => mozjs.cpp} (82%)
diff --git a/Makefile.am b/Makefile.am
index ee84b75..59e0ef0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -31,9 +31,15 @@ endif
if MOZJS
js_sources = src/js_funcs.c
builtin_modules += mozjs
-builtin_sources += plugins/mozjs.c
-builtin_cflags += @MOZJS_CFLAGS@
-builtin_libadd += @MOZJS_LIBS@
+builtin_libadd += plugins/libmozjsplugin.a @MOZJS_LIBS@ -lstdc++
+# similar to v8 if mozjs isn't enabled then
+# try to avoid using g++ by building a library
+# This is a bit funny because at first sight you would think that
+# the #if MOZJS would keep the builtin_sources from affecting the automake
+# choice of linker, but it doesn't.
+noinst_LIBRARIES += plugins/libmozjsplugin.a
+plugins_libmozjsplugin_a_SOURCES = plugins/mozjs.cpp
+plugins_libmozjsplugin_a_CXXFLAGS = $(AM_CFLAGS) @MOZJS_CFLAGS@ @DBUS_CFLAGS@
@GLIB_CFLAGS@
endif
if V8
@@ -137,16 +143,16 @@ unit_test_pacrunner_LDADD += @CURL_LIBS@
endif
if MOZJS
-unit_test_pacrunner_SOURCES += plugins/mozjs.c
-
+unit_test_pacrunner_SOURCES += plugins/mozjs.cpp
+unit_test_pacrunner_CXXFLAGS = $(AM_CFLAGS) @MOZJS_CFLAGS@
unit_test_pacrunner_LDADD += @MOZJS_LIBS@ @PTHREAD_LIBS@
noinst_PROGRAMS += unit/test-mozjs
unit_test_mozjs_SOURCES = unit/test-mozjs.c src/pacrunner.h \
src/proxy.c src/manual.c src/download.c \
- src/js.c plugins/mozjs.c $(js_sources)
-
+ src/js.c plugins/mozjs.cpp $(js_sources)
+unit_test_mozjs_CXXFLAGS = $(AM_CFLAGS) @MOZJS_CFLAGS@
unit_test_mozjs_LDADD = @MOZJS_LIBS@ @GLIB_LIBS@ @PTHREAD_LIBS@
endif
diff --git a/configure.ac b/configure.ac
index 42a64a9..d2fc8f8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,8 +76,8 @@ AM_CONDITIONAL(DUKTAPE, test "${enable_duktape}" = "yes")
AC_ARG_ENABLE(mozjs, AC_HELP_STRING([--enable-mozjs],
[enable Mozilla Javascript plugin support]))
if (test "${enable_mozjs}" = "yes"); then
- PKG_CHECK_MODULES(MOZJS, mozjs185, dummy=yes,
- AC_MSG_ERROR(Mozilla Javascript >= 1.8 is required))
+ PKG_CHECK_MODULES(MOZJS, mozjs-24, dummy=yes,
+ AC_MSG_ERROR(Mozilla Javascript >= 24 is required))
AC_SUBST(MOZJS_CFLAGS)
AC_SUBST(MOZJS_LIBS)
fi
diff --git a/plugins/mozjs.c b/plugins/mozjs.cpp
similarity index 82%
rename from plugins/mozjs.c
rename to plugins/mozjs.cpp
index a923203..843b2fa 100644
--- a/plugins/mozjs.c
+++ b/plugins/mozjs.cpp
@@ -34,8 +34,10 @@
#include <jsapi.h>
#pragma GCC diagnostic error "-Wredundant-decls"
+extern "C" {
#include "pacrunner.h"
#include "js.h"
+}
static pthread_mutex_t mozjs_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -43,11 +45,12 @@ struct pacrunner_mozjs {
struct pacrunner_proxy *proxy;
JSContext *jsctx;
JSObject *jsobj;
+ JSAutoCompartment *jsac;
};
-static JSBool myipaddress(JSContext *jsctx, uintN argc, jsval *vp)
+static JSBool myipaddress(JSContext *jsctx, unsigned argc, jsval *vp)
{
- struct pacrunner_mozjs *ctx = JS_GetContextPrivate(jsctx);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)JS_GetContextPrivate(jsctx);
char address[NI_MAXHOST];
DBG("");
@@ -68,9 +71,9 @@ static JSBool myipaddress(JSContext *jsctx, uintN argc, jsval
*vp)
return JS_TRUE;
}
-static JSBool dnsresolve(JSContext *jsctx, uintN argc, jsval *vp)
+static JSBool dnsresolve(JSContext *jsctx, unsigned argc, jsval *vp)
{
- struct pacrunner_mozjs *ctx = JS_GetContextPrivate(jsctx);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)JS_GetContextPrivate(jsctx);
char address[NI_MAXHOST];
jsval *argv = JS_ARGV(jsctx, vp);
char *host = JS_EncodeString(jsctx, JS_ValueToString(jsctx, argv[0]));
@@ -97,10 +100,10 @@ static JSBool dnsresolve(JSContext *jsctx, uintN argc,
jsval *vp)
static JSClass jscls = {
"global", JSCLASS_GLOBAL_FLAGS,
- JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
+ JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub,
JS_StrictPropertyStub,
- JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+ JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, NULL,
+ JSCLASS_NO_OPTIONAL_MEMBERS
};
static JSRuntime *jsrun;
@@ -115,7 +118,7 @@ static int create_object(struct pacrunner_proxy *proxy)
if (!script)
return 0;
- ctx = g_malloc0(sizeof(struct pacrunner_mozjs));
+ ctx = (pacrunner_mozjs *)g_malloc0(sizeof(struct pacrunner_mozjs));
ctx->proxy = proxy;
ctx->jsctx = JS_NewContext(jsrun, 8 * 1024);
@@ -126,12 +129,10 @@ static int create_object(struct pacrunner_proxy *proxy)
JS_SetContextPrivate(ctx->jsctx, ctx);
__pacrunner_proxy_set_jsctx(proxy, ctx);
-#if JS_VERSION >= 185
- ctx->jsobj = JS_NewCompartmentAndGlobalObject(ctx->jsctx, &jscls,
- NULL);
-#else
- ctx->jsobj = JS_NewObject(ctx->jsctx, &jscls, NULL, NULL);
-#endif
+ JS::CompartmentOptions compart_opts;
+ compart_opts.setVersion(JSVERSION_LATEST);
+ ctx->jsobj = JS_NewGlobalObject(ctx->jsctx, &jscls, NULL, compart_opts);
+ ctx->jsac = new JSAutoCompartment(ctx->jsctx, ctx->jsobj);
if (!JS_InitStandardClasses(ctx->jsctx, ctx->jsobj))
pacrunner_error("Failed to init JS standard classes");
@@ -152,13 +153,14 @@ static int create_object(struct pacrunner_proxy *proxy)
static int mozjs_clear_proxy(struct pacrunner_proxy *proxy)
{
- struct pacrunner_mozjs *ctx = __pacrunner_proxy_get_jsctx(proxy);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)__pacrunner_proxy_get_jsctx(proxy);
DBG("proxy %p ctx %p", proxy, ctx);
if (!ctx)
return -EINVAL;
+ delete ctx->jsac;
JS_DestroyContext(ctx->jsctx);
__pacrunner_proxy_set_jsctx(proxy, NULL);
@@ -180,7 +182,7 @@ static int mozjs_set_proxy(struct pacrunner_proxy *proxy)
static char * mozjs_execute(struct pacrunner_proxy *proxy, const char *url,
const char *host)
{
- struct pacrunner_mozjs *ctx = __pacrunner_proxy_get_jsctx(proxy);
+ struct pacrunner_mozjs *ctx = (pacrunner_mozjs
*)__pacrunner_proxy_get_jsctx(proxy);
JSBool result;
jsval rval, args[2];
char *answer, *g_answer;
@@ -229,7 +231,7 @@ static int mozjs_init(void)
{
DBG("");
- jsrun = JS_NewRuntime(8 * 1024 * 1024);
+ jsrun = JS_NewRuntime(8 * 1024 * 1024, JS_USE_HELPER_THREADS);
return pacrunner_js_driver_register(&mozjs_driver);
}
--
2.9.2
------------------------------
Message: 3
Date: Wed, 31 Aug 2016 14:14:02 -0700
From: Naveen Singh <[email protected]>
To: Marcel Holtmann <[email protected]>
Cc: Patrik Flykt <[email protected]>, [email protected]
Subject: Re: Connman on Android/Brillo
Message-ID:
<caewpxkyh3xudyvpnvczg6-rsiednyjodcxnq3ndgsp92qbu...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi Marcel
On Sat, Aug 27, 2016 at 7:12 AM, Marcel Holtmann <[email protected]>
wrote:
> Hi Naveen,
>
> > > I had this talk with Marcel few weeks back about compiling connman on
> > > Android/Brillo. This would surely give connman the penetration into
> > > Android world and future IoT devices which are based of Brillo.
> > >
> > > I actually got it compiled and working. There are two challenges:
> > >
> > > a) Some of the libraries that are required by connman are missing.
> > > For
> > > my work I got those libraries compiled first.
> > >
> > > b) Changes in connman itself: Open source connman does not compile as
> > > such for Android/Brillo. There are some changes needed in connman to
> > > get this going. I would like to see if we can upstream these changes.
> > >
> > > The intent of this email is to discuss those changes. Following are
> > > the changes needed:
> > >
> > > 1) Backtrace system call: In log.c from function print_backtrace we
> > > call backtrace. It is a glibc API and is no present in bionic. There
> > > is an equivalent function in bionic for doing this.
> >
> > Backtrace printing was moved to its own file, src/backtrace.c, in
> > ConnMan 1.32, so this is just an automake check away.
> >
> > > 2) hard check for ns_initparse in libresolv.so: There is no
> > > libresolv.so for android/Brillo. All these ns_* symbols are part of
> > > libc.so. So hard check has to go. We may need to check in
> > > configure.ac
> > > whether we are compiling against glibc or bionic early on and do
> > > stuff
> > > differently.
> >
> > Yes, some automake magic needed.
> >
> > > 3) NTP code calls adjtime to adjust clock. This function is missing
> > > in
> > > bionic. We may need to find a similar function in bionic for doing
> > > this.
> >
> > The adjtimex patch on the ml will probably solve this. I'll take a look
> > at that patch nextish.
> >
> > > 4) struct in6_pktinfo is defined in connman code (file
> > > gdhcp/common.h)
> > > under #ifndef __USE_GNU. Now this structure is defined in bionic
> > > header file libc/kernel/uapi/ipv6.h. Not sure what is the intent of
> > > #ifndef __USE_GNU? Should this go away? Similarly struct in6_ifreq is
> > > defined in inet.c file and it is also defined in the same bionic
> > > header file. I had to comment out this definition to compile connman.
> >
> > See commit message for e8784053a0a680ec8943ff20559c6561cb5b9a96.
> > For struct in6_ifreq it looks like very old code that should be fixed.
> >
> > > 5) Some of the structures which are needed for connman compilation
> > > are
> > > defined under #ifdef __USE_BSD in bionic header file. For Bionic
> > > __USE_BSD is defined only if _GNU_SOURCE is defined. So for those
> > > files in connman we have to define _GNU_SOURCE as the first line in
> > > that file. Example is ipv4ll.c. I hope this should be OK.
> >
> > I'd like to keep the files as clean as possible. Looking at autoconf
> > magic, it seems to be possible to use AC_DEFINE to add values to the
> > generated config.h file, which is included first. config.h is used
> > everywhere and should be the first file included. So could one add the
> > needed defines in order to config.h with AC_DEFINE instead? And/or the
> > use of bionic, if needed?
> >
> > > 6) GResolv structure in gresolv.c: struct __res_state is a member for
> > > GResolv structure. This structure is defined in resolv.h file in
> > > glibc. struct __res_state in bionic requires inclusion of two other
> > > header files resolv_private.h and res_private. Also this structure is
> > > defined very differently between bionic and glibc. This caused
> > > changes
> > > in gresolv.c, the way it accesses various members of this structure.
> >
> > Ok, sounds a bit more complicated. You should perhaps post an RFC patch
> > for this so we have an idea of how complicated it becomes.
> >
> > > 7) Struct sockaddr_in6 defined differently b/w bionic and glibc.
> >
> > What is the difference here? Something that does not compile on both
> > "platforms"?
> >
> > > 8) ETH_ALEN is not defined in bionic header file
> >
> > Should be easy once we know bionic is being used.
> >
> > > 9) Need to include resolv_params.h in resolver.c. This is because
> > > "MAXDNSRCH" etc is defined in resolv_params.h in bionic.
> >
> > Automake/conf magic, I hope.
> >
> > > 10) Needed to remove "-lresolv -lrt" from Makefile.am.
> >
> > As above, I hope.
> >
> > > Some of these changes are easily doable if we can have #ifdef ANDROID
> > > in code. Through configure.ac we can detect if we are compiling
> > > against bionic or glibc and appropriately turn on this flag. Not sure
> > > what your thought are on this.
> >
> > I'd go for configure.ac, it makes the code cleaner and uses
> > autoconf/automake for it's intended purpose. Let's start with the easy
> > parts first.
> >
> > Thanks for the heads up!
> >
> >
> > Patrik
> > Something like this: (it may not be syntactically correct)
> > with_android=no
> > AC_MSG_CHECKING([checking for android])
> > case "${host}" in
> >
> > *android*)
> > with_android=yes
> > ;;
> >
> > *)
> > AM_CONDITIONAL([BIONIC], [test "${with_android}" = "yes"])
>
> this should be the last resort in handling it. BlueZ for Android can
> compile either with glibc/musl or with Bionic. And I think we should get to
> the level where we do not have huge difference.
>
> That said, I recognize that Bionic is just plain ancient and missing
> anything modern. Which is the biggest pain. Especially with networking
> capabilities it seems it never caught up to anything recent. I would
> actually try to detect every missing piece individually and not just use a
> big hammer like HAVE_BIONIC.
>
> With that in mind, lets just get patches to the mailing list and together
> figure out a way to make this least intrusive to the code base. It is not
> the first time we dealt with Android specific, but this might be the most
> painful one since ConnMan uses a lot of low-level stuff.
>
> Regards
>
> Marcel
>
I will send my patches. It may be very difficult to handle all of them
without doing some autoconf magic. For example we have a hard check for
looking for ns_initparse in resolver library. ns_initparse and all other
ns_* functions which connman uses in fact is present in bionic but it is a
part of libc.so. I am not sure if it would be correct to make these
functions part of connman. It would probably be much easier to look for
this function in libc.so once we detect that we are compiling against
bionic.
Similarly for backtrace support we do detect whether we have execinfo.h
header file or not. If we have that file then we implement print_backtrace
otherwise it is empty. I was thinking of enhancing that implementation by
using android specific function when we detect we do not have execinfo.h
header file and we are compiling against bionic.
Regards
Naveen
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.01.org/pipermail/connman/attachments/20160831/19dd9850/attachment-0001.html>
------------------------------
Message: 4
Date: Thu, 1 Sep 2016 17:12:14 +0900
From: Eunok Lee <[email protected]>
To: Jose Blanquicet <[email protected]>
Cc: [email protected], [email protected], Tomasz
Bursztyka <[email protected]>, Patrik Flykt
<[email protected]>
Subject: Re: [PATCH 1/3] technology: Add specific D-Bus methods for
WPS connections
Message-ID:
<cafbyjonhv84e7mcu8odm3rzm283kuz_d_l3-v2gzjplzyau...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"
Hi Jose,
In my system, p2p-wlan0-x is the interface name for p2p group operation. x
is the integer value and is increasing for every new p2p group creation.
< P2P connection >
- P2PDevice.GONegotiationRequest is arrived on wlan0.
- After calling "Connect", the new interface for p2p group operation is
created on wpa-supplicant.
- WPS.Event is arrived on p2p-wlan0-x interface.
(wifi->p2p_connecting in wps_event() is false and is_p2p_connecting() is
true.)
< wps sta pbc connection >
- WPS.Event is arrrived on wlan0 interface.
The second idea is good, but it looks better checking p2p connecting. :)
Regards,
Eunok
2016-08-30 18:18 GMT+09:00 Jose Blanquicet <[email protected]>:
> Hi Eunok Lee,
>
> Thanks for your feedback.
>
> > I applied the changes to my local source code(based on connman 1.29) for
> > testing, and got some issue.
> > When trying to establish p2p connection for using Miracast, it's failed.
> > Though, the issue has gone with the below change.
> > I'm not sure if this issue occurs only on connman 1.29, but would like to
> > share this issue to you.
> >
> > --- a/connman/plugins/wifi.c
> > +++ b/connman/plugins/wifi.c
> > @@ -3183,7 +3183,7 @@ static void wps_event(GSupplicantInterface
> *interface,
> > struct wifi_data *wifi = g_supplicant_interface_get_
> data(interface);
> >
> > /* Do nothing here for P2P Connections */
> > - if (wifi->p2p_connecting)
> > + if (is_p2p_connecting())
> > return;
> >
> > switch (state) {
>
> is_p2p_connecting() checks if any interface has started a p2p
> connection, instead what I did by checking the value of
> wifi->p2p_connecting is to check if the specific interface on which
> the event has arrived has started a p2p connection. Therefore, if for
> you the current implementation does not work, it makes me think that
> in your system the wpa_supplicant has been configured to create a
> separated interface for p2p group operations, right? Although the
> creation of that separated interface is the default behavior of the
> wpa_supplicant there are many drives that do not support it, for
> example my driver does not, so I did not test the patch with such a
> configuration, sorry about that :(.
>
> I think your proposed solution could have problems when WPS and P2P
> are running concurrently in different interfaces, because the fact
> that P2P is also connecting on any interface will result in the
> discard of all the events, even the ones related to WPS which we do
> not want to discard. I will study the following two ideas, the first
> one is to check only in the original P2P interface if P2P is
> connection instead of doing on all the interfaces. On the other hand,
> a second idea could be to define a "wps_connecting" flag, doing so we
> can check if WPS is connecting instead of check if p2p is connection.
> Suggestion/Comments?
>
> > And it looks like every dbus_malloc0 needs to check if it's NULL and
> return
> > -ENOMEM. :)
>
> You are right. In fact, I will move to glib memory functions as Tomasz
> suggested in order to not introduce more inconsistency because of the
> mixed used of glib and dbus.
>
> Regards,
>
> Jose Blanquicet
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.01.org/pipermail/connman/attachments/20160901/1fb21613/attachment.html>
------------------------------
Subject: Digest Footer
_______________________________________________
connman mailing list
[email protected]
https://lists.01.org/mailman/listinfo/connman
------------------------------
End of connman Digest, Vol 11, Issue 1
**************************************