Branch Coverage

blib/lib/Net/SIP/Dispatcher.pm
Criterion Covered Total %
branch 143 280 51.0


line true false branch
71 0 57 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 57 defined $do_retransmits ? :
110 0 57 if $outgoing_proxy
115 174 0 if ($self) { }
137 0 0 unless @_
154 0 0 unless @_
170 59 0 if (my $receiver = shift()) { }
171 5 54 if (my $sub = UNIVERSAL::can($receiver, 'receive'))
198 59 0 if (UNIVERSAL::isa($arg, 'Net::SIP::Leg')) { }
0 0 elsif (UNIVERSAL::isa($arg, 'IO::Handle')) { }
0 0 elsif (UNIVERSAL::isa($arg, 'HASH')) { }
215 59 0 if (my $socketpool = $leg->socketpool)
218 0 209 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 209 unless $self
222 0 209 unless ($packet, $from) = $leg->receive($packet, $from)
224 70 139 if ($packet->is_request)
228 0 70 if $$vref++
230 70 0 $d =~ m[^SIP/2\S+\s+(\S+)$] ? :
233 0 70 if (exists $h->{'rport'} and not defined $h->{'rport'})
236 0 70 if ($host ne $from->{'addr'}) { }
0 70 elsif ($nh{'rport'}) { }
244 0 70 if (%nh)
275 53 0 if (my $pool = $leg->socketpool)
296 155 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 189 7 unless defined $do_retransmits
394 76 120 if ($packet->is_response)
396 76 0 if ($do_retransmits)
413 189 7 if $do_retransmits
430 48 293 if (@_ == 2) { }
432 48 0 if ($typ eq 'callid') { }
0 0 elsif ($typ eq 'id') { }
0 0 elsif ($typ eq 'qentry') { }
440 133 160 if (ref $id)
447 133 208 if ($qentry) { }
160 48 elsif (defined $id) { }
48 0 elsif (defined $callid) { }
483 77 139 if ($packet->is_request)
485 47 30 if (%$cache)
491 1 46 if (my $response = $cache->{$cid})
524 10 0 if (my $retransmits = $qe->{'retransmits'})
529 0 10 unless (@$retransmits)
539 5 5 if ($retransmit)
545 9 1 if (not defined $min_expire or $next_retransmit < $min_expire)
552 0 174 if $changed
558 0 83 if ($expire < $now) { }
68 15 elsif (not defined $min_expire or $expire < $min_expire) { }
589 0 314 if ($leg and @{$qentry->{'leg'};} > 1)
594 113 201 unless ($dst_addr and $leg)
601 0 113 if (my($route) = $packet->get_header('route')) { }
611 0 113 if (@error) { }
627 30 171 if ($qentry->{'retransmits'} and not $leg->do_retransmits)
634 0 88 unless $self
635 0 88 if (not $error and $qentry->{'retransmits'})
645 0 201 if $Net::SIP::Dispatcher::DEBUG
652 133 68 if (not $qentry->{'retransmits'})
679 0 120 unless ($domain)
686 10 110 if ($sip_proto eq 'sips') { }
4 106 elsif (my $p = $param->{'transport'}) { }
700 0 120 if ($allowed_proto and @$allowed_proto)
704 0 0 if $p
707 0 0 unless (@proto)
716 39 81 if (@$legs)
720 0 120 unless (@$allowed_legs)
727 7 113 $ip_addr ? :
728 75 45 if defined $port
729 68 52 if ($family) { }
739 120 0 unless (@$dst_addr)
741 81 39 if ($d2p and %$d2p)
745 38 183 unless $dom =~ s/^[^\.]+\.//
749 45 36 if ($addr)
757 0 120 if (not @$dst_addr and my $addr = $self->{'outgoing_proxy'})
765 75 45 if (not @$dst_addr and $ip_addr)
771 7 113 if (my $ip = $param->{'maddr'})
772 7 0 if ip_is_v46($ip)
779 72 75 if (ref $addr) { }
782 0 75 unless my($proto, $host, $port, $family) = sip_uri2sockinfo($addr)
784 75 0 $family ? :
791 0 75 $proto ? :
800 4 116 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 120 0 if (@resp)
820 120 0 unless grep {not $_->{'addr'};} @resp
837 0 120 if $Net::SIP::Dispatcher::DEBUG
839 0 120 unless $resp and @$resp
860 126 85 if ($leg) { }
868 0 120 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 113 83 if (not $addr) { }
0 83 elsif (not ref $addr) { }
83 0 elsif (ref $addr eq 'HASH') { }
1246 0 0 $si[3] ? :
1258 122 74 if (my $leg = $self->{'leg'})
1259 122 0 if UNIVERSAL::can($leg, 'deliver')
1275 52 137 if $self->{'leg'}[0] and not $self->{'leg'}[0]->do_retransmits
1286 39 98 if ($p->is_response) { }
40 58 elsif ($p->method eq 'INVITE') { }
24 34 elsif ($p->method eq 'ACK') { }
1287 19 20 if ($p->code > 100 and $p->cseq =~ /\sINVITE$/)
1304 44 93 unless $t1
1315 371 399 if $t2 and $to > $t2