From: "stipa (Code Review)" Date: Mon, 31 Jul 2023 11:27:05 +0000 References: Reply-To: lstipakov@...277..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <5686a39411cec135016dd392f76ed665e9f067ee-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="CK9831YH5ZI="; charset=UTF-8 Subject: [Openvpn-devel] [XL] Change in openvpn[release/2.6]: add basic CMake based build List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: openvpn-devel , plaisthos , flichtenheld --CK9831YH5ZI= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Attention is currently required from: flichtenheld, plaisthos. stipa has uploaded this change for review. ( http://gerrit.openvpn.net/c/op= envpn/+/322?usp=3Demail ) Change subject: add basic CMake based build ...................................................................... add basic CMake based build This helps with IDE integration among other things. This is a basic implementation for development purposes that can't replace any of the existing release builds. Change-Id: I666314a223d324ca72dbe7ba7d22f764996d3ca2 Signed-off-by: Arne Schwabe Signed-off-by: Frank Lichtenheld --- A CMakeLists.txt A config.h.cmake.in M src/openvpn/lzo.h 3 files changed, 1,091 insertions(+), 1 deletion(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/22/322/1 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9978ea4 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,591 @@ + cmake_minimum_required(VERSION 3.3) +project(openvpn) + +# This CMake file implements building OpenVPN with CMAKE +# +# Note that this is *NOT* the official way to build openvpn on anything +# other than Windows/mingw despite working on other platforms too. You wil= l need +# to add -DUNSUPPORTED_BUILDS=3Dtrue to build on non Windows platforms. +# +# This cmake also makes a few assertions like lzo, lz4 being used +# and OpenSSL having version 1.1.1+ and generally does not offer the same +# configurability like autoconf + +# -DCMAKE_TOOLCHAIN_FILE=3DC:/Users/User/source/repos/vcpkg/scripts/builds= ystems/vcpkg.cmake +#-DVCPKG_OVERLAY_PORTS=3DC:/Users/User/source/repos/openvpn/contrib/vcpkg-= ports +#-GNinja + +option(UNSUPPORTED_BUILDS "Allow unsupported builds" OFF) + +if (NOT WIN32 AND NOT ${UNSUPPORTED_BUILDS}) + message(FATAL_ERROR "Note: on Unix platform the official and supported= build method is using autoconfig. CMake based build should be only used fo= r Windows and internal testing/development.") +endif() + +option(MBED "BUILD with mbed" OFF) +option(WOLFSSL "BUILD with wolfSSL" OFF) +if (MSVC) + option(USE_WERROR "Treat compiler warnings as errors (-Werror)" OFF) +else () + option(USE_WERROR "Treat compiler warnings as errors (-Werror)" ON) +endif () +option(PLUGIN_DIR "Location of the plugin directory" /usr/local/lib/openvp= n/plugins) + +# AddressSanitize - use CXX=3Dclang++ CC=3Dclang cmake -DCMAKE_BUILD_TYPE= =3Dasan to build with ASAN +set(CMAKE_C_FLAGS_ASAN + "-fsanitize=3Daddress,undefined -fno-sanitize-recover=3Dall -fno-o= ptimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-po= inter -g -O1" + CACHE STRING "Flags used by the C compiler during AddressSanitizer= builds." + FORCE) +set(CMAKE_CXX_FLAGS_ASAN + "-fsanitize=3Daddress,undefined -fno-sanitize-recover=3Dall -fno-o= ptimize-sibling-calls -fsanitize-address-use-after-scope -fno-omit-frame-po= inter -g -O1" + CACHE STRING "Flags used by the C++ compiler during AddressSanitiz= er builds." + FORCE) + +if (MSVC) + target_compile_options(${target} PRIVATE /W3) +else () + add_compile_options(-Wall -Wuninitialized) + # We are not ready for this + #add_compile_options(-Wsign-compare) +endif () + +find_package(PkgConfig) +INCLUDE(CheckSymbolExists) +INCLUDE(CheckIncludeFiles) +INCLUDE(CheckTypeSize) +INCLUDE(CheckStructHasMember) + +set(OPENVPN_VERSION_MAJOR 2) +set(OPENVPN_VERSION_MINOR 6) +set(OPENVPN_VERSION_PATCH _git) + +if (NOT WIN32) + add_definitions(-DPLUGIN_LIBDIR=3D\"${PLUGIN_DIR}\") +endif () + +# TODO remove later when msvc-config.h is removed and we can always includ= e config.h +add_definitions(-DHAVE_CONFIG_H) + + +# Set the various defines for config.h.cmake.in +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(TARGET_LINUX YES) + set(ENABLE_ASYNC_PUSH YES) + set(ENABLE_LINUXDCO YES) + set(ENABLE_SITNL YES) + set(HAVE_DECL_SO_MARK YES) + set(ENABLE_FEATURE_TUN_PERSIST 1) + set(HAVE_LINUX_TYPES_H 1) + set(ENABLE_DCO YES) + set(HAVE_CMSGHDR YES) +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") + set(TARGET_FREEBSD YES) + set(ENABLE_DCO YES) + link_libraries(-lnv) +elseif (WIN32) + set(ENABLE_DCO YES) +elseif (APPLE) + set(TARGET_DARWIN YES) + set(HAVE_NET_IF_UTUN_H YES) +endif () + +if (UNIX) + set(PATH_SEPARATOR /) + set(ENABLE_PORT_SHARE YES) + set(HAVE_SA_FAMILY_T YES) +elseif (WIN32) + set(PATH_SEPARATOR \\\\) + set(TARGET_WIN32 YES) +endif () + +CHECK_SYMBOL_EXISTS(chroot unistd.h HAVE_CHROOT) +CHECK_SYMBOL_EXISTS(chdir unistd.h HAVE_CHDIR) +CHECK_SYMBOL_EXISTS(dup unistd.h HAVE_DUP) +CHECK_SYMBOL_EXISTS(dup2 unistd.h HAVE_DUP2) +CHECK_SYMBOL_EXISTS(fork unistd.h HAVE_FORK) +CHECK_SYMBOL_EXISTS(execve unistd.h HAVE_EXECVE) +CHECK_SYMBOL_EXISTS(ftruncate unistd.h HAVE_FTRUNCATE) +CHECK_SYMBOL_EXISTS(setgid unistd.h HAVE_SETGID) +CHECK_SYMBOL_EXISTS(setuid unistd.h HAVE_SETUID) +CHECK_SYMBOL_EXISTS(getpeereid unistd.h HAVE_GETPEEREID) + +CHECK_SYMBOL_EXISTS(epoll_create sys/epoll.h HAVE_EPOLL_CREATE) + +CHECK_SYMBOL_EXISTS(gettimeofday sys/time.h HAVE_GETTIMEOFDAY) +CHECK_SYMBOL_EXISTS(basename libgen.h HAVE_BASENAME) +CHECK_SYMBOL_EXISTS(chsize io.h HAVE_CHSIZE) +CHECK_SYMBOL_EXISTS(daemon stdlib.h HAVE_DAEMON) +CHECK_SYMBOL_EXISTS(dirname libgen.h HAVE_DIRNAME) +CHECK_SYMBOL_EXISTS(getrlimit sys/resource.h HAVE_GETRLIMIT) +CHECK_SYMBOL_EXISTS(mlockall sys/mman.h HAVE_MLOCKALL) + +CHECK_SYMBOL_EXISTS(sendmsg sys/socket.h HAVE_SENDMSG) +CHECK_SYMBOL_EXISTS(recvmsg sys/socket.h HAVE_RECVMSG) +CHECK_SYMBOL_EXISTS(cmsghdr sys/socket.h HAVE_CMSGHDR) +CHECK_SYMBOL_EXISTS(openlog syslog.h HAVE_OPENLOG) +CHECK_SYMBOL_EXISTS(syslog syslog.h HAVE_SYSLOG) +CHECK_SYMBOL_EXISTS(getgrnam grp.h HAVE_GETGRNAM) +CHECK_SYMBOL_EXISTS(getpwnam pwd.h HAVE_GETPWNAM) +CHECK_SYMBOL_EXISTS(getsockname sys/socket.h HAVE_GETSOCKNAME) + +# Some OS (e.g. FreeBSD) need some basic headers to allow +# including network headers +SET(NETEXTRA sys/types.h) +CHECK_INCLUDE_FILES("${NETEXTRA};netinet/in.h" HAVE_NETINET_IN_H) + +if (HAVE_NETINET_IN_H) + LIST(APPEND NETEXTRA netinet/in.h) +endif () + +CHECK_INCLUDE_FILES("${NETEXTRA};netinet/in6.h" HAVE_NETINET_IN_H) +CHECK_INCLUDE_FILES(linux/if_tun.h HAVE_LINUX_IF_TUN_H) +CHECK_INCLUDE_FILES(linux/sockios.h HAVE_LINUX_SOCKIOS_H) +CHECK_INCLUDE_FILES(dlfcn.h HAVE_DLFCN_H) +CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H) +CHECK_INCLUDE_FILES(dmalloc.h HAVE_DMALLOC_H) +CHECK_INCLUDE_FILES(err.h HAVE_ERR_H) +CHECK_INCLUDE_FILES(sys/epoll.h HAVE_SYS_EPOLL_H) +CHECK_INCLUDE_FILES(poll.h HAVE_POLL_H) +CHECK_INCLUDE_FILES(sys/socket.h HAVE_SYS_SOCKET_H) +CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H) +CHECK_INCLUDE_FILES(netdb.h HAVE_NETDB_H) +CHECK_INCLUDE_FILES(unistd.h HAVE_UNISTD_H) +CHECK_INCLUDE_FILES(sys/un.h HAVE_SYS_UN_H) +CHECK_INCLUDE_FILES(libgen.h HAVE_LIBGEN_H) +CHECK_INCLUDE_FILES(net/if.h HAVE_NET_IF_H) +CHECK_INCLUDE_FILES("${NETEXTRA};netinet/ip.h" HAVE_NETINET_IP_H) +CHECK_INCLUDE_FILES(arpa/inet.h HAVE_ARPA_INET_H) +CHECK_INCLUDE_FILES(net/if_utun.h HAVE_NET_UTUN_H) +CHECK_INCLUDE_FILES(sys/ioctl.h HAVE_SYS_IOCTL_H) +CHECK_INCLUDE_FILES(sys/inotify.h HAVE_SYS_INOTIFY_H) +CHECK_INCLUDE_FILES("${NETEXTRA};sys/uio.h" HAVE_SYS_UIO_H) +CHECK_INCLUDE_FILES(syslog.h HAVE_SYSLOG_H) +CHECK_INCLUDE_FILES(sys/wait.h HAVE_SYS_WAIT_H) +CHECK_INCLUDE_FILES(grp.h HAVE_GRP_H) +CHECK_INCLUDE_FILES(pwd.h HAVE_PWD_H) +CHECK_INCLUDE_FILES(sys/mman.h HAVE_SYS_MMAN_H) + + +CHECK_INCLUDE_FILES("${NETEXTRA};resolv.h" HAVE_RESOLV_H) +CHECK_INCLUDE_FILES("${NETEXTRA};net/if_tun.h" HAVE_NET_IF_TUN_H) + +# Is this obscure header needed anywhere?! +CHECK_INCLUDE_FILES(netinet/in_systm.h HAVE_NETINET_IN_SYSTM_H) + + +SET(CMAKE_EXTRA_INCLUDE_FILES netinet/ip.h) +CHECK_TYPE_SIZE("struct in_pktinfo" IN_PKTINFO) +CHECK_STRUCT_HAS_MEMBER("struct in_pktinfo" ipi_spec_dst netinet/ip.h HAVE= _IPI_SPEC_DST) +CHECK_TYPE_SIZE("struct msghdr" MSGHDR) +SET(CMAKE_EXTRA_INCLUDE_FILES) + +find_program(IFCONFIG_PATH ifconfig) +find_program(IPROUTE_PATH ip) +find_program(ROUTE_PATH route) + + +if (NOT WIN32) + set(ENABLE_LZ4 YES) + set(ENABLE_LZO YES) +endif () + +function(add_library_deps target) + if (${MBED}) + target_include_directories(${target} PRIVATE $ENV{HOME}/oss/mbedtl= s2/include) + message("Building ${target} for mbed TLS") + target_link_libraries(${target} PUBLIC -L$ENV{HOME}/oss/mbedtls2/l= ibrary -L/usr/local/opt/lzo/lib -lmbedtls -lmbedx509 -lmbedcrypto) + elseif (${WOLFSSL}) + pkg_search_module(wolfssl wolfssl REQUIRED) + target_link_libraries(${target} PUBLIC ${wolfssl_LINK_LIBRARIES}) + target_include_directories(${target} PRIVATE ${wolfssl_INCLUDE_DIR= S}/wolfssl) + message("Building ${target} for WolfSSL: ${wolfssl_LINK_LIBRARIES}= ${wolfssl_INCLUDE_DIRS}/wolfsll") + else () + set(ENABLE_X509ALTUSERNAME YES) + + find_package(OpenSSL REQUIRED) + target_link_libraries(${target} PUBLIC OpenSSL::SSL) + + message("Building ${target} for default OpenSSL") + endif () + + + if (${ENABLE_LZ4}) + pkg_search_module(liblz4 liblz4 REQUIRED IMPORTED_TARGET) + target_link_libraries(${target} PUBLIC PkgConfig::liblz4) + endif () + + if (${ENABLE_LZO}) + pkg_search_module(lzo2 lzo2 REQUIRED IMPORTED_TARGET) + target_link_libraries(${target} PUBLIC PkgConfig::lzo2) + endif () + + if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + target_include_directories(${target} PUBLIC ${LIBNL_INCLUDE_DIRS}) + target_link_libraries(${target} PUBLIC ${LIBNL_LIBRARIES}) + endif () + + if (USE_WERROR) + if (MSVC) + target_compile_options(${target} PRIVATE /WX) + else () + target_compile_options(${target} PRIVATE -Werror) + endif () + endif () +endfunction() + +if (${MBED}) + set(ENABLE_CRYPTO_MBEDTLS YES) +elseif (${WOLFSSL}) + set(ENABLE_CRYPTO_OPENSSL YES) + set(ENABLE_CRYPTO_WOLFSSL YES) + set(ENABLE_X509ALTUSERNAME YES) +else () + set(ENABLE_CRYPTO_OPENSSL YES) + set(ENABLE_X509ALTUSERNAME YES) +endif () + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} src/compat include) + +if (WIN32) + find_package(OpenSSL REQUIRED) + + link_libraries(OpenSSL::SSL OpenSSL::Crypto ws2_32.lib Crypt32.lib fwp= uclnt.lib iphlpapi.lib + wininet.lib setupapi.lib rpcrt4.lib wtsapi32.lib Ncrypt.lib) + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE = -D _WINSOCK_DEPRECATED_NO_WARNINGS -D_CONSOLE) +endif () + +configure_file(config.h.cmake.in config.h) +configure_file(include/openvpn-plugin.h.in openvpn-plugin.h) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + +set(SOURCE_FILES + ${CMAKE_CURRENT_BINARY_DIR}/config.h + ${CMAKE_CURRENT_BINARY_DIR}/openvpn-plugin.h + + src/compat/compat-basename.c + src/compat/compat-daemon.c + src/compat/compat-dirname.c + src/compat/compat-gettimeofday.c + src/compat/compat-strsep.c + src/compat/compat-versionhelpers.h + src/openvpn/argv.c + src/openvpn/argv.h + src/openvpn/base64.c + src/openvpn/base64.h + src/openvpn/basic.h + src/openvpn/block_dns.h + src/openvpn/block_dns.c + src/openvpn/buffer.c + src/openvpn/buffer.h + src/openvpn/circ_list.h + src/openvpn/clinat.c + src/openvpn/clinat.h + src/openvpn/common.h + src/openvpn/comp-lz4.c + src/openvpn/comp-lz4.h + src/openvpn/comp.c + src/openvpn/comp.h + src/openvpn/compstub.c + src/openvpn/console.c + src/openvpn/console_builtin.c + src/openvpn/console.h + src/openvpn/crypto.c + src/openvpn/crypto.h + src/openvpn/crypto_backend.h + src/openvpn/crypto_openssl.c + src/openvpn/crypto_openssl.h + src/openvpn/crypto_mbedtls.c + src/openvpn/crypto_mbedtls.h + src/openvpn/cryptoapi.c + src/openvpn/cryptoapi.h + src/openvpn/dco.c + src/openvpn/dco.h + src/openvpn/dco_win.c + src/openvpn/dco_win.h + src/openvpn/dco_linux.c + src/openvpn/dco_linux.h + src/openvpn/dco_freebsd.c + src/openvpn/dco_freebsd.h + src/openvpn/dhcp.c + src/openvpn/dhcp.h + src/openvpn/dns.c + src/openvpn/dns.h + src/openvpn/errlevel.h + src/openvpn/env_set.c + src/openvpn/env_set.h + src/openvpn/error.c + src/openvpn/error.h + src/openvpn/event.c + src/openvpn/event.h + src/openvpn/fdmisc.c + src/openvpn/fdmisc.h + src/openvpn/forward.c + src/openvpn/forward.h + src/openvpn/fragment.c + src/openvpn/fragment.h + src/openvpn/gremlin.c + src/openvpn/gremlin.h + src/openvpn/helper.c + src/openvpn/helper.h + src/openvpn/httpdigest.c + src/openvpn/httpdigest.h + src/openvpn/init.c + src/openvpn/init.h + src/openvpn/integer.h + src/openvpn/interval.c + src/openvpn/interval.h + src/openvpn/list.c + src/openvpn/list.h + src/openvpn/lladdr.c + src/openvpn/lladdr.h + src/openvpn/lzo.c + src/openvpn/lzo.h + src/openvpn/manage.c + src/openvpn/manage.h + src/openvpn/mbuf.c + src/openvpn/mbuf.h + src/openvpn/memdbg.h + src/openvpn/misc.c + src/openvpn/misc.h + src/openvpn/mroute.c + src/openvpn/mroute.h + src/openvpn/mss.c + src/openvpn/mss.h + src/openvpn/mstats.c + src/openvpn/mstats.h + src/openvpn/mtcp.c + src/openvpn/mtcp.h + src/openvpn/mtu.c + src/openvpn/mtu.h + src/openvpn/mudp.c + src/openvpn/mudp.h + src/openvpn/multi.c + src/openvpn/multi.h + src/openvpn/ntlm.c + src/openvpn/ntlm.h + src/openvpn/occ.c + src/openvpn/occ.h + src/openvpn/openvpn.c + src/openvpn/openvpn.h + src/openvpn/options.c + src/openvpn/options.h + src/openvpn/options_util.c + src/openvpn/options_util.h + src/openvpn/otime.c + src/openvpn/otime.h + src/openvpn/ovpn_dco_win.h + src/openvpn/packet_id.c + src/openvpn/packet_id.h + src/openvpn/perf.c + src/openvpn/perf.h + src/openvpn/ping.c + src/openvpn/ping.h + src/openvpn/pkcs11.c + src/openvpn/pkcs11.h + src/openvpn/pkcs11_backend.h + src/openvpn/pkcs11_openssl.c + src/openvpn/pkcs11_mbedtls.c + src/openvpn/platform.c + src/openvpn/platform.h + src/openvpn/plugin.c + src/openvpn/plugin.h + src/openvpn/pool.c + src/openvpn/pool.h + src/openvpn/proto.c + src/openvpn/proto.h + src/openvpn/proxy.c + src/openvpn/proxy.h + src/openvpn/ps.c + src/openvpn/ps.h + src/openvpn/push.c + src/openvpn/push.h + src/openvpn/pushlist.h + src/openvpn/reliable.c + src/openvpn/reliable.h + src/openvpn/route.c + src/openvpn/route.h + src/openvpn/run_command.c + src/openvpn/run_command.h + src/openvpn/schedule.c + src/openvpn/schedule.h + src/openvpn/session_id.c + src/openvpn/session_id.h + src/openvpn/shaper.c + src/openvpn/shaper.h + src/openvpn/sig.c + src/openvpn/sig.h + src/openvpn/socket.c + src/openvpn/socket.h + src/openvpn/socks.c + src/openvpn/socks.h + src/openvpn/ssl.c + src/openvpn/ssl.h + src/openvpn/ssl_backend.h + src/openvpn/ssl_common.h + src/openvpn/ssl_openssl.c + src/openvpn/ssl_openssl.h + src/openvpn/ssl_mbedtls.c + src/openvpn/ssl_mbedtls.h + src/openvpn/ssl_verify.c + src/openvpn/ssl_verify.h + src/openvpn/ssl_verify_backend.h + src/openvpn/ssl_verify_openssl.c + src/openvpn/ssl_verify_openssl.h + src/openvpn/ssl_verify_mbedtls.c + src/openvpn/ssl_verify_mbedtls.h + src/openvpn/status.c + src/openvpn/status.h + src/openvpn/syshead.h + src/openvpn/tls_crypt.c + src/openvpn/tun.c + src/openvpn/tun.h + src/openvpn/networking_sitnl.c + src/openvpn/networking_freebsd.c + src/openvpn/auth_token.c + src/openvpn/auth_token.h + src/openvpn/ssl_ncp.c + src/openvpn/ssl_ncp.h + src/openvpn/ssl_pkt.c + src/openvpn/ssl_pkt.h + src/openvpn/ssl_util.c + src/openvpn/ssl_util.h + src/openvpn/vlan.c + src/openvpn/vlan.h + src/openvpn/win32.c + src/openvpn/win32-util.c + src/openvpn/win32.h + src/openvpn/win32-util.h + src/openvpn/xkey_helper.c + src/openvpn/xkey_provider.c + ) + +add_executable(openvpn ${SOURCE_FILES}) + +add_library_deps(openvpn) + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + target_link_libraries(openvpn PUBLIC -ldl) + + find_package(PkgConfig) + pkg_search_module(LIBNL REQUIRED libnl-genl-3.0) + + target_link_libraries(openvpn PUBLIC ${LIBNL_LIBRARIES}) + target_include_directories(openvpn PRIVATE ${LIBNL_INCLUDE_DIRS}) +endif () + + +if (MINGW) + target_link_options(openvpn PRIVATE -municode) +endif () + +if (NOT WIN32) + find_library(resolv resolv) + # some platform like BSDs already include resolver functionality in th= e libc and not have an extra resolv library + if (${resolv} OR APPLE) + target_link_libraries(openvpn PUBLIC -lresolv) + endif () +endif () + + +pkg_search_module(cmocka cmocka REQUIRED IMPORTED_TARGET) +enable_testing() + +SET(unit_tests "test_packet_id" "test_crypto" "test_ncp" "test_auth_token"= "test_misc" "test_buffer" "test_provider" "test_pkt") + +# These tests work on only on Linux since they depend on special linker fe= atures +if (WIN32) + LIST(APPEND unit_tests "test_cryptoapi") +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + LIST(APPEND unit_tests "test_networking" "test_tls_crypt" "test_argv") +endif () + + +FOREACH (test_name ${unit_tests}) + add_executable(${test_name} + tests/unit_tests/openvpn/${test_name}.c + tests/unit_tests/openvpn/mock_msg.c + src/openvpn/platform.c + src/openvpn/crypto_mbedtls.c + src/openvpn/crypto_openssl.c + src/openvpn/crypto.c + src/openvpn/otime.c + src/openvpn/packet_id.c + src/openvpn/base64.c + src/openvpn/win32-util.c + src/openvpn/mtu.c + src/openvpn/networking_sitnl.c + src/compat/compat-strsep.c + src/compat/compat-gettimeofday.c + src/openvpn/ssl_util.c + src/openvpn/reliable.c + src/openvpn/session_id.c + src/openvpn/mss.c + src/openvpn/xkey_provider.c + ) + + add_library_deps(${test_name}) + target_link_libraries(${test_name} PUBLIC PkgConfig::cmocka) + + target_include_directories(${test_name} PRIVATE src/openvpn) + + if (NOT ${test_name} STREQUAL "test_buffer") + target_sources(${test_name} PRIVATE + src/openvpn/buffer.c + ) + endif () + add_test(NAME ${test_name} COMMAND ${test_name}) +ENDFOREACH () + +target_sources(test_pkt PRIVATE + src/openvpn/argv.c + src/openvpn/env_set.c + src/openvpn/reliable.c + src/openvpn/run_command.c + src/openvpn/session_id.c + src/openvpn/ssl_pkt.c + src/openvpn/tls_crypt.c + ) + +if (TARGET test_cryptoapi) + target_sources(test_cryptoapi PRIVATE + src/openvpn/xkey_helper.c + src/openvpn/xkey_provider.c + ) +endif () + +target_sources(test_provider PRIVATE + src/openvpn/xkey_provider.c + src/openvpn/xkey_helper.c + ) + +target_sources(test_misc PRIVATE + src/openvpn/options_util.c + ) + +IF (TARGET test_tls_crypt) + target_sources(test_tls_crypt PRIVATE + src/openvpn/argv.c + src/openvpn/env_set.c + src/openvpn/run_command.c) +endif () + +if (TARGET test_argv) + target_sources(test_argv PRIVATE + src/openvpn/argv.c + src/openvpn/env_set.c + src/openvpn/run_command.c) +endif () + + +FOREACH (test_name "networking" "tls_crypt" "argv") + if (TARGET test_${test_name}) + target_link_options(test_${test_name} PRIVATE -Wl,--wrap=3Dparse_l= ine) + endif () +ENDFOREACH () + +if (TARGET test_tls_crypt) + target_link_options("test_tls_crypt" PRIVATE + -Wl,--wrap=3Dbuffer_read_from_file + -Wl,--wrap=3Dbuffer_write_file + -Wl,--wrap=3Drand_bytes) +ENDIF () \ No newline at end of file diff --git a/config.h.cmake.in b/config.h.cmake.in new file mode 100644 index 0000000..6185971 --- /dev/null +++ b/config.h.cmake.in @@ -0,0 +1,492 @@ + +/* Configuration settings */ +#define CONFIGURE_DEFINES "N/A" + +/* Enable async push */ +#cmakedefine ENABLE_ASYNC_PUSH + +/* Use mbed TLS library */ +#cmakedefine ENABLE_CRYPTO_MBEDTLS + +/* Use Openssl */ +#cmakedefine ENABLE_CRYPTO_OPENSSL + +/* Use wolfSSL crypto library */ +#cmakedefine ENABLE_CRYPTO_WOLFSSL + +/* Enable shared data channel offload */ +#cmakedefine ENABLE_DCO + +/* Enable debugging support (needed for verb>=3D4) */ +#define ENABLE_DEBUG 1 + +/* We have persist tun capability */ +#cmakedefine ENABLE_FEATURE_TUN_PERSIST + +/* Enable internal fragmentation support */ +#define ENABLE_FRAGMENT 1 + +/* Enable linux data channel offload */ +#cmakedefine ENABLE_LINUXDCO + +/* Enable LZ4 compression library */ +#cmakedefine ENABLE_LZ4 + +/* Enable LZO compression library */ +#cmakedefine ENABLE_LZO + +/* Enable management server capability */ +#define ENABLE_MANAGEMENT 1 + +/* Enable OFB and CFB cipher modes */ +#define ENABLE_OFB_CFB_MODE + +/* Enable PKCS11 */ +/* #undef ENABLE_PKCS11 */ + +/* Enable plug-in support */ +#define ENABLE_PLUGIN 1 + +/* Enable TCP Server port sharing */ +#cmakedefine ENABLE_PORT_SHARE + +/* SELinux support */ +#cmakedefine ENABLE_SELINUX + +/* enable sitnl support */ +#cmakedefine ENABLE_SITNL + +/* Enable systemd integration */ +/* #undef ENABLE_SYSTEMD */ + +/* Enable --x509-username-field feature */ +#cmakedefine ENABLE_X509ALTUSERNAME + +/* Compiler supports anonymous unions */ +#define HAVE_ANONYMOUS_UNION_SUPPORT + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ARPA_INET_H 1 + +/* Define to 1 if you have the `basename' function. */ +#cmakedefine HAVE_BASENAME + +/* Define to 1 if you have the `chdir' function. */ +#cmakedefine HAVE_CHDIR + +/* Define to 1 if you have the `chroot' function. */ +#cmakedefine HAVE_CHROOT + +/* Define to 1 if you have the `chsize' function. */ +#cmakedefine HAVE_CHSIZE + +/* struct cmsghdr needed for extended socket error support */ +#cmakedefine HAVE_CMSGHDR + +/* Define to 1 if you have the `daemon' function. */ +#cmakedefine HAVE_DAEMON + +/* Define to 1 if you have the declaration of `SO_MARK', and to 0 if you +don't. */ +#cmakedefine01 HAVE_DECL_SO_MARK + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DIRECT_H + +/* Define to 1 if you have the `dirname' function. */ +#cmakedefine HAVE_DIRNAME + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_DMALLOC_H + +/* Define to 1 if you have the `dup' function. */ +#cmakedefine HAVE_DUP + +/* Define to 1 if you have the `dup2' function. */ +#cmakedefine HAVE_DUP2 + +/* Define to 1 if you have the `epoll_create' function. */ +#cmakedefine HAVE_EPOLL_CREATE + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_ERR_H + +/* Crypto library supports keying material exporter */ +#define HAVE_EXPORT_KEYING_MATERIAL 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_FCNTL_H + +/* Define to 1 if you have the `fork' function. */ +#cmakedefine HAVE_FORK +#cmakedefine HAVE_EXECVE + +/* Define to 1 if you have the `ftruncate' function. */ +#cmakedefine HAVE_FTRUNCATE + +/* Define to 1 if you have the `getgrnam' function. */ +#cmakedefine HAVE_GETGRNAM + +/* Define to 1 if you have the `getpeereid' function. */ +#cmakedefine HAVE_GETPEEREID + +/* Define to 1 if you have the `getpwnam' function. */ +#cmakedefine HAVE_GETPWNAM + +/* Define to 1 if you have the `getrlimit' function. */ +#undef HAVE_GETRLIMIT + +/* Define to 1 if you have the `getsockname' function. */ +#cmakedefine HAVE_GETSOCKNAME + +/* Define to 1 if you have the `gettimeofday' function. */ +#cmakedefine HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_GRP_H + +/* struct in_pktinfo needed for IP_PKTINFO support */ +#cmakedefine HAVE_IN_PKTINFO + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_IO_H + +/* struct in_pktinfo.ipi_spec_dst needed for IP_PKTINFO support */ +#cmakedefine HAVE_IPI_SPEC_DST + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LIBGEN_H + +/* Define to 1 if you have the header file. */ +#define HAVE_LIMITS_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_IF_TUN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_SOCKIOS_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_LINUX_TYPES_H + +/* Define to 1 if you have the header file. */ +#define HAVE_LZO_CONF_H + +/* Define to 1 if you have the header file. */ +#define HAVE_LZO1X_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_LZOUTIL_H 1 + +/* Define to 1 if you have the `mlockall' function. */ +#cmakedefine HAVE_MLOCKALL + +/* struct msghdr needed for extended socket error support */ +#cmakedefine HAVE_MSGHDR + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_SYSTM_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NETINET_IP_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_TCP_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_IF_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_IF_TUN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine01 HAVE_NET_IF_UTUN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_NET_TUN_IF_TUN_H + +/* Define to 1 if you have the `nice' function. */ +#undef HAVE_NICE + +/* Define to 1 if you have the `openlog' function. */ +#undef HAVE_OPENLOG + +/* OpenSSL engine support available */ +#undef HAVE_OPENSSL_ENGINE + +/* Define to 1 if you have the `poll' function. */ +#undef HAVE_POLL + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_POLL_H + +/* Define to 1 if you have the `putenv' function. */ +#undef HAVE_PUTENV + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_PWD_H + +/* Define to 1 if you have the `readv' function. */ +#undef HAVE_READV + +/* Define to 1 if you have the `recvmsg' function. */ +#cmakedefine HAVE_RECVMSG +#cmakedefine HAVE_SENDMSG + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_RESOLV_H + +/* sa_family_t, needed to hold AF_* info */ +#cmakedefine HAVE_SA_FAMILY_T + +/* Define to 1 if you have the `sd_booted' function. */ +#undef HAVE_SD_BOOTED + +/* Define to 1 if you have the `setgid' function. */ +#cmakedefine HAVE_SETGID + +/* Define to 1 if you have the `setgroups' function. */ +#undef HAVE_SETGROUPS + +/* Define to 1 if you have the `setsid' function. */ +#undef HAVE_SETSID + +/* Define to 1 if you have the `setsockopt' function. */ +#define HAVE_SETSOCKOPT 1 + +/* Define to 1 if you have the `setuid' function. */ +#cmakedefine HAVE_SETUID + +/* Define to 1 if you have the header file. */ +#undef HAVE_SIGNAL_H + +/* Define to 1 if you have the `socket' function. */ +#undef HAVE_SOCKET + +/* struct sock_extended_err needed for extended socket error support */ +#undef HAVE_SOCK_EXTENDED_ERR + +/* Define to 1 if you have the `stat' function. */ +#define HAVE_STAT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDARG_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDIO_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strsep' function. */ +#undef HAVE_STRSEP + +/* Define to 1 if you have the `syslog' function. */ +#undef HAVE_SYSLOG + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYSLOG_H + +/* Define to 1 if you have the `system' function. */ +#undef HAVE_SYSTEM + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYSTEMD_SD_DAEMON_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_EPOLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_FILE_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_INOTIFY_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_KERN_CONTROL_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKIO_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UIO_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_UN_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_SYS_WAIT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TAP_WINDOWS_H + +/* Define to 1 if you have the `time' function. */ +#define HAVE_TIME 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_UAPI_H + +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VALGRIND_MEMCHECK_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VERSIONHELPERS_H + +/* Define to 1 if you have the `vfork' function. */ +#undef HAVE_VFORK + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFORK_H + +/* Define to 1 if you have the `vsnprintf' function. */ +#undef HAVE_VSNPRINTF + +/* we always assume a recent mbed TLS version */ +#define HAVE_CTR_DRBG_UPDATE_RET 1 + +/* Path to ifconfig tool */ +#define IFCONFIG_PATH "@IFCONFIG_PATH@" + +/* Path to iproute tool */ +#define IPROUTE_PATH "@IPROUTE_PATH@" + +/* Path to route tool */ +#define ROUTE_PATH "@ROUTE_PATH@" + +/* OpenVPN major version - integer */ +#undef OPENVPN_VERSION_MAJOR + +/* OpenVPN minor version - integer */ +#undef OPENVPN_VERSION_MINOR + +/* OpenVPN patch level - may be a string or integer */ +#define OPENVPN_VERSION_PATCH "@OPENVPN_VERSION_PATCH@" + +/* Name of package */ +#define PACKAGE "openvpn" + +/* Define to the address where bug reports for this package should be sent= . */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "OpenVPN" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "OpenVPN @OPENVPN_VERSION_MAJOR@...220...@OPENVPN_V= ERSION_MINOR@@OPENVPN_VERSION_PATCH@" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@OPENVPN_VERSION_MAJOR@...220...@OPENVPN_VERSION_= MINOR@@OPENVPN_VERSION_PATCH@" + +/* OpenVPN major version - integer */ +#define OPENVPN_VERSION_MAJOR @OPENVPN_VERSION_MAJOR@ + +/* OpenVPN minor version - integer */ +#define OPENVPN_VERSION_MINOR @OPENVPN_VERSION_MINOR@ + +/* Path to systemd-ask-password tool */ +#undef SYSTEMD_ASK_PASSWORD_PATH + +/* systemd is newer than v216 */ +#define SYSTEMD_NEWER_THAN_216 + +/* The tap-windows id */ +#define TAP_WIN_COMPONENT_ID "tap0901" + +/* The tap-windows version number is required for OpenVPN */ +#define TAP_WIN_MIN_MAJOR 9 + +/* The tap-windows version number is required for OpenVPN */ +#define TAP_WIN_MIN_MINOR 9 + +/* Are we running on Mac OS X? */ +#cmakedefine TARGET_DARWIN + +/* Are we running on FreeBSD? */ +#cmakedefine TARGET_FREEBSD + +/* Are we running on Linux? */ +#cmakedefine TARGET_LINUX + +/* Are we running WIN32? */ +#cmakedefine TARGET_WIN32 + +#define TARGET_ALIAS "@CMAKE_SYSTEM_NAME@" + +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif + + +#if defined(_WIN32) +#include +typedef uint32_t in_addr_t; +typedef uint16_t in_port_t; + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGUSR1 10 +#define SIGUSR2 12 +#define SIGTERM 15 +#endif + +#if defined(_MSC_VER) +#include +typedef SSIZE_T ssize_t; +#define strncasecmp strnicmp +#define strcasecmp _stricmp + + +#define S_IRUSR 0 +#define S_IWUSR 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#define F_OK 0 +#endif + diff --git a/src/openvpn/lzo.h b/src/openvpn/lzo.h index c572354..f05c002 100644 --- a/src/openvpn/lzo.h +++ b/src/openvpn/lzo.h @@ -37,7 +37,14 @@ * @addtogroup compression * @{ */ - +#if defined(HAVE_LZO_CONF_H) +/* The lzo.h magic gets confused and still wants + * to include lzo/lzoconf.h even if our include paths + * are setup to include the paths without lzo/ include lzoconf.h to + * avoid it being include by lzoutil.h */ +#include +#include +#endif #if defined(HAVE_LZO_LZOUTIL_H) #include #elif defined(HAVE_LZOUTIL_H) -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/322?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: release/2.6 Gerrit-Change-Id: I666314a223d324ca72dbe7ba7d22f764996d3ca2 Gerrit-Change-Number: 322 Gerrit-PatchSet: 1 Gerrit-Owner: stipa Gerrit-Reviewer: flichtenheld Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-Attention: plaisthos Gerrit-Attention: flichtenheld Gerrit-MessageType: newchange --CK9831YH5ZI= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

Attention is currently required from: flichtenheld, plaisthos.

stipa has uploaded this change for review.

View Change=

add basic CMake based build

This helps with IDE integration among o= ther things.

This is a basic implementation for development purposes=
that can't replace any of the existing release builds.

Chang= e-Id: I666314a223d324ca72dbe7ba7d22f764996d3ca2
Signed-off-by: Arne Schw= abe <arne@...1227...>
Signed-off-by: Frank Lichtenheld <frank@...220...= ..2641...>
---
A CMakeLists.txt
A config.h.cmake.in
M src/op= envpn/lzo.h
3 files changed, 1,091 insertions(+), 1 deletion(-)

<= /pre>
<=
span>diff --git a/CMakeLists.txt b/CMakeLists.txt
new file = mode 100644
index 0000000..9978ea4
--- /dev= /null
+++ b/CMakeLists.txt
@@ -0,0 +1,591 @= @
+ cmake_minimum_re= quired(VERSION 3.3)
+= project(openvpn)
+
+# This CMake file impl= ements building OpenVPN with CMAKE
+#
+# N= ote that this is *NOT* the official way to build openvpn on anything=
+# other than Windows/mingw= despite working on other platforms too. You will need
+# to add -DUNSUPPORTED_BUILDS=3Dtrue to = build on non Windows platforms.
+#
+# This= cmake also makes a few assertions like lzo, lz4 being used
+# and OpenSSL having version 1.1.1+= and generally does not offer the same

+# configurability like autoconf
+
+# -DCMAKE_TOOLCHAIN_FILE=3DC:/Users/User/source/repos/vcpkg/scr= ipts/buildsystems/vcpkg.cmake
+#-DVCPKG_OVERLAY_PORTS=3DC:/Users/User/source/repos/openvpn/contr= ib/vcpkg-ports
+#-GNi= nja
+
+option(UNSUPPORTED_BUILDS "All= ow unsupported builds" OFF)
+
+if (NO= T WIN32 AND NOT ${UNSUPPORTED_BUILDS})
+ message(FATAL_ERROR "Note: on Unix platform the= official and supported build method is using autoconfig. CMake based build= should be only used for Windows and internal testing/development.")
+endif()
+

+option(MBED "BUILD with mbed" OFF)<= br>+option(WOLFSSL "BUILD = with wolfSSL" OFF)
+if (MSVC)
+ op= tion(USE_WERROR "Treat compiler warnings as errors (-Werror)" OFF= )
+else ()
= + option(USE_WERROR "Tr= eat compiler warnings as errors (-Werror)" ON)
+endif ()
+option(PLUGIN_DIR "Location of the plugin direc= tory" /usr/local/lib/openvpn/plugins)
+
+# AddressSanitize - use CXX=3Dclang++ CC=3Dclang cmake -DCMAKE_BUILD_TY= PE=3Dasan to build with ASAN
+set(CMAKE_C_FLAGS_ASAN
+ "-fsanitize=3Daddress,undefined -fno-sanitize-reco= ver=3Dall -fno-optimize-sibling-calls -fsanitize-address-use-after-scope -f= no-omit-frame-pointer -g -O1"
+ CACHE STRING "Flags used by the C compiler duri= ng AddressSanitizer builds."
+ FORCE)
+set(CMAKE_CXX_FLAGS_ASAN
+ "-fsanitize=3Daddress,undefined -fno-sanitize-re= cover=3Dall -fno-optimize-sibling-calls -fsanitize-address-use-after-scope = -fno-omit-frame-pointer -g -O1"
+ CACHE STRING "Flags used by the C++ compiler = during AddressSanitizer builds."
+ FORCE)
+
+if (MS= VC)
+ target_compi= le_options(${target} PRIVATE /W3)
+else ()
+ add_compile_options(-Wall -Wuninitialized)
+ # We are not ready for this
+ #add_compile_options(-Wsign-co= mpare)
+endif ()

+
+find_package(PkgConfig)
+INCLUDE(CheckSymbolExists)
= +INCLUDE(CheckIncludeFiles)
+INCLUDE(CheckTypeSize)<= /span>
+INCLUDE(CheckStructH= asMember)
++set(OPENVPN_VERSION_MAJOR 2)<= /span>
+set(OPENVPN_VERSION_= MINOR 6)
+set(OPENVPN= _VERSION_PATCH _git)
= +
+if (NOT WIN32)
+ add_definitions(-DP= LUGIN_LIBDIR=3D\"${PLUGIN_DIR}\")
+endif ()
+
+# TODO= remove later when msvc-config.h is removed and we can always include confi= g.h
+add_definitions(= -DHAVE_CONFIG_H)
+
+
+# Set the various defines for config.h.cm= ake.in
+if (${CMAKE_S= YSTEM_NAME} STREQUAL "Linux")
+ set(TARGET_LINUX YES)
+ set(ENABLE_ASYNC_PUSH YES)
+ set(ENABLE_LINUXDCO YES)+ set(ENABLE_SITNL YES)
+ set(HAVE_DECL_SO_MA= RK YES)
+ set(ENAB= LE_FEATURE_TUN_PERSIST 1)
+ set(HAVE_LINUX_TYPES_H 1)
+ set(ENABLE_DCO YES)
+ set(HAVE_CMSGHDR YES)
+elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeB= SD")
+ set(TA= RGET_FREEBSD YES)
+ = set(ENABLE_DCO YES)
+ link_libraries(-lnv)
+elseif (WIN32)
+ set(ENABLE_DCO YES)
+elseif (APPLE)
= + set(TARGET_DARWIN YES)
+ set(HAVE_NET_IF_UTUN_H YES)
+endif ()
+
+if (UNIX)<= /span>
+ set(PATH_SEPARAT= OR /)
+ set(ENABLE= _PORT_SHARE YES)
+ = set(HAVE_SA_FAMILY_T YES)
+elseif (WIN32)
+ set(PATH_SEPARATOR \\\\)
+ set(TARGET_WIN32 YES)
+endif ()
+
+CHECK_SYMBOL_= EXISTS(chroot unistd.h HAVE_CHROOT)
+CHECK_SYMBOL_EXISTS(chdir unistd.h HAVE_CHDIR)
+CHECK_SYMBOL_EXISTS(dup unistd.h= HAVE_DUP)

+CHECK_SYM= BOL_EXISTS(dup2 unistd.h HAVE_DUP2)
+CHECK_SYMBOL_EXISTS(fork unistd.h HAVE_FORK)
+CHECK_SYMBOL_EXISTS(execve unistd.= h HAVE_EXECVE)

+CHECK= _SYMBOL_EXISTS(ftruncate unistd.h HAVE_FTRUNCATE)
+CHECK_SYMBOL_EXISTS(setgid unistd.h HAVE_SETG= ID)
+CHECK_SYMBOL_EXI= STS(setuid unistd.h HAVE_SETUID)
+CHECK_SYMBOL_EXISTS(getpeereid unistd.h HAVE_GETPEEREID)

+
+CHECK_SYMBOL_EXISTS(epoll_create sys/epoll.h= HAVE_EPOLL_CREATE)
+=
+CHECK_SYMBOL_EXISTS= (gettimeofday sys/time.h HAVE_GETTIMEOFDAY)
+CHECK_SYMBOL_EXISTS(basename libgen.h HAVE_BASENAME= )
+CHECK_SYMBOL_EXIST= S(chsize io.h HAVE_CHSIZE)
+CHECK_SYMBOL_EXISTS(daemon stdlib.h HAVE_DAEMON)
+CHECK_SYMBOL_EXISTS(dirname libgen.h HA= VE_DIRNAME)
+CHECK_SY= MBOL_EXISTS(getrlimit sys/resource.h HAVE_GETRLIMIT)
+CHECK_SYMBOL_EXISTS(mlockall sys/mman.h H= AVE_MLOCKALL)
+
+CHECK_SYMBOL_EXISTS(sendm= sg sys/socket.h HAVE_SENDMSG)
+CHECK_SYMBOL_EXISTS(recvmsg sys/socket.h HAVE_RECVMSG)
= +CHECK_SYMBOL_EXISTS(cmsghdr sy= s/socket.h HAVE_CMSGHDR)
+CHECK_SYMBOL_EXISTS(openlog syslog.h HAVE_OPENLOG)
+CHECK_SYMBOL_EXISTS(syslog syslog.h HAV= E_SYSLOG)
+CHECK_SYMB= OL_EXISTS(getgrnam grp.h HAVE_GETGRNAM)
+CHECK_SYMBOL_EXISTS(getpwnam pwd.h HAVE_GETPWNAM)
+CHECK_SYMBOL_EXISTS(getso= ckname sys/socket.h HAVE_GETSOCKNAME)
+
+#= Some OS (e.g. FreeBSD) need some basic headers to allow
+# including network headers
= +SET(NETEXTRA sys/types.h)
+CHECK_INCLUDE_FILES(&quo= t;${NETEXTRA};netinet/in.h" HAVE_NETINET_IN_H)
+
+if (HAVE_NETINET_IN_H)
+ LIST(APPEND NETEXTRA netinet/in.h)
+endif ()
+
+CHECK_INCLUDE_FILES("${NETEXTRA};netinet/in6.h" HAVE_NETIN= ET_IN_H)
+CHECK_INCLU= DE_FILES(linux/if_tun.h HAVE_LINUX_IF_TUN_H)
+CHECK_INCLUDE_FILES(linux/sockios.h HAVE_LINUX_SOC= KIOS_H)
+CHECK_INCLUD= E_FILES(dlfcn.h HAVE_DLFCN_H)
+CHECK_INCLUDE_FILES(fcntl.h HAVE_FCNTL_H)
+CHECK_INCLUDE_FILES(dmalloc.h HAVE_DMALLO= C_H)
+CHECK_INCLUDE_F= ILES(err.h HAVE_ERR_H)
+CHECK_INCLUDE_FILES(poll.h HAVE_POLL_H)
+CHECK_INCLUDE_FILES(s= ys/socket.h HAVE_SYS_SOCKET_H)
+CHECK_INCLUDE_FILES(sys/time.h HAVE_SYS_TIME_H)
+CHECK_INCLUDE_FILES(netdb.h HAVE_NET= DB_H)
+CHECK_INCLUDE_= FILES(unistd.h HAVE_UNISTD_H)
+CHECK_INCLUDE_FILES(sys/un.h HAVE_SYS_UN_H)
+CHECK_INCLUDE_FILES(libgen.h HAVE_LIBGEN_= H)
+CHECK_INCLUDE_FIL= ES(net/if.h HAVE_NET_IF_H)
+CHECK_INCLUDE_FILES("${NETEXTRA};netinet/ip.h" HAVE_NETINE= T_IP_H)
+CHECK_INCLUD= E_FILES(arpa/inet.h HAVE_ARPA_INET_H)
+CHECK_INCLUDE_FILES(net/if_utun.h HAVE_NET_UTUN_H)=
+CHECK_INCLUDE_FILES(sys/io= ctl.h HAVE_SYS_IOCTL_H)
+CHECK_INCLUDE_FILES(sys/inotify.h HAVE_SYS_INOTIFY_H)
+CHECK_INCLUDE_FILES("${NETEXTRA}= ;sys/uio.h" HAVE_SYS_UIO_H)
+CHECK_INCLUDE_FILES(syslog.h HAVE_SYSLOG_H)
+CHECK_INCLUDE_FILES(sys/wait.h HAVE_SY= S_WAIT_H)
+CHECK_INCL= UDE_FILES(grp.h HAVE_GRP_H)
+CHECK_INCLUDE_FILES(pwd.h HAVE_PWD_H)
+CHECK_INCLUDE_FILES(sys/mman.h HAVE_SYS_MMAN_H)
+
+
+CHECK_INCLUDE_FILES("${NETEXTRA};resolv.h" HAVE_R= ESOLV_H)
+CHECK_INCLU= DE_FILES("${NETEXTRA};net/if_tun.h" HAVE_NET_IF_TUN_H)
= +
+# Is this obscure header needed anywhere?!=
+CHECK_INCLUDE_FILES(netine= t/in_systm.h HAVE_NETINET_IN_SYSTM_H)
+
+<= /span>
+SET(CMAKE_EXTRA_INCL= UDE_FILES netinet/ip.h)
+CHECK_TYPE_SIZE("struct in_pktinfo" IN_PKTINFO)
+CHECK_STRUCT_HAS_MEMBER("str= uct in_pktinfo" ipi_spec_dst netinet/ip.h HAVE_IPI_SPEC_DST)
+CHECK_TYPE_SIZE("struct = msghdr" MSGHDR)
= +SET(CMAKE_EXTRA_INCLUDE_FILES)
+
+find_pr= ogram(IFCONFIG_PATH ifconfig)
+find_program(IPROUTE_PATH ip)
+find_program(ROUTE_PATH route)
+
+
+if (NOT= WIN32)
+ set(ENAB= LE_LZ4 YES)
+ set(= ENABLE_LZO YES)
+endi= f ()
+
+function(add_library_deps target)<= /span>
+ if (${MBED})
+ target_include_= directories(${target} PRIVATE $ENV{HOME}/oss/mbedtls2/include)
+ message("Building $= {target} for mbed TLS")

+ target_link_libraries(${target} PUBLIC -L$ENV{HOME}/oss/mb= edtls2/library -L/usr/local/opt/lzo/lib -lmbedtls -lmbedx509 -lmbedcrypto)<= /span>
+ elseif (${WOLFSS= L})
+ pkg_sear= ch_module(wolfssl wolfssl REQUIRED)
+ target_link_libraries(${target} PUBLIC ${wolfssl_LI= NK_LIBRARIES})
+ = target_include_directories(${target} PRIVATE ${wolfssl_INCLUDE_DIRS}/wol= fssl)
+ messag= e("Building ${target} for WolfSSL: ${wolfssl_LINK_LIBRARIES} ${wolfssl= _INCLUDE_DIRS}/wolfsll")
+ else ()
+ set(ENABLE_X509ALTUSERNAME YES)
+
+ target_link_libraries(${target} PUBLIC OpenSS= L::SSL)
+
<= span style=3D"color: hsl(120, 100%, 40%);">+ message("Building = ${target} for default OpenSSL")

+ endif ()
+
++ if (${ENABLE_LZ4})
+ pkg_search_module= (liblz4 liblz4 REQUIRED IMPORTED_TARGET)
+ target_link_libraries(${target} PUBLIC PkgConf= ig::liblz4)
+ endi= f ()
+
+ if (${ENABLE_LZO})

<= span style=3D"color: hsl(120, 100%, 40%);">+ pkg_search_module(lzo2 = lzo2 REQUIRED IMPORTED_TARGET)

+ target_link_libraries(${target} PUBLIC PkgConfig::lzo2)<= /span>
+ endif ()<= br>+
+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Li= nux")
+ t= arget_include_directories(${target} PUBLIC ${LIBNL_INCLUDE_DIRS})+ target_link_libraries= (${target} PUBLIC ${LIBNL_LIBRARIES})
+ endif ()
+
+ if (= USE_WERROR)
+ = if (MSVC)
+ = target_compile_options(${target} PRIVATE /WX)
+ else ()
+ target_compile_options(${target} PRIVAT= E -Werror)
+ e= ndif ()
+ endif ()=
+endfunction()
+
+if (${MBED})
+ set(ENABLE_CRYPTO_MBEDTLS YES)
+elseif (${WOLFSSL})
+ set(ENABLE_CRYPTO_OPENSSL YES)
+ set(ENABLE_CRYPTO= _WOLFSSL YES)
+ se= t(ENABLE_X509ALTUSERNAME YES)
+else ()
+ = set(ENABLE_CRYPTO_OPENSSL YES)
+ set(ENABLE_X509ALTUSERNAME YES)
+endif ()
+
+i= nclude_directories(${CMAKE_CURRENT_SOURCE_DIR} src/compat include)+
+if (WIN32)
+ find_package(OpenSSL REQUIRED)
+
+ link_libraries(OpenSSL::SSL OpenSSL::Crypto ws2_32.lib C= rypt32.lib fwpuclnt.lib iphlpapi.lib
+ wininet.lib setupapi.lib rpcrt4.lib wtsapi32.l= ib Ncrypt.lib)
+ a= dd_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D _WI= NSOCK_DEPRECATED_NO_WARNINGS -D_CONSOLE)
+endif ()
+
+configure= _file(config.h.cmake.in config.h)
+configure_file(include/openvpn-plugin.h.in openvpn-plugin.h)<= /span>
+
+include_directories(${CMAKE_CURRENT_BIN= ARY_DIR})
++set(SOURCE_FILES
+ ${CMAKE_CURRENT_BINARY_D= IR}/config.h

+ = ${CMAKE_CURRENT_BINARY_DIR}/openvpn-plugin.h
+
+ src/compat/compat-basename.c
+ src/compat/compat-daemon.c
+ src/compat/compat-dirname.c<= /span>
+ src/compat/c= ompat-gettimeofday.c
= + src/compat/compat-strsep.c
+ src/compat/compat-versionhelpers.h
+ src/openvpn/argv.c+ src/openvpn/argv.h
+ src/openvpn/ba= se64.c
+ src/o= penvpn/base64.h
+ = src/openvpn/basic.h
+ src/openvpn/block_dns.h
+ src/openvpn/block_dns.c
+ src/openvpn/buffer.c
+ src/openvpn/buffer.h+ src/openvpn/circ_list= .h
+ src/openv= pn/clinat.c
+ = src/openvpn/clinat.h
= + src/openvpn/common.h
+ src/openvpn/comp-lz4.c
+ src/openvpn/comp-lz4.h
+ src/openvpn/comp.c
+ src/openvpn/comp.h
<= br>+ src/openvpn/compstu= b.c
+ src/open= vpn/console.c
+ = src/openvpn/console_builtin.c
+ src/openvpn/console.h
+ src/openvpn/crypto.c
+ src/openvpn/crypto.h
+ src/openvpn/crypto_backend.= h

+ src/openvp= n/crypto_openssl.c
+ = src/openvpn/crypto_openssl.h
+ src/openvpn/crypto_mbedtls.c
+ src/openvpn/crypto_mbedtls.h
+ src/openvpn/cryp= toapi.c
+ src/= openvpn/cryptoapi.h
+= src/openvpn/dco.c
+ src/openvpn/dco.h
+ src/openvpn/dco_win.c
+ src/openvpn/dco_win.h
+ src/openvpn/dco_linux.c+ src/openvpn/dco_linux= .h
+ src/openv= pn/dco_freebsd.c
+ = src/openvpn/dco_freebsd.h
+ src/openvpn/dhcp.c
+ src/openvpn/dhcp.h
+ src/openvpn/dns.c
+ src/openvpn/dns.h
+ src/openvpn/errlevel.h<= br>+ src/openvpn/env_set= .c
+ src/openv= pn/env_set.h
+ = src/openvpn/error.c
= + src/openvpn/error.h
+ src/openvpn/event.c
+ src/openvpn/event.h
+ src/openvpn/fdmisc.c
+ src/openvpn/fdmisc.h
+ src/openvpn/forward.c
+ src/openvpn/fo= rward.h
+ src/= openvpn/fragment.c
+ = src/openvpn/fragment.h
+ src/openvpn/gremlin.c
+ src/openvpn/gremlin.h
+ src/openvpn/helper.c
+ src/openvpn/helper.h<= br>+ src/openvpn/httpdig= est.c
+ src/op= envpn/httpdigest.h
+ = src/openvpn/init.c
+ src/openvpn/init.h
+ src/openvpn/integer.h
+ src/openvpn/interval.c
+ src/openvpn/interval.h
= + src/openvpn/list.c
+ src/openvpn/lis= t.h
+ src/open= vpn/lladdr.c
+ = src/openvpn/lladdr.h
+ src/openvpn/lzo.c
+ src/openvpn/lzo.h
+ src/openvpn/manage.c
+ src/openvpn/manage.h
+ src/openvpn/mbuf.c
+ src/openvpn/mbuf.h
<= br>+ src/openvpn/memdbg.= h
+ src/openvp= n/misc.c
+ src= /openvpn/misc.h
+ = src/openvpn/mroute.c
+ src/openvpn/mroute.h
+ src/openvpn/mss.c
+ src/openvpn/mss.h
+ src/openvpn/mstats.c
+ src/openvpn/mstats.h
<= span style=3D"color: hsl(120, 100%, 40%);">+ src/openvpn/mtcp.c
+ src/openvpn/mtcp= .h
+ src/openv= pn/mtu.c
+ src= /openvpn/mtu.h
+ = src/openvpn/mudp.c
+ src/openvpn/mudp.h
+ src/openvpn/multi.c
+ src/openvpn/multi.h
+ src/openvpn/ntlm.c
+ src/openvpn/ntlm.h
+ src/openvpn/occ.c
+ src/openvpn/occ.h
+ src/openvpn/op= envpn.c
+ src/= openvpn/openvpn.h
+ = src/openvpn/options.c
+ src/openvpn/options.h
+ src/openvpn/options_util.c
+ src/openvpn/options_util.h=
+ src/openvpn/otime.= c
+ src/openvp= n/otime.h
+ sr= c/openvpn/ovpn_dco_win.h
+ src/openvpn/packet_id.c
+ src/openvpn/packet_id.h
+ src/openvpn/perf.c
+ src/openvpn/perf.h
+ src/openvpn/ping.c
+ src/openvpn/ping.= h
+ src/openvp= n/pkcs11.c
+ s= rc/openvpn/pkcs11.h
+= src/openvpn/pkcs11_backend.h
+ src/openvpn/pkcs11_openssl.c
+ src/openvpn/pkcs11_mbedtls.c
+ src/openvpn/plat= form.c
+ src/o= penvpn/platform.h
+ = src/openvpn/plugin.c
+ src/openvpn/plugin.h
+ src/openvpn/pool.c
+ src/openvpn/pool.h
+ src/openvpn/proto.c
+ src/openvpn/proto.h+ src/openvpn/proxy.c
+ src/openvpn/p= roxy.h
+ src/o= penvpn/ps.c
+ = src/openvpn/ps.h
+ = src/openvpn/push.c
+ src/openvpn/push.h
+ src/openvpn/pushlist.h
+ src/openvpn/reliable.c
+ src/openvpn/reliable.h
= + src/openvpn/route.c

+ src/openvpn/ro= ute.h
+ src/op= envpn/run_command.c
+= src/openvpn/run_command.h
+ src/openvpn/schedule.c
+ src/openvpn/schedule.h
+ src/openvpn/session_id.c=
+ src/openvpn/sessio= n_id.h
+ src/o= penvpn/shaper.c
+ = src/openvpn/shaper.h
+ src/openvpn/sig.c
+ src/openvpn/sig.h
+ src/openvpn/socket.c
+ src/openvpn/socket.h
+ src/openvpn/socks.c
+ src/openvpn/socks.h
+ src/openvpn/ssl.= c
+ src/openvp= n/ssl.h
+ src/= openvpn/ssl_backend.h
+ src/openvpn/ssl_common.h
+ src/openvpn/ssl_openssl.c
+ src/openvpn/ssl_openssl.h
+ src/openvpn/ssl_mbedtls.= c

+ src/openvp= n/ssl_mbedtls.h
+ = src/openvpn/ssl_verify.c
+ src/openvpn/ssl_verify.h
+ src/openvpn/ssl_verify_backend.h
+ src/openvpn/ssl_verify_o= penssl.c

+ src= /openvpn/ssl_verify_openssl.h
+ src/openvpn/ssl_verify_mbedtls.c
+ src/openvpn/ssl_verify_mbedtls.h
+ src/openvpn/sta= tus.c
+ src/op= envpn/status.h
+ = src/openvpn/syshead.h
+ src/openvpn/tls_crypt.c
+ src/openvpn/tun.c
+ src/openvpn/tun.h
+ src/openvpn/networking_sitnl.c<= br>+ src/openvpn/network= ing_freebsd.c
+ = src/openvpn/auth_token.c
+ src/openvpn/auth_token.h
+ src/openvpn/ssl_ncp.c
+ src/openvpn/ssl_ncp.h
+ src/openvpn/ssl_pkt.c
+ src/openvpn/ssl_p= kt.h
+ src/ope= nvpn/ssl_util.c
+ = src/openvpn/ssl_util.h
+ src/openvpn/vlan.c
+ src/openvpn/vlan.h
+ src/openvpn/win32.c
+ src/openvpn/win32-util.c
+ src/openvpn/win32.h
+ src/openvpn/win32= -util.h
+ src/= openvpn/xkey_helper.c
+ src/openvpn/xkey_provider.c
+ )
+
+add_executa= ble(openvpn ${SOURCE_FILES})
+
+add_librar= y_deps(openvpn)
+

+if (${CMAKE_SYSTEM_NAME= } STREQUAL "Linux")
+ target_link_libraries(openvpn PUBLIC -ldl)
+
+ find_package(PkgConfig)
+ pkg_search_module(LIBNL REQUIRED libnl-genl-3= .0)
+
+ target_link_libraries(openvpn P= UBLIC ${LIBNL_LIBRARIES})

+ target_include_directories(openvpn PRIVATE ${LIBNL_INCLUDE_DIRS})=
+endif ()
= +
+
+if (MINGW)
+ = target_link_options(openvpn PRIVATE -municode)
+endif ()
+
+i= f (NOT WIN32)
+ fi= nd_library(resolv resolv)
+ # some platform like BSDs already include resolver functionality = in the libc and not have an extra resolv library
+ if (${resolv} OR APPLE)
+ target_link_libraries(openvpn = PUBLIC -lresolv)
+ = endif ()
+endif ()
+
+
+pkg_search_module(cmocka cmocka REQUIRED IMPORTED_TARGET)
+enable_testing()
+
+SET(unit_tests "test_packet_id"= "test_crypto" "test_ncp" "test_auth_token" &= quot;test_misc" "test_buffer" "test_provider" &quo= t;test_pkt")
+
+# These tests work on= only on Linux since they depend on special linker features
+if (WIN32)

+ LIST(APPEND unit_tests "test_crypto= api")
+elseif ($= {CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+ LIST(APPEND unit_tests "test_networkin= g" "test_tls_crypt" "test_argv")
+endif ()
+
+
+FOREACH (te= st_name ${unit_tests})
+ tests/unit_tests/openvpn/${test_name}.c+ tests/unit_tests= /openvpn/mock_msg.c
+= src/openvpn/platform.c
+ src/openvpn/crypto_mbedtls.c
+ src/openvpn/crypto_openssl.= c
+ src/op= envpn/crypto.c
+ = src/openvpn/otime.c
+ src/openvpn/packet_id.c
+ src/openvpn/base64.c
+ src/openvpn/win32-util.c
+ src/openvp= n/mtu.c
+ = src/openvpn/networking_sitnl.c
+ src/compat/compat-strsep.c
+ src/compat/compat-gettimeofday.c<= /span>
+ src/open= vpn/ssl_util.c
+ = src/openvpn/reliable.c
+ src/openvpn/session_id.c
+ src/openvpn/mss.c
+ src/openvpn/xkey_provider.= c
+ )
+
+ add_library_deps(${test_name})=
+ target_link_libraries(= ${test_name} PUBLIC PkgConfig::cmocka)
+
+= target_include_directories(${test_name} PRIVATE src/openvpn)
= +
+ if (NOT ${test_name} STREQUAL "test_buff= er")
+ ta= rget_sources(${test_name} PRIVATE
+ src/openvpn/buffer.c
+ )
+ endif ()
+ add_test(NAME ${test_name} COMMAND ${test_name})<= /span>
+ENDFOREACH ()=
+
+target_sources(test_pkt PRIVATE
+ src/openvpn/argv.c
=
+ src/openvpn/env_se= t.c
+ src/open= vpn/reliable.c
+ = src/openvpn/run_command.c
+ src/openvpn/session_id.c
+ src/openvpn/ssl_pkt.c
+ src/openvpn/tls_crypt.c+ )
+
+if (TARGET test_cryptoapi)
+ target_sources(test_cryptoapi PRIVATE+ src/openvpn/xkey_= helper.c
+ = src/openvpn/xkey_provider.c
+ )
+<= br>+target_sources(test_provide= r PRIVATE
+ sr= c/openvpn/xkey_provider.c
+ src/openvpn/xkey_helper.c
+ )
+
+target_so= urces(test_misc PRIVATE
+ src/openvpn/options_util.c
+ )
+
+IF (TARGET= test_tls_crypt)
+ = target_sources(test_tls_crypt PRIVATE
+ src/openvpn/argv.c
+ src/openvpn/env_set.c
<= span style=3D"color: hsl(120, 100%, 40%);">+ src/openvpn/run_com= mand.c)

+endif ()
+
+if (TARGET test_argv)
+ target_sources(test_argv PRIVATE
+ src/openvp= n/argv.c
+ = src/openvpn/env_set.c
+endif ()
+
+<= br>+FOREACH (test_name "ne= tworking" "tls_crypt" "argv")
+ if (TARGET test_${test_name})=
+ target_link_option= s(test_${test_name} PRIVATE -Wl,--wrap=3Dparse_line)
+ endif ()
+ENDFOREACH ()
+
+if (TARGET test_tls_crypt)
+ target_link_options("test_tls_crypt" PRIVATE<= br>+ -Wl,--wrap=3Dbu= ffer_read_from_file
+= -Wl,--wrap=3Dbuffer_write_file
+ -Wl,--wrap=3Drand_bytes)
+ENDIF ()

\ No newli= ne at end of file
diff --git a/config.h.cmake.in b/config.h= .cmake.in
new file mode 100644
index 000000= 0..6185971
--- /dev/null
+++ b/config.h.cma= ke.in
@@ -0,0 +1,492 @@
+
= +/* Configuration settings */
+#define CONFIGURE_DEFINES "N/A"
+
+/* Enable async push */
+#cmakedefine ENABLE_ASYNC_PUSH
+
+/* Use mbed TLS library */
+#cmakedefine ENABLE_CRYPTO_MBEDTLS
+
+/* Use Openssl */
+#cmakedefine ENABLE_CRYPTO_OPENSSL
+
+/* Use wolfSSL crypto library */
+#cmakedefine ENABLE_CRYPTO_WOLFSSL
+
+/* Enable shared data channel offload */
+#cmakedefine ENABLE_DCO
+

+/* Enable debugging support (needed for verb>=3D= 4) */
+#define ENABLE= _DEBUG 1
+
= +/* We have persist tun capabil= ity */
+#cmakedefine = ENABLE_FEATURE_TUN_PERSIST
+
+/* Enable in= ternal fragmentation support */
+#define ENABLE_FRAGMENT 1
+
+/= * Enable linux data channel offload */
+#cmakedefine ENABLE_LINUXDCO
+
+/* Enable LZ4 compression library */
+#cmakedefine ENABLE_LZ4
+
+/* Enable LZO compression library */
+#cmakedefine ENABLE_LZO
+
+/* Enable management server capability */
+#define ENABLE_MANAGEMENT 1
= +
+/* Enable OFB and CFB cipher modes */
<= span style=3D"color: hsl(120, 100%, 40%);">+#define ENABLE_OFB_CFB_MODE
+
+/* Enable PKCS11 */
+/* #undef ENABLE_PKCS11 */
+

+/* Enable plug-in support */
+#define ENABLE_PLUGIN 1
+
+/* Enable TCP Server port sharing */
+#cmakedefine ENABLE_PORT_SHARE
= +
+/* SELinux support */
+#cmakedefine ENABLE_SELINUX
+
+/* enable sitnl support */
+#cmakedefine ENABLE_SITNL
+
+/* Enable systemd integration */
+/* #undef ENABLE_SYSTEMD */
+
+/* Enable --x509-username-field feature */
+#cmakedefine ENABLE_X509ALTUSERNAME
+
+/* Compiler supports anonymous unions */=
+#define HAVE_ANONYM= OUS_UNION_SUPPORT
+
+/* Define to 1 if you= have the <arpa/inet.h> header file. */
+#cmakedefine HAVE_ARPA_INET_H 1
+
+/* Define to 1 if you have the `basename' function. = */
+#cmakedefine HAVE= _BASENAME
++/* Define to 1 if you have th= e `chdir' function. */
+#cmakedefine HAVE_CHDIR
+
+/* Defin= e to 1 if you have the `chroot' function. */
+#cmakedefine HAVE_CHROOT
+
+/* Define to 1 if you have the `chsize' function. */
+#cmakedefine HAVE_CHSIZ= E
+
+/* struct cmsghdr needed for extended= socket error support */
+#cmakedefine HAVE_CMSGHDR
+
+/* Defin= e to 1 if you have the `daemon' function. */
+#cmakedefine HAVE_DAEMON
+
+/* Define to 1 if you have the declaration of `SO_MARK',= and to 0 if you
+don= 't. */
+#cmakedef= ine01 HAVE_DECL_SO_MARK
+
+/* Define to 1 = if you have the <direct.h> header file. */
+#cmakedefine HAVE_DIRECT_H
+
+/* Define to 1 if you have the `dirname' function. */<= /span>
+#cmakedefine HAVE_DI= RNAME
+
+/* Define to 1 if you have the &l= t;dlfcn.h> header file. */

+#cmakedefine HAVE_DLFCN_H
+
+/* = Define to 1 if you have the <dmalloc.h> header file. */
+#cmakedefine HAVE_DMALLOC_H
+
+/* Define to 1 if you have the `dup' fun= ction. */
+#cmakedefi= ne HAVE_DUP
+<= br>+/* Define to 1 if you have = the `dup2' function. */
+#cmakedefine HAVE_DUP2
+
+/* Defin= e to 1 if you have the `epoll_create' function. */
+#cmakedefine HAVE_EPOLL_CREATE+
+/* Define to 1 if you have the <err.h> hea= der file. */
+#cmaked= efine HAVE_ERR_H
+
+/* Crypto library supp= orts keying material exporter */
+#define HAVE_EXPORT_KEYING_MATERIAL 1
+
+/* Define to 1 if you have the <fcntl.h> header file. */<= /span>
+#cmakedefine HAVE_FC= NTL_H
+
+/* Define to 1 if you have the `f= ork' function. */

+#cmakedefine HAVE_FORK
+#cmakedefine HAVE_EXECVE
+
+/* Define= to 1 if you have the `ftruncate' function. */
+#cmakedefine HAVE_FTRUNCATE
+
+/* Define to 1 if you have the `getgrnam' function.= */
+#cmakedefine HAV= E_GETGRNAM
++/* Define to 1 if you have t= he `getpeereid' function. */
+#cmakedefine HAVE_GETPEEREID
+
+#cmakedefine HAVE_GETPWNAM=
+
+/* Define to 1 if you have the `getrlimit'= ; function. */
+#unde= f HAVE_GETRLIMIT
+
+/* Define to 1 if you = have the `getsockname' function. */
+#cmakedefine HAVE_GETSOCKNAME
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#cmakedefine HAVE_GET= TIMEOFDAY
++/* Define to 1 if you have th= e <grp.h> header file. */
+#cmakedefine HAVE_GRP_H
+
+/* = struct in_pktinfo needed for IP_PKTINFO support */
+#cmakedefine HAVE_IN_PKTINFO
+

+/* Define to 1 if you have the <io.h> header fil= e. */
+#cmakedefine H= AVE_IO_H
+
= +/* struct in_pktinfo.ipi_spec_= dst needed for IP_PKTINFO support */
+#cmakedefine HAVE_IPI_SPEC_DST
+
+/* Define to 1 if you have the <libgen.h> header file. */
+#cmakedefine HAVE_LIBG= EN_H
+
+/* Define to 1 if you have the <= ;limits.h> header file. */

+#define HAVE_LIMITS_H 1
+
+/* De= fine to 1 if you have the <linux/if_tun.h> header file. */
= +#cmakedefine HAVE_LINUX_IF_TUN= _H
+
+/* Define to 1 if you have the <l= inux/sockios.h> header file. */
+#cmakedefine HAVE_LINUX_SOCKIOS_H
+
+/* Define to 1 if you have the <linux/types.h> header file.= */
+#cmakedefine HAV= E_LINUX_TYPES_H
+

+/* Define to 1 if you h= ave the <lzoconf.h> header file. */
+#define HAVE_LZO_CONF_H
+
+/* Define to 1 if you have the <lzo1x.h> header file. */
+#define HAVE_LZO1X_H 1
+
+/* Define to 1 if you have the <lzouti= l.h> header file. */
+#define HAVE_LZOUTIL_H 1
+
+/* Define = to 1 if you have the `mlockall' function. */
+#cmakedefine HAVE_MLOCKALL
+
+/* struct msghdr needed for extended socket error support = */
+#cmakedefine HAVE= _MSGHDR
+
<= span style=3D"color: hsl(120, 100%, 40%);">+/* Define to 1 if you have the = <netdb.h> header file. */

+#cmakedefine HAVE_NETDB_H
+
+/= * Define to 1 if you have the <netinet/in.h> header file. */+#cmakedefine HAVE_NETINET_IN= _H
+
+/* Define to 1 if you have the <n= etinet/in_systm.h> header file. */
+#undef HAVE_NETINET_IN_SYSTM_H
+
+/* Define to 1 if you have the <netinet/ip.h> header file. = */
+#cmakedefine HAVE= _NETINET_IP_H
+
+/* Define to 1 if you hav= e the <netinet/tcp.h> header file. */
+#undef HAVE_NETINET_TCP_H
+
+/* Define to 1 if you have the <net/if.h> header file. */<= /span>
+#cmakedefine HAVE_NE= T_IF_H
+
+/* Define to 1 if you have the &= lt;net/if_tun.h> header file. */

+#cmakedefine HAVE_NET_IF_TUN_H
+
+/* Define to 1 if you have the <net/if_utun.h> header file. *= /
+#cmakedefine01 HAV= E_NET_IF_UTUN_H
+
+/* Define to 1 if you h= ave the <net/tun/if_tun.h> header file. */
+#cmakedefine HAVE_NET_TUN_IF_TUN_H
<= span style=3D"color: hsl(120, 100%, 40%);">+

+/* Define to 1 if you have the `nice' function= . */
+#undef HAVE_NIC= E
+
+/* Define to 1 if you have the `openl= og' function. */
= +#undef HAVE_OPENLOG
= +
+/* OpenSSL engine = support available */
= +#undef HAVE_OPENSSL_ENGINE
+
+/* Define t= o 1 if you have the `poll' function. */
+#undef HAVE_POLL
+
+/* Define to 1 if you have the <poll.h> header file. */
<= span style=3D"color: hsl(120, 100%, 40%);">+#cmakedefine HAVE_POLL_H
=
+
+/* Define to 1 if you have the `putenv' f= unction. */
+#undef H= AVE_PUTENV
++/* Define to 1 if you have t= he <pwd.h> header file. */
+#cmakedefine HAVE_PWD_H
+
+/*= Define to 1 if you have the `readv' function. */
+#undef HAVE_READV
+
+/* Define to 1 if you have the `recvmsg' function. */
+#cmakedefine HAVE_RECV= MSG
+#cmakedefine HAV= E_SENDMSG
++/* Define to 1 if you have th= e <resolv.h> header file. */
+#cmakedefine HAVE_RESOLV_H
+
+#cmakedefine HAVE_SA_FAMILY_T
+
+/* Define to 1 if you have the `sd_booted' function. = */
+#undef HAVE_SD_BO= OTED
+
+/* Define to 1 if you have the `se= tgid' function. */

+
+/* Define t= o 1 if you have the `setgroups' function. */
+#undef HAVE_SETGROUPS
+
+/* Define to 1 if you have the `setsid' function. */=
+#undef HAVE_SETSID<= br>+
+/* Define to 1 if you have the `setsockopt'= ; function. */
+#defi= ne HAVE_SETSOCKOPT 1
= +
+/* Define to 1 if = you have the `setuid' function. */
+#cmakedefine HAVE_SETUID
+
+/* Define to 1 if you have the <signal.h> header file. */=
+#undef HAVE_SIGNAL_H
+
+/* Define to 1 if you have the `socket' = function. */
+#undef = HAVE_SOCKET
+<= br>+/* struct sock_extended_err= needed for extended socket error support */
+#undef HAVE_SOCK_EXTENDED_ERR
+
+/* Define to 1 if you have the `stat' function. */
+#define HAVE_STAT 1
+
+/* Define to 1 if you have the <stdarg= .h> header file. */
+
+/* Define to= 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdio.h> header fi= le. */
+#define HAVE_= STDIO_H 1
++/* Define to 1 if you have th= e <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+= /* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the <strings.h> header fi= le. */
+#define HAVE_= STRINGS_H 1
+<= br>+/* Define to 1 if you have = the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the `strsep' function. */
+#undef HAVE_STRSEP
+
+/* Define to 1 if you have the `syslog' function. */=
+#undef HAVE_SYSLOG<= /span>
+
+/* Define to 1 if you have the <sysl= og.h> header file. */
+#cmakedefine HAVE_SYSLOG_H
+
+/* Defi= ne to 1 if you have the `system' function. */
+#undef HAVE_SYSTEM
+
+/* Define to 1 if you have the <systemd/sd-daemon.h> header= file. */
+#undef HAV= E_SYSTEMD_SD_DAEMON_H
+
+/* Define to 1 if= you have the <sys/epoll.h> header file. */
+#cmakedefine HAVE_SYS_EPOLL_H
+

+/* Define to 1 if you have the <sys/file.h> head= er file. */
+#undef H= AVE_SYS_FILE_H
+
+/* Define to 1 if you ha= ve the <sys/inotify.h> header file. */
+#cmakedefine HAVE_SYS_INOTIFY_H
+
+/* Define to 1 if you have the <sys/ioctl.h> header= file. */
+#cmakedefi= ne HAVE_SYS_IOCTL_H
+=
+/* Define to 1 if y= ou have the <sys/kern_control.h> header file. */
+#undef HAVE_SYS_KERN_CONTROL_H+
+/* Define to 1 if you have the <sys/mman.h>= ; header file. */
+#c= makedefine HAVE_SYS_MMAN_H
+
+/* Define to= 1 if you have the <sys/socket.h> header file. */
+#cmakedefine HAVE_SYS_SOCKET_H+
+/* Define to 1 if you have the <sys/sockio.h= > header file. */
= +#undef HAVE_SYS_SOCKIO_H
+
+/* Define to = 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+

+/* Define to 1 if you have the <sys/time.h> head= er file. */
+#cmakede= fine HAVE_SYS_TIME_H
= +
+/* Define to 1 if = you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/uio.h> header file= . */
+#cmakedefine HA= VE_SYS_UIO_H
+=
+/* Define to 1 if you have= the <sys/un.h> header file. */
+#cmakedefine HAVE_SYS_UN_H
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#cmakedefine HAVE_SYS_W= AIT_H
+
+/* Define to 1 if you have the &l= t;tap-windows.h> header file. */

+#undef HAVE_TAP_WINDOWS_H
+
+#define HAVE_TIME 1
+
+/* Define to 1 if you have the <time.h> header fil= e. */
+#define HAVE_T= IME_H 1
+
<= span style=3D"color: hsl(120, 100%, 40%);">+/* Define to 1 if you have the = <uapi.h> header file. */

+#undef HAVE_UAPI_H
+
+/* Define= to 1 if you have the <unistd.h> header file. */
+#cmakedefine HAVE_UNISTD_H
+

+/* Define to 1 if you have the <valgrind/memcheck= .h> header file. */
+
+/* D= efine to 1 if you have the <versionhelpers.h> header file. */<= br>+#undef HAVE_VERSIONHELPERS_= H
+
+/* Define to 1 if you have the `vfork= ' function. */
+#= undef HAVE_VFORK
+
+/* Define to 1 if you = have the <vfork.h> header file. */
+#undef HAVE_VFORK_H
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#undef HAVE_VSNPRINTF

<= span style=3D"color: hsl(120, 100%, 40%);">+

+/* we always assume a recent mbed TLS version */
+#define HAVE_CTR_DRBG= _UPDATE_RET 1
+
+/* Path to ifconfig tool = */
+#define IFCONFIG_= PATH "@IFCONFIG_PATH@"
+
+/* Pat= h to iproute tool */
= +#define IPROUTE_PATH "@IPROUTE_PATH@"
+
+/* Path to route tool */
+#define ROUTE_PATH "@ROUTE_PATH@"
+
+/* OpenVPN major version - integer */
+#undef OPENVPN_VERSION_MAJOR+
+/* OpenVPN minor version - integer */+#undef OPENVPN_VERSION_MINOR<= /span>
+
+/* OpenVPN patch level - may be a strin= g or integer */
+#def= ine OPENVPN_VERSION_PATCH "@OPENVPN_VERSION_PATCH@"
+

+/* Name of package */
+#define PACKAGE "openvpn"
+

+/* Define to the address where bug reports for this p= ackage should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Defin= e to the full name of this package. */
+#define PACKAGE_NAME "OpenVPN"
+

+/* Define to the full name and version of this package= . */
+#define PACKAGE= _STRING "OpenVPN @OPENVPN_VERSION_MAJOR@...220...@OPENVPN_VERSION_MINO= R@@OPENVPN_VERSION_PATCH@"
+
+/* Defi= ne to the version of this package. */
+#define PACKAGE_VERSION "@OPENVPN_VERSION_MAJOR@...1665...= 20...@...2740...@@OPENVPN_VERSION_PATCH@"
+
+/* OpenVPN major version - integer */
+#define OPENVPN_VERSION_MAJOR @OPENVPN= _VERSION_MAJOR@
+
+/* OpenVPN minor versio= n - integer */
+#defi= ne OPENVPN_VERSION_MINOR @OPENVPN_VERSION_MINOR@
+
+/* Path to systemd-ask-password tool */
+#undef SYSTEMD_ASK_PASSWORD_PATH
+

+/* systemd is newer than v216 */
+#define SYSTEMD_NEWER_THAN_216<= br>+
+/* The tap-windows id */
+#define TAP_WIN_COMPONENT_ID "tap090= 1"
+
<= span style=3D"color: hsl(120, 100%, 40%);">+/* The tap-windows version numb= er is required for OpenVPN */

+#define TAP_WIN_MIN_MAJOR 9
+
+/= * The tap-windows version number is required for OpenVPN */
+#define TAP_WIN_MIN_MINOR 9
<= br>+
+/* Are we running on Mac OS X? */
+#cmakedefine TARGET_DARWIN
+
+/* Are we running on FreeBSD? */
<= span style=3D"color: hsl(120, 100%, 40%);">+#cmakedefine TARGET_FREEBSD
+
+/* Are we running on Linux? */
= +#cmakedefine TARGET_LINUX
+
+/* Are we running WIN32? */
+#cmakedefine TARGET_WIN32
<= br>+
+#define TARGET_ALIAS "@CMAKE_SYSTEM_NAME@= "
+
+/* Enable GNU extensions on syst= ems that have them. */

+#ifndef _GNU_SOURCE
+# define _GNU_SOURCE 1
+#endif
+
+
+#if defined(_WIN32)
+#include <inttypes.h>
+typedef uint32_t in_addr_t;+typedef uint16_t in_port_t;<= /span>
+
+#define SIGHUP 1
+#define SIGINT 2
+#define SIGUSR1 10
+#define SIGUSR2 12
+#define SIGTERM 15
+#endif
+
+#if defined(_MSC_VER)
+#include <BaseTsd.h>
+typedef SSIZE_T ssize_t;
+#define strncasecmp strnicmp
+#define strcasecmp _stricmp
+
+
+= #define S_IRUSR 0
+#d= efine S_IWUSR 0
+#def= ine R_OK 4
+#define W= _OK 2
+#define X_OK 1=
+#define F_OK 0
+#endif
+
diff --git a/src/ope= nvpn/lzo.h b/src/openvpn/lzo.h
index c572354..f05c002 10064= 4
--- a/src/openvpn/lzo.h
+++ b/src/openvpn= /lzo.h
@@ -37,7 +37,14 @@
* @addtogroup c= ompression
* @{
*/
-
+#if defined(HAVE_LZO_CONF_H)
+/* The lzo.h magic gets confused and still wants
+ * to include lzo/lzoco= nf.h even if our include paths
+ * are setup to include the paths without lzo/ include lzoconf.h= to
+ * avoid it bein= g include by lzoutil.h */
+#include <lzodefs.h>
+#include <lzoconf.h>
+#endif
#if defined(HAVE_LZO_LZOUTIL_H)=
#include <lzo/lzoutil.h>
#elif def= ined(HAVE_LZOUTIL_H)

To view, visit change 322. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: release/2.6
Gerrit-Change-Id: I666314a223d324ca72dbe7ba7d2= 2f764996d3ca2
Gerrit-Change-Number: 322
Gerrit-PatchSet: 1
Gerrit-Owner: stipa <lstipakov@...277...>= ;
Gerrit-Reviewer: flichtenheld <frank@...2716...= 1...>
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-Attention: plaisthos <arne-openvpn@...220...= ..1227...>
Gerrit-Attention: flichtenheld <frank@...2375...= 41...>
Gerrit-MessageType: newchange
--CK9831YH5ZI=--