File: ipforward.pl

package info (click to toggle)
net-snmp 5.9.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 38,720 kB
  • sloc: ansic: 282,878; perl: 17,704; sh: 12,151; makefile: 2,711; python: 734; xml: 663; pascal: 62; sql: 47
file content (30 lines) | stat: -rw-r--r-- 974 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use SNMP;
$SNMP::use_enums = 1;

my $host = shift;
my $comm = shift;
$sess = new SNMP::Session(DestHost => $host, Community => $comm);

$vars = new SNMP::VarList( ['ipRouteIfIndex'], ['ipRouteType'],
                           ['ipRouteProto'], ['ipRouteMask'],
                           ['ipRouteNextHop'], ['ipRouteAge'],
			   ['ipRouteMetric1']);

format STDOUT_TOP =
  Destination      Next Hop          Mask       Proto    Age    Metric
--------------- --------------- -------------- ------- -------- ------
.

format STDOUT =
@<<<<<<<<<<<<<< @<<<<<<<<<<<<<< @<<<<<<<<<<<<< @|||||| @||||||| @|||||
$dest,          $nhop,          $mask,         $proto, $age,    $metric
.

for (($index,$type,$proto,$mask,$nhop,$age,$metric) = $sess->getnext($vars);
     $$vars[0]->tag eq 'ipRouteIfIndex' and not $sess->{ErrorStr};
     ($index,$type,$proto,$mask,$nhop,$age,$metric) = $sess->getnext($vars)) {
    $dest = $$vars[0]->iid;
    write;
}

print "$sess->{ErrorStr}\n";