line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Interface; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005; |
4
|
2
|
|
|
2
|
|
31125
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
85
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
148
|
|
6
|
2
|
|
|
2
|
|
12
|
use vars qw(@EXPORT @EXPORT_OK @ISA %EXPORT_TAGS $VERSION $AUTOLOAD); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
209
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
18
|
use IO::Socket; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
13
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
require DynaLoader; |
12
|
2
|
|
|
2
|
|
2736
|
use AutoLoader; |
|
2
|
|
|
|
|
3981
|
|
|
2
|
|
|
|
|
12
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
%EXPORT_TAGS = ( 'all' => [@functions,@flags], |
22
|
|
|
|
|
|
|
'functions' => \@functions, |
23
|
|
|
|
|
|
|
'flags' => \@flags, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
@EXPORT = qw( ); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
@ISA = qw(Exporter DynaLoader); |
31
|
|
|
|
|
|
|
$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
|
|
|
4
|
|
80
|
my $constname; |
39
|
4
|
|
|
|
|
29
|
($constname = $AUTOLOAD) =~ s/.*:://; |
40
|
4
|
50
|
|
|
|
13
|
croak "&constant not defined" if $constname eq 'constant'; |
41
|
4
|
50
|
|
|
|
32
|
my $val = constant($constname, @_ ? $_[0] : 0); |
42
|
4
|
50
|
|
|
|
18
|
if ($! != 0) { |
43
|
0
|
0
|
0
|
|
|
0
|
if ($! =~ /Invalid/ || $!{EINVAL}) { |
44
|
0
|
|
|
|
|
0
|
$AutoLoader::AUTOLOAD = $AUTOLOAD; |
45
|
0
|
|
|
|
|
0
|
goto &AutoLoader::AUTOLOAD; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
else { |
48
|
0
|
|
|
|
|
0
|
croak "Your vendor has not defined IO::Interface macro $constname"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
{ |
52
|
2
|
|
|
2
|
|
562
|
no strict 'refs'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
255
|
|
|
4
|
|
|
|
|
6
|
|
53
|
4
|
|
|
9
|
|
33
|
*$AUTOLOAD = sub { $val }; # *$AUTOLOAD = sub() { $val }; |
|
9
|
|
|
|
|
36
|
|
54
|
|
|
|
|
|
|
} |
55
|
4
|
|
|
|
|
16
|
goto &$AUTOLOAD; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
bootstrap IO::Interface $VERSION; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# copy routines into IO::Socket |
61
|
|
|
|
|
|
|
{ |
62
|
2
|
|
|
2
|
|
13
|
no strict 'refs'; |
|
2
|
|
|
|
|
16
|
|
|
2
|
|
|
|
|
1053
|
|
63
|
|
|
|
|
|
|
*{"IO\:\:Socket\:\:$_"} = \&$_ foreach @functions; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Preloaded methods go here. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub if_list { |
69
|
4
|
|
|
4
|
1
|
759
|
my %hash = map {$_=>undef} &_if_list; |
|
24
|
|
|
|
|
54
|
|
70
|
4
|
|
|
|
|
35
|
sort keys %hash; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub addr_to_interface { |
74
|
2
|
|
|
2
|
1
|
3
|
my ($sock,$addr) = @_; |
75
|
2
|
50
|
|
|
|
8
|
return "any" if $addr eq '0.0.0.0'; |
76
|
2
|
|
|
|
|
8
|
my @interfaces = $sock->if_list; |
77
|
2
|
|
|
|
|
5
|
foreach (@interfaces) { |
78
|
4
|
50
|
|
|
|
40
|
my $if_addr = $sock->if_addr($_) or next; |
79
|
4
|
100
|
|
|
|
12
|
return $_ if $if_addr eq $addr; |
80
|
|
|
|
|
|
|
} |
81
|
1
|
|
|
|
|
7
|
return; # couldn't find it |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
85
|
|
|
|
|
|
|
1; |
86
|
|
|
|
|
|
|
__END__ |