From ae90406453eb894400a25e0557bb2c7bf19f06a4 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 7 Aug 2013 02:05:53 +0200 Subject: Define ethhdr when it is not available --- CMakeLists.txt | 8 ++++++++ config.h.in | 3 +++ src/compat.h | 13 +++++++++++++ 3 files changed, 24 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf0f5f7..942f5ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,14 @@ else() set(LINUX FALSE) endif() + +set(CMAKE_EXTRA_INCLUDE_FILES "netinet/if_ether.h") +include(CheckTypeSize) + +check_type_size("struct ethhdr" SIZEOF_ETHHDR) +string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_ETHHDR) + + set(WITH_CAPABILITIES ${LINUX} CACHE BOOL "Include support for POSIX capabilities") if(WITH_CAPABILITIES) diff --git a/config.h.in b/config.h.in index 0ad647c..1e094da 100644 --- a/config.h.in +++ b/config.h.in @@ -27,6 +27,9 @@ #ifndef _FASTD_CONFIG_H_ #define _FASTD_CONFIG_H_ +#cmakedefine HAVE_ETHHDR + + #cmakedefine WITH_CAPABILITIES #cmakedefine USE_CRYPTO_AES128CTR diff --git a/src/compat.h b/src/compat.h index e127dba..6afcbad 100644 --- a/src/compat.h +++ b/src/compat.h @@ -27,6 +27,11 @@ #ifndef _FASTD_COMPAT_H_ #define _FASTD_COMPAT_H_ +#include + +#include + + #ifndef ETH_ALEN #define ETH_ALEN 6 #endif @@ -35,4 +40,12 @@ #define ETH_HLEN 14 #endif +#ifndef HAVE_ETHHDR +struct ethhdr { + uint8_t h_dest[ETH_ALEN]; + uint8_t h_source[ETH_ALEN]; + uint16_t h_proto; +} __attribute__((packed)); +#endif + #endif /* _FASTD_COMPAT_H_ */ -- cgit v1.2.3