NetPacket::SLL(3pm)
π NAME π
NetPacket::SLL β the manual page you're reading right now is from the Perl world (that's the 3pm part, bestie), and it's all about assembling and disassembling Linux cooked capture (SLL) packets. Yes. That's the whole vibe. π
β¨ VERSION β¨
version 1.8.0 β she's serving.
π¦ SYNOPSIS π¦
Like, here's the whole flow in three lines. Slay.
use NetPacket::SLL;
my $sll_obj = NetPacket::SLL->decode($raw_pkt);
my $sll_pkt = $sll_obj->encode();
my $sll_data = NetPacket::SLL::strip($raw_pkt);
πΈ DESCRIPTION πΈ
Okay so NetPacket::SLL hands you a whole little toolkit for assembling and disassembling packets using Linux cooked capture (that's libpcap SLL if you're being fancy). Linux cooked capture is a pseudo-link-layer β literally not a real link layer, it's giving cosplay π β and libpcap uses it when it's capturing packets on the "any" device (because those packets might have all different link layer headers, chaos!) or when the native link layer headers just can't be used.
If you want the actual lore, go read these two, they ate:
- <https://gitlab.com/wireshark/wireshark/-/wikis/SLL>
- <https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL.html>
π Methods π
NetPacket::SLL->decode([RAW PACKET])β decodes the raw packet data you give it and returns an object containing the instance data. Heads up though: this method will quite happily decode garbage input. Garbage in, garbage out, no cap. It is 100% the programmer's responsibility to make sure valid packet data is passed to this method. π$sll_obj->encode()β returns an SLL packet encoded with the instance data you specified. Iconic.
π§ Functions π§
NetPacket::SLL::strip([RAW PACKET])β returns the encapsulated data (aka the payload) contained in the SLL packet. This data is suitable to be used as input for otherNetPacket::*modules. It's literally equivalent to creating an object with the decode() constructor and grabbing thedatafield of that object. Same thing. Periodt.
π Instance data π
The instance data for the NetPacket::SLL object is made of these fields, bestie:
typeβ the SLL packet type. Here's the whole menu:
# SLL_TYPE_UNICAST
0, if the packet was specifically sent to us by somebody else;
# SLL_TYPE_BROADCAST
1, if the packet was broadcast by somebody else;
# SLL_TYPE_MULTICAST
2, if the packet was multicast, but not broadcast, by somebody else;
# SLL_TYPE_SENT_TO_OTHER
3, if the packet was sent to somebody else by somebody else;
# SLL_TYPE_SENT_BY_US
4, if the packet was sent by us.
htypeβ the device type as a Linux ARP hardware type <https://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml>.src_addrβ up to the first 8 bytes of the source link-layer address for this packet, as a hex string. β¨protoβ the protocol type for this packet. Usually it's an ethernet protocol type, but the meaning depends on the device type as described at <https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL.html>. Depends! On vibes! No β on the device type, sorry. πdataβ the encapsulated data (payload) for this SLL packet.
π Exports π
defaultβ none. Nothing. Zero. Zilch. You get nothing by default, bestie. πtagsβ the following tags group together related exportable items::types
SLL_TYPE_UNICAST SLL_TYPE_BROADCAST SLL_TYPE_MULTICAST
SLL_TYPE_SENT_TO_OTHER SLL_TYPE_SENT_BY_US
:stripβ import the strip functionsll_strip.:ALLβ all the above exportable items. The whole collection. The full set. π«Ά
β EXAMPLE β
This script prints the source address, device type, and protocol type of each packet to standard output. It's giving main character energy.
#!/usr/bin/perl
use strict;
use warnings;
use Net::PcapUtils;
use NetPacket::SLL;
sub process_pkt {
my ($user, $hdr, $pkt) = @_;
my $sll_obj = NetPacket::SLL->decode($pkt);
print("$sll_obj->{src_addr} $sll_obj->{htype} $sll_obj->{proto}\n");
}
Net::PcapUtils::loop(\&process_pkt);
π₯ COPYRIGHT π₯
Copyright (c) 2021 Dan Book.
This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.
This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. So like, don't come for her if it breaks, okay? π
π AUTHOR π
Dan Book <dbook@cpan.org>
That's the whole page, bestie. Go capture some packets. π
Signed off with love: this beauty is perl v5.40.1, dated 2026-02-20, and lives at NetPacket::SLL(3pm). Stan. π¦β¨
π¦ where this page comes from
- ubuntu stonking: libnetpacket-perl 1.8.0-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms