diff --git a/daemon/call.c b/daemon/call.c index 788ec561e..24c115b9d 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -3721,6 +3721,29 @@ static int call_get_monologue_new(struct call_monologue *dialogue[2], struct cal __monologue_unkernelize(cs->monologue); } + // if we have a to-tag, confirm that this dialogue association is intact + if (totag && totag->s) { + for (GList *sub = ret->subscribers.head; sub; sub = sub->next) { + struct call_subscription *cs = sub->data; + if (!cs->offer_answer) + continue; + struct call_monologue *csm = cs->monologue; + if (str_cmp_str(&csm->tag, totag)) { + __C_DBG("different to-tag than existing dialogue association"); + csm = call_get_monologue(call, totag); + if (!csm) + goto new_branch; + // use existing to-tag + __monologue_unkernelize(csm); + __subscribe_only_one_offer_answer(ret, csm); + __subscribe_only_one_offer_answer(csm, ret); + break; + } + break; // there should only be one + // XXX check if there's more than a one-to-one mapping here? + } + } + if (!viabranch) goto ok_check_tag; diff --git a/perl/NGCP/Rtpengine/AutoTest.pm b/perl/NGCP/Rtpengine/AutoTest.pm index 0f9b43579..d28002eba 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 subscribe_request subscribe_answer publish); }; @@ -143,7 +143,7 @@ sub sdp_match { 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); return sdp_match($cmd, $name, $resp->{sdp}, $exp_sdp_out); @@ -153,7 +153,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 subscribe_request { @@ -270,6 +270,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 84a02f84c..5b6d2352d 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 }, <