| 1 | # SNMP::Info::Layer2::LigoWave - SNMP interface to LigoWave DLB radios | ||
| 2 | # | ||
| 3 | # Copyright (c) 2026 by The Netdisco Developer Team. | ||
| 4 | # | ||
| 5 | # Redistribution and use in source and binary forms, with or without | ||
| 6 | # modification, are permitted provided that the following conditions are met: | ||
| 7 | # | ||
| 8 | # * Redistributions of source code must retain the above copyright notice, | ||
| 9 | # this list of conditions and the following disclaimer. | ||
| 10 | # * Redistributions in binary form must reproduce the above copyright | ||
| 11 | # notice, this list of conditions and the following disclaimer in the | ||
| 12 | # documentation and/or other materials provided with the distribution. | ||
| 13 | # * Neither the name of the University of California, Santa Cruz nor the | ||
| 14 | # names of its contributors may be used to endorse or promote products | ||
| 15 | # derived from this software without specific prior written permission. | ||
| 16 | # | ||
| 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 18 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 19 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 20 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
| 21 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 22 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 23 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 24 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 25 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 26 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 27 | # POSSIBILITY OF SUCH DAMAGE. | ||
| 28 | |||
| 29 | package SNMP::Info::Layer2::LigoWave; | ||
| 30 | |||
| 31 | use strict; | ||
| 32 | use warnings; | ||
| 33 | use Exporter; | ||
| 34 | use SNMP::Info::IEEE802dot11; | ||
| 35 | use SNMP::Info::Layer2; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer2::LigoWave::ISA | ||
| 38 | = qw/SNMP::Info::IEEE802dot11 SNMP::Info::Layer2 Exporter/; | ||
| 39 | @SNMP::Info::Layer2::LigoWave::EXPORT_OK = qw//; | ||
| 40 | |||
| 41 | our ($VERSION, %FUNCS, %GLOBALS, %MIBS, %MUNGE); | ||
| 42 | |||
| 43 | $VERSION = '3.985003'; | ||
| 44 | |||
| 45 | %MIBS = ( | ||
| 46 | %SNMP::Info::Layer2::MIBS, | ||
| 47 | %SNMP::Info::IEEE802dot11::MIBS, | ||
| 48 | ); | ||
| 49 | |||
| 50 | %GLOBALS = ( | ||
| 51 | %SNMP::Info::Layer2::GLOBALS, | ||
| 52 | %SNMP::Info::IEEE802dot11::GLOBALS, | ||
| 53 | # LIGO-GENERIC-MIB subtree, beyond the published objects | ||
| 54 | 'ligo_unit_id' => '.1.3.6.1.4.1.32750.3.1.1.1.0.1.2.0', | ||
| 55 | ); | ||
| 56 | |||
| 57 | %FUNCS = ( | ||
| 58 | %SNMP::Info::Layer2::FUNCS, | ||
| 59 | %SNMP::Info::IEEE802dot11::FUNCS, | ||
| 60 | # LIGO-WIRELESS-MIB, read by numeric OID until netdisco-mibs#310 is | ||
| 61 | # released. ligoWiIfConfTable columns 1 to 16, in MIB order, from | ||
| 62 | # ligoWiIfMacAddress to ligoWiIfAssocNodeCount: | ||
| 63 | 'ligo_wifi_mac' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.1', | ||
| 64 | 'ligo_wifi_protocol' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.2', | ||
| 65 | 'ligo_wifi_mode' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.3', | ||
| 66 | 'ligo_wifi_essid' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.4', | ||
| 67 | 'ligo_wifi_country' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.5', | ||
| 68 | 'ligo_wifi_frequency' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.6', | ||
| 69 | 'ligo_wifi_channel' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.7', | ||
| 70 | 'ligo_wifi_width' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.8', | ||
| 71 | 'ligo_wifi_encryption' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.9', | ||
| 72 | 'ligo_wifi_tx_power' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.10', | ||
| 73 | 'ligo_wifi_bitrate' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.11', | ||
| 74 | 'ligo_wifi_snr' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.12', | ||
| 75 | 'ligo_wifi_max_snr' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.13', | ||
| 76 | 'ligo_wifi_signal' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.14', | ||
| 77 | 'ligo_wifi_noise' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.15', | ||
| 78 | 'ligo_wifi_assoc_count' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.16', | ||
| 79 | # Column 17 is served beyond the published table. | ||
| 80 | 'ligo_wifi_state' => '.1.3.6.1.4.1.32750.3.10.1.2.1.1.17', | ||
| 81 | # ligoWiRemoteNodeStatsTable, ligoWiRmtNode*; the agent also serves | ||
| 82 | # columns 7 to 11, beyond the published table. | ||
| 83 | 'ligo_peer_mac' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.1', | ||
| 84 | 'ligo_peer_associated' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.2', | ||
| 85 | 'ligo_peer_tx_bytes' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.3', | ||
| 86 | 'ligo_peer_rx_bytes' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.4', | ||
| 87 | 'ligo_peer_signal' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.5', | ||
| 88 | 'ligo_peer_noise' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.6', | ||
| 89 | 'ligo_peer_ip' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.7', | ||
| 90 | 'ligo_peer_remote_port' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.8', | ||
| 91 | 'ligo_peer_name' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.9', | ||
| 92 | 'ligo_peer_rx_rate' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.10', | ||
| 93 | 'ligo_peer_tx_rate' => '.1.3.6.1.4.1.32750.3.10.1.3.2.1.11', | ||
| 94 | ); | ||
| 95 | |||
| 96 | %MUNGE = ( | ||
| 97 | %SNMP::Info::Layer2::MUNGE, | ||
| 98 | %SNMP::Info::IEEE802dot11::MUNGE, | ||
| 99 | 'ligo_wifi_mac' => \&SNMP::Info::munge_mac, | ||
| 100 | 'ligo_peer_mac' => \&SNMP::Info::munge_mac, | ||
| 101 | ); | ||
| 102 | |||
| 103 | sub vendor { return 'ligowave'; } | ||
| 104 | |||
| 105 | sub model { | ||
| 106 | my $self = shift; | ||
| 107 | my $desc = $self->description() || ''; | ||
| 108 | return $self->SUPER::model() unless $desc =~ /^(LigoDLB\s+.+)$/i; | ||
| 109 | my $model = $1; | ||
| 110 | $model =~ s/\s+v\d+(?:\.\d+)*\s*$//i; | ||
| 111 | return $model; | ||
| 112 | } | ||
| 113 | |||
| 114 | sub os { return 'ligowave os'; } | ||
| 115 | |||
| 116 | sub os_ver { | ||
| 117 | my $self = shift; | ||
| 118 | my $desc = $self->description() || ''; | ||
| 119 | return $1 if $desc =~ /\bv([\d]+(?:\.[\d]+)*)\b/i; | ||
| 120 | return $self->SUPER::os_ver(); | ||
| 121 | } | ||
| 122 | |||
| 123 | # ligoWiIfConfTable says INDEX { ifIndex }, but the agent numbers its rows | ||
| 124 | # otherwise (7 and 10 on captures where ath0 is ifIndex 410). Join each row | ||
| 125 | # to the athN interface that has the row's MAC address. | ||
| 126 | sub _ligo_wifi_ifindex { | ||
| 127 | my $self = shift; | ||
| 128 | my $wifi_mac = $self->ligo_wifi_mac() || {}; | ||
| 129 | my $names = $self->interfaces() || {}; | ||
| 130 | my $macs = $self->i_mac() || {}; | ||
| 131 | |||
| 132 | my @radios = grep { ( $names->{$_} || '' ) =~ /^ath\d+$/ } keys %$names; | ||
| 133 | my %ifindex; | ||
| 134 | foreach my $row ( keys %$wifi_mac ) { | ||
| 135 | my $mac = lc( $wifi_mac->{$row} || '' ); | ||
| 136 | my @match = grep { lc( $macs->{$_} || '' ) eq $mac } @radios; | ||
| 137 | $ifindex{$row} = $match[0] if $mac and @match == 1; | ||
| 138 | } | ||
| 139 | return \%ifindex; | ||
| 140 | } | ||
| 141 | |||
| 142 | sub _ligo_by_ifindex { | ||
| 143 | my ( $self, $column, $partial ) = @_; | ||
| 144 | my $values = $self->$column() || {}; | ||
| 145 | my $ifindex = $self->_ligo_wifi_ifindex(); | ||
| 146 | my %by_ifindex; | ||
| 147 | foreach my $row ( keys %$ifindex ) { | ||
| 148 | next if defined $partial and $ifindex->{$row} ne $partial; | ||
| 149 | next unless defined $values->{$row}; | ||
| 150 | $by_ifindex{ $ifindex->{$row} } = $values->{$row}; | ||
| 151 | } | ||
| 152 | return \%by_ifindex; | ||
| 153 | } | ||
| 154 | |||
| 155 | sub i_ssidlist { | ||
| 156 | my ( $self, $partial ) = @_; | ||
| 157 | return $self->_ligo_by_ifindex( 'ligo_wifi_essid', $partial ); | ||
| 158 | } | ||
| 159 | |||
| 160 | sub i_ssidmac { | ||
| 161 | my ( $self, $partial ) = @_; | ||
| 162 | return $self->_ligo_by_ifindex( 'ligo_wifi_mac', $partial ); | ||
| 163 | } | ||
| 164 | |||
| 165 | # The inherited IEEE802dot11 channel method needs dot11PHYType, which this | ||
| 166 | # firmware does not serve. | ||
| 167 | sub i_80211channel { | ||
| 168 | my ( $self, $partial ) = @_; | ||
| 169 | return $self->_ligo_by_ifindex( 'ligo_wifi_channel', $partial ); | ||
| 170 | } | ||
| 171 | |||
| 172 | sub _vlan_interfaces { | ||
| 173 | my $self = shift; | ||
| 174 | my $names = $self->i_name() || {}; | ||
| 175 | my $descr = $self->i_description() || {}; | ||
| 176 | my %interfaces; | ||
| 177 | |||
| 178 | foreach my $ifindex ( keys %$names, keys %$descr ) { | ||
| 179 | my $name = $names->{$ifindex} || $descr->{$ifindex} || ''; | ||
| 180 | my $vlan; | ||
| 181 | $vlan = $1 if $name =~ /^(?:eth\d+|ath\d+)\.(\d{1,4})$/i; | ||
| 182 | $vlan = $1 if !defined($vlan) && $name =~ /^br(\d{1,4})$/i; | ||
| 183 | next unless defined $vlan && $vlan >= 1 && $vlan <= 4094; | ||
| 184 | $interfaces{$ifindex} = 0 + $vlan; | ||
| 185 | } | ||
| 186 | |||
| 187 | return \%interfaces; | ||
| 188 | } | ||
| 189 | |||
| 190 | # VLANs are represented as logical interfaces by this firmware (for example, | ||
| 191 | # br99 and eth0.99). They are not switch-port memberships or PVIDs. | ||
| 192 | sub v_name { | ||
| 193 | my $self = shift; | ||
| 194 | my $interfaces = $self->_vlan_interfaces(); | ||
| 195 | my %vlans = map { | ||
| 196 | $interfaces->{$_} => 'VLAN ' . $interfaces->{$_} | ||
| 197 | } keys %$interfaces; | ||
| 198 | return \%vlans; | ||
| 199 | } | ||
| 200 | |||
| 201 | sub v_index { | ||
| 202 | my $self = shift; | ||
| 203 | my $names = $self->v_name() || {}; | ||
| 204 | return { map { $_ => $_ } keys %$names }; | ||
| 205 | } | ||
| 206 | |||
| 207 | sub i_vlan_membership { | ||
| 208 | my $self = shift; | ||
| 209 | my $partial = shift; | ||
| 210 | my $interfaces = $self->_vlan_interfaces(); | ||
| 211 | my %membership; | ||
| 212 | foreach my $ifindex ( keys %$interfaces ) { | ||
| 213 | next if defined($partial) && $ifindex ne $partial; | ||
| 214 | $membership{$ifindex} = [ $interfaces->{$ifindex} ]; | ||
| 215 | } | ||
| 216 | return \%membership; | ||
| 217 | } | ||
| 218 | |||
| 219 | sub i_vlan_membership_untagged { return {}; } | ||
| 220 | |||
| 221 | 1; | ||
| 222 | |||
| 223 | __END__ |