NetPacket::SLL2(3pm)
β¨ NAME β¨
hey bestie π this is NetPacket::SLL2(3pm) from the User Contributed Perl Documentation, and it's here to help you assemble and disassemble Linux cooked capture (SLL2) packets. no cap, it's giving niche-but-iconic. β¨
πΈ VERSION πΈ
version 1.8.0 β that's the version, bestie. π
π¦ SYNOPSIS π¦
use NetPacket::SLL2;
my $sll_obj = NetPacket::SLL2->decode($raw_pkt);
my $sll_pkt = $sll_obj->encode();
my $sll_data = NetPacket::SLL2::strip($raw_pkt);
π DESCRIPTION π
NetPacket::SLL2 gives you a whole little set of routines for assembling and disassembling packets using Linux cooked capture (libpcap SLL2). Linux cooked capture is a pseudo-link-layer that libpcap uses when it's capturing packets on the "any" device β because those packets may have different link layer headers, bestie β or when the native link layer headers can't be used. it's giving "we made a flexible little container for chaos." π
for more details on the SLL2 protocol, peek at https://gitlab.com/wireshark/wireshark/-/wikis/SLL and https://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html. π¦
π Methods π
NetPacket::SLL2->decode([RAW PACKET])β decodes the raw packet data you give it and returns an object containing instance data. okay so real talk: this method will quite happily decode garbage input π. it is the responsibility of the programmer to ensure valid packet data is passed to this method. no vibes-based packet validation here, bestie.$sll_obj->encode()β returns an SLL2 packet encoded with the instance data specified. slay, it puts the little packet back together. β¨
π§ Functions π§
NetPacket::SLL2::strip([RAW PACKET])β returns the encapsulated data (or payload) contained in the SLL2 packet. this data is suitable to be used as input for otherNetPacket::*modules. it's literally the payload bestie, ready to hand off. π«Ά
this function is equivalent to creating an object using the decode() constructor and returning the data field of that object. iykyk. π
π Instance data π
the instance data for the NetPacket::SLL2 object consists of the following fields. periodt.
protoβ the protocol type for the packet. usually an ethernet protocol type, but the meaning depends on the device type as described athttps://www.tcpdump.org/linktypes/LINKTYPE_LINUX_SLL2.html. π¦interfaceβ the 1-based index of the interface this packet was observed on. yes, 1-based, not 0-based β stay strong. πhtypeβ the device type as a Linux ARP hardware type (https://www.iana.org/assignments/arp-parameters/arp-parameters.xhtml). πtypeβ the SLL packet type. the vibes are:
# 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.
src_addrβ up to the first 8 bytes of the source link-layer address for this packet as a hex string. hex string bestie, not a whole address novel. π₯dataβ the encapsulated data (payload) for this SLL2 packet. the main character payload, honestly. π
π Exports π
defaultβ none.tagsβ the following tags group together related exportable items.:typesβ re-exported fromNetPacket::SLLfor convenience.:stripβ import the strip functionsll2_strip.:ALLβ all the above exportable items.
π EXAMPLE π
the following script prints the source address, device type, and protocol type of each packet to standard output. cute, useful, iconic. π
#!/usr/bin/perl
use strict;
use warnings;
use Net::PcapUtils;
use NetPacket::SLL2;
sub process_pkt {
my ($user, $hdr, $pkt) = @_;
my $sll_obj = NetPacket::SLL2->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. no fake promises, bestie. π«Ά
π AUTHOR π
Dan Book <dbook@cpan.org> β author icon, periodt. π
okay bye bestie ππ«Ά this page was made with perl v5.40.1, dated 2026-02-20, and it's the NetPacket::SLL2(3pm) show. mwah πβ¨
π¦ 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