--- a/cmake/checks.cmake +++ b/cmake/checks.cmake @@ -54,9 +54,13 @@ if(NOT DARWIN) endif(NOT DARWIN) +set(CMAKE_EXTRA_INCLUDE_FILES "linux/if_ether.h") +check_type_size("struct ethhdr" SIZEOF_ETHHDR) +string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_LINUX_ETHHDR) + set(CMAKE_EXTRA_INCLUDE_FILES "netinet/if_ether.h") check_type_size("struct ethhdr" SIZEOF_ETHHDR) -string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_ETHHDR) +string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_NETINET_ETHHDR) set(CMAKE_REQUIRED_INCLUDES "sys/types.h") --- a/src/compat.h +++ b/src/compat.h @@ -45,7 +45,12 @@ #include #include #include + +#if defined(HAVE_LINUX_ETHHDR) +#include +#elif defined(HAVE_NETINET_ETHHDR) #include +#endif #ifndef ETH_ALEN /** The length of a MAC address */ @@ -55,9 +60,8 @@ #ifndef ETH_HLEN /** The length of the standard ethernet header */ #define ETH_HLEN 14 -#endif -#ifndef HAVE_ETHHDR +#if !defined(HAVE_LINUX_ETHHDR) && !defined(HAVE_NETINET_ETHHDR) /** An ethernet header */ struct ethhdr { uint8_t h_dest[ETH_ALEN]; /**< The destination MAC address field */ @@ -65,6 +69,7 @@ struct ethhdr { uint16_t h_proto; /**< The EtherType/length field */ } __attribute__((packed)); #endif +#endif #if defined(USE_FREEBIND) && !defined(IP_FREEBIND) /** Compatiblity define for systems supporting, but not defining IP_FREEBIND */ --- a/src/fastd_config.h.in +++ b/src/fastd_config.h.in @@ -35,8 +35,11 @@ /** Defined if the platform supports the AI_ADDRCONFIG flag to getaddrinfo() */ #cmakedefine HAVE_AI_ADDRCONFIG -/** Defined if the platform defines the \e ethhdr struct */ -#cmakedefine HAVE_ETHHDR +/** Defined if the platform defines the \e ethhdr struct through linux/if_ether.h */ +#cmakedefine HAVE_LINUX_ETHHDR + +/** Defined if the platform defines the \e ethhdr struct through netinet/if_ether.h */ +#cmakedefine HAVE_NETINET_ETHHDR /** Defined if the platform defines get_current_dir_name() */ #cmakedefine HAVE_GET_CURRENT_DIR_NAME