Skip to contentSkip to conversation

libc-compat.h: prevent redefinition of struct ethhdr

PATCH New David Heidelberger 1 participant 1 message Mar 14, 2014 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 libc-compat.h: prevent redefinition of struct ethhdr

---
 include/uapi/linux/if_ether.h    | 4 +++-
 include/uapi/linux/libc-compat.h | 6 ++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
include/uapi/linux/if_ether.h +1 -0
index 2ce0f6a..18cfb23 100644
@@ -22,6 +22,7 @@
 #define _UAPI_LINUX_IF_ETHER_H
 
 #include <linux/types.h>
+#include <linux/libc-compat.h>
 
 /*
  *	IEEE 802.3 Ethernet magic constants.  The frame sizes omit the 

preamble
@@ -131,11 +132,12 @@
* This is an Ethernet frame header.
*/

+#if __UAPI_DEF_ETHHDR
struct ethhdr {
unsigned char h_dest[ETH_ALEN]; /* destination eth addr */
unsigned char h_source[ETH_ALEN]; /* source ether addr */
__be16 h_proto; /* packet type ID field */
} __attribute__((packed));
-
+#endif

#endif /* _UAPI_LINUX_IF_ETHER_H */

include/uapi/linux/libc-compat.h +6 -0
index c16c34c..c491d7a 100644
@@ -50,6 +50,12 @@
 
 #ifndef __KERNEL__ /* we're used from userspace */
 
+#ifdef _NETINET_IF_ETHER_H /* musl */
+#define __UAPI_DEF_ETHHDR 0
+#else /* glibc uses __NETINET_IF_ETHER_H, and includes the kernel header. */
+#define __UAPI_DEF_ETHHDR 1
+#endif
+
 /* Coordinate with libc netinet/in.h header. */
 #ifdef _NETINET_IN_H
 
Signature · 1 line
1.8.4