diff --git a/tests/test_etcp_two_instances.c b/tests/test_etcp_two_instances.c index 8c9e79de..4ae5aa97 100644 --- a/tests/test_etcp_two_instances.c +++ b/tests/test_etcp_two_instances.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "../src/etcp.h" #include "../src/etcp_connections.h" @@ -148,6 +149,36 @@ static void monitor_connections(void* arg) { link->init_retry_count); if (link->initialized) { client_initialized = 1; + + // Check NAT fields are populated + DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[CLIENT] Checking NAT fields..."); + if (link->nat_ip == 0) { + DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[CLIENT] FAIL: nat_ip is 0 (should be set)"); + test_completed = 2; // Failure + return; + } + if (link->nat_port == 0) { + DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[CLIENT] FAIL: nat_port is 0 (should be set)"); + test_completed = 2; // Failure + return; + } + + // Convert nat_ip to string for display + char nat_ip_str[INET_ADDRSTRLEN]; + struct in_addr nat_addr; + nat_addr.s_addr = htonl(link->nat_ip); + inet_ntop(AF_INET, &nat_addr, nat_ip_str, sizeof(nat_ip_str)); + + DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[CLIENT] PASS: NAT address is set: %s:%u", + nat_ip_str, link->nat_port); + DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[CLIENT] PASS: nat_changes_count=%u, nat_hits_count=%u", + link->nat_changes_count, link->nat_hits_count); + + // Verify it's localhost (127.0.0.1) since we're testing locally + if (link->nat_ip != 0x7F000001) { // 127.0.0.1 in host byte order + DEBUG_WARN(DEBUG_CATEGORY_ETCP, "[CLIENT] WARNING: NAT IP is not 127.0.0.1 (got 0x%08X)", + link->nat_ip); + } } } link = link->next;