From 0e610292315da12a1e5ed5108377e5d000dda813 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 8 Mar 2026 19:55:59 +0300 Subject: [PATCH] 1 --- configure.ac | 14 -------------- src/Makefile.am | 8 +++++--- src/tun_freebsd.c | 4 ++++ src/tun_linux.c | 4 ++++ src/tun_windows.c | 5 +++++ 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/configure.ac b/configure.ac index 278a9a0..14653c3 100644 --- a/configure.ac +++ b/configure.ac @@ -81,20 +81,6 @@ AC_MSG_RESULT([$os_freebsd]) AM_CONDITIONAL([OS_FREEBSD], [test "x$os_freebsd" = "xyes"]) -# Set TUN source file based on platform -if test "x$os_freebsd" = "xyes"; then - TUN_SOURCE="tun_freebsd.c" - TUN_LIBS="" -elif test "x$os_windows" = "xyes"; then - TUN_SOURCE="tun_windows.c" - TUN_LIBS="-liphlpapi -lws2_32 -ladvapi32 -lbcrypt -ldbghelp" -else - TUN_SOURCE="tun_linux.c" - TUN_LIBS="" -fi -AC_SUBST([TUN_SOURCE]) -AC_SUBST([TUN_LIBS]) - # Checks for header files, typedefs, functions... AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h netinet/in.h stdlib.h string.h sys/ioctl.h sys/socket.h unistd.h]) AC_TYPE_SIZE_T diff --git a/src/Makefile.am b/src/Makefile.am index 9803480..0c1b33a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,9 @@ utun_CORE_SOURCES = \ routing.c \ tun_if.c \ tun_route.c \ + tun_linux.c \ + tun_freebsd.c \ + tun_windows.c \ etcp.c \ etcp_connections.c \ etcp_loadbalancer.c \ @@ -22,9 +25,8 @@ utun_CORE_SOURCES = \ etcp_api.c \ control_server.c -# Platform-specific TUN sources -utun_TUN_SOURCES = $(TUN_SOURCE) -utun_TUN_LIBS = $(TUN_LIBS) +# Platform-specific TUN libs (Windows only) +utun_TUN_LIBS = -liphlpapi -lws2_32 -ladvapi32 -lbcrypt -ldbghelp # TinyCrypt sources (only used without OpenSSL) utun_TINYCRYPT_SOURCES = \ diff --git a/src/tun_freebsd.c b/src/tun_freebsd.c index b2a400c..c9e515b 100644 --- a/src/tun_freebsd.c +++ b/src/tun_freebsd.c @@ -1,6 +1,8 @@ // tun_freebsd.c - FreeBSD TUN/TAP implementation // Uses /dev/tun device with ioctl +#if defined(__FreeBSD__) + #include "tun_if.h" #include "../lib/debug_config.h" #include @@ -235,3 +237,5 @@ ssize_t tun_platform_write(struct tun_if* tun, const uint8_t* buf, size_t len) { int tun_platform_get_poll_fd(struct tun_if* tun) { return tun->fd; } + +#endif // __FreeBSD__ diff --git a/src/tun_linux.c b/src/tun_linux.c index 3c9bbff..581e7da 100644 --- a/src/tun_linux.c +++ b/src/tun_linux.c @@ -1,6 +1,8 @@ // tun_linux.c - Linux TUN/TAP implementation // Uses /dev/net/tun device with ioctl +#if defined(__linux__) + #include "tun_if.h" #include "../lib/debug_config.h" #include @@ -237,3 +239,5 @@ ssize_t tun_platform_write(struct tun_if* tun, const uint8_t* buf, size_t len) { int tun_platform_get_poll_fd(struct tun_if* tun) { return tun->fd; } + +#endif // __linux__ diff --git a/src/tun_windows.c b/src/tun_windows.c index 714ad0b..f1dfb8f 100644 --- a/src/tun_windows.c +++ b/src/tun_windows.c @@ -1,4 +1,7 @@ // tun_windows.c - Wintun implementation + +#if defined(_WIN32) + #include "../lib/debug_config.h" #include "../lib/u_async.h" #include "tun_if.h" @@ -307,3 +310,5 @@ DWORD WINAPI tun_read_thread_proc(LPVOID arg) DEBUG_DEBUG(DEBUG_CATEGORY_TUN, "TUN exit"); return 0; } + +#endif // _WIN32