Net::F...::Layer(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::F...::Layer ๐Ÿ’–

okay so bestie, welcome to the User Contributed Perl Documentation corner of the internet, where we're about to talk about Net::Frame::Layer โ€” yes the (3pm) one, the icon, the moment. โœจ


๐ŸŒธ NAME ๐ŸŒธ

Net::Frame::Layer โ€” the base class for literally all the layer objects. the mother of the whole little family. the blueprint. periodt. ๐Ÿ’…


โœจ DESCRIPTION โœจ

so basically: this is the base class for every other layer module. it's the one that shows up first and sets the vibe, and it hands down to all those little layer modules their inheritable attributes, methods, constants and genuinely useful subroutines. it's giving foundational, it's giving main character energy, no cap. ๐Ÿซถ


๐ŸŽ€ ATTRIBUTES ๐ŸŽ€

  • raw โ€” stores the raw layer, like the version captured straight off the network, or the version packed up and ready to get sent out onto the network. it's the layer in its โœจferalโœจ form.
  • payload โ€” stores everything that isn't part of this layer, aka the encapsulated part that the upper layers are gonna decode later. it's the little gift inside the box. ๐ŸŽ
  • nextLayer โ€” a user-definable next layer! so if you wanna build your own custom protocols, this is your moment, bestie, go off. ๐Ÿ’œ

๐Ÿ’… METHODS ๐Ÿ’…

  • new
  • new (hash) โ€” the object constructor. it makes the object. that's it, that's the job, and it does it flawlessly. ๐Ÿ‘‘
  • layer โ€” returns the string that describes the layer. like, for a Net::Frame::Layer::IPv4 object it hands you back 'IPv4'. iconic behavior honestly.
  • computeLengths
  • computeChecksums โ€” okay so when a layer gets built, some attributes are just not knowable yet until every layer that's gonna be assembled is finally known. these methods compute the various lengths and checksums attributes sitting inside a specific layer. they return 1 on success, and undef otherwise. how you use them totally depends on the layer, so go read the related documentation, i'm not gonna guess for you. ๐Ÿ™ˆ
also note: in most cases you're gonna need to call computeLength before computeChecksums, because the checksums may depend upon the lengths. order matters, babe, it always does. ๐Ÿ˜ญ
  • pack โ€” packs all the attributes into a raw format so you can inject it onto the network. returns the raw packed string on success, undef otherwise. and the result gets stored into the raw attribute, cute. ๐Ÿ“ฆ
  • unpack โ€” unpacks raw data coming in from the network and stores those attributes right into the object. returns $self on success, undef otherwise. it's the receiving end of the vibe. ๐Ÿฆ‹
  • encapsulate โ€” returns the next layer type, parsed from the payload. it's the exact same string you'd get from the layer method. twins. ๐Ÿ‘ฏ
  • getLength โ€” returns the layer length in bytes.
  • getPayloadLength โ€” returns the length of the layer's payload in bytes.
  • print โ€” just returns a string in a human readable format describing all the attributes found in the layer. for the girlies who like their data legible. ๐ŸŒธ
  • dump โ€” just returns a string in hexadecimal format, which is exactly how the layer appears on the network. nerdy and gorgeous at the same time. ๐Ÿ”ฅ

๐Ÿงš USEFUL SUBROUTINES ๐Ÿงš

to load them, do this:

use Net::Frame::Layer qw(:subs);
  • getHostIpv4Addr (hostname) โ€” resolves the IPv4 address of the hostname you specify.
  • getHostIpv4Addrs (hostname) โ€” same as above but it returns an array of IPv4 addresses. more is more. โœจ
  • getHostIpv6Addr (hostname) โ€” resolves the IPv6 address of the hostname you specify.
  • inet6Aton (IPv6 address) โ€” takes an IPv6 address and returns the network form of it.
  • inet6Ntoa (IPv6 network form) โ€” takes an IPv6 address in network format and returns the IPv6 human form. the reverse glow-up. ๐Ÿ’ซ
  • inetAton (IPv4 address)
  • inetNtoa (IPv4 network form) โ€” same deal as the IPv6 ones, but for IPv4 addresses. equal treatment, as they deserve. ๐Ÿ’–
  • convertMac (MAC network form) โ€” takes a MAC address from network form and returns the human form. translating mac-fluent into people-fluent. ๐Ÿ“
  • getRandom16bitsInt
  • getRandom32bitsInt โ€” return a random 16 bits integer and a random 32 bits integer respectively. chaos, but make it numeric. ๐ŸŽฒ
  • getRandomHighPort โ€” returns a random high port, and by high we mean > 1024.
  • inetChecksum (pseudo header format) โ€” takes a frame in pseudo header format and computes the INET checksum. math but make it slay. ๐Ÿงฎ

โญ CONSTANTS โญ

to load them, do this:

use Net::Frame::Layer qw(:consts);
  • NF_LAYER_NONE
  • NF_LAYER_UNKNOWN
  • NF_LAYER_NOT_AVAILABLE

๐Ÿ‘‘ AUTHOR ๐Ÿ‘‘

Patrice <GomoR> Auffret โ€” the legend, the originator, we stan. ๐Ÿซถ


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

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


okay that's the whole page bestie, every single detail preserved, nothing skipped, we ate and left no crumbs ๐Ÿ’…โœจ

this gorgeous little document was put together under perl v5.36.0, dated 2022-12-04, and it's filed as Net::F...::Layer(3pm). mwah, bye! ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹