lib/Net/SinFP3/Next/IpPort.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 52 CC 3 SCAR 18.4
CC
3
Cov
0%
new
12.0
print
2.0
BEGIN
2.0
CRAP 6.3
1 #
2 # $Id: IpPort.pm,v 008243d3e89a 2018/07/21 14:54:07 gomor $
3 #
4 package Net::SinFP3::Next::IpPort;
5 use strict;
6 use warnings;
7  
8 use base qw(Net::SinFP3::Next);
9 our @AS = qw(
10 ip
11 mac
12 port
13 hostname
14 reverse
15 );
16 __PACKAGE__->cgBuildIndices;
17 __PACKAGE__->cgBuildAccessorsScalar(\@AS);
18  
19 sub new {
20 my $self = shift->SUPER::new(
21 ip => '127.0.0.1',
22 port => 1,
23 mac => '00:00:00:00:00:00',
24 hostname => 'unknown',
25 reverse => 'unknown',
26 @_,
27 );
28  
29 my $global = $self->global;
30 my $log = $global->log;
31  
32 # Be sure it is in IP format (not Int format)
33 $self->ip($global->intToIp(int => $self->ip)) or return;
34  
35 if ($global->ipv6 && $self->mac =~ /00:00:00:00:00:00/) {
36 my $mac = $global->lookupMac6(ipv6 => $self->ip);
37 $self->mac($mac);
38 }
39  
40 if ($global->dnsReverse) {
41 my $reverse = $global->getAddrReverse(addr => $self->ip) || 'unknown';
42 $self->reverse($reverse);
43 }
44  
45 return $self;
46 }
47  
48 sub print {
49 my $self = shift;
50 my $buf = "[".$self->ip."]:".$self->port;
51 $buf .= " hostname[".$self->hostname."]";
52 $buf .= " reverse[".$self->reverse."]";
53 $buf .= " mac[".$self->mac."]";
54 return $buf;
55 }
56  
57 1;
58  
59 __END__