line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::BSD::Networks; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
80406316
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
80
|
|
4
|
1
|
|
|
1
|
|
10
|
use warnings; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
74
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
460
|
use FusionInventory::Agent::Tools; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
137
|
|
7
|
1
|
|
|
1
|
|
396
|
use FusionInventory::Agent::Tools::Network; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
184
|
|
8
|
1
|
|
|
1
|
|
431
|
use FusionInventory::Agent::Tools::Unix; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
9
|
1
|
|
|
1
|
|
366
|
use FusionInventory::Agent::Tools::BSD; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
351
|
|
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
|
0
|
0
|
|
|
|
|
$interface->{IPGATEWAY} = $default if isSameNetwork( |
31
|
|
|
|
|
|
|
$default, $interface->{IPADDRESS}, $interface->{IPMASK} |
32
|
|
|
|
|
|
|
); |
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
|
0
|
|
|
|
|
|
my @interfaces = getInterfacesFromIfconfig( |
49
|
|
|
|
|
|
|
logger => $params{logger} |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
foreach my $interface (@interfaces) { |
53
|
0
|
|
|
|
|
|
$interface->{IPSUBNET} = getSubnetAddress( |
54
|
|
|
|
|
|
|
$interface->{IPADDRESS}, |
55
|
|
|
|
|
|
|
$interface->{IPMASK} |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
$interface->{IPDHCP} = getIpDhcp( |
59
|
|
|
|
|
|
|
$params{logger}, |
60
|
|
|
|
|
|
|
$interface->{DESCRIPTION} |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
|
|
|
|
if ($interface->{DESCRIPTION} =~ m/^(lo|vboxnet|vmnet|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; |