| 1 | package Net::SNMP::Mixin::InetCidrRouteTable; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # store this package name in a handy variable, | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # used for unambiguous prefix of mixin attributes | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # storage in object hash | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | my $prefix = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # this module import config | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use Net::SNMP qw(oid_lex_sort); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | ▶ | use Net::SNMP::Mixin::Util qw/idx2val push_error get_init_slot/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Socket qw(inet_ntop AF_INET AF_INET6); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # this module export config | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 4 | my @mixin_methods; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 4 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 4 | @mixin_methods = (qw/ get_inet_cidr_route_table /); | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 4 | ▶ | use Sub::Exporter -setup => { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | exports => [@mixin_methods], | ||||||||||||||||||||||||||||||||||||||||||
| 32 | groups => { default => [@mixin_methods], }, | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | Net::SNMP::Mixin::InetCidrRouteTable - mixin class for the inetCidrRouteTable | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | Version 0.03 | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | 4 | our $VERSION = '0.03'; | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | use Net::SNMP; | ||||||||||||||||||||||||||||||||||||||||||
| 50 | use Net::SNMP::Mixin; | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | #... | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | my $session = Net::SNMP->session( -hostname => 'foo.bar.com' ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | $session->mixer('Net::SNMP::Mixin::InetCidrRouteTable'); | ||||||||||||||||||||||||||||||||||||||||||
| 57 | $session->init_mixins; | ||||||||||||||||||||||||||||||||||||||||||
| 58 | snmp_dispatcher(); | ||||||||||||||||||||||||||||||||||||||||||
| 59 | $session->init_ok(); | ||||||||||||||||||||||||||||||||||||||||||
| 60 | die $session->errors if $session->errors; | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | my @routes = $session->get_inet_cidr_route_table(); | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | foreach my $route (@routes) { | ||||||||||||||||||||||||||||||||||||||||||
| 65 | my $prefix = $route->{inetCidrRoutePrefix}; | ||||||||||||||||||||||||||||||||||||||||||
| 66 | my $next_hop = $route->{inetCidrRouteNextHop}; | ||||||||||||||||||||||||||||||||||||||||||
| 67 | my $if_index = $route->{inetCidrRouteIfIndex}; | ||||||||||||||||||||||||||||||||||||||||||
| 68 | # ... | ||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||
| 70 | print "$prefix => $if_index/$next_hop\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | A Net::SNMP mixin class for inetCidrRouteTable. | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | The inetCidrRouteTable provides the ability to display IP version-independent multipath CIDR routes. | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # SNMP oid constants used in this module | ||||||||||||||||||||||||||||||||||||||||||
| 83 | # | ||||||||||||||||||||||||||||||||||||||||||
| 84 | # from IP Forwarding Table MIB, RFC 2096 | ||||||||||||||||||||||||||||||||||||||||||
| 85 | # | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | ▶ | use constant { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | INET_CIDR_ROUTE_TABLE => '1.3.6.1.2.1.4.24.7', | |||||||||||||||||||||||||||||||||||||||||
| 88 | INET_CIDR_ROUTE_ENTRY => '1.3.6.1.2.1.4.24.7.1', | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | INET_CIDR_ROUTE_DEST_TYPE => '1.3.6.1.2.1.4.24.7.1.1', # index, InetAddressType | ||||||||||||||||||||||||||||||||||||||||||
| 91 | INET_CIDR_ROUTE_DEST => '1.3.6.1.2.1.4.24.7.1.2', # index, InetAddress | ||||||||||||||||||||||||||||||||||||||||||
| 92 | INET_CIDR_ROUTE_PFXLEN => '1.3.6.1.2.1.4.24.7.1.3', # index, InetAddressPrefixLength | ||||||||||||||||||||||||||||||||||||||||||
| 93 | INET_CIDR_ROUTE_POLICY => '1.3.6.1.2.1.4.24.7.1.4', # index, OID | ||||||||||||||||||||||||||||||||||||||||||
| 94 | INET_CIDR_ROUTE_NEXTHOP_TYPE => '1.3.6.1.2.1.4.24.7.1.5', # index, InetAddressType | ||||||||||||||||||||||||||||||||||||||||||
| 95 | INET_CIDR_ROUTE_NEXTHOP => '1.3.6.1.2.1.4.24.7.1.6', # index, InetAddress | ||||||||||||||||||||||||||||||||||||||||||
| 96 | INET_CIDR_ROUTE_IFINDEX => '1.3.6.1.2.1.4.24.7.1.7', | ||||||||||||||||||||||||||||||||||||||||||
| 97 | INET_CIDR_ROUTE_TYPE => '1.3.6.1.2.1.4.24.7.1.8', | ||||||||||||||||||||||||||||||||||||||||||
| 98 | INET_CIDR_ROUTE_PROTO => '1.3.6.1.2.1.4.24.7.1.9', | ||||||||||||||||||||||||||||||||||||||||||
| 99 | INET_CIDR_ROUTE_AGE => '1.3.6.1.2.1.4.24.7.1.10', | ||||||||||||||||||||||||||||||||||||||||||
| 100 | INET_CIDR_ROUTE_NEXTHOPAS => '1.3.6.1.2.1.4.24.7.1.11', | ||||||||||||||||||||||||||||||||||||||||||
| 101 | INET_CIDR_ROUTE_METRIC1 => '1.3.6.1.2.1.4.24.7.1.12', | ||||||||||||||||||||||||||||||||||||||||||
| 102 | INET_CIDR_ROUTE_METRIC2 => '1.3.6.1.2.1.4.24.7.1.13', | ||||||||||||||||||||||||||||||||||||||||||
| 103 | INET_CIDR_ROUTE_METRIC3 => '1.3.6.1.2.1.4.24.7.1.14', | ||||||||||||||||||||||||||||||||||||||||||
| 104 | INET_CIDR_ROUTE_METRIC4 => '1.3.6.1.2.1.4.24.7.1.15', | ||||||||||||||||||||||||||||||||||||||||||
| 105 | INET_CIDR_ROUTE_METRIC5 => '1.3.6.1.2.1.4.24.7.1.16', | ||||||||||||||||||||||||||||||||||||||||||
| 106 | INET_CIDR_ROUTE_STATUS => '1.3.6.1.2.1.4.24.7.1.17', | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | }; | |||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | # | ||||||||||||||||||||||||||||||||||||||||||
| 110 | # the InetAddressType enum | ||||||||||||||||||||||||||||||||||||||||||
| 111 | # | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 4 | my %address_type_enum = ( | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 => 'unknown', | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 => 'ipv4', | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 2 => 'ipv6', | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 3 => 'ipv4z', | ||||||||||||||||||||||||||||||||||||||||||
| 117 | 4 => 'ipv6z', | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 16 => 'dns16', | ||||||||||||||||||||||||||||||||||||||||||
| 119 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | # | ||||||||||||||||||||||||||||||||||||||||||
| 122 | # the inetCidrRouteType enum | ||||||||||||||||||||||||||||||||||||||||||
| 123 | # | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 4 | my %route_type_enum = ( | |||||||||||||||||||||||||||||||||||||||||
| 125 | 1 => 'other', | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 => 'reject', | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 3 => 'local', | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 4 => 'remote', | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 5 => 'blackhole', | ||||||||||||||||||||||||||||||||||||||||||
| 130 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | # | ||||||||||||||||||||||||||||||||||||||||||
| 133 | # the inetCidrRouteProto enum | ||||||||||||||||||||||||||||||||||||||||||
| 134 | # | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 4 | my %proto_enum = ( | |||||||||||||||||||||||||||||||||||||||||
| 136 | 1 => 'other', | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 2 => 'local', | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 3 => 'netmgmt', | ||||||||||||||||||||||||||||||||||||||||||
| 139 | 4 => 'icmp', | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 5 => 'egp', | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 6 => 'ggp', | ||||||||||||||||||||||||||||||||||||||||||
| 142 | 7 => 'hello', | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 8 => 'rip', | ||||||||||||||||||||||||||||||||||||||||||
| 144 | 9 => 'is-is', | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 10 => 'es-is', | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 11 => 'ciscoIgrp', | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 12 => 'bbnSpfIgp', | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 13 => 'ospf', | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 14 => 'bgp', | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 15 => 'idpr', | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 16 => 'ciscoEigrp', | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 17 => 'DVMR', | ||||||||||||||||||||||||||||||||||||||||||
| 153 | 18 => 'RPL', | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 19 => 'DHCP', | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 20 => 'TTDP', | ||||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | # | ||||||||||||||||||||||||||||||||||||||||||
| 159 | # the inetCidrRouteStatus enum | ||||||||||||||||||||||||||||||||||||||||||
| 160 | # | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 4 | my %status_enum = ( | |||||||||||||||||||||||||||||||||||||||||
| 162 | 1 => 'active', | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 2 => 'notInService', | ||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 => 'notReady', | ||||||||||||||||||||||||||||||||||||||||||
| 165 | 4 => 'createAndGo', | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 => 'createAndWait', | ||||||||||||||||||||||||||||||||||||||||||
| 167 | 6 => 'destroy', | ||||||||||||||||||||||||||||||||||||||||||
| 168 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | =head1 MIXIN METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | =head2 B<< OBJ->get_inet_cidr_route_table() >> | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | Returns a sorted list of inetCidrRouteTable and cooked entries. Every list element (route entry) is a hashref with the following fields and values: | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | inetCidrRoutePrefix => CIDR String, | ||||||||||||||||||||||||||||||||||||||||||
| 178 | inetCidrRouteZone => InetAddress, | ||||||||||||||||||||||||||||||||||||||||||
| 179 | inetCidrRouteNextHop => InetAddress, | ||||||||||||||||||||||||||||||||||||||||||
| 180 | inetCidrRoutePolicy => OBJECT IDENTIFIER, | ||||||||||||||||||||||||||||||||||||||||||
| 181 | inetCidrRouteIfIndex => InterfaceIndexOrZero, | ||||||||||||||||||||||||||||||||||||||||||
| 182 | inetCidrRouteType => INTEGER, | ||||||||||||||||||||||||||||||||||||||||||
| 183 | inetCidrRouteTypeString => String, # resolved enum | ||||||||||||||||||||||||||||||||||||||||||
| 184 | inetCidrRouteProto => IANAipRouteProtocol, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | inetCidrRouteProtoString => String, # resolved enum | ||||||||||||||||||||||||||||||||||||||||||
| 186 | inetCidrRouteAge => Gauge32, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | inetCidrRouteNextHopAS => InetAutonomousSystemNumber, | ||||||||||||||||||||||||||||||||||||||||||
| 188 | inetCidrRouteMetric1 => Integer32, | ||||||||||||||||||||||||||||||||||||||||||
| 189 | inetCidrRouteMetric2 => Integer32, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | inetCidrRouteMetric3 => Integer32, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | inetCidrRouteMetric4 => Integer32, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | inetCidrRouteMetric5 => Integer32, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | inetCidrRouteStatus => RowStatus | ||||||||||||||||||||||||||||||||||||||||||
| 194 | inetCidrRouteStatusString => String, # resolved enum | ||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | ▶ | sub get_inet_cidr_route_table { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_inet_cidr_route_table: not called CC=14 SCAR=53.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | my $agent = $session->hostname; | |||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | Carp::croak "$agent: '$prefix' not initialized," | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | unless $session->init_ok($prefix); | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | # stash for return values | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my @route_tbl; | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $inetCidrRoutePrefix, $inetCidrRouteZone, $inetCidrRouteNextHop, $inetCidrRoutePolicy, | |||||||||||||||||||||||||||||||||||||||||
| 211 | $inetCidrRouteIfIndex, $inetCidrRouteType, $inetCidrRouteTypeString, $inetCidrRouteProto, | ||||||||||||||||||||||||||||||||||||||||||
| 212 | $inetCidrRouteProtoString, $inetCidrRouteAge, $inetCidrRouteNextHopAS, $inetCidrRouteMetric1, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | $inetCidrRouteMetric2, $inetCidrRouteMetric3, $inetCidrRouteMetric4, $inetCidrRouteMetric5, | ||||||||||||||||||||||||||||||||||||||||||
| 214 | $inetCidrRouteStatus, $inetCidrRouteStatusString, | ||||||||||||||||||||||||||||||||||||||||||
| 215 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | # | ||||||||||||||||||||||||||||||||||||||||||
| 218 | # inetCidrRouteIfIndex is used for table index walk | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | foreach my $idx ( oid_lex_sort keys %{ $session->{$prefix}{inetCidrRouteIfIndex} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | $inetCidrRoutePrefix = $session->{$prefix}{inetCidrRoutePrefix}{$idx} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRoutePrefix"}{$idx} // ""
MC/DC0%0/1
$session->{$prefix}{"inetCidrRoutePrefix"}{$idx} // ""
$session->{$prefix}{"inetCidrRoutePrefix"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRoutePrefix"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | $inetCidrRouteZone = $session->{$prefix}{inetCidrRouteZone}{$idx} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRouteZone"}{$idx} // ""
MC/DC0%0/1
$session->{$prefix}{"inetCidrRouteZone"}{$idx} // ""
$session->{$prefix}{"inetCidrRouteZone"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRouteZone"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | $inetCidrRouteNextHop = $session->{$prefix}{inetCidrRouteNextHop}{$idx} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRouteNextHop"}{$idx} // ""
MC/DC0%0/1
$session->{$prefix}{"inetCidrRouteNextHop"}{$idx} // ""
$session->{$prefix}{"inetCidrRouteNextHop"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRouteNextHop"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | $inetCidrRoutePolicy = $session->{$prefix}{inetCidrRoutePolicy}{$idx} // ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRoutePolicy"}{$idx} // ""
MC/DC0%0/1
$session->{$prefix}{"inetCidrRoutePolicy"}{$idx} // ""
$session->{$prefix}{"inetCidrRoutePolicy"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRoutePolicy"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | ▶ | $inetCidrRouteIfIndex = $session->{$prefix}{inetCidrRouteIfIndex}{$idx} // 0; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRouteIfIndex"}{$idx} // 0
MC/DC0%0/1
$session->{$prefix}{"inetCidrRouteIfIndex"}{$idx} // 0
$session->{$prefix}{"inetCidrRouteIfIndex"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRouteIfIndex"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | ▶ | $inetCidrRouteType = $session->{$prefix}{inetCidrRouteType}{$idx} // -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRouteType"}{$idx} // -1
MC/DC0%0/1
$session->{$prefix}{"inetCidrRouteType"}{$idx} // -1
$session->{$prefix}{"inetCidrRouteType"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRouteType"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | $inetCidrRouteTypeString = $route_type_enum{$inetCidrRouteType} // 'unknown'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$route_type_enum{$inetCidrRouteType} // "unknown"
MC/DC0%0/1
$route_type_enum{$inetCidrRouteType} // "unknown"
$route_type_enum{$inetCidrRouteType}
Truth table0%0/2
A
A= $route_type_enum{$inetCidrRouteType}
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | $inetCidrRouteProto = $session->{$prefix}{inetCidrRouteProto}{$idx} // -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRouteProto"}{$idx} // -1
MC/DC0%0/1
$session->{$prefix}{"inetCidrRouteProto"}{$idx} // -1
$session->{$prefix}{"inetCidrRouteProto"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRouteProto"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | $inetCidrRouteProtoString = $proto_enum{$inetCidrRouteProto} // 'unknown'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$proto_enum{$inetCidrRouteProto} // "unknown"
MC/DC0%0/1
$proto_enum{$inetCidrRouteProto} // "unknown"
$proto_enum{$inetCidrRouteProto}
Truth table0%0/2
A
A= $proto_enum{$inetCidrRouteProto}
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $inetCidrRouteAge = $session->{$prefix}{inetCidrRouteAge}{$idx}; | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $inetCidrRouteNextHopAS = $session->{$prefix}{inetCidrRouteNextHopAS}{$idx}; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $inetCidrRouteMetric1 = $session->{$prefix}{inetCidrRouteMetric1}{$idx}; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $inetCidrRouteMetric2 = $session->{$prefix}{inetCidrRouteMetric2}{$idx}; | |||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | $inetCidrRouteMetric3 = $session->{$prefix}{inetCidrRouteMetric3}{$idx}; | |||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | $inetCidrRouteMetric4 = $session->{$prefix}{inetCidrRouteMetric4}{$idx}; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | $inetCidrRouteMetric5 = $session->{$prefix}{inetCidrRouteMetric5}{$idx}; | |||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | $inetCidrRouteStatus = $session->{$prefix}{inetCidrRouteStatus}{$idx} // -1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$session->{$prefix}{"inetCidrRouteStatus"}{$idx} // -1
MC/DC0%0/1
$session->{$prefix}{"inetCidrRouteStatus"}{$idx} // -1
$session->{$prefix}{"inetCidrRouteStatus"}{$idx}
Truth table0%0/2
A
A= $session->{$prefix}{"inetCidrRouteStatus"}{$idx}
| |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | $inetCidrRouteStatusString = $status_enum{$inetCidrRouteStatus} // 'unknown'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$status_enum{$inetCidrRouteStatus} // "unknown"
MC/DC0%0/1
$status_enum{$inetCidrRouteStatus} // "unknown"
$status_enum{$inetCidrRouteStatus}
Truth table0%0/2
A
A= $status_enum{$inetCidrRouteStatus}
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | push @route_tbl, { | |||||||||||||||||||||||||||||||||||||||||
| 241 | inetCidrRoutePrefix => $inetCidrRoutePrefix, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | inetCidrRouteZone => $inetCidrRouteZone, | ||||||||||||||||||||||||||||||||||||||||||
| 243 | inetCidrRouteNextHop => $inetCidrRouteNextHop, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | inetCidrRoutePolicy => $inetCidrRoutePolicy, | ||||||||||||||||||||||||||||||||||||||||||
| 245 | inetCidrRouteIfIndex => $inetCidrRouteIfIndex, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | inetCidrRouteType => $inetCidrRouteType, | ||||||||||||||||||||||||||||||||||||||||||
| 247 | inetCidrRouteTypeString => $inetCidrRouteTypeString, | ||||||||||||||||||||||||||||||||||||||||||
| 248 | inetCidrRouteProto => $inetCidrRouteProto, | ||||||||||||||||||||||||||||||||||||||||||
| 249 | inetCidrRouteProtoString => $inetCidrRouteProtoString, | ||||||||||||||||||||||||||||||||||||||||||
| 250 | inetCidrRouteAge => $inetCidrRouteAge, | ||||||||||||||||||||||||||||||||||||||||||
| 251 | inetCidrRouteNextHopAS => $inetCidrRouteNextHopAS, | ||||||||||||||||||||||||||||||||||||||||||
| 252 | inetCidrRouteMetric1 => $inetCidrRouteMetric1, | ||||||||||||||||||||||||||||||||||||||||||
| 253 | inetCidrRouteMetric2 => $inetCidrRouteMetric2, | ||||||||||||||||||||||||||||||||||||||||||
| 254 | inetCidrRouteMetric3 => $inetCidrRouteMetric3, | ||||||||||||||||||||||||||||||||||||||||||
| 255 | inetCidrRouteMetric4 => $inetCidrRouteMetric4, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | inetCidrRouteMetric5 => $inetCidrRouteMetric5, | ||||||||||||||||||||||||||||||||||||||||||
| 257 | inetCidrRouteStatus => $inetCidrRouteStatus, | ||||||||||||||||||||||||||||||||||||||||||
| 258 | inetCidrRouteStatusString => $inetCidrRouteStatusString, | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | return @route_tbl; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | =head1 INITIALIZATION | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | =head2 B<< OBJ->_init($reload) >> | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | Fetch the inetCidrRouteTable from the host. Don't call this method direct! | ||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||
| 274 | # | ||||||||||||||||||||||||||||||||||||||||||
| 275 | # due to the asynchron nature, we don't know what init job is really the last, we decrement | ||||||||||||||||||||||||||||||||||||||||||
| 276 | # the value after each callback | ||||||||||||||||||||||||||||||||||||||||||
| 277 | # | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 4 | ▶ | use constant THIS_INIT_JOBS => 1; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | sub _init { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my ( $session, $reload ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my $agent = $session->hostname; | |||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | die "$agent: $prefix already initialized and reload not forced.\n" | ||||||||||||||||||||||||||||||||||||||||||
| 285 | if exists get_init_slot($session)->{$prefix} | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | ▶ | && get_init_slot($session)->{$prefix} == 0 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
exists get_init_slot($session)->{$prefix} and get_init_slot($session)->{$prefix} == 0 and not $reload
exists get_init_slot($session)->{$prefix} and get_init_slot($session)->{$prefix} == 0
MC/DC0%0/3
exists get_init_slot($session)->{$prefix} and get_init_slot($session)->{$prefix} == 0 and not $reload
exists get_init_slot($session)->{$prefix}
get_init_slot($session)->{$prefix} == 0
not $reload
Truth table0%0/4
A and B and not(C)
A= exists get_init_slot($session)->{$prefix}B= get_init_slot($session)->{$prefix} == 0C= not $reload
| |||||||||||||||||||||||||||||||||||||||||||
| 287 | && not $reload; | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | # set number of async init jobs for proper initialization | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | get_init_slot($session)->{$prefix} = THIS_INIT_JOBS; | |||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | # populate the object with needed mib values | ||||||||||||||||||||||||||||||||||||||||||
| 293 | # | ||||||||||||||||||||||||||||||||||||||||||
| 294 | # initialize the object for inetCidrRouteTable infos | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | _fetch_inet_cidr_route_tbl($session); | |||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return if $session->error; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | =head1 PRIVATE METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | Only for developers or maintainers. | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =head2 B<< _fetch_inet_cidr_route_tbl($session) >> | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | Fetch the inetCidrRouteTable once during object initialization. | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub _fetch_inet_cidr_route_tbl { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fetch_inet_cidr_route_tbl: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $result; | |||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | # fetch the inetCidrRouteTable | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $result = $session->get_table( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | -baseoid => INET_CIDR_ROUTE_TABLE, | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | # define callback if in nonblocking mode | ||||||||||||||||||||||||||||||||||||||||||
| 320 | $session->nonblocking ? ( -callback => \&_inet_cidr_route_tbl_cb ) : (), | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | unless ( defined $result ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | if ( my $err_msg = $session->error ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | push_error( $session, "$prefix: $err_msg" ); | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | # in nonblocking mode the callback will be called asynchronously | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | return 1 if $session->nonblocking; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||
| 334 | # ok we are in synchronous mode, call the result mangling function | ||||||||||||||||||||||||||||||||||||||||||
| 335 | # by hand | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | _inet_cidr_route_tbl_cb($session); | |||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | =head2 B<< _inet_cidr_route_tbl_cb($session) >> | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | The callback for _fetch_inet_cidr_route_tbl(). | ||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||
| 344 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | sub _inet_cidr_route_tbl_cb { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_inet_cidr_route_tbl_cb: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | my $session = shift; | |||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my $vbl = $session->var_bind_list; | |||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | unless ( defined $vbl ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | ▶ | if ( my $err_msg = $session->error ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | push_error( $session, "$prefix: $err_msg" ); | |||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | # build parallel hashes, keys are the very complex table index, | ||||||||||||||||||||||||||||||||||||||||||
| 358 | # index OIDs are not extra populated with valus, | ||||||||||||||||||||||||||||||||||||||||||
| 359 | # | ||||||||||||||||||||||||||||||||||||||||||
| 360 | # INET_CIDR_ROUTE_DEST_TYPE => '1.3.6.1.2.1.4.24.7.1.1', # index, InetAddressType | ||||||||||||||||||||||||||||||||||||||||||
| 361 | # INET_CIDR_ROUTE_DEST => '1.3.6.1.2.1.4.24.7.1.2', # index, InetAddress | ||||||||||||||||||||||||||||||||||||||||||
| 362 | # INET_CIDR_ROUTE_PFXLEN => '1.3.6.1.2.1.4.24.7.1.3', # index, InetAddressPrefixLength | ||||||||||||||||||||||||||||||||||||||||||
| 363 | # INET_CIDR_ROUTE_POLICY => '1.3.6.1.2.1.4.24.7.1.4', # index, OID | ||||||||||||||||||||||||||||||||||||||||||
| 364 | # INET_CIDR_ROUTE_NEXTHOP_TYPE => '1.3.6.1.2.1.4.24.7.1.5', # index, InetAddressType | ||||||||||||||||||||||||||||||||||||||||||
| 365 | # INET_CIDR_ROUTE_NEXTHOP => '1.3.6.1.2.1.4.24.7.1.6', # index, InetAddress | ||||||||||||||||||||||||||||||||||||||||||
| 366 | # | ||||||||||||||||||||||||||||||||||||||||||
| 367 | # split the index for these values in get_inet_cidr_route_table() | ||||||||||||||||||||||||||||||||||||||||||
| 368 | # | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | $session->{$prefix}{inetCidrRouteIfIndex} = | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_IFINDEX, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | $session->{$prefix}{inetCidrRouteType} = | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_TYPE, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | $session->{$prefix}{inetCidrRouteProto} = | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_PROTO, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | $session->{$prefix}{inetCidrRouteAge} = | ||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_AGE, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | $session->{$prefix}{inetCidrRouteNextHopAS} = | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_NEXTHOPAS, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | $session->{$prefix}{inetCidrRouteMetric1} = | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_METRIC1, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | $session->{$prefix}{inetCidrRouteMetric2} = | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_METRIC2, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | $session->{$prefix}{inetCidrRouteMetric3} = | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_METRIC3, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | $session->{$prefix}{inetCidrRouteMetric4} = | ||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_METRIC4, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | $session->{$prefix}{inetCidrRouteMetric5} = | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_METRIC5, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | $session->{$prefix}{inetCidrRouteStatus} = | ||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | idx2val( $vbl, INET_CIDR_ROUTE_STATUS, undef, undef, ); | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | foreach my $idx ( keys %{ $session->{$prefix}{inetCidrRouteIfIndex} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | # | ||||||||||||||||||||||||||||||||||||||||||
| 406 | # split the index for these values to get the values for prefix, next_hop and policy | ||||||||||||||||||||||||||||||||||||||||||
| 407 | # | ||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | my ( $rt_prefix, $zone, $next_hop, $policy ) = _split_idx( $session, $idx ); | |||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $session->{$prefix}{inetCidrRoutePrefix}{$idx} = $rt_prefix; | |||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $session->{$prefix}{inetCidrRouteZone}{$idx} = $zone; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | $session->{$prefix}{inetCidrRouteNextHop}{$idx} = $next_hop; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | $session->{$prefix}{inetCidrRoutePolicy}{$idx} = $policy; | |||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | # this init job is finished | ||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | get_init_slot($session)->{$prefix}--; | |||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | # type IPv4 | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # | len in bytes | ||||||||||||||||||||||||||||||||||||||||||
| 424 | # | | IP address destination, var len | ||||||||||||||||||||||||||||||||||||||||||
| 425 | # | | | Pfxlen destination | ||||||||||||||||||||||||||||||||||||||||||
| 426 | # | | | | OID, policy, var len | ||||||||||||||||||||||||||||||||||||||||||
| 427 | # | | | | | type | ||||||||||||||||||||||||||||||||||||||||||
| 428 | # | | | | | | len in bytes | ||||||||||||||||||||||||||||||||||||||||||
| 429 | # | | | | | | | IP address next hop, var len | ||||||||||||||||||||||||||||||||||||||||||
| 430 | # | | | | | | | | | ||||||||||||||||||||||||||||||||||||||||||
| 431 | # 1.4.10.96.2.0.24.2.0.0.1.4.134.60.112.246 | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | # type IPv6 | ||||||||||||||||||||||||||||||||||||||||||
| 434 | # | len in bytes | ||||||||||||||||||||||||||||||||||||||||||
| 435 | # | | IP address destination, var len | ||||||||||||||||||||||||||||||||||||||||||
| 436 | # | | | Pfxlen destination | ||||||||||||||||||||||||||||||||||||||||||
| 437 | # | | | | OID, policy, var len | ||||||||||||||||||||||||||||||||||||||||||
| 438 | # | | | | | type | ||||||||||||||||||||||||||||||||||||||||||
| 439 | # | | | | | | len in bytes | ||||||||||||||||||||||||||||||||||||||||||
| 440 | # | | | | | | | IP address next hop, var len | ||||||||||||||||||||||||||||||||||||||||||
| 441 | # | | | | | | | | | ||||||||||||||||||||||||||||||||||||||||||
| 442 | # 2.16.32.1.7.192.0.3.161.11.0.0.0.0.0.0.0.0.127.2.0.0.2.16.254.128.0.0.0.0.0.0.78.119.109.255.254.212.255.135 | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | # type IPv6z | ||||||||||||||||||||||||||||||||||||||||||
| 445 | # | len in bytes | ||||||||||||||||||||||||||||||||||||||||||
| 446 | # | | IP address destination, var len | ||||||||||||||||||||||||||||||||||||||||||
| 447 | # | | | Pfxlen destination | ||||||||||||||||||||||||||||||||||||||||||
| 448 | # | | | | OID, policy, var len | ||||||||||||||||||||||||||||||||||||||||||
| 449 | # | | | | | type | ||||||||||||||||||||||||||||||||||||||||||
| 450 | # | | | | | | len in bytes | ||||||||||||||||||||||||||||||||||||||||||
| 451 | # | | | | | | | | ||||||||||||||||||||||||||||||||||||||||||
| 452 | # | | | | | | | | ||||||||||||||||||||||||||||||||||||||||||
| 453 | # 4.20.254.128.0.0.0.0.0.0.0.0.0.0.0.0.0.0.18.0.0.1.10.2.0.0.0.0 | ||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | sub _split_idx { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_idx: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | my ( $session, $idx ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | my @subs = split( /\./, $idx ); | |||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | my ( $t1, $t2, $dest, $nh, $pfx_len, $policy, $size ); | |||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $t1 = shift @subs; | |||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $size = shift @subs; | |||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $dest = pack( 'C*', @subs[ 0 .. $size - 1 ] ); | |||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | @subs = @subs[ $size .. $#subs ]; | |||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | $pfx_len = shift @subs; | |||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $size = shift @subs; | |||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $policy = join( '.', @subs[ 0 .. $size - 1 ] ); | |||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | @subs = @subs[ $size .. $#subs ]; | |||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | $t2 = shift @subs; | |||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | $size = shift @subs; | |||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $nh = pack( 'C*', @subs[ 0 .. $size - 1 ] ); | |||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | my ( $rt_prefix, $zone, $next_hop ); | |||||||||||||||||||||||||||||||||||||||||
| 479 | |||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ( $rt_prefix, $zone ) = _get_addr( $session, $idx, $t1, $dest ); | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | ▶ | $rt_prefix = "$rt_prefix/$pfx_len" if defined $rt_prefix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ( $next_hop, undef ) = _get_addr( $session, $idx, $t2, $nh ); | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | return ( $rt_prefix, $zone, $next_hop, $policy ); | |||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | sub _get_addr { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_addr: not called CC=11 SCAR=42.7
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | my ( $session, $idx, $type, $n_bytes ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 490 | |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if ( $address_type_enum{$type} eq 'unknown' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | ▶ | my $len = do { use bytes; length($n_bytes) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | push_error( $session, "$prefix: address-type and -value mismatch in '$idx'" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 494 | if $len != 0; | ||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 496 | } | ||||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | if ( $address_type_enum{$type} eq 'ipv4' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | my $len = do { use bytes; length($n_bytes) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | push_error( $session, "$prefix: address-type and -value mismatch in '$idx'" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | if $len != 4; | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $ip_addr = inet_ntop( AF_INET, $n_bytes ); | |||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | return $ip_addr; | |||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | ▶ | if ( $address_type_enum{$type} eq 'ipv6' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | my $len = do { use bytes; length($n_bytes) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | push_error( $session, "$prefix: address-type and -value mismatch in '$idx'" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | if $len != 16; | ||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my $ip_addr = inet_ntop( AF_INET6, $n_bytes ); | |||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | return $ip_addr; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | # addrs with zones suffix | ||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | ▶ | if ( $address_type_enum{$type} eq 'ipv4z' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | my $len = do { use bytes; length($n_bytes) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | push_error( $session, "$prefix: address-type and -value mismatch in '$idx'" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 520 | if $len != 8; | ||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | my $ip_n = substr( $n_bytes, 0, 4 ); | |||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | my $zone_n = substr( $n_bytes, 4, 4 ); | |||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my $ip_addr = inet_ntop( AF_INET, $ip_n ); | |||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $zone = inet_ntop( AF_INET, $zone_n ); | |||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | return ( $ip_addr, $zone ); | |||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if ( $address_type_enum{$type} eq 'ipv6z' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | my $len = do { use bytes; length($n_bytes) }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | push_error( $session, "$prefix: address-type and -value mismatch in '$idx'" ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 534 | if $len != 20; | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $ip_n = substr( $n_bytes, 0, 16 ); | |||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $zone_n = substr( $n_bytes, 16, 4 ); | |||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $ip_addr = inet_ntop( AF_INET6, $ip_n ); | |||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | my $zone = inet_ntop( AF_INET, $zone_n ); | |||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | return ( $ip_addr, $zone ); | |||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | push_error( $session, "$prefix: unknown address-type '$type' in '$idx'" ); | |||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||||||||||||||||
| 549 | 4 | ▶ | unless ( caller() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | print "$prefix compiles and initializes successful.\n"; | |||||||||||||||||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | L<< Net::SNMP::Mixin >> | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | =head1 REQUIREMENTS | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | L<< Net::SNMP >>, L<< Net::SNMP::Mixin >> | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | =head1 BUGS, PATCHES & FIXES | ||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | There are no known bugs at the time of this release. However, if you spot a bug or are experiencing difficulties that are not explained within the POD documentation, please submit a bug to the RT system (see link below). However, it would help greatly if you are able to pinpoint problems or even supply a patch. | ||||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | Fixes are dependant upon their severity and my availablity. Should a fix not be forthcoming, please feel free to (politely) remind me by sending an email to gaissmai@cpan.org . | ||||||||||||||||||||||||||||||||||||||||||
| 566 | |||||||||||||||||||||||||||||||||||||||||||
| 567 | RT: http://rt.cpan.org/Public/Dist/Display.html?Name=Net-SNMP-Mixin-InetCidrRouteTable | ||||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||
| 572 | Karl Gaissmaier <karl.gaissmaier at uni-ulm.de> | ||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||
| 576 | Copyright 2019 Karl Gaissmaier, all rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||||||||||||
| 579 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||
| 581 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | # vim: sw=2 | ||||||||||||||||||||||||||||||||||||||||||