| 1 | # SNMP::Info::Layer3::Pf | ||
| 2 | # | ||
| 3 | # Copyright (c) 2010 Max Baker | ||
| 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 Pf Networks, Inc. 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::Pf; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::Layer3; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer3::Pf::ISA = qw/SNMP::Info::Layer3 Exporter/; | ||
| 38 | @SNMP::Info::Layer3::Pf::EXPORT_OK = qw//; | ||
| 39 | |||
| 40 | our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE); | ||
| 41 | |||
| 42 | $VERSION = '3.985003'; | ||
| 43 | |||
| 44 | %MIBS = ( | ||
| 45 | %SNMP::Info::Layer3::MIBS, | ||
| 46 | # Enterprise container where BEGEMOT-* lives | ||
| 47 | 'FOKUS-MIB' => 'fokus', | ||
| 48 | # MIBs used included in Layer3 and above: | ||
| 49 | # UDP-MIB | ||
| 50 | # TCP-MIB | ||
| 51 | # IF-MIB | ||
| 52 | # | ||
| 53 | # Stuff in these MIBs but not used for Netdisco yet for my test device: | ||
| 54 | # | ||
| 55 | #'BEGEMOT-SNMPD-MIB', | ||
| 56 | #'BEGEMOT-PF-MIB', | ||
| 57 | #'BEGEMOT-NETGRAPH-MIB', | ||
| 58 | #'BEGEMOT-MIB2-MIB', | ||
| 59 | #'BEGEMOT-HOSTRES-MIB', | ||
| 60 | # HOST-RESOURCES-MIB | ||
| 61 | # IP-FORWARD-MIB | ||
| 62 | # | ||
| 63 | # Nothing in these MIBs for my test device: | ||
| 64 | # | ||
| 65 | #'BEGEMOT-IP-MIB', | ||
| 66 | #'BEGEMOT-MIB', | ||
| 67 | #'BEGEMOT-BRIDGE-MIB', | ||
| 68 | ); | ||
| 69 | |||
| 70 | %GLOBALS = ( | ||
| 71 | %SNMP::Info::Layer3::GLOBALS, | ||
| 72 | ); | ||
| 73 | |||
| 74 | %FUNCS = ( | ||
| 75 | %SNMP::Info::Layer3::FUNCS, | ||
| 76 | ); | ||
| 77 | |||
| 78 | %MUNGE = ( | ||
| 79 | %SNMP::Info::Layer3::MUNGE, | ||
| 80 | ); | ||
| 81 | |||
| 82 | sub vendor { | ||
| 83 | return 'freebsd'; | ||
| 84 | } | ||
| 85 | |||
| 86 | sub model { | ||
| 87 | my $pf = shift; | ||
| 88 | my $descr = $pf->description() || ''; | ||
| 89 | my $model = undef; | ||
| 90 | $model = $1 if ( $descr =~ /FreeBSD\s+(\S+)/ ); | ||
| 91 | return $model if defined $model; | ||
| 92 | return $pf->os_ver(); | ||
| 93 | } | ||
| 94 | |||
| 95 | sub os { | ||
| 96 | return 'Pf'; | ||
| 97 | } | ||
| 98 | |||
| 99 | sub os_ver { | ||
| 100 | my $pf = shift; | ||
| 101 | my $id = $pf->id(); | ||
| 102 | |||
| 103 | my $os_ver = &SNMP::translateObj($id); | ||
| 104 | return $id unless defined $os_ver; | ||
| 105 | |||
| 106 | # From /usr/share/snmp/defs/tree.def on a Pf Machine | ||
| 107 | # (2 begemotSnmpdDefs | ||
| 108 | # (1 begemotSnmpdAgent | ||
| 109 | # (1 begemotSnmpdAgentFreeBSD OID op_dummy) | ||
| 110 | # We're leaving the 1.1 and trimming off up to the 2 | ||
| 111 | $os_ver =~ s/fokus.1.1.2.//; | ||
| 112 | return $os_ver; | ||
| 113 | } | ||
| 114 | |||
| 115 | 1; | ||
| 116 | __END__ |