make fortinet return a useful interface name. (#319)

* make fortinet return a useful interface name.

also fixes missing interface issue due to being unable to map the port
'interfaces - ignoring 54 (no port mapping)'
This commit is contained in:
nick n
2019-04-01 19:32:40 +02:00
committed by GitHub
parent d63baa2473
commit f0b429039e
2 changed files with 37 additions and 0 deletions

View File

@@ -1,3 +1,9 @@
Version 3.67 (2019-xx-xx)
[BUG FIXES]
* #319 make fortinet return a useful interface name (inphobia)
Version 3.66 (2019-03-24) Version 3.66 (2019-03-24)
[NEW FEATURES] [NEW FEATURES]

View File

@@ -63,6 +63,29 @@ sub vendor {
return 'fortinet'; return 'fortinet';
} }
# fortios 5.4 and higher can have empty ifDescr. use ifName (but
# without the ifAlias fixup that's done in layer3::i_name()) which
# mimics fortios >5.4
# copied from an old Layer3.pm which did not have duplicate
# description fixup
sub interfaces {
my $fortinet = shift;
my $partial = shift;
my $interfaces = $fortinet->i_index($partial);
my $descriptions = $fortinet->orig_i_name($partial);
my %interfaces = ();
foreach my $iid ( keys %$interfaces ) {
my $desc = $descriptions->{$iid};
next unless defined $desc;
$interfaces{$iid} = $desc;
}
return \%interfaces;
}
sub model { sub model {
my $fortinet = shift; my $fortinet = shift;
my $id = $fortinet->id() || ''; my $id = $fortinet->id() || '';
@@ -193,6 +216,14 @@ See documentation in L<SNMP::Info::Layer3/"GLOBALS"> for details.
These are methods that return tables of information in the form of a reference These are methods that return tables of information in the form of a reference
to a hash. to a hash.
=over
=item $fortinet->interfaces();
Returns the map between SNMP Interface Identifier (iid) and C<ifName>.
=back
=head2 Table Methods imported from SNMP::Info::Layer3 =head2 Table Methods imported from SNMP::Info::Layer3
See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details. See documentation in L<SNMP::Info::Layer3/"TABLE METHODS"> for details.