| 1 | # SNMP::Info::Layer3::CheckPoint | ||
| 2 | # | ||
| 3 | # Copyright (c) 2008 Bill Fenner | ||
| 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::CheckPoint; | ||
| 31 | |||
| 32 | use strict; | ||
| 33 | use warnings; | ||
| 34 | use Exporter; | ||
| 35 | use SNMP::Info::Layer3; | ||
| 36 | |||
| 37 | @SNMP::Info::Layer3::CheckPoint::ISA = qw/SNMP::Info::Layer3 Exporter/; | ||
| 38 | @SNMP::Info::Layer3::CheckPoint::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 | 'CHECKPOINT-MIB' => 'fwProduct', | ||
| 47 | 'UCD-SNMP-MIB' => 'versionTag', | ||
| 48 | 'NET-SNMP-TC' => 'netSnmpAliasDomain', | ||
| 49 | 'NET-SNMP-EXTEND-MIB' => 'nsExtendNumEntries', | ||
| 50 | 'HOST-RESOURCES-MIB' => 'hrSystem', | ||
| 51 | ); | ||
| 52 | |||
| 53 | %GLOBALS = ( | ||
| 54 | %SNMP::Info::Layer3::GLOBALS, | ||
| 55 | 'netsnmp_vers' => 'versionTag', | ||
| 56 | 'hrSystemUptime' => 'hrSystemUptime', | ||
| 57 | 'serial_number' => 'svnApplianceSerialNumber', | ||
| 58 | 'product_name' => 'svnApplianceProductName', | ||
| 59 | 'manufacturer' => 'svnApplianceManufacturer', | ||
| 60 | 'version' => 'svnVersion', | ||
| 61 | ); | ||
| 62 | |||
| 63 | %FUNCS = ( | ||
| 64 | %SNMP::Info::Layer3::FUNCS, | ||
| 65 | |||
| 66 | # Net-SNMP Extend table that could but customize to add a the CheckPoint version | ||
| 67 | 'extend_output_table' => 'nsExtendOutputFull', | ||
| 68 | ); | ||
| 69 | |||
| 70 | %MUNGE = ( | ||
| 71 | %SNMP::Info::Layer3::MUNGE, | ||
| 72 | ); | ||
| 73 | |||
| 74 | sub vendor { | ||
| 75 | my $ckp = shift; | ||
| 76 | |||
| 77 | if (defined $ckp->manufacturer) { | ||
| 78 | return lc $ckp->manufacturer; | ||
| 79 | } else { | ||
| 80 | return 'checkpoint'; | ||
| 81 | } | ||
| 82 | } | ||
| 83 | |||
| 84 | sub model { | ||
| 85 | my $ckp = shift; | ||
| 86 | my $id = $ckp->id; | ||
| 87 | |||
| 88 | my $model = &SNMP::translateObj($id); | ||
| 89 | |||
| 90 | if (defined $ckp->product_name) { | ||
| 91 | return $ckp->product_name; | ||
| 92 | } elsif (defined $model) { | ||
| 93 | $model =~ s/^checkPoint//; | ||
| 94 | return $model; | ||
| 95 | } else { | ||
| 96 | return $id; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | sub os { | ||
| 101 | return 'checkpoint'; | ||
| 102 | } | ||
| 103 | |||
| 104 | sub os_ver { | ||
| 105 | my $ckp = shift; | ||
| 106 | if (defined $ckp->version) { | ||
| 107 | return $ckp->version; | ||
| 108 | } else { | ||
| 109 | my $extend_table = $ckp->extend_output_table() || {}; | ||
| 110 | |||
| 111 | my $descr = $ckp->description(); | ||
| 112 | my $vers = $ckp->netsnmp_vers(); | ||
| 113 | my $os_ver = undef; | ||
| 114 | |||
| 115 | foreach my $ex (keys %$extend_table) { | ||
| 116 | (my $name = pack('C*',split(/\./,$ex))) =~ s/[^[:print:]]//g; | ||
| 117 | if ($name eq 'ckpVersion') { | ||
| 118 | return $1 if ($extend_table->{$ex} =~ /^This is Check Point's software version (.*)$/); | ||
| 119 | last; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
| 123 | $os_ver = $1 if ( $descr =~ /^\S+\s+\S+\s+(\S+)\s+/ ); | ||
| 124 | if ($vers) { | ||
| 125 | $os_ver = "???" unless defined($os_ver); | ||
| 126 | $os_ver .= " / Net-SNMP " . $vers; | ||
| 127 | } | ||
| 128 | return $os_ver; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | |||
| 132 | sub serial { | ||
| 133 | my $ckp = shift; | ||
| 134 | |||
| 135 | if (defined $ckp->serial_number) { | ||
| 136 | return $ckp->serial_number; | ||
| 137 | } else { | ||
| 138 | my $extend_table = $ckp->extend_output_table() || {}; | ||
| 139 | |||
| 140 | foreach my $ex (keys %$extend_table) { | ||
| 141 | (my $name = pack('C*',split(/\./,$ex))) =~ s/[^[:print:]]//g; | ||
| 142 | if ($name eq 'ckpAsset') { | ||
| 143 | return $1 if ($extend_table->{$ex} =~ /Serial Number: (\S+)/); | ||
| 144 | last; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | } | ||
| 148 | return ''; | ||
| 149 | } | ||
| 150 | |||
| 151 | sub layers { | ||
| 152 | return '01001100'; | ||
| 153 | } | ||
| 154 | |||
| 155 | # sysUptime gives us the time since the SNMP daemon has restarted, | ||
| 156 | # so return the system uptime since that's probably what the user | ||
| 157 | # wants. (Caution: this could cause trouble if using | ||
| 158 | # sysUptime-based discontinuity timers or other TimeStamp | ||
| 159 | # objects. | ||
| 160 | sub uptime { | ||
| 161 | my $ckp = shift; | ||
| 162 | my $uptime; | ||
| 163 | |||
| 164 | $uptime = $ckp->hrSystemUptime(); | ||
| 165 | return $uptime if defined $uptime; | ||
| 166 | |||
| 167 | return $ckp->SUPER::uptime(); | ||
| 168 | } | ||
| 169 | |||
| 170 | sub i_ignore { | ||
| 171 | my $l3 = shift; | ||
| 172 | my $partial = shift; | ||
| 173 | |||
| 174 | my $interfaces = $l3->interfaces($partial) || {}; | ||
| 175 | |||
| 176 | my %i_ignore; | ||
| 177 | foreach my $if ( keys %$interfaces ) { | ||
| 178 | |||
| 179 | # lo0 etc | ||
| 180 | if ( $interfaces->{$if} =~ /\blo\d*\b/i ) { | ||
| 181 | $i_ignore{$if}++; | ||
| 182 | } | ||
| 183 | } | ||
| 184 | return \%i_ignore; | ||
| 185 | } | ||
| 186 | |||
| 187 | 1; | ||
| 188 | __END__ |