Skip to content

Commit ae8828b

Browse files
Improve Brother SNMP printer inventory
1 parent 9012a71 commit ae8828b

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

lib/GLPI/Agent/SNMP/MibSupport/BrotherNetConfig.pm

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ use constant printerinfomation => net_peripheral . '.4.2.1.5.5' ;
1919
use constant brInfoSerialNumber => printerinfomation . '.1.0' ;
2020
use constant brScanCountCounter => printerinfomation . '.54.2.2.1.3.3';
2121

22+
use constant brpsWLanName => brother . '.2.4.3.100.11.1.3';
23+
2224
# Brother NetConfig
2325
use constant brnetconfig => brother . '.2.4.3.1240' ;
2426
use constant brconfig => brnetconfig . '.1' ;
@@ -77,6 +79,40 @@ sub getModel {
7779
return $model;
7880
}
7981

82+
sub getWlanPorts {
83+
my ($self) = @_;
84+
85+
my $device = $self->device
86+
or return;
87+
88+
# Get list of device ports
89+
my %ports = %{$device->{PORTS}->{PORT}}; # Shallow copy
90+
foreach my $key (keys %ports) {
91+
$ports{$key} = {%{$ports{$key}}}; # Deep copy for one level deep hash
92+
}
93+
94+
foreach my $port (keys %ports) {
95+
# Loopback or DOWN interfaces
96+
if ($ports{$port}->{IFTYPE} == 24 || $ports{$port}->{IFTYPE} == 2) {
97+
delete $ports{$port};
98+
}
99+
}
100+
101+
# Only one interface remaining and actually connected to a WLAN network
102+
my $brpsWLanName = $self->walk(brpsWLanName);
103+
if (scalar(keys %ports) == 1 && $brpsWLanName) {
104+
foreach my $port (keys %ports) {
105+
# Replaces the port ifType from "Ethernet" to "WiFi" (71)
106+
if ($ports{$port}->{IFTYPE} == 6 || $ports{$port}->{IFTYPE} == 7) {
107+
# WLAN network name strlen is greather than zero
108+
if (length((keys %{$brpsWLanName})[0]) gt 0) {
109+
$device->{PORTS}->{PORT}->{$port}->{IFTYPE} = 71;
110+
}
111+
};
112+
}
113+
}
114+
}
115+
80116
sub run {
81117
my ($self) = @_;
82118

@@ -92,6 +128,8 @@ sub run {
92128
or next;
93129
$device->{PAGECOUNTERS}->{$counter} = $count;
94130
}
131+
132+
$self->getWlanPorts();
95133
}
96134

97135
1;

0 commit comments

Comments
 (0)