summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2017-05-10 10:56:26 +0200
committerTobias Klauser <tklauser@distanz.ch>2017-05-10 11:01:20 +0200
commitb25a51fa5915df87f31a0cc0459cd9f05e17f540 (patch)
tree1b22ab8550889f1270d938aa084ee9b792265409
parent977a0f81d1e7dcd746fb22b3f972578e996e86d3 (diff)
all: use <net/*> headers instead of <linux/*> where possible
The musl libc headers redefine some of the structs in linux/if_arp.h and linux/if_ether.h, leading to compilation errors. Fix those by using the libc provided versions of these headers and provide compatibility defines for those that aren't present in older glibc versions. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
-rw-r--r--astraceroute.c2
-rw-r--r--built_in.h16
-rw-r--r--dev.c4
-rw-r--r--pcap_io.h2
-rw-r--r--proto_nlmsg.c1
5 files changed, 19 insertions, 6 deletions
diff --git a/astraceroute.c b/astraceroute.c
index ca47ba0..91674e6 100644
--- a/astraceroute.c
+++ b/astraceroute.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <asm/byteorder.h>
#include <linux/tcp.h>
+#include <netinet/if_ether.h>
#include <netinet/ip.h>
#include <netinet/ip6.h>
#include <netinet/in.h>
@@ -28,7 +29,6 @@
#include <netdb.h>
#include <sys/time.h>
#include <arpa/inet.h>
-#include <linux/if_ether.h>
#include <linux/icmp.h>
#include <linux/icmpv6.h>
diff --git a/built_in.h b/built_in.h
index d10579a..bb24746 100644
--- a/built_in.h
+++ b/built_in.h
@@ -382,10 +382,26 @@ static inline u64 cpu_to_le64(u64 val)
# define PACKET_QDISC_BYPASS 20
#endif
+#ifndef ARPHRD_CAN
+# define ARPHRD_CAN 280
+#endif
+
#ifndef ARPHRD_IEEE802154_MONITOR
# define ARPHRD_IEEE802154_MONITOR 805
#endif
+#ifndef ARPHRD_PHONET
+# define ARPHRD_PHONET 820
+#endif
+
+#ifndef ARPHRD_PHONET_PIPE
+# define ARPHRD_PHONET_PIPE 821
+#endif
+
+#ifndef ARPHRD_CAIF
+# define ARPHRD_CAIF 822
+#endif
+
#ifndef ARPHRD_IP6GRE
# define ARPHRD_IP6GRE 823
#endif
diff --git a/dev.c b/dev.c
index b509aee..82d97d2 100644
--- a/dev.c
+++ b/dev.c
@@ -3,7 +3,7 @@
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/socket.h>
-#include <linux/if_arp.h>
+#include <net/if_arp.h>
#include <ifaddrs.h>
#include <arpa/inet.h>
@@ -385,10 +385,8 @@ const char *device_type2str(uint16_t type)
return "phonet";
case ARPHRD_PHONET_PIPE:
return "phonet_pipe";
-#if defined(ARPHRD_CAIF)
case ARPHRD_CAIF:
return "caif";
-#endif
case ARPHRD_IP6GRE:
return "ip6gre";
case ARPHRD_NETLINK:
diff --git a/pcap_io.h b/pcap_io.h
index 3d70b21..af5ce8e 100644
--- a/pcap_io.h
+++ b/pcap_io.h
@@ -14,9 +14,9 @@
#include <errno.h>
#include <sys/time.h>
#include <sys/socket.h>
+#include <net/if_arp.h>
#include <linux/if.h>
#include <linux/if_packet.h>
-#include <linux/if_arp.h>
#include "built_in.h"
#include "die.h"
diff --git a/proto_nlmsg.c b/proto_nlmsg.c
index f206405..58bf715 100644
--- a/proto_nlmsg.c
+++ b/proto_nlmsg.c
@@ -12,7 +12,6 @@
#include <netlink/msg.h>
#include <netlink/route/link.h>
#include <netlink/route/addr.h>
-#include <linux/if_arp.h>
#include <arpa/inet.h>
#include "dev.h"