NAME
Net::Frame::Layer - base class for all layer objects
DESCRIPTION
This is the base class for all other layer modules. It provides those layers with inheritable attributes, methods, constants and useful subroutines.
ATTRIBUTES
- raw
-
Stores the raw layer (as captured from the network, or packed to send to network).
- payload
-
Stores what is not part of the layer, that is the encapsulated part to be decoded by upper layers.
- nextLayer
-
User definable next layer. It may be used to define custom protocols.
METHODS
- new
- new (hash)
-
Object constructor.
- layer
-
Returns the string describing the layer (example: 'IPv4' for a Net::Frame::Layer::IPv4 object).
- computeLengths
- computeChecksums
-
Generally, when a layer is built, some attributes are not yet known until all layers that will be assembled are known. Those methods computes various lengths and checksums attributes found in a specific layer. Return 1 on success, undef otherwise. The usage depends from layer to layer, so see related documentation.
Also note that in most cases, you will need to call computeLength before computeChecksums, because checksums may depend upon lengths.
- pack
-
Packs all attributes into a raw format, in order to inject to network. Returns the raw packed string on success, undef otherwise. Result is stored into raw attribute.
- unpack
-
Unpacks raw data from network and stores attributes into the object. Returns $self on success, undef otherwise.
- encapsulate
-
Returns the next layer type (parsed from payload). This is the same string as returned by layer method.
- getLength
-
Returns the layer length in bytes.
- getPayloadLength
-
Returns the length of layer's payload in bytes.
-
Just returns a string in a human readable format describing attributes found in the layer.
- dump
-
Just returns a string in hexadecimal format which is how the layer appears on the network.
USEFUL SUBROUTINES
Load them: use Net::Frame::Layer qw(:subs);
- getHostIpv4Addr (hostname)
-
Resolves IPv4 address of specified hostname.
- getHostIpv4Addrs (hostname)
-
Same as above, but returns an array of IPv4 addresses.
- getHostIpv6Addr (hostname)
-
Resolves IPv6 address of specified hostname.
- inet6Aton (IPv6 address)
-
Takes IPv6 address and returns the network form.
- inet6Ntoa (IPv6 network form)
-
Takes IPv6 address in network format, and returns the IPv6 human form.
- inetAton (IPv4 address)
- inetNtoa (IPv4 network form)
-
Same as for IPv6, but for IPv4 addresses.
- convertMac (MAC network form)
-
Takes a MAC address from network form, and returns the human form.
- getRandom16bitsInt
- getRandom32bitsInt
-
Returns respectively a random 16 bits integer, and a random 32 bits integer.
- getRandomHighPort
-
Returns a random high port (> 1024).
- inetChecksum (pseudo header format)
-
Will take a frame in pseudo header format, and compute the INET checksum.
CONSTANTS
Load them: use Net::Frame::Layer qw(:consts);
- NF_LAYER_NONE
- NF_LAYER_UNKNOWN
- NF_LAYER_NOT_AVAILABLE
AUTHOR
Patrice <GomoR> Auffret
COPYRIGHT AND LICENSE
Copyright (c) 2006-2018, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.