From 6289859ab365dc1c0d420323174418b316b14502 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Mon, 20 Feb 2012 15:44:52 +0100 Subject: [PATCH] Only compile raw socket code when it is supported on that platform. --- configure.in | 2 +- src/raw_socket_device.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index c8cc2031..4d6a9493 100644 --- a/configure.in +++ b/configure.in @@ -119,7 +119,7 @@ dnl We do this in multiple stages, because unlike Linux all the other operating AC_HEADER_STDC AC_CHECK_HEADERS([stdbool.h syslog.h sys/file.h sys/ioctl.h sys/mman.h sys/param.h sys/resource.h sys/socket.h sys/time.h time.h sys/uio.h sys/wait.h netdb.h arpa/inet.h dirent.h]) -AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h], +AC_CHECK_HEADERS([net/if.h net/if_types.h linux/if_tun.h net/if_tun.h net/tun/if_tun.h net/if_tap.h net/tap/if_tap.h net/ethernet.h net/if_arp.h netinet/in_systm.h netinet/in.h netinet/in6.h netpacket/packet.h], [], [], [#include "have.h"] ) AC_CHECK_HEADERS([netinet/if_ether.h netinet/ip.h netinet/ip6.h], diff --git a/src/raw_socket_device.c b/src/raw_socket_device.c index e2692ecc..b9671e3e 100644 --- a/src/raw_socket_device.c +++ b/src/raw_socket_device.c @@ -20,7 +20,9 @@ #include "system.h" +#ifdef HAVE_NETPACKET_PACKET_H #include +#endif #include "conf.h" #include "device.h" @@ -35,6 +37,7 @@ static char *device_info; static uint64_t device_total_in = 0; static uint64_t device_total_out = 0; +#if defined(PF_SOCKET) && defined(ETH_P_ALL) && defined(AF_PACKET) static bool setup_device(void) { struct ifreq ifr; struct sockaddr_ll sa; @@ -135,3 +138,19 @@ const devops_t raw_socket_devops = { .write = write_packet, .dump_stats = dump_device_stats, }; + +#else + +static bool not_supported(void) { + logger(LOG_ERR, "Raw socket device not supported on this platform"); + return false; +} + +const devops_t raw_socket_devops = { + .setup = not_supported, + .close = NULL, + .read = NULL, + .write = NULL, + .dump_stats = NULL, +}; +#endif -- 2.20.1