| 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
| |||||||||||||||||||||||||||||
| 41 | 4 | ▶ | my $val = constant($constname, @_ ? $_[0] : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 4 | ▶ | if ($! != 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($! =~ /Invalid/ || $!{EINVAL}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$! =~ /Invalid/ or $!{"EINVAL"}
MC/DC0%0/2
$! =~ /Invalid/ or $!{"EINVAL"}
$! =~ /Invalid/
$!{"EINVAL"}
Truth table0%0/3
A or B
A= $! =~ /Invalid/B= $!{"EINVAL"}
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 76 | 2 | my @interfaces = $sock->if_list; | |||||||||||||||||||||||||||
| 77 | 2 | foreach (@interfaces) { | |||||||||||||||||||||||||||
| 78 | 4 | ▶ | my $if_addr = $sock->if_addr($_) or next; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 79 | 4 | ▶ | return $_ if $if_addr eq $addr; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||