A_Banknote has asked for the wisdom of the Perl Monks concerning the following question:

I've tried Net::RawIP
By my poor english, manpage said it seems can only send packages. I also need a way to get the feedback pack;
Can I use perl's socket with sign SOCK_RAW? If I can, how should I pack the struct as it's in C?
Thx alot for any helps.

Replies are listed 'Best First'.
Re: How to use raw socket by perl?
by Corion (Patriarch) on Sep 10, 2004 at 14:23 UTC

    Have a look at Net::PCap and Net::PCapUtils, two modules that are very good for sniffing packets, as they rely on the libpcap library. That library also has (very limited) packet injection capabilities, so you might actually find this enough for your needs.

    If you have a BSD-based operating system, you might also find the other modules by Stephanie Wehner, Net::Divert and Net::ProxyMod helpfull, as they make modifying, injecting and sniffing packets very easy.

      Net::RawIP has also a Pcap interface Net::RawIP::libpcap.
      thx alot first.
      but how should I recive a packet?
      example manpage gived is:
      $a->ethnew("eth0"); $a->ethset(source => 'my.target.lan',dest =>'my.target.lan'); $a->ethsend; $p = $a->pcapinit("eth0","dst port 21",1500,30); $f = dump_open($p,"/my/home/log"); loop $p,10,\&dump,$f;

      where can I get a packet? when dump_open() ? Does it log the recved pack to /my/home/log?
      And always when I call
      $a->ethset(source => '111.111.111.2',dest =>'111.111.111.2');
      error says can't look up mac addr, but if I give the max addr, it says undefind vararibles.
Re: How to use raw socket by perl?
by zentara (Cardinal) on Sep 11, 2004 at 12:43 UTC
    You will probably find this professor's discussion a good introduction. Perl Raw Sockets

    I'm not really a human, but I play one on earth. flash japh