Net::F...r::ETH(3pm)

πŸ“¦
version 1.21 Β· 2 versions
  • 1.21 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 1.21 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::Frame::Layer::ETH β€” the Ethernet/802.3 layer object, bestie edition πŸ’–

okay so this is Net::Frame::Layer::ETH from the Perl user-contributed docs, and it is literally the module that handles encoding and decoding of your Ethernet/802.3 layer. it's giving packet-crafting main character energy and we're obsessed πŸ¦‹


✨ NAME ✨

Net::Frame::Layer::ETH β€” Ethernet/802.3 layer object πŸŽ€


🌸 SYNOPSIS 🌸

bestie here's the whole vibe, copy-paste ready, no cap:

use Net::Frame::Layer::ETH qw(:consts);

# Build a layer
my $layer = Net::Frame::Layer::ETH->new(
   src  => '00:00:00:00:00:00',
   dst  => NF_ETH_ADDR_BROADCAST,
   type => NF_ETH_TYPE_IPv4,
);
$layer->pack;

print 'RAW: '.$layer->dump."\n";

# Read a raw layer
my $layer = Net::Frame::Layer::ETH->new(raw => $raw);

print $layer->print."\n";
print 'PAYLOAD: '.unpack('H*', $layer->payload)."\n"
   if $layer->payload;

build it, pack it, dump it, read it back, print it β€” the full lil lifecycle, periodt πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

This module implements the encoding and the decoding of the Ethernet/802.3 layer. that's the whole job, and it does it flawlessly, as it should πŸ‘‘

RFC: ftp://ftp.rfc-editor.org/in-notes/rfc894.txt β€” go read it, iykyk πŸ“œ

Also go look at Net::Frame::Layer for other attributes and methods, because this module inherits a lot from it 🫢


πŸ’… ATTRIBUTES πŸ’…

  • src, dst β€” source and destination MAC addresses, in the classical format (00:11:22:33:44:55). classic for a reason ✨
  • type β€” the encapsulated layer type (IPv4, IPv6 ...) for Ethernet. Values for Ethernet types are greater than 1500. If it's less than 1500, the layer is considered a 802.3 one. Check http://www.iana.org/assignments/ethernet-numbers for the full tea πŸ“‹
  • length β€” the length of the payload when this layer is a 802.3 one. This is the same attribute as type, but heads up: you cannot use it when calling new (you can only use it as an accessor after that). so like, it's the same thing wearing a different outfit πŸ’€

The following are inherited attributes. See Net::Frame::Layer for more information:

  • raw
  • payload
  • nextLayer

πŸŽ€ METHODS πŸŽ€

  • new
  • new (hash) β€” object constructor πŸ’– you can pass attributes that will overwrite the default ones. See SYNOPSIS for default values, bestie.

The following are inherited methods. Some of them may be overridden in this layer, and some others may not be meaningful in this layer. See Net::Frame::Layer for more information:

  • layer
  • computeLengths
  • computeChecksums
  • pack
  • unpack
  • encapsulate
  • getLength
  • getPayloadLength
  • print
  • dump

⭐ CONSTANTS ⭐

Load them like this, don't forget it:

use Net::Frame::Layer::ETH qw(:consts);
  • NF_ETH_ADDR_BROADCAST β€” Ethernet broadcast address. shouting to everyone on the network, iconic πŸ“£
  • NF_ETH_TYPE_IPv4, NF_ETH_TYPE_X25, NF_ETH_TYPE_ARP, NF_ETH_TYPE_CGMP, NF_ETH_TYPE_80211, NF_ETH_TYPE_PPPIPCP, NF_ETH_TYPE_RARP, NF_ETH_TYPE_DDP, NF_ETH_TYPE_AARP, NF_ETH_TYPE_PPPCCP, NF_ETH_TYPE_WCP, NF_ETH_TYPE_8021Q, NF_ETH_TYPE_IPX, NF_ETH_TYPE_STP, NF_ETH_TYPE_IPv6, NF_ETH_TYPE_WLCCP, NF_ETH_TYPE_MPLS, NF_ETH_TYPE_PPPoED, NF_ETH_TYPE_PPPoES, NF_ETH_TYPE_8021X, NF_ETH_TYPE_AoE, NF_ETH_TYPE_80211I, NF_ETH_TYPE_LLDP, NF_ETH_TYPE_LLTD, NF_ETH_TYPE_LOOP, NF_ETH_TYPE_VLAN, NF_ETH_TYPE_PPPPAP, NF_ETH_TYPE_PPPCHAP β€” various supported Ethernet types. look at this lineup, it's a whole squad πŸ”₯

🌈 SEE ALSO 🌈

  • Net::Frame::Layer

πŸ‘‘ AUTHOR πŸ‘‘

Patrice <GomoR> Auffret πŸ’œ


Copyright (c) 2006-2019, Patrice <GomoR> Auffret

You may distribute this module under the terms of the Artistic license. See the LICENSE.Artistic file in the source distribution archive.


and that's the whole page, bestie!! this was documented as perl v5.36.0, dated 2022-12-04, and it goes out to you with all the love in the world β€” stay packet-crafting, mwah πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ’…πŸ«Ά