|
|
|
|
@ -157,7 +157,10 @@ static void fixture_init(struct fixture* f) {
|
|
|
|
|
assert(!getsockname(f->source.fd, (struct sockaddr*)&f->source.local_addr, &size)); |
|
|
|
|
f->source.interface_addr = f->source.local_addr; |
|
|
|
|
f->source.instance = &f->inst; |
|
|
|
|
f->source.nat_type = NAT_VERIFIED_STRICT; |
|
|
|
|
f->source.address_profile.mapping = ADDRESS_MAP_DEPENDENT; |
|
|
|
|
f->source.address_profile.inbound = ADDRESS_IN_CONTACT; |
|
|
|
|
f->source.address_profile.evidence_id = 1; |
|
|
|
|
f->source.address_profile.checked_at = 1; |
|
|
|
|
f->source.nat_addr = f->source.local_addr; |
|
|
|
|
snprintf(f->source.name, sizeof(f->source.name), "source"); |
|
|
|
|
f->inst.etcp_sockets = &f->source; |
|
|
|
|
@ -307,6 +310,19 @@ int main(void) {
|
|
|
|
|
run_case("unstable mapping", &unstable, STUN_MAP_UNKNOWN, STUN_FILTER_UNKNOWN); |
|
|
|
|
struct fixture direct = { .rfc = 1, .direct = 1, .mapping = STUN_MAP_EIM, .filtering = STUN_FILTER_EIF }; |
|
|
|
|
run_case("no translation", &direct, STUN_MAP_EIM, STUN_FILTER_EIF); |
|
|
|
|
struct fixture helpers = { .mapping = STUN_MAP_EIM }; |
|
|
|
|
fixture_init(&helpers); |
|
|
|
|
struct ETCP_SOCKET auxiliary = helpers.source; |
|
|
|
|
auxiliary.probe_only = 1; |
|
|
|
|
snprintf(auxiliary.name, sizeof(auxiliary.name), "nat-helper"); |
|
|
|
|
auxiliary.next = &helpers.source; |
|
|
|
|
helpers.inst.etcp_sockets = &auxiliary; |
|
|
|
|
fixture_start(&helpers, 0, 0, 0); |
|
|
|
|
struct stun_nat_result helper_result = wait_result(&helpers); |
|
|
|
|
assert(helper_result.mapping == STUN_MAP_MATCH); |
|
|
|
|
assert(stun_nat_get_result(&helpers.inst, "nat-helper", &helper_result) < 0); |
|
|
|
|
fixture_destroy(&helpers); |
|
|
|
|
DEBUG_INFO(DEBUG_CATEGORY_NAT, "PASS STUN skips auxiliary NAT helper sockets"); |
|
|
|
|
struct fixture duplicate = { .mapping = STUN_MAP_EIM }; |
|
|
|
|
fixture_init(&duplicate); |
|
|
|
|
fixture_start(&duplicate, 0, 0, 1); |
|
|
|
|
|