| 1 | # SNMP::Info::Layer2::Nexans | ||
| 2 | # | ||
| 3 | # Copyright (c) 2018 Christoph Neuhaus | ||
| 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::Layer2::Nexans; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::Layer2; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer2::Nexans::ISA = qw/SNMP::Info::Layer2 Exporter/; | ||
| 38 | @SNMP::Info::Layer2::Nexans::EXPORT_OK = qw//; | ||
| 39 | |||
| 40 | our ($VERSION, %GLOBALS, %FUNCS, %MIBS, %MUNGE); | ||
| 41 | |||
| 42 | $VERSION = '3.985003'; | ||
| 43 | |||
| 44 | %MIBS = ( | ||
| 45 | %SNMP::Info::Layer2::MIBS, | ||
| 46 | 'NEXANS-MIB' => 'nexansANS', | ||
| 47 | 'NEXANS-BM-MIB' => 'infoDescr', | ||
| 48 | ); | ||
| 49 | |||
| 50 | %GLOBALS = ( | ||
| 51 | %SNMP::Info::Layer2::GLOBALS, | ||
| 52 | 'mac' => 'adminAgentPhysAddress.0', | ||
| 53 | ); | ||
| 54 | |||
| 55 | %FUNCS = ( | ||
| 56 | %SNMP::Info::Layer2::FUNCS, | ||
| 57 | 'i_duplex' => 'portLinkState', #NEXANS-BM-MIB | ||
| 58 | 'i_duplex_admin' => 'portSpeedDuplexSetup', #NEXANS-BM-MIB | ||
| 59 | 'nexans_i_name' => 'ifAlias', | ||
| 60 | ); | ||
| 61 | |||
| 62 | %MUNGE = ( | ||
| 63 | %SNMP::Info::Layer2::MUNGE, | ||
| 64 | 'i_duplex' => \&munge_i_duplex, | ||
| 65 | 'i_duplex_admin' => \&munge_i_duplex_admin, | ||
| 66 | ); | ||
| 67 | |||
| 68 | sub munge_i_duplex { | ||
| 69 | my $duplex = shift; | ||
| 70 | return unless defined $duplex; | ||
| 71 | $duplex = 'half' if $duplex =~/Hdx/; | ||
| 72 | $duplex = 'full' if $duplex =~/Fdx/; | ||
| 73 | return $duplex; | ||
| 74 | } | ||
| 75 | |||
| 76 | sub munge_i_duplex_admin { | ||
| 77 | my $duplex_admin = shift; | ||
| 78 | return unless defined $duplex_admin; | ||
| 79 | $duplex_admin = 'full' if $duplex_admin =~/Fdx/; | ||
| 80 | $duplex_admin = 'half' if $duplex_admin =~/Hdx/; | ||
| 81 | $duplex_admin = 'auto' if $duplex_admin =~/autoneg/; | ||
| 82 | return $duplex_admin; | ||
| 83 | } | ||
| 84 | |||
| 85 | sub vendor { | ||
| 86 | return 'nexans'; | ||
| 87 | } | ||
| 88 | |||
| 89 | sub model { | ||
| 90 | my $nexans = shift; | ||
| 91 | my $id = $nexans->id() || ''; | ||
| 92 | my $model = &SNMP::translateObj($id); | ||
| 93 | return $id unless defined $model; | ||
| 94 | return $model; | ||
| 95 | } | ||
| 96 | |||
| 97 | sub os { | ||
| 98 | return 'nexanos'; | ||
| 99 | } | ||
| 100 | |||
| 101 | sub os_ver { | ||
| 102 | my $nexans = shift; | ||
| 103 | my $ver = $nexans->infoMgmtFirmwareVersion() || ''; | ||
| 104 | return $ver; | ||
| 105 | } | ||
| 106 | |||
| 107 | sub serial { | ||
| 108 | my $nexans = shift; | ||
| 109 | return $nexans->infoSeriesNo(); | ||
| 110 | } | ||
| 111 | |||
| 112 | sub i_name { | ||
| 113 | my $nexans = shift; | ||
| 114 | my $return = $nexans->nexans_i_name(); | ||
| 115 | # replace i_name where possible | ||
| 116 | foreach my $iid ( keys %$return ) { | ||
| 117 | next unless $return->{$iid} eq ""; | ||
| 118 | $return->{$iid} = $iid; | ||
| 119 | } | ||
| 120 | return \%$return; | ||
| 121 | } | ||
| 122 | |||
| 123 | 1; | ||
| 124 | |||
| 125 | __END__ |