line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
package Net::Link; |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
35995
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
47
|
|
5
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
2340
|
use Net::Interface; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Carp; |
9
|
|
|
|
|
|
|
use IO::File; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = qw( Net::Interface ); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
croak(__PACKAGE__ . " requires Linux") if $^O ne 'linux'; |
16
|
|
|
|
|
|
|
croak(__PACKAGE__ . " requires /sys/") unless -d '/sys/'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub up { |
19
|
|
|
|
|
|
|
my ($self) = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $carrier = '/sys/class/net/' . $self->name . '/carrier'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $io = new IO::File($carrier); |
24
|
|
|
|
|
|
|
if($io) { |
25
|
|
|
|
|
|
|
my $line = $io->getline; |
26
|
|
|
|
|
|
|
return ($line and $line =~ /^1/); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub down { return ! $_[0]->up } |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
!0; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
__END__ |