pppd: Fix pppol2tp-android.so build
This patch enables USING_UAPI for pppol2tp-android plugin and fixes
related build errors.
1. Enable USING_UAPI for pppol2tp-android build. When trying to build
pppol2tp-android.so as is (in current pppd codebase) we will see build
errors like this one:
bionic/libc/kernel/uapi/linux/ppp_defs.h:59:6:
error: redefinition of 'NPmode'
external/ppp/pppd/include/net/ppp_defs.h:142:6:
note: previous definition is here
This is basically because USING_API option is not defined when building
pppol2tp-android.c, though it should be. Enabling that option fixes the
build. Detailed explanation is below.
Unlike the upstream pppd project, we don't keep include/linux/* headers
inside of pppd codebase. Instead, we define USING_UAPI when such headers
(user-space API [1]) are used, providing missing functionality in
ppp_defs.h file. From pppol2tp-android.c file it's obvious that UAPI is
used there (as linux/* files are included there). So we need to enable
USING_UAPI definition. Whether UAPI can be used or not is checked by
inspecting PPP_ADDRESS definition (if defined -- then we are actually
using UAPI, so USING_UAPI is defined). But for PPP_ADDRESS to be defined
we need to include <linux/ppp_defs.h> first (just like it's done in
sys-linux.c). So let's do that for all Linux systems, before actually
checking PPP_ADDRESS.
2. If we try to build pppol2tp-android plugin with current pppd
codebase, we will see next build errors (when USING_UAPI is enabled):
external/ppp/pppd/include/net/ppp_defs.h:142:17:
error: field has incomplete type 'struct ifreq'
external/ppp/pppd/include/net/ppp_defs.h:143:21:
error: field has incomplete type 'struct ppp_stats'
Let's include net/if.h for struct ifreq, and linux/ppp_defs.h for
struct ppp_stats.
[1] https://lwn.net/Articles/507794/
Change-Id: I3338a78b5579229ebe3dbd908a9a9f37aa63e042
Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
1 file changed