diff --git a/build_direct.sh b/build_direct.sh index f4fb0f82..f40bd556 100644 --- a/build_direct.sh +++ b/build_direct.sh @@ -70,14 +70,14 @@ echo "Building utun.exe..." cd src EXE_NEEDS_REBUILD=0 -CORE_SOURCES="utun.c utun_instance.c config_parser.c config_updater.c route_lib.c topo_bgp.c routing.c tun_if.c tun_route.c etcp.c etcp_connections.c etcp_loadbalancer.c secure_channel.c crc32.c pkt_normalizer.c etcp_api.c tun_windows.c" +CORE_SOURCES="utun.c utun_instance.c config_parser.c config_updater.c routing_layer/route_lib.c topo_bgp.c routing_layer/routing.c tun_if.c tun_route.c transport_layer/etcp.c transport_layer/etcp_connections.c transport_layer/etcp_loadbalancer.c transport_layer/secure_channel.c transport_layer/crc32.c transport_layer/pkt_normalizer.c transport_layer/etcp_api.c tun_windows.c" for src in $CORE_SOURCES; do if [ -f "$src" ]; then obj="utun-${src%.c}.o" if [ ! -f "$obj" ] || [ "$src" -nt "$obj" ]; then echo " CC $src" - x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. -I../lib -I../tinycrypt/lib/include -I../tinycrypt/lib/source $CFLAGS -g -O2 -c "$src" -o "$obj" 2>&1 | grep -E "error:|warning:.*deprecated" || true + x86_64-w64-mingw32-gcc -DHAVE_CONFIG_H -I. -I.. -I../lib -I../src/transport_layer -I../src/routing_layer -I../tinycrypt/lib/include -I../tinycrypt/lib/source $CFLAGS -g -O2 -c "$src" -o "$obj" 2>&1 | grep -E "error:|warning:.*deprecated" || true EXE_NEEDS_REBUILD=1 else echo " SKIPPED $src (up to date)" diff --git a/cross-build-win.sh b/cross-build-win.sh index 011c54cc..dd5f5527 100755 --- a/cross-build-win.sh +++ b/cross-build-win.sh @@ -194,15 +194,15 @@ mkdir -p "$SRC_OBJDIR" # Все .c файлы из src/Makefile.am (utun_CORE_SOURCES) SRC_SOURCES=( utun.c utun_instance.c config_parser.c config_updater.c - route_lib.c route6_lib.c topo_bgp.c route_ping.c - topo_node.c topo_node_lmdb.c route_connectivity.c conn_mgr.c - routing.c tun_if.c tun_route.c tun_linux.c tun_freebsd.c tun_windows.c - etcp.c etcp_connections.c etcp_bbr.c etcp_loadbalancer.c - etcp_debug.c etcp_dump.c secure_channel.c crc32.c - stcp_link.c stcp.c stcp_server.c stcp_client.c - pkt_normalizer.c packet_dump.c etcp_api.c + routing_layer/route_lib.c routing_layer/route6_lib.c topo_bgp.c routing_layer/route_ping.c + routing_layer/topo_node.c topo_node_lmdb.c routing_layer/route_connectivity.c routing_layer/conn_mgr.c + routing_layer/routing.c tun_if.c tun_route.c tun_linux.c tun_freebsd.c tun_windows.c + transport_layer/etcp.c transport_layer/etcp_connections.c transport_layer/etcp_bbr.c transport_layer/etcp_loadbalancer.c + transport_layer/etcp_debug.c transport_layer/etcp_dump.c transport_layer/secure_channel.c transport_layer/crc32.c + transport_layer/stcp_link.c transport_layer/stcp.c transport_layer/stcp_server.c transport_layer/stcp_client.c + transport_layer/pkt_normalizer.c transport_layer/packet_dump.c transport_layer/etcp_api.c control_server.c msg_transport.c - firewall.c eim_nat.c nat_transport.c dummynet.c + firewall.c eim_nat.c nat_transport.c transport_layer/dummynet.c etcp_router.c proxy/udp_proxy.c proxy/socks_proxy.c lwip_tcp/lwip_pbuf.c @@ -210,6 +210,7 @@ SRC_SOURCES=( SRC_CFLAGS="-DUSE_OPENSSL" SRC_CFLAGS+=" -I$SCRIPT_DIR/src -I$SCRIPT_DIR/lib -I$SCRIPT_DIR/lib/liblmdb" +SRC_CFLAGS+=" -I$SCRIPT_DIR/src/transport_layer -I$SCRIPT_DIR/src/routing_layer" SRC_CFLAGS+=" -I$SCRIPT_DIR/tinycrypt/lib/include -I$SCRIPT_DIR/tinycrypt/lib/source" SRC_CFLAGS+=" -I$PREFIX/include" SRC_CFLAGS+=" -g -O2 -Wno-deprecated-declarations" diff --git a/malloc_test b/malloc_test new file mode 100755 index 00000000..b6958901 Binary files /dev/null and b/malloc_test differ diff --git a/malloc_test.c b/malloc_test.c new file mode 100644 index 00000000..b0482fea --- /dev/null +++ b/malloc_test.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include + +#define BLOCK_SIZE 10 + +static int counts[] = {0, 100, 1000, 10000, 100000}; +static int n_counts = 5; + +static long read_vm_field(const char *field) { + char path[64], buf[256]; + snprintf(path, sizeof(path), "/proc/%d/status", getpid()); + FILE *f = fopen(path, "r"); + if (!f) return -1; + long val = -1; + while (fgets(buf, sizeof(buf), f)) { + if (strncmp(buf, field, strlen(field)) == 0) { + sscanf(buf + strlen(field) + 1, "%ld", &val); + break; + } + } + fclose(f); + return val; +} + +static void measure(const char *label) { + long rss = read_vm_field("VmRSS"); + long data = read_vm_field("VmData"); + long size = read_vm_field("VmSize"); + printf(" %-8s VmRSS=%6ld kB VmData=%6ld kB VmSize=%6ld kB\n", label, rss, data, size); +} + +int main(void) { + printf("Block size: %d bytes\n", BLOCK_SIZE); + + for (int c = 0; c < n_counts; c++) { + int n = counts[c]; + printf("\n--- %d blocks (requested %d bytes) ---\n", n, n * BLOCK_SIZE); + measure("before"); + + void **ptrs = malloc(n * sizeof(void*)); + for (int i = 0; i < n; i++) { + ptrs[i] = malloc(BLOCK_SIZE); + memset(ptrs[i], 0, BLOCK_SIZE); + } + + measure("after "); + free(ptrs); + } + return 0; +} diff --git a/src/Makefile.am b/src/Makefile.am index fd0a3cb2..ce5fda04 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,48 +7,48 @@ utun_CORE_SOURCES = \ utun_instance.c \ config_parser.c \ config_updater.c \ - route_lib.c \ - route6_lib.c \ - topo_group.c \ - route_ping.c \ - nat_detection.c \ - topo_node.c \ - topo_node_sqlite.c \ - route_connectivity.c \ - conn_mgr.c \ + routing_layer/route_lib.c \ + routing_layer/route6_lib.c \ + routing_layer/topo_group.c \ + routing_layer/route_ping.c \ + routing_layer/nat_detection.c \ + routing_layer/topo_node.c \ + routing_layer/topo_node_sqlite.c \ + routing_layer/route_connectivity.c \ + routing_layer/conn_mgr.c \ db_sync.c \ - routing.c \ + routing_layer/routing.c \ tun_if.c \ tun_route.c \ tun_linux.c \ tun_freebsd.c \ tun_windows.c \ - etcp.c \ - etcp_connections.c \ - etcp_bbr.c \ - etcp_loadbalancer.c \ - etcp_debug.c \ - etcp_dump.c \ - secure_channel.c \ - crc32.c \ - stcp_link.c \ - stcp.c \ - stcp_server.c \ - stcp_client.c \ - pkt_normalizer.c \ - packet_dump.c \ - etcp_api.c \ - etcp_connect.c \ + transport_layer/etcp.c \ + transport_layer/etcp_connections.c \ + transport_layer/etcp_bbr.c \ + transport_layer/etcp_loadbalancer.c \ + transport_layer/etcp_debug.c \ + transport_layer/etcp_dump.c \ + transport_layer/secure_channel.c \ + transport_layer/crc32.c \ + transport_layer/stcp_link.c \ + transport_layer/stcp.c \ + transport_layer/stcp_server.c \ + transport_layer/stcp_client.c \ + transport_layer/pkt_normalizer.c \ + transport_layer/packet_dump.c \ + transport_layer/etcp_api.c \ + transport_layer/etcp_connect.c \ control_server.c \ msg_transport.c \ firewall.c \ eim_nat.c \ nat_transport.c \ - dummynet.c \ + transport_layer/dummynet.c \ ntp_time.c \ ntp_node_time.c \ proxy/tcp_proxy_client.c \ - etcp_router.c \ + routing_layer/etcp_router.c \ proxy/tcp_proxy_server.c \ proxy/udp_proxy.c \ proxy/socks_proxy.c \ @@ -63,48 +63,48 @@ libutun_a_SOURCES = \ utun_instance.c \ config_parser.c \ config_updater.c \ - route_lib.c \ - route6_lib.c \ - topo_group.c \ - route_ping.c \ - nat_detection.c \ - topo_node.c \ - topo_node_sqlite.c \ - route_connectivity.c \ - conn_mgr.c \ + routing_layer/route_lib.c \ + routing_layer/route6_lib.c \ + routing_layer/topo_group.c \ + routing_layer/route_ping.c \ + routing_layer/nat_detection.c \ + routing_layer/topo_node.c \ + routing_layer/topo_node_sqlite.c \ + routing_layer/route_connectivity.c \ + routing_layer/conn_mgr.c \ db_sync.c \ - routing.c \ + routing_layer/routing.c \ tun_if.c \ tun_route.c \ tun_linux.c \ tun_freebsd.c \ tun_windows.c \ - etcp.c \ - etcp_connections.c \ - etcp_bbr.c \ - etcp_loadbalancer.c \ - etcp_debug.c \ - etcp_dump.c \ - secure_channel.c \ - crc32.c \ - stcp_link.c \ - stcp.c \ - stcp_server.c \ - stcp_client.c \ - pkt_normalizer.c \ - packet_dump.c \ - etcp_api.c \ - etcp_connect.c \ + transport_layer/etcp.c \ + transport_layer/etcp_connections.c \ + transport_layer/etcp_bbr.c \ + transport_layer/etcp_loadbalancer.c \ + transport_layer/etcp_debug.c \ + transport_layer/etcp_dump.c \ + transport_layer/secure_channel.c \ + transport_layer/crc32.c \ + transport_layer/stcp_link.c \ + transport_layer/stcp.c \ + transport_layer/stcp_server.c \ + transport_layer/stcp_client.c \ + transport_layer/pkt_normalizer.c \ + transport_layer/packet_dump.c \ + transport_layer/etcp_api.c \ + transport_layer/etcp_connect.c \ control_server.c \ msg_transport.c \ firewall.c \ eim_nat.c \ nat_transport.c \ - dummynet.c \ + transport_layer/dummynet.c \ ntp_time.c \ ntp_node_time.c \ proxy/tcp_proxy_client.c \ - etcp_router.c \ + routing_layer/etcp_router.c \ proxy/tcp_proxy_server.c \ proxy/udp_proxy.c \ proxy/socks_proxy.c \ @@ -123,6 +123,9 @@ utun_SOURCES = utun.c # Include paths utun_CFLAGS = \ -I$(top_srcdir)/lib \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/transport_layer \ + -I$(top_srcdir)/src/routing_layer \ -I$(top_srcdir)/src/uip \ -g \ -DUSE_SQLITE \ diff --git a/src/_route_tz.txt b/src/routing_layer/_route_tz.txt similarity index 100% rename from src/_route_tz.txt rename to src/routing_layer/_route_tz.txt diff --git a/src/conn_mgr.c b/src/routing_layer/conn_mgr.c similarity index 99% rename from src/conn_mgr.c rename to src/routing_layer/conn_mgr.c index 7b97c217..d88e0fad 100644 --- a/src/conn_mgr.c +++ b/src/routing_layer/conn_mgr.c @@ -416,7 +416,7 @@ static void cm_start_local_scan(struct CONN_MGR_ENTRY* entry) { struct sockaddr_storage sa; memset(&sa, 0, sizeof(sa)); memcpy(&sa, &sin, sizeof(sin)); struct cm_ping_ctx* ctx = u_calloc(1, sizeof(struct cm_ping_ctx)); if (!ctx) continue; ctx->entry = entry; ctx->addr = sa; ctx->sock = s; ctx->phase = 0; ctx->attempt = 0; - etcp_send_ping_to_socket(entry->mgr->instance, s, target->node->public_key, &sa, CONN_MGR_LOCAL_SCAN_TIMEOUT_MS, cm_ping_cb, ctx, NULL, 0); + etcp_send_ping_to_socket(entry->mgr->instance, s, target->node->public_key, &sa, CONN_MGR_LOCAL_SCAN_TIMEOUT_MS, cm_ping_cb, ctx, NULL, 0, 0); return; } s = s->next; @@ -519,7 +519,7 @@ static void cm_ping_cb(int success, uint16_t rtt, void* arg, uint64_t nonce, if (ctx->attempt < CONN_MGR_LOCAL_SCAN_ATTEMPTS && ctx->phase == 0) { etcp_send_ping_to_socket(entry->mgr->instance, ctx->sock, topo_node_find_by_id(topo_groups_get_default(entry->mgr->instance->topo_groups), entry->node_id)->node->public_key, - &ctx->addr, CONN_MGR_LOCAL_SCAN_TIMEOUT_MS, cm_ping_cb, ctx, NULL, 0); + &ctx->addr, CONN_MGR_LOCAL_SCAN_TIMEOUT_MS, cm_ping_cb, ctx, NULL, 0, 0); return; } DEBUG_INFO(DEBUG_CATEGORY_GENERAL, "conn_mgr: %s failed for 0x%016llx after %d attempts", @@ -943,7 +943,7 @@ static void cm_bg_ping_timer_cb(void* arg) { while (s) { if (s->local_addr.ss_family == AF_INET) break; s = s->next; } if (!s) break; etcp_send_ping_to_socket(mgr->instance, s, nq->node->public_key, &sa, - CONN_PROBE_TIMEOUT_MS, cm_bg_ping_noop_cb, NULL, NULL, 0); + CONN_PROBE_TIMEOUT_MS, cm_bg_ping_noop_cb, NULL, NULL, 0, 0); break; } } diff --git a/src/conn_mgr.h b/src/routing_layer/conn_mgr.h similarity index 100% rename from src/conn_mgr.h rename to src/routing_layer/conn_mgr.h diff --git a/src/conn_mgr_doc.md b/src/routing_layer/conn_mgr_doc.md similarity index 100% rename from src/conn_mgr_doc.md rename to src/routing_layer/conn_mgr_doc.md diff --git a/src/etcp_router.c b/src/routing_layer/etcp_router.c similarity index 100% rename from src/etcp_router.c rename to src/routing_layer/etcp_router.c diff --git a/src/etcp_router.h b/src/routing_layer/etcp_router.h similarity index 100% rename from src/etcp_router.h rename to src/routing_layer/etcp_router.h diff --git a/src/etcp_router_doc.md b/src/routing_layer/etcp_router_doc.md similarity index 100% rename from src/etcp_router_doc.md rename to src/routing_layer/etcp_router_doc.md diff --git a/src/nat_detection.c b/src/routing_layer/nat_detection.c similarity index 100% rename from src/nat_detection.c rename to src/routing_layer/nat_detection.c diff --git a/src/nat_detection.h b/src/routing_layer/nat_detection.h similarity index 100% rename from src/nat_detection.h rename to src/routing_layer/nat_detection.h diff --git a/src/route6_lib.c b/src/routing_layer/route6_lib.c similarity index 100% rename from src/route6_lib.c rename to src/routing_layer/route6_lib.c diff --git a/src/route6_lib.h b/src/routing_layer/route6_lib.h similarity index 100% rename from src/route6_lib.h rename to src/routing_layer/route6_lib.h diff --git a/src/route6_lib_doc.md b/src/routing_layer/route6_lib_doc.md similarity index 100% rename from src/route6_lib_doc.md rename to src/routing_layer/route6_lib_doc.md diff --git a/src/route_bgp.txt b/src/routing_layer/route_bgp.txt similarity index 100% rename from src/route_bgp.txt rename to src/routing_layer/route_bgp.txt diff --git a/src/route_connectivity.c b/src/routing_layer/route_connectivity.c similarity index 98% rename from src/route_connectivity.c rename to src/routing_layer/route_connectivity.c index 8eb4b71e..456ad258 100644 --- a/src/route_connectivity.c +++ b/src/routing_layer/route_connectivity.c @@ -16,6 +16,7 @@ #include "topo_node.h" #include "topo_group.h" #include "route_connectivity.h" +#include "topo_node_sqlite.h" #define CONN_MAX_SOCKET_CANDIDATES 8 @@ -201,7 +202,8 @@ static void conn_probe_start_series(struct conn_probe_ctx* ctx) { int ret = etcp_send_ping_to_socket(ctx->instance, sock, ctx->peer_pubkey, &ctx->target_addr, ctx->timeout_ms, - conn_probe_single_cb, ctx, NULL, 0); + conn_probe_single_cb, ctx, NULL, 0, 0); + if (ret != 0) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "probe: cannot start ping from socket %s", sock->name); ctx->count_sent = 3; // simulate full failure @@ -231,7 +233,7 @@ static void conn_probe_single_cb(int success, uint16_t rtt, void* arg, struct ETCP_SOCKET* sock = ctx->candidate_sockets[ctx->candidate_index]; int ret = etcp_send_ping_to_socket(ctx->instance, sock, ctx->peer_pubkey, &ctx->target_addr, ctx->timeout_ms, - conn_probe_single_cb, ctx, NULL, 0); + conn_probe_single_cb, ctx, NULL, 0, 0); if (ret != 0) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "probe: cannot continue ping from socket %s", sock->name); ctx->count_sent = ctx->count_total; // force finish series @@ -279,6 +281,8 @@ static void conn_probe_finish(struct conn_probe_ctx* ctx, int ok) { DEBUG_INFO(DEBUG_CATEGORY_BGP, "connectivity probe DONE for node %016llx: intf=%d nat=%d real=%d", (unsigned long long)ctx->nq->node->node_id, c->interface_status, c->nat_status, c->real_status); + if (ctx->instance && ctx->instance->topo_sqlite_db) + topo_node_sqlite_nodeinfo_updated(ctx->instance->topo_sqlite_db, ctx->nq->node->node_id); } } diff --git a/src/route_connectivity.h b/src/routing_layer/route_connectivity.h similarity index 100% rename from src/route_connectivity.h rename to src/routing_layer/route_connectivity.h diff --git a/src/route_connectivity_doc.md b/src/routing_layer/route_connectivity_doc.md similarity index 100% rename from src/route_connectivity_doc.md rename to src/routing_layer/route_connectivity_doc.md diff --git a/src/route_lib.c b/src/routing_layer/route_lib.c similarity index 100% rename from src/route_lib.c rename to src/routing_layer/route_lib.c diff --git a/src/route_lib.h b/src/routing_layer/route_lib.h similarity index 100% rename from src/route_lib.h rename to src/routing_layer/route_lib.h diff --git a/src/route_lib.txt b/src/routing_layer/route_lib.txt similarity index 100% rename from src/route_lib.txt rename to src/routing_layer/route_lib.txt diff --git a/src/route_lib_doc.md b/src/routing_layer/route_lib_doc.md similarity index 100% rename from src/route_lib_doc.md rename to src/routing_layer/route_lib_doc.md diff --git a/src/route_p2pconn.txt b/src/routing_layer/route_p2pconn.txt similarity index 100% rename from src/route_p2pconn.txt rename to src/routing_layer/route_p2pconn.txt diff --git a/src/route_ping.c b/src/routing_layer/route_ping.c similarity index 99% rename from src/route_ping.c rename to src/routing_layer/route_ping.c index 13804941..2b20f83b 100644 --- a/src/route_ping.c +++ b/src/routing_layer/route_ping.c @@ -309,7 +309,7 @@ static void route_ping_single_cb(int success, ctx->timeout_ms, route_ping_single_cb, ctx, - NULL, 0); + NULL, 0, 0); if (ret != 0) { /* Не смогли отправить следующий — завершаем серию досрочно */ @@ -391,7 +391,7 @@ void route_ping_handle_req(struct NAT_DETECTION* nd, struct TOPO_GROUP* group, ctx->timeout_ms, route_ping_single_cb, ctx, - NULL, 0); + NULL, 0, 0); if (ret != 0) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "ping req: cannot start first ping"); diff --git a/src/route_ping.h b/src/routing_layer/route_ping.h similarity index 100% rename from src/route_ping.h rename to src/routing_layer/route_ping.h diff --git a/src/route_ping_doc.md b/src/routing_layer/route_ping_doc.md similarity index 100% rename from src/route_ping_doc.md rename to src/routing_layer/route_ping_doc.md diff --git a/src/routing.c b/src/routing_layer/routing.c similarity index 100% rename from src/routing.c rename to src/routing_layer/routing.c diff --git a/src/routing.h b/src/routing_layer/routing.h similarity index 100% rename from src/routing.h rename to src/routing_layer/routing.h diff --git a/src/routing_doc.md b/src/routing_layer/routing_doc.md similarity index 100% rename from src/routing_doc.md rename to src/routing_layer/routing_doc.md diff --git a/src/topo_group.c b/src/routing_layer/topo_group.c similarity index 99% rename from src/topo_group.c rename to src/routing_layer/topo_group.c index 7cb12297..021c37da 100644 --- a/src/topo_group.c +++ b/src/routing_layer/topo_group.c @@ -586,6 +586,7 @@ int topo_group_process_nodeinfo(struct TOPO_GROUP* group, struct ETCP_CONN* from topo_node_sqlite_member_put(sdb, group->channel_id, node_id, NULL, 0, NULL, 0, NULL, NULL, NULL, NULL); DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG, "SQLite member_put: ch=%s node=%016llx", group->channel_id, (unsigned long long)node_id); } + topo_node_sqlite_nodeinfo_updated(sdb, node_id); } } if (group->instance->control_srv) control_server_notify_node_change(group->instance->control_srv, nodeinfo1); diff --git a/src/topo_group.h b/src/routing_layer/topo_group.h similarity index 100% rename from src/topo_group.h rename to src/routing_layer/topo_group.h diff --git a/src/topo_group_doc.md b/src/routing_layer/topo_group_doc.md similarity index 100% rename from src/topo_group_doc.md rename to src/routing_layer/topo_group_doc.md diff --git a/src/topo_node.c b/src/routing_layer/topo_node.c similarity index 92% rename from src/topo_node.c rename to src/routing_layer/topo_node.c index 41dc34ca..632a04ce 100644 --- a/src/topo_node.c +++ b/src/routing_layer/topo_node.c @@ -13,6 +13,8 @@ #include "topo_group.h" #include "route_lib.h" #include "etcp_debug.h" +#include "topo_node_sqlite.h" +#include "../lib/u_async.h" void topo_node_ref(struct TOPO_NODE* ni) { if (!ni) return; @@ -262,6 +264,55 @@ struct TOPO_NODEQ* topo_node_find_by_id(struct TOPO_GROUP* group, uint64_t node_ return e ? (struct TOPO_NODEQ*)e : NULL; } +int topo_node_ping_request_cbk(struct TOPO_GROUPS* groups, uint64_t node_id) { + if (!groups || !groups->group_list) return 0; + uint64_t now = get_time_tb(); + struct ll_entry* ge = groups->group_list->head; + while (ge) { + struct TOPO_GROUP* g = (struct TOPO_GROUP*)ge; + struct TOPO_NODEQ* nq = topo_node_find_by_id(g, node_id); + if (nq) { + struct TOPO_CONNECTIVITY* c = &nq->connectivity; + if (c->last_ping_time == 0 || (now - c->last_ping_time) > PING_TTL_TB) { + DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "ping_request_cbk: node=%016llx last_ping=%llu now=%llu stale=1", + (unsigned long long)node_id, (unsigned long long)c->last_ping_time, (unsigned long long)now); + return 1; + } + DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "ping_request_cbk: node=%016llx last_ping=%llu now=%llu stale=0", + (unsigned long long)node_id, (unsigned long long)c->last_ping_time, (unsigned long long)now); + } + ge = ge->next; + } + return 0; +} + +void topo_node_ping_update_rtt(struct TOPO_GROUPS* groups, uint64_t node_id, uint16_t rtt) { + if (!groups || !groups->group_list) { + DEBUG_WARN(DEBUG_CATEGORY_BGP, "ping_update_rtt: no groups, node=%016llx rtt=%u", (unsigned long long)node_id, (unsigned)rtt); + return; + } + uint64_t now = get_time_tb(); + struct ll_entry* ge = groups->group_list->head; + while (ge) { + struct TOPO_GROUP* g = (struct TOPO_GROUP*)ge; + struct TOPO_NODEQ* nq = topo_node_find_by_id(g, node_id); + if (nq) { + nq->connectivity.last_ping_time = now; + if (nq->connectivity.interface_min_rtt == 0 || rtt < nq->connectivity.interface_min_rtt) + nq->connectivity.interface_min_rtt = rtt; + if (nq->connectivity.nat_min_rtt == 0 || rtt < nq->connectivity.nat_min_rtt) + nq->connectivity.nat_min_rtt = rtt; + if (nq->connectivity.real_min_rtt == 0 || rtt < nq->connectivity.real_min_rtt) + nq->connectivity.real_min_rtt = rtt; + DEBUG_INFO(DEBUG_CATEGORY_BGP, "ping_update_rtt: node=%016llx rtt=%u (%llu) group=%016llx", + (unsigned long long)node_id, (unsigned)rtt, (unsigned long long)now, (unsigned long long)g->group_id); + if (groups->instance && groups->instance->topo_sqlite_db) + topo_node_sqlite_nodeinfo_updated(groups->instance->topo_sqlite_db, node_id); + } + ge = ge->next; + } +} + // ===== dump / format ===== static int is_node_connectivity_active(struct TOPO_CONNECTIVITY* c) { @@ -270,7 +321,8 @@ static int is_node_connectivity_active(struct TOPO_CONNECTIVITY* c) { || c->nat_status != PROBE_RESULT_UNKNOWN || c->real_status != PROBE_RESULT_UNKNOWN || c->probe_start_time != 0 - || c->ping_req_time != 0; + || c->ping_req_time != 0 + || c->last_ping_time != 0; } static const char* probe_status_str(uint8_t s) { @@ -360,11 +412,11 @@ void topo_node_dump_all(struct TOPO_GROUP* group) { struct TOPO_CONNECTIVITY* c = &nq->connectivity; if (is_node_connectivity_active(c)) { - DEBUG_INFO(DEBUG_CATEGORY_BGP, " connectivity: probe=%s iface=%s(%u) nat=%s(%u) real=%s(%u) pend=%u iface_rtt=%u nat_rtt=%u real_rtt=%u start_tb=%llu ping_req_tb=%llu", + DEBUG_INFO(DEBUG_CATEGORY_BGP, " connectivity: probe=%s iface=%s(%u) nat=%s(%u) real=%s(%u) pend=%u iface_rtt=%u nat_rtt=%u real_rtt=%u start_tb=%llu ping_req_tb=%llu last_ping_tb=%llu", probe_status_str(c->probe_status), probe_result_str(c->interface_status), c->interface_min_rtt, probe_result_str(c->nat_status), c->nat_min_rtt, probe_result_str(c->real_status), c->real_min_rtt, c->pending_count, c->interface_min_rtt, c->nat_min_rtt, c->real_min_rtt, - (unsigned long long)c->probe_start_time, (unsigned long long)c->ping_req_time); + (unsigned long long)c->probe_start_time, (unsigned long long)c->ping_req_time, (unsigned long long)c->last_ping_time); } if (nq->conn_mgr_type != CONN_TYPE_NONE) { char interm_buf[200] = ""; int ipos = 0; @@ -448,11 +500,11 @@ int topo_node_format_all(struct TOPO_GROUP* group, char* buf, size_t buf_size) { struct TOPO_CONNECTIVITY* c = &nq->connectivity; if (is_node_connectivity_active(c)) { - FMT_ADD(" connectivity: probe=%s iface=%s(%u) nat=%s(%u) real=%s(%u) pend=%u iface_rtt=%u nat_rtt=%u real_rtt=%u start_tb=%llu ping_req_tb=%llu\n", + FMT_ADD(" connectivity: probe=%s iface=%s(%u) nat=%s(%u) real=%s(%u) pend=%u iface_rtt=%u nat_rtt=%u real_rtt=%u start_tb=%llu ping_req_tb=%llu last_ping_tb=%llu\n", probe_status_str(c->probe_status), probe_result_str(c->interface_status), c->interface_min_rtt, probe_result_str(c->nat_status), c->nat_min_rtt, probe_result_str(c->real_status), c->real_min_rtt, c->pending_count, c->interface_min_rtt, c->nat_min_rtt, c->real_min_rtt, - (unsigned long long)c->probe_start_time, (unsigned long long)c->ping_req_time); + (unsigned long long)c->probe_start_time, (unsigned long long)c->ping_req_time, (unsigned long long)c->last_ping_time); } if (nq->conn_mgr_type != CONN_TYPE_NONE) { FMT_ADD(" conn_mgr: type=%s intermediates=[", conn_mgr_type_str(nq->conn_mgr_type)); diff --git a/src/topo_node.h b/src/routing_layer/topo_node.h similarity index 96% rename from src/topo_node.h rename to src/routing_layer/topo_node.h index 2c16e780..8f80a7d5 100644 --- a/src/topo_node.h +++ b/src/routing_layer/topo_node.h @@ -31,6 +31,7 @@ extern "C" { #include "secure_channel.h" struct TOPO_GROUP; +struct TOPO_GROUPS; struct ETCP_SOCKET; struct UTUN_INSTANCE; @@ -100,9 +101,12 @@ struct TOPO_CONNECTIVITY { uint64_t nat_probe_time; uint64_t real_probe_time; uint64_t ping_req_time; + uint64_t last_ping_time; // время последнего успешного пинга (0.1ms timebase) void* probe_list; }; +#define PING_TTL_TB (86400ULL * 10000ULL) // 1 день в 0.1ms units + // ======================================================================= // Протокольные структуры (wire-format, packed, без next) // ======================================================================= @@ -270,6 +274,9 @@ int topo_group_update_my_nodeinfo(struct UTUN_INSTANCE* instance, struct TOPO_GR void topo_node_dump_all(struct TOPO_GROUP* group); int topo_node_format_all(struct TOPO_GROUP* group, char* buf, size_t buf_size); +int topo_node_ping_request_cbk(struct TOPO_GROUPS* groups, uint64_t node_id); +void topo_node_ping_update_rtt(struct TOPO_GROUPS* groups, uint64_t node_id, uint16_t rtt); + #ifdef __cplusplus } #endif diff --git a/src/topo_node_doc.md b/src/routing_layer/topo_node_doc.md similarity index 100% rename from src/topo_node_doc.md rename to src/routing_layer/topo_node_doc.md diff --git a/src/topo_node_sqlite.c b/src/routing_layer/topo_node_sqlite.c similarity index 85% rename from src/topo_node_sqlite.c rename to src/routing_layer/topo_node_sqlite.c index 20e7fb36..4d862d2b 100644 --- a/src/topo_node_sqlite.c +++ b/src/routing_layer/topo_node_sqlite.c @@ -78,6 +78,22 @@ int topo_node_sqlite_init(sqlite3* db) { return -1; } + { + sqlite3_stmt* s = NULL; + if (sqlite3_prepare_v2(db, + "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'peers\\_%' ESCAPE '\\'", + -1, &s, NULL) == SQLITE_OK) { + char isql[256]; + while (sqlite3_step(s) == SQLITE_ROW) { + const char* tbl = (const char*)sqlite3_column_text(s, 0); + snprintf(isql, sizeof(isql), + "CREATE INDEX IF NOT EXISTS \"idx_%s_type_rtt\" ON \"%s\" (node_type, node_RTT)", tbl, tbl); + sqlite3_exec(db, isql, NULL, NULL, NULL); + } + sqlite3_finalize(s); + } + } + DEBUG_INFO(DEBUG_CATEGORY_BGP, "topo_node_sqlite tables initialized"); return 0; } @@ -235,7 +251,8 @@ int topo_node_sqlite_channel_put(sqlite3* db, const char* channel_id, char sql[512]; snprintf(sql, sizeof(sql), "CREATE TABLE IF NOT EXISTS \"%s\" (" // таблица мемберов канала - " node_id INTEGER NOT NULL," // ид меббера группы + " id INTEGER PRIMARY KEY AUTOINCREMENT," + " node_id INTEGER NOT NULL UNIQUE," // ид мембера группы " x25519_pubkey BLOB NOT NULL," // ключ мембера для шифрования " ed25519_pubkey BLOB NOT NULL," // ключ мембера для подписи " join_sig BLOB NOT NULL," // подпись мембера неизменяемая (при присоединении) сh_x25519_pubkey(32) || ch_ed25519_pubkey(32) || node_id(8 LE) || node_x25519_pubkey(32) || join_ts(8 LE) @@ -246,11 +263,15 @@ int topo_node_sqlite_channel_put(sqlite3* db, const char* channel_id, " creator_sig BLOB," // валидация мембера админом канала " adm_tags TEXT," // тэги которые может менять админ (json_flat style) " adm_tags_sig BLOB," // подпись тэгов adm_tags (может быть подписана ключом суперадмина или админов - проверяем перебором) - " node_type INTEGER NOT NULL," // ENUM(0-'PRIV',1-'NAT',2-'EIM-NAT',3-'PUBLIC',4-SUPERNODE) тип ноды - private (только нода подключается), nat (односторонние подключения), eim-nat (доступны подключения но надо запрашивать ip), public - на прямых ip (но может быть недоступна в чебурнетах), supernode - на прямых ip, рекомендуемая для подключения - " PRIMARY KEY (node_id))", peers_tbl); + " node_type INTEGER NOT NULL DEFAULT 0," // ENUM(0-'PRIV',1-'NAT',2-'EIM-NAT',3-'PUBLIC',4-SUPERNODE) тип ноды - private (только нода подключается), nat (односторонние подключения), eim-nat (доступны подключения но надо запрашивать ip), public - на прямых ip (но может быть недоступна в чебурнетах), supernode - на прямых ip, рекомендуемая для подключения + " node_RTT INTEGER" // задержка в ms + ")", peers_tbl); char* err = NULL; sqlite3_exec(db, sql, NULL, NULL, &err); if (err) { DEBUG_ERROR(DEBUG_CATEGORY_BGP, "topo_node_sqlite_channel_put peers: %s", err); sqlite3_free(err); } + snprintf(sql, sizeof(sql), + "CREATE INDEX IF NOT EXISTS \"idx_%s_type_rtt\" ON \"%s\" (node_type, node_RTT)", peers_tbl, peers_tbl); + sqlite3_exec(db, sql, NULL, NULL, NULL); sqlite3_stmt* stmt = NULL; if (sqlite3_prepare_v2(db, @@ -502,3 +523,64 @@ int topo_node_sqlite_get_ed25519_pubkey(sqlite3* db, uint64_t node_id, uint8_t p sqlite3_finalize(stmt); return rc; } + +int topo_node_sqlite_nodeinfo_updated(sqlite3* db, uint64_t node_id) { + if (!db) return -1; + + int best_at = -1; + { + sqlite3_stmt* s = NULL; + if (sqlite3_prepare_v2(db, + "SELECT addr_type FROM node_addresses WHERE node_id=?", -1, &s, NULL) == SQLITE_OK) { + sqlite3_bind_int64(s, 1, (sqlite3_int64)node_id); + while (sqlite3_step(s) == SQLITE_ROW) { + int at = sqlite3_column_int(s, 0); + if (at == ADDR_TYPE_DIRECT) { best_at = ADDR_TYPE_DIRECT; break; } + if (best_at < 0 || at < best_at) best_at = at; + } + sqlite3_finalize(s); + } + } + + static const int at2type[] = { [ADDR_TYPE_NETIF]=1, [ADDR_TYPE_DIRECT]=1, [ADDR_TYPE_NAT_EIM]=2, [ADDR_TYPE_NAT_STRICT]=1 }; + int base_type = (best_at < 0) ? 0 : at2type[best_at]; + + sqlite3_stmt* s = NULL; + if (sqlite3_prepare_v2(db, + "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE 'peers\\_%' ESCAPE '\\'", + -1, &s, NULL) != SQLITE_OK) return -1; + + char sql[256]; + while (sqlite3_step(s) == SQLITE_ROW) { + const char* tbl = (const char*)sqlite3_column_text(s, 0); + + int node_type = base_type; + if (best_at == ADDR_TYPE_DIRECT && base_type == 1) { + snprintf(sql, sizeof(sql), + "SELECT adm_tags FROM \"%s\" WHERE node_id=?", tbl); + sqlite3_stmt* a = NULL; + if (sqlite3_prepare_v2(db, sql, -1, &a, NULL) == SQLITE_OK) { + sqlite3_bind_int64(a, 1, (sqlite3_int64)node_id); + if (sqlite3_step(a) == SQLITE_ROW) { + const char* tags = (const char*)sqlite3_column_text(a, 0); + if (tags && strstr(tags, "supernode=yes")) node_type = 4; + } + sqlite3_finalize(a); + } + } + + snprintf(sql, sizeof(sql), + "UPDATE \"%s\" SET node_type=? WHERE node_id=?", tbl); + sqlite3_stmt* u = NULL; + if (sqlite3_prepare_v2(db, sql, -1, &u, NULL) == SQLITE_OK) { + sqlite3_bind_int(u, 1, node_type); + sqlite3_bind_int64(u, 2, (sqlite3_int64)node_id); + sqlite3_step(u); sqlite3_finalize(u); + } + } + sqlite3_finalize(s); + + DEBUG_DEBUG(DEBUG_CATEGORY_BGP, "nodeinfo_updated: node=%016llx best_at=%d base_type=%d", + (unsigned long long)node_id, best_at, base_type); + return 0; +} diff --git a/src/topo_node_sqlite.h b/src/routing_layer/topo_node_sqlite.h similarity index 90% rename from src/topo_node_sqlite.h rename to src/routing_layer/topo_node_sqlite.h index c1f21b65..08b89485 100644 --- a/src/topo_node_sqlite.h +++ b/src/routing_layer/topo_node_sqlite.h @@ -49,4 +49,7 @@ int topo_node_sqlite_node_set_online(sqlite3* db, uint64_t node_id, int online); int topo_node_sqlite_node_get_online(sqlite3* db, uint64_t node_id); int topo_node_sqlite_get_ed25519_pubkey(sqlite3* db, uint64_t node_id, uint8_t pubkey_out[32]); +/** Пересчитывает node_type во всех peers_* таблицах на основе addr_type из node_addresses */ +int topo_node_sqlite_nodeinfo_updated(sqlite3* db, uint64_t node_id); + #endif diff --git a/src/topo_node_sqlite_doc.md b/src/routing_layer/topo_node_sqlite_doc.md similarity index 100% rename from src/topo_node_sqlite_doc.md rename to src/routing_layer/topo_node_sqlite_doc.md diff --git a/src/topo_strategy.txt b/src/routing_layer/topo_strategy.txt similarity index 100% rename from src/topo_strategy.txt rename to src/routing_layer/topo_strategy.txt diff --git a/src/BBR/bbr_v3.c b/src/transport_layer/BBR/bbr_v3.c similarity index 100% rename from src/BBR/bbr_v3.c rename to src/transport_layer/BBR/bbr_v3.c diff --git a/src/crc32.c b/src/transport_layer/crc32.c similarity index 100% rename from src/crc32.c rename to src/transport_layer/crc32.c diff --git a/src/crc32.h b/src/transport_layer/crc32.h similarity index 100% rename from src/crc32.h rename to src/transport_layer/crc32.h diff --git a/src/crc32_doc.md b/src/transport_layer/crc32_doc.md similarity index 100% rename from src/crc32_doc.md rename to src/transport_layer/crc32_doc.md diff --git a/src/dummynet.c b/src/transport_layer/dummynet.c similarity index 100% rename from src/dummynet.c rename to src/transport_layer/dummynet.c diff --git a/src/dummynet.h b/src/transport_layer/dummynet.h similarity index 100% rename from src/dummynet.h rename to src/transport_layer/dummynet.h diff --git a/src/dummynet_doc.md b/src/transport_layer/dummynet_doc.md similarity index 100% rename from src/dummynet_doc.md rename to src/transport_layer/dummynet_doc.md diff --git a/src/etcp.c b/src/transport_layer/etcp.c similarity index 100% rename from src/etcp.c rename to src/transport_layer/etcp.c diff --git a/src/etcp.h b/src/transport_layer/etcp.h similarity index 100% rename from src/etcp.h rename to src/transport_layer/etcp.h diff --git a/src/etcp_api.c b/src/transport_layer/etcp_api.c similarity index 100% rename from src/etcp_api.c rename to src/transport_layer/etcp_api.c diff --git a/src/etcp_api.h b/src/transport_layer/etcp_api.h similarity index 100% rename from src/etcp_api.h rename to src/transport_layer/etcp_api.h diff --git a/src/etcp_api_doc.md b/src/transport_layer/etcp_api_doc.md similarity index 100% rename from src/etcp_api_doc.md rename to src/transport_layer/etcp_api_doc.md diff --git a/src/etcp_bbr.c b/src/transport_layer/etcp_bbr.c similarity index 100% rename from src/etcp_bbr.c rename to src/transport_layer/etcp_bbr.c diff --git a/src/etcp_bbr.h b/src/transport_layer/etcp_bbr.h similarity index 100% rename from src/etcp_bbr.h rename to src/transport_layer/etcp_bbr.h diff --git a/src/etcp_bbr_doc.md b/src/transport_layer/etcp_bbr_doc.md similarity index 100% rename from src/etcp_bbr_doc.md rename to src/transport_layer/etcp_bbr_doc.md diff --git a/src/etcp_connect.c b/src/transport_layer/etcp_connect.c similarity index 100% rename from src/etcp_connect.c rename to src/transport_layer/etcp_connect.c diff --git a/src/etcp_connect.h b/src/transport_layer/etcp_connect.h similarity index 100% rename from src/etcp_connect.h rename to src/transport_layer/etcp_connect.h diff --git a/src/etcp_connect_doc.md b/src/transport_layer/etcp_connect_doc.md similarity index 100% rename from src/etcp_connect_doc.md rename to src/transport_layer/etcp_connect_doc.md diff --git a/src/etcp_connections.c b/src/transport_layer/etcp_connections.c similarity index 97% rename from src/etcp_connections.c rename to src/transport_layer/etcp_connections.c index 870d06a7..a39e8e0f 100644 --- a/src/etcp_connections.c +++ b/src/transport_layer/etcp_connections.c @@ -1011,7 +1011,8 @@ static void ping_timeout_cbk(void* arg) { int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* e_sock, const uint8_t* peer_pubkey_bin, const struct sockaddr_storage* addr, int timeout_ms, etcp_ping_callback_t cb, void* user_arg, - const uint8_t* user_data, size_t user_data_len) { + const uint8_t* user_data, size_t user_data_len, + uint8_t flags) { if (!instance || !e_sock || !peer_pubkey_bin || !addr || timeout_ms <= 0 || !cb) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "bad args"); return -1; @@ -1044,6 +1045,7 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* memcpy(ctx->user_data, user_data, user_data_len); ctx->user_data_len = user_data_len; } + memcpy(ctx->peer_pubkey, peer_pubkey_bin, SC_PUBKEY_SIZE); struct ETCP_DGRAM* dgram = u_malloc(PACKET_DATA_SIZE); if (!dgram) { if (ctx->user_data) u_free(ctx->user_data); @@ -1056,6 +1058,7 @@ int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* size_t offset = 0; uint8_t* p = dgram->data; *p++ = ETCP_PING; + *p++ = flags; // flags uint64_t nid = htobe64(instance->node_id); memcpy(p, &nid, 8); p += 8; uint64_t nonce_be = htobe64(ctx->nonce); @@ -1115,25 +1118,39 @@ int etcp_send_ping(struct UTUN_INSTANCE* instance, const uint8_t* peer_pubkey_bi } DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "ping N1 [%s]", sockaddr_storage_to_str(addr).str); return etcp_send_ping_to_socket(instance, e_sock, peer_pubkey_bin, addr, timeout_ms, - cb, user_arg, user_data, user_data_len); + cb, user_arg, user_data, user_data_len, 0); } // === Helpers extracted from etcp_connections_read_callback_socket === static int handle_ping(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pkt, const struct sockaddr_storage* addr, const uint8_t* decrypted_pubkey, size_t pkt_len) { - if (pkt_len < 22) { + if (pkt_len < 23) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "PING too short: pkt_len=%zu from %s", pkt_len, sockaddr_storage_to_str(addr).str); return 7; } - uint64_t nonce = be64toh(*(uint64_t*)(pkt->data + 9)); - uint16_t ulen = be16toh(*(uint16_t*)(pkt->data + 17)); - const uint8_t* udata = (ulen > 0) ? (pkt->data + 19) : NULL; + uint8_t flags = pkt->data[1]; + uint64_t peer_id = be64toh(*(uint64_t*)(pkt->data + 2)); + uint64_t nonce = be64toh(*(uint64_t*)(pkt->data + 10)); + uint16_t ulen = be16toh(*(uint16_t*)(pkt->data + 18)); + const uint8_t* udata = (ulen > 0) ? (pkt->data + 20) : NULL; + + if ((flags & ETCP_PING_FLAG_SEND_RTT) && ulen >= 2) { + uint16_t rtt_val = be16toh(*(uint16_t*)udata); + topo_node_ping_update_rtt(e_sock->instance->topo_groups, peer_id, rtt_val); + DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "PING rtt=%u from peer=%016llx", (unsigned)rtt_val, (unsigned long long)peer_id); + } + + uint8_t pong_flags = 0; + if (e_sock->instance->topo_groups && topo_node_ping_request_cbk(e_sock->instance->topo_groups, peer_id)) + pong_flags |= ETCP_PING_FLAG_WANT_RTT; + struct ETCP_DGRAM* resp = u_malloc(PACKET_DATA_SIZE); if (resp) { resp->link = NULL; resp->noencrypt_len = SC_PUBKEY_ENC_SIZE; uint8_t* p = resp->data; *p++ = ETCP_PONG; + *p++ = pong_flags; uint64_t nid = htobe64(e_sock->instance->node_id); memcpy(p, &nid, 8); p += 8; uint64_t n = htobe64(nonce); @@ -1152,8 +1169,8 @@ static int handle_ping(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pkt, const sc_context_t resp_sc; sc_init_ctx(&resp_sc, &e_sock->instance->my_keys); if (sc_set_peer_public_key(&resp_sc, decrypted_pubkey, SC_PEER_PUBKEY_BIN) == SC_OK) { - DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "PONG send nonce=%016llx to=%s fd=%d", - (unsigned long long)nonce, sockaddr_storage_to_str(addr).str, e_sock->fd); + DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "PONG send nonce=%016llx flags=%02x to=%s fd=%d", + (unsigned long long)nonce, (unsigned)pong_flags, sockaddr_storage_to_str(addr).str, e_sock->fd); etcp_send_ping_raw(resp, e_sock->fd, &resp_sc, addr); } u_free(resp); @@ -1162,22 +1179,28 @@ static int handle_ping(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pkt, const return 0; } +static void rtt_send_ping_cb(int success, uint16_t rtt, void* arg, uint64_t nonce, + const uint8_t* resp_data, size_t resp_data_len) { + (void)success; (void)rtt; (void)arg; (void)nonce; (void)resp_data; (void)resp_data_len; +} + static int handle_pong(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pkt, const struct sockaddr_storage* addr, size_t pkt_len) { - if (pkt_len < 20) { + if (pkt_len < 23) { DEBUG_ERROR(DEBUG_CATEGORY_CONNECTION, "PONG too short: pkt_len=%zu from %s", pkt_len, sockaddr_storage_to_str(addr).str); return 7; } - uint64_t nonce = be64toh(*(uint64_t*)(pkt->data + 9)); + uint8_t flags = pkt->data[1]; + uint64_t nonce = be64toh(*(uint64_t*)(pkt->data + 10)); uint16_t ulen = 0; const uint8_t* udata = NULL; - if (pkt->data_len >= 19) { - ulen = be16toh(*(uint16_t*)(pkt->data + 17)); - if (ulen > 0 && pkt->data_len >= 19 + ulen) { - udata = pkt->data + 19; + if (pkt->data_len >= 20) { + ulen = be16toh(*(uint16_t*)(pkt->data + 18)); + if (ulen > 0 && pkt->data_len >= 20 + ulen) { + udata = pkt->data + 20; } } - DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "PONG recv nonce=%016llx data_len=%u from=%s socket=%s", - (unsigned long long)nonce, (unsigned)pkt->data_len, + DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "PONG recv nonce=%016llx flags=%02x data_len=%u from=%s socket=%s", + (unsigned long long)nonce, (unsigned)flags, (unsigned)pkt->data_len, sockaddr_storage_to_str(addr).str, e_sock->name); struct PING_CONTEXT* ctx = e_sock->instance->pending_pings; struct PING_CONTEXT* prev = NULL; @@ -1193,9 +1216,21 @@ static int handle_pong(struct ETCP_SOCKET* e_sock, struct ETCP_DGRAM* pkt, const } uint64_t now = get_time_tb(); uint16_t rtt = (now >= ctx->send_time) ? (uint16_t)(now - ctx->send_time) : 0; - DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "PONG matched nonce=%016llx rtt=%u", - (unsigned long long)nonce, (unsigned)rtt); + DEBUG_DEBUG(DEBUG_CATEGORY_CONNECTION, "PONG matched nonce=%016llx rtt=%u want_rtt=%d", + (unsigned long long)nonce, (unsigned)rtt, (flags & ETCP_PING_FLAG_WANT_RTT) ? 1 : 0); + + uint64_t pong_peer_id = be64toh(*(uint64_t*)(pkt->data + 2)); + topo_node_ping_update_rtt(e_sock->instance->topo_groups, pong_peer_id, rtt); + ctx->cb(1, rtt, ctx->arg, nonce, udata, ulen); + + if ((flags & ETCP_PING_FLAG_WANT_RTT) && ctx->peer_pubkey[0] != 0) { + uint8_t rtt_buf[2]; + rtt_buf[0] = (uint8_t)(rtt >> 8); + rtt_buf[1] = (uint8_t)(rtt & 0xFF); + etcp_send_ping_to_socket(e_sock->instance, e_sock, ctx->peer_pubkey, addr, 1000, + rtt_send_ping_cb, NULL, rtt_buf, 2, ETCP_PING_FLAG_SEND_RTT); + } if (ctx->user_data) u_free(ctx->user_data); u_free(ctx); break; @@ -1580,7 +1615,7 @@ void etcp_connections_read_callback_socket(socket_t sock, void* arg) { pkt->data_len=pkt_len-3; pkt->noencrypt_len=0; uint8_t code = pkt->data[0]; - uint64_t peer_id = be64toh(*(uint64_t*)(pkt->data + 1)); + uint64_t peer_id = be64toh(*(uint64_t*)(pkt->data + 2)); if (code == ETCP_PING) { DEBUG_INFO(DEBUG_CATEGORY_CONNECTION, "X25519 decrypted: PING from peer=0x%016llx src=%s", (unsigned long long)peer_id, sockaddr_storage_to_str(&addr).str); diff --git a/src/etcp_connections.h b/src/transport_layer/etcp_connections.h similarity index 98% rename from src/etcp_connections.h rename to src/transport_layer/etcp_connections.h index 7b58585a..8f93f59b 100644 --- a/src/etcp_connections.h +++ b/src/transport_layer/etcp_connections.h @@ -37,6 +37,9 @@ extern "C" { #define ETCP_PONG 0x07 #define ETCP_KEEPALIVE 0x08 +#define ETCP_PING_FLAG_WANT_RTT 0x01 // в PONG: хочу получить RTT от пингера +#define ETCP_PING_FLAG_SEND_RTT 0x02 // в PING: несу RTT для получателя + /* Адаптивный keepalive */ #define KA_PERIOD_MIN_MS 200 #define KA_PERIOD_MAX_MS 10000 @@ -110,6 +113,7 @@ struct PING_CONTEXT { uint64_t nonce; void* timeout_timer; uint64_t send_time; // время отправки пинга в 0.1ms + uint8_t peer_pubkey[SC_PUBKEY_SIZE]; uint8_t* user_data; size_t user_data_len; }; @@ -339,10 +343,12 @@ int etcp_send_ping(struct UTUN_INSTANCE* instance, const uint8_t* peer_pubkey_bi const uint8_t* user_data, size_t user_data_len); // шлёт пинг на addr используя pubkey. в пакет помещает user_data[user_len]. при получении ответа или таймауте вызывает callback. +// flags: ETCP_PING_FLAG_SEND_RTT — user_data содержит RTT для peer int etcp_send_ping_to_socket(struct UTUN_INSTANCE* instance, struct ETCP_SOCKET* e_sock, const uint8_t* peer_pubkey_bin, const struct sockaddr_storage* addr, int timeout_ms, etcp_ping_callback_t cb, void* user_arg, - const uint8_t* user_data, size_t user_data_len); + const uint8_t* user_data, size_t user_data_len, + uint8_t flags); void etcp_connections_read_callback_socket(socket_t sock, void* arg); diff --git a/src/etcp_connections_doc.md b/src/transport_layer/etcp_connections_doc.md similarity index 100% rename from src/etcp_connections_doc.md rename to src/transport_layer/etcp_connections_doc.md diff --git a/src/etcp_debug.c b/src/transport_layer/etcp_debug.c similarity index 100% rename from src/etcp_debug.c rename to src/transport_layer/etcp_debug.c diff --git a/src/etcp_debug.h b/src/transport_layer/etcp_debug.h similarity index 100% rename from src/etcp_debug.h rename to src/transport_layer/etcp_debug.h diff --git a/src/etcp_debug_doc.md b/src/transport_layer/etcp_debug_doc.md similarity index 100% rename from src/etcp_debug_doc.md rename to src/transport_layer/etcp_debug_doc.md diff --git a/src/etcp_doc.md b/src/transport_layer/etcp_doc.md similarity index 100% rename from src/etcp_doc.md rename to src/transport_layer/etcp_doc.md diff --git a/src/etcp_dump.c b/src/transport_layer/etcp_dump.c similarity index 100% rename from src/etcp_dump.c rename to src/transport_layer/etcp_dump.c diff --git a/src/etcp_dump.h b/src/transport_layer/etcp_dump.h similarity index 100% rename from src/etcp_dump.h rename to src/transport_layer/etcp_dump.h diff --git a/src/etcp_dump_doc.md b/src/transport_layer/etcp_dump_doc.md similarity index 100% rename from src/etcp_dump_doc.md rename to src/transport_layer/etcp_dump_doc.md diff --git a/src/etcp_loadbalancer.c b/src/transport_layer/etcp_loadbalancer.c similarity index 100% rename from src/etcp_loadbalancer.c rename to src/transport_layer/etcp_loadbalancer.c diff --git a/src/etcp_loadbalancer.h b/src/transport_layer/etcp_loadbalancer.h similarity index 100% rename from src/etcp_loadbalancer.h rename to src/transport_layer/etcp_loadbalancer.h diff --git a/src/etcp_loadbalancer_doc.md b/src/transport_layer/etcp_loadbalancer_doc.md similarity index 100% rename from src/etcp_loadbalancer_doc.md rename to src/transport_layer/etcp_loadbalancer_doc.md diff --git a/src/etcp_send_test.txt b/src/transport_layer/etcp_send_test.txt similarity index 100% rename from src/etcp_send_test.txt rename to src/transport_layer/etcp_send_test.txt diff --git a/src/packet_dump.c b/src/transport_layer/packet_dump.c similarity index 100% rename from src/packet_dump.c rename to src/transport_layer/packet_dump.c diff --git a/src/packet_dump.h b/src/transport_layer/packet_dump.h similarity index 100% rename from src/packet_dump.h rename to src/transport_layer/packet_dump.h diff --git a/src/packet_dump_doc.md b/src/transport_layer/packet_dump_doc.md similarity index 100% rename from src/packet_dump_doc.md rename to src/transport_layer/packet_dump_doc.md diff --git a/src/pkt_normalizer.c b/src/transport_layer/pkt_normalizer.c similarity index 100% rename from src/pkt_normalizer.c rename to src/transport_layer/pkt_normalizer.c diff --git a/src/pkt_normalizer.h b/src/transport_layer/pkt_normalizer.h similarity index 100% rename from src/pkt_normalizer.h rename to src/transport_layer/pkt_normalizer.h diff --git a/src/pkt_normalizer_doc.md b/src/transport_layer/pkt_normalizer_doc.md similarity index 100% rename from src/pkt_normalizer_doc.md rename to src/transport_layer/pkt_normalizer_doc.md diff --git a/src/secure_channel.c b/src/transport_layer/secure_channel.c similarity index 100% rename from src/secure_channel.c rename to src/transport_layer/secure_channel.c diff --git a/src/secure_channel.h b/src/transport_layer/secure_channel.h similarity index 100% rename from src/secure_channel.h rename to src/transport_layer/secure_channel.h diff --git a/src/secure_channel_doc.md b/src/transport_layer/secure_channel_doc.md similarity index 100% rename from src/secure_channel_doc.md rename to src/transport_layer/secure_channel_doc.md diff --git a/src/stcp.c b/src/transport_layer/stcp.c similarity index 100% rename from src/stcp.c rename to src/transport_layer/stcp.c diff --git a/src/stcp.h b/src/transport_layer/stcp.h similarity index 100% rename from src/stcp.h rename to src/transport_layer/stcp.h diff --git a/src/stcp_client.c b/src/transport_layer/stcp_client.c similarity index 100% rename from src/stcp_client.c rename to src/transport_layer/stcp_client.c diff --git a/src/stcp_client.h b/src/transport_layer/stcp_client.h similarity index 100% rename from src/stcp_client.h rename to src/transport_layer/stcp_client.h diff --git a/src/stcp_client_doc.md b/src/transport_layer/stcp_client_doc.md similarity index 100% rename from src/stcp_client_doc.md rename to src/transport_layer/stcp_client_doc.md diff --git a/src/stcp_doc.md b/src/transport_layer/stcp_doc.md similarity index 100% rename from src/stcp_doc.md rename to src/transport_layer/stcp_doc.md diff --git a/src/stcp_link.c b/src/transport_layer/stcp_link.c similarity index 100% rename from src/stcp_link.c rename to src/transport_layer/stcp_link.c diff --git a/src/stcp_link.h b/src/transport_layer/stcp_link.h similarity index 100% rename from src/stcp_link.h rename to src/transport_layer/stcp_link.h diff --git a/src/stcp_link_doc.md b/src/transport_layer/stcp_link_doc.md similarity index 100% rename from src/stcp_link_doc.md rename to src/transport_layer/stcp_link_doc.md diff --git a/src/stcp_server.c b/src/transport_layer/stcp_server.c similarity index 100% rename from src/stcp_server.c rename to src/transport_layer/stcp_server.c diff --git a/src/stcp_server.h b/src/transport_layer/stcp_server.h similarity index 100% rename from src/stcp_server.h rename to src/transport_layer/stcp_server.h diff --git a/src/stcp_server_doc.md b/src/transport_layer/stcp_server_doc.md similarity index 100% rename from src/stcp_server_doc.md rename to src/transport_layer/stcp_server_doc.md diff --git a/tests/Makefile.am b/tests/Makefile.am index 3e97bedc..63628172 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -64,7 +64,8 @@ check_PROGRAMS = \ noinst_PROGRAMS = # Basic includes -AM_CFLAGS = -g -I$(top_srcdir)/src -I$(top_srcdir)/lib +AM_CFLAGS = -g +AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/src/transport_layer -I$(top_srcdir)/src/routing_layer -I$(top_srcdir)/lib LIBUTUN = $(top_builddir)/src/libutun.a # Windows-specific libraries diff --git a/tests/bbr_integration/test_bbr_integration.c b/tests/bbr_integration/test_bbr_integration.c index f1641f59..47030242 100644 --- a/tests/bbr_integration/test_bbr_integration.c +++ b/tests/bbr_integration/test_bbr_integration.c @@ -25,17 +25,17 @@ #include "../lib/debug_config.h" #include "../lib/platform_compat.h" #include "../lib/mem.h" -#include "../src/dummynet.h" +#include "dummynet.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/etcp.h" -#include "../src/etcp_api.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_bbr.h" -#include "../src/secure_channel.h" +#include "etcp.h" +#include "etcp_api.h" +#include "etcp_connections.h" +#include "etcp_bbr.h" +#include "secure_channel.h" #include "../src/config_updater.h" -#include "../src/routing.h" -#include "../src/crc32.h" +#include "routing.h" +#include "crc32.h" /* ===== Test constants ===== */ #define DN_PORT 21001 diff --git a/tests/test_bgp_route_exchange.c b/tests/test_bgp_route_exchange.c index 30859238..66207f20 100644 --- a/tests/test_bgp_route_exchange.c +++ b/tests/test_bgp_route_exchange.c @@ -32,17 +32,17 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/routing.h" -#include "../src/route_lib.h" -#include "../src/topo_group.h" -#include "../src/dummynet.h" +#include "routing.h" +#include "route_lib.h" +#include "topo_group.h" +#include "dummynet.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" #include "../lib/mem.h" diff --git a/tests/test_bgp_triangle.c b/tests/test_bgp_triangle.c index bd687723..9d6750d4 100644 --- a/tests/test_bgp_triangle.c +++ b/tests/test_bgp_triangle.c @@ -36,18 +36,18 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/routing.h" -#include "../src/route_lib.h" -#include "../src/topo_group.h" -#include "../src/topo_node.h" -#include "../src/dummynet.h" +#include "routing.h" +#include "route_lib.h" +#include "topo_group.h" +#include "topo_node.h" +#include "dummynet.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" #include "../lib/mem.h" diff --git a/tests/test_chat_sync_stress.c b/tests/test_chat_sync_stress.c index 7a23f3e5..6b90b088 100644 --- a/tests/test_chat_sync_stress.c +++ b/tests/test_chat_sync_stress.c @@ -17,7 +17,7 @@ #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/db_sync.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" diff --git a/tests/test_conn_mgr.c b/tests/test_conn_mgr.c index aa5e7557..a6673d2e 100644 --- a/tests/test_conn_mgr.c +++ b/tests/test_conn_mgr.c @@ -20,13 +20,13 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/topo_group.h" -#include "../src/conn_mgr.h" +#include "topo_group.h" +#include "conn_mgr.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" #include "../lib/mem.h" diff --git a/tests/test_db_sync.c b/tests/test_db_sync.c index 41bba303..1e2255ae 100644 --- a/tests/test_db_sync.c +++ b/tests/test_db_sync.c @@ -14,15 +14,15 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" +#include "secure_channel.h" #include "../src/db_sync.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" diff --git a/tests/test_dummynet.c b/tests/test_dummynet.c index c4907ff3..e1e28329 100644 --- a/tests/test_dummynet.c +++ b/tests/test_dummynet.c @@ -18,7 +18,7 @@ #include "../lib/u_async.h" #include "../lib/socket_compat.h" #include "../lib/debug_config.h" -#include "../src/dummynet.h" +#include "dummynet.h" #define LISTEN_PORT 18000 #define PKT_COUNT 1000 diff --git a/tests/test_etcp_100_packets.c b/tests/test_etcp_100_packets.c index d069d688..7c87c70b 100644 --- a/tests/test_etcp_100_packets.c +++ b/tests/test_etcp_100_packets.c @@ -12,13 +12,13 @@ #include #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_api.c b/tests/test_etcp_api.c index 56bfc786..3fdca458 100644 --- a/tests/test_etcp_api.c +++ b/tests/test_etcp_api.c @@ -21,15 +21,15 @@ #include #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_api.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "etcp_api.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" -#include "../src/pkt_normalizer.h" +#include "secure_channel.h" +#include "pkt_normalizer.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_bbr.c b/tests/test_etcp_bbr.c index 86fde0c1..17e6fdb8 100644 --- a/tests/test_etcp_bbr.c +++ b/tests/test_etcp_bbr.c @@ -1,4 +1,4 @@ -#include "../src/etcp_bbr.h" +#include "etcp_bbr.h" #include #include #include diff --git a/tests/test_etcp_congestion.c b/tests/test_etcp_congestion.c index eea561b4..4f768d58 100644 --- a/tests/test_etcp_congestion.c +++ b/tests/test_etcp_congestion.c @@ -26,16 +26,16 @@ #include "../lib/debug_config.h" #include "../lib/platform_compat.h" #include "../lib/mem.h" -#include "../src/dummynet.h" +#include "dummynet.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/etcp.h" -#include "../src/etcp_api.h" -#include "../src/etcp_connections.h" -#include "../src/secure_channel.h" +#include "etcp.h" +#include "etcp_api.h" +#include "etcp_connections.h" +#include "secure_channel.h" #include "../src/config_updater.h" -#include "../src/routing.h" -#include "../src/crc32.h" +#include "routing.h" +#include "crc32.h" /* ===== Конфигурация теста ===== */ #define TEST_DURATION_MS 25000 diff --git a/tests/test_etcp_connect.c b/tests/test_etcp_connect.c index b884294e..c9f6bcaf 100644 --- a/tests/test_etcp_connect.c +++ b/tests/test_etcp_connect.c @@ -8,15 +8,15 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_api.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "etcp_api.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/topo_group.h" -#include "../src/topo_node.h" -#include "../src/secure_channel.h" +#include "topo_group.h" +#include "topo_node.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_crypto.c b/tests/test_etcp_crypto.c index 053d8c78..7027a472 100644 --- a/tests/test_etcp_crypto.c +++ b/tests/test_etcp_crypto.c @@ -1,5 +1,5 @@ // test_etcp_crypto.c - ETCP encryption/decryption test -#include "../src/secure_channel.h" +#include "secure_channel.h" #include #include #include diff --git a/tests/test_etcp_dummynet.c b/tests/test_etcp_dummynet.c index 4bf3ed5d..12a64278 100644 --- a/tests/test_etcp_dummynet.c +++ b/tests/test_etcp_dummynet.c @@ -18,16 +18,16 @@ #include "../lib/memory_pool.h" #include "../lib/debug_config.h" #include "../lib/platform_compat.h" -#include "../src/dummynet.h" +#include "dummynet.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/etcp.h" -#include "../src/etcp_api.h" -#include "../src/etcp_connections.h" -#include "../src/secure_channel.h" +#include "etcp.h" +#include "etcp_api.h" +#include "etcp_connections.h" +#include "secure_channel.h" #include "../src/config_updater.h" -#include "../src/routing.h" -#include "../src/crc32.h" +#include "routing.h" +#include "crc32.h" #include "../lib/mem.h" #define SEND_MS 1000 diff --git a/tests/test_etcp_link_id.c b/tests/test_etcp_link_id.c index 0ea1b7b8..b7970492 100644 --- a/tests/test_etcp_link_id.c +++ b/tests/test_etcp_link_id.c @@ -1,8 +1,8 @@ // test_etcp_link_id.c - Unit test for etcp_find_free_local_link_id function // Tests: empty connection, full allocation, random deletion/addition cycles -#include "../src/etcp_connections.h" -#include "../src/etcp.h" +#include "etcp_connections.h" +#include "etcp.h" #include #include #include diff --git a/tests/test_etcp_minimal.c b/tests/test_etcp_minimal.c index 0911b84d..852258a7 100644 --- a/tests/test_etcp_minimal.c +++ b/tests/test_etcp_minimal.c @@ -1,7 +1,7 @@ // test_etcp_minimal.c - Minimal ETCP traffic debugging test // This is the most basic test to verify ETCP packet processing works -#include "../src/etcp.h" +#include "etcp.h" #include "../lib/debug_config.h" #include #include diff --git a/tests/test_etcp_ping.c b/tests/test_etcp_ping.c index 03954cdc..9faa6cfa 100644 --- a/tests/test_etcp_ping.c +++ b/tests/test_etcp_ping.c @@ -6,13 +6,13 @@ #include #include #include "test_utils.h" -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_reconnect.c b/tests/test_etcp_reconnect.c index 5807858c..ceb2e13f 100644 --- a/tests/test_etcp_reconnect.c +++ b/tests/test_etcp_reconnect.c @@ -14,14 +14,14 @@ #include #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" -#include "../src/etcp_dump.h" +#include "secure_channel.h" +#include "etcp_dump.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_reinit_inflight.c b/tests/test_etcp_reinit_inflight.c index ef68d228..72b23200 100644 --- a/tests/test_etcp_reinit_inflight.c +++ b/tests/test_etcp_reinit_inflight.c @@ -14,15 +14,15 @@ #include "../lib/debug_config.h" #include "../lib/platform_compat.h" #include "../lib/mem.h" -#include "../src/dummynet.h" +#include "dummynet.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/etcp.h" -#include "../src/etcp_api.h" -#include "../src/etcp_connections.h" -#include "../src/secure_channel.h" +#include "etcp.h" +#include "etcp_api.h" +#include "etcp_connections.h" +#include "secure_channel.h" #include "../src/config_updater.h" -#include "../src/routing.h" +#include "routing.h" #define CLI_PORT 31000 #define DN_PORT 31001 diff --git a/tests/test_etcp_router.c b/tests/test_etcp_router.c index 296c6937..beea0f1a 100644 --- a/tests/test_etcp_router.c +++ b/tests/test_etcp_router.c @@ -19,18 +19,18 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_api.h" -#include "../src/etcp_router.h" -#include "../src/dummynet.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "etcp_api.h" +#include "etcp_router.h" +#include "dummynet.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" -#include "../src/pkt_normalizer.h" -#include "../src/topo_group.h" +#include "secure_channel.h" +#include "pkt_normalizer.h" +#include "topo_group.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_router_reconnect.c b/tests/test_etcp_router_reconnect.c index 2cb15a8b..6adc8caa 100644 --- a/tests/test_etcp_router_reconnect.c +++ b/tests/test_etcp_router_reconnect.c @@ -16,17 +16,17 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_router.h" -#include "../src/etcp_api.h" -#include "../src/topo_group.h" -#include "../src/topo_node.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "etcp_router.h" +#include "etcp_api.h" +#include "topo_group.h" +#include "topo_node.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_router_unit.c b/tests/test_etcp_router_unit.c index 433de172..4f9324a1 100644 --- a/tests/test_etcp_router_unit.c +++ b/tests/test_etcp_router_unit.c @@ -8,10 +8,10 @@ #include #include -#include "../src/etcp.h" -#include "../src/etcp_api.h" -#include "../src/etcp_router.h" -#include "../src/topo_group.h" +#include "etcp.h" +#include "etcp_api.h" +#include "etcp_router.h" +#include "topo_group.h" #include "../src/utun_instance.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" diff --git a/tests/test_etcp_simple_traffic.c b/tests/test_etcp_simple_traffic.c index 7c9b66d3..a97cd783 100644 --- a/tests/test_etcp_simple_traffic.c +++ b/tests/test_etcp_simple_traffic.c @@ -14,13 +14,13 @@ #include #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_etcp_stcp.c b/tests/test_etcp_stcp.c index d96581b6..c6528ea9 100644 --- a/tests/test_etcp_stcp.c +++ b/tests/test_etcp_stcp.c @@ -1,8 +1,8 @@ // test_etcp_stcp.c — integration: etcp_send + etcp_bind over STCP link -#include "../src/stcp_link.h" -#include "../src/etcp_api.h" -#include "../src/etcp.h" -#include "../src/secure_channel.h" +#include "stcp_link.h" +#include "etcp_api.h" +#include "etcp.h" +#include "secure_channel.h" #include "../src/utun_instance.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" diff --git a/tests/test_etcp_two_instances.c b/tests/test_etcp_two_instances.c index f3b6b80d..ee03e253 100644 --- a/tests/test_etcp_two_instances.c +++ b/tests/test_etcp_two_instances.c @@ -12,13 +12,13 @@ #include #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" diff --git a/tests/test_icmp_proxy.c b/tests/test_icmp_proxy.c index 43137fb4..149019ff 100644 --- a/tests/test_icmp_proxy.c +++ b/tests/test_icmp_proxy.c @@ -17,15 +17,15 @@ #endif #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_api.h" -#include "../src/etcp_router.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "etcp_api.h" +#include "etcp_router.h" #include "../src/proxy/icmp_proxy.h" #include "../src/proxy/tcp_proxy_server.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" diff --git a/tests/test_ipv6_sockets.c b/tests/test_ipv6_sockets.c index 4e1101c4..a10e2aa0 100644 --- a/tests/test_ipv6_sockets.c +++ b/tests/test_ipv6_sockets.c @@ -28,16 +28,16 @@ #include #endif -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" -#include "../src/route_lib.h" -#include "../src/topo_group.h" -#include "../src/topo_node.h" +#include "routing.h" +#include "route_lib.h" +#include "topo_group.h" +#include "topo_node.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" diff --git a/tests/test_nat_detection.c b/tests/test_nat_detection.c index f0446137..d2142c20 100644 --- a/tests/test_nat_detection.c +++ b/tests/test_nat_detection.c @@ -15,18 +15,18 @@ #include #include #include "test_utils.h" -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/routing.h" -#include "../src/topo_group.h" -#include "../src/route_ping.h" -#include "../src/nat_detection.h" -#include "../src/topo_node.h" +#include "routing.h" +#include "topo_group.h" +#include "route_ping.h" +#include "nat_detection.h" +#include "topo_node.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" diff --git a/tests/test_nat_engine.c b/tests/test_nat_engine.c index b51b342f..601377f5 100644 --- a/tests/test_nat_engine.c +++ b/tests/test_nat_engine.c @@ -13,7 +13,7 @@ #include #include "../lib/debug_config.h" #include "../src/eim_nat.h" -#include "../src/etcp.h" +#include "etcp.h" #include "../src/config_parser.h" #ifdef ENABLE_STATIC_ASSERT diff --git a/tests/test_nat_stress.c b/tests/test_nat_stress.c index d1ee3781..15d5de48 100644 --- a/tests/test_nat_stress.c +++ b/tests/test_nat_stress.c @@ -12,7 +12,7 @@ #include #include "../lib/debug_config.h" #include "../src/eim_nat.h" -#include "../src/etcp.h" +#include "etcp.h" #include "../src/config_parser.h" static struct { diff --git a/tests/test_nat_transport.c b/tests/test_nat_transport.c index 245c82ca..dc3d3b4c 100644 --- a/tests/test_nat_transport.c +++ b/tests/test_nat_transport.c @@ -15,18 +15,18 @@ #include #include #include "test_utils.h" -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/routing.h" -#include "../src/topo_group.h" +#include "routing.h" +#include "topo_group.h" #include "../src/tun_if.h" #include "../src/nat_transport.h" #include "../src/eim_nat.h" -#include "../src/etcp_api.h" -#include "../src/etcp_router.h" +#include "etcp_api.h" +#include "etcp_router.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" #include "../lib/mem.h" diff --git a/tests/test_pkt_normalizer_etcp.c b/tests/test_pkt_normalizer_etcp.c index 5312ef9d..d9c12a61 100644 --- a/tests/test_pkt_normalizer_etcp.c +++ b/tests/test_pkt_normalizer_etcp.c @@ -12,14 +12,14 @@ #include #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" -#include "../src/pkt_normalizer.h" +#include "secure_channel.h" +#include "pkt_normalizer.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_pkt_normalizer_standalone.c b/tests/test_pkt_normalizer_standalone.c index 1f8b5309..953b9770 100644 --- a/tests/test_pkt_normalizer_standalone.c +++ b/tests/test_pkt_normalizer_standalone.c @@ -9,8 +9,8 @@ #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/memory_pool.h" -#include "../src/pkt_normalizer.h" -#include "../src/etcp.h" +#include "pkt_normalizer.h" +#include "etcp.h" // Weak stub for etcp_conn_reinit — overridden if real ETCP is linked // Weak stub for etcp_conn_reinit - can be overridden by real ETCP implementation diff --git a/tests/test_route6_lib.c b/tests/test_route6_lib.c index a27890fd..cc49463e 100644 --- a/tests/test_route6_lib.c +++ b/tests/test_route6_lib.c @@ -3,8 +3,8 @@ #include #include #include -#include "../src/topo_node.h" -#include "../src/route6_lib.h" +#include "topo_node.h" +#include "route6_lib.h" #include "../lib/debug_config.h" #include "../lib/mem.h" #include "../lib/u_async.h" diff --git a/tests/test_route_ping.c b/tests/test_route_ping.c index 73852bfb..8d80b6a3 100644 --- a/tests/test_route_ping.c +++ b/tests/test_route_ping.c @@ -15,16 +15,16 @@ #include #include #include "test_utils.h" -#include "../src/etcp.h" -#include "../src/etcp_connections.h" +#include "etcp.h" +#include "etcp_connections.h" #include "../src/config_parser.h" #include "../src/config_updater.h" #include "../src/utun_instance.h" -#include "../src/routing.h" -#include "../src/topo_group.h" -#include "../src/route_ping.h" +#include "routing.h" +#include "topo_group.h" +#include "route_ping.h" #include "../src/tun_if.h" -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/debug_config.h" diff --git a/tests/test_socks_http_proxy.c b/tests/test_socks_http_proxy.c index 832ca54e..ac9235f8 100644 --- a/tests/test_socks_http_proxy.c +++ b/tests/test_socks_http_proxy.c @@ -23,13 +23,13 @@ #include "../lib/debug_config.h" #include "../lib/ll_queue.h" #include "../lib/mem.h" -#include "../src/etcp.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_api.h" -#include "../src/etcp_router.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "etcp_api.h" +#include "etcp_router.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" #define TIMEOUT_MS 300000 diff --git a/tests/test_stcp.c b/tests/test_stcp.c index f469c2a8..69442ad9 100644 --- a/tests/test_stcp.c +++ b/tests/test_stcp.c @@ -1,8 +1,8 @@ // test_stcp.c — comprehensive STCP integration tests -#include "../src/stcp.h" -#include "../src/stcp_server.h" -#include "../src/stcp_client.h" -#include "../src/secure_channel.h" +#include "stcp.h" +#include "stcp_server.h" +#include "stcp_client.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_stcp_link.c b/tests/test_stcp_link.c index c9ff93e8..ac7835ed 100644 --- a/tests/test_stcp_link.c +++ b/tests/test_stcp_link.c @@ -1,6 +1,6 @@ // test_stcp_link.c — integration test for stcp_link API (TCP via STCP) -#include "../src/stcp_link.h" -#include "../src/secure_channel.h" +#include "stcp_link.h" +#include "secure_channel.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" #include "../lib/debug_config.h" diff --git a/tests/test_stcp_traffic.c b/tests/test_stcp_traffic.c index d015f0fe..9b1af0ad 100644 --- a/tests/test_stcp_traffic.c +++ b/tests/test_stcp_traffic.c @@ -1,11 +1,11 @@ // test_stcp_traffic.c — STCP transport test: 2 nodes, 1MB bidirectional, random packets, content verify -#include "../src/stcp_link.h" -#include "../src/etcp_api.h" -#include "../src/etcp.h" -#include "../src/secure_channel.h" -#include "../src/etcp_connections.h" -#include "../src/topo_group.h" -#include "../src/topo_node.h" +#include "stcp_link.h" +#include "etcp_api.h" +#include "etcp.h" +#include "secure_channel.h" +#include "etcp_connections.h" +#include "topo_group.h" +#include "topo_node.h" #include "../src/utun_instance.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" diff --git a/tests/test_stream_cipher.c b/tests/test_stream_cipher.c index b215f5a4..ba25bae4 100644 --- a/tests/test_stream_cipher.c +++ b/tests/test_stream_cipher.c @@ -1,5 +1,5 @@ // test_stream_cipher.c — tests for streaming cipher (AES-128-CTR) -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/debug_config.h" #include #include diff --git a/tests/test_stream_sign.c b/tests/test_stream_sign.c index 75551617..684a358f 100644 --- a/tests/test_stream_sign.c +++ b/tests/test_stream_sign.c @@ -1,5 +1,5 @@ // test_stream_sign.c — tests for streaming Ed25519 signature -#include "../src/secure_channel.h" +#include "secure_channel.h" #include "../lib/debug_config.h" #include #include diff --git a/tests/test_tcp_proxy_remote.c b/tests/test_tcp_proxy_remote.c index a1536abc..d7673a88 100644 --- a/tests/test_tcp_proxy_remote.c +++ b/tests/test_tcp_proxy_remote.c @@ -17,8 +17,8 @@ #include #include "../src/proxy/tcp_proxy_client.h" -#include "../src/etcp.h" -#include "../src/etcp_router.h" +#include "etcp.h" +#include "etcp_router.h" #include "../src/proxy/tcp_proxy_server.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" diff --git a/tests/test_udp_proxy.c b/tests/test_udp_proxy.c index 8e6654f0..d0d923c5 100644 --- a/tests/test_udp_proxy.c +++ b/tests/test_udp_proxy.c @@ -15,15 +15,15 @@ #endif #include -#include "../src/etcp.h" -#include "../src/etcp_connections.h" -#include "../src/etcp_api.h" -#include "../src/etcp_router.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "etcp_api.h" +#include "etcp_router.h" #include "../src/proxy/udp_proxy.h" #include "../src/proxy/tcp_proxy_server.h" #include "../src/config_parser.h" #include "../src/utun_instance.h" -#include "../src/routing.h" +#include "routing.h" #include "../src/tun_if.h" #include "../lib/u_async.h" #include "../lib/ll_queue.h" diff --git a/tools/chatgui/libutun/CMakeLists.txt b/tools/chatgui/libutun/CMakeLists.txt index 62857b05..be040aa3 100644 --- a/tools/chatgui/libutun/CMakeLists.txt +++ b/tools/chatgui/libutun/CMakeLists.txt @@ -56,47 +56,47 @@ set(UTUN_COMMON_SOURCES ${SRC_DIR}/utun_instance.c ${SRC_DIR}/config_parser.c ${SRC_DIR}/config_updater.c - ${SRC_DIR}/route_lib.c - ${SRC_DIR}/route6_lib.c - ${SRC_DIR}/topo_group.c - ${SRC_DIR}/route_ping.c - ${SRC_DIR}/nat_detection.c - ${SRC_DIR}/topo_node.c - ${SRC_DIR}/topo_node_sqlite.c - ${SRC_DIR}/route_connectivity.c + ${SRC_DIR}/routing_layer/route_lib.c + ${SRC_DIR}/routing_layer/route6_lib.c + ${SRC_DIR}/routing_layer/topo_group.c + ${SRC_DIR}/routing_layer/route_ping.c + ${SRC_DIR}/routing_layer/nat_detection.c + ${SRC_DIR}/routing_layer/topo_node.c + ${SRC_DIR}/routing_layer/topo_node_sqlite.c + ${SRC_DIR}/routing_layer/route_connectivity.c ${SRC_DIR}/db_sync.c - ${SRC_DIR}/conn_mgr.c + ${SRC_DIR}/routing_layer/conn_mgr.c ${TRANSPORT_DIR}/chat_sync.c ${TRANSPORT_DIR}/merkle_sync.c ${TRANSPORT_DIR}/member_sync.c - ${SRC_DIR}/routing.c + ${SRC_DIR}/routing_layer/routing.c ${SRC_DIR}/tun_if.c ${SRC_DIR}/tun_route.c - ${SRC_DIR}/etcp.c - ${SRC_DIR}/etcp_connections.c - ${SRC_DIR}/etcp_bbr.c - ${SRC_DIR}/etcp_loadbalancer.c - ${SRC_DIR}/etcp_debug.c - ${SRC_DIR}/etcp_dump.c - ${SRC_DIR}/secure_channel.c - ${SRC_DIR}/crc32.c - ${SRC_DIR}/stcp_link.c - ${SRC_DIR}/stcp.c - ${SRC_DIR}/stcp_server.c - ${SRC_DIR}/stcp_client.c - ${SRC_DIR}/pkt_normalizer.c - ${SRC_DIR}/packet_dump.c - ${SRC_DIR}/etcp_api.c - ${SRC_DIR}/etcp_connect.c + ${SRC_DIR}/transport_layer/etcp.c + ${SRC_DIR}/transport_layer/etcp_connections.c + ${SRC_DIR}/transport_layer/etcp_bbr.c + ${SRC_DIR}/transport_layer/etcp_loadbalancer.c + ${SRC_DIR}/transport_layer/etcp_debug.c + ${SRC_DIR}/transport_layer/etcp_dump.c + ${SRC_DIR}/transport_layer/secure_channel.c + ${SRC_DIR}/transport_layer/crc32.c + ${SRC_DIR}/transport_layer/stcp_link.c + ${SRC_DIR}/transport_layer/stcp.c + ${SRC_DIR}/transport_layer/stcp_server.c + ${SRC_DIR}/transport_layer/stcp_client.c + ${SRC_DIR}/transport_layer/pkt_normalizer.c + ${SRC_DIR}/transport_layer/packet_dump.c + ${SRC_DIR}/transport_layer/etcp_api.c + ${SRC_DIR}/transport_layer/etcp_connect.c ${SRC_DIR}/control_server.c ${SRC_DIR}/msg_transport.c ${SRC_DIR}/firewall.c ${SRC_DIR}/eim_nat.c ${SRC_DIR}/nat_transport.c - ${SRC_DIR}/dummynet.c + ${SRC_DIR}/transport_layer/dummynet.c ${SRC_DIR}/ntp_time.c ${SRC_DIR}/ntp_node_time.c - ${SRC_DIR}/etcp_router.c + ${SRC_DIR}/routing_layer/etcp_router.c ${SRC_DIR}/proxy/tcp_proxy_client.c ${SRC_DIR}/proxy/tcp_proxy_server.c ${SRC_DIR}/proxy/udp_proxy.c @@ -123,6 +123,8 @@ add_library(utun STATIC ${UTUN_COMMON_SOURCES} ${UTUN_TUN_SOURCES}) target_include_directories(utun PUBLIC ${SRC_DIR} + ${SRC_DIR}/transport_layer + ${SRC_DIR}/routing_layer ${LIB_DIR} ${TRANSPORT_DIR} ${SRC_DIR}/uip diff --git a/tools/chatgui/src/joindialog.cpp b/tools/chatgui/src/joindialog.cpp index ffb1a0f5..cca19499 100644 --- a/tools/chatgui/src/joindialog.cpp +++ b/tools/chatgui/src/joindialog.cpp @@ -14,7 +14,7 @@ #include extern "C" { -#include "../../../src/secure_channel.h" +#include "secure_channel.h" #include "../../../lib/sha256.h" } diff --git a/tools/chatgui/transport/chat_conn_mgr.c b/tools/chatgui/transport/chat_conn_mgr.c index efaf5b5a..fc27f2a7 100644 --- a/tools/chatgui/transport/chat_conn_mgr.c +++ b/tools/chatgui/transport/chat_conn_mgr.c @@ -11,10 +11,10 @@ #include "gui_bridge.h" #include "../../../src/utun_instance.h" -#include "../../../src/etcp_api.h" -#include "../../../src/etcp.h" -#include "../../../src/etcp_connections.h" -#include "../../../src/secure_channel.h" +#include "etcp_api.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "secure_channel.h" #include "../../../lib/u_async.h" #include "../../../lib/ll_queue.h" #include "../../../lib/mem.h" @@ -516,7 +516,7 @@ static void cm_ping_timer_cb(void* arg) { if (cm_addr_taken(node, ai)) { mgr->ping_timer = uasync_set_timeout(mgr->inst->ua, CM_PING_TB, mgr, cm_ping_timer_cb, "cm_ping"); return; } struct ETCP_SOCKET* sock = cm_best_socket(mgr); - if (sock) etcp_send_ping_to_socket(mgr->inst, sock, node->pubkey, &node->addrs[ai].sa, CM_PING_TIMEOUT_MS, cm_ping_result_cb, &node->addrs[ai], NULL, 0); + if (sock) etcp_send_ping_to_socket(mgr->inst, sock, node->pubkey, &node->addrs[ai].sa, CM_PING_TIMEOUT_MS, cm_ping_result_cb, &node->addrs[ai], NULL, 0, 0); mgr->ping_timer = uasync_set_timeout(mgr->inst->ua, CM_PING_TB, mgr, cm_ping_timer_cb, "cm_ping"); } diff --git a/tools/chatgui/transport/chat_core.c b/tools/chatgui/transport/chat_core.c index 40773669..c869be2d 100644 --- a/tools/chatgui/transport/chat_core.c +++ b/tools/chatgui/transport/chat_core.c @@ -14,10 +14,10 @@ #include "member_sync.h" #include "../../../src/utun_instance.h" -#include "../../../src/etcp_api.h" -#include "../../../src/etcp.h" -#include "../../../src/etcp_connections.h" -#include "../../../src/secure_channel.h" +#include "etcp_api.h" +#include "etcp.h" +#include "etcp_connections.h" +#include "secure_channel.h" #include "../../../src/ntp_time.h" #include "../../../lib/u_async.h" #include "../../../lib/ll_queue.h" diff --git a/tools/chatgui/transport/chat_sync.c b/tools/chatgui/transport/chat_sync.c index 527b60cf..72df5542 100644 --- a/tools/chatgui/transport/chat_sync.c +++ b/tools/chatgui/transport/chat_sync.c @@ -8,9 +8,9 @@ #include "merkle_sync.h" #include "../../../src/utun_instance.h" -#include "../../../src/etcp_api.h" -#include "../../../src/etcp.h" -#include "../../../src/secure_channel.h" +#include "etcp_api.h" +#include "etcp.h" +#include "secure_channel.h" #include "../../../src/ntp_time.h" #include "../../../lib/u_async.h" #include "../../../lib/ll_queue.h" diff --git a/tools/chatgui/transport/merkle_sync.c b/tools/chatgui/transport/merkle_sync.c index 66d9eb93..94df19d6 100644 --- a/tools/chatgui/transport/merkle_sync.c +++ b/tools/chatgui/transport/merkle_sync.c @@ -1,8 +1,8 @@ #include "merkle_sync.h" #include "../../../src/utun_instance.h" -#include "../../../src/etcp_api.h" -#include "../../../src/etcp.h" +#include "etcp_api.h" +#include "etcp.h" #include "../../../lib/debug_config.h" #include "../../../lib/mem.h" #include "../../../lib/u_async.h" diff --git a/tools/chatgui/transport/utun_node.cpp b/tools/chatgui/transport/utun_node.cpp index 1ce4fa95..ba0965f1 100644 --- a/tools/chatgui/transport/utun_node.cpp +++ b/tools/chatgui/transport/utun_node.cpp @@ -26,7 +26,7 @@ extern "C" { #include "chat_core.h" #include "db_sync.h" #include "gui_bridge.h" -#include "../src/topo_node_sqlite.h" +#include "topo_node_sqlite.h" } #define ETCP_RT_ID_CHAT 0x11