bury all dead whitespace, better off to just do it in one command. i wonder why ss...
[torrus-plus.git] / src / lib / Torrus / DevDiscover / RFC2011_IP_MIB.pm
blob380e0ea7d9cdb8c62b7eaed950a072965ad33c30
1 # Copyright (C) 2005 Stanislav Sinyagin
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
17 # Stanislav Sinyagin <ssinyagin@yahoo.com>
19 # Discovery module for IP-MIB (RFC 2011)
20 # This module does not generate any XML, but provides information
21 # for other discovery modules. For the sake of discovery time and traffic,
22 # it is not implicitly executed during the normal discovery process.
24 package Torrus::DevDiscover::RFC2011_IP_MIB;
26 use strict;
27 use warnings;
29 use Torrus::Log;
31 our $VERSION = 1.0;
33 our %oiddef =
35 # IP-MIB
36 'ipNetToMediaTable' => '1.3.6.1.2.1.4.22',
37 'ipNetToMediaPhysAddress' => '1.3.6.1.2.1.4.22.1.2',
43 sub discover
45 my $dd = shift;
46 my $devdetails = shift;
48 my $data = $devdetails->data();
49 my $session = $dd->session();
51 my $table = $session->get_table( -baseoid =>
52 $dd->oiddef('ipNetToMediaPhysAddress'));
54 if( not defined($table) or scalar(keys %{$table}) == 0 )
56 return 0;
59 $devdetails->storeSnmpVars( $table );
61 for my $INDEX
62 ( $devdetails->
63 getSnmpIndices( $dd->oiddef('ipNetToMediaPhysAddress') ) )
65 my( $ifIndex, @ipAddrOctets ) = split( '\.', $INDEX );
66 my $ipAddr = join('.', @ipAddrOctets);
68 my $interface = $data->{'interfaces'}{$ifIndex};
69 next if not defined( $interface );
71 my $phyAddr =
72 $devdetails->snmpVar($dd->oiddef('ipNetToMediaPhysAddress') .
73 '.' . $INDEX);
75 $interface->{'ipNetToMedia'}{$ipAddr} = $phyAddr;
76 $interface->{'mediaToIpNet'}{$phyAddr} = $ipAddr;
78 # Cisco routers assign ARP to subinterfaces, but MAC accounting
79 # to main interfaces. Let them search in a global table
80 $data->{'ipNetToMedia'}{$ipAddr} = $phyAddr;
81 $data->{'mediaToIpNet'}{$phyAddr} = $ipAddr;
84 return 1;
92 # Local Variables:
93 # mode: perl
94 # indent-tabs-mode: nil
95 # perl-indent-level: 4
96 # End: