| 1 | package Nmap::Scanner::PortList; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 2 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 6 | 2 | my $class = shift; | |||||||||||||||||||
| 7 | 2 | my $me = { TCP => shift, UDP => shift }; | |||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 2 | my @tcpkeys = sort { $a <=> $b } keys %{$me->{TCP}}; | |||||||||||||||||||
| 10 | 0 | my @udpkeys = sort { $a <=> $b } keys %{$me->{UDP}}; | |||||||||||||||||||
| 11 | 2 | $me->{UDPKEYS} = \@udpkeys; | |||||||||||||||||||
| 12 | 2 | $me->{TCPKEYS} = \@tcpkeys; | |||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 2 | return bless $me, $class; | |||||||||||||||||||
| 15 | } | ||||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 2 | ▶ | sub get_next_tcp { | ||||||||||||||||||
|
Subroutine
get_next_tcp: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 18 | 2 | return $_[0]->{TCP}->{shift @{$_[0]->{TCPKEYS}}} | |||||||||||||||||||
| 19 | 2 | ▶ | if @{$_[0]->{TCPKEYS}}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 20 | } | ||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | 0 | ▶ | sub get_next_udp { | ||||||||||||||||||
|
Subroutine
get_next_udp: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 23 | 0 | return $_[0]->{UDP}->{shift @{$_[0]->{UDPKEYS}}} | |||||||||||||||||||
| 24 | 0 | ▶ | if @{$_[0]->{UDPKEYS}}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 2 | ▶ | sub get_next { | ||||||||||||||||||
|
Subroutine
get_next: called CC=2 SCAR=9.2
Pod
undocumented
| |||||||||||||||||||||
| 28 | 2 | ▶ | return $_[0]->get_next_tcp() || $_[0]->get_next_udp(); | ||||||||||||||||||
|
Condition33%1/3
$_[0]->get_next_tcp || $_[0]->get_next_udp
MC/DC0%0/2
$_[0]->get_next_tcp || $_[0]->get_next_udp
$_[0]->get_next_tcp
$_[0]->get_next_udp
Truth table33%1/3
A || B
A= $_[0]->get_next_tcpB= $_[0]->get_next_udp
| |||||||||||||||||||||
| 29 | } | ||||||||||||||||||||
| 30 | |||||||||||||||||||||
| 31 | 0 | ▶ | sub as_xml { | ||||||||||||||||||
|
Subroutine
as_xml: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 32 | 0 | my $self = shift; | |||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | 0 | my $xml; | |||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | 0 | ▶ | while (my $p = $self->get_next()) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 37 | 0 | ▶ | last unless defined $p; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 38 | 0 | $xml .= $p->as_xml() . "\n"; | |||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 0 | return $xml; | |||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 3 | 1; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | =pod | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head2 DESCRIPTION | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | Holds a list of Nmap::Scanner::Port | ||||||||||||||||||||
| 52 | objects. get_next() returns a port | ||||||||||||||||||||
| 53 | reference while there are ports in | ||||||||||||||||||||
| 54 | the list and returns undef when | ||||||||||||||||||||
| 55 | the list is exhausted. Port lists are | ||||||||||||||||||||
| 56 | sorted internally by port number. | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | get_next_tcp() and get_next_udp() will | ||||||||||||||||||||
| 59 | return the next port of either protocol; | ||||||||||||||||||||
| 60 | get_next() returns first tcp then udp. | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | =cut | ||||||||||||||||||||