lib/Net/Ifconfig/Wrapper.pm

filter: Statementstmt 32.2% 118 / 366 Branchbran 8.2% 13 / 158 Conditioncond 6.8% 6 / 88 MC/DCmcdc 0.0% 0 / 49 Subroutinesub 38.1% 8 / 21 Podpod 50.0% 1 / 2 totaltotal 21.3% 146 / 684 CC 111 SCAR 51.3
CC
111
Cov
22%
__ANON__
417.7
__ANON__
306.0
__ANON__
182.0
CRAP 169.1
↑ Summary
1 package Net::Ifconfig::Wrapper;
2
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS @EXPORT_FAIL);
Subroutine BEGIN: called CC=1 SCAR=0.0
6
7 2 $VERSION = 0.25;
8
9 2 require Exporter;
10
11 2 @ISA = qw(Exporter);
12 # Items to export into caller's namespace by default. Note: do not export
13 # names by default without a very good reason. Use EXPORT_OK instead.
14 # Do not simply export all your public functions/methods/constants.
15 2 @EXPORT = qw();
16
17 2 %EXPORT_TAGS = ('Ifconfig' => [qw(Ifconfig)]);
18
19 2 foreach (keys(%EXPORT_TAGS))
20 2 { push(@{$EXPORT_TAGS{'all'}}, @{$EXPORT_TAGS{$_}}); };
21
22 $EXPORT_TAGS{'all'}
23 2 ▶ and @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
Branch: 1 branch
BranchTrueFalseTotal
$Net::Ifconfig::Wrapper::EXPORT_TAGS{"all"} and @Net::Ifconfig::Wrapper::EXPORT_OK = @{$Net::Ifconfig::Wrapper::EXPORT_TAGS{"all"};} 2 0 2
24
25 2 my $DEBUG = 0;
26
27 2 ▶use POSIX;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 2 my ($OsName, $OsVers) = (POSIX::uname())[0,2];
29
30 2 my $Win32_FormatMessage = undef;
31 2 my %Win32API = ();
32 2 my %ToLoad = ('iphlpapi' => {'GetAdaptersInfo' => [['P','P'], 'N'],
33 #'GetIpAddrTable' => [['P','P','I'], 'N'],
34 'AddIPAddress' => [['N','N','N','P','P'], 'N'],
35 'DeleteIPAddress' => [['N'], 'N'],
36 },
37 );
38
39 2 my $Win32_ERROR_BUFFER_OVERFLOW = undef;
40 2 my $Win32_ERROR_INSUFFICIENT_BUFFER = undef;
41 2 my $Win32_NO_ERROR = undef;
42
43 2 my $ETHERNET = 'ff:ff:ff:ff:ff:ff';
44
45 2 ▶(($^O eq 'openbsd') &&
Branch: 1 branch
BranchTrueFalseTotal
$^O eq "openbsd" and `/usr/sbin/arp -a 2>&1` =~ /(?:\A|\n).+\s+at\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s+static\s*(?:\n|\Z)/i and $ETHERNET = $1 0 2 2
Condition33%1/3
$^O eq "openbsd" and `/usr/sbin/arp -a 2>&1` =~ /(?:\A|\n).+\s+at\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s+static\s*(?:\n|\Z)/i
!ll&&!rl&&r
200
MC/DC0%0/2
$^O eq "openbsd" and `/usr/sbin/arp -a 2>&1` =~ /(?:\A|\n).+\s+at\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s+static\s*(?:\n|\Z)/i
$^O eq "openbsd" `/usr/sbin/arp -a 2>&1` =~ /(?:\A|\n).+\s+at\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s+static\s*(?:\n|\Z)/i
Truth table33%1/3
A and B
A= $^O eq "openbsd"B= `/usr/sbin/arp -a 2>&1` =~ /(?:\A|\n).+\s+at\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s+static\s*(?:\n|\Z)/i
ABresult
0X0
100
111
46 (`/usr/sbin/arp -a 2>&1` =~ m/(?:\A|\n).+\s+at\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s+static\s*(?:\n|\Z)/i))
47 and $ETHERNET = $1;
48
49 2 ▶if (($^O eq 'MSWin32') || ($^O eq 'cygwin'))
Branch: 1 branch
BranchTrueFalseTotal
if ($^O eq "MSWin32" or $^O eq "cygwin") 0 2 2
Condition33%1/3
$^O eq "MSWin32" or $^O eq "cygwin"
l!l&&r!l&&!r
002
MC/DC0%0/2
$^O eq "MSWin32" or $^O eq "cygwin"
$^O eq "MSWin32" $^O eq "cygwin"
Truth table33%1/3
A or B
A= $^O eq "MSWin32"B= $^O eq "cygwin"
ABresult
1X1
011
000
50 {
51 0 eval 'use Win32::API;
52 use Win32::WinError;
53
54 Win32::IsWinNT()
55 or die "Only WinNT (from Win2K) is supported";
56
57 $Win32_FormatMessage = sub { return Win32::FormatMessage(@_); };
58 $Win32_ERROR_BUFFER_OVERFLOW = ERROR_BUFFER_OVERFLOW;
59 $Win32_ERROR_INSUFFICIENT_BUFFER = ERROR_INSUFFICIENT_BUFFER;
60 $Win32_NO_ERROR = NO_ERROR;
61
62 foreach my $DLib (keys(%ToLoad))
63 {
64 foreach my $Func (keys(%{$ToLoad{$DLib}}))
65 {
66 $Win32API{$DLib}{$Func} = Win32::API->new($DLib, $Func, $ToLoad{$DLib}{$Func}->[0], $ToLoad{$DLib}{$Func}->[1])
67 or die "Cannot import function \'$Func\' from \'$DLib\' DLL: $^E";
68 };
69 };
70 ';
71
72 0 ▶ $@ and die $@;
Branch: 1 branch
BranchTrueFalseTotal
$@ and die $@ 0 0 0
73 };
74
75 2 my $MAXLOGIC = 65535;
76
77 2 my %Hex2Mask = ('00000000' => '0.0.0.0', '80000000' => '128.0.0.0',
78 'c0000000' => '192.0.0.0', 'e0000000' => '224.0.0.0',
79 'f0000000' => '240.0.0.0', 'f8000000' => '248.0.0.0',
80 'fc000000' => '252.0.0.0', 'fe000000' => '254.0.0.0',
81 'ff000000' => '255.0.0.0', 'ff800000' => '255.128.0.0',
82 'ffc00000' => '255.192.0.0', 'ffe00000' => '255.224.0.0',
83 'fff00000' => '255.240.0.0', 'fff80000' => '255.248.0.0',
84 'fffc0000' => '255.252.0.0', 'fffe0000' => '255.254.0.0',
85 'ffff0000' => '255.255.0.0', 'ffff8000' => '255.255.128.0',
86 'ffffc000' => '255.255.192.0', 'ffffe000' => '255.255.224.0',
87 'fffff000' => '255.255.240.0', 'fffff800' => '255.255.248.0',
88 'fffffc00' => '255.255.252.0', 'fffffe00' => '255.255.254.0',
89 'ffffff00' => '255.255.255.0', 'ffffff80' => '255.255.255.128',
90 'ffffffc0' => '255.255.255.192', 'ffffffe0' => '255.255.255.224',
91 'fffffff0' => '255.255.255.240', 'fffffff8' => '255.255.255.248',
92 'fffffffc' => '255.255.255.252', 'fffffffe' => '255.255.255.254',
93 'ffffffff' => '255.255.255.255',
94 );
95
96 2 my $Inet2Logic = undef;
97 2 my $Logic2Inet = undef;
98
99 2 my $Name2Index = undef;
100
101 2 my %Ifconfig = ();
102
103 my $RunCmd = sub($$)
104 1 ▶ {
Subroutine __ANON__: called CC=7 SCAR=21.8
105 1 my ($CName, $Iface, $Logic, $Addr, $Mask) = @_;
106
107 my $Cmd = (defined($Ifconfig{$CName}{$^O}{$OsName}{$OsVers}{'ifconfig'}) ?
108 $Ifconfig{$CName}{$^O}{$OsName}{$OsVers}{'ifconfig'} :
109 1 ▶ $Ifconfig{$CName}{$^O}{'ifconfig'}).' 2>&1';
Branch: 1 branch
BranchTrueFalseTotal
defined $Ifconfig{$CName}{$^O}{$OsName}{$OsVers}{'ifconfig'} ? : 0 1 1
110
111 1 ▶ $DEBUG && print STDERR "\n=== RunCmd ===\n\$CName: $CName, \$Iface: $Iface, \$Logic: $Logic, \$Addr: $Addr, \$Mask: $Mask\n";
Branch: 1 branch
BranchTrueFalseTotal
$DEBUG and print STDERR "\n=== RunCmd ===\n\$CName: $CName, \$Iface: $Iface, \$Logic: $Logic, \$Addr: $Addr, \$Mask: $Mask\n" 0 1 1
112
113 0 $Cmd =~ s{%Iface%}{$Iface}gsex;
114 0 $Cmd =~ s{%Logic%}{$Logic}gsex;
115 0 $Cmd =~ s{%Addr%}{$Addr}gsex;
116 0 $Cmd =~ s{%Mask%}{$Mask}gsex;
117
118 1 ▶ $DEBUG && print STDERR "Cmd is ==$Cmd==\n";
Branch: 1 branch
BranchTrueFalseTotal
$DEBUG and print STDERR "Cmd is ==$Cmd==\n" 0 1 1
119
120 1 ▶ my $saveLang = $ENV{'LANG'} || '';
Condition50%1/2
$ENV{'LANG'} || ''
l!l
01
MC/DC0%0/1
$ENV{'LANG'} || ''
$ENV{'LANG'}
Truth table50%1/2
A
A= $ENV{'LANG'}
Aresult
11
00
121 1 $ENV{'LANG'} = 'C';
122 1 my @Output = `$Cmd`;
123 1 $ENV{'LANG'} = $saveLang;
124
125 1 ▶ $@ = "Command '$Cmd', exit code '".(defined($?) ? $? : '!UNDEFINED!')."'".join("\t", @Output);
Branch: 1 branch
BranchTrueFalseTotal
defined $? ? : 1 0 1
126
127 1 ▶ $? ? return : return \@Output;
Branch: 1 branch
BranchTrueFalseTotal
$? ? : 1 0 1
128 2 }; # RunCmd
129
130 my $SolarisList = sub($$$$)
131 0 ▶ {
Subroutine __ANON__: not called CC=17 SCAR=57.2
132 0 $Inet2Logic = undef;
133 0 $Logic2Inet = undef;
134
135 0 ▶ my $Output = &{$RunCmd}('list', '', '', '', '') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $Output = &{$RunCmd;}("list", "", "", "", "") or return 0 0 0
136
137 0 $Inet2Logic = {};
138 0 $Logic2Inet = {};
139
140 0 my $Iface = undef;
141 0 my $Logic = undef;
142 0 my $LogUp = undef;
143 0 my $Info = {};
144 0 foreach (@{$Output})
145 {
146 0 ▶ if (
Branch: 6 branches
BranchTrueFalseTotal
if ($_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+\,)*(up)?(?:\,\w+)*\>.*\n?\Z/io or $_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+(?:\,\w+)*)*\>.*\n?\Z/io) { } 0 0 0
elsif (not $Iface) { } 0 0 0
elsif ($_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(?:0x)?([a-f\d]{8})(?:\s.*)?\n?\Z/io or 0) { } 0 0 0
elsif ($_ =~ /\A\s+media\:?\s+(ethernet.*)\s*\n?\Z/io and not $Info->{$Iface}{'ether'}) { } 0 0 0
elsif ($_ =~ /\A\s+supported\s+media\:?\s+(.*)\s*\n?\Z/io and not $Info->{$Iface}{'media'}) { } 0 0 0
elsif ($_ =~ /\A\s+ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})(?:\s.*)?\n?\Z/io) { } 0 0 0
Condition0%0/3
$_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+\,)*(up)?(?:\,\w+)*\>.*\n?\Z/io or $_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+(?:\,\w+)*)*\>.*\n?\Z/io
l!l&&r!l&&!r
000
MC/DC0%0/2
$_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+\,)*(up)?(?:\,\w+)*\>.*\n?\Z/io or $_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+(?:\,\w+)*)*\>.*\n?\Z/io
$_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+\,)*(up)?(?:\,\w+)*\>.*\n?\Z/io $_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+(?:\,\w+)*)*\>.*\n?\Z/io
Truth table0%0/3
A or B
A= $_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+\,)*(up)?(?:\,\w+)*\>.*\n?\Z/ioB= $_ =~ /\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+(?:\,\w+)*)*\>.*\n?\Z/io
ABresult
1X1
011
000
147 ($_ =~ m/\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+\,)*(up)?(?:\,\w+)*\>.*\n?\Z/io)
148 ||
149 ($_ =~ m/\A([a-z]+\d+)(?:\:(\d+))?\:\s+flags=[^\<]+\<(?:\w+(?:\,\w+)*)*\>.*\n?\Z/io)
150 )
151 {
152 0 $Iface = $1;
153 0 ▶ $Logic = defined($2) ? $2 : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 0 0 0
154 0 $LogUp = 1 && $3;
155 #$Info->{$Iface}{'status'} = ($Info->{$Iface}{'status'} || $LogUp) ? 1 : 0;
156 0 ▶ $Info->{$Iface}{'status'} = $Info->{$Iface}{'status'} || $LogUp;
Condition0%0/3
$Info->{$Iface}{'status'} || $LogUp
l!l&&r!l&&!r
000
MC/DC0%0/2
$Info->{$Iface}{'status'} || $LogUp
$Info->{$Iface}{'status'} $LogUp
Truth table0%0/3
A || B
A= $Info->{$Iface}{'status'}B= $LogUp
ABresult
1X1
011
000
157 }
158 elsif (!$Iface)
159 {
160 0 next;
161 }
162 ▶ elsif (
Condition0%0/2
$_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(?:0x)?([a-f\d]{8})(?:\s.*)?\n?\Z/io or 0
l!l
00
MC/DC0%0/1
$_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(?:0x)?([a-f\d]{8})(?:\s.*)?\n?\Z/io or 0
$_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(?:0x)?([a-f\d]{8})(?:\s.*)?\n?\Z/io
Truth table0%0/2
A
A= $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(?:0x)?([a-f\d]{8})(?:\s.*)?\n?\Z/io
Aresult
11
00
163 ($_ =~ m/\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(?:0x)?([a-f\d]{8})(?:\s.*)?\n?\Z/io)
164 ||
165 0
166 )
167 {
168 $LogUp
169 0 ▶ and $Info->{$Iface}{'inet'}{$1} = $Hex2Mask{$2};
Branch: 1 branch
BranchTrueFalseTotal
$LogUp and $Info->{$Iface}{"inet"}{$1} = $Hex2Mask{$2} 0 0 0
170 0 $Inet2Logic->{$Iface}{$1} = $Logic;
171 0 $Logic2Inet->{$Iface}{$Logic} = $1;
172 }
173 ▶ elsif (($_ =~ m/\A\s+media\:?\s+(ethernet.*)\s*\n?\Z/io) && !$Info->{$Iface}{'ether'})
Condition0%0/3
$_ =~ /\A\s+media\:?\s+(ethernet.*)\s*\n?\Z/io and not $Info->{$Iface}{"ether"}
!ll&&!rl&&r
000
MC/DC0%0/2
$_ =~ /\A\s+media\:?\s+(ethernet.*)\s*\n?\Z/io and not $Info->{$Iface}{"ether"}
$_ =~ /\A\s+media\:?\s+(ethernet.*)\s*\n?\Z/io not $Info->{$Iface}{"ether"}
Truth table0%0/3
A and not(B)
A= $_ =~ /\A\s+media\:?\s+(ethernet.*)\s*\n?\Z/ioB= not $Info->{$Iface}{"ether"}
ABresult
0X0
100
111
174 {
175 0 $Info->{$Iface}{'ether'} = $ETHERNET;
176 0 ▶ if (!$Info->{$Iface}{'media'})
Branch: 1 branch
BranchTrueFalseTotal
unless ($Info->{$Iface}{"media"}) 0 0 0
177 0 {$Info->{$Iface}{'media'} = $1; };
178 }
179 ▶ elsif (($_ =~ m/\A\s+supported\s+media\:?\s+(.*)\s*\n?\Z/io) && !$Info->{$Iface}{'media'})
Condition0%0/3
$_ =~ /\A\s+supported\s+media\:?\s+(.*)\s*\n?\Z/io and not $Info->{$Iface}{"media"}
!ll&&!rl&&r
000
MC/DC0%0/2
$_ =~ /\A\s+supported\s+media\:?\s+(.*)\s*\n?\Z/io and not $Info->{$Iface}{"media"}
$_ =~ /\A\s+supported\s+media\:?\s+(.*)\s*\n?\Z/io not $Info->{$Iface}{"media"}
Truth table0%0/3
A and not(B)
A= $_ =~ /\A\s+supported\s+media\:?\s+(.*)\s*\n?\Z/ioB= not $Info->{$Iface}{"media"}
ABresult
0X0
100
111
180 {
181 0 $Info->{$Iface}{'media'} = $1;
182 }
183 elsif ($_ =~ m/\A\s+ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})(?:\s.*)?\n?\Z/io)
184 {
185 0 $Info->{$Iface}{'ether'} = $1;
186 };
187 };
188 0 return $Info;
189 2 }; # SolarisList
190
191 my $LinuxList = sub($$$$)
192 1 ▶ {
Subroutine __ANON__: called CC=23 SCAR=60.3
193 # warn " DDD start sub LinuxList...\n";
194 1 $Inet2Logic = undef;
195 1 $Logic2Inet = undef;
196
197 1 ▶ my $Output = &{$RunCmd}('list', '', '', '', '')
Branch: 1 branch
BranchTrueFalseTotal
my $Output = &{$RunCmd;}("list", "", "", "", "") or return 0 1 1
198 or return;
199
200 0 $Inet2Logic = {};
201 0 $Logic2Inet = {};
202
203 0 my $Iface = undef;
204 0 my $Logic = undef;
205 0 my $Info = {};
206 0 foreach (@{$Output})
207 {
208 0 ▶ $DEBUG && warn " DDD looking at line of Output=$_";
Branch: 1 branch
BranchTrueFalseTotal
$DEBUG and warn " DDD looking at line of Output=$_" 0 0 0
209 0 ▶ if (
Branch: 6 branches
BranchTrueFalseTotal
if ($_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+link\s+encap\:(?:ethernet\s+hwaddr\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io or $_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+Link\s+encap\:(?:Ethernet\s+Hardware\s+Adresse\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io or $_ =~ m[link/ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s]io) { } 0 0 0
elsif ($_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\:\s+flags=\d+<(\w+(?:,\w+)*)*>.*\n?\Z/io) { } 0 0 0
elsif (not $Iface) { } 0 0 0
elsif ($_ =~ /\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/io or $_ =~ /\A\s+inet\s+Adresse\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?Maske\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ m[\sinet\s+(\d{1,3}(?:\.\d{1,3}){3})/(\d+)\s]io) { } 0 0 0
elsif ($_ =~ /\A\s+ether\s+([a-f0-9]{1,2}(?:\:[a-f0-9]{1,2}){5})(?:\s|\n|\Z)/io) { } 0 0 0
elsif ($_ =~ /\A\s+up(?:\s+[^\s]+)*\s*\n?\Z/io) { } 0 0 0
Condition0%0/6
$_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+link\s+encap\:(?:ethernet\s+hwaddr\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io or $_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+Link\s+encap\:(?:Ethernet\s+Hardware\s+Adresse\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io or $_ =~ m[link/ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s]io
l!l&&r!l&&!r
000
$_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+link\s+encap\:(?:ethernet\s+hwaddr\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io or $_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+Link\s+encap\:(?:Ethernet\s+Hardware\s+Adresse\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io
l!l&&r!l&&!r
000
MC/DC0%0/3
$_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+link\s+encap\:(?:ethernet\s+hwaddr\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io or $_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+Link\s+encap\:(?:Ethernet\s+Hardware\s+Adresse\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io or $_ =~ m[link/ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s]io
$_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+link\s+encap\:(?:ethernet\s+hwaddr\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io $_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+Link\s+encap\:(?:Ethernet\s+Hardware\s+Adresse\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io $_ =~ m[link/ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s]io
Truth table0%0/4
A or B or C
A= $_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+link\s+encap\:(?:ethernet\s+hwaddr\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/ioB= $_ =~ /\A([a-z0-9]+)(?:\:(\d+))?\s+Link\s+encap\:(?:Ethernet\s+Hardware\s+Adresse\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/ioC= $_ =~ m[link/ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s]io
ABCresult
1XX1
01X1
0011
0000
210 ($_ =~ m/\A([a-z0-9]+)(?:\:(\d+))?\s+link\s+encap\:(?:ethernet\s+hwaddr\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io)
211 ||
212 # German locale de_DE.UTF-8
213 ($_ =~ m/\A([a-z0-9]+)(?:\:(\d+))?\s+Link\s+encap\:(?:Ethernet\s+Hardware\s+Adresse\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5}))?.*\n?\Z/io)
214 ||
215 # /sbin/ip on some linux systems:
216 ($_ =~ m/link\/ether\s+([a-f\d]{1,2}(?:\:[a-f\d]{1,2}){5})\s/io)
217 )
218 {
219 0 $Iface = $1;
220 0 ▶ $Logic = defined($2) ? $2 : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 0 0 0
221 defined($3)
222 0 ▶ and $Info->{$Iface}{'ether'} = $3;
Branch: 1 branch
BranchTrueFalseTotal
defined $3 and $Info->{$Iface}{"ether"} = $3 0 0 0
223 0 $Info->{$Iface}{'status'} = 0;
224 }
225 elsif (
226 ($_ =~ m/\A([a-z0-9]+)(?:\:(\d+))?\:\s+flags=\d+<(\w+(?:,\w+)*)*>.*\n?\Z/io)
227 )
228 {
229 0 $Iface = $1;
230 0 ▶ $Logic = defined($2) ? $2 : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $2 ? : 0 0 0
231 0 my $sFlags = $3;
232 0 ▶ $DEBUG && warn " DDD matched 'flags' line, Iface=$Iface, sFlags=$sFlags\n";
Branch: 1 branch
BranchTrueFalseTotal
$DEBUG and warn " DDD matched 'flags' line, Iface=$Iface, sFlags=$sFlags\n" 0 0 0
233 0 ▶ $Info->{$Iface}{'status'} = 1 if ($sFlags =~ m/\bUP\b/);
Branch: 1 branch
BranchTrueFalseTotal
if $sFlags =~ /\bUP\b/ 0 0 0
234 }
235 elsif (!$Iface)
236 {
237 0 next;
238 }
239 ▶ elsif (
Condition0%0/9
$_ =~ /\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/io or $_ =~ /\A\s+inet\s+Adresse\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?Maske\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ m[\sinet\s+(\d{1,3}(?:\.\d{1,3}){3})/(\d+)\s]io
l!l&&r!l&&!r
000
$_ =~ /\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/io or $_ =~ /\A\s+inet\s+Adresse\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?Maske\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io
l!l&&r!l&&!r
000
$_ =~ /\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/io
l!l&&r!l&&!r
000
MC/DC0%0/4
$_ =~ /\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/io or $_ =~ /\A\s+inet\s+Adresse\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?Maske\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io or $_ =~ m[\sinet\s+(\d{1,3}(?:\.\d{1,3}){3})/(\d+)\s]io
$_ =~ /\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/io $_ =~ /\A\s+inet\s+Adresse\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?Maske\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io $_ =~ m[\sinet\s+(\d{1,3}(?:\.\d{1,3}){3})/(\d+)\s]io
Truth table0%0/5
A or B or C or D
A= $_ =~ /\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/ioB= $_ =~ /\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/ioC= $_ =~ /\A\s+inet\s+Adresse\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?Maske\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/ioD= $_ =~ m[\sinet\s+(\d{1,3}(?:\.\d{1,3}){3})/(\d+)\s]io
ABCDresult
1XXX1
01XX1
001X1
00011
00000
240 # RHEL 6 et alia:
241 ($_ =~ m/\A\s+inet\s+addr\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?mask\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io)
242 ||
243 # RHEL 7 et alia:
244 ($_ =~ m/\A\s+inet\s+(\d{1,3}(?:\.\d{1,3}){3})\s+netmask\s+(\d{1,3}(?:\.\d{1,3}){3})(?:\s.*)?\n?\Z/io)
245 ||
246 # German locale de_DE.UTF-8
247 ($_ =~ m/\A\s+inet\s+Adresse\:(\d{1,3}(?:\.\d{1,3}){3})\s+(?:.*\s)?Maske\:(\d{1,3}(?:\.\d{1,3}){3}).*\n?\Z/io)
248 ||
249 ($_ =~ m/\sinet\s+(\d{1,3}(?:\.\d{1,3}){3})\/(\d+)\s/io)
250 )
251 {
252 0 my $sIP = $1;
253 0 my $sNetmask = $2;
254 0 ▶ $DEBUG && warn " DDD matched 'netmask' line, sIP=$sIP, sNetmask=$sNetmask\n";
Branch: 1 branch
BranchTrueFalseTotal
$DEBUG and warn " DDD matched 'netmask' line, sIP=$sIP, sNetmask=$sNetmask\n" 0 0 0
255 0 ▶ if ($sNetmask =~ m/\A\d+\z/)
Branch: 1 branch
BranchTrueFalseTotal
if ($sNetmask =~ /\A\d+\z/) 0 0 0
256 {
257 # The netmask appeared as a slash/number at the end of the IP
258 # address; convert it to an IP "address" quad string:
259 2 ▶ use Net::Netmask;
Subroutine BEGIN: called CC=1 SCAR=0.0
260 0 my $block = new Net::Netmask("$sIP/$sNetmask");
261 0 $sNetmask = $block->mask();
262 } # if
263 0 $Info->{$Iface}{'inet'}{$sIP} = $sNetmask;
264 0 $Inet2Logic->{$Iface}{$sIP} = $Logic;
265 0 $Logic2Inet->{$Iface}{$Logic} = $sIP;
266 }
267 elsif ($_ =~ m/\A\s+ether\s+([a-f0-9]{1,2}(?:\:[a-f0-9]{1,2}){5})(?:\s|\n|\Z)/io)
268 {
269 0 $Info->{$Iface}{'ether'} = $1;
270 }
271 elsif ($_ =~ m/\A\s+up(?:\s+[^\s]+)*\s*\n?\Z/io)
272 {
273 0 ▶ $DEBUG && warn " DDD matched 'up' line\n";
Branch: 1 branch
BranchTrueFalseTotal
$DEBUG and warn " DDD matched 'up' line\n" 0 0 0
274 0 $Info->{$Iface}{'status'} = 1;
275 };
276 };
277
278 0 return $Info;
279 2 }; # LinuxList
280
281 # 64-bit Windows support added by Laurent Aml: use 'Q' for pointers,
282 # and align to 8 bytes.
283 2 ▶my ($LQ, @pad) = (length(pack('P')) == 4) ? ('L') : ('Q', '_pad' => 'L');
Branch: 1 branch
BranchTrueFalseTotal
length pack('P') == 4 ? : 0 2 2
284 2 my $st_IP_ADDR_STRING =
285 ['Next' => $LQ, #struct _IP_ADDR_STRING*
286 'IpAddress' => 'a16', #IP_ADDRESS_STRING
287 'IpMask' => 'a16', #IP_MASK_STRING
288 'Context' => 'L', #DWORD
289 @pad,
290 ];
291
292 2 my $MAX_ADAPTER_NAME_LENGTH = 256;
293 2 my $MAX_ADAPTER_DESCRIPTION_LENGTH = 128;
294 2 my $MAX_ADAPTER_ADDRESS_LENGTH = 8;
295
296 2 my $st_IP_ADAPTER_INFO =
297 ['Next' => $LQ, #struct _IP_ADAPTER_INFO*
298 'ComboIndex' => 'L', #DWORD
299 'AdapterName' => 'a'.($MAX_ADAPTER_NAME_LENGTH+4), #char[MAX_ADAPTER_NAME_LENGTH + 4]
300 'Description' => 'a'.($MAX_ADAPTER_DESCRIPTION_LENGTH+4), #char[MAX_ADAPTER_DESCRIPTION_LENGTH + 4]
301 'AddressLength' => 'L', #UINT
302 'Address' => 'a'.$MAX_ADAPTER_ADDRESS_LENGTH, #BYTE[MAX_ADAPTER_ADDRESS_LENGTH]
303 'Index' => 'L', #DWORD
304 'Type' => 'L', #UINT
305 'DhcpEnabled' => 'L', #UINT
306 @pad,
307 'CurrentIpAddress' => $LQ, #PIP_ADDR_STRING
308 'IpAddressList' => $st_IP_ADDR_STRING, #IP_ADDR_STRING
309 'GatewayList' => $st_IP_ADDR_STRING, #IP_ADDR_STRING
310 'DhcpServer' => $st_IP_ADDR_STRING, #IP_ADDR_STRING
311 'HaveWins' => 'L', #BOOL
312 @pad,
313 'PrimaryWinsServer' => $st_IP_ADDR_STRING, #IP_ADDR_STRING
314 'SecondaryWinsServer' => $st_IP_ADDR_STRING, #IP_ADDR_STRING
315 'LeaseObtained' => $LQ, #time_t
316 'LeaseExpires' => $LQ, #time_t
317 ];
318
319 #my $st_MIB_IPADDRROW =
320 # ['dwAddr' => 'L', #DWORD
321 # 'dwIndex' => 'L', #DWORD
322 # 'dwMask' => 'L', #DWORD
323 # 'dwBCastAddr' => 'L', #DWORD
324 # 'dwReasmSize' => 'L', #DWORD
325 # 'unused1' => 'S', #unsigned short
326 # 'unused2' => 'S', #unsigned short
327 # ];
328
329 2 my %UnpackStrCache = ();
330 2 my $UnpackStr = undef;
331 $UnpackStr = sub($$)
332 0 ▶ {
Subroutine __ANON__: not called CC=6 SCAR=37.4
333 0 my ($Struct, $Repeat) = @_;
334 0 ▶ $Repeat or $Repeat = 1;
Branch: 1 branch
BranchTrueFalseTotal
$Repeat or $Repeat = 1 0 0 0
335
336 0 my $StructUpStr = '';
337
338 0 ▶ if (!defined($UnpackStrCache{$Struct}))
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $UnpackStrCache{$Struct}) { } 0 0 0
339 {
340 0 ▶ for (my $RI = 1; defined($Struct->[$RI]); $RI += 2)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Struct->[$RI]) 0 0 0
341 {
342 $StructUpStr .= ref($Struct->[$RI]) ?
343 0 ▶ &{$UnpackStr}($Struct->[$RI], 1) :
Branch: 1 branch
BranchTrueFalseTotal
ref $Struct->[$RI] ? : 0 0 0
344 $Struct->[$RI];
345 };
346 0 $UnpackStrCache{$Struct} = $StructUpStr;
347 }
348 else
349 0 { $StructUpStr = $UnpackStrCache{$Struct}; };
350
351 0 my $UpStr = '';
352 0 ▶ for (; $Repeat > 0; $Repeat--)
Branch: 1 branch
BranchTrueFalseTotal
if ($Repeat > 0) 0 0 0
353 0 { $UpStr .= $StructUpStr; };
354
355 0 return $UpStr;
356 2 }; # $Unpackstr
357
358
359 2 my $ShiftStruct = undef;
360 $ShiftStruct = sub($$)
361 0 ▶ {
Subroutine __ANON__: not called CC=3 SCAR=24.8
362 0 my ($Array, $Struct) = @_;
363
364 0 my $Result = {};
365 #tie(%{$Result}, 'Tie::IxHash');
366
367 0 ▶ for (my $RI = 0; defined($Struct->[$RI]); $RI += 2)
Branch: 1 branch
BranchTrueFalseTotal
if (defined $Struct->[$RI]) 0 0 0
368 {
369 $Result->{$Struct->[$RI]} = ref($Struct->[$RI+1]) ?
370 0 &{$ShiftStruct}($Array, $Struct->[$RI+1]) :
371 0 ▶ shift(@{$Array});
Branch: 1 branch
BranchTrueFalseTotal
ref $$Struct[$RI + 1] ? : 0 0 0
372 };
373 0 return $Result;
374 2 };
375
376 my $UnpackStruct = sub($$)
377 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
378 0 my ($pBuff, $Struct) = @_;
379
380 0 my $UpStr = &{$UnpackStr}($Struct);
381
382 0 my @Array = unpack($UpStr, ${$pBuff});
383
384 0 substr(${$pBuff}, 0, length(pack($UpStr)), '');
385
386 0 return &{$ShiftStruct}(\@Array, $Struct);
387 2 };
388
389
390 my $if_hwaddr = sub($$)
391 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
392 0 my($len, $addr) = @_;
393 0 return join(':', map {sprintf '%02x', $_ } unpack('C' x $len, $addr));
394 2 };
395
396 0 ▶sub if_ipaddr {
Subroutine if_ipaddr: not called CC=1 SCAR=6.9
Pod undocumented
397 0 my ($addr) = @_;
398 0 return join(".", unpack("C4", pack("L", $addr)));
399 };
400
401 my $Win32List = sub($$$$)
402 0 ▶ {
Subroutine __ANON__: not called CC=13 SCAR=52.0
403 0 $Inet2Logic = undef;
404 0 $Logic2Inet = undef;
405 0 $Name2Index = undef;
406
407 0 my $Buff = '';
408 0 my $BuffLen = pack('L', 0);
409
410 0 my $Res = $Win32API{'iphlpapi'}{'GetAdaptersInfo'}->Call(0, $BuffLen);
411
412 0 ▶ while ($Res == $Win32_ERROR_BUFFER_OVERFLOW)
Branch: 1 branch
BranchTrueFalseTotal
if ($Res == $Win32_ERROR_BUFFER_OVERFLOW) 0 0 0
413 {
414 0 $Buff = "\0" x unpack("L", $BuffLen);
415 0 $Res = $Win32API{'iphlpapi'}{'GetAdaptersInfo'}->Call($Buff, $BuffLen);
416 } # while
417
418 0 ▶ if ($Res != $Win32_NO_ERROR)
Branch: 1 branch
BranchTrueFalseTotal
if ($Res != $Win32_NO_ERROR) 0 0 0
419 {
420 0 $! = $Res;
421 0 $@ = "Error running 'GetAdaptersInfo' function: ".&{$Win32_FormatMessage}($Res);
422 0 return;
423 } # if
424
425 0 my $Info = {};
426
427 0 $Inet2Logic = {};
428 0 $Logic2Inet = {};
429 0 $Name2Index = {};
430
431 0 while (1)
432 {
433 0 my $ADAPTER_INFO = &{$UnpackStruct}(\$Buff, $st_IP_ADAPTER_INFO);
434
435 0 foreach my $Field ('AdapterName', 'Description')
436 0 { $ADAPTER_INFO->{$Field} =~ s/\x00+\Z//o; };
437
438 0 foreach my $AddrField ('IpAddressList', 'GatewayList', 'DhcpServer', 'PrimaryWinsServer', 'SecondaryWinsServer')
439 {
440 0 foreach my $Field ('IpAddress', 'IpMask')
441 0 { $ADAPTER_INFO->{$AddrField}{$Field} =~ s/\x00+\Z//o; };
442 };
443
444
445 0 $ADAPTER_INFO->{'Address'} = &{$if_hwaddr}($ADAPTER_INFO->{'AddressLength'}, $ADAPTER_INFO->{'Address'});
446
447 0 foreach my $IpList ('IpAddressList', 'GatewayList')
448 {
449 0 my $ADDR_STRING = $ADAPTER_INFO->{$IpList};
450 0 $ADAPTER_INFO->{$IpList} = [$ADDR_STRING,];
451 0 ▶ while ($ADDR_STRING->{'Next'})
Branch: 1 branch
BranchTrueFalseTotal
if ($ADDR_STRING->{"Next"}) 0 0 0
452 {
453 0 $ADDR_STRING = &{$UnpackStruct}(\$Buff, $st_IP_ADDR_STRING);
454 0 foreach my $Field ('IpAddress', 'IpMask')
455 {
456 0 $ADDR_STRING->{$Field} =~ s/\x00+\Z//o;
457 } # foreach
458 0 push(@{$ADAPTER_INFO->{$IpList}}, $ADDR_STRING);
459 } # while
460 } # foreach
461
462 0 my $Iface = $ADAPTER_INFO->{'AdapterName'};
463
464 0 $Info->{$Iface}{'descr'} = $ADAPTER_INFO->{'Description'};
465 0 $Info->{$Iface}{'ether'} = $ADAPTER_INFO->{'Address'};
466 0 $Info->{$Iface}{'status'} = 1;
467
468 0 foreach my $Addr (@{$ADAPTER_INFO->{'IpAddressList'}})
469 {
470 0 ▶ ($Addr->{'IpAddress'} eq '0.0.0.0')
Branch: 1 branch
BranchTrueFalseTotal
$Addr->{"IpAddress"} eq "0.0.0.0" and next 0 0 0
471 and next;
472 0 $Info->{$Iface}{'inet'}{$Addr->{'IpAddress'}} = $Addr->{'IpMask'};
473 0 $Inet2Logic->{$Iface}{$Addr->{'IpAddress'}} = $Addr->{'Context'};
474 0 $Logic2Inet->{$Iface}{$Addr->{'Context'}} = $Addr->{'IpAddress'};
475 } # foreach
476
477 0 $Name2Index->{$Iface} = $ADAPTER_INFO->{'Index'};
478
479 0 ▶ $ADAPTER_INFO->{'Next'}
Branch: 1 branch
BranchTrueFalseTotal
$ADAPTER_INFO->{"Next"} or last 0 0 0
480 or last;
481 } # while
482
483
484 #$Buff = '';
485 #$BuffLen = pack('L', 0);
486 #$Res = $Win32API{'iphlpapi'}{'GetIpAddrTable'}->Call($Buff, $BuffLen, 0);
487 #
488 #while ($Res == ERROR_INSUFFICIENT_BUFFER)
489 # {
490 # $Buff = "\0" x unpack("L", $BuffLen);
491 # $Res = $Win32API{'iphlpapi'}{'GetIpAddrTable'}->Call($Buff, $BuffLen, 0);
492 # };
493 #
494 #if ($Res != $Win32_NO_ERROR)
495 # {
496 # $! = $Res;
497 # $@ = "Error running 'GetIpAddrTable' function: ".&{$Win32_FormatMessage}($Res);
498 # return;
499 # };
500 #
501 #my $IpAddrTable = &{$UnpackStruct}(\$Buff, ['Len' => 'L']);
502 #my %Info1 = ();
503 #for (; $IpAddrTable->{'Len'} > 0; $IpAddrTable->{'Len'}--)
504 # {
505 # my $IPADDRROW = &{$UnpackStruct}(\$Buff, $st_MIB_IPADDRROW);
506 # $Info->{$IPADDRROW->{'dwIndex'}}
507 # and next;
508 # $Info1{$IPADDRROW->{'dwIndex'}}{'inet'}{if_ipaddr($IPADDRROW->{'dwAddr'})} = if_ipaddr($IPADDRROW->{'dwMask'});
509 # };
510 #
511 #foreach my $Iface (keys(%Info1))
512 # { $Info->{$Iface} = $Info1{$Iface}; };
513
514 0 ▶ return wantarray ? %{$Info} : $Info;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
515 2 }; # Win32List
516
517
518 2 my $IFCONFIG = '/sbin/ifconfig';
519
520 2 $Ifconfig{'list'} = {'solaris' => {'ifconfig' => qq/LC_ALL=C $IFCONFIG -a/,
521 'function' => $SolarisList},
522 'openbsd' => {'ifconfig' => qq/LC_ALL=C $IFCONFIG -A/,
523 'function' => $SolarisList},
524 'linux' => {'ifconfig' => qq/LC_ALL=C $IFCONFIG -a/,
525 'function' => $LinuxList},
526 'MSWin32' => {'ifconfig' => '',
527 'function' => $Win32List,},
528 };
529
530 2 $Ifconfig{'list'}{'freebsd'} = $Ifconfig{'list'}{'solaris'};
531 2 $Ifconfig{'list'}{'darwin'} = $Ifconfig{'list'}{'solaris'};
532 2 $Ifconfig{'list'}{'cygwin'} = $Ifconfig{'list'}{'MSWin32'};
533
534
535 my $UpDown = sub($$$$)
536 0 ▶ {
Subroutine __ANON__: not called CC=5 SCAR=34.0
537 0 my ($CName, $Iface, $Addr, $Mask) = @_;
538
539 0 ▶ if (!(defined($Iface) && defined($Addr) && defined($Mask)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Iface and defined $Addr and defined $Mask) 0 0 0
Condition0%0/6
defined $Iface and defined $Addr and defined $Mask
!ll&&!rl&&r
000
defined $Iface and defined $Addr
!ll&&!rl&&r
000
MC/DC0%0/3
defined $Iface and defined $Addr and defined $Mask
defined $Iface defined $Addr defined $Mask
Truth table0%0/4
A and B and C
A= defined $IfaceB= defined $AddrC= defined $Mask
ABCresult
0XX0
10X0
1100
1111
540 {
541 0 $@ = "Command '$CName': interface, inet address and netmask have to be defined";
542 0 return;
543 };
544
545 0 my $Output = &{$RunCmd}($CName, $Iface, '', $Addr, $Mask);
546
547 0 $Inet2Logic = undef;
548 0 $Logic2Inet = undef;
549
550 0 ▶ $Output ? return $Output : return;
Branch: 1 branch
BranchTrueFalseTotal
$Output ? : 0 0 0
551 2 }; # $UpDown
552
553 my $UpDownNewLog = sub($$$$)
554 0 ▶ {
Subroutine __ANON__: not called CC=11 SCAR=48.8
555 0 my ($CName, $Iface, $Addr, $Mask) = @_;
556
557 0 ▶ if (!(defined($Iface) && defined($Addr) && defined($Mask)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Iface and defined $Addr and defined $Mask) 0 0 0
Condition0%0/6
defined $Iface and defined $Addr and defined $Mask
!ll&&!rl&&r
000
defined $Iface and defined $Addr
!ll&&!rl&&r
000
MC/DC0%0/3
defined $Iface and defined $Addr and defined $Mask
defined $Iface defined $Addr defined $Mask
Truth table0%0/4
A and B and C
A= defined $IfaceB= defined $AddrC= defined $Mask
ABCresult
0XX0
10X0
1100
1111
558 {
559 0 $@ = "Command '$CName': interface, inet address and netmask have to be defined";
560 0 return;
561 };
562
563 defined($Inet2Logic)
564 or (defined($Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}) ?
565 0 &{$Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}}() :
566 0 ▶ &{$Ifconfig{'list'}{$^O}{'function'}}())
Branch: 2 branches
BranchTrueFalseTotal
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}() or return 0 0 0
defined $Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'} ? : 0 0 0
Condition0%0/3
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
defined $Inet2Logic defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
Truth table0%0/3
A or B
A= defined $Inet2LogicB= defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
ABresult
1X1
011
000
567 or return;
568
569 0 my $Logic = $Inet2Logic->{$Iface}{$Addr};
570
571 0 my $RunIndex = 1;
572 0 ▶ for(; !defined($Logic); $RunIndex++)
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Logic) 0 0 0
573 {
574 0 ▶ if ($RunIndex > $MAXLOGIC)
Branch: 1 branch
BranchTrueFalseTotal
if ($RunIndex > $MAXLOGIC) 0 0 0
575 {
576 0 $@ = "Command '$CName': maximum number of logic interfaces ($MAXLOGIC) on interface '$Iface' exceeded";
577 0 return;
578 };
579 0 ▶ defined($Logic2Inet->{$Iface}{$RunIndex})
Branch: 1 branch
BranchTrueFalseTotal
defined $Logic2Inet->{$Iface}{$RunIndex} or $Logic = $RunIndex 0 0 0
580 or $Logic = $RunIndex;
581 };
582
583 0 my $Output = &{$RunCmd}($CName, $Iface, $Logic, $Addr, $Mask);
584
585 0 $Inet2Logic = undef;
586 0 $Logic2Inet = undef;
587
588 0 ▶ $Output ? return $Output : return;
Branch: 1 branch
BranchTrueFalseTotal
$Output ? : 0 0 0
589 2 }; # $UpDownNewLog
590
591 my $UpDownReqLog = sub($$$$)
592 0 ▶ {
Subroutine __ANON__: not called CC=9 SCAR=45.0
593 0 my ($CName, $Iface, $Addr, $Mask) = @_;
594
595 0 ▶ if (!(defined($Iface) && defined($Addr) && defined($Mask)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Iface and defined $Addr and defined $Mask) 0 0 0
Condition0%0/6
defined $Iface and defined $Addr and defined $Mask
!ll&&!rl&&r
000
defined $Iface and defined $Addr
!ll&&!rl&&r
000
MC/DC0%0/3
defined $Iface and defined $Addr and defined $Mask
defined $Iface defined $Addr defined $Mask
Truth table0%0/4
A and B and C
A= defined $IfaceB= defined $AddrC= defined $Mask
ABCresult
0XX0
10X0
1100
1111
596 {
597 0 $@ = "Command '$CName': interface, inet address and netmask have to be defined";
598 0 return;
599 };
600
601 defined($Inet2Logic)
602 or (defined($Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}) ?
603 0 &{$Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}}() :
604 0 ▶ &{$Ifconfig{'list'}{$^O}{'function'}}())
Branch: 2 branches
BranchTrueFalseTotal
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}() or return 0 0 0
defined $Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'} ? : 0 0 0
Condition0%0/3
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
defined $Inet2Logic defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
Truth table0%0/3
A or B
A= defined $Inet2LogicB= defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
ABresult
1X1
011
000
605 or return;
606
607 0 my $Logic = $Inet2Logic->{$Iface}{$Addr};
608
609 0 ▶ if (!defined($Logic))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Logic) 0 0 0
610 {
611 0 $@ = "Command '$CName': can not get logic interface for interface '$Iface', inet address '$Addr'";
612 0 return;
613 };
614
615 0 my $Output = &{$RunCmd}($CName, $Iface, $Logic, $Addr, $Mask);
616
617 0 $Inet2Logic = undef;
618 0 $Logic2Inet = undef;
619
620 0 ▶ $Output ? return $Output : return;
Branch: 1 branch
BranchTrueFalseTotal
$Output ? : 0 0 0
621 2 }; # $UpDownReqLog
622
623 #my $Win32UpDown = sub($$)
624 # {
625 # my ($Iface, $State) = @_;
626 #
627 #
628 # };
629 #
630 #my $Win32Inet = sub($$$$)
631 # {
632 # my ($CName, $Iface, $Addr, $Mask) = @_;
633 #
634 #
635 # if (!(defined($Iface) && defined($Addr) && defined($Mask)))
636 # {
637 # $@ = "Command '$CName': interface, inet address and netmask have to be defined";
638 # return;
639 # };
640 #
641 # $Win32Up($Iface)
642 # or return;
643 #
644 # $Win32AddIP($Iface, $Addr, $Mask)
645 # or return;
646 # my $Output = &{$RunCmd}('inet', '$Iface', '', '$Addr', '$Mask');
647 #
648 # $Inet2Logic = undef;
649 # $Logic2Inet = undef;
650 #
651 # $Output ? return $Output : return;
652 # };
653
654
655 my $PackIP = sub($)
656 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
657 0 my @Bytes = split('\.', $_[0]);
658 0 return unpack("L", pack('C4', @Bytes));
659 2 };
660
661 my $Win32AddAlias = sub($$$$)
662 0 ▶ {
Subroutine __ANON__: not called CC=10 SCAR=47.0
663 0 my ($CName, $Iface, $Addr, $Mask) = @_;
664
665 0 ▶ if (!(defined($Iface) && defined($Addr) && defined($Mask)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Iface and defined $Addr and defined $Mask) 0 0 0
Condition0%0/6
defined $Iface and defined $Addr and defined $Mask
!ll&&!rl&&r
000
defined $Iface and defined $Addr
!ll&&!rl&&r
000
MC/DC0%0/3
defined $Iface and defined $Addr and defined $Mask
defined $Iface defined $Addr defined $Mask
Truth table0%0/4
A and B and C
A= defined $IfaceB= defined $AddrC= defined $Mask
ABCresult
0XX0
10X0
1100
1111
666 {
667 0 $@ = "Command '$CName': interface, inet address and netmask have to be defined";
668 0 return;
669 };
670
671 defined($Inet2Logic)
672 or (defined($Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}) ?
673 0 &{$Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}}() :
674 0 ▶ &{$Ifconfig{'list'}{$^O}{'function'}}())
Branch: 2 branches
BranchTrueFalseTotal
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}() or return 0 0 0
defined $Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'} ? : 0 0 0
Condition0%0/3
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
defined $Inet2Logic defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
Truth table0%0/3
A or B
A= defined $Inet2LogicB= defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
ABresult
1X1
011
000
675 or return;
676
677 0 my $NTEContext = pack('L', 0);
678 0 my $NTEInstance = pack('L', 0);
679
680 0 my $Index = $Name2Index->{$Iface};
681
682 0 ▶ if (!defined($Index))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Index) 0 0 0
683 {
684 0 $@ = "Command '$CName': can not get interface index for interface '$Iface'";
685 0 return;
686 };
687
688 0 my $Res = $Win32API{'iphlpapi'}{'AddIPAddress'}->Call(&{$PackIP}($Addr), &{$PackIP}($Mask), $Index, $NTEContext, $NTEInstance);
689
690 0 ▶ if ($Res != $Win32_NO_ERROR)
Branch: 1 branch
BranchTrueFalseTotal
if ($Res != $Win32_NO_ERROR) 0 0 0
691 {
692 0 $! = $Res;
693 0 ▶ $@ = &{$Win32_FormatMessage}($Res)
Branch: 1 branch
BranchTrueFalseTotal
$@ = &{$Win32_FormatMessage;}($Res) or $@ = "Unknown error :(" 0 0 0
694 or $@ = 'Unknown error :(';
695 0 return;
696 };
697
698 0 $Inet2Logic = undef;
699 0 $Logic2Inet = undef;
700
701 0 return ['Command completed successfully'];
702 2 };
703
704 my $Win32RemAlias = sub($$$$)
705 0 ▶ {
Subroutine __ANON__: not called CC=9 SCAR=45.0
706 0 my ($CName, $Iface, $Addr, $Mask) = @_;
707
708 0 ▶ if (!(defined($Iface) && defined($Addr) && defined($Mask)))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Iface and defined $Addr and defined $Mask) 0 0 0
Condition0%0/6
defined $Iface and defined $Addr and defined $Mask
!ll&&!rl&&r
000
defined $Iface and defined $Addr
!ll&&!rl&&r
000
MC/DC0%0/3
defined $Iface and defined $Addr and defined $Mask
defined $Iface defined $Addr defined $Mask
Truth table0%0/4
A and B and C
A= defined $IfaceB= defined $AddrC= defined $Mask
ABCresult
0XX0
10X0
1100
1111
709 {
710 0 $@ = "Command '$CName': interface, inet address and netmask have to be defined";
711 0 return;
712 };
713
714 defined($Inet2Logic)
715 or (defined($Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}) ?
716 0 &{$Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}}() :
717 0 ▶ &{$Ifconfig{'list'}{$^O}{'function'}}())
Branch: 2 branches
BranchTrueFalseTotal
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}() or return 0 0 0
defined $Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'} ? : 0 0 0
Condition0%0/3
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
defined $Inet2Logic defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
Truth table0%0/3
A or B
A= defined $Inet2LogicB= defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
ABresult
1X1
011
000
718 or return;
719
720 0 my $Logic = $Inet2Logic->{$Iface}{$Addr};
721
722 0 ▶ if (!defined($Logic))
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $Logic) 0 0 0
723 {
724 0 $@ = "Command '$CName': can not get logic interface for interface '$Iface', inet address '$Addr'";
725 0 return;
726 };
727
728 0 my $Res = $Win32API{'iphlpapi'}{'DeleteIPAddress'}->Call($Logic);
729
730 0 ▶ if ($Res != $Win32_NO_ERROR)
Branch: 1 branch
BranchTrueFalseTotal
if ($Res != $Win32_NO_ERROR) 0 0 0
731 {
732 0 $! = $Res;
733 0 $@ = &{$Win32_FormatMessage}($Res);
734 0 return;
735 };
736
737 0 $Inet2Logic = undef;
738 0 $Logic2Inet = undef;
739
740 0 return ['Command completed successfully'];
741 2 };
742
743
744 2 $Ifconfig{'inet'} = {'solaris' => {'ifconfig' => $IFCONFIG .' %Iface% inet %Addr% netmask %Mask% up',
745 'function' => $UpDown},
746 # 'MSWin32' => {'ifconfig' => '',
747 # 'function' => $Win32Inet,},
748 };
749 2 $Ifconfig{'inet'}{'freebsd'} = $Ifconfig{'inet'}{'solaris'};
750 2 $Ifconfig{'inet'}{'openbsd'} = $Ifconfig{'inet'}{'solaris'};
751 2 $Ifconfig{'inet'}{'linux'} = $Ifconfig{'inet'}{'solaris'};
752 2 $Ifconfig{'inet'}{'darwin'} = $Ifconfig{'inet'}{'solaris'};
753
754 2 $Ifconfig{'up'} = $Ifconfig{'inet'};
755
756 2 $Ifconfig{'down'}{'solaris'} = {'ifconfig' => $IFCONFIG .' %Iface% down',
757 'function' => $UpDown,
758 };
759 2 $Ifconfig{'down'}{'freebsd'} = $Ifconfig{'down'}{'solaris'};
760 2 $Ifconfig{'down'}{'openbsd'} = $Ifconfig{'down'}{'solaris'};
761 2 $Ifconfig{'down'}{'linux'} = $Ifconfig{'down'}{'solaris'};
762 2 $Ifconfig{'down'}{'darwin'} = $Ifconfig{'down'}{'solaris'};
763
764 2 $Ifconfig{'+alias'} = {'freebsd' => {'ifconfig' => $IFCONFIG .' %Iface% inet %Addr% netmask %Mask% alias',
765 'function' => $UpDown},
766 'solaris' => {'ifconfig' => $IFCONFIG .' %Iface%:%Logic% inet %Addr% netmask %Mask% up',
767 'function' => $UpDownNewLog},
768 'MSWin32' => {'ifconfig' => '',
769 'function' => $Win32AddAlias,},
770 };
771 2 $Ifconfig{'+alias'}{'openbsd'} = $Ifconfig{'+alias'}{'freebsd'};
772 2 $Ifconfig{'+alias'}{'linux'} = $Ifconfig{'+alias'}{'solaris'};
773 2 $Ifconfig{'+alias'}{'darwin'} = $Ifconfig{'+alias'}{'freebsd'};
774
775 2 $Ifconfig{'+alias'}{'solaris'}{'SunOS'}{'5.8'}{'ifconfig'} = $IFCONFIG .' %Iface%:%Logic% plumb; '. $IFCONFIG .' %Iface%:%Logic% inet %Addr% netmask %Mask% up';
776 2 $Ifconfig{'+alias'}{'solaris'}{'SunOS'}{'5.9'}{'ifconfig'} = $Ifconfig{'+alias'}{'solaris'}{'SunOS'}{'5.8'}{'ifconfig'};
777 2 $Ifconfig{'+alias'}{'solaris'}{'SunOS'}{'5.10'}{'ifconfig'} = $Ifconfig{'+alias'}{'solaris'}{'SunOS'}{'5.8'}{'ifconfig'};
778
779 2 $Ifconfig{'alias'} = $Ifconfig{'+alias'};
780
781
782 2 $Ifconfig{'-alias'} = {'freebsd' => {'ifconfig' => $IFCONFIG .' %Iface% inet %Addr% -alias',
783 'function' => $UpDown},
784 'solaris' => {'ifconfig' => $IFCONFIG .' %Iface%:%Logic% down',
785 'function' => $UpDownReqLog},
786 'MSWin32' => {'ifconfig' => '',
787 'function' => $Win32RemAlias,},
788 };
789 2 $Ifconfig{'-alias'}{'openbsd'} = $Ifconfig{'-alias'}{'freebsd'};
790 2 $Ifconfig{'-alias'}{'linux'} = $Ifconfig{'-alias'}{'solaris'};
791 2 $Ifconfig{'-alias'}{'darwin'} = $Ifconfig{'-alias'}{'freebsd'};
792
793 2 $Ifconfig{'-alias'}{'solaris'}{'SunOS'}{'5.9'}{'ifconfig'} = $IFCONFIG .' %Iface%:%Logic% unplumb';
794
795 1 ▶sub Ifconfig {
Subroutine Ifconfig: called CC=9 SCAR=35.0
Pod documented
796 1 my ($CName, $Iface, $Addr, $Mask) = @_;
797 1 ▶ if (!($CName && $Ifconfig{$CName} && $Ifconfig{$CName}{$^O}))
Branch: 1 branch
BranchTrueFalseTotal
unless ($CName and $Ifconfig{$CName} and $Ifconfig{$CName}{$^O}) 0 1 1
Condition33%2/6
$CName and $Ifconfig{$CName} and $Ifconfig{$CName}{$^O}
!ll&&!rl&&r
001
$CName and $Ifconfig{$CName}
!ll&&!rl&&r
001
MC/DC0%0/3
$CName and $Ifconfig{$CName} and $Ifconfig{$CName}{$^O}
$CName $Ifconfig{$CName} $Ifconfig{$CName}{$^O}
Truth table25%1/4
A and B and C
A= $CNameB= $Ifconfig{$CName}C= $Ifconfig{$CName}{$^O}
ABCresult
0XX0
10X0
1100
1111
798 {
799 0 $@ = "Command '$CName' is not defined for system '$^O'";
800 0 return;
801 };
802
803 defined($Inet2Logic)
804 or (defined($Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}) ?
805 0 &{$Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'}}() :
806 1 ▶ &{$Ifconfig{'list'}{$^O}{'function'}}())
Branch: 2 branches
BranchTrueFalseTotal
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}() or return 0 1 1
defined $Ifconfig{'list'}{$^O}{$OsName}{$OsVers}{'function'} ? : 0 1 1
Condition33%1/3
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
l!l&&r!l&&!r
001
MC/DC0%0/2
defined $Inet2Logic or defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
defined $Inet2Logic defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
Truth table33%1/3
A or B
A= defined $Inet2LogicB= defined $Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"} ? &{$Ifconfig{"list"}{$^O}{$OsName}{$OsVers}{"function"};}() : &{$Ifconfig{"list"}{$^O}{"function"};}()
ABresult
1X1
011
000
807 or return;
808
809 my $Output = (defined($Ifconfig{$CName}{$^O}{$OsName}{$OsVers}{'function'}) ?
810 0 &{$Ifconfig{$CName}{$^O}{$OsName}{$OsVers}{'function'}}($CName, $Iface, $Addr, $Mask) :
811 0 ▶ &{$Ifconfig{$CName}{$^O}{'function'}}($CName, $Iface, $Addr, $Mask));
Branch: 1 branch
BranchTrueFalseTotal
defined $Ifconfig{$CName}{$^O}{$OsName}{$OsVers}{'function'} ? : 0 0 0
812
813 0 ▶ $Output ? return $Output : return;
Branch: 1 branch
BranchTrueFalseTotal
$Output ? : 0 0 0
814 }
815
816 2 1;
817
818 __END__
↑ Summary