NAME

NetPacket::IPv6 - Assembling and disassembling IPv6 (Internet Protocol Version 6) packets.

VERSION

version 0.43.1

SYNOPSIS

use NetPacket::IPv6;

$ip6_obj = NetPacket::IPv6->decode($raw_pkt);
$ip6_pkt = NetPacket::IPv6->encode();
$ip6_data = NetPacket::IPv6::strip($raw_pkt);

DESCRIPTION

NetPacket::IPv6 provides a set of routines for assembling and disassembling IPv6 (Internet Protocol Version 6) packets.

Methods

NetPacket::IPv6->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::IPv6->encode()

Return an IPv6 packet encoded with the instance data specified. This will infer the packet length automatically from the payload length.

Functions

NetPacket::IPv6::strip([RAW PACKET])

Return the encapsulated data (or payload) contained in the IPv6 packet. This data is suitable to be used as input for other NetPacket::* modules.

This function is equivalent to creating an object using the decode() constructor and returning the data field of that object.

Instance data

The instance data for the NetPacket::IPv6 object consists of the following fields.

ver

The IPv6 version number of this packet. This must always be 6.

class

The IPv6 traffic class.

flow

The IPv6 flow label.

plen

The payload length. This is the length of the payload (data); it does not include the length of the packet header.

nxt

The next header. This field identifies the type of header that follows the IPv6 header. It uses the same values as the IPv4 protocol header.

hlim

The hop limit. Each router that handles the packet will decrement this field by 1. Once the field reaches 0, the packet is discarded. Similar to the TTL field in the IPv4 header.

src_ip

The source IPv6 address. The address is expressed as a colon-separated hex string. Leading zeros within the hex numbers are removed.

dest_ip

The destination IPv6 address. The address is expressed as a colon-separated hex string. Leading zeros within the hex numbers are removed.

data

The encapsulated data (payload).

Exports

default

none

exportable

Protocols:

IP_PROTO_IPV6 IP_PROTO_ICMPV6 

IPv6 version number:

IP_VERSION_IPv6 IPV6_VERSION

Maximum IPv6 packet size:

IPV6_MAXPACKET 

Strip function:

ipv6_strip
tags

The following tags can be used to export certain items:

:protos

IP_PROTO_IPV6 IP_PROTO_ICMPV6

:versions

IP_VERSION_IPv6 IPV6_VERSION

:strip

The function ipv6_strip

:ALL

All the above exportable items

EXAMPLE

The following prints the source and destination IPv6 address along with the value of the next header field.

#!/usr/bin/perl -w

use strict;
use Net::PcapUtils;
use NetPacket::Ethernet qw(:strip);
use NetPacket::IPv6;

sub process_pkt {
    my ($user, $hdr, $pkt) = @_;

    my $ip6_obj = NetPacket::IPv6->decode(eth_strip($pkt));
    print("$ip6_obj->{src_ip} -> $ip6_obj->{dest_ip} ");
    print("$ip6_obj->{nxt}\n");
}

Net::PcapUtils::loop(\&process_pkt, FILTER => 'ip6');

TODO

Nothing at this time.

COPYRIGHT

Copyright (c) 2003, 2004 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>