lib/Rex/Hardware/Network/Linux.pm

filter: Statementstmt 52.8% 111 / 210 Branchbran 43.1% 38 / 88 Conditioncond 41.3% 12 / 29 MC/DCmcdc 35.2% 6 / 17 Subroutinesub 81.2% 13 / 16 Podpod 0.0% 0 / 6 totaltotal 49.1% 180 / 366 CC 62 SCAR 46.8
CC
62
Cov
49%
netstat
380.0
default_gateway
72.0
get_bridge_devices
20.7
CRAP 108.1
« lib/Rex/Commands/Run.pm ↑ Summary lib/Rex/Commands/Kernel.pm »
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4  
5 package Rex::Hardware::Network::Linux;
6  
7 6 ▶use v5.14.4;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 6 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 6 our $VERSION = '1.16.1'; # VERSION
11  
12 6 ▶use Rex::Logger;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 6 ▶use Rex::Helper::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 6 ▶use Rex::Commands::Run;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 6 ▶use Rex::Helper::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 6 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 9 ▶sub get_bridge_devices {
Subroutine get_bridge_devices: called CC=5 SCAR=30.3
Pod undocumented
19 9 ▶ unless ( can_run("brctl") ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (can_run("brctl")) 9 0 9
20 9 Rex::Logger::debug("No brctl available");
21 9 return {};
22 }
23  
24 0 local $/ = "\n";
25 0 my @lines = i_run 'brctl show', fail_ok => 1;
26 0 chomp @lines;
27 0 shift @lines;
28  
29 0 my $current_bridge;
30 0 my $data = {};
31 0 for my $line (@lines) {
32 0 ▶ if ( $line =~ m/^[A-Za-z0-9_.]+/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^[A-Za-z0-9_.]+/u) 0 0 0
33 0 my ( $br, $br_id, $stp, $dev ) = split( /\s+/, $line );
34 0 $current_bridge = $br;
35 0 $data->{$br}->{stp} = 0;
36 0 push @{ $data->{$br}->{devices} }, $dev;
37 0 next;
38 }
39  
40 0 my ($dev) = ( $line =~ m/([a-zA-Z0-9_.]+)$/ );
41 0 ▶ if ($dev) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dev) 0 0 0
42 0 push @{ $data->{$current_bridge}->{devices} }, $dev;
43 }
44 }
45  
46 0 return $data;
47 }
48  
49 9 ▶sub get_network_devices {
Subroutine get_network_devices: called CC=3 SCAR=11.2
Pod undocumented
50  
51 9 ▶ my $command = can_run('ip') ? 'ip addr show' : 'ifconfig -a';
Branch: 1 branch
BranchTrueFalseTotal
can_run('ip') ? : 0 9 9
52 9 my @output = i_run( "$command", fail_ok => 1 );
53  
54 9 ▶ my $devices =
Branch: 1 branch
BranchTrueFalseTotal
$command eq 'ip addr show' ? : 0 9 9
55 ( $command eq 'ip addr show' )
56 ? _parse_ip(@output)
57 : _parse_ifconfig(@output);
58 9 my @device_list = keys %{$devices};
59  
60 9 return \@device_list;
61 }
62  
63 9 ▶sub get_network_configuration {
Subroutine get_network_configuration: called CC=5 SCAR=16.7
Pod undocumented
64  
65 9 my $device_info = {};
66  
67 9 ▶ my $command = can_run('ip') ? 'ip addr show' : 'ifconfig -a';
Branch: 1 branch
BranchTrueFalseTotal
can_run('ip') ? : 0 9 9
68 9 my @output = i_run( "$command", fail_ok => 1 );
69  
70 9 my $br_data = get_bridge_devices();
71  
72 9 ▶ my $data =
Branch: 1 branch
BranchTrueFalseTotal
$command eq 'ip addr show' ? : 0 9 9
73 ( $command eq 'ip addr show' )
74 ? _parse_ip(@output)
75 : _parse_ifconfig(@output);
76  
77 9 for my $dev ( keys %{$data} ) {
78 9 ▶ if ( exists $br_data->{$dev} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $br_data->{$dev}) { } 0 9 9
79 0 $data->{$dev}->{is_bridge} = 1;
80 }
81 else {
82 9 $data->{$dev}->{is_bridge} = 0;
83 }
84 }
85  
86 9 return $data;
87 }
88  
89 22 ▶sub _parse_ifconfig {
Subroutine _parse_ifconfig: called CC=11 SCAR=24.0
90 22 my (@ifconfig) = @_;
91  
92 22 my $dev = {};
93  
94 22 my $cur_dev;
95 22 for my $line (@ifconfig) {
96 67 ▶ if ( $line =~ m/^([a-zA-Z0-9:\._]+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^([a-zA-Z0-9:\._]+)/u) 24 43 67
97 24 my $new_dev = $1;
98 24 ▶ $new_dev = substr( $new_dev, 0, -1 ) if ( $new_dev =~ m/:$/ );
Branch: 1 branch
BranchTrueFalseTotal
if $new_dev =~ /:$/u 21 3 24
99  
100 24 ▶ if ( $cur_dev && $cur_dev ne $new_dev ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur_dev and $cur_dev ne $new_dev) 2 22 24
Condition66%2/3
$cur_dev and $cur_dev ne $new_dev
!ll&&!rl&&r
2202
MC/DC50%1/2
$cur_dev and $cur_dev ne $new_dev
$cur_dev $cur_dev ne $new_dev
Truth table66%2/3
A and B
A= $cur_devB= $cur_dev ne $new_dev
ABresult
0X0
100
111
101 2 $cur_dev = $new_dev;
102 }
103  
104 24 ▶ if ( !$cur_dev ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cur_dev) 22 2 24
105 22 $cur_dev = $new_dev;
106 }
107  
108 24 $dev->{$cur_dev}->{mac} = "";
109 24 $dev->{$cur_dev}->{ip} = "";
110 24 $dev->{$cur_dev}->{netmask} = "";
111 24 $dev->{$cur_dev}->{broadcast} = "";
112  
113 }
114  
115 67 ▶ if ( $line =~ m/(ether|HWaddr) (..:..:..:..:..:..)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /(ether|HWaddr) (..:..:..:..:..:..)/u) 4 63 67
116 4 $dev->{$cur_dev}->{mac} = $2;
117 }
118  
119 67 ▶ if ( $line =~ m/inet( addr:| )?(\d+\.\d+\.\d+\.\d+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /inet( addr:| )?(\d+\.\d+\.\d+\.\d+)/u) 5 62 67
120 5 $dev->{$cur_dev}->{ip} = $2;
121 }
122  
123 67 ▶ if ( $line =~ m/(netmask |Mask:)(\d+\.\d+\.\d+\.\d+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /(netmask |Mask:)(\d+\.\d+\.\d+\.\d+)/u) 5 62 67
124 5 $dev->{$cur_dev}->{netmask} = $2;
125 }
126  
127 67 ▶ if ( $line =~ m/(broadcast |Bcast:)(\d+\.\d+\.\d+\.\d+)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /(broadcast |Bcast:)(\d+\.\d+\.\d+\.\d+)/u) 3 64 67
128 3 $dev->{$cur_dev}->{broadcast} = $2;
129 }
130  
131 }
132  
133 22 return $dev;
134  
135 }
136  
137 6 ▶sub _parse_ip {
Subroutine _parse_ip: called CC=15 SCAR=27.1
138 6 my (@ip_lines) = @_;
139  
140 6 my $dev = {};
141  
142 6 my $cur_dev;
143 6 for my $line (@ip_lines) {
144 47 ▶ if ( $line =~ m/^\d+:\s*([^\s]+):/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^\d+:\s*([^\s]+):/u) 9 38 47
145 9 my $new_dev = $1;
146  
147 9 ▶ if ( $cur_dev && $cur_dev ne $new_dev ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur_dev and $cur_dev ne $new_dev) 3 6 9
Condition66%2/3
$cur_dev and $cur_dev ne $new_dev
!ll&&!rl&&r
603
MC/DC50%1/2
$cur_dev and $cur_dev ne $new_dev
$cur_dev $cur_dev ne $new_dev
Truth table66%2/3
A and B
A= $cur_devB= $cur_dev ne $new_dev
ABresult
0X0
100
111
148 3 $cur_dev = $new_dev;
149 }
150  
151 9 ▶ if ( !$cur_dev ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($cur_dev) 6 3 9
152 6 $cur_dev = $new_dev;
153 }
154  
155 9 $dev->{$cur_dev}->{ip} = "";
156 9 $dev->{$cur_dev}->{mac} = "";
157 9 $dev->{$cur_dev}->{netmask} = "";
158 9 $dev->{$cur_dev}->{broadcast} = "";
159  
160 9 next;
161 }
162  
163 38 ▶ if ( $line =~ m/^\s*link\/ether (..:..:..:..:..:..)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ m[^\s*link/ether (..:..:..:..:..:..)]u) 5 33 38
164 5 $dev->{$cur_dev}->{mac} = $1;
165 }
166  
167 # loopback
168 # if ( $line =~ m/^\s*inet (\d+\.\d+\.\d+\.\d+)\/(\d+) scope host lo/ ) {
169 # $dev->{$cur_dev}->{ip} = $1;
170 # $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($2);
171 # }
172  
173 38 my $sec_i = 1;
174 38 ▶ if ( $line =~
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ m[^\s*inet (\d+\.\d+\.\d+\.\d+)/(\d+) (brd (\d+\.\d+\.\d+\.\d+) )?scope ([^\s]+) (\w+\s)?(.+?)$]u) 9 29 38
175 m/^\s*inet (\d+\.\d+\.\d+\.\d+)\/(\d+) (brd (\d+\.\d+\.\d+\.\d+) )?scope ([^\s]+) (\w+\s)?(.+?)$/
176 )
177 {
178 9 my $ip = $1;
179 9 my $cidr_prefix = $2;
180 9 ▶ my $broadcast = $4 || '';
Condition100%2/2
$4 || ''
l!l
54
MC/DC100%1/1
$4 || ''
$4
Truth table100%2/2
A
A= $4
Aresult
11
00
181 9 my $scope = $5;
182 9 ▶ my $dev_name = $7 || $6;
Condition33%1/3
$7 || $6
l!l&&r!l&&!r
900
MC/DC0%0/2
$7 || $6
$7 $6
Truth table33%1/3
A || B
A= $7B= $6
ABresult
1X1
011
000
183 9 chomp $dev_name;
184  
185 9 ▶ if ( $scope eq "global" && $dev_name ne $cur_dev ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($scope eq 'global' and $dev_name ne $cur_dev) { } 1 8 9
elsif ($dev_name eq $cur_dev and $dev->{$cur_dev}{'ip'}) { } 1 7 8
Condition100%3/3
$scope eq "global" and $dev_name ne $cur_dev
!ll&&!rl&&r
351
MC/DC100%2/2
$scope eq "global" and $dev_name ne $cur_dev
$scope eq "global" $dev_name ne $cur_dev
Truth table100%3/3
A and B
A= $scope eq "global"B= $dev_name ne $cur_dev
ABresult
0X0
100
111
186  
187 # this is an alias
188 1 $dev->{$dev_name}->{ip} = $ip;
189 1 $dev->{$dev_name}->{broadcast} = $broadcast;
190 1 $dev->{$dev_name}->{netmask} = _convert_cidr_prefix($cidr_prefix);
191 1 $dev->{$dev_name}->{mac} = $dev->{$cur_dev}->{mac};
192 }
193 ▶ elsif ( $dev_name eq $cur_dev && $dev->{$cur_dev}->{ip} ) {
Condition66%2/3
$dev_name eq $cur_dev and $dev->{$cur_dev}{"ip"}
!ll&&!rl&&r
071
MC/DC50%1/2
$dev_name eq $cur_dev and $dev->{$cur_dev}{"ip"}
$dev_name eq $cur_dev $dev->{$cur_dev}{"ip"}
Truth table66%2/3
A and B
A= $dev_name eq $cur_devB= $dev->{$cur_dev}{"ip"}
ABresult
0X0
100
111
194  
195 # there is already an ip address, so this must be a secondary
196 1 $dev->{"${dev_name}_${sec_i}"}->{ip} = $ip;
197 1 $dev->{"${dev_name}_${sec_i}"}->{broadcast} = $broadcast;
198 $dev->{"${dev_name}_${sec_i}"}->{netmask} =
199 1 _convert_cidr_prefix($cidr_prefix);
200 1 $dev->{"${dev_name}_${sec_i}"}->{mac} = $dev->{$cur_dev}->{mac};
201 1 $sec_i++;
202 }
203 else {
204 7 $dev->{$cur_dev}->{ip} = $ip;
205 7 $dev->{$cur_dev}->{broadcast} = $broadcast;
206 7 $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($cidr_prefix);
207 }
208 }
209  
210 # ppp
211 38 ▶ if ( $line =~
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ m[^\s*inet (\d+\.\d+\.\d+\.\d+) peer (\d+\.\d+\.\d+\.\d+)/(\d+)]u) 1 37 38
212 m/^\s*inet (\d+\.\d+\.\d+\.\d+) peer (\d+\.\d+\.\d+\.\d+)\/(\d+)/ )
213 {
214 1 $dev->{$cur_dev}->{ip} = $1;
215 1 $dev->{$cur_dev}->{netmask} = _convert_cidr_prefix($3);
216 }
217 }
218  
219 6 return $dev;
220 }
221  
222 0 ▶sub route {
Subroutine route: not called CC=3 SCAR=24.8
Pod undocumented
223  
224 0 my @ret = ();
225  
226 0 my @route = i_run "netstat -nr", fail_ok => 1;
227 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
228 0 die("Error running netstat");
229 }
230  
231 0 shift @route;
232 0 shift @route; # remove first 2 lines
233  
234 0 for my $route_entry (@route) {
235 0 my ( $dest, $gw, $genmask, $flags, $mss, $window, $irtt, $iface ) =
236 split( /\s+/, $route_entry, 8 );
237 0 push(
238 @ret,
239 {
240 destination => $dest,
241 gateway => $gw,
242 genmask => $genmask,
243 flags => $flags,
244 mss => $mss,
245 irtt => $irtt,
246 iface => $iface,
247 }
248 );
249 }
250  
251 0 return @ret;
252  
253 }
254  
255 0 ▶sub default_gateway {
Subroutine default_gateway: not called CC=8 SCAR=42.8
Pod undocumented
256  
257 0 my ( $class, $new_default_gw ) = @_;
258  
259 0 ▶ if ($new_default_gw) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_default_gw) { } 0 0 0
260 0 ▶ if ( default_gateway() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (default_gateway()) 0 0 0
261 0 i_run "/sbin/route del default", fail_ok => 1;
262 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
263 0 die("Error running route del default");
264 }
265 }
266  
267 0 i_run "/sbin/route add default gw $new_default_gw", fail_ok => 1;
268 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
269 0 die("Error route add default");
270 }
271  
272 }
273 else {
274 0 my @route = route();
275  
276 my ($default_route) = grep {
277 0 $_->{"flags"} =~ m/UG/
278 && ( $_->{"destination"} eq "0.0.0.0"
279 0 ▶ || $_->{"destination"} eq "default" )
Condition0%0/6
$_->{'flags'} =~ /UG/u && ($_->{'destination'} eq '0.0.0.0' || $_->{'destination'} eq 'default')
!ll&&!rl&&r
000
$_->{"destination"} eq "0.0.0.0" or $_->{"destination"} eq "default"
l!l&&r!l&&!r
000
MC/DC0%0/3
$_->{'flags'} =~ /UG/u && ($_->{'destination'} eq '0.0.0.0' || $_->{'destination'} eq 'default')
$_->{'flags'} =~ /UG/u $_->{"destination"} eq "0.0.0.0" $_->{"destination"} eq "default"
Truth table0%0/4
A && B or C
A= $_->{'flags'} =~ /UG/uB= $_->{"destination"} eq "0.0.0.0"C= $_->{"destination"} eq "default"
ABCresult
0XX0
1000
11X1
1011
280 } @route;
281 0 ▶ return $default_route->{"gateway"} if $default_route;
Branch: 1 branch
BranchTrueFalseTotal
if $default_route 0 0 0
282 }
283 }
284  
285 0 ▶sub netstat {
Subroutine netstat: not called CC=19 SCAR=59.4
Pod undocumented
286  
287 0 my @ret;
288 0 my @netstat = i_run "netstat -nap", fail_ok => 1;
289 0 ▶ if ( $? != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? != 0) 0 0 0
290 0 die("Error running netstat");
291 }
292 0 my ( $in_inet, $in_unix, $in_unknown ) = ( 0, 0, 0 );
293 0 for my $line (@netstat) {
294 0 ▶ if ( $in_inet == 1 ) { ++$in_inet; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($in_inet == 1) 0 0 0
295 0 ▶ if ( $in_unix == 1 ) { ++$in_unix; next; }
Branch: 1 branch
BranchTrueFalseTotal
if ($in_unix == 1) 0 0 0
296 0 ▶ if ( $line =~ m/^Active Internet/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Active Internet/u) 0 0 0
297 0 $in_inet = 1;
298 0 $in_unix = 0;
299 0 $in_unknown = 0;
300 0 next;
301 }
302  
303 0 ▶ if ( $line =~ m/^Active UNIX/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Active UNIX/u) 0 0 0
304 0 $in_inet = 0;
305 0 $in_unix = 1;
306 0 $in_unknown = 0;
307 0 next;
308 }
309  
310 0 ▶ if ( $line =~ m/^Active/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^Active/u) 0 0 0
311 0 $in_inet = 0;
312 0 $in_unix = 0;
313 0 $in_unknown = 1;
314 0 next;
315 }
316  
317 0 ▶ if ($in_unknown) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_unknown) 0 0 0
318 0 next;
319 }
320  
321 0 ▶ if ($in_inet) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_inet) 0 0 0
322 0 my ( $proto, $recvq, $sendq, $local_addr, $foreign_addr, $state,
323 $pid_cmd );
324  
325 0 ▶ unless ( $line =~ m/^udp/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^udp/u) { } 0 0 0
326  
327 # no state
328 0 ( $proto, $recvq, $sendq, $local_addr, $foreign_addr, $state, $pid_cmd )
329 = split( /\s+/, $line, 7 );
330 }
331 else {
332 0 ( $proto, $recvq, $sendq, $local_addr, $foreign_addr, $pid_cmd ) =
333 split( /\s+/, $line, 6 );
334 }
335  
336 0 ▶ $pid_cmd ||= "";
Condition0%0/2
$pid_cmd ||= ""
l!l
00
MC/DC0%0/1
$pid_cmd ||= ""
$pid_cmd
Truth table0%0/2
A
A= $pid_cmd
Aresult
11
00
337  
338 0 my ( $pid, $cmd ) = split( /\//, $pid_cmd, 2 );
339 0 ▶ if ( $pid =~ m/^-/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pid =~ /^-/u) 0 0 0
340 0 $pid = "";
341 }
342 0 ▶ $cmd ||= "";
Condition0%0/2
$cmd ||= ""
l!l
00
MC/DC0%0/1
$cmd ||= ""
$cmd
Truth table0%0/2
A
A= $cmd
Aresult
11
00
343 0 ▶ $state ||= "";
Condition0%0/2
$state ||= ""
l!l
00
MC/DC0%0/1
$state ||= ""
$state
Truth table0%0/2
A
A= $state
Aresult
11
00
344  
345 0 $cmd =~ s/\s+$//;
346  
347 0 push(
348 @ret,
349 {
350 proto => $proto,
351 recvq => $recvq,
352 sendq => $sendq,
353 local_addr => $local_addr,
354 foreign_addr => $foreign_addr,
355 state => $state,
356 pid => $pid,
357 command => $cmd,
358 }
359 );
360 0 next;
361 }
362  
363 0 ▶ if ($in_unix) {
Branch: 1 branch
BranchTrueFalseTotal
if ($in_unix) 0 0 0
364  
365 0 my ( $proto, $refcnt, $flags, $type, $state, $inode, $pid, $cmd, $path );
366  
367 0 ▶ if ( $line =~
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ m(^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+(\d+)/([^\s]+)\s+(.*)$)iu) { } 0 0 0
368 m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+(\d+)\/([^\s]+)\s+(.*)$/i
369 )
370 {
371 0 ( $proto, $refcnt, $flags, $type, $state, $inode, $pid, $cmd, $path ) =
372 ( $line =~
373 m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+(\d+)\/([^\s]+)\s+(.*)$/i
374 );
375 }
376 else {
377 0 ( $proto, $refcnt, $flags, $type, $state, $inode, $path ) =
378 ( $line =~
379 m/^([a-z]+)\s+(\d+)\s+\[([^\]]+)\]\s+([a-z]+)\s+([a-z]+)?\s+(\d+)\s+\-\s+(.*)$/i
380 );
381  
382 0 $pid = "";
383 0 $cmd = "";
384 }
385  
386 0 ▶ $state =~ s/^\s|\s$//g if ($state);
Branch: 1 branch
BranchTrueFalseTotal
if $state 0 0 0
387 0 ▶ $flags =~ s/\s+$// if ($flags);
Branch: 1 branch
BranchTrueFalseTotal
if $flags 0 0 0
388 0 $cmd =~ s/\s+$//;
389  
390 0 my $data = {
391 proto => $proto,
392 refcnt => $refcnt,
393 flags => $flags,
394 type => $type,
395 state => $state,
396 inode => $inode,
397 pid => $pid,
398 command => $cmd,
399 path => $path,
400 };
401  
402 0 push( @ret, $data );
403 }
404  
405 }
406  
407 0 return @ret;
408  
409 }
410  
411 10 ▶sub _convert_cidr_prefix {
Subroutine _convert_cidr_prefix: called CC=1 SCAR=0.0
412 10 my ($cidr_prefix) = @_;
413  
414 # convert CIDR prefix to dotted decimal notation
415 10 my $binary_mask = '1' x $cidr_prefix . '0' x ( 32 - $cidr_prefix );
416 10 my $dotted_decimal_mask = join '.', unpack 'C4', pack 'B32', $binary_mask;
417  
418 10 return $dotted_decimal_mask;
419 }
420  
421 6 1;
« lib/Rex/Commands/Run.pm ↑ Summary lib/Rex/Commands/Kernel.pm »