Commit Graph
79 Commits
Author SHA1 Message Date
Evgeny f168f1dc8b 1 2026-03-08 19:05:31 +03:00
Evgeny daba3b96a0 1 2026-03-08 18:52:53 +03:00
jeka 60d97a90b1 1 2026-03-08 17:35:00 +03:00
jeka 2beb945bb0 1 2026-03-08 17:31:56 +03:00
jeka 5816fbea70 1 2026-03-08 17:19:38 +03:00
jeka 8880db0ca2 1 2026-03-08 16:52:24 +03:00
jeka 0e9a91729c 1 2026-03-07 20:47:15 +03:00
jeka 5d4cef0c3e race condition fix (win tun) 2026-03-07 12:21:01 +03:00
jeka 5dfd1ea5fe проверки thread в ll_queue 2026-03-06 22:45:00 +03:00
jeka 1811764f6d +queue names 2026-03-06 21:01:24 +03:00
Evgeny 55828da328 c 2026-03-06 16:19:30 +03:00
jeka 7c29349de9 1 2026-03-06 15:56:41 +03:00
jeka 066a9aa89e +memory check module
fix double free @routing
2026-03-06 15:55:16 +03:00
jeka 15c7968c8c mem 2026-03-06 01:36:57 +03:00
jeka 76555f019b dump 2026-03-05 21:16:02 +03:00
jeka 69d33636bf 1 2026-03-05 15:05:20 +03:00
jeka 357169a38a 1 2026-03-05 15:03:27 +03:00
jeka 5e4db00d4b queue add check consistency 2026-03-05 14:56:23 +03:00
jeka 32090cfa1d len fix 2026-03-05 02:31:57 +03:00
jeka de053a00c0 cleanup tests (winsock) 2026-03-04 17:27:33 +03:00
Evgeny 1aec884c2d linux routing + debug output 2026-03-04 14:59:38 +03:00
jeka b20bff32dd config 2026-03-04 01:53:17 +03:00
jeka 61d575f09b logs 2026-03-03 15:15:34 +03:00
jeka c271084d35 tun/win шлёт в routing. 2026-03-02 20:22:34 +03:00
jeka c420b8f18e пердайт icmp в tun 2026-03-01 02:48:03 +03:00
jeka 9d0223d3fa refactor 2026-02-28 15:15:34 +03:00
jeka b27ea97055 1 2026-02-22 23:28:11 +03:00
Evgeny 8502451ec7 compile fixes 2026-02-21 21:30:39 +03:00
jeka d10bddd1f7 Build: incremental build support, Windows uasync fixes, TUN cross-platform refactoring
- build.sh: added --full flag for full rebuild (autoreconf + configure + make)
- build_direct.sh: incremental compilation (skips unchanged files)
- build_full.bat: new Windows batch for full rebuild
- configure.ac: fixed Windows detection using AC_COMPILE_IFELSE
- lib/u_async.c/h: Windows wakeup socket support, uasync_post for thread-safe callbacks
- src/tun_if.c/h: cross-platform TUN refactoring, Windows read thread support
- src/tun_windows.c: Windows TUN implementation improvements
- src/control_server.c: removed premature return statement
- src/routing.c: include ordering fix
- src/utun.c: windows compat includes
- Deleted obsolete net_emulator/Makefile and tinycrypt/Makefile
2026-02-20 21:20:50 +03:00
jeka 734851329f Control: Add monitoring server with ETCP protocol support
- Implement control_server.c/h for monitoring and management
- Add Windows-compatible uasync_poll using select() instead of WSAPoll
- Fix Wintun adapter creation to open existing adapters first
- Add debug category for control server operations
- Update build files to include control server in compilation
- Add test_control_server to test suite
2026-02-19 01:24:42 +03:00
jeka 3ab19094d0 Fix: segfault in ETCP tests and add wintun.dll to gitignore
- Fix segfault in ETCP tests by initializing uECC RNG in sc_init_local_keys()
- Fix segfault during cleanup by adding reference counting to socket_platform_cleanup()
- Add wintun.dll to .gitignore
- Update AGENTS.md and platform compatibility headers

All 19 tests now pass successfully.
2026-02-16 23:36:50 +03:00
jeka 4a3c5724b7 Windows: Исправлен запуск utun - TUN, логирование, права администратора
- Добавлен platform_compat.c с кроссплатформенной генерацией случайных чисел
- Исправлена генерация ключей и node_id на Windows (вместо /dev/urandom)
- PID файл отключен по умолчанию на Windows
- Добавлено двойное логирование: файл utun.log + консоль
- Добавлен манифест Windows для запроса прав администратора
- Исправлено завершение программы при ошибках отправки (Network unreachable)
- TUN инициализация включена по умолчанию
- Исправлен main loop (instance->running = 1)
2026-02-16 14:31:16 +03:00
jeka 78dfdde400 Fix Windows test failures: proper WSAPoll error handling and FD_SETSIZE check 2026-02-16 10:33:43 +03:00
jeka 6dfeac03a8 1 2026-02-16 08:44:05 +03:00
jeka c8af35c4b9 Fix u_async: Windows socket registration, timers, and poll issues
- Remove FD_SETSIZE check for Windows sockets (can have any value)
- Fix process_timeouts to handle all expired timers (continue instead of break)
- Handle case when no sockets to poll (sleep instead of calling poll)
- Disable wakeup pipe on Windows (incompatible with WSAPoll)
- Add gettimeofday and ssize_t implementations for Windows
2026-02-15 17:38:45 +03:00
Evgeny f510d78bb5 Fix Windows: use sys/time.h for gettimeofday, remove custom implementation 2026-02-15 12:57:53 +03:00
Evgeny 4403c46788 Fix Windows build: skip gettimeofday on MSYS2, force recompile ecc_platform_specific 2026-02-15 12:26:32 +03:00
Evgeny 0798b149ab Fix Windows build: use WSAPoll instead of poll for linking 2026-02-15 03:54:35 +03:00
Evgeny 605a928350 Fix Windows build: POSIX dependencies (netdb.h, fork, setsid, SIGHUP, etc.)
- Wrap POSIX headers (netdb.h, ifaddrs.h, net/if.h) in #ifndef _WIN32 in config_parser.c
- Add Windows stub for get_netif_index() - returns 0 (no interface binding)
- Wrap daemonize() function for Windows - returns 0 (no fork/setsid support)
- Replace setlinebuf() with setvbuf() for Windows compatibility
- Wrap SIGHUP signal handler in #ifndef _WIN32
- Add explicit poll() declaration for Windows in platform_compat.h
- All 22 tests pass on Linux
2026-02-15 03:26:02 +03:00
Evgeny c83fdeeaad Fix Windows build: add sa_family_t typedef, replace arpa/inet.h, fix ll_queue warnings
- Add sa_family_t typedef for Windows in platform_compat.h
- Add forward declaration of struct ll_queue in ll_queue.h to fix warnings
- Replace arpa/inet.h includes with platform_compat.h in:
  tun_linux.c, etcp_connections.c, route_lib.c, route_bgp.c,
  utun_instance.c, routing.c, utun.c, packet_dump.h, config_parser.c
- All 22 tests pass on Linux
2026-02-15 03:06:02 +03:00
Evgeny 9b1d43996e Remove #include <poll.h> from Windows section - already in winsock2.h 2026-02-15 02:58:32 +03:00
Evgeny 1bd4bf5d11 Fix Windows build errors: config_parser.h, poll(), localtime()
- Replace sys/socket.h with platform_compat.h in config_parser.h
- Add #include <poll.h> for Windows in platform_compat.h
- Fix localtime() type mismatch: cast tv.tv_sec to time_t
- All 22 tests pass on Linux
2026-02-15 02:56:08 +03:00
Evgeny 0688efcd0e Fix platform_compat.h - remove duplicate definitions for MSYS2
- Remove duplicate struct pollfd (already in winsock2.h)
- Remove duplicate struct timezone (already in time.h)
- Remove duplicate nanosleep (already in pthread_time.h)
- Add fcntl.h include for _O_BINARY
- Use platform_pipe/fcntl to avoid naming conflicts
- All 22 tests pass on Linux
2026-02-15 02:52:27 +03:00
Evgeny 0c43a633b9 Add platform_compat.h for Windows POSIX compatibility
- Add platform_compat.h with Windows implementations of:
  * gettimeofday() using GetSystemTimeAsFileTime
  * poll() using select()
  * pipe() using _pipe()
  * fcntl() using ioctlsocket for O_NONBLOCK
  * pollfd structure and POLL* constants
  * strcasecmp/strncasecmp macros

- Update debug_config.c and u_async.c/h to use platform_compat.h
- Remove POSIX-specific headers (arpa/inet.h, sys/time.h, etc.)
- All 22 tests pass on Linux
- Fixes build errors on Windows MSYS2
2026-02-15 02:46:41 +03:00
Evgeny b0fd7d60a0 Fix Windows build: add conditional headers for sys/socket.h
- Add #ifdef _WIN32 to use winsock2.h/ws2tcpip.h instead of sys/socket.h
- Update build.sh to support both Linux and Windows/MSYS2
- Auto-detect platform and configure accordingly (--host=x86_64-w64-mingw32 for Windows)
- All 22 tests pass on Linux
2026-02-15 02:39:02 +03:00
Evgeny 15b670e563 Add cross-platform TUN support with Wintun for Windows
- Split TUN implementation into platform-specific files:
  - tun_if.c: Common code (queues, callbacks, statistics)
  - tun_linux.c: Linux TUN/TAP implementation (/dev/net/tun + ioctl)
  - tun_windows.c: Windows Wintun implementation (wintun.dll + IP Helper)

- Update tun_if.h with platform abstraction layer:
  - tun_platform_init/cleanup/read/write/get_poll_fd
  - Platform handles: fd (Linux), WINTUN handles (Windows)

- Windows implementation features:
  - Dynamic loading of wintun.dll with graceful error handling
  - IP Helper API for IP address and MTU configuration
  - HANDLE-based uasync integration
  - Clear error message if wintun.dll is not found

- Update build system:
  - configure.ac: Detect Windows (mingw/msys/cygwin)
  - src/Makefile.am: Conditional compilation of tun_linux/tun_windows
  - tests/Makefile.am: Link platform-specific TUN objects

- Add wintun.dll and wintun.h to lib/ directory
- All 22 tests pass on Linux
- Ready for MSYS2 UCRT64 Windows build
2026-02-15 01:40:17 +03:00
Evgeny 3f1d4077e9 Add cross-platform socket compatibility layer for Windows support
- Add socket_compat.h/c with platform abstraction for POSIX/Windows
- socket_t typedef: int on POSIX, SOCKET on Windows
- Add socket_platform_init/cleanup for WSAStartup on Windows
- Add socket operations: create_udp, sendto, recvfrom, set_nonblocking
- Add socket options: set_buffers, set_reuseaddr, set_mark (Linux), bind_to_device (Linux)
- Update u_async: add socket_t support with uasync_add_socket_t/remove_socket_t
- Update ETCP: use socket_t and socket_compat functions
- Add DEBUG_CATEGORY_SOCKET for socket debugging
- All 22 tests pass on Linux
- MSYS2 UCRT64 compatible
2026-02-15 01:01:35 +03:00
Evgeny 68668821e4 BGP: Implement route exchange module between uTun instances
- Add route_bgp.c/h with BGP-like route exchange functionality
- Implement route_bgp_init/destroy for module lifecycle
- Add route_bgp_new_conn to send routing table on connection
- Implement route_bgp_receive_cbk for processing incoming routes
- Add route_table_delete_entry for individual route removal
- Extend ROUTE_ENTRY with endpoint_ip, endpoint_port, destination_node_id
- Add DEBUG_CATEGORY_BGP to debug_config.h
- Integrate BGP initialization into utun_instance_create
- Call route_bgp_new_conn from etcp_connections on link init
- Create integration test test_bgp_route_exchange.c
- Add route_bgp_delete_entry tests to test_route_lib.c
- Update Makefiles to include new module

Route exchange tested and working in both directions (client-server)
2026-02-14 20:37:14 +03:00
Evgeny 801770f117 Backup before routing refactor: etcp_bind id=0 + etcp_send routing 2026-02-14 01:58:59 +03:00
Evgeny 15001487af Build: Out-of-tree build system with separate build directory
- Build in build/ directory instead of source tree
- Main binary (utun) copied to project root
- Tests run from build/tests/ with config files copied there
- Test output redirected to build/tests/logs/*.log files
- Console shows only [PASS]/[FAIL]/[SKIP] status
- Incremental build works correctly
- make check runs all tests with summary

Changes:
- New root Makefile as wrapper for out-of-tree build
- Updated Makefile.am files for lib, src, tests
- Added tinycrypt-objects target for test dependencies
- Tests no longer clutter project root
2026-02-13 22:58:41 +03:00