line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package FusionInventory::Agent::Task::Inventory::Win32::Networks; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
62014235
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
120
|
|
4
|
2
|
|
|
2
|
|
15
|
use warnings; |
|
2
|
|
|
|
|
14
|
|
|
2
|
|
|
|
|
144
|
|
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1066
|
use FusionInventory::Agent::Tools; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
488
|
|
7
|
2
|
|
|
2
|
|
1430
|
use FusionInventory::Agent::Tools::Network; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
476
|
|
8
|
2
|
|
|
2
|
|
1406
|
use FusionInventory::Agent::Tools::Win32; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
995
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub isEnabled { |
11
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
12
|
0
|
0
|
|
|
|
0
|
return 0 if $params{no_category}->{network}; |
13
|
0
|
|
|
|
|
0
|
return 1; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub doInventory { |
17
|
0
|
|
|
0
|
0
|
0
|
my (%params) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
0
|
my $inventory = $params{inventory}; |
20
|
0
|
|
|
|
|
0
|
my (@gateways, @dns, @ips); |
21
|
|
|
|
|
|
|
|
22
|
0
|
|
|
|
|
0
|
foreach my $interface (getInterfaces()) { |
23
|
|
|
|
|
|
|
push @gateways, $interface->{IPGATEWAY} |
24
|
0
|
0
|
|
|
|
0
|
if $interface->{IPGATEWAY}; |
25
|
|
|
|
|
|
|
push @dns, $interface->{dns} |
26
|
0
|
0
|
|
|
|
0
|
if $interface->{dns}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
push @ips, $interface->{IPADDRESS} |
29
|
0
|
0
|
|
|
|
0
|
if $interface->{IPADDRESS}; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
delete $interface->{dns}; |
32
|
0
|
|
|
|
|
0
|
$interface->{TYPE} = _getMediaType($interface->{PNPDEVICEID}); |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
0
|
$inventory->addEntry( |
35
|
|
|
|
|
|
|
section => 'NETWORKS', |
36
|
|
|
|
|
|
|
entry => $interface |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$inventory->setHardware({ |
41
|
0
|
|
|
|
|
0
|
DEFAULTGATEWAY => join('/', uniq @gateways), |
42
|
|
|
|
|
|
|
DNS => join('/', uniq @dns), |
43
|
|
|
|
|
|
|
IPADDR => join('/', uniq @ips), |
44
|
|
|
|
|
|
|
}); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _getMediaType { |
49
|
6
|
|
|
6
|
|
3249
|
my ($deviceId, $logger) = @_; |
50
|
|
|
|
|
|
|
|
51
|
6
|
50
|
|
|
|
16
|
return unless defined $deviceId; |
52
|
|
|
|
|
|
|
|
53
|
6
|
|
|
|
|
19
|
my $key = getRegistryKey( |
54
|
|
|
|
|
|
|
path => "HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Network/{4D36E972-E325-11CE-BFC1-08002BE10318}", |
55
|
|
|
|
|
|
|
logger => $logger |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
|
58
|
6
|
|
|
|
|
8077
|
foreach my $subkey_name (keys %$key) { |
59
|
|
|
|
|
|
|
# skip variables |
60
|
24
|
100
|
|
|
|
68
|
next if $subkey_name =~ m{^/}; |
61
|
18
|
|
|
|
|
38
|
my $subkey = $key->{$subkey_name}; |
62
|
|
|
|
|
|
|
next unless |
63
|
|
|
|
|
|
|
$subkey->{'Connection/'} && |
64
|
|
|
|
|
|
|
$subkey->{'Connection/'}->{'/PnpInstanceID'} && |
65
|
18
|
100
|
66
|
|
|
116
|
$subkey->{'Connection/'}->{'/PnpInstanceID'} eq $deviceId; |
|
|
|
66
|
|
|
|
|
66
|
1
|
|
|
|
|
3
|
my $subtype = $subkey->{'Connection/'}->{'/MediaSubType'}; |
67
|
|
|
|
|
|
|
return |
68
|
1
|
0
|
|
|
|
16
|
!defined $subtype ? 'ethernet' : |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$subtype eq '0x00000001' ? 'ethernet' : |
70
|
|
|
|
|
|
|
$subtype eq '0x00000002' ? 'wifi' : |
71
|
|
|
|
|
|
|
undef; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
## no critic (ExplicitReturnUndef) |
75
|
5
|
|
|
|
|
55
|
return undef; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |