RawIP::libpcap(3pm)
π NAME π
Net::RawIP::libpcap β an interface to libpcap in Net::RawIP(3pm). And yeah, bestie, this page right here is RawIP::libpcap(3pm) β the Perl one, straight out of User Contributed Perl Documentation, and it is iconic. π
β¨ DESCRIPTION β¨
okay so the original here is one big vibe-table of functions, and every single one of them does the same lil dance: it takes input parameters, and it hands you back output parameters. That's the whole structure. So I'm gonna give each function its own moment, one by one, nothing skipped, no cap, because you deserve the full set. π
Which functions have an error scalar? The ones with $err. What does "less than zero" mean? Bad news. What does it mean when $err gets filled? You get an error string. That's the pattern, iykyk. π¦
πΈ open_live
Input parameters:
- a network device (
eth0,ppp0, ...) - a snap length
- a promisc β boolean
- a timeout in sec
$erris an undef scalar
Output parameters:
- Return value is a
pcap_t*. If retval less than zero then$errfilled with an error string.
πΈ open_offline
Input parameters:
- a filename which is filled with a raw output of dump
$erris an undef scalar
Output parameters:
- Return value is
pcap_t*. If retval less than zero then$errfilled with an error string.
πΈ dump_open
Input parameters:
pcap_t*$err
Output parameters:
- Return value is a
FILE*.
πΈ lookupdev
Input parameters:
$err
Output parameters:
- Return value is a name of first device which is found by
libpcap.
πΈ lookupnet
Input parameters:
- a network device
- a netnumber is undef
- a netmask is undef
$erris undef
Output parameters:
- a netnumber
- a netmask
- If retval less than zero then
$errfilled with an error string.
πΈ dispatch
Input parameters:
- a scalar with
pcap_t* - number of packets for processing
- reference to the perl callback β this callback will be called with 3 parameters:
$_[0]is fourth parameter fromdispatch$_[1]is a scalar with structurepcap_pkthdrfor a current packet$_[2]is a scalar with a current packet
- fourth parameter could be an array or a hash reference or a pointer (
FILE*) returned bydump_open, it can be unreferenced in the perl callback or be used as a perl filehandle in that callback
Output parameters:
- No output parameters.
πΈ loop
Input parameters:
- As for
dispatch.
Output parameters:
- As for
dispatch.
πΈ dump
Input parameters:
- As for a perl callback but
$_[0]must be a pointer (FILE*) only.
Output parameters:
- No output.
πΈ compile
Input parameters:
- a scalar with
pcap_t* - a
bpf_programis undef - a scalar with filter string
- a boolean value (optimize or not)
- a scalar with netmask
Output parameters:
- a scalar with
bpf_program - If retval is less than zero then there was a problem with filter grammar.
πΈ setfilter
Input parameters:
- a scalar with
pcap_t* - a scalar with
bpf_programreturned bycompile
Output parameters:
- If retval is less than zero then there was a problem while settting filter.
πΈ next
Input parameters:
- a scalar with
pcap_t* - a scalar with structure
pcap_pkthdrfor a current packet, originally is undef
Output parameters:
- A scalar with next packet
- a scalar with structure
pcap_pkthdralso will be modified for an every packet and it can be accessed but for read only.
πΈ datalink
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- Retval is the link layer type, e.g.
DLT_EN10MB.
πΈ snapshot
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- Retval is the snapshot length specified when
open_livewas called.
πΈ is_swapped
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- returns true if the current savefile uses a different byte order than the current system.
πΈ major_version
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- returns the major number of the version of the pcap used to write the savefile.
πΈ minor_version
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- returns the minor number of the version of the pcap used to write the savefile.
πΈ file
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- returns the name of the savefile.
πΈ stats
Input parameters:
- a scalar with
pcap_t* - a scalar with structure
pcap_stat, originally undef
Output parameters:
- If retval
0then a scalar with structurepcap_statwill be filled with the packet statistics.
πΈ fileno
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- returns the file descriptor number of the savefile.
- A core perl function is available as
CORE::fileno.
πΈ geterr
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- returns the error text pertaining to the last
pcaplibrary error.
πΈ perror
Input parameters:
- a scalar with
pcap_t* - a scalar with prefix
Output parameters:
- prints the text of the last
pcaplibrary error onstderr, prefixed by prefix.
πΈ close
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- closes the files associated with
pcap_t*and deallocates resources. - A core perl function is available as
CORE::close.
πΈ dump_close
Input parameters:
- a scalar with
pcap_t*
Output parameters:
- closes the savefile.
π AUTHOR π
Sergey Kolychev <ksv@al.lg.ua> β the actual main character who wrote all of this, we stan. π«Ά
π SEE ALSO π
Net::RawIP(3pm)pcap(3).
and that's the whole page, bestie, you read every single function, ate and left no crumbs π β¨
this whole thing shipped as perl v5.42.3, dated 2026-08-20, under the RawIP::libpcap(3pm) name β so when you're out here writing raw packets, remember who told you. mwah. πππ¦πΈ
π¦ where this page comes from
- ubuntu stonking: libnet-rawip-perl 0.25-4build2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms