File Coverage

blib/lib/NetPacket/ICMPv6.pm
Criterion Covered Total %
statement 263 268 98.1
branch 1 2 50.0
condition n/a
subroutine 84 86 97.6
pod 3 5 60.0
total 351 361 97.2


line stmt bran cond sub pod time code
1             package NetPacket::ICMPv6;
2             our $AUTHORITY = 'cpan:YANICK';
3             # ABSTRACT: Assemble and disassemble ICMPv6 (Internet Control Message Protocol for IPv6) packets.
4             $NetPacket::ICMPv6::VERSION = '1.7.2';
5 1     1   69919 use strict;
  1         11  
  1         29  
6 1     1   6 use warnings;
  1         2  
  1         27  
7              
8 1     1   444 use parent 'NetPacket';
  1         297  
  1         6  
9 1     1   491 use NetPacket::IPv6 'IP_PROTO_ICMPv6';
  1         2  
  1         301  
10              
11             our @EXPORT_OK = qw(icmpv6_strip icmpv6_infotype
12             ICMPv6_UNREACH ICMPv6_TOOBIG ICMPv6_TIMXCEED ICMPv6_PARAMPROB
13             ICMPv6_PRIVATEERROR1 ICMPv6_PRIVATEERROR2 ICMPv6_EXPANSIONERROR
14             ICMPv6_ECHOREQ ICMPv6_ECHOREPLY ICMPv6_MULTICASTQUERY
15             ICMPv6_MULTICASTREPORT ICMPv6_MULTICASTDONE
16             ICMPv6_ROUTERSOLICIT ICMPv6_ROUTERADVERT
17             ICMPv6_NEIGHBORSOLICIT ICMPv6_NEIGHBORADVERT
18             ICMPv6_REDIRECT ICMPv6_ROUTERRENUMBER
19             ICMPv6_NODEINFOQUERY ICMPv6_NODEINFOREPLY
20             ICMPv6_INVNEIGHBORSOLICIT ICMPv6_INVNEIGHBORADVERT
21             ICMPv6_MULTICASTREPORTV2
22             ICMPv6_HOMEAGENTREQUEST ICMPv6_HOMEAGENTREPLY
23             ICMPv6_MOBILEPREFIXSOLICIT ICMPv6_MOBILEPREFIXADVERT
24             ICMPv6_CERTPATHSOLICIT ICMPv6_CERTPATHADVERT
25             ICMPv6_MULTICASTADVERT ICMPv6_MULTICASTSOLICIT
26             ICMPv6_MULTICASTTERM ICMPv6_FMIPv6 ICMPv6_RPLCONTROL
27             ICMPv6_DUPREQUEST ICMPv6_DUPCONFIRM ICMPv6_MPLCONTROL
28             ICMPv6_EXTECHOREQ ICMPv6_EXTECHOREPLY
29             ICMPv6_PRIVATEINFO1 ICMPv6_PRIVATEINFO2 ICMPv6_EXPANSIONINFO
30             ICMPv6_UNREACH_NO_ROUTE ICMPv6_UNREACH_COMM_PROHIB
31             ICMPv6_UNREACH_BEYOND_SCOPE ICMPv6_UNREACH_ADDRESS ICMPv6_UNREACH_PORT
32             ICMPv6_UNREACH_SRC_FAIL_POLICY ICMPv6_UNREACH_REJECT_DEST
33             ICMPv6_TIMXCEED_INTRANS ICMPv6_TIMXCEED_REASS
34             ICMPv6_PARAMPROB_HEADER_FIELD ICMPv6_PARAMPROB_NEXT_HEADER
35             ICMPv6_PARAMPROB_OPTION
36             ICMPv6_ROUTERRENUMBER_COMMAND ICMPv6_ROUTERRENUMBER_RESULT
37             ICMPv6_ROUTERRENUMBER_RESET
38             ICMPv6_NODEINFOQUERY_IPv6 ICMPv6_NODEINFOQUERY_NAME
39             ICMPv6_NODEINFOQUERY_IPv4 ICMPv6_NODEINFOREPLY_SUCCESS
40             ICMPv6_NODEINFOREPLY_REFUSED ICMPv6_NODEINFOREPLY_UNKNOWN
41             ICMPv6_RPLCONTROL_DODAG_SOLICIT ICMPv6_RPLCONTROL_DODAG_OBJECT
42             ICMPv6_RPLCONTROL_DEST_ADVERT ICMPv6_RPLCONTROL_DEST_ACK
43             ICMPv6_RPLCONTROL_SECURE_DODAG_SOLICIT ICMPv6_RPLCONTROL_SECURE_DODAG_OBJECT
44             ICMPv6_RPLCONTROL_SECURE_DEST_ADVERT ICMPv6_RPLCONTROL_SECURE_DEST_ACK
45             ICMPv6_RPLCONTROL_CONSISTENCY
46             ICMPv6_EXTECHOREPLY_NO_ERROR ICMPv6_EXTECHOREPLY_MALFORMED
47             ICMPv6_EXTECHOREPLY_NO_INTERFACE ICMPv6_EXTECHOREPLY_NO_ENTRY
48             ICMPv6_EXTECHOREPLY_MULTIPLE
49             );
50              
51             our %EXPORT_TAGS = (
52             ALL => [@EXPORT_OK],
53             types => [qw(ICMPv6_UNREACH ICMPv6_TOOBIG ICMPv6_TIMXCEED ICMPv6_PARAMPROB
54             ICMPv6_PRIVATEERROR1 ICMPv6_PRIVATEERROR2 ICMPv6_EXPANSIONERROR
55             ICMPv6_ECHOREQ ICMPv6_ECHOREPLY ICMPv6_MULTICASTQUERY
56             ICMPv6_MULTICASTREPORT ICMPv6_MULTICASTDONE
57             ICMPv6_ROUTERSOLICIT ICMPv6_ROUTERADVERT
58             ICMPv6_NEIGHBORSOLICIT ICMPv6_NEIGHBORADVERT
59             ICMPv6_REDIRECT ICMPv6_ROUTERRENUMBER
60             ICMPv6_NODEINFOQUERY ICMPv6_NODEINFOREPLY
61             ICMPv6_INVNEIGHBORSOLICIT ICMPv6_INVNEIGHBORADVERT
62             ICMPv6_MULTICASTREPORTV2
63             ICMPv6_HOMEAGENTREQUEST ICMPv6_HOMEAGENTREPLY
64             ICMPv6_MOBILEPREFIXSOLICIT ICMPv6_MOBILEPREFIXADVERT
65             ICMPv6_CERTPATHSOLICIT ICMPv6_CERTPATHADVERT
66             ICMPv6_MULTICASTADVERT ICMPv6_MULTICASTSOLICIT
67             ICMPv6_MULTICASTTERM ICMPv6_FMIPv6 ICMPv6_RPLCONTROL
68             ICMPv6_DUPREQUEST ICMPv6_DUPCONFIRM ICMPv6_MPLCONTROL
69             ICMPv6_EXTECHOREQ ICMPv6_EXTECHOREPLY
70             ICMPv6_PRIVATEINFO1 ICMPv6_PRIVATEINFO2 ICMPv6_EXPANSIONINFO)],
71             codes => [qw(ICMPv6_UNREACH_NO_ROUTE ICMPv6_UNREACH_COMM_PROHIB
72             ICMPv6_UNREACH_BEYOND_SCOPE ICMPv6_UNREACH_ADDRESS ICMPv6_UNREACH_PORT
73             ICMPv6_UNREACH_SRC_FAIL_POLICY ICMPv6_UNREACH_REJECT_DEST
74             ICMPv6_TIMXCEED_INTRANS ICMPv6_TIMXCEED_REASS
75             ICMPv6_PARAMPROB_HEADER_FIELD ICMPv6_PARAMPROB_NEXT_HEADER
76             ICMPv6_PARAMPROB_OPTION
77             ICMPv6_ROUTERRENUMBER_COMMAND ICMPv6_ROUTERRENUMBER_RESULT
78             ICMPv6_ROUTERRENUMBER_RESET
79             ICMPv6_NODEINFOQUERY_IPv6 ICMPv6_NODEINFOQUERY_NAME
80             ICMPv6_NODEINFOQUERY_IPv4 ICMPv6_NODEINFOREPLY_SUCCESS
81             ICMPv6_NODEINFOREPLY_REFUSED ICMPv6_NODEINFOREPLY_UNKNOWN
82             ICMPv6_RPLCONTROL_DODAG_SOLICIT ICMPv6_RPLCONTROL_DODAG_OBJECT
83             ICMPv6_RPLCONTROL_DEST_ADVERT ICMPv6_RPLCONTROL_DEST_ACK
84             ICMPv6_RPLCONTROL_SECURE_DODAG_SOLICIT ICMPv6_RPLCONTROL_SECURE_DODAG_OBJECT
85             ICMPv6_RPLCONTROL_SECURE_DEST_ADVERT ICMPv6_RPLCONTROL_SECURE_DEST_ACK
86             ICMPv6_RPLCONTROL_CONSISTENCY
87             ICMPv6_EXTECHOREPLY_NO_ERROR ICMPv6_EXTECHOREPLY_MALFORMED
88             ICMPv6_EXTECHOREPLY_NO_INTERFACE ICMPv6_EXTECHOREPLY_NO_ENTRY
89             ICMPv6_EXTECHOREPLY_MULTIPLE)],
90             strip => [qw(icmpv6_strip)],
91             );
92              
93             # ICMPv6 Types
94              
95 1     1   9 use constant ICMPv6_UNREACH => 1;
  1         1  
  1         69  
96 1     1   7 use constant ICMPv6_TOOBIG => 2;
  1         2  
  1         68  
97 1     1   8 use constant ICMPv6_TIMXCEED => 3;
  1         1  
  1         45  
98 1     1   5 use constant ICMPv6_PARAMPROB => 4;
  1         2  
  1         55  
99 1     1   7 use constant ICMPv6_PRIVATEERROR1 => 100;
  1         2  
  1         64  
100 1     1   7 use constant ICMPv6_PRIVATEERROR2 => 101;
  1         4  
  1         38  
101 1     1   5 use constant ICMPv6_EXPANSIONERROR => 127;
  1         7  
  1         56  
102 1     1   6 use constant ICMPv6_ECHOREQ => 128;
  1         2  
  1         50  
103 1     1   7 use constant ICMPv6_ECHOREPLY => 129;
  1         1  
  1         71  
104 1     1   7 use constant ICMPv6_MULTICASTQUERY => 130;
  1         2  
  1         55  
105 1     1   7 use constant ICMPv6_MULTICASTREPORT => 131;
  1         1  
  1         64  
106 1     1   7 use constant ICMPv6_MULTICASTDONE => 132;
  1         1  
  1         55  
107 1     1   6 use constant ICMPv6_ROUTERSOLICIT => 133;
  1         6  
  1         53  
108 1     1   7 use constant ICMPv6_ROUTERADVERT => 134;
  1         2  
  1         41  
109 1     1   5 use constant ICMPv6_NEIGHBORSOLICIT => 135;
  1         2  
  1         55  
110 1     1   7 use constant ICMPv6_NEIGHBORADVERT => 136;
  1         2  
  1         60  
111 1     1   7 use constant ICMPv6_REDIRECT => 137;
  1         1  
  1         53  
112 1     1   7 use constant ICMPv6_ROUTERRENUMBER => 138;
  1         2  
  1         61  
113 1     1   7 use constant ICMPv6_NODEINFOQUERY => 139;
  1         2  
  1         41  
114 1     1   5 use constant ICMPv6_NODEINFOREPLY => 140;
  1         2  
  1         53  
115 1     1   6 use constant ICMPv6_INVNEIGHBORSOLICIT => 141;
  1         2  
  1         48  
116 1     1   7 use constant ICMPv6_INVNEIGHBORADVERT => 142;
  1         2  
  1         41  
117 1     1   5 use constant ICMPv6_MULTICASTREPORTV2 => 143;
  1         1  
  1         53  
118 1     1   6 use constant ICMPv6_HOMEAGENTREQUEST => 144;
  1         2  
  1         50  
119 1     1   7 use constant ICMPv6_HOMEAGENTREPLY => 145;
  1         1  
  1         57  
120 1     1   6 use constant ICMPv6_MOBILEPREFIXSOLICIT => 146;
  1         2  
  1         58  
121 1     1   7 use constant ICMPv6_MOBILEPREFIXADVERT => 147;
  1         1  
  1         53  
122 1     1   7 use constant ICMPv6_CERTPATHSOLICIT => 148;
  1         2  
  1         56  
123 1     1   6 use constant ICMPv6_CERTPATHADVERT => 149;
  1         2  
  1         54  
124 1     1   7 use constant ICMPv6_MULTICASTADVERT => 151;
  1         2  
  1         41  
125 1     1   6 use constant ICMPv6_MULTICASTSOLICIT => 152;
  1         1  
  1         63  
126 1     1   7 use constant ICMPv6_MULTICASTTERM => 153;
  1         2  
  1         49  
127 1     1   7 use constant ICMPv6_FMIPv6 => 154;
  1         2  
  1         68  
128 1     1   7 use constant ICMPv6_RPLCONTROL => 155;
  1         2  
  1         58  
129 1     1   6 use constant ICMPv6_DUPREQUEST => 157;
  1         2  
  1         50  
130 1     1   8 use constant ICMPv6_DUPCONFIRM => 158;
  1         2  
  1         55  
131 1     1   7 use constant ICMPv6_MPLCONTROL => 159;
  1         69  
  1         81  
132 1     1   7 use constant ICMPv6_EXTECHOREQ => 160;
  1         2  
  1         42  
133 1     1   6 use constant ICMPv6_EXTECHOREPLY => 161;
  1         2  
  1         36  
134 1     1   5 use constant ICMPv6_PRIVATEINFO1 => 200;
  1         2  
  1         48  
135 1     1   7 use constant ICMPv6_PRIVATEINFO2 => 201;
  1         10  
  1         54  
136 1     1   7 use constant ICMPv6_EXPANSIONINFO => 255;
  1         2  
  1         54  
137              
138             # Destination Unreachable Codes
139              
140 1     1   6 use constant ICMPv6_UNREACH_NO_ROUTE => 0;
  1         2  
  1         50  
141 1     1   6 use constant ICMPv6_UNREACH_COMM_PROHIB => 1;
  1         2  
  1         53  
142 1     1   7 use constant ICMPv6_UNREACH_BEYOND_SCOPE => 2;
  1         1  
  1         50  
143 1     1   7 use constant ICMPv6_UNREACH_ADDRESS => 3;
  1         1  
  1         41  
144 1     1   5 use constant ICMPv6_UNREACH_PORT => 4;
  1         2  
  1         49  
145 1     1   7 use constant ICMPv6_UNREACH_SRC_FAIL_POLICY => 5;
  1         2  
  1         51  
146 1     1   7 use constant ICMPv6_UNREACH_REJECT_DEST => 6;
  1         2  
  1         43  
147              
148             # Time-Exceeded Codes
149              
150 1     1   24 use constant ICMPv6_TIMXCEED_INTRANS => 0;
  1         2  
  1         61  
151 1     1   8 use constant ICMPv6_TIMXCEED_REASS => 1;
  1         1  
  1         43  
152              
153             # Parameter-Problem Codes
154              
155 1     1   5 use constant ICMPv6_PARAMPROB_HEADER_FIELD => 0;
  1         2  
  1         50  
156 1     1   7 use constant ICMPv6_PARAMPROB_NEXT_HEADER => 1;
  1         2  
  1         57  
157 1     1   7 use constant ICMPv6_PARAMPROB_OPTION => 2;
  1         2  
  1         59  
158              
159             # Router Renumbering Codes
160              
161 1     1   36 use constant ICMPv6_ROUTERRENUMBER_COMMAND => 0;
  1         3  
  1         72  
162 1     1   7 use constant ICMPv6_ROUTERRENUMBER_RESULT => 1;
  1         1  
  1         42  
163 1     1   5 use constant ICMPv6_ROUTERRENUMBER_RESET => 255;
  1         2  
  1         59  
164              
165             # Node Information Query Codes
166              
167 1     1   18 use constant ICMPv6_NODEINFOQUERY_IPv6 => 0;
  1         3  
  1         55  
168 1     1   7 use constant ICMPv6_NODEINFOQUERY_NAME => 1;
  1         1  
  1         42  
169 1     1   5 use constant ICMPv6_NODEINFOQUERY_IPv4 => 2;
  1         2  
  1         54  
170              
171             # Node Information Reply Codes
172              
173 1     1   7 use constant ICMPv6_NODEINFOREPLY_SUCCESS => 0;
  1         1  
  1         50  
174 1     1   6 use constant ICMPv6_NODEINFOREPLY_REFUSED => 1;
  1         2  
  1         41  
175 1     1   5 use constant ICMPv6_NODEINFOREPLY_UNKNOWN => 2;
  1         2  
  1         50  
176              
177             # RPL Control Codes
178              
179 1     1   7 use constant ICMPv6_RPLCONTROL_DODAG_SOLICIT => 0x00;
  1         1  
  1         51  
180 1     1   6 use constant ICMPv6_RPLCONTROL_DODAG_OBJECT => 0x01;
  1         2  
  1         40  
181 1     1   19 use constant ICMPv6_RPLCONTROL_DEST_ADVERT => 0x02;
  1         4  
  1         62  
182 1     1   7 use constant ICMPv6_RPLCONTROL_DEST_ACK => 0x03;
  1         2  
  1         40  
183 1     1   5 use constant ICMPv6_RPLCONTROL_SECURE_DODAG_SOLICIT => 0x80;
  1         2  
  1         61  
184 1     1   6 use constant ICMPv6_RPLCONTROL_SECURE_DODAG_OBJECT => 0x81;
  1         10  
  1         63  
185 1     1   6 use constant ICMPv6_RPLCONTROL_SECURE_DEST_ADVERT => 0x82;
  1         2  
  1         41  
186 1     1   5 use constant ICMPv6_RPLCONTROL_SECURE_DEST_ACK => 0x83;
  1         2  
  1         57  
187 1     1   7 use constant ICMPv6_RPLCONTROL_CONSISTENCY => 0x8A;
  1         2  
  1         59  
188              
189             # Extended Echo Reply Codes
190              
191 1     1   14 use constant ICMPv6_EXTECHOREPLY_NO_ERROR => 0;
  1         2  
  1         67  
192 1     1   7 use constant ICMPv6_EXTECHOREPLY_MALFORMED => 1;
  1         9  
  1         58  
193 1     1   7 use constant ICMPv6_EXTECHOREPLY_NO_INTERFACE => 2;
  1         2  
  1         45  
194 1     1   5 use constant ICMPv6_EXTECHOREPLY_NO_ENTRY => 3;
  1         2  
  1         49  
195 1     1   6 use constant ICMPv6_EXTECHOREPLY_MULTIPLE => 4;
  1         2  
  1         468  
196              
197             #
198             # Test for informational types
199             #
200              
201             sub icmpv6_infotype {
202 0     0 0 0 my $type = shift;
203 0         0 return $type >= ICMPv6_ECHOREQ;
204             }
205              
206             #
207             # Decode the packet
208             #
209              
210             sub decode {
211 10     10 1 50 my $class = shift;
212 10         23 my($pkt, $parent) = @_;
213 10         25 my $self = {};
214              
215             # Class fields
216              
217 10         34 $self->{_parent} = $parent;
218 10         21 $self->{_frame} = $pkt;
219              
220             # Decode ICMPv6 packet
221              
222 10 50       27 if (defined($pkt)) {
223 10         46 ($self->{type}, $self->{code}, $self->{cksum}, $self->{data}) =
224             unpack("CCna*", $pkt);
225             }
226              
227             # Return a blessed object
228              
229 10         21 bless($self, $class);
230 10         28 return $self;
231             }
232              
233             #
234             # Strip a packet of its header and return the data
235             #
236              
237             undef &icmpv6_strip;
238             *icmpv6strip = \&strip;
239              
240             sub strip {
241 0     0 1 0 my ($pkt) = @_;
242              
243 0         0 my $icmpv6_obj = decode($pkt);
244 0         0 return $icmpv6_obj->{data};
245             }
246              
247             #
248             # Encode a packet
249             #
250              
251             sub encode {
252 5     5 1 11360 my $self = shift;
253 5         19 my ($ipv6) = @_;
254            
255             # Checksum the packet
256 5         21 $self->checksum($ipv6);
257              
258             # Put the packet together
259             my $packet = pack("CCna*", $self->{type}, $self->{code},
260 5         21 $self->{cksum}, $self->{data});
261              
262 5         21 return($packet);
263             }
264              
265             #
266             # Calculate ICMPv6 checksum
267              
268             sub checksum {
269 5     5 0 10 my $self = shift;
270 5         10 my ($ipv6) = @_;
271              
272             # Put the packet together for checksumming
273 5         16 my $len = length($self->{data}) + 32;
274 5         28 my $packet = $ipv6->pseudo_header($len, IP_PROTO_ICMPv6);
275 5         27 $packet .= pack("CCna*", $self->{type}, $self->{code}, 0, $self->{data});
276              
277 5         32 $self->{cksum} = NetPacket::htons(NetPacket::in_cksum($packet));
278             }
279              
280              
281             #
282             # Module initialisation
283             #
284              
285             1;
286              
287             # autoloaded methods go after the END token (&& pod) below
288              
289             =pod
290              
291             =head1 NAME
292              
293             NetPacket::ICMPv6 - Assemble and disassemble ICMPv6 (Internet Control Message Protocol for IPv6) packets.
294              
295             =head1 VERSION
296              
297             version 1.7.2
298              
299             =head1 SYNOPSIS
300              
301             use NetPacket::ICMPv6;
302              
303             $icmpv6_obj = NetPacket::ICMPv6->decode($raw_pkt);
304             $icmpv6_pkt = NetPacket::ICMPv6->encode($ipv6_pkt);
305             $icmpv6_data = NetPacket::ICMPv6::strip($raw_pkt);
306              
307             =head1 DESCRIPTION
308              
309             C provides a set of routines for assembling and
310             disassembling packets using ICMPv6 (Internet Control Message Protocol
311             for IPv6).
312              
313             =head2 Methods
314              
315             =over
316              
317             =item Cdecode([RAW PACKET])>
318              
319             Decode the raw packet data given and return an object containing
320             instance data. This method will quite happily decode garbage input.
321             It is the responsibility of the programmer to ensure valid packet data
322             is passed to this method.
323              
324             =item Cencode($ipv6_obj)>
325              
326             Return an ICMPv6 packet encoded with the instance data specified.
327             Needs parts of the IPv6 header contained in $ipv6_obj in order to calculate
328             the ICMPv6 checksum.
329              
330             =back
331              
332             =head2 Functions
333              
334             =over
335              
336             =item C
337              
338             Return the encapsulated data (or payload) contained in the ICMPv6
339             packet.
340              
341             =back
342              
343             =head2 Instance data
344              
345             The instance data for the C object consists of
346             the following fields.
347              
348             =over
349              
350             =item type
351              
352             The ICMPv6 message type of this packet.
353              
354             =item code
355              
356             The ICMPv6 message code of this packet.
357              
358             =item cksum
359              
360             The checksum for this packet.
361              
362             =item data
363              
364             The encapsulated data (payload) for this packet.
365              
366             =back
367              
368             =head2 Exports
369              
370             =over
371              
372             =item default
373              
374             none
375              
376             =item exportable
377              
378             ICMPv6 message types:
379              
380             ICMPv6_UNREACH ICMPv6_TOOBIG ICMPv6_TIMXCEED ICMPv6_PARAMPROB
381             ICMPv6_PRIVATEERROR1 ICMPv6_PRIVATEERROR2 ICMPv6_EXPANSIONERROR
382             ICMPv6_ECHOREQ ICMPv6_ECHOREPLY ICMPv6_MULTICASTQUERY
383             ICMPv6_MULTICASTREPORT ICMPv6_MULTICASTDONE
384             ICMPv6_ROUTERSOLICIT ICMPv6_ROUTERADVERT
385             ICMPv6_NEIGHBORSOLICIT ICMPv6_NEIGHBORADVERT
386             ICMPv6_REDIRECT ICMPv6_ROUTERRENUMBER
387             ICMPv6_NODEINFOQUERY ICMPv6_NODEINFOREPLY
388             ICMPv6_INVNEIGHBORSOLICIT ICMPv6_INVNEIGHBORADVERT
389             ICMPv6_MULTICASTREPORTV2
390             ICMPv6_HOMEAGENTREQUEST ICMPv6_HOMEAGENTREPLY
391             ICMPv6_MOBILEPREFIXSOLICIT ICMPv6_MOBILEPREFIXADVERT
392             ICMPv6_CERTPATHSOLICIT ICMPv6_CERTPATHADVERT
393             ICMPv6_MULTICASTADVERT ICMPv6_MULTICASTSOLICIT
394             ICMPv6_MULTICASTTERM ICMPv6_FMIPv6 ICMPv6_RPLCONTROL
395             ICMPv6_DUPREQUEST ICMPv6_DUPCONFIRM ICMPv6_MPLCONTROL
396             ICMPv6_EXTECHOREQ ICMPv6_EXTECHOREPLY
397             ICMPv6_PRIVATEINFO1 ICMPv6_PRIVATEINFO2 ICMPv6_EXPANSIONINFO
398              
399             ICMPv6 message codes:
400              
401             ICMPv6_UNREACH_NO_ROUTE ICMPv6_UNREACH_COMM_PROHIB
402             ICMPv6_UNREACH_BEYOND_SCOPE ICMPv6_UNREACH_ADDRESS ICMPv6_UNREACH_PORT
403             ICMPv6_UNREACH_SRC_FAIL_POLICY ICMPv6_UNREACH_REJECT_DEST
404             ICMPv6_TIMXCEED_INTRANS ICMPv6_TIMXCEED_REASS
405             ICMPv6_PARAMPROB_HEADER_FIELD ICMPv6_PARAMPROB_NEXT_HEADER
406             ICMPv6_PARAMPROB_OPTION
407             ICMPv6_ROUTERRENUMBER_COMMAND ICMPv6_ROUTERRENUMBER_RESULT
408             ICMPv6_ROUTERRENUMBER_RESET
409             ICMPv6_NODEINFOQUERY_IPv6 ICMPv6_NODEINFOQUERY_NAME
410             ICMPv6_NODEINFOQUERY_IPv4 ICMPv6_NODEINFOREPLY_SUCCESS
411             ICMPv6_NODEINFOREPLY_REFUSED ICMPv6_NODEINFOREPLY_UNKNOWN
412             ICMPv6_RPLCONTROL_DODAG_SOLICIT ICMPv6_RPLCONTROL_DODAG_OBJECT
413             ICMPv6_RPLCONTROL_DEST_ADVERT ICMPv6_RPLCONTROL_DEST_ACK
414             ICMPv6_RPLCONTROL_SECURE_DODAG_SOLICIT ICMPv6_RPLCONTROL_SECURE_DODAG_OBJECT
415             ICMPv6_RPLCONTROL_SECURE_DEST_ADVERT ICMPv6_RPLCONTROL_SECURE_DEST_ACK
416             ICMPv6_RPLCONTROL_CONSISTENCY
417             ICMPv6_EXTECHOREPLY_NO_ERROR ICMPv6_EXTECHOREPLY_MALFORMED
418             ICMPv6_EXTECHOREPLY_NO_INTERFACE ICMPv6_EXTECHOREPLY_NO_ENTRY
419             ICMPv6_EXTECHOREPLY_MULTIPLE
420              
421             =item tags
422              
423             The following tags group together related exportable items.
424              
425             =over
426              
427             =item C<:types>
428              
429             =item C<:codes>
430              
431             =item C<:strip>
432              
433             Import the strip function C.
434              
435             =item C<:ALL>
436              
437             All the above exportable items.
438              
439             =back
440              
441             =back
442              
443             =head1 EXAMPLE
444              
445             The following example prints the ICMPv6 type, code, and checksum
446             fields.
447              
448             #!/usr/bin/perl
449              
450             use strict;
451             use warnings;
452             use Net::PcapUtils;
453             use NetPacket::Ethernet qw(:strip);
454             use NetPacket::IPv6 qw(:strip);
455             use NetPacket::ICMPv6;
456              
457             sub process_pkt {
458             my ($user, $hdr, $pkt) = @_;
459              
460             my $icmpv6_obj = NetPacket::ICMPv6->decode(ipv6_strip(eth_strip($pkt)));
461              
462             print("Type: $icmpv6_obj->{type}\n");
463             print("Code: $icmpv6_obj->{code}\n");
464             print("Checksum: $icmpv6_obj->{cksum}\n\n");
465             }
466              
467             Net::PcapUtils::loop(\&process_pkt, FILTER => 'icmp6');
468              
469             =head1 COPYRIGHT
470              
471             Copyright (c) 2018 Dan Book.
472              
473             This module is free software. You can redistribute it and/or
474             modify it under the terms of the Artistic License 2.0.
475              
476             This program is distributed in the hope that it will be useful,
477             but without any warranty; without even the implied warranty of
478             merchantability or fitness for a particular purpose.
479              
480             =head1 AUTHOR
481              
482             Dan Book Edbook@cpan.orgE
483              
484             =cut
485              
486             __END__