| 1 | # SNMP::Info::Layer3::VOSS | ||
| 2 | # | ||
| 3 | # Copyright (c) 2026 The SNMP::Info Developers | ||
| 4 | # All rights reserved. | ||
| 5 | # | ||
| 6 | # Redistribution and use in source and binary forms, with or without | ||
| 7 | # modification, are permitted provided that the following conditions are met: | ||
| 8 | # | ||
| 9 | # * Redistributions of source code must retain the above copyright notice, | ||
| 10 | # this list of conditions and the following disclaimer. | ||
| 11 | # * Redistributions in binary form must reproduce the above copyright | ||
| 12 | # notice, this list of conditions and the following disclaimer in the | ||
| 13 | # documentation and/or other materials provided with the distribution. | ||
| 14 | # * Neither the name of the University of California, Santa Cruz nor the | ||
| 15 | # names of its contributors may be used to endorse or promote products | ||
| 16 | # derived from this software without specific prior written permission. | ||
| 17 | # | ||
| 18 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
| 19 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
| 20 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
| 21 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
| 22 | # LIABLE FOR # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
| 23 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
| 24 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
| 25 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
| 26 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 27 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 28 | # POSSIBILITY OF SUCH DAMAGE. | ||
| 29 | |||
| 30 | package SNMP::Info::Layer3::VOSS; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::RapidCityVRF; | ||
| 36 | use SNMP::Info::RapidCity; | ||
| 37 | use SNMP::Info::Layer3; | ||
| 38 | |||
| 39 | @SNMP::Info::Layer3::VOSS::ISA | ||
| 40 | = qw/SNMP::Info::RapidCityVRF SNMP::Info::RapidCity | ||
| 41 | SNMP::Info::Layer3 Exporter/; | ||
| 42 | @SNMP::Info::Layer3::VOSS::EXPORT_OK = qw//; | ||
| 43 | |||
| 44 | our ( $VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE ); | ||
| 45 | |||
| 46 | $VERSION = '3.985003'; | ||
| 47 | |||
| 48 | %MIBS = ( | ||
| 49 | %SNMP::Info::Layer3::MIBS, | ||
| 50 | %SNMP::Info::RapidCity::MIBS, | ||
| 51 | %SNMP::Info::RapidCityVRF::MIBS, | ||
| 52 | 'EXTREME-BASE-MIB' => 'extremeAgent', | ||
| 53 | ); | ||
| 54 | |||
| 55 | %GLOBALS = ( | ||
| 56 | %SNMP::Info::Layer3::GLOBALS, | ||
| 57 | %SNMP::Info::RapidCity::GLOBALS, | ||
| 58 | %SNMP::Info::RapidCityVRF::GLOBALS, | ||
| 59 | 'mac' => 'dot1dBaseBridgeAddress', | ||
| 60 | ); | ||
| 61 | |||
| 62 | %FUNCS = ( | ||
| 63 | %SNMP::Info::Layer3::FUNCS, | ||
| 64 | %SNMP::Info::RapidCity::FUNCS, | ||
| 65 | %SNMP::Info::RapidCityVRF::FUNCS, | ||
| 66 | ); | ||
| 67 | |||
| 68 | %MUNGE = ( | ||
| 69 | %SNMP::Info::Layer3::MUNGE, | ||
| 70 | %SNMP::Info::RapidCity::MUNGE, | ||
| 71 | %SNMP::Info::RapidCityVRF::MUNGE, | ||
| 72 | ); | ||
| 73 | |||
| 74 | sub vendor { | ||
| 75 | return 'extreme'; | ||
| 76 | } | ||
| 77 | |||
| 78 | sub os { | ||
| 79 | return 'voss'; | ||
| 80 | } | ||
| 81 | |||
| 82 | # VOSS / Fabric Engine sysDescr is "<model> (<a.b.c.d>[_build])" | ||
| 83 | sub os_ver { | ||
| 84 | my $voss = shift; | ||
| 85 | my $descr = $voss->description(); | ||
| 86 | return unless defined $descr; | ||
| 87 | |||
| 88 | if ( $descr =~ m/^\S+\s+\((\d+(?:\.\d+){3})/ ) { | ||
| 89 | return $1; | ||
| 90 | } | ||
| 91 | |||
| 92 | return; | ||
| 93 | } | ||
| 94 | |||
| 95 | # Returns the sysObjectID unchanged when EXTREME-BASE-MIB does not name it, | ||
| 96 | # as Layer3::Extreme did for these devices | ||
| 97 | sub model { | ||
| 98 | my $voss = shift; | ||
| 99 | my $id = $voss->id(); | ||
| 100 | return unless defined $id; | ||
| 101 | |||
| 102 | my $model = &SNMP::translateObj($id); | ||
| 103 | |||
| 104 | return defined $model ? $model : $id; | ||
| 105 | } | ||
| 106 | |||
| 107 | # Layer3's serial first (the entity table, then serial1, OLD-CISCO-CHASSIS-MIB | ||
| 108 | # chassisId), as Layer3::Extreme reported it; rcChasSerialNumber only when | ||
| 109 | # that is empty, so a serial Netdisco already stores does not change | ||
| 110 | sub serial { | ||
| 111 | my $voss = shift; | ||
| 112 | |||
| 113 | my $serial = $voss->SNMP::Info::Layer3::serial(@_); | ||
| 114 | return $serial if defined $serial and length $serial; | ||
| 115 | return $voss->rc_serial(); | ||
| 116 | } | ||
| 117 | |||
| 118 | # ifName is a nice concise port name on Fabric Engine, but a router | ||
| 119 | # interface's ifName holds its IP address, so ifDescr names those | ||
| 120 | sub interfaces { | ||
| 121 | my $voss = shift; | ||
| 122 | my $partial = shift; | ||
| 123 | my $i_name = $voss->orig_i_name($partial); | ||
| 124 | my $i_description = $voss->orig_i_description($partial); | ||
| 125 | my $interfaces = {}; | ||
| 126 | foreach my $idx ( keys %$i_name ) { | ||
| 127 | if ( $i_name->{$idx} =~ /\([0-9.]+\)/ ) { | ||
| 128 | $interfaces->{$idx} = $i_description->{$idx}; | ||
| 129 | } | ||
| 130 | else { | ||
| 131 | $interfaces->{$idx} = $i_name->{$idx}; | ||
| 132 | } | ||
| 133 | } | ||
| 134 | return $interfaces; | ||
| 135 | } | ||
| 136 | |||
| 137 | # Fabric Engine bridge port numbers are ifIndexes | ||
| 138 | sub bp_index { | ||
| 139 | my $voss = shift; | ||
| 140 | |||
| 141 | my $bindex = $voss->SUPER::bp_index(); | ||
| 142 | return $bindex if ( ref {} eq ref $bindex and keys %$bindex ); | ||
| 143 | |||
| 144 | my $if_index = $voss->i_index(); | ||
| 145 | |||
| 146 | my %bp_index; | ||
| 147 | foreach my $iid ( keys %$if_index ) { | ||
| 148 | $bp_index{$iid} = $iid; | ||
| 149 | } | ||
| 150 | return \%bp_index; | ||
| 151 | } | ||
| 152 | |||
| 153 | # Q-BRIDGE first, as Layer3::Extreme read it: some releases serve no | ||
| 154 | # rcVlanPortTable. RapidCity answers where Q-BRIDGE lists nothing. | ||
| 155 | sub i_vlan { | ||
| 156 | my $voss = shift; | ||
| 157 | |||
| 158 | return _rows_or_undef( $voss->SNMP::Info::Layer3::i_vlan(@_) ) | ||
| 159 | // _rows_or_undef( $voss->SUPER::i_vlan(@_) ); | ||
| 160 | } | ||
| 161 | |||
| 162 | sub i_vlan_membership { | ||
| 163 | my $voss = shift; | ||
| 164 | |||
| 165 | return _rows_or_undef( $voss->SNMP::Info::Layer3::i_vlan_membership(@_) ) | ||
| 166 | // _rows_or_undef( $voss->SUPER::i_vlan_membership(@_) ); | ||
| 167 | } | ||
| 168 | |||
| 169 | # RapidCity lists every port, with no value for one with no untagged VLAN | ||
| 170 | sub i_vlan_membership_untagged { | ||
| 171 | my $voss = shift; | ||
| 172 | |||
| 173 | return _rows_or_undef( | ||
| 174 | $voss->SNMP::Info::Layer3::i_vlan_membership_untagged(@_) ) | ||
| 175 | // _rows_or_undef( | ||
| 176 | _rows_with_values( $voss->SUPER::i_vlan_membership_untagged(@_) ) ); | ||
| 177 | } | ||
| 178 | |||
| 179 | sub _rows_with_values { | ||
| 180 | my $rows = shift; | ||
| 181 | |||
| 182 | return unless ref {} eq ref $rows; | ||
| 183 | return { | ||
| 184 | map { $_ => $rows->{$_} } | ||
| 185 | grep { defined $rows->{$_} } keys %$rows | ||
| 186 | }; | ||
| 187 | } | ||
| 188 | |||
| 189 | sub _rows_or_undef { | ||
| 190 | my $rows = shift; | ||
| 191 | |||
| 192 | return $rows if ref {} eq ref $rows and keys %$rows; | ||
| 193 | return; | ||
| 194 | } | ||
| 195 | |||
| 196 | 1; | ||
| 197 | |||
| 198 | __END__ |