1NetPacket::IPv6(3) User Contributed Perl Documentation NetPacket::IPv6(3)
2
3
4
6 NetPacket::IPv6 - Assemble and disassemble IPv6 (Internet Protocol
7 version 6) packets.
8
10 version 1.7.2
11
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
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 object.
47
48 NetPacket::IPv6::ipv6_extheader([TYPE])
49 Return whether the IP protocol type is an IPv6 extension header.
50
51 Instance data
52 The instance data for the "NetPacket::IPv6" object consists of the
53 following fields.
54
55 ver The IP version number of this packet.
56
57 traffic_class
58 The traffic class of this packet, equivalent to the type-of-service
59 field for IPv4.
60
61 flow_label
62 The flow label of this packet.
63
64 len The payload length (including any extension headers) in bytes for
65 this packet.
66
67 proto
68 The IP protocol number for this packet.
69
70 hop_limit
71 The hop limit for this packet, equivalent to the time-to-live field
72 for IPv4.
73
74 src_ip
75 The source IP address for this packet in colon-separated hextet
76 notation.
77
78 dest_ip
79 The destination IP address for this packet in colon-separated
80 hextet notation.
81
82 extheaders
83 Array of any extension headers for this packet, as a hashref
84 containing the fields described below. An ESP (Encapsulating
85 Security Payload) header will not be represented here; as it and
86 any further extension headers and the payload data will be
87 encrypted, it will be instead represented as the packet payload
88 data itself, with a protocol number of 50 ("IPv6_EXTHEADER_ESP").
89
90 data
91 The encapsulated data (payload) for this IPv6 packet.
92
93 Extension headers may contain the following fields.
94
95 type
96 The extension header type number.
97
98 len The extension header length, in 8-byte units, minus the first
99 8-byte unit. (For Authentication extension headers, this length is
100 in 4-byte units, minus the first two 4-byte units.)
101
102 data
103 The remaining contents of the extension header following the next-
104 header and length bytes.
105
106 Exports
107 default
108 none
109
110 tags
111 The following tags group together related exportable items.
112
113 ":protos"
114 ":tos"
115 ":misc"
116 Re-exported from NetPacket::IP for convenience.
117
118 ":extheaders"
119 IPv6_EXTHEADER_HOPBYHOP IPv6_EXTHEADER_ROUTING
120 IPv6_EXTHEADER_FRAGMENT IPv6_EXTHEADER_ESP IPv6_EXTHEADER_AUTH
121 IPv6_EXTHEADER_NONEXT IPv6_EXTHEADER_DESTOPT
122 IPv6_EXTHEADER_MOBILITY IPv6_EXTHEADER_HOSTIDENT
123 IPv6_EXTHEADER_SHIM6 IPv6_EXTHEADER_TESTING1
124 IPv6_EXTHEADER_TESTING2
125
126 ":versions"
127 IP_VERSION_IPv6
128
129 ":strip"
130 Import the strip function "ipv6_strip".
131
132 ":ALL"
133 All the above exportable items.
134
136 The following script dumps IPv6 frames by IP address and protocol to
137 standard output.
138
139 #!/usr/bin/perl -w
140
141 use strict;
142 use Net::PcapUtils;
143 use NetPacket::Ethernet qw(:strip);
144 use NetPacket::IPv6;
145
146 sub process_pkt {
147 my ($user, $hdr, $pkt) = @_;
148
149 my $ip_obj = NetPacket::IPv6->decode(eth_strip($pkt));
150 print("$ip_obj->{src_ip}:$ip_obj->{dest_ip} $ip_obj->{proto}\n");
151 }
152
153 Net::PcapUtils::loop(\&process_pkt, FILTER => 'ip6');
154
156 More specific keys for well-defined extension headers.
157 Parse routing extension headers to correctly compute upper-level
158 checksums.
159
161 Copyright (c) 2018 Dan Book.
162
163 This module is free software. You can redistribute it and/or modify it
164 under the terms of the Artistic License 2.0.
165
166 This program is distributed in the hope that it will be useful, but
167 without any warranty; without even the implied warranty of
168 merchantability or fitness for a particular purpose.
169
171 Dan Book <dbook@cpan.org>
172
173
174
175perl v5.36.0 2023-01-20 NetPacket::IPv6(3)