From 1d9c71ae9b3f623f06398fe2e495ec5b4a10d6a1 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 2 Sep 2021 17:00:44 -0400 Subject: [PATCH] TT#131651 support reverse re-invite to new to-tag Change-Id: Iaea12033d3a142b4675cc22ed0e3270af654e7de --- daemon/call.c | 13 ++++ perl/NGCP/Rtpengine/AutoTest.pm | 9 ++- t/auto-daemon-tests.pl | 124 ++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 3 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index f48942338..49f99ab24 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -3106,6 +3106,19 @@ static struct call_monologue *call_get_monologue(struct call *call, const str *f __monologue_unkernelize(ret); __monologue_unkernelize(ret->active_dialogue); + // if we have a to-tag, confirm that this dialogue association is intact + if (totag && totag->s) { + if (str_cmp_str(&ret->active_dialogue->tag, totag)) { + __C_DBG("different to-tag than existing dialogue association"); + os = g_hash_table_lookup(call->tags, totag); + if (!os) + goto new_branch; + // use existing to-tag + os->active_dialogue = ret; + ret->active_dialogue = os; + } + } + if (!viabranch) goto ok_check_tag; diff --git a/perl/NGCP/Rtpengine/AutoTest.pm b/perl/NGCP/Rtpengine/AutoTest.pm index 2c499c1fa..92ec7d581 100644 --- a/perl/NGCP/Rtpengine/AutoTest.pm +++ b/perl/NGCP/Rtpengine/AutoTest.pm @@ -20,7 +20,7 @@ BEGIN { require Exporter; @ISA = qw(Exporter); our @EXPORT = qw(autotest_start new_call offer answer ft tt snd srtp_snd rtp rcv srtp_rcv - srtp_dec escape rtpm rtpmre reverse_tags new_tt crlf sdp_split rtpe_req offer_answer + srtp_dec escape rtpm rtpmre reverse_tags new_ft new_tt crlf sdp_split rtpe_req offer_answer autotest_init); }; @@ -120,7 +120,7 @@ sub rtpe_req { sub offer_answer { my ($cmd, $name, $req, $sdps) = @_; my ($sdp_in, $exp_sdp_out) = sdp_split($sdps); - $req->{'from-tag'} = $ft; + $req->{'from-tag'} //= $ft; $req->{sdp} = $sdp_in; my $resp = rtpe_req($cmd, $name, $req); my $regexp = "^\Q$exp_sdp_out\E\$"; @@ -147,7 +147,7 @@ sub offer { } sub answer { my ($name, $req, $sdps) = @_; - $req->{'to-tag'} = $tt; + $req->{'to-tag'} //= $tt; return offer_answer('answer', $name, $req, $sdps); } sub snd { @@ -250,6 +250,9 @@ sub tt { return $tt; } sub reverse_tags { ($tt, $ft) = ($ft, $tt); } +sub new_ft { + $ft = $tag_iter++ . "-test-fromtag" . $tag_suffix; +} sub new_tt { $tt = $tag_iter++ . "-test-totag" . $tag_suffix; } diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index b02bf3635..e1aebdec6 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -40,6 +40,130 @@ my ($sock_a, $sock_b, $sock_c, $sock_d, $port_a, $port_b, $ssrc, $ssrc_b, $resp, +new_call; +my $ft1 = ft(); + +offer('re-invite re-tag w/ via-branch', { 'via-branch' => 'foo' }, < 'bar' }, < 'bar' }, < $ft1 }); + +# reverse re-invite to new from-tag ft3 +new_ft; +my $ft3 = ft(); +reverse_tags; +# tt is the new tag ft3 now + +($port_b) = offer('re-invite re-tag w/ via-branch', { 'via-branch' => 'blah', 'to-tag' => tt() }, < 'baz', 'to-tag' => $ft2 }, <