blib/lib/IO/Interface.pm

filter: Statementstmt 93.3% 56 / 60 Branchbran 50.0% 7 / 14 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 11 / 11 Podpod 100% 2 / 2 totaltotal 82.6% 76 / 92 CC 10 SCAR 15.0
CC
10
Cov
82%
AUTOLOAD
9.2
addr_to_interface
5.1
BEGIN
1.0
CRAP 4.5
↑ Summary blib/lib/IO/Interface/Simple.pm »
1 package IO::Interface;
2  
3 2 require 5.005;
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use vars qw(@EXPORT @EXPORT_OK @ISA %EXPORT_TAGS $VERSION $AUTOLOAD);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use IO::Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 require Exporter;
11 2 require DynaLoader;
12 2 ▶use AutoLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 my @functions = qw(if_addr if_broadcast if_netmask if_dstaddr if_hwaddr if_flags if_list if_mtu if_metric
15 addr_to_interface if_index if_indextoname );
16 2 my @flags = qw(IFF_ALLMULTI IFF_AUTOMEDIA IFF_BROADCAST
17 IFF_DEBUG IFF_LOOPBACK IFF_MASTER
18 IFF_MULTICAST IFF_NOARP IFF_NOTRAILERS
19 IFF_POINTOPOINT IFF_PORTSEL IFF_PROMISC
20 IFF_RUNNING IFF_SLAVE IFF_UP);
21 2 %EXPORT_TAGS = ( 'all' => [@functions,@flags],
22 'functions' => \@functions,
23 'flags' => \@flags,
24 );
25  
26 2 @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
27  
28 2 @EXPORT = qw( );
29  
30 2 @ISA = qw(Exporter DynaLoader);
31 2 $VERSION = '1.08';
32  
33 sub AUTOLOAD {
34 # This AUTOLOAD is used to 'autoload' constants from the constant()
35 # XS function. If a constant is not found then control is passed
36 # to the AUTOLOAD in AutoLoader.
37  
38 4 ▶ my $constname;
Subroutine AUTOLOAD: called CC=6 SCAR=22.1
39 4 ($constname = $AUTOLOAD) =~ s/.*:://;
40 4 ▶ croak "&constant not defined" if $constname eq 'constant';
Branch: 1 branch
BranchTrueFalseTotal
if $constname eq "constant" 0 4 4
41 4 ▶ my $val = constant($constname, @_ ? $_[0] : 0);
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 4 4
42 4 ▶ if ($! != 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($! != 0) 0 4 4
43 0 ▶ if ($! =~ /Invalid/ || $!{EINVAL}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($! =~ /Invalid/ or $!{'EINVAL'}) { } 0 0 0
Condition0%0/3
$! =~ /Invalid/ or $!{"EINVAL"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$! =~ /Invalid/ or $!{"EINVAL"}
$! =~ /Invalid/ $!{"EINVAL"}
Truth table0%0/3
A or B
A= $! =~ /Invalid/B= $!{"EINVAL"}
ABresult
1X1
011
000
44 0 $AutoLoader::AUTOLOAD = $AUTOLOAD;
45 0 goto &AutoLoader::AUTOLOAD;
46 }
47 else {
48 0 croak "Your vendor has not defined IO::Interface macro $constname";
49 }
50 }
51 {
52 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
53 4 ▶ *$AUTOLOAD = sub { $val }; # *$AUTOLOAD = sub() { $val };
Subroutine __ANON__: called CC=1 SCAR=0.0
54 }
55 4 goto &$AUTOLOAD;
56 }
57  
58 2 bootstrap IO::Interface $VERSION;
59  
60 # copy routines into IO::Socket
61 {
62 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
63 2 *{"IO\:\:Socket\:\:$_"} = \&$_ foreach @functions;
64 }
65  
66 # Preloaded methods go here.
67  
68 sub if_list {
69 4 ▶ my %hash = map {$_=>undef} &_if_list;
Subroutine if_list: called CC=1 SCAR=0.0
Pod documented
70 4 sort keys %hash;
71 }
72  
73 sub addr_to_interface {
74 2 ▶ my ($sock,$addr) = @_;
Subroutine addr_to_interface: called CC=5 SCAR=16.3
Pod documented
75 2 ▶ return "any" if $addr eq '0.0.0.0';
Branch: 1 branch
BranchTrueFalseTotal
if $addr eq "0.0.0.0" 0 2 2
76 2 my @interfaces = $sock->if_list;
77 2 foreach (@interfaces) {
78 4 ▶ my $if_addr = $sock->if_addr($_) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $if_addr = $sock->if_addr($_) or next 0 4 4
79 4 ▶ return $_ if $if_addr eq $addr;
Branch: 1 branch
BranchTrueFalseTotal
if $if_addr eq $addr 1 3 4
80 }
81 1 return; # couldn't find it
82 }
83  
84 # Autoload methods go after =cut, and are processed by the autosplit program.
85 2 1;
86 __END__
↑ Summary blib/lib/IO/Interface/Simple.pm »