Skip to content

Commit 9c78bb2

Browse files
Update BrotherNetConfig.pm
1 parent ae8828b commit 9c78bb2

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

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

+22-26
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ 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';
22+
use constant brMultiIFConfigureEntry => brother . '.2.4.4.1240.1.5.1';
23+
use constant brMultiIFType => brMultiIFConfigureEntry . '.2';
24+
use constant brMultiIFNodeType => brMultiIFConfigureEntry . '.8';
2325

2426
# Brother NetConfig
2527
use constant brnetconfig => brother . '.2.4.3.1240' ;
@@ -79,36 +81,30 @@ sub getModel {
7981
return $model;
8082
}
8183

82-
sub getWlanPorts {
84+
sub getPortIfType {
8385
my ($self) = @_;
8486

8587
my $device = $self->device
8688
or return;
8789

8890
# 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;
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+
96+
# Get list of device ports names
97+
my $brMultiIFNodeType = $self->walk(brMultiIFNodeType) || {};
98+
99+
foreach my $index (keys %{$brMultiIFType}) {
100+
foreach my $port (keys %{$ports}) {
101+
if ($ports->{$port}->{IFDESCR} eq $brMultiIFNodeType->{$index}) {
102+
# wirelesslan(2)
103+
if (defined($brMultiIFType->{$index}) && $brMultiIFType->{$index} eq 2) {
104+
# ieee80211(71)
105+
$ports->{$port}->{IFTYPE} = 71
110106
}
111-
};
107+
}
112108
}
113109
}
114110
}
@@ -128,8 +124,8 @@ sub run {
128124
or next;
129125
$device->{PAGECOUNTERS}->{$counter} = $count;
130126
}
131-
132-
$self->getWlanPorts();
127+
128+
$self->getPortIfType();
133129
}
134130

135131
1;

0 commit comments

Comments
 (0)