NAME
NetPacket::ICMPv6
- Assemble and disassemble ICMPv6 (Internet Control Message Protocol Version 6) packets.
VERSION
version 0.43.1
SYNOPSIS
use NetPacket::ICMPv6;
$icmp6_obj = NetPacket::ICMPv6->decode($raw_pkt);
$icmp6_pkt = NetPacket::ICMPv6->encode($ip6_obj);
$icmp6_data = NetPacket::ICMPv6::strip($raw_pkt);
$cksum = $icmp6_obj->checksum($ip6_obj);
DESCRIPTION
NetPacket::ICMPv6
provides a set of routines for assembling and disassembling ICMPv6 (Internet Control Message Protocol Version 6) packets.
Methods
NetPacket::ICMPv6->decode([RAW PACKET])
-
Decode the raw packet data given and return an object containing instance data. This method will quite happily decode garbage input. It is the responsibility of the programmer to ensure valid packet data is passed to this method.
NetPacket::ICMPv6->encode($ip6_obj)
-
Return an ICMPv6 packet encoded with the instance data specified. The
NetPacket::IPv6
object that the ICMPv6 packet was encapsulated in must be passed to encode() because some of the IPv6 header fields are used in the ICMPv6 checksum calculation. NetPacket::ICMPv6->checksum($ip6_obj)
-
Calculate the ICMPv6 checksum based on the instance data of the
NetPacket::ICMPv6
object. TheNetPacket::IPv6
object that the ICMPv6 packet was/will be encapsulated in must be specified as some of the IPv6 header fields are used in the ICMPv6 calculation.
Functions
NetPacket::ICMPv6::strip([RAW PACKET])
-
Return the encapsulated data (or payload) contained in the ICMPv6 packet.
Instance data
The instance data for the NetPacket::ICMPv6
object consists of the following fields.
- type
-
The ICMPv6 message type of this packet.
- code
-
The ICMPv6 message code of this packet.
- cksum
-
The checksum for this packet.
- data
-
The encapsulated data (payload) for this packet.
Type-Specific Instance Data
- id
-
Identification number used to match Echo Requests with Echo Replies. (Echo Request, Echo Reply)
- seq
-
Sequence number used to match Echo Requests with Echo Replies. (Echo Request, Echo Reply)
- mtu
-
The Maximum Transmission Unit of the next-hop link. (Packet Too Big)
- ptr
-
Problem pointer. Identifies the location in the original packet where the problem was. (Parameter Problem)
- unused
-
These ICMPv6 types contain an unused header field: Destination Unreachable, Time Exceeded.
Exports
- default
-
none
- exportable
-
ICMPv6 message types:
ICMPV6_DST_UNREACH ICMPV6_PACKET_TOO_BIG ICMPV6_TIME_EXCEEDED ICMPV6_PARAM_PROB ICMPV6_ECHO_REQUEST ICMPV6_ECHO_REPLY
Strip function:
icmpv6_strip
-
The following tags group together related exportable items.
EXAMPLE
The following example prints the ICMPv6 type, code, and checksum fields.
#!/usr/bin/perl -w
use strict;
use Net::PcapUtils;
use NetPacket::Ethernet qw(:strip);
use NetPacket::IPv6 qw(:strip);
use NetPacket::ICMPv6;
sub process_pkt {
my ($user, $hdr, $pkt) = @_;
my $ip6_obj = NetPacket::IPv6->decode(eth_strip($pkt));
my $icmp6_obj = NetPacket::ICMPv6->decode(ipv6_strip($ip6_obj));
print("Type: $icmp6_obj->{type}\n");
print("Code: $icmp6_obj->{code}\n");
print("Checksum: $icmp6_obj->{cksum}\n\n");
}
Net::PcapUtils::loop(\&process_pkt, FILTER => 'icmp6');
TODO
Nothing at this time.
COPYRIGHT
Copyright (c) 2003-2009 Joel Knight <knight.joel@gmail.com>
Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
AUTHOR
Joel Knight <knight.joel@gmail.com>