NetPack...Ethernet(3)
β¨ NetPacket::Ethernet π
okay bestie, so this is the manual page for NetPacket::Ethernet, living in the User Contributed Perl Documentation corner of the perl v5.42.0 manual set. it's giving packet girlie energy and honestly? we ate. π
πΈ NAME πΈ
NetPacket::Ethernet β assemble and disassemble ethernet packets. that's it, that's the whole vibe. π¦
β VERSION β
version 1.8.0 β she's a lil vintage but she works, no cap. π
π SYNOPSIS π
use NetPacket::Ethernet;
$eth_obj = NetPacket::Ethernet->decode($raw_pkt);
$eth_pkt = NetPacket::Ethernet->encode(params...); # Not implemented
$eth_data = NetPacket::Ethernet::strip($raw_pkt);
okay so like, you use it, you decode a raw packet, you could encode one except not implemented (we'll get there, we'll get there π), and strip just yoinks the payload right out. iconic behaviour fr fr. β¨
π DESCRIPTION π
NetPacket::Ethernet hands you a whole set of routines for assembling and disassembling packets using the Ethernet protocol. it's your lil bestie for talking to the wire. π«Ά
π¦ Methods π¦
NetPacket::Ethernet->decode([RAW PACKET])β decode the raw packet data you hand over and return an object stuffed with instance data. and listen, bestie: this method will quite happily decode garbage input. like, it does not care. it has no standards. it will chew up trash and hand you back an object. so it is 100% the programmer's responsibility to make sure the packet data passed to this method is actually valid. do not come for her when you fed her nonsense. πNetPacket::Ethernet->encode(param => value)β return an ethernet packet encoded with the instance data you specified. Not implemented. yeah. that's the whole thing. she's a dream deferred. π
π Functions π
NetPacket::Ethernet::strip([RAW PACKET])β return the encapsulated data (or payload) that's sitting inside the ethernet packet. this data is suitable to be used as input for otherNetPacket::*modules, so it's basically the handoff queen. π
this function is equivalent to creating an object using the decode() constructor and returning the data field of that object. same thing, less typing. periodt.
π Instance data π
the instance data for the NetPacket::Ethernet object is made up of these fields:
src_macβ the source MAC address for the ethernet packet, as a hex string.dest_macβ the destination MAC address for the ethernet packet, as a hex string.typeβ the protocol type for the ethernet packet.dataβ the payload for the ethernet packet.
π§ Exports π§
defaultβ none. nothing. zero. the bare minimum. respect. πexportableβETH_TYPE_IPETH_TYPE_ARPETH_TYPE_APPLETALKETH_TYPE_SNMPETH_TYPE_IPv6ETH_TYPE_PPPtagsβ the following tags group together related exportable items::typesβETH_TYPE_IPETH_TYPE_ARPETH_TYPE_APPLETALKETH_TYPE_SNMPETH_TYPE_IPv6ETH_TYPE_PPP:stripβ import the strip functioneth_strip, which is an alias forNetPacket::Ethernet::strip:ALLβ all the above exportable items. the whole buffet. π₯
π EXAMPLE π
the following script dumps ethernet frames by mac address and protocol to standard output. she's a lil cutie, she just watches. π
#!/usr/bin/perl -w
use strict;
use Net::PcapUtils;
use NetPacket::Ethernet;
sub process_pkt {
my($arg, $hdr, $pkt) = @_;
my $eth_obj = NetPacket::Ethernet->decode($pkt);
print("$eth_obj->{src_mac}:$eth_obj->{dest_mac} $eth_obj->{type}\n");
}
Net::PcapUtils::loop(\&process_pkt);
π TODO π
implement encode() function. yes. that's the todo. it's just that. the whole list. one item. we're manifesting it. β¨
π COPYRIGHT π
Copyright (c) 2001 Tim Potter and Stephanie Wehner.
Copyright (c) 1995,1996,1997,1998,1999 ANU and CSIRO on behalf of the participants in the CRC for Advanced Computational Systems ('ACSys').
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.
π AUTHOR π
Tim Potter <tpot@samba.org> β ty king, we appreciate you. π«Ά
and that's the whole page bestie, no notes, go decode some packets π
this lil legend ships as part of perl v5.42.0, dated 2026-02-05 β mwah, kiss the manual page goodnight. ππ β¨
π¦ where this page comes from
- fedora 43: perl-NetPacket 1.8.0-1.fc43 Β· Artistic-2.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl)
- fedora 44: perl-NetPacket 1.8.0-1.fc44 Β· Artistic-2.0 AND (GPL-1.0-or-later OR Artistic-1.0-Perl)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms