[LWN Logo]

Date:	Tue, 19 Jan 1999 18:44:51 +0200
From:	"Sergey V. Kolychev" <ksv@GW.AL.LG.UA>
Subject:      ANNOUNCE: Net::RawIP 0.03 released
To:	BUGTRAQ@NETSPACE.ORG

 Good day.

 The perl module Net::RawIP 0.03 just released.I have announce in this list
 0.02b version.
 Thanks all for interest and suggestions.

 If you don't remember or don't knew about Net::RawIP before:

 Net::RawIP is a perl module can to manipulate raw IP packets,
 with an optional feature for manipulating Ethernet headers.

 Net::RawIP can be used for easy writing low level programms
 which can manipulate raw IP packets directly from Perl.

 Changes from 0.02b to 0.03:
  - port to Linux with libc5
  - port to Alpha Linux
  - port to Solaris
  - port to FreeBSD
  - fix memory leaks
  - fix problems with gcc 2.7.2.1
  - implemented manipulate IP and TCP options

Homepage of Net::RawIP: http://quake.skif.net/RawIP/

Just one small example.

ipopt_traceroute.pl
-----------------------
#!/usr/bin/perl
# This script use IP option called "record route" for emulate traceroute.
# Unfortunately max size of ip options is only 40 bytes and we can see
# just 9 hops, other hops will be ignored ;(

use Net::RawIP;
require 'getopts.pl';
Getopts('i:s:d:');
die "Usage $0 -i <interface> -d <dest host> -s <your host>"
unless ($opt_d && $opt_d && $opt_s);
$a = new Net::RawIP ({icmp =>{}});
$a->set({ip => {saddr => $opt_s,
                daddr => $opt_d},
         icmp => {type => 8, id => $$}
         });
$data = "\5".("\0" x 37);
$a->optset(ip => {type => [(7)],data =>[($data)] });
$device = $opt_i;
$filt = "ip proto \\icmp and dst host $opt_s";
$size = 1500;
$tout = 30;
$pcap = $a->pcapinit($device,$filt,$size,$tout);
$i =0;
if(fork){
        loop $pcap,1,\&dmp,\@a;
}
else{
     sleep 1;
     $a->set({icmp => {sequence => $i,data => timem()}});
     $a->send(1,1);
}
sub dmp{
  $a->bset(substr($_[2],14));
  $opt = ($a->optget(ip => {type => [(7)] } ))[2];
  $opt = substr($opt,2);
  @route = unpack("N9",$opt);
  $j = 0;
  for $site (@route){
                     last unless $site;
                     printf(" -> ") if $j;
                     printf("\n") if $j == 4;
                     printf("%u.%u.%u.%u",unpack("C4",pack("N",$site)));
                     $j++;
                    }
 printf("\n");
}
--------------------


I'll be glad if you find my work interesting.


   ----------------------Alchevsk Linux User Group-----------------------
      UNIX is user friendly. It's just selective who the friends are.
      Linux is like wigwam - no windows, no gates, apache inside.
      http://www.ic.al.lg.ua/~ksv | e-mail: ksv@gw.al.lg.ua
      PGP key & Geekcode: finger ksv@gw.al.lg.ua