Skip to content

Commit ba16c12

Browse files
Improve Brother SNMP printer inventory (ifType) (#836)
* Improve Brother SNMP printer inventory to report wifi port as wireless port Co-authored-by: Guillaume Bougard <[email protected]>
1 parent 9012a71 commit ba16c12

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

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

+37
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ 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 brMultiIFConfigureEntry => brother . '.2.4.4.1240.1.5.1';
23+
use constant brMultiIFType => brMultiIFConfigureEntry . '.2';
24+
use constant brMultiIFNodeType => brMultiIFConfigureEntry . '.8';
25+
2226
# Brother NetConfig
2327
use constant brnetconfig => brother . '.2.4.3.1240' ;
2428
use constant brconfig => brnetconfig . '.1' ;
@@ -77,6 +81,37 @@ sub getModel {
7781
return $model;
7882
}
7983

84+
sub updatePortIfType {
85+
my ($self) = @_;
86+
87+
my $device = $self->device
88+
or return;
89+
90+
# Get list of device ports
91+
my $ports = $device->{PORTS}->{PORT};
92+
93+
# Get list of device ports types (lan(1)/wirelesslan(2))
94+
my $brMultiIFType = $self->walk(brMultiIFType)
95+
or return;
96+
97+
# Get list of device ports names
98+
my $brMultiIFNodeType = $self->walk(brMultiIFNodeType)
99+
or return;
100+
101+
foreach my $index (keys %{$brMultiIFType}) {
102+
foreach my $port (keys %{$ports}) {
103+
next unless defined($ports->{$port}->{IFNAME}) && defined($brMultiIFNodeType->{$index});
104+
if ($ports->{$port}->{IFNAME} eq getCanonicalString($brMultiIFNodeType->{$index})) {
105+
# wirelesslan(2)
106+
if (defined($brMultiIFType->{$index}) && isInteger($brMultiIFType->{$index}) && int($brMultiIFType->{$index}) == 2) {
107+
# ieee80211(71)
108+
$ports->{$port}->{IFTYPE} = 71
109+
}
110+
}
111+
}
112+
}
113+
}
114+
80115
sub run {
81116
my ($self) = @_;
82117

@@ -92,6 +127,8 @@ sub run {
92127
or next;
93128
$device->{PAGECOUNTERS}->{$counter} = $count;
94129
}
130+
131+
$self->updatePortIfType();
95132
}
96133

97134
1;

0 commit comments

Comments
 (0)