lkml.org 
[lkml]   [1997]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectroute-cache.pl [Re: 2.0.30/31-2 bug: ICMP redirect...]
#! /usr/bin/perl -w
# Author: Ulrik Dickow <ukd@kampsax.dk>, Feb & June 1997.
# Print the Linux kernel routing cache in a somewhat readable format,
# skipping blank lines and the direct host routes.
# This script will hopefully be obsoleted by the next release of net-tools
# (after net-tools-1.32-alpha).
#
use strict;

my $cache = "/proc/net/rt_cache";
my @fields;

open(CACHE, $cache) or die "Can't open $cache: $!";

while (<CACHE>) {
@fields = split;
next if $fields[1] eq $fields[2]; # Destination = Gateway
# Quick & dirty hack: just translate anything looking like a 32 bit hex
# number into dotted decimal notation (reverse byte order).
s/\b[0-9A-F]{8}\b/
sprintf "%d.%d.%d.%d", reverse unpack "C4", pack "H8", $& /eg;
# Only print the first 9 columns (up to & including MTU):
/(\S+\s+){8}\S+/ and print $& . "\n";
}

\
 
 \ /
  Last update: 2005-03-22 13:39    [W:0.027 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site