diff --git a/tests/test_etcp_two_instances.c b/tests/test_etcp_two_instances.c index 4ae5aa97..e7ddfcbd 100644 --- a/tests/test_etcp_two_instances.c +++ b/tests/test_etcp_two_instances.c @@ -163,7 +163,7 @@ static void monitor_connections(void* arg) { return; } - // Convert nat_ip to string for display + // 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); @@ -174,11 +174,26 @@ static void monitor_connections(void* arg) { 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)", + // Verify NAT IP is 127.0.0.1 (localhost) since client connects from localhost + // In host byte order: 127.0.0.1 = 0x7F000001 + if (link->nat_ip != 0x7F000001) { + DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[CLIENT] FAIL: NAT IP is not 127.0.0.1 (expected 0x7F000001, got 0x%08X)", link->nat_ip); + test_completed = 2; // Failure + return; } + + // Verify NAT port is in valid ephemeral port range (> 1024, typically) + // Ephemeral ports are usually 32768-60999, but can be any > 1024 + if (link->nat_port <= 1024 || link->nat_port > 65535) { + DEBUG_ERROR(DEBUG_CATEGORY_ETCP, "[CLIENT] FAIL: NAT port %u is out of valid range (expected > 1024 and <= 65535)", + link->nat_port); + test_completed = 2; // Failure + return; + } + + DEBUG_INFO(DEBUG_CATEGORY_ETCP, "[CLIENT] PASS: NAT IP and port contain valid values (127.0.0.1:%u)", + link->nat_port); } } link = link->next;