summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@ugent.be>2017-08-21 09:11:38 +0000
committerSander Vrijders <sander.vrijders@ugent.be>2017-08-21 09:11:38 +0000
commit5b242e7207483860143d3c84438134430ac1448f (patch)
treea04a750b802436a4e244d8224b800a2f26071091
parentafe8b6f496dd4e0e3aaaa5dec0d6fb32253a49f7 (diff)
parent8f58e5a3ec0e4a15fc8ae0911cc864f5dbf86c6e (diff)
downloadouroboros-5b242e7207483860143d3c84438134430ac1448f.tar.gz
ouroboros-5b242e7207483860143d3c84438134430ac1448f.zip
Merged in dstaesse/ouroboros/be-build (pull request #557)
build: Revise the build system
-rw-r--r--CMakeLists.txt32
-rw-r--r--doc/man/CMakeLists.txt2
-rw-r--r--include/ouroboros/CMakeLists.txt4
-rw-r--r--include/ouroboros/config.h.in88
-rw-r--r--include/ouroboros/endian.h51
-rw-r--r--include/ouroboros/wrap/CMakeLists.txt9
-rw-r--r--src/CMakeLists.txt3
-rw-r--r--src/ipcpd/CMakeLists.txt12
-rw-r--r--src/ipcpd/config.h.in (renamed from src/nsmd/main.c)33
-rw-r--r--src/ipcpd/ipcp.c19
-rw-r--r--src/ipcpd/ipcp.h12
-rw-r--r--src/ipcpd/local/CMakeLists.txt2
-rw-r--r--src/ipcpd/local/main.c34
-rw-r--r--src/ipcpd/normal/CMakeLists.txt11
-rw-r--r--src/ipcpd/normal/addr_auth.c1
-rw-r--r--src/ipcpd/normal/connmgr.c6
-rw-r--r--src/ipcpd/normal/dht.c5
-rw-r--r--src/ipcpd/normal/dir.c3
-rw-r--r--src/ipcpd/normal/dt.c5
-rw-r--r--src/ipcpd/normal/dt_pci.c1
-rw-r--r--src/ipcpd/normal/enroll.c4
-rw-r--r--src/ipcpd/normal/fa.c5
-rw-r--r--src/ipcpd/normal/gam.c3
-rw-r--r--src/ipcpd/normal/main.c5
-rw-r--r--src/ipcpd/normal/neighbors.c3
-rw-r--r--src/ipcpd/normal/pff.c5
-rw-r--r--src/ipcpd/normal/pol/complete.c3
-rw-r--r--src/ipcpd/normal/pol/flat.c3
-rw-r--r--src/ipcpd/normal/pol/graph.c3
-rw-r--r--src/ipcpd/normal/pol/link_state.c3
-rw-r--r--src/ipcpd/normal/pol/tests/graph_test.c3
-rw-r--r--src/ipcpd/normal/ribmgr.c3
-rw-r--r--src/ipcpd/normal/routing.c3
-rw-r--r--src/ipcpd/normal/sdu_sched.c5
-rw-r--r--src/ipcpd/shim-data.c5
-rw-r--r--src/ipcpd/shim-data.h6
-rw-r--r--src/ipcpd/shim-eth-llc/CMakeLists.txt62
-rw-r--r--src/ipcpd/shim-eth-llc/main.c84
-rw-r--r--src/ipcpd/shim-udp/CMakeLists.txt17
-rw-r--r--src/ipcpd/shim-udp/main.c40
-rw-r--r--src/ipcpd/shim-udp/shim_udp_config.h.in28
-rw-r--r--src/ipcpd/shim-udp/tests/CMakeLists.txt33
-rw-r--r--src/ipcpd/shim-udp/tests/shim_udp_test.c100
-rw-r--r--src/irmd/CMakeLists.txt22
-rw-r--r--src/irmd/api_table.c5
-rw-r--r--src/irmd/config.h.in46
-rw-r--r--src/irmd/ipcp.c5
-rw-r--r--src/irmd/irm_flow.c5
-rw-r--r--src/irmd/main.c8
-rw-r--r--src/irmd/registry.c5
-rw-r--r--src/irmd/registry.h1
-rw-r--r--src/irmd/utils.c3
-rw-r--r--src/lib/CMakeLists.txt104
-rw-r--r--src/lib/cacep.c3
-rw-r--r--src/lib/cdap.c3
-rw-r--r--src/lib/cdap_req.c5
-rw-r--r--src/lib/cdap_req.h1
-rw-r--r--src/lib/config.h.in57
-rw-r--r--src/lib/dev.c15
-rw-r--r--src/lib/frct_pci.c1
-rw-r--r--src/lib/hash.c3
-rw-r--r--src/lib/irm.c3
-rw-r--r--src/lib/lockfile.c15
-rw-r--r--src/lib/md5.c2
-rw-r--r--src/lib/nsm.c55
-rw-r--r--src/lib/random.c3
-rw-r--r--src/lib/rib.c5
-rw-r--r--src/lib/shm_flow_set.c43
-rw-r--r--src/lib/shm_rbuff.c7
-rw-r--r--src/lib/shm_rbuff_ll.c3
-rw-r--r--src/lib/shm_rbuff_pthr.c3
-rw-r--r--src/lib/shm_rdrbuff.c5
-rw-r--r--src/lib/sockets.c1
-rw-r--r--src/lib/tests/CMakeLists.txt8
-rw-r--r--src/lib/tests/rib_test.c3
-rw-r--r--src/lib/time_utils.c3
-rw-r--r--src/lib/timerwheel.c5
-rw-r--r--src/lib/tpm.c5
-rw-r--r--src/nsmd/CMakeLists.txt24
-rw-r--r--src/nsmd/tests/CMakeLists.txt19
-rw-r--r--src/tools/operf/operf.c1
-rw-r--r--src/tools/operf/operf_client.c4
-rw-r--r--src/tools/operf/operf_server.c4
-rw-r--r--src/tools/oping/CMakeLists.txt2
-rw-r--r--src/tools/oping/oping.c1
-rw-r--r--src/tools/oping/oping_client.c4
-rw-r--r--src/tools/oping/oping_server.c4
87 files changed, 645 insertions, 638 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ba56dc33..d4060d5f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,14 +10,10 @@ git_version_gen()
include(GNUInstallDirs)
set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
-set(PACKAGE_DESCRIPTION "The Ouroboros prototype"
- CACHE STRING "Package description")
-set(PACKAGE_URL "None"
- CACHE STRING "Package URL")
-set(PACKAGE_BUGREPORT "None"
- CACHE STRING "Packaged bug-report email")
-set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}"
- CACHE STRING "Package version")
+set(PACKAGE_DESCRIPTION "The Ouroboros prototype")
+set(PACKAGE_URL "None")
+set(PACKAGE_BUGREPORT "None")
+set(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}")
if (APPLE)
set(CMAKE_MACOSX_RPATH 1)
@@ -72,15 +68,11 @@ test_and_set_c_compiler_flag_global(-Wunreachable-code)
test_and_set_c_compiler_flag_global(-Wdeclaration-after-statement)
test_and_set_c_compiler_flag_global(-fmax-errors=5)
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.pc.in"
- "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc"
- @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc" @ONLY)
-if (NOT APPLE)
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc"
- DESTINATION "/usr/lib/pkgconfig")
-endif ()
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.pc"
+ DESTINATION "usr/lib/pkgconfig")
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
@@ -88,15 +80,13 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
find_package(ProtobufC REQUIRED)
include_directories(${PROTOBUF_C_INCLUDE_DIRS})
-add_subdirectory(src)
add_subdirectory(include)
+add_subdirectory(src)
add_subdirectory(doc)
# Uninstall target
-configure_file(
- "${CMAKE_SOURCE_DIR}/cmake/CmakeUninstall.cmake.in"
- "${CMAKE_BINARY_DIR}/cmake/CmakeUninstall.cmake"
- IMMEDIATE @ONLY)
+configure_file("${CMAKE_SOURCE_DIR}/cmake/CmakeUninstall.cmake.in"
+ "${CMAKE_BINARY_DIR}/cmake/CmakeUninstall.cmake" IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake/CmakeUninstall.cmake)
diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt
index f0ce5df4..eadd385e 100644
--- a/doc/man/CMakeLists.txt
+++ b/doc/man/CMakeLists.txt
@@ -20,6 +20,8 @@ find_program(GZIP_EXECUTABLE
NAMES gzip
DOC "Will gzip the man pages")
+mark_as_advanced(GZIP_EXECUTABLE)
+
if (GZIP_EXECUTABLE)
foreach (m ${MAN_NAMES})
set(md ${CMAKE_CURRENT_BINARY_DIR}/${m}.gz)
diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt
index 8f57d4d7..e39759fd 100644
--- a/include/ouroboros/CMakeLists.txt
+++ b/include/ouroboros/CMakeLists.txt
@@ -1,7 +1,3 @@
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
- "${CMAKE_CURRENT_BINARY_DIR}/config.h")
-
set(HEADER_FILES
cacep.h
cdap.h
diff --git a/include/ouroboros/config.h.in b/include/ouroboros/config.h.in
deleted file mode 100644
index d5871624..00000000
--- a/include/ouroboros/config.h.in
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * Configuration information
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-#ifndef OUROBOROS_CONFIG
-#define OUROBOROS_CONFIG
-
-#define PROJECT_NAME "@CMAKE_PROJECT_NAME@"
-#define PROJECT_VERSION "@PACKAGE_VERSION@"
-#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
-#define _POSIX_C_SOURCE 200809L
-#define __XSI_VISIBLE 500
-#ifdef __FreeBSD__
-#define __BSD_VISIBLE 1
-#endif
-#ifdef __APPLE__
-#define _BSD_SOURCE
-#define _DARWIN_C_SOURCE
-#endif
-#define IPCP_SHIM_UDP_EXEC "@IPCP_SHIM_UDP_TARGET@"
-#define IPCP_SHIM_ETH_LLC_EXEC "@IPCP_SHIM_ETH_LLC_TARGET@"
-#define IPCP_NORMAL_EXEC "@IPCP_NORMAL_TARGET@"
-#define IPCP_LOCAL_EXEC "@IPCP_LOCAL_TARGET@"
-#cmakedefine HAVE_ROBUST_MUTEX
-#cmakedefine HAVE_SYS_RANDOM
-#cmakedefine HAVE_LIBGCRYPT
-#cmakedefine HAVE_OPENSSL
-#cmakedefine HAVE_NETMAP
-#cmakedefine HAVE_BPF
-#define AP_MAX_FLOWS 2048
-#define AP_RES_FDS 64
-#define AP_MAX_FQUEUES 64
-#define SHM_RDRB_BLOCK_SIZE sysconf(_SC_PAGESIZE)
-#define SHM_RDRB_MULTI_BLOCK
-#define SHM_RDRB_NAME "/ouroboros.rdrb"
-#define LOCKFILE_NAME "/ouroboros.lockfile"
-#define SHM_BUFFER_SIZE 1 << 14
-#define DU_BUFF_HEADSPACE 128
-#define DU_BUFF_TAILSPACE 0
-#define SHM_RBUFF_LOCKLESS 0
-#define SHM_RBUFF_PREFIX "/ouroboros.rbuff."
-#define SHM_FLOW_SET_PREFIX "/ouroboros.sets."
-#define IRMD_MAX_FLOWS 4096
-/* IRMD dynamic threadpooling */
-#define IRMD_MIN_THREADS 16
-#define IRMD_ADD_THREADS 32
-/* IPCP dynamic threadpooling */
-#define IPCP_MIN_THREADS 4
-#define IPCP_ADD_THREADS 16
-#define IPCP_SCHED_THREADS 2
-#define IPCPD_MAX_CONNS IRMD_MAX_FLOWS
-#ifdef __APPLE__
-#define PTHREAD_COND_CLOCK CLOCK_REALTIME
-#else
-#define PTHREAD_COND_CLOCK CLOCK_MONOTONIC
-#endif
-#define PFT_SIZE 1 << 12
-/* Timeout values */
-#define IRMD_ACCEPT_TIMEOUT 100
-#define IRMD_REQ_ARR_TIMEOUT 500
-#define IRMD_FLOW_TIMEOUT 5000
-#define IPCP_ACCEPT_TIMEOUT 100
-#define SOCKET_TIMEOUT 1000
-#define BOOTSTRAP_TIMEOUT 5000
-#define ENROLL_TIMEOUT 60000
-#define REG_TIMEOUT 10000
-#define QUERY_TIMEOUT 3000
-#define CDAP_REPLY_TIMEOUT 1000
-
-#endif /* OUROBOROS_CONFIG */
diff --git a/include/ouroboros/endian.h b/include/ouroboros/endian.h
index 18df0e99..00c7e043 100644
--- a/include/ouroboros/endian.h
+++ b/include/ouroboros/endian.h
@@ -24,42 +24,18 @@
#define OUROBOROS_ENDIAN_H
#if defined(__linux__) || defined(__CYGWIN__) || \
- (defined(__MACH__) && !defined(__APPLE__))
-
-#ifndef _BSD_SOURCE
-#define _BSD_SOURCE
-#endif
-#ifndef __USE_BSD
-#define __USE_BSD
-#endif
-#ifndef _DEFAULT_SOURCE
+ (defined(__MACH__) && !defined(__APPLE__))
#define _DEFAULT_SOURCE
-#endif
-
#include <endian.h>
-#include <features.h>
-
-#define betoh16(x) be16toh(x)
-#define letoh16(x) le16toh(x)
-#define betoh32(x) be32toh(x)
-#define letoh32(x) le32toh(x)
-#define betoh64(x) be64toh(x)
-#define letoh64(x) le64toh(x)
-
-#elif defined(__NetBSD__) || defined(__FreeBSD__)
-
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#include <sys/endian.h>
-
-#define betoh16(x) be16toh(x)
-#define letoh16(x) le16toh(x)
-#define betoh32(x) be32toh(x)
-#define letoh32(x) le32toh(x)
-#define betoh64(x) be64toh(x)
-#define letoh64(x) le64toh(x)
-
#elif defined(__APPLE__)
-
#include <libkern/OSByteOrder.h>
+#else
+#error OS currently not supported
+#endif
+
+#if defined (__APPLE__)
#define htobe16(x) OSSwapHostToBigInt16(x)
#define htole16(x) OSSwapHostToLittleInt16(x)
@@ -76,13 +52,14 @@
#define betoh64(x) OSSwapBigToHostInt64(x)
#define letoh64(x) OSSwapLittleToHostInt64(x)
-#elif defined(__OpenBSD__)
-
-#include <sys/endian.h>
+#elif !defined(__OpenBSD__)
-#else
-
-#error OS currently not supported
+#define betoh16(x) be16toh(x)
+#define letoh16(x) le16toh(x)
+#define betoh32(x) be32toh(x)
+#define letoh32(x) le32toh(x)
+#define betoh64(x) be64toh(x)
+#define letoh64(x) le64toh(x)
#endif
diff --git a/include/ouroboros/wrap/CMakeLists.txt b/include/ouroboros/wrap/CMakeLists.txt
index eb44ed33..435b3b70 100644
--- a/include/ouroboros/wrap/CMakeLists.txt
+++ b/include/ouroboros/wrap/CMakeLists.txt
@@ -1,10 +1,9 @@
-find_package(SWIG)
-
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
+find_package(SWIG)
if (NOT SWIG_FOUND)
- message(STATUS "SWIG not found: Bindings for other languages disabled.")
+ message(STATUS "SWIG not found: Bindings for other languages disabled")
else ()
include(${SWIG_USE_FILE})
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
@@ -12,7 +11,7 @@ else ()
find_package(PythonLibs)
if (NOT PYTHONLIBS_FOUND)
- message(STATUS "Python not found: Python bindings will not be built.")
+ message(STATUS "Python not found: Python bindings will not be built")
else ()
include_directories(${PYTHON_INCLUDE_PATH})
@@ -55,3 +54,5 @@ else ()
DESTINATION ${PYTHON_MODULE_PATH})
endif ()
endif ()
+
+mark_as_advanced(SWIG_EXECUTABLE)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 0037d437..54fdd8ab 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,4 @@
+add_subdirectory(lib)
add_subdirectory(ipcpd)
add_subdirectory(irmd)
-add_subdirectory(nsmd)
-add_subdirectory(lib)
add_subdirectory(tools)
diff --git a/src/ipcpd/CMakeLists.txt b/src/ipcpd/CMakeLists.txt
index b2f350dd..6356b1ba 100644
--- a/src/ipcpd/CMakeLists.txt
+++ b/src/ipcpd/CMakeLists.txt
@@ -1,3 +1,12 @@
+set(IPCP_ACCEPT_TIMEOUT 100 CACHE STRING
+ "Timeout for accept in IPCP mainloop threads (ms)")
+set(IPCP_SCHED_THREADS 2 CACHE STRING
+ "Number of scheduler threads in the normal IPCP")
+set(IPCP_MIN_THREADS 4 CACHE STRING
+ "Minimum number of worker threads in the IPCP")
+set(IPCP_ADD_THREADS 4 CACHE STRING
+ "Number of extra threads to start when an IPCP faces thread starvation")
+
set(IPCP_SOURCES
# Add source files here
${CMAKE_CURRENT_SOURCE_DIR}/ipcp.c
@@ -8,3 +17,6 @@ add_subdirectory(local)
add_subdirectory(normal)
add_subdirectory(shim-udp)
add_subdirectory(shim-eth-llc)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
diff --git a/src/nsmd/main.c b/src/ipcpd/config.h.in
index 537aaa81..0bef20be 100644
--- a/src/nsmd/main.c
+++ b/src/ipcpd/config.h.in
@@ -1,7 +1,7 @@
/*
* Ouroboros - Copyright (C) 2016 - 2017
*
- * Normal IPC Process
+ * IPC process configuration
*
* Dimitri Staessens <dimitri.staessens@ugent.be>
* Sander Vrijders <sander.vrijders@ugent.be>
@@ -20,13 +20,30 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#define OUROBOROS_PREFIX "nsmd"
+#define PTHREAD_COND_CLOCK @PTHREAD_COND_CLOCK@
-#include <ouroboros/logs.h>
+#define SYS_MAX_FLOWS @SYS_MAX_FLOWS@
+#define AP_RES_FDS @AP_RES_FDS@
+#define AP_MAX_FLOWS @AP_MAX_FLOWS@
-int main(void)
-{
- log_dbg("Test of the NSMd");
+#define IPCP_ACCEPT_TIMEOUT @IPCP_ACCEPT_TIMEOUT@
- return 0;
-}
+#define SOCKET_TIMEOUT @SOCKET_TIMEOUT@
+
+#define SHM_BUFFER_SIZE @SHM_BUFFER_SIZE@
+
+#define IPCP_MIN_THREADS @IPCP_MIN_THREADS@
+#define IPCP_ADD_THREADS @IPCP_ADD_THREADS@
+
+/* normal IPCP */
+#define IPCP_SCHED_THREADS @IPCP_SCHED_THREADS@
+#define PFT_SIZE @PFT_SIZE@
+
+/* shim-udp */
+#define NSUPDATE_EXEC "@NSUPDATE_EXECUTABLE@"
+#define NSLOOKUP_EXEC "@NSLOOKUP_EXECUTABLE@"
+
+/* shim-eth-llc */
+#cmakedefine HAVE_NETMAP
+#cmakedefine HAVE_BPF
+#cmakedefine HAVE_RAW_SOCKETS
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index 368c6eb8..300c22f4 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -20,9 +20,13 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+#define __XSI_VISIBLE 500
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "ipcpd/ipcp"
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/logs.h>
#include <ouroboros/time_utils.h>
@@ -533,7 +537,6 @@ int ipcp_init(int argc,
ipcpi.irmd_fd = -1;
ipcpi.state = IPCP_NULL;
- ipcpi.shim_data = NULL;
ipcpi.sock_path = ipcp_sock_path(getpid());
if (ipcpi.sock_path == NULL)
@@ -597,20 +600,10 @@ int ipcp_init(int argc,
ipcpi.alloc_id = -1;
ipcpi.csockfd = -1;
- if (type != IPCP_NORMAL) {
- ipcpi.shim_data = shim_data_create();
- if (ipcpi.shim_data == NULL) {
- ret = -ENOMEM;
- goto fail_shim_data;
- }
- }
-
pthread_condattr_destroy(&cattr);
return 0;
- fail_shim_data:
- pthread_cond_destroy(&ipcpi.acc_cond);
fail_acc_cond:
pthread_cond_destroy(&ipcpi.cmd_cond);
fail_cmd_cond:
@@ -702,8 +695,6 @@ void ipcp_fini()
free(ipcpi.sock_path);
- shim_data_destroy(ipcpi.shim_data);
-
pthread_cond_destroy(&ipcpi.state_cond);
pthread_mutex_destroy(&ipcpi.state_mtx);
pthread_cond_destroy(&ipcpi.alloc_cond);
diff --git a/src/ipcpd/ipcp.h b/src/ipcpd/ipcp.h
index 422670d7..cd18d198 100644
--- a/src/ipcpd/ipcp.h
+++ b/src/ipcpd/ipcp.h
@@ -20,16 +20,14 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef IPCPD_IPCP_H
-#define IPCPD_IPCP_H
+#ifndef OUROBOROS_IPCPD_IPCP_H
+#define OUROBOROS_IPCPD_IPCP_H
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/ipcp.h>
+#include <ouroboros/qoscube.h>
#include <ouroboros/sockets.h>
-#include "shim-data.h"
-
#include <pthread.h>
#include <time.h>
#include <signal.h>
@@ -80,8 +78,6 @@ struct ipcp {
struct ipcp_ops * ops;
int irmd_fd;
- struct shim_data * shim_data;
-
enum ipcp_state state;
pthread_rwlock_t state_lock;
pthread_mutex_t state_mtx;
@@ -136,4 +132,4 @@ uint8_t * ipcp_hash_dup(const uint8_t * hash);
void ipcp_hash_str(char buf[],
const uint8_t * hash);
-#endif
+#endif /* OUROBOROS_IPCPD_IPCP_H */
diff --git a/src/ipcpd/local/CMakeLists.txt b/src/ipcpd/local/CMakeLists.txt
index 824b4ca6..925092bd 100644
--- a/src/ipcpd/local/CMakeLists.txt
+++ b/src/ipcpd/local/CMakeLists.txt
@@ -12,7 +12,7 @@ include_directories(${CURRENT_BINARY_PARENT_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
-set(IPCP_LOCAL_TARGET ipcpd-local CACHE STRING "IPCP_LOCAL")
+set(IPCP_LOCAL_TARGET ipcpd-local CACHE INTERNAL "")
set(SHIM_LOCAL_SOURCES
# Add source files here
diff --git a/src/ipcpd/local/main.c b/src/ipcpd/local/main.c
index 241a47eb..37d23fc3 100644
--- a/src/ipcpd/local/main.c
+++ b/src/ipcpd/local/main.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "ipcpd-local"
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
@@ -33,6 +36,7 @@
#include <ouroboros/local-dev.h>
#include "ipcp.h"
+#include "shim-data.h"
#include <string.h>
#include <stdlib.h>
@@ -44,18 +48,20 @@
#define THIS_TYPE IPCP_LOCAL
struct {
- int in_out[IRMD_MAX_FLOWS];
- flow_set_t * flows;
- fqueue_t * fq;
+ struct shim_data * shim_data;
- pthread_rwlock_t lock;
- pthread_t sduloop;
+ int in_out[SYS_MAX_FLOWS];
+ flow_set_t * flows;
+ fqueue_t * fq;
+
+ pthread_rwlock_t lock;
+ pthread_t sduloop;
} local_data;
static int local_data_init(void)
{
int i;
- for (i = 0; i < IRMD_MAX_FLOWS; ++i)
+ for (i = 0; i < SYS_MAX_FLOWS; ++i)
local_data.in_out[i] = -1;
local_data.flows = flow_set_create();
@@ -68,12 +74,20 @@ static int local_data_init(void)
return -ENOMEM;
}
+ local_data.shim_data = shim_data_create();
+ if (local_data.shim_data == NULL) {
+ fqueue_destroy(local_data.fq);
+ flow_set_destroy(local_data.flows);
+ return -ENOMEM;
+ }
+
pthread_rwlock_init(&local_data.lock, NULL);
return 0;
}
static void local_data_fini(void){
+ shim_data_destroy(local_data.shim_data);
flow_set_destroy(local_data.flows);
fqueue_destroy(local_data.fq);
pthread_rwlock_destroy(&local_data.lock);
@@ -142,7 +156,7 @@ static int ipcp_local_reg(const uint8_t * hash)
return -ENOMEM;
}
- if (shim_data_reg_add_entry(ipcpi.shim_data, hash_dup)) {
+ if (shim_data_reg_add_entry(local_data.shim_data, hash_dup)) {
log_dbg("Failed to add " HASH_FMT " to local registry.",
HASH_VAL(hash));
free(hash_dup);
@@ -156,7 +170,7 @@ static int ipcp_local_reg(const uint8_t * hash)
static int ipcp_local_unreg(const uint8_t * hash)
{
- shim_data_reg_del_entry(ipcpi.shim_data, hash);
+ shim_data_reg_del_entry(local_data.shim_data, hash);
log_info("Unregistered " HASH_FMT ".", HASH_VAL(hash));
@@ -167,7 +181,7 @@ static int ipcp_local_query(const uint8_t * hash)
{
int ret;
- ret = (shim_data_reg_has(ipcpi.shim_data, hash) ? 0 : -1);
+ ret = (shim_data_reg_has(local_data.shim_data, hash) ? 0 : -1);
return ret;
}
diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt
index 8c2d4efc..7a40e94c 100644
--- a/src/ipcpd/normal/CMakeLists.txt
+++ b/src/ipcpd/normal/CMakeLists.txt
@@ -12,7 +12,7 @@ include_directories(${CURRENT_BINARY_PARENT_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
-set(IPCP_NORMAL_TARGET ipcpd-normal CACHE STRING "IPCP_NORMAL_TARGET")
+set(IPCP_NORMAL_TARGET ipcpd-normal CACHE INTERNAL "")
protobuf_generate_c(FLOW_ALLOC_SRCS FLOW_ALLOC_HDRS flow_alloc.proto)
protobuf_generate_c(KAD_PROTO_SRCS KAD_PROTO_HDRS kademlia.proto)
@@ -20,6 +20,10 @@ protobuf_generate_c(KAD_PROTO_SRCS KAD_PROTO_HDRS kademlia.proto)
# Add GPB sources of policies last
protobuf_generate_c(FSO_SRCS FSO_HDRS pol/fso.proto)
+math(EXPR PFT_EXPR "1 << 12")
+set(PFT_SIZE ${PFT_EXPR} CACHE STRING
+ "Size of the PDU forwarding table")
+
set(SOURCE_FILES
# Add source files here
addr_auth.c
@@ -56,4 +60,7 @@ endif (CMAKE_BUILD_TYPE MATCHES Debug)
install(TARGETS ipcpd-normal RUNTIME DESTINATION sbin)
add_subdirectory(pol/tests)
-add_subdirectory(tests)
+
+if (NOT GNU)
+ add_subdirectory(tests)
+endif ()
diff --git a/src/ipcpd/normal/addr_auth.c b/src/ipcpd/normal/addr_auth.c
index 56b41384..e327e2fa 100644
--- a/src/ipcpd/normal/addr_auth.c
+++ b/src/ipcpd/normal/addr_auth.c
@@ -22,7 +22,6 @@
#define OUROBOROS_PREFIX "addr_auth"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include "addr_auth.h"
diff --git a/src/ipcpd/normal/connmgr.c b/src/ipcpd/normal/connmgr.c
index 1513c12a..f48175fa 100644
--- a/src/ipcpd/normal/connmgr.c
+++ b/src/ipcpd/normal/connmgr.c
@@ -20,14 +20,16 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "normal-ipcp"
-#include <ouroboros/config.h>
-#include <ouroboros/logs.h>
#include <ouroboros/dev.h>
#include <ouroboros/cacep.h>
#include <ouroboros/cdap.h>
#include <ouroboros/errno.h>
+#include <ouroboros/list.h>
+#include <ouroboros/logs.h>
#include "ae.h"
#include "connmgr.h"
diff --git a/src/ipcpd/normal/dht.c b/src/ipcpd/normal/dht.c
index f41541d2..65e26406 100644
--- a/src/ipcpd/normal/dht.c
+++ b/src/ipcpd/normal/dht.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "dht"
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/bitmap.h>
#include <ouroboros/errno.h>
diff --git a/src/ipcpd/normal/dir.c b/src/ipcpd/normal/dir.c
index 231ba110..feae7013 100644
--- a/src/ipcpd/normal/dir.c
+++ b/src/ipcpd/normal/dir.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "directory"
-#include <ouroboros/config.h>
#include <ouroboros/endian.h>
#include <ouroboros/errno.h>
#include <ouroboros/logs.h>
diff --git a/src/ipcpd/normal/dt.c b/src/ipcpd/normal/dt.c
index 290c409d..173266f4 100644
--- a/src/ipcpd/normal/dt.c
+++ b/src/ipcpd/normal/dt.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "dt-ae"
-#include <ouroboros/config.h>
#include <ouroboros/bitmap.h>
#include <ouroboros/errno.h>
#include <ouroboros/logs.h>
diff --git a/src/ipcpd/normal/dt_pci.c b/src/ipcpd/normal/dt_pci.c
index e139cf91..9e6dfa89 100644
--- a/src/ipcpd/normal/dt_pci.c
+++ b/src/ipcpd/normal/dt_pci.c
@@ -20,7 +20,6 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
#include <ouroboros/errno.h>
#include <ouroboros/rib.h>
diff --git a/src/ipcpd/normal/enroll.c b/src/ipcpd/normal/enroll.c
index be1596d0..471230bc 100644
--- a/src/ipcpd/normal/enroll.c
+++ b/src/ipcpd/normal/enroll.c
@@ -19,9 +19,11 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+
+#define _POSIX_C_SOURCE 199309L
+
#define OUROBOROS_PREFIX "enrollment"
-#include <ouroboros/config.h>
#include <ouroboros/endian.h>
#include <ouroboros/errno.h>
#include <ouroboros/cdap.h>
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c
index 2488f017..682dc5c6 100644
--- a/src/ipcpd/normal/fa.c
+++ b/src/ipcpd/normal/fa.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "flow-allocator"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include <ouroboros/fqueue.h>
#include <ouroboros/rib.h>
diff --git a/src/ipcpd/normal/gam.c b/src/ipcpd/normal/gam.c
index 9997506c..3b4cc5de 100644
--- a/src/ipcpd/normal/gam.c
+++ b/src/ipcpd/normal/gam.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "dt-gam"
-#include <ouroboros/config.h>
#include <ouroboros/cdap.h>
#include <ouroboros/dev.h>
#include <ouroboros/logs.h>
diff --git a/src/ipcpd/normal/main.c b/src/ipcpd/normal/main.c
index 27fefdb6..95b0ed56 100644
--- a/src/ipcpd/normal/main.c
+++ b/src/ipcpd/normal/main.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "normal-ipcp"
-#include <ouroboros/config.h>
#include <ouroboros/endian.h>
#include <ouroboros/logs.h>
#include <ouroboros/ipcp-dev.h>
diff --git a/src/ipcpd/normal/neighbors.c b/src/ipcpd/normal/neighbors.c
index 0ac5e958..5da0f0df 100644
--- a/src/ipcpd/normal/neighbors.c
+++ b/src/ipcpd/normal/neighbors.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 199309L
+
#define OUROBOROS_PREFIX "neighbors"
-#include <ouroboros/config.h>
#include <ouroboros/qoscube.h>
#include <ouroboros/ipcp-dev.h>
#include <ouroboros/errno.h>
diff --git a/src/ipcpd/normal/pff.c b/src/ipcpd/normal/pff.c
index acf4db1a..d6c9ddee 100644
--- a/src/ipcpd/normal/pff.c
+++ b/src/ipcpd/normal/pff.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "pff"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include <ouroboros/hashtable.h>
#include <ouroboros/errno.h>
diff --git a/src/ipcpd/normal/pol/complete.c b/src/ipcpd/normal/pol/complete.c
index e31f345a..6c6e7372 100644
--- a/src/ipcpd/normal/pol/complete.c
+++ b/src/ipcpd/normal/pol/complete.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "complete"
-#include <ouroboros/config.h>
#include <ouroboros/qoscube.h>
#include <ouroboros/rib.h>
#include <ouroboros/dev.h>
diff --git a/src/ipcpd/normal/pol/flat.c b/src/ipcpd/normal/pol/flat.c
index 966d0d03..1fece07f 100644
--- a/src/ipcpd/normal/pol/flat.c
+++ b/src/ipcpd/normal/pol/flat.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "flat-addr-auth"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
#include <ouroboros/time_utils.h>
diff --git a/src/ipcpd/normal/pol/graph.c b/src/ipcpd/normal/pol/graph.c
index 7ec9c035..3611f0b0 100644
--- a/src/ipcpd/normal/pol/graph.c
+++ b/src/ipcpd/normal/pol/graph.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "graph"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
diff --git a/src/ipcpd/normal/pol/link_state.c b/src/ipcpd/normal/pol/link_state.c
index 322b22d7..9dfed5c0 100644
--- a/src/ipcpd/normal/pol/link_state.c
+++ b/src/ipcpd/normal/pol/link_state.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "link-state-routing"
-#include <ouroboros/config.h>
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
#include <ouroboros/logs.h>
diff --git a/src/ipcpd/normal/pol/tests/graph_test.c b/src/ipcpd/normal/pol/tests/graph_test.c
index 30201800..87574187 100644
--- a/src/ipcpd/normal/pol/tests/graph_test.c
+++ b/src/ipcpd/normal/pol/tests/graph_test.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200112L
+
#include <ouroboros/utils.h>
#include <stdio.h>
diff --git a/src/ipcpd/normal/ribmgr.c b/src/ipcpd/normal/ribmgr.c
index ee81581f..ab2aa430 100644
--- a/src/ipcpd/normal/ribmgr.c
+++ b/src/ipcpd/normal/ribmgr.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "rib-manager"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include <ouroboros/cdap.h>
#include <ouroboros/list.h>
diff --git a/src/ipcpd/normal/routing.c b/src/ipcpd/normal/routing.c
index 5bf985fb..c00ec67c 100644
--- a/src/ipcpd/normal/routing.c
+++ b/src/ipcpd/normal/routing.c
@@ -20,9 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
#define OUROBOROS_PREFIX "routing"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include "routing.h"
diff --git a/src/ipcpd/normal/sdu_sched.c b/src/ipcpd/normal/sdu_sched.c
index b46f2563..f3550d5c 100644
--- a/src/ipcpd/normal/sdu_sched.c
+++ b/src/ipcpd/normal/sdu_sched.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 199309L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "sdu-scheduler"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
diff --git a/src/ipcpd/shim-data.c b/src/ipcpd/shim-data.c
index 0b81a36a..747a210b 100644
--- a/src/ipcpd/shim-data.c
+++ b/src/ipcpd/shim-data.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#include <ouroboros/list.h>
#include <ouroboros/time_utils.h>
#include <ouroboros/errno.h>
diff --git a/src/ipcpd/shim-data.h b/src/ipcpd/shim-data.h
index 4fd1ad3d..983f97f6 100644
--- a/src/ipcpd/shim-data.h
+++ b/src/ipcpd/shim-data.h
@@ -20,8 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifndef IPCPD_IPCP_DATA_H
-#define IPCPD_IPCP_DATA_H
+#ifndef OUROBOROS_IPCPD_IPCP_DATA_H
+#define OUROBOROS_IPCPD_IPCP_DATA_H
#include <ouroboros/qoscube.h>
#include <ouroboros/list.h>
@@ -93,4 +93,4 @@ void shim_data_dir_query_destroy(struct dir_query * query);
int shim_data_dir_query_wait(struct dir_query * query,
const struct timespec * timeout);
-#endif /* IPCPD_SHIM_DATA_H */
+#endif /* OUROBOROS_IPCPD_SHIM_DATA_H */
diff --git a/src/ipcpd/shim-eth-llc/CMakeLists.txt b/src/ipcpd/shim-eth-llc/CMakeLists.txt
index 21003cf0..6474eb8d 100644
--- a/src/ipcpd/shim-eth-llc/CMakeLists.txt
+++ b/src/ipcpd/shim-eth-llc/CMakeLists.txt
@@ -15,26 +15,56 @@ include_directories(${CMAKE_BINARY_DIR}/include)
find_path(NETMAP_C_INCLUDE_DIR
net/netmap_user.h
HINTS /usr/include /usr/local/include
- )
+)
+
+mark_as_advanced(NETMAP_C_INCLUDE_DIR)
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(DISABLE_RAW_SOCKETS FALSE CACHE BOOL
+ "Disable raw socket support for LLC shim")
+ if (NOT DISABLE_RAW_SOCKETS)
+ message(STATUS "Raw socket support for shim-eth-llc enabled")
+ set(HAVE_RAW_SOCKETS TRUE PARENT_SCOPE)
+ else ()
+ message(STATUS "Raw socket support for shim-eth-llc disabled by user")
+ endif ()
+endif ()
-find_path(BPF_C_INCLUDE_DIR
- net/bpf.h
- HINTS /usr/include /usr/local/include
+if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ find_path(BPF_C_INCLUDE_DIR
+ net/bpf.h
+ HINTS /usr/include /usr/local/include
)
-if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux" AND
- NOT BPF_C_INCLUDE_DIR STREQUAL "BPF_C_INCLUDE_DIR-NOTFOUND")
- message(STATUS "Found Berkeley Packet Filter headers in ${BPF_C_INCLUDE_DIR}")
- set(HAVE_BPF "1" CACHE STRING "Have Berkeley Packet Filter")
+ mark_as_advanced(BPF_C_INCLUDE_DIR)
+
+ if (BPF_C_INCLUDE_DIR)
+ set(DISABLE_BPF FALSE CACHE BOOL
+ "Disable Berkeley Packet Filter support for LLC shim")
+ if (NOT DISABLE_BPF)
+ message(STATUS "Berkeley Packet Filter support "
+ "for shim-eth-llc enabled")
+ set(HAVE_BPF TRUE PARENT_SCOPE)
+ else ()
+ message(STATUS "Berkeley Packet Filter support "
+ "for shim-eth-llc disabled by user")
+ endif ()
+ endif ()
endif ()
-if (NOT NETMAP_C_INCLUDE_DIR STREQUAL "NETMAP_C_INCLUDE_DIR-NOTFOUND")
- message(STATUS "Found netmap headers in ${NETMAP_C_INCLUDE_DIR}")
- set(HAVE_NETMAP "1" CACHE STRING "Have netmap")
- test_and_set_c_compiler_flag_global(-std=c99)
+if (NETMAP_C_INCLUDE_DIR)
+ set(DISABLE_NETMAP FALSE CACHE BOOL
+ "Disable netmap support for LLC shim")
+ if (NOT DISABLE_NETMAP)
+ message(STATUS "Netmap support for shim-eth-llc enabled")
+ set(HAVE_NETMAP TRUE PARENT_SCOPE)
+ test_and_set_c_compiler_flag_global(-std=c99)
+ else ()
+ message(STATUS "Netmap support for shim-eth-llc disabled by user")
+ endif ()
endif ()
-if (HAVE_NETMAP OR HAVE_BPF OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if (HAVE_NETMAP OR HAVE_BPF OR HAVE_RAW_SOCKETS)
message(STATUS "Supported raw Ethernet API found, building shim-eth-llc")
protobuf_generate_c(SHIM_ETH_LLC_PROTO_SRCS SHIM_ETH_LLC_PROTO_HDRS
shim_eth_llc_messages.proto)
@@ -44,8 +74,7 @@ if (HAVE_NETMAP OR HAVE_BPF OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
${CMAKE_CURRENT_SOURCE_DIR}/main.c
)
- set(IPCP_SHIM_ETH_LLC_TARGET ipcpd-shim-eth-llc
- CACHE STRING "IPCP_SHIM_ETH_LLC_TARGET")
+ set(IPCP_SHIM_ETH_LLC_TARGET ipcpd-shim-eth-llc CACHE INTERNAL "")
add_executable(ipcpd-shim-eth-llc ${SHIM_ETH_LLC_SOURCES} ${IPCP_SOURCES}
${SHIM_ETH_LLC_PROTO_SRCS})
@@ -55,7 +84,8 @@ if (HAVE_NETMAP OR HAVE_BPF OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif ()
if (HAVE_NETMAP AND NOT APPLE)
- target_include_directories(ipcpd-shim-eth-llc PUBLIC ${NETMAP_C_INCLUDE_DIR})
+ target_include_directories(ipcpd-shim-eth-llc PUBLIC
+ ${NETMAP_C_INCLUDE_DIR})
endif ()
target_link_libraries(ipcpd-shim-eth-llc LINK_PUBLIC ouroboros
diff --git a/src/ipcpd/shim-eth-llc/main.c b/src/ipcpd/shim-eth-llc/main.c
index 55406a00..37df964b 100644
--- a/src/ipcpd/shim-eth-llc/main.c
+++ b/src/ipcpd/shim-eth-llc/main.c
@@ -20,9 +20,19 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+
+
+#ifdef __APPLE__
+#define _BSD_SOURCE
+#define _DARWIN_C_SOURCE
+#else
+#define _POSIX_C_SOURCE 200112L
+#endif
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "ipcpd/shim-eth-llc"
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
@@ -35,6 +45,7 @@
#include <ouroboros/time_utils.h>
#include "ipcp.h"
+#include "shim-data.h"
#include "shim_eth_llc_messages.pb-c.h"
#include <signal.h>
@@ -78,7 +89,6 @@
#include <net/bpf.h>
#endif
-#define THIS_TYPE IPCP_SHIM_ETH_LLC
#define MGMT_SAP 0x01
#define MAC_SIZE 6
#define LLC_HEADER_SIZE 3
@@ -117,6 +127,8 @@ struct mgmt_frame {
};
struct {
+ struct shim_data * shim_data;
+
#if defined(HAVE_NETMAP)
struct nm_desc * nmd;
uint8_t hw_addr[MAC_SIZE];
@@ -125,7 +137,7 @@ struct {
#elif defined(HAVE_BPF)
int bpf;
uint8_t hw_addr[MAC_SIZE];
-#elif defined __linux__
+#elif defined HAVE_RAW_SOCKETS
int s_fd;
struct sockaddr_ll device;
#endif /* HAVE_NETMAP */
@@ -154,7 +166,7 @@ static int eth_llc_data_init(void)
int ret = -ENOMEM;
pthread_condattr_t cattr;
- eth_llc_data.fd_to_ef = malloc(sizeof(struct ef) * IRMD_MAX_FLOWS);
+ eth_llc_data.fd_to_ef = malloc(sizeof(struct ef) * SYS_MAX_FLOWS);
if (eth_llc_data.fd_to_ef == NULL)
goto fail_fd_to_ef;
@@ -177,12 +189,16 @@ static int eth_llc_data_init(void)
for (i = 0; i < MAX_SAPS; ++i)
eth_llc_data.ef_to_fd[i] = -1;
- for (i = 0; i < IRMD_MAX_FLOWS; ++i) {
+ for (i = 0; i < SYS_MAX_FLOWS; ++i) {
eth_llc_data.fd_to_ef[i].sap = -1;
eth_llc_data.fd_to_ef[i].r_sap = -1;
memset(&eth_llc_data.fd_to_ef[i].r_addr, 0, MAC_SIZE);
}
+ eth_llc_data.shim_data = shim_data_create();
+ if (eth_llc_data.shim_data == NULL)
+ goto fail_shim_data;
+
ret = -1;
if (pthread_rwlock_init(&eth_llc_data.flows_lock, NULL))
@@ -206,6 +222,7 @@ static int eth_llc_data_init(void)
list_head_init(&eth_llc_data.mgmt_frames);
return 0;
+
fail_mgmt_cond:
pthread_condattr_destroy(&cattr);
fail_condattr:
@@ -213,6 +230,8 @@ static int eth_llc_data_init(void)
fail_mgmt_lock:
pthread_rwlock_destroy(&eth_llc_data.flows_lock);
fail_flows_lock:
+ shim_data_destroy(eth_llc_data.shim_data);
+ fail_shim_data:
fqueue_destroy(eth_llc_data.fq);
fail_fq:
flow_set_destroy(eth_llc_data.np1_flows);
@@ -232,12 +251,13 @@ void eth_llc_data_fini(void)
nm_close(eth_llc_data.nmd);
#elif defined(HAVE_BPF)
close(eth_llc_data.bpf);
-#elif defined(__linux__)
+#elif defined(HAVE_RAW_SOCKETS)
close(eth_llc_data.s_fd);
#endif
pthread_cond_destroy(&eth_llc_data.mgmt_cond);
pthread_mutex_destroy(&eth_llc_data.mgmt_lock);
pthread_rwlock_destroy(&eth_llc_data.flows_lock);
+ shim_data_destroy(eth_llc_data.shim_data);
fqueue_destroy(eth_llc_data.fq);
flow_set_destroy(eth_llc_data.np1_flows);
bmp_destroy(eth_llc_data.saps);
@@ -280,7 +300,7 @@ static int eth_llc_ipcp_send_frame(const uint8_t * dst_addr,
memcpy(llc_frame->src_hwaddr,
#if defined(HAVE_NETMAP) || defined(HAVE_BPF)
eth_llc_data.hw_addr,
-#elif defined(__linux__)
+#elif defined(HAVE_RAW_SOCKETS)
eth_llc_data.device.sll_addr,
#endif /* HAVE_NETMAP */
MAC_SIZE);
@@ -306,7 +326,7 @@ static int eth_llc_ipcp_send_frame(const uint8_t * dst_addr,
return -1;
}
-#elif defined(__linux__)
+#elif defined(HAVE_RAW_SOCKETS)
if (sendto(eth_llc_data.s_fd,
frame,
frame_len,
@@ -475,7 +495,7 @@ static int eth_llc_ipcp_name_query_req(const uint8_t * hash,
{
shim_eth_llc_msg_t msg = SHIM_ETH_LLC_MSG__INIT;
- if (shim_data_reg_has(ipcpi.shim_data, hash)) {
+ if (shim_data_reg_has(eth_llc_data.shim_data, hash)) {
msg.code = SHIM_ETH_LLC_MSG_CODE__NAME_QUERY_REPLY;
msg.has_hash = true;
msg.hash.len = ipcp_dir_hash_len();
@@ -495,11 +515,11 @@ static int eth_llc_ipcp_name_query_reply(const uint8_t * hash,
memcpy(&address, r_addr, MAC_SIZE);
- shim_data_dir_add_entry(ipcpi.shim_data, hash, address);
+ shim_data_dir_add_entry(eth_llc_data.shim_data, hash, address);
- pthread_mutex_lock(&ipcpi.shim_data->dir_queries_lock);
+ pthread_mutex_lock(&eth_llc_data.shim_data->dir_queries_lock);
- list_for_each(pos, &ipcpi.shim_data->dir_queries) {
+ list_for_each(pos, &eth_llc_data.shim_data->dir_queries) {
struct dir_query * e =
list_entry(pos, struct dir_query, next);
if (memcmp(e->hash, hash, ipcp_dir_hash_len()) == 0) {
@@ -507,7 +527,7 @@ static int eth_llc_ipcp_name_query_reply(const uint8_t * hash,
}
}
- pthread_mutex_unlock(&ipcpi.shim_data->dir_queries_lock);
+ pthread_mutex_unlock(&eth_llc_data.shim_data->dir_queries_lock);
return 0;
}
@@ -526,7 +546,7 @@ static int eth_llc_ipcp_mgmt_frame(const uint8_t * buf,
switch (msg->code) {
case SHIM_ETH_LLC_MSG_CODE__FLOW_REQ:
- if (shim_data_reg_has(ipcpi.shim_data, msg->hash.data)) {
+ if (shim_data_reg_has(eth_llc_data.shim_data, msg->hash.data)) {
eth_llc_ipcp_sap_req(msg->ssap,
r_addr,
msg->hash.data,
@@ -614,7 +634,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
struct nm_pkthdr hdr;
#elif defined(HAVE_BPF)
uint8_t buf[BPF_BLEN];
-#elif defined(__linux__)
+#elif defined(HAVE_RAW_SOCKETS)
uint8_t buf[ETH_FRAME_SIZE];
#endif
int frame_len = 0;
@@ -641,7 +661,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
}
#elif defined(HAVE_BPF)
frame_len = read(eth_llc_data.bpf, buf, BPF_BLEN);
-#elif defined(__linux__)
+#elif defined(HAVE_RAW_SOCKETS)
frame_len = recv(eth_llc_data.s_fd, buf,
SHIM_ETH_LLC_MAX_SDU_SIZE, 0);
#endif
@@ -659,7 +679,7 @@ static void * eth_llc_ipcp_sdu_reader(void * o)
#if !defined(HAVE_BPF)
#if defined(HAVE_NETMAP)
if (memcmp(eth_llc_data.hw_addr,
- #elif defined(__linux__)
+ #elif defined(HAVE_RAW_SOCKETS)
if (memcmp(eth_llc_data.device.sll_addr,
#endif /* HAVE_NETMAP */
llc_frame->dst_hwaddr,
@@ -792,7 +812,7 @@ static int eth_llc_ipcp_bootstrap(const struct ipcp_config * conf)
int disable = 0;
int blen;
struct timeval tv = {0, EVENT_WAIT_TIMEOUT};
-#elif defined(__linux__)
+#elif defined(HAVE_RAW_SOCKETS)
struct timeval tv = {0, EVENT_WAIT_TIMEOUT};
#endif /* HAVE_NETMAP */
@@ -825,8 +845,10 @@ static int eth_llc_ipcp_bootstrap(const struct ipcp_config * conf)
log_dbg("Interface %s found.", conf->if_name);
#if defined(HAVE_NETMAP) || defined(HAVE_BPF)
- memcpy(eth_llc_data.hw_addr, LLADDR((struct sockaddr_dl *)(ifa)->ifa_addr), MAC_SIZE);
- #else
+ memcpy(eth_llc_data.hw_addr,
+ LLADDR((struct sockaddr_dl *) (ifa)->ifa_addr),
+ MAC_SIZE);
+ #elif defined (HAVE_RAW_SOCKETS)
memcpy(&ifr.ifr_addr, ifa->ifa_addr, sizeof(*ifa->ifa_addr));
#endif
break;
@@ -927,7 +949,7 @@ static int eth_llc_ipcp_bootstrap(const struct ipcp_config * conf)
}
log_info("Using Berkeley Packet Filter.");
-#elif defined(__linux__)
+#elif defined(HAVE_RAW_SOCKETS)
memset(&(eth_llc_data.device), 0, sizeof(eth_llc_data.device));
eth_llc_data.device.sll_ifindex = idx;
eth_llc_data.device.sll_family = AF_PACKET;
@@ -991,7 +1013,7 @@ static int eth_llc_ipcp_reg(const uint8_t * hash)
return -ENOMEM;
}
- if (shim_data_reg_add_entry(ipcpi.shim_data, hash_dup)) {
+ if (shim_data_reg_add_entry(eth_llc_data.shim_data, hash_dup)) {
log_err("Failed to add " HASH_FMT " to local registry.",
HASH_VAL(hash));
free(hash_dup);
@@ -1005,7 +1027,7 @@ static int eth_llc_ipcp_reg(const uint8_t * hash)
static int eth_llc_ipcp_unreg(const uint8_t * hash)
{
- shim_data_reg_del_entry(ipcpi.shim_data, hash);
+ shim_data_reg_del_entry(eth_llc_data.shim_data, hash);
return 0;
}
@@ -1019,7 +1041,7 @@ static int eth_llc_ipcp_query(const uint8_t * hash)
struct dir_query * query;
int ret;
- if (shim_data_dir_has(ipcpi.shim_data, hash))
+ if (shim_data_dir_has(eth_llc_data.shim_data, hash))
return 0;
msg.code = SHIM_ETH_LLC_MSG_CODE__NAME_QUERY_REQ;
@@ -1033,18 +1055,18 @@ static int eth_llc_ipcp_query(const uint8_t * hash)
if (query == NULL)
return -1;
- pthread_mutex_lock(&ipcpi.shim_data->dir_queries_lock);
- list_add(&query->next, &ipcpi.shim_data->dir_queries);
- pthread_mutex_unlock(&ipcpi.shim_data->dir_queries_lock);
+ pthread_mutex_lock(&eth_llc_data.shim_data->dir_queries_lock);
+ list_add(&query->next, &eth_llc_data.shim_data->dir_queries);
+ pthread_mutex_unlock(&eth_llc_data.shim_data->dir_queries_lock);
eth_llc_ipcp_send_mgmt_frame(&msg, r_addr);
ret = shim_data_dir_query_wait(query, &timeout);
- pthread_mutex_lock(&ipcpi.shim_data->dir_queries_lock);
+ pthread_mutex_lock(&eth_llc_data.shim_data->dir_queries_lock);
list_del(&query->next);
shim_data_dir_query_destroy(query);
- pthread_mutex_unlock(&ipcpi.shim_data->dir_queries_lock);
+ pthread_mutex_unlock(&eth_llc_data.shim_data->dir_queries_lock);
return ret;
}
@@ -1066,11 +1088,11 @@ static int eth_llc_ipcp_flow_alloc(int fd,
return -1;
}
- if (!shim_data_dir_has(ipcpi.shim_data, hash)) {
+ if (!shim_data_dir_has(eth_llc_data.shim_data, hash)) {
log_err("Destination unreachable.");
return -1;
}
- addr = shim_data_dir_get_addr(ipcpi.shim_data, hash);
+ addr = shim_data_dir_get_addr(eth_llc_data.shim_data, hash);
pthread_rwlock_wrlock(&eth_llc_data.flows_lock);
diff --git a/src/ipcpd/shim-udp/CMakeLists.txt b/src/ipcpd/shim-udp/CMakeLists.txt
index 3ff8dd5f..eff3f5d0 100644
--- a/src/ipcpd/shim-udp/CMakeLists.txt
+++ b/src/ipcpd/shim-udp/CMakeLists.txt
@@ -15,18 +15,14 @@ include_directories(${CMAKE_BINARY_DIR}/include)
protobuf_generate_c(SHIM_UDP_PROTO_SRCS SHIM_UDP_PROTO_HDRS
shim_udp_messages.proto)
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/shim_udp_config.h.in"
- "${CMAKE_CURRENT_BINARY_DIR}/shim_udp_config.h")
-
-set(IPCP_SHIM_UDP_TARGET ipcpd-shim-udp CACHE STRING "IPCP_SHIM_UDP_TARGET")
+set(IPCP_SHIM_UDP_TARGET ipcpd-shim-udp CACHE INTERNAL "")
set(SHIM_UDP_SOURCES
# Add source files here
${CMAKE_CURRENT_SOURCE_DIR}/main.c)
add_executable(ipcpd-shim-udp ${SHIM_UDP_SOURCES} ${IPCP_SOURCES}
- ${SHIM_UDP_PROTO_SRCS} "${CMAKE_CURRENT_BINARY_DIR}/shim_udp_config.h")
+ ${SHIM_UDP_PROTO_SRCS})
target_link_libraries(ipcpd-shim-udp LINK_PUBLIC ouroboros
${PROTOBUF_C_LIBRARY})
@@ -40,10 +36,12 @@ find_program(NSLOOKUP_EXECUTABLE
NAMES nslookup
DOC "The nslookup tool that resolves DNS names")
+mark_as_advanced(NSLOOKUP_EXECUTABLE NSUPDATE_EXECUTABLE)
+
include(AddCompileFlags)
-if (${NSUPDATE_EXECUTABLE} STREQUAL "NSUPDATE_EXECUTABLE-NOTFOUND")
+if (NOT NSUPDATE_EXECUTABLE)
message(STATUS "Could not find nsupdate. Disabling DDNS functionality.")
-elseif (${NSLOOKUP_EXECUTABLE} STREQUAL "NSLOOKUP_EXECUTABLE-NOTFOUND")
+elseif (NOT NSLOOKUP_EXECUTABLE)
message(STATUS "Could not find nslookup. Disabling DNS lookups.")
else ()
message(STATUS "Found nsupdate: ${NSUPDATE_EXECUTABLE}")
@@ -56,6 +54,3 @@ if (CMAKE_BUILD_TYPE MATCHES Debug)
endif (CMAKE_BUILD_TYPE MATCHES Debug)
install(TARGETS ipcpd-shim-udp RUNTIME DESTINATION sbin)
-
-# Enable once ipcp-shim-udp has tests
-# add_subdirectory(tests)
diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 195e3bc0..55fe19a6 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "ipcpd/shim-udp"
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/list.h>
#include <ouroboros/utils.h>
@@ -32,9 +35,9 @@
#include <ouroboros/errno.h>
#include <ouroboros/logs.h>
-#include "shim_udp_messages.pb-c.h"
#include "ipcp.h"
-#include "shim_udp_config.h"
+#include "shim-data.h"
+#include "shim_udp_messages.pb-c.h"
#include <string.h>
#include <sys/socket.h>
@@ -68,6 +71,8 @@ struct uf {
};
struct {
+ struct shim_data * shim_data;
+
uint32_t ip_addr;
uint32_t dns_addr;
/* listen server */
@@ -79,7 +84,7 @@ struct {
fd_set flow_fd_s;
/* bidir mappings of (n - 1) file descriptor to (n) flow descriptor */
int uf_to_fd[FD_SETSIZE];
- struct uf fd_to_uf[IRMD_MAX_FLOWS];
+ struct uf fd_to_uf[SYS_MAX_FLOWS];
pthread_rwlock_t flows_lock;
pthread_t sduloop;
@@ -98,7 +103,7 @@ static int udp_data_init(void)
for (i = 0; i < FD_SETSIZE; ++i)
udp_data.uf_to_fd[i] = -1;
- for (i = 0; i < IRMD_MAX_FLOWS; ++i) {
+ for (i = 0; i < SYS_MAX_FLOWS; ++i) {
udp_data.fd_to_uf[i].skfd = -1;
udp_data.fd_to_uf[i].udp = -1;
}
@@ -115,6 +120,13 @@ static int udp_data_init(void)
return -ENOMEM;
}
+ udp_data.shim_data = shim_data_create();
+ if (udp_data.shim_data == NULL) {
+ fqueue_destroy(udp_data.fq);
+ flow_set_destroy(udp_data.np1_flows);
+ return -ENOMEM;
+ }
+
pthread_rwlock_init(&udp_data.flows_lock, NULL);
pthread_cond_init(&udp_data.fd_set_cond, NULL);
pthread_mutex_init(&udp_data.fd_set_lock, NULL);
@@ -127,6 +139,8 @@ static void udp_data_fini(void)
flow_set_destroy(udp_data.np1_flows);
fqueue_destroy(udp_data.fq);
+ shim_data_destroy(udp_data.shim_data);
+
pthread_rwlock_destroy(&udp_data.flows_lock);
pthread_mutex_destroy(&udp_data.fd_set_lock);
pthread_cond_destroy(&udp_data.fd_set_cond);
@@ -322,7 +336,7 @@ static int udp_port_to_fd(int udp_port)
{
int i;
- for (i = 0; i < IRMD_MAX_FLOWS; ++i)
+ for (i = 0; i < SYS_MAX_FLOWS; ++i)
if (udp_data.fd_to_uf[i].udp == udp_port)
return i;
@@ -765,7 +779,7 @@ static int ipcp_udp_reg(const uint8_t * hash)
return -ENOMEM;
}
- if (shim_data_reg_add_entry(ipcpi.shim_data, hash_dup)) {
+ if (shim_data_reg_add_entry(udp_data.shim_data, hash_dup)) {
log_err("Failed to add " HASH_FMT " to local registry.",
HASH_VAL(hash));
free(hash_dup);
@@ -794,7 +808,7 @@ static int ipcp_udp_reg(const uint8_t * hash)
dnsstr, hashstr, DNS_TTL, ipstr);
if (ddns_send(cmd)) {
- shim_data_reg_del_entry(ipcpi.shim_data, hash_dup);
+ shim_data_reg_del_entry(udp_data.shim_data, hash_dup);
return -1;
}
}
@@ -835,7 +849,7 @@ static int ipcp_udp_unreg(const uint8_t * hash)
}
#endif
- shim_data_reg_del_entry(ipcpi.shim_data, hash);
+ shim_data_reg_del_entry(udp_data.shim_data, hash);
log_dbg("Unregistered " HASH_FMT ".", HASH_VAL(hash));
@@ -855,7 +869,7 @@ static int ipcp_udp_query(const uint8_t * hash)
ipcp_hash_str(hashstr, hash);
- if (shim_data_dir_has(ipcpi.shim_data, hash))
+ if (shim_data_dir_has(udp_data.shim_data, hash))
return 0;
#ifdef CONFIG_OUROBOROS_ENABLE_DNS
@@ -880,7 +894,7 @@ static int ipcp_udp_query(const uint8_t * hash)
}
#endif
- if (shim_data_dir_add_entry(ipcpi.shim_data, hash, ip_addr)) {
+ if (shim_data_dir_add_entry(udp_data.shim_data, hash, ip_addr)) {
log_err("Failed to add directory entry.");
return -1;
}
@@ -926,12 +940,12 @@ static int ipcp_udp_flow_alloc(int fd,
return -1;
}
- if (!shim_data_dir_has(ipcpi.shim_data, dst)) {
+ if (!shim_data_dir_has(udp_data.shim_data, dst)) {
log_dbg("Could not resolve destination.");
close(skfd);
return -1;
}
- ip_addr = (uint32_t) shim_data_dir_get_addr(ipcpi.shim_data, dst);
+ ip_addr = (uint32_t) shim_data_dir_get_addr(udp_data.shim_data, dst);
/* connect to server (store the remote IP address in the fd) */
memset((char *) &r_saddr, 0, sizeof(r_saddr));
diff --git a/src/ipcpd/shim-udp/shim_udp_config.h.in b/src/ipcpd/shim-udp/shim_udp_config.h.in
deleted file mode 100644
index c32210e9..00000000
--- a/src/ipcpd/shim-udp/shim_udp_config.h.in
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * Configuration information specific for the shim UDP
- *
- * Sander Vrijders <sander.vrijders@intec.ugent.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-#ifndef OUROBOROS_SHIM_UDP_CONFIG
-#define OUROBOROS_SHIM_UDP_CONFIG
-
-#define NSUPDATE_EXEC "@NSUPDATE_EXECUTABLE@"
-#define NSLOOKUP_EXEC "@NSLOOKUP_EXECUTABLE@"
-
-#endif
diff --git a/src/ipcpd/shim-udp/tests/CMakeLists.txt b/src/ipcpd/shim-udp/tests/CMakeLists.txt
deleted file mode 100644
index bdd7defb..00000000
--- a/src/ipcpd/shim-udp/tests/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-get_filename_component(PARENT_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
-get_filename_component(PARENT_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR} DIRECTORY)
-get_filename_component(PARENT_DIR ${PARENT_SOURCE_PATH} NAME)
-
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-include_directories(${PARENT_SOURCE_PATH})
-include_directories(${PARENT_BINARY_PATH})
-
-include_directories(${CMAKE_SOURCE_DIR}/include)
-include_directories(${CMAKE_BINARY_DIR}/include)
-
-create_test_sourcelist(${PARENT_DIR}_tests test_suite.c
- # Add new tests here
- shim_udp_test.c
-)
-
-add_executable(${PARENT_DIR}_test EXCLUDE_FROM_ALL ${IPCP_SOURCES} ${${PARENT_DIR}_tests})
-target_link_libraries(${PARENT_DIR}_test ouroboros)
-
-include(MacroAddCompileFlags)
-MACRO_ADD_COMPILE_FLAGS(${PARENT_DIR}_test -DMAKE_CHECK)
-
-add_dependencies(check ${PARENT_DIR}_test)
-
-set(tests_to_run ${${PARENT_DIR}_tests})
-remove(tests_to_run test_suite.c)
-
-foreach(test ${tests_to_run})
- get_filename_component(test_name ${test} NAME_WE)
- add_test(${test_name} ${C_TEST_PATH}/${PARENT_DIR}_test ${test_name})
-endforeach(test)
diff --git a/src/ipcpd/shim-udp/tests/shim_udp_test.c b/src/ipcpd/shim-udp/tests/shim_udp_test.c
deleted file mode 100644
index 88669a9e..00000000
--- a/src/ipcpd/shim-udp/tests/shim_udp_test.c
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * Test of the Shim UDP IPCP Daemon
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-#include <ouroboros/config.h>
-#include <ouroboros/ipcp.h>
-#include <ouroboros/utils.h>
-#include <ouroboros/shm_du_map.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include "main.c"
-
-#include <ouroboros/logs.h>
-
-struct ipcp * _ipcp;
-
-int shim_udp_test(int argc, char ** argv)
-{
- struct shm_du_map * dum;
- char * ipcp_name = "test-shim-ipcp";
- int i = 0;
-
- char bogus[16];
- memset(&bogus, 0, 16);
-
- struct ipcp_config conf;
- memset(&conf, 0, sizeof conf);
- conf.dif_name = strdup("test-dif");
- conf.type = IPCP_SHIM_UDP;
- conf.ip_addr = 0;
-
- dum = shm_du_map_create();
- if (dum == NULL) {
- log_err("Failed to create shared memory.");
- exit(1);
- }
-
- _ipcp = ipcp_udp_create(ipcp_name);
- if (_ipcp == NULL) {
- log_err("Could not instantiate shim IPCP.");
- shm_du_map_destroy(dum);
- exit(1);
- }
-
- if (ipcp_udp_bootstrap(&conf)) {
- log_err("Could not bootstrap.");
- }
-
- if (ipcp_udp_name_reg("bogus name")) {
- log_err("Failed to register application.");
- shm_du_map_destroy(dum);
- exit(1);
- }
-
- if (ipcp_udp_name_unreg("bogus name")) {
- log_err("Failed to unregister application.");
- shm_du_map_destroy(dum);
- exit(1);
- }
-
- for (i = 0; i < 1000; ++i) {
- sprintf(bogus, "bogus name %4d", i);
- if (ipcp_udp_name_reg(bogus)) {
- log_err("Failed to register application %s.", bogus);
- shm_du_map_destroy(dum);
- exit(1);
- }
- }
-
- for (i = 0; i < 1000; ++i) {
- sprintf(bogus, "bogus name %4d", i);
- if(ipcp_udp_name_unreg(bogus)) {
- log_err("Failed to unregister application %s.", bogus);
- shm_du_map_destroy(dum);
- exit(1);
- }
- }
-
- shm_du_map_destroy(dum);
-
- exit(0);
-}
diff --git a/src/irmd/CMakeLists.txt b/src/irmd/CMakeLists.txt
index 930c7b05..3339991a 100644
--- a/src/irmd/CMakeLists.txt
+++ b/src/irmd/CMakeLists.txt
@@ -4,6 +4,28 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${CMAKE_BINARY_DIR}/include)
+set(IRMD_ACCEPT_TIMEOUT 100 CACHE STRING
+ "Timeout for accept in IRMD mainloop threads (ms)")
+set(IRMD_REQ_ARR_TIMEOUT 500 CACHE STRING
+ "Timeout for an application to respond to a new flow (ms)")
+set(IRMD_FLOW_TIMEOUT 5000 CACHE STRING
+ "Timeout for a flow allocation response (ms)")
+set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING
+ "Timeout for an IPCP to bootstrap (ms)")
+set(ENROLL_TIMEOUT 60000 CACHE STRING
+ "Timeout for an IPCP to enroll (ms)")
+set(REG_TIMEOUT 10000 CACHE STRING
+ "Timeout for registering a name (ms)")
+set(QUERY_TIMEOUT 3000 CACHE STRING
+ "Timeout to query a name with an IPCP (ms)")
+set(IRMD_MIN_THREADS 8 CACHE STRING
+ "Minimum number of worker threads in the IRMd.")
+set(IRMD_ADD_THREADS 8 CACHE STRING
+ "Number of extra threads to start when the IRMD faces thread starvation")
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
+
set(SOURCE_FILES
# Add source files here
api_table.c
diff --git a/src/irmd/api_table.c b/src/irmd/api_table.c
index 5765916e..df56dd02 100644
--- a/src/irmd/api_table.c
+++ b/src/irmd/api_table.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#include <ouroboros/list.h>
#include <ouroboros/errno.h>
#include <ouroboros/time_utils.h>
diff --git a/src/irmd/config.h.in b/src/irmd/config.h.in
new file mode 100644
index 00000000..eb396bbc
--- /dev/null
+++ b/src/irmd/config.h.in
@@ -0,0 +1,46 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2017
+ *
+ * Configuration for the IPC Resource Manager
+ *
+ * Dimitri Staessens <dimitri.staessens@ugent.be>
+ * Sander Vrijders <sander.vrijders@ugent.be>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#define IPCP_SHIM_UDP_EXEC "@IPCP_SHIM_UDP_TARGET@"
+#define IPCP_SHIM_ETH_LLC_EXEC "@IPCP_SHIM_ETH_LLC_TARGET@"
+#define IPCP_NORMAL_EXEC "@IPCP_NORMAL_TARGET@"
+#define IPCP_LOCAL_EXEC "@IPCP_LOCAL_TARGET@"
+
+#define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@"
+
+#define PTHREAD_COND_CLOCK @PTHREAD_COND_CLOCK@
+
+#define SOCKET_TIMEOUT @SOCKET_TIMEOUT@
+
+#define IRMD_ACCEPT_TIMEOUT @IRMD_ACCEPT_TIMEOUT@
+#define IRMD_REQ_ARR_TIMEOUT @IRMD_REQ_ARR_TIMEOUT@
+#define IRMD_FLOW_TIMEOUT @IRMD_FLOW_TIMEOUT@
+
+#define BOOTSTRAP_TIMEOUT @BOOTSTRAP_TIMEOUT@
+#define ENROLL_TIMEOUT @ENROLL_TIMEOUT@
+#define REG_TIMEOUT @REG_TIMEOUT@
+#define QUERY_TIMEOUT @QUERY_TIMEOUT@
+
+#define SYS_MAX_FLOWS @SYS_MAX_FLOWS@
+
+#define IRMD_MIN_THREADS @IRMD_MIN_THREADS@
+#define IRMD_ADD_THREADS @IRMD_ADD_THREADS@
diff --git a/src/irmd/ipcp.c b/src/irmd/ipcp.c
index f3f97811..b8f11508 100644
--- a/src/irmd/ipcp.c
+++ b/src/irmd/ipcp.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 199309L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "irmd/ipcp"
-#include <ouroboros/config.h>
#include <ouroboros/logs.h>
#include <ouroboros/errno.h>
#include <ouroboros/utils.h>
diff --git a/src/irmd/irm_flow.c b/src/irmd/irm_flow.c
index ae5585a2..e335ef48 100644
--- a/src/irmd/irm_flow.c
+++ b/src/irmd/irm_flow.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 199309L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "irm_flow"
-#include <ouroboros/config.h>
#include <ouroboros/errno.h>
#include <ouroboros/logs.h>
#include <ouroboros/time_utils.h>
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 62c1cc61..77471cfc 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -20,9 +20,13 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200812L
+#define __XSI_VISIBLE 500
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "irmd"
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/errno.h>
#include <ouroboros/sockets.h>
@@ -2068,7 +2072,7 @@ static int irm_init(void)
list_head_init(&irmd.registry);
list_head_init(&irmd.irm_flows);
- irmd.port_ids = bmp_create(IRMD_MAX_FLOWS, 0);
+ irmd.port_ids = bmp_create(SYS_MAX_FLOWS, 0);
if (irmd.port_ids == NULL) {
log_err("Failed to create port_ids bitmap.");
goto fail_port_ids;
diff --git a/src/irmd/registry.c b/src/irmd/registry.c
index ad6a10d4..3cc9b5f5 100644
--- a/src/irmd/registry.c
+++ b/src/irmd/registry.c
@@ -20,9 +20,12 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
#define OUROBOROS_PREFIX "registry"
-#include <ouroboros/config.h>
#include <ouroboros/errno.h>
#include <ouroboros/logs.h>
#include <ouroboros/irm.h>
diff --git a/src/irmd/registry.h b/src/irmd/registry.h
index d1733f6c..486843a2 100644
--- a/src/irmd/registry.h
+++ b/src/irmd/registry.h
@@ -23,7 +23,6 @@
#ifndef OUROBOROS_IRMD_REGISTRY_H
#define OUROBOROS_IRMD_REGISTRY_H
-#include <ouroboros/config.h>
#include <ouroboros/hash.h>
#include <ouroboros/ipcp.h>
#include <ouroboros/list.h>
diff --git a/src/irmd/utils.c b/src/irmd/utils.c
index 5a3da732..08699a05 100644
--- a/src/irmd/utils.c
+++ b/src/irmd/utils.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
#include <stdlib.h>
#include <string.h>
diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt
index 728d975a..4522613b 100644
--- a/src/lib/CMakeLists.txt
+++ b/src/lib/CMakeLists.txt
@@ -15,7 +15,7 @@ protobuf_generate_c(CACEP_PROTO_SRCS CACEP_PROTO_HDRS cacep.proto)
if (NOT APPLE)
find_library(LIBRT_LIBRARIES rt)
if (NOT LIBRT_LIBRARIES)
- message(FATAL_ERROR "Could not find librt.")
+ message(FATAL_ERROR "Could not find librt")
endif ()
else ()
set(LIBRT_LIBRARIES "")
@@ -23,7 +23,7 @@ endif ()
find_library(LIBPTHREAD_LIBRARIES pthread)
if (NOT LIBPTHREAD_LIBRARIES)
- message(FATAL_ERROR "Could not find libpthread.")
+ message(FATAL_ERROR "Could not find libpthread")
endif ()
include(CheckSymbolExists)
@@ -31,30 +31,60 @@ list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -D__XSI_VISIBLE=500)
list(APPEND CMAKE_REQUIRED_LIBRARIES pthread)
check_symbol_exists(pthread_mutexattr_setrobust pthread.h HAVE_ROBUST_MUTEX)
-set(HAVE_ROBUST_MUTEX CACHE STRING "Have robust mutexes")
+
+if (HAVE_ROBUST_MUTEX)
+ set(DISABLE_ROBUST_MUTEXES FALSE CACHE BOOL "Disable robust mutex support")
+ if (NOT DISABLE_ROBUST_MUTEXES)
+ message(STATUS "Robust mutex support enabled")
+ set(HAVE_ROBUST_MUTEX TRUE)
+ else ()
+ message(STATUS "Robust mutex support disabled by user")
+ set(HAVE_ROBUST_MUTEX FALSE)
+ endif ()
+endif ()
find_library(LIBGCRYPT_LIBRARIES gcrypt)
if (LIBGCRYPT_LIBRARIES)
- find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h HINTS /usr/include /usr/local/include)
- if (NOT LIBGCRYPT_INCLUDE_DIR STREQUAL "GRYPT_INCLUDE_DIR-NOTFOUND")
+ find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h
+ HINTS /usr/include /usr/local/include)
+ if (LIBGCRYPT_INCLUDE_DIR)
file(STRINGS ${LIBGCRYPT_INCLUDE_DIR}/gcrypt.h GCSTR
REGEX "^#define GCRYPT_VERSION ")
string(REGEX REPLACE "^#define GCRYPT_VERSION \"(.*)\".*$" "\\1"
GCVER "${GCSTR}")
- message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES} (found version \"${GCVER}\")")
+ message(STATUS "Found libgcrypt: ${LIBGCRYPT_LIBRARIES}"
+ "(found version \"${GCVER}\")")
if (NOT GCVER VERSION_LESS "1.7.0")
- set(HAVE_LIBGCRYPT "1" CACHE STRING "Have libgcrypt")
+ set (DISABLE_LIBGCRYPT FALSE CACHE BOOL "Disable libgcrypt support")
+ if (NOT DISABLE_LIBGCRYPT)
+ message(STATUS "libgcrypt support enabled")
+ set(HAVE_LIBGCRYPT TRUE)
+ else ()
+ message(STATUS "libgcrpyt support disabled by user")
+ endif()
+ else ()
+ message(STATUS "Install version > \"1.7.0\" to enable libgcrypt support")
endif()
endif ()
-else ()
+endif ()
+
+if (NOT HAVE_LIBGCRYPT)
set(LIBGCRYPT_LIBRARIES "")
set(LIBGCRYPT_INCLUDE_DIR "")
endif ()
find_package(OpenSSL)
if (OPENSSL_FOUND)
- set(HAVE_OPENSSL "1" CACHE STRING "Have OpenSSL")
-else ()
+ set (DISABLE_OPENSSL FALSE CACHE BOOL "Disable OpenSSL support")
+ if (NOT DISABLE_OPENSSL)
+ message(STATUS "OpenSSL support enabled")
+ set(HAVE_OPENSSL TRUE)
+ else()
+ message(STATUS "OpenSSL support disabled by user")
+ endif()
+endif ()
+
+if (NOT HAVE_OPENSSL)
set (OPENSSL_INCLUDE_DIR "")
endif ()
@@ -62,9 +92,9 @@ if (APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(SYS_RND_HDR "")
else ()
find_path(SYS_RND_HDR sys/random.h PATH /usr/include/ /usr/local/include/)
- if (NOT SYS_RND_HDR STREQUAL "SYS_RND_HDR-NOTFOUND")
+ if (SYS_RND_HDR)
message(STATUS "Found sys/random.h in ${SYS_RND_HDR}")
- set(HAVE_SYS_RANDOM "1" CACHE STRING "Have random header")
+ set(HAVE_SYS_RANDOM TRUE)
else ()
set(SYS_RND_HDR "")
endif ()
@@ -73,10 +103,52 @@ endif()
if (NOT ((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") OR APPLE OR
HAVE_SYS_RANDOM OR HAVE_OPENSSL OR HAVE_LIBGCRYPT))
message(FATAL_ERROR "No secure random generator found, "
- "please install libgcrypt (> 1.7.0) or OpenSSL"
- )
+ "please install libgcrypt (> 1.7.0) or OpenSSL")
endif ()
+mark_as_advanced(LIBRT_LIBRARIES LIBPTHREAD_LIBRARIES
+ LIBGCRYPT_LIBRARIES OPENSSL_LIBRARIES SYS_RND_INCLUDE_DIR
+ LIBGCRYPT_INCLUDE_DIR SYS_RND_HDR)
+
+math(EXPR SHM_BUFFER_EXPR "1 << 20")
+set(SHM_BUFFER_SIZE ${SHM_BUFFER_EXPR} CACHE STRING
+ "Number of blocks in SDU buffer, must be a power of 2")
+set(SYS_MAX_FLOWS 4096 CACHE STRING
+ "Maximum number of total flows for this system")
+set(AP_MAX_FLOWS 1024 CACHE STRING
+ "Maximum number of flows in an application")
+set(AP_RES_FDS 64 CACHE STRING
+ "Number of reserved flow descriptors per application")
+set(AP_MAX_FQUEUES 32 CACHE STRING
+ "Maximum number of flow sets per application")
+set(DU_BUFF_HEADSPACE 128 CACHE STRING
+ "Bytes of headspace to reserve for future headers")
+set(DU_BUFF_TAILSPACE 0 CACHE STRING
+ "Bytes of tailspace to reserve for future tails")
+if (NOT APPLE)
+ set(PTHREAD_COND_CLOCK "CLOCK_MONOTONIC" CACHE STRING
+ "Clock to use for condition variable timing")
+else ()
+ set (PTHREAD_COND_CLOCK "CLOCK_REALTIME" CACHE INTERNAL
+ "Clock to use for condition variable timing")
+endif ()
+set(SOCKET_TIMEOUT 1000 CACHE STRING
+ "Default timeout for responses from IPCPs (ms)")
+set(CDAP_REPLY_TIMEOUT 6000 CACHE STRING
+ "Timeout for CDAP to wait for reply")
+set(SHM_PREFIX "ouroboros" CACHE STRING
+ "String to prepend to POSIX shared memory filenames")
+set(SHM_RBUFF_PREFIX "/${SHM_PREFIX}.rbuff." CACHE INTERNAL
+ "Prefix for rbuff POSIX shared memory filenames")
+set(SHM_LOCKFILE_NAME "/${SHM_PREFIX}.lockfile" CACHE INTERNAL
+ "Filename for the POSIX shared memory lockfile")
+set(SHM_FLOW_SET_PREFIX "/${SHM_PREFIX}.set." CACHE INTERNAL
+ "Prefix for the POSIX shared memory flow set")
+set(SHM_RDRB_NAME "/${SHM_PREFIX}.rdrb" CACHE INTERNAL
+ "Name for the main POSIX shared memory buffer")
+set(SHM_RDRB_BLOCK_SIZE "sysconf(_SC_PAGESIZE)" CACHE STRING
+ "SDU buffer block size, multiple of pagesize for performance")
+
set(SOURCE_FILES
# Add source files here
bitmap.c
@@ -94,7 +166,6 @@ set(SOURCE_FILES
lockfile.c
logs.c
md5.c
- nsm.c
qos.c
qoscube.c
random.c
@@ -110,6 +181,9 @@ set(SOURCE_FILES
utils.c
)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/config.h" @ONLY)
+
add_library(ouroboros SHARED ${SOURCE_FILES} ${IRM_PROTO_SRCS}
${IPCP_PROTO_SRCS} ${DIF_CONFIG_PROTO_SRCS} ${CDAP_PROTO_SRCS}
${CACEP_PROTO_SRCS} ${RO_PROTO_SRCS})
diff --git a/src/lib/cacep.c b/src/lib/cacep.c
index 55d11b0f..722adca1 100644
--- a/src/lib/cacep.c
+++ b/src/lib/cacep.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 199309L
+
#include <ouroboros/cacep.h>
#include <ouroboros/dev.h>
#include <ouroboros/errno.h>
diff --git a/src/lib/cdap.c b/src/lib/cdap.c
index bf8d5816..679771f5 100644
--- a/src/lib/cdap.c
+++ b/src/lib/cdap.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
#include <ouroboros/cdap.h>
#include <ouroboros/bitmap.h>
#include <ouroboros/dev.h>
diff --git a/src/lib/cdap_req.c b/src/lib/cdap_req.c
index 7aded62f..a9b85525 100644
--- a/src/lib/cdap_req.c
+++ b/src/lib/cdap_req.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
#include <ouroboros/time_utils.h>
#include <ouroboros/errno.h>
diff --git a/src/lib/cdap_req.h b/src/lib/cdap_req.h
index 89f4145a..4c9cd15b 100644
--- a/src/lib/cdap_req.h
+++ b/src/lib/cdap_req.h
@@ -23,7 +23,6 @@
#ifndef OUROBOROS_CDAP_REQ_H
#define OUROBOROS_CDAP_REQ_H
-#include <ouroboros/config.h>
#include <ouroboros/cdap.h>
#include <ouroboros/list.h>
#include <ouroboros/utils.h>
diff --git a/src/lib/config.h.in b/src/lib/config.h.in
new file mode 100644
index 00000000..c4b189d7
--- /dev/null
+++ b/src/lib/config.h.in
@@ -0,0 +1,57 @@
+/*
+ * Ouroboros - Copyright (C) 2016 - 2017
+ *
+ * Ouroboros library configuration
+ *
+ * Dimitri Staessens <dimitri.staessens@ugent.be>
+ * Sander Vrijders <sander.vrijders@ugent.be>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., http://www.fsf.org/about/contact/.
+ */
+
+#cmakedefine HAVE_SYS_RANDOM
+#cmakedefine HAVE_LIBGCRYPT
+#cmakedefine HAVE_OPENSSL
+
+#define SYS_MAX_FLOWS @SYS_MAX_FLOWS@
+
+#cmakedefine SHM_RBUFF_LOCKLESS
+
+#define SHM_RBUFF_PREFIX "@SHM_RBUFF_PREFIX@"
+#define SHM_LOCKFILE_NAME "@SHM_LOCKFILE_NAME@"
+#define SHM_FLOW_SET_PREFIX "@SHM_FLOW_SET_PREFIX@"
+#define SHM_RDRB_NAME "@SHM_RDRB_NAME@"
+#define SHM_RDRB_BLOCK_SIZE @SHM_RDRB_BLOCK_SIZE@
+#define SHM_BUFFER_SIZE @SHM_BUFFER_SIZE@
+
+#if defined(__linux__) || (defined(__MACH__) && !defined(__APPLE__))
+/* Avoid a bug in robust mutex implementation of glibc 2.25 */
+ #include <features.h>
+ #if !defined(__GLIBC__) || !(__GLIBC__ == 2 && __GLIBC_MINOR__ == 25)
+ #cmakedefine HAVE_ROBUST_MUTEX
+ #else
+ #cmakedefine HAVE_ROBUST_MUTEX
+ #endif
+#endif
+
+#define PTHREAD_COND_CLOCK @PTHREAD_COND_CLOCK@
+
+#define AP_MAX_FLOWS @AP_MAX_FLOWS@
+#define AP_RES_FDS @AP_RES_FDS@
+#define AP_MAX_FQUEUES @AP_MAX_FQUEUES@
+
+#define DU_BUFF_HEADSPACE @DU_BUFF_HEADSPACE@
+#define DU_BUFF_TAILSPACE @DU_BUFF_TAILSPACE@
+
+#define CDAP_REPLY_TIMEOUT @CDAP_REPLY_TIMEOUT@
diff --git a/src/lib/dev.c b/src/lib/dev.c
index e81bf105..1018f556 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
#include <ouroboros/errno.h>
#include <ouroboros/dev.h>
#include <ouroboros/ipcp-dev.h>
@@ -596,7 +599,7 @@ int ouroboros_init(const char * ap_name)
frcti_fini(i);
}
- ai.ports = malloc(sizeof(*ai.ports) * IRMD_MAX_FLOWS);
+ ai.ports = malloc(sizeof(*ai.ports) * SYS_MAX_FLOWS);
if (ai.ports == NULL)
goto fail_ports;
@@ -611,7 +614,7 @@ int ouroboros_init(const char * ap_name)
}
}
- for (i = 0; i < IRMD_MAX_FLOWS; ++i) {
+ for (i = 0; i < SYS_MAX_FLOWS; ++i) {
ai.ports[i].state = PORT_INIT;
if (pthread_mutex_init(&ai.ports[i].state_lock, NULL)) {
int j;
@@ -640,10 +643,10 @@ int ouroboros_init(const char * ap_name)
fail_timerwheel:
pthread_rwlock_destroy(&ai.lock);
fail_lock:
- for (i = 0; i < IRMD_MAX_FLOWS; ++i)
+ for (i = 0; i < SYS_MAX_FLOWS; ++i)
pthread_cond_destroy(&ai.ports[i].state_cond);
fail_state_cond:
- for (i = 0; i < IRMD_MAX_FLOWS; ++i)
+ for (i = 0; i < SYS_MAX_FLOWS; ++i)
pthread_mutex_destroy(&ai.ports[i].state_lock);
fail_announce:
free(ai.ap_name);
@@ -688,7 +691,7 @@ void ouroboros_fini()
}
}
- for (i = 0; i < IRMD_MAX_FLOWS; ++i) {
+ for (i = 0; i < SYS_MAX_FLOWS; ++i) {
pthread_mutex_destroy(&ai.ports[i].state_lock);
pthread_cond_destroy(&ai.ports[i].state_cond);
}
diff --git a/src/lib/frct_pci.c b/src/lib/frct_pci.c
index 92cf8cd9..392e11c6 100644
--- a/src/lib/frct_pci.c
+++ b/src/lib/frct_pci.c
@@ -20,7 +20,6 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
#include <ouroboros/frct_pci.h>
#include <ouroboros/hash.h>
#include <ouroboros/errno.h>
diff --git a/src/lib/hash.c b/src/lib/hash.c
index e062a0ad..09e5be8c 100644
--- a/src/lib/hash.c
+++ b/src/lib/hash.c
@@ -23,7 +23,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#include "config.h"
+
#include <ouroboros/hash.h>
#ifndef HAVE_LIBGCRYPT
diff --git a/src/lib/irm.c b/src/lib/irm.c
index a6075d33..4232cec1 100644
--- a/src/lib/irm.c
+++ b/src/lib/irm.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
#include <ouroboros/errno.h>
#include <ouroboros/hash.h>
#include <ouroboros/irm.h>
diff --git a/src/lib/lockfile.c b/src/lib/lockfile.c
index e2e4d289..4a3dcb91 100644
--- a/src/lib/lockfile.c
+++ b/src/lib/lockfile.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#include <ouroboros/lockfile.h>
#include <stdlib.h>
@@ -47,7 +50,7 @@ struct lockfile * lockfile_create() {
mask = umask(0);
- fd = shm_open(LOCKFILE_NAME, O_CREAT | O_EXCL | O_RDWR, 0666);
+ fd = shm_open(SHM_LOCKFILE_NAME, O_CREAT | O_EXCL | O_RDWR, 0666);
if (fd == -1) {
free(lf);
return NULL;
@@ -69,7 +72,7 @@ struct lockfile * lockfile_create() {
close (fd);
if (lf->api == MAP_FAILED) {
- shm_unlink(LOCKFILE_NAME);
+ shm_unlink(SHM_LOCKFILE_NAME);
free(lf);
return NULL;
}
@@ -85,7 +88,7 @@ struct lockfile * lockfile_open() {
if (lf == NULL)
return NULL;
- fd = shm_open(LOCKFILE_NAME, O_RDWR, 0666);
+ fd = shm_open(SHM_LOCKFILE_NAME, O_RDWR, 0666);
if (fd < 0) {
free(lf);
return NULL;
@@ -100,7 +103,7 @@ struct lockfile * lockfile_open() {
close(fd);
if (lf->api == MAP_FAILED) {
- shm_unlink(LOCKFILE_NAME);
+ shm_unlink(SHM_LOCKFILE_NAME);
free(lf);
return NULL;
}
@@ -126,7 +129,7 @@ void lockfile_destroy(struct lockfile * lf)
munmap(lf->api, LF_SIZE);
- shm_unlink(LOCKFILE_NAME);
+ shm_unlink(SHM_LOCKFILE_NAME);
free(lf);
}
diff --git a/src/lib/md5.c b/src/lib/md5.c
index a4d92de3..3394f406 100644
--- a/src/lib/md5.c
+++ b/src/lib/md5.c
@@ -1,7 +1,7 @@
/*
* Ouroboros - Copyright (C) 2016 - 2017
*
- * SHA3 algorithm
+ * MD5 algorithm
*
* Dimitri Staessens <dimitri.staessens@ugent.be>
* Sander Vrijders <sander.vrijders@ugent.be>
diff --git a/src/lib/nsm.c b/src/lib/nsm.c
deleted file mode 100644
index 2dd5729b..00000000
--- a/src/lib/nsm.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Ouroboros - Copyright (C) 2016 - 2017
- *
- * The API to instruct the global Namespace Manager
- *
- * Dimitri Staessens <dimitri.staessens@ugent.be>
- * Sander Vrijders <sander.vrijders@ugent.be>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., http://www.fsf.org/about/contact/.
- */
-
-#include <ouroboros/nsm.h>
-
-int nsm_reg(char * name,
- char ** dafs,
- size_t dafs_size)
-{
- (void) name;
- (void) dafs;
- (void) dafs_size;
-
- return -1;
-}
-
-int nsm_unreg(char * name,
- char ** dafs,
- size_t dafs_size)
-{
- (void) name;
- (void) dafs;
- (void) dafs_size;
-
-
- return -1;
-}
-
-ssize_t nsm_resolve(char * name,
- char ** dafs)
-{
- (void) name;
- (void) dafs;
-
- return -1;
-}
diff --git a/src/lib/random.c b/src/lib/random.c
index 66aefaa3..27719b26 100644
--- a/src/lib/random.c
+++ b/src/lib/random.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#include "config.h"
+
#include <ouroboros/random.h>
#if defined(__APPLE__) /* Barf */
diff --git a/src/lib/rib.c b/src/lib/rib.c
index e8cf97d4..104dc0cc 100644
--- a/src/lib/rib.c
+++ b/src/lib/rib.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
#include <ouroboros/rib.h>
diff --git a/src/lib/shm_flow_set.c b/src/lib/shm_flow_set.c
index 2f1d4e33..f4a70689 100644
--- a/src/lib/shm_flow_set.c
+++ b/src/lib/shm_flow_set.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
#include <ouroboros/lockfile.h>
#include <ouroboros/time_utils.h>
#include <ouroboros/shm_flow_set.h>
@@ -38,11 +41,22 @@
#include <string.h>
#include <assert.h>
+/*
+ * pthread_cond_timedwait has a WONTFIX bug as of glibc 2.25 where it
+ * doesn't test pthread cancellation when passed an expired timeout
+ * with the clock set to CLOCK_MONOTONIC.
+ */
+#if ((defined(__linux__) || (defined(__MACH__) && !defined(__APPLE__))) \
+ && (defined(__GLIBC__) && ((__GLIBC__ * 1000 + __GLIBC_MINOR__) >= 2025)) \
+ && (PTHREAD_COND_CLOCK == CLOCK_MONOTONIC))
+#define HAVE_CANCEL_BUG
+#endif
+
#define FN_MAX_CHARS 255
#define FQUEUESIZE ((SHM_BUFFER_SIZE) * sizeof(int))
-#define SHM_FLOW_SET_FILE_SIZE (IRMD_MAX_FLOWS * sizeof(ssize_t) \
+#define SHM_FLOW_SET_FILE_SIZE (SYS_MAX_FLOWS * sizeof(ssize_t) \
+ AP_MAX_FQUEUES * sizeof(size_t) \
+ AP_MAX_FQUEUES * sizeof(pthread_cond_t) \
+ AP_MAX_FQUEUES * FQUEUESIZE \
@@ -109,7 +123,7 @@ struct shm_flow_set * shm_flow_set_create()
}
set->mtable = shm_base;
- set->heads = (size_t *) (set->mtable + IRMD_MAX_FLOWS);
+ set->heads = (size_t *) (set->mtable + SYS_MAX_FLOWS);
set->conds = (pthread_cond_t *)(set->heads + AP_MAX_FQUEUES);
set->fqueues = (int *) (set->conds + AP_MAX_FQUEUES);
set->lock = (pthread_mutex_t *)
@@ -132,7 +146,7 @@ struct shm_flow_set * shm_flow_set_create()
pthread_cond_init(&set->conds[i], &cattr);
}
- for (i = 0; i < IRMD_MAX_FLOWS; ++i)
+ for (i = 0; i < SYS_MAX_FLOWS; ++i)
set->mtable[i] = -1;
set->api = getpid();
@@ -175,7 +189,7 @@ struct shm_flow_set * shm_flow_set_open(pid_t api)
}
set->mtable = shm_base;
- set->heads = (size_t *) (set->mtable + IRMD_MAX_FLOWS);
+ set->heads = (size_t *) (set->mtable + SYS_MAX_FLOWS);
set->conds = (pthread_cond_t *)(set->heads + AP_MAX_FQUEUES);
set->fqueues = (int *) (set->conds + AP_MAX_FQUEUES);
set->lock = (pthread_mutex_t *)
@@ -233,7 +247,7 @@ void shm_flow_set_zero(struct shm_flow_set * set,
pthread_mutex_lock(set->lock);
- for (i = 0; i < IRMD_MAX_FLOWS; ++i)
+ for (i = 0; i < SYS_MAX_FLOWS; ++i)
if (set->mtable[i] == (ssize_t) idx)
set->mtable[i] = -1;
@@ -248,7 +262,7 @@ int shm_flow_set_add(struct shm_flow_set * set,
int port_id)
{
assert(set);
- assert(!(port_id < 0) && port_id < IRMD_MAX_FLOWS);
+ assert(!(port_id < 0) && port_id < SYS_MAX_FLOWS);
assert(idx < AP_MAX_FQUEUES);
pthread_mutex_lock(set->lock);
@@ -270,7 +284,7 @@ void shm_flow_set_del(struct shm_flow_set * set,
int port_id)
{
assert(set);
- assert(!(port_id < 0) && port_id < IRMD_MAX_FLOWS);
+ assert(!(port_id < 0) && port_id < SYS_MAX_FLOWS);
assert(idx < AP_MAX_FQUEUES);
pthread_mutex_lock(set->lock);
@@ -288,7 +302,7 @@ int shm_flow_set_has(struct shm_flow_set * set,
int ret = 0;
assert(set);
- assert(!(port_id < 0) && port_id < IRMD_MAX_FLOWS);
+ assert(!(port_id < 0) && port_id < SYS_MAX_FLOWS);
assert(idx < AP_MAX_FQUEUES);
pthread_mutex_lock(set->lock);
@@ -305,7 +319,7 @@ void shm_flow_set_notify(struct shm_flow_set * set,
int port_id)
{
assert(set);
- assert(!(port_id < 0) && port_id < IRMD_MAX_FLOWS);
+ assert(!(port_id < 0) && port_id < SYS_MAX_FLOWS);
pthread_mutex_lock(set->lock);
@@ -345,13 +359,18 @@ ssize_t shm_flow_set_wait(const struct shm_flow_set * set,
(void *) set->lock);
while (set->heads[idx] == 0 && ret != -ETIMEDOUT) {
- if (abstime != NULL)
+ if (abstime != NULL) {
ret = -pthread_cond_timedwait(set->conds + idx,
set->lock,
abstime);
- else
+#ifdef HAVE_CANCEL_BUG
+ if (ret == -ETIMEDOUT)
+ pthread_testcancel();
+#endif
+ } else {
ret = -pthread_cond_wait(set->conds + idx,
set->lock);
+ }
#ifdef HAVE_ROBUST_MUTEX
if (ret == -EOWNERDEAD)
pthread_mutex_consistent(set->lock);
diff --git a/src/lib/shm_rbuff.c b/src/lib/shm_rbuff.c
index 7f8af9f5..93108332 100644
--- a/src/lib/shm_rbuff.c
+++ b/src/lib/shm_rbuff.c
@@ -19,9 +19,12 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
-#if ((SHM_RBUFF_LOCKLESS > 0) && \
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
+#if (defined(SHM_RBUFF_LOCKLESS) && \
(defined(__GNUC__) || defined (__clang__)))
#include "shm_rbuff_ll.c"
#else
diff --git a/src/lib/shm_rbuff_ll.c b/src/lib/shm_rbuff_ll.c
index b420b785..ec0199c0 100644
--- a/src/lib/shm_rbuff_ll.c
+++ b/src/lib/shm_rbuff_ll.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#include "config.h"
+
#include <ouroboros/shm_rbuff.h>
#include <ouroboros/lockfile.h>
#include <ouroboros/time_utils.h>
diff --git a/src/lib/shm_rbuff_pthr.c b/src/lib/shm_rbuff_pthr.c
index 7dc5f5d9..9567762f 100644
--- a/src/lib/shm_rbuff_pthr.c
+++ b/src/lib/shm_rbuff_pthr.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
#include <ouroboros/shm_rbuff.h>
#include <ouroboros/lockfile.h>
#include <ouroboros/time_utils.h>
diff --git a/src/lib/shm_rdrbuff.c b/src/lib/shm_rdrbuff.c
index 0919b1e0..447f8b35 100644
--- a/src/lib/shm_rdrbuff.c
+++ b/src/lib/shm_rdrbuff.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200809L
+
+#include "config.h"
+
#include <ouroboros/errno.h>
#include <ouroboros/shm_rdrbuff.h>
#include <ouroboros/shm_du_buff.h>
diff --git a/src/lib/sockets.c b/src/lib/sockets.c
index 7f0c4dd4..263d2356 100644
--- a/src/lib/sockets.c
+++ b/src/lib/sockets.c
@@ -20,7 +20,6 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
#include <ouroboros/errno.h>
#include <ouroboros/sockets.h>
#include <ouroboros/utils.h>
diff --git a/src/lib/tests/CMakeLists.txt b/src/lib/tests/CMakeLists.txt
index fd3c1c6a..0223262a 100644
--- a/src/lib/tests/CMakeLists.txt
+++ b/src/lib/tests/CMakeLists.txt
@@ -1,6 +1,12 @@
get_filename_component(PARENT_PATH ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
get_filename_component(PARENT_DIR ${PARENT_PATH} NAME)
+if (NOT (APPLE OR GNU))
+ set(TIMERWHEEL_TEST "timerwheel_test.c")
+else ()
+ set(TIMERWHEEL_TEST "")
+endif ()
+
create_test_sourcelist(${PARENT_DIR}_tests test_suite.c
# Add new tests here
bitmap_test.c
@@ -11,7 +17,7 @@ create_test_sourcelist(${PARENT_DIR}_tests test_suite.c
rib_test.c
sha3_test.c
time_utils_test.c
- timerwheel_test.c
+ ${TIMERWHEEL_TEST}
)
add_executable(${PARENT_DIR}_test EXCLUDE_FROM_ALL ${${PARENT_DIR}_tests})
diff --git a/src/lib/tests/rib_test.c b/src/lib/tests/rib_test.c
index e1fa427d..6a2446b9 100644
--- a/src/lib/tests/rib_test.c
+++ b/src/lib/tests/rib_test.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 199309L
+
#include <ouroboros/time_utils.h>
#include <ouroboros/rib.h>
#include <ouroboros/rqueue.h>
diff --git a/src/lib/time_utils.c b/src/lib/time_utils.c
index 2dec4524..22937d4b 100644
--- a/src/lib/time_utils.c
+++ b/src/lib/time_utils.c
@@ -20,7 +20,8 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 199309L
+
#include <ouroboros/time_utils.h>
#include <stddef.h>
diff --git a/src/lib/timerwheel.c b/src/lib/timerwheel.c
index 7e2779d0..76f0ab32 100644
--- a/src/lib/timerwheel.c
+++ b/src/lib/timerwheel.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#include <ouroboros/time_utils.h>
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
diff --git a/src/lib/tpm.c b/src/lib/tpm.c
index 739996c4..dd71d276 100644
--- a/src/lib/tpm.c
+++ b/src/lib/tpm.c
@@ -20,7 +20,10 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#include <ouroboros/config.h>
+#define _POSIX_C_SOURCE 200112L
+
+#include "config.h"
+
#include <ouroboros/errno.h>
#include <ouroboros/list.h>
#include <ouroboros/time_utils.h>
diff --git a/src/nsmd/CMakeLists.txt b/src/nsmd/CMakeLists.txt
deleted file mode 100644
index 2995b725..00000000
--- a/src/nsmd/CMakeLists.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-include_directories(${CMAKE_CURRENT_SOURCE_DIR})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-include_directories(${CMAKE_SOURCE_DIR}/include)
-include_directories(${CMAKE_BINARY_DIR}/include)
-
-set(SOURCE_FILES
- # Add source files here
- main.c
- )
-
-add_executable(nsmd ${SOURCE_FILES})
-
-target_link_libraries(nsmd LINK_PUBLIC ouroboros)
-
-include(AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES Debug)
- add_compile_flags(nsmd -DCONFIG_OUROBOROS_DEBUG)
-endif (CMAKE_BUILD_TYPE MATCHES Debug)
-
-install(TARGETS nsmd RUNTIME DESTINATION sbin)
-
-# Enable once nsmd has tests
-# add_subdirectory(tests)
diff --git a/src/nsmd/tests/CMakeLists.txt b/src/nsmd/tests/CMakeLists.txt
deleted file mode 100644
index 68bd762d..00000000
--- a/src/nsmd/tests/CMakeLists.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-get_filename_component(tmp ".." ABSOLUTE)
-get_filename_component(src_folder "${tmp}" NAME)
-
-create_test_sourcelist(${src_folder}_tests test_suite.c
- # Add new tests here
-)
-
-add_executable(${src_folder}_test EXCLUDE_FROM_ALL ${${src_folder}_tests})
-target_link_libraries(${src_folder}_test ouroboros)
-
-add_dependencies(check ${src_folder}_test)
-
-set(tests_to_run ${${src_folder}_tests})
-remove(tests_to_run test_suite.c)
-
-foreach(test ${tests_to_run})
- get_filename_component(test_name ${test} NAME_WE)
- add_test(${test_name} ${C_TEST_PATH}/${src_folder}_test ${test_name})
-endforeach(test)
diff --git a/src/tools/operf/operf.c b/src/tools/operf/operf.c
index d2dfeaa3..e54fbc6b 100644
--- a/src/tools/operf/operf.c
+++ b/src/tools/operf/operf.c
@@ -21,6 +21,7 @@
*/
#define _POSIX_C_SOURCE 199506L
+#define __XSI_VISIBLE 500
#include <ouroboros/fqueue.h>
#include <ouroboros/dev.h>
diff --git a/src/tools/operf/operf_client.c b/src/tools/operf/operf_client.c
index a905b05e..4ad26d13 100644
--- a/src/tools/operf/operf_client.c
+++ b/src/tools/operf/operf_client.c
@@ -24,10 +24,6 @@
#include <ouroboros/fcntl.h>
#include <ouroboros/time_utils.h>
-#ifdef __FreeBSD__
-#define __XSI_VISIBLE 500
-#endif
-
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/src/tools/operf/operf_server.c b/src/tools/operf/operf_server.c
index 3b43ece4..c016ad63 100644
--- a/src/tools/operf/operf_server.c
+++ b/src/tools/operf/operf_server.c
@@ -20,10 +20,6 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifdef __FreeBSD__
-#define __XSI_VISIBLE 500
-#endif
-
#include <stdlib.h>
#include <signal.h>
#include <arpa/inet.h>
diff --git a/src/tools/oping/CMakeLists.txt b/src/tools/oping/CMakeLists.txt
index f129a02b..b95add7e 100644
--- a/src/tools/oping/CMakeLists.txt
+++ b/src/tools/oping/CMakeLists.txt
@@ -9,6 +9,8 @@ if(NOT LIBM_LIBRARIES)
message(FATAL_ERROR "libm not found")
endif()
+mark_as_advanced(LIBM_LIBRARIES)
+
set(SOURCE_FILES
# Add source files here
oping.c
diff --git a/src/tools/oping/oping.c b/src/tools/oping/oping.c
index be87343e..13132815 100644
--- a/src/tools/oping/oping.c
+++ b/src/tools/oping/oping.c
@@ -21,6 +21,7 @@
*/
#define _POSIX_C_SOURCE 199506L
+#define __XSI_VISIBLE 500
#include <ouroboros/fqueue.h>
#include <ouroboros/dev.h>
diff --git a/src/tools/oping/oping_client.c b/src/tools/oping/oping_client.c
index d0fc2d66..db0ef199 100644
--- a/src/tools/oping/oping_client.c
+++ b/src/tools/oping/oping_client.c
@@ -24,10 +24,6 @@
#include <ouroboros/fcntl.h>
#include <ouroboros/time_utils.h>
-#ifdef __FreeBSD__
-#define __XSI_VISIBLE 500
-#endif
-
#include <signal.h>
#include <stdlib.h>
#include <sys/time.h>
diff --git a/src/tools/oping/oping_server.c b/src/tools/oping/oping_server.c
index 3a7f061c..57d1fd7c 100644
--- a/src/tools/oping/oping_server.c
+++ b/src/tools/oping/oping_server.c
@@ -20,10 +20,6 @@
* Foundation, Inc., http://www.fsf.org/about/contact/.
*/
-#ifdef __FreeBSD__
-#define __XSI_VISIBLE 500
-#endif
-
#include <stdlib.h>
#include <signal.h>
#include <arpa/inet.h>