line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package IO::Interface; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.005; |
4
|
2
|
|
|
2
|
|
32404
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
93
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
163
|
|
6
|
2
|
|
|
2
|
|
14
|
use vars qw(@EXPORT @EXPORT_OK @ISA %EXPORT_TAGS $VERSION $AUTOLOAD); |
|
2
|
|
|
|
|
9
|
|
|
2
|
|
|
|
|
241
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
15
|
use IO::Socket; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
19
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
require DynaLoader; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @functions = qw(if_addr if_broadcast if_netmask if_dstaddr if_hwaddr if_flags if_list if_mtu if_metric |
14
|
|
|
|
|
|
|
addr_to_interface if_index if_indextoname ); |
15
|
|
|
|
|
|
|
my @flags = qw(IFF_ALLMULTI IFF_AUTOMEDIA IFF_BROADCAST |
16
|
|
|
|
|
|
|
IFF_DEBUG IFF_LOOPBACK IFF_MASTER |
17
|
|
|
|
|
|
|
IFF_MULTICAST IFF_NOARP IFF_NOTRAILERS |
18
|
|
|
|
|
|
|
IFF_POINTOPOINT IFF_PORTSEL IFF_PROMISC |
19
|
|
|
|
|
|
|
IFF_RUNNING IFF_SLAVE IFF_UP); |
20
|
|
|
|
|
|
|
%EXPORT_TAGS = ( 'all' => [@functions,@flags], |
21
|
|
|
|
|
|
|
'functions' => \@functions, |
22
|
|
|
|
|
|
|
'flags' => \@flags, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
@EXPORT = qw( ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
@ISA = qw(Exporter DynaLoader); |
30
|
|
|
|
|
|
|
$VERSION = '1.09'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub AUTOLOAD { |
33
|
|
|
|
|
|
|
# This AUTOLOAD is used to 'autoload' constants from the constant() |
34
|
|
|
|
|
|
|
# XS function. If a constant is not found then control is passed |
35
|
|
|
|
|
|
|
# to the AUTOLOAD in AutoLoader. |
36
|
|
|
|
|
|
|
|
37
|
4
|
|
|
4
|
|
80
|
my $constname; |
38
|
4
|
|
|
|
|
32
|
($constname = $AUTOLOAD) =~ s/.*:://; |
39
|
4
|
50
|
|
|
|
15
|
croak "&constant not defined" if $constname eq 'constant'; |
40
|
4
|
50
|
|
|
|
36
|
my $val = constant($constname, @_ ? $_[0] : 0); |
41
|
4
|
50
|
|
|
|
16
|
if ($! != 0) { |
42
|
0
|
0
|
0
|
|
|
0
|
if ($! =~ /Invalid/ || $!{EINVAL}) { |
43
|
0
|
|
|
|
|
0
|
$AutoLoader::AUTOLOAD = $AUTOLOAD; |
44
|
0
|
|
|
|
|
0
|
goto &AutoLoader::AUTOLOAD; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
else { |
47
|
0
|
|
|
|
|
0
|
croak "Your vendor has not defined IO::Interface macro $constname"; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
{ |
51
|
2
|
|
|
2
|
|
1903
|
no strict 'refs'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
272
|
|
|
4
|
|
|
|
|
6
|
|
52
|
4
|
|
|
9
|
|
37
|
*$AUTOLOAD = sub { $val }; # *$AUTOLOAD = sub() { $val }; |
|
9
|
|
|
|
|
39
|
|
53
|
|
|
|
|
|
|
} |
54
|
4
|
|
|
|
|
16
|
goto &$AUTOLOAD; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
bootstrap IO::Interface $VERSION; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# copy routines into IO::Socket |
60
|
|
|
|
|
|
|
{ |
61
|
2
|
|
|
2
|
|
11
|
no strict 'refs'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
465
|
|
62
|
|
|
|
|
|
|
*{"IO\:\:Socket\:\:$_"} = \&$_ foreach @functions; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Preloaded methods go here. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub if_list { |
68
|
4
|
|
|
4
|
1
|
410
|
my %hash = map {$_=>undef} &_if_list; |
|
8
|
|
|
|
|
28
|
|
69
|
4
|
|
|
|
|
34
|
sort keys %hash; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub addr_to_interface { |
73
|
2
|
|
|
2
|
1
|
3
|
my ($sock,$addr) = @_; |
74
|
2
|
50
|
|
|
|
8
|
return "any" if $addr eq '0.0.0.0'; |
75
|
2
|
|
|
|
|
10
|
my @interfaces = $sock->if_list; |
76
|
2
|
|
|
|
|
6
|
foreach (@interfaces) { |
77
|
4
|
50
|
|
|
|
46
|
my $if_addr = $sock->if_addr($_) or next; |
78
|
4
|
100
|
|
|
|
11
|
return $_ if $if_addr eq $addr; |
79
|
|
|
|
|
|
|
} |
80
|
1
|
|
|
|
|
7
|
return; # couldn't find it |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
# Autoload methods go after =cut, and are processed by the autosplit program. |
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
__END__ |