Branch Coverage

blib/lib/Net/SIP/Dispatcher.pm
Criterion Covered Total %
branch 142 280 50.7


line true false branch
71 0 55 if %args
79 0 30 if (ref $_) { }
82 0 30 unless my($proto, $host, $port, $family) = sip_uri2sockinfo($_)
84 0 0 $proto && $proto eq 'tls' ? :
85 48 0 $family ? :
12 18 $proto ? :
97 0 55 defined $do_retransmits ? :
110 0 55 if $outgoing_proxy
115 168 0 if ($self) { }
137 0 0 unless @_
154 0 0 unless @_
170 57 0 if (my $receiver = shift()) { }
171 5 52 if (my $sub = UNIVERSAL::can($receiver, 'receive'))
198 57 0 if (UNIVERSAL::isa($arg, 'Net::SIP::Leg')) { }
0 0 elsif (UNIVERSAL::isa($arg, 'IO::Handle')) { }
0 0 elsif (UNIVERSAL::isa($arg, 'HASH')) { }
215 57 0 if (my $socketpool = $leg->socketpool)
218 0 204 unless eval { do { my($self, $leg, $packet, $from) = @_; return unless $self; return unless ($packet, $from) = $leg->receive($packet, $from); if ($packet->is_request) { $packet->scan_header('via', [sub { my($vref, $hdr) = @_; return if $$vref++; my($d, $h) = sip_hdrval2parts('via', $hdr->{'value'}); my($host, $port) = $d =~ m[^SIP/2\S+\s+(\S+)$] ? ip_string2parts($1) : (); my %nh; if (exists $h->{'rport'} and not defined $h->{'rport'}) { $nh{'rport'} = $from->{'port'}; } ; if ($host ne $from->{'addr'}) { $nh{'received'} = $from->{'addr'}; } elsif ($nh{'rport'}) { $nh{'received'} = $from->{'addr'}; } ; if (%nh) { $hdr->{'value'} = sip_parts2hdrval('via', $d, {%$h, %nh}); $hdr->set_modified; } ; } , \my $cvia]); } ; $self->receive($packet, $leg, $from); 1 } }
220 0 204 unless $self
222 0 204 unless ($packet, $from) = $leg->receive($packet, $from)
224 65 139 if ($packet->is_request)
228 0 65 if $$vref++
230 65 0 $d =~ m[^SIP/2\S+\s+(\S+)$] ? :
233 0 65 if (exists $h->{'rport'} and not defined $h->{'rport'})
236 0 65 if ($host ne $from->{'addr'}) { }
0 65 elsif ($nh{'rport'}) { }
244 0 65 if (%nh)
275 51 0 if (my $pool = $leg->socketpool)
296 151 2 unless @_
301 0 2 if $leg->match(\%args)
320 7 0 if (ref $_[-1] eq 'SCALAR')
328 7 24 if $legs->[$i] == $_
347 0 0 if (ref $_[-1])
348 0 0 if ${pop @_;} ne join('|', map({$_->key;} @$legs))
390 180 7 unless defined $do_retransmits
394 71 116 if ($packet->is_response)
396 71 0 if ($do_retransmits)
413 180 7 if $do_retransmits
430 46 286 if (@_ == 2) { }
432 46 0 if ($typ eq 'callid') { }
0 0 elsif ($typ eq 'id') { }
0 0 elsif ($typ eq 'qentry') { }
440 128 158 if (ref $id)
447 128 204 if ($qentry) { }
158 46 elsif (defined $id) { }
46 0 elsif (defined $callid) { }
483 72 139 if ($packet->is_request)
485 44 28 if (%$cache)
491 2 42 if (my $response = $cache->{$cid})
524 10 0 if (my $retransmits = $qe->{'retransmits'})
529 0 10 unless (@$retransmits)
539 8 2 if ($retransmit)
545 10 0 if (not defined $min_expire or $next_retransmit < $min_expire)
552 0 168 if $changed
558 0 75 if ($expire < $now) { }
61 14 elsif (not defined $min_expire or $expire < $min_expire) { }
589 0 304 if ($leg and @{$qentry->{'leg'};} > 1)
594 109 195 unless ($dst_addr and $leg)
601 0 109 if (my($route) = $packet->get_header('route')) { }
611 0 109 if (@error) { }
627 30 165 if ($qentry->{'retransmits'} and not $leg->do_retransmits)
634 0 88 unless $self
635 0 88 if (not $error and $qentry->{'retransmits'})
645 0 195 if $Net::SIP::Dispatcher::DEBUG
652 128 67 if (not $qentry->{'retransmits'})
679 0 116 unless ($domain)
686 10 106 if ($sip_proto eq 'sips') { }
4 102 elsif (my $p = $param->{'transport'}) { }
700 0 116 if ($allowed_proto and @$allowed_proto)
704 0 0 if $p
707 0 0 unless (@proto)
716 37 79 if (@$legs)
720 0 116 unless (@$allowed_legs)
727 7 109 $ip_addr ? :
728 71 45 if defined $port
729 64 52 if ($family) { }
739 116 0 unless (@$dst_addr)
741 81 35 if ($d2p and %$d2p)
745 38 183 unless $dom =~ s/^[^\.]+\.//
749 45 36 if ($addr)
757 0 116 if (not @$dst_addr and my $addr = $self->{'outgoing_proxy'})
765 71 45 if (not @$dst_addr and $ip_addr)
771 7 109 if (my $ip = $param->{'maddr'})
772 7 0 if ip_is_v46($ip)
779 72 71 if (ref $addr) { }
782 0 71 unless my($proto, $host, $port, $family) = sip_uri2sockinfo($addr)
784 71 0 $family ? :
791 0 71 $proto ? :
800 4 112 if (@resp and my $proto = $param->{'transport'})
802 0 4 if ($proto eq 'udp') { }
4 0 elsif ($proto eq 'tcp') { }
0 0 elsif ($proto eq 'tls') { }
813 0 4 unless @resp
817 116 0 if (@resp)
820 116 0 unless grep {not $_->{'addr'};} @resp
837 0 116 if $Net::SIP::Dispatcher::DEBUG
839 0 116 unless $resp and @$resp
860 122 81 if ($leg) { }
868 0 116 unless @$dst_addr
876 0 0 unless (ref $dst_addr)
878 0 0 $si[3] ? :
904 0 0 if (not ref $host) { }
0 0 elsif (ref $host eq 'HASH') { }
917 0 0 unless @rec
929 0 0 if ($_->{'addr'}) { }
935 0 0 unless @rec
977 0 0 $_ eq 'tls' ? :
1042 0 0 if $qid
1046 0 0 unless $qid
1050 0 0 if ($q->{'type'} eq 'BREAK-IF-RESULTS')
1051 0 0 if (@$results)
1056 0 0 if ($i == 0)
1064 0 0 unless "$q->{'type'}:$q->{'name'}" eq $qid
1070 0 0 if ($q->{'type'} eq 'SRV') { }
0 0 elsif ($q->{'type'} eq 'AAAA' or $q->{'type'} eq 'A') { }
1074 0 0 if ($type eq 'A' or $type eq 'AAAA')
1080 0 0 if $type ne 'SRV'
1084 0 0 $family ? :
1093 0 0 if $res[$i]{'family'}
1094 0 0 unless my $ipt = $addr2ip{$res[$i]{'host'}}
1098 0 0 $type eq 'A' ? :
1108 0 0 if ($_->{'family'})
1119 0 0 $type eq 'A' ? :
1131 0 0 $type eq 'A' ? :
1142 0 0 unless (@$queries)
1175 0 0 if ($rr->type eq 'SRV') { }
0 0 elsif ($rr->type eq 'A' or $rr->type eq 'AAAA') { }
1243 109 78 if (not $addr) { }
0 78 elsif (not ref $addr) { }
78 0 elsif (ref $addr eq 'HASH') { }
1246 0 0 $si[3] ? :
1258 115 72 if (my $leg = $self->{'leg'})
1259 115 0 if UNIVERSAL::can($leg, 'deliver')
1275 52 128 if $self->{'leg'}[0] and not $self->{'leg'}[0]->do_retransmits
1286 34 94 if ($p->is_response) { }
38 56 elsif ($p->method eq 'INVITE') { }
22 34 elsif ($p->method eq 'ACK') { }
1287 17 17 if ($p->code > 100 and $p->cseq =~ /\sINVITE$/)
1304 39 89 unless $t1
1315 357 381 if $t2 and $to > $t2