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