1# SNMP::Info::Layer3::CiscoFWSM
2#
3# Copyright (c) 2010 Brian De Wolf
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
30package SNMP::Info::Layer3::CiscoFWSM;
31
32use strict;
33use warnings;
34use Exporter;
35use SNMP::Info::CiscoStats;
36use SNMP::Info::Layer3;
37
38@SNMP::Info::Layer3::CiscoFWSM::ISA = qw/SNMP::Info::CiscoStats
39	SNMP::Info::Layer3
40	Exporter/;
41@SNMP::Info::Layer3::CiscoFWSM::EXPORT_OK = qw//;
42
43our ($VERSION, %GLOBALS, %MIBS, %FUNCS, %MUNGE);
44
45$VERSION = '3.81';
46
47%MIBS = ( %SNMP::Info::Layer3::MIBS, %SNMP::Info::CiscoStats::MIBS, );
48
49%GLOBALS
50	= ( %SNMP::Info::Layer3::GLOBALS, %SNMP::Info::CiscoStats::GLOBALS, );
51
52%FUNCS = (
53	%SNMP::Info::Layer3::FUNCS,
54	%SNMP::Info::CiscoStats::FUNCS,
55);
56
57%MUNGE = ( %SNMP::Info::Layer3::MUNGE, %SNMP::Info::CiscoStats::MUNGE, );
58
59# For FWSMs, the ipNetToPhysicalPhysAddress table appears to be of the form:
60# $ifindex.$inetaddresstype.$proto.$ip_address -> $mac_address
61#
62# Using the output of ipNetToPhysicalPhysAddress, we can emulate the other
63# functions.
64#
65# This doesn't really line up to what at_* return, so we munge it
66
67sub at_paddr {
68	my ($fwsm)    = shift;
69	my ($partial) = shift;
70
71	my $paddrs   = $fwsm->n2p_paddr($partial);
72	my $n_paddrs = {};
73
74	foreach my $key ( keys %$paddrs ) {
75		my $paddr = $paddrs->{$key};
76		my @parts = split /\./, $key;
77		my ( $ifindex, $addrtype, $proto ) = splice @parts, 0, 3;
78		my $ip = join ".", @parts;
79
80		next if ( $proto != 4 );    # at_paddr doesn't support non-IPv4
81
82		$n_paddrs->{"$ifindex.$ip"} = $paddr;
83	}
84	return $n_paddrs;
85}
86
87sub at_netaddr {
88	my ($fwsm)    = shift;
89	my ($partial) = shift;
90
91	my $paddrs = $fwsm->n2p_paddr($partial);
92
93	my $netaddrs = {};
94
95	foreach my $key ( keys %$paddrs ) {
96		my $paddr = $paddrs->{$key};
97		my @parts = split /\./, $key;
98		my ( $ifindex, $addrtype, $proto ) = splice @parts, 0, 3;
99		my $ip = join ".", @parts;
100
101		next if ( $proto != 4 );    # at_netaddr doesn't support non-IPv4
102
103		$netaddrs->{"$ifindex.$ip"} = $ip;
104	}
105	return $netaddrs;
106}
107
108sub at_ifaddr {
109	my ($fwsm)    = shift;
110	my ($partial) = shift;
111
112	my $paddrs = $fwsm->n2p_paddr($partial);
113
114	my $ifaddrs = {};
115
116	foreach my $key ( keys %$paddrs ) {
117		my $paddr = $paddrs->{$key};
118		my @parts = split /\./, $key;
119		my ( $ifindex, $addrtype, $proto ) = splice @parts, 0, 3;
120		my $ip = join ".", @parts;
121
122		next if ( $proto != 4 );    # at_ifaddr doesn't support non-IPv4
123
124		$ifaddrs->{"$ifindex.$ip"} = $ip;
125	}
126	return $ifaddrs;
127}
128
1291;
130__END__
131
132=head1 NAME
133
134SNMP::Info::Layer3::CiscoFWSM - SNMP Interface to Firewall Services Modules
135for features not covered elsewhere.
136
137=head1 AUTHOR
138
139Brian De Wolf
140
141=head1 SYNOPSIS
142
143 # Let SNMP::Info determine the correct subclass for you.
144 my $fwsm = new SNMP::Info(
145						AutoSpecify => 1,
146						Debug       => 1,
147						# These arguments are passed directly to SNMP::Session
148						DestHost    => 'myswitch',
149						Community   => 'public',
150						Version     => 2
151						)
152	or die "Can't connect to DestHost.\n";
153
154 my $class      = $fwsm->class();
155 print "SNMP::Info determined this device to fall under subclass : $class\n";
156
157=head1 DESCRIPTION
158
159Subclass for Cisco Firewall Services Modules
160
161=head2 Inherited Classes
162
163=over
164
165=item SNMP::Info::CiscoStats
166
167=item SNMP::Info::Layer3
168
169=back
170
171=head2 Required MIBs
172
173=over
174
175=item Inherited Classes' MIBs
176
177See L<SNMP::Info::CiscoStats/"Required MIBs"> for its own MIB requirements.
178
179See L<SNMP::Info::Layer3/"Required MIBs"> for its own MIB requirements.
180
181=back
182
183=head1 GLOBALS
184
185=head2 Globals imported from SNMP::Info::CiscoStats
186
187See documentation in L<SNMP::Info::CiscoStats/"GLOBALS"> for details.
188
189=head2 Global Methods imported from SNMP::Info::Layer3
190
191See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
192
193=head1 TABLE METHODS
194
195These are methods that return tables of information in the form of a reference
196to a hash.
197
198=head2 Overrides
199
200=over
201
202=item $fwsm->at_paddr()
203
204This function derives the at_paddr information from the n2p_paddr() table as
205the MIB to provide that information isn't supported on FWSM.
206
207=item $fwsm->at_netaddr()
208
209This function derives the at_netaddr information from the n2p_paddr() table as
210the MIB to provide that information isn't supported on FWSM.
211
212=item $fwsm->at_ifaddr()
213
214This function derives the at_ifaddr information from the n2p_paddr() table as
215the MIB to provide that information isn't supported on FWSM.
216
217=back
218
219=head2 Table Methods imported from SNMP::Info::CiscoStats
220
221See documentation in L<SNMP::Info::CiscoStats/"TABLE METHODS"> for details.
222
223=head2 Table Methods imported from SNMP::Info::Layer3
224
225See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.
226
227=cut
228