diff --git a/daemon/call.c b/daemon/call.c index c1e4d4700..bece918d3 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2275,8 +2275,12 @@ static void media_loop_protect(struct stream_params *sp, struct call_media *medi intf_addr.addr = sp->rtp_endpoint.address; if (!intf_addr.addr.family) // dummy/empty address return; - if (!is_local_endpoint(&intf_addr, sp->rtp_endpoint.port)) + if (!is_local_endpoint(&intf_addr, sp->rtp_endpoint.port)) { + if (MEDIA_ISSET(media, LOOP_CHECK)) + ilog(LOG_DEBUG, "Remote endpoint is no longer local, disabling loop checking"); + MEDIA_CLEAR(media, LOOP_CHECK); return; + } ilog(LOG_DEBUG, "Detected local endpoint advertised by remote client, " "enabling loop checking"); diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 333724859..6a8cc3800 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -29551,6 +29551,101 @@ rcv($sock_b, $port_d, rtpm(98, 8000, 9000, 0xa234, "b")); +# Scenario: initial offer uses a local daemon address (203.0.113.1), triggering LOOP_CHECK. A +# re-INVITE changes the endpoint to non-local, which should clear it. +new_call; + +offer('loop check cleared on non-local re-INVITE', { }, <{tags}{ft()}{medias}[0]{flags}}, + 'loop check flag set with local endpoint'); + +# re-INVITE: endpoint changes to non-local address +offer('loop check cleared on non-local re-INVITE', { }, <{tags}{ft()}{medias}[0]{flags}}, + 'loop check flag cleared after non-local re-INVITE'); + + + #done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit; done_testing();