diff --git a/lib/SNMP/Info/CiscoVTP.pm b/lib/SNMP/Info/CiscoVTP.pm index aedd418d..29cbc044 100644 --- a/lib/SNMP/Info/CiscoVTP.pm +++ b/lib/SNMP/Info/CiscoVTP.pm @@ -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 diff --git a/lib/SNMP/Info/Layer3.pm b/lib/SNMP/Info/Layer3.pm index 0b36759f..c65a3fa6 100644 --- a/lib/SNMP/Info/Layer3.pm +++ b/lib/SNMP/Info/Layer3.pm @@ -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, value = array of +C. These are the VLAN subinterfaces (C type) for the parent +(C 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.