1NetPacket::IPv6(3)    User Contributed Perl Documentation   NetPacket::IPv6(3)
2
3
4

NAME

6       NetPacket::IPv6 - Assemble and disassemble IPv6 (Internet Protocol
7       version 6) packets.
8

VERSION

10       version 1.7.2
11

SYNOPSIS

13         use NetPacket::IPv6;
14
15         $ip_obj = NetPacket::IPv6->decode($raw_pkt);
16         $ip_pkt = NetPacket::IPv6->encode($ip_obj);
17         $ip_data = NetPacket::IPv6::strip($raw_pkt);
18

DESCRIPTION

20       "NetPacket::IPv6" provides a set of routines for assembling and
21       disassembling packets using IPv6 (Internet Protocol version 6).
22
23   Methods
24       "NetPacket::IPv6->decode([RAW PACKET])"
25           Decode the raw packet data given and return an object containing
26           instance data.  This method will quite happily decode garbage
27           input.  It is the responsibility of the programmer to ensure valid
28           packet data is passed to this method.
29
30       "NetPacket::IPv6->encode()"
31           Return an IPv6 packet encoded with the instance data specified.
32           This will infer the total length of the packet automatically from
33           the payload length and length of any extension headers.
34
35       "NetPacket::IPv6->pseudo_header([PACKET LENGTH], [PROTOCOL])"
36           Return an IPv6 "pseudo-header" suitable for computing checksums for
37           certain upper-level protocols.
38
39   Functions
40       "NetPacket::IPv6::strip([RAW PACKET])"
41           Return the encapsulated data (or payload) contained in the IPv6
42           packet.  This data is suitable to be used as input for other
43           "NetPacket::*" modules.
44
45           This function is equivalent to creating an object using the
46           "decode()" constructor and returning the "data" field of that
47           object.
48
49       "NetPacket::IPv6::ipv6_extheader([TYPE])"
50           Return whether the IP protocol type is an IPv6 extension header.
51
52   Instance data
53       The instance data for the "NetPacket::IPv6" object consists of the
54       following fields.
55
56       ver The IP version number of this packet.
57
58       traffic_class
59           The traffic class of this packet, equivalent to the type-of-service
60           field for IPv4.
61
62       flow_label
63           The flow label of this packet.
64
65       len The payload length (including any extension headers) in bytes for
66           this packet.
67
68       proto
69           The IP protocol number for this packet.
70
71       hop_limit
72           The hop limit for this packet, equivalent to the time-to-live field
73           for IPv4.
74
75       src_ip
76           The source IP address for this packet in colon-separated hextet
77           notation.
78
79       dest_ip
80           The destination IP address for this packet in colon-separated
81           hextet notation.
82
83       extheaders
84           Array of any extension headers for this packet, as a hashref
85           containing the fields described below. An ESP (Encapsulating
86           Security Payload) header will not be represented here; as it and
87           any further extension headers and the payload data will be
88           encrypted, it will be instead represented as the packet payload
89           data itself, with a protocol number of 50 ("IPv6_EXTHEADER_ESP").
90
91       data
92           The encapsulated data (payload) for this IPv6 packet.
93
94       Extension headers may contain the following fields.
95
96       type
97           The extension header type number.
98
99       len The extension header length, in 8-byte units, minus the first
100           8-byte unit.  (For Authentication extension headers, this length is
101           in 4-byte units, minus the first two 4-byte units.)
102
103       data
104           The remaining contents of the extension header following the next-
105           header and length bytes.
106
107   Exports
108       default
109           none
110
111       tags
112           The following tags group together related exportable items.
113
114           ":protos"
115           ":tos"
116           ":misc"
117               Re-exported from NetPacket::IP for convenience.
118
119           ":extheaders"
120               IPv6_EXTHEADER_HOPBYHOP IPv6_EXTHEADER_ROUTING
121               IPv6_EXTHEADER_FRAGMENT IPv6_EXTHEADER_ESP IPv6_EXTHEADER_AUTH
122               IPv6_EXTHEADER_NONEXT IPv6_EXTHEADER_DESTOPT
123               IPv6_EXTHEADER_MOBILITY IPv6_EXTHEADER_HOSTIDENT
124               IPv6_EXTHEADER_SHIM6 IPv6_EXTHEADER_TESTING1
125               IPv6_EXTHEADER_TESTING2
126
127           ":versions"
128               IP_VERSION_IPv6
129
130           ":strip"
131               Import the strip function "ipv6_strip".
132
133           ":ALL"
134               All the above exportable items.
135

EXAMPLE

137       The following script dumps IPv6 frames by IP address and protocol to
138       standard output.
139
140         #!/usr/bin/perl -w
141
142         use strict;
143         use Net::PcapUtils;
144         use NetPacket::Ethernet qw(:strip);
145         use NetPacket::IPv6;
146
147         sub process_pkt {
148             my ($user, $hdr, $pkt) = @_;
149
150             my $ip_obj = NetPacket::IPv6->decode(eth_strip($pkt));
151             print("$ip_obj->{src_ip}:$ip_obj->{dest_ip} $ip_obj->{proto}\n");
152         }
153
154         Net::PcapUtils::loop(\&process_pkt, FILTER => 'ip6');
155

TODO

157       More specific keys for well-defined extension headers.
158       Parse routing extension headers to correctly compute upper-level
159       checksums.
160
162       Copyright (c) 2018 Dan Book.
163
164       This module is free software.  You can redistribute it and/or modify it
165       under the terms of the Artistic License 2.0.
166
167       This program is distributed in the hope that it will be useful, but
168       without any warranty; without even the implied warranty of
169       merchantability or fitness for a particular purpose.
170

AUTHOR

172       Dan Book <dbook@cpan.org>
173
174
175
176perl v5.30.0                      2019-07-26                NetPacket::IPv6(3)
Impressum