1 Remove kernel header includes causing issues with musl
3 Include the kernel headers from netfilter causes a conflict with the
4 <netinet/in.h> way of defining the IPPROTO_* constants, resulting in
5 the following build failure:
7 In file included from /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/netdb.h:9:0,
8 from /home/peko/autobuild/instance-0/output/build/norm-1.5r6/protolib/include/protoAddress.h:13,
9 from /home/peko/autobuild/instance-0/output/build/norm-1.5r6/protolib/include/protoDetour.h:5,
10 from ../protolib/src/linux/linuxDetour.cpp:3:
11 /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:28:3: error: expected identifier before numeric constant
12 IPPROTO_IP = 0, /* Dummy protocol for TCP */
14 /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:28:3: error: expected '}' before numeric constant
15 /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:28:3: error: expected unqualified-id before numeric constant
16 In file included from /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/netfilter.h:7:0,
17 from /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/netfilter_ipv4.h:8,
18 from ../protolib/src/linux/linuxDetour.cpp:10:
19 /home/peko/autobuild/instance-0/output/host/usr/arm-buildroot-linux-musleabihf/sysroot/usr/include/linux/in.h:79:1: error: expected declaration before '}' token
23 Since from musl's developers perspective including kernel headers is
24 seen as being unsafe, we simply duplicate the necessary netfilter
25 definitions (there are just a few) instead of including some kernel
28 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
30 Index: b/protolib/src/linux/linuxDetour.cpp
31 ===================================================================
32 --- a/protolib/src/linux/linuxDetour.cpp
33 +++ b/protolib/src/linux/linuxDetour.cpp
35 #include <stdlib.h> // for atoi(), getenv()
37 #include <unistd.h> // for close()
38 -#include <linux/netfilter_ipv4.h> // for NF_IP_LOCAL_OUT, etc
39 -#include <linux/netfilter_ipv6.h> // for NF_IP6_LOCAL_OUT, etc
40 -#include <linux/netfilter.h> // for NF_ACCEPT, etc
41 #include <libnetfilter_queue/libnetfilter_queue.h>
43 #include <fcntl.h> // for fcntl(), etc
44 #include <linux/if_ether.h> // for ETH_P_IP
45 #include <net/if_arp.h> // for ARPHRD_ETHER
47 +/* From netfilter kernel headers */
48 +#define NF_IP_LOCAL_OUT 3
55 * 1) This newer implementation of LinuxDetour uses netfilter_queue