1# SNMP::Info::Layer7::CiscoIPS
2#
3# Copyright (c) 2013 Moe Kraus
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
23# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29# POSSIBILITY OF SUCH DAMAGE.
30
31package SNMP::Info::Layer7::CiscoIPS;
32
33use strict;
34use warnings;
35use Exporter;
36use SNMP::Info::CiscoStats;
37use SNMP::Info::Layer7;
38use SNMP::Info::Entity;
39
40@SNMP::Info::Layer7::CiscoIPS::ISA = qw/
41    SNMP::Info::CiscoStats
42    SNMP::Info::Layer7
43    Exporter/;
44@SNMP::Info::Layer7::CiscoIPS::EXPORT_OK = qw//;
45
46our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE);
47
48$VERSION = '3.81';
49
50%MIBS = ( %SNMP::Info::Layer7::MIBS, %SNMP::Info::Entity::MIBS, );
51
52%GLOBALS
53    = ( %SNMP::Info::Layer7::GLOBALS, %SNMP::Info::Entity::GLOBALS, );
54
55%FUNCS = (
56    %SNMP::Info::Layer7::FUNCS,
57    %SNMP::Info::Entity::FUNCS,
58);
59
60%MUNGE = (
61    %SNMP::Info::Layer7::MUNGE,
62    %SNMP::Info::Entity::MUNGE,
63);
64
65my ($serial, $descr, $model);
66
67sub _fetch_info {
68    my $self = shift;
69    foreach my $id ( keys %{ $self->e_id() } ){
70
71        if (
72            $self->e_name->{$id} =~ m/^Module$/ and
73            $self->e_model->{$id} =~ m/IPS/
74        ) {
75            $serial = $self->e_serial->{$id};
76            $descr  = $self->e_descr->{$id};
77            $model  = $self->e_model->{$id};
78        }
79
80    }
81
82}
83
84sub layers {
85    return '01001000';
86}
87
88sub serial {
89    my $self = shift;
90    _fetch_info($self) unless defined $serial;
91    return $serial;
92}
93
94sub sysdescr {
95    my $self = shift;
96    _fetch_info($self) unless defined $descr;
97    return $descr;
98}
99
100sub model {
101    my $self = shift;
102    _fetch_info($self) unless defined $descr;
103    $descr =~ s/ Security Services Processor//g;
104    $descr =~ s/ /-/g;
105    return $descr;
106}
107
108sub productname {
109    my $self = shift;
110    return $self->model;
111}
112
113sub b_mac {
114    my ( $self ) = shift;
115
116    foreach my $mac ( values %{$self->i_mac()} ){
117
118        next unless defined $mac;
119        next unless $mac =~ m/^e4:d3:f1/;
120        return  $mac;
121    }
122
123    return '';
124}
125
126sub e_index {
127    my $self = shift();
128    my %index;
129    foreach my $id ( keys %{$self->e_id} ){
130        $index{$id} = $id;
131    }
132    return \%index;
133}
134
1351;
136__END__
137
138=head1 NAME
139
140SNMP::Info::Layer7::CiscoIPS - Cisco Adaptive Security Appliance IPS module
141
142=head1 AUTHOR
143
144Moe Kraus
145
146=head1 SYNOPSIS
147
148 # Let SNMP::Info determine the correct subclass for you.
149 my $info = new SNMP::Info(
150                        AutoSpecify => 1,
151                        Debug       => 1,
152                        # These arguments are passed directly to SNMP::Session
153                        DestHost    => 'myIPS',
154                        Community   => 'public',
155                        Version     => 2
156                        )
157    or die "Can't connect to DestHost.\n";
158
159 my $class      = $info->class();
160 print "SNMP::Info determined this device to fall under subclass: $class\n";
161
162=head1 DESCRIPTION
163
164Subclass for Cisco IPS Module
165
166=head2 Inherited Classes
167
168=over
169
170=item SNMP::Info::Entity
171
172=item SNMP::Info::Layer7
173
174=back
175
176=head2 Required MIBs
177
178=over
179
180=item Inherited Classes' MIBs
181
182See classes listed above for their required MIBs.
183
184=back
185
186
187=head1 GLOBALS
188
189These are methods that return scalar value from SNMP
190
191=over
192
193=item $info->b_mac()
194
195Returns base mac. Matches only on e4:d3:f1
196
197=item $info->serial()
198
199Fetches serial from Module
200
201=item $info->e_index()
202
203overrides Entity->e_index() since entity table the IPS delivering is buggy.
204
205=item $info->layers
206
207Returns '01001000'
208
209=item $info->model
210
211Returns model name
212
213=item $info->productname
214
215Returns the product name
216
217=item $info->serial
218
219Returns the serial number
220
221=item $info->sysdescr
222
223Returns the system description
224
225=back
226
227=head2 Global Methods imported from SNMP::Info::Layer7
228
229See documentation in L<SNMP::Info::Layer7/"GLOBALS"> for details.
230
231=head2 Global Methods imported from SNMP::Info::Entity
232
233See documentation in L<SNMP::Info::Entity/"GLOBALS"> for details.
234
235=head1 TABLE METHODS
236
237These are methods that return tables of information in the form of a
238reference to a hash.
239
240=head2 Table Methods imported from SNMP::Info::Layer7
241
242See documentation in L<SNMP::Info::Layer7/"TABLE METHODS"> for details.
243
244=head2 Table Methods imported from SNMP::Info::Entity
245
246See documentation in L<SNMP::Info::Entity/"TABLE METHODS"> for details.
247
248=cut
249