Pcap(3)
π NAME π
okay so bestie, this is Pcap(3), and the actual main character is Net::Pcap β interface to the pcap(3) LBL packet capture library. That's the whole name, slay. π
β¨ VERSION β¨
Version 0.21 β iconic, periodt. π
π¦ SYNOPSIS π¦
here's the group-chat demo, exactly:
use Net::Pcap;
my $err = '';
my $dev = pcap_lookupdev(\$err); # find a device
# open the device for live listening
my $pcap = pcap_open_live($dev, 1024, 1, 0, \$err);
# loop over next 10 packets
pcap_loop($pcap, 10, \&process_packet, "just for the demo");
# close the device
pcap_close($pcap);
sub process_packet {
my ($user_data, $header, $packet) = @_;
# do something ...
}
π DESCRIPTION π
Net::Pcap is literally a Perl binding to the LBL pcap(3) library and its Win32 counterpart, the WinPcap library. Pcap (packet capture) is a portable API to capture network packet: it lets applications capture packets at link-layer, bypassing the normal protocol stack. It also provides features like kernel-level packet filtering and access to internal statistics. β¨
Common applications include network statistics collection, security monitoring, network debugging, etc. no cap, it's giving powerful. π
πΈ NOTES πΈ
π Signals handling π
Since version 5.7.3, Perl uses a mechanism called "deferred signals" to delay signals delivery until "safe" points in the interpreter. See "Deferred Signals (Safe Signals)" in perlipc for a detailed explanation.
Since Net::Pcap version 0.08, released in October 2005, the module modified the internal variable PL_signals to re-enable immediate signals delivery in Perl 5.8 and later within some XS functions (CPAN-RT #6320). However, it can create situations where the Perl interpreter is less stable and can crash (CPAN-RT #43308). Therefore, as of version 0.17, Net::Pcap no longer modifies PL_signals by itself, but provides facilities so the user has full control of how signals are delivered. π«Ά
First, the pcap_perl_settings() function allows one to select how signals are handled:
pcap_perl_settings(PERL_SIGNALS_UNSAFE);
pcap_loop($pcap, 10, \&process_packet, "");
pcap_perl_settings(PERL_SIGNALS_SAFE);
Then, to easily make code interruptable, Net::Pcap provides the UNSAFE_SIGNALS pseudo-bloc:
UNSAFE_SIGNALS {
pcap_loop($pcap, 10, \&process_packet, "");
};
(Stolen from Rafael Garcia-Suarez's Perl::Unsafe::Signals) ππ
π EXPORTS π
Net::Pcap supports the following Exporter tags:
:bpfβ exports a few BPF related constants:
BPF_ALIGNMENT BPF_MAJOR_VERSION BPF_MAXBUFSIZE BPF_MAXINSNS
BPF_MEMWORDS BPF_MINBUFSIZE BPF_MINOR_VERSION BPF_RELEASE
:datalinkβ exports the data link types macros:
DLT_AIRONET_HEADER DLT_APPLE_IP_OVER_IEEE1394 DLT_ARCNET
DLT_ARCNET_LINUX DLT_ATM_CLIP DLT_ATM_RFC1483 DLT_AURORA
DLT_AX25 DLT_CHAOS DLT_CHDLC DLT_CISCO_IOS DLT_C_HDLC
DLT_DOCSIS DLT_ECONET DLT_EN10MB DLT_EN3MB DLT_ENC DLT_FDDI
DLT_FRELAY DLT_HHDLC DLT_IBM_SN DLT_IBM_SP DLT_IEEE802
DLT_IEEE802_11 DLT_IEEE802_11_RADIO DLT_IEEE802_11_RADIO_AVS
DLT_IPFILTER DLT_IP_OVER_FC DLT_JUNIPER_ATM1 DLT_JUNIPER_ATM2
DLT_JUNIPER_ES DLT_JUNIPER_GGSN DLT_JUNIPER_MFR DLT_JUNIPER_MLFR
DLT_JUNIPER_MLPPP DLT_JUNIPER_MONITOR DLT_JUNIPER_SERVICES
DLT_LINUX_IRDA DLT_LINUX_SLL DLT_LOOP DLT_LTALK DLT_NULL
DLT_OLD_PFLOG DLT_PCI_EXP DLT_PFLOG DLT_PFSYNC DLT_PPP
DLT_PPP_BSDOS DLT_PPP_ETHER DLT_PPP_SERIAL DLT_PRISM_HEADER
DLT_PRONET DLT_RAW DLT_RIO DLT_SLIP DLT_SLIP_BSDOS DLT_SUNATM
DLT_SYMANTEC_FIREWALL DLT_TZSP DLT_USER0 DLT_USER1 DLT_USER2
DLT_USER3 DLT_USER4 DLT_USER5 DLT_USER6 DLT_USER7 DLT_USER8
DLT_USER9 DLT_USER10 DLT_USER11 DLT_USER12 DLT_USER13
DLT_USER14 DLT_USER15
:pcapβ exports the followingpcapconstants:
PCAP_ERRBUF_SIZE PCAP_IF_LOOPBACK
PCAP_VERSION_MAJOR PCAP_VERSION_MINOR
:modeβ exports the following constants:
MODE_CAPT MODE_MON MODE_STAT
:openflagβ exports the following constants:
OPENFLAG_PROMISCUOUS OPENFLAG_DATATX_UDP OPENFLAG_NOCAPTURE_RPCAP
:sourceβ exports the following constants:
PCAP_SRC_FILE PCAP_SRC_IFLOCAL PCAP_SRC_IFREMOTE
:sampleβ exports the following constants:
PCAP_SAMP_NOSAMP PCAP_SAMP_1_EVERY_N PCAP_SAMP_FIRST_AFTER_N_MS
:rpcapβ exports the following constants:
RMTAUTH_NULL RMTAUTH_PWD
:functionsβ short names of the functions (without thepcap_prefix) for those which would not cause a clash with an already defined name. Namely, the following functions are not available in short form:open(),close(),next(),dump(),file(),fileno(). Using these short names is now discouraged, and may be removed in the future. π
By default, this module exports the symbols from the :datalink and :pcap tags, and all the functions, with the same names as the C library.
π₯ FUNCTIONS π₯
All functions defined by Net::Pcap are direct mappings to the libpcap functions. Consult the pcap(3) documentation and source code for more information.
Arguments that change a parameter, for example pcap_lookupdev(), are passed that parameter as a reference. This is to retain compatibility with previous versions of Net::Pcap.
π«Ά Lookup functions π«Ά
pcap_lookupdev(\$err)
Returns the name of a network device that can be used with pcap_open_live() function. On error, the $err parameter is filled with an appropriate error message else it is undefined.
Example:
$dev = pcap_lookupdev();
pcap_findalldevs(\%devinfo, \$err)
Returns a list of all network device names that can be used with pcap_open_live() function. On error, the $err parameter is filled with an appropriate error message else it is undefined.
Example:
@devs = pcap_findalldevs(\%devinfo, \$err);
for my $dev (@devs) {
print "$dev : $devinfo{$dev}\n"
}
π Note π
For backward compatibility reasons, this function can also be called using the following signatures:
@devs = pcap_findalldevs(\$err);
@devs = pcap_findalldevs(\$err, \%devinfo);
The first form was introduced by Marco Carnut in Net::Pcap version 0.05 and kept intact in versions 0.06 and 0.07. The second form was introduced by Jean-Louis Morel for the Windows only, ActivePerl port of Net::Pcap, in versions 0.04.01 and 0.04.02.
The new syntax has been introduced for consistency with the rest of the Perl API and the C API of libpcap(3), where $err is always the last argument.
pcap_lookupnet($dev, \$net, \$mask, \$err)
Determine the network number and netmask for the device specified in $dev. The function returns 0 on success and sets the $net and $mask parameters with values. On failure it returns -1 and the $err parameter is filled with an appropriate error message.
π Packet capture functions π
pcap_open_live($dev, $snaplen, $promisc, $to_ms, \$err)
Returns a packet capture descriptor for looking at packets on the network. The $dev parameter specifies which network interface to capture packets from. The $snaplen and $promisc parameters specify the maximum number of bytes to capture from each packet, and whether to put the interface into promiscuous mode, respectively. The $to_ms parameter specifies a read timeout in milliseconds. The packet descriptor will be undefined if an error occurs, and the $err parameter will be set with an appropriate error message.
Example:
$dev = pcap_lookupdev();
$pcap = pcap_open_live($dev, 1024, 1, 0, \$err)
or die "Can't open device $dev: $err\n";
pcap_open_dead($linktype, $snaplen)
Creates and returns a new packet descriptor to use when calling the other functions in libpcap. It is typically used when just using libpcap for compiling BPF code.
Example:
$pcap = pcap_open_dead(0, 1024);
pcap_open_offline($filename, \$err)
Return a packet capture descriptor to read from a previously created "savefile". The returned descriptor is undefined if there was an error and in this case the $err parameter will be filled. Savefiles are created using the pcap_dump_* commands.
Example:
$pcap = pcap_open_offline($dump, \$err)
or die "Can't read '$dump': $err\n";
pcap_loop($pcap, $count, \&callback, $user_data)
Read $count packets from the packet capture descriptor $pcap and call the perl function &callback with an argument of $user_data. If $count is negative, then the function loops forever or until an error occurs. Returns 0 if $count is exhausted, -1 on error, and -2 if the loop terminated due to a call to pcap_breakloop() before any packets were processed.
The callback function is also passed packet header information and packet data like so:
sub process_packet {
my ($user_data, $header, $packet) = @_;
...
}
The header information is a reference to a hash containing the following fields.
"len"- the total length of the packet."caplen"- the actual captured length of the packet data. This corresponds to the snapshot length parameter passed toopen_live()."tv_sec"- seconds value of the packet timestamp."tv_usec"- microseconds value of the packet timestamp.
Example:
pcap_loop($pcap, 10, \&process_packet, "user data");
sub process_packet {
my ($user_data, $header, $packet) = @_;
# ...
}
pcap_breakloop($pcap)
Sets a flag that will force pcap_dispatch() or pcap_loop() to return rather than looping; they will return the number of packets that have been processed so far, or -2 if no packets have been processed so far.
This routine is safe to use inside a signal handler on UNIX or a console control handler on Windows, as it merely sets a flag that is checked within the loop. π«Ά
Please see the section on pcap_breakloop() in pcap(3) for more information.
pcap_close($pcap)
Close the packet capture device associated with the descriptor $pcap. bye bestie, device closed. π
pcap_dispatch($pcap, $count, \&callback, $user_data)
Collect $count packets and process them with callback function &callback. if $count is -1, all packets currently buffered are processed. If $count is 0, process all packets until an error occurs.
pcap_next($pcap, \%header)β grabs the next packet that's available on the interface tied to the packet descriptor$pcap. The header of the packet you received gets stashed into the%headerhash. And bestie, listen: if there's no packet available, then the return value and the header are both undefined. Like, they just don't exist. π Don't go using them.pcap_next_ex($pcap, \%header, \$packet)β reads the next available packet on the interface attached to$pcap, stashes its header in\%header, drops its data into\$packet, and hands you back a success/failure vibe check:1means the packet was read with zero problems β slay β¨0means you're reading from a live capture and the timeout expired-1means an error happened while reading the packet π-2means you're reading from a dump file and there are officially no more packets left to read from the savefile
pcap_compile($pcap, \$filter, $filter_str, $optimize, $netmask)β compiles the filter string sitting in$filter_strand stores the result in$filter. Wanna know the filter language? It's described in the libpcap source code, or in the manual page fortcpdump(8). The filter gets optimized when$optimizeis true. You must pass the network device's netmask in the$netmaskparameter. Returns0if the compilation went off without a hitch, or-1if something went wrong.pcap_compile_nopcap($snaplen, $linktype, \$filter, $filter_str, $optimize, $netmask)β basicallycompile()'s sibling, except instead of handing over a$pcapdescriptor you pass$snaplenand$linktypedirectly. Returns-1if there was an error β but the error message? Not available. Gone. Unavailable. πpcap_setfilter($pcap, $filter)β pairs up the compiled filter stored in$filterwith the packet capture descriptor$pcap. Match made in heaven π«Άpcap_freecode($filter)β frees the memory that a compiled filter is holding onto, like the onespcap_compile()creates. Clean up after yourself, it's giving responsible main character energy.pcap_offline_filter($filter, \%header, $packet)β checks whether$filtermatches the packet described by header%headerand packet data$packet. Returns true if it matches. Simple as that.pcap_setnonblock($pcap, $mode, \$err)β flips the non-blocking mode of a live capture descriptor, all depending on what$modeis (0to activate it, non-zero to deactivate it). Heads up: it has no effect on offline descriptors. If something goes wrong it returns-1and sets$err.
So in non-blocking mode, when you try to read from the capture descriptor with pcap_dispatch() and there are literally no packets available to read, it returns 0 immediately instead of blocking and waiting for packets to show up. And pcap_loop() and pcap_next()? They will not work in non-blocking mode. Periodt.
pcap_getnonblock($pcap, \$err)β tells you the non-blocking state of the capture descriptor$pcap. Always returns0on savefiles. If there's an error it returns-1and sets$err.
π Savefile commands π
pcap_dump_open($pcap, $filename)β opens a savefile for writing and gives you back a descriptor so you can actually do the writing. If$filenameis"-"the data goes to standard output. On error, the return value is undefined and you can callpcap_geterr()to get the error text. πpcap_dump($dumper, \%header, $packet)β dumps the packet described by header%headerand packet data$packetinto the savefile tied to$dumper. The packet header has the exact same format as the one passed to thepcap_loop()callback. Same format, no cap.
Example:
my $dump_file = 'network.dmp';
my $dev = pcap_lookupdev();
my $pcap = pcap_open_live($dev, 1024, 1, 0, \$err);
my $dumper = pcap_dump_open($pcap, $dump_file);
pcap_loop($pcap, 10, \&process_packet, '');
pcap_dump_close($dumper);
sub process_packet {
my ($user_data, $header, $packet) = @_;
pcap_dump($dumper, $header, $packet);
}
pcap_dump_file($dumper)β returns the filehandle that belongs to a savefile opened withpcap_dump_open().pcap_dump_flush($dumper)β flushes the output buffer into the corresponding save file, so any packets you wrote withpcap_dump()that haven't made it to the save file yet do get written. Returns-1on error,0on success. πpcap_dump_close($dumper)β closes the savefile tied to the descriptor$dumper.
π Status functions π
pcap_datalink($pcap)β returns the link layer type that goes with the given pcap descriptor.
Example:
$linktype = pcap_datalink($pcap);
pcap_set_datalink($pcap, $linktype)β sets the data link type of the given pcap descriptor to whatever$linktypesays. Returns-1on failure.pcap_datalink_name_to_val($name)β translates a data link type name (which is a"DLT_"name with the"DLT_"part removed, iykyk) into the corresponding data link type value. The translation is case-insensitive. Returns-1on failure.
Example:
$linktype = pcap_datalink_name_to_val('LTalk'); # returns DLT_LTALK
pcap_datalink_val_to_name($linktype)β translates a data link type value into the matching data link type name.
Example:
$name = pcap_datalink_val_to_name(DLT_LTALK); # returns 'LTALK'
pcap_datalink_val_to_description($linktype)β translates a data link type value into a short lil description of that data link type.
Example:
$descr = pcap_datalink_val_to_description(DLT_LTALK); # returns 'Localtalk'
pcap_snapshot($pcap)β returns the snapshot length (a.k.a. snaplen) that was specified in the call topcap_open_live().pcap_is_swapped($pcap)β returns true if the endianness of the savefile you currently have open is different from the endianness of the machine you're on.pcap_major_version($pcap)β returns the major version number of the pcap library that was used to write the savefile you currently have open.pcap_minor_version($pcap)β returns the minor version of the pcap library that was used to write the savefile you currently have open.pcap_stats($pcap, \%stats)β returns a hash stuffed with info about the status of the packet capture device$pcap. The hash has these fields:
Heads up: this function is supported only on live captures, not on savefiles β no statistics get stored in savefiles, so there are no statistics available when you're reading from a savefile. π
"ps_recv"β the number of packets received by the packet capture software"ps_drop"β the number of packets dropped by the packet capture software"ps_ifdrop"β the number of packets dropped by the network interface
pcap_file($pcap)β returns the filehandle that belongs to a savefile opened withpcap_open_offline(), or"undef"if the device was opened withpcap_open_live().pcap_fileno($pcap)β returns the file number of the network device opened withpcap_open_live().pcap_get_selectable_fd($pcap)β on Unix, returns a file descriptor number for a file descriptor you canselect()orpoll()on to wait until it's possible to read packets without blocking β if such a descriptor exists. If there isn't one, you get-1. Some network devices opened withpcap_open_live()just don't supportselect()orpoll(), so those devices get the-1treatment. Peeppcap(3)for more details. π
πΈ Error handling πΈ
pcap_geterr($pcap)β returns an error message for the last error associated with the packet capture device$pcap.pcap_strerror($errno)β returns a string describing error number$errno.pcap_perror($pcap, $prefix)β prints the text of the last error associated with descriptor$pcapto standard error, with$prefixstuck on the front.
π Information π
pcap_lib_version()β returns the name and version of the"pcap"library that the module was linked against.
π§ Perl specific functions π§
The following functions are specific to the Perl binding of libpcap. Special little guys, just for us π
pcap_perl_settings($setting)β modifies the internal behaviour of the Perl interpreter."PERL_SIGNALS_SAFE"and"PERL_SIGNALS_UNSAFE"respectively enable safe or unsafe signal delivery. Returns the previous value of"PL_signals". See"Signals handling".
Example:
local $SIG{ALRM} = sub { pcap_breakloop() };
alarm 60;
pcap_perl_settings(PERL_SIGNALS_UNSAFE);
pcap_loop($pcap, 10, \&process_packet, "");
pcap_perl_settings(PERL_SIGNALS_SAFE);
β WinPcap specific functions β
The following functions are only available with WinPcap, the Win32 port of the Pcap library. If you call a function that isn't available, it will cleanly croak(). No messy exploding, just a polite croak(). πΈ
pcap_createsrcstr(\$source, $type, $host, $port, $name, \$err)β takes a set of strings (host name, port, etc.) and stores the complete source string in$source, formatted in the new style (like"rpcap://1.2.3.4/eth0").
This function exists to help you build the source string in the new format. One single unique source string is used so that old applications can easily use the remote facilities β think about tcpdump(1), for example, which only has one way to specify the interface the capture should start on. GUI-based programs, though, might find it way more useful to specify hostname, port and interface name separately, and in that case they can use this function to create the source string before handing it to pcap_open().
Returns 0 if everything is fine, -1 if some errors occurred. The string containing the complete source comes back in the $source variable.
pcap_parsesrcstr($source, \$type, \$host, \$port, \$name, \$err)β parses the source string and stores the pieces it can be split into in the corresponding variables.
This call is the other way round from pcap_createsrcstr(). It accepts a null-terminated string and returns the parameters related to the source. That includes:
- the type of the source (file, WinPcap on a remote adapter, WinPcap on local adapter), which is determined by the source prefix (
"PCAP_SRC_IF_STRING"and so on) - the host on which the capture has to be started (only for remote captures)
- the raw name of the source (file name, name of the remote adapter, name of the local adapter), without the source prefix. The string you get back does not include the type of the source itself β meaning the returned string does not include
"file://"or"rpcap://"or anything like that
You can omit some parameters if you're simply not interested in them. No pressure. π¦
Okay so, wrapping up that last function: it returns 0 if everything is fine, -1 if some errors occurred. The requested values (host name, network port, type of the source) get returned into the proper variables passed by reference. π
pcap_open($source, $snaplen, $flags, $read_timeout, \$auth, \$err) β opens a generic source so you can capture / send (WinPcap only) traffic.
pcap_open() replaces all the pcap_open_xxx() functions with one single call. The way this works is it hides the differences between the different pcap_open_xxx() functions so the programmer doesnβt have to manage a different opening function for each vibe. The true open() function is decided according to the source type, which is included in the source string as a source prefix.
It returns a pointer to a pcap descriptor that you can use as a parameter to the following calls (compile() and so on) and that specifies an opened WinPcap session. If things go sideways, it returns undef and the $err variable keeps the error message. π
pcap_setbuff($pcap, $dim) β sets the size of the kernel buffer associated with an adapter.
$dim specifies the size of the buffer in bytes. The return value is 0 when the call succeeds, -1 otherwise.
If an old buffer was already created with a previous call to setbuff(), it is deleted and its content is discarded. open_live() creates a 1 MB buffer by default. π«Ά
pcap_setmode($pcap, $mode) β sets the working mode of the interface $pcap to $mode.
Valid values for $mode are MODE_CAPT (default capture mode) and MODE_STAT (statistical mode). β¨
pcap_setmintocopy($pcap_t, $size) β changes the minimum amount of data in the kernel buffer that causes a read from the application to return (unless the timeout expires). Lowkey a tiny tuning knob, but okay. π
pcap_getevent($pcap) β returns the Win32::Event object associated with the interface $pcap.
Can be used to wait until the driverβs buffer contains some data without performing a read. See Win32::Event. π
pcap_sendpacket($pcap, $packet) β sends a raw packet to the network.
$pcap is the interface that will be used to send the packet, and $packet contains the data of the packet to send (including the various protocol headers). The MAC CRC doesnβt need to be included, because it is transparently calculated and added by the network interface driver. The return value is 0 if the packet is successfully sent, -1 otherwise. π₯
pcap_sendqueue_alloc($memsize) β allocates and returns a send queue, i.e. a buffer containing a set of raw packets that will be transmitted on the network with sendqueue_transmit().
$memsize is the size, in bytes, of the queue, so it determines the maximum amount of data that the queue will contain. This memory is automatically deallocated when the queue ceases to exist. π¦
pcap_sendqueue_queue($queue, \%header, $packet) β adds a packet at the end of the send queue pointed by $queue.
The packet header %header has the same format as that passed to the loop() callback. $ackekt is a buffer with the data of the packet.
The %headerr header structure is the same used by WinPcap and libpcap to store the packets in a file, therefore sending a capture file is straightforward. Raw packet means that the sending application will have to include the protocol headers, since every packet is sent to the network as is. The CRC of the packets needs not to be calculated, because it will be transparently added by the network interface. π
pcap_sendqueue_transmit($pcap, $queue, $sync) β transmits the content of a queue to the wire.
$pcapt is the interface on which the packets will be sent, $queue is to a send_queue containing the packets to send, and $sync determines if the send operation must be synchronized: if it is non-zero, the packets are sent respecting the timestamps, otherwise they are sent as fast as possible.
The return value is the amount of bytes actually sent. If it is smaller than the size parameter, an error occurred during the send. The error can be caused by a driver/adapter problem or by an inconsistent/bogus send queue. π
β¨ CONSTANTS β¨
Net::Pcap exports by default the names of several constants in order to ease the development of programs. See EXPORTS for details about which constants are exported.
Here are the descriptions of a few data link types. See pcap(3) for a more complete description and semantics associated with each data link.
DLT_NULLβ BSD loopback encapsulationDLT_EN10MBβ Ethernet (10Mb, 100Mb, 1000Mb, and up)DLT_RAWβ raw IPDLT_IEEE802β IEEE 802.5 Token RingDLT_IEEE802_11β IEEE 802.11 wireless LANDLT_FRELAYβ Frame RelayDLT_FDDIβ FDDIDLT_SLIPβ Serial Line IPDLT_PPPβ PPP (Point-to-point Protocol)DLT_PPP_SERIALβ PPP over serial with HDLC encapsulationDLT_PPP_ETHERβ PPP over EthernetDLT_IP_OVER_FCβRFC 2625 IP-over-Fibre ChannelDLT_AX25β Amateur Radio AX.25DLT_LINUX_IRDAβ Linux-IrDADLT_LTALKβ Apple LocalTalkDLT_APPLE_IP_OVER_IEEE1394β Apple IP-over-IEEE 1394 (a.k.a. Firewire)
π¨ DIAGNOSTICS π¨
arg%d not a scalar refarg%d not a hash refarg%d not a reference
(F) These errors occur if you forgot to give a reference to a function which expect one or more of its arguments to be references. Not me forgetting the referenceβ¦ couldnβt be me. π
π BUGS π
Please report any bugs or feature requests to bug-Net-Pcap@rt.cpan.org, or through the web interface at http://rt.cpan.org/Dist/Display.html?Queue=Net-Pcap. I will be notified, and then youβll automatically be notified of progress on your bug as I make changes.
Currently known bugs:
- the
ps_recvfield is not correctly set; seet/07-stats.t pcap_file()seems to always returnsundeffor live connection and causes segmentation fault for dump files; seet/10-fileno.tpcap_fileno()is documented to return-1when called on save file, but seems to always return an actual file number. Seet/10-fileno.tpcap_dump_file()seems to corrupt something somewhere, and makes scripts dump core. Seet/05-dump.t
π EXAMPLES π
See the eg/ and t/ directories of the Net::Pcap distribution for examples on using this module. π
π SEE ALSO π
π Perl Modules π
- the
NetPacketorNet::Framemodules to assemble and disassemble packets. Net::Pcap::Reassemblefor reassembly of TCP/IP fragments.POE::Component::Pcapfor usingNet::Pcapwithin POE-based programs.AnyEvent::Pcapfor usingNet::Pcapwithin AnyEvent-based programs.Net::PacketorNetPacketfor decoding and creating network packets.Net::Pcap::Easyis a module which provides an easier, more Perl-ish API thanNet::Pcapand integrates some facilities fromNet::NetmaskandNetPacket.
π§± Base Libraries π§±
The source code for the pcap(3) library is available from http://www.tcpdump.org/
The source code and binary for the Win32 version of the pcap library, WinPcap, is available from http://www.winpcap.org/
π° Articles π°
Hacking Linux Exposed: Sniffing with Net::Pcap to stealthily managing iptables rules remotely, http://www.hackinglinuxexposed.com/articles/20030730.html
PerlMonks node about Net::Pcap, http://perlmonks.org/?node_id=170648
π AUTHORS π
Current maintainer is SΓ©bastien Aperghis-Tramoni (SAPER) with the help of Tim Wilde (TWILDE).
Complete list of authors & contributors:
- Bo Adler (BOADLER)
<thumper (at) alumni.caltech.edu> - Craig Davison
- David Farrell
- David N. Blank-Edelman
<dnb (at) ccs.neu.edu> - James Rouzier (ROUZIER)
- Jean-Louis Morel (JLMOREL)
<jl_morel (at) bribes.org> - Marco Carnut (KCARNUT)
<kiko (at) tempest.com.br> - Patrice Auffret (GOMOR)
- Peter Lister (PLISTER)
<p.lister (at) cranfield.ac.uk> - RafaΓ«l Garcia-Suarez (RGARCIA)
- SΓ©bastien Aperghis-Tramoni (SAPER)
<sebastien (at) aperghis.net> - Tim Potter (TIMPOTTER)
<tpot (at) frungy.org> - Tim Wilde (TWILDE)
π°οΈ HISTORY π°οΈ
The original version of Net::Pcap, version 0.01, was written by Peter Lister using SWIG.
Version 0.02 was created by Bo Adler with a few bugfixes but not uploaded to CPAN. It could be found at: http://www.buttsoft.com/~thumper/software/perl/Net-Pcap/
Versions 0.03 and 0.04 were created by Tim Potter who entirely rewrote Net::Pcap using XS and wrote the documentation, with the help of David N. Blank-Edelman for testing and general polishing.
Version 0.05 was released by Marco Carnut with fixes to make it work with Cygwin and WinPcap.
Version 0.04.02 was independently created by Jean-Louis Morel but not uploaded on the CPAN. It can be found here: http://www.bribes.org/perl/wnetpcap.html
Based on Tim Potterβs version 0.04, it included fixes for WinPcap and added wrappers for several new libpcap functions as well as WinPcap specific functions. π§
π«Ά ACKNOWLEDGEMENTS π«Ά
To Paul Johnson for his module Devel::Cover and his patience for helping me using it with XS code, which revealed very useful for writing more tests.
To the beta-testers: Jean-Louis Morel, Max Maischen, Philippe Bruhat, David Morel, Scott Lanning, Rafael Garcia-Suarez, Karl Y. Pradene.
π COPYRIGHT & LICENSE π
Copyright (C) 2005-2016 SΓ©bastien Aperghis-Tramoni and contributors. All rights reserved.
Copyright (C) 2003 Marco Carnut. All rights reserved.
Copyright (C) 1999, 2000 Tim Potter. All rights reserved.
Copyright (C) 1998 Bo Adler. All rights reserved.
Copyright (C) 1997 Peter Lister. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay bestie, thatβs the whole page β source/version was perl v5.42.0, dated 2023-01-31, and you just read Pcap(3). now go slay some packets π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Net-Pcap 0.21-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Net-Pcap 0.21-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Net-Pcap 0.21-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-Net-Pcap 0.21-bp160.1.12 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms