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.
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
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
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.
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.
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.
7) Struct sockaddr_in6 defined differently b/w bionic and glibc.
8) ETH_ALEN is not defined in bionic header file
9) Need to include resolv_params.h in resolver.c. This is because
"MAXDNSRCH" etc is defined in resolv_params.h in bionic.
10) Needed to remove "-lresolv -lrt" from Makefile.am.
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.