|
|
|
|
@ -127,11 +127,12 @@ static void run_case(enum fault_mode mode, uint8_t mapping, uint8_t inbound) {
|
|
|
|
|
nat_detection_set_automatic(owner->nat_det, 0); |
|
|
|
|
memset(&fault, 0, sizeof(fault)); fault.fixture = &fixture; fault.owner = owner; |
|
|
|
|
fault.observer = observer; fault.helper = helper; fault.socket = test_etcp_bound_socket(owner, "udp"); fault.mode = mode; |
|
|
|
|
assert(!nat_detection_request_check_socket(owner->nat_det, fault.socket, observer->node_id)); |
|
|
|
|
struct nat_check_status status = {0}; |
|
|
|
|
nat_detection_get_status(owner->nat_det, fault.socket, &status); uint32_t rounds = status.rounds; |
|
|
|
|
assert(!nat_detection_request_check_socket(owner->nat_det, fault.socket, observer->node_id)); |
|
|
|
|
uint64_t end = get_time_tb() + 400000; |
|
|
|
|
do { test_clock_poll(fixture.ua, 1000); assert(!nat_detection_get_status(owner->nat_det, fault.socket, &status)); } |
|
|
|
|
while (get_time_tb() < end && (!status.rounds || status.phase || status.cycling)); |
|
|
|
|
while (get_time_tb() < end && (status.rounds == rounds || status.phase || status.cycling)); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_NAT, "fault fixture result mode=%d mapping=%s inbound=%s phase=%u cycling=%u reason=%s dropped=%u observations=%u", |
|
|
|
|
mode, address_mapping_name(fault.socket->address_profile.mapping), address_inbound_name(fault.socket->address_profile.inbound), |
|
|
|
|
status.phase, status.cycling, nat_check_reason_name(status.reason), fault.dropped, fault.observations); |
|
|
|
|
@ -163,10 +164,11 @@ static void run_alias(const char *alias_ip) {
|
|
|
|
|
struct ETCP_SOCKET *socket = test_etcp_bound_socket(owner, "udp"); |
|
|
|
|
memset(&fault, 0, sizeof(fault)); fault.fixture = &fixture; fault.owner = owner; fault.socket = socket; |
|
|
|
|
fault.observer = observer; fault.helper = helper; fault.alias = alias; fault.alias_source = test_etcp_bound_socket(alias, "alias"); |
|
|
|
|
assert(!nat_detection_request_check_socket(owner->nat_det, socket, observer->node_id)); |
|
|
|
|
struct nat_check_status status = {0}; uint64_t end = get_time_tb() + 400000; |
|
|
|
|
nat_detection_get_status(owner->nat_det, socket, &status); uint32_t rounds = status.rounds; |
|
|
|
|
assert(!nat_detection_request_check_socket(owner->nat_det, socket, observer->node_id)); |
|
|
|
|
do { test_clock_poll(fixture.ua, 1000); assert(!nat_detection_get_status(owner->nat_det, socket, &status)); } |
|
|
|
|
while (get_time_tb() < end && (!status.rounds || status.phase || status.cycling)); |
|
|
|
|
while (get_time_tb() < end && (status.rounds == rounds || status.phase || status.cycling)); |
|
|
|
|
assert(socket->address_profile.mapping == ADDRESS_MAP_UNCHANGED && socket->address_profile.inbound == ADDRESS_IN_OPEN); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_NAT, "alias fixture result source=%s helper=%016llx expected=%016llx reselections=%u remapped=%u", |
|
|
|
|
alias_ip, (unsigned long long)status.helper, (unsigned long long)helper->node_id, |
|
|
|
|
@ -191,10 +193,14 @@ static void run_endpoint_retry(void) {
|
|
|
|
|
nat_fixture_connect(&fixture, observer, "tcp", helper); nat_fixture_connect(&fixture, owner, "tcp", observer); |
|
|
|
|
nat_detection_set_automatic(owner->nat_det, 0); |
|
|
|
|
struct ETCP_SOCKET *socket = test_etcp_bound_socket(owner, "udp"); |
|
|
|
|
assert(!nat_detection_request_check_socket(owner->nat_det, socket, observer->node_id)); |
|
|
|
|
struct nat_check_status status = {0}; uint64_t end = get_time_tb() + 400000; |
|
|
|
|
nat_detection_get_status(owner->nat_det, socket, &status); uint32_t rounds = status.rounds; |
|
|
|
|
assert(!nat_detection_request_check_socket(owner->nat_det, socket, observer->node_id)); |
|
|
|
|
do { test_clock_poll(fixture.ua, 1000); assert(!nat_detection_get_status(owner->nat_det, socket, &status)); } |
|
|
|
|
while (get_time_tb() < end && (!status.rounds || status.phase || status.cycling)); |
|
|
|
|
while (get_time_tb() < end && (status.rounds == rounds || status.phase || status.cycling)); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_NAT, "endpoint fixture result mapping=%s inbound=%s rounds=%u previous=%u reason=%s", |
|
|
|
|
address_mapping_name(socket->address_profile.mapping), address_inbound_name(socket->address_profile.inbound), |
|
|
|
|
status.rounds, rounds, nat_check_reason_name(status.reason)); |
|
|
|
|
assert(socket->address_profile.mapping == ADDRESS_MAP_UNCHANGED && socket->address_profile.inbound == ADDRESS_IN_OPEN); |
|
|
|
|
assert(status.helper_reselections && status.observer == observer->node_id); |
|
|
|
|
nat_fixture_cleanup(&fixture); |
|
|
|
|
|