| 1 | package Net::Prober::tcp; | ||||||||||||||||||||||||||||
| 2 | 1 | $Net::Prober::tcp::VERSION = '0.16'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use base 'Net::Prober::Probe::TCP'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Net::Prober (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | sub probe { | ||||||||||||||||||||||||||||
| 11 | 2 | ▶ | my ($self, $args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
probe: called CC=8 SCAR=24.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | my ($host, $port, $timeout, $proto) = | |||||||||||||||||||||||||||
| 14 | $self->parse_args($args, qw(host port timeout proto)); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 2 | $port = Net::Prober::port_name_to_num($port); | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 2 | ▶ | if (! defined $port or $port == 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $port or $port == 0
MC/DC50%1/2
not defined $port or $port == 0
not defined $port
$port == 0
Truth table66%2/3
not(A) or B
A= not defined $portB= $port == 0
| |||||||||||||||||||||||||||||
| 19 | 1 | Carp::croak("Can't probe: undefined port"); | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | ▶ | $timeout ||= 3.5; | ||||||||||||||||||||||||||
|
Condition50%1/2
$timeout ||= "3.5"
MC/DC0%0/1
$timeout ||= "3.5"
$timeout
Truth table50%1/2
A
A= $timeout
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 1 | my $t0 = $self->time_now(); | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | my $sock = $self->open_socket($args); | |||||||||||||||||||||||||||
| 27 | 1 | my $good = 0; | |||||||||||||||||||||||||||
| 28 | 1 | my $reason; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 1 | ▶ | if (! $sock) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 1 | $reason = "Socket open failed"; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | else { | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | $good = $sock->connected() && $sock->close(); | ||||||||||||||||||||||||||
|
Condition0%0/3
$sock->connected && $sock->close
MC/DC0%0/2
$sock->connected && $sock->close
$sock->connected
$sock->close
Truth table0%0/3
A && B
A= $sock->connectedB= $sock->close
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if (! $good) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | $reason = "Socket connect or close failed"; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 1 | my $elapsed = $self->time_elapsed(); | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 1 | ▶ | if ($good) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | return $self->probe_ok( | |||||||||||||||||||||||||||
| 44 | time => $elapsed, | ||||||||||||||||||||||||||||
| 45 | host => $host, | ||||||||||||||||||||||||||||
| 46 | port => $port, | ||||||||||||||||||||||||||||
| 47 | ); | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 1 | return $self->probe_failed( | |||||||||||||||||||||||||||
| 51 | time => $elapsed, | ||||||||||||||||||||||||||||
| 52 | host => $host, | ||||||||||||||||||||||||||||
| 53 | port => $port, | ||||||||||||||||||||||||||||
| 54 | reason => $reason, | ||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | 1; | |||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | __END__ | ||||||||||||||||||||||||||||