Net::Frame::Layer::ICMPv4 - Internet Control Message Protocol v4 layer object
use Net::Frame::Simple; use Net::Frame::Layer::ICMPv4 qw(:consts); my $icmp = Net::Frame::Layer::ICMPv4->new( type => NF_ICMPv4_TYPE_ECHO_REQUEST, code => NF_ICMPv4_CODE_ZERO, checksum => 0, ); # Build an ICMPv4 echo-request use Net::Frame::Layer::ICMPv4::Echo; my $echo = Net::Frame::Layer::ICMPv4::Echo->new( payload => 'echo' ); my $echoReq = Net::Frame::Simple->new( layers => [ $icmp, $echo ] ); print $echoReq->print."\n"; # Build an information-request use Net::Frame::Layer::ICMPv4::Information; my $info = Net::Frame::Layer::ICMPv4::Information->new( payload => 'info' ); $icmp->type(NF_ICMPv4_TYPE_INFORMATION_REQUEST); my $infoReq = Net::Frame::Simple->new( layers => [ $icmp, $info ] ); print $infoReq->print."\n"; # Build an address-mask request use Net::Frame::Layer::ICMPv4::AddressMask; my $mask = Net::Frame::Layer::ICMPv4::AddressMask->new( payload => 'mask' ); $icmp->type(NF_ICMPv4_TYPE_ADDRESS_MASK_REQUEST); my $maskReq = Net::Frame::Simple->new( layers => [ $icmp, $mask ] ); print $maskReq->print."\n"; # Build a timestamp request use Net::Frame::Layer::ICMPv4::Timestamp; my $timestamp = Net::Frame::Layer::ICMPv4::Timestamp->new( payload => 'time' ); $icmp->type(NF_ICMPv4_TYPE_TIMESTAMP_REQUEST); my $timestampReq = Net::Frame::Simple->new( layers => [ $icmp, $timestamp ] ); print $timestampReq->print."\n"; # # Read a raw layer # my $layer = Net::Frame::Layer::ICMPv4->new(raw => $raw); print $layer->print."\n"; print 'PAYLOAD: '.unpack('H*', $layer->payload)."\n" if $layer->payload;
This modules implements the encoding and decoding of the ICMPv4 layer.
RFC: ftp://ftp.rfc-editor.org/in-notes/rfc792.txt
See also Net::Frame::Layer for other attributes and methods.
Type and code fields. See CONSTANTS.
The checksum of ICMPv4 header.
The following are inherited attributes. See Net::Frame::Layer for more information.
Object constructor. You can pass attributes that will overwrite default ones. See SYNOPSIS for default values.
Computes the ICMPv4 checksum.
These two methods are basically used to increase the speed when using recv method from Net::Frame::Simple. Usually, you write them when you need to write match method.
This method is mostly used internally. You pass a Net::Frame::Layer::ICMPv4 layer as a parameter, and it returns true if this is a response corresponding for the request, or returns false if not.
The following are inherited methods. Some of them may be overriden in this layer, and some others may not be meaningful in this layer. See Net::Frame::Layer for more information.
Load them: use Net::Frame::Layer::ICMPv4 qw(:consts);
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.
Parameter problem, with possible code numbers.
Source quench type.
Other request/reply ICMP messages types.
Net::Frame::Layer
Patrice <GomoR> Auffret
Copyright (c) 2006-2012, Patrice <GomoR> Auffret
You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.
To install Net::Frame::Layer::ICMPv4, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Frame::Layer::ICMPv4
CPAN shell
perl -MCPAN -e shell install Net::Frame::Layer::ICMPv4
For more information on module installation, please visit the detailed CPAN module installation guide.