Preparation Host Flows: Dissector Packet ICMP and ICMPv6
[metze/wireshark/wip.git] / epan / dissectors / packet-icmpv6.c
1 /* packet-icmpv6.c
2  * Routines for ICMPv6 packet disassembly
3  *
4  * Wireshark - Network traffic analyzer
5  * By Gerald Combs <gerald@wireshark.org>
6  * Copyright 1998 Gerald Combs
7  *
8  * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@siemens.hr>
9  * Copyright 2006, Nicolas DICHTEL - 6WIND - <nicolas.dichtel@6wind.com>
10  *
11  * HMIPv6 support added by Martti Kuparinen <martti.kuparinen@iki.fi>
12  *
13  * FMIPv6 support added by Martin Andre <andre@clarinet.u-strasbg.fr>
14  *
15  * RPL support added by Colin O'Flynn & Owen Kirby.
16  *
17  * Enhance ICMPv6 dissector by Alexis La Goutte
18  *
19  * P2P-RPL support added by Cenk Gundogan <cnkgndgn@gmail.com>
20  *
21  * This program is free software; you can redistribute it and/or
22  * modify it under the terms of the GNU General Public License
23  * as published by the Free Software Foundation; either version 2
24  * of the License, or (at your option) any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  * GNU General Public License for more details.
30  *
31  * You should have received a copy of the GNU General Public License
32  * along with this program; if not, write to the Free Software
33  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
34  */
35
36 #include "config.h"
37
38 #include "math.h"
39
40 #include <epan/packet.h>
41 #include <epan/in_cksum.h>
42 #include <epan/ipproto.h>
43 #include <epan/expert.h>
44 #include <epan/conversation.h>
45 #include <epan/tap.h>
46
47 #include "packet-ber.h"
48 #include "packet-dns.h"
49 #include "packet-x509af.h"
50 #include "packet-x509if.h"
51 #include "packet-icmp.h"    /* same transaction_t used both both v4 and v6 */
52 #include "packet-ieee802154.h"
53 #include "packet-6lowpan.h"
54 #include "packet-ip.h"
55
56 void proto_register_icmpv6(void);
57 void proto_reg_handoff_icmpv6(void);
58
59 /*
60  * The information used comes from:
61  * RFC 1885/2463/4443: Internet Control Message Protocol (ICMPv6) for the Internet Protocol Version 6 (IPv6) Specification
62  * RFC 2461/4861: Neighbor Discovery for IP Version 6 (IPv6)
63  * RFC 2491: IPv6 over Non-Broadcast Multiple Access (NBMA) networks
64  * RFC 2710: Multicast Listener Discovery for IPv6
65  * RFC 2894: Router Renumbering for IPv6
66  * RFC 3122: Extensions to IPv6 Neighbor Discovery for Inverse Discovery Specification
67  * RFC 3775/6275: Mobility Support in IPv6
68  * RFC 3810: Multicast Listener Discovery Version 2 (MLDv2) for IPv6
69  * RFC 3971: SEcure Neighbor Discovery (SEND)
70  * RFC 4065: Instructions for Seamoby and Experimental Mobility Protocol IANA Allocations
71  * RFC 4068/5268/5568: Fast Handovers for Mobile IPv6 (Mobile IPv6 Fast Handovers)
72  * RFC 4140/5380: Hierarchical Mobile IPv6 Mobility Management (HMIPv6)
73  * RFC 4191: Default Router Preferences and More-Specific Routes
74  * RFC 4286: Multicast Router Discovery
75  * RFC 4620: IPv6 Node Information Queries
76  * RFC 5006/6106: IPv6 Router Advertisement Options for DNS Configuration
77  * RFC 5075/5175: IPv6 Router Advertisement Flags Option
78  * RFC 5269: Distributing a Symmetric Fast Mobile IPv6 (FMIPv6) Handover Key Using SEcure Neighbor Discovery (SEND)
79  * RFC 5271: Mobile IPv6 Fast Handovers for 3G CDMA Networks
80  * RFC 6275: Mobility Support in IPv6
81  * RFC 6495: Subject Key Identifier (SKI) SEND Name Type fields
82  * RFC 6496: Secure Proxy ND Support for SEND
83  * RFC 6550: RPL: IPv6 Routing Protocol for Low power and Lossy Networks
84  * RFC 6554: An IPv6 Routing Header for Source Routes with RPL
85  * RFC 6743: ICMP Locator Update message for ILNPv6
86  * RFC 6775: Neighbor Discovery Optimization for Low Power and Lossy Networks (6LoWPAN)
87  * RFC 6997: Reactive Discovery of Point-to-Point Routes in Low-Power and Lossy Networks
88  * RFC 7112: Implications of Oversized IPv6 Header Chains
89  * RFC 7400: 6LoWPAN-GHC: Generic Header Compression for IPv6 over Low-Power Wireless Personal Area Networks (6LoWPANs)
90  * http://www.iana.org/assignments/icmpv6-parameters (last updated 2015-01-22)
91  */
92
93 static int proto_icmpv6 = -1;
94 static int hf_icmpv6_type = -1;
95 static int hf_icmpv6_code = -1;
96 static int hf_icmpv6_checksum = -1;
97 static int hf_icmpv6_checksum_bad = -1;
98 static int hf_icmpv6_reserved = -1;
99 static int hf_icmpv6_data = -1;
100 static int hf_icmpv6_unknown_data = -1;
101 static int hf_icmpv6_mtu = -1;
102 static int hf_icmpv6_pointer = -1;
103 static int hf_icmpv6_echo_identifier = -1;
104 static int hf_icmpv6_echo_sequence_number = -1;
105 static int hf_icmpv6_nonce = -1;
106
107 /* RFC 2461/4861 : Neighbor Discovery for IP version 6 (IPv6) */
108 static int hf_icmpv6_nd_ra_cur_hop_limit = -1;
109 static int hf_icmpv6_nd_ra_flag = -1;
110 static int hf_icmpv6_nd_ra_flag_m = -1;
111 static int hf_icmpv6_nd_ra_flag_o = -1;
112 static int hf_icmpv6_nd_ra_flag_h = -1;
113 static int hf_icmpv6_nd_ra_flag_prf = -1;
114 static int hf_icmpv6_nd_ra_flag_p = -1;
115 static int hf_icmpv6_nd_ra_flag_rsv = -1;
116 static int hf_icmpv6_nd_ra_router_lifetime = -1;
117 static int hf_icmpv6_nd_ra_reachable_time = -1;
118 static int hf_icmpv6_nd_ra_retrans_timer = -1;
119 static int hf_icmpv6_nd_ns_target_address = -1;
120 static int hf_icmpv6_nd_na_flag = -1;
121 static int hf_icmpv6_nd_na_flag_r = -1;
122 static int hf_icmpv6_nd_na_flag_s = -1;
123 static int hf_icmpv6_nd_na_flag_o = -1;
124 static int hf_icmpv6_nd_na_flag_rsv = -1;
125 static int hf_icmpv6_nd_na_target_address = -1;
126 static int hf_icmpv6_nd_rd_target_address = -1;
127 static int hf_icmpv6_nd_rd_destination_address = -1;
128
129 /* ND Options */
130 static int hf_icmpv6_opt = -1;
131 static int hf_icmpv6_opt_type = -1;
132 static int hf_icmpv6_opt_length = -1;
133 static int hf_icmpv6_opt_linkaddr_mac = -1;
134 static int hf_icmpv6_opt_src_linkaddr_mac = -1;
135 static int hf_icmpv6_opt_target_linkaddr_mac = -1;
136 static int hf_icmpv6_opt_linkaddr = -1;
137 static int hf_icmpv6_opt_src_linkaddr = -1;
138 static int hf_icmpv6_opt_target_linkaddr = -1;
139 static int hf_icmpv6_opt_linkaddr_eui64 = -1;
140 static int hf_icmpv6_opt_src_linkaddr_eui64 = -1;
141 static int hf_icmpv6_opt_target_linkaddr_eui64 = -1;
142 static int hf_icmpv6_opt_prefix_len = -1;
143 static int hf_icmpv6_opt_prefix_flag = -1;
144 static int hf_icmpv6_opt_prefix_flag_l = -1;
145 static int hf_icmpv6_opt_prefix_flag_a = -1;
146 static int hf_icmpv6_opt_prefix_flag_r = -1;
147 static int hf_icmpv6_opt_prefix_flag_reserved = -1;
148 static int hf_icmpv6_opt_prefix_valid_lifetime = -1;
149 static int hf_icmpv6_opt_prefix_preferred_lifetime = -1;
150 static int hf_icmpv6_opt_prefix = -1;
151 static int hf_icmpv6_opt_naack_option_code = -1;
152 static int hf_icmpv6_opt_naack_status = -1;
153 static int hf_icmpv6_opt_naack_supplied_ncoa = -1;
154 static int hf_icmpv6_opt_cga_pad_len = -1;
155 static int hf_icmpv6_opt_cga = -1;
156 static int hf_icmpv6_opt_cga_modifier = -1;
157 static int hf_icmpv6_opt_cga_subnet_prefix = -1;
158 static int hf_icmpv6_opt_cga_count = -1;
159 static int hf_icmpv6_opt_cga_ext_type = -1;
160 static int hf_icmpv6_opt_cga_ext_length = -1;
161 static int hf_icmpv6_opt_cga_ext_data = -1;
162 static int hf_icmpv6_opt_rsa_key_hash = -1;
163 static int hf_icmpv6_opt_digital_signature_padding = -1;
164 static int hf_icmpv6_opt_ps_key_hash = -1;
165 static int hf_icmpv6_opt_timestamp = -1;
166 static int hf_icmpv6_opt_nonce = -1;
167 static int hf_icmpv6_opt_certificate_padding = -1;
168 static int hf_icmpv6_opt_ipa_option_code = -1;
169 static int hf_icmpv6_opt_ipa_prefix_len = -1;
170 static int hf_icmpv6_opt_ipa_ipv6_address = -1;
171 static int hf_icmpv6_opt_nrpi_option_code = -1;
172 static int hf_icmpv6_opt_nrpi_prefix_len = -1;
173 static int hf_icmpv6_opt_nrpi_prefix = -1;
174 static int hf_icmpv6_opt_lla_option_code = -1;
175 static int hf_icmpv6_opt_lla_bytes = -1;
176 static int hf_icmpv6_opt_map_dist = -1;
177 static int hf_icmpv6_opt_map_pref = -1;
178 static int hf_icmpv6_opt_map_flag = -1;
179 static int hf_icmpv6_opt_map_flag_r = -1;
180 static int hf_icmpv6_opt_map_flag_reserved = -1;
181 static int hf_icmpv6_opt_map_valid_lifetime = -1;
182 static int hf_icmpv6_opt_map_global_address = -1;
183 static int hf_icmpv6_opt_route_info_flag = -1;
184 static int hf_icmpv6_opt_route_info_flag_route_preference = -1;
185 static int hf_icmpv6_opt_route_info_flag_reserved = -1;
186 static int hf_icmpv6_opt_route_lifetime = -1;
187 static int hf_icmpv6_opt_name_type = -1;
188 static int hf_icmpv6_opt_name_x501 = -1;
189 static int hf_icmpv6_opt_name_fqdn = -1;
190 static int hf_icmpv6_opt_cert_type = -1;
191 static int hf_icmpv6_x509if_Name = -1;
192 static int hf_icmpv6_x509af_Certificate = -1;
193 static int hf_icmpv6_opt_redirected_packet = -1;
194 static int hf_icmpv6_opt_mtu = -1;
195 static int hf_icmpv6_opt_nbma_shortcut_limit = -1;
196 static int hf_icmpv6_opt_advertisement_interval = -1;
197 static int hf_icmpv6_opt_home_agent_preference = -1;
198 static int hf_icmpv6_opt_home_agent_lifetime = -1;
199 static int hf_icmpv6_opt_ipv6_address = -1;
200 static int hf_icmpv6_opt_reserved = -1;
201 static int hf_icmpv6_opt_padding = -1;
202 static int hf_icmpv6_opt_rdnss_lifetime = -1;
203 static int hf_icmpv6_opt_rdnss = -1;
204 static int hf_icmpv6_opt_efo = -1;
205 static int hf_icmpv6_opt_efo_m = -1;
206 static int hf_icmpv6_opt_efo_o = -1;
207 static int hf_icmpv6_opt_efo_h = -1;
208 static int hf_icmpv6_opt_efo_prf = -1;
209 static int hf_icmpv6_opt_efo_p = -1;
210 static int hf_icmpv6_opt_efo_rsv = -1;
211 static int hf_icmpv6_opt_hkr_pad_length = -1;
212 static int hf_icmpv6_opt_hkr_at = -1;
213 static int hf_icmpv6_opt_hkr_reserved = -1;
214 static int hf_icmpv6_opt_hkr_encryption_public_key = -1;
215 static int hf_icmpv6_opt_hkr_padding = -1;
216 static int hf_icmpv6_opt_hkr_lifetime = -1;
217 static int hf_icmpv6_opt_hkr_encrypted_handover_key = -1;
218 static int hf_icmpv6_opt_hai_option_code = -1;
219 static int hf_icmpv6_opt_hai_length = -1;
220 static int hf_icmpv6_opt_hai_value = -1;
221 static int hf_icmpv6_opt_mn_option_code = -1;
222 static int hf_icmpv6_opt_mn_length = -1;
223 static int hf_icmpv6_opt_mn_value = -1;
224 static int hf_icmpv6_opt_dnssl_lifetime = -1;
225 static int hf_icmpv6_opt_dnssl = -1;
226
227 static int hf_icmpv6_opt_aro_status = -1;
228 static int hf_icmpv6_opt_aro_registration_lifetime = -1;
229 static int hf_icmpv6_opt_aro_eui64 = -1;
230 static int hf_icmpv6_opt_6co_context_length = -1;
231 static int hf_icmpv6_opt_6co_flag = -1;
232 static int hf_icmpv6_opt_6co_flag_c = -1;
233 static int hf_icmpv6_opt_6co_flag_cid = -1;
234 static int hf_icmpv6_opt_6co_flag_reserved = -1;
235 static int hf_icmpv6_opt_6co_valid_lifetime = -1;
236 static int hf_icmpv6_opt_6co_context_prefix  = -1;
237 static int hf_icmpv6_opt_abro_version_low = -1;
238 static int hf_icmpv6_opt_abro_version_high = -1;
239 static int hf_icmpv6_opt_abro_valid_lifetime = -1;
240 static int hf_icmpv6_opt_abro_6lbr_address = -1;
241 static int hf_icmpv6_opt_6cio_unassigned1 = -1;
242 static int hf_icmpv6_opt_6cio_flag_g = -1;
243 static int hf_icmpv6_opt_6cio_unassigned2 = -1;
244
245 /* RFC 2710: Multicast Listener Discovery for IPv6 */
246 static int hf_icmpv6_mld_mrd = -1;
247 static int hf_icmpv6_mld_multicast_address = -1;
248
249 /* RFC 2894: Router Renumbering for IPv6 */
250 static int hf_icmpv6_rr_sequencenumber = -1;
251 static int hf_icmpv6_rr_segmentnumber = -1;
252 static int hf_icmpv6_rr_flag = -1;
253 static int hf_icmpv6_rr_flag_t = -1;
254 static int hf_icmpv6_rr_flag_r = -1;
255 static int hf_icmpv6_rr_flag_a = -1;
256 static int hf_icmpv6_rr_flag_s = -1;
257 static int hf_icmpv6_rr_flag_p = -1;
258 static int hf_icmpv6_rr_flag_rsv = -1;
259 static int hf_icmpv6_rr_maxdelay = -1;
260 static int hf_icmpv6_rr_pco_mp_part = -1;
261 static int hf_icmpv6_rr_pco_mp_opcode = -1;
262 static int hf_icmpv6_rr_pco_mp_oplength = -1;
263 static int hf_icmpv6_rr_pco_mp_ordinal = -1;
264 static int hf_icmpv6_rr_pco_mp_matchlen = -1;
265 static int hf_icmpv6_rr_pco_mp_minlen = -1;
266 static int hf_icmpv6_rr_pco_mp_maxlen = -1;
267 static int hf_icmpv6_rr_pco_mp_matchprefix = -1;
268 static int hf_icmpv6_rr_pco_up_part = -1;
269 static int hf_icmpv6_rr_pco_up_uselen = -1;
270 static int hf_icmpv6_rr_pco_up_keeplen = -1;
271 static int hf_icmpv6_rr_pco_up_flagmask = -1;
272 static int hf_icmpv6_rr_pco_up_flagmask_l = -1;
273 static int hf_icmpv6_rr_pco_up_flagmask_a = -1;
274 static int hf_icmpv6_rr_pco_up_flagmask_reserved = -1;
275 static int hf_icmpv6_rr_pco_up_raflags = -1;
276 static int hf_icmpv6_rr_pco_up_raflags_l = -1;
277 static int hf_icmpv6_rr_pco_up_raflags_a = -1;
278 static int hf_icmpv6_rr_pco_up_raflags_reserved = -1;
279 static int hf_icmpv6_rr_pco_up_validlifetime = -1;
280 static int hf_icmpv6_rr_pco_up_preferredlifetime = -1;
281 static int hf_icmpv6_rr_pco_up_flag = -1;
282 static int hf_icmpv6_rr_pco_up_flag_v = -1;
283 static int hf_icmpv6_rr_pco_up_flag_p = -1;
284 static int hf_icmpv6_rr_pco_up_flag_reserved = -1;
285 static int hf_icmpv6_rr_pco_up_useprefix = -1;
286 static int hf_icmpv6_rr_rm = -1;
287 static int hf_icmpv6_rr_rm_flag = -1;
288 static int hf_icmpv6_rr_rm_flag_b = -1;
289 static int hf_icmpv6_rr_rm_flag_f = -1;
290 static int hf_icmpv6_rr_rm_flag_reserved = -1;
291 static int hf_icmpv6_rr_rm_ordinal = -1;
292 static int hf_icmpv6_rr_rm_matchedlen = -1;
293 static int hf_icmpv6_rr_rm_interfaceindex = -1;
294 static int hf_icmpv6_rr_rm_matchedprefix = -1;
295
296 /* RFC 3810: Multicast Listener Discovery Version 2 (MLDv2) for IPv6 */
297 static int hf_icmpv6_mld_mrc = -1;
298 static int hf_icmpv6_mld_flag = -1;
299 static int hf_icmpv6_mld_flag_s = -1;
300 static int hf_icmpv6_mld_flag_qrv = -1;
301 static int hf_icmpv6_mld_flag_rsv = -1;
302 static int hf_icmpv6_mld_qqi = -1;
303 static int hf_icmpv6_mld_nb_sources = -1;
304 static int hf_icmpv6_mld_source_address = -1;
305 static int hf_icmpv6_mldr_nb_mcast_records = -1;
306 static int hf_icmpv6_mldr_mar = -1;
307 static int hf_icmpv6_mldr_mar_record_type = -1;
308 static int hf_icmpv6_mldr_mar_aux_data_len = -1;
309 static int hf_icmpv6_mldr_mar_nb_sources = -1;
310 static int hf_icmpv6_mldr_mar_multicast_address = -1;
311 static int hf_icmpv6_mldr_mar_source_address = -1;
312 static int hf_icmpv6_mldr_mar_auxiliary_data = -1;
313
314 /* RFC3775/6275: Mobility Support in IPv6 */
315 static int hf_icmpv6_mip6_identifier = -1;
316 static int hf_icmpv6_mip6_home_agent_address = -1;
317 static int hf_icmpv6_mip6_flag = -1;
318 static int hf_icmpv6_mip6_flag_m = -1;
319 static int hf_icmpv6_mip6_flag_o = -1;
320 static int hf_icmpv6_mip6_flag_rsv = -1;
321
322 /* RFC3971: SEcure Neighbor Discovery (SEND) */
323 static int hf_icmpv6_send_identifier = -1;
324 static int hf_icmpv6_send_all_components = -1;
325 static int hf_icmpv6_send_component = -1;
326
327 /* RFC 4068/5268/5568: Fast Handovers for Mobile IPv6 ( Mobile IPv6 Fast Handovers ) */
328 static int hf_icmpv6_fmip6_subtype = -1;
329 static int hf_icmpv6_fmip6_hi_flag = -1;
330 static int hf_icmpv6_fmip6_hi_flag_s = -1;
331 static int hf_icmpv6_fmip6_hi_flag_u = -1;
332 static int hf_icmpv6_fmip6_hi_flag_reserved = -1;
333 static int hf_icmpv6_fmip6_identifier = -1;
334
335 /* RFC 4286: Multicast Router Discovery */
336 static int hf_icmpv6_mcast_ra_query_interval = -1;
337 static int hf_icmpv6_mcast_ra_robustness_variable = -1;
338
339 /* RFC 4620: IPv6 Node Information Queries */
340 static int hf_icmpv6_ni_qtype = -1;
341 static int hf_icmpv6_ni_flag = -1;
342 static int hf_icmpv6_ni_flag_g = -1;
343 static int hf_icmpv6_ni_flag_s = -1;
344 static int hf_icmpv6_ni_flag_l = -1;
345 static int hf_icmpv6_ni_flag_c = -1;
346 static int hf_icmpv6_ni_flag_a = -1;
347 static int hf_icmpv6_ni_flag_t = -1;
348 static int hf_icmpv6_ni_flag_rsv = -1;
349 static int hf_icmpv6_ni_nonce = -1;
350 static int hf_icmpv6_ni_query_subject_ipv6 = -1;
351 static int hf_icmpv6_ni_query_subject_fqdn = -1;
352 static int hf_icmpv6_ni_query_subject_ipv4 = -1;
353 static int hf_icmpv6_ni_reply_node_ttl = -1;
354 static int hf_icmpv6_ni_reply_node_name = -1;
355 static int hf_icmpv6_ni_reply_node_address = -1;
356 static int hf_icmpv6_ni_reply_ipv4_address = -1;
357
358 /* RPL: RFC 6550/6997 : Routing and Discovery of P2P Routes in Low-Power and Lossy Networks. */
359 static int hf_icmpv6_rpl_dis_flag = -1;
360 static int hf_icmpv6_rpl_dio_instance = -1;
361 static int hf_icmpv6_rpl_dio_version = -1;
362 static int hf_icmpv6_rpl_dio_rank = -1;
363 static int hf_icmpv6_rpl_dio_flag = -1;
364 static int hf_icmpv6_rpl_dio_flag_g = -1;
365 static int hf_icmpv6_rpl_dio_flag_0 = -1;
366 static int hf_icmpv6_rpl_dio_flag_mop = -1;
367 static int hf_icmpv6_rpl_dio_flag_prf = -1;
368 static int hf_icmpv6_rpl_dio_dtsn = -1;
369 static int hf_icmpv6_rpl_dio_dagid = -1;
370 static int hf_icmpv6_rpl_dao_instance = -1;
371 static int hf_icmpv6_rpl_dao_flag = -1;
372 static int hf_icmpv6_rpl_dao_flag_k = -1;
373 static int hf_icmpv6_rpl_dao_flag_d = -1;
374 static int hf_icmpv6_rpl_dao_flag_rsv = -1;
375 static int hf_icmpv6_rpl_dao_sequence = -1;
376 static int hf_icmpv6_rpl_dao_dodagid = -1;
377 static int hf_icmpv6_rpl_daoack_instance = -1;
378 static int hf_icmpv6_rpl_daoack_flag = -1;
379 static int hf_icmpv6_rpl_daoack_flag_d = -1;
380 static int hf_icmpv6_rpl_daoack_flag_rsv = -1;
381 static int hf_icmpv6_rpl_daoack_sequence = -1;
382 static int hf_icmpv6_rpl_daoack_status = -1;
383 static int hf_icmpv6_rpl_daoack_dodagid = -1;
384 static int hf_icmpv6_rpl_cc_instance = -1;
385 static int hf_icmpv6_rpl_cc_flag = -1;
386 static int hf_icmpv6_rpl_cc_flag_r = -1;
387 static int hf_icmpv6_rpl_cc_flag_rsv = -1;
388 static int hf_icmpv6_rpl_cc_nonce = -1;
389 static int hf_icmpv6_rpl_cc_dodagid = -1;
390 static int hf_icmpv6_rpl_cc_destination_counter = -1;
391 static int hf_icmpv6_rpl_secure_flag = -1;
392 static int hf_icmpv6_rpl_secure_flag_t = -1;
393 static int hf_icmpv6_rpl_secure_flag_rsv = -1;
394 static int hf_icmpv6_rpl_secure_algorithm = -1;
395 static int hf_icmpv6_rpl_secure_algorithm_encryption = -1;
396 static int hf_icmpv6_rpl_secure_algorithm_signature = -1;
397 static int hf_icmpv6_rpl_secure_kim = -1;
398 static int hf_icmpv6_rpl_secure_lvl = -1;
399 static int hf_icmpv6_rpl_secure_rsv = -1;
400 static int hf_icmpv6_rpl_secure_counter = -1;
401 static int hf_icmpv6_rpl_secure_key_source = -1;
402 static int hf_icmpv6_rpl_secure_key_index = -1;
403 static int hf_icmpv6_rpl_opt = -1;
404 static int hf_icmpv6_rpl_opt_type = -1;
405 static int hf_icmpv6_rpl_opt_length = -1;
406 static int hf_icmpv6_rpl_opt_reserved = -1;
407 static int hf_icmpv6_rpl_opt_padn = -1;
408 static int hf_icmpv6_rpl_opt_route_prefix_length = -1;
409 static int hf_icmpv6_rpl_opt_route_flag = -1;
410 static int hf_icmpv6_rpl_opt_route_pref = -1;
411 static int hf_icmpv6_rpl_opt_route_reserved = -1;
412 static int hf_icmpv6_rpl_opt_route_lifetime = -1;
413 static int hf_icmpv6_rpl_opt_route_prefix = -1;
414 static int hf_icmpv6_rpl_opt_config_flag = -1;
415 static int hf_icmpv6_rpl_opt_config_reserved = -1;
416 static int hf_icmpv6_rpl_opt_config_auth = -1;
417 static int hf_icmpv6_rpl_opt_config_pcs = -1;
418 static int hf_icmpv6_rpl_opt_config_doublings = -1;
419 static int hf_icmpv6_rpl_opt_config_min_interval = -1;
420 static int hf_icmpv6_rpl_opt_config_redundancy = -1;
421 static int hf_icmpv6_rpl_opt_config_rank_incr = -1;
422 static int hf_icmpv6_rpl_opt_config_hop_rank_inc = -1;
423 static int hf_icmpv6_rpl_opt_config_ocp = -1;
424 static int hf_icmpv6_rpl_opt_config_rsv = -1;
425 static int hf_icmpv6_rpl_opt_config_def_lifetime = -1;
426 static int hf_icmpv6_rpl_opt_config_lifetime_unit = -1;
427 static int hf_icmpv6_rpl_opt_target_flag = -1;
428 static int hf_icmpv6_rpl_opt_target_prefix_length = -1;
429 static int hf_icmpv6_rpl_opt_target_prefix = -1;
430 static int hf_icmpv6_rpl_opt_transit_flag = -1;
431 static int hf_icmpv6_rpl_opt_transit_flag_e = -1;
432 static int hf_icmpv6_rpl_opt_transit_flag_rsv = -1;
433 static int hf_icmpv6_rpl_opt_transit_pathseq = -1;
434 static int hf_icmpv6_rpl_opt_transit_pathctl = -1;
435 static int hf_icmpv6_rpl_opt_transit_pathlifetime = -1;
436 static int hf_icmpv6_rpl_opt_transit_parent = -1;
437 static int hf_icmpv6_rpl_opt_solicited_instance = -1;
438 static int hf_icmpv6_rpl_opt_solicited_flag = -1;
439 static int hf_icmpv6_rpl_opt_solicited_flag_v = -1;
440 static int hf_icmpv6_rpl_opt_solicited_flag_i = -1;
441 static int hf_icmpv6_rpl_opt_solicited_flag_d = -1;
442 static int hf_icmpv6_rpl_opt_solicited_flag_rsv = -1;
443 static int hf_icmpv6_rpl_opt_solicited_dodagid = -1;
444 static int hf_icmpv6_rpl_opt_solicited_version = -1;
445 static int hf_icmpv6_rpl_opt_prefix = -1;
446 static int hf_icmpv6_rpl_opt_prefix_flag = -1;
447 static int hf_icmpv6_rpl_opt_prefix_flag_l = -1;
448 static int hf_icmpv6_rpl_opt_prefix_flag_a = -1;
449 static int hf_icmpv6_rpl_opt_prefix_flag_r = -1;
450 static int hf_icmpv6_rpl_opt_prefix_flag_rsv = -1;
451 static int hf_icmpv6_rpl_opt_prefix_vlifetime = -1;
452 static int hf_icmpv6_rpl_opt_prefix_plifetime = -1;
453 static int hf_icmpv6_rpl_opt_prefix_length = -1;
454 static int hf_icmpv6_rpl_opt_targetdesc = -1;
455 static int hf_icmpv6_rpl_opt_route_discovery_flag = -1;
456 static int hf_icmpv6_rpl_opt_route_discovery_reply = -1;
457 static int hf_icmpv6_rpl_opt_route_discovery_hop_by_hop = -1;
458 static int hf_icmpv6_rpl_opt_route_discovery_num_of_routes = -1;
459 static int hf_icmpv6_rpl_opt_route_discovery_compr = -1;
460 static int hf_icmpv6_rpl_opt_route_discovery_lifetime = -1;
461 static int hf_icmpv6_rpl_opt_route_discovery_nh = -1;
462 static int hf_icmpv6_rpl_opt_route_discovery_maxrank = -1;
463 static int hf_icmpv6_rpl_opt_route_discovery_target_addr = -1;
464 static int hf_icmpv6_rpl_opt_route_discovery_addr_vec = -1;
465 static int hf_icmpv6_rpl_opt_route_discovery_addr_vec_addr = -1;
466 static int hf_icmpv6_rpl_p2p_dro_instance = -1;
467 static int hf_icmpv6_rpl_p2p_dro_version = -1;
468 static int hf_icmpv6_rpl_p2p_dro_flag = -1;
469 static int hf_icmpv6_rpl_p2p_dro_flag_stop = -1;
470 static int hf_icmpv6_rpl_p2p_dro_flag_ack = -1;
471 static int hf_icmpv6_rpl_p2p_dro_flag_seq = -1;
472 static int hf_icmpv6_rpl_p2p_dro_flag_reserved = -1;
473 static int hf_icmpv6_rpl_p2p_dro_dagid = -1;
474 static int hf_icmpv6_rpl_p2p_droack_flag = -1;
475 static int hf_icmpv6_rpl_p2p_droack_flag_seq = -1;
476 static int hf_icmpv6_rpl_p2p_droack_flag_reserved = -1;
477
478 /* RFC6743 Locator Update (156) */
479 static int hf_icmpv6_ilnp_nb_locs = -1;
480 static int hf_icmpv6_ilnp_locator = -1;
481 static int hf_icmpv6_ilnp_preference = -1;
482 static int hf_icmpv6_ilnp_lifetime = -1;
483
484 static int hf_icmpv6_da_status = -1;
485 static int hf_icmpv6_da_rsv = -1;
486 static int hf_icmpv6_da_lifetime = -1;
487 static int hf_icmpv6_da_eui64 = -1;
488 static int hf_icmpv6_da_raddr = -1;
489
490 static int icmpv6_tap = -1;
491
492 /* Conversation related data */
493 static int hf_icmpv6_resp_in = -1;
494 static int hf_icmpv6_resp_to = -1;
495 static int hf_icmpv6_no_resp = -1;
496 static int hf_icmpv6_resptime = -1;
497
498 typedef struct _icmpv6_conv_info_t {
499     wmem_tree_t *unmatched_pdus;
500     wmem_tree_t *matched_pdus;
501 } icmpv6_conv_info_t;
502
503 static icmp_transaction_t *transaction_start(packet_info *pinfo, proto_tree *tree, guint32 *key);
504 static icmp_transaction_t *transaction_end(packet_info *pinfo, proto_tree *tree, guint32 *key);
505
506 static gint ett_icmpv6 = -1;
507 static gint ett_icmpv6_opt = -1;
508 static gint ett_icmpv6_mar = -1;
509 static gint ett_icmpv6_flag_prefix = -1;
510 static gint ett_icmpv6_flag_map = -1;
511 static gint ett_icmpv6_flag_route_info = -1;
512 static gint ett_icmpv6_flag_6lowpan = -1;
513 static gint ett_icmpv6_flag_efo = -1;
514 static gint ett_icmpv6_rpl_opt = -1;
515 static gint ett_icmpv6_rpl_flag_routing = -1;
516 static gint ett_icmpv6_rpl_flag_config = -1;
517 static gint ett_icmpv6_rpl_flag_transit = -1;
518 static gint ett_icmpv6_rpl_flag_solicited = -1;
519 static gint ett_icmpv6_rpl_flag_prefix = -1;
520 static gint ett_icmpv6_rpl_route_discovery_flag = -1;
521 static gint ett_icmpv6_rpl_route_discovery_addr_vec = -1;
522 static gint ett_icmpv6_rpl_p2p_dro_flag = -1;
523 static gint ett_icmpv6_rpl_p2p_droack_flag = -1;
524 static gint ett_icmpv6_flag_ni = -1;
525 static gint ett_icmpv6_flag_rr = -1;
526 static gint ett_icmpv6_rr_mp = -1;
527 static gint ett_icmpv6_rr_up = -1;
528 static gint ett_icmpv6_rr_up_flag_mask = -1;
529 static gint ett_icmpv6_rr_up_flag_ra = -1;
530 static gint ett_icmpv6_rr_up_flag = -1;
531 static gint ett_icmpv6_rr_rm = -1;
532 static gint ett_icmpv6_rr_rm_flag = -1;
533 static gint ett_icmpv6_flag_mld = -1;
534 static gint ett_icmpv6_flag_ra = -1;
535 static gint ett_icmpv6_flag_na = -1;
536 static gint ett_icmpv6_flag_mip6 = -1;
537 static gint ett_icmpv6_flag_fmip6 = -1;
538 static gint ett_icmpv6_flag_secure = -1;
539 static gint ett_icmpv6_flag_rpl_dio = -1;
540 static gint ett_icmpv6_flag_rpl_dao = -1;
541 static gint ett_icmpv6_flag_rpl_daoack = -1;
542 static gint ett_icmpv6_flag_rpl_cc = -1;
543 static gint ett_icmpv6_opt_name = -1;
544 static gint ett_icmpv6_cga_param_name = -1;
545
546 static expert_field ei_icmpv6_invalid_option_length = EI_INIT;
547 static expert_field ei_icmpv6_undecoded_option = EI_INIT;
548 static expert_field ei_icmpv6_unknown_data = EI_INIT;
549 static expert_field ei_icmpv6_undecoded_rpl_option = EI_INIT;
550 static expert_field ei_icmpv6_undecoded_type = EI_INIT;
551 static expert_field ei_icmpv6_rr_pco_mp_matchlen = EI_INIT;
552 static expert_field ei_icmpv6_rr_pco_mp_matchedlen = EI_INIT;
553 static expert_field ei_icmpv6_checksum = EI_INIT;
554 static expert_field ei_icmpv6_resp_not_found = EI_INIT;
555 static expert_field ei_icmpv6_rpl_p2p_hop_by_hop = EI_INIT;
556 static expert_field ei_icmpv6_rpl_p2p_num_of_routes = EI_INIT;
557 static expert_field ei_icmpv6_rpl_p2p_dro_rdo_zero = EI_INIT;
558 static expert_field ei_icmpv6_rpl_p2p_dro_zero = EI_INIT;
559
560 static dissector_handle_t icmpv6_handle;
561
562 static dissector_handle_t ipv6_handle;
563 static dissector_handle_t data_handle;
564
565 #define ICMP6_DST_UNREACH                 1
566 #define ICMP6_PACKET_TOO_BIG              2
567 #define ICMP6_TIME_EXCEEDED               3
568 #define ICMP6_PARAM_PROB                  4
569 #define ICMP6_ECHO_REQUEST              128
570 #define ICMP6_ECHO_REPLY                129
571 #define ICMP6_MEMBERSHIP_QUERY          130
572 #define ICMP6_MEMBERSHIP_REPORT         131
573 #define ICMP6_MEMBERSHIP_REDUCTION      132
574 #define ICMP6_ND_ROUTER_SOLICIT         133
575 #define ICMP6_ND_ROUTER_ADVERT          134
576 #define ICMP6_ND_NEIGHBOR_SOLICIT       135
577 #define ICMP6_ND_NEIGHBOR_ADVERT        136
578 #define ICMP6_ND_REDIRECT               137
579 #define ICMP6_ROUTER_RENUMBERING        138
580 #define ICMP6_NI_QUERY                  139
581 #define ICMP6_NI_REPLY                  140
582 #define ICMP6_IND_SOLICIT               141
583 #define ICMP6_IND_ADVERT                142
584 #define ICMP6_MLDV2_REPORT              143
585 #define ICMP6_MIP6_DHAAD_REQUEST        144
586 #define ICMP6_MIP6_DHAAD_REPLY          145
587 #define ICMP6_MIP6_MPS                  146
588 #define ICMP6_MIP6_MPA                  147
589 #define ICMP6_CERT_PATH_SOL             148
590 #define ICMP6_CERT_PATH_AD              149
591 #define ICMP6_EXPERIMENTAL_MOBILITY     150
592 #define ICMP6_MCAST_ROUTER_ADVERT       151
593 #define ICMP6_MCAST_ROUTER_SOLICIT      152
594 #define ICMP6_MCAST_ROUTER_TERM         153
595 #define ICMP6_FMIPV6_MESSAGES           154
596 #define ICMP6_RPL_CONTROL               155
597 #define ICMP6_ILNPV6                    156
598 #define ICMP6_6LOWPANND_DAR             157
599 #define ICMP6_6LOWPANND_DAC             158
600
601
602 static const value_string icmpv6_type_val[] = {
603     { ICMP6_DST_UNREACH,           "Destination Unreachable" },                         /* [RFC4443] */
604     { ICMP6_PACKET_TOO_BIG,        "Packet Too Big" },                                  /* [RFC4443] */
605     { ICMP6_TIME_EXCEEDED,         "Time Exceeded" },                                   /* [RFC4443] */
606     { ICMP6_PARAM_PROB,            "Parameter Problem" },                               /* [RFC4443] */
607     { 100,                         "Private experimentation" },                         /* [RFC4443] */
608     { 101,                         "Private experimentation" },                         /* [RFC4443] */
609     { 127,                         "Reserved for expansion of ICMPv6 error messages" }, /* [RFC4443] */
610     { ICMP6_ECHO_REQUEST,          "Echo (ping) request" },                             /* [RFC4443] */
611     { ICMP6_ECHO_REPLY,            "Echo (ping) reply" },                               /* [RFC4443] */
612     { ICMP6_MEMBERSHIP_QUERY,      "Multicast Listener Query" },                        /* [RFC2710] */
613     { ICMP6_MEMBERSHIP_REPORT,     "Multicast Listener Report" },                       /* [RFC2710] */
614     { ICMP6_MEMBERSHIP_REDUCTION,  "Multicast Listener Done" },                         /* [RFC2710] */
615     { ICMP6_ND_ROUTER_SOLICIT,     "Router Solicitation" },                             /* [RFC4861] */
616     { ICMP6_ND_ROUTER_ADVERT,      "Router Advertisement" },                            /* [RFC4861] */
617     { ICMP6_ND_NEIGHBOR_SOLICIT,   "Neighbor Solicitation" },                           /* [RFC4861] */
618     { ICMP6_ND_NEIGHBOR_ADVERT,    "Neighbor Advertisement" },                          /* [RFC4861] */
619     { ICMP6_ND_REDIRECT,           "Redirect" },                                        /* [RFC4861] */
620     { ICMP6_ROUTER_RENUMBERING,    "Router Renumbering" },                              /* [RFC2894] */
621     { ICMP6_NI_QUERY,              "Node Information Query" },                          /* [RFC4620] */
622     { ICMP6_NI_REPLY,              "Node Information Reply" },                          /* [RFC4620] */
623     { ICMP6_IND_SOLICIT,           "Inverse Neighbor Discovery Solicitation" },         /* [RFC3122] */
624     { ICMP6_IND_ADVERT,            "Inverse Neighbor Discovery Advertisement" },        /* [RFC3122] */
625     { ICMP6_MLDV2_REPORT,          "Multicast Listener Report Message v2" },            /* [RFC3810] */
626     { ICMP6_MIP6_DHAAD_REQUEST,    "Home Agent Address Discovery Request" },            /* [RFC6275] */
627     { ICMP6_MIP6_DHAAD_REPLY,      "Home Agent Address Discovery Reply" },              /* [RFC6275] */
628     { ICMP6_MIP6_MPS,              "Mobile Prefix Solicitation" },                      /* [RFC6275] */
629     { ICMP6_MIP6_MPA,              "Mobile Prefix Advertisement" },                     /* [RFC6275] */
630     { ICMP6_CERT_PATH_SOL,         "Certification Path Solicitation" },                 /* [RFC3971] */
631     { ICMP6_CERT_PATH_AD,          "Certification Path Advertisement" },                /* [RFC3971] */
632     { ICMP6_EXPERIMENTAL_MOBILITY, "Experimental Mobility" },                           /* [RFC4065] */
633     { ICMP6_MCAST_ROUTER_ADVERT,   "Multicast Router Advertisement" },                  /* [RFC4286] */
634     { ICMP6_MCAST_ROUTER_SOLICIT,  "Multicast Router Solicitation" },                   /* [RFC4286] */
635     { ICMP6_MCAST_ROUTER_TERM,     "Multicast Router Termination" },                    /* [RFC4286] */
636     { ICMP6_FMIPV6_MESSAGES,       "FMIPv6" },                                          /* [RFC5568] */
637     { ICMP6_RPL_CONTROL,           "RPL Control" },                                     /* [RFC6550] */
638     { ICMP6_ILNPV6,                "Locator Update"},                                   /* [RFC6743] */
639     { ICMP6_6LOWPANND_DAR,         "Duplicate Address Request"},                        /* [RFC6775] */
640     { ICMP6_6LOWPANND_DAC,         "Duplicate Address Confirmation"},                   /* [RFC6775] */
641     { 200,                         "Private experimentation" },                         /* [RFC4443] */
642     { 201,                         "Private experimentation" },                         /* [RFC4443] */
643     { 255,                         "Reserved for expansion of ICMPv6 informational messages" }, /* [RFC4443] */
644     { 0, NULL }
645 };
646
647 #define ICMP6_DST_UNREACH_NOROUTE               0       /* no route to destination */
648 #define ICMP6_DST_UNREACH_ADMIN                 1       /* administratively prohibited */
649 #define ICMP6_DST_UNREACH_NOTNEIGHBOR           2       /* not a neighbor(obsolete) */
650 #define ICMP6_DST_UNREACH_BEYONDSCOPE           2       /* beyond scope of source address */
651 #define ICMP6_DST_UNREACH_ADDR                  3       /* address unreachable */
652 #define ICMP6_DST_UNREACH_NOPORT                4       /* port unreachable */
653 #define ICMP6_DST_UNREACH_INGR_EGR              5       /* source address failed ingress/egress policy */
654 #define ICMP6_DST_UNREACH_REJECT                6       /* reject route to destination */
655 #define ICMP6_DST_UNREACH_ERROR                 7       /* error in Source Routing Header */
656
657 static const value_string icmpv6_unreach_code_val[] = {
658     { ICMP6_DST_UNREACH_NOROUTE,     "no route to destination" },
659     { ICMP6_DST_UNREACH_ADMIN,       "Administratively prohibited" },
660     { ICMP6_DST_UNREACH_BEYONDSCOPE, "Beyond scope of source address" },
661     { ICMP6_DST_UNREACH_ADDR,        "Address unreachable" },
662     { ICMP6_DST_UNREACH_NOPORT,      "Port unreachable" },
663     { ICMP6_DST_UNREACH_INGR_EGR,    "Source address failed ingress/egress policy" },
664     { ICMP6_DST_UNREACH_REJECT,      "Reject route to destination" },
665     { ICMP6_DST_UNREACH_ERROR,       "Error in Source Routing Header" }, /* [RFC6550] [RFC6554] */
666     { 0, NULL }
667 };
668
669 #define ICMP6_TIME_EXCEED_TRANSIT       0       /* ttl==0 in transit */
670 #define ICMP6_TIME_EXCEED_REASSEMBLY    1       /* ttl==0 in reass */
671
672 static const value_string icmpv6_timeex_code_val[] = {
673     { ICMP6_TIME_EXCEED_TRANSIT,    "hop limit exceeded in transit" },
674     { ICMP6_TIME_EXCEED_REASSEMBLY, "fragment reassembly time exceeded" },
675     { 0, NULL }
676 };
677
678 #define ICMP6_PARAMPROB_HEADER                  0       /* erroneous header field */
679 #define ICMP6_PARAMPROB_NEXTHEADER              1       /* unrecognized next header */
680 #define ICMP6_PARAMPROB_OPTION                  2       /* unrecognized option */
681 #define ICMP6_PARAMPROB_FIRSTFRAG               3       /* IPv6 First Fragment has incomplete IPv6 Header Chain [RFC 7112] */
682
683 static const value_string icmpv6_paramprob_code_val[] = {
684     { ICMP6_PARAMPROB_HEADER,     "erroneous header field encountered" },
685     { ICMP6_PARAMPROB_NEXTHEADER, "unrecognized Next Header type encountered" },
686     { ICMP6_PARAMPROB_OPTION,     "unrecognized IPv6 option encountered" },
687     { ICMP6_PARAMPROB_FIRSTFRAG,  "IPv6 First Fragment has incomplete IPv6 Header Chain" },
688     { 0, NULL }
689 };
690
691
692 /* RFC2894 - Router Renumbering for IPv6 */
693
694 #define ICMP6_ROUTER_RENUMBERING_COMMAND          0     /* rr command */
695 #define ICMP6_ROUTER_RENUMBERING_RESULT           1     /* rr result */
696 #define ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET   255     /* rr seq num reset */
697
698 static const value_string icmpv6_rr_code_val[] = {
699     { ICMP6_ROUTER_RENUMBERING_COMMAND,      "Command" },
700     { ICMP6_ROUTER_RENUMBERING_RESULT,       "Result" },
701     { ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET, "Sequence number reset" },
702     { 0, NULL }
703 };
704
705 #define RR_FLAG_T       0x80
706 #define RR_FLAG_R       0x40
707 #define RR_FLAG_A       0x20
708 #define RR_FLAG_S       0x10
709 #define RR_FLAG_P       0x08
710 #define RR_FLAG_RSV     0x07
711
712 static const value_string rr_pco_mp_opcode_val[] = {
713     { 1,    "Add" },
714     { 2,    "Change" },
715     { 3,    "Set Global" },
716     { 0,    NULL }
717 };
718
719
720 /* RFC3810 - Multicast Listener Discovery Version 2 (MLDv2) for IPv6 */
721
722 #define MLDV2_PACKET_MINLEN 28
723
724 #define MLD_FLAG_S      0x08
725 #define MLD_FLAG_QRV    0x07
726 #define MLD_FLAG_RSV    0xF0
727
728 static const value_string mldr_record_type_val[] = {
729     { 1, "Include" },
730     { 2, "Exclude" },
731     { 3, "Changed to include" },
732     { 4, "Changed to exclude" },
733     { 5, "Allow new sources" },
734     { 6, "Block old sources" },
735     { 0, NULL }
736 };
737
738 /* RFC 4068/5268/5568: Fast Handovers for Mobile IPv6 ( Mobile IPv6 Fast Handovers ) */
739
740 #define FMIP6_SUBTYPE_RTSOLPR   2
741 #define FMIP6_SUBTYPE_PRRTADV   3
742 #define FMIP6_SUBTYPE_HI        4
743 #define FMIP6_SUBTYPE_HACK      5
744
745 static const value_string fmip6_subtype_val[] = {
746     { FMIP6_SUBTYPE_RTSOLPR,    "Router Solicitation for Proxy Advertisement" },
747     { FMIP6_SUBTYPE_PRRTADV,    "Proxy Router Advertisement" },
748     { FMIP6_SUBTYPE_HI,         "Handover Initiate" },
749     { FMIP6_SUBTYPE_HACK,       "Handover Acknowledge" },
750     { 0,                        NULL }
751 };
752
753 static const value_string fmip6_prrtadv_code_val[] = {
754     { 0,   "MN should use AP-ID, AR-info tuple" },
755     { 1,   "Network Initiated Handover trigger" },
756     { 2,   "No new router information" },
757     { 3,   "Limited new router information" },
758     { 4,   "Unsolicited" },
759     { 0,    NULL }
760 };
761
762 static const value_string fmip6_hi_code_val[] = {
763     { 0,    "FBU sent from previous link" },
764     { 1,    "FBU sent from new link" },
765     { 0,    NULL }
766 };
767
768 static const value_string fmip6_hack_code_val[] = {
769     { 0,    "Handover Accepted, NCoA valid" },
770     { 1,    "Handover Accepted, NCoA not valid" },
771     { 2,    "Handover Accepted, NCoA in use" },
772     { 3,    "Handover Accepted, NCoA assigned" },
773     { 4,    "Handover Accepted, NCoA not assigned" },
774     { 128,  "Handover Not Accepted, reason unspecified" },
775     { 129,  "Administratively prohibited" },
776     { 130,  "Insufficient resources" },
777     { 0,    NULL }
778 };
779
780 #define FMIP6_HI_FLAG_S     0x80
781 #define FMIP6_HI_FLAG_U     0x40
782 #define FMIP6_HI_FLAG_RSV   0x3F
783
784 /* RFC 4620 - IPv6 Node Information Queries */
785
786 #define ICMP6_NI_SUBJ_IPV6      0   /* Query Subject is an IPv6 address */
787 #define ICMP6_NI_SUBJ_FQDN      1   /* Query Subject is a Domain name */
788 #define ICMP6_NI_SUBJ_IPV4      2   /* Query Subject is an IPv4 address */
789
790 #define ICMP6_NI_SUCCESS        0   /* node information successful reply */
791 #define ICMP6_NI_REFUSED        1   /* node information request is refused */
792 #define ICMP6_NI_UNKNOWN        2   /* unknown Qtype */
793
794 #define NI_QTYPE_NOOP           0   /* NOOP  */
795 #define NI_QTYPE_SUPTYPES       1   /* Supported Qtypes (Obso) */
796 #define NI_QTYPE_NODENAME       2   /* Node Name */
797 #define NI_QTYPE_NODEADDR       3   /* Node Addresses */
798 #define NI_QTYPE_IPV4ADDR       4   /* IPv4 Addresses */
799
800 static const value_string ni_query_code_val[] = {
801     { ICMP6_NI_SUBJ_IPV6,   "Query subject = IPv6 addresses" },
802     { ICMP6_NI_SUBJ_FQDN,   "Query subject = DNS name or empty" },
803     { ICMP6_NI_SUBJ_IPV4,   "Query subject = IPv4 addresses" },
804     { 0, NULL }
805 };
806
807 static const value_string ni_reply_code_val[] = {
808     { ICMP6_NI_SUCCESS,   "Successful" },
809     { ICMP6_NI_REFUSED,   "Refused" },
810     { ICMP6_NI_UNKNOWN,   "Unknown query type" },
811     { 0, NULL }
812 };
813 static const value_string ni_qtype_val[] = {
814     { NI_QTYPE_NOOP,            "NOOP" },
815     { NI_QTYPE_SUPTYPES,        "Supported query types (Obsolete)" },
816     { NI_QTYPE_NODENAME,        "Node Name" },
817     { NI_QTYPE_NODEADDR,        "Node addresses" },
818     { NI_QTYPE_IPV4ADDR,        "IPv4 node addresses" },
819     { 0,                        NULL }
820 };
821
822 #define NI_FLAG_G       0x0020
823 #define NI_FLAG_S       0x0010
824 #define NI_FLAG_L       0x0008
825 #define NI_FLAG_C       0x0004
826 #define NI_FLAG_A       0x0002
827 #define NI_FLAG_T       0x0001
828 #define NI_FLAG_RSV     0xFFC0
829
830 static const true_false_string tfs_ni_flag_a = {
831     "All unicast address",
832     "Unicast addresses on the queried interface"
833 };
834
835 #define ND_OPT_SOURCE_LINKADDR           1
836 #define ND_OPT_TARGET_LINKADDR           2
837 #define ND_OPT_PREFIX_INFORMATION        3
838 #define ND_OPT_REDIRECTED_HEADER         4
839 #define ND_OPT_MTU                       5
840 #define ND_OPT_NBMA                      6
841 #define ND_OPT_ADVINTERVAL               7
842 #define ND_OPT_HOMEAGENT_INFO            8
843 #define ND_OPT_SOURCE_ADDRLIST           9
844 #define ND_OPT_TARGET_ADDRLIST          10
845 #define ND_OPT_CGA                      11
846 #define ND_OPT_RSA                      12
847 #define ND_OPT_TIMESTAMP                13
848 #define ND_OPT_NONCE                    14
849 #define ND_OPT_TRUST_ANCHOR             15
850 #define ND_OPT_CERTIFICATE              16
851 #define ND_OPT_IP_ADDRESS_PREFIX        17
852 #define ND_OPT_NEW_ROUTER_PREFIX_INFO   18
853 #define ND_OPT_LINK_LAYER_ADDRESS       19
854 #define ND_OPT_NEIGHBOR_ADV_ACK         20
855 #define ND_OPT_MAP                      23
856 #define ND_OPT_ROUTE_INFO               24
857 #define ND_OPT_RECURSIVE_DNS_SERVER     25
858 #define ND_OPT_FLAGS_EXTENSION          26
859 #define ND_OPT_HANDOVER_KEY_REQUEST     27
860 #define ND_OPT_HANDOVER_KEY_REPLY       28
861 #define ND_OPT_HANDOVER_ASSIST_INFO     29
862 #define ND_OPT_MOBILE_NODE_ID           30
863 #define ND_OPT_DNS_SEARCH_LIST          31
864 #define ND_OPT_PROXY_SIGNATURE          32
865 #define ND_OPT_ADDR_REGISTRATION        33
866 #define ND_OPT_6LOWPAN_CONTEXT          34
867 #define ND_OPT_AUTH_BORDER_ROUTER       35
868 #define ND_OPT_6CIO                     36
869
870 static const value_string option_vals[] = {
871 /*  1 */   { ND_OPT_SOURCE_LINKADDR,           "Source link-layer address" },
872 /*  2 */   { ND_OPT_TARGET_LINKADDR,           "Target link-layer address" },
873 /*  3 */   { ND_OPT_PREFIX_INFORMATION,        "Prefix information" },
874 /*  4 */   { ND_OPT_REDIRECTED_HEADER,         "Redirected header" },
875 /*  5 */   { ND_OPT_MTU,                       "MTU" },
876 /*  6 */   { ND_OPT_NBMA,                      "NBMA Shortcut Limit Option" },             /* [RFC2491] */
877 /*  7 */   { ND_OPT_ADVINTERVAL,               "Advertisement Interval" },                 /* [RFC6275] */
878 /*  8 */   { ND_OPT_HOMEAGENT_INFO,            "Home Agent Information" },                 /* [RFC6275] */
879 /*  9 */   { ND_OPT_SOURCE_ADDRLIST,           "Source Address List" },                    /* [RFC3122] */
880 /* 10 */   { ND_OPT_TARGET_ADDRLIST,           "Target Address List" },                    /* [RFC3122] */
881 /* 11 */   { ND_OPT_CGA,                       "CGA" },                                    /* [RFC3971] */
882 /* 12 */   { ND_OPT_RSA,                       "RSA Signature" },                          /* [RFC3971] */
883 /* 13 */   { ND_OPT_TIMESTAMP,                 "Timestamp" },                              /* [RFC3971] */
884 /* 14 */   { ND_OPT_NONCE,                     "Nonce" },                                  /* [RFC3971] */
885 /* 15 */   { ND_OPT_TRUST_ANCHOR,              "Trust Anchor" },                           /* [RFC3971] */
886 /* 16 */   { ND_OPT_CERTIFICATE,               "Certificate" },                            /* [RFC3971] */
887 /* 17 */   { ND_OPT_IP_ADDRESS_PREFIX,         "IP Address/Prefix Option" },               /* [RFC5568] */
888 /* 18 */   { ND_OPT_NEW_ROUTER_PREFIX_INFO,    "New Router Prefix Information" },          /* [RFC4068] OBSO */
889 /* 19 */   { ND_OPT_LINK_LAYER_ADDRESS,        "Link-layer Address" },                     /* [RFC5568] */
890 /* 20 */   { ND_OPT_NEIGHBOR_ADV_ACK,          "Neighbor Advertisement Acknowledgment" },  /* [RFC5568] */
891 /* 21-22   Unassigned */
892 /* 23 */   { ND_OPT_MAP,                       "MAP" },                                    /* [RFC4140] */
893 /* 24 */   { ND_OPT_ROUTE_INFO,                "Route Information" },                      /* [RFC4191] */
894 /* 25 */   { ND_OPT_RECURSIVE_DNS_SERVER,      "Recursive DNS Server" },                   /* [RFC6106] */
895 /* 26 */   { ND_OPT_FLAGS_EXTENSION,           "RA Flags Extension" },                     /* [RFC5175] */
896 /* 27 */   { ND_OPT_HANDOVER_KEY_REQUEST,      "Handover Key Request" },                   /* [RFC5269] */
897 /* 28 */   { ND_OPT_HANDOVER_KEY_REPLY,        "Handover Key Reply" },                     /* [RFC5269] */
898 /* 29 */   { ND_OPT_HANDOVER_ASSIST_INFO,      "Handover Assist Information" },            /* [RFC5271] */
899 /* 30 */   { ND_OPT_MOBILE_NODE_ID,            "Mobile Node Identifier Option" },          /* [RFC5271] */
900 /* 31 */   { ND_OPT_DNS_SEARCH_LIST,           "DNS Search List Option" },                 /* [RFC6106] */
901 /* 32 */   { ND_OPT_PROXY_SIGNATURE,           "Proxy Signature (PS)" },                   /* [RFC6496] */
902 /* 33 */   { ND_OPT_ADDR_REGISTRATION,         "Address Registration Option" },            /* [RFC6775] */
903 /* 34 */   { ND_OPT_6LOWPAN_CONTEXT,           "6LoWPAN Context Option" },                 /* [RFC6775] */
904 /* 35 */   { ND_OPT_AUTH_BORDER_ROUTER,        "Authoritative Border Router" },            /* [RFC6775] */
905 /* 36 */   { ND_OPT_6CIO,                      "6LoWPAN Capability Indication Option" },   /* [RFC7400] */
906 /* 37-137  Unassigned */
907    { 138,                              "CARD Request" },                           /* [RFC4065] */
908    { 139,                              "CARD Reply" },                             /* [RFC4065] */
909 /* 140-252 Unassigned */
910    { 253,                              "RFC3692-style Experiment 1" },             /* [RFC4727] */
911    { 254,                              "RFC3692-style Experiment 2" },             /* [RFC4727] */
912    { 0,                                NULL }
913 };
914
915 #define ND_RA_FLAG_M    0x80
916 #define ND_RA_FLAG_O    0x40
917 #define ND_RA_FLAG_H    0x20
918 #define ND_RA_FLAG_PRF  0x18
919 #define ND_RA_FLAG_P    0x04
920 #define ND_RA_FLAG_RSV  0x02
921
922 #define ND_NA_FLAG_R    0x80000000
923 #define ND_NA_FLAG_S    0x40000000
924 #define ND_NA_FLAG_O    0x20000000
925 #define ND_NA_FLAG_RSV  0x1FFFFFFF
926
927 static const value_string nd_flag_router_pref[] = {
928     { 1, "High" },
929     { 0, "Medium" },
930     { 3, "Low" },
931     { 2, "Reserved" },
932     { 0, NULL}
933 };
934
935 static const value_string nd_opt_ipa_option_code_val[] = {
936     { 1, "Old Care-of Address" },
937     { 2, "New Care-of Address" },
938     { 3, "NAR's IP address" },
939     { 4, "NAR's Prefix (sent in PrRtAdv)" },
940     { 0, NULL }
941 };
942
943 static const value_string nd_opt_lla_option_code_val[] = {
944     { 0, "Wildcard" },
945     { 1, "Link-layer Address of the New Access Point" },
946     { 2, "Link-layer Address of the MN" },
947     { 3, "Link-layer Address of the NAR" },
948     { 4, "Link-layer Address of the source" },
949     { 5, "The AP belongs to the current interface of the router" },
950     { 6, "No prefix information available" },
951     { 7, "No fast handovers support available" },
952     { 0, NULL }
953 };
954
955 static const value_string nd_opt_hai_option_code_val[] = {
956     { 1, "Access Network Identifier (AN ID)" },
957     { 2, "Sector ID" },
958     { 0, NULL }
959 };
960
961 static const value_string nd_opt_mn_option_code_val[] = {
962     { 1, "NAI" },
963     { 2, "IMSI" },
964     { 0, NULL }
965 };
966 static const value_string nd_opt_naack_status_val[] = {
967     { 1,    "New CoA is invalid, perform address configuration" },
968     { 2,    "New CoA is invalid, use the supplied CoA" },
969     { 3,    "NCoA is invalid, use NAR's IP address as NCoA in FBU" },
970     { 4,    "PCoA supplied, do not send FBU" },
971     { 128,  "LLA is unrecognized" },
972     { 0,    NULL }
973 };
974
975 #define ND_OPT_6CO_FLAG_C        0x10
976 #define ND_OPT_6CO_FLAG_CID      0x0F
977 #define ND_OPT_6CO_FLAG_RESERVED 0xE0
978
979 static const value_string nd_opt_6lowpannd_status_val[] = {
980     { 0, "Success" },
981     { 1, "Duplicate Exists" },
982     { 2, "Neighbor Cache Full" },
983     { 0, NULL }
984 };
985
986 static const value_string icmpv6_option_name_type_vals[] = {
987     { 1,    "DER Encoded X.501 Name" },
988     { 2,    "FQDN" },
989     { 3,    "SHA-1 Subject Key Identifier (SKI)" },
990     { 4,    "SHA-224 Subject Key Identifier (SKI)" },
991     { 5,    "SHA-256 Subject Key Identifier (SKI)" },
992     { 6,    "SHA-384 Subject Key Identifier (SKI)" },
993     { 7,    "SHA-512 Subject Key Identifier (SKI)" },
994     { 253,  "Reserved for Experimental Use" },
995     { 254,  "Reserved for Experimental Use" },
996     { 255,  "Reserved" },
997     { 0,    NULL }
998 };
999
1000 static const value_string icmpv6_option_cert_type_vals[] = {
1001     { 1,    "X.509v3 Certificate" },
1002     { 0,    NULL }
1003 };
1004
1005 /* RFC 4191: Default Router Preferences and More-Specific Routes  */
1006
1007 #define ND_RA_FLAG_RTPREF_MASK  0x18 /* 00011000 */
1008 #define ND_RA_FLAG_RESERV_MASK  0xE7 /* 11100111 */
1009
1010 /* RFC 5075/5175 : IPv6 Router Advertisement Flags Option */
1011 #define FLAGS_EO_M      0x8000
1012 #define FLAGS_EO_O      0x4000
1013 #define FLAGS_EO_H      0x2000
1014 #define FLAGS_EO_PRF    0x1800
1015 #define FLAGS_EO_P      0x0400
1016 #define FLAGS_EO_RSV    0x02FF
1017
1018
1019
1020 /* RPL : RFC 6550 : Routing over Low-Power and Lossy Networks. */
1021 /* RPL ICMPv6 Codes */
1022 #define ICMP6_RPL_DIS           0x00   /* DODAG Information Solicitation */
1023 #define ICMP6_RPL_DIO           0x01   /* DODAG Information Object */
1024 #define ICMP6_RPL_DAO           0x02   /* Destination Advertisement Object */
1025 #define ICMP6_RPL_DAOACK        0x03   /* Destination Advertisement Object Ack */
1026 #define ICMP6_RPL_P2P_DRO       0x04   /* P2P Discovery Reply Object */
1027 #define ICMP6_RPL_P2P_DROACK    0x05   /* P2P Discovery Reply Object Acknowledgement */
1028 #define ICMP6_RPL_SDIS          0x80   /* Secure DODAG Information Solicitation */
1029 #define ICMP6_RPL_SDIO          0x81   /* Secure DODAG Information Object */
1030 #define ICMP6_RPL_SDAO          0x82   /* Secure Destination Advertisement Object */
1031 #define ICMP6_RPL_SDAOACK       0x83   /* Secure Destination Advertisement Object Ack */
1032 #define ICMP6_RPL_P2P_SDRO      0x84   /* Secure P2P Discovery Reply Object */
1033 #define ICMP6_RPL_P2P_SDROACK   0x85   /* Secure P2P Discovery Reply Object Acknowledgement */
1034 #define ICMP6_RPL_CC            0x8A   /* Consistency Check */
1035
1036
1037 /* RPL DIO Flags */
1038 #define RPL_DIO_FLAG_G           0x80
1039 #define RPL_DIO_FLAG_0           0x40
1040 #define RPL_DIO_FLAG_MOP         0x38
1041 #define RPL_DIO_FLAG_PRF         0x07
1042
1043 /* RPL DAO Flags */
1044 #define RPL_DAO_FLAG_K                  0x80
1045 #define RPL_DAO_FLAG_D                  0x40
1046 #define RPL_DAO_FLAG_RESERVED           0x3F
1047
1048 /* RPL DAO ACK Flags */
1049 #define RPL_DAOACK_FLAG_D               0x80
1050 #define RPL_DAOACK_FLAG_RESERVED        0x7F
1051
1052 /* RPL CC Flags */
1053 #define RPL_CC_FLAG_R               0x80
1054 #define RPL_CC_FLAG_RESERVED        0x7F
1055
1056 /* RPL Secure */
1057 #define ICMP6_RPL_SECURE    0x80
1058
1059 #define RPL_SECURE_FLAG_T   0x80
1060 #define RPL_SECURE_FLAG_RSV 0x7F
1061
1062 #define RPL_SECURE_LVL      0x07
1063 #define RPL_SECURE_KIM      0xC0
1064 #define RPL_SECURE_RSV      0x38
1065
1066 /* RPL P2P DRO Flags */
1067 #define RPL_P2P_DRO_FLAG_S      0x8000
1068 #define RPL_P2P_DRO_FLAG_A      0x4000
1069 #define RPL_P2P_DRO_FLAG_SEQ    0x3000
1070 #define RPL_P2P_DRO_FLAG_RSV    0x0FFF
1071
1072 /* RPL P2P DROACK Flags */
1073 #define RPL_P2P_DROACK_FLAG_SEQ    0xc000
1074 #define RPL_P2P_DROACK_FLAG_RSV    0x3FFF
1075
1076 /* RPL Option Bitfields */
1077 #define RPL_OPT_PREFIX_FLAG_L           0x80
1078 #define RPL_OPT_PREFIX_FLAG_A           0x40
1079 #define RPL_OPT_PREFIX_FLAG_R           0x20
1080 #define RPL_OPT_PREFIX_FLAG_RSV         0x1F
1081 #define RPL_OPT_ROUTE_PREFERENCE        0x18
1082 #define RPL_OPT_ROUTE_RESERVED          0xE7
1083 #define RPL_OPT_CONFIG_FLAG_AUTH        0x08
1084 #define RPL_OPT_CONFIG_FLAG_PCS         0x07
1085 #define RPL_OPT_CONFIG_FLAG_RESERVED    0xF0
1086 #define RPL_OPT_TRANSIT_FLAG_E          0x80
1087 #define RPL_OPT_TRANSIT_FLAG_RSV        0x7F
1088 #define RPL_OPT_SOLICITED_FLAG_V        0x80
1089 #define RPL_OPT_SOLICITED_FLAG_I        0x40
1090 #define RPL_OPT_SOLICITED_FLAG_D        0x20
1091 #define RPL_OPT_SOLICITED_FLAG_RSV      0x1F
1092 #define RPL_OPT_ROUTE_DISCOVERY_R       0x80
1093 #define RPL_OPT_ROUTE_DISCOVERY_H       0x40
1094 #define RPL_OPT_ROUTE_DISCOVERY_N       0x30
1095 #define RPL_OPT_ROUTE_DISCOVERY_COMPR   0x0F
1096 #define RPL_OPT_ROUTE_DISCOVERY_L       0xC0
1097 #define RPL_OPT_ROUTE_DISCOVERY_MR_NH   0x3F
1098
1099 static const value_string rpl_dio_map_val[] = {
1100     { 0, "No Downward routes maintained by RPL" },
1101     { 1, "Non-Storing Mode of Operation" },
1102     { 2, "Storing Mode of Operation with no multicast support" },
1103     { 3, "Storing Mode of Operation with multicast support" },
1104     { 4, "P2P Route Discovery Mode of Operation" },
1105     { 0, NULL }
1106 };
1107 static const value_string rpl_code_val[] = {
1108     { ICMP6_RPL_DIS,        "DODAG Information Solicitation" },
1109     { ICMP6_RPL_DIO,        "DODAG Information Object" },
1110     { ICMP6_RPL_DAO,        "Destination Advertisement Object" },
1111     { ICMP6_RPL_DAOACK,     "Destination Advertisement Object Acknowledgment" },
1112     { ICMP6_RPL_SDIS,       "Secure DODAG Information Solicitation" },
1113     { ICMP6_RPL_SDIO,       "Secure DODAG Information Object" },
1114     { ICMP6_RPL_SDAO,       "Secure Destination Advertisement Object" },
1115     { ICMP6_RPL_SDAOACK,    "Secure Destination Advertisement Object Acknowledgment" },
1116     { ICMP6_RPL_CC,         "Consistency Check" },
1117     { ICMP6_RPL_P2P_DRO,    "P2P Discovery Reply Object" },
1118     { ICMP6_RPL_P2P_SDRO,   "P2P Secure Discovery Reply Object" },
1119     { ICMP6_RPL_P2P_DROACK, "P2P Discovery Reply Object Acknowledgement" },
1120     { ICMP6_RPL_P2P_SDROACK,"P2P Secure Discovery Reply Object Acknowledgement" },
1121     { 0, NULL }
1122 };
1123
1124 static const value_string rpl_secure_algorithm_encryption_val[] = {
1125     { 0, "CCM with AES-128" },
1126     { 0, NULL }
1127 };
1128
1129 static const value_string rpl_secure_algorithm_signature_val[] = {
1130     { 0, "RSA with SHA-256" },
1131     { 0, NULL }
1132 };
1133 /* RPL Option Types */
1134 /* Pending IANA Assignment */
1135 #define RPL_OPT_PAD1            0   /* 1-byte padding */
1136 #define RPL_OPT_PADN            1   /* n-byte padding */
1137 #define RPL_OPT_METRIC          2   /* DAG metric container */
1138 #define RPL_OPT_ROUTING         3   /* Routing Information */
1139 #define RPL_OPT_CONFIG          4   /* DAG configuration */
1140 #define RPL_OPT_TARGET          5   /* RPL Target */
1141 #define RPL_OPT_TRANSIT         6   /* Transit */
1142 #define RPL_OPT_SOLICITED       7   /* Solicited Information */
1143 #define RPL_OPT_PREFIX          8   /* Destination prefix */
1144 #define RPL_OPT_TARGETDESC      9   /* RPL Target Descriptor */
1145 #define RPL_OPT_ROUTE_DISCOVERY 10  /* P2P Route Discovery */
1146
1147 static const value_string rpl_option_vals[] = {
1148     { RPL_OPT_PAD1,             "1-byte padding" },
1149     { RPL_OPT_PADN,             "n-byte padding" },
1150     { RPL_OPT_METRIC,           "DAG Metric container" },
1151     { RPL_OPT_ROUTING,          "Routing Information"},
1152     { RPL_OPT_CONFIG,           "DODAG configuration" },
1153     { RPL_OPT_TARGET,           "RPL Target" },
1154     { RPL_OPT_TRANSIT,          "Transit Information" },
1155     { RPL_OPT_SOLICITED,        "Solicited Information"},
1156     { RPL_OPT_PREFIX,           "Prefix Information"},
1157     { RPL_OPT_TARGETDESC,       "RPL Target Descriptor"},
1158     { RPL_OPT_ROUTE_DISCOVERY,  "P2P Route Discovery"},
1159     { 0, NULL }
1160 };
1161
1162 /* RFC 7400 */
1163 #define ND_OPT_6CIO_FLAG_G          0x0001
1164 #define ND_OPT_6CIO_FLAG_UNASSIGNED 0xFFFE
1165
1166 static int
1167 dissect_contained_icmpv6(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1168 {
1169     gboolean  save_in_error_pkt;
1170     tvbuff_t *next_tvb;
1171
1172     /* Save the current value of the "we're inside an error packet"
1173        flag, and set that flag; subdissectors may treat packets
1174        that are the payload of error packets differently from
1175        "real" packets. */
1176     save_in_error_pkt = pinfo->flags.in_error_pkt;
1177     pinfo->flags.in_error_pkt = TRUE;
1178
1179     next_tvb = tvb_new_subset_remaining(tvb, offset);
1180
1181     /* tiny sanity check */
1182     if ((tvb_get_guint8(tvb, offset) & 0xf0) == 0x60) {
1183         /* The contained packet is an IPv6 datagram; dissect it. */
1184         offset += call_dissector(ipv6_handle, next_tvb, pinfo, tree);
1185     } else
1186         offset += call_dissector(data_handle, next_tvb, pinfo, tree);
1187
1188     /* Restore the "we're inside an error packet" flag. */
1189     pinfo->flags.in_error_pkt = save_in_error_pkt;
1190
1191     return offset;
1192 }
1193
1194
1195 /* ======================================================================= */
1196 static conversation_t *_find_or_create_conversation(packet_info *pinfo)
1197 {
1198     conversation_t *conv = NULL;
1199
1200     /* Have we seen this conversation before? */
1201     conv = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
1202         pinfo->ptype, 0, 0, 0);
1203     if (conv == NULL) {
1204         /* No, this is a new conversation. */
1205         conv = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
1206             pinfo->ptype, 0, 0, 0);
1207     }
1208     return conv;
1209 }
1210
1211 /* ======================================================================= */
1212 static icmp_transaction_t *transaction_start(packet_info *pinfo, proto_tree *tree, guint32 *key)
1213 {
1214     conversation_t     *conversation;
1215     icmpv6_conv_info_t *icmpv6_info;
1216     icmp_transaction_t *icmpv6_trans;
1217     wmem_tree_key_t     icmpv6_key[3];
1218     proto_item         *it;
1219
1220     /* Handle the conversation tracking */
1221     conversation = _find_or_create_conversation(pinfo);
1222     icmpv6_info = (icmpv6_conv_info_t *)conversation_get_proto_data(conversation, proto_icmpv6);
1223     if (icmpv6_info == NULL) {
1224         icmpv6_info = wmem_new(wmem_file_scope(), icmpv6_conv_info_t);
1225         icmpv6_info->unmatched_pdus = wmem_tree_new(wmem_file_scope());
1226         icmpv6_info->matched_pdus = wmem_tree_new(wmem_file_scope());
1227         conversation_add_proto_data(conversation, proto_icmpv6, icmpv6_info);
1228     }
1229
1230     if (!PINFO_FD_VISITED(pinfo)) {
1231         /*
1232          * This is a new request, create a new transaction structure and map it
1233          * to the unmatched table.
1234          */
1235         icmpv6_key[0].length = 2;
1236         icmpv6_key[0].key = key;
1237         icmpv6_key[1].length = 0;
1238         icmpv6_key[1].key = NULL;
1239
1240         icmpv6_trans = wmem_new(wmem_file_scope(), icmp_transaction_t);
1241         icmpv6_trans->rqst_frame = PINFO_FD_NUM(pinfo);
1242         icmpv6_trans->resp_frame = 0;
1243         icmpv6_trans->rqst_time = pinfo->fd->abs_ts;
1244         nstime_set_zero(&icmpv6_trans->resp_time);
1245         wmem_tree_insert32_array(icmpv6_info->unmatched_pdus, icmpv6_key, (void *)icmpv6_trans);
1246     } else {
1247         /* Already visited this frame */
1248         guint32 frame_num = pinfo->fd->num;
1249
1250         icmpv6_key[0].length = 2;
1251         icmpv6_key[0].key = key;
1252         icmpv6_key[1].length = 1;
1253         icmpv6_key[1].key = &frame_num;
1254         icmpv6_key[2].length = 0;
1255         icmpv6_key[2].key = NULL;
1256
1257         icmpv6_trans = (icmp_transaction_t *)wmem_tree_lookup32_array(icmpv6_info->matched_pdus, icmpv6_key);
1258     }
1259
1260     if (icmpv6_trans == NULL) {
1261         if (PINFO_FD_VISITED(pinfo)) {
1262                 /* No response found - add field and expert info */
1263                 it = proto_tree_add_item(tree, hf_icmpv6_no_resp, NULL, 0, 0,
1264                                          ENC_NA);
1265                 PROTO_ITEM_SET_GENERATED(it);
1266
1267                 col_append_fstr(pinfo->cinfo, COL_INFO, " (no response found!)");
1268
1269                 /* Expert info.  TODO: add to _icmp_transaction_t type and sequence number
1270                    so can report here (and in taps) */
1271                 expert_add_info_format(pinfo, it, &ei_icmpv6_resp_not_found,
1272                                        "No response seen to ICMPv6 request in frame %u",
1273                                        pinfo->fd->num);
1274         }
1275
1276         return NULL;
1277     }
1278
1279     /* Print state tracking in the tree */
1280     if (icmpv6_trans->resp_frame) {
1281         if (tree) {
1282             it = proto_tree_add_uint(tree, hf_icmpv6_resp_in, NULL, 0, 0,
1283                 icmpv6_trans->resp_frame);
1284             PROTO_ITEM_SET_GENERATED(it);
1285         }
1286         col_append_fstr(pinfo->cinfo, COL_INFO, " (reply in %d)", icmpv6_trans->resp_frame);
1287     }
1288
1289     return icmpv6_trans;
1290
1291 } /* transaction_start() */
1292
1293 /* ======================================================================= */
1294 static icmp_transaction_t *transaction_end(packet_info *pinfo, proto_tree *tree, guint32 *key)
1295 {
1296     conversation_t     *conversation;
1297     icmpv6_conv_info_t *icmpv6_info;
1298     icmp_transaction_t *icmpv6_trans;
1299     wmem_tree_key_t     icmpv6_key[3];
1300     proto_item         *it;
1301     nstime_t            ns;
1302     double resp_time;
1303
1304     conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
1305         pinfo->ptype, 0, 0, 0);
1306     if (conversation == NULL)
1307         return NULL;
1308
1309     icmpv6_info = (icmpv6_conv_info_t *)conversation_get_proto_data(conversation, proto_icmpv6);
1310     if (icmpv6_info == NULL)
1311         return NULL;
1312
1313     if (!PINFO_FD_VISITED(pinfo)) {
1314         guint32 frame_num;
1315
1316         icmpv6_key[0].length = 2;
1317         icmpv6_key[0].key = key;
1318         icmpv6_key[1].length = 0;
1319         icmpv6_key[1].key = NULL;
1320
1321         icmpv6_trans = (icmp_transaction_t *)wmem_tree_lookup32_array(icmpv6_info->unmatched_pdus, icmpv6_key);
1322         if (icmpv6_trans == NULL)
1323             return NULL;
1324
1325         /* we have already seen this response, or an identical one */
1326         if (icmpv6_trans->resp_frame != 0)
1327             return NULL;
1328
1329         icmpv6_trans->resp_frame = PINFO_FD_NUM(pinfo);
1330
1331         /*
1332          * we found a match.  Add entries to the matched table for both
1333          * request and reply frames
1334          */
1335         icmpv6_key[0].length = 2;
1336         icmpv6_key[0].key = key;
1337         icmpv6_key[1].length = 1;
1338         icmpv6_key[1].key = &frame_num;
1339         icmpv6_key[2].length = 0;
1340         icmpv6_key[2].key = NULL;
1341
1342         frame_num = icmpv6_trans->rqst_frame;
1343         wmem_tree_insert32_array(icmpv6_info->matched_pdus, icmpv6_key, (void *)icmpv6_trans);
1344
1345         frame_num = icmpv6_trans->resp_frame;
1346         wmem_tree_insert32_array(icmpv6_info->matched_pdus, icmpv6_key, (void *)icmpv6_trans);
1347     } else {
1348         /* Already visited this frame */
1349         guint32 frame_num = pinfo->fd->num;
1350
1351         icmpv6_key[0].length = 2;
1352         icmpv6_key[0].key = key;
1353         icmpv6_key[1].length = 1;
1354         icmpv6_key[1].key = &frame_num;
1355         icmpv6_key[2].length = 0;
1356         icmpv6_key[2].key = NULL;
1357
1358         icmpv6_trans = (icmp_transaction_t *)wmem_tree_lookup32_array(icmpv6_info->matched_pdus, icmpv6_key);
1359         if (icmpv6_trans == NULL)
1360             return NULL;
1361     }
1362
1363     /* Print state tracking in the tree */
1364     if (tree) {
1365         it = proto_tree_add_uint(tree, hf_icmpv6_resp_to, NULL, 0, 0,
1366             icmpv6_trans->rqst_frame);
1367         PROTO_ITEM_SET_GENERATED(it);
1368     }
1369
1370     nstime_delta(&ns, &pinfo->fd->abs_ts, &icmpv6_trans->rqst_time);
1371     icmpv6_trans->resp_time = ns;
1372     if (tree) {
1373         resp_time = nstime_to_msec(&ns);
1374         it = proto_tree_add_double_format_value(tree, hf_icmpv6_resptime, NULL,
1375             0, 0, resp_time, "%.3f ms", resp_time);
1376         PROTO_ITEM_SET_GENERATED(it);
1377     }
1378
1379     col_append_fstr(pinfo->cinfo, COL_INFO, " (request in %d)",
1380         icmpv6_trans->rqst_frame);
1381
1382     return icmpv6_trans;
1383
1384 } /* transaction_end() */
1385
1386 static int
1387 dissect_icmpv6_nd_opt(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
1388 {
1389     proto_tree *icmp6opt_tree, *flag_tree;
1390     proto_item *ti, *ti_opt, *ti_opt_len;
1391     guint8      opt_type;
1392     int         opt_len;
1393     int         opt_offset;
1394
1395     while ((int)tvb_reported_length(tvb) > offset) {
1396         /* there are more options */
1397
1398         /* ICMPv6 Option */
1399         opt_len = tvb_get_guint8(tvb, offset + 1) * 8;
1400         ti = proto_tree_add_item(tree, hf_icmpv6_opt, tvb, offset, opt_len, ENC_NA);
1401         icmp6opt_tree = proto_item_add_subtree(ti, ett_icmpv6_opt);
1402         opt_offset = offset;
1403
1404         /* Option type */
1405         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_type, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1406         opt_type = tvb_get_guint8(tvb, opt_offset);
1407         opt_offset += 1;
1408
1409         /* Add option name to option root label */
1410         proto_item_append_text(ti, " (%s", val_to_str(opt_type, option_vals, "Unknown %d"));
1411
1412         /* Option length */
1413         ti_opt_len = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_length, tvb,opt_offset, 1, ENC_BIG_ENDIAN);
1414         opt_offset += 1;
1415
1416         /* Add length value in bytes */
1417         proto_item_append_text(ti_opt_len, " (%i bytes)", opt_len);
1418
1419         if(opt_len == 0){
1420             expert_add_info_format(pinfo, ti_opt_len, &ei_icmpv6_invalid_option_length, "Invalid option length (Zero)");
1421             return opt_offset;
1422         }
1423
1424         /* decode... */
1425         switch (opt_type) {
1426             case ND_OPT_SOURCE_LINKADDR: /* Source Link-layer Address (1) */
1427             {
1428                 const gchar *link_str;
1429                 /* if the opt len is 8, the Link Addr is MAC Address */
1430                 if(opt_len == 8){
1431                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_linkaddr_mac, tvb, opt_offset, 6, ENC_NA);
1432                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_src_linkaddr_mac, tvb, opt_offset, 6, ENC_NA);
1433                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1434
1435                     link_str = tvb_ether_to_str(tvb, opt_offset);
1436                     col_append_fstr(pinfo->cinfo, COL_INFO, " from %s", link_str);
1437                     proto_item_append_text(ti, " : %s", link_str);
1438                 /* if the opt len is 16 and the 6 last bytes is 0n the Link Addr is EUI64 Address */
1439                 }else if(opt_len == 16 && tvb_get_ntohl(tvb, opt_offset + 8) == 0 && tvb_get_ntohs(tvb, opt_offset + 12) == 0){
1440                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_linkaddr_eui64, tvb, opt_offset, 8, ENC_BIG_ENDIAN);
1441                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_src_linkaddr_eui64, tvb, opt_offset, 8, ENC_BIG_ENDIAN);
1442                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1443                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_linkaddr, tvb, opt_offset, 8, ENC_NA);
1444                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1445                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_src_linkaddr, tvb, opt_offset, 8, ENC_NA);
1446                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1447
1448                     /* Padding: 6 bytes */
1449                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset + 8, 6, ENC_NA);
1450
1451                     link_str = tvb_eui64_to_str(tvb, opt_offset);
1452                     col_append_fstr(pinfo->cinfo, COL_INFO, " from %s", link_str);
1453                     proto_item_append_text(ti, " : %s", link_str);
1454                 }else{
1455                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_linkaddr, tvb, opt_offset, opt_len-2, ENC_NA);
1456                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_src_linkaddr, tvb, opt_offset, opt_len-2, ENC_NA);
1457                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1458                 }
1459                 opt_offset += opt_len;
1460
1461                 break;
1462             }
1463             case ND_OPT_TARGET_LINKADDR: /* Target Link-layer Address (2) */
1464             {
1465                 const gchar *link_str;
1466                 /* if the opt len is 8, the Link Addr is MAC Address */
1467                 if(opt_len == 8){
1468                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_linkaddr_mac, tvb, opt_offset, 6, ENC_NA);
1469                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_target_linkaddr_mac, tvb, opt_offset, 6, ENC_NA);
1470                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1471
1472                     link_str = tvb_ether_to_str(tvb, opt_offset);
1473                     col_append_fstr(pinfo->cinfo, COL_INFO, " is at %s", link_str);
1474                     proto_item_append_text(ti, " : %s", link_str);
1475
1476                 /* if the opt len is 16 and the 6 last bytes is 0n the Link Addr is EUI64 Address */
1477                 }else if(opt_len == 16 && tvb_get_ntohl(tvb, opt_offset + 8) == 0 && tvb_get_ntohs(tvb, opt_offset + 12) == 0){
1478                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_linkaddr_eui64, tvb, opt_offset, 8, ENC_BIG_ENDIAN);
1479                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_target_linkaddr_eui64, tvb, opt_offset, 8, ENC_BIG_ENDIAN);
1480                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1481
1482                     /* Padding: 6 bytes */
1483                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset + 8, 6, ENC_NA);
1484
1485                     link_str = tvb_eui64_to_str(tvb, opt_offset);
1486                     col_append_fstr(pinfo->cinfo, COL_INFO, " from %s", link_str);
1487                     proto_item_append_text(ti, " : %s", link_str);
1488                 }else{
1489                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_linkaddr, tvb, opt_offset, opt_len-2, ENC_NA);
1490                     ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_target_linkaddr, tvb, opt_offset, opt_len-2, ENC_NA);
1491                     PROTO_ITEM_SET_HIDDEN(ti_opt);
1492                 }
1493                 opt_offset += opt_len;
1494                 break;
1495             }
1496             case ND_OPT_PREFIX_INFORMATION: /* Prefix Information (3) */
1497             {
1498                 guint8 prefix_len;
1499                 /* RFC 4861 */
1500
1501                 /* Prefix Length */
1502                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_prefix_len, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1503                 prefix_len = tvb_get_guint8(tvb, opt_offset);
1504                 opt_offset += 1;
1505
1506                 /* Flags */
1507                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_prefix_flag, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1508                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_flag_prefix);
1509
1510                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_prefix_flag_l, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1511                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_prefix_flag_a, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1512                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_prefix_flag_r, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1513                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_prefix_flag_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1514                 opt_offset += 1;
1515
1516                 /* Prefix Valid Lifetime */
1517                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_prefix_valid_lifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
1518
1519                 switch(tvb_get_ntohl(tvb, opt_offset)){
1520                     case 0xffffffff:
1521                         proto_item_append_text(ti_opt, " (Infinity)");
1522                         break;
1523                     default:
1524                         break;
1525                 }
1526                 opt_offset += 4;
1527
1528                 /* Prefix Preferred Lifetime */
1529                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_prefix_preferred_lifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
1530
1531                 switch(tvb_get_ntohl(tvb, opt_offset)){
1532                     case 0xffffffff:
1533                         proto_item_append_text(ti_opt, " (Infinity)");
1534                         break;
1535                     default:
1536                         break;
1537                 }
1538                 opt_offset += 4;
1539
1540                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 4, ENC_NA);
1541                 opt_offset += 4;
1542
1543                 /* Prefix */
1544                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_prefix, tvb, opt_offset, 16, ENC_NA);
1545                 proto_item_append_text(ti, " : %s/%d", tvb_ip6_to_str(tvb, opt_offset), prefix_len);
1546                 opt_offset += 16;
1547
1548                 break;
1549             }
1550             case ND_OPT_REDIRECTED_HEADER: /* Redirected Header (4) */
1551
1552                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 6, ENC_NA);
1553                 opt_offset += 6;
1554
1555                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_redirected_packet, tvb, opt_offset, -1, ENC_NA);
1556
1557                 opt_offset = dissect_contained_icmpv6(tvb, opt_offset, pinfo, icmp6opt_tree);
1558                 break;
1559             case ND_OPT_MTU: /* MTU (5) */
1560
1561                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
1562                 opt_offset += 2;
1563
1564                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_mtu, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
1565                 proto_item_append_text(ti, " : %d", tvb_get_ntohl(tvb, opt_offset));
1566                 opt_offset += 4;
1567                 break;
1568             case ND_OPT_NBMA: /* NBMA Shortcut Limit Option (6) */
1569
1570                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_nbma_shortcut_limit, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1571                 proto_item_append_text(ti, " : %d", tvb_get_guint8(tvb, opt_offset));
1572
1573                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 1, ENC_NA);
1574                 opt_offset += 1;
1575
1576                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 4, ENC_NA);
1577                 opt_offset += 4;
1578
1579                 break;
1580             case ND_OPT_ADVINTERVAL: /* Advertisement Interval Option (7) */
1581
1582                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
1583                 opt_offset += 2;
1584
1585                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_advertisement_interval, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
1586                 proto_item_append_text(ti, " : %d", tvb_get_ntohl(tvb, opt_offset));
1587                 opt_offset += 4;
1588
1589                 break;
1590             case ND_OPT_HOMEAGENT_INFO: /* Home Agent Information Option (8) */
1591             {
1592
1593                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
1594                 opt_offset += 2;
1595
1596                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_home_agent_preference, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
1597                 opt_offset += 2;
1598
1599                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_home_agent_lifetime, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
1600                 opt_offset += 2;
1601                 break;
1602             }
1603             case  ND_OPT_SOURCE_ADDRLIST: /* Source Address List (9) */
1604             case  ND_OPT_TARGET_ADDRLIST: /* Target Address List (10)*/
1605             {
1606                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 6, ENC_NA);
1607                 opt_offset += 6;
1608
1609                 while(opt_offset < (offset + opt_len) ) {
1610                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_ipv6_address, tvb, opt_offset, 16, ENC_NA);
1611                     proto_item_append_text(ti, " %s", tvb_ip6_to_str(tvb, opt_offset));
1612                     opt_offset += 16;
1613                 }
1614                 break;
1615             }
1616             case ND_OPT_CGA: /* CGA Option (11) */
1617             {
1618                 proto_tree *cga_tree;
1619                 proto_item *cga_item;
1620                 guint16 ext_data_len;
1621                 guint8 padd_length;
1622                 int par_len;
1623                 asn1_ctx_t asn1_ctx;
1624
1625                 /* Pad Length */
1626                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_cga_pad_len, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1627                 padd_length = tvb_get_guint8(tvb, opt_offset);
1628                 opt_offset += 1;
1629
1630                 /* Reserved 8 bits */
1631
1632                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 1, ENC_NA);
1633                 opt_offset += 1;
1634
1635                 /* CGA Parameters A variable-length field containing the CGA Parameters data
1636                  * structure described in Section 4 of
1637                  * "Cryptographically Generated Addresses (CGA)", RFC3972.
1638                  */
1639                 par_len = opt_len -4 -padd_length;
1640                 cga_item = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_cga, tvb, opt_offset, par_len, ENC_NA);
1641                 par_len += opt_offset;
1642
1643                 cga_tree = proto_item_add_subtree(cga_item, ett_icmpv6_cga_param_name);
1644                 proto_tree_add_item(cga_tree, hf_icmpv6_opt_cga_modifier, tvb, opt_offset, 16, ENC_NA);
1645                 opt_offset += 16;
1646
1647                 proto_tree_add_item(cga_tree, hf_icmpv6_opt_cga_subnet_prefix, tvb, opt_offset, 8, ENC_NA);
1648                 opt_offset += 8;
1649
1650                 proto_tree_add_item(cga_tree ,hf_icmpv6_opt_cga_count, tvb, opt_offset, 1, ENC_NA);
1651                 opt_offset += 1;
1652
1653                 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1654                 opt_offset = dissect_x509af_SubjectPublicKeyInfo(FALSE, tvb, opt_offset, &asn1_ctx, cga_tree, -1);
1655
1656                 /* Process RFC 4581*/
1657                 while (opt_offset < par_len) {
1658                     proto_tree_add_item(cga_tree, hf_icmpv6_opt_cga_ext_type, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
1659                     opt_offset += 2;
1660
1661                     ext_data_len = tvb_get_ntohs(tvb, opt_offset);
1662                     proto_tree_add_item(cga_tree, hf_icmpv6_opt_cga_ext_length, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
1663                     opt_offset += 2;
1664
1665                     proto_tree_add_item(cga_tree, hf_icmpv6_opt_cga_ext_data, tvb, opt_offset, ext_data_len, ENC_NA);
1666                     opt_offset += ext_data_len;
1667                 }
1668
1669                 /* Padding */
1670                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset, padd_length, ENC_NA);
1671                 opt_offset += padd_length;
1672                 break;
1673             }
1674             case ND_OPT_RSA: /* RSA Signature Option (12) */
1675             {
1676                 int par_len;
1677                 /*5.2.  RSA Signature Option */
1678                 /* Reserved, A 16-bit field reserved for future use. */
1679                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
1680                 opt_offset = opt_offset + 2;
1681
1682                 /* Key Hash
1683                  * A 128-bit field containing the most significant (leftmost) 128
1684                  * bits of a SHA-1 [14] hash of the public key used for constructing
1685                  * the signature.
1686                  */
1687                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_rsa_key_hash, tvb, opt_offset, 16, ENC_NA);
1688                 opt_offset = opt_offset + 16;
1689
1690                 /* Digital Signature */
1691                 par_len = opt_len - 20;
1692                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_digital_signature_padding , tvb, opt_offset, par_len, ENC_NA);
1693                 opt_offset += par_len;
1694
1695                 /* Padding */
1696                 /* TODO: Calculate padding length and exclude from the signature */
1697                 break;
1698             }
1699             case ND_OPT_TIMESTAMP: /* Timestamp Option (13) */
1700                 /* Reserved A 48-bit field reserved for future use. */
1701                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 6, ENC_NA);
1702                 opt_offset += 6;
1703
1704                 /* Timestamp
1705                  * A 64-bit unsigned integer field containing a timestamp.  The value
1706                  * indicates the number of seconds since January 1, 1970, 00:00 UTC,
1707                  * by using a fixed point format.  In this format, the integer number
1708                  * of seconds is contained in the first 48 bits of the field, and the
1709                  * remaining 16 bits indicate the number of 1/64K fractions of a
1710                  * second.
1711                  */
1712                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_timestamp, tvb, opt_offset + 2, 4, ENC_TIME_TIMESPEC|ENC_BIG_ENDIAN);
1713                 opt_offset += 8;
1714                 break;
1715             case ND_OPT_NONCE: /* Nonce option (14) */
1716
1717                 /* 5.3.2.  Nonce Option */
1718                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_nonce, tvb, opt_offset, opt_len - 2, ENC_NA);
1719                 opt_offset += opt_len -2;
1720                 break;
1721             case ND_OPT_TRUST_ANCHOR: /* Trust Anchor Option (15) */
1722             {
1723                 proto_tree *name_tree;
1724                 proto_item *name_item;
1725                 guint8 name_type;
1726                 guint8 padd_length;
1727                 int par_len;
1728                 asn1_ctx_t asn1_ctx;
1729
1730                 /* Name Type */
1731                 name_type = tvb_get_guint8(tvb, opt_offset);
1732                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_name_type, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1733                 opt_offset += 1;
1734
1735                 /* Pad Length */
1736                 padd_length = tvb_get_guint8(tvb, opt_offset);
1737                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_cga_pad_len, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1738                 opt_offset += 1;
1739
1740                 par_len = opt_len - 4 - padd_length;
1741
1742                 switch (name_type){
1743                     case 1:
1744                         /* DER Encoded X.501 Name */
1745                         name_item = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_name_x501, tvb, opt_offset, par_len, ENC_NA);
1746                         name_tree = proto_item_add_subtree(name_item, ett_icmpv6_opt_name);
1747                         asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1748                         dissect_x509if_Name(FALSE, tvb, opt_offset, &asn1_ctx, name_tree, hf_icmpv6_x509if_Name);
1749                         break;
1750                     case 2:
1751                         /* FQDN */
1752                         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_name_fqdn, tvb, opt_offset, par_len, ENC_ASCII|ENC_NA);
1753                         break;
1754                     default:
1755                         break;
1756                 }
1757                 opt_offset += par_len;
1758
1759                 /* Padding */
1760                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset, padd_length, ENC_NA);
1761                 opt_offset += padd_length;
1762
1763                 break;
1764             }
1765             case ND_OPT_CERTIFICATE: /* Certificate Option (16) */
1766             {
1767                 guint8 cert_type;
1768                 guint8 padd_length;
1769                 asn1_ctx_t asn1_ctx;
1770
1771                 /* Cert Type */
1772                 cert_type = tvb_get_guint8(tvb, opt_offset);
1773                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_cert_type, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1774                 opt_offset += 1;
1775
1776                 /* Reserved */
1777                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 1, ENC_NA);
1778                 opt_offset += 1;
1779
1780                 /* Certificate */
1781
1782                 if(cert_type == 1){
1783                     asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
1784                     opt_offset = dissect_x509af_Certificate(FALSE, tvb, opt_offset, &asn1_ctx, icmp6opt_tree, hf_icmpv6_x509af_Certificate);
1785                     padd_length = opt_len - (opt_offset - offset);
1786                     /* Padding */
1787                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset, padd_length, ENC_NA);
1788                     opt_offset += padd_length;
1789                 }else{
1790                     padd_length = opt_len - 4;
1791                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_certificate_padding, tvb, opt_offset, padd_length, ENC_NA);
1792                     opt_offset += padd_length;
1793                 }
1794                 break;
1795
1796             }
1797             case ND_OPT_IP_ADDRESS_PREFIX: /* IP Address/Prefix Option (17) */
1798             {
1799                 guint8 prefix_len;
1800
1801                 /* Option-code */
1802                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_ipa_option_code, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1803                 opt_offset += 1;
1804
1805                 /* Prefix Len */
1806                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_ipa_prefix_len, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1807                 prefix_len = tvb_get_guint8(tvb, opt_offset);
1808                 opt_offset += 1;
1809
1810                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 4, ENC_NA);
1811                 opt_offset += 4;
1812
1813                 /* IPv6 Address */
1814                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_ipa_ipv6_address, tvb, opt_offset, 16, ENC_NA);
1815                 proto_item_append_text(ti, " %s/%d", tvb_ip6_to_str(tvb, opt_offset), prefix_len);
1816                 opt_offset += 16;
1817
1818                 break;
1819             }
1820             case ND_OPT_NEW_ROUTER_PREFIX_INFO: /* New Router Prefix Information Option (18) OBSO... */
1821             {
1822
1823                 guint8 prefix_len;
1824
1825                 /* Option-code */
1826                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_nrpi_option_code, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1827                 opt_offset += 1;
1828
1829                 /* Prefix Len */
1830                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_nrpi_prefix_len, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1831                 prefix_len = tvb_get_guint8(tvb, opt_offset);
1832                 opt_offset += 1;
1833
1834                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 4, ENC_NA);
1835                 opt_offset += 4;
1836
1837                 /* Prefix */
1838                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_nrpi_prefix, tvb, opt_offset, 16, ENC_NA);
1839                 proto_item_append_text(ti, " %s/%d", tvb_ip6_to_str(tvb, opt_offset), prefix_len);
1840                 opt_offset += 16;
1841
1842                 break;
1843             }
1844             case ND_OPT_LINK_LAYER_ADDRESS: /* Link-layer Address Option (19) */
1845             {
1846                 /* Option-Code */
1847                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_lla_option_code, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1848                 opt_offset += 1;
1849
1850                 /* Link Layer Address */
1851                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_lla_bytes, tvb, opt_offset, opt_len-3, ENC_NA);
1852                 opt_offset += opt_len - 3;
1853                 break;
1854             }
1855
1856             case ND_OPT_NEIGHBOR_ADV_ACK: /* Neighbor Advertisement Acknowledgment Option (20) */
1857             {
1858                 guint8 status;
1859
1860                 /* Option-Code */
1861                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_naack_option_code, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1862                 opt_offset += 1;
1863
1864                 /* Status */
1865                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_naack_status, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1866                 status = tvb_get_guint8(tvb, opt_offset);
1867                 opt_offset += 1;
1868
1869                 if(status == 2){
1870                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_naack_supplied_ncoa, tvb, opt_offset, 16, ENC_NA);
1871                     opt_offset += 16;
1872                 }else{
1873                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, opt_len - 4, ENC_NA);
1874                     opt_offset += opt_len - 4;
1875                 }
1876                 break;
1877             }
1878             case ND_OPT_MAP: /* MAP Option (23) */
1879             {
1880
1881                 /* Dist */
1882                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_map_dist, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1883
1884                 /* Pref */
1885                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_map_pref, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1886                 opt_offset += 1;
1887
1888                 /* Flags */
1889                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_map_flag, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1890                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_flag_map);
1891
1892                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_map_flag_r, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1893                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_map_flag_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1894                 opt_offset += 1;
1895
1896                 /* Valid Lifetime */
1897                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_map_valid_lifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
1898                 opt_offset += 4;
1899
1900                 /* Global Address */
1901                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_map_global_address, tvb, opt_offset, 16, ENC_NA);
1902                 opt_offset += 16;
1903                 break;
1904             }
1905             case ND_OPT_ROUTE_INFO: /* Route Information Option (24) */
1906             {
1907                 /* RFC 4191 */
1908                 guint8 prefix_len;
1909                 guint8 route_preference;
1910                 struct e_in6_addr prefix;
1911                 address prefix_addr;
1912
1913                 /* Prefix Len */
1914                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_prefix_len, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1915                 prefix_len = tvb_get_guint8(tvb, opt_offset);
1916                 opt_offset += 1;
1917
1918                 /* Flags */
1919                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_route_info_flag, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1920                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_flag_route_info);
1921
1922                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_route_info_flag_route_preference, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1923                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_route_info_flag_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
1924
1925                 route_preference = tvb_get_guint8(tvb, opt_offset);
1926                 route_preference = (route_preference & ND_RA_FLAG_RTPREF_MASK) >> 3;
1927                 proto_item_append_text(ti, " : %s", val_to_str(route_preference, nd_flag_router_pref, "Unknown %d") );
1928                 opt_offset += 1;
1929
1930                 /* Route Lifetime */
1931                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_route_lifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
1932
1933                 switch(tvb_get_ntohl(tvb, opt_offset)){
1934                     case 0xffffffff:
1935                         proto_item_append_text(ti_opt, " (Infinity)");
1936                         break;
1937                     default:
1938                         break;
1939                 }
1940                 opt_offset += 4;
1941
1942                 /* Prefix */
1943                 switch(opt_len){
1944                     case 8: /* Default Option Length without prefix */
1945                         proto_item_append_text(ti, " ::/%d", prefix_len);
1946                         break;
1947                     case 16:
1948                         memset(&prefix, 0, sizeof(prefix));
1949                         tvb_memcpy(tvb, (guint8 *)&prefix.bytes, opt_offset, 8);
1950                         proto_tree_add_ipv6(icmp6opt_tree, hf_icmpv6_opt_prefix, tvb, opt_offset, 8, prefix.bytes);
1951                         SET_ADDRESS(&prefix_addr, AT_IPv6, 16, prefix.bytes);
1952                         proto_item_append_text(ti, " %s/%d", address_to_str(wmem_packet_scope(), &prefix_addr), prefix_len);
1953                         opt_offset += 8;
1954                         break;
1955                     case 24:
1956                         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_prefix, tvb, opt_offset, 16, ENC_NA);
1957                         proto_item_append_text(ti, " %s/%d", tvb_ip6_to_str(tvb, opt_offset), prefix_len);
1958                         opt_offset += 16;
1959                         break;
1960                     default:
1961                         expert_add_info(pinfo, ti_opt_len, &ei_icmpv6_invalid_option_length);
1962                         break;
1963                 }
1964                 break;
1965
1966             }
1967
1968             case ND_OPT_RECURSIVE_DNS_SERVER: /* Recursive DNS Server Option (25) */
1969             {
1970                 /* Reserved */
1971                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
1972                 opt_offset += 2;
1973
1974                 /* RDNSS Lifetime */
1975                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_rdnss_lifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
1976                 /* A value of all one bits (0xffffffff) represents infinity.  A value of
1977                  * zero means that the RDNSS address MUST no longer be used.
1978                  */
1979                 switch(tvb_get_ntohl(tvb, opt_offset)){
1980                     case 0:
1981                         proto_item_append_text(ti_opt, " (RDNSS address MUST no longer be used)");
1982                         break;
1983                     case 0xffffffff:
1984                         proto_item_append_text(ti_opt, " (Infinity)");
1985                         break;
1986                     default:
1987                         break;
1988                 }
1989                 opt_offset += 4;
1990
1991                 while(opt_offset < (offset + opt_len) ) {
1992                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_rdnss, tvb, opt_offset, 16, ENC_NA);
1993                     proto_item_append_text(ti, " %s", tvb_ip6_to_str(tvb, opt_offset));
1994                     opt_offset += 16;
1995
1996                 }
1997                 break;
1998             }
1999             case ND_OPT_FLAGS_EXTENSION: /* RA Flags Extension Option (26) */
2000             {
2001                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_efo, tvb, opt_offset, 6, ENC_NA);
2002                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_flag_efo);
2003
2004                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_efo_m, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2005                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_efo_o, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2006                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_efo_h, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2007                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_efo_prf, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2008                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_efo_p, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2009                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_efo_rsv, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2010                 opt_offset += 2;
2011
2012                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 4, ENC_NA);
2013                 opt_offset += 4;
2014                 break;
2015             }
2016             case ND_OPT_HANDOVER_KEY_REQUEST: /* Handover Key Request Option (27) */
2017             {
2018                 int par_len;
2019                 guint padd_length;
2020
2021                 /* Pad Length */
2022                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_pad_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2023                 padd_length = tvb_get_guint8(tvb, opt_offset);
2024                 opt_offset += 1;
2025
2026                 /* AT */
2027                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_at, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2028
2029                 /* Reserved */
2030                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2031                 opt_offset += 1;
2032
2033                 /* Handover Key Encryption Public Key */
2034                 par_len = opt_len-4-padd_length;
2035                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_encryption_public_key, tvb, opt_offset, par_len, ENC_NA);
2036                 opt_offset += par_len;
2037
2038                 /* Padding */
2039                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_padding, tvb, opt_offset, padd_length, ENC_NA);
2040                 opt_offset += 1;
2041                 break;
2042             }
2043             case ND_OPT_HANDOVER_KEY_REPLY: /* Handover Key Reply Option (28) */
2044             {
2045                 int par_len;
2046                 guint padd_length;
2047
2048                 /* Pad Length */
2049                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_pad_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2050                 padd_length = tvb_get_guint8(tvb, opt_offset);
2051                 opt_offset += 1;
2052
2053                 /* AT */
2054                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_at, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2055
2056                 /* Reserved */
2057                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2058                 opt_offset += 1;
2059
2060                 /* Lifetime */
2061                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_lifetime, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2062                 opt_offset += 2;
2063
2064                 /* Encrypted Handover Key */
2065                 par_len = opt_len-6-padd_length;
2066                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_encrypted_handover_key, tvb, opt_offset, par_len, ENC_NA);
2067                 opt_offset += par_len;
2068
2069                 /* Padding */
2070                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hkr_padding, tvb, opt_offset, padd_length, ENC_NA);
2071                 opt_offset += 1;
2072                 break;
2073             }
2074             case ND_OPT_HANDOVER_ASSIST_INFO: /* Handover Assist Information Option (29) */
2075             {
2076                 guint8 hai_len;
2077                 int padd_length;
2078                 /* Option-Code */
2079                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hai_option_code, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2080                 opt_offset += 1;
2081
2082                 /* HAI Length */
2083                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hai_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2084                 hai_len = tvb_get_guint8(tvb, opt_offset);
2085                 opt_offset += 1;
2086
2087                 /* HAI Value */
2088                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_hai_value, tvb, opt_offset, hai_len, ENC_NA);
2089                 opt_offset += hai_len;
2090
2091                 /* Padding... */
2092                 padd_length = opt_len - opt_offset;
2093                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset, padd_length, ENC_NA);
2094                 opt_offset += padd_length;
2095
2096                 break;
2097             }
2098             case ND_OPT_MOBILE_NODE_ID: /* Mobile Node Identifier Option (30) */
2099             {
2100                 guint8 mn_len;
2101                 int padd_length;
2102                 /* Option-Code */
2103                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_mn_option_code, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2104                 opt_offset += 1;
2105
2106                 /* MN Length */
2107                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_mn_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2108                 mn_len = tvb_get_guint8(tvb, opt_offset);
2109                 opt_offset += 1;
2110
2111                 /* MN Value */
2112                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_mn_value, tvb, opt_offset, mn_len, ENC_NA);
2113                 opt_offset += mn_len;
2114
2115                 /* Padding... */
2116                 padd_length = opt_len - opt_offset;
2117                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset, padd_length, ENC_NA);
2118                 opt_offset += padd_length;
2119
2120                 break;
2121             }
2122             case ND_OPT_DNS_SEARCH_LIST: /* DNS Search List Option (31) */
2123             {
2124                 int dnssl_len;
2125                 const guchar *dnssl_name;
2126
2127                 /* Reserved */
2128                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
2129                 opt_offset += 2;
2130
2131                 /* DNSSL Lifetime */
2132                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_dnssl_lifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
2133                 switch(tvb_get_ntohl(tvb, opt_offset)){
2134                     case 0:
2135                         proto_item_append_text(ti_opt, " (DNSSL domain name MUST no longer be used)");
2136                         break;
2137                     case 0xffffffff:
2138                         proto_item_append_text(ti_opt, " (Infinity)");
2139                         break;
2140                     default:
2141                         break;
2142                 }
2143                 opt_offset += 4;
2144                 while(opt_offset < (offset + opt_len) ) {
2145
2146                     if(tvb_get_guint8(tvb, opt_offset) == 0){
2147                         /* Padding... */
2148                         int padd_length = (offset + opt_len) - opt_offset;
2149                         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_padding, tvb, opt_offset, padd_length, ENC_NA);
2150                         opt_offset += padd_length;
2151                         break;
2152                     }
2153                     dnssl_len = get_dns_name(tvb, opt_offset, 0, opt_offset, &dnssl_name);
2154                     proto_tree_add_string(icmp6opt_tree, hf_icmpv6_opt_dnssl, tvb, opt_offset, dnssl_len, dnssl_name);
2155                     proto_item_append_text(ti, " %s", dnssl_name);
2156                     opt_offset += dnssl_len;
2157
2158                 }
2159                 break;
2160             }
2161             case ND_OPT_PROXY_SIGNATURE: /* Proxy Signature Option (32) */
2162             {
2163                 int par_len;
2164
2165                 /* Reserved */
2166                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
2167                 opt_offset +=  2;
2168
2169                 /* Key Hash
2170                  * A 128-bit field containing the most significant (leftmost) 128
2171                  * bits of a SHA-1 [14] hash of the public key used for constructing
2172                  * the signature.
2173                  */
2174                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_ps_key_hash, tvb, opt_offset, 16, ENC_NA);
2175                 opt_offset += 16;
2176
2177                 /* Digital Signature */
2178                 par_len = opt_len - 20;
2179                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_digital_signature_padding , tvb, opt_offset, par_len, ENC_NA);
2180                 opt_offset += par_len;
2181                 /* Padding */
2182                 /* TODO: Calculate padding length and exclude from the signature */
2183                 break;
2184             }
2185             case ND_OPT_ADDR_REGISTRATION: /* Address Registration (TBD1 Pending IANA...) */
2186             {
2187                 /* 6lowpan-ND */
2188                 guint8 status;
2189
2190                 /* Status */
2191                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_aro_status, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2192                 status = tvb_get_guint8(tvb, opt_offset);
2193                 opt_offset += 1;
2194
2195                 /* Reserved */
2196                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 3, ENC_NA);
2197                 opt_offset += 3;
2198
2199                 /* Lifetime */
2200                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_aro_registration_lifetime, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2201                 opt_offset += 2;
2202
2203                 /* EUI-64 */
2204                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_aro_eui64, tvb, opt_offset, 8, ENC_BIG_ENDIAN);
2205                 proto_item_append_text(ti, " : Register %s %s", tvb_eui64_to_str(tvb, opt_offset), val_to_str(status, nd_opt_6lowpannd_status_val, "Unknown %d"));
2206                 opt_offset += 8;
2207
2208             }
2209             break;
2210             case ND_OPT_6LOWPAN_CONTEXT: /* 6LoWPAN Context (TBD2 Pending IANA...) */
2211             {
2212                 ieee802154_hints_t *hints;
2213                 /* 6lowpan-ND */
2214                 guint8 context_id;
2215                 guint8 context_len;
2216                 struct e_in6_addr context_prefix;
2217                 address context_prefix_addr;
2218
2219                 /* Context Length */
2220                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_6co_context_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2221                 context_len = tvb_get_guint8(tvb, opt_offset);
2222                 opt_offset += 1;
2223
2224                 /*  Flags & CID */
2225                 context_id = tvb_get_guint8(tvb, opt_offset) & ND_OPT_6CO_FLAG_CID;
2226                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_6co_flag, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2227                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_flag_6lowpan);
2228                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_6co_flag_c, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2229                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_6co_flag_cid, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2230                 proto_tree_add_item(flag_tree, hf_icmpv6_opt_6co_flag_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2231                 opt_offset += 1;
2232
2233                 /* Reserved */
2234                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_reserved, tvb, opt_offset, 2, ENC_NA);
2235                 opt_offset += 2;
2236
2237                 /* Lifetime */
2238                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_6co_valid_lifetime, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2239                 opt_offset += 2;
2240
2241                 /* Context */
2242                 memset(&context_prefix.bytes, 0, sizeof(context_prefix));
2243                 switch(opt_len){
2244                     case 8: /* Default Option Length without context prefix */
2245                         proto_item_append_text(ti, " ::/%d", context_len);
2246                         break;
2247                     case 16:
2248                         tvb_memcpy(tvb, (guint8 *)&context_prefix.bytes, opt_offset, 8);
2249                         proto_tree_add_ipv6(icmp6opt_tree, hf_icmpv6_opt_6co_context_prefix, tvb, opt_offset, 8, context_prefix.bytes);
2250                         SET_ADDRESS(&context_prefix_addr, AT_IPv6, 16, context_prefix.bytes);
2251                         proto_item_append_text(ti, " %s/%d", address_to_str(wmem_packet_scope(), &context_prefix_addr), context_len);
2252                         opt_offset += 8;
2253                         break;
2254                     case 24:
2255                         tvb_memcpy(tvb, (guint8 *)&context_prefix.bytes, opt_offset, 16);
2256                         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_6co_context_prefix, tvb, opt_offset, 16, ENC_NA);
2257                         proto_item_append_text(ti, " %s/%d", tvb_ip6_to_str(tvb, opt_offset), context_len);
2258                         opt_offset += 16;
2259                         break;
2260                     default:
2261                         expert_add_info(pinfo, ti_opt_len, &ei_icmpv6_invalid_option_length);
2262                         break;
2263                 }
2264                 /* Update the 6LoWPAN dissectors with new context information. */
2265                 hints = (ieee802154_hints_t *)p_get_proto_data(wmem_file_scope(), pinfo,
2266                         proto_get_id_by_filter_name(IEEE802154_PROTOABBREV_WPAN), 0);
2267                 if ((opt_len <= 24) && hints) {
2268                     lowpan_context_insert(context_id, hints->src_pan, context_len, &context_prefix, pinfo->fd->num);
2269                 }
2270             }
2271             break;
2272             case ND_OPT_AUTH_BORDER_ROUTER: /* Authoritative Border Router (33) */
2273             {
2274                 guint16 version_low, version_high, valid_lifetime;
2275
2276                 /* Version low*/
2277                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_abro_version_low, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2278                 version_low = tvb_get_ntohs(tvb, opt_offset);
2279                 opt_offset += 2;
2280
2281                 /* Version high */
2282                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_abro_version_high, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2283                 version_high = tvb_get_ntohs(tvb, opt_offset);
2284                 opt_offset += 2;
2285
2286                 /* Valid lifetime */
2287                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_abro_valid_lifetime, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2288                 valid_lifetime = tvb_get_ntohs(tvb, opt_offset);
2289                 opt_offset += 2;
2290
2291                 /* 6LBR Address */
2292                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_abro_6lbr_address, tvb, opt_offset, 16, ENC_NA);
2293                 proto_item_append_text(ti, " : Version %d.%d, Valid Lifetime : %d, 6LBR : %s", version_high, version_low, valid_lifetime, tvb_ip6_to_str(tvb, opt_offset));
2294                 opt_offset += 16;
2295
2296             }
2297             break;
2298             case ND_OPT_6CIO: /* 6LoWPAN Capability Indication Option (35) */
2299             {
2300
2301                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_6cio_unassigned1, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2302                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_6cio_flag_g, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2303                 opt_offset += 2;
2304
2305                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_opt_6cio_unassigned2, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
2306                 opt_offset += 4;
2307
2308
2309             }
2310             break;
2311             default :
2312                 expert_add_info_format(pinfo, ti, &ei_icmpv6_undecoded_option,
2313                                        "Dissector for ICMPv6 Option (%d)"
2314                                        " code not implemented, Contact Wireshark developers"
2315                                        " if you want this supported", opt_type);
2316                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_data, tvb, opt_offset, opt_len, ENC_NA);
2317                 opt_offset += opt_len;
2318                 break;
2319
2320         } /* switch (opt_type) */
2321
2322         offset += opt_len;
2323
2324         if(offset > opt_offset){
2325             ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_unknown_data, tvb, opt_offset, offset - opt_offset, ENC_NA);
2326             expert_add_info(pinfo, ti_opt, &ei_icmpv6_unknown_data);
2327         }
2328         /* Close the ) to option root label */
2329         proto_item_append_text(ti, ")");
2330     }
2331     return offset;
2332 }
2333
2334
2335 /* RPL: RFC 6550/6997 : Routing and Discovery of P2P Routes in Low-Power and Lossy Networks. */
2336 static int
2337 dissect_icmpv6_rpl_opt(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, guint8 icmp6_code)
2338 {
2339     proto_tree *icmp6opt_tree, *flag_tree;
2340     proto_item *ti, *ti_opt, *ti_opt_len, *ti_opt_reply, *ti_opt_hop_by_hop, *ti_opt_num_of_routes,
2341                *ti_opt_lifetime, *ti_opt_mr_nh = NULL;
2342     guint8      opt_type;
2343     int         opt_len;
2344     int         opt_offset;
2345
2346     while ((int)tvb_reported_length(tvb) > offset) {
2347         /* there are more options */
2348
2349         /* ICMPv6 RPL Option */
2350         ti = proto_tree_add_item(tree, hf_icmpv6_rpl_opt, tvb, offset, 1, ENC_NA);
2351         icmp6opt_tree = proto_item_add_subtree(ti, ett_icmpv6_rpl_opt);
2352         opt_offset = offset;
2353
2354         /* Option type */
2355         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_type, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2356         opt_type = tvb_get_guint8(tvb, opt_offset);
2357         opt_offset += 1;
2358
2359         /* Add option name to option root label */
2360         proto_item_append_text(ti, " (%s", val_to_str(opt_type, rpl_option_vals, "Unknown %d"));
2361
2362         /* The Pad1 option is a special case, and contains no data. */
2363         if (opt_type == RPL_OPT_PAD1) {
2364             offset += 1;
2365             proto_item_append_text(ti, ")");
2366             continue;
2367         }
2368
2369         /* Option length */
2370         ti_opt_len = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2371         opt_len = tvb_get_guint8(tvb, opt_offset);
2372         proto_item_set_len(ti, opt_len + 2);
2373         opt_offset += 1;
2374
2375         /* decode... */
2376         switch (opt_type) {
2377             case RPL_OPT_PADN:
2378                 /* n-byte padding */
2379                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_padn, tvb, opt_offset, opt_len, ENC_NA);
2380                 proto_item_append_text(ti_opt, " (Length : %i bytes)", opt_len);
2381                 opt_offset += opt_len;
2382                 break;
2383
2384             case RPL_OPT_METRIC:
2385                 /* DAG metric container */
2386                 /* See draft-ietf-roll-routing-metrics for formatting. */
2387                 break;
2388             case RPL_OPT_ROUTING: {
2389                 guint8 prefix_len;
2390                 struct e_in6_addr prefix;
2391                 address prefix_addr;
2392
2393                 /* Prefix length */
2394                 prefix_len = tvb_get_guint8(tvb, opt_offset);
2395                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_prefix_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2396                 opt_offset +=1;
2397
2398                 /* Flags */
2399                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_flag, tvb, opt_offset, 1, ENC_NA);
2400                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_rpl_flag_routing);
2401
2402                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_route_pref, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2403                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_route_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2404                 opt_offset +=1;
2405
2406                 /* Prefix lifetime. */
2407                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_lifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
2408
2409                 switch(tvb_get_ntohl(tvb, opt_offset)){
2410                     case 0xffffffff:
2411                         proto_item_append_text(ti_opt, " (Infinity)");
2412                         break;
2413                     default:
2414                         break;
2415                 }
2416                 opt_offset += 4;
2417
2418                 switch(opt_len){
2419                     case 6: /* Default Option Length without prefix */
2420                         proto_item_append_text(ti, " ::/%d", prefix_len);
2421                         break;
2422                     case 14:
2423                         memset(&prefix, 0, sizeof(prefix));
2424                         tvb_memcpy(tvb, (guint8 *)&prefix.bytes, opt_offset, 8);
2425                         proto_tree_add_ipv6(icmp6opt_tree, hf_icmpv6_rpl_opt_route_prefix, tvb, opt_offset, 8, prefix.bytes);
2426                         SET_ADDRESS(&prefix_addr, AT_IPv6, 16, prefix.bytes);
2427                         proto_item_append_text(ti, " %s/%d", address_to_str(wmem_packet_scope(), &prefix_addr), prefix_len);
2428                         opt_offset += 8;
2429                         break;
2430                     case 22:
2431                         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_prefix, tvb, opt_offset, 16, ENC_NA);
2432                         proto_item_append_text(ti, " %s/%d", tvb_ip6_to_str(tvb, opt_offset), prefix_len);
2433                         opt_offset += 16;
2434                         break;
2435                     default:
2436                         expert_add_info(pinfo, ti_opt_len, &ei_icmpv6_invalid_option_length);
2437                         break;
2438                 }
2439                 break;
2440             }
2441             case RPL_OPT_CONFIG: {
2442
2443                 /* Flags */
2444                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_flag, tvb, opt_offset, 1, ENC_NA);
2445                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_rpl_flag_config);
2446
2447                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_config_reserved, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2448                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_config_auth, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2449                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_config_pcs, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2450                 opt_offset += 1;
2451
2452                 /* DIOIntervalDoublings */
2453                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_doublings, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2454                 opt_offset += 1;
2455
2456                 /* DIOIntervalMin */
2457                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_min_interval, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2458                 opt_offset += 1;
2459
2460                 /* DIORedundancyConstant */
2461                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_redundancy, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2462                 opt_offset += 1;
2463
2464                 /* MaxRankIncrease */
2465                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_rank_incr, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2466                 opt_offset += 2;
2467
2468                 /* MinHopRankInc */
2469                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_hop_rank_inc, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2470                 opt_offset += 2;
2471
2472                 /* OCP */
2473                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_ocp, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2474                 opt_offset += 2;
2475
2476                 /* Reserved */
2477                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_rsv, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2478                 opt_offset += 1;
2479
2480                 /* Default Lifetime */
2481                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_def_lifetime, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2482                 opt_offset += 1;
2483
2484                 /* Lifetime Unit */
2485                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_config_lifetime_unit, tvb, opt_offset, 2, ENC_BIG_ENDIAN);
2486                 opt_offset += 2;
2487                 break;
2488             }
2489             case RPL_OPT_TARGET: {
2490                 guint8              prefix_len;
2491                 struct e_in6_addr   target_prefix;
2492                 address target_prefix_addr;
2493
2494                 /* Flag */
2495                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_target_flag, tvb, opt_offset, 1, ENC_NA);
2496                 opt_offset += 1;
2497
2498                 /* Prefix length */
2499                 prefix_len = tvb_get_guint8(tvb, opt_offset);
2500                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_target_prefix_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2501                 opt_offset += 1;
2502
2503                 /* Target Prefix */
2504
2505                 switch(opt_len){
2506                     case 2: /* Default Option Length without prefix */
2507                         proto_item_append_text(ti, " ::/%d", prefix_len);
2508                         break;
2509                     case 10:
2510                         memset(&target_prefix, 0, sizeof(target_prefix));
2511                         tvb_memcpy(tvb, (guint8 *)&target_prefix.bytes, opt_offset, 8);
2512                         proto_tree_add_ipv6(icmp6opt_tree, hf_icmpv6_rpl_opt_target_prefix, tvb, opt_offset, 8, target_prefix.bytes);
2513                         SET_ADDRESS(&target_prefix_addr, AT_IPv6, 16, target_prefix.bytes);
2514                         proto_item_append_text(ti, " %s/%d", address_to_str(wmem_packet_scope(), &target_prefix_addr), prefix_len);
2515                         opt_offset += 8;
2516                         break;
2517                     case 18:
2518                         proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_target_prefix, tvb, opt_offset, 16, ENC_NA);
2519                         proto_item_append_text(ti, " %s/%d", tvb_ip6_to_str(tvb, opt_offset), prefix_len);
2520                         opt_offset += 16;
2521                         break;
2522                     default:
2523                         expert_add_info(pinfo, ti_opt_len, &ei_icmpv6_invalid_option_length);
2524                         break;
2525                 }
2526                 break;
2527             }
2528             case RPL_OPT_TRANSIT: {
2529                 /* Flags */
2530                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_transit_flag, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2531                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_rpl_flag_transit);
2532
2533                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_transit_flag_e, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2534                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_transit_flag_rsv, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2535                 opt_offset += 1;
2536
2537                 /* Path Control */
2538                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_transit_pathctl, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2539                 opt_offset += 1;
2540
2541                 /* Path Sequence */
2542                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_transit_pathseq, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2543                 opt_offset += 1;
2544
2545                 /* Path Lifetime */
2546                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_transit_pathlifetime, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2547                 opt_offset += 1;
2548
2549                 /* Option contains parent */
2550                 if(opt_len > 4)
2551                 {
2552                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_transit_parent, tvb, opt_offset, 16, ENC_NA);
2553                     proto_item_append_text(ti, " %s", tvb_ip6_to_str(tvb, opt_offset));
2554                     opt_offset += 16;
2555                 }
2556
2557                 break;
2558             }
2559             case RPL_OPT_SOLICITED: {
2560
2561                 /*Instance ID */
2562                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_solicited_instance, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2563                 opt_offset += 1;
2564
2565                 /* Flags */
2566                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_solicited_flag, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2567                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_rpl_flag_solicited);
2568
2569                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_solicited_flag_v, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2570                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_solicited_flag_i, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2571                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_solicited_flag_d, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2572                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_solicited_flag_rsv, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2573                 opt_offset += 1;
2574
2575                 /* DODAG ID */
2576                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_solicited_dodagid, tvb, opt_offset, 16, ENC_NA);
2577                 opt_offset += 16;
2578
2579                 /* Version Number */
2580                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_solicited_version, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2581                 opt_offset += 1;
2582
2583                 break;
2584             }
2585             case RPL_OPT_PREFIX: {
2586                 /* Destination prefix option. */
2587                 guint8              prefix_len;
2588
2589                 /* Prefix length */
2590                 prefix_len = tvb_get_guint8(tvb, opt_offset);
2591                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_prefix_length, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2592                 opt_offset +=1;
2593
2594                 /* Flags */
2595                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_prefix_flag, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2596                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_rpl_flag_prefix);
2597
2598                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_prefix_flag_l, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2599                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_prefix_flag_a, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2600                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_prefix_flag_r, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2601                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_prefix_flag_rsv, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2602                 opt_offset += 1;
2603
2604                 /* Valid lifetime. */
2605                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_prefix_vlifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
2606                 switch(tvb_get_ntohl(tvb, opt_offset)){
2607                     case 0xffffffff:
2608                         proto_item_append_text(ti_opt, " (Infinity)");
2609                         break;
2610                     default:
2611                         break;
2612                 }
2613                 opt_offset += 4;
2614
2615                 /* Preferred Lifetime */
2616                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_prefix_plifetime, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
2617                 switch(tvb_get_ntohl(tvb, opt_offset)){
2618                     case 0xffffffff:
2619                         proto_item_append_text(ti_opt, " (Infinity)");
2620                         break;
2621                     default:
2622                         break;
2623                 }
2624                 opt_offset += 4;
2625
2626                 /* 4 reserved bytes. */
2627                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_reserved, tvb, opt_offset, 4, ENC_NA);
2628                 opt_offset += 4;
2629
2630                 /* Prefix */
2631                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_prefix, tvb, opt_offset, 16, ENC_NA);
2632                 proto_item_append_text(ti, " %s/%d", tvb_ip6_to_str(tvb, opt_offset), prefix_len);
2633                 opt_offset += 16;
2634
2635                 break;
2636             }
2637
2638             case RPL_OPT_TARGETDESC: {
2639
2640                 /* Descriptor */
2641                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_targetdesc, tvb, opt_offset, 4, ENC_BIG_ENDIAN);
2642                 opt_offset += 4;
2643                 break;
2644             }
2645
2646             case RPL_OPT_ROUTE_DISCOVERY: {
2647                 int num_of_addr = 0;
2648                 guint8 flags = 0, compr = 0, addr_len = 0, lt_mr_nh = 0;
2649                 guint8 addr[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2650
2651                 /* Flags */
2652                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_discovery_flag, tvb, opt_offset, 1, ENC_NA);
2653                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_rpl_route_discovery_flag);
2654
2655                 flags = tvb_get_guint8(tvb, opt_offset);
2656                 compr = flags & RPL_OPT_ROUTE_DISCOVERY_COMPR;
2657
2658                 /* Reply */
2659                 ti_opt_reply = proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_route_discovery_reply, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2660
2661                 /* Hop-by-Hop */
2662                 ti_opt_hop_by_hop = proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_route_discovery_hop_by_hop, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2663
2664                 /* Num of Source Routes */
2665                 ti_opt_num_of_routes = proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_route_discovery_num_of_routes, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2666
2667                 /* Compr */
2668                 proto_tree_add_item(flag_tree, hf_icmpv6_rpl_opt_route_discovery_compr, tvb, opt_offset, 1, ENC_BIG_ENDIAN);
2669                 opt_offset +=1;
2670
2671                 /* Lifetime / MaxRank / NH */
2672                 lt_mr_nh = tvb_get_guint8(tvb, opt_offset);
2673                 ti_opt_lifetime = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_discovery_lifetime, tvb, opt_offset, 1, ENC_NA);
2674
2675                 if ((icmp6_code == ICMP6_RPL_P2P_DRO) || (icmp6_code == ICMP6_RPL_P2P_SDRO)) {
2676                     proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_discovery_nh, tvb, opt_offset, 1, ENC_NA);
2677                 } else {
2678                     ti_opt_mr_nh = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_discovery_maxrank, tvb, opt_offset, 1, ENC_NA);
2679                 }
2680
2681                 opt_offset +=1;
2682
2683                 /* add expert and auxiliary info */
2684                 switch (icmp6_code) {
2685                     case ICMP6_RPL_P2P_SDRO:
2686                     case ICMP6_RPL_P2P_DRO:
2687
2688                         if (flags & RPL_OPT_ROUTE_DISCOVERY_R) {
2689                             expert_add_info(pinfo, ti_opt_reply, &ei_icmpv6_rpl_p2p_dro_rdo_zero);
2690                         }
2691
2692                         if (flags & RPL_OPT_ROUTE_DISCOVERY_N) {
2693                             expert_add_info(pinfo, ti_opt_num_of_routes, &ei_icmpv6_rpl_p2p_dro_rdo_zero);
2694                         }
2695
2696                         if (lt_mr_nh & RPL_OPT_ROUTE_DISCOVERY_L) {
2697                             expert_add_info(pinfo, ti_opt_lifetime, &ei_icmpv6_rpl_p2p_dro_rdo_zero);
2698                         }
2699
2700                         break;
2701                     default:
2702
2703                         if (flags & RPL_OPT_ROUTE_DISCOVERY_H) {
2704                             if (!(flags & RPL_OPT_ROUTE_DISCOVERY_R)) {
2705                                 expert_add_info(pinfo, ti_opt_hop_by_hop, &ei_icmpv6_rpl_p2p_hop_by_hop);
2706                             }
2707
2708                             if (flags & RPL_OPT_ROUTE_DISCOVERY_N) {
2709                                 expert_add_info(pinfo, ti_opt_num_of_routes, &ei_icmpv6_rpl_p2p_num_of_routes);
2710                             }
2711                         }
2712
2713                         proto_item_append_text(ti_opt_lifetime, " (%d sec)", (int) pow(4.0, (lt_mr_nh & RPL_OPT_ROUTE_DISCOVERY_L) >> 6));
2714
2715                         if (!(lt_mr_nh & RPL_OPT_ROUTE_DISCOVERY_MR_NH)) {
2716                             proto_item_append_text(ti_opt_mr_nh, " (Infinity)");
2717                         }
2718
2719                         break;
2720                 }
2721
2722                 /* TargetAddr */
2723                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_discovery_target_addr, tvb, opt_offset, 16, ENC_NA);
2724                 opt_offset +=16;
2725
2726                 addr_len = (16 - compr);
2727                 num_of_addr = (opt_len - 18) / addr_len;
2728
2729                 /* Address Vector */
2730                 ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_rpl_opt_route_discovery_addr_vec, tvb, opt_offset, (opt_len - 18), ENC_NA);
2731                 flag_tree = proto_item_add_subtree(ti_opt, ett_icmpv6_rpl_route_discovery_addr_vec);
2732
2733                 proto_item_append_text(flag_tree, " (%d Address%s)", num_of_addr, num_of_addr != 1 ? "es" : "");
2734
2735                 while (num_of_addr--) {
2736                     memset(addr, 0, sizeof(addr));
2737                     memcpy(addr + compr, tvb_get_ptr(tvb, opt_offset, addr_len), addr_len);
2738                     proto_tree_add_ipv6(flag_tree, hf_icmpv6_rpl_opt_route_discovery_addr_vec_addr, tvb, opt_offset, addr_len, addr);
2739                     opt_offset += addr_len;
2740                 }
2741
2742                 break;
2743             }
2744             default :
2745                 expert_add_info_format(pinfo, ti, &ei_icmpv6_undecoded_rpl_option,
2746                                        "Dissector for ICMPv6 RPL Option"
2747                                        " (%d) code not implemented, Contact"
2748                                        " Wireshark developers if you want this supported", opt_type);
2749                 proto_tree_add_item(icmp6opt_tree, hf_icmpv6_data, tvb, opt_offset, opt_len, ENC_NA);
2750                 opt_offset += opt_len;
2751                 break;
2752         } /* switch (opt_type) */
2753
2754         offset += opt_len + 2;
2755
2756         if(offset > opt_offset){
2757             ti_opt = proto_tree_add_item(icmp6opt_tree, hf_icmpv6_unknown_data, tvb, opt_offset, offset - opt_offset, ENC_NA);
2758             expert_add_info(pinfo, ti_opt, &ei_icmpv6_unknown_data);
2759         }
2760
2761         /* Close the ) to option root label */
2762         proto_item_append_text(ti, ")");
2763     } /* while */
2764     return offset;
2765 }
2766
2767 static int
2768 dissect_rpl_control(tvbuff_t *tvb, int rpl_offset, packet_info *pinfo _U_, proto_tree *icmp6_tree, guint8 icmp6_type _U_, guint8 icmp6_code)
2769 {
2770     proto_tree *flag_tree;
2771     proto_item *ti;
2772
2773     /* Secure RPL ? (ICMP Code start to 0x8x) */
2774     if(icmp6_code & ICMP6_RPL_SECURE)
2775     {
2776         guint8 kim, lvl;
2777
2778         /* Flags */
2779         ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2780         flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_secure);
2781         proto_tree_add_item(flag_tree, hf_icmpv6_rpl_secure_flag_t, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2782         proto_tree_add_item(flag_tree, hf_icmpv6_rpl_secure_flag_rsv, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2783         rpl_offset += 1;
2784
2785         /* Algorithm */
2786         ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_algorithm, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2787         flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_secure);
2788         proto_tree_add_item(flag_tree, hf_icmpv6_rpl_secure_algorithm_encryption, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2789         proto_tree_add_item(flag_tree, hf_icmpv6_rpl_secure_algorithm_signature, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2790         rpl_offset += 1;
2791
2792         /* KIM & LVL */
2793         ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2794         flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_secure);
2795         proto_tree_add_item(flag_tree, hf_icmpv6_rpl_secure_kim, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2796         proto_tree_add_item(flag_tree, hf_icmpv6_rpl_secure_lvl, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2797         proto_tree_add_item(flag_tree, hf_icmpv6_rpl_secure_rsv, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2798         kim = tvb_get_guint8(tvb, rpl_offset) & RPL_SECURE_KIM >> 6;
2799         lvl = tvb_get_guint8(tvb, rpl_offset) & RPL_SECURE_LVL;
2800         rpl_offset += 1;
2801
2802         /* Flags */
2803         proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2804         rpl_offset += 1;
2805
2806         /* Counter */
2807         proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_counter, tvb, rpl_offset, 4, ENC_BIG_ENDIAN);
2808         rpl_offset += 4;
2809
2810         /*  Key Identifier */
2811         switch(kim){
2812             case 0:
2813             {
2814                 proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_key_index, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2815                 rpl_offset += 1;
2816                 break;
2817             }
2818             case 1:
2819             {
2820                 /* No Key Identifier */
2821                 break;
2822             }
2823             case 2:
2824             {
2825                 proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_key_source, tvb, rpl_offset, 8, ENC_NA);
2826                 rpl_offset += 8;
2827                 proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_key_index, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2828                 rpl_offset += 1;
2829                 break;
2830             }
2831             case 3:
2832             {
2833                 if(lvl == 1 || lvl == 3)
2834                 {
2835                     proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_key_source, tvb, rpl_offset, 8, ENC_NA);
2836                     rpl_offset += 8;
2837                     proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_secure_key_index, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2838                     rpl_offset += 1;
2839                 }
2840                 break;
2841             }
2842
2843         }
2844
2845     }
2846     switch(icmp6_code){
2847         case ICMP6_RPL_DIS: /* DODAG Information Solicitation (0) */
2848         case ICMP6_RPL_SDIS: /* Secure DODAG Information Solicitation (128) */
2849         {
2850             /* Flags */
2851             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dis_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2852             rpl_offset += 1;
2853
2854             /* Reserved */
2855             proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, rpl_offset, 1, ENC_NA);
2856             rpl_offset += 1;
2857
2858             /* RPL Options */
2859             rpl_offset = dissect_icmpv6_rpl_opt(tvb, rpl_offset, pinfo, icmp6_tree, icmp6_code);
2860             break;
2861         }
2862         case ICMP6_RPL_DIO: /* DODAG Information Object (1) */
2863         case ICMP6_RPL_SDIO: /* Secure DODAG Information Object (129) */
2864         {
2865             /* RPLInstanceID */
2866             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dio_instance, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2867             rpl_offset += 1;
2868
2869             /* Version Number */
2870             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dio_version, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2871             rpl_offset += 1;
2872
2873             /* Rank */
2874             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dio_rank, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
2875             rpl_offset += 2;
2876
2877             /* Flags */
2878             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dio_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2879             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_rpl_dio);
2880             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_dio_flag_g, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2881             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_dio_flag_0, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2882             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_dio_flag_mop, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2883             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_dio_flag_prf, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2884             rpl_offset += 1;
2885
2886             /* Destination Advertisement Trigger Sequence Number (DTSN) */
2887             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dio_dtsn, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2888             rpl_offset += 1;
2889
2890             /* Flags */
2891             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dio_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2892             rpl_offset += 1;
2893
2894             /* Reserved */
2895             proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, rpl_offset, 1, ENC_NA);
2896             rpl_offset += 1;
2897
2898             /* DODAGID */
2899             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dio_dagid, tvb, rpl_offset, 16, ENC_NA);
2900             rpl_offset += 16;
2901
2902             /* RPL Options */
2903             rpl_offset = dissect_icmpv6_rpl_opt(tvb, rpl_offset, pinfo, icmp6_tree, icmp6_code);
2904             break;
2905         }
2906         case ICMP6_RPL_DAO: /* Destination Advertisement Object (2) */
2907         case ICMP6_RPL_SDAO: /* Secure Destination Advertisement Object (130) */
2908         {
2909             guint8 flags;
2910
2911             /* DAO Instance */
2912             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dao_instance, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2913             rpl_offset += 1;
2914
2915             /* Flags */
2916             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dao_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2917             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_rpl_dao);
2918             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_dao_flag_k, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2919             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_dao_flag_d, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2920             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_dao_flag_rsv, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2921             flags = tvb_get_guint8(tvb, rpl_offset);
2922             rpl_offset += 1;
2923
2924             /* Reserved */
2925             proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, rpl_offset, 1, ENC_NA);
2926             rpl_offset += 1;
2927
2928             /* Sequence */
2929             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dao_sequence, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2930             rpl_offset += 1;
2931
2932             /* DODAGID */
2933             if(flags & RPL_DAO_FLAG_D)
2934             {
2935                 proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_dao_dodagid, tvb, rpl_offset, 16, ENC_NA);
2936                 rpl_offset += 16;
2937             }
2938             /* Options */
2939             rpl_offset = dissect_icmpv6_rpl_opt(tvb, rpl_offset, pinfo, icmp6_tree, icmp6_code);
2940             break;
2941         }
2942         case ICMP6_RPL_DAOACK: /* Destination Advertisement Object Acknowledgment (3) */
2943         case ICMP6_RPL_SDAOACK: /* Secure Destination Advertisement Object Acknowledgment (131) */
2944         {
2945             guint8 flags;
2946
2947             /* DAO Instance */
2948             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_daoack_instance, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2949             rpl_offset += 1;
2950
2951             /* Flags */
2952             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_daoack_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2953             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_rpl_daoack);
2954             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_daoack_flag_d, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2955             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_daoack_flag_rsv, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2956             flags = tvb_get_guint8(tvb, rpl_offset);
2957             rpl_offset += 1;
2958
2959             /* DAO Sequence */
2960             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_daoack_sequence, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2961             rpl_offset += 1;
2962
2963             /* Status */
2964             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_daoack_status, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2965             rpl_offset += 1;
2966
2967             /* DODAGID */
2968             if(flags & RPL_DAOACK_FLAG_D)
2969             {
2970                 proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_daoack_dodagid, tvb, rpl_offset, 16, ENC_NA);
2971                 rpl_offset += 16;
2972             }
2973
2974             /* Options */
2975             rpl_offset = dissect_icmpv6_rpl_opt(tvb, rpl_offset, pinfo, icmp6_tree, icmp6_code);
2976             break;
2977         }
2978        case ICMP6_RPL_CC:
2979        {
2980             /* CC Instance */
2981             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_cc_instance, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2982             rpl_offset += 1;
2983
2984             /* Flags */
2985             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_cc_flag, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2986             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_rpl_cc);
2987             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_cc_flag_r, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2988             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_cc_flag_rsv, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
2989             rpl_offset += 1;
2990
2991             /* CC Nonce */
2992             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_cc_nonce, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
2993             rpl_offset += 2;
2994
2995             /* DODAGID */
2996             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_cc_dodagid, tvb, rpl_offset, 16, ENC_NA);
2997             rpl_offset += 16;
2998
2999             /* Destination Counter */
3000             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_cc_destination_counter, tvb, rpl_offset, 4, ENC_BIG_ENDIAN);
3001             rpl_offset += 4;
3002
3003             /* Options */
3004             rpl_offset = dissect_icmpv6_rpl_opt(tvb, rpl_offset, pinfo, icmp6_tree, icmp6_code);
3005             break;
3006        }
3007         case ICMP6_RPL_P2P_DRO: /* P2P Discovery Reply Object (0x4) */
3008         case ICMP6_RPL_P2P_SDRO: /* Secure P2P Discovery Reply Object (0x84) */
3009         {
3010             /* RPLInstanceID */
3011             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_dro_instance, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
3012             rpl_offset += 1;
3013
3014             /* Version Number */
3015             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_dro_version, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
3016             if (tvb_get_guint8(tvb, rpl_offset)) {
3017                 expert_add_info(pinfo, ti, &ei_icmpv6_rpl_p2p_dro_zero);
3018             }
3019             rpl_offset += 1;
3020
3021             /* Flags */
3022             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_dro_flag, tvb, rpl_offset, 2, ENC_NA);
3023             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_rpl_p2p_dro_flag);
3024
3025             /* Stop */
3026             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_p2p_dro_flag_stop, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
3027             /* Ack */
3028             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_p2p_dro_flag_ack, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
3029             /* Seq */
3030             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_p2p_dro_flag_seq, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
3031             /* Reserved */
3032             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_p2p_dro_flag_reserved, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
3033             rpl_offset += 2;
3034
3035             /* DODAGID */
3036             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_dro_dagid, tvb, rpl_offset, 16, ENC_NA);
3037             rpl_offset += 16;
3038
3039             /* RPL Options */
3040             rpl_offset = dissect_icmpv6_rpl_opt(tvb, rpl_offset, pinfo, icmp6_tree, icmp6_code);
3041             break;
3042         }
3043         case ICMP6_RPL_P2P_DROACK:  /* P2P Discovery Reply Object Acknowledgement (0x5) */
3044         case ICMP6_RPL_P2P_SDROACK: /* Secure P2P Discovery Reply Object Acknowledgement (0x85) */
3045         {
3046             /* RPLInstanceID */
3047             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_dro_instance, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
3048             rpl_offset += 1;
3049
3050             /* Version Number */
3051             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_dro_version, tvb, rpl_offset, 1, ENC_BIG_ENDIAN);
3052             if (tvb_get_guint8(tvb, rpl_offset)) {
3053                 expert_add_info(pinfo, ti, &ei_icmpv6_rpl_p2p_dro_zero);
3054             }
3055             rpl_offset += 1;
3056
3057             /* Flags */
3058             ti = proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_droack_flag, tvb, rpl_offset, 2, ENC_NA);
3059             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_rpl_p2p_droack_flag);
3060
3061             /* Seq */
3062             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_p2p_droack_flag_seq, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
3063             /* Reserved */
3064             proto_tree_add_item(flag_tree, hf_icmpv6_rpl_p2p_dro_flag_reserved, tvb, rpl_offset, 2, ENC_BIG_ENDIAN);
3065             rpl_offset += 2;
3066
3067             /* DODAGID */
3068             proto_tree_add_item(icmp6_tree, hf_icmpv6_rpl_p2p_dro_dagid, tvb, rpl_offset, 16, ENC_NA);
3069             rpl_offset += 16;
3070             break;
3071         }
3072
3073     }
3074     return rpl_offset;
3075 }
3076 /* RFC 4620 - IPv6 Node Information Queries */
3077
3078 static int
3079 dissect_nodeinfo(tvbuff_t *tvb, int ni_offset, packet_info *pinfo _U_, proto_tree *tree, guint8 icmp6_type, guint8 icmp6_code)
3080 {
3081     proto_tree *flag_tree;
3082     proto_item *ti;
3083     guint16     qtype;
3084
3085     /* Qtype */
3086     proto_tree_add_item(tree, hf_icmpv6_ni_qtype, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3087     qtype = tvb_get_ntohs(tvb, ni_offset);
3088     ni_offset += 2;
3089
3090     /* Flags */
3091     ti = proto_tree_add_item(tree, hf_icmpv6_ni_flag, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3092     flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_ni);
3093     proto_tree_add_item(flag_tree, hf_icmpv6_ni_flag_g, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3094     proto_tree_add_item(flag_tree, hf_icmpv6_ni_flag_s, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3095     proto_tree_add_item(flag_tree, hf_icmpv6_ni_flag_l, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3096     proto_tree_add_item(flag_tree, hf_icmpv6_ni_flag_c, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3097     proto_tree_add_item(flag_tree, hf_icmpv6_ni_flag_a, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3098     proto_tree_add_item(flag_tree, hf_icmpv6_ni_flag_t, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3099     proto_tree_add_item(flag_tree, hf_icmpv6_ni_flag_rsv, tvb, ni_offset, 2, ENC_BIG_ENDIAN);
3100     ni_offset += 2;
3101
3102     /* Nonce */
3103     proto_tree_add_item(tree, hf_icmpv6_ni_nonce, tvb, ni_offset, 8, ENC_BIG_ENDIAN);
3104     ni_offset += 8;
3105
3106     /* Data ? */
3107     if(tvb_reported_length_remaining(tvb, ni_offset) == 0){
3108         return ni_offset;
3109     }
3110
3111     if(icmp6_type == ICMP6_NI_QUERY){
3112         switch(icmp6_code){
3113             case ICMP6_NI_SUBJ_IPV6: {
3114                 proto_tree_add_item(tree, hf_icmpv6_ni_query_subject_ipv6, tvb, ni_offset, 16, ENC_NA);
3115                 ni_offset += 16;
3116                 break;
3117             }
3118             case ICMP6_NI_SUBJ_FQDN: {
3119                 int fqdn_len;
3120                 const guchar *fqdn_name;
3121                 fqdn_len = get_dns_name(tvb, ni_offset, 0, ni_offset, &fqdn_name);
3122                 proto_tree_add_string(tree, hf_icmpv6_ni_query_subject_fqdn, tvb, ni_offset, fqdn_len, fqdn_name);
3123                 ni_offset += fqdn_len;
3124                 break;
3125             }
3126             case ICMP6_NI_SUBJ_IPV4: {
3127                 proto_tree_add_item(tree, hf_icmpv6_ni_query_subject_ipv4, tvb, ni_offset, 4, ENC_BIG_ENDIAN);
3128                 ni_offset += 4;
3129                 break;
3130             }
3131         }
3132     } else { /* It is ICMP6_NI_REPLY */
3133         switch(qtype){
3134             case NI_QTYPE_NOOP:
3135                 break;
3136             case NI_QTYPE_NODENAME: {
3137                 int node_len;
3138                 const guchar *node_name;
3139                 /* TTL */
3140                 proto_tree_add_item(tree, hf_icmpv6_ni_reply_node_ttl, tvb, ni_offset, 4, ENC_BIG_ENDIAN);
3141                 ni_offset += 4;
3142                 /* Data ? */
3143                 if(tvb_reported_length_remaining(tvb, ni_offset) == 0){
3144                     return ni_offset;
3145                 }
3146                 while(ni_offset < (int)tvb_reported_length(tvb) ) {
3147
3148                     if(tvb_get_guint8(tvb, ni_offset) == 0){ /* if Zero there is padding, skip the loop */
3149                         break;
3150                     }
3151                     /* Node Name */
3152                     node_len = get_dns_name(tvb, ni_offset, 0, ni_offset, &node_name);
3153                     proto_tree_add_string(tree, hf_icmpv6_ni_reply_node_name, tvb, ni_offset, node_len, node_name);
3154                     ni_offset += node_len;
3155                 }
3156                 break;
3157             }
3158             case NI_QTYPE_NODEADDR: {
3159                 while(ni_offset < (int)tvb_reported_length(tvb) ) {
3160                     /* TTL */
3161                     proto_tree_add_item(tree, hf_icmpv6_ni_reply_node_ttl, tvb, ni_offset, 4, ENC_BIG_ENDIAN);
3162                     ni_offset += 4;
3163                     /* Node Addresses */
3164                     proto_tree_add_item(tree, hf_icmpv6_ni_reply_node_address, tvb, ni_offset, 16, ENC_NA);
3165                     ni_offset += 16;
3166                 }
3167                 break;
3168             }
3169             case NI_QTYPE_IPV4ADDR: {
3170                 while(ni_offset < (int)tvb_reported_length(tvb) ) {
3171                     /* TTL */
3172                     proto_tree_add_item(tree, hf_icmpv6_ni_reply_node_ttl, tvb, ni_offset, 4, ENC_BIG_ENDIAN);
3173                     ni_offset += 4;
3174                     /* IPv4 Address */
3175                     proto_tree_add_item(tree, hf_icmpv6_ni_reply_ipv4_address, tvb, ni_offset, 4, ENC_BIG_ENDIAN);
3176                     ni_offset += 4;
3177                 }
3178                 break;
3179             }
3180         }
3181     }
3182     return ni_offset;
3183 }
3184 /* RFC 2894 - Router Renumbering for IPv6 */
3185
3186 static int
3187 dissect_rrenum(tvbuff_t *tvb, int rr_offset, packet_info *pinfo _U_, proto_tree *tree, guint8 icmp6_type _U_, guint8 icmp6_code)
3188 {
3189     proto_tree *flag_tree, *mp_tree, *up_tree, *rm_tree;
3190     proto_item *ti,        *ti_mp,   *ti_up,   *ti_rm;
3191
3192     /* Sequence Number */
3193     proto_tree_add_item(tree, hf_icmpv6_rr_sequencenumber, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3194     rr_offset += 4;
3195
3196     /* Segment Number */
3197     proto_tree_add_item(tree, hf_icmpv6_rr_segmentnumber, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3198     rr_offset += 1;
3199
3200     /* Flags */
3201     ti = proto_tree_add_item(tree, hf_icmpv6_rr_flag, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3202     flag_tree = proto_item_add_subtree(ti, ett_icmpv6_flag_rr);
3203     proto_tree_add_item(flag_tree, hf_icmpv6_rr_flag_t, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3204     proto_tree_add_item(flag_tree, hf_icmpv6_rr_flag_r, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3205     proto_tree_add_item(flag_tree, hf_icmpv6_rr_flag_a, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3206     proto_tree_add_item(flag_tree, hf_icmpv6_rr_flag_s, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3207     proto_tree_add_item(flag_tree, hf_icmpv6_rr_flag_p, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3208     proto_tree_add_item(flag_tree, hf_icmpv6_rr_flag_rsv, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3209     rr_offset += 1;
3210
3211     /* Max Delay */
3212     proto_tree_add_item(tree, hf_icmpv6_rr_maxdelay, tvb, rr_offset, 2, ENC_BIG_ENDIAN);
3213     rr_offset += 2;
3214
3215     /* Reserved */
3216     proto_tree_add_item(tree, hf_icmpv6_reserved, tvb, rr_offset, 4, ENC_NA);
3217     rr_offset += 4;
3218
3219     /* Data ? */
3220     if(tvb_reported_length_remaining(tvb, rr_offset) == 0){
3221         return rr_offset;
3222     }
3223
3224     if(icmp6_code == ICMP6_ROUTER_RENUMBERING_COMMAND){
3225         /* Match-Prefix Part */
3226         guint8 opcode, matchlen, minlen, maxlen;
3227
3228         ti_mp = proto_tree_add_item(tree, hf_icmpv6_rr_pco_mp_part, tvb, rr_offset, 24, ENC_NA);
3229         mp_tree = proto_item_add_subtree(ti_mp, ett_icmpv6_rr_mp);
3230
3231         /* OpCode */
3232         proto_tree_add_item(mp_tree, hf_icmpv6_rr_pco_mp_opcode, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3233         opcode = tvb_get_guint8(tvb, rr_offset);
3234         rr_offset += 1;
3235
3236         /* OpLength */
3237         proto_tree_add_item(mp_tree, hf_icmpv6_rr_pco_mp_oplength, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3238         rr_offset += 1;
3239
3240         /* Ordinal */
3241         proto_tree_add_item(mp_tree, hf_icmpv6_rr_pco_mp_ordinal, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3242         rr_offset += 1;
3243
3244         /* MatchLen  */
3245         proto_tree_add_item(mp_tree, hf_icmpv6_rr_pco_mp_matchlen, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3246         matchlen = tvb_get_guint8(tvb, rr_offset);
3247         if (matchlen > 128) {
3248             expert_add_info(pinfo, ti, &ei_icmpv6_rr_pco_mp_matchlen);
3249         }
3250         rr_offset += 1;
3251
3252         /* MinLen  */
3253         proto_tree_add_item(mp_tree, hf_icmpv6_rr_pco_mp_minlen, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3254         minlen = tvb_get_guint8(tvb, rr_offset);
3255         rr_offset += 1;
3256
3257         /* MaxLen  */
3258         proto_tree_add_item(mp_tree, hf_icmpv6_rr_pco_mp_maxlen, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3259         maxlen = tvb_get_guint8(tvb, rr_offset);
3260         rr_offset += 1;
3261
3262         /* Reserved  */
3263         proto_tree_add_item(mp_tree, hf_icmpv6_reserved, tvb, rr_offset, 2, ENC_NA);
3264         rr_offset += 2;
3265
3266         /* Match Prefix  */
3267         proto_tree_add_item(mp_tree, hf_icmpv6_rr_pco_mp_matchprefix, tvb, rr_offset, 16, ENC_NA);
3268
3269         /* Add Info (Prefix, Length...) to Match Prefix Part label */
3270         proto_item_append_text(ti_mp, ": %s %s/%u (%u-%u)", val_to_str(opcode, rr_pco_mp_opcode_val, "Unknown %d"), tvb_ip6_to_str(tvb, rr_offset), matchlen, minlen, maxlen);
3271         rr_offset += 16;
3272
3273         while ((int)tvb_reported_length(tvb) > rr_offset) {
3274             /* Use-Prefix Part */
3275             guint8 uselen, keeplen;
3276
3277             ti_up = proto_tree_add_item(tree, hf_icmpv6_rr_pco_up_part, tvb, rr_offset, 32, ENC_NA);
3278             up_tree = proto_item_add_subtree(ti_up, ett_icmpv6_rr_up);
3279
3280             /* UseLen */
3281             proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_uselen, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3282             uselen = tvb_get_guint8(tvb, rr_offset);
3283             rr_offset += 1;
3284
3285             /* KeepLen */
3286             proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_keeplen, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3287             keeplen = tvb_get_guint8(tvb, rr_offset);
3288             rr_offset += 1;
3289
3290             /* FlagMask */
3291             ti = proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_flagmask, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3292             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_rr_up_flag_mask);
3293             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_flagmask_l, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3294             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_flagmask_a, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3295             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_flagmask_reserved, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3296             rr_offset += 1;
3297
3298             /* RaFlags */
3299             ti = proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_raflags, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3300             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_rr_up_flag_ra);
3301             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_raflags_l, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3302             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_raflags_a, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3303             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_raflags_reserved, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3304             rr_offset += 1;
3305
3306             /* Valid Lifetime */
3307             ti = proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_validlifetime, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3308             switch(tvb_get_ntohl(tvb, rr_offset)){
3309                 case 0xffffffff:
3310                     proto_item_append_text(ti, " (Infinity)");
3311                 break;
3312                 default:
3313                 break;
3314             }
3315             rr_offset += 4;
3316
3317             /* Preferred Lifetime */
3318             ti = proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_preferredlifetime, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3319             switch(tvb_get_ntohl(tvb, rr_offset)){
3320                 case 0xffffffff:
3321                     proto_item_append_text(ti, " (Infinity)");
3322                 break;
3323                 default:
3324                 break;
3325             }
3326             rr_offset += 4;
3327
3328             /* Flags */
3329             ti = proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_flag, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3330             flag_tree = proto_item_add_subtree(ti, ett_icmpv6_rr_up_flag);
3331             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_flag_v, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3332             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_flag_p, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3333             proto_tree_add_item(flag_tree, hf_icmpv6_rr_pco_up_flag_reserved, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3334             rr_offset += 4;
3335
3336             /* UsePrefix */
3337             proto_tree_add_item(up_tree, hf_icmpv6_rr_pco_up_useprefix, tvb, rr_offset, 16, ENC_NA);
3338             rr_offset += 16;
3339
3340             /* Add Info (Prefix, Length...) to Use Prefix Part label */
3341             proto_item_append_text(ti_up, ": %s/%u (keep %u)", tvb_ip6_to_str(tvb, rr_offset), uselen, keeplen);
3342         }
3343
3344     }else if(icmp6_code == ICMP6_ROUTER_RENUMBERING_RESULT){
3345         while ((int)tvb_reported_length(tvb) > rr_offset) {
3346         guint8 matchlen;
3347         guint32 interfaceindex;
3348         /* Result Message */
3349
3350         ti_rm = proto_tree_add_item(tree, hf_icmpv6_rr_rm, tvb, rr_offset, 24, ENC_NA);
3351         rm_tree = proto_item_add_subtree(ti_rm, ett_icmpv6_rr_rm);
3352
3353         /* Flags */
3354         ti = proto_tree_add_item(rm_tree, hf_icmpv6_rr_rm_flag, tvb, rr_offset, 2, ENC_BIG_ENDIAN);
3355         flag_tree = proto_item_add_subtree(ti, ett_icmpv6_rr_rm_flag);
3356         proto_tree_add_item(flag_tree, hf_icmpv6_rr_rm_flag_reserved, tvb, rr_offset, 2, ENC_BIG_ENDIAN);
3357         proto_tree_add_item(flag_tree, hf_icmpv6_rr_rm_flag_b, tvb, rr_offset, 2, ENC_BIG_ENDIAN);
3358         proto_tree_add_item(flag_tree, hf_icmpv6_rr_rm_flag_f, tvb, rr_offset, 2, ENC_BIG_ENDIAN);
3359         rr_offset +=2;
3360
3361         /* Ordinal */
3362         proto_tree_add_item(rm_tree, hf_icmpv6_rr_rm_ordinal, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3363         rr_offset +=1;
3364
3365         /* MatchLen */
3366         ti = proto_tree_add_item(rm_tree, hf_icmpv6_rr_rm_matchedlen, tvb, rr_offset, 1, ENC_BIG_ENDIAN);
3367         matchlen = tvb_get_guint8(tvb, rr_offset);
3368         if (matchlen > 128) {
3369             expert_add_info(pinfo, ti, &ei_icmpv6_rr_pco_mp_matchedlen);
3370         }
3371         rr_offset +=1;
3372
3373         /* InterfaceIndex */
3374         proto_tree_add_item(rm_tree, hf_icmpv6_rr_rm_interfaceindex, tvb, rr_offset, 4, ENC_BIG_ENDIAN);
3375         interfaceindex = tvb_get_ntohl(tvb, rr_offset);
3376         rr_offset +=4;
3377
3378         /* MatchedPrefix */
3379         proto_tree_add_item(rm_tree, hf_icmpv6_rr_rm_matchedprefix, tvb, rr_offset, 16, ENC_NA);
3380
3381         /* Add Info (Prefix, Length...) to Use Resultant Message label */
3382         proto_item_append_text(ti_rm, ": %s/%u (interface %u)", tvb_ip6_to_str(tvb, rr_offset), matchlen, interfaceindex);
3383         rr_offset +=16;
3384         }
3385     }
3386     return rr_offset;
3387 }
3388
3389
3390 static int
3391 dissect_mldrv2( tvbuff_t *tvb, guint32 offset, packet_info *pinfo _U_, proto_tree *tree )
3392 {
3393     proto_tree *mar_tree;
3394     proto_item *ti_mar;
3395     int         mldr_offset = offset;
3396
3397     /* Reserved */
3398     proto_tree_add_item(tree, hf_icmpv6_reserved, tvb, mldr_offset, 2, ENC_NA );
3399     mldr_offset += 2;
3400
3401     /* Nr of Mcast Address Records (M) */
3402     proto_tree_add_item(tree, hf_icmpv6_mldr_nb_mcast_records, tvb, mldr_offset, 2, ENC_BIG_ENDIAN );
3403     mldr_offset += 2;
3404
3405     /* Multicast Address Record */
3406     while(mldr_offset < (int)tvb_reported_length(tvb) ) {
3407         guint8 aux_data_len, record_type;
3408         guint16 i, nb_sources;
3409
3410         ti_mar = proto_tree_add_item(tree, hf_icmpv6_mldr_mar, tvb, mldr_offset, -1, ENC_NA);
3411         mar_tree = proto_item_add_subtree(ti_mar, ett_icmpv6_mar);
3412
3413         /* Record Type */
3414         proto_tree_add_item(mar_tree, hf_icmpv6_mldr_mar_record_type, tvb, mldr_offset, 1, ENC_BIG_ENDIAN);
3415         record_type = tvb_get_guint8(tvb, mldr_offset);
3416         mldr_offset += 1;
3417
3418         /* Aux Data Len */
3419         proto_tree_add_item(mar_tree, hf_icmpv6_mldr_mar_aux_data_len, tvb, mldr_offset, 1, ENC_BIG_ENDIAN);
3420         aux_data_len = tvb_get_guint8(tvb, mldr_offset);
3421         mldr_offset += 1;
3422
3423         /* Number of Sources (N) */
3424         proto_tree_add_item(mar_tree, hf_icmpv6_mldr_mar_nb_sources, tvb, mldr_offset, 2, ENC_BIG_ENDIAN);
3425         nb_sources = tvb_get_ntohs(tvb, mldr_offset);
3426         mldr_offset += 2;
3427
3428         /* Multicast Address */
3429         proto_tree_add_item(mar_tree, hf_icmpv6_mldr_mar_multicast_address, tvb, mldr_offset, 16, ENC_NA);
3430         proto_item_append_text(ti_mar, " %s: %s", val_to_str(record_type, mldr_record_type_val,"Unknown Record Type (%d)"), tvb_ip6_to_str(tvb, mldr_offset));
3431         mldr_offset += 16;
3432
3433         /* Source Address */
3434         for (i=0; i < nb_sources; i++){
3435             proto_tree_add_item(mar_tree, hf_icmpv6_mldr_mar_source_address, tvb, mldr_offset, 16, ENC_NA);
3436             mldr_offset += 16;
3437         }
3438
3439         /* Auxiliary Data ? */
3440         if(aux_data_len)
3441         {
3442             proto_tree_add_item(mar_tree, hf_icmpv6_mldr_mar_auxiliary_data, tvb, mldr_offset, aux_data_len * 4, ENC_NA);
3443             mldr_offset += aux_data_len * 4;
3444         }
3445
3446         /* Multicast Address Record Length */
3447         proto_item_set_len(ti_mar, 4 + 16 + (16 * nb_sources) + (aux_data_len * 4));
3448
3449     }
3450     return mldr_offset;
3451 }
3452
3453
3454 static int
3455 dissect_icmpv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
3456 {
3457     proto_tree         *icmp6_tree = NULL, *flag_tree = NULL;
3458     proto_item         *ti         = NULL, *hidden_item, *checksum_item = NULL, *code_item = NULL, *ti_flag = NULL;
3459     const char         *code_name  = NULL;
3460     guint               length     = 0, reported_length;
3461     vec_t               cksum_vec[4];
3462     guint32             phdr[2];
3463     guint16             cksum, computed_cksum;
3464     int                 offset;
3465     tvbuff_t           *next_tvb;
3466     guint8              icmp6_type, icmp6_code;
3467     icmp_transaction_t *trans      = NULL;
3468     ws_ip *iph = (ws_ip*)data;
3469
3470     col_set_str(pinfo->cinfo, COL_PROTOCOL, "ICMPv6");
3471     col_clear(pinfo->cinfo, COL_INFO);
3472
3473     offset = 0;
3474
3475     if (tree) {
3476         ti = proto_tree_add_item(tree, proto_icmpv6, tvb, offset, -1, ENC_NA);
3477         icmp6_tree = proto_item_add_subtree(ti, ett_icmpv6);
3478
3479         /* Type */
3480         proto_tree_add_item(icmp6_tree, hf_icmpv6_type, tvb, offset, 1, ENC_BIG_ENDIAN);
3481     }
3482     icmp6_type = tvb_get_guint8(tvb, offset);
3483     offset += 1;
3484
3485     col_add_str(pinfo->cinfo, COL_INFO, val_to_str(icmp6_type, icmpv6_type_val, "Unknown (%d)"));
3486
3487     if (tree)
3488         code_item = proto_tree_add_item(icmp6_tree, hf_icmpv6_code, tvb, offset, 1, ENC_BIG_ENDIAN);
3489
3490     icmp6_code = tvb_get_guint8(tvb, offset);
3491     offset += 1;
3492
3493     switch (icmp6_type) {
3494         case ICMP6_DST_UNREACH:
3495             code_name = val_to_str_const(icmp6_code, icmpv6_unreach_code_val, "Unknown");
3496             break;
3497         case ICMP6_TIME_EXCEEDED:
3498             code_name = val_to_str(icmp6_code, icmpv6_timeex_code_val, "Unknown (%d)");
3499             break;
3500         case ICMP6_PARAM_PROB:
3501             code_name = val_to_str(icmp6_code, icmpv6_paramprob_code_val, "Unknown (%d)");
3502             break;
3503         case ICMP6_ROUTER_RENUMBERING:
3504             code_name = val_to_str(icmp6_code, icmpv6_rr_code_val, "Unknown (%d)");
3505             break;
3506         case ICMP6_NI_QUERY:
3507             code_name = val_to_str(icmp6_code, ni_query_code_val, "Unknown (%d)");
3508             break;
3509         case ICMP6_NI_REPLY:
3510             code_name = val_to_str(icmp6_code, ni_reply_code_val, "Unknown (%d)");
3511             break;
3512         case ICMP6_RPL_CONTROL:
3513             code_name = val_to_str(icmp6_code, rpl_code_val, "Unknown (%d)");
3514             break;
3515     }
3516
3517     if (code_name)
3518         col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", code_name);
3519
3520     /* RFC 4380
3521      * 2.7.   Teredo UDP Port
3522      * 5.2.9. Direct IPv6 Connectivity Test  */
3523     if (pinfo->destport == 3544 && icmp6_type == ICMP6_ECHO_REQUEST) {
3524         col_set_str(pinfo->cinfo, COL_PROTOCOL, "Teredo");
3525         col_set_str(pinfo->cinfo, COL_INFO, "Direct IPv6 Connectivity Test");
3526     }
3527
3528     if (tree) {
3529         if (code_name)
3530             proto_item_append_text(code_item, " (%s)", code_name);
3531         checksum_item = proto_tree_add_item(icmp6_tree, hf_icmpv6_checksum, tvb, offset, 2, ENC_BIG_ENDIAN);
3532     }
3533
3534     cksum = tvb_get_ntohs(tvb, offset);
3535
3536     if (1) { /* There's an expert info in here so always execute */
3537         length = tvb_captured_length(tvb);
3538         reported_length = tvb_reported_length(tvb);
3539         if (!pinfo->fragmented && length >= reported_length && !pinfo->flags.in_error_pkt) {
3540             /* The packet isn't part of a fragmented datagram, isn't truncated,
3541              * and we aren't in an ICMP error packet, so we can checksum it.
3542              */
3543
3544             /* Set up the fields of the pseudo-header. */
3545             SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data, pinfo->src.len);
3546             SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data, pinfo->dst.len);
3547             phdr[0] = g_htonl(reported_length);
3548             phdr[1] = g_htonl(IP_PROTO_ICMPV6);
3549             SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)&phdr, 8);
3550             SET_CKSUM_VEC_TVB(cksum_vec[3], tvb, 0, reported_length);
3551             computed_cksum = in_cksum(cksum_vec, 4);
3552
3553             if (computed_cksum == 0) {
3554                 hidden_item = proto_tree_add_boolean(icmp6_tree, hf_icmpv6_checksum_bad, tvb, offset, 2, FALSE);
3555                 PROTO_ITEM_SET_HIDDEN(hidden_item);
3556                 proto_item_append_text(checksum_item, " [correct]");
3557             } else {
3558                 hidden_item = proto_tree_add_boolean(icmp6_tree, hf_icmpv6_checksum_bad, tvb, offset, 2, TRUE);
3559                 PROTO_ITEM_SET_HIDDEN(hidden_item);
3560                 proto_item_append_text(checksum_item, " [incorrect, should be 0x%04x]", in_cksum_shouldbe(cksum, computed_cksum));
3561                 expert_add_info_format(pinfo, checksum_item, &ei_icmpv6_checksum,
3562                                        "ICMPv6 Checksum Incorrect, should be 0x%04x", in_cksum_shouldbe(cksum, computed_cksum));
3563             }
3564         } else {
3565                 proto_item_append_text(checksum_item, " [%s]",
3566                     pinfo->flags.in_error_pkt ? "in ICMP error packet" : "fragmented datagram");
3567         }
3568     }
3569     offset += 2;
3570
3571     if (icmp6_type == ICMP6_ECHO_REQUEST || icmp6_type == ICMP6_ECHO_REPLY) {
3572         guint16 identifier, sequence;
3573
3574         /* Identifier */
3575         if (tree)
3576             proto_tree_add_item(icmp6_tree, hf_icmpv6_echo_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3577         identifier = tvb_get_ntohs(tvb, offset);
3578         offset += 2;
3579
3580         /* Sequence Number */
3581         if (tree)
3582             proto_tree_add_item(icmp6_tree, hf_icmpv6_echo_sequence_number, tvb, offset, 2, ENC_BIG_ENDIAN);
3583         sequence = tvb_get_ntohs(tvb, offset);
3584         offset += 2;
3585
3586         col_append_fstr(pinfo->cinfo, COL_INFO, " id=0x%04x, seq=%u, hop limit=%u",
3587             identifier, sequence, (iph != NULL) ? iph->ip_ttl : 0);
3588
3589         if (pinfo->destport == 3544 && icmp6_type == ICMP6_ECHO_REQUEST) {
3590             /* RFC 4380
3591              * 2.7.   Teredo UDP Port
3592              * 5.2.9. Direct IPv6 Connectivity Test
3593              *
3594              * TODO: Clarify the nonce:  The RFC states, "(It is recommended to
3595              * use a random number [the nonce] at least 64 bits long.)"
3596              *
3597              * Shouldn't the nonce be at least 8 then?  Why not just use (-1),
3598              * as it could really be any length, couldn't it?
3599              */
3600             if (tree)
3601                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nonce, tvb, offset, 4, ENC_NA);
3602             offset += 4;
3603         } else {
3604             if (!pinfo->flags.in_error_pkt) {
3605                 guint32 conv_key[2];
3606
3607                 conv_key[1] = (guint32)((identifier << 16) | sequence);
3608
3609                 if (icmp6_type == ICMP6_ECHO_REQUEST) {
3610                     conv_key[0] = (guint32)cksum;
3611                     if (pinfo->flags.in_gre_pkt)
3612                         conv_key[0] |= 0x00010000; /* set a bit for "in GRE" */
3613                     trans = transaction_start(pinfo, icmp6_tree, conv_key);
3614                 } else { /* ICMP6_ECHO_REPLY */
3615                     guint16 tmp[2];
3616
3617                     tmp[0] = ~cksum;
3618                     tmp[1] = ~0x0100; /* The difference between echo request & reply */
3619                     SET_CKSUM_VEC_PTR(cksum_vec[0], (guint8 *)tmp, sizeof(tmp));
3620                     conv_key[0] = in_cksum(cksum_vec, 1);
3621                     if (conv_key[0] == 0)
3622                         conv_key[0] = 0xffff;
3623                     if (pinfo->flags.in_gre_pkt)
3624                         conv_key[0] |= 0x00010000; /* set a bit for "in GRE" */
3625                     trans = transaction_end(pinfo, icmp6_tree, conv_key);
3626                 }
3627             }
3628             next_tvb = tvb_new_subset_remaining(tvb, offset);
3629             offset += call_dissector(data_handle, next_tvb, pinfo, icmp6_tree);
3630         }
3631     }
3632
3633     if (1) { /* There are expert infos buried in here so always execute */
3634         /* decode... */
3635         /* FIXME: The following messages MUST have a TTL^WHop-Limit of 255:
3636                 133-137, 141-142, 148-149. Detect this and add expert items. */
3637         switch (icmp6_type) {
3638             case ICMP6_DST_UNREACH: /* Destination Unreachable (1) */
3639             case ICMP6_TIME_EXCEEDED: /* Time Exceeded (3) */
3640                 /* Reserved */
3641                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 4, ENC_NA);
3642                 offset += 4;
3643
3644                 offset = dissect_contained_icmpv6(tvb, offset, pinfo, icmp6_tree);
3645                 break;
3646             case ICMP6_PACKET_TOO_BIG: /* Packet Too Big (2) */
3647                 /* MTU */
3648                 proto_tree_add_item(icmp6_tree, hf_icmpv6_mtu, tvb, offset, 4, ENC_BIG_ENDIAN);
3649                 offset += 4;
3650
3651                 offset = dissect_contained_icmpv6(tvb, offset, pinfo, icmp6_tree);
3652                 break;
3653             case ICMP6_PARAM_PROB: /* Parameter Problem (4) */
3654                 /* MTU */
3655                 proto_tree_add_item(icmp6_tree, hf_icmpv6_pointer, tvb, offset, 4, ENC_BIG_ENDIAN);
3656                 offset += 4;
3657
3658                 offset = dissect_contained_icmpv6(tvb, offset, pinfo, icmp6_tree);
3659                 break;
3660             case ICMP6_ECHO_REQUEST:    /* Echo Request (128) */
3661             case ICMP6_ECHO_REPLY:      /* Echo Reply (129) */
3662                 /* Already handled above */
3663                 break;
3664             case ICMP6_MEMBERSHIP_QUERY: /* Multicast Listener Query (130) */
3665             case ICMP6_MEMBERSHIP_REPORT: /* Multicast Listener Report (131) */
3666             case ICMP6_MEMBERSHIP_REDUCTION: /* Multicast Listener Done (132) */
3667             {
3668                 /* It is MLDv2 packet ? (the min length for a MLDv2 packet is 28) */
3669                 if ((icmp6_type == ICMP6_MEMBERSHIP_QUERY) && (length >= MLDV2_PACKET_MINLEN)) {
3670                     guint32 mrc;
3671                     guint16 qqi, i, nb_sources;
3672
3673                     /* Maximum Response Code */
3674                     mrc = tvb_get_ntohs(tvb, offset);
3675                     if (mrc >= 32768){
3676                         mrc = ((mrc & 0x0fff) | 0x1000) << (((mrc & 0x7000) >> 12) + 3);
3677                     }
3678                     proto_tree_add_uint(icmp6_tree, hf_icmpv6_mld_mrc, tvb, offset, 2, mrc);
3679                     offset += 2;
3680
3681                     /* Reserved */
3682                     proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 2, ENC_NA);
3683                     offset += 2;
3684
3685                     /* Multicast Address */
3686                     proto_tree_add_item(icmp6_tree, hf_icmpv6_mld_multicast_address, tvb, offset, 16, ENC_NA);
3687                     offset += 16;
3688
3689                     /* Flag */
3690                     ti_flag = proto_tree_add_item(icmp6_tree, hf_icmpv6_mld_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
3691                     flag_tree = proto_item_add_subtree(ti_flag, ett_icmpv6_flag_mld);
3692                     proto_tree_add_item(flag_tree, hf_icmpv6_mld_flag_s, tvb, offset, 1, ENC_BIG_ENDIAN);
3693                     proto_tree_add_item(flag_tree, hf_icmpv6_mld_flag_qrv, tvb, offset, 1, ENC_BIG_ENDIAN);
3694                     proto_tree_add_item(flag_tree, hf_icmpv6_mld_flag_rsv, tvb, offset, 1, ENC_BIG_ENDIAN);
3695                     offset += 1;
3696
3697                     /* QQI */
3698                     qqi = tvb_get_guint8(tvb, offset);
3699                     if (qqi >= 128){
3700                         qqi = ((qqi & 0x0f) | 0x10) << (((qqi & 0x70) >> 4) + 3);
3701                     }
3702                     proto_tree_add_uint(icmp6_tree, hf_icmpv6_mld_qqi, tvb, offset, 1, qqi);
3703                     offset += 1;
3704
3705                     /* Number of Sources */
3706                     proto_tree_add_item(icmp6_tree, hf_icmpv6_mld_nb_sources, tvb, offset, 2, ENC_BIG_ENDIAN);
3707                     nb_sources = tvb_get_ntohs(tvb, offset);
3708                     offset += 2;
3709
3710                     /* Source Address */
3711                     for (i=0; i < nb_sources; i++){
3712                         proto_tree_add_item(icmp6_tree, hf_icmpv6_mld_source_address, tvb, offset, 16, ENC_NA);
3713                         offset += 16;
3714                     }
3715
3716                 }else{ /* It is a MLDv1 Packet */
3717
3718                     proto_tree_add_item(icmp6_tree, hf_icmpv6_mld_mrd, tvb, offset, 2, ENC_BIG_ENDIAN);
3719                     offset += 2;
3720
3721                     /* Reserved */
3722                     proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 2, ENC_NA);
3723                     offset += 2;
3724
3725                     /* Multicast Address */
3726                     proto_tree_add_item(icmp6_tree, hf_icmpv6_mld_multicast_address, tvb, offset, 16, ENC_NA);
3727                     offset += 16;
3728                 }
3729                 break;
3730             }
3731             case ICMP6_ND_ROUTER_SOLICIT: /* Router Solicitation (133) */
3732             {
3733                 /* Reserved */
3734                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 4, ENC_NA);
3735                 offset += 4;
3736
3737                 /* Show options */
3738                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3739                 break;
3740             }
3741             case ICMP6_ND_ROUTER_ADVERT: /* Router Advertisement (134) */
3742             {
3743
3744                 /* Current hop limit */
3745                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_ra_cur_hop_limit, tvb, offset, 1, ENC_BIG_ENDIAN);
3746                 offset += 1;
3747
3748                 /* Flags */
3749                 ti_flag = proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_ra_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
3750                 flag_tree = proto_item_add_subtree(ti_flag, ett_icmpv6_flag_ra);
3751
3752                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_ra_flag_m, tvb, offset, 1, ENC_BIG_ENDIAN);
3753                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_ra_flag_o, tvb, offset, 1, ENC_BIG_ENDIAN);
3754                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_ra_flag_h, tvb, offset, 1, ENC_BIG_ENDIAN);
3755                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_ra_flag_prf, tvb, offset, 1, ENC_BIG_ENDIAN);
3756                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_ra_flag_p, tvb, offset, 1, ENC_BIG_ENDIAN);
3757                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_ra_flag_rsv, tvb, offset, 1, ENC_BIG_ENDIAN);
3758                 offset += 1;
3759
3760                 /* Router lifetime */
3761                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_ra_router_lifetime, tvb, offset, 2, ENC_BIG_ENDIAN);
3762                 offset += 2;
3763
3764                 /* Reachable time */
3765                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_ra_reachable_time, tvb, offset, 4, ENC_BIG_ENDIAN);
3766                 offset += 4;
3767
3768                 /* Retrans timer */
3769                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_ra_retrans_timer, tvb, offset, 4, ENC_BIG_ENDIAN);
3770                 offset += 4;
3771
3772                 /* Show options */
3773                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3774                 break;
3775             }
3776             case ICMP6_ND_NEIGHBOR_SOLICIT: /* Neighbor Solicitation (135) */
3777             {
3778                 /* Reserved */
3779                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 4, ENC_NA);
3780                 offset += 4;
3781
3782                 /* Target Address */
3783                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_ns_target_address, tvb, offset, 16, ENC_NA);
3784                 col_append_fstr(pinfo->cinfo, COL_INFO, " for %s", tvb_ip6_to_str(tvb, offset));
3785
3786                 offset += 16;
3787
3788                 /* Show options */
3789                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3790                 break;
3791             }
3792             case ICMP6_ND_NEIGHBOR_ADVERT: /* Neighbor Advertisement (136) */
3793             {
3794                 guint32 na_flags;
3795                 wmem_strbuf_t *flags_strbuf = wmem_strbuf_new_label(wmem_packet_scope());
3796
3797                 /* Flags */
3798                 ti_flag = proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_na_flag, tvb, offset, 4, ENC_BIG_ENDIAN);
3799                 flag_tree = proto_item_add_subtree(ti_flag, ett_icmpv6_flag_na);
3800                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_na_flag_r, tvb, offset, 4, ENC_BIG_ENDIAN);
3801                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_na_flag_s, tvb, offset, 4, ENC_BIG_ENDIAN);
3802                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_na_flag_o, tvb, offset, 4, ENC_BIG_ENDIAN);
3803                 proto_tree_add_item(flag_tree, hf_icmpv6_nd_na_flag_rsv, tvb, offset, 4, ENC_BIG_ENDIAN);
3804                 na_flags = tvb_get_ntohl(tvb, offset);
3805                 offset += 4;
3806
3807                 /* Target Address */
3808                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_na_target_address, tvb, offset, 16, ENC_NA);
3809
3810
3811                 if (na_flags & ND_NA_FLAG_R) {
3812                     wmem_strbuf_append(flags_strbuf, "rtr, ");
3813                 }
3814                 if (na_flags & ND_NA_FLAG_S) {
3815                     wmem_strbuf_append(flags_strbuf, "sol, ");
3816                 }
3817                 if (na_flags & ND_NA_FLAG_O) {
3818                     wmem_strbuf_append(flags_strbuf, "ovr, ");
3819                 }
3820                 if (wmem_strbuf_get_len(flags_strbuf) > 2) {
3821                     wmem_strbuf_truncate(flags_strbuf, wmem_strbuf_get_len(flags_strbuf) - 2);
3822                 } else {
3823                     wmem_strbuf_truncate(flags_strbuf, 0);
3824                     wmem_strbuf_append(flags_strbuf, "none");
3825                 }
3826
3827                 col_append_fstr(pinfo->cinfo, COL_INFO, " %s (%s)", tvb_ip6_to_str(tvb, offset), wmem_strbuf_get_str(flags_strbuf));
3828                 offset += 16;
3829
3830                 /* Show options */
3831                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3832                 break;
3833             }
3834             case ICMP6_ND_REDIRECT: /* Redirect Message (137) */
3835             {
3836                 /* Reserved */
3837                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 4, ENC_NA);
3838                 offset += 4;
3839
3840                 /* Target Address */
3841                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_rd_target_address, tvb, offset, 16, ENC_NA);
3842                 offset += 16;
3843
3844                 /* Destination Address */
3845                 proto_tree_add_item(icmp6_tree, hf_icmpv6_nd_rd_destination_address, tvb, offset, 16, ENC_NA);
3846                 offset += 16;
3847
3848                 /* Show options */
3849                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3850                 break;
3851             }
3852             case ICMP6_ROUTER_RENUMBERING: /* Router Renumbering (138) */
3853             {
3854                 offset = dissect_rrenum(tvb, offset, pinfo, icmp6_tree, icmp6_type, icmp6_code);
3855                 break;
3856             }
3857             case ICMP6_NI_QUERY: /* ICMP Node Information Query (139) */
3858             case ICMP6_NI_REPLY: /* ICMP Node Information Response (140) */
3859             {
3860                 offset = dissect_nodeinfo(tvb, offset, pinfo, icmp6_tree, icmp6_type, icmp6_code);
3861                 break;
3862             }
3863             case ICMP6_IND_SOLICIT: /* Inverse Neighbor Discovery Solicitation Message (141) */
3864             case ICMP6_IND_ADVERT: /* Inverse Neighbor Discovery Advertisement Message (142) */
3865             {
3866                 /* Reserved */
3867                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 4, ENC_NA);
3868                 offset += 4;
3869
3870                 /* Show options */
3871                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3872                 break;
3873             }
3874             case ICMP6_MLDV2_REPORT: /* Version 2 Multicast Listener Report (143) */
3875             {
3876                 offset = dissect_mldrv2( tvb, offset, pinfo, icmp6_tree );
3877                 break;
3878             }
3879             case ICMP6_MIP6_DHAAD_REQUEST: /* Home Agent Address Discovery Request Message (144) */
3880             {
3881                 /* Identifier */
3882                 proto_tree_add_item(icmp6_tree, hf_icmpv6_mip6_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3883                 offset += 2;
3884
3885                 /* Reserved */
3886                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 2, ENC_NA);
3887                 offset += 2;
3888
3889                 break;
3890             }
3891             case ICMP6_MIP6_DHAAD_REPLY: /* Home Agent Address Discovery Reply Message (145) */
3892             {
3893                 /* Identifier */
3894                 proto_tree_add_item(icmp6_tree, hf_icmpv6_mip6_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3895                 offset += 2;
3896
3897                 /* Reserved */
3898                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 2, ENC_NA);
3899                 offset += 2;
3900
3901                 /* Show all Home Agent Addresses */
3902                 while((int)length > offset)
3903                 {
3904                     proto_tree_add_item(icmp6_tree, hf_icmpv6_mip6_home_agent_address, tvb, offset, 16, ENC_NA);
3905                     offset += 16;
3906                 }
3907                 break;
3908             }
3909             case ICMP6_MIP6_MPS: /* Mobile Prefix Solicitation (146) */
3910             {
3911                 /* Identifier */
3912                 proto_tree_add_item(icmp6_tree, hf_icmpv6_mip6_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3913                 offset += 2;
3914
3915                 /* Reserved */
3916                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 2, ENC_NA);
3917                 offset += 2;
3918                 break;
3919             }
3920             case ICMP6_MIP6_MPA: /* Mobile Prefix Advertisement (147) */
3921             {
3922                 /* Identifier */
3923                 proto_tree_add_item(icmp6_tree, hf_icmpv6_mip6_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3924                 offset += 2;
3925
3926                 /* Flag */
3927                 ti_flag = proto_tree_add_item(icmp6_tree, hf_icmpv6_mip6_flag, tvb,offset, 6, ENC_NA);
3928                 flag_tree = proto_item_add_subtree(ti_flag, ett_icmpv6_flag_mip6);
3929                 proto_tree_add_item(flag_tree, hf_icmpv6_mip6_flag_m, tvb, offset, 2, ENC_BIG_ENDIAN);
3930                 proto_tree_add_item(flag_tree, hf_icmpv6_mip6_flag_o, tvb, offset, 2, ENC_BIG_ENDIAN);
3931                 proto_tree_add_item(flag_tree, hf_icmpv6_mip6_flag_rsv, tvb, offset, 2, ENC_BIG_ENDIAN);
3932                 offset += 2;
3933
3934                 /* Show options */
3935                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3936                 break;
3937             }
3938             case ICMP6_CERT_PATH_SOL: /* Certification Path Solicitation Message (148) */
3939             {
3940
3941                 /* Identifier */
3942                 proto_tree_add_item(icmp6_tree, hf_icmpv6_send_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3943                 offset += 2;
3944
3945                 /* Component  */
3946                 proto_tree_add_item(icmp6_tree, hf_icmpv6_send_component, tvb, offset, 2, ENC_BIG_ENDIAN);
3947                 offset += 2;
3948
3949                 /* Show options */
3950                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3951                 break;
3952             }
3953             case ICMP6_CERT_PATH_AD: /* Certification Path Advertisement Message (149) */
3954             {
3955
3956                 /* Identifier */
3957                 proto_tree_add_item(icmp6_tree, hf_icmpv6_send_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
3958                 offset += 2;
3959
3960                 /* All Components */
3961                 proto_tree_add_item(icmp6_tree, hf_icmpv6_send_all_components, tvb, offset, 2, ENC_BIG_ENDIAN);
3962                 offset += 2;
3963
3964                 /* Component  */
3965                 proto_tree_add_item(icmp6_tree, hf_icmpv6_send_component, tvb, offset, 2, ENC_BIG_ENDIAN);
3966                 offset += 2;
3967
3968                 /* Reserved */
3969                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 2, ENC_NA);
3970                 offset += 2;
3971
3972                 /* Show options */
3973                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
3974                 break;
3975             }
3976             case ICMP6_EXPERIMENTAL_MOBILITY: /* ICMP messages utilized by experimental mobility protocols (150) */
3977             case ICMP6_FMIPV6_MESSAGES:  /* FMIPv6 Messages (154)*/
3978             {
3979                 guint8 subtype;
3980
3981                 /* Subtype */
3982                 proto_tree_add_item(icmp6_tree, hf_icmpv6_fmip6_subtype, tvb, offset, 1, ENC_BIG_ENDIAN);
3983                 subtype = tvb_get_guint8(tvb, offset);
3984                 col_append_fstr(pinfo->cinfo, COL_INFO, " (%s)", val_to_str(subtype, fmip6_subtype_val, "Unknown (%d)"));
3985                 offset += 1;
3986
3987                 switch(subtype){
3988                     case FMIP6_SUBTYPE_RTSOLPR:
3989                     {
3990                         /* Reserved */
3991                         proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 1, ENC_NA);
3992                     }
3993                     break;
3994                     case FMIP6_SUBTYPE_PRRTADV:
3995                     {
3996                         proto_item_append_text(code_item, " (%s)", val_to_str(icmp6_code, fmip6_prrtadv_code_val, "Unknown %d") );
3997                         /* Reserved */
3998                         proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 1, ENC_NA);
3999                     }
4000                     break;
4001                     case FMIP6_SUBTYPE_HI:
4002                     {
4003                         proto_item_append_text(code_item, " (%s)", val_to_str(icmp6_code, fmip6_hi_code_val, "Unknown %d") );
4004                         /* Flags */
4005                         ti_flag = proto_tree_add_item(icmp6_tree, hf_icmpv6_fmip6_hi_flag, tvb, offset, 1, ENC_BIG_ENDIAN);
4006                         flag_tree = proto_item_add_subtree(ti_flag, ett_icmpv6_flag_fmip6);
4007
4008                         proto_tree_add_item(flag_tree, hf_icmpv6_fmip6_hi_flag_s, tvb, offset, 1, ENC_BIG_ENDIAN);
4009                         proto_tree_add_item(flag_tree, hf_icmpv6_fmip6_hi_flag_u, tvb, offset, 1, ENC_BIG_ENDIAN);
4010                         proto_tree_add_item(flag_tree, hf_icmpv6_fmip6_hi_flag_reserved, tvb, offset, 1, ENC_BIG_ENDIAN);
4011                     }
4012                     break;
4013                     case FMIP6_SUBTYPE_HACK:
4014                     {
4015                         proto_item_append_text(code_item, " (%s)", val_to_str(icmp6_code, fmip6_hack_code_val, "Unknown %d") );
4016                         /* Reserved */
4017                         proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 1, ENC_NA);
4018                     }
4019                     break;
4020                 }
4021                 offset +=1;
4022
4023                 /* Identifier */
4024                 proto_tree_add_item(icmp6_tree, hf_icmpv6_fmip6_identifier, tvb, offset, 2, ENC_BIG_ENDIAN);
4025                 offset += 2;
4026
4027                 /* Show options */
4028                 offset = dissect_icmpv6_nd_opt(tvb, offset, pinfo, icmp6_tree);
4029                 break;
4030             }
4031             case ICMP6_MCAST_ROUTER_ADVERT: /* Multicast Router Advertisement (151) */
4032             {
4033                 /* Query Interval */
4034                 proto_tree_add_item(icmp6_tree, hf_icmpv6_mcast_ra_query_interval, tvb, offset, 2, ENC_BIG_ENDIAN);
4035                 offset += 2;
4036
4037                 /* Robustness Variable */
4038                 proto_tree_add_item(icmp6_tree, hf_icmpv6_mcast_ra_robustness_variable, tvb, offset, 2, ENC_BIG_ENDIAN);
4039                 offset += 2;
4040             }
4041             case ICMP6_MCAST_ROUTER_SOLICIT: /* Multicast Router Solicitation (152) */
4042             case ICMP6_MCAST_ROUTER_TERM: /* Multicast Router Termination (153) */
4043             {
4044                 /* No Action... */
4045                 break;
4046             }
4047             case ICMP6_RPL_CONTROL: /* RPL Control (155) */
4048             {
4049                 /* RPL: RFC 6550 : Routing over Low-Power and Lossy Networks. */
4050                 offset = dissect_rpl_control(tvb, offset, pinfo, icmp6_tree, icmp6_type, icmp6_code);
4051                 break;
4052             }
4053             case ICMP6_ILNPV6: /* Locator Update (156) */
4054             {
4055                 guint8 nb_locs, i;
4056                 /* Number of locs */
4057                 proto_tree_add_item(icmp6_tree, hf_icmpv6_ilnp_nb_locs, tvb, offset, 1, ENC_BIG_ENDIAN);
4058                 nb_locs = tvb_get_guint8(tvb, offset);
4059                 offset += 1;
4060
4061                 /* Reserved */
4062                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 1, ENC_NA);
4063                 offset += 1;
4064
4065                 /* Reserved */
4066                 proto_tree_add_item(icmp6_tree, hf_icmpv6_reserved, tvb, offset, 2, ENC_NA);
4067                 offset += 2;
4068
4069                 /* Locator / Preference / Lifetime */
4070                 for (i=0; i < nb_locs; i++){
4071                     proto_tree_add_item(icmp6_tree, hf_icmpv6_ilnp_locator, tvb, offset, 8, ENC_NA);
4072                     offset += 8;
4073
4074                     proto_tree_add_item(icmp6_tree, hf_icmpv6_ilnp_preference, tvb, offset, 2, ENC_NA);
4075                     offset += 2;
4076
4077                     proto_tree_add_item(icmp6_tree, hf_icmpv6_ilnp_lifetime, tvb, offset, 2, ENC_NA);
4078                     offset += 2;
4079
4080                 }
4081                 break;
4082             }
4083             case ICMP6_6LOWPANND_DAR:
4084             case ICMP6_6LOWPANND_DAC:
4085             {
4086                 /* Status */
4087                 proto_tree_add_item(icmp6_tree, hf_icmpv6_da_status, tvb, offset, 1, ENC_BIG_ENDIAN);
4088                 offset += 1;
4089
4090                 /* Reserved */
4091                 proto_tree_add_item(icmp6_tree, hf_icmpv6_da_rsv, tvb, offset, 1, ENC_BIG_ENDIAN);
4092                 offset += 1;
4093
4094                 /* Lifetime */
4095                 proto_tree_add_item(icmp6_tree, hf_icmpv6_da_lifetime, tvb, offset, 2, ENC_BIG_ENDIAN);
4096                 offset += 2;
4097
4098                 /* EUI-64 */
4099                 proto_tree_add_item(icmp6_tree, hf_icmpv6_da_eui64, tvb, offset, 8, ENC_BIG_ENDIAN);
4100                 offset += 8;
4101
4102                 /* Address */
4103                 proto_tree_add_item(icmp6_tree, hf_icmpv6_da_raddr, tvb, offset, 16, ENC_NA);
4104                 offset += 16;
4105                 break;
4106             }
4107             default:
4108                 expert_add_info_format(pinfo, ti, &ei_icmpv6_undecoded_type,
4109                                        "Dissector for ICMPv6 Type (%d)"
4110                                        " code not implemented, Contact Wireshark"
4111                                        " developers if you want this supported", icmp6_type);
4112                 proto_tree_add_item(icmp6_tree, hf_icmpv6_data, tvb, offset, -1, ENC_NA);
4113                 break;
4114         } /* switch (icmp6_type) */
4115     } /* if (1) */
4116
4117     if (trans)
4118         tap_queue_packet(icmpv6_tap, pinfo, trans);
4119
4120         col_append_fstr(pinfo->cinfo, COL_INFO, ", Type=%d, Code=%d", icmp6_type, icmp6_code);
4121     return offset;
4122 }
4123
4124 void
4125 proto_register_icmpv6(void)
4126 {
4127     static hf_register_info hf[] = {
4128         { &hf_icmpv6_type,
4129           { "Type", "icmpv6.type", FT_UINT8, BASE_DEC, VALS(icmpv6_type_val), 0x0,
4130             "Indicates the type of the message", HFILL }},
4131         { &hf_icmpv6_code,
4132           { "Code", "icmpv6.code", FT_UINT8, BASE_DEC, NULL, 0x0,
4133             "Depends on the message type.  It is used to create an additional level of message granularity", HFILL }},
4134         { &hf_icmpv6_checksum,
4135           { "Checksum", "icmpv6.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
4136             "Used to detect data corruption in the ICMPv6 message and parts of the IPv6 header", HFILL }},
4137         { &hf_icmpv6_checksum_bad,
4138           { "Bad Checksum", "icmpv6.checksum_bad", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
4139             NULL, HFILL }},
4140         { &hf_icmpv6_reserved,
4141           { "Reserved", "icmpv6.reserved", FT_BYTES, BASE_NONE, NULL, 0x0,
4142             "Must be Zero", HFILL }},
4143         { &hf_icmpv6_data,
4144           { "Data", "icmpv6.data", FT_BYTES, BASE_NONE, NULL, 0x0,
4145             NULL, HFILL }},
4146         { &hf_icmpv6_unknown_data,
4147           { "Unknown Data", "icmpv6.unknown_data", FT_BYTES, BASE_NONE, NULL, 0x0,
4148             "Not interpreted Data", HFILL }},
4149         { &hf_icmpv6_mtu,
4150           { "MTU", "icmpv6.mtu", FT_UINT32, BASE_DEC, NULL, 0x0,
4151             "The Maximum Transmission Unit of the next-hop link", HFILL }},
4152         { &hf_icmpv6_pointer,
4153           { "Pointer", "icmpv6.pointer", FT_UINT32, BASE_DEC, NULL, 0x0,
4154             "Identifies the octet offset within the invoking packet where the error was detected", HFILL }},
4155         { &hf_icmpv6_echo_identifier,
4156           { "Identifier", "icmpv6.echo.identifier", FT_UINT16, BASE_HEX, NULL, 0x0,
4157             "An identifier to aid in matching with Request and Reply", HFILL }},
4158         { &hf_icmpv6_echo_sequence_number,
4159           { "Sequence", "icmpv6.echo.sequence_number", FT_UINT16, BASE_DEC, NULL, 0x0,
4160             "A sequence number to aid in matching Echo Replies to this Echo Request", HFILL }},
4161         { &hf_icmpv6_nonce,
4162           { "Nonce", "icmpv6.nonce", FT_BYTES, BASE_NONE, NULL, 0x0,
4163             NULL, HFILL }},
4164         /* RFC 2461/4861 : Neighbor Discovery for IP version 6 (IPv6) */
4165         { &hf_icmpv6_nd_ra_cur_hop_limit,
4166           { "Cur hop limit", "icmpv6.nd.ra.cur_hop_limit", FT_UINT8, BASE_DEC, NULL, 0x0,
4167             "The default value that should be placed in the Hop Count field of the IP header for outgoing IP packets", HFILL }},
4168         { &hf_icmpv6_nd_ra_flag,
4169           { "Flags", "icmpv6.nd.ra.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4170             NULL, HFILL }},
4171         { &hf_icmpv6_nd_ra_flag_m,
4172           { "Managed address configuration", "icmpv6.nd.ra.flag.m", FT_BOOLEAN, 8, TFS(&tfs_set_notset), ND_RA_FLAG_M,
4173             "When set, it indicates that addresses are available via DHCPv6", HFILL }},
4174         { &hf_icmpv6_nd_ra_flag_o,
4175           { "Other configuration", "icmpv6.nd.ra.flag.o", FT_BOOLEAN, 8, TFS(&tfs_set_notset), ND_RA_FLAG_O,
4176             "When set, it indicates that other configuration information is available via DHCPv6", HFILL }},
4177         { &hf_icmpv6_nd_ra_flag_h,
4178           { "Home Agent", "icmpv6.nd.ra.flag.h", FT_BOOLEAN, 8, TFS(&tfs_set_notset), ND_RA_FLAG_H,
4179             "When set, it indicate that the router sending this Router Advertisement is also functioning as a Mobile IPv6 home agent on this link", HFILL }},
4180         { &hf_icmpv6_nd_ra_flag_prf,
4181           { "Prf (Default Router Preference)", "icmpv6.nd.ra.flag.prf", FT_UINT8, BASE_DEC, VALS(nd_flag_router_pref), ND_RA_FLAG_PRF,
4182             "Indicates whether to prefer this router over other default routers", HFILL }},
4183         { &hf_icmpv6_nd_ra_flag_p,
4184           { "Proxy", "icmpv6.nd.ra.flag.p", FT_BOOLEAN, 8, TFS(&tfs_set_notset), ND_RA_FLAG_P,
4185            NULL, HFILL }},
4186         { &hf_icmpv6_nd_ra_flag_rsv,
4187           { "Reserved", "icmpv6.nd.ra.flag.rsv", FT_UINT8, BASE_DEC, NULL, ND_RA_FLAG_RSV,
4188             "Must be Zero", HFILL }},
4189         { &hf_icmpv6_nd_ra_router_lifetime,
4190           { "Router lifetime (s)", "icmpv6.nd.ra.router_lifetime", FT_UINT16, BASE_DEC, NULL, 0x0,
4191             "The lifetime associated with the default router", HFILL }},
4192         { &hf_icmpv6_nd_ra_reachable_time,
4193           { "Reachable time (ms)", "icmpv6.nd.ra.reachable_time", FT_UINT32, BASE_DEC, NULL, 0x0,
4194             "The time that a node assumes a neighbor is reachable after having received a reachability confirmation", HFILL }},
4195         { &hf_icmpv6_nd_ra_retrans_timer,
4196           { "Retrans timer (ms)", "icmpv6.nd.ra.retrans_timer", FT_UINT32, BASE_DEC, NULL, 0x0,
4197             "The time between retransmitted Neighbor Solicitation messages", HFILL }},
4198         { &hf_icmpv6_nd_ns_target_address,
4199           { "Target Address", "icmpv6.nd.ns.target_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4200             "The IP address of the target of the solicitation", HFILL }},
4201         { &hf_icmpv6_nd_na_flag,
4202           { "Flags", "icmpv6.nd.na.flag", FT_UINT32, BASE_HEX, NULL, 0x0,
4203             NULL, HFILL }},
4204         { &hf_icmpv6_nd_na_flag_r,
4205           { "Router", "icmpv6.nd.na.flag.r", FT_BOOLEAN, 32, TFS(&tfs_set_notset), ND_NA_FLAG_R,
4206             "When set, it indicates that the sender is a router", HFILL }},
4207         { &hf_icmpv6_nd_na_flag_s,
4208           { "Solicited", "icmpv6.nd.na.flag.s", FT_BOOLEAN, 32, TFS(&tfs_set_notset), ND_NA_FLAG_S,
4209             "When set, it indicates that the advertisement was sent in response to a Neighbor Solicitation from the Destination address", HFILL }},
4210         { &hf_icmpv6_nd_na_flag_o,
4211           { "Override", "icmpv6.nd.na.flag.o", FT_BOOLEAN, 32, TFS(&tfs_set_notset), ND_NA_FLAG_O,
4212             "When set, it indicates that the advertisement should override an existing cache entry and update the cached link-layer address", HFILL }},
4213         { &hf_icmpv6_nd_na_flag_rsv,
4214           { "Reserved", "icmpv6.nd.na.flag.rsv", FT_UINT32, BASE_DEC, NULL, ND_NA_FLAG_RSV,
4215             "Must be Zero", HFILL }},
4216         { &hf_icmpv6_nd_na_target_address,
4217           { "Target Address", "icmpv6.nd.na.target_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4218             "the Target Address field in the Neighbor Solicitation message that prompted this advertisement", HFILL }},
4219         { &hf_icmpv6_nd_rd_target_address,
4220           { "Target Address", "icmpv6.nd.rd.target_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4221             "An IP address that is a better first hop to use for the ICMP Destination Address", HFILL }},
4222         { &hf_icmpv6_nd_rd_destination_address,
4223           { "Destination Address", "icmpv6.rd.na.destination_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4224             "The IP address of the destination that is redirected to the target", HFILL }},
4225         { &hf_icmpv6_opt,
4226           { "ICMPv6 Option", "icmpv6.opt", FT_NONE, BASE_NONE, NULL, 0x0,
4227             "Option", HFILL }},
4228         { &hf_icmpv6_opt_type,
4229           { "Type", "icmpv6.opt.type", FT_UINT8, BASE_DEC, VALS(option_vals), 0x0,
4230             "Options type", HFILL }},
4231         { &hf_icmpv6_opt_length,
4232           { "Length", "icmpv6.opt.length", FT_UINT8, BASE_DEC, NULL, 0x0,
4233             "The length (in units of 8 bytes) of the option (including the Type and Length fields)", HFILL }},
4234         { &hf_icmpv6_opt_reserved,
4235           { "Reserved", "icmpv6.opt.reserved", FT_NONE, BASE_NONE, NULL, 0x0,
4236             "Reserved (Must be 0)", HFILL }},
4237         { &hf_icmpv6_opt_padding,
4238           { "Padding", "icmpv6.opt.padding", FT_NONE, BASE_NONE, NULL, 0x0,
4239             "Padding (Must be 0)", HFILL }},
4240         { &hf_icmpv6_opt_linkaddr,
4241           { "Link-layer address", "icmpv6.opt.linkaddr", FT_BYTES, BASE_NONE, NULL, 0x0,
4242             NULL, HFILL }},
4243        { &hf_icmpv6_opt_src_linkaddr,
4244           { "Source Link-layer address", "icmpv6.opt.src_linkaddr", FT_BYTES, BASE_NONE, NULL, 0x0,
4245             NULL, HFILL }},
4246        { &hf_icmpv6_opt_target_linkaddr,
4247           { "Target Link-layer address", "icmpv6.opt.target_linkaddr", FT_BYTES, BASE_NONE, NULL, 0x0,
4248             NULL, HFILL }},
4249         { &hf_icmpv6_opt_linkaddr_mac,
4250           { "Link-layer address", "icmpv6.opt.linkaddr", FT_ETHER, BASE_NONE, NULL, 0x0,
4251             NULL, HFILL }},
4252        { &hf_icmpv6_opt_src_linkaddr_mac,
4253           { "Source Link-layer address", "icmpv6.opt.src_linkaddr", FT_ETHER, BASE_NONE, NULL, 0x0,
4254             NULL, HFILL }},
4255        { &hf_icmpv6_opt_target_linkaddr_mac,
4256           { "Target Link-layer address", "icmpv6.opt.target_linkaddr", FT_ETHER, BASE_NONE, NULL, 0x0,
4257             NULL, HFILL }},
4258         { &hf_icmpv6_opt_linkaddr_eui64,
4259           { "Link-layer address", "icmpv6.opt.linkaddr_eui64", FT_EUI64, BASE_NONE, NULL, 0x0,
4260             NULL, HFILL }},
4261        { &hf_icmpv6_opt_src_linkaddr_eui64,
4262           { "Source Link-layer address", "icmpv6.opt.src_linkaddr_eui64", FT_EUI64, BASE_NONE, NULL, 0x0,
4263             NULL, HFILL }},
4264        { &hf_icmpv6_opt_target_linkaddr_eui64,
4265           { "Target Link-layer address", "icmpv6.opt.target_linkaddr_eui64", FT_EUI64, BASE_NONE, NULL, 0x0,
4266             NULL, HFILL }},
4267         { &hf_icmpv6_opt_prefix_len,
4268           { "Prefix Length", "icmpv6.opt.prefix.length", FT_UINT8, BASE_DEC, NULL, 0x0,
4269             "The number of leading bits in the Prefix that are valid", HFILL }},
4270         { &hf_icmpv6_opt_prefix_flag,
4271           { "Flag", "icmpv6.opt.prefix.flag", FT_UINT8, BASE_HEX, NULL, 0x00,
4272             NULL, HFILL }},
4273         { &hf_icmpv6_opt_prefix_flag_l,
4274           { "On-link flag(L)", "icmpv6.opt.prefix.flag.l", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80,
4275             "When set, indicates that this prefix can be used for on-link determination", HFILL }},
4276         { &hf_icmpv6_opt_prefix_flag_a,
4277           { "Autonomous address-configuration flag(A)", "icmpv6.opt.prefix.flag.a", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40,
4278             "When set indicates that this prefix can be used for stateless address configuration", HFILL }},
4279         { &hf_icmpv6_opt_prefix_flag_r,
4280           { "Router address flag(R)", "icmpv6.opt.prefix.flag.r", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x20,
4281             "When set indicates that the Prefix field contains a complete IP address assigned to the sending router", HFILL }},
4282         { &hf_icmpv6_opt_prefix_flag_reserved,
4283           { "Reserved", "icmpv6.opt.prefix.flag.reserved", FT_UINT8, BASE_DEC, NULL, 0x1f,
4284             NULL, HFILL }},
4285         { &hf_icmpv6_opt_prefix_valid_lifetime,
4286           { "Valid Lifetime", "icmpv6.opt.prefix.valid_lifetime", FT_UINT32, BASE_DEC, NULL, 0x00,
4287             "The length of time in seconds that the prefix is valid for the purpose of on-link determination", HFILL }},
4288         { &hf_icmpv6_opt_prefix_preferred_lifetime,
4289           { "Preferred Lifetime", "icmpv6.opt.prefix.preferred_lifetime", FT_UINT32, BASE_DEC, NULL, 0x00,
4290             "The length of time in seconds that addresses generated from the prefix via stateless address autoconfiguration remain preferred", HFILL }},
4291         { &hf_icmpv6_opt_prefix,
4292           { "Prefix", "icmpv6.opt.prefix", FT_IPv6, BASE_NONE, NULL, 0x00,
4293             "An IP address or a prefix of an IP address", HFILL }},
4294         { &hf_icmpv6_opt_cga_pad_len,
4295           { "Pad Length", "icmpv6.opt.cga.pad_length", FT_UINT8, BASE_DEC, NULL, 0x0,
4296             "Pad Length (in bytes)", HFILL }},
4297         { &hf_icmpv6_opt_cga,
4298           { "CGA", "icmpv6.opt.cga", FT_BYTES, BASE_NONE, NULL, 0x0,
4299             NULL, HFILL }},
4300         { &hf_icmpv6_opt_cga_modifier,
4301           { "Modifier", "icmpv6.opt.cga.modifier", FT_BYTES, BASE_NONE, NULL, 0x0,
4302             NULL, HFILL }},
4303         { &hf_icmpv6_opt_cga_subnet_prefix,
4304           { "Subnet Prefix", "icmpv6.opt.cga.subnet_prefix", FT_BYTES, BASE_NONE, NULL, 0x0,
4305             NULL, HFILL }},
4306         { &hf_icmpv6_opt_cga_count,
4307           { "Count", "icmpv6.opt.cga.count", FT_BYTES, BASE_NONE, NULL, 0x0,
4308             NULL, HFILL }},
4309         { &hf_icmpv6_opt_cga_ext_type,
4310           { "Ext Type", "icmpv6.opt.cga.ext_type", FT_UINT16, BASE_DEC, NULL, 0x0,
4311             NULL, HFILL }},
4312         { &hf_icmpv6_opt_cga_ext_length,
4313           { "Ext Length", "icmpv6.opt.cga.ext_length", FT_UINT16, BASE_DEC, NULL, 0x0,
4314             NULL, HFILL }},
4315         { &hf_icmpv6_opt_cga_ext_data,
4316           { "Ext Data", "icmpv6.opt.cga.ext_data", FT_BYTES, BASE_NONE, NULL, 0x0,
4317             NULL, HFILL }},
4318         { &hf_icmpv6_opt_rsa_key_hash,
4319           { "Key Hash", "icmpv6.opt.rsa.key_hash", FT_BYTES, BASE_NONE, NULL, 0x0,
4320             NULL, HFILL }},
4321         { &hf_icmpv6_opt_digital_signature_padding,
4322           { "Digital Signature and Padding", "icmpv6.opt.digital_signature_padding", FT_NONE, BASE_NONE, NULL, 0x0,
4323             "TO DO FIX ME !!", HFILL }},
4324         { &hf_icmpv6_opt_ps_key_hash,
4325           { "Key Hash", "icmpv6.opt.ps.key_hash", FT_BYTES, BASE_NONE, NULL, 0x0,
4326             NULL, HFILL }},
4327         { &hf_icmpv6_opt_timestamp,
4328           { "Timestamp", "icmpv6.opt.timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0,
4329             "The value indicates the number of seconds since January 1, 1970, 00:00 UTC", HFILL }},
4330         { &hf_icmpv6_opt_nonce,
4331           { "Nonce", "icmpv6.opt.nonce", FT_BYTES, BASE_NONE, NULL, 0x0,
4332             "A field containing a random number selected by the sender of the solicitation message", HFILL }},
4333         { &hf_icmpv6_opt_certificate_padding,
4334           { "Certificate and Padding", "icmpv6.opt.certificate_padding", FT_NONE, BASE_NONE, NULL, 0x0,
4335             NULL, HFILL }},
4336         { &hf_icmpv6_opt_ipa_option_code,
4337           { "Option-code", "icmpv6.opt.ipa.option_code", FT_UINT8, BASE_DEC, VALS(nd_opt_ipa_option_code_val), 0x00,
4338             NULL, HFILL }},
4339         { &hf_icmpv6_opt_ipa_prefix_len,
4340           { "Prefix Length", "icmpv6.opt.ipa.prefix_len", FT_UINT8, BASE_DEC, NULL, 0x00,
4341             "That indicates the length of the IPv6 Address Prefix", HFILL }},
4342         { &hf_icmpv6_opt_ipa_ipv6_address,
4343           { "IPv6 Address", "icmpv6.opt.ipa.ipv6_address", FT_IPv6, BASE_NONE, NULL, 0x00,
4344             "The IP address/prefix defined by the Option-Code field", HFILL }},
4345         { &hf_icmpv6_opt_nrpi_option_code,
4346           { "Option-code", "icmpv6.opt.nrpi.option_code", FT_UINT8, BASE_DEC, NULL, 0x00,
4347             NULL, HFILL }},
4348         { &hf_icmpv6_opt_nrpi_prefix_len,
4349           { "Prefix Length", "icmpv6.opt.nrpi.prefix_len", FT_UINT8, BASE_DEC, NULL, 0x00,
4350             "The number of leading bits in the Prefix that are valid", HFILL }},
4351         { &hf_icmpv6_opt_nrpi_prefix,
4352           { "Prefix", "icmpv6.opt.nrpi.prefix", FT_IPv6, BASE_NONE, NULL, 0x00,
4353             "An IP address or a prefix of an IP address", HFILL }},
4354         { &hf_icmpv6_opt_lla_option_code,
4355           { "Option-code", "icmpv6.opt.lla.option_code", FT_UINT8, BASE_DEC, VALS(nd_opt_lla_option_code_val), 0x00,
4356             NULL, HFILL }},
4357         { &hf_icmpv6_opt_lla_bytes,
4358           { "Link-Layer Address", "icmpv6.opt.lla.bytes", FT_BYTES, BASE_NONE, NULL, 0x00,
4359             "(in Bytes Format)", HFILL }},
4360         { &hf_icmpv6_opt_naack_option_code,
4361           { "Option-Code", "icmpv6.opt.naack.option_code", FT_UINT8, BASE_DEC, NULL, 0x00,
4362             NULL, HFILL }},
4363         { &hf_icmpv6_opt_naack_status,
4364           { "Status", "icmpv6.opt.naack.status", FT_UINT8, BASE_DEC, VALS(nd_opt_naack_status_val), 0x00,
4365             "Indicating the disposition of the Unsolicited Neighbor Advertisement message", HFILL }},
4366         { &hf_icmpv6_opt_naack_supplied_ncoa,
4367           { "Supplied NCoA", "icmpv6.opt.naack.supplied_ncoa", FT_IPv6, BASE_NONE, NULL, 0x00,
4368             NULL, HFILL }},
4369         { &hf_icmpv6_opt_map_dist,
4370           { "Distance", "icmpv6.opt.map.distance", FT_UINT8, BASE_DEC, NULL, 0xF0,
4371             "Identifying the distance between MAP and the receiver of the advertisement (in the number of hops)", HFILL }},
4372         { &hf_icmpv6_opt_map_pref,
4373           { "Preference", "icmpv6.opt.map.preference", FT_UINT8, BASE_DEC, NULL, 0x0F,
4374             "Used as an indicator of operator preference (Highest is better)", HFILL }},
4375         { &hf_icmpv6_opt_map_flag,
4376           { "Flag", "icmpv6.opt.map.flag", FT_UINT8, BASE_HEX, NULL, 0x00,
4377             NULL, HFILL }},
4378         { &hf_icmpv6_opt_map_flag_r,
4379           { "RCoA Flag", "icmpv6.opt.map.flag.r", FT_BOOLEAN, 8, NULL, 0x80,
4380             "It indicates that the mobile node is allocated the RCoA by the MAP", HFILL }},
4381         { &hf_icmpv6_opt_map_flag_reserved,
4382           { "Reserved", "icmpv6.opt.map.flag.reserved", FT_UINT8, BASE_DEC, NULL, 0x7F,
4383             "Must be 0", HFILL }},
4384         { &hf_icmpv6_opt_map_valid_lifetime,
4385           { "Valid Lifetime", "icmpv6.opt.map.valid_lifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
4386             "This value indicates the validity of the MAP's address and the RCoA.", HFILL }},
4387         { &hf_icmpv6_opt_map_global_address,
4388           { "Global Address", "icmpv6.opt.map.global_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4389             "One of the MAP's global addresses", HFILL }},
4390         { &hf_icmpv6_opt_route_info_flag,
4391           { "Flag", "icmpv6.opt.route_info.flag", FT_UINT8, BASE_HEX, NULL, 0x00,
4392             NULL, HFILL }},
4393         { &hf_icmpv6_opt_route_info_flag_route_preference,
4394           { "Route Preference", "icmpv6.opt.route_info.flag.route_preference", FT_UINT8, BASE_DEC, VALS(nd_flag_router_pref), ND_RA_FLAG_RTPREF_MASK,
4395             "The Route Preference indicates whether to prefer the router associated with this prefix over others", HFILL }},
4396         { &hf_icmpv6_opt_route_info_flag_reserved,
4397           { "Reserved", "icmpv6.opt.route_info.flag.reserved", FT_UINT8, BASE_DEC, NULL, ND_RA_FLAG_RESERV_MASK,
4398             "Must be 0", HFILL }},
4399         { &hf_icmpv6_opt_route_lifetime,
4400           { "Route Lifetime", "icmpv6.opt.route_lifetime", FT_UINT32, BASE_DEC, NULL, 0x00,
4401             "The length of time in seconds that the prefix is valid for the purpose of route determination", HFILL }},
4402         { &hf_icmpv6_opt_name_type,
4403           { "Name Type", "icmpv6.opt.name_type", FT_UINT8, BASE_DEC, VALS(icmpv6_option_name_type_vals), 0x0,
4404             NULL, HFILL }},
4405         { &hf_icmpv6_opt_name_x501,
4406           { "DER Encoded X.501 Name", "icmpv6.opt.name_x501", FT_BYTES, BASE_NONE, NULL, 0x0,
4407             NULL, HFILL }},
4408         { &hf_icmpv6_opt_name_fqdn,
4409           { "FQDN", "icmpv6.opt.name_type.fqdn", FT_STRING, BASE_NONE, NULL, 0x0,
4410             NULL, HFILL }},
4411         { &hf_icmpv6_opt_cert_type,
4412           { "Cert Type", "icmpv6.opt.name_type", FT_UINT8, BASE_DEC, VALS(icmpv6_option_cert_type_vals), 0x0,
4413             NULL, HFILL }},
4414         /* RFC3971:  SEcure Neighbor Discovery (SEND) */
4415         { &hf_icmpv6_send_identifier,
4416           { "Identifier", "icmpv6.send.identifier", FT_UINT16, BASE_DEC, NULL, 0x0,
4417             "An identifier to aid in matching with Request and Reply", HFILL }},
4418         { &hf_icmpv6_send_all_components,
4419           { "All Components", "icmpv6.send.all_components", FT_UINT16, BASE_DEC, NULL, 0x0,
4420             "Inform the receiver of the number of certificates in the entire path", HFILL }},
4421         { &hf_icmpv6_send_component,
4422           { "Component", "icmpv6.send.component", FT_UINT16, BASE_DEC, NULL, 0x0,
4423             "If the field is set to 65,535 if the sender seeks to retrieve all certificates", HFILL }},
4424
4425         { &hf_icmpv6_x509if_Name,
4426           { "Name", "icmpv6.x509_Name", FT_UINT32, BASE_DEC, VALS(x509if_Name_vals), 0x0,
4427             NULL, HFILL }},
4428         { &hf_icmpv6_x509af_Certificate,
4429           { "Certificate", "icmpv6.x509_Certificate", FT_NONE, BASE_NONE, NULL, 0x0,
4430             NULL, HFILL }},
4431         { &hf_icmpv6_opt_redirected_packet,
4432           { "Redirected Packet", "icmpv6.opt.redirected_packet", FT_NONE, BASE_NONE, NULL, 0x0,
4433             NULL, HFILL }},
4434         { &hf_icmpv6_opt_mtu,
4435           { "MTU", "icmpv6.opt.mtu", FT_UINT32, BASE_DEC, NULL, 0x0,
4436             "The recommended MTU for the link", HFILL }},
4437         { &hf_icmpv6_opt_nbma_shortcut_limit,
4438           { "Shortcut Limit", "icmpv6.opt.nbma.shortcut_limit", FT_UINT8, BASE_DEC, NULL, 0x0,
4439             "Hop limit for shortcut attempt", HFILL }},
4440         { &hf_icmpv6_opt_advertisement_interval,
4441           { "Advertisement Interval", "icmpv6.opt.advertisement_interval", FT_UINT32, BASE_DEC, NULL, 0x0,
4442             "The maximum time (in milliseconds) between successive unsolicited Router Advertisement messages sent by this router on this network interface", HFILL }},
4443         { &hf_icmpv6_opt_home_agent_preference,
4444           { "Home Agent Preference", "icmpv6.opt.home_agent_preference", FT_UINT16, BASE_DEC, NULL, 0x0,
4445             "The preference for the home agent sending this Router Advertisement", HFILL }},
4446         { &hf_icmpv6_opt_home_agent_lifetime,
4447           { "Home Agent Preference", "icmpv6.opt.home_agent_lifetime", FT_UINT16, BASE_DEC, NULL, 0x0,
4448             "The lifetime associated with the home agent in units of seconds.", HFILL }},
4449         { &hf_icmpv6_opt_ipv6_address,
4450           { "IPv6 Address", "icmpv6.opt.ipv6_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4451             "IPv6 addresses of the interface", HFILL }},
4452         { &hf_icmpv6_opt_rdnss_lifetime,
4453           { "Lifetime", "icmpv6.opt.rdnss.lifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
4454             NULL, HFILL }},
4455         { &hf_icmpv6_opt_rdnss,
4456           { "Recursive DNS Servers", "icmpv6.opt.rdnss", FT_IPv6, BASE_NONE, NULL, 0x0,
4457             NULL, HFILL }},
4458         { &hf_icmpv6_opt_efo,
4459           { "Flags Expansion Option", "icmpv6.opt.efo", FT_NONE, BASE_NONE, NULL, 0x0,
4460             NULL, HFILL }},
4461         { &hf_icmpv6_opt_efo_m,
4462           { "Managed address configuration", "icmpv6.opt.efo.m", FT_BOOLEAN, 16, TFS(&tfs_set_notset), FLAGS_EO_M,
4463             "When set, it indicates that addresses are available via DHCPv6", HFILL }},
4464         { &hf_icmpv6_opt_efo_o,
4465           { "Other configuration", "icmpv6.opt.efo.o", FT_BOOLEAN, 16, TFS(&tfs_set_notset), FLAGS_EO_O,
4466             "When set, it indicates that other configuration information is available via DHCPv6", HFILL }},
4467         { &hf_icmpv6_opt_efo_h,
4468           { "Home Agent", "icmpv6.opt.efo.h", FT_BOOLEAN, 16, TFS(&tfs_set_notset), FLAGS_EO_H,
4469             "When set, it indicate that the router sending this Router Advertisement is also functioning as a Mobile IPv6 home agent on this link", HFILL }},
4470         { &hf_icmpv6_opt_efo_prf,
4471           { "Prf (Default Router Preference)", "icmpv6.opt.efo.prf", FT_UINT16, BASE_DEC, VALS(nd_flag_router_pref), FLAGS_EO_PRF,
4472             "Indicates whether to prefer this router over other default routers", HFILL }},
4473         { &hf_icmpv6_opt_efo_p,
4474           { "Proxy", "icmpv6.opt.efo.p", FT_BOOLEAN, 16, TFS(&tfs_set_notset), FLAGS_EO_P,
4475            NULL, HFILL }},
4476         { &hf_icmpv6_opt_efo_rsv,
4477           { "Reserved", "icmpv6.opt.efo.rsv", FT_UINT16, BASE_DEC, NULL, FLAGS_EO_RSV,
4478             "Must be Zero", HFILL }},
4479         { &hf_icmpv6_opt_hkr_pad_length,
4480           { "Pad Length", "icmpv6.opt.hkr.pad_length", FT_UINT8, BASE_DEC, NULL, 0x0,
4481             "The number of padding octets beyond the end of the Handover Key", HFILL }},
4482         { &hf_icmpv6_opt_hkr_at,
4483           { "AT", "icmpv6.opt.hkr.at", FT_UINT8, BASE_DEC, NULL, 0xF0,
4484             "The algorithm type field describing the algorithm used by FMIPv6 to calculate the authenticator", HFILL }},
4485         { &hf_icmpv6_opt_hkr_reserved,
4486           { "Reserved", "icmpv6.opt.hkr.reserved", FT_UINT8, BASE_DEC, NULL, 0x0F,
4487             "Reserved (Must be Zero)", HFILL }},
4488         { &hf_icmpv6_opt_hkr_encryption_public_key,
4489           { "Handover Key Encryption Public Key", "icmpv6.opt.hkr.encryption_public_key", FT_BYTES, BASE_NONE, NULL, 0x0,
4490             NULL, HFILL }},
4491         { &hf_icmpv6_opt_hkr_padding,
4492           { "Padding", "icmpv6.opt.hkr.padding", FT_BYTES, BASE_NONE, NULL, 0x0,
4493             "A variable-length field making the option length a multiple of 8", HFILL }},
4494         { &hf_icmpv6_opt_hkr_lifetime,
4495           { "Padding", "icmpv6.opt.hkr.lifetime", FT_UINT16, BASE_DEC, NULL, 0x0,
4496             "Lifetime of the handover key (in seconds)", HFILL }},
4497         { &hf_icmpv6_opt_hkr_encrypted_handover_key,
4498           { "Encrypted Handover Key", "icmpv6.opt.hkr.encrypted_handover_key", FT_BYTES, BASE_NONE, NULL, 0x0,
4499             "The shared handover key, encrypted with the MN's handover key encryption public key", HFILL }},
4500         { &hf_icmpv6_opt_hai_option_code,
4501           { "Option-Code", "icmpv6.opt.hai.option_code", FT_UINT8, BASE_DEC, VALS(nd_opt_hai_option_code_val), 0x0,
4502             NULL, HFILL }},
4503         { &hf_icmpv6_opt_hai_length,
4504           { "HAI-Length", "icmpv6.opt.hai.length", FT_UINT8, BASE_DEC, NULL, 0x0,
4505             "The size of the HAI-Value field in octets", HFILL }},
4506         { &hf_icmpv6_opt_hai_value,
4507           { "HAI-Value", "icmpv6.opt.hai.value", FT_BYTES, BASE_NONE, NULL, 0x0,
4508             "The value specified by the Option-Code", HFILL }},
4509         { &hf_icmpv6_opt_mn_option_code,
4510           { "Option-Code", "icmpv6.opt.mn.option_code", FT_UINT8, BASE_DEC, VALS(nd_opt_mn_option_code_val), 0x0,
4511             NULL, HFILL }},
4512         { &hf_icmpv6_opt_mn_length,
4513           { "MN-Length", "icmpv6.opt.mn.length", FT_UINT8, BASE_DEC, NULL, 0x0,
4514             "The size of the MN-Value field in octets", HFILL }},
4515         { &hf_icmpv6_opt_mn_value,
4516           { "MN-Value", "icmpv6.opt.mn.value", FT_BYTES, BASE_NONE, NULL, 0x0,
4517             "The value specified by the Option-Code", HFILL }},
4518         { &hf_icmpv6_opt_dnssl_lifetime,
4519           { "Lifetime", "icmpv6.opt.dnssl.lifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
4520             NULL, HFILL }},
4521         { &hf_icmpv6_opt_dnssl,
4522           { "Domain Names", "icmpv6.opt.dnssl", FT_STRING, BASE_NONE, NULL, 0x0,
4523             NULL, HFILL }},
4524         { &hf_icmpv6_opt_aro_status,
4525           { "Status", "icmpv6.opt.aro.status", FT_UINT8, BASE_DEC, VALS(nd_opt_6lowpannd_status_val), 0x00,
4526             "Indicates the status of a registration in the NA response", HFILL }},
4527         { &hf_icmpv6_opt_aro_registration_lifetime,
4528           { "Registration  Lifetime", "icmpv6.opt.aro.registration_lifetime", FT_UINT16, BASE_DEC, NULL, 0x00,
4529             "The amount of time (in a unit of 60 seconds) that the router should retain the Neighbor Cache entry", HFILL }},
4530         { &hf_icmpv6_opt_aro_eui64,
4531           { "EUI-64", "icmpv6.opt.aro.eui64", FT_EUI64, BASE_NONE, NULL, 0x00,
4532             "This field is used to uniquely identify the interface of the registered address", HFILL }},
4533         { &hf_icmpv6_opt_6co_context_length,
4534           { "Context Length", "icmpv6.opt.6co.context_length", FT_UINT8, BASE_DEC, NULL, 0x00,
4535             "The number of leading bits in the Context Prefix field that are valid", HFILL }},
4536         { &hf_icmpv6_opt_6co_flag,
4537           { "Flag", "icmpv6.opt.6co.flag", FT_UINT8, BASE_HEX, NULL, 0x00,
4538             NULL, HFILL }},
4539         { &hf_icmpv6_opt_6co_flag_c,
4540           { "Compression Flag", "icmpv6.opt.6co.flag.c", FT_BOOLEAN, 8, TFS(&tfs_set_notset), ND_OPT_6CO_FLAG_C,
4541             "This flag indicates if the context is valid for use in compression", HFILL }},
4542         { &hf_icmpv6_opt_6co_flag_cid,
4543           { "CID", "icmpv6.opt.6co.flag.cid", FT_UINT8, BASE_DEC, NULL, ND_OPT_6CO_FLAG_CID,
4544             "Context Identifier for this prefix information", HFILL }},
4545         { &hf_icmpv6_opt_6co_flag_reserved,
4546           { "Reserved", "icmpv6.opt.6co.flag.reserved", FT_UINT8, BASE_DEC, NULL, ND_OPT_6CO_FLAG_RESERVED,
4547             "Must be zero", HFILL }},
4548         { &hf_icmpv6_opt_6co_valid_lifetime,
4549           { "Lifetime", "icmpv6.opt.6co.valid_lifetime", FT_UINT16, BASE_DEC, NULL, 0x00,
4550             "The length of time in a unit of 60 seconds that the context is valid for the purpose of header compression or decompression", HFILL }},
4551         { &hf_icmpv6_opt_6co_context_prefix,
4552           { "Context Prefix", "icmpv6.opt.6co.context_prefix", FT_IPv6, BASE_NONE, NULL, 0x00,
4553             "The IPv6 prefix or address corresponding to the Context ID (CID) field", HFILL }},
4554         { &hf_icmpv6_opt_abro_version_low,
4555           { "Version Low", "icmpv6.opt.abro.version_low", FT_UINT16, BASE_DEC, NULL, 0x00,
4556             "The version number low (the least significant 16 bits) corresponding to this set of information contained in the RA message", HFILL }},
4557         { &hf_icmpv6_opt_abro_version_high,
4558           { "Version", "icmpv6.opt.abro.version_high", FT_UINT16, BASE_DEC, NULL, 0x00,
4559             "The version number high (most significant 16 bits) corresponding to this set of information contained in the RA message", HFILL }},
4560         { &hf_icmpv6_opt_abro_valid_lifetime,
4561           { "Valid Lifetime", "icmpv6.opt.abro.valid_lifetime", FT_UINT16, BASE_DEC, NULL, 0x00,
4562             "The length of time in a unit of 60 seconds (relative to the time the packet is received) that this set of border router information is valid.", HFILL }},
4563         { &hf_icmpv6_opt_abro_6lbr_address,
4564           { "6LBR Address", "icmpv6.opt.abro.6lbr_address", FT_IPv6, BASE_NONE, NULL, 0x00,
4565             "IPv6 address of the 6LBR that is the origin of the included version number", HFILL }},
4566         { &hf_icmpv6_opt_6cio_unassigned1,
4567           { "Unassigned", "icmpv6.opt.6cio.unassigned1", FT_UINT16, BASE_HEX, NULL, ND_OPT_6CIO_FLAG_UNASSIGNED,
4568             NULL, HFILL }},
4569         { &hf_icmpv6_opt_6cio_flag_g,
4570           { "G", "icmpv6.opt.6cio.flag_g", FT_UINT16, BASE_HEX, NULL, ND_OPT_6CIO_FLAG_G,
4571             NULL, HFILL }},
4572         { &hf_icmpv6_opt_6cio_unassigned2,
4573           { "Unassigned", "icmpv6.opt.6cio.unassigned2", FT_UINT32, BASE_HEX, NULL, 0x00,
4574             NULL, HFILL }},
4575
4576         /* RFC2710:  Multicast Listener Discovery for IPv6 */
4577         { &hf_icmpv6_mld_mrd,
4578           { "Maximum Response Delay [ms]", "icmpv6.mld.maximum_response_delay", FT_UINT16, BASE_DEC, NULL, 0x0,
4579             "Specifies the maximum allowed delay before sending a responding Report, in units of milliseconds", HFILL }},
4580         { &hf_icmpv6_mld_multicast_address,
4581           { "Multicast Address", "icmpv6.mld.multicast_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4582             "Specific IPv6 multicast address", HFILL }},
4583         /* RFC 2894: Router Renumbering for IPv6 */
4584         { &hf_icmpv6_rr_sequencenumber,
4585            { "Sequence Number", "icmpv6.rr.sequence_number", FT_UINT32, BASE_DEC, NULL, 0x0,
4586              "The sequence number MUST be non-decreasing between Sequence Number Resets", HFILL }},
4587         { &hf_icmpv6_rr_segmentnumber,
4588            { "Segment Number", "icmpv6.rr.segment_number", FT_UINT8, BASE_DEC, NULL, 0x0,
4589              "Enumerates different valid RR messages having the same Sequence Number", HFILL }},
4590         { &hf_icmpv6_rr_flag,
4591            { "Flags", "icmpv6.rr.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4592              "Five are defined and three bits are reserved", HFILL }},
4593         { &hf_icmpv6_rr_flag_t,
4594            { "Test Command", "icmpv6.rr.flag.t", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RR_FLAG_T,
4595              "Indicates a Test message: processing is to be simulated and no configuration changes are to be made", HFILL }},
4596         { &hf_icmpv6_rr_flag_r,
4597            { "Result requested", "icmpv6.rr.flag.r", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RR_FLAG_R,
4598              "Indicates that the router send a Result message upon completion of processing the Command message", HFILL }},
4599         { &hf_icmpv6_rr_flag_a,
4600            { "All Interfaces", "icmpv6.rr.flag.a", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RR_FLAG_A,
4601              "Indicates that the Command be applied to all interfaces regardless of administrative shutdown status", HFILL }},
4602         { &hf_icmpv6_rr_flag_s,
4603            { "Site-specific", "icmpv6.rr.flag.s", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RR_FLAG_S,
4604              "Indicates that the Command be applied only to interfaces which belong to the same site as the interface to which the Command is addressed", HFILL }},
4605         { &hf_icmpv6_rr_flag_p,
4606            { "Processed previously", "icmpv6.rr.flag.p", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RR_FLAG_P,
4607              "Indicates that the Command message was previously processed (and is not a Test) and the responding router is not processing it again", HFILL }},
4608         { &hf_icmpv6_rr_flag_rsv,
4609            { "Reserved", "icmpv6.rr.flag.rsv", FT_UINT8, BASE_DEC, NULL, RR_FLAG_RSV,
4610              "Must be Zero", HFILL }},
4611         { &hf_icmpv6_rr_maxdelay,
4612            { "Max Delay", "icmpv6.rr.maxdelay", FT_UINT16, BASE_DEC, NULL, 0x0,
4613              "Specifying the maximum time (in milliseconds) by which a router MUST delay sending any reply to this Command", HFILL }},
4614
4615         { &hf_icmpv6_rr_pco_mp_part,
4616            { "Match-Prefix Part", "icmpv6.rr.pco.mp", FT_NONE, BASE_NONE, NULL, 0x0,
4617              NULL, HFILL }},
4618         { &hf_icmpv6_rr_pco_mp_opcode,
4619            { "OpCode", "icmpv6.rr.pco.mp.opcode", FT_UINT8, BASE_DEC, VALS(rr_pco_mp_opcode_val), 0x0,
4620              "Specifying the operation to be performed when the associated MatchPrefix matches an interface's prefix or address", HFILL }},
4621         { &hf_icmpv6_rr_pco_mp_oplength,
4622            { "OpLength", "icmpv6.rr.pco.mp.oplength", FT_UINT8, BASE_DEC, NULL, 0x0,
4623              "The total length of this Prefix Control Operation (in units of 8 octets)", HFILL }},
4624         { &hf_icmpv6_rr_pco_mp_ordinal,
4625            { "Ordinal", "icmpv6.rr.pco.mp.ordinal", FT_UINT8, BASE_HEX, NULL, 0x0,
4626              "The value is otherwise unconstrained", HFILL }},
4627         { &hf_icmpv6_rr_pco_mp_matchlen,
4628            { "MatchLen", "icmpv6.rr.pco.mp.matchlen", FT_UINT8, BASE_DEC, NULL, 0x0,
4629              "Between 0 and 128 inclusive specifying the number of initial bits of MatchPrefix which are significant in matching", HFILL }},
4630         { &hf_icmpv6_rr_pco_mp_minlen,
4631            { "MinLen", "icmpv6.rr.pco.mp.minlen", FT_UINT8, BASE_DEC, NULL, 0x0,
4632              "Specifying the minimum length which any configured prefix must have in order to be eligible for testing against the MatchPrefix", HFILL }},
4633         { &hf_icmpv6_rr_pco_mp_maxlen,
4634            { "MaxLen", "icmpv6.rr.pco.mp.maxlen", FT_UINT8, BASE_DEC, NULL, 0x0,
4635              "Specifying the maximum length which any configured prefix must have in order to be eligible for testing against the MatchPrefix", HFILL }},
4636         { &hf_icmpv6_rr_pco_mp_matchprefix,
4637            { "MatchPrefix", "icmpv6.rr.pco.mp.matchprefix", FT_IPv6, BASE_NONE, NULL, 0x0,
4638              "The 128-bit prefix to be compared with each interface's prefix or address", HFILL }},
4639         { &hf_icmpv6_rr_pco_up_part,
4640            { "Use-Prefix Part", "icmpv6.rr.pco.up", FT_NONE, BASE_NONE, NULL, 0x0,
4641              NULL, HFILL }},
4642         { &hf_icmpv6_rr_pco_up_uselen,
4643            { "UseLen", "icmpv6.rr.pco.up.uselen", FT_UINT8, BASE_DEC, NULL, 0x0,
4644              "specifying the number of initial bits of UsePrefix to use in creating a new prefix for an interface", HFILL }},
4645         { &hf_icmpv6_rr_pco_up_keeplen,
4646            { "KeepLen", "icmpv6.rr.pco.up.keeplen", FT_UINT8, BASE_DEC, NULL, 0x0,
4647              "Specifying the number of bits of the prefix or address which matched the associated Match-Prefix which should be retained in the new prefix", HFILL }},
4648         { &hf_icmpv6_rr_pco_up_flagmask,
4649            { "FlagMask", "icmpv6.rr.pco.up.flagmask", FT_UINT8, BASE_HEX, NULL, 0x0,
4650              "A 1 bit in any position means that the corresponding flag bit in a Router Advertisement (RA) Prefix Information Option for the New Prefix should be set from the RAFlags field in this Use-Prefix Part", HFILL }},
4651
4652         { &hf_icmpv6_rr_pco_up_flagmask_l,
4653           { "On-link flag(L)", "icmpv6.rr.pco.up.flagmask.l", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80,
4654             "When set, indicates the On-link (L) flag bit in a Router Advertisement (RA) Prefix Information Option for the New Prefix should be set from the RAFlags field in this Use-Prefix Part", HFILL }},
4655         { &hf_icmpv6_rr_pco_up_flagmask_a,
4656           { "Autonomous address-configuration flag(A)", "icmpv6.rr.pco.up.flagmask.a", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40,
4657             "When set, indicates the Autonomous address-configuration (A) flag bit in a Router Advertisement (RA) Prefix Information Option for the New Prefix should be set from the RAFlags field in this Use-Prefix Part", HFILL }},
4658         { &hf_icmpv6_rr_pco_up_flagmask_reserved,
4659           { "Reserved", "icmpv6.rr.pco.up.flagmask.reserved", FT_UINT8, BASE_DEC, NULL, 0x3f,
4660             NULL, HFILL }},
4661         { &hf_icmpv6_rr_pco_up_raflags,
4662            { "RAFlags", "icmpv6.rr.pco.up.raflags", FT_UINT8, BASE_HEX, NULL, 0x0,
4663              "Under control of the FlagMask field, may be used to initialize the flags in Router Advertisement Prefix Information Options  which advertise the New Prefix", HFILL }},
4664         { &hf_icmpv6_rr_pco_up_raflags_l,
4665           { "On-link flag(L)", "icmpv6.rr.pco.up.flagmask.l", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x80,
4666             "When set, indicates that this prefix can be used for on-link determination", HFILL }},
4667         { &hf_icmpv6_rr_pco_up_raflags_a,
4668           { "Autonomous address-configuration flag(A)", "icmpv6.rr.pco.up.flagmask.a", FT_BOOLEAN, 8, TFS(&tfs_set_notset), 0x40,
4669             "When set indicates that this prefix can be used for stateless address configuration", HFILL }},
4670         { &hf_icmpv6_rr_pco_up_raflags_reserved,
4671           { "Reserved", "icmpv6.rr.pco.up.flagmask.reserved", FT_UINT8, BASE_DEC, NULL, 0x3f,
4672             NULL, HFILL }},
4673         { &hf_icmpv6_rr_pco_up_validlifetime,
4674            { "Valid Lifetime", "icmpv6.rr.pco.up.validlifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
4675              "The number of seconds for which the New Prefix will be valid", HFILL }},
4676         { &hf_icmpv6_rr_pco_up_preferredlifetime,
4677            { "Preferred Lifetime", "icmpv6.rr.pco.up.preferredlifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
4678              "The number of seconds for which the New Prefix will be preferred", HFILL }},
4679         { &hf_icmpv6_rr_pco_up_flag,
4680            { "Flags", "icmpv6.rr.pco.up.flag", FT_UINT32, BASE_HEX, NULL, 0x0,
4681              NULL, HFILL }},
4682         { &hf_icmpv6_rr_pco_up_flag_v,
4683           { "Decrement valid lifetime", "icmpv6.rr.pco.up.flag.v", FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x80000000,
4684             "When set, indicating that the valid lifetime of the New Prefix MUST be effectively decremented in real time", HFILL }},
4685         { &hf_icmpv6_rr_pco_up_flag_p,
4686           { "Decrement preferred lifetime", "icmpv6.rr.pco.up.flag.p", FT_BOOLEAN, 32, TFS(&tfs_set_notset), 0x40000000,
4687             "When set, indicating that the preferred lifetime of the New Prefix MUST be effectively decremented in real time", HFILL }},
4688         { &hf_icmpv6_rr_pco_up_flag_reserved,
4689           { "Reserved", "icmpv6.rr.pco.up.flag.reserved", FT_UINT32, BASE_DEC, NULL, 0x3FFFFFFF,
4690             NULL, HFILL }},
4691         { &hf_icmpv6_rr_pco_up_useprefix,
4692            { "UsePrefix", "icmpv6.rr.pco.up.useprefix", FT_IPv6, BASE_NONE, NULL, 0x0,
4693              "The 128-bit Use-prefix which either becomes or is used in forming (if KeepLen is nonzero) the New Prefix", HFILL }},
4694         { &hf_icmpv6_rr_rm,
4695            { "Result Message", "icmpv6.rr.rm", FT_NONE, BASE_NONE, NULL, 0x0,
4696              NULL, HFILL }},
4697         { &hf_icmpv6_rr_rm_flag,
4698            { "Flags", "icmpv6.rr.rm.flag", FT_UINT16, BASE_HEX, NULL, 0x0,
4699              NULL, HFILL }},
4700         { &hf_icmpv6_rr_rm_flag_b,
4701           { "Bounds", "icmpv6.rr.rm.flag.b", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x0002,
4702             "When set, indicates that one or more fields in the associated PCO were out of bounds", HFILL }},
4703         { &hf_icmpv6_rr_rm_flag_f,
4704           { "Forbidden", "icmpv6.rr.rm.flag.f", FT_BOOLEAN, 16, TFS(&tfs_set_notset), 0x0001,
4705             "When set, indicates that one or more Use-Prefix parts from the associated PCO were not honored by the router because of attempted formation of a forbidden prefix format, such as a multicast or loopback address", HFILL }},
4706         { &hf_icmpv6_rr_rm_flag_reserved,
4707           { "Reserved", "icmpv6.rr.rm.flag.reserved", FT_UINT16, BASE_DEC, NULL, 0xFFFC,
4708             "Must be Zero", HFILL }},
4709         { &hf_icmpv6_rr_rm_ordinal,
4710            { "Ordinal", "icmpv6.rr.rm.ordinal", FT_UINT8, BASE_HEX, NULL, 0x0,
4711              "The value is otherwise unconstrained", HFILL }},
4712         { &hf_icmpv6_rr_rm_matchedlen,
4713            { "MatchedLen", "icmpv6.rr.rm.matchedlen", FT_UINT8, BASE_DEC, NULL, 0x0,
4714              "The length of the Matched Prefix", HFILL }},
4715         { &hf_icmpv6_rr_rm_interfaceindex,
4716            { "InterfaceIndex", "icmpv6.rr.rm.interfaceindex", FT_UINT32, BASE_DEC, NULL, 0x0,
4717              "The router's numeric designation of the interface on which the MatchedPrefix was configured", HFILL }},
4718         { &hf_icmpv6_rr_rm_matchedprefix,
4719            { "MatchedPrefix", "icmpv6.rr.rm.matchedprefix", FT_IPv6, BASE_NONE, NULL, 0x0,
4720              "The 128 Bits MatchedPrefix", HFILL }},
4721
4722         /* RFC3775/6275: Mobility Support in IPv6 */
4723         { &hf_icmpv6_mip6_identifier,
4724           { "Identifier", "icmpv6.mip6.identifier", FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
4725             "An identifier to aid in matching with Request and Reply", HFILL }},
4726         { &hf_icmpv6_mip6_home_agent_address,
4727           { "Home Agent Address", "icmpv6.mip6.home_agent_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4728             "A list of addresses of home agents on the home link for the mobile node", HFILL }},
4729         { &hf_icmpv6_mip6_flag,
4730           { "Flags", "icmpv6.mip6.flag", FT_NONE, BASE_NONE, NULL, 0x0,
4731             NULL, HFILL }},
4732         { &hf_icmpv6_mip6_flag_m,
4733           { "Managed address configuration", "icmpv6.mip6.flag.m", FT_BOOLEAN, 16, TFS(&tfs_set_notset), FLAGS_EO_M,
4734             "When set, it indicates that addresses are available via DHCPv6", HFILL }},
4735         { &hf_icmpv6_mip6_flag_o,
4736           { "Other configuration", "icmpv6.mip6.flag.o", FT_BOOLEAN, 16, TFS(&tfs_set_notset), FLAGS_EO_O,
4737             "When set, it indicates that other configuration information is available via DHCPv6", HFILL }},
4738         { &hf_icmpv6_mip6_flag_rsv,
4739           { "Reserved", "icmpv6.mip6.flag.rsv", FT_UINT16, BASE_DEC, NULL, 0x2FFF,
4740             "Must be Zero", HFILL }},
4741
4742         /* RFC3810: Multicast Listener Discovery Version 2 (MLDv2) for IPv6 */
4743         { &hf_icmpv6_mld_mrc,
4744           { "Maximum Response Code", "icmpv6.mld.maximum_response_code", FT_UINT16, BASE_DEC, NULL, 0x0,
4745             "Specifies the maximum allowed delay before sending a responding Report", HFILL }},
4746        { &hf_icmpv6_mld_flag,
4747           { "Flags", "icmpv6.mld.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4748             NULL, HFILL }},
4749        { &hf_icmpv6_mld_flag_s,
4750           { "Suppress Router-Side Processing", "icmpv6.mld.flag.s", FT_BOOLEAN, 8, NULL, MLD_FLAG_S,
4751             "Indicates to any receiving multicast routers that they have to suppress the normal timer updates they perform upon hearing a Query", HFILL }},
4752        { &hf_icmpv6_mld_flag_qrv,
4753           { "QRV (Querier's Robustness Variable)", "icmpv6.mld.flag.qrv", FT_UINT8, BASE_DEC, NULL, MLD_FLAG_QRV,
4754             "Contains the RV (Robustness Variable) value used by the Querier", HFILL }},
4755        { &hf_icmpv6_mld_flag_rsv,
4756           { "Reserved", "icmpv6.mld.flag.reserved", FT_UINT8, BASE_DEC, NULL, MLD_FLAG_RSV,
4757             "Must Be Zero", HFILL }},
4758        { &hf_icmpv6_mld_qqi,
4759           { "QQIC (Querier's Query Interval Code)", "icmpv6.mld.qqi", FT_UINT8, BASE_DEC, NULL, 0x0,
4760             "Specifies the QI (Query Interval) used by the Querier", HFILL }},
4761        { &hf_icmpv6_mld_nb_sources,
4762           { "Number of Sources", "icmpv6.mld.nb_sources", FT_UINT16, BASE_DEC, NULL, 0x0,
4763             "Specifies how many source addresses are present in the Query", HFILL }},
4764        { &hf_icmpv6_mld_source_address,
4765           { "Source Address", "icmpv6.mld.source_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4766             "The Source Address fields are a vector of unicast addresses", HFILL }},
4767         { &hf_icmpv6_mldr_nb_mcast_records,
4768           { "Number of Multicast Address Records", "icmpv6.mldr.nb_mcast_records", FT_UINT16, BASE_DEC, NULL, 0x0,
4769             "Specifies how many Multicast Address Records are present in this Report", HFILL }},
4770         { &hf_icmpv6_mldr_mar,
4771           { "Multicast Address Record", "icmpv6.mldr.mar", FT_NONE, BASE_NONE, NULL, 0x0,
4772             "Each Multicast Address Record is a block of fields that contain information on the sender listening to a single multicast address on the interface from which the Report is sent", HFILL }},
4773         { &hf_icmpv6_mldr_mar_record_type,
4774           { "Record Type", "icmpv6.mldr.mar.record_type", FT_UINT8, BASE_DEC, VALS(mldr_record_type_val), 0x0,
4775             "It specifies the type of the Multicast Address Record", HFILL }},
4776         { &hf_icmpv6_mldr_mar_aux_data_len,
4777           { "Aux Data Len", "icmpv6.mldr.mar.aux_data_len", FT_UINT8, BASE_DEC, NULL, 0x0,
4778             "The Aux Data Len field contains the length (in units of 32-bit words) of the Auxiliary Data Field in this Multicast Address Record", HFILL }},
4779         { &hf_icmpv6_mldr_mar_nb_sources,
4780           { "Number of Sources", "icmpv6.mldr.mar.nb_sources", FT_UINT16, BASE_DEC, NULL, 0x0,
4781             "The Number of Sources field specifies how many source addresses are present in this Multicast Address Record", HFILL }},
4782         { &hf_icmpv6_mldr_mar_multicast_address,
4783           { "Multicast Address", "icmpv6.mldr.mar.multicast_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4784             "The Multicast Address field contains the multicast address to which this Multicast Address Record pertains", HFILL }},
4785         { &hf_icmpv6_mldr_mar_source_address,
4786           { "Source Address", "icmpv6.mldr.mar.source_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4787             "The Source Address fields are a vector of unicast addresses", HFILL }},
4788         { &hf_icmpv6_mldr_mar_auxiliary_data,
4789           { "Auxiliary Data", "icmpv6.mldr.mar.auxiliary_data", FT_BYTES, BASE_NONE, NULL, 0x0,
4790             "Contains additional information that pertain to this Multicast Address Record", HFILL }},
4791         /* RFC 4068/5268/5568: Fast Handovers for Mobile IPv6 ( Mobile IPv6 Fast Handovers ) */
4792         { &hf_icmpv6_fmip6_subtype,
4793            { "Subtype", "icmpv6.fmip6.subtype", FT_UINT8, BASE_DEC, VALS(fmip6_subtype_val), 0x0,
4794              "Designates the Subtype of information", HFILL }},
4795         { &hf_icmpv6_fmip6_hi_flag,
4796           { "Flag", "icmpv6.fmip6.hi.flag", FT_UINT8, BASE_HEX, NULL, 0x00,
4797             NULL, HFILL }},
4798         { &hf_icmpv6_fmip6_hi_flag_s,
4799           { "Assigned address configuration", "icmpv6.fmip6.hi.flag.s", FT_BOOLEAN, 8, TFS(&tfs_set_notset), FMIP6_HI_FLAG_S,
4800             "When set, this message requests a new CoA to be returned by the destination", HFILL }},
4801         { &hf_icmpv6_fmip6_hi_flag_u,
4802           { "Buffer", "icmpv6.fmip6.hi.flag.a", FT_BOOLEAN, 8, TFS(&tfs_set_notset), FMIP6_HI_FLAG_U,
4803             "When set, the destination SHOULD buffer any packets toward the node indicated in the options of this message", HFILL }},
4804         { &hf_icmpv6_fmip6_hi_flag_reserved,
4805           { "Reserved", "icmpv6.fmip6.hi.flag.reserved", FT_UINT8, BASE_DEC, NULL, FMIP6_HI_FLAG_RSV,
4806             NULL, HFILL }},
4807         { &hf_icmpv6_fmip6_identifier,
4808           { "Identifier", "icmpv6.fmip6.identifier", FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
4809             "An identifier to aid in matching with Request and Reply", HFILL }},
4810
4811         /* RFC 4286: Multicast Router Discovery */
4812         { &hf_icmpv6_mcast_ra_query_interval,
4813           { "Query Interval", "icmpv6.mcast_ra.query_interval", FT_UINT16, BASE_DEC, NULL, 0x0,
4814             "The Query Interval value (in seconds) in use by MLD on the interface.", HFILL }},
4815         { &hf_icmpv6_mcast_ra_robustness_variable,
4816           { "Robustness Variable", "icmpv6.mcast_ra.robustness_variable", FT_UINT16, BASE_DEC, NULL, 0x0,
4817             "The Robustness Variable in use by MLD on the advertising interface", HFILL }},
4818
4819         /* RFC 4620: IPv6 Node Information Queries */
4820         { &hf_icmpv6_ni_qtype,
4821            { "Qtype", "icmpv6.ni.qtype", FT_UINT16, BASE_DEC, VALS(ni_qtype_val), 0x0,
4822              "Designates the type of information", HFILL }},
4823         { &hf_icmpv6_ni_flag,
4824            { "Flags", "icmpv6.ni.flag", FT_UINT16, BASE_HEX, NULL, 0x0,
4825              "Qtype-specific flags that may be defined for certain Query types and their Replies", HFILL }},
4826         { &hf_icmpv6_ni_flag_g,
4827            { "Global-scope addresses", "icmpv6.ni.flag.g", FT_BOOLEAN, 16, TFS(&tfs_set_notset), NI_FLAG_G,
4828              "Global-scope addresses are requested", HFILL }},
4829         { &hf_icmpv6_ni_flag_s,
4830            { "Site-local addresses", "icmpv6.ni.flag.s", FT_BOOLEAN, 16, TFS(&tfs_set_notset), NI_FLAG_S,
4831              "Site-local addresses are requested", HFILL }},
4832         { &hf_icmpv6_ni_flag_l,
4833            { "Link-local addresses", "icmpv6.ni.flag.l", FT_BOOLEAN, 16, TFS(&tfs_set_notset), NI_FLAG_L,
4834              "Link-local addresses are requested", HFILL }},
4835         { &hf_icmpv6_ni_flag_c,
4836            { "Compression", "icmpv6.ni.flag.c", FT_BOOLEAN, 16, TFS(&tfs_set_notset), NI_FLAG_C,
4837              "IPv4-compatible (now deprecated) and IPv4-mapped addresses are requested", HFILL }},
4838         { &hf_icmpv6_ni_flag_a,
4839            { "Unicast Addresses", "icmpv6.ni.flag.a", FT_BOOLEAN, 16, TFS(&tfs_ni_flag_a), NI_FLAG_A,
4840              "Responder's unicast addresses", HFILL }},
4841         { &hf_icmpv6_ni_flag_t,
4842            { "Truncated", "icmpv6.ni.flag.t", FT_BOOLEAN, 16, TFS(&tfs_set_notset), NI_FLAG_T,
4843              "Defined in a Reply only, indicates that the set of addresses is incomplete for space reasons", HFILL }},
4844         { &hf_icmpv6_ni_flag_rsv,
4845            { "Reserved", "icmpv6.ni.flag.rsv", FT_UINT16, BASE_HEX, NULL, NI_FLAG_RSV,
4846              "Must be Zero", HFILL }},
4847         { &hf_icmpv6_ni_nonce,
4848            { "Nonce", "icmpv6.ni.nonce", FT_UINT64, BASE_HEX, NULL, 0x0,
4849              "An opaque 64-bit field", HFILL }},
4850         { &hf_icmpv6_ni_query_subject_ipv6,
4851            { "IPv6 subject address", "icmpv6.ni.query.subject_ipv6", FT_IPv6, BASE_NONE, NULL, 0x0,
4852              NULL, HFILL }},
4853         { &hf_icmpv6_ni_query_subject_fqdn,
4854            { "FQDN subject", "icmpv6.ni.query.subject_fqdn", FT_STRING, BASE_NONE, NULL, 0x0,
4855              NULL, HFILL }},
4856         { &hf_icmpv6_ni_query_subject_ipv4,
4857            { "IPv4 subject address", "icmpv6.ni.query.subject_ipv4", FT_IPv4, BASE_NONE, NULL, 0x0,
4858              NULL, HFILL }},
4859         { &hf_icmpv6_ni_reply_node_ttl,
4860            { "TTL", "icmpv6.ni.reply.node_ttl", FT_UINT32, BASE_DEC, NULL, 0x0,
4861              NULL, HFILL }},
4862         { &hf_icmpv6_ni_reply_node_name,
4863            { "Name Node", "icmpv6.ni.reply.node_name", FT_STRING, BASE_NONE, NULL, 0x0,
4864              NULL, HFILL }},
4865         { &hf_icmpv6_ni_reply_node_address,
4866            { "IPv6 Node address", "icmpv6.ni.reply.node_address", FT_IPv6, BASE_NONE, NULL, 0x0,
4867              NULL, HFILL }},
4868         { &hf_icmpv6_ni_reply_ipv4_address,
4869            { "IPv4 Node address", "icmpv6.ni.reply.ipv4_address", FT_IPv4, BASE_NONE, NULL, 0x0,
4870              NULL, HFILL }},
4871
4872         /* RPL: RFC 6550 : Routing over Low-Power and Lossy Networks. */
4873         { &hf_icmpv6_rpl_dis_flag,
4874            { "Flags", "icmpv6.rpl.dis.flags", FT_UINT8, BASE_DEC, NULL, 0x0,
4875              "8-bit unused field reserved for flags", HFILL }},
4876         { &hf_icmpv6_rpl_dio_instance,
4877            { "RPLInstanceID", "icmpv6.rpl.dio.instance", FT_UINT8, BASE_DEC, NULL, 0x0,
4878              "Set by the DODAG root that indicates which RPL Instance the DODAG is part of", HFILL }},
4879         { &hf_icmpv6_rpl_dio_version,
4880            { "Version", "icmpv6.rpl.dio.version", FT_UINT8, BASE_DEC, NULL, 0x0,
4881              "Set by the DODAG root to the DODAGVersionNumber", HFILL }},
4882         { &hf_icmpv6_rpl_dio_rank,
4883            { "Rank", "icmpv6.rpl.dio.rank", FT_UINT16, BASE_DEC, NULL, 0x0,
4884              "Indicating the DODAG rank of the node sending the DIO message", HFILL }},
4885         { &hf_icmpv6_rpl_dio_flag,
4886            { "Flags", "icmpv6.rpl.dio.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4887              NULL, HFILL }},
4888         { &hf_icmpv6_rpl_dio_flag_g,
4889            { "Grounded (G)", "icmpv6.rpl.dio.flag.g", FT_BOOLEAN, 8, NULL, RPL_DIO_FLAG_G,
4890              "Indicates whether the DODAG advertised can satisfy the application-defined goal", HFILL }},
4891         { &hf_icmpv6_rpl_dio_flag_0,
4892            { "Zero", "icmpv6.rpl.dio.flag.0", FT_BOOLEAN, 8, NULL, RPL_DIO_FLAG_0,
4893              NULL, HFILL }},
4894         { &hf_icmpv6_rpl_dio_flag_mop,
4895            { "Mode of Operation (MOP)", "icmpv6.rpl.dio.flag.mop", FT_UINT8, BASE_HEX, VALS(rpl_dio_map_val), RPL_DIO_FLAG_MOP,
4896              "Identifies the mode of operation of the RPL Instance as administratively provisioned at and distributed by the DODAG Root", HFILL }},
4897         { &hf_icmpv6_rpl_dio_flag_prf,
4898            { "DODAG Preference", "icmpv6.rpl.dio.flag.preference", FT_UINT8, BASE_DEC, NULL, RPL_DIO_FLAG_PRF,
4899              "Defines how preferable the root of this DODAG is compared to other DODAG roots within the instance", HFILL }},
4900         { &hf_icmpv6_rpl_dio_dtsn,
4901            { "Destination Advertisement Trigger Sequence Number (DTSN)", "icmpv6.rpl.dio.dtsn", FT_UINT8, BASE_DEC, NULL, 0x0,
4902              "The DTSN is used as part of the procedure to maintain downward routes.", HFILL }},
4903         { &hf_icmpv6_rpl_dio_dagid,
4904            { "DODAGID", "icmpv6.rpl.dio.dagid", FT_IPv6, BASE_NONE, NULL, 0x0,
4905              "IPv6 address set by a DODAG root which uniquely identifies a DODAG", HFILL }},
4906         { &hf_icmpv6_rpl_dao_instance,
4907            { "RPLInstanceID", "icmpv6.rpl.dao.instance", FT_UINT8, BASE_DEC, NULL, 0x0,
4908              "Indicating the topology instance associated with the DODAG as learned from the DIO", HFILL }},
4909         { &hf_icmpv6_rpl_dao_flag,
4910            { "Flags", "icmpv6.rpl.dao.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4911              NULL, HFILL }},
4912         { &hf_icmpv6_rpl_dao_flag_k,
4913            { "DAO-ACK Request (K)", "icmpv6.rpl.dao.flag.k", FT_BOOLEAN, 8, NULL, RPL_DAO_FLAG_K,
4914              "Indicates that the recipient is expected to send a DAO-ACK back", HFILL }},
4915         { &hf_icmpv6_rpl_dao_flag_d,
4916            { "DODAGID Present (D)", "icmpv6.rpl.dao.flag.d", FT_BOOLEAN, 8, NULL, RPL_DAO_FLAG_D,
4917              "Indicates that the DODAGID field is present", HFILL }},
4918         { &hf_icmpv6_rpl_dao_flag_rsv,
4919            { "Reserved", "icmpv6.rpl.dao.flag.rsv", FT_UINT8, BASE_DEC, NULL, RPL_DAO_FLAG_RESERVED,
4920              "Must be zero", HFILL }},
4921         { &hf_icmpv6_rpl_dao_sequence,
4922            { "DAO Sequence", "icmpv6.rpl.dao.sequence", FT_UINT8, BASE_DEC, NULL, 0x0,
4923              "Incremented at each unique DAO message from a node and echoed in the DAO-ACK message", HFILL }},
4924         { &hf_icmpv6_rpl_dao_dodagid,
4925            { "DODAGID", "icmpv6.rpl.dao.dodagid", FT_IPv6, BASE_NONE, NULL, 0x0,
4926              "IPv6 address set by a DODAG root which uniquely identifies a DODAG", HFILL }},
4927         { &hf_icmpv6_rpl_daoack_instance,
4928            { "RPLInstanceID", "icmpv6.rpl.daoack.instance", FT_UINT8, BASE_DEC, NULL, 0x0,
4929              "Indicating the topology instance associated with the DODAG, as learned from the DIO", HFILL }},
4930         { &hf_icmpv6_rpl_daoack_flag,
4931            { "Flag", "icmpv6.rpl.daoack.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4932              NULL, HFILL }},
4933         { &hf_icmpv6_rpl_daoack_flag_d,
4934            { "DODAGID Present (D)", "icmpv6.rpl.daoack.flag.d", FT_BOOLEAN, 8, NULL, RPL_DAOACK_FLAG_D,
4935              "Indicates that the DODAGID field is present", HFILL }},
4936         { &hf_icmpv6_rpl_daoack_flag_rsv,
4937            { "Reserved", "icmpv6.rpl.daoack.flag.rsv", FT_UINT8, BASE_DEC, NULL, RPL_DAOACK_FLAG_RESERVED,
4938              "Must be zero", HFILL }},
4939         { &hf_icmpv6_rpl_daoack_sequence,
4940            { "DAO-ACK Sequence", "icmpv6.rpl.daoack.sequence", FT_UINT8, BASE_DEC, NULL, 0x0,
4941              "Incremented at each DAO message from a node, and echoed in the DAO-ACK by the recipient", HFILL }},
4942         { &hf_icmpv6_rpl_daoack_status,
4943            { "Status", "icmpv6.rpl.daoack.status", FT_UINT8, BASE_DEC, NULL, 0x0,
4944              "Indicates the completion", HFILL }},
4945         { &hf_icmpv6_rpl_daoack_dodagid,
4946            { "DODAGID", "icmpv6.rpl.daoack.dodagid", FT_IPv6, BASE_NONE, NULL, 0x0,
4947              "IPv6 address integer set by a DODAG root which uniquely identifies a DODAG", HFILL }},
4948         { &hf_icmpv6_rpl_cc_instance,
4949            { "RPLInstanceID", "icmpv6.rpl.cc.instance", FT_UINT8, BASE_DEC, NULL, 0x0,
4950              "Indicating the topology instance associated with the DODAG, as learned from the DIO", HFILL }},
4951         { &hf_icmpv6_rpl_cc_flag,
4952            { "Flag", "icmpv6.rpl.cc.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4953              NULL, HFILL }},
4954         { &hf_icmpv6_rpl_cc_flag_r,
4955            { "Response (R)", "icmpv6.rpl.cc.flag.r", FT_BOOLEAN, 8, NULL, RPL_CC_FLAG_R,
4956              "Indicates whether the CC message is a response", HFILL }},
4957         { &hf_icmpv6_rpl_cc_flag_rsv,
4958            { "Reserved", "icmpv6.rpl.cc.flag.rsv", FT_UINT8, BASE_DEC, NULL, RPL_CC_FLAG_RESERVED,
4959              "Must be zero", HFILL }},
4960         { &hf_icmpv6_rpl_cc_nonce,
4961            { "CC Nonce", "icmpv6.rpl.cc.nonce", FT_UINT16, BASE_HEX, NULL, 0x0,
4962              "The corresponding CC response includes the same CC nonce value as the request, as learned from the DIO", HFILL }},
4963         { &hf_icmpv6_rpl_cc_dodagid,
4964            { "DODAGID", "icmpv6.rpl.cc.dodagid", FT_IPv6, BASE_NONE, NULL, 0x0,
4965              "IPv6 address integer set by a DODAG root which uniquely identifies a DODAG", HFILL }},
4966         { &hf_icmpv6_rpl_cc_destination_counter,
4967            { "Destination Counter", "icmpv6.rpl.cc.destination_counter", FT_UINT32, BASE_DEC, NULL, 0x0,
4968              "Indicating the sender's estimate of the destination's current security Counter value", HFILL }},
4969         { &hf_icmpv6_rpl_secure_flag,
4970            { "Flags", "icmpv6.rpl.secure.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
4971              NULL, HFILL }},
4972         { &hf_icmpv6_rpl_secure_flag_t,
4973            { "Counter is Time (T)", "icmpv6.rpl.secure.flag.t", FT_BOOLEAN, 8, NULL, RPL_SECURE_FLAG_T,
4974              "If it is set then the Counter field is a timestamp", HFILL }},
4975         { &hf_icmpv6_rpl_secure_flag_rsv,
4976            { "Reserved", "icmpv6.rpl.secure.flag.rsv", FT_UINT8, BASE_DEC, NULL, RPL_SECURE_FLAG_RSV,
4977              "Must be zero", HFILL }},
4978         { &hf_icmpv6_rpl_secure_algorithm,
4979            { "Algorithm", "icmpv6.rpl.secure.algorithm", FT_UINT8, BASE_DEC, NULL, 0x0,
4980              "The Security Algorithm field specifies the encryption, MAC, and signature scheme the network uses", HFILL }},
4981         { &hf_icmpv6_rpl_secure_algorithm_encryption,
4982            { "Algorithm (Encryption)", "icmpv6.rpl.secure.algorithm.encryption", FT_UINT8, BASE_DEC, VALS(rpl_secure_algorithm_encryption_val), 0x0,
4983              NULL, HFILL }},
4984         { &hf_icmpv6_rpl_secure_algorithm_signature,
4985            { "Algorithm (Signature)", "icmpv6.rpl.secure.algorithm.signature", FT_UINT8, BASE_DEC, VALS(rpl_secure_algorithm_signature_val), 0x0,
4986              NULL, HFILL }},
4987         { &hf_icmpv6_rpl_secure_kim,
4988            { "Key Identifier Mode (KIM)", "icmpv6.rpl.secure.kim", FT_UINT8, BASE_DEC, NULL, RPL_SECURE_KIM,
4989              "That indicates whether the key used for packet protection is determined implicitly or explicitly and indicates the particular representation of the Key Identifier field", HFILL }},
4990         { &hf_icmpv6_rpl_secure_lvl,
4991            { "Security Level (LVL)", "icmpv6.rpl.secure.lvl", FT_UINT8, BASE_DEC, NULL, RPL_SECURE_LVL,
4992              "Indicates the provided packet protection", HFILL }},
4993         { &hf_icmpv6_rpl_secure_rsv,
4994            { "Reserved", "icmpv6.rpl.secure.rsv", FT_UINT8, BASE_DEC, NULL, RPL_SECURE_RSV,
4995              "Must be zero", HFILL }},
4996         { &hf_icmpv6_rpl_secure_counter,
4997            { "Counter", "icmpv6.rpl.secure.counter", FT_UINT32, BASE_DEC, NULL, 0x0,
4998              "Indicates the non-repeating 4-octet value used to construct the cryptographic mechanism that implements packet protection and allows for the provision of semantic security", HFILL }},
4999         { &hf_icmpv6_rpl_secure_key_source,
5000            { "Key Source", "icmpv6.rpl.secure.key.source", FT_BYTES, BASE_NONE, NULL, 0x0,
5001              "Indicates the logical identifier of the originator of a group key", HFILL }},
5002         { &hf_icmpv6_rpl_secure_key_index,
5003            { "Key Source", "icmpv6.rpl.secure.key.index", FT_UINT8, BASE_DEC, NULL, 0x0,
5004              "Allows unique identification of different keys with the same originator", HFILL }},
5005         { &hf_icmpv6_rpl_opt,
5006           { "ICMPv6 RPL Option", "icmpv6.opt", FT_NONE, BASE_NONE, NULL, 0x0,
5007             "Option", HFILL }},
5008         { &hf_icmpv6_rpl_opt_type,
5009           { "Type", "icmpv6.rpl.opt.type", FT_UINT8, BASE_DEC, VALS(rpl_option_vals), 0x0,
5010             "Options type", HFILL }},
5011         { &hf_icmpv6_rpl_opt_length,
5012           { "Length", "icmpv6.rpl.opt.length", FT_UINT8, BASE_DEC, NULL, 0x0,
5013             "The length of the option in octets excluding the Type and Length fields", HFILL }},
5014         { &hf_icmpv6_rpl_opt_reserved,
5015           { "Reserved", "icmpv6.rpl.opt.reserved", FT_NONE, BASE_NONE, NULL, 0x0,
5016             "Reserved (Must be 0)", HFILL }},
5017         { &hf_icmpv6_rpl_opt_padn,
5018           { "Paddn", "icmpv6.rpl.opt.padn", FT_NONE, BASE_NONE, NULL, 0x0,
5019             "Padding (Must be 0)", HFILL }},
5020         { &hf_icmpv6_rpl_opt_route_prefix_length,
5021            { "Prefix Length", "icmpv6.rpl.opt.route.prefix_length", FT_UINT8, BASE_DEC, NULL, 0x0,
5022              "The number of leading bits in the Prefix that are valid", HFILL }},
5023         { &hf_icmpv6_rpl_opt_route_flag,
5024            { "Flag","icmpv6.rpl.opt.route.flag", FT_NONE, BASE_NONE, NULL, 0x0,
5025              NULL, HFILL }},
5026         { &hf_icmpv6_rpl_opt_route_pref,
5027            { "Preference","icmpv6.rpl.opt.route.pref", FT_UINT8, BASE_DEC, VALS(nd_flag_router_pref), RPL_OPT_ROUTE_PREFERENCE,
5028              "The Route Preference indicates whether to prefer the router associated with this prefix over others, when multiple identical prefixes (for different routers) have been received", HFILL }},
5029         { &hf_icmpv6_rpl_opt_route_reserved,
5030            { "Reserved","icmpv6.rpl.opt.route.reserved", FT_UINT8, BASE_DEC, NULL, RPL_OPT_ROUTE_RESERVED,
5031              "Reserved (Must be Zero)", HFILL }},
5032         { &hf_icmpv6_rpl_opt_route_lifetime,
5033            { "Route Lifetime", "icmpv6.rpl.opt.route.lifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
5034              "The length of time in seconds (relative to the time the packet is sent) that the prefix is valid for route determination", HFILL }},
5035         { &hf_icmpv6_rpl_opt_route_prefix,
5036            { "Prefix", "icmpv6.rpl.opt.route.prefix", FT_IPv6, BASE_NONE, NULL, 0x0,
5037              "Variable-length field containing an IP address or a prefix of an IPv6 address", HFILL }},
5038         { &hf_icmpv6_rpl_opt_config_flag,
5039            { "Flag","icmpv6.rpl.opt.config.flag", FT_NONE, BASE_NONE, NULL, 0x0,
5040              NULL, HFILL }},
5041         { &hf_icmpv6_rpl_opt_config_reserved,
5042            { "Reserved","icmpv6.rpl.opt.config.reserved", FT_UINT8, BASE_DEC, NULL, RPL_OPT_CONFIG_FLAG_RESERVED,
5043              "Must be Zero", HFILL }},
5044         { &hf_icmpv6_rpl_opt_config_auth,
5045            { "Authentication Enabled","icmpv6.rpl.opt.config.auth", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RPL_OPT_CONFIG_FLAG_AUTH,
5046              "One bit flag describing the security mode of the network", HFILL }},
5047         { &hf_icmpv6_rpl_opt_config_pcs,
5048            { "Path Control Size", "icmpv6.rpl.opt.config.pcs", FT_UINT8, BASE_DEC, NULL, RPL_OPT_CONFIG_FLAG_PCS,
5049              "Used to configure the number of bits that may be allocated to the Path Control field", HFILL }},
5050         { &hf_icmpv6_rpl_opt_config_doublings,
5051            { "DIOIntervalDoublings","icmpv6.rpl.opt.config.interval_double", FT_UINT8, BASE_DEC, NULL, 0x0,
5052              "Used to configure Imax of the DIO trickle timer", HFILL }},
5053         { &hf_icmpv6_rpl_opt_config_min_interval,
5054            { "DIOIntervalMin", "icmpv6.rpl.opt.config.interval_min", FT_UINT16, BASE_DEC, NULL, 0x0,
5055              "Used to configure Imin of the DIO trickle timer", HFILL }},
5056         { &hf_icmpv6_rpl_opt_config_redundancy,
5057            { "DIORedundancyConstant", "icmpv6.rpl.opt.config.redundancy", FT_UINT8, BASE_DEC, NULL, 0x0,
5058              "Used to configure k of the DIO trickle timer", HFILL }},
5059         { &hf_icmpv6_rpl_opt_config_rank_incr,
5060            { "MaxRankInc", "icmpv6.rpl.opt.config.max_rank_inc", FT_UINT16, BASE_DEC, NULL, 0x0,
5061              "Used to configure DAGMaxRankIncrease", HFILL }},
5062         { &hf_icmpv6_rpl_opt_config_hop_rank_inc,
5063            { "MinHopRankInc", "icmpv6.rpl.opt.config.min_hop_rank_inc", FT_UINT16, BASE_DEC, NULL, 0x0,
5064               "Used to configure MinHopRankIncrease", HFILL }},
5065         { &hf_icmpv6_rpl_opt_config_ocp,
5066            { "OCP (Objective Code Point)","icmpv6.rpl.opt.config.ocp", FT_UINT16, BASE_DEC, NULL, 0x0,
5067               "The OCP field identifies the OF and is managed by the IANA", HFILL }},
5068         { &hf_icmpv6_rpl_opt_config_rsv,
5069            { "Reserved", "icmpv6.rpl.opt.config.rsv", FT_UINT8, BASE_DEC, NULL, 0x0,
5070               NULL, HFILL }},
5071         { &hf_icmpv6_rpl_opt_config_def_lifetime,
5072            { "Default Lifetime", "icmpv6.rpl.opt.config.def_lifetime", FT_UINT8, BASE_DEC, NULL, 0x0,
5073               "This is the lifetime that is used as default for all RPL routes", HFILL }},
5074         { &hf_icmpv6_rpl_opt_config_lifetime_unit,
5075            { "Lifetime Unit", "icmpv6.rpl.opt.config.lifetime_unit", FT_UINT16, BASE_DEC, NULL, 0x0,
5076               "Provides the unit in seconds that is used to express route lifetimes in RPL", HFILL }},
5077         { &hf_icmpv6_rpl_opt_target_flag,
5078            { "Reserved", "icmpv6.rpl.opt.target.flag", FT_NONE, BASE_NONE, NULL, 0x0,
5079               "Unused field reserved for flags", HFILL }},
5080         { &hf_icmpv6_rpl_opt_target_prefix_length,
5081            { "Target Length", "icmpv6.rpl.opt.target.prefix_length", FT_UINT8, BASE_DEC, NULL, 0x0,
5082               "Number of valid leading bits in the IPv6 Prefix", HFILL }},
5083         { &hf_icmpv6_rpl_opt_target_prefix,
5084            { "Target", "icmpv6.rpl.opt.target.prefix", FT_IPv6, BASE_NONE, NULL, 0x0,
5085               "Identifying an IPv6 destination address, prefix, or multicast group", HFILL }},
5086         { &hf_icmpv6_rpl_opt_transit_flag,
5087            { "Flags", "icmpv6.rpl.opt.transit.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
5088              NULL, HFILL }},
5089          { &hf_icmpv6_rpl_opt_transit_flag_e,
5090            { "External", "icmpv6.rpl.opt.transit.flag.e", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RPL_OPT_TRANSIT_FLAG_E,
5091              "Indicate that the parent router redistributes external targets into the RPL network", HFILL }},
5092          { &hf_icmpv6_rpl_opt_transit_flag_rsv,
5093            { "Reserved", "icmpv6.rpl.opt.transit.flag.rsv", FT_UINT8, BASE_DEC, NULL, RPL_OPT_TRANSIT_FLAG_RSV,
5094              "Must be Zero", HFILL }},
5095         { &hf_icmpv6_rpl_opt_transit_pathctl,
5096            { "Path Control", "icmpv6.rpl.opt.transit.pathctl", FT_UINT8, BASE_DEC, NULL, 0x0,
5097               "Limits the number of DAO-Parents to which a DAO message advertising connectivity", HFILL }},
5098         { &hf_icmpv6_rpl_opt_transit_pathseq,
5099            { "Path Sequence", "icmpv6.rpl.opt.transit.pathseq", FT_UINT8, BASE_DEC, NULL, 0x0,
5100               "Increments the Path Sequence each time it issues a RPL Target option with updated information", HFILL }},
5101         { &hf_icmpv6_rpl_opt_transit_pathlifetime,
5102            { "Path Lifetime", "icmpv6.rpl.opt.transit.pathlifetime", FT_UINT8, BASE_DEC, NULL, 0x0,
5103               "The length of time in Lifetime Units that the prefix is valid for route determination", HFILL }},
5104         { &hf_icmpv6_rpl_opt_transit_parent,
5105            { "Parent Address", "icmpv6.rpl.opt.transit.parent", FT_IPv6, BASE_NONE, NULL, 0x0,
5106               "IPv6 Address of the DODAG Parent of the node originally issuing the Transit Information Option", HFILL }},
5107         { &hf_icmpv6_rpl_opt_solicited_instance,
5108            { "Instance", "icmpv6.rpl.opt.solicited.instance", FT_UINT8, BASE_DEC, NULL, 0x0,
5109               "Containing the RPLInstanceID that is being solicited when valid", HFILL }},
5110         { &hf_icmpv6_rpl_opt_solicited_flag,
5111            { "Flag", "icmpv6.rpl.opt.solicited.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
5112               NULL, HFILL }},
5113         { &hf_icmpv6_rpl_opt_solicited_flag_v,
5114            { "Version predicate", "icmpv6.rpl.opt.solicited.flag.v", FT_BOOLEAN, 8, TFS(&tfs_true_false), RPL_OPT_SOLICITED_FLAG_V,
5115               "The Version predicate is true if the receiver's DODAGVersionNumber matches the requested Version Number", HFILL }},
5116         { &hf_icmpv6_rpl_opt_solicited_flag_i,
5117            { "InstanceID predicate","icmpv6.rpl.opt.solicited.flag.i", FT_BOOLEAN, 8, TFS(&tfs_true_false), RPL_OPT_SOLICITED_FLAG_I,
5118               "The InstanceID predicate is true when the RPL node's current RPLInstanceID matches the requested RPLInstanceID", HFILL }},
5119         { &hf_icmpv6_rpl_opt_solicited_flag_d,
5120            { "DODAGID predicate", "icmpv6.rpl.opt.solicited.flag.d", FT_BOOLEAN, 8, TFS(&tfs_true_false), RPL_OPT_SOLICITED_FLAG_D,
5121               "The DODAGID predicate is true if the RPL node's parent set has the same DODAGID as the DODAGID field", HFILL }},
5122          { &hf_icmpv6_rpl_opt_solicited_flag_rsv,
5123            { "Reserved", "icmpv6.rpl.opt.solicited.flag.rsv", FT_UINT8, BASE_DEC, NULL, RPL_OPT_SOLICITED_FLAG_RSV,
5124              "Must be Zero", HFILL }},
5125         { &hf_icmpv6_rpl_opt_solicited_dodagid,
5126            { "DODAGID", "icmpv6.rpl.opt.solicited.dodagid", FT_IPv6, BASE_NONE, NULL, 0x0,
5127               "the DODAGID that is being solicited when valid", HFILL }},
5128         { &hf_icmpv6_rpl_opt_solicited_version,
5129            { "Version", "icmpv6.rpl.opt.solicited.version", FT_UINT8, BASE_DEC, NULL, 0x0,
5130               "the value of  DODAGVersionNumber that is being solicited when valid", HFILL }},
5131
5132         { &hf_icmpv6_rpl_opt_prefix_length,
5133            { "Prefix Length", "icmpv6.rpl.opt.prefix.length", FT_UINT8, BASE_DEC, NULL, 0x0,
5134              "The number of leading bits in the Prefix that are valid", HFILL }},
5135         { &hf_icmpv6_rpl_opt_prefix_flag,
5136            { "Flag", "icmpv6.rpl.opt.prefix.flag", FT_UINT8, BASE_HEX, NULL, 0x0,
5137              NULL, HFILL }},
5138         { &hf_icmpv6_rpl_opt_prefix_flag_l,
5139            { "On Link", "icmpv6.rpl.opt.prefix.flag.l", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RPL_OPT_PREFIX_FLAG_L,
5140              "When set, indicates that this prefix can be used for on-link determination", HFILL }},
5141         { &hf_icmpv6_rpl_opt_prefix_flag_a,
5142            { "Auto Address Config","icmpv6.rpl.opt.config.flag.a", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RPL_OPT_PREFIX_FLAG_A,
5143              "When set indicates that this prefix can be used for stateless address configuration", HFILL }},
5144         { &hf_icmpv6_rpl_opt_prefix_flag_r,
5145            { "Router Address", "icmpv6.rpl.opt.config.flag.r", FT_BOOLEAN, 8, TFS(&tfs_set_notset), RPL_OPT_PREFIX_FLAG_R,
5146              "When set, indicates that the Prefix field contains a complete IPv6 address assigned to the sending router that can be used as parent in a target option", HFILL }},
5147         { &hf_icmpv6_rpl_opt_prefix_flag_rsv,
5148            { "Reserved", "icmpv6.rpl.opt.config.flag.rsv", FT_UINT8, BASE_DEC, NULL, RPL_OPT_PREFIX_FLAG_RSV,
5149              "Must Be Zero", HFILL }},
5150         { &hf_icmpv6_rpl_opt_prefix_vlifetime,
5151            { "Valid Lifetime", "icmpv6.rpl.opt.prefix.valid_lifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
5152              "The length of time in seconds that the prefix is valid for the purpose of on-link determination", HFILL }},
5153         { &hf_icmpv6_rpl_opt_prefix_plifetime,
5154            { "Preferred Lifetime", "icmpv6.rpl.opt.prefix.preferred_lifetime", FT_UINT32, BASE_DEC, NULL, 0x0,
5155              "The length of time in seconds that addresses generated from the prefix via stateless address autoconfiguration remain preferred", HFILL }},
5156         { &hf_icmpv6_rpl_opt_prefix,
5157            { "Destination Prefix", "icmpv6.rpl.opt.prefix", FT_IPv6, BASE_NONE, NULL, 0x0,
5158              "An IPv6 address or a prefix of an IPv6 address", HFILL }},
5159         { &hf_icmpv6_rpl_opt_targetdesc,
5160            { "Descriptor", "icmpv6.rpl.opt.targetdesc.descriptor", FT_UINT32, BASE_HEX, NULL, 0x0,
5161              "Opaque Data", HFILL }},
5162
5163         { &hf_icmpv6_rpl_opt_route_discovery_flag,
5164            { "Flags", "icmpv6.rpl.opt.routediscovery.flag", FT_NONE, BASE_NONE, NULL, 0x0,
5165              "NULL", HFILL }},
5166         { &hf_icmpv6_rpl_opt_route_discovery_reply,
5167            { "Reply", "icmpv6.rpl.opt.routediscovery.flag.reply", FT_BOOLEAN, 8, TFS(&tfs_yes_no), RPL_OPT_ROUTE_DISCOVERY_R,
5168              "The Origin sets this flag to one to allow the Target(s) to send P2P-DRO messages back to the Origin", HFILL }},
5169         { &hf_icmpv6_rpl_opt_route_discovery_hop_by_hop,
5170            { "Hop-by-Hop", "icmpv6.rpl.opt.routediscovery.flag.hopbyhop", FT_BOOLEAN, 8, TFS(&tfs_yes_no), RPL_OPT_ROUTE_DISCOVERY_H,
5171              "The Origin sets this flag to one if it desires Hop-by-hop Routes and to zero if it desires Source Routes.", HFILL }},
5172         { &hf_icmpv6_rpl_opt_route_discovery_num_of_routes,
5173            { "Number of Routes", "icmpv6.rpl.opt.routediscovery.flag.numofroutes", FT_UINT8, BASE_DEC, NULL, RPL_OPT_ROUTE_DISCOVERY_N,
5174              "This value plus one indicates the number of Source Routes that each Target should convey to the Origin", HFILL }},
5175         { &hf_icmpv6_rpl_opt_route_discovery_compr,
5176            { "Compr", "icmpv6.rpl.opt.routediscovery.flag.compr", FT_UINT8, BASE_DEC, NULL, RPL_OPT_ROUTE_DISCOVERY_COMPR,
5177              "Number of prefix octets that are elided from the Target field and Address vector", HFILL }},
5178         { &hf_icmpv6_rpl_opt_route_discovery_lifetime,
5179            { "Lifetime", "icmpv6.rpl.opt.routediscovery.lifetime", FT_UINT8, BASE_DEC, NULL, RPL_OPT_ROUTE_DISCOVERY_L,
5180              "Lifetime of the temporary DODAG", HFILL }},
5181         { &hf_icmpv6_rpl_opt_route_discovery_maxrank,
5182            { "MaxRank", "icmpv6.rpl.opt.routediscovery.maxrank", FT_UINT8, BASE_DEC, NULL, RPL_OPT_ROUTE_DISCOVERY_MR_NH,
5183              "Upper limit of the integer portion of the rank when used inside a DIO", HFILL }},
5184         { &hf_icmpv6_rpl_opt_route_discovery_nh,
5185            { "NH", "icmpv6.rpl.opt.routediscovery.nh", FT_UINT8, BASE_DEC, NULL, RPL_OPT_ROUTE_DISCOVERY_MR_NH,
5186              "Index of the next-hop (NH) address inside the Address vector", HFILL }},
5187         { &hf_icmpv6_rpl_opt_route_discovery_target_addr,
5188            { "Target Address", "icmpv6.rpl.opt.routediscovery.targetaddr", FT_IPv6, BASE_NONE, NULL, 0x0,
5189              "An IPv6 address of the Target after eliding Compr number of prefix octets", HFILL }},
5190         { &hf_icmpv6_rpl_opt_route_discovery_addr_vec,
5191            { "Address Vector", "icmpv6.rpl.opt.routediscovery.addr_vec", FT_NONE, BASE_NONE, NULL, 0x0,
5192              "NULL", HFILL }},
5193         { &hf_icmpv6_rpl_opt_route_discovery_addr_vec_addr,
5194           { "Address", "icmpv6.rpl.opt.routediscovery.addrvec.addr", FT_IPv6, BASE_NONE, NULL, 0x0,
5195             NULL, HFILL }},
5196         { &hf_icmpv6_rpl_p2p_dro_instance,
5197            { "RPLInstanceID", "icmpv6.rpl.p2p.dro.instance", FT_UINT8, BASE_DEC, NULL, 0x0,
5198              "Set by the DODAG root that indicates which RPL Instance the DODAG is part of", HFILL }},
5199         { &hf_icmpv6_rpl_p2p_dro_version,
5200            { "Version", "icmpv6.rpl.p2p.dro.version", FT_UINT8, BASE_DEC, NULL, 0x0,
5201              "Set by the DODAG root to the DODAGVersionNumber", HFILL }},
5202         { &hf_icmpv6_rpl_p2p_dro_flag,
5203            { "Flags", "icmpv6.rpl.p2p.dro.flag", FT_NONE, BASE_NONE, NULL, 0x0,
5204              "NULL", HFILL }},
5205         { &hf_icmpv6_rpl_p2p_dro_flag_stop,
5206            { "Stop", "icmpv6.rpl.p2p.dro.flag.stop", FT_BOOLEAN, 16, TFS(&tfs_yes_no), RPL_P2P_DRO_FLAG_S,
5207              "Indicates that the P2P-RPL route discovery is over", HFILL }},
5208         { &hf_icmpv6_rpl_p2p_dro_flag_ack,
5209            { "Ack", "icmpv6.rpl.p2p.dro.flag.ack", FT_BOOLEAN, 16, TFS(&tfs_yes_no), RPL_P2P_DRO_FLAG_A,
5210              "Indicates that the Origin MUST unicast a P2P-DRO-ACK message to the Target", HFILL }},
5211         { &hf_icmpv6_rpl_p2p_dro_flag_seq,
5212            { "Seq", "icmpv6.rpl.p2p.dro.flag.seq", FT_UINT16, BASE_DEC, NULL, RPL_P2P_DRO_FLAG_SEQ,
5213              "Indicates the sequence number for the P2P-DRO", HFILL }},
5214         { &hf_icmpv6_rpl_p2p_dro_flag_reserved,
5215            { "Reserved", "icmpv6.rpl.p2p.dro.flag.reserved", FT_UINT16, BASE_DEC, NULL, RPL_P2P_DRO_FLAG_RSV,
5216              NULL, HFILL }},
5217         { &hf_icmpv6_rpl_p2p_dro_dagid,
5218            { "DODAGID", "icmpv6.rpl.p2p.dro.dagid", FT_IPv6, BASE_NONE, NULL, 0x0,
5219              "IPv6 address set by a DODAG root which uniquely identifies a DODAG", HFILL }},
5220         { &hf_icmpv6_rpl_p2p_droack_flag,
5221            { "Flags", "icmpv6.rpl.p2p.droack.flag", FT_NONE, BASE_NONE, NULL, 0x0,
5222              "NULL", HFILL }},
5223         { &hf_icmpv6_rpl_p2p_droack_flag_seq,
5224            { "Seq", "icmpv6.rpl.p2p.droack.flag.seq", FT_UINT16, BASE_DEC, NULL, RPL_P2P_DROACK_FLAG_SEQ,
5225              "Indicates the sequence number for the P2P-DRO", HFILL }},
5226         { &hf_icmpv6_rpl_p2p_droack_flag_reserved,
5227            { "Reserved", "icmpv6.rpl.p2p.droack.flag.reserved", FT_UINT16, BASE_DEC, NULL, RPL_P2P_DROACK_FLAG_RSV,
5228              NULL, HFILL }},
5229
5230         /* RFC6743 Locator Update (156) */
5231
5232         { &hf_icmpv6_ilnp_nb_locs,
5233           { "Num of Locs", "icmpv6.ilnp.nb_locs", FT_UINT8, BASE_DEC, NULL, 0x0,
5234             "The number of 64-bit Locator values that are advertised in this message", HFILL }},
5235         { &hf_icmpv6_ilnp_locator,
5236           { "Locator", "icmpv6.ilnp.nb_locs", FT_UINT64, BASE_HEX, NULL, 0x0,
5237             "The 64-bit Locator values currently valid for the sending ILNPv6 node", HFILL }},
5238         { &hf_icmpv6_ilnp_preference,
5239           { "Preference", "icmpv6.ilnp.nb_locs", FT_UINT32, BASE_DEC, NULL, 0x0,
5240             "The preferability of each Locator relative to other valid Locator values", HFILL }},
5241         { &hf_icmpv6_ilnp_lifetime,
5242           { "Lifetime", "icmpv6.ilnp.nb_locs", FT_UINT32, BASE_DEC, NULL, 0x0,
5243             "The maximum number of seconds that this particular Locator may be considered valid", HFILL }},
5244
5245         /* 6lowpan-nd: Neighbour Discovery for 6LoWPAN Networks */
5246         { &hf_icmpv6_da_status,
5247           { "Status", "icmpv6.6lowpannd.da.status", FT_UINT8, BASE_DEC, VALS(nd_opt_6lowpannd_status_val), 0x0,
5248             "Indicates the status of a registration in the DAC", HFILL }},
5249         { &hf_icmpv6_da_rsv,
5250           { "Reserved", "icmpv6.6lowpannd.da.rsv", FT_UINT8, BASE_DEC, NULL, 0x0,
5251             "Must be Zero", HFILL }},
5252         { &hf_icmpv6_da_lifetime,
5253           { "Lifetime", "icmpv6.6lowpannd.da.lifetime", FT_UINT16, BASE_DEC, NULL, 0x0,
5254             "The amount of time in a unit of 60 seconds that the router should retain the Neighbor Cache entry for the sender of the NS that includes this option", HFILL }},
5255         { &hf_icmpv6_da_eui64,
5256           { "EUI-64", "icmpv6.6lowpannd.da.eui64", FT_EUI64, BASE_NONE, NULL, 0x0,
5257             "This field is used to uniquely identify the interface of the registered address by including the EUI-64 identifier", HFILL }},
5258         { &hf_icmpv6_da_raddr,
5259           { "Registered Address", "icmpv6.6lowpannd.da.reg_addr", FT_IPv6, BASE_NONE, NULL, 0x0,
5260             "Carries the host address, which was contained in the IPv6 Source field in the NS that contained the ARO option sent by the host", HFILL }},
5261
5262         /* Conversation-related [generated] header fields */
5263         { &hf_icmpv6_resp_in,
5264             { "Response In", "icmpv6.resp_in", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
5265               "The response to this request is in this frame", HFILL }},
5266         {&hf_icmpv6_no_resp,
5267             {"No response seen", "icmpv6.no_resp", FT_NONE, BASE_NONE, NULL, 0x0,
5268              "No corresponding response frame was seen", HFILL}},
5269         { &hf_icmpv6_resp_to,
5270             { "Response To", "icmpv6.resp_to", FT_FRAMENUM, BASE_NONE, NULL, 0x0,
5271               "This is the response to the request in this frame", HFILL }},
5272         { &hf_icmpv6_resptime,
5273             { "Response Time", "icmpv6.resptime", FT_DOUBLE, BASE_NONE, NULL, 0x0,
5274               "The time between the request and the response, in ms.", HFILL }}
5275     };
5276
5277     static gint *ett[] = {
5278         &ett_icmpv6,
5279         &ett_icmpv6_opt,
5280         &ett_icmpv6_mar,
5281         &ett_icmpv6_flag_prefix,
5282         &ett_icmpv6_flag_map,
5283         &ett_icmpv6_flag_route_info,
5284         &ett_icmpv6_flag_6lowpan,
5285         &ett_icmpv6_flag_efo,
5286         &ett_icmpv6_rpl_opt,
5287         &ett_icmpv6_rpl_flag_routing,
5288         &ett_icmpv6_rpl_flag_config,
5289         &ett_icmpv6_rpl_flag_transit,
5290         &ett_icmpv6_rpl_flag_solicited,
5291         &ett_icmpv6_rpl_flag_prefix,
5292         &ett_icmpv6_rpl_route_discovery_flag,
5293         &ett_icmpv6_rpl_route_discovery_addr_vec,
5294         &ett_icmpv6_rpl_p2p_dro_flag,
5295         &ett_icmpv6_rpl_p2p_droack_flag,
5296         &ett_icmpv6_flag_ni,
5297         &ett_icmpv6_flag_rr,
5298         &ett_icmpv6_rr_mp,
5299         &ett_icmpv6_rr_up,
5300         &ett_icmpv6_rr_up_flag_mask,
5301         &ett_icmpv6_rr_up_flag_ra,
5302         &ett_icmpv6_rr_up_flag,
5303         &ett_icmpv6_rr_rm,
5304         &ett_icmpv6_rr_rm_flag,
5305         &ett_icmpv6_flag_mld,
5306         &ett_icmpv6_flag_ra,
5307         &ett_icmpv6_flag_na,
5308         &ett_icmpv6_flag_mip6,
5309         &ett_icmpv6_flag_fmip6,
5310         &ett_icmpv6_flag_secure,
5311         &ett_icmpv6_flag_rpl_dio,
5312         &ett_icmpv6_flag_rpl_dao,
5313         &ett_icmpv6_flag_rpl_daoack,
5314         &ett_icmpv6_flag_rpl_cc,
5315         &ett_icmpv6_opt_name,
5316         &ett_icmpv6_cga_param_name
5317     };
5318
5319     static ei_register_info ei[] = {
5320         { &ei_icmpv6_invalid_option_length, { "icmpv6.invalid_option_length", PI_MALFORMED, PI_ERROR, "Invalid Option Length", EXPFILL }},
5321         { &ei_icmpv6_undecoded_option, { "icmpv6.undecoded.option", PI_UNDECODED, PI_NOTE, "Undecoded option", EXPFILL }},
5322         { &ei_icmpv6_unknown_data, { "icmpv6.unknown_data.expert", PI_MALFORMED, PI_ERROR, "Unknown Data (not interpreted)", EXPFILL }},
5323         { &ei_icmpv6_undecoded_rpl_option, { "icmpv6.undecoded.rpl_option", PI_UNDECODED, PI_NOTE, "Undecoded RPL Option", EXPFILL }},
5324         { &ei_icmpv6_undecoded_type, { "icmpv6.undecoded.type", PI_UNDECODED, PI_NOTE, "Undecoded type", EXPFILL }},
5325         { &ei_icmpv6_rr_pco_mp_matchlen, { "icmpv6.rr.pco.mp.matchlen.gt128", PI_PROTOCOL, PI_WARN, "MatchLen is greater than 128", EXPFILL }},
5326         { &ei_icmpv6_rr_pco_mp_matchedlen, { "icmpv6.rr.pco.mp.matchedlen.gt128", PI_PROTOCOL, PI_WARN, "MatchedLen is greater than 128", EXPFILL }},
5327         { &ei_icmpv6_checksum, { "icmpv6.checksum_bad.expert", PI_CHECKSUM, PI_WARN, "Bad checksum", EXPFILL }},
5328         { &ei_icmpv6_resp_not_found, { "icmpv6.resp_not_found", PI_SEQUENCE, PI_WARN, "Response not found", EXPFILL }},
5329         { &ei_icmpv6_rpl_p2p_hop_by_hop, { "icmpv6.rpl.p2p.hop_by_hop", PI_PROTOCOL, PI_WARN, "Reply MUST be set to one in order to establish a Hop-by-Hop Route", EXPFILL }},
5330         { &ei_icmpv6_rpl_p2p_num_of_routes, { "icmpv6.rpl.p2p.num_of_routes", PI_PROTOCOL, PI_WARN, "This field MUST be set to zero when Hop-by-Hop Routes are being discovered", EXPFILL }},
5331         { &ei_icmpv6_rpl_p2p_dro_rdo_zero, { "icmpv6.rpl.p2p.dro.rdo.zero", PI_PROTOCOL, PI_WARN, "This field MUST be set to zero when the P2P-RDO is included in a P2P-DRO", EXPFILL }},
5332         { &ei_icmpv6_rpl_p2p_dro_zero, { "icmpv6.rpl.p2p.dro.zero", PI_PROTOCOL, PI_WARN, "This field MUST be set to zero", EXPFILL }},
5333     };
5334
5335     expert_module_t* expert_icmpv6;
5336
5337     proto_icmpv6 = proto_register_protocol("Internet Control Message Protocol v6",
5338                                            "ICMPv6", "icmpv6");
5339     proto_register_field_array(proto_icmpv6, hf, array_length(hf));
5340     proto_register_subtree_array(ett, array_length(ett));
5341     expert_icmpv6 = expert_register_protocol(proto_icmpv6);
5342     expert_register_field_array(expert_icmpv6, ei, array_length(ei));
5343
5344     icmpv6_handle = new_register_dissector("icmpv6", dissect_icmpv6, proto_icmpv6);
5345
5346     icmpv6_tap = register_tap("icmpv6");
5347 }
5348
5349 void
5350 proto_reg_handoff_icmpv6(void)
5351 {
5352     dissector_add_uint("ip.proto", IP_PROTO_ICMPV6, icmpv6_handle);
5353
5354     /*
5355      * Get a handle for the IPv6 dissector.
5356      */
5357     ipv6_handle = find_dissector("ipv6");
5358     data_handle = find_dissector("data");
5359 }
5360
5361 /*
5362  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
5363  *
5364  * Local variables:
5365  * c-basic-offset: 4
5366  * tab-width: 8
5367  * indent-tabs-mode: nil
5368  * End:
5369  *
5370  * vi: set shiftwidth=4 tabstop=8 expandtab:
5371  * :indentSize=4:tabSize=8:noTabs=true:
5372  */