
Net::Packet::ICMPv4 - Internet Control Message Protocol v4 layer 4 object

use Net::Packet::ICMPv4;
use Net::Packet::Consts qw(:icmpv4);
# Build echo-request header
my $echo = Net::Packet::ICMPv4->new(data => '0123456789');
# Build information-request header
my $info = Net::Packet::ICMPv4->new(
type => NP_ICMPv4_TYPE_INFORMATION_REQUEST,
data => '0123456789',
);
# Build address-mask request header
my $mask = Net::Packet::ICMPv4->new(
type => NP_ICMPv4_TYPE_ADDRESS_MASK_REQUEST,
data => '0123456789',
);
# Build timestamp request header
my $timestamp = Net::Packet::ICMPv4->new(
type => NP_ICMPv4_TYPE_TIMESTAMP_REQUEST,
data => '0123456789',
);
# Decode from network to create the object
# Usually, you do not use this, it is used by Net::Packet::Frame
my $decode = Net::Packet::ICMPv4->new(raw => $rawFromNetwork);
print $echo->print, "\n";

This modules implements the encoding and decoding of the ICMPv4 layer.
RFC: ftp://ftp.rfc-editor.org/in-notes/rfc792.txt
See also Net::Packet::Layer and Net::Packet::Layer4 for other attributes a nd methods.

Type and code fields. See CONSTANTS.
The checksum of ICMPv4 header.
Identification number.
Sequence number.
Three timestamps used by the NP_ICMPv4_TYPE_TIMESTAMP_REQUEST message.
Used by the NP_ICMPv4_TYPE_ADDRESS_MASK_REQUEST message.
Used by the NP_ICMPv4_TYPE_REDIRECT message.
Zero value field used in various ICMP messages.
A pointer to a Net::Packet::Frame object, usually set when an ICMP error message has been returned.
Additionnal data can be added to an ICMP message, traditionnaly used in NP_ICMPv4_TYPE_ECHO_REQUEST.

Object constructor. You can pass attributes that will overwrite default ones. Default values:
type: NP_ICMPv4_TYPE_ECHO_REQUEST
code: NP_ICMPv4_CODE_ZERO
checksum: 0
identifier: getRandom16bitsInt()
sequenceNumber: getRandom16bitsInt()
originateTimestamp: time()
receiveTimestamp: 0
transmitTimestamp: 0
addressMask: 0
gateway: "127.0.0.1"
unused: 0
data: ""
Will search for a matching replies in framesSorted or frames from a Net::Packet::Dump object.
Returns the length in bytes of data attribute.
Packs all attributes into a raw format, in order to inject to network. Returns 1 on success, undef otherwise.
Unpacks raw data from network and stores attributes into the object. Returns 1 on success, undef otherwise.
Returns 1 if the type attribute is of specified type.

Load them: use Net::Packet::Consts qw(:icmpv4);
ICMP code zero, used by various ICMP messages.
Destination unreachable type, with possible code numbers.
Redirect type message, with possible code numbers.
Time exceeded message, with possible code numbers.
Other request/reply ICMP messages types.

Patrice <GomoR> Auffret

Copyright (c) 2004-2005, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See Copying file in the source distribution archive.
