add i_subinterfaces to Layer3

This commit is contained in:
Oliver Gorwits
2022-08-17 22:03:03 +01:00
parent a59af743a9
commit 9842bb2dc2
2 changed files with 41 additions and 1 deletions

View File

@@ -201,7 +201,7 @@ sub i_vlan {
sub i_subinterfaces {
my $vtp = shift;
my %i_subs = ();
my %i_subs = %{ $vtp->SUPER::i_subinterfaces() || {} };
# CISCO-VLAN-IFTABLE-RELATION-MIB
# Used for traditional Cisco Routers and Aironet

View File

@@ -277,6 +277,30 @@ sub model {
return $model;
}
sub i_subinterfaces {
my $dev = shift;
my $partial = shift;
my $ifstack = $dev->i_stack_status() || {};
# TODO: if we want to do partial, we need to use inverse status
my $iftype = $dev->i_type() || {};
my $ret = $dev->SUPER::i_subinterfaces() || {};
foreach my $idx ( keys %$ifstack ) {
next unless $ifstack->{$idx} eq 'active';
my ( $higher, $lower ) = split /\./, $idx;
next if ( $higher == 0 or $lower == 0 );
if ( $iftype->{ $higher } eq 'l2vlan' or $iftype->{ $higher } eq 'l3ipvlan') {
push @{ $ret->{ $lower } }, $higher;
}
}
return $ret;
}
sub i_name {
my $l3 = shift;
my $partial = shift;
@@ -611,6 +635,22 @@ name.
Only returns those iids that have a description listed in $l3->i_description()
=item $l3->i_subinterfaces()
Returns reference to hash of arrays: key = C<ifIndex>, value = array of
C<ifIndex>. These are the VLAN subinterfaces (C<l2vlan> type) for the parent
(C<ethernetCsmacd> type) interface.
Example:
my $interfaces = $l3->interfaces();
my $i_subs = $l3->i_subinterfaces();
foreach my $iid (sort keys %$interfaces) {
my $port = $interfaces->{$iid};
my $subs = join(',', sort(map {$interfaces->{$_}} @{$i_subs->{$iid}}));
print "Port: $port has subinterfaces: $subs\n";
}
=item $l3->i_name()
Returns reference to hash of iid to human set name.