summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt7
-rw-r--r--config.h.in1
-rw-r--r--src/compat.h16
3 files changed, 23 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d66ada..c9c76d5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -26,12 +26,17 @@ else()
endif()
-set(CMAKE_EXTRA_INCLUDE_FILES "netinet/if_ether.h")
+include(CheckPrototypeDefinition)
include(CheckTypeSize)
+set(CMAKE_EXTRA_INCLUDE_FILES "netinet/if_ether.h")
+set(CMAKE_REQUIRED_DEFINITIONS "-D_GNU_SOURCE")
+
+check_prototype_definition("get_current_dir_name" "char *get_current_dir_name(void)" "NULL" "unistd.h" HAVE_GET_CURRENT_DIR_NAME)
check_type_size("struct ethhdr" SIZEOF_ETHHDR)
string(COMPARE NOTEQUAL "${SIZEOF_ETHHDR}" "" HAVE_ETHHDR)
+
set(USE_BINDTODEVICE ${LINUX})
set(USE_PMTU ${LINUX})
set(USE_PKTINFO ${LINUX})
diff --git a/config.h.in b/config.h.in
index 4a33d23..cd71d3d 100644
--- a/config.h.in
+++ b/config.h.in
@@ -28,6 +28,7 @@
#define _FASTD_CONFIG_H_
#cmakedefine HAVE_ETHHDR
+#cmakedefine HAVE_GET_CURRENT_DIR_NAME
#cmakedefine USE_BINDTODEVICE
diff --git a/src/compat.h b/src/compat.h
index 6afcbad..5a24a97 100644
--- a/src/compat.h
+++ b/src/compat.h
@@ -30,6 +30,7 @@
#include <config.h>
#include <stdint.h>
+#include <unistd.h>
#ifndef ETH_ALEN
@@ -48,4 +49,19 @@ struct ethhdr {
} __attribute__((packed));
#endif
+
+#ifndef HAVE_GET_CURRENT_DIR_NAME
+
+#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
+static inline char *get_current_dir_name(void) {
+ return getcwd(NULL, 0);
+}
+#else
+
+#error unknown system, get_current_dir_name() not implemented
+
+#endif
+
+#endif
+
#endif /* _FASTD_COMPAT_H_ */