diff options
author | Sam Protsenko <semen.protsenko@linaro.org> | 2018-05-05 23:29:54 +0300 |
---|---|---|
committer | Sam Protsenko <semen.protsenko@linaro.org> | 2018-07-04 17:34:01 +0300 |
commit | da34949ce33819fa336f311f0fc1c1509925a40a (patch) | |
tree | 2d1057b92fd46598ee89fd13d54e13c61ae80618 | |
parent | c976b782201514779dd67013d6c57f2a219023c6 (diff) | |
download | ppp-da34949ce33819fa336f311f0fc1c1509925a40a.tar.gz |
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>
-rw-r--r-- | pppd/include/net/ppp_defs.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/pppd/include/net/ppp_defs.h b/pppd/include/net/ppp_defs.h index a21afdb..9522290 100644 --- a/pppd/include/net/ppp_defs.h +++ b/pppd/include/net/ppp_defs.h @@ -38,6 +38,10 @@ #ifndef _PPP_DEFS_H_ #define _PPP_DEFS_H_ +#if defined(__linux__) +#include <linux/ppp_defs.h> +#endif + #if defined(PPP_ADDRESS) #define USING_UAPI #endif @@ -131,6 +135,10 @@ typedef u_int32_t ext_accm[8]; * What to do with network protocol (NP) packets. */ #if defined(USING_UAPI) + +/* For struct ifreq */ +#include <net/if.h> + /* This stuff isn't in uapi. TODO: is there a newer pppd that doesn't use this? */ #define ifr__name b.ifr_ifrn.ifrn_name #define stats_ptr b.ifr_ifru.ifru_data |