summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/compiler.cmake60
-rw-r--r--cmake/dependencies.cmake16
-rw-r--r--cmake/dependencies/bpf.cmake20
-rw-r--r--cmake/dependencies/fuse.cmake23
-rw-r--r--cmake/dependencies/libgcrypt.cmake31
-rw-r--r--cmake/dependencies/libtoml.cmake5
-rw-r--r--cmake/dependencies/netmap.cmake18
-rw-r--r--cmake/dependencies/openssl.cmake26
-rw-r--r--cmake/dependencies/protobufc.cmake11
-rw-r--r--cmake/dependencies/rawsockets.cmake12
-rw-r--r--cmake/dependencies/robustmutex.cmake18
-rw-r--r--cmake/dependencies/sysrandom.cmake21
-rw-r--r--cmake/dependencies/systemlibraries.cmake20
-rw-r--r--cmake/doc.cmake64
-rw-r--r--cmake/include.cmake28
-rw-r--r--cmake/install.cmake64
-rw-r--r--cmake/ipcp.cmake10
-rw-r--r--cmake/ipcp/broadcast.cmake22
-rw-r--r--cmake/ipcp/eth.cmake40
-rw-r--r--cmake/ipcp/ipcp.cmake58
-rw-r--r--cmake/ipcp/local.cmake11
-rw-r--r--cmake/ipcp/udp.cmake51
-rw-r--r--cmake/ipcp/unicast.cmake46
-rw-r--r--cmake/irmd.cmake115
-rw-r--r--cmake/lib.cmake7
-rw-r--r--cmake/lib/common.cmake124
-rw-r--r--cmake/lib/dev.cmake37
-rw-r--r--cmake/lib/irm.cmake34
-rw-r--r--cmake/lib/lib.cmake99
-rw-r--r--cmake/package.cmake31
-rw-r--r--cmake/tests.cmake21
-rw-r--r--cmake/tools.cmake8
-rw-r--r--cmake/tools/irm.cmake33
-rw-r--r--cmake/tools/obc.cmake4
-rw-r--r--cmake/tools/ocbr.cmake4
-rw-r--r--cmake/tools/oecho.cmake4
-rw-r--r--cmake/tools/operf.cmake4
-rw-r--r--cmake/tools/oping.cmake4
-rw-r--r--cmake/tools/ovpn.cmake6
-rw-r--r--cmake/tools/tools.cmake8
-rw-r--r--cmake/utils/AddCompileFlags.cmake (renamed from cmake/AddCompileFlags.cmake)0
-rw-r--r--cmake/utils/CMakeUninstall.cmake.in (renamed from cmake/CmakeUninstall.cmake.in)0
-rw-r--r--cmake/utils/CompilerUtils.cmake (renamed from cmake/CompilerUtils.cmake)0
-rw-r--r--cmake/utils/FindProtobufC.cmake (renamed from cmake/FindProtobufC.cmake)0
-rw-r--r--cmake/version.cmake5
45 files changed, 1223 insertions, 0 deletions
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
new file mode 100644
index 00000000..4fa0e2ea
--- /dev/null
+++ b/cmake/compiler.cmake
@@ -0,0 +1,60 @@
+include(utils/CompilerUtils)
+
+test_and_set_c_compiler_flag_global(-std=c89)
+test_and_set_c_compiler_flag_global(-Wall)
+# -Wextra may fail on clobbered warning due to pthread_cleanup
+test_and_set_c_compiler_flag_global(-Wno-clobbered)
+test_and_set_c_compiler_flag_global(-Wextra)
+# explicitly add other flags in -Wextra
+test_and_set_c_compiler_flag_global(-Wempty-body)
+test_and_set_c_compiler_flag_global(-Wignored-qualifiers)
+test_and_set_c_compiler_flag_global(-Wimplicit-fallthrough=4)
+test_and_set_c_compiler_flag_global(-Wmissing-field-initializers)
+test_and_set_c_compiler_flag_global(-Wmissing-parameter-type)
+test_and_set_c_compiler_flag_global(-Wold-style-declaration)
+test_and_set_c_compiler_flag_global(-Woverride-init)
+test_and_set_c_compiler_flag_global(-Wsign-compare)
+test_and_set_c_compiler_flag_global(-Wtype-limits)
+test_and_set_c_compiler_flag_global(-Wuninitialized)
+test_and_set_c_compiler_flag_global(-Wshift-negative-value)
+test_and_set_c_compiler_flag_global(-Wunused-parameter)
+test_and_set_c_compiler_flag_global(-Wunused-but-set-parameter)
+test_and_set_c_compiler_flag_global(-Werror)
+test_and_set_c_compiler_flag_global(-Wundef)
+test_and_set_c_compiler_flag_global(-Wpointer-arith)
+test_and_set_c_compiler_flag_global(-Wstrict-prototypes)
+test_and_set_c_compiler_flag_global(-Wvla)
+test_and_set_c_compiler_flag_global(-Wswitch-default)
+test_and_set_c_compiler_flag_global(-Wreturn-type)
+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(-Winfinite-recursion)
+test_and_set_c_compiler_flag_global(-fmax-errors=5)
+
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING
+ "Build type (Release, Debug, DebugASan, DebugTSan, DebugLSan, DebugUSan, DebugAnalyzer)" FORCE)
+endif()
+
+if (CMAKE_BUILD_TYPE STREQUAL "Release")
+ test_and_set_c_compiler_flag_global(-O3)
+elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ test_and_set_c_compiler_flag_global(-g)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugASan")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(-fsanitize=address)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugTSan")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(-fsanitize=thread)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugLSan")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(-fsanitize=leak)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugUSan")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(-fsanitize=undefined)
+elseif (CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(-fanalyzer)
+else ()
+ message(FATAL_ERROR "Unkown build type ${CMAKE_BUILD_TYPE}")
+endif ()
diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
new file mode 100644
index 00000000..161563a0
--- /dev/null
+++ b/cmake/dependencies.cmake
@@ -0,0 +1,16 @@
+include(FindPkgConfig)
+include(CheckSymbolExists)
+
+include(dependencies/protobufc)
+include(dependencies/systemlibraries)
+include(dependencies/robustmutex)
+include(dependencies/fuse)
+include(dependencies/libgcrypt)
+include(dependencies/openssl)
+include(dependencies/sysrandom)
+include(dependencies/libtoml)
+include(dependencies/rawsockets)
+include(dependencies/bpf)
+include(dependencies/netmap)
+
+
diff --git a/cmake/dependencies/bpf.cmake b/cmake/dependencies/bpf.cmake
new file mode 100644
index 00000000..8c04937f
--- /dev/null
+++ b/cmake/dependencies/bpf.cmake
@@ -0,0 +1,20 @@
+# Berkeley Packet Filter support (BSD/macOS only)
+if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ find_path(BPF_C_INCLUDE_DIR
+ net/bpf.h
+ HINTS /usr/include /usr/local/include)
+
+ mark_as_advanced(BPF_C_INCLUDE_DIR)
+
+ if (BPF_C_INCLUDE_DIR)
+ set(DISABLE_BPF FALSE CACHE BOOL
+ "Disable Berkeley Packet Filter support for Ethernet IPCPs")
+ if (NOT DISABLE_BPF)
+ message(STATUS "Berkeley Packet Filter support for Ethernet IPCPs enabled")
+ set(HAVE_BPF TRUE)
+ else ()
+ message(STATUS "Berkeley Packet Filter support for Ethernet IPCPs disabled by user")
+ unset(HAVE_BPF)
+ endif ()
+ endif ()
+endif ()
diff --git a/cmake/dependencies/fuse.cmake b/cmake/dependencies/fuse.cmake
new file mode 100644
index 00000000..8ef60292
--- /dev/null
+++ b/cmake/dependencies/fuse.cmake
@@ -0,0 +1,23 @@
+find_library(FUSE_LIBRARIES fuse QUIET)
+if (FUSE_LIBRARIES)
+ #FIXME: Check for version >= 2.6
+ set(DISABLE_FUSE FALSE CACHE BOOL "Disable FUSE support")
+ if (NOT DISABLE_FUSE)
+ message(STATUS "FUSE support enabled")
+ set(FUSE_PREFIX "/tmp/ouroboros" CACHE STRING
+ "Mountpoint for RIB filesystem")
+ set(HAVE_FUSE TRUE CACHE INTERNAL "")
+ else ()
+ message(STATUS "FUSE support disabled by user")
+ unset(HAVE_FUSE CACHE)
+ endif ()
+else ()
+ message(STATUS "Install FUSE version > 2.6 to enable RIB access")
+endif ()
+
+if (NOT HAVE_FUSE)
+ set(FUSE_LIBRARIES "")
+ set(FUSE_INCLUDE_DIR "")
+endif ()
+
+mark_as_advanced(FUSE_LIBRARIES)
diff --git a/cmake/dependencies/libgcrypt.cmake b/cmake/dependencies/libgcrypt.cmake
new file mode 100644
index 00000000..90a25f36
--- /dev/null
+++ b/cmake/dependencies/libgcrypt.cmake
@@ -0,0 +1,31 @@
+find_library(LIBGCRYPT_LIBRARIES gcrypt QUIET)
+if (LIBGCRYPT_LIBRARIES)
+ 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}")
+ if (NOT GCVER VERSION_LESS "1.7.0")
+ set(DISABLE_LIBGCRYPT FALSE CACHE BOOL "Disable libgcrypt support")
+ if (NOT DISABLE_LIBGCRYPT)
+ message(STATUS "libgcrypt support enabled")
+ set(HAVE_LIBGCRYPT TRUE CACHE INTERNAL "")
+ else ()
+ message(STATUS "libgcrypt support disabled by user")
+ unset(HAVE_LIBGCRYPT CACHE)
+ endif()
+ else ()
+ message(STATUS "Install version >= \"1.7.0\" to enable libgcrypt support "
+ "(found version \"${GCVER}\")")
+ endif()
+ endif ()
+endif ()
+
+if (NOT HAVE_LIBGCRYPT)
+ set(LIBGCRYPT_LIBRARIES "")
+ set(LIBGCRYPT_INCLUDE_DIR "")
+endif ()
+
+mark_as_advanced(LIBGCRYPT_LIBRARIES LIBGCRYPT_INCLUDE_DIR)
diff --git a/cmake/dependencies/libtoml.cmake b/cmake/dependencies/libtoml.cmake
new file mode 100644
index 00000000..3974a1dd
--- /dev/null
+++ b/cmake/dependencies/libtoml.cmake
@@ -0,0 +1,5 @@
+find_library(LIBTOML_LIBRARIES toml QUIET)
+if (LIBTOML_LIBRARIES)
+ find_path(LIBTOML_INCLUDE toml.h)
+ mark_as_advanced(LIBTOML_LIBRARIES LIBTOML_INCLUDE)
+endif ()
diff --git a/cmake/dependencies/netmap.cmake b/cmake/dependencies/netmap.cmake
new file mode 100644
index 00000000..d8d3781b
--- /dev/null
+++ b/cmake/dependencies/netmap.cmake
@@ -0,0 +1,18 @@
+# netmap support (optional acceleration)
+find_path(NETMAP_C_INCLUDE_DIR
+ net/netmap_user.h
+ HINTS /usr/include /usr/local/include)
+
+mark_as_advanced(NETMAP_C_INCLUDE_DIR)
+
+if (NOT HAVE_RAW_SOCKETS AND NOT HAVE_BPF AND NETMAP_C_INCLUDE_DIR)
+ set(DISABLE_NETMAP FALSE CACHE BOOL
+ "Disable netmap support for ETH IPCPs")
+ if (NOT DISABLE_NETMAP)
+ message(STATUS "Netmap support for Ethernet IPCPs enabled")
+ set(HAVE_NETMAP TRUE)
+ else ()
+ message(STATUS "Netmap support for Ethernet IPCPs disabled by user")
+ unset(HAVE_NETMAP)
+ endif ()
+endif ()
diff --git a/cmake/dependencies/openssl.cmake b/cmake/dependencies/openssl.cmake
new file mode 100644
index 00000000..604d5d99
--- /dev/null
+++ b/cmake/dependencies/openssl.cmake
@@ -0,0 +1,26 @@
+find_package(OpenSSL QUIET)
+if (OPENSSL_FOUND)
+ set(HAVE_OPENSSL_RNG TRUE)
+ if (OPENSSL_VERSION VERSION_LESS "1.1.0")
+ message(STATUS "Install version >= \"1.1.0\" to enable OpenSSL support "
+ "(found version \"${OPENSSL_VERSION}\")")
+ else ()
+ set(DISABLE_OPENSSL FALSE CACHE BOOL "Disable OpenSSL support")
+ if (NOT DISABLE_OPENSSL)
+ message(STATUS "OpenSSL support enabled")
+ set(HAVE_OPENSSL TRUE CACHE INTERNAL "")
+ else()
+ message(STATUS "OpenSSL support disabled")
+ unset(HAVE_OPENSSL CACHE)
+ endif()
+ endif ()
+else()
+ message(STATUS "Install openSSL version >= \"1.1.0\" to enable OpenSSL support")
+ unset(HAVE_OPENSSL_RNG)
+ unset(HAVE_OPENSSL CACHE)
+ set(OPENSSL_INCLUDE_DIR "")
+ set(OPENSSL_LIBRARIES "")
+ set(OPENSSL_CRYPTO_LIBRARY "")
+endif ()
+
+mark_as_advanced(OPENSSL_LIBRARIES OPENSSL_CRYPTO_LIBRARY)
diff --git a/cmake/dependencies/protobufc.cmake b/cmake/dependencies/protobufc.cmake
new file mode 100644
index 00000000..f1fab59d
--- /dev/null
+++ b/cmake/dependencies/protobufc.cmake
@@ -0,0 +1,11 @@
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/utils")
+
+find_package(ProtobufC QUIET)
+if (NOT (PROTOBUF_C_INCLUDE_DIRS AND PROTOBUF_C_LIBRARY
+ AND PROTOBUF_PROTOC_C_EXECUTABLE))
+ message(FATAL_ERROR "Protobuf C compiler required but not found. "
+ "Please install Google Protocol Buffers.")
+else ()
+ message(STATUS "Found protobuf C compiler in ${PROTOBUF_PROTOC_C_EXECUTABLE}")
+endif ()
+include_directories(${PROTOBUF_C_INCLUDE_DIRS})
diff --git a/cmake/dependencies/rawsockets.cmake b/cmake/dependencies/rawsockets.cmake
new file mode 100644
index 00000000..92f7b8b7
--- /dev/null
+++ b/cmake/dependencies/rawsockets.cmake
@@ -0,0 +1,12 @@
+# Raw sockets support (Linux only)
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(DISABLE_RAW_SOCKETS FALSE CACHE BOOL
+ "Disable raw socket support for Ethernet IPCPs")
+ if (NOT DISABLE_RAW_SOCKETS)
+ message(STATUS "Raw socket support for Ethernet IPCPs enabled")
+ set(HAVE_RAW_SOCKETS TRUE)
+ else ()
+ message(STATUS "Raw socket support for Ethernet IPCPs disabled by user")
+ unset(HAVE_RAW_SOCKETS)
+ endif ()
+endif ()
diff --git a/cmake/dependencies/robustmutex.cmake b/cmake/dependencies/robustmutex.cmake
new file mode 100644
index 00000000..94aec8f0
--- /dev/null
+++ b/cmake/dependencies/robustmutex.cmake
@@ -0,0 +1,18 @@
+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)
+
+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")
+ unset(HAVE_ROBUST_MUTEX)
+ endif ()
+else()
+ message(STATUS "Robust mutex support not available")
+ unset(HAVE_ROBUST_MUTEX)
+endif ()
diff --git a/cmake/dependencies/sysrandom.cmake b/cmake/dependencies/sysrandom.cmake
new file mode 100644
index 00000000..972db801
--- /dev/null
+++ b/cmake/dependencies/sysrandom.cmake
@@ -0,0 +1,21 @@
+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 (SYS_RND_HDR)
+ message(STATUS "Found sys/random.h in ${SYS_RND_HDR}")
+ set(HAVE_SYS_RANDOM TRUE)
+ else ()
+ set(SYS_RND_HDR "")
+ unset(HAVE_SYS_RANDOM)
+ endif ()
+endif()
+
+# Validate that at least one secure random generator is available
+if (NOT ((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") OR APPLE OR
+ HAVE_SYS_RANDOM OR HAVE_OPENSSL_RNG OR HAVE_LIBGCRYPT))
+ message(FATAL_ERROR "No secure random generator found, "
+ "please install libgcrypt (> 1.7.0) or OpenSSL")
+endif ()
+
+mark_as_advanced(SYS_RND_HDR)
diff --git a/cmake/dependencies/systemlibraries.cmake b/cmake/dependencies/systemlibraries.cmake
new file mode 100644
index 00000000..e00266d6
--- /dev/null
+++ b/cmake/dependencies/systemlibraries.cmake
@@ -0,0 +1,20 @@
+if (NOT APPLE)
+ find_library(LIBRT_LIBRARIES rt)
+ if (NOT LIBRT_LIBRARIES)
+ message(FATAL_ERROR "Could not find librt")
+ endif ()
+else ()
+ set(LIBRT_LIBRARIES "")
+endif ()
+
+find_library(LIBPTHREAD_LIBRARIES pthread)
+if (NOT LIBPTHREAD_LIBRARIES)
+ message(FATAL_ERROR "Could not find libpthread")
+endif ()
+
+find_library(LIBM_LIBRARIES m)
+if (NOT LIBM_LIBRARIES)
+ message(FATAL_ERROR "Could not find libm")
+endif ()
+
+mark_as_advanced(LIBRT_LIBRARIES LIBPTHREAD_LIBRARIES LIBM_LIBRARIES)
diff --git a/cmake/doc.cmake b/cmake/doc.cmake
new file mode 100644
index 00000000..16991f82
--- /dev/null
+++ b/cmake/doc.cmake
@@ -0,0 +1,64 @@
+set(DOC_SOURCE_DIR "${CMAKE_SOURCE_DIR}/doc")
+set(DOC_BINARY_DIR "${CMAKE_BINARY_DIR}/doc")
+
+set(MAN_NAMES
+ # Add man page sources here
+ flow_accept.3
+ flow_alloc.3
+ flow_dealloc.3
+ flow_read.3
+ flow_write.3
+ fccntl.3
+ fqueue.3
+ fqueue_create.3
+ fqueue_destroy.3
+ fqueue_next.3
+ fevent.3
+ fset.3
+ fset_create.3
+ fset_destroy.3
+ fset_zero.3
+ fset_add.3
+ fset_del.3
+ fset_has.3
+ ouroboros-glossary.7
+ ouroboros-tutorial.7
+ ouroboros.8
+ irmd.8
+ irm.8
+ )
+
+macro(INSTALL_MAN __mans)
+ foreach (_man ${ARGV})
+ string(REGEX REPLACE "^.+[.]([1-9]).gz" "\\1" _mansect ${_man})
+ install(FILES ${_man} DESTINATION "${CMAKE_INSTALL_MANDIR}/man${_mansect}")
+ endforeach (_man)
+endmacro(INSTALL_MAN __mans)
+
+find_program(GZIP_EXECUTABLE
+ NAMES gzip
+ DOC "Will gzip the man pages")
+
+mark_as_advanced(GZIP_EXECUTABLE)
+
+if (GZIP_EXECUTABLE)
+ # Create the doc output directory
+ file(MAKE_DIRECTORY ${DOC_BINARY_DIR})
+
+ foreach (m ${MAN_NAMES})
+ set(md ${DOC_BINARY_DIR}/${m}.gz)
+
+ add_custom_command(
+ OUTPUT ${md}
+ COMMAND ${GZIP_EXECUTABLE}
+ ARGS -c ${DOC_SOURCE_DIR}/man/${m} > ${md}
+ COMMENT "Compressing manpage ${m}"
+ VERBATIM)
+
+ set(MAN_FILES ${MAN_FILES} ${md})
+ endforeach ()
+
+ add_custom_target(man ALL DEPENDS ${MAN_FILES})
+
+ INSTALL_MAN(${MAN_FILES})
+endif ()
diff --git a/cmake/include.cmake b/cmake/include.cmake
new file mode 100644
index 00000000..c14d205d
--- /dev/null
+++ b/cmake/include.cmake
@@ -0,0 +1,28 @@
+set(HEADERS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/include/ouroboros")
+
+set(SOCK_BUF_SIZE 10240 CACHE STRING
+ "Size of the buffer used by the UNIX sockets for local IPC")
+
+configure_file("${CMAKE_SOURCE_DIR}/include/ouroboros/version.h.in"
+ "${CMAKE_BINARY_DIR}/include/ouroboros/version.h" @ONLY)
+
+configure_file("${CMAKE_SOURCE_DIR}/include/ouroboros/sockets.h.in"
+ "${CMAKE_BINARY_DIR}/include/ouroboros/sockets.h" @ONLY)
+
+set(PUBLIC_HEADER_FILES
+ ${HEADERS_SOURCE_DIR}/cep.h
+ ${HEADERS_SOURCE_DIR}/cdefs.h
+ ${HEADERS_SOURCE_DIR}/dev.h
+ ${HEADERS_SOURCE_DIR}/errno.h
+ ${HEADERS_SOURCE_DIR}/fccntl.h
+ ${HEADERS_SOURCE_DIR}/fqueue.h
+ ${HEADERS_SOURCE_DIR}/ipcp.h
+ ${HEADERS_SOURCE_DIR}/irm.h
+ ${HEADERS_SOURCE_DIR}/name.h
+ ${HEADERS_SOURCE_DIR}/proto.h
+ ${HEADERS_SOURCE_DIR}/qos.h
+ ${CMAKE_BINARY_DIR}/include/ouroboros/version.h
+ )
+
+install(FILES ${PUBLIC_HEADER_FILES}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ouroboros)
diff --git a/cmake/install.cmake b/cmake/install.cmake
new file mode 100644
index 00000000..21a8cd52
--- /dev/null
+++ b/cmake/install.cmake
@@ -0,0 +1,64 @@
+# Installation configuration
+
+# Install pkg-config files
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+
+# Systemd service file installation
+set(SYSTEMD_INSTALL_FILES "DETECT" CACHE STRING
+ "Install systemd .service files (NO (never), DETECT (use pkg-config - default),\
+ FORCE (always - see SYSTEMD_UNITDIR_OVERRIDE))")
+set(SYSTEMD_UNITDIR_OVERRIDE "" CACHE PATH
+ "Path to install systemd files. When SYSTEMD_INSTALL_FILES == DETECT, this\
+ can be empty to automatically determine the path. Cannot be empty when FORCE.")
+
+if (SYSTEMD_INSTALL_FILES STREQUAL "DETECT" OR SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
+ if (SYSTEMD_INSTALL_FILES STREQUAL "DETECT")
+ pkg_check_modules(SYSTEMD "systemd")
+ if (SYSTEMD_FOUND)
+ if ("${SYSTEMD_UNITDIR_OVERRIDE}" STREQUAL "")
+ execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
+ --variable=systemdsystemunitdir systemd
+ OUTPUT_VARIABLE SYSTEMD_UNITDIR_INTERNAL)
+ string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_UNITDIR_INTERNAL
+ "${SYSTEMD_UNITDIR_INTERNAL}"
+ )
+ else ()
+ set(SYSTEMD_UNITDIR_INTERNAL "${SYSTEMD_UNITDIR_OVERRIDE}")
+ endif ()
+ else ()
+ set(SYSTEMD_UNITDIR_INTERNAL "")
+ endif ()
+ elseif (SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
+ if ("${SYSTEMD_UNITDIR_OVERRIDE}" STREQUAL "")
+ message(FATAL_ERROR "Systemd installation required by user, but no path\
+ provided with SYSTEMD_UNITDIR_OVERRIDE.")
+ else ()
+ set(SYSTEMD_UNITDIR_INTERNAL "${SYSTEMD_UNITDIR_OVERRIDE}")
+ endif ()
+ endif()
+ if (NOT ${SYSTEMD_UNITDIR_INTERNAL} STREQUAL "")
+ message(STATUS "Systemd service installation enabled to: ${SYSTEMD_UNITDIR_INTERNAL}")
+ if (LIBTOML_LIBRARIES AND NOT DISABLE_CONFIGFILE)
+ set (CONFIGURE_STRING "--config ${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}")
+ else ()
+ set (CONFIGURE_STRING "")
+ endif ()
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.service.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service" @ONLY)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service"
+ DESTINATION "${SYSTEMD_UNITDIR_INTERNAL}")
+ endif ()
+else ()
+ message(STATUS "Systemd service installation disabled by user")
+endif()
+
+# Uninstall target
+configure_file("${CMAKE_SOURCE_DIR}/cmake/utils/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/cmake/ipcp.cmake b/cmake/ipcp.cmake
new file mode 100644
index 00000000..6839fcc2
--- /dev/null
+++ b/cmake/ipcp.cmake
@@ -0,0 +1,10 @@
+include(ipcp/ipcp)
+include(ipcp/eth)
+include(ipcp/udp)
+include(ipcp/local)
+include(ipcp/broadcast)
+include(ipcp/unicast)
+
+configure_file("${IPCP_SOURCE_DIR}/config.h.in"
+ "${IPCP_BINARY_DIR}/config.h" @ONLY)
+
diff --git a/cmake/ipcp/broadcast.cmake b/cmake/ipcp/broadcast.cmake
new file mode 100644
index 00000000..20610a25
--- /dev/null
+++ b/cmake/ipcp/broadcast.cmake
@@ -0,0 +1,22 @@
+set(BROADCAST_SOURCE_DIR "${IPCP_SOURCE_DIR}/broadcast")
+
+set(IPCP_BROADCAST_TARGET ipcpd-broadcast CACHE INTERNAL "")
+
+set(IPCP_BROADCAST_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Broadcast IPCP, in ms")
+
+set(BROADCAST_SOURCES
+ "${BROADCAST_SOURCE_DIR}/connmgr.c"
+ "${BROADCAST_SOURCE_DIR}/dt.c"
+ "${BROADCAST_SOURCE_DIR}/main.c"
+)
+
+add_executable(${IPCP_BROADCAST_TARGET}
+ ${BROADCAST_SOURCES}
+ ${IPCP_SOURCES}
+ ${COMMON_SOURCES}
+)
+
+target_include_directories(${IPCP_BROADCAST_TARGET} PRIVATE ${IPCP_INCLUDE_DIRS})
+target_link_libraries(${IPCP_BROADCAST_TARGET} PUBLIC ouroboros-dev)
+install(TARGETS ${IPCP_BROADCAST_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/ipcp/eth.cmake b/cmake/ipcp/eth.cmake
new file mode 100644
index 00000000..0d37bf9b
--- /dev/null
+++ b/cmake/ipcp/eth.cmake
@@ -0,0 +1,40 @@
+set(ETH_SOURCE_DIR "${IPCP_SOURCE_DIR}/eth")
+
+set(IPCP_ETH_LLC_TARGET ipcpd-eth-llc CACHE INTERNAL "")
+set(IPCP_ETH_DIX_TARGET ipcpd-eth-dix CACHE INTERNAL "")
+
+set(IPCP_ETH_RD_THR 1 CACHE STRING
+ "Number of reader threads in Ethernet IPCP")
+set(IPCP_ETH_WR_THR 1 CACHE STRING
+ "Number of writer threads in Ethernet IPCP")
+set(IPCP_ETH_QDISC_BYPASS false CACHE BOOL
+ "Bypass the Qdisc in the kernel when using raw sockets")
+set(IPCP_ETH_LO_MTU 1500 CACHE STRING
+ "Restrict Ethernet MTU over loopback interfaces")
+set(IPCP_ETH_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Ethernet IPCPs, in ms")
+
+if (HAVE_RAW_SOCKETS OR HAVE_BPF OR HAVE_NETMAP)
+ set(HAVE_ETH TRUE)
+else ()
+ unset(HAVE_ETH)
+endif ()
+
+if (HAVE_ETH)
+ add_executable(${IPCP_ETH_LLC_TARGET} "${ETH_SOURCE_DIR}/llc.c" ${IPCP_SOURCES})
+ add_executable(${IPCP_ETH_DIX_TARGET} "${ETH_SOURCE_DIR}/dix.c" ${IPCP_SOURCES})
+
+ foreach(target ${IPCP_ETH_LLC_TARGET} ${IPCP_ETH_DIX_TARGET})
+ target_include_directories(${target} PRIVATE ${IPCP_INCLUDE_DIRS})
+ if (HAVE_BPF AND NOT APPLE)
+ target_include_directories(${target} PRIVATE ${BPF_C_INCLUDE_DIR})
+ endif ()
+ if (HAVE_NETMAP AND NOT APPLE)
+ set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -std=c99")
+ target_include_directories(${target} PRIVATE ${NETMAP_C_INCLUDE_DIR})
+ endif ()
+ target_link_libraries(${target} PUBLIC ouroboros-dev)
+ endforeach()
+
+ install(TARGETS ${IPCP_ETH_LLC_TARGET} ${IPCP_ETH_DIX_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
+endif ()
diff --git a/cmake/ipcp/ipcp.cmake b/cmake/ipcp/ipcp.cmake
new file mode 100644
index 00000000..5b1eef09
--- /dev/null
+++ b/cmake/ipcp/ipcp.cmake
@@ -0,0 +1,58 @@
+set(IPCP_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/ipcpd")
+set(IPCP_BINARY_DIR "${CMAKE_BINARY_DIR}/src/ipcpd")
+
+set(CONNMGR_RCV_TIMEOUT 1000 CACHE STRING
+ "Timeout for the connection manager to wait for OCEP info (ms).")
+set(IPCP_DEBUG_LOCAL FALSE CACHE BOOL
+ "Use PID as address for local debugging")
+set(IPCP_QOS_CUBE_BE_PRIO 50 CACHE STRING
+ "Priority for best effort QoS cube (0-99)")
+set(IPCP_QOS_CUBE_VIDEO_PRIO 90 CACHE STRING
+ "Priority for video QoS cube (0-99)")
+set(IPCP_QOS_CUBE_VOICE_PRIO 99 CACHE STRING
+ "Priority for voice QoS cube (0-99)")
+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_SCHED_THR_MUL 2 CACHE STRING
+ "Number of scheduler threads per QoS cube")
+set(DISABLE_CORE_LOCK TRUE CACHE BOOL
+ "Disable locking performance threads to a core")
+
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(IPCP_LINUX_TIMERSLACK_NS 1000 CACHE STRING
+ "Slack value for high resolution timers on Linux systems.")
+endif ()
+
+if ((IPCP_QOS_CUBE_BE_PRIO LESS 0) OR (IPCP_QOS_CUBE_BE_PRIO GREATER 99))
+ message(FATAL_ERROR "Invalid priority for best effort QoS cube")
+endif ()
+
+if ((IPCP_QOS_CUBE_VIDEO_PRIO LESS 0) OR (IPCP_QOS_CUBE_VIDEO_PRIO GREATER 99))
+ message(FATAL_ERROR "Invalid priority for video QoS cube")
+endif ()
+
+if ((IPCP_QOS_CUBE_VOICE_PRIO LESS 0) OR (IPCP_QOS_CUBE_VOICE_PRIO GREATER 99))
+ message(FATAL_ERROR "Invalid priority for voice QoS cube")
+endif ()
+
+if ((DHT_ENROLL_SLACK LESS 0) OR (DHT_ENROLL_SLACK GREATER 999))
+ message(FATAL_ERROR "Invalid DHT slack value")
+endif ()
+
+set(IPCP_SOURCES
+ "${IPCP_SOURCE_DIR}/ipcp.c"
+ "${IPCP_SOURCE_DIR}/shim-data.c"
+)
+
+set(COMMON_SOURCES
+ "${IPCP_SOURCE_DIR}/common/enroll.c"
+)
+
+set(IPCP_INCLUDE_DIRS
+ ${IPCP_SOURCE_DIR}
+ ${IPCP_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+)
diff --git a/cmake/ipcp/local.cmake b/cmake/ipcp/local.cmake
new file mode 100644
index 00000000..9e320aad
--- /dev/null
+++ b/cmake/ipcp/local.cmake
@@ -0,0 +1,11 @@
+set(LOCAL_SOURCE_DIR "${IPCP_SOURCE_DIR}/local")
+
+set(IPCP_LOCAL_TARGET ipcpd-local CACHE INTERNAL "")
+
+set(IPCP_LOCAL_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Local IPCP, in ms")
+
+add_executable(${IPCP_LOCAL_TARGET} "${LOCAL_SOURCE_DIR}/main.c" ${IPCP_SOURCES})
+target_include_directories(${IPCP_LOCAL_TARGET} PRIVATE ${IPCP_INCLUDE_DIRS})
+target_link_libraries(${IPCP_LOCAL_TARGET} PUBLIC ouroboros-dev)
+install(TARGETS ${IPCP_LOCAL_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/ipcp/udp.cmake b/cmake/ipcp/udp.cmake
new file mode 100644
index 00000000..7195dfa1
--- /dev/null
+++ b/cmake/ipcp/udp.cmake
@@ -0,0 +1,51 @@
+set(UDP_SOURCE_DIR "${IPCP_SOURCE_DIR}/udp")
+
+set(IPCP_UDP4_TARGET ipcpd-udp4 CACHE INTERNAL "")
+set(IPCP_UDP6_TARGET ipcpd-udp6 CACHE INTERNAL "")
+
+set(IPCP_UDP_RD_THR 3 CACHE STRING
+ "Number of reader threads in UDP IPCPs")
+set(IPCP_UDP_WR_THR 3 CACHE STRING
+ "Number of writer threads in UDP IPCPs")
+set(IPCP_UDP_MPL 5000 CACHE STRING
+ "Default maximum packet lifetime for the UDP IPCPs, in ms")
+
+# Find nsupdate and nslookup for DDNS support
+find_program(NSUPDATE_EXECUTABLE
+ NAMES nsupdate
+ DOC "The nsupdate tool that enables DDNS")
+
+find_program(NSLOOKUP_EXECUTABLE
+ NAMES nslookup
+ DOC "The nslookup tool that resolves DNS names")
+
+mark_as_advanced(NSLOOKUP_EXECUTABLE NSUPDATE_EXECUTABLE)
+
+if (NSLOOKUP_EXECUTABLE AND NSUPDATE_EXECUTABLE)
+ set(DISABLE_DDNS FALSE CACHE BOOL "Disable DDNS support")
+ if (NOT DISABLE_DDNS)
+ message(STATUS "DDNS support enabled")
+ set(HAVE_DDNS TRUE CACHE INTERNAL "")
+ else ()
+ message(STATUS "DDNS support disabled by user")
+ unset(HAVE_DDNS CACHE)
+ endif ()
+else ()
+ if (NSLOOKUP_EXECUTABLE)
+ message(STATUS "Install nsupdate to enable DDNS support")
+ elseif (NSUPDATE_EXECUTABLE)
+ message(STATUS "Install nslookup to enable DDNS support")
+ else ()
+ message(STATUS "Install nslookup and nsupdate to enable DDNS support")
+ endif ()
+endif ()
+
+add_executable(${IPCP_UDP4_TARGET} "${UDP_SOURCE_DIR}/udp4.c" ${IPCP_SOURCES})
+add_executable(${IPCP_UDP6_TARGET} "${UDP_SOURCE_DIR}/udp6.c" ${IPCP_SOURCES})
+
+foreach(target ${IPCP_UDP4_TARGET} ${IPCP_UDP6_TARGET})
+ target_include_directories(${target} PRIVATE ${IPCP_INCLUDE_DIRS})
+ target_link_libraries(${target} PUBLIC ouroboros-dev)
+endforeach()
+
+install(TARGETS ${IPCP_UDP4_TARGET} ${IPCP_UDP6_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/ipcp/unicast.cmake b/cmake/ipcp/unicast.cmake
new file mode 100644
index 00000000..8517f8af
--- /dev/null
+++ b/cmake/ipcp/unicast.cmake
@@ -0,0 +1,46 @@
+set(UNICAST_SOURCE_DIR "${IPCP_SOURCE_DIR}/unicast")
+set(UNICAST_BINARY_DIR "${IPCP_BINARY_DIR}/unicast")
+
+set(IPCP_UNICAST_TARGET ipcpd-unicast CACHE INTERNAL "")
+
+set(IPCP_UNICAST_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Unicast IPCP, in ms")
+set(PFT_SIZE 256 CACHE STRING
+ "Prefix forwarding table size for the Unicast IPCP")
+
+# Generate DHT protobuf files
+protobuf_generate_c(DHT_PROTO_SRCS DHT_PROTO_HDRS "${UNICAST_SOURCE_DIR}/dir/dht.proto")
+
+set (UNICAST_SOURCES
+ "${UNICAST_SOURCE_DIR}/addr-auth.c"
+ "${UNICAST_SOURCE_DIR}/ca.c"
+ "${UNICAST_SOURCE_DIR}/connmgr.c"
+ "${UNICAST_SOURCE_DIR}/dir.c"
+ "${UNICAST_SOURCE_DIR}/dt.c"
+ "${UNICAST_SOURCE_DIR}/fa.c"
+ "${UNICAST_SOURCE_DIR}/main.c"
+ "${UNICAST_SOURCE_DIR}/pff.c"
+ "${UNICAST_SOURCE_DIR}/routing.c"
+ "${UNICAST_SOURCE_DIR}/psched.c"
+ "${UNICAST_SOURCE_DIR}/addr-auth/flat.c"
+ "${UNICAST_SOURCE_DIR}/ca/mb-ecn.c"
+ "${UNICAST_SOURCE_DIR}/ca/nop.c"
+ "${UNICAST_SOURCE_DIR}/dir/dht.c"
+ "${UNICAST_SOURCE_DIR}/pff/simple.c"
+ "${UNICAST_SOURCE_DIR}/pff/alternate.c"
+ "${UNICAST_SOURCE_DIR}/pff/multipath.c"
+ "${UNICAST_SOURCE_DIR}/pff/pft.c"
+ "${UNICAST_SOURCE_DIR}/routing/link-state.c"
+ "${UNICAST_SOURCE_DIR}/routing/graph.c"
+)
+
+add_executable(${IPCP_UNICAST_TARGET}
+ ${UNICAST_SOURCES}
+ ${IPCP_SOURCES}
+ ${COMMON_SOURCES}
+ ${DHT_PROTO_SRCS}
+)
+target_include_directories(${IPCP_UNICAST_TARGET} PRIVATE ${IPCP_INCLUDE_DIRS})
+target_include_directories(${IPCP_UNICAST_TARGET} PRIVATE "${UNICAST_SOURCE_DIR}")
+target_link_libraries(${IPCP_UNICAST_TARGET} PUBLIC ouroboros-dev)
+install(TARGETS ${IPCP_UNICAST_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/irmd.cmake b/cmake/irmd.cmake
new file mode 100644
index 00000000..d4b4808c
--- /dev/null
+++ b/cmake/irmd.cmake
@@ -0,0 +1,115 @@
+set(IRMD_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/irmd")
+set(IRMD_BINARY_DIR "${CMAKE_BINARY_DIR}/src/irmd")
+
+set(OUROBOROS_CONFIG_DIR /etc/ouroboros CACHE STRING
+ "Configuration directory (should be absolute)")
+
+# Configuration file support
+set(OUROBOROS_SECURITY_DIR "${OUROBOROS_CONFIG_DIR}/security" CACHE STRING
+ "Security directory holding authentication information")
+set(OUROBOROS_CA_CRT_DIR "${OUROBOROS_SECURITY_DIR}/cacert" CACHE STRING
+ "Directory holding trusted CA certificates")
+set(OUROBOROS_SRV_CRT_DIR "${OUROBOROS_SECURITY_DIR}/server" CACHE STRING
+ "Directory holding server certificates")
+set(OUROBOROS_CLI_CRT_DIR "${OUROBOROS_SECURITY_DIR}/client" CACHE STRING
+ "Directory holding client certificates")
+set(OUROBOROS_UNTRUSTED_DIR "${OUROBOROS_SECURITY_DIR}/untrusted" CACHE STRING
+ "Directory holding untrusted intermediate certificates")
+
+# IRMd timeouts and parameters
+set(IRMD_REQ_ARR_TIMEOUT 1000 CACHE STRING
+ "Timeout for an application to respond to a new flow (ms)")
+set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING
+ "Timeout for an IPCP to bootstrap (ms)")
+set(ENROLL_TIMEOUT 20000 CACHE STRING
+ "Timeout for an IPCP to enroll (ms)")
+set(REG_TIMEOUT 20000 CACHE STRING
+ "Timeout for registering a name (ms)")
+set(QUERY_TIMEOUT 200 CACHE STRING
+ "Timeout to query a name with an IPCP (ms)")
+set(CONNECT_TIMEOUT 20000 CACHE STRING
+ "Timeout to connect an IPCP to another IPCP (ms)")
+set(FLOW_ALLOC_TIMEOUT 20000 CACHE STRING
+ "Timeout for a flow allocation response (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")
+set(IRMD_PKILL_TIMEOUT 30 CACHE STRING
+ "Number of seconds to wait before sending SIGKILL to subprocesses on exit")
+set(IRMD_KILL_ALL_PROCESSES TRUE CACHE BOOL
+ "Kill all processes on exit")
+set(DEBUG_PROTO_OAP FALSE CACHE BOOL
+ "Add Flow allocation protocol message output to IRMd debug logging")
+
+# Configuration file support (libtoml)
+if (LIBTOML_LIBRARIES)
+ set(DISABLE_CONFIGFILE FALSE CACHE BOOL
+ "Disable configuration file support")
+ if (NOT DISABLE_CONFIGFILE)
+ set(OUROBOROS_CONFIG_FILE irmd.conf CACHE STRING
+ "Name of the IRMd configuration file")
+ set(HAVE_TOML TRUE)
+ message(STATUS "Configuration file support enabled")
+ message(STATUS "Configuration directory: ${OUROBOROS_CONFIG_DIR}")
+ set(INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
+ configure_file("${CMAKE_SOURCE_DIR}/irmd.conf.in"
+ "${CMAKE_BINARY_DIR}/${OUROBOROS_CONFIG_FILE}.example" @ONLY)
+ install(FILES "${CMAKE_BINARY_DIR}/${OUROBOROS_CONFIG_FILE}.example"
+ DESTINATION "${OUROBOROS_CONFIG_DIR}")
+ install(CODE "
+ if (NOT EXISTS \"${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}\")
+ file(WRITE \"${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}\" \"\")
+ endif()
+ ")
+ unset(INSTALL_DIR)
+ else ()
+ message(STATUS "Configuration file support disabled by user")
+ unset(OUROBOROS_CONFIG_FILE CACHE)
+ set(HAVE_TOML FALSE)
+ endif ()
+else ()
+ message(STATUS "Install tomlc99 for config file support")
+ message(STATUS " https://github.com/cktan/tomlc99")
+ unset(HAVE_TOML)
+endif ()
+
+configure_file("${IRMD_SOURCE_DIR}/config.h.in"
+ "${IRMD_BINARY_DIR}/config.h" @ONLY)
+
+set(IRMD_SOURCES
+ "${IRMD_SOURCE_DIR}/ipcp.c"
+ "${IRMD_SOURCE_DIR}/configfile.c"
+ "${IRMD_SOURCE_DIR}/main.c"
+ "${IRMD_SOURCE_DIR}/oap.c"
+ "${IRMD_SOURCE_DIR}/reg/flow.c"
+ "${IRMD_SOURCE_DIR}/reg/ipcp.c"
+ "${IRMD_SOURCE_DIR}/reg/proc.c"
+ "${IRMD_SOURCE_DIR}/reg/prog.c"
+ "${IRMD_SOURCE_DIR}/reg/name.c"
+ "${IRMD_SOURCE_DIR}/reg/reg.c"
+)
+
+add_executable(irmd ${IRMD_SOURCES})
+
+target_include_directories(irmd PRIVATE
+ "${IRMD_SOURCE_DIR}"
+ "${IRMD_BINARY_DIR}"
+ "${CMAKE_SOURCE_DIR}/include"
+ "${CMAKE_BINARY_DIR}/include")
+
+target_link_libraries(irmd PUBLIC ouroboros-common)
+if (LIBTOML_LIBRARIES)
+ target_link_libraries(irmd PUBLIC ${LIBTOML_LIBRARIES})
+endif ()
+
+if (HAVE_TOML)
+ target_include_directories(irmd PRIVATE ${LIBTOML_INCLUDE})
+endif ()
+
+include(utils/AddCompileFlags)
+if (CMAKE_BUILD_TYPE MATCHES "Debug*")
+ add_compile_flags(irmd -DCONFIG_OUROBOROS_DEBUG)
+endif ()
+
+install(TARGETS irmd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/lib.cmake b/cmake/lib.cmake
new file mode 100644
index 00000000..6d9333a3
--- /dev/null
+++ b/cmake/lib.cmake
@@ -0,0 +1,7 @@
+include(lib/lib)
+include(lib/common)
+include(lib/dev)
+include(lib/irm)
+
+configure_file("${LIB_SOURCE_DIR}/config.h.in"
+ "${LIB_BINARY_DIR}/config.h" @ONLY)
diff --git a/cmake/lib/common.cmake b/cmake/lib/common.cmake
new file mode 100644
index 00000000..1e834f10
--- /dev/null
+++ b/cmake/lib/common.cmake
@@ -0,0 +1,124 @@
+# Common library configuration
+
+set(LIB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/lib")
+set(LIB_BINARY_DIR "${CMAKE_BINARY_DIR}/src/lib")
+
+# Protobuf files
+set_source_files_properties(
+ "${LIB_SOURCE_DIR}/pb/model.proto"
+ "${LIB_SOURCE_DIR}/pb/ipcp_config.proto"
+ "${LIB_SOURCE_DIR}/pb/enroll.proto"
+ "${LIB_SOURCE_DIR}/pb/cep.proto"
+ "${LIB_SOURCE_DIR}/pb/irm.proto"
+ "${LIB_SOURCE_DIR}/pb/ipcp.proto"
+ PROPERTIES
+ COMPILE_FLAGS "-I${LIB_SOURCE_DIR}/pb"
+)
+
+protobuf_generate_c(MODEL_PROTO_SRCS MODEL_PROTO_HDRS
+ "${LIB_SOURCE_DIR}/pb/model.proto")
+protobuf_generate_c(IPCP_CONFIG_PROTO_SRCS IPCP_CONFIG_PROTO_HDRS
+ "${LIB_SOURCE_DIR}/pb/ipcp_config.proto")
+protobuf_generate_c(ENROLL_PROTO_SRCS ENROLL_PROTO_HDRS
+ "${LIB_SOURCE_DIR}/pb/enroll.proto")
+protobuf_generate_c(CEP_PROTO_SRCS CEP_PROTO_HDRS
+ "${LIB_SOURCE_DIR}/pb/cep.proto")
+protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS
+ "${LIB_SOURCE_DIR}/pb/irm.proto")
+protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS
+ "${LIB_SOURCE_DIR}/pb/ipcp.proto")
+
+# Common library source files
+set(SOURCE_FILES_COMMON
+ bitmap.c
+ btree.c
+ crc32.c
+ crypt.c
+ hash.c
+ list.c
+ lockfile.c
+ logs.c
+ md5.c
+ notifier.c
+ protobuf.c
+ qoscube.c
+ random.c
+ rib.c
+ serdes-irm.c
+ serdes-oep.c
+ sha3.c
+ shm_flow_set.c
+ shm_rbuff.c
+ shm_rdrbuff.c
+ sockets.c
+ tpm.c
+ utils.c
+)
+
+# Convert relative paths to absolute
+set(SOURCE_FILES_COMMON_ABS)
+foreach(src ${SOURCE_FILES_COMMON})
+ list(APPEND SOURCE_FILES_COMMON_ABS "${LIB_SOURCE_DIR}/${src}")
+endforeach()
+
+if (HAVE_OPENSSL)
+ set(OPENSSL_SOURCES "${LIB_SOURCE_DIR}/crypt/openssl.c")
+else()
+ set(OPENSSL_SOURCES "")
+endif()
+
+add_library(ouroboros-common SHARED
+ ${SOURCE_FILES_COMMON_ABS}
+ ${IRM_PROTO_SRCS}
+ ${IPCP_PROTO_SRCS}
+ ${IPCP_CONFIG_PROTO_SRCS}
+ ${MODEL_PROTO_SRCS}
+ ${ENROLL_PROTO_SRCS}
+ ${OPENSSL_SOURCES})
+
+set_target_properties(ouroboros-common PROPERTIES
+ VERSION ${PACKAGE_VERSION}
+ SOVERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR})
+
+include(utils/AddCompileFlags)
+if (CMAKE_BUILD_TYPE MATCHES "Debug*")
+ add_compile_flags(ouroboros-common -DCONFIG_OUROBOROS_DEBUG)
+endif ()
+
+target_include_directories(ouroboros-common PUBLIC
+ ${LIB_SOURCE_DIR}
+ ${LIB_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+ ${CMAKE_BINARY_DIR}
+ ${PROTOBUF_C_INCLUDE_DIRS}
+ ${SYS_RND_HDR})
+
+if (LIBGCRYPT_INCLUDE_DIR)
+ target_include_directories(ouroboros-common PUBLIC ${LIBGCRYPT_INCLUDE_DIR})
+endif ()
+
+if (OPENSSL_INCLUDE_DIR)
+ target_include_directories(ouroboros-common PUBLIC ${OPENSSL_INCLUDE_DIR})
+endif ()
+
+
+target_link_libraries(ouroboros-common
+ ${LIBRT_LIBRARIES}
+ ${LIBPTHREAD_LIBRARIES}
+ ${PROTOBUF_C_LIBRARY})
+
+if (OPENSSL_CRYPTO_LIBRARY)
+ target_link_libraries(ouroboros-common ${OPENSSL_CRYPTO_LIBRARY})
+endif ()
+
+if (LIBGCRYPT_LIBRARIES)
+ target_link_libraries(ouroboros-common ${LIBGCRYPT_LIBRARIES})
+endif ()
+
+if (FUSE_LIBRARIES)
+ target_link_libraries(ouroboros-common ${FUSE_LIBRARIES})
+endif ()
+
+install(TARGETS ouroboros-common LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
+
diff --git a/cmake/lib/dev.cmake b/cmake/lib/dev.cmake
new file mode 100644
index 00000000..21fe140d
--- /dev/null
+++ b/cmake/lib/dev.cmake
@@ -0,0 +1,37 @@
+set(SOURCE_FILES_DEV
+ cep.c
+ dev.c
+)
+
+# Convert relative paths to absolute
+set(SOURCE_FILES_DEV_ABS)
+foreach(src ${SOURCE_FILES_DEV})
+ list(APPEND SOURCE_FILES_DEV_ABS "${LIB_SOURCE_DIR}/${src}")
+endforeach()
+
+add_library(ouroboros-dev SHARED
+ ${SOURCE_FILES_DEV_ABS}
+ ${CEP_PROTO_SRCS})
+
+set_target_properties(ouroboros-dev PROPERTIES
+ VERSION ${PACKAGE_VERSION}
+ SOVERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR})
+
+if (CMAKE_BUILD_TYPE MATCHES "Debug*")
+ add_compile_flags(ouroboros-dev -DCONFIG_OUROBOROS_DEBUG)
+endif ()
+
+target_include_directories(ouroboros-dev PUBLIC
+ ${LIB_SOURCE_DIR}
+ ${LIB_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+ ${CMAKE_BINARY_DIR}
+ ${PROTOBUF_C_INCLUDE_DIRS}
+ ${SYS_RND_HDR}
+ ${LIBGCRYPT_INCLUDE_DIR}
+ ${OPENSSL_INCLUDE_DIR})
+
+target_link_libraries(ouroboros-dev ouroboros-common)
+
+install(TARGETS ouroboros-dev LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/cmake/lib/irm.cmake b/cmake/lib/irm.cmake
new file mode 100644
index 00000000..5e336b31
--- /dev/null
+++ b/cmake/lib/irm.cmake
@@ -0,0 +1,34 @@
+set(SOURCE_FILES_IRM
+ irm.c
+)
+
+# Convert relative paths to absolute
+set(SOURCE_FILES_IRM_ABS)
+foreach(src ${SOURCE_FILES_IRM})
+ list(APPEND SOURCE_FILES_IRM_ABS "${LIB_SOURCE_DIR}/${src}")
+endforeach()
+
+add_library(ouroboros-irm SHARED ${SOURCE_FILES_IRM_ABS})
+
+set_target_properties(ouroboros-irm PROPERTIES
+ VERSION ${PACKAGE_VERSION}
+ SOVERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR})
+
+if (CMAKE_BUILD_TYPE MATCHES "Debug*")
+ add_compile_flags(ouroboros-irm -DCONFIG_OUROBOROS_DEBUG)
+endif ()
+
+target_include_directories(ouroboros-irm PUBLIC
+ ${LIB_SOURCE_DIR}
+ ${LIB_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+ ${CMAKE_BINARY_DIR}
+ ${PROTOBUF_C_INCLUDE_DIRS}
+ ${SYS_RND_HDR}
+ ${LIBGCRYPT_INCLUDE_DIR}
+ ${OPENSSL_INCLUDE_DIR})
+
+target_link_libraries(ouroboros-irm ouroboros-common)
+
+install(TARGETS ouroboros-irm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/cmake/lib/lib.cmake b/cmake/lib/lib.cmake
new file mode 100644
index 00000000..bf79da44
--- /dev/null
+++ b/cmake/lib/lib.cmake
@@ -0,0 +1,99 @@
+set(LIB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/lib")
+set(LIB_BINARY_DIR "${CMAKE_BINARY_DIR}/src/lib")
+
+# Library configuration variables
+set(SHM_BUFFER_SIZE 16384 CACHE STRING
+ "Number of blocks in packet buffer, must be a power of 2")
+set(SHM_RBUFF_SIZE 1024 CACHE STRING
+ "Number of blocks in rbuff buffer, must be a power of 2")
+set(SYS_MAX_FLOWS 10240 CACHE STRING
+ "Maximum number of total flows for this system")
+set(PROG_MAX_FLOWS 4096 CACHE STRING
+ "Maximum number of flows in an application")
+set(PROG_RES_FDS 64 CACHE STRING
+ "Number of reserved flow descriptors per application")
+set(PROG_MAX_FQUEUES 32 CACHE STRING
+ "Maximum number of flow sets per application")
+set(DU_BUFF_HEADSPACE 256 CACHE STRING
+ "Bytes of headspace to reserve for future headers")
+set(DU_BUFF_TAILSPACE 32 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 500 CACHE STRING
+ "Default timeout for responses from IPCPs (ms)")
+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
+ "Packet buffer block size, multiple of pagesize for performance")
+set(SHM_RDRB_MULTI_BLOCK TRUE CACHE BOOL
+ "Packet buffer multiblock packet support")
+set(SHM_RBUFF_LOCKLESS FALSE CACHE BOOL
+ "Enable shared memory lockless rbuff support")
+set(QOS_DISABLE_CRC TRUE CACHE BOOL
+ "Ignores ber setting on all QoS cubes")
+set(DELTA_T_MPL 60 CACHE STRING
+ "Maximum packet lifetime (s)")
+set(DELTA_T_ACK 10 CACHE STRING
+ "Maximum time to acknowledge a packet (s)")
+set(DELTA_T_RTX 120 CACHE STRING
+ "Maximum time to retransmit a packet (s)")
+set(FRCT_REORDER_QUEUE_SIZE 256 CACHE STRING
+ "Size of the reordering queue, must be a power of 2")
+set(FRCT_START_WINDOW 64 CACHE STRING
+ "Start window, must be a power of 2")
+set(FRCT_LINUX_RTT_ESTIMATOR TRUE CACHE BOOL
+ "Use Linux RTT estimator formula instead of the TCP RFC formula")
+set(FRCT_RTO_MDEV_MULTIPLIER 2 CACHE STRING
+ "Multiplier for deviation term in the RTO: RTO = sRTT + (mdev << X)")
+set(FRCT_RTO_INC_FACTOR 0 CACHE STRING
+ "Divisor for RTO increase after timeout: RTO += RTX >> X, 0: Karn/Partridge")
+set(FRCT_RTO_MIN 250 CACHE STRING
+ "Minimum Retransmission Timeout (RTO) for FRCT (us)")
+set(FRCT_TICK_TIME 5000 CACHE STRING
+ "Tick time for FRCT activity (retransmission, acknowledgments) (us)")
+set(RXM_BUFFER_ON_HEAP FALSE CACHE BOOL
+ "Store packets for retransmission on the heap instead of in packet buffer")
+set(RXM_BLOCKING TRUE CACHE BOOL
+ "Use blocking writes for retransmission")
+set(RXM_MIN_RESOLUTION 20 CACHE STRING
+ "Minimum retransmission delay (ns), as a power to 2")
+set(RXM_WHEEL_MULTIPLIER 4 CACHE STRING
+ "Factor for retransmission wheel levels as a power to 2")
+set(RXM_WHEEL_LEVELS 3 CACHE STRING
+ "Number of levels in the retransmission wheel")
+set(RXM_WHEEL_SLOTS_PER_LEVEL 256 CACHE STRING
+ "Number of slots per level in the retransmission wheel, must be a power of 2")
+set(ACK_WHEEL_SLOTS 256 CACHE STRING
+ "Number of slots in the acknowledgment wheel, must be a power of 2")
+set(ACK_WHEEL_RESOLUTION 18 CACHE STRING
+ "Minimum acknowledgment delay (ns), as a power to 2")
+set(TPM_DEBUG_REPORT_INTERVAL 0 CACHE STRING
+ "Interval at wich the TPM will report long running threads (s), 0 disables")
+set(TPM_DEBUG_ABORT_TIMEOUT 0 CACHE STRING
+ "TPM abort process after a thread reaches this timeout (s), 0 disables")
+
+if (HAVE_FUSE)
+ set(PROC_FLOW_STATS TRUE CACHE BOOL
+ "Enable flow statistics tracking for application flows")
+ if (PROC_FLOW_STATS)
+ message(STATUS "Application flow statistics enabled")
+ else ()
+ message(STATUS "Application flow statistics disabled")
+ endif ()
+endif ()
diff --git a/cmake/package.cmake b/cmake/package.cmake
new file mode 100644
index 00000000..d45222dc
--- /dev/null
+++ b/cmake/package.cmake
@@ -0,0 +1,31 @@
+set(PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
+set(PACKAGE_DESCRIPTION "The Ouroboros prototype")
+set(PACKAGE_URL "http://ouroboros.rocks")
+set(PACKAGE_BUGREPORT "http://ouroboros.rocks/bugzilla/")
+
+message(STATUS "Package name is: ${PACKAGE_NAME}")
+message(STATUS "Package description is: ${PACKAGE_DESCRIPTION}")
+message(STATUS "Package version is: ${PACKAGE_VERSION}")
+message(STATUS "Package URL is: ${PACKAGE_URL}")
+message(STATUS "Package bug-report address: ${PACKAGE_BUGREPORT}")
+message(STATUS "Package install prefix: ${CMAKE_INSTALL_PREFIX}")
+
+# Pkg-config files configuration
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros-dev.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc" @ONLY)
+
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros-irm.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc" @ONLY)
+
+# CPack packaging configuration
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_DESCRIPTION}")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
+set(CPACK_PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION_MAJOR}")
+set(CPACK_PACKAGE_VERSION_MINOR "${PACKAGE_VERSION_MINOR}")
+set(CPACK_PACKAGE_VERSION_PATCH "${PACKAGE_VERSION_PATCH}")
+set(CPACK_PACKAGE_INSTALL_DIRECTORY
+ "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
+set(CPACK_GENERATOR "TGZ")
+set(CPACK_SOURCE_GENERATOR "TGZ")
+
+include(CPack)
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
new file mode 100644
index 00000000..fb81c5f9
--- /dev/null
+++ b/cmake/tests.cmake
@@ -0,0 +1,21 @@
+include(CTest) # Sets BUILD_TESTING by default to on.
+
+if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
+ set(BUILD_TESTS ON)
+else ()
+ set(BUILD_TESTS OFF)
+endif()
+
+add_custom_target(build_tests)
+
+if (BUILD_TESTS)
+ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
+ add_dependencies(check build_tests)
+
+ add_subdirectory(src/lib/tests)
+ add_subdirectory(src/irmd/tests)
+ add_subdirectory(src/ipcpd/unicast/pff/tests)
+ add_subdirectory(src/ipcpd/unicast/routing/tests)
+ add_subdirectory(src/ipcpd/unicast/dir/tests)
+ add_subdirectory(src/irmd/reg/tests)
+endif ()
diff --git a/cmake/tools.cmake b/cmake/tools.cmake
new file mode 100644
index 00000000..de1d374c
--- /dev/null
+++ b/cmake/tools.cmake
@@ -0,0 +1,8 @@
+include(tools/tools)
+include(tools/irm)
+include(tools/ocbr)
+include(tools/oecho)
+include(tools/obc)
+include(tools/oping)
+include(tools/operf)
+include(tools/ovpn)
diff --git a/cmake/tools/irm.cmake b/cmake/tools/irm.cmake
new file mode 100644
index 00000000..c9090a2c
--- /dev/null
+++ b/cmake/tools/irm.cmake
@@ -0,0 +1,33 @@
+set(IRM_SOURCE_DIR "${TOOLS_SOURCE_DIR}/irm")
+
+set(IRM_SOURCES
+ "${IRM_SOURCE_DIR}/irm.c"
+ "${IRM_SOURCE_DIR}/irm_bind_program.c"
+ "${IRM_SOURCE_DIR}/irm_bind_process.c"
+ "${IRM_SOURCE_DIR}/irm_bind_ipcp.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp_create.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp_destroy.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp_bootstrap.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp_enroll.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp_list.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp_connect.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp_disconnect.c"
+ "${IRM_SOURCE_DIR}/irm_unbind_program.c"
+ "${IRM_SOURCE_DIR}/irm_unbind_process.c"
+ "${IRM_SOURCE_DIR}/irm_unbind_ipcp.c"
+ "${IRM_SOURCE_DIR}/irm_unbind.c"
+ "${IRM_SOURCE_DIR}/irm_bind.c"
+ "${IRM_SOURCE_DIR}/irm_ipcp.c"
+ "${IRM_SOURCE_DIR}/irm_name.c"
+ "${IRM_SOURCE_DIR}/irm_name_create.c"
+ "${IRM_SOURCE_DIR}/irm_name_destroy.c"
+ "${IRM_SOURCE_DIR}/irm_name_reg.c"
+ "${IRM_SOURCE_DIR}/irm_name_unreg.c"
+ "${IRM_SOURCE_DIR}/irm_name_list.c"
+ "${IRM_SOURCE_DIR}/irm_utils.c"
+)
+
+add_executable(irm ${IRM_SOURCES})
+target_include_directories(irm PRIVATE ${TOOLS_INCLUDE_DIRS})
+target_link_libraries(irm PUBLIC ouroboros-irm)
+install(TARGETS irm RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/tools/obc.cmake b/cmake/tools/obc.cmake
new file mode 100644
index 00000000..99e001b6
--- /dev/null
+++ b/cmake/tools/obc.cmake
@@ -0,0 +1,4 @@
+add_executable(obc "${TOOLS_SOURCE_DIR}/obc/obc.c")
+target_include_directories(obc PRIVATE ${TOOLS_INCLUDE_DIRS})
+target_link_libraries(obc PUBLIC ouroboros-dev)
+install(TARGETS obc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/ocbr.cmake b/cmake/tools/ocbr.cmake
new file mode 100644
index 00000000..bab80da8
--- /dev/null
+++ b/cmake/tools/ocbr.cmake
@@ -0,0 +1,4 @@
+add_executable(ocbr "${TOOLS_SOURCE_DIR}/ocbr/ocbr.c")
+target_include_directories(ocbr PRIVATE ${TOOLS_INCLUDE_DIRS})
+target_link_libraries(ocbr PUBLIC ouroboros-dev)
+install(TARGETS ocbr RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/oecho.cmake b/cmake/tools/oecho.cmake
new file mode 100644
index 00000000..73522731
--- /dev/null
+++ b/cmake/tools/oecho.cmake
@@ -0,0 +1,4 @@
+add_executable(oecho "${TOOLS_SOURCE_DIR}/oecho/oecho.c")
+target_include_directories(oecho PRIVATE ${TOOLS_INCLUDE_DIRS})
+target_link_libraries(oecho PUBLIC ouroboros-dev)
+install(TARGETS oecho RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/operf.cmake b/cmake/tools/operf.cmake
new file mode 100644
index 00000000..f6b2b465
--- /dev/null
+++ b/cmake/tools/operf.cmake
@@ -0,0 +1,4 @@
+add_executable(operf "${TOOLS_SOURCE_DIR}/operf/operf.c")
+target_include_directories(operf PRIVATE ${TOOLS_INCLUDE_DIRS})
+target_link_libraries(operf PUBLIC ouroboros-dev)
+install(TARGETS operf RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/oping.cmake b/cmake/tools/oping.cmake
new file mode 100644
index 00000000..6bb18132
--- /dev/null
+++ b/cmake/tools/oping.cmake
@@ -0,0 +1,4 @@
+add_executable(oping "${TOOLS_SOURCE_DIR}/oping/oping.c")
+target_include_directories(oping PRIVATE ${TOOLS_INCLUDE_DIRS})
+target_link_libraries(oping PUBLIC ${LIBM_LIBRARIES} ouroboros-dev)
+install(TARGETS oping RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/ovpn.cmake b/cmake/tools/ovpn.cmake
new file mode 100644
index 00000000..331daff9
--- /dev/null
+++ b/cmake/tools/ovpn.cmake
@@ -0,0 +1,6 @@
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ add_executable(ovpn "${TOOLS_SOURCE_DIR}/ovpn/ovpn.c")
+ target_include_directories(ovpn PRIVATE ${TOOLS_INCLUDE_DIRS})
+ target_link_libraries(ovpn PUBLIC ouroboros-dev)
+ install(TARGETS ovpn RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
+endif ()
diff --git a/cmake/tools/tools.cmake b/cmake/tools/tools.cmake
new file mode 100644
index 00000000..26abdc63
--- /dev/null
+++ b/cmake/tools/tools.cmake
@@ -0,0 +1,8 @@
+set(TOOLS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/tools")
+set(TOOLS_BINARY_DIR "${CMAKE_BINARY_DIR}/src/tools")
+
+set(TOOLS_INCLUDE_DIRS
+ ${TOOLS_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+)
diff --git a/cmake/AddCompileFlags.cmake b/cmake/utils/AddCompileFlags.cmake
index 8f3877d9..8f3877d9 100644
--- a/cmake/AddCompileFlags.cmake
+++ b/cmake/utils/AddCompileFlags.cmake
diff --git a/cmake/CmakeUninstall.cmake.in b/cmake/utils/CMakeUninstall.cmake.in
index 985b31b2..985b31b2 100644
--- a/cmake/CmakeUninstall.cmake.in
+++ b/cmake/utils/CMakeUninstall.cmake.in
diff --git a/cmake/CompilerUtils.cmake b/cmake/utils/CompilerUtils.cmake
index 7c8b022f..7c8b022f 100644
--- a/cmake/CompilerUtils.cmake
+++ b/cmake/utils/CompilerUtils.cmake
diff --git a/cmake/FindProtobufC.cmake b/cmake/utils/FindProtobufC.cmake
index ff892b5b..ff892b5b 100644
--- a/cmake/FindProtobufC.cmake
+++ b/cmake/utils/FindProtobufC.cmake
diff --git a/cmake/version.cmake b/cmake/version.cmake
new file mode 100644
index 00000000..00183d34
--- /dev/null
+++ b/cmake/version.cmake
@@ -0,0 +1,5 @@
+set(PACKAGE_VERSION_MAJOR 0)
+set(PACKAGE_VERSION_MINOR 22)
+set(PACKAGE_VERSION_PATCH 0)
+set(PACKAGE_VERSION
+ "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}")