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

I am using the perl module Net::RawIP, i wanted to know what they are doing in the routine send_eth_packet, I found that it was bootstrap-ed, and I able to find RawIP.so, but I want to see the C code of this routine send_eth_packet.
I searched in perlmonks, there was some link in the thread Net::RawIp and it seems to be obsolete now, can you help me to view the C source code of send_eth_packet (possibly the entire C source code of RawIP.so).

Vivek
-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

Replies are listed 'Best First'.
Re: Net::RawIP question
by locked_user sundialsvc4 (Abbot) on Mar 05, 2009 at 16:57 UTC

    The source-code to any CPAN package will probably be found in the .cpan/build directory (note the leading period, indicating a hidden directory or file) once you have installed the package.

    For instance:   find ~/.cpan -iname \*RawIP\*

    (Gee, I do know it by heart...!)

      I found an XS file /root/.cpan/build/Net-RawIP-0.25/RawIP.xs
      It contains this definition for the routine
      void send_eth_packet(fd,eth_device,pkt,flag) int fd char* eth_device SV* pkt int flag CODE: send_eth_packet(fd, eth_device, (char*)SvPV(pkt,PL_na), SvCUR(pkt) +,flag);
      but here too I am missing the actual code of the C function
      UPDATE
      I got some C code from this file http://search.cpan.org/CPAN/authors/id/S/SA/SAPER/Net-RawIP-0.25.tar.gz
      thanks.

      Vivek
      -- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
Re: Net::RawIP question
by kennethk (Abbot) on Mar 05, 2009 at 17:02 UTC
    Alternatively to what sundialsvc4 says, you could also download the tarball directly from the cpan page, for example here. This will work if you want to examine source before install.
Re: Net::RawIP question
by locked_user sundialsvc4 (Abbot) on Mar 05, 2009 at 19:23 UTC

    “Ahh, padewan, these are truly the Deep Mysteries of Perl! Must you venture hither?” The small little man tapped his cane meaningfully against the ground. “Many pilgrims before you have trod this ground before you, and all of them now have male pattern baldness... and Band-Aids® upon their foreheads!”

    Yes, what you are looking at is a preprocessor input-file. But perhaps you can glean the insights that you need to know from what you have, without delving into how it is made. Also, the search.cpan.org website contains easy links to the source-code of any package, right there on the appropriate web page. If your quest is only for answers, perhaps you can discern what you need to know even from these...