NetPacket::SLL2(3pm)

πŸ“¦
version 1.8.0 Β· 2 versions
, in ubuntu stonking

✨ 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 other NetPacket::* 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.

# 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 from NetPacket::SLL for convenience.
    • :strip β€” import the strip function sll2_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 (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