1 From eec38a200357b195efbb23bb645ab721c040f246 Mon Sep 17 00:00:00 2001
2 From: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
3 Date: Thu, 3 Nov 2016 12:59:39 +0000
4 Subject: [PATCH] iptunnel.c: do not include netinet/ip.h
6 This fixes a struct redefinition problem like this one:
8 ================================
9 In file included from /usr/include/linux/if_tunnel.h:6:0,
11 /usr/include/linux/ip.h:85:8: error: redefinition of 'struct iphdr'
14 In file included from iptunnel.c:29:0:
15 /usr/include/netinet/ip.h:45:8: note: originally defined here
18 ================================
20 iptunnel.c includes netinet/ip.h which contains a definition of the
23 iptunnel.c also includes linux/if_tunnel.h which includes linux/ip.h
24 which contains a definition of the iphdr struct.
26 So, both netinet/ip.h and linux/ip.h define the iphdr struct, and both
27 of them have been included directly or indirectly by iptunnel.c. Because
28 of that the compilation fails due to a struct redefinition.
30 The problem can be solved by just not including netinet/ip.h.
32 However, some Linux headers included in certain toolchains may not have
33 an updated linux/if_tunnel.h which includes linux/ip.h, so we need to
34 include it unconditionally otherwise linux/if_tunnel.h will use the
35 struct iphdr before being defined and the compilation will also fail in
38 ================================
39 In file included from iptunnel.c:33:0:
40 /usr/include/linux/if_tunnel.h:37:16: error: field 'iph' has incomplete type
43 ================================
45 Upstream status: merge request sent
46 https://sourceforge.net/p/net-tools/code/merge-requests/4/
48 Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
51 1 file changed, 1 insertion(+), 1 deletion(-)
53 diff --git a/iptunnel.c b/iptunnel.c
54 index 3fe1b84..e2ec2d8 100644
58 #include <sys/socket.h>
59 #include <sys/ioctl.h>
60 #include <netinet/in.h>
61 -#include <netinet/ip.h>
62 #include <arpa/inet.h>
64 #include <net/if_arp.h>
65 #include <linux/types.h>
66 +#include <linux/ip.h>
67 #include <linux/if_tunnel.h>