NetPacket::SLL(3pm)

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

πŸ’… 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:


πŸ’œ 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 other NetPacket::* modules. It's literally equivalent to creating an object with the decode() constructor and grabbing the data field 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.

🌈 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 function sll_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 (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