line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::BSD::Networks; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
89652093
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
56
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
487
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
128
|
|
7
|
1
|
|
|
1
|
|
350
|
use FusionInventory::Agent::Tools::Network; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
141
|
|
8
|
1
|
|
|
1
|
|
394
|
use FusionInventory::Agent::Tools::Unix; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
59
|
|
9
|
1
|
|
|
1
|
|
334
|
use FusionInventory::Agent::Tools::BSD; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
317
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub isEnabled { |
12
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
13
|
0
|
0
|
|
|
|
|
return 0 if $params{no_category}->{network}; |
14
|
0
|
|
|
|
|
|
return canRun('ifconfig'); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub doInventory { |
18
|
0
|
|
|
0
|
0
|
|
my (%params) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $inventory = $params{inventory}; |
21
|
0
|
|
|
|
|
|
my $logger = $params{logger}; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
my $routes = getRoutingTable(logger => $logger); |
24
|
0
|
|
|
|
|
|
my $default = $routes->{'0.0.0.0'}; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my @interfaces = _getInterfaces(logger => $logger); |
27
|
0
|
|
|
|
|
|
foreach my $interface (@interfaces) { |
28
|
|
|
|
|
|
|
# if the default gateway address and the interface address belongs to |
29
|
|
|
|
|
|
|
# the same network, that's the gateway for this network |
30
|
|
|
|
|
|
|
$interface->{IPGATEWAY} = $default if isSameNetwork( |
31
|
|
|
|
|
|
|
$default, $interface->{IPADDRESS}, $interface->{IPMASK} |
32
|
0
|
0
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$inventory->addEntry( |
35
|
|
|
|
|
|
|
section => 'NETWORKS', |
36
|
|
|
|
|
|
|
entry => $interface |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$inventory->setHardware({ |
41
|
0
|
|
|
|
|
|
DEFAULTGATEWAY => $default |
42
|
|
|
|
|
|
|
}); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub _getInterfaces { |
46
|
0
|
|
|
0
|
|
|
my (%params) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my @interfaces = getInterfacesFromIfconfig( |
49
|
|
|
|
|
|
|
logger => $params{logger} |
50
|
0
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
foreach my $interface (@interfaces) { |
53
|
|
|
|
|
|
|
$interface->{IPSUBNET} = getSubnetAddress( |
54
|
|
|
|
|
|
|
$interface->{IPADDRESS}, |
55
|
|
|
|
|
|
|
$interface->{IPMASK} |
56
|
0
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
$interface->{IPDHCP} = getIpDhcp( |
59
|
|
|
|
|
|
|
$params{logger}, |
60
|
|
|
|
|
|
|
$interface->{DESCRIPTION} |
61
|
0
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ($interface->{DESCRIPTION} =~ m/^(lo|vboxnet|vmnet|vtnet|sit|tun|pflog|pfsync|enc|strip|plip|sl|ppp|faith)/) { |
64
|
0
|
|
|
|
|
|
$interface->{VIRTUALDEV} = 1; |
65
|
|
|
|
|
|
|
|
66
|
0
|
0
|
|
|
|
|
if ($interface->{DESCRIPTION} =~ m/^lo/) { |
67
|
0
|
|
|
|
|
|
$interface->{TYPE} = 'loopback'; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
0
|
0
|
|
|
|
|
if ($interface->{DESCRIPTION} =~ m/^ppp/) { |
71
|
0
|
|
|
|
|
|
$interface->{TYPE} = 'dialup'; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} else { |
74
|
0
|
|
|
|
|
|
$interface->{VIRTUALDEV} = 0; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
return @interfaces; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |