1 /* packet-ipv6.c
2 * Routines for IPv6 packet disassembly
3 *
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
7 *
8 * SHIM6 support added by Matthijs Mekking <matthijs@NLnetLabs.nl>
9 *
10 * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@siemens.hr>
11 *
12 * Added support for new IPv6 Hop by Hop PMTU Option <bob.hinden@gmail.com>
13 *
14 * SPDX-License-Identifier: GPL-2.0-or-later
15 */
16
17 #include "config.h"
18
19 #include <math.h>
20 #include <epan/packet.h>
21 #include <epan/capture_dissectors.h>
22 #include <epan/expert.h>
23 #include <epan/ip_opts.h>
24 #include <epan/addr_resolv.h>
25 #include <epan/maxmind_db.h>
26 #include <epan/prefs.h>
27 #include <epan/conversation_table.h>
28 #include <epan/conversation_filter.h>
29 #include <epan/reassemble.h>
30 #include <epan/ipproto.h>
31 #include <epan/etypes.h>
32 #include <epan/ppptypes.h>
33 #include <epan/aftypes.h>
34 #include <epan/nlpid.h>
35 #include <epan/arcnet_pids.h>
36 #include <epan/decode_as.h>
37 #include <epan/proto_data.h>
38 #include <epan/to_str.h>
39
40 #include <wiretap/erf_record.h>
41 #include <wsutil/str_util.h>
42 #include "packet-ip.h"
43 #include "packet-juniper.h"
44 #include "packet-sflow.h"
45 #include "packet-vxlan.h"
46 #include "packet-mpls.h"
47 #include "packet-nsh.h"
48
49 void proto_register_ipv6(void);
50 void proto_reg_handoff_ipv6(void);
51
52 /* Offsets of fields within an IPv6 header. */
53 #define IP6H_CTL_VFC 0
54 #define IP6H_CTL_FLOW 0
55 #define IP6H_CTL_PLEN 4
56 #define IP6H_CTL_NXT 6
57 #define IP6H_CTL_HLIM 7
58 #define IP6H_SRC 8
59 #define IP6H_DST 24
60
61 /* Option types and related macros */
62 #define IP6OPT_PAD1 0x00 /* 00 0 00000 = 0 */
63 #define IP6OPT_PADN 0x01 /* 00 0 00001 = 1 */
64 #define IP6OPT_TEL 0x04 /* 00 0 00100 = 4 */
65 #define IP6OPT_RTALERT 0x05 /* 00 0 00101 = 5 */
66 #define IP6OPT_CALIPSO 0x07 /* 00 0 00111 = 7 */
67 #define IP6OPT_SMF_DPD 0x08 /* 00 0 01000 = 8 */
68 #define IP6OPT_PDM 0x0F /* 00 0 01111 = 15 */
69 #define IP6OPT_EXP_1E 0x1E /* 00 0 11110 = 30 */
70 #define IP6OPT_QUICKSTART 0x26 /* 00 1 00110 = 38 */
71 #define IP6OPT_PMTU 0x30 /* 00 1 10000 = 48 */
72 #define IP6OPT_EXP_3E 0x3E /* 00 1 11110 = 62 */
73 #define IP6OPT_TPF 0x41 /* 01 0 00001 = 65 */
74 #define IP6OPT_EXP_5E 0x5E /* 01 0 11110 = 94 */
75 #define IP6OPT_RPL 0x63 /* 01 1 00011 = 99 */
76 #define IP6OPT_MPL 0x6D /* 01 1 01101 = 109 */
77 #define IP6OPT_EXP_7E 0x7E /* 01 1 11110 = 126 */
78 #define IP6OPT_ENDI 0x8A /* 10 0 01010 = 138 */ /* DEPRECATED */
79 #define IP6OPT_ILNP_NONCE 0x8B /* 10 0 01011 = 139 */
80 #define IP6OPT_LIO 0x8C /* 10 0 01100 = 140 */
81 #define IP6OPT_EXP_9E 0x9E /* 10 0 11110 = 158 */
82 #define IP6OPT_EXP_BE 0xBE /* 10 1 11110 = 190 */
83 #define IP6OPT_JUMBO 0xC2 /* 11 0 00010 = 194 */
84 #define IP6OPT_HOME_ADDRESS 0xC9 /* 11 0 01001 = 201 */
85 #define IP6OPT_EXP_DE 0xDE /* 11 0 11110 = 222 */
86 #define IP6OPT_IP_DFF 0xEE /* 11 1 01110 = 238 */
87 #define IP6OPT_EXP_FE 0xFE /* 11 1 11110 = 254 */
88
89 #define IP6OPT_RTALERT_MLD 0 /* Datagram contains MLD msg */
90 #define IP6OPT_RTALERT_RSVP 1 /* Datagram contains RSVP msg */
91 #define IP6OPT_RTALERT_ACTNET 2 /* Datagram contains ACTNET msg */
92
93 /* RPL Routing header */
94 #define IP6RRPL_BITMASK_CMPRI 0xF0000000
95 #define IP6RRPL_BITMASK_CMPRE 0x0F000000
96 #define IP6RRPL_BITMASK_PAD 0x00F00000
97 #define IP6RRPL_BITMASK_RESERVED 0x000FFFFF
98
99 /* Protocol specific data indices */
100 #define IPV6_PROTO_VALUE 1
101 #define IPV6_PROTO_PINFO 2
102
103 static int ipv6_tap = -1;
104
105 static int proto_ipv6 = -1;
106 static int proto_ipv6_hopopts = -1;
107 static int proto_ipv6_routing = -1;
108 static int proto_ipv6_fraghdr = -1;
109 static int proto_ipv6_dstopts = -1;
110
111 static int proto_ipv6_routing_rt0 = -1;
112 static int proto_ipv6_routing_mipv6 = -1;
113 static int proto_ipv6_routing_rpl = -1;
pdu_store(packet_info * pinfo,wmem_tree_t * multisegment_pdus,guint32 first_frame,gboolean is_ipp,guint document)114 static int proto_ipv6_routing_srh = -1;
115 static int proto_ipv6_routing_crh = -1;
116
117 static int hf_ipv6_version = -1;
118 static int hf_ip_version = -1;
119 static int hf_ipv6_tclass = -1;
120 static int hf_ipv6_tclass_dscp = -1;
121 static int hf_ipv6_tclass_ecn = -1;
122 static int hf_ipv6_flow = -1;
123 static int hf_ipv6_plen = -1;
124 static int hf_ipv6_nxt = -1;
125 static int hf_ipv6_hlim = -1;
126 static int hf_ipv6_src = -1;
127 static int hf_ipv6_src_host = -1;
128 static int hf_ipv6_src_slaac_mac = -1;
129 static int hf_ipv6_src_isatap_ipv4 = -1;
130 static int hf_ipv6_src_6to4_gateway_ipv4 = -1;
131 static int hf_ipv6_src_6to4_sla_id = -1;
132 static int hf_ipv6_src_teredo_server_ipv4 = -1;
133 static int hf_ipv6_src_teredo_port = -1;
134 static int hf_ipv6_src_teredo_client_ipv4 = -1;
init_ippusb_conversation_data(void)135 static int hf_ipv6_src_embed_ipv4 = -1;
136 static int hf_ipv6_dst = -1;
137 static int hf_ipv6_dst_host = -1;
138 static int hf_ipv6_dst_slaac_mac = -1;
139 static int hf_ipv6_dst_isatap_ipv4 = -1;
140 static int hf_ipv6_dst_6to4_gateway_ipv4 = -1;
141 static int hf_ipv6_dst_6to4_sla_id = -1;
142 static int hf_ipv6_dst_teredo_server_ipv4 = -1;
143 static int hf_ipv6_dst_teredo_port = -1;
144 static int hf_ipv6_dst_teredo_client_ipv4 = -1;
145 static int hf_ipv6_dst_embed_ipv4 = -1;
146 static int hf_ipv6_addr = -1;
get_ippusb_conversation_data(conversation_t * conv,packet_info * pinfo)147 static int hf_ipv6_host = -1;
148 static int hf_ipv6_slaac_mac = -1;
149 static int hf_ipv6_isatap_ipv4 = -1;
150 static int hf_ipv6_6to4_gateway_ipv4 = -1;
151 static int hf_ipv6_6to4_sla_id = -1;
152 static int hf_ipv6_teredo_server_ipv4 = -1;
153 static int hf_ipv6_teredo_port = -1;
154 static int hf_ipv6_teredo_client_ipv4 = -1;
155 static int hf_ipv6_embed_ipv4 = -1;
156 static int hf_ipv6_opt = -1;
157 static int hf_ipv6_opt_type = -1;
158 static int hf_ipv6_opt_type_action = -1;
159 static int hf_ipv6_opt_type_change = -1;
160 static int hf_ipv6_opt_type_rest = -1;
161 static int hf_ipv6_opt_length = -1;
162 static int hf_ipv6_opt_pad1 = -1;
163 static int hf_ipv6_opt_padn = -1;
164 static int hf_ipv6_opt_tel = -1;
165 static int hf_ipv6_opt_rtalert = -1;
ippusb_temporary_key(const packet_info * pinfo _U_,const guint32 id _U_,const void * data)166 static int hf_ipv6_opt_pmtu_min = -1;
167 static int hf_ipv6_opt_pmtu_rtn = -1;
168 static int hf_ipv6_opt_pmtu_rtn_flag = -1;
169 static int hf_ipv6_opt_jumbo = -1;
170 static int hf_ipv6_opt_calipso_doi = -1;
ippusb_persistent_key(const packet_info * pinfo _U_,const guint32 id _U_,const void * data)171 static int hf_ipv6_opt_calipso_cmpt_length = -1;
172 static int hf_ipv6_opt_calipso_sens_level = -1;
173 static int hf_ipv6_opt_calipso_checksum = -1;
174 static int hf_ipv6_opt_calipso_cmpt_bitmap = -1;
175 static int hf_ipv6_opt_smf_dpd_hash_bit = -1;
ippusb_free_temporary_key(gpointer ptr _U_)176 static int hf_ipv6_opt_smf_dpd_tid_type = -1;
177 static int hf_ipv6_opt_smf_dpd_tid_len = -1;
ippusb_free_persistent_key(gpointer ptr _U_)178 static int hf_ipv6_opt_smf_dpd_tagger_id = -1;
179 static int hf_ipv6_opt_smf_dpd_ident = -1;
180 static int hf_ipv6_opt_smf_dpd_hav = -1;
181 static int hf_ipv6_opt_pdm_scale_dtlr = -1;
182 static int hf_ipv6_opt_pdm_scale_dtls = -1;
183 static int hf_ipv6_opt_pdm_psn_this_pkt = -1;
184 static int hf_ipv6_opt_pdm_psn_last_recv = -1;
185 static int hf_ipv6_opt_pdm_delta_last_recv = -1;
186 static int hf_ipv6_opt_pdm_delta_last_sent = -1;
187 static int hf_ipv6_opt_qs_func = -1;
188 static int hf_ipv6_opt_qs_rate = -1;
189 static int hf_ipv6_opt_qs_ttl = -1;
190 static int hf_ipv6_opt_qs_ttl_diff = -1;
191 static int hf_ipv6_opt_qs_unused = -1;
192 static int hf_ipv6_opt_qs_nonce = -1;
193 static int hf_ipv6_opt_qs_reserved = -1;
194 static int hf_ipv6_opt_tpf_information = -1;
dissect_ippusb(tvbuff_t * tvb,packet_info * pinfo,proto_tree * tree,void * data)195 static int hf_ipv6_opt_mipv6_home_address = -1;
196 static int hf_ipv6_opt_rpl_flag = -1;
197 static int hf_ipv6_opt_rpl_flag_o = -1;
198 static int hf_ipv6_opt_rpl_flag_r = -1;
199 static int hf_ipv6_opt_rpl_flag_f = -1;
200 static int hf_ipv6_opt_rpl_flag_rsv = -1;
201 static int hf_ipv6_opt_rpl_instance_id = -1;
202 static int hf_ipv6_opt_rpl_senderrank = -1;
203 static int hf_ipv6_opt_ilnp_nonce = -1;
204 static int hf_ipv6_opt_lio_len = -1;
205 static int hf_ipv6_opt_lio_id = -1;
206 static int hf_ipv6_opt_mpl_flag = -1;
207 static int hf_ipv6_opt_mpl_flag_s = -1;
208 static int hf_ipv6_opt_mpl_flag_m = -1;
209 static int hf_ipv6_opt_mpl_flag_v = -1;
210 static int hf_ipv6_opt_mpl_flag_rsv = -1;
211 static int hf_ipv6_opt_mpl_sequence = -1;
212 static int hf_ipv6_opt_mpl_seed_id = -1;
213 static int hf_ipv6_opt_dff_flags = -1;
214 static int hf_ipv6_opt_dff_flag_ver = -1;
215 static int hf_ipv6_opt_dff_flag_dup = -1;
216 static int hf_ipv6_opt_dff_flag_ret = -1;
217 static int hf_ipv6_opt_dff_flag_rsv = -1;
218 static int hf_ipv6_opt_dff_seqnum = -1;
219 static int hf_ipv6_opt_experimental = -1;
220 static int hf_ipv6_opt_unknown_data = -1;
221 static int hf_ipv6_opt_unknown = -1;
222 static int hf_ipv6_dstopts_nxt = -1;
223 static int hf_ipv6_dstopts_len = -1;
224 static int hf_ipv6_dstopts_len_oct = -1;
225 static int hf_ipv6_hopopts_nxt = -1;
226 static int hf_ipv6_hopopts_len = -1;
227 static int hf_ipv6_hopopts_len_oct = -1;
228 static int hf_ipv6_routing_nxt = -1;
229 static int hf_ipv6_routing_len = -1;
230 static int hf_ipv6_routing_len_oct = -1;
231 static int hf_ipv6_routing_type = -1;
232 static int hf_ipv6_routing_segleft = -1;
233 static int hf_ipv6_routing_unknown_data = -1;
234 static int hf_ipv6_fraghdr_nxt = -1;
235 static int hf_ipv6_fraghdr_reserved_octet = -1;
236 static int hf_ipv6_fraghdr_offset = -1;
237 static int hf_ipv6_fraghdr_reserved_bits = -1;
238 static int hf_ipv6_fraghdr_more = -1;
239 static int hf_ipv6_fraghdr_ident = -1;
240 static int hf_ipv6_fragment = -1;
241 static int hf_ipv6_fragment_overlap = -1;
242 static int hf_ipv6_fragment_overlap_conflict = -1;
243 static int hf_ipv6_fragment_multiple_tails = -1;
244 static int hf_ipv6_fragment_too_long_fragment = -1;
245 static int hf_ipv6_fragment_error = -1;
246 static int hf_ipv6_fragment_count = -1;
247 static int hf_ipv6_fragments = -1;
248 static int hf_ipv6_reassembled_in = -1;
249 static int hf_ipv6_reassembled_length = -1;
250 static int hf_ipv6_reassembled_data = -1;
251
252 static int hf_ipv6_routing_src_reserved = -1;
253 static int hf_ipv6_routing_src_addr = -1;
254
255 static int hf_ipv6_routing_mipv6_reserved = -1;
256 static int hf_ipv6_routing_mipv6_home_address = -1;
257
258 static int hf_ipv6_routing_rpl_cmprI = -1;
259 static int hf_ipv6_routing_rpl_cmprE = -1;
260 static int hf_ipv6_routing_rpl_pad = -1;
261 static int hf_ipv6_routing_rpl_reserved = -1;
262 static int hf_ipv6_routing_rpl_addr_count = -1;
263 static int hf_ipv6_routing_rpl_addr = -1;
264 static int hf_ipv6_routing_rpl_fulladdr = -1;
265
266 static int hf_ipv6_routing_srh_last_entry = -1;
267 static int hf_ipv6_routing_srh_flags = -1;
268 static int hf_ipv6_routing_srh_tag = -1;
269 static int hf_ipv6_routing_srh_addr = -1;
270
271 static int hf_ipv6_routing_crh16_current_sid = -1;
272 static int hf_ipv6_routing_crh32_current_sid = -1;
273 static int hf_ipv6_routing_crh16_segment_id = -1;
274 static int hf_ipv6_routing_crh32_segment_id = -1;
275
276 static int hf_geoip_country = -1;
277 static int hf_geoip_country_iso = -1;
278 static int hf_geoip_city = -1;
279 static int hf_geoip_as_number = -1;
280 static int hf_geoip_as_org = -1;
281 static int hf_geoip_latitude = -1;
282 static int hf_geoip_longitude = -1;
283 static int hf_geoip_src_summary = -1;
284 static int hf_geoip_src_country = -1;
285 static int hf_geoip_src_country_iso = -1;
286 static int hf_geoip_src_city = -1;
287 static int hf_geoip_src_as_number = -1;
288 static int hf_geoip_src_as_org = -1;
289 static int hf_geoip_src_latitude = -1;
290 static int hf_geoip_src_longitude = -1;
291 static int hf_geoip_dst_summary = -1;
292 static int hf_geoip_dst_country = -1;
293 static int hf_geoip_dst_country_iso = -1;
294 static int hf_geoip_dst_city = -1;
295 static int hf_geoip_dst_as_number = -1;
296 static int hf_geoip_dst_as_org = -1;
297 static int hf_geoip_dst_latitude = -1;
298 static int hf_geoip_dst_longitude = -1;
299
300 static gint ett_ipv6_proto = -1;
301 static gint ett_ipv6_traffic_class = -1;
302 static gint ett_ipv6_opt = -1;
303 static gint ett_ipv6_opt_type = -1;
304 static gint ett_ipv6_opt_rpl = -1;
305 static gint ett_ipv6_opt_mpl = -1;
306 static gint ett_ipv6_opt_dff_flags = -1;
307 static gint ett_ipv6_hopopts_proto = -1;
308 static gint ett_ipv6_fraghdr_proto = -1;
309 static gint ett_ipv6_routing_proto = -1;
310 static gint ett_ipv6_routing_srh_vect = -1;
311 static gint ett_ipv6_fragments = -1;
312 static gint ett_ipv6_fragment = -1;
313 static gint ett_ipv6_dstopts_proto = -1;
314
315 static gint ett_geoip_info = -1;
316
317 static expert_field ei_ipv6_routing_invalid_length = EI_INIT;
318 static expert_field ei_ipv6_routing_invalid_segleft = EI_INIT;
319 static expert_field ei_ipv6_routing_undecoded = EI_INIT;
320 static expert_field ei_ipv6_dst_addr_not_multicast = EI_INIT;
321 static expert_field ei_ipv6_src_route_list_mult_inst_same_addr = EI_INIT;
322 static expert_field ei_ipv6_src_route_list_src_addr = EI_INIT;
323 static expert_field ei_ipv6_src_route_list_dst_addr = EI_INIT;
324 static expert_field ei_ipv6_src_route_list_multicast_addr = EI_INIT;
325 static expert_field ei_ipv6_routing_rpl_cmpri_cmpre_pad = EI_INIT;
326 static expert_field ei_ipv6_routing_rpl_addr_count_ge0 = EI_INIT;
327 static expert_field ei_ipv6_routing_rpl_reserved = EI_INIT;
328 static expert_field ei_ipv6_routing_deprecated = EI_INIT;
329 static expert_field ei_ipv6_opt_jumbo_missing = EI_INIT;
330 static expert_field ei_ipv6_opt_jumbo_prohibited = EI_INIT;
331 static expert_field ei_ipv6_opt_jumbo_truncated = EI_INIT;
332 static expert_field ei_ipv6_opt_jumbo_fragment = EI_INIT;
333 static expert_field ei_ipv6_opt_invalid_len = EI_INIT;
334 static expert_field ei_ipv6_opt_unknown_data = EI_INIT;
335 static expert_field ei_ipv6_opt_deprecated = EI_INIT;
336 static expert_field ei_ipv6_opt_mpl_ipv6_src_seed_id = EI_INIT;
337 static expert_field ei_ipv6_hopopts_not_first = EI_INIT;
338 static expert_field ei_ipv6_plen_exceeds_framing = EI_INIT;
339 static expert_field ei_ipv6_plen_zero = EI_INIT;
340 static expert_field ei_ipv6_bogus_ipv6_version = EI_INIT;
341 static expert_field ei_ipv6_invalid_header = EI_INIT;
342 static expert_field ei_ipv6_opt_header_mismatch = EI_INIT;
343
344 static dissector_handle_t ipv6_handle;
345
346 #define set_address_ipv6(dst, src_ip6) \
347 set_address((dst), AT_IPv6, IPv6_ADDR_SIZE, (src_ip6))
348
349 #define set_address_ipv6_tvb(dst, tvb, offset) \
350 set_address_tvb((dst), AT_IPv6, IPv6_ADDR_SIZE, (tvb), (offset))
351
352 #define alloc_address_wmem_ipv6(scope, dst, src_ip6) \
353 alloc_address_wmem((scope), (dst), AT_IPv6, IPv6_ADDR_SIZE, (src_ip6))
354
355 #define alloc_address_tvb_ipv6(scope, dst, tvb, offset) \
356 alloc_address_tvb((scope), (dst), AT_IPv6, IPv6_ADDR_SIZE, (tvb), (offset))
357
358 extern const ws_in6_addr *tvb_get_ptr_ipv6(tvbuff_t tvb, int offset);
359 #define tvb_get_ptr_ipv6(tvb, offset) \
360 ((const ws_in6_addr *)tvb_get_ptr(tvb, offset, IPv6_ADDR_SIZE))
361
362 ipv6_pinfo_t *p_get_ipv6_pinfo(packet_info *pinfo)
363 {
364 return (ipv6_pinfo_t *)p_get_proto_data(pinfo->pool, pinfo, proto_ipv6, IPV6_PROTO_PINFO);
365 }
366
367 /* Return tree pointer (for tree root preference) */
368 proto_tree *p_ipv6_pinfo_select_root(packet_info *pinfo, proto_tree *tree)
369 {
370 ipv6_pinfo_t *p;
371
372 if ((p = p_get_ipv6_pinfo(pinfo)) != NULL && p->ipv6_tree != NULL)
373 return p->ipv6_tree;
374 return tree;
375 }
376
377 ipv6_pinfo_t *p_ipv6_pinfo_add_len(packet_info *pinfo, int exthdr_len)
378 {
379 ipv6_pinfo_t *p;
380
381 if ((p = p_get_ipv6_pinfo(pinfo)) == NULL)
382 return NULL;
383
384 p->frag_plen -= exthdr_len;
385 p->ipv6_item_len += exthdr_len;
386 return p;
387 }
388
389 static void p_add_ipv6_nxt(packet_info *pinfo, guint8 nxt)
390 {
391 guint8 *ptr;
392
393 ptr = (guint8 *)wmem_memdup(pinfo->pool, &nxt, sizeof(guint8));
394 p_add_proto_data(pinfo->pool, pinfo, proto_ipv6,
395 (pinfo->curr_layer_num<<8) | IPV6_PROTO_VALUE, ptr);
396 }
397
398 static guint8 *p_get_ipv6_nxt(packet_info *pinfo)
399 {
400 return (guint8 *)p_get_proto_data(pinfo->pool, pinfo, proto_ipv6,
401 (pinfo->curr_layer_num<<8) | IPV6_PROTO_VALUE);
402 }
403
404 static gpointer ipv6_value(packet_info *pinfo)
405 {
406 guint8 *nxt = p_get_ipv6_nxt(pinfo);
407
408 if (nxt == NULL) {
409 return GUINT_TO_POINTER(255); /* Reserved IP Protocol */
410 }
411 return GUINT_TO_POINTER((guint)*nxt);
412 }
413
414 static void ipv6_prompt(packet_info *pinfo, gchar *result)
415 {
416 gpointer value = ipv6_value(pinfo);
417
418 g_snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "IP protocol %u as", GPOINTER_TO_UINT(value));
419 }
420
421 static const char* ipv6_conv_get_filter_type(conv_item_t* conv, conv_filter_type_e filter)
422 {
423 if ((filter == CONV_FT_SRC_ADDRESS) && (conv->src_address.type == AT_IPv6))
424 return "ipv6.src";
425
426 if ((filter == CONV_FT_DST_ADDRESS) && (conv->dst_address.type == AT_IPv6))
427 return "ipv6.dst";
428
429 if ((filter == CONV_FT_ANY_ADDRESS) && (conv->src_address.type == AT_IPv6))
430 return "ipv6.addr";
431
432 return CONV_FILTER_INVALID;
433 }
434
435 static ct_dissector_info_t ipv6_ct_dissector_info = {&ipv6_conv_get_filter_type};
436
437 static tap_packet_status
438 ipv6_conversation_packet(void *pct, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip)
439 {
is_http_header(guint first_linelen,const guchar * first_line)440 conv_hash_t *hash = (conv_hash_t*) pct;
441 const ipv6_tap_info_t *ip6 = (const ipv6_tap_info_t *)vip;
442
443 add_conversation_table_data(hash, &ip6->ip6_src, &ip6->ip6_dst, 0, 0, 1,
444 pinfo->fd->pkt_len, &pinfo->rel_ts, &pinfo->abs_ts,
445 &ipv6_ct_dissector_info, ENDPOINT_NONE);
446
447 return TAP_PACKET_REDRAW;
448 }
449
450 static const char* ipv6_host_get_filter_type(hostlist_talker_t* host, conv_filter_type_e filter)
451 {
452 if ((filter == CONV_FT_ANY_ADDRESS) && (host->myaddress.type == AT_IPv6))
ippusb_shutdown(void)453 return "ipv6.addr";
454
455 return CONV_FILTER_INVALID;
456 }
457
proto_register_ippusb(void)458 static hostlist_dissector_info_t ipv6_host_dissector_info = {&ipv6_host_get_filter_type};
459
460 static tap_packet_status
461 ipv6_hostlist_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, const void *vip)
462 {
463 conv_hash_t *hash = (conv_hash_t*) pit;
464 const ipv6_tap_info_t *ip6 = (const ipv6_tap_info_t *)vip;
465
466 add_hostlist_table_data(hash, &ip6->ip6_src, 0, TRUE, 1,
467 pinfo->fd->pkt_len, &ipv6_host_dissector_info, ENDPOINT_NONE);
468 add_hostlist_table_data(hash, &ip6->ip6_dst, 0, FALSE, 1,
469 pinfo->fd->pkt_len, &ipv6_host_dissector_info, ENDPOINT_NONE);
470
471 return TAP_PACKET_REDRAW;
472 }
473
474 static gboolean
475 ipv6_filter_valid(packet_info *pinfo)
476 {
477 return proto_is_frame_protocol(pinfo->layers, "ipv6");
478 }
479
480 static gchar*
481 ipv6_build_filter(packet_info *pinfo)
482 {
483 return g_strdup_printf("ipv6.addr eq %s and ipv6.addr eq %s",
484 address_to_str(pinfo->pool, &pinfo->net_src),
485 address_to_str(pinfo->pool, &pinfo->net_dst));
486 }
487
488 static gint
489 ipv6_previous_layer_id(packet_info *pinfo)
490 {
491 wmem_list_frame_t *layer;
492
493 layer = wmem_list_tail(pinfo->layers);
494 DISSECTOR_ASSERT(layer);
495 layer = wmem_list_frame_prev(layer);
496 if (layer != NULL) {
497 return GPOINTER_TO_INT(wmem_list_frame_data(layer));
498 }
499 return -1;
500 }
501
502 static const fragment_items ipv6_frag_items = {
503 &ett_ipv6_fragment,
504 &ett_ipv6_fragments,
505 &hf_ipv6_fragments,
506 &hf_ipv6_fragment,
507 &hf_ipv6_fragment_overlap,
508 &hf_ipv6_fragment_overlap_conflict,
509 &hf_ipv6_fragment_multiple_tails,
510 &hf_ipv6_fragment_too_long_fragment,
511 &hf_ipv6_fragment_error,
512 &hf_ipv6_fragment_count,
513 &hf_ipv6_reassembled_in,
514 &hf_ipv6_reassembled_length,
515 &hf_ipv6_reassembled_data,
516 "IPv6 fragments"
517 };
518
519 static dissector_table_t ip_dissector_table;
520 static dissector_table_t ipv6_routing_dissector_table;
521
522 /* Reassemble fragmented datagrams */
523 static gboolean ipv6_reassemble = TRUE;
524
525 /* Place IPv6 summary in proto tree */
526 static gboolean ipv6_summary_in_tree = TRUE;
527
528 /* Look up addresses via mmdbresolve */
529 static gboolean ipv6_use_geoip = TRUE;
530
531 /* Perform strict RFC adherence checking */
proto_reg_handoff_ippusb(void)532 static gboolean g_ipv6_rpl_srh_strict_rfc_checking = FALSE;
533
534 /* Use heuristics to determine subdissector */
535 static gboolean try_heuristic_first = FALSE;
536
537 /* Display IPv6 extension headers under the root tree */
538 static gboolean ipv6_exthdr_under_root = FALSE;
539
540 /* Hide extension header generated field for length */
541 static gboolean ipv6_exthdr_hide_len_oct_field = FALSE;
542
543 /* Assume TSO and correct zero-length IP packets */
544 static gboolean ipv6_tso_supported = FALSE;
545
546 /*
547 * defragmentation of IPv6
548 */
549 static reassembly_table ipv6_reassembly_table;
550
551 /* http://www.iana.org/assignments/ipv6-parameters (last updated 2015-07-07) */
552 static const value_string ipv6_opt_type_vals[] = {
553 { IP6OPT_PAD1, "Pad1" },
554 { IP6OPT_PADN, "PadN" },
555 { IP6OPT_TEL, "Tunnel Encapsulation Limit" },
556 { IP6OPT_RTALERT, "Router Alert" },
557 { IP6OPT_CALIPSO, "CALIPSO" },
558 { IP6OPT_SMF_DPD, "SMF_DPD" },
559 { IP6OPT_PDM, "Performance and Diagnostic Metrics" },
560 { IP6OPT_EXP_1E, "Experimental (0x1E)" },
561 { IP6OPT_QUICKSTART, "Quick-Start" },
562 { IP6OPT_PMTU, "Path MTU Option" },
563 { IP6OPT_EXP_3E, "Experimental (0x3E)" },
564 { IP6OPT_TPF, "Tunnel Payload Forwarding (TPF) Information" },
565 { IP6OPT_EXP_5E, "Experimental (0x5E)" },
566 { IP6OPT_RPL, "RPL Option" },
567 { IP6OPT_MPL, "MPL Option" },
568 { IP6OPT_EXP_7E, "Experimental (0x7E)" },
569 { IP6OPT_ENDI, "Endpoint Identification" },
570 { IP6OPT_ILNP_NONCE, "ILNP Nonce" },
571 { IP6OPT_LIO, "Line-Identification Option" },
572 { IP6OPT_EXP_9E, "Experimental (0x9E)" },
573 { IP6OPT_EXP_BE, "Experimental (0xBE)" },
574 { IP6OPT_JUMBO, "Jumbo Payload" },
575 { IP6OPT_HOME_ADDRESS, "Home Address" },
576 { IP6OPT_EXP_DE, "Experimental (0xDE)" },
577 { IP6OPT_IP_DFF, "IP_DFF" },
578 { IP6OPT_EXP_FE, "Experimental (0xFE)" },
579 { 0, NULL }
580 };
581 static value_string_ext ipv6_opt_type_vals_ext = VALUE_STRING_EXT_INIT(ipv6_opt_type_vals);
582
583 static const value_string ipv6_opt_rtalert_vals[] = {
584 { IP6OPT_RTALERT_MLD, "MLD" },
585 { IP6OPT_RTALERT_RSVP, "RSVP" },
586 { IP6OPT_RTALERT_ACTNET, "Active Network" },
587 { 0, NULL }
588 };
589
590 enum {
591 IP6OPT_SMF_DPD_NULL = 0,
592 IP6OPT_SMF_DPD_DFLT,
593 IP6OPT_SMF_DPD_IPv4,
594 IP6OPT_SMF_DPD_IPv6
595 };
596
597 static const value_string ipv6_opt_smf_dpd_tidty_vals[] = {
598 { IP6OPT_SMF_DPD_NULL, "NULL" },
599 { IP6OPT_SMF_DPD_DFLT, "DEFAULT" },
600 { IP6OPT_SMF_DPD_IPv4, "IPv4" },
601 { IP6OPT_SMF_DPD_IPv6, "IPv6" },
602 { 0, NULL }
603 };
604
605 enum {
606 IPv6_OPT_ACTION_SKIP = 0,
607 IPv6_OPT_ACTION_DISC,
608 IPv6_OPT_ACTION_ICMP,
609 IPv6_OPT_ACTION_MCST,
610 };
611
612 static const value_string ipv6_opt_type_action_vals[] = {
613 { IPv6_OPT_ACTION_SKIP, "Skip and continue" },
614 { IPv6_OPT_ACTION_DISC, "Discard" },
615 { IPv6_OPT_ACTION_ICMP, "Discard and send ICMP Parameter Problem" },
616 { IPv6_OPT_ACTION_MCST, "Discard and send ICMP if not multicast" },
617 { 0, NULL }
618 };
619
620 enum {
621 IPv6_OPT_HDR_HBH = 0,
622 IPv6_OPT_HDR_DST,
623 IPv6_OPT_HDR_ANY
624 };
625
626 static const gint _ipv6_opt_type_hdr[][2] = {
627 { IP6OPT_TEL, IPv6_OPT_HDR_DST },
628 { IP6OPT_RTALERT, IPv6_OPT_HDR_HBH },
629 { IP6OPT_PMTU, IPv6_OPT_HDR_HBH },
630 { IP6OPT_CALIPSO, IPv6_OPT_HDR_HBH },
631 { IP6OPT_SMF_DPD, IPv6_OPT_HDR_HBH },
632 { IP6OPT_PDM, IPv6_OPT_HDR_DST },
633 { IP6OPT_QUICKSTART, IPv6_OPT_HDR_HBH },
634 { IP6OPT_TPF, IPv6_OPT_HDR_DST },
635 { IP6OPT_RPL, IPv6_OPT_HDR_HBH },
636 { IP6OPT_MPL, IPv6_OPT_HDR_HBH },
637 { IP6OPT_ILNP_NONCE, IPv6_OPT_HDR_DST },
638 { IP6OPT_LIO, IPv6_OPT_HDR_DST },
639 { IP6OPT_JUMBO, IPv6_OPT_HDR_HBH },
640 { IP6OPT_HOME_ADDRESS, IPv6_OPT_HDR_DST },
641 { IP6OPT_IP_DFF, IPv6_OPT_HDR_HBH },
642 { 0, IPv6_OPT_HDR_ANY }
643 };
644
645 static inline gint
646 ipv6_opt_type_hdr(gint type)
647 {
648 const gint (*p)[2] = _ipv6_opt_type_hdr;
649
650 for (; (*p)[1] != IPv6_OPT_HDR_ANY; p++) {
651 if ((*p)[0] == type) {
652 return (*p)[1];
653 }
654 }
655 return IPv6_OPT_HDR_ANY;
656 }
657
658 enum {
659 IPv6_RT_HEADER_SOURCE_ROUTING = 0, /* DEPRECATED */
660 IPv6_RT_HEADER_NIMROD = 1, /* DEPRECATED */
661 IPv6_RT_HEADER_MOBILE_IP = 2,
662 IPv6_RT_HEADER_RPL = 3,
663 IPv6_RT_HEADER_SEGMENT_ROUTING = 4,
664 IPv6_RT_HEADER_COMPACT_16 = 5,
665 IPv6_RT_HEADER_COMPACT_32 = 6,
666 IPv6_RT_HEADER_EXP1 = 253,
667 IPv6_RT_HEADER_EXP2 = 254
668 };
669
670 /* Routing Header Types */
671 static const value_string routing_header_type[] = {
672 { IPv6_RT_HEADER_SOURCE_ROUTING, "Source Route" },
673 { IPv6_RT_HEADER_NIMROD, "Nimrod" },
674 { IPv6_RT_HEADER_MOBILE_IP, "Type 2 Routing" },
675 { IPv6_RT_HEADER_RPL, "RPL Source Route" },
676 { IPv6_RT_HEADER_SEGMENT_ROUTING, "Segment Routing" },
677 { IPv6_RT_HEADER_COMPACT_16, "Compact Routing Header 16" },
678 { IPv6_RT_HEADER_COMPACT_32, "Compact Routing Header 32" },
679 { IPv6_RT_HEADER_EXP1, "Experiment 1" },
680 { IPv6_RT_HEADER_EXP2, "Experiment 2" },
681 { 0, NULL }
682 };
683
684 static const value_string mpl_seed_id_len_vals[] = {
685 { 0, "0" },
686 { 1, "16-bit unsigned integer" },
687 { 2, "64-bit unsigned integer" },
688 { 3, "128-bit unsigned integer" },
689 { 0, NULL }
690 };
691
692 static gboolean
693 capture_ipv6(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
694 {
695 guint8 nxt;
696
697 if (!BYTES_ARE_IN_FRAME(offset, len, IPv6_HDR_SIZE))
698 return FALSE;
699
700 capture_dissector_increment_count(cpinfo, proto_ipv6);
701
702 nxt = pd[offset+6]; /* get the "next header" value */
703 offset += IPv6_HDR_SIZE; /* skip past the IPv6 header */
704
705 return try_capture_dissector("ip.proto", nxt, pd, offset, len, cpinfo, pseudo_header);
706 }
707
708 static gboolean
709 capture_ipv6_exthdr(const guchar *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
710 {
711 guint8 nxt;
712 int advance;
713
714 if (!BYTES_ARE_IN_FRAME(offset, len, 2))
715 return FALSE;
716 nxt = pd[offset];
717 switch (nxt) {
718 case IP_PROTO_FRAGMENT:
719 advance = IPv6_FRAGMENT_HDR_SIZE;
720 break;
721 default:
722 advance = (pd[offset+1] + 1) << 3;
723 break;
724 }
725 if (!BYTES_ARE_IN_FRAME(offset, len, advance))
726 return FALSE;
727 offset += advance;
728
729 return try_capture_dissector("ip.proto", nxt, pd, offset, len, cpinfo, pseudo_header);
730 }
731
732 static void
733 add_geoip_info_entry(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, const ws_in6_addr *ip6, int isdst)
734 {
735 const mmdb_lookup_t *lookup = maxmind_db_lookup_ipv6(ip6);
736 if (!lookup->found) return;
737
738 wmem_strbuf_t *summary = wmem_strbuf_new(pinfo->pool, "");
739 if (lookup->city) {
740 wmem_strbuf_append(summary, lookup->city);
741 }
742 if (lookup->country_iso) {
743 if (wmem_strbuf_get_len(summary) > 0) wmem_strbuf_append(summary, ", ");
744 wmem_strbuf_append(summary, lookup->country_iso);
745 } else if (lookup->country) {
746 if (wmem_strbuf_get_len(summary) > 0) wmem_strbuf_append(summary, ", ");
747 wmem_strbuf_append(summary, lookup->country);
748 }
749 if (lookup->as_number > 0) {
750 if (wmem_strbuf_get_len(summary) > 0) wmem_strbuf_append(summary, ", ");
751 wmem_strbuf_append_printf(summary, "ASN %u", lookup->as_number);
752 }
753 if (lookup->as_org) {
754 if (wmem_strbuf_get_len(summary) > 0) wmem_strbuf_append(summary, ", ");
755 wmem_strbuf_append(summary, lookup->as_org);
756 }
757
758 int addr_offset = offset + isdst ? IP6H_DST : IP6H_SRC;
759 int dir_hf = isdst ? hf_geoip_dst_summary : hf_geoip_src_summary;
760 proto_item *geoip_info_item = proto_tree_add_string(tree, dir_hf, tvb, addr_offset, 16, wmem_strbuf_finalize(summary));
761 proto_item_set_generated(geoip_info_item);
762 proto_tree *geoip_info_tree = proto_item_add_subtree(geoip_info_item, ett_geoip_info);
763
764 proto_item *item;
765
766 if (lookup->city) {
767 dir_hf = isdst ? hf_geoip_dst_city : hf_geoip_src_city;
768 item = proto_tree_add_string(geoip_info_tree, dir_hf, tvb, addr_offset, 16, lookup->city);
769 proto_item_set_generated(item);
770 item = proto_tree_add_string(geoip_info_tree, hf_geoip_city, tvb, addr_offset, 16, lookup->city);
771 proto_item_set_generated(item);
772 }
773
774 if (lookup->country) {
775 dir_hf = isdst ? hf_geoip_dst_country : hf_geoip_src_country;
776 item = proto_tree_add_string(geoip_info_tree, dir_hf, tvb, addr_offset, 16, lookup->country);
777 proto_item_set_generated(item);
778 item = proto_tree_add_string(geoip_info_tree, hf_geoip_country, tvb, addr_offset, 16, lookup->country);
779 proto_item_set_generated(item);
780 }
781
782 if (lookup->country_iso) {
783 dir_hf = isdst ? hf_geoip_dst_country_iso : hf_geoip_src_country_iso;
784 item = proto_tree_add_string(geoip_info_tree, dir_hf, tvb, addr_offset, 16, lookup->country_iso);
785 proto_item_set_generated(item);
786 item = proto_tree_add_string(geoip_info_tree, hf_geoip_country_iso, tvb, addr_offset, 16, lookup->country_iso);
787 proto_item_set_generated(item);
788 }
789
790 if (lookup->as_number > 0) {
791 dir_hf = isdst ? hf_geoip_dst_as_number : hf_geoip_src_as_number;
792 item = proto_tree_add_uint(geoip_info_tree, dir_hf, tvb, addr_offset, 16, lookup->as_number);
793 proto_item_set_generated(item);
794 item = proto_tree_add_uint(geoip_info_tree, hf_geoip_as_number, tvb, addr_offset, 16, lookup->as_number);
795 proto_item_set_generated(item);
796 }
797
798 if (lookup->as_org) {
799 dir_hf = isdst ? hf_geoip_dst_as_org : hf_geoip_src_as_org;
800 item = proto_tree_add_string(geoip_info_tree, dir_hf, tvb, addr_offset, 16, lookup->as_org);
801 proto_item_set_generated(item);
802 item = proto_tree_add_string(geoip_info_tree, hf_geoip_as_org, tvb, addr_offset, 16, lookup->as_org);
803 proto_item_set_generated(item);
804 }
805
806 if (lookup->latitude >= -90.0 && lookup->latitude <= 90.0) {
807 dir_hf = isdst ? hf_geoip_dst_latitude : hf_geoip_src_latitude;
808 item = proto_tree_add_double(geoip_info_tree, dir_hf, tvb, addr_offset, 16, lookup->latitude);
809 proto_item_set_generated(item);
810 item = proto_tree_add_double(geoip_info_tree, hf_geoip_latitude, tvb, addr_offset, 16, lookup->latitude);
811 proto_item_set_generated(item);
812 }
813
814 if (lookup->longitude >= -180.0 && lookup->longitude <= 180.0) {
815 dir_hf = isdst ? hf_geoip_dst_longitude : hf_geoip_src_longitude;
816 item = proto_tree_add_double(geoip_info_tree, dir_hf, tvb, addr_offset, 16, lookup->longitude);
817 proto_item_set_generated(item);
818 item = proto_tree_add_double(geoip_info_tree, hf_geoip_longitude, tvb, addr_offset, 16, lookup->longitude);
819 proto_item_set_generated(item);
820 }
821 }
822
823 static void
824 add_geoip_info(proto_tree *tree, packet_info *pinfo, tvbuff_t *tvb, gint offset, const ws_in6_addr *src, const ws_in6_addr *dst)
825 {
826 add_geoip_info_entry(tree, pinfo, tvb, offset, src, FALSE);
827 add_geoip_info_entry(tree, pinfo, tvb, offset, dst, TRUE);
828 }
829
830 /* Returns TRUE if reassembled */
831 static gboolean
832 ipv6_reassemble_do(tvbuff_t **tvb_ptr, gint *offset_ptr, packet_info *pinfo, proto_tree *ipv6_tree,
833 guint32 plen, guint16 frag_off, gboolean frag_flg, guint32 frag_ident,
834 gboolean *show_data_ptr)
835 {
836 fragment_head *ipfd_head;
837 tvbuff_t *next_tvb;
838 gboolean update_col_info = TRUE;
839
840 pinfo->fragmented = TRUE;
841 *show_data_ptr = TRUE;
842 if (!ipv6_reassemble) {
843 /* not reassembling */
844 if (frag_off == 0) {
845 /* first fragment */
846 *show_data_ptr = FALSE;
847 }
848 return FALSE;
849 }
850
851 /* reassembling */
852 if (tvb_bytes_exist(*tvb_ptr, *offset_ptr, plen)) {
853 ipfd_head = fragment_add_check(&ipv6_reassembly_table,
854 *tvb_ptr, *offset_ptr, pinfo, frag_ident, NULL,
855 frag_off, plen, frag_flg);
856 next_tvb = process_reassembled_data(*tvb_ptr, *offset_ptr, pinfo, "Reassembled IPv6",
857 ipfd_head, &ipv6_frag_items, &update_col_info, ipv6_tree);
858 if (next_tvb) {
859 /* Process post-fragment headers after reassembly */
860 *offset_ptr = 0;
861 *tvb_ptr = next_tvb;
862 pinfo->fragmented = FALSE;
863 *show_data_ptr = FALSE;
864 return TRUE;
865 }
866 }
867 return FALSE;
868 }
869
870 static proto_item *
871 _proto_tree_add_ipv6_vector_address(proto_tree *tree, packet_info *pinfo, int hfindex, tvbuff_t *tvb, gint start,
872 gint length, const ws_in6_addr *value_ptr, int idx)
873 {
874 address addr;
875 gchar *str;
876
877 set_address_ipv6(&addr, value_ptr);
878 str = address_with_resolution_to_str(pinfo->pool, &addr);
879 return proto_tree_add_ipv6_format(tree, hfindex, tvb, start, length,
880 value_ptr, "Address[%d]: %s", idx, str);
881 }
882
883 /* IPv6 Source Routing Header (Type 0) */
884 static int
885 dissect_routing6_rt0(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
886 {
887 struct ws_rthdr *rt = (struct ws_rthdr *)data;
888 proto_item *ti;
889 int offset = 0;
890 gint idx;
891 gint rt0_addr_count;
892 const ws_in6_addr *addr = NULL;
893
894 proto_tree_add_item(tree, hf_ipv6_routing_src_reserved, tvb, offset, 4, ENC_NA);
895 offset += 4;
896
897 if (rt->hdr.ip6r_len % 2 != 0) {
898 expert_add_info_format(pinfo, rt->ti_len, &ei_ipv6_routing_invalid_length,
899 "IPv6 Routing Header extension header length must not be odd");
900 }
901 rt0_addr_count = rt->hdr.ip6r_len / 2;
902 if (rt->hdr.ip6r_segleft > rt0_addr_count) {
903 expert_add_info_format(pinfo, rt->ti_segleft, &ei_ipv6_routing_invalid_segleft,
904 "IPv6 Type 0 Routing Header segments left field must not exceed address count (%u)", rt0_addr_count);
905 }
906
907 for (idx = 1; idx <= rt0_addr_count; idx++) {
908 addr = tvb_get_ptr_ipv6(tvb, offset);
909 ti = _proto_tree_add_ipv6_vector_address(tree, pinfo, hf_ipv6_routing_src_addr, tvb,
910 offset, IPv6_ADDR_SIZE, addr, idx);
911 offset += IPv6_ADDR_SIZE;
912 if (in6_addr_is_multicast(addr)) {
913 expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_multicast_addr);
914 }
915 }
916
917 if (addr != NULL && pinfo->dst.type == AT_IPv6 && rt->hdr.ip6r_segleft > 0) {
918 alloc_address_wmem_ipv6(pinfo->pool, &pinfo->dst, addr);
919 }
920
921 expert_add_info(pinfo, rt->ti_type, &ei_ipv6_routing_deprecated);
922 return tvb_captured_length(tvb);
923 }
924
925 /* Mobile IPv6 Routing Header (Type 2) */
926 static int
927 dissect_routing6_mipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
928 {
929 struct ws_rthdr *rt = (struct ws_rthdr *)data;
930 proto_item *ti;
931 int offset = 0;
932 const ws_in6_addr *addr;
933
934 proto_tree_add_item(tree, hf_ipv6_routing_mipv6_reserved, tvb, offset, 4, ENC_NA);
935 offset += 4;
936
937 if (rt->hdr.ip6r_len != 2) {
938 expert_add_info_format(pinfo, rt->ti_len, &ei_ipv6_routing_invalid_length,
939 "IPv6 Type 2 Routing Header extension header length must equal 2");
940 }
941 if (rt->hdr.ip6r_segleft != 1) {
942 expert_add_info_format(pinfo, rt->ti_segleft, &ei_ipv6_routing_invalid_segleft,
943 "IPv6 Type 2 Routing Header segments left field must equal 1");
944 }
945
946 addr = tvb_get_ptr_ipv6(tvb, offset);
947 ti = _proto_tree_add_ipv6_vector_address(tree, pinfo, hf_ipv6_routing_mipv6_home_address, tvb,
948 offset, IPv6_ADDR_SIZE, addr, 1);
949 if (in6_addr_is_multicast(addr)) {
950 expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_multicast_addr);
951 }
952
953 if (pinfo->dst.type == AT_IPv6 && rt->hdr.ip6r_segleft > 0) {
954 alloc_address_wmem_ipv6(pinfo->pool, &pinfo->dst, addr);
955 }
956
957 return tvb_captured_length(tvb);
958 }
959
960 /* RPL Source Routing Header (Type 3) */
961 static int
962 dissect_routing6_rpl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
963 {
964 struct ws_rthdr *rt = (struct ws_rthdr *)data;
965 proto_item *ti;
966 int offset = 0;
967 guint8 cmprI, cmprE, cmprX, pad;
968 guint32 reserved;
969 gint idx;
970 gint rpl_addr_count;
971 ws_in6_addr rpl_fulladdr;
972 const ws_in6_addr *ip6_dst_addr, *ip6_src_addr;
973 wmem_array_t *rpl_addr_vector = NULL;
974 guint i;
975
976 /* Must be IPv6 addresses */
977 if ((pinfo->dst.type != AT_IPv6) || (pinfo->src.type != AT_IPv6))
978 return 0;
979
980 /* IPv6 destination address used for elided bytes */
981 ip6_dst_addr = (const ws_in6_addr *)pinfo->dst.data;
982 /* IPv6 source address used for strict checking */
983 ip6_src_addr = (const ws_in6_addr *)pinfo->src.data;
984
985 /* from RFC6554: Multicast addresses MUST NOT appear in the IPv6 Destination Address field */
986 if (in6_addr_is_multicast(ip6_dst_addr)) {
987 expert_add_info(pinfo, proto_tree_get_parent(tree), &ei_ipv6_dst_addr_not_multicast);
988 }
989
990 proto_tree_add_item(tree, hf_ipv6_routing_rpl_cmprI, tvb, offset, 4, ENC_BIG_ENDIAN);
991 proto_tree_add_item(tree, hf_ipv6_routing_rpl_cmprE, tvb, offset, 4, ENC_BIG_ENDIAN);
992 ti = proto_tree_add_item(tree, hf_ipv6_routing_rpl_pad, tvb, offset, 4, ENC_BIG_ENDIAN);
993
994 cmprI = tvb_get_guint8(tvb, offset) & 0xF0;
995 cmprE = tvb_get_guint8(tvb, offset) & 0x0F;
996 pad = tvb_get_guint8(tvb, offset + 1) & 0xF0;
997
998 /* Shift bytes over */
999 cmprI >>= 4;
1000 pad >>= 4;
1001
1002 /* from RFC6554: when CmprI and CmprE are both 0, Pad MUST carry a value of 0 */
1003 if (cmprI == 0 && cmprE == 0 && pad != 0) {
1004 expert_add_info_format(pinfo, ti, &ei_ipv6_routing_rpl_cmpri_cmpre_pad, "When cmprI equals 0 and cmprE equals 0, pad MUST equal 0 but instead was %d", pad);
1005 }
1006
1007 ti = proto_tree_add_item(tree, hf_ipv6_routing_rpl_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
1008 reserved = tvb_get_bits32(tvb, ((offset + 1) * 8) + 4, 20, ENC_BIG_ENDIAN);
1009
1010 if (reserved != 0) {
1011 expert_add_info_format(pinfo, ti, &ei_ipv6_routing_rpl_reserved, "Reserved field must equal 0 but instead was %d", reserved);
1012 }
1013
1014 /* From RFC6554:
1015 * n = (((Hdr Ext Len * 8) - Pad - (16 - CmprE)) / (16 - CmprI)) + 1
1016 */
1017 rpl_addr_count = 0;
1018 if (rt->hdr.ip6r_len > 0) {
1019 rpl_addr_count = (((rt->hdr.ip6r_len * 8) - pad - (16 - cmprE)) / (16 - cmprI)) + 1;
1020 }
1021 ti = proto_tree_add_int(tree, hf_ipv6_routing_rpl_addr_count, tvb, offset, 2, rpl_addr_count);
1022 proto_item_set_generated(ti);
1023 if (rpl_addr_count < 0) {
1024 /* This error should always be reported */
1025 expert_add_info_format(pinfo, ti, &ei_ipv6_routing_rpl_addr_count_ge0, "Calculated total address count must be greater than or equal to 0, instead was %d", rpl_addr_count);
1026 }
1027 else if (rt->hdr.ip6r_segleft > (guint)rpl_addr_count) {
1028 expert_add_info_format(pinfo, rt->ti_segleft, &ei_ipv6_routing_invalid_segleft,
1029 "IPv6 RPL Routing Header segments left field must not exceed address count (%d)", rpl_addr_count);
1030 }
1031
1032 if (rpl_addr_count > 0) {
1033 offset += 4;
1034
1035 if (g_ipv6_rpl_srh_strict_rfc_checking)
1036 rpl_addr_vector = wmem_array_sized_new(pinfo->pool, IPv6_ADDR_SIZE, rpl_addr_count);
1037
1038 /* We use cmprI for internal (e.g.: not last) address for how many bytes to elide, so actual bytes present = 16-CmprI */
1039 for (idx = 1; idx <= rpl_addr_count; idx++) {
1040 if (idx == rpl_addr_count)
1041 cmprX = 16 - cmprE;
1042 else
1043 cmprX = 16 - cmprI;
1044 proto_tree_add_item(tree, hf_ipv6_routing_rpl_addr, tvb, offset, cmprX, ENC_NA);
1045 /* Display Full Address */
1046 memcpy(&rpl_fulladdr, ip6_dst_addr, IPv6_ADDR_SIZE);
1047 tvb_memcpy(tvb, &rpl_fulladdr.bytes[16-cmprX], offset, cmprX);
1048 ti = _proto_tree_add_ipv6_vector_address(tree, pinfo, hf_ipv6_routing_rpl_fulladdr, tvb,
1049 offset, cmprX, &rpl_fulladdr, idx);
1050 proto_item_set_generated(ti);
1051 offset += cmprX;
1052
1053 /* IPv6 Source and Destination addresses of the encapsulating datagram (MUST) not appear in the SRH*/
1054 if (memcmp(&rpl_fulladdr, ip6_src_addr, IPv6_ADDR_SIZE) == 0) {
1055 expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_src_addr);
1056 }
1057 if (memcmp(&rpl_fulladdr, ip6_dst_addr, IPv6_ADDR_SIZE) == 0) {
1058 expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_dst_addr);
1059 }
1060
1061 /* Multicast addresses MUST NOT appear in the in SRH */
1062 if (in6_addr_is_multicast(&rpl_fulladdr)) {
1063 expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_multicast_addr);
1064 }
1065
1066 if (g_ipv6_rpl_srh_strict_rfc_checking) {
1067 /* from RFC6554: */
1068 /* The SRH MUST NOT specify a path that visits a node more than once. */
1069 /* To do this, we will just check the current 'addr' against the previous addresses */
1070 for (i = 0; i < wmem_array_get_count(rpl_addr_vector); i++) {
1071 /* Compare the addresses */
1072 if (memcmp(&rpl_fulladdr, wmem_array_index(rpl_addr_vector, i), IPv6_ADDR_SIZE) == 0) {
1073 /* Found a previous that is the same */
1074 expert_add_info(pinfo, ti, &ei_ipv6_src_route_list_mult_inst_same_addr);
1075 break;
1076 }
1077 }
1078 wmem_array_append(rpl_addr_vector, &rpl_fulladdr, 1);
1079 }
1080
1081 if (pinfo->dst.type == AT_IPv6 && rt->hdr.ip6r_segleft > 0) {
1082 alloc_address_wmem_ipv6(pinfo->pool, &pinfo->dst, &rpl_fulladdr);
1083 }
1084 }
1085 }
1086
1087 return tvb_captured_length(tvb);
1088 }
1089
1090 /* Segment Routing Header (Type 4) */
1091 static int
1092 dissect_routing6_srh(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
1093 {
1094 struct ws_rthdr *rt = (struct ws_rthdr *)data;
1095 int offset = 0;
1096 gint addr_offset;
1097 guint32 last_entry, addr_count;
1098
1099 proto_tree_add_item_ret_uint(tree, hf_ipv6_routing_srh_last_entry,
1100 tvb, offset, 1, ENC_BIG_ENDIAN,
1101 &last_entry);
1102 addr_count = last_entry + 1;
1103 offset += 1;
1104
1105 proto_tree_add_item(tree, hf_ipv6_routing_srh_flags, tvb, offset, 1, ENC_BIG_ENDIAN);
1106 offset += 1;
1107
1108 proto_tree_add_item(tree, hf_ipv6_routing_srh_tag, tvb, offset, 2, ENC_NA);
1109 offset += 2;
1110
1111 if (rt->hdr.ip6r_segleft > addr_count) {
1112 expert_add_info_format(pinfo, rt->ti_segleft, &ei_ipv6_routing_invalid_segleft,
1113 "IPv6 Type 4 Routing Header segments left field must not exceed address count (%u)", addr_count);
1114 }
1115
1116 if (pinfo->dst.type == AT_IPv6 && rt->hdr.ip6r_segleft > 0) {
1117 alloc_address_wmem_ipv6(pinfo->pool, &pinfo->dst, tvb_get_ptr_ipv6(tvb, offset));
1118 }
1119
1120 for (unsigned i = 0; i < addr_count; i++) {
1121 addr_offset = offset + i * IPv6_ADDR_SIZE;
1122 _proto_tree_add_ipv6_vector_address(tree, pinfo, hf_ipv6_routing_srh_addr, tvb,
1123 addr_offset, IPv6_ADDR_SIZE, tvb_get_ptr_ipv6(tvb, addr_offset), i);
1124 }
1125
1126 /* TODO: dissect TLVs */
1127
1128 return tvb_captured_length(tvb);
1129 }
1130
1131 /* Compact Routing Header 16 (Type 5) and Compact Routing Header 32 (Type 6).
1132 https://tools.ietf.org/html/draft-bonica-6man-comp-rtg-hdr-23. */
1133 static int dissect_routing6_crh(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data)
1134 {
1135 int offset, minimum_crh_length;
1136 gint sid;
1137
1138 unsigned sid_count;
1139 unsigned octets_per_sid;
1140 unsigned sids_beyond_first_word;
1141 unsigned sids_per_word;
1142 struct ws_rthdr* rt = (struct ws_rthdr*)data;
1143 gboolean is_crh16 = rt->hdr.ip6r_type == IPv6_RT_HEADER_COMPACT_16;
1144 guint8 segments_left = rt->hdr.ip6r_segleft;
1145
1146 /* Compute the minimum CRH length measured in 8-octet units, not including
1147 the first 8 octets */
1148 minimum_crh_length = -1;
1149 switch (rt->hdr.ip6r_type) {
1150 case IPv6_RT_HEADER_COMPACT_16:
1151 octets_per_sid = 2;
1152 sids_per_word = 4;
1153 sid_count = rt->hdr.ip6r_len * 4 + 2;
1154 if (segments_left <= 2)
1155 minimum_crh_length = 0;
1156 sids_beyond_first_word = segments_left - 2;
1157 break;
1158 case IPv6_RT_HEADER_COMPACT_32:
1159 octets_per_sid = 4;
1160 sids_per_word = 2;
1161 sid_count = rt->hdr.ip6r_len * 2 + 1;
1162 if (segments_left <= 1)
1163 minimum_crh_length = 0;
1164 sids_beyond_first_word = segments_left - 1;
1165 break;
1166 default:
1167 DISSECTOR_ASSERT_NOT_REACHED();
1168 }
1169 if (minimum_crh_length) {
1170 minimum_crh_length = sids_beyond_first_word / sids_per_word;
1171 if (sids_beyond_first_word % sids_per_word)
1172 minimum_crh_length++;
1173 }
1174 if (minimum_crh_length > rt->hdr.ip6r_len) {
1175 expert_add_info_format(pinfo, rt->ti_len, &ei_ipv6_routing_invalid_length,
1176 "IPv6 Compact Routing Header minimum length must not exceed header length (%u)",
1177 rt->hdr.ip6r_len);
1178 }
1179
1180 offset = 0;
1181 if (is_crh16) {
1182 proto_item* current_sid_item = proto_tree_add_item(tree, hf_ipv6_routing_crh16_current_sid,
1183 tvb, offset + (octets_per_sid * segments_left), octets_per_sid, ENC_BIG_ENDIAN);
1184 proto_item_set_generated(current_sid_item);
1185 } else {
1186 proto_item* current_sid_item = proto_tree_add_item(tree, hf_ipv6_routing_crh32_current_sid,
1187 tvb, offset + (octets_per_sid * segments_left), octets_per_sid, ENC_BIG_ENDIAN);
1188 proto_item_set_generated(current_sid_item);
1189 }
1190 sid = is_crh16 ? tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN)
1191 : tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
1192 proto_tree* segment_ids
1193 = proto_tree_add_subtree(tree, tvb, 0, -1, 0, NULL, "Segment Identifiers");
1194 for (unsigned i = 0; i < sid_count && sid; i++) {
1195 if (is_crh16) {
1196 proto_tree_add_uint_format(segment_ids, hf_ipv6_routing_crh16_segment_id, tvb, offset,
1197 octets_per_sid, sid, "SID[%d] = %d", i, sid);
1198 } else {
1199 proto_tree_add_uint_format(segment_ids, hf_ipv6_routing_crh32_segment_id, tvb, offset,
1200 octets_per_sid, sid, "SID[%d] = %d", i, sid);
1201 }
1202 offset += octets_per_sid;
1203 sid = is_crh16 ? tvb_get_guint16(tvb, offset, ENC_BIG_ENDIAN)
1204 : tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
1205 }
1206
1207 return tvb_captured_length(tvb);
1208 }
1209
1210 /*
1211 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1212 | Next Header | Hdr Ext Len | Routing Type | Segments Left |
1213 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1214 | |
1215 . .
1216 . type-specific data .
1217 . .
1218 | |
1219 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1220 */
1221 static int
1222 dissect_routing6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
1223 struct ws_rthdr rt;
1224 guint nxt, hdr_len, total_len;
1225 proto_tree *rt_tree, *root_tree;
1226 proto_item *pi, *ti, *ti_hdr_len, *ti_type, *ti_segs;
1227 int offset = 0;
1228 tvbuff_t *next_tvb;
1229 int type, type_len;
1230 dissector_handle_t type_dissector;
1231
1232 col_append_sep_str(pinfo->cinfo, COL_INFO, " , ", "IPv6 routing");
1233
1234 root_tree = p_ipv6_pinfo_select_root(pinfo, tree);
1235
1236 pi = proto_tree_add_item(root_tree, proto_ipv6_routing, tvb, offset, -1, ENC_NA);
1237 rt_tree = proto_item_add_subtree(pi, ett_ipv6_routing_proto);
1238
1239 proto_tree_add_item(rt_tree, hf_ipv6_routing_nxt, tvb, offset, 1, ENC_BIG_ENDIAN);
1240 nxt = tvb_get_guint8(tvb, offset);
1241 offset += 1;
1242
1243 ti_hdr_len = proto_tree_add_item(rt_tree, hf_ipv6_routing_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1244 hdr_len = tvb_get_guint8(tvb, offset);
1245 /*
1246 Hdr Ext Len 8-bit unsigned integer. Length of the Routing
1247 header in 8-octet units, not including the
1248 first 8 octets.
1249 */
1250 total_len = (hdr_len + 1) * 8;
1251 type_len = total_len - 4;
1252
1253 proto_item_set_len(pi, total_len);
1254 ti = proto_tree_add_uint(rt_tree, hf_ipv6_routing_len_oct, tvb, offset, 1, total_len);
1255 proto_item_set_generated(ti);
1256 if (ipv6_exthdr_hide_len_oct_field) {
1257 proto_item_set_hidden(ti);
1258 proto_item_append_text(ti_hdr_len, " (%d bytes)", total_len);
1259 }
1260 p_ipv6_pinfo_add_len(pinfo, total_len);
1261 offset += 1;
1262
1263 ti_type = proto_tree_add_item(rt_tree, hf_ipv6_routing_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1264 type = tvb_get_guint8(tvb, offset);
1265 proto_item_append_text(pi, " (%s)", val_to_str(type, routing_header_type, "Unknown type %u"));
1266 offset += 1;
1267
1268 ti_segs = proto_tree_add_item(rt_tree, hf_ipv6_routing_segleft, tvb, offset, 1, ENC_BIG_ENDIAN);
1269 offset += 1;
1270
1271 type_dissector = dissector_get_uint_handle(ipv6_routing_dissector_table, type);
1272 if (type_dissector != NULL) {
1273 tvb_memcpy(tvb, &(rt.hdr), 0, 4);
1274 rt.ti_len = ti_hdr_len;
1275 rt.ti_type = ti_type;
1276 rt.ti_segleft = ti_segs;
1277 call_dissector_with_data(type_dissector, tvb_new_subset_length(tvb, offset, type_len), pinfo, rt_tree, &rt);
1278 }
1279 else {
1280 /* Unknown Routing Header Type */
1281 ti = proto_tree_add_item(rt_tree, hf_ipv6_routing_unknown_data, tvb, offset, type_len, ENC_NA);
1282 expert_add_info(pinfo, ti, &ei_ipv6_routing_undecoded);
1283 }
1284
1285 p_add_ipv6_nxt(pinfo, nxt);
1286
1287 next_tvb = tvb_new_subset_remaining(tvb, total_len);
1288 ipv6_dissect_next(nxt, next_tvb, pinfo, tree, (ws_ip6 *)data);
1289 return tvb_captured_length(tvb);
1290 }
1291
1292 static int
1293 dissect_fraghdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) {
1294 proto_item *pi, *ti;
1295 proto_tree *frag_tree, *root_tree;
1296 guint8 nxt;
1297 guint16 offlg;
1298 guint16 frag_off;
1299 gboolean frag_flg;
1300 guint32 frag_ident;
1301 gint offset = 0;
1302 ipv6_pinfo_t *ipv6_pinfo;
1303 gboolean show_data = FALSE;
1304 gboolean reassembled;
1305 tvbuff_t *next_tvb;
1306
1307 nxt = tvb_get_guint8(tvb, offset);
1308 offlg = tvb_get_ntohs(tvb, offset + 2);
1309 frag_off = offlg & IP6F_OFF_MASK; /* offset in bytes */
1310 frag_flg = offlg & IP6F_MORE_FRAG;
1311 frag_ident = tvb_get_ntohl(tvb, offset + 4);
1312 col_add_fstr(pinfo->cinfo, COL_INFO, "IPv6 fragment (off=%u more=%s ident=0x%08x nxt=%u)",
1313 frag_off, frag_flg ? "y" : "n", frag_ident, nxt);
1314
1315 root_tree = p_ipv6_pinfo_select_root(pinfo, tree);
1316 ipv6_pinfo = p_ipv6_pinfo_add_len(pinfo, IPv6_FRAGMENT_HDR_SIZE);
1317
1318 /* IPv6 Fragmentation Header has fixed length of 8 bytes */
1319 pi = proto_tree_add_item(root_tree, proto_ipv6_fraghdr, tvb, offset, IPv6_FRAGMENT_HDR_SIZE, ENC_NA);
1320 if (ipv6_pinfo != NULL && ipv6_pinfo->jumbo_plen != 0) {
1321 expert_add_info(pinfo, pi, &ei_ipv6_opt_jumbo_fragment);
1322 }
1323
1324 frag_tree = proto_item_add_subtree(pi, ett_ipv6_fraghdr_proto);
1325
1326 proto_tree_add_item(frag_tree, hf_ipv6_fraghdr_nxt, tvb, offset, 1, ENC_BIG_ENDIAN);
1327 offset += 1;
1328
1329 proto_tree_add_item(frag_tree, hf_ipv6_fraghdr_reserved_octet, tvb, offset, 1, ENC_BIG_ENDIAN);
1330 offset += 1;
1331
1332 ti = proto_tree_add_item(frag_tree, hf_ipv6_fraghdr_offset, tvb, offset, 2, ENC_BIG_ENDIAN);
1333 proto_item_append_text(ti, " (%d bytes)", frag_off);
1334
1335 proto_tree_add_item(frag_tree, hf_ipv6_fraghdr_reserved_bits, tvb, offset, 2, ENC_BIG_ENDIAN);
1336
1337 proto_tree_add_item(frag_tree, hf_ipv6_fraghdr_more, tvb, offset, 2, ENC_BIG_ENDIAN);
1338 offset += 2;
1339
1340 proto_tree_add_item(frag_tree, hf_ipv6_fraghdr_ident, tvb, offset, 4, ENC_BIG_ENDIAN);
1341 offset += 4;
1342
1343 if (ipv6_pinfo != NULL && ipv6_pinfo->frag_plen > 0) {
1344 if ((frag_off != 0) || frag_flg) {
1345 reassembled = ipv6_reassemble_do(&tvb, &offset, pinfo, root_tree, ipv6_pinfo->frag_plen,
1346 frag_off, frag_flg, frag_ident, &show_data);
1347 if (show_data) {
1348 next_tvb = tvb_new_subset_remaining(tvb, offset);
1349 call_data_dissector(next_tvb, pinfo, tree);
1350 return tvb_captured_length(tvb);
1351 }
1352 if (reassembled) {
1353 ipv6_pinfo->frag_plen = 0;
1354 next_tvb = tvb_new_subset_remaining(tvb, offset);
1355 ipv6_dissect_next(nxt, next_tvb, pinfo, tree, (ws_ip6 *)data);
1356 return tvb_captured_length(tvb);
1357 }
1358 }
1359 }
1360
1361 p_add_ipv6_nxt(pinfo, nxt);
1362
1363 next_tvb = tvb_new_subset_remaining(tvb, offset);
1364 ipv6_dissect_next(nxt, next_tvb, pinfo, tree, (ws_ip6 *)data);
1365 return tvb_captured_length(tvb);
1366 }
1367
1368 struct opt_proto_item {
1369 proto_item *type, *len;
1370 };
1371
1372 /*
1373 * Jumbo Payload Option
1374 *
1375 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1376 | Option Type | Opt Data Len |
1377 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1378 | Jumbo Payload Length |
1379 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1380 */
1381 static gint
1382 dissect_opt_jumbo(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1383 struct opt_proto_item *opt_ti, guint8 opt_len)
1384 {
1385 proto_item *pi = proto_tree_get_parent(opt_tree);
1386 proto_item *ti;
1387 guint32 jumbo_plen = 0;
1388 ipv6_pinfo_t *ipv6_pinfo = p_get_ipv6_pinfo(pinfo);
1389
1390 if (opt_len != 4) {
1391 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1392 "Jumbo Payload: Invalid length (%u bytes)", opt_len);
1393 }
1394 ti = proto_tree_add_item_ret_uint(opt_tree, hf_ipv6_opt_jumbo, tvb, offset, 4, ENC_BIG_ENDIAN, &jumbo_plen);
1395 offset += 4;
1396
1397 if (ipv6_pinfo != NULL && ipv6_pinfo->ip6_plen != 0) {
1398 expert_add_info(pinfo, pi, &ei_ipv6_opt_jumbo_prohibited);
1399 }
1400 if (jumbo_plen < 65536) {
1401 expert_add_info(pinfo, ti, &ei_ipv6_opt_jumbo_truncated);
1402 }
1403
1404 return offset;
1405 }
1406
1407 /*
1408 * RPL Option
1409 *
1410 0 1 2 3
1411 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1412 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1413 | Option Type | Opt Data Len |
1414 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1415 |O|R|F|0|0|0|0|0| RPLInstanceID | SenderRank |
1416 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1417 | (sub-TLVs) |
1418 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1419 */
1420 static gint
1421 dissect_opt_rpl(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1422 struct opt_proto_item *opt_ti, guint8 opt_len)
1423 {
1424 static int * const rpl_flags[] = {
1425 &hf_ipv6_opt_rpl_flag_o,
1426 &hf_ipv6_opt_rpl_flag_r,
1427 &hf_ipv6_opt_rpl_flag_f,
1428 &hf_ipv6_opt_rpl_flag_rsv,
1429 NULL
1430 };
1431
1432 if (opt_len < 4) {
1433 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1434 "RPL Option: Invalid length (%u bytes)", opt_len);
1435 }
1436 proto_tree_add_bitmask(opt_tree, tvb, offset, hf_ipv6_opt_rpl_flag, ett_ipv6_opt_rpl, rpl_flags, ENC_NA);
1437 offset += 1;
1438 proto_tree_add_item(opt_tree, hf_ipv6_opt_rpl_instance_id, tvb, offset, 1, ENC_NA);
1439 offset += 1;
1440 proto_tree_add_item(opt_tree, hf_ipv6_opt_rpl_senderrank, tvb, offset, 2, ENC_BIG_ENDIAN);
1441 offset += 2;
1442
1443 /* TODO: Add dissection of sub-TLVs */
1444
1445 return offset;
1446 }
1447
1448 /*
1449 * Tunnel Encapsulation Limit Option
1450 *
1451 Option Type Opt Data Len Opt Data Len
1452 0 1 2 3 4 5 6 7
1453 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1454 |0 0 0 0 0 1 0 0| 1 | Tun Encap Lim |
1455 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1456 */
1457 static gint
1458 dissect_opt_tel(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1459 struct opt_proto_item *opt_ti, guint8 opt_len)
1460 {
1461 if (opt_len != 1) {
1462 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1463 "Tunnel Encapsulation Limit: Invalid length (%u bytes)", opt_len);
1464 }
1465 proto_tree_add_item(opt_tree, hf_ipv6_opt_tel, tvb, offset, 1, ENC_BIG_ENDIAN);
1466 offset += 1;
1467
1468 return offset;
1469 }
1470
1471 /*
1472 * IPv6 Minimum Path MTU Hop by Hop Option
1473 *
1474
1475 Option Option Option
1476 Type Data Len Data
1477 +--------+--------+--------+--------+---------+-------+-+
1478 |BBCTTTTT|00000100| Min-PMTU | Rtn-PMTU |R|
1479 +--------+--------+--------+--------+---------+-------+-+
1480
1481 Option Type:
1482
1483 BB 00 Skip over this option and continue processing.
1484
1485 C 1 Option data can change en route to the packet's final
1486 destination.
1487
1488 TTTTT 10000 Option Type assigned from IANA [IANA-HBH].
1489
1490 Length: 4 The size of the each value field in Option Data
1491 field supports Path MTU values from 0 to 65,535 octets.
1492
1493 Min-PMTU: n 16-bits. The minimum PMTU in octets, reflecting the
1494 smallest link MTU that the packet experienced across
1495 the path. This is called the Reported PMTU. A value
1496 less than the IPv6 minimum link MTU [RFC8200]
1497 should be ignored.
1498
1499 Rtn-PMTU: n 15-bits. The returned mimimum PMTU, carrying the 15
1500 most significant bits of the latest received Min-PMTU
1501 field. The value zero means that no Reported MTU is
1502 being returned.
1503
1504 R n 1-bit. R-Flag. Set by the source to signal that
1505 the destination should include the received
1506 Reported PMTU in Rtn-PMTU field.
1507
1508 [IANA-HBH]
1509 "Destination Options and Hop-by-Hop Options",
1510 <https://www.iana.org/assignments/ipv6-parameters/
1511 ipv6-parameters.xhtml#ipv6-parameters-2>
1512 */
1513 static gint
1514 dissect_opt_pmtu(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1515 struct opt_proto_item *opt_ti, guint8 opt_len)
1516 {
1517 guint16 val;
1518
1519 if (opt_len != 4) {
1520 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1521 "PMTU Option: Invalid Length (%u bytes)", opt_len);
1522 }
1523
1524 proto_tree_add_item(opt_tree, hf_ipv6_opt_pmtu_min, tvb, offset, 2, ENC_BIG_ENDIAN);
1525 offset += 2;
1526 val = tvb_get_ntohs(tvb, offset);
1527 proto_tree_add_uint(opt_tree, hf_ipv6_opt_pmtu_rtn, tvb, offset, 2, val & 0xFFFE);
1528 offset += 1;
1529 proto_tree_add_boolean(opt_tree, hf_ipv6_opt_pmtu_rtn_flag, tvb, offset, 1, val & 0x0001);
1530 offset += 1;
1531
1532 return offset;
1533 }
1534
1535 /*
1536 * IPv6 Router Alert Option
1537 *
1538 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1539 |0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0| Value (2 octets) |
1540 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1541 length = 2
1542 */
1543 static gint
1544 dissect_opt_rtalert(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1545 struct opt_proto_item *opt_ti, guint8 opt_len)
1546 {
1547 if (opt_len != 2) {
1548 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1549 "Router alert: Invalid Length (%u bytes)", opt_len);
1550 }
1551 proto_tree_add_item(opt_tree, hf_ipv6_opt_rtalert, tvb, offset, 2, ENC_BIG_ENDIAN);
1552 offset += 2;
1553
1554 return offset;
1555 }
1556
1557 /*
1558 * Quick-Start Option for IPv6
1559 *
1560 0 1 2 3
1561 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1562 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1563 | Option | Length=6 | Func. | Rate | Not Used |
1564 | | | 1000 | Report| |
1565 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1566 | QS Nonce | R |
1567 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1568 */
1569 static gint
1570 dissect_opt_quickstart(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1571 struct opt_proto_item *opt_ti, guint8 opt_len, ws_ip6 *iph)
1572 {
1573 proto_item *pi = proto_tree_get_parent(opt_tree);
1574 proto_item *ti;
1575 guint8 command, function, rate;
1576 guint32 qs_ttl = 0;
1577
1578 if (opt_len != 6) {
1579 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1580 "Quick-Start: Invalid Length (%u bytes)", opt_len);
1581 }
1582
1583 command = tvb_get_guint8(tvb, offset);
1584 function = command >> 4;
1585 rate = command & QS_RATE_MASK;
1586
1587 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_func, tvb, offset, 1, ENC_BIG_ENDIAN);
1588
1589 switch (function) {
1590 case QS_RATE_REQUEST:
1591 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
1592 offset += 1;
1593 proto_tree_add_item_ret_uint(opt_tree, hf_ipv6_opt_qs_ttl, tvb, offset, 1, ENC_BIG_ENDIAN, &qs_ttl);
1594 proto_item_append_text(pi, ", %s, QS TTL %u",
1595 val_to_str_ext(rate, &qs_rate_vals_ext, "Unknown (%u)"),
1596 qs_ttl);
1597 if (iph != NULL) {
1598 guint8 ttl_diff;
1599
1600 ttl_diff = (iph->ip6_hop - qs_ttl) % 256;
1601 ti = proto_tree_add_uint(opt_tree, hf_ipv6_opt_qs_ttl_diff, tvb, offset, 1, ttl_diff);
1602 proto_item_set_generated(ti);
1603 proto_item_append_text(pi, ", QS TTL diff %u", ttl_diff);
1604 }
1605 offset += 1;
1606 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_nonce, tvb, offset, 4, ENC_BIG_ENDIAN);
1607 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
1608 offset += 4;
1609 break;
1610 case QS_RATE_REPORT:
1611 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_rate, tvb, offset, 1, ENC_BIG_ENDIAN);
1612 proto_item_append_text(pi, ", %s", val_to_str_ext(rate, &qs_rate_vals_ext, "Unknown (%u)"));
1613 offset += 1;
1614 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_unused, tvb, offset, 1, ENC_BIG_ENDIAN);
1615 offset += 1;
1616 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_nonce, tvb, offset, 4, ENC_BIG_ENDIAN);
1617 proto_tree_add_item(opt_tree, hf_ipv6_opt_qs_reserved, tvb, offset, 4, ENC_BIG_ENDIAN);
1618 offset += 4;
1619 break;
1620 default:
1621 break;
1622 }
1623
1624 return offset;
1625 }
1626
1627 /*
1628 * Tunnel Payload Forwarding Option for IPv6
1629 *
1630 0 1 2 3
1631 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1632 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1633 | Option Type | Option Length |
1634 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1635 | TPF Information |
1636 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1637 */
1638 static gint
1639 dissect_opt_tpf(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1640 struct opt_proto_item *opt_ti, guint8 opt_len)
1641 {
1642 if (opt_len != 4) {
1643 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1644 "TPF: Invalid Length (%u bytes)", opt_len);
1645 }
1646 proto_tree_add_item(opt_tree, hf_ipv6_opt_tpf_information, tvb, offset, 4, ENC_BIG_ENDIAN);
1647 offset += 4;
1648
1649 return offset;
1650 }
1651
1652 /*
1653 ------------------------------------------------------------
1654 | Next Header | Hdr Ext Len | Option Type | Option Length|
1655 +-------------+---------------+-------------+--------------+
1656 | CALIPSO Domain of Interpretation |
1657 +-------------+---------------+-------------+--------------+
1658 | Cmpt Length | Sens Level | Checksum (CRC-16) |
1659 +-------------+---------------+-------------+--------------+
1660 | Compartment Bitmap (Optional; variable length) |
1661 +-------------+---------------+-------------+--------------+
1662 */
1663 static gint
1664 dissect_opt_calipso(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1665 struct opt_proto_item *opt_ti, guint8 opt_len)
1666 {
1667 guint32 cmpt_length = 0;
1668
1669 if (opt_len < 8) {
1670 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1671 "CALIPSO: Invalid Length (%u bytes)", opt_len);
1672 }
1673
1674 proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_doi, tvb,
1675 offset, 4, ENC_BIG_ENDIAN);
1676 offset += 4;
1677
1678 proto_tree_add_item_ret_uint(opt_tree, hf_ipv6_opt_calipso_cmpt_length, tvb,
1679 offset, 1, ENC_BIG_ENDIAN, &cmpt_length);
1680 offset += 1;
1681
1682 proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_sens_level, tvb,
1683 offset, 1, ENC_BIG_ENDIAN);
1684 offset += 1;
1685
1686 proto_tree_add_checksum(opt_tree, tvb, offset, hf_ipv6_opt_calipso_checksum, -1,
1687 NULL, pinfo, 0, ENC_BIG_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
1688 offset += 2;
1689
1690 proto_tree_add_item(opt_tree, hf_ipv6_opt_calipso_cmpt_bitmap, tvb,
1691 offset, cmpt_length*4, ENC_NA);
1692 offset += cmpt_length*4;
1693
1694 return offset;
1695 }
1696
1697 /*
1698 * IPv6 SMF_DPD Option Header
1699 *
1700 0 1 2 3
1701 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1702 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1703 ... |0|0|0| 01000 | Opt. Data Len |
1704 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1705 |0|TidTy| TidLen| TaggerId (optional) ... |
1706 +-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1707 | | Identifier ...
1708 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1709
1710 Figure 3: IPv6 SMF_DPD Option Header in I-DPD mode
1711
1712 0 1 2 3
1713 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1714 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1715 ... |0|0|0| OptType | Opt. Data Len |
1716 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1717 |1| Hash Assist Value (HAV) ...
1718 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1719
1720 Figure 4: IPv6 SMF_DPD Option Header in H-DPD Mode
1721 */
1722 static gint
1723 dissect_opt_smf_dpd(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *opt_tree,
1724 struct opt_proto_item *opt_ti _U_, guint8 opt_len)
1725 {
1726 guint8 hash_tid;
1727 guint8 tid_len;
1728 gint ident_len;
1729
1730 proto_tree_add_item(opt_tree, hf_ipv6_opt_smf_dpd_hash_bit, tvb, offset, 1, ENC_BIG_ENDIAN);
1731 hash_tid = tvb_get_guint8(tvb, offset);
1732
1733 if (hash_tid & 0x80) {
1734 /* H-DPD Mode */
1735 proto_tree_add_item(opt_tree, hf_ipv6_opt_smf_dpd_hav, tvb, offset, opt_len, ENC_NA);
1736 return offset + opt_len;
1737 }
1738
1739 /* I-DPD Mode */
1740 proto_tree_add_item(opt_tree, hf_ipv6_opt_smf_dpd_tid_type, tvb, offset, 1, ENC_BIG_ENDIAN);
1741 proto_tree_add_item(opt_tree, hf_ipv6_opt_smf_dpd_tid_len, tvb, offset, 1, ENC_BIG_ENDIAN);
1742 offset += 1;
1743 ident_len = opt_len - 1;
1744 if (hash_tid & 0x70) {
1745 tid_len = (hash_tid & 0x0f) + 1;
1746 proto_tree_add_item(opt_tree, hf_ipv6_opt_smf_dpd_tagger_id, tvb, offset, tid_len, ENC_NA);
1747 offset += tid_len;
1748 ident_len -= tid_len;
1749 }
1750 if (ident_len > 0) {
1751 proto_tree_add_item(opt_tree, hf_ipv6_opt_smf_dpd_ident, tvb, offset, ident_len, ENC_NA);
1752 offset += ident_len;
1753 }
1754
1755 return offset;
1756 }
1757
1758 /*
1759 * Performance and Diagnostic Metrics Destination Option (ietf-ippm-6man-pdm-option-13)
1760 *
1761 0 1 2 3
1762 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1763 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1764 | Option Type | Option Length | ScaleDTLR | ScaleDTLS |
1765 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1766 | PSN This Packet | PSN Last Received |
1767 |-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1768 | Delta Time Last Received | Delta Time Last Sent |
1769 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1770 */
1771 static gint
1772 dissect_opt_pdm(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *opt_tree,
1773 struct opt_proto_item *opt_ti _U_, guint8 opt_len)
1774 {
1775 if (opt_len != 10) {
1776 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1777 "PDM: Invalid length (%u bytes)", opt_len);
1778 }
1779 proto_tree_add_item(opt_tree, hf_ipv6_opt_pdm_scale_dtlr, tvb, offset, 1, ENC_BIG_ENDIAN);
1780 offset += 1;
1781 proto_tree_add_item(opt_tree, hf_ipv6_opt_pdm_scale_dtls, tvb, offset, 1, ENC_BIG_ENDIAN);
1782 offset += 1;
1783 proto_tree_add_item(opt_tree, hf_ipv6_opt_pdm_psn_this_pkt, tvb, offset, 2, ENC_BIG_ENDIAN);
1784 offset += 2;
1785 proto_tree_add_item(opt_tree, hf_ipv6_opt_pdm_psn_last_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
1786 offset += 2;
1787 proto_tree_add_item(opt_tree, hf_ipv6_opt_pdm_delta_last_recv, tvb, offset, 2, ENC_BIG_ENDIAN);
1788 offset += 2;
1789 proto_tree_add_item(opt_tree, hf_ipv6_opt_pdm_delta_last_sent, tvb, offset, 2, ENC_BIG_ENDIAN);
1790 offset += 2;
1791
1792 return offset;
1793 }
1794
1795 /*
1796 * Home Address Option
1797 *
1798 0 1 2 3
1799 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1800 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1801 | Option Type | Option Length |
1802 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1803 | |
1804 + +
1805 | |
1806 + Home Address +
1807 | |
1808 + +
1809 | |
1810 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1811 */
1812 static gint
1813 dissect_opt_home_address(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1814 struct opt_proto_item *opt_ti, guint8 opt_len)
1815 {
1816 if (opt_len != 16) {
1817 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1818 "Home Address: Invalid length (%u bytes)", opt_len);
1819 }
1820 proto_tree_add_item(opt_tree, hf_ipv6_opt_mipv6_home_address, tvb, offset, IPv6_ADDR_SIZE, ENC_NA);
1821 alloc_address_tvb_ipv6(pinfo->pool, &pinfo->src, tvb, offset);
1822 offset += IPv6_ADDR_SIZE;
1823
1824 return offset;
1825 }
1826
1827 /*
1828 * ILNP Nonce Option
1829 *
1830
1831 0 1 2 3
1832 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1833 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1834 | Next Header | Hdr Ext Len | Option Type | Option Length |
1835 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1836 / Nonce Value /
1837 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1838 */
1839 static gint
1840 dissect_opt_ilnp_nonce(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *opt_tree,
1841 struct opt_proto_item *opt_ti _U_, guint8 opt_len)
1842 {
1843 proto_tree_add_item(opt_tree, hf_ipv6_opt_ilnp_nonce, tvb, offset, opt_len, ENC_NA);
1844 offset += opt_len;
1845
1846 return offset;
1847 }
1848
1849 /*
1850 * Line-Identification Option
1851 *
1852 0 1 2 3
1853 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1854 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1855 | Option Type | Option Length |
1856 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1857 | LineIDLen | Line ID...
1858 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1859 */
1860 static gint
1861 dissect_opt_lio(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *opt_tree,
1862 struct opt_proto_item *opt_ti _U_, guint8 opt_len)
1863 {
1864 guint32 lid_len = 0;
1865
1866 proto_tree_add_item_ret_uint(opt_tree, hf_ipv6_opt_lio_len, tvb, offset, 1, ENC_BIG_ENDIAN, &lid_len);
1867 offset += 1;
1868
1869 if (lid_len + 1 > opt_len) {
1870 /* XXX Add expert info */
1871 lid_len = opt_len - 1;
1872 }
1873 proto_tree_add_item(opt_tree, hf_ipv6_opt_lio_id, tvb, offset, lid_len, ENC_BIG_ENDIAN|ENC_ASCII);
1874 offset += lid_len;
1875
1876 return offset;
1877 }
1878
1879 /*
1880 * MPL Option
1881 *
1882 0 1 2 3
1883 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1884 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1885 | Option Type | Opt Data Len |
1886 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1887 | S |M|V| rsv | sequence | seed-id (optional) |
1888 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1889 */
1890 static gint
1891 dissect_opt_mpl(tvbuff_t *tvb, gint offset, packet_info *pinfo _U_, proto_tree *opt_tree,
1892 struct opt_proto_item *opt_ti _U_, guint8 opt_len _U_)
1893 {
1894 static int * const mpl_flags[] = {
1895 &hf_ipv6_opt_mpl_flag_s,
1896 &hf_ipv6_opt_mpl_flag_m,
1897 &hf_ipv6_opt_mpl_flag_v,
1898 &hf_ipv6_opt_mpl_flag_rsv,
1899 NULL
1900 };
1901 static const guint8 seed_id_len_arr[4] = {0, 2, 8, 16};
1902 guint8 seed_id_len;
1903
1904 proto_tree_add_bitmask(opt_tree, tvb, offset, hf_ipv6_opt_mpl_flag, ett_ipv6_opt_mpl, mpl_flags, ENC_NA);
1905 seed_id_len = seed_id_len_arr[tvb_get_guint8(tvb, offset) >> 6];
1906 offset +=1;
1907
1908 proto_tree_add_item(opt_tree, hf_ipv6_opt_mpl_sequence, tvb, offset, 1, ENC_NA);
1909 offset +=1;
1910 if (seed_id_len > 0) {
1911 proto_tree_add_item(opt_tree, hf_ipv6_opt_mpl_seed_id, tvb, offset, seed_id_len, ENC_NA);
1912 offset += seed_id_len;
1913 }
1914 else {
1915 expert_add_info(pinfo, opt_ti->type, &ei_ipv6_opt_mpl_ipv6_src_seed_id);
1916 }
1917
1918 return offset;
1919 }
1920
1921 /*
1922 * IPv6 DFF Header
1923 *
1924 1 2 3
1925 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
1926 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1927 | Next Header | Hdr Ext Len | OptTypeDFF | OptDataLenDFF |
1928 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1929 |VER|D|R|0|0|0|0| Sequence Number | Pad1 |
1930 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
1931 */
1932 static gint
1933 dissect_opt_dff(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1934 struct opt_proto_item *opt_ti, guint8 opt_len)
1935 {
1936 static int * const dff_flags[] = {
1937 &hf_ipv6_opt_dff_flag_ver,
1938 &hf_ipv6_opt_dff_flag_dup,
1939 &hf_ipv6_opt_dff_flag_ret,
1940 &hf_ipv6_opt_dff_flag_rsv,
1941 NULL
1942 };
1943
1944 /* Option length is 3 octets */
1945 /* http://www.rfc-editor.org/errata_search.php?eid=3937 */
1946 if (opt_len != 3) {
1947 expert_add_info_format(pinfo, opt_ti->len, &ei_ipv6_opt_invalid_len,
1948 "IPv6 DFF: Invalid length (%u bytes)", opt_len);
1949 }
1950 proto_tree_add_bitmask(opt_tree, tvb, offset, hf_ipv6_opt_dff_flags,
1951 ett_ipv6_opt_dff_flags, dff_flags, ENC_NA);
1952 offset += 1;
1953 proto_tree_add_item(opt_tree, hf_ipv6_opt_dff_seqnum, tvb, offset, 2, ENC_BIG_ENDIAN);
1954 offset += 2;
1955
1956 return offset;
1957 }
1958
1959 static gint
1960 dissect_opt_unknown(tvbuff_t *tvb, gint offset, packet_info *pinfo, proto_tree *opt_tree,
1961 struct opt_proto_item *opt_ti _U_, guint8 opt_len)
1962 {
1963 proto_item *ti;
1964
1965 ti = proto_tree_add_item(opt_tree, hf_ipv6_opt_unknown, tvb,
1966 offset, opt_len, ENC_NA);
1967 expert_add_info(pinfo, ti, &ei_ipv6_opt_unknown_data);
1968
1969 return offset + opt_len;
1970 }
1971
1972 static int
1973 dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, packet_info *pinfo, ws_ip6 *iph, const int exthdr_proto)
1974 {
1975 gint len, offset_end;
1976 guint8 nxt;
1977 proto_tree *exthdr_tree, *opt_tree, *opt_type_tree, *root_tree;
1978 proto_item *pi, *ti, *ti_len;
1979 int hf_exthdr_item_nxt, hf_exthdr_item_len, hf_exthdr_item_len_oct;
1980 int ett_exthdr_proto;
1981 guint8 opt_type, opt_len, opt_start;
1982 gint opt_hdr_type;
1983 const gchar *opt_name;
1984 gboolean hopopts;
1985 struct opt_proto_item opt_ti;
1986 tvbuff_t *next_tvb;
1987
1988 hopopts = (exthdr_proto == proto_ipv6_hopopts);
1989
1990 nxt = tvb_get_guint8(tvb, offset);
1991 len = (tvb_get_guint8(tvb, offset + 1) + 1) << 3;
1992 offset_end = offset + len;
1993
1994 root_tree = p_ipv6_pinfo_select_root(pinfo, tree);
1995 p_ipv6_pinfo_add_len(pinfo, len);
1996
1997 /* !!! specify length */
1998 ti = proto_tree_add_item(root_tree, exthdr_proto, tvb, offset, len, ENC_NA);
1999
2000 if (hopopts && ipv6_previous_layer_id(pinfo) != proto_ipv6) {
2001 /* IPv6 Hop-by-Hop must appear immediately after IPv6 header (RFC 2460) */
2002 expert_add_info(pinfo, ti, &ei_ipv6_hopopts_not_first);
2003 }
2004
2005 if (exthdr_proto == proto_ipv6_hopopts) {
2006 hf_exthdr_item_nxt = hf_ipv6_hopopts_nxt;
2007 hf_exthdr_item_len = hf_ipv6_hopopts_len;
2008 hf_exthdr_item_len_oct = hf_ipv6_hopopts_len_oct;
2009 ett_exthdr_proto = ett_ipv6_hopopts_proto;
2010 } else if (exthdr_proto == proto_ipv6_dstopts) {
2011 hf_exthdr_item_nxt = hf_ipv6_dstopts_nxt;
2012 hf_exthdr_item_len = hf_ipv6_dstopts_len;
2013 hf_exthdr_item_len_oct = hf_ipv6_dstopts_len_oct;
2014 ett_exthdr_proto = ett_ipv6_dstopts_proto;
2015 } else {
2016 DISSECTOR_ASSERT_NOT_REACHED();
2017 }
2018
2019 exthdr_tree = proto_item_add_subtree(ti, ett_exthdr_proto);
2020
2021 proto_tree_add_item(exthdr_tree, hf_exthdr_item_nxt, tvb, offset, 1, ENC_BIG_ENDIAN);
2022 offset += 1;
2023
2024 ti_len = proto_tree_add_item(exthdr_tree, hf_exthdr_item_len, tvb, offset, 1, ENC_BIG_ENDIAN);
2025 ti = proto_tree_add_uint(exthdr_tree, hf_exthdr_item_len_oct, tvb, offset, 1, len);
2026 proto_item_set_generated(ti);
2027 if (ipv6_exthdr_hide_len_oct_field) {
2028 proto_item_set_hidden(ti);
2029 proto_item_append_text(ti_len, " (%d bytes)", len);
2030 }
2031 offset += 1;
2032
2033 while (offset < offset_end) {
2034 /* there are more options */
2035
2036 opt_type = tvb_get_guint8(tvb, offset);
2037 opt_len = tvb_get_guint8(tvb, offset + 1);
2038 opt_name = val_to_str_ext(opt_type, &ipv6_opt_type_vals_ext, "Unknown IPv6 Option (%u)");
2039
2040 pi = proto_tree_add_none_format(exthdr_tree, hf_ipv6_opt, tvb, offset, 2 + opt_len,
2041 "%s", opt_name);
2042 opt_tree = proto_item_add_subtree(pi, ett_ipv6_opt);
2043
2044 opt_ti.type = proto_tree_add_item(opt_tree, hf_ipv6_opt_type, tvb, offset, 1, ENC_BIG_ENDIAN);
2045
2046 if (opt_type == IP6OPT_PAD1) {
2047 /* The Pad1 option is a special case, and contains no data. */
2048 proto_tree_add_item(opt_tree, hf_ipv6_opt_pad1, tvb, offset, 1, ENC_NA);
2049 offset += 1;
2050 continue;
2051 }
2052
2053 if ((opt_hdr_type = ipv6_opt_type_hdr(opt_type)) != IPv6_OPT_HDR_ANY) {
2054 if (hopopts && (opt_hdr_type == IPv6_OPT_HDR_DST)) {
2055 expert_add_info_format(pinfo, opt_ti.type, &ei_ipv6_opt_header_mismatch,
2056 "%s must use a destination options header", opt_name);
2057 }
2058 else if (!hopopts && (opt_hdr_type == IPv6_OPT_HDR_HBH)) {
2059 expert_add_info_format(pinfo, opt_ti.type, &ei_ipv6_opt_header_mismatch,
2060 "%s must use a hop-by-hop options header", opt_name);
2061 }
2062 }
2063
2064 opt_type_tree = proto_item_add_subtree(opt_ti.type, ett_ipv6_opt_type);
2065 proto_tree_add_item(opt_type_tree, hf_ipv6_opt_type_action, tvb, offset, 1, ENC_BIG_ENDIAN);
2066 proto_tree_add_item(opt_type_tree, hf_ipv6_opt_type_change, tvb, offset, 1, ENC_BIG_ENDIAN);
2067 proto_tree_add_item(opt_type_tree, hf_ipv6_opt_type_rest, tvb, offset, 1, ENC_BIG_ENDIAN);
2068 offset += 1;
2069
2070 opt_ti.len = proto_tree_add_item(opt_tree, hf_ipv6_opt_length, tvb, offset, 1, ENC_BIG_ENDIAN);
2071 offset += 1;
2072
2073 if (opt_type == IP6OPT_PADN) {
2074 /* RFC 2460 states :
2075 * "The PadN option is used to insert two or more octets of
2076 * padding into the Options area of a header. For N octets of
2077 * padding, the Opt Data Len field contains the value N-2, and
2078 * the Option Data consists of N-2 zero-valued octets."
2079 */
2080 proto_tree_add_item(opt_tree, hf_ipv6_opt_padn, tvb, offset, opt_len, ENC_NA);
2081 offset += opt_len;
2082 continue;
2083 }
2084
2085 opt_start = offset;
2086 switch (opt_type) {
2087 case IP6OPT_JUMBO:
2088 offset = dissect_opt_jumbo(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2089 break;
2090 case IP6OPT_RPL:
2091 offset = dissect_opt_rpl(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2092 break;
2093 case IP6OPT_TEL:
2094 offset = dissect_opt_tel(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2095 break;
2096 case IP6OPT_RTALERT:
2097 offset = dissect_opt_rtalert(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2098 break;
2099 case IP6OPT_PMTU:
2100 offset = dissect_opt_pmtu(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2101 break;
2102 case IP6OPT_QUICKSTART:
2103 offset = dissect_opt_quickstart(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len, iph);
2104 break;
2105 case IP6OPT_TPF:
2106 offset = dissect_opt_tpf(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2107 break;
2108 case IP6OPT_CALIPSO:
2109 offset = dissect_opt_calipso(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2110 break;
2111 case IP6OPT_SMF_DPD:
2112 offset = dissect_opt_smf_dpd(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2113 break;
2114 case IP6OPT_PDM:
2115 offset = dissect_opt_pdm(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2116 break;
2117 case IP6OPT_HOME_ADDRESS:
2118 offset = dissect_opt_home_address(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2119 break;
2120 case IP6OPT_ILNP_NONCE:
2121 offset = dissect_opt_ilnp_nonce(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2122 break;
2123 case IP6OPT_LIO:
2124 offset = dissect_opt_lio(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2125 break;
2126 case IP6OPT_MPL:
2127 offset = dissect_opt_mpl(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2128 break;
2129 case IP6OPT_IP_DFF:
2130 offset = dissect_opt_dff(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2131 break;
2132 case IP6OPT_ENDI:
2133 offset = dissect_opt_unknown(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2134 expert_add_info(pinfo, opt_ti.type, &ei_ipv6_opt_deprecated);
2135 break;
2136 case IP6OPT_EXP_1E:
2137 case IP6OPT_EXP_3E:
2138 case IP6OPT_EXP_5E:
2139 case IP6OPT_EXP_7E:
2140 case IP6OPT_EXP_9E:
2141 case IP6OPT_EXP_BE:
2142 case IP6OPT_EXP_DE:
2143 case IP6OPT_EXP_FE:
2144 proto_tree_add_item(opt_tree, hf_ipv6_opt_experimental, tvb,
2145 offset, opt_len, ENC_NA);
2146 offset += opt_len;
2147 break;
2148 default:
2149 offset = dissect_opt_unknown(tvb, offset, pinfo, opt_tree, &opt_ti, opt_len);
2150 break;
2151 }
2152 if (offset < opt_start + opt_len) {
2153 ti = proto_tree_add_item(opt_tree, hf_ipv6_opt_unknown_data, tvb,
2154 offset, opt_start + opt_len - offset, ENC_NA);
2155 expert_add_info(pinfo, ti, &ei_ipv6_opt_unknown_data);
2156 offset = opt_start + opt_len;
2157 }
2158 }
2159
2160 p_add_ipv6_nxt(pinfo, nxt);
2161
2162 next_tvb = tvb_new_subset_remaining(tvb, len);
2163 ipv6_dissect_next(nxt, next_tvb, pinfo, tree, iph);
2164 return tvb_captured_length(tvb);
2165 }
2166
2167 static int
2168 dissect_hopopts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
2169 {
2170 col_append_sep_str(pinfo->cinfo, COL_INFO, " , ", "IPv6 hop-by-hop options");
2171
2172 return dissect_opts(tvb, 0, tree, pinfo, (ws_ip6 *)data, proto_ipv6_hopopts);
2173 }
2174
2175 static int
2176 dissect_dstopts(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
2177 {
2178 col_append_sep_str(pinfo->cinfo, COL_INFO, " , ", "IPv6 destination options");
2179
2180 return dissect_opts(tvb, 0, tree, pinfo, (ws_ip6 *)data, proto_ipv6_dstopts);
2181 }
2182
2183 /* return value is > G_MAXUINT16, else zero */
2184 /* tvb + offset contains the Hbh header */
2185 static guint32
2186 ipv6_get_jumbo_plen(tvbuff_t *tvb, gint offset)
2187 {
2188 gint offset_end, hdr_len;
2189 gint opt_type, opt_len;
2190 guint32 jumbo_plen;
2191
2192 if (!tvb_bytes_exist(tvb, offset, 2)) {
2193 return 0;
2194 }
2195 hdr_len = (tvb_get_guint8(tvb, offset + 1) + 1) * 8;
2196 offset_end = offset + hdr_len;
2197 offset +=2;
2198
2199 while (offset < offset_end && tvb_bytes_exist(tvb, offset, 6)) {
2200 opt_type = tvb_get_guint8(tvb, offset);
2201 offset += 1;
2202 if (opt_type == IP6OPT_PAD1) {
2203 continue;
2204 }
2205 opt_len = tvb_get_guint8(tvb, offset);
2206 offset += 1;
2207 if (opt_type == IP6OPT_JUMBO && opt_len == 4) {
2208 jumbo_plen = tvb_get_guint32(tvb, offset, ENC_BIG_ENDIAN);
2209 if (jumbo_plen > G_MAXUINT16) {
2210 return jumbo_plen;
2211 }
2212 return 0;
2213 }
2214 offset += opt_len;
2215 }
2216 return 0;
2217 }
2218
2219 static void
2220 add_ipv6_address(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset,
2221 gint hf_addr, gint hf_host)
2222 {
2223 address addr;
2224 const char *name;
2225 proto_item *ti;
2226
2227 proto_tree_add_item(tree, hf_addr, tvb, offset, IPv6_ADDR_SIZE, ENC_NA);
2228 ti = proto_tree_add_item(tree, hf_ipv6_addr, tvb, offset, IPv6_ADDR_SIZE, ENC_NA);
2229 proto_item_set_hidden(ti);
2230
2231 set_address_ipv6_tvb(&addr, tvb, offset);
2232 name = address_to_display(pinfo->pool, &addr);
2233
2234 ti = proto_tree_add_string(tree, hf_host, tvb, offset, IPv6_ADDR_SIZE, name);
2235 proto_item_set_generated(ti);
2236 proto_item_set_hidden(ti);
2237 ti = proto_tree_add_string(tree, hf_ipv6_host, tvb, offset, IPv6_ADDR_SIZE, name);
2238 proto_item_set_generated(ti);
2239 proto_item_set_hidden(ti);
2240 }
2241
2242 #define ADDRESS_SET_GENERATED_HIDDEN(ti) \
2243 G_STMT_START { \
2244 proto_item_set_generated(ti); \
2245 if (i > 0) proto_item_set_hidden(ti); \
2246 } G_STMT_END
2247
2248 /* RFC 3056 section 2 */
2249 static void
2250 add_ipv6_address_6to4(proto_tree *tree, tvbuff_t *tvb, int offset,
2251 gint hf_gateway, gint hf_sla_id)
2252 {
2253 if (tvb_get_ntohs(tvb, offset) != 0x2002)
2254 return;
2255
2256 struct { gint gateway, sla_id; } hf[2] = {
2257 { hf_gateway, hf_sla_id},
2258 { hf_ipv6_6to4_gateway_ipv4, hf_ipv6_6to4_sla_id}
2259 };
2260 proto_item *ti;
2261 for (int i = 0; i < 2; i++) {
2262 ti = proto_tree_add_item(tree, hf[i].gateway, tvb, offset + 2, 4, ENC_BIG_ENDIAN);
2263 ADDRESS_SET_GENERATED_HIDDEN(ti);
2264 ti = proto_tree_add_item(tree, hf[i].sla_id, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
2265 ADDRESS_SET_GENERATED_HIDDEN(ti);
2266 }
2267 }
2268
2269 /* RFC 4380 section 4 */
2270 static void
2271 add_ipv6_address_teredo(proto_tree *tree, tvbuff_t *tvb, int offset,
2272 gint hf_server, gint hf_port, gint hf_client)
2273 {
2274 if (tvb_get_ntohl(tvb, offset) != 0x20010000)
2275 return;
2276
2277 guint16 mapped_port = tvb_get_ntohs(tvb, offset + 10) ^ 0xffff;
2278 guint32 client_v4 = tvb_get_ipv4(tvb, offset + 12) ^ 0xffffffff;
2279
2280 struct { gint server, port, client; } hf[2] = {
2281 { hf_server, hf_port, hf_client },
2282 { hf_ipv6_teredo_server_ipv4, hf_ipv6_teredo_port, hf_ipv6_teredo_client_ipv4 }
2283 };
2284 proto_item *ti;
2285 for (int i = 0; i < 2; i++) {
2286 ti = proto_tree_add_item(tree, hf[i].server, tvb, offset + 4, 4, ENC_BIG_ENDIAN);
2287 ADDRESS_SET_GENERATED_HIDDEN(ti);
2288 ti = proto_tree_add_uint(tree, hf[i].port, tvb, offset + 10, 2, mapped_port);
2289 ADDRESS_SET_GENERATED_HIDDEN(ti);
2290 ti = proto_tree_add_ipv4(tree, hf[i].client, tvb, offset + 12, 4, client_v4);
2291 ADDRESS_SET_GENERATED_HIDDEN(ti);
2292 }
2293 }
2294
2295 /* RFC 4291 appendix A */
2296 static void
2297 add_ipv6_address_slaac(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_slaac)
2298 {
2299 if (!(tvb_get_guint8(tvb, offset + 8) & 0x02) ||
2300 !(tvb_get_ntohs(tvb, offset + 11) == 0xfffe)) {
2301 return;
2302 }
2303
2304 guint8 *mac_addr = (guint8 *)wmem_alloc(pinfo->pool, 6);
2305 tvb_memcpy(tvb, mac_addr, offset + 8, 3);
2306 tvb_memcpy(tvb, mac_addr+3, offset + 13, 3);
2307 mac_addr[0] &= ~0x02;
2308
2309 struct { gint mac; } hf[2] = {
2310 { hf_slaac },
2311 { hf_ipv6_slaac_mac }
2312 };
2313 proto_item *ti;
2314 for (int i = 0; i < 2; i++) {
2315 ti = proto_tree_add_ether(tree, hf[i].mac, tvb, offset + 8, 8, mac_addr);
2316 ADDRESS_SET_GENERATED_HIDDEN(ti);
2317 }
2318 }
2319
2320 /* RFC 5214 section 6.1 */
2321 static void
2322 add_ipv6_address_isatap(proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_isatap)
2323 {
2324 if ((tvb_get_ntohl(tvb, offset + 8) & 0xfcffffff) != 0x00005efe)
2325 return;
2326
2327 struct { gint ipv4; } hf[2] = {
2328 { hf_isatap },
2329 { hf_ipv6_isatap_ipv4 }
2330 };
2331 proto_item *ti;
2332 for (int i = 0; i < 2; i++) {
2333 ti = proto_tree_add_item(tree, hf[i].ipv4, tvb, offset + 12, 4, ENC_BIG_ENDIAN);
2334 ADDRESS_SET_GENERATED_HIDDEN(ti);
2335 }
2336 }
2337
2338 /* RFC 6052 */
2339 static void
2340 add_ipv6_address_embed_ipv4(proto_tree *tree, tvbuff_t *tvb, int offset, gint hf_embed)
2341 {
2342 /* Well-Known Prefix for IPv4-Embedded IPv6 Address: 64:FF9B::/96 */
2343 static const guint8 ipv6_embedded_ipv4_well_known_prefix[] = {
2344 0x00, 0x64, 0xFF, 0x9B,
2345 0x00, 0x00, 0x00, 0x00,
2346 0x00, 0x00, 0x00, 0x00
2347 };
2348 /* Check for well-known prefix */
2349 if (tvb_memeql(tvb, offset, ipv6_embedded_ipv4_well_known_prefix, 12) != 0)
2350 return;
2351
2352 struct { gint embed; } hf[2] = {
2353 { hf_embed },
2354 { hf_ipv6_embed_ipv4 }
2355 };
2356 proto_item *ti;
2357 for (int i = 0; i < 2; i++) {
2358 ti = proto_tree_add_item(tree, hf[i].embed, tvb, offset + 12, 4, ENC_NA);
2359 ADDRESS_SET_GENERATED_HIDDEN(ti);
2360 }
2361 }
2362
2363 static int
2364 dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
2365 {
2366 proto_tree *ipv6_tree, *pt;
2367 proto_item *ipv6_item, *ti, *pi;
2368 proto_item *ti_ipv6_plen = NULL, *ti_ipv6_version;
2369 guint8 ip6_tcls, ip6_nxt, ip6_hlim;
2370 guint32 ip6_flow;
2371 const ws_in6_addr *ip6_src, *ip6_dst;
2372 guint32 ip6_plen = 0, jumbo_plen = 0;
2373 guint32 plen;
2374 int offset;
2375 guint reported_plen;
2376 tvbuff_t *next_tvb;
2377 gboolean save_fragmented;
2378 int version;
2379 ws_ip6 *iph;
2380
2381 offset = 0;
2382
2383 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPv6");
2384 col_clear(pinfo->cinfo, COL_INFO);
2385
2386 ipv6_item = proto_tree_add_item(tree, proto_ipv6, tvb, offset, IPv6_HDR_SIZE, ENC_NA);
2387 ipv6_tree = proto_item_add_subtree(ipv6_item, ett_ipv6_proto);
2388
2389 /* Validate IP version (6) */
2390 version = tvb_get_bits8(tvb, (offset + IP6H_CTL_VFC) * 8, 4);
2391 ti_ipv6_version = proto_tree_add_bits_item(ipv6_tree, hf_ipv6_version, tvb,
2392 (offset + IP6H_CTL_VFC) * 8, 4, ENC_BIG_ENDIAN);
2393 pi = proto_tree_add_item(ipv6_tree, hf_ip_version, tvb,
2394 offset + IP6H_CTL_VFC, 1, ENC_BIG_ENDIAN);
2395 proto_item_append_text(pi, " [This field makes the filter match on \"ip.version == 6\" possible]");
2396 proto_item_set_hidden(pi);
2397 if (version != 6) {
2398 col_add_fstr(pinfo->cinfo, COL_INFO,
2399 "Bogus IPv6 version (%u, must be 6)", version);
2400 expert_add_info_format(pinfo, ti_ipv6_version, &ei_ipv6_bogus_ipv6_version, "Bogus IPv6 version");
2401 return offset + IP6H_CTL_VFC;
2402 }
2403
2404 /* Validate header size (40 bytes) */
2405 if (tvb_reported_length(tvb) < IPv6_HDR_SIZE) {
2406 col_add_fstr(pinfo->cinfo, COL_INFO,
2407 "Invalid IPv6 header (%u bytes, need exactly 40)",
2408 tvb_reported_length(tvb));
2409 expert_add_info_format(pinfo, ipv6_item, &ei_ipv6_invalid_header,
2410 "IPv6 header must be exactly 40 bytes");
2411 }
2412
2413 /* !!! warning: (4-bit) version, (6-bit) DSCP, (2-bit) ECN and (20-bit) Flow */
2414 ti = proto_tree_add_item(ipv6_tree, hf_ipv6_tclass, tvb,
2415 offset + IP6H_CTL_VFC, 4, ENC_BIG_ENDIAN);
2416 ip6_tcls = tvb_get_bits8(tvb, (offset + IP6H_CTL_VFC) * 8 + 4, 8);
2417 proto_item_append_text(ti, " (DSCP: %s, ECN: %s)",
2418 val_to_str_ext_const(IPDSFIELD_DSCP(ip6_tcls), &dscp_short_vals_ext, "Unknown"),
2419 val_to_str_ext_const(IPDSFIELD_ECN(ip6_tcls), &ecn_short_vals_ext, "Unknown"));
2420
2421 pt = proto_item_add_subtree(ti, ett_ipv6_traffic_class);
2422 proto_tree_add_item(pt, hf_ipv6_tclass_dscp, tvb,
2423 offset + IP6H_CTL_VFC, 4, ENC_BIG_ENDIAN);
2424 proto_tree_add_item(pt, hf_ipv6_tclass_ecn, tvb,
2425 offset + IP6H_CTL_VFC, 4, ENC_BIG_ENDIAN);
2426
2427 /* Set DSCP column */
2428 col_add_str(pinfo->cinfo, COL_DSCP_VALUE,
2429 val_to_str_ext(IPDSFIELD_DSCP(ip6_tcls), &dscp_short_vals_ext, "%u"));
2430
2431 proto_tree_add_item_ret_uint(ipv6_tree, hf_ipv6_flow, tvb,
2432 offset + IP6H_CTL_FLOW + 1, 3, ENC_BIG_ENDIAN, &ip6_flow);
2433
2434 ip6_plen = tvb_get_guint16(tvb, offset + IP6H_CTL_PLEN, ENC_BIG_ENDIAN);
2435
2436 ip6_nxt = tvb_get_guint8(tvb, offset + IP6H_CTL_NXT);
2437
2438 if (ipv6_tso_supported && ip6_plen == 0 &&
2439 ip6_nxt != IP_PROTO_HOPOPTS && ip6_nxt != IP_PROTO_NONE) {
2440 ip6_plen = tvb_reported_length(tvb) - IPv6_HDR_SIZE;
2441 pi = proto_tree_add_uint_format_value(ipv6_tree, hf_ipv6_plen, tvb,
2442 offset + IP6H_CTL_PLEN, 2, ip6_plen,
2443 "%u bytes (reported as 0, presumed to be because "
2444 "of \"TCP segmentation offload\" (TSO))",
2445 ip6_plen);
2446 proto_item_set_generated(pi);
2447 } else {
2448 ti_ipv6_plen = proto_tree_add_item(ipv6_tree, hf_ipv6_plen, tvb,
2449 offset + IP6H_CTL_PLEN, 2, ENC_BIG_ENDIAN);
2450 if (ip6_plen == 0 && ip6_nxt != IP_PROTO_HOPOPTS && ip6_nxt != IP_PROTO_NONE) {
2451 expert_add_info(pinfo, ti_ipv6_plen, &ei_ipv6_plen_zero);
2452 }
2453 }
2454
2455 proto_tree_add_item(ipv6_tree, hf_ipv6_nxt, tvb, offset + IP6H_CTL_NXT, 1, ENC_NA);
2456
2457 proto_tree_add_item(ipv6_tree, hf_ipv6_hlim, tvb,
2458 offset + IP6H_CTL_HLIM, 1, ENC_BIG_ENDIAN);
2459 ip6_hlim = tvb_get_guint8(tvb, offset + IP6H_CTL_HLIM);
2460
2461 /* Source address */
2462 add_ipv6_address(pinfo, ipv6_tree, tvb, offset + IP6H_SRC, hf_ipv6_src, hf_ipv6_src_host);
2463 ip6_src = tvb_get_ptr_ipv6(tvb, offset + IP6H_SRC);
2464 alloc_address_wmem_ipv6(pinfo->pool, &pinfo->net_src, ip6_src);
2465 copy_address_shallow(&pinfo->src, &pinfo->net_src);
2466
2467 /* Destination address */
2468 add_ipv6_address(pinfo, ipv6_tree, tvb, offset + IP6H_DST, hf_ipv6_dst, hf_ipv6_dst_host);
2469 ip6_dst = tvb_get_ptr_ipv6(tvb, offset + IP6H_DST);
2470 alloc_address_wmem_ipv6(pinfo->pool, &pinfo->net_dst, ip6_dst);
2471 copy_address_shallow(&pinfo->dst, &pinfo->net_dst);
2472
2473 if (tree) {
2474 if (ipv6_summary_in_tree) {
2475 proto_item_append_text(ipv6_item, ", Src: %s, Dst: %s",
2476 address_with_resolution_to_str(pinfo->pool, &pinfo->src),
2477 address_with_resolution_to_str(pinfo->pool, &pinfo->dst));
2478 }
2479
2480 /* Add the different items for the address */
2481 add_ipv6_address_6to4(ipv6_tree, tvb, offset + IP6H_SRC,
2482 hf_ipv6_src_6to4_gateway_ipv4, hf_ipv6_src_6to4_sla_id);
2483 add_ipv6_address_6to4(ipv6_tree, tvb, offset + IP6H_DST,
2484 hf_ipv6_dst_6to4_gateway_ipv4, hf_ipv6_dst_6to4_sla_id);
2485
2486 add_ipv6_address_teredo(ipv6_tree, tvb, offset + IP6H_SRC,
2487 hf_ipv6_src_teredo_server_ipv4, hf_ipv6_src_teredo_port, hf_ipv6_src_teredo_client_ipv4);
2488 add_ipv6_address_teredo(ipv6_tree, tvb, offset + IP6H_DST,
2489 hf_ipv6_dst_teredo_server_ipv4, hf_ipv6_dst_teredo_port, hf_ipv6_dst_teredo_client_ipv4);
2490
2491 add_ipv6_address_slaac(pinfo, ipv6_tree, tvb, offset + IP6H_SRC, hf_ipv6_src_slaac_mac);
2492 add_ipv6_address_slaac(pinfo, ipv6_tree, tvb, offset + IP6H_DST, hf_ipv6_dst_slaac_mac);
2493
2494 add_ipv6_address_isatap(ipv6_tree, tvb, offset + IP6H_SRC, hf_ipv6_src_isatap_ipv4);
2495 add_ipv6_address_isatap(ipv6_tree, tvb, offset + IP6H_DST, hf_ipv6_dst_isatap_ipv4);
2496
2497 add_ipv6_address_embed_ipv4(ipv6_tree, tvb, offset + IP6H_SRC, hf_ipv6_src_embed_ipv4);
2498 add_ipv6_address_embed_ipv4(ipv6_tree, tvb, offset + IP6H_DST, hf_ipv6_dst_embed_ipv4);
2499
2500 if (ipv6_use_geoip) {
2501 add_geoip_info(ipv6_tree, pinfo, tvb, offset, ip6_src, ip6_dst);
2502 }
2503 }
2504
2505 /* Increment offset to point to next header (may be an extension header) */
2506 offset += IPv6_HDR_SIZE;
2507
2508 /* Check for Jumbo option */
2509 plen = ip6_plen;
2510 if (plen == 0 && ip6_nxt == IP_PROTO_HOPOPTS) {
2511 jumbo_plen = ipv6_get_jumbo_plen(tvb, offset);
2512 if (jumbo_plen != 0) {
2513 proto_item_append_text(ti_ipv6_plen, " (Jumbogram)");
2514 plen = jumbo_plen;
2515 } else {
2516 /* IPv6 length zero is invalid if there is a hop-by-hop header without jumbo option */
2517 col_add_fstr(pinfo->cinfo, COL_INFO, "Invalid IPv6 payload length");
2518 expert_add_info(pinfo, ti_ipv6_plen, &ei_ipv6_opt_jumbo_missing);
2519 }
2520 }
2521
2522 reported_plen = tvb_reported_length(tvb) - IPv6_HDR_SIZE;
2523 if (!pinfo->flags.in_error_pkt && plen > reported_plen) {
2524 expert_add_info_format(pinfo, ti_ipv6_plen, &ei_ipv6_plen_exceeds_framing,
2525 "IPv6 payload length exceeds framing length (%d bytes)", reported_plen);
2526 }
2527
2528 /* Fill in IP header fields for subdissectors */
2529 iph = wmem_new0(pinfo->pool, ws_ip6);
2530 iph->ip6_ver = 6;
2531 iph->ip6_tc = ip6_tcls;
2532 iph->ip6_flw = ip6_flow;
2533 iph->ip6_len = plen;
2534 iph->ip6_nxt = ip6_nxt;
2535 iph->ip6_hop = ip6_hlim;
2536 alloc_address_wmem_ipv6(pinfo->pool, &iph->ip6_src, ip6_src);
2537 alloc_address_wmem_ipv6(pinfo->pool, &iph->ip6_dst, ip6_dst);
2538
2539 /* Shared state between IPv6 header and extensions. */
2540 ipv6_pinfo_t *ipv6_pinfo = wmem_new0(pinfo->pool, ipv6_pinfo_t);
2541 ipv6_pinfo->ip6_plen = ip6_plen;
2542 ipv6_pinfo->jumbo_plen = jumbo_plen;
2543 ipv6_pinfo->frag_plen = ip6_plen; /* updated by extension header dissectors, if any */
2544 if (!ipv6_exthdr_under_root) {
2545 ipv6_pinfo->ipv6_tree = ipv6_tree;
2546 ipv6_pinfo->ipv6_item_len = IPv6_HDR_SIZE;
2547 }
2548 p_add_proto_data(pinfo->pool, pinfo, proto_ipv6, IPV6_PROTO_PINFO, ipv6_pinfo);
2549
2550 /* Adjust the length of this tvbuff to include only the IPv6 datagram. */
2551 set_actual_length(tvb, IPv6_HDR_SIZE + plen);
2552 save_fragmented = pinfo->fragmented;
2553
2554 p_add_ipv6_nxt(pinfo, ip6_nxt);
2555
2556 next_tvb = tvb_new_subset_remaining(tvb, offset);
2557 ipv6_dissect_next(ip6_nxt, next_tvb, pinfo, tree, iph);
2558
2559 pinfo->fragmented = save_fragmented;
2560 return tvb_captured_length(tvb);
2561 }
2562
2563 void
2564 ipv6_dissect_next(guint nxt, tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ws_ip6 *iph)
2565 {
2566 dissector_handle_t nxt_handle;
2567 ipv6_pinfo_t *ipv6_pinfo = p_get_ipv6_pinfo(pinfo);
2568
2569 switch (nxt) {
2570 case IP_PROTO_HOPOPTS:
2571 case IP_PROTO_ROUTING:
2572 case IP_PROTO_FRAGMENT:
2573 case IP_PROTO_DSTOPTS:
2574 case IP_PROTO_AH:
2575 case IP_PROTO_MIPV6:
2576 case IP_PROTO_SHIM6:
2577 nxt_handle = dissector_get_uint_handle(ip_dissector_table, nxt);
2578 break;
2579 default:
2580 nxt_handle = NULL;
2581 break;
2582 }
2583 if (nxt_handle != NULL) {
2584 call_dissector_with_data(nxt_handle, tvb, pinfo, tree, iph);
2585 return;
2586 }
2587
2588 /*
2589 * Done with extension header chain
2590 */
2591
2592 if (ipv6_pinfo != NULL && ipv6_pinfo->ipv6_tree != NULL) {
2593 /* Set IPv6 Header length */
2594 proto_item_set_len(proto_tree_get_parent(ipv6_pinfo->ipv6_tree), ipv6_pinfo->ipv6_item_len);
2595 ipv6_pinfo->ipv6_tree = NULL;
2596 }
2597
2598 if (iph != NULL && iph->ip6_ver == 6) {
2599 iph->ip6_nxt = nxt; /* upper-layer protocol more useful */
2600 tap_queue_packet(ipv6_tap, pinfo, iph);
2601 }
2602
2603 if (nxt == IP_PROTO_NONE) {
2604 col_set_str(pinfo->cinfo, COL_INFO, "IPv6 no next header");
2605 call_data_dissector(tvb, pinfo, tree);
2606 return;
2607 }
2608
2609 if (ip_try_dissect(try_heuristic_first, nxt, tvb, pinfo, tree, iph)) {
2610 return;
2611 }
2612
2613 /* Unknown protocol. */
2614 col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown IP Protocol: %s (%u)", ipprotostr(nxt), nxt);
2615 call_data_dissector(tvb, pinfo, tree);
2616 }
2617
2618 void
2619 proto_register_ipv6(void)
2620 {
2621 static hf_register_info hf_ipv6[] = {
2622 { &hf_ipv6_version,
2623 { "Version", "ipv6.version",
2624 FT_UINT8, BASE_DEC, NULL, 0x00,
2625 NULL, HFILL }
2626 },
2627 { &hf_ip_version,
2628 { "Version", "ip.version",
2629 FT_UINT8, BASE_DEC, NULL, 0xF0,
2630 NULL, HFILL }
2631 },
2632 { &hf_ipv6_tclass,
2633 { "Traffic Class", "ipv6.tclass",
2634 FT_UINT32, BASE_HEX, NULL, 0x0FF00000,
2635 NULL, HFILL }
2636 },
2637 { &hf_ipv6_tclass_dscp,
2638 { "Differentiated Services Codepoint", "ipv6.tclass.dscp",
2639 FT_UINT32, BASE_DEC | BASE_EXT_STRING, &dscp_vals_ext, 0x0FC00000,
2640 NULL, HFILL }
2641 },
2642 { &hf_ipv6_tclass_ecn,
2643 { "Explicit Congestion Notification", "ipv6.tclass.ecn",
2644 FT_UINT32, BASE_DEC | BASE_EXT_STRING, &ecn_vals_ext, 0x00300000,
2645 NULL, HFILL }
2646 },
2647 { &hf_ipv6_flow,
2648 { "Flow Label", "ipv6.flow",
2649 FT_UINT24, BASE_HEX, NULL, 0x0FFFFF,
2650 NULL, HFILL }
2651 },
2652 { &hf_ipv6_plen,
2653 { "Payload Length", "ipv6.plen",
2654 FT_UINT16, BASE_DEC, NULL, 0x0,
2655 NULL, HFILL }
2656 },
2657 { &hf_ipv6_nxt,
2658 { "Next Header", "ipv6.nxt",
2659 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x0,
2660 NULL, HFILL }
2661 },
2662 { &hf_ipv6_hlim,
2663 { "Hop Limit", "ipv6.hlim",
2664 FT_UINT8, BASE_DEC, NULL, 0x0,
2665 NULL, HFILL }
2666 },
2667 { &hf_ipv6_src,
2668 { "Source Address", "ipv6.src",
2669 FT_IPv6, BASE_NONE, NULL, 0x0,
2670 "Source IPv6 Address", HFILL }
2671 },
2672 { &hf_ipv6_src_host,
2673 { "Source Host", "ipv6.src_host",
2674 FT_STRING, BASE_NONE, NULL, 0x0,
2675 "Source IPv6 Host", HFILL }
2676 },
2677 { &hf_ipv6_src_slaac_mac,
2678 { "Source SLAAC MAC", "ipv6.src_slaac_mac",
2679 FT_ETHER, BASE_NONE, NULL, 0x0,
2680 "Source IPv6 Stateless Address Autoconfiguration (SLAAC) 48-bit MAC Identifier", HFILL }
2681 },
2682 { &hf_ipv6_src_isatap_ipv4,
2683 { "Source ISATAP IPv4", "ipv6.src_isatap_ipv4",
2684 FT_IPv4, BASE_NONE, NULL, 0x0,
2685 "Source IPv6 ISATAP Encapsulated IPv4 Address", HFILL }
2686 },
2687 { &hf_ipv6_src_6to4_gateway_ipv4,
2688 { "Source 6to4 Gateway IPv4", "ipv6.src_6to4_gw_ipv4",
2689 FT_IPv4, BASE_NONE, NULL, 0x0,
2690 "Source IPv6 6to4 Gateway IPv4 Address", HFILL }
2691 },
2692 { &hf_ipv6_src_6to4_sla_id,
2693 { "Source 6to4 SLA ID", "ipv6.src_6to4_sla_id",
2694 FT_UINT16, BASE_DEC, NULL, 0x0,
2695 "Source IPv6 6to4 SLA ID", HFILL }
2696 },
2697 { &hf_ipv6_src_teredo_server_ipv4,
2698 { "Source Teredo Server IPv4", "ipv6.src_ts_ipv4",
2699 FT_IPv4, BASE_NONE, NULL, 0x0,
2700 "Source IPv6 Teredo Server Encapsulated IPv4 Address", HFILL }
2701 },
2702 { &hf_ipv6_src_teredo_port,
2703 { "Source Teredo Port", "ipv6.src_tc_port",
2704 FT_UINT16, BASE_DEC, NULL, 0x0,
2705 "Source IPv6 Teredo Client Mapped Port", HFILL }
2706 },
2707 { &hf_ipv6_src_teredo_client_ipv4,
2708 { "Source Teredo Client IPv4", "ipv6.src_tc_ipv4",
2709 FT_IPv4, BASE_NONE, NULL, 0x0,
2710 "Source IPv6 Teredo Client Encapsulated IPv4 Address", HFILL }
2711 },
2712 { &hf_ipv6_src_embed_ipv4,
2713 { "Source Embedded IPv4", "ipv6.src_embed_ipv4",
2714 FT_IPv4, BASE_NONE, NULL, 0x0,
2715 "Source IPv4-Embedded IPv6 Address with Well-Known Prefix", HFILL }
2716 },
2717 { &hf_ipv6_dst,
2718 { "Destination Address", "ipv6.dst",
2719 FT_IPv6, BASE_NONE, NULL, 0x0,
2720 "Destination IPv6 Address", HFILL }
2721 },
2722 { &hf_ipv6_dst_host,
2723 { "Destination Host", "ipv6.dst_host",
2724 FT_STRING, BASE_NONE, NULL, 0x0,
2725 "Destination IPv6 Host", HFILL }
2726 },
2727 { &hf_ipv6_dst_slaac_mac,
2728 { "Destination SLAAC MAC", "ipv6.dst_slaac_mac",
2729 FT_ETHER, BASE_NONE, NULL, 0x0,
2730 "Destination IPv6 Stateless Address Autoconfiguration (SLAAC) 48-bit MAC Identifier", HFILL }
2731 },
2732 { &hf_ipv6_dst_isatap_ipv4,
2733 { "Destination ISATAP IPv4", "ipv6.dst_isatap_ipv4",
2734 FT_IPv4, BASE_NONE, NULL, 0x0,
2735 "Destination IPv6 ISATAP Encapsulated IPv4 Address", HFILL }
2736 },
2737 { &hf_ipv6_dst_6to4_gateway_ipv4,
2738 { "Destination 6to4 Gateway IPv4", "ipv6.dst_6to4_gw_ipv4",
2739 FT_IPv4, BASE_NONE, NULL, 0x0,
2740 "Destination IPv6 6to4 Gateway IPv4 Address", HFILL }
2741 },
2742 { &hf_ipv6_dst_6to4_sla_id,
2743 { "Destination 6to4 SLA ID", "ipv6.dst_6to4_sla_id",
2744 FT_UINT16, BASE_DEC, NULL, 0x0,
2745 "Destination IPv6 6to4 SLA ID", HFILL }
2746 },
2747 { &hf_ipv6_dst_teredo_server_ipv4,
2748 { "Destination Teredo Server IPv4", "ipv6.dst_ts_ipv4",
2749 FT_IPv4, BASE_NONE, NULL, 0x0,
2750 "Destination IPv6 Teredo Server Encapsulated IPv4 Address", HFILL }
2751 },
2752 { &hf_ipv6_dst_teredo_port,
2753 { "Destination Teredo Port", "ipv6.dst_tc_port",
2754 FT_UINT16, BASE_DEC, NULL, 0x0,
2755 "Destination IPv6 Teredo Client Mapped Port", HFILL }
2756 },
2757 { &hf_ipv6_dst_teredo_client_ipv4,
2758 { "Destination Teredo Client IPv4", "ipv6.dst_tc_ipv4",
2759 FT_IPv4, BASE_NONE, NULL, 0x0,
2760 "Destination IPv6 Teredo Client Encapsulated IPv4 Address", HFILL }
2761 },
2762 { &hf_ipv6_dst_embed_ipv4,
2763 { "Destination Embedded IPv4", "ipv6.dst_embed_ipv4",
2764 FT_IPv4, BASE_NONE, NULL, 0x0,
2765 "Destination IPv4-Embedded IPv6 Address with Well-Known Prefix", HFILL }
2766 },
2767 { &hf_ipv6_addr,
2768 { "Source or Destination Address", "ipv6.addr",
2769 FT_IPv6, BASE_NONE, NULL, 0x0,
2770 NULL, HFILL }
2771 },
2772 { &hf_ipv6_host,
2773 { "Source or Destination Host", "ipv6.host",
2774 FT_STRING, BASE_NONE, NULL, 0x0,
2775 NULL, HFILL }
2776 },
2777 { &hf_ipv6_slaac_mac,
2778 { "SLAAC MAC", "ipv6.slaac_mac",
2779 FT_ETHER, BASE_NONE, NULL, 0x0,
2780 "IPv6 Stateless Address Autoconfiguration (SLAAC) 48-bit MAC Identifier", HFILL }
2781 },
2782 { &hf_ipv6_isatap_ipv4,
2783 { "ISATAP IPv4", "ipv6.isatap_ipv4",
2784 FT_IPv4, BASE_NONE, NULL, 0x0,
2785 "IPv6 ISATAP Encapsulated IPv4 Address", HFILL }
2786 },
2787 { &hf_ipv6_6to4_gateway_ipv4,
2788 { "6to4 Gateway IPv4", "ipv6.6to4_gw_ipv4",
2789 FT_IPv4, BASE_NONE, NULL, 0x0,
2790 "IPv6 6to4 Gateway IPv4 Address", HFILL }
2791 },
2792 { &hf_ipv6_6to4_sla_id,
2793 { "6to4 SLA ID", "ipv6.6to4_sla_id",
2794 FT_UINT16, BASE_DEC, NULL, 0x0,
2795 "IPv6 6to4 SLA ID", HFILL }
2796 },
2797 { &hf_ipv6_teredo_server_ipv4,
2798 { "Teredo Server IPv4", "ipv6.ts_ipv4",
2799 FT_IPv4, BASE_NONE, NULL, 0x0,
2800 "IPv6 Teredo Server Encapsulated IPv4 Address", HFILL }
2801 },
2802 { &hf_ipv6_teredo_port,
2803 { "Teredo Port", "ipv6.tc_port",
2804 FT_UINT16, BASE_DEC, NULL, 0x0,
2805 "IPv6 Teredo Client Mapped Port", HFILL }
2806 },
2807 { &hf_ipv6_teredo_client_ipv4,
2808 { "Teredo Client IPv4", "ipv6.tc_ipv4",
2809 FT_IPv4, BASE_NONE, NULL, 0x0,
2810 "IPv6 Teredo Client Encapsulated IPv4 Address", HFILL }
2811 },
2812 { &hf_ipv6_embed_ipv4,
2813 { "Embedded IPv4", "ipv6.embed_ipv4",
2814 FT_IPv4, BASE_NONE, NULL, 0x0,
2815 "IPv4-Embedded IPv6 Address with Well-Known Prefix", HFILL }
2816 },
2817
2818 { &hf_geoip_country,
2819 { "Source or Destination GeoIP Country", "ipv6.geoip.country",
2820 FT_STRING, STR_UNICODE, NULL, 0x0,
2821 NULL, HFILL }
2822 },
2823 { &hf_geoip_country_iso,
2824 { "Source or Destination GeoIP ISO Two Letter Country Code", "ipv6.geoip.country_iso",
2825 FT_STRING, STR_UNICODE, NULL, 0x0,
2826 NULL, HFILL }
2827 },
2828 { &hf_geoip_city,
2829 { "Source or Destination GeoIP City", "ipv6.geoip.city",
2830 FT_STRING, STR_UNICODE, NULL, 0x0,
2831 NULL, HFILL }
2832 },
2833 { &hf_geoip_as_number,
2834 { "Source or Destination GeoIP AS Number", "ipv6.geoip.asnum",
2835 FT_UINT32, BASE_DEC, NULL, 0x0,
2836 NULL, HFILL }
2837 },
2838 { &hf_geoip_as_org,
2839 { "Source or Destination GeoIP AS Organization", "ipv6.geoip.org",
2840 FT_STRING, STR_UNICODE, NULL, 0x0,
2841 NULL, HFILL }
2842 },
2843 { &hf_geoip_latitude,
2844 { "Source or Destination GeoIP Latitude", "ipv6.geoip.lat",
2845 FT_DOUBLE, BASE_NONE, NULL, 0x0,
2846 NULL, HFILL }
2847 },
2848 { &hf_geoip_longitude,
2849 { "Source or Destination GeoIP Longitude", "ipv6.geoip.lon",
2850 FT_DOUBLE, BASE_NONE, NULL, 0x0,
2851 NULL, HFILL }
2852 },
2853 { &hf_geoip_src_summary,
2854 { "Source GeoIP", "ipv6.geoip.src_summary",
2855 FT_STRING, STR_UNICODE, NULL, 0x0,
2856 NULL, HFILL }
2857 },
2858 { &hf_geoip_src_country,
2859 { "Source GeoIP Country", "ipv6.geoip.src_country",
2860 FT_STRING, STR_UNICODE, NULL, 0x0,
2861 NULL, HFILL }
2862 },
2863 { &hf_geoip_src_country_iso,
2864 { "Source GeoIP ISO Two Letter Country Code", "ipv6.geoip.src_country_iso",
2865 FT_STRING, STR_UNICODE, NULL, 0x0,
2866 NULL, HFILL }
2867 },
2868 { &hf_geoip_src_city,
2869 { "Source GeoIP City", "ipv6.geoip.src_city",
2870 FT_STRING, STR_UNICODE, NULL, 0x0,
2871 NULL, HFILL }
2872 },
2873 { &hf_geoip_src_as_number,
2874 { "Source GeoIP AS Number", "ipv6.geoip.src_asnum",
2875 FT_UINT32, BASE_DEC, NULL, 0x0,
2876 NULL, HFILL }
2877 },
2878 { &hf_geoip_src_as_org,
2879 { "Source GeoIP AS Organization", "ipv6.geoip.src_org",
2880 FT_STRING, STR_UNICODE, NULL, 0x0,
2881 NULL, HFILL }
2882 },
2883 { &hf_geoip_src_latitude,
2884 { "Source GeoIP Latitude", "ipv6.geoip.src_lat",
2885 FT_DOUBLE, BASE_NONE, NULL, 0x0,
2886 NULL, HFILL }
2887 },
2888 { &hf_geoip_src_longitude,
2889 { "Source GeoIP Longitude", "ipv6.geoip.src_lon",
2890 FT_DOUBLE, BASE_NONE, NULL, 0x0,
2891 NULL, HFILL }
2892 },
2893 { &hf_geoip_dst_summary,
2894 { "Destination GeoIP", "ipv6.geoip.dst_summary",
2895 FT_STRING, STR_UNICODE, NULL, 0x0,
2896 NULL, HFILL }
2897 },
2898 { &hf_geoip_dst_country,
2899 { "Destination GeoIP Country", "ipv6.geoip.dst_country",
2900 FT_STRING, STR_UNICODE, NULL, 0x0,
2901 NULL, HFILL }
2902 },
2903 { &hf_geoip_dst_country_iso,
2904 { "Destination GeoIP ISO Two Letter Country Code", "ipv6.geoip.dst_country_iso",
2905 FT_STRING, STR_UNICODE, NULL, 0x0,
2906 NULL, HFILL }
2907 },
2908 { &hf_geoip_dst_city,
2909 { "Destination GeoIP City", "ipv6.geoip.dst_city",
2910 FT_STRING, STR_UNICODE, NULL, 0x0,
2911 NULL, HFILL }
2912 },
2913 { &hf_geoip_dst_as_number,
2914 { "Destination GeoIP AS Number", "ipv6.geoip.dst_asnum",
2915 FT_UINT32, BASE_DEC, NULL, 0x0,
2916 NULL, HFILL }
2917 },
2918 { &hf_geoip_dst_as_org,
2919 { "Destination GeoIP AS Organization", "ipv6.geoip.dst_org",
2920 FT_STRING, STR_UNICODE, NULL, 0x0,
2921 NULL, HFILL }
2922 },
2923 { &hf_geoip_dst_latitude,
2924 { "Destination GeoIP Latitude", "ipv6.geoip.dst_lat",
2925 FT_DOUBLE, BASE_NONE, NULL, 0x0,
2926 NULL, HFILL }
2927 },
2928 { &hf_geoip_dst_longitude,
2929 { "Destination GeoIP Longitude", "ipv6.geoip.dst_lon",
2930 FT_DOUBLE, BASE_NONE, NULL, 0x0,
2931 NULL, HFILL }
2932 },
2933
2934 { &hf_ipv6_opt,
2935 { "IPv6 Option", "ipv6.opt",
2936 FT_NONE, BASE_NONE, NULL, 0x0,
2937 "Option", HFILL }
2938 },
2939 { &hf_ipv6_opt_type,
2940 { "Type", "ipv6.opt.type",
2941 FT_UINT8, BASE_HEX | BASE_EXT_STRING, &ipv6_opt_type_vals_ext, 0x0,
2942 "Option type", HFILL }
2943 },
2944 { &hf_ipv6_opt_type_action,
2945 { "Action", "ipv6.opt.type.action",
2946 FT_UINT8, BASE_DEC, VALS(ipv6_opt_type_action_vals), 0xC0,
2947 "Action for unrecognized option type", HFILL }
2948 },
2949 { &hf_ipv6_opt_type_change,
2950 { "May Change", "ipv6.opt.type.change",
2951 FT_BOOLEAN, 8, TFS(&tfs_yes_no), 0x20,
2952 "Whether the option data may change en-route", HFILL }
2953 },
2954 { &hf_ipv6_opt_type_rest,
2955 { "Low-Order Bits", "ipv6.opt.type.rest",
2956 FT_UINT8, BASE_HEX, NULL, 0x1F,
2957 "Remaining low-order bits", HFILL }
2958 },
2959 { &hf_ipv6_opt_length,
2960 { "Length", "ipv6.opt.length",
2961 FT_UINT8, BASE_DEC, NULL, 0x0,
2962 "Option length in octets", HFILL }
2963 },
2964 { &hf_ipv6_opt_pad1,
2965 { "Pad1", "ipv6.opt.pad1",
2966 FT_NONE, BASE_NONE, NULL, 0x0,
2967 "Pad1 Option", HFILL }
2968 },
2969 { &hf_ipv6_opt_padn,
2970 { "PadN", "ipv6.opt.padn",
2971 FT_BYTES, BASE_NONE|BASE_ALLOW_ZERO, NULL, 0x0,
2972 "PadN Option", HFILL }
2973 },
2974 { &hf_ipv6_opt_pmtu_min,
2975 { "Minimum Reported PMTU", "ipv6.opt.pmtu.min",
2976 FT_UINT16, BASE_DEC, NULL, 0x0,
2977 "The minimum reported PMTU in octets", HFILL }
2978 },
2979 { &hf_ipv6_opt_pmtu_rtn,
2980 { "Return Minimum PMTU", "ipv6.opt.pmtu.rtn",
2981 FT_UINT16, BASE_DEC, NULL, 0x0,
2982 "The Return Min-PMTU in octets", HFILL }
2983 },
2984 { &hf_ipv6_opt_pmtu_rtn_flag,
2985 { "Return Flag", "ipv6.opt.pmtu.r_flag",
2986 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
2987 "Destination should include the received reported PMTU", HFILL }
2988 },
2989 { &hf_ipv6_opt_rtalert,
2990 { "Router Alert", "ipv6.opt.router_alert",
2991 FT_UINT16, BASE_DEC, VALS(ipv6_opt_rtalert_vals), 0x0,
2992 "Router Alert Option", HFILL }
2993 },
2994 { &hf_ipv6_opt_tel,
2995 { "Tunnel Encapsulation Limit", "ipv6.opt.tel",
2996 FT_UINT8, BASE_DEC, NULL, 0x0,
2997 "How many further levels of encapsulation are permitted", HFILL }
2998 },
2999 { &hf_ipv6_opt_jumbo,
3000 { "Payload Length", "ipv6.opt.jumbo",
3001 FT_UINT32, BASE_DEC, NULL, 0x0,
3002 "IPv6 (Jumbo) Payload Length", HFILL }
3003 },
3004 { &hf_ipv6_opt_calipso_doi,
3005 { "CALIPSO Domain of Interpretation", "ipv6.opt.calipso.doi",
3006 FT_UINT8, BASE_DEC, NULL, 0x0,
3007 NULL, HFILL }
3008 },
3009 { &hf_ipv6_opt_calipso_cmpt_length,
3010 { "Compartment Length", "ipv6.opt.calipso.cmpt.length",
3011 FT_UINT8, BASE_DEC, NULL, 0x0,
3012 NULL, HFILL }
3013 },
3014 { &hf_ipv6_opt_calipso_sens_level,
3015 { "Sensitivity Level", "ipv6.opt.calipso.sens_level",
3016 FT_UINT8, BASE_DEC, NULL, 0x0,
3017 NULL, HFILL }
3018 },
3019 { &hf_ipv6_opt_calipso_checksum,
3020 { "Checksum", "ipv6.opt.calipso.checksum",
3021 FT_UINT16, BASE_HEX, NULL, 0x0,
3022 NULL, HFILL }
3023 },
3024 { &hf_ipv6_opt_calipso_cmpt_bitmap,
3025 { "Compartment Bitmap", "ipv6.opt.calipso.cmpt_bitmap",
3026 FT_BYTES, BASE_NONE, NULL, 0x0,
3027 NULL, HFILL }
3028 },
3029 { &hf_ipv6_opt_smf_dpd_hash_bit,
3030 { "H-bit", "ipv6.opt.smf_dpd.hash_bit",
3031 FT_BOOLEAN, 8, NULL, 0x80,
3032 "Hash indicator", HFILL }
3033 },
3034 { &hf_ipv6_opt_smf_dpd_tid_type,
3035 { "TaggerID Type", "ipv6.opt.smf_dpd.tid_type",
3036 FT_UINT8, BASE_DEC, VALS(ipv6_opt_smf_dpd_tidty_vals), 0x70,
3037 NULL, HFILL }
3038 },
3039 { &hf_ipv6_opt_smf_dpd_tid_len,
3040 { "TaggerID Length", "ipv6.opt.smf_dpd.tid_len",
3041 FT_UINT8, BASE_DEC, NULL, 0x0F,
3042 NULL, HFILL }
3043 },
3044 { &hf_ipv6_opt_smf_dpd_tagger_id,
3045 { "TaggerID", "ipv6.opt.smf_dpd.tagger_id",
3046 FT_BYTES, BASE_NONE, NULL, 0x0,
3047 NULL, HFILL }
3048 },
3049 { &hf_ipv6_opt_smf_dpd_ident,
3050 { "Identifier", "ipv6.opt.smf_dpd.ident",
3051 FT_BYTES, BASE_NONE, NULL, 0x0,
3052 NULL, HFILL }
3053 },
3054 { &hf_ipv6_opt_smf_dpd_hav,
3055 { "Hash Assist Value", "ipv6.opt.smf_dpd.hav",
3056 FT_BYTES, BASE_NONE, NULL, 0x0,
3057 NULL, HFILL }
3058 },
3059 { &hf_ipv6_opt_pdm_scale_dtlr,
3060 { "Scale DTLR", "ipv6.opt.pdm.scale_dtlr",
3061 FT_UINT8, BASE_DEC, NULL, 0x0,
3062 "Scale for Delta Time Last Received", HFILL }
3063 },
3064 { &hf_ipv6_opt_pdm_scale_dtls,
3065 { "Scale DTLS", "ipv6.opt.pdm.scale_dtls",
3066 FT_UINT8, BASE_DEC, NULL, 0x0,
3067 "Scale for Delta Time Last Sent", HFILL }
3068 },
3069 { &hf_ipv6_opt_pdm_psn_this_pkt,
3070 { "PSN This Packet", "ipv6.opt.pdm.psn_this_pkt",
3071 FT_UINT16, BASE_DEC, NULL, 0x0,
3072 "Packet Sequence Number This Packet", HFILL }
3073 },
3074 { &hf_ipv6_opt_pdm_psn_last_recv,
3075 { "PSN Last Received", "ipv6.opt.pdm.psn_last_recv",
3076 FT_UINT16, BASE_DEC, NULL, 0x0,
3077 "Packet Sequence Number Last Received", HFILL }
3078 },
3079 { &hf_ipv6_opt_pdm_delta_last_recv,
3080 { "Delta Time Last Received", "ipv6.opt.pdm.delta_last_recv",
3081 FT_UINT16, BASE_DEC, NULL, 0x0,
3082 NULL, HFILL }
3083 },
3084 { &hf_ipv6_opt_pdm_delta_last_sent,
3085 { "Delta Time Last Sent", "ipv6.opt.pdm.delta_last_sent",
3086 FT_UINT16, BASE_DEC, NULL, 0x0,
3087 NULL, HFILL }
3088 },
3089 { &hf_ipv6_opt_qs_func,
3090 { "Function", "ipv6.opt.qs_func",
3091 FT_UINT8, BASE_DEC, VALS(qs_func_vals), QS_FUNC_MASK,
3092 NULL, HFILL }
3093 },
3094 { &hf_ipv6_opt_qs_rate,
3095 { "Rate", "ipv6.opt.qs_rate",
3096 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &qs_rate_vals_ext, QS_RATE_MASK,
3097 NULL, HFILL }
3098 },
3099 { &hf_ipv6_opt_qs_ttl,
3100 { "QS TTL", "ipv6.opt.qs_ttl",
3101 FT_UINT8, BASE_DEC, NULL, 0x0,
3102 NULL, HFILL }
3103 },
3104 { &hf_ipv6_opt_qs_ttl_diff,
3105 { "TTL Diff", "ipv6.opt.qs_ttl_diff",
3106 FT_UINT8, BASE_DEC, NULL, 0x0,
3107 NULL, HFILL }
3108 },
3109 { &hf_ipv6_opt_qs_unused,
3110 { "Not Used", "ipv6.opt.qs_unused",
3111 FT_UINT8, BASE_DEC, NULL, 0x0,
3112 NULL, HFILL }
3113 },
3114 { &hf_ipv6_opt_qs_nonce,
3115 { "QS Nonce", "ipv6.opt.qs_nonce",
3116 FT_UINT32, BASE_HEX, NULL, 0xFFFFFFFC,
3117 NULL, HFILL }
3118 },
3119 { &hf_ipv6_opt_qs_reserved,
3120 { "Reserved", "ipv6.opt.qs_reserved",
3121 FT_UINT32, BASE_HEX, NULL, 0x0003,
3122 NULL, HFILL }
3123 },
3124 { &hf_ipv6_opt_tpf_information,
3125 { "TPF Information", "ipv6.opt.tpf_information",
3126 FT_UINT32, BASE_HEX, NULL, 0x0,
3127 "Tunnel Payload Forwarding Information", HFILL }
3128 },
3129 { &hf_ipv6_opt_mipv6_home_address,
3130 { "MIPv6 Home Address", "ipv6.opt.mipv6.home_address",
3131 FT_IPv6, BASE_NONE, NULL, 0x0,
3132 NULL, HFILL }
3133 },
3134 { &hf_ipv6_opt_rpl_flag,
3135 { "Flag", "ipv6.opt.rpl.flag",
3136 FT_UINT8, BASE_HEX, NULL, 0x0,
3137 NULL, HFILL }
3138 },
3139 { &hf_ipv6_opt_rpl_flag_o,
3140 { "Down", "ipv6.opt.rpl.flag.o",
3141 FT_BOOLEAN, 8, NULL, 0x80,
3142 "The packet is expected to progress Up or Down", HFILL }
3143 },
3144 { &hf_ipv6_opt_rpl_flag_r,
3145 { "Rank Error", "ipv6.opt.rpl.flag.r",
3146 FT_BOOLEAN, 8, NULL, 0x40,
3147 "Whether a rank error was detected", HFILL }
3148 },
3149 { &hf_ipv6_opt_rpl_flag_f,
3150 { "Forwarding Error", "ipv6.opt.rpl.flag.f",
3151 FT_BOOLEAN, 8, NULL, 0x20,
3152 "Set if the node cannot forward the packet further towards the destination", HFILL }
3153 },
3154 { &hf_ipv6_opt_rpl_flag_rsv,
3155 { "Reserved", "ipv6.opt.rpl.flag.rsv",
3156 FT_UINT8, BASE_HEX, NULL, 0x1F,
3157 "Reserved (must be zero)", HFILL }
3158 },
3159 { &hf_ipv6_opt_rpl_instance_id,
3160 { "RPLInstanceID", "ipv6.opt.rpl.instance_id",
3161 FT_UINT8, BASE_HEX, NULL, 0x0,
3162 "The DODAG instance along which the packet is sent", HFILL }
3163 },
3164 { &hf_ipv6_opt_rpl_senderrank,
3165 { "Sender Rank", "ipv6.opt.rpl.sender_rank",
3166 FT_UINT16, BASE_HEX, NULL, 0x0,
3167 "Set to zero by the source and to DAGRank(rank) by a router that forwards inside the RPL network", HFILL }
3168 },
3169 { &hf_ipv6_opt_ilnp_nonce,
3170 { "ILNP Nonce", "ipv6.opt.ilnp_nonce",
3171 FT_BYTES, BASE_NONE, NULL, 0x0,
3172 NULL, HFILL }
3173 },
3174 { &hf_ipv6_opt_lio_len,
3175 { "LineIDLen", "ipv6.opt.lio.length",
3176 FT_UINT8, BASE_DEC, NULL, 0x0,
3177 NULL, HFILL }
3178 },
3179 { &hf_ipv6_opt_lio_id,
3180 { "Line ID", "ipv6.opt.lio.line_id",
3181 FT_STRING, BASE_NONE, NULL, 0x0,
3182 NULL, HFILL }
3183 },
3184 { &hf_ipv6_opt_mpl_flag,
3185 { "Flag", "ipv6.opt.mpl.flag",
3186 FT_UINT8, BASE_HEX, NULL, 0x0,
3187 NULL, HFILL }
3188 },
3189 { &hf_ipv6_opt_mpl_flag_s,
3190 { "Seed ID Length", "ipv6.opt.mpl.flag.s",
3191 FT_UINT8, BASE_DEC, VALS(mpl_seed_id_len_vals), 0xC0,
3192 "Identifies the length of Seed ID", HFILL }
3193 },
3194 { &hf_ipv6_opt_mpl_flag_m,
3195 { "Largest Sequence", "ipv6.opt.mpl.flag.m",
3196 FT_BOOLEAN, 8, NULL, 0x20,
3197 "Indicates Sequence is known to be the largest sequence number", HFILL }
3198 },
3199 { &hf_ipv6_opt_mpl_flag_v,
3200 { "Version", "ipv6.opt.mpl.flag.v",
3201 FT_BOOLEAN, 8, NULL, 0x10,
3202 "0 indicates this option conforms to RFC<TBC>", HFILL }
3203 },
3204 { &hf_ipv6_opt_mpl_flag_rsv,
3205 { "Reserved", "ipv6.opt.mpl.flag.rsv",
3206 FT_UINT8, BASE_HEX, NULL, 0x0F,
3207 "Reserved (must be zero)", HFILL }
3208 },
3209 { &hf_ipv6_opt_mpl_sequence,
3210 { "Sequence", "ipv6.opt.mpl.sequence",
3211 FT_UINT8, BASE_HEX, NULL, 0x0,
3212 "Identifies relative ordering of MPL Data Messages from the MPL Seed identified by Seed ID", HFILL }
3213 },
3214 { &hf_ipv6_opt_mpl_seed_id,
3215 { "Seed ID", "ipv6.opt.mpl.seed_id",
3216 FT_BYTES, BASE_NONE, NULL, 0x0,
3217 "Uniquely identifies the MPL Seed that initiated dissemination of the MPL Data Message", HFILL }
3218 },
3219 { &hf_ipv6_opt_dff_flags,
3220 { "Flags", "ipv6.opt.dff.flags",
3221 FT_UINT8, BASE_HEX, NULL, 0x0,
3222 NULL, HFILL }
3223 },
3224 { &hf_ipv6_opt_dff_flag_ver,
3225 { "Version (VER)", "ipv6.opt.dff.flag.ver",
3226 FT_UINT8, BASE_DEC, NULL, 0xC0,
3227 "The version of DFF that is used", HFILL }
3228 },
3229 { &hf_ipv6_opt_dff_flag_dup,
3230 { "Duplicate (DUP)", "ipv6.opt.dff.flag.dup",
3231 FT_BOOLEAN, 8, NULL, 0x20,
3232 "Indicates the packet is being retransmitted", HFILL }
3233 },
3234 { &hf_ipv6_opt_dff_flag_ret,
3235 { "Return (RET)", "ipv6.opt.dff.flag.ret",
3236 FT_BOOLEAN, 8, NULL, 0x10,
3237 "Must be set to 1 prior to sending the packet back to the Previous Hop", HFILL }
3238 },
3239 { &hf_ipv6_opt_dff_flag_rsv,
3240 { "Reserved", "ipv6.opt.dff.flag.rsv",
3241 FT_UINT8, BASE_HEX, NULL, 0x0F,
3242 "Reserved (must be zero)", HFILL }
3243 },
3244 { &hf_ipv6_opt_dff_seqnum,
3245 { "Sequence Number", "ipv6.opt.dff.sequence_number",
3246 FT_UINT16, BASE_DEC_HEX, NULL, 0x0,
3247 NULL, HFILL }
3248 },
3249 { &hf_ipv6_opt_experimental,
3250 { "Experimental Option", "ipv6.opt.experimental",
3251 FT_BYTES, BASE_NONE, NULL, 0x0,
3252 NULL, HFILL }
3253 },
3254 { &hf_ipv6_opt_unknown_data,
3255 { "Unknown Data", "ipv6.opt_unknown_data",
3256 FT_BYTES, BASE_NONE, NULL, 0x0,
3257 "Not interpreted data", HFILL }
3258 },
3259 { &hf_ipv6_opt_unknown,
3260 { "Unknown Option Payload", "ipv6.opt.unknown",
3261 FT_BYTES, BASE_NONE, NULL, 0x0,
3262 NULL, HFILL }
3263 },
3264 { &hf_ipv6_fragment,
3265 { "IPv6 Fragment", "ipv6.fragment",
3266 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3267 NULL, HFILL }
3268 },
3269 { &hf_ipv6_fragment_overlap,
3270 { "Fragment overlap", "ipv6.fragment.overlap",
3271 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3272 "Fragment overlaps with other fragments", HFILL }
3273 },
3274 { &hf_ipv6_fragment_overlap_conflict,
3275 { "Conflicting data in fragment overlap", "ipv6.fragment.overlap.conflict",
3276 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3277 "Overlapping fragments contained conflicting data", HFILL }
3278 },
3279 { &hf_ipv6_fragment_multiple_tails,
3280 { "Multiple tail fragments found", "ipv6.fragment.multipletails",
3281 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3282 "Several tails were found when defragmenting the packet", HFILL }
3283 },
3284 { &hf_ipv6_fragment_too_long_fragment,
3285 { "Fragment too long", "ipv6.fragment.toolongfragment",
3286 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
3287 "Fragment contained data past end of packet", HFILL }
3288 },
3289 { &hf_ipv6_fragment_error,
3290 { "Defragmentation error", "ipv6.fragment.error",
3291 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3292 "Defragmentation error due to illegal fragments", HFILL }
3293 },
3294 { &hf_ipv6_fragment_count,
3295 { "Fragment count", "ipv6.fragment.count",
3296 FT_UINT32, BASE_DEC, NULL, 0x0,
3297 NULL, HFILL }
3298 },
3299 { &hf_ipv6_fragments,
3300 { "IPv6 Fragments", "ipv6.fragments",
3301 FT_NONE, BASE_NONE, NULL, 0x0,
3302 NULL, HFILL }
3303 },
3304 { &hf_ipv6_reassembled_in,
3305 { "Reassembled IPv6 in frame", "ipv6.reassembled.in",
3306 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
3307 "This IPv6 packet is reassembled in this frame", HFILL }
3308 },
3309 { &hf_ipv6_reassembled_length,
3310 { "Reassembled IPv6 length", "ipv6.reassembled.length",
3311 FT_UINT32, BASE_DEC, NULL, 0x0,
3312 "The total length of the reassembled payload", HFILL }
3313 },
3314 { &hf_ipv6_reassembled_data,
3315 { "Reassembled IPv6 data", "ipv6.reassembled.data",
3316 FT_BYTES, BASE_NONE, NULL, 0x0,
3317 "The reassembled payload", HFILL }
3318 }
3319 };
3320
3321 static hf_register_info hf_ipv6_hopopts[] = {
3322 { &hf_ipv6_hopopts_nxt,
3323 { "Next Header", "ipv6.hopopts.nxt",
3324 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x0,
3325 NULL, HFILL }
3326 },
3327 { &hf_ipv6_hopopts_len,
3328 { "Length", "ipv6.hopopts.len",
3329 FT_UINT8, BASE_DEC, NULL, 0x0,
3330 "Extension header length in 8-octet words (minus 1)", HFILL }
3331 },
3332 { &hf_ipv6_hopopts_len_oct,
3333 { "Length", "ipv6.hopopts.len_oct",
3334 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0,
3335 "Extension header length in octets", HFILL }
3336 }
3337 };
3338
3339 static hf_register_info hf_ipv6_dstopts[] = {
3340 { &hf_ipv6_dstopts_nxt,
3341 { "Next Header", "ipv6.dstopts.nxt",
3342 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x0,
3343 NULL, HFILL }
3344 },
3345 { &hf_ipv6_dstopts_len,
3346 { "Length", "ipv6.dstopts.len",
3347 FT_UINT8, BASE_DEC, NULL, 0x0,
3348 "Extension header length in 8-octet words (minus 1)", HFILL }
3349 },
3350 { &hf_ipv6_dstopts_len_oct,
3351 { "Length", "ipv6.dstopts.len_oct",
3352 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0,
3353 "Extension header length in octets", HFILL }
3354 }
3355 };
3356
3357 static hf_register_info hf_ipv6_routing[] = {
3358
3359 /* IPv6 Routing Header */
3360 { &hf_ipv6_routing_nxt,
3361 { "Next Header", "ipv6.routing.nxt",
3362 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x0,
3363 NULL, HFILL }
3364 },
3365 { &hf_ipv6_routing_len,
3366 { "Length", "ipv6.routing.len",
3367 FT_UINT8, BASE_DEC, NULL, 0x0,
3368 "Extension header length in 8-octet words (minus 1)", HFILL }
3369 },
3370 { &hf_ipv6_routing_len_oct,
3371 { "Length", "ipv6.routing.len_oct",
3372 FT_UINT16, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0,
3373 "Extension header length in octets", HFILL }
3374 },
3375 { &hf_ipv6_routing_type,
3376 { "Type", "ipv6.routing.type",
3377 FT_UINT8, BASE_DEC, VALS(routing_header_type), 0x0,
3378 "Routing Header Type", HFILL }
3379 },
3380 { &hf_ipv6_routing_segleft,
3381 { "Segments Left", "ipv6.routing.segleft",
3382 FT_UINT8, BASE_DEC, NULL, 0x0,
3383 "Routing Header Segments Left", HFILL }
3384 },
3385 { &hf_ipv6_routing_unknown_data,
3386 { "Type-Specific Data", "ipv6.routing.unknown_data",
3387 FT_BYTES, BASE_NONE, NULL, 0x0,
3388 "Unknown routing header type-specific data", HFILL }
3389 },
3390
3391 /* Source Routing Header */
3392 { &hf_ipv6_routing_src_reserved,
3393 { "Reserved", "ipv6.routing.src.reserved",
3394 FT_BYTES, BASE_NONE, NULL, 0x0,
3395 "Must be zero", HFILL }
3396 },
3397 { &hf_ipv6_routing_src_addr,
3398 { "Address", "ipv6.routing.src.addr",
3399 FT_IPv6, BASE_NONE, NULL, 0x0,
3400 "Source Routing Header Address", HFILL }},
3401
3402 /* Mobile IPv6 */
3403 { &hf_ipv6_routing_mipv6_reserved,
3404 { "Reserved", "ipv6.routing.mipv6.reserved",
3405 FT_BYTES, BASE_NONE, NULL, 0x0,
3406 "Must be zero", HFILL }
3407 },
3408 { &hf_ipv6_routing_mipv6_home_address,
3409 { "Home Address", "ipv6.routing.mipv6.home_address",
3410 FT_IPv6, BASE_NONE, NULL, 0x0,
3411 NULL, HFILL }
3412 },
3413
3414 /* RPL Routing Header */
3415 { &hf_ipv6_routing_rpl_cmprI,
3416 { "Compressed Internal Octets (CmprI)", "ipv6.routing.rpl.cmprI",
3417 FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_CMPRI,
3418 "Elided octets from all but last segment", HFILL }
3419 },
3420 { &hf_ipv6_routing_rpl_cmprE,
3421 { "Compressed Final Octets (CmprE)", "ipv6.routing.rpl.cmprE",
3422 FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_CMPRE,
3423 "Elided octets from last segment address", HFILL }
3424 },
3425 { &hf_ipv6_routing_rpl_pad,
3426 { "Padding Bytes", "ipv6.routing.rpl.pad",
3427 FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_PAD,
3428 NULL, HFILL }
3429 },
3430 { &hf_ipv6_routing_rpl_reserved,
3431 { "Reserved", "ipv6.routing.rpl.reserved",
3432 FT_UINT32, BASE_DEC, NULL, IP6RRPL_BITMASK_RESERVED,
3433 "Must be zero", HFILL }
3434 },
3435 { &hf_ipv6_routing_rpl_addr_count,
3436 { "Total Address Count", "ipv6.routing.rpl.addr_count",
3437 FT_INT32, BASE_DEC, NULL, 0,
3438 NULL, HFILL }
3439 },
3440 { &hf_ipv6_routing_rpl_addr,
3441 { "Address", "ipv6.routing.rpl.address",
3442 FT_BYTES, BASE_NONE, NULL, 0,
3443 NULL, HFILL }
3444 },
3445 { &hf_ipv6_routing_rpl_fulladdr,
3446 { "Full Address", "ipv6.routing.rpl.full_address",
3447 FT_IPv6, BASE_NONE, NULL, 0,
3448 "Uncompressed IPv6 Address", HFILL }
3449 },
3450
3451 /* Segment Routing Header */
3452 { &hf_ipv6_routing_srh_last_entry,
3453 { "Last Entry", "ipv6.routing.srh.last_entry",
3454 FT_UINT8, BASE_DEC, NULL, 0x0,
3455 "Index (zero based) of the last element of the Segment List", HFILL }
3456 },
3457 { &hf_ipv6_routing_srh_flags,
3458 { "Flags", "ipv6.routing.srh.flags",
3459 FT_UINT8, BASE_HEX, NULL, 0x0,
3460 "Unused, 8 bits of flags", HFILL }
3461 },
3462 { &hf_ipv6_routing_srh_tag,
3463 { "Tag", "ipv6.routing.srh.tag",
3464 FT_BYTES, BASE_NONE, NULL, 0x0,
3465 "Tag a packet as part of a class or group of packets", HFILL }
3466 },
3467 { &hf_ipv6_routing_srh_addr,
3468 { "Address", "ipv6.routing.srh.addr",
3469 FT_IPv6, BASE_NONE, NULL, 0x0,
3470 "Segment address", HFILL }
3471 },
3472
3473 /* Compact Routing Header */
3474 { &hf_ipv6_routing_crh16_current_sid,
3475 { "Current SID", "ipv6.routing.crh16.current_sid",
3476 FT_UINT16, BASE_DEC, NULL, 0x0,
3477 "Value of the current Segment ID", HFILL }
3478 },
3479 { &hf_ipv6_routing_crh32_current_sid,
3480 { "Current SID", "ipv6.routing.crh32.current_sid",
3481 FT_UINT32, BASE_DEC, NULL, 0x0,
3482 "Value of the current Segment ID", HFILL }
3483 },
3484 { &hf_ipv6_routing_crh16_segment_id,
3485 { "Segment ID", "ipv6.routing.crh16.sid",
3486 FT_UINT16, BASE_DEC, NULL, 0x0,
3487 "Segment address", HFILL }
3488 },
3489 { &hf_ipv6_routing_crh32_segment_id,
3490 { "Segment ID", "ipv6.routing.crh32.sid",
3491 FT_UINT32, BASE_DEC, NULL, 0x0,
3492 "Segment address", HFILL }
3493 }
3494 };
3495
3496 static hf_register_info hf_ipv6_fraghdr[] = {
3497 { &hf_ipv6_fraghdr_nxt,
3498 { "Next header", "ipv6.fraghdr.nxt",
3499 FT_UINT8, BASE_DEC | BASE_EXT_STRING, &ipproto_val_ext, 0x0,
3500 NULL, HFILL }
3501 },
3502 { &hf_ipv6_fraghdr_reserved_octet,
3503 { "Reserved octet", "ipv6.fraghdr.reserved_octet",
3504 FT_UINT8, BASE_HEX, NULL, 0x0,
3505 "Should always be 0", HFILL }
3506 },
3507 { &hf_ipv6_fraghdr_offset,
3508 { "Offset", "ipv6.fraghdr.offset",
3509 FT_UINT16, BASE_DEC, NULL, IP6F_OFF_MASK,
3510 "Fragment Offset", HFILL }
3511 },
3512 { &hf_ipv6_fraghdr_reserved_bits,
3513 { "Reserved bits", "ipv6.fraghdr.reserved_bits",
3514 FT_UINT16, BASE_DEC, NULL, IP6F_RESERVED_MASK,
3515 NULL, HFILL }
3516 },
3517 { &hf_ipv6_fraghdr_more,
3518 { "More Fragments", "ipv6.fraghdr.more",
3519 FT_BOOLEAN, 16, TFS(&tfs_yes_no), IP6F_MORE_FRAG,
3520 NULL, HFILL }
3521 },
3522 { &hf_ipv6_fraghdr_ident,
3523 { "Identification", "ipv6.fraghdr.ident",
3524 FT_UINT32, BASE_HEX, NULL, 0x0,
3525 "Fragment Identification", HFILL }
3526 }
3527 };
3528
3529 static gint *ett_ipv6[] = {
3530 &ett_ipv6_proto,
3531 &ett_ipv6_traffic_class,
3532 &ett_geoip_info,
3533 &ett_ipv6_opt,
3534 &ett_ipv6_opt_type,
3535 &ett_ipv6_opt_rpl,
3536 &ett_ipv6_opt_mpl,
3537 &ett_ipv6_opt_dff_flags,
3538 &ett_ipv6_fragment,
3539 &ett_ipv6_fragments
3540 };
3541
3542 static gint *ett_ipv6_hopopts[] = {
3543 &ett_ipv6_hopopts_proto
3544 };
3545
3546 static gint *ett_ipv6_routing[] = {
3547 &ett_ipv6_routing_proto,
3548 &ett_ipv6_routing_srh_vect
3549 };
3550
3551 static gint *ett_ipv6_fraghdr[] = {
3552 &ett_ipv6_fraghdr_proto
3553 };
3554
3555 static gint *ett_ipv6_dstopts[] = {
3556 &ett_ipv6_dstopts_proto
3557 };
3558
3559 static ei_register_info ei_ipv6[] = {
3560 { &ei_ipv6_opt_jumbo_missing,
3561 { "ipv6.opt.jumbo.missing", PI_MALFORMED, PI_ERROR,
3562 "IPv6 payload length equals 0 and Hop-By-Hop present and Jumbo Payload option missing", EXPFILL }
3563 },
3564 { &ei_ipv6_opt_jumbo_prohibited,
3565 { "ipv6.opt.jumbo.prohibited", PI_PROTOCOL, PI_WARN,
3566 "When IPv6 payload length does not equal 0 a Jumbo Payload option must not be present", EXPFILL }
3567 },
3568 { &ei_ipv6_opt_jumbo_truncated,
3569 { "ipv6.opt.jumbo.truncated", PI_PROTOCOL, PI_WARN,
3570 "Jumbo Payload option present and jumbo length < 65536", EXPFILL }
3571 },
3572 { &ei_ipv6_opt_jumbo_fragment,
3573 { "ipv6.opt.jumbo.fragment", PI_PROTOCOL, PI_WARN,
3574 "Jumbo Payload option cannot be used with a fragment header", EXPFILL }
3575 },
3576 { &ei_ipv6_opt_invalid_len,
3577 { "ipv6.opt.invalid_len", PI_MALFORMED, PI_ERROR,
3578 "Invalid IPv6 option length", EXPFILL }
3579 },
3580 { &ei_ipv6_opt_unknown_data,
3581 { "ipv6.opt.unknown_data.expert", PI_UNDECODED, PI_NOTE,
3582 "Unknown Data (not interpreted)", EXPFILL }
3583 },
3584 { &ei_ipv6_plen_exceeds_framing,
3585 { "ipv6.plen_exceeds_framing", PI_PROTOCOL, PI_WARN,
3586 "IPv6 payload length does not match expected framing length", EXPFILL }
3587 },
3588 { &ei_ipv6_plen_zero,
3589 { "ipv6.plen_zero", PI_PROTOCOL, PI_CHAT,
3590 "IPv6 payload length equals 0 (maybe because of \"TCP segmentation offload\" (TSO))", EXPFILL }
3591 },
3592 { &ei_ipv6_bogus_ipv6_version,
3593 { "ipv6.bogus_ipv6_version", PI_MALFORMED, PI_ERROR,
3594 "Bogus IP version", EXPFILL }
3595 },
3596 { &ei_ipv6_invalid_header,
3597 { "ipv6.invalid_header", PI_MALFORMED, PI_ERROR,
3598 "Invalid IPv6 header", EXPFILL }
3599 },
3600 { &ei_ipv6_opt_header_mismatch,
3601 { "ipv6.opt.header_mismatch", PI_PROTOCOL, PI_WARN,
3602 "Wrong options extension header for type", EXPFILL }
3603 },
3604 { &ei_ipv6_opt_deprecated,
3605 { "ipv6.opt.deprecated", PI_DEPRECATED, PI_NOTE,
3606 "Option type is deprecated", EXPFILL }
3607 },
3608 { &ei_ipv6_opt_mpl_ipv6_src_seed_id,
3609 { "ipv6.opt.mpl.ipv6_src_seed_id", PI_PROTOCOL, PI_COMMENT,
3610 "Seed ID is the IPv6 Source Address", EXPFILL }
3611 }
3612 };
3613
3614 static ei_register_info ei_ipv6_hopopts[] = {
3615 { &ei_ipv6_hopopts_not_first,
3616 { "ipv6.hopopts.not_first", PI_PROTOCOL, PI_ERROR,
3617 "IPv6 Hop-by-Hop extension header must appear immediately after IPv6 header", EXPFILL }
3618 }
3619 };
3620
3621 static ei_register_info ei_ipv6_routing[] = {
3622 { &ei_ipv6_dst_addr_not_multicast,
3623 { "ipv6.dst_addr.not_multicast", PI_PROTOCOL, PI_WARN,
3624 "Destination address must not be a multicast address", EXPFILL }
3625 },
3626 { &ei_ipv6_src_route_list_mult_inst_same_addr,
3627 { "ipv6.src_route_list.mult_inst_same_addr", PI_PROTOCOL, PI_WARN,
3628 "Multiple instances of the same address must not appear in the source route list", EXPFILL }
3629 },
3630 { &ei_ipv6_src_route_list_src_addr,
3631 { "ipv6.src_route_list.src_addr", PI_PROTOCOL, PI_WARN,
3632 "Source address must not appear in the source route list", EXPFILL }
3633 },
3634 { &ei_ipv6_src_route_list_dst_addr,
3635 { "ipv6.src_route_list.dst_addr", PI_PROTOCOL, PI_WARN,
3636 "Destination address must not appear in the source route list", EXPFILL }
3637 },
3638 { &ei_ipv6_src_route_list_multicast_addr,
3639 { "ipv6.src_route_list.multicast_addr", PI_PROTOCOL, PI_WARN,
3640 "Multicast addresses must not appear in the source route list", EXPFILL }
3641 },
3642 { &ei_ipv6_routing_rpl_cmpri_cmpre_pad,
3643 { "ipv6.routing.rpl.cmprI_cmprE_pad", PI_PROTOCOL, PI_WARN,
3644 "When cmprI equals 0 and cmprE equals 0, pad MUST equal 0 but instead was X", EXPFILL }
3645 },
3646 { &ei_ipv6_routing_rpl_addr_count_ge0,
3647 { "ipv6.routing.rpl.addr_count_ge0", PI_MALFORMED, PI_ERROR,
3648 "Calculated total address count must be greater than or equal to 0, instead was X", EXPFILL }
3649 },
3650 { &ei_ipv6_routing_rpl_reserved,
3651 { "ipv6.routing.rpl.reserved_not0", PI_PROTOCOL, PI_NOTE,
3652 "Reserved field must equal 0 but instead was X", EXPFILL }
3653 },
3654 { &ei_ipv6_routing_invalid_length,
3655 { "ipv6.routing.invalid_length", PI_MALFORMED, PI_ERROR,
3656 "Invalid IPv6 Routing header length", EXPFILL }
3657 },
3658 { &ei_ipv6_routing_invalid_segleft,
3659 { "ipv6.routing.invalid_segleft", PI_PROTOCOL, PI_WARN,
3660 "IPv6 Routing Header segments left field must not exceed address count", EXPFILL }
3661 },
3662 { &ei_ipv6_routing_undecoded,
3663 { "ipv6.routing.undecoded", PI_UNDECODED, PI_NOTE,
3664 "Undecoded IPv6 routing header field", EXPFILL }
3665 },
3666 { &ei_ipv6_routing_deprecated,
3667 { "ipv6.routing.deprecated", PI_DEPRECATED, PI_NOTE,
3668 "Routing header type is deprecated", EXPFILL }
3669 }
3670 };
3671
3672 /* Decode As handling */
3673 static build_valid_func ipv6_da_build_value[1] = {ipv6_value};
3674 static decode_as_value_t ipv6_da_values = {ipv6_prompt, 1, ipv6_da_build_value};
3675
3676 static decode_as_t ipv6_da = {"ipv6", "ip.proto", 1, 0, &ipv6_da_values, NULL, NULL,
3677 decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3678
3679 static decode_as_t ipv6_hopopts_da = {"ipv6.hopopts", "ip.proto", 1, 0, &ipv6_da_values, NULL, NULL,
3680 decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3681
3682 static decode_as_t ipv6_routing_da = {"ipv6.routing", "ip.proto", 1, 0, &ipv6_da_values, NULL, NULL,
3683 decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3684
3685 static decode_as_t ipv6_fraghdr_da = {"ipv6.fraghdr", "ip.proto", 1, 0, &ipv6_da_values, NULL, NULL,
3686 decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3687
3688 static decode_as_t ipv6_dstopts_da = {"ipv6.dstopts", "ip.proto", 1, 0, &ipv6_da_values, NULL, NULL,
3689 decode_as_default_populate_list, decode_as_default_reset, decode_as_default_change, NULL};
3690
3691 module_t *ipv6_module;
3692 expert_module_t* expert_ipv6;
3693 expert_module_t* expert_ipv6_hopopts;
3694 expert_module_t* expert_ipv6_routing;
3695
3696 proto_ipv6 = proto_register_protocol("Internet Protocol Version 6", "IPv6", "ipv6");
3697 proto_register_field_array(proto_ipv6, hf_ipv6, array_length(hf_ipv6));
3698 proto_register_subtree_array(ett_ipv6, array_length(ett_ipv6));
3699 expert_ipv6 = expert_register_protocol(proto_ipv6);
3700 expert_register_field_array(expert_ipv6, ei_ipv6, array_length(ei_ipv6));
3701
3702 proto_ipv6_hopopts = proto_register_protocol("IPv6 Hop-by-Hop Option", "IPv6 Hop-by-Hop", "ipv6.hopopts");
3703 proto_register_field_array(proto_ipv6_hopopts, hf_ipv6_hopopts, array_length(hf_ipv6_hopopts));
3704 proto_register_subtree_array(ett_ipv6_hopopts, array_length(ett_ipv6_hopopts));
3705 expert_ipv6_hopopts = expert_register_protocol(proto_ipv6_hopopts);
3706 expert_register_field_array(expert_ipv6_hopopts, ei_ipv6_hopopts, array_length(ei_ipv6_hopopts));
3707
3708 proto_ipv6_routing = proto_register_protocol("Routing Header for IPv6", "IPv6 Routing", "ipv6.routing");
3709 proto_register_field_array(proto_ipv6_routing, hf_ipv6_routing, array_length(hf_ipv6_routing));
3710 proto_register_subtree_array(ett_ipv6_routing, array_length(ett_ipv6_routing));
3711 expert_ipv6_routing = expert_register_protocol(proto_ipv6_routing);
3712 expert_register_field_array(expert_ipv6_routing, ei_ipv6_routing, array_length(ei_ipv6_routing));
3713
3714 ipv6_routing_dissector_table = register_dissector_table("ipv6.routing.type", "IPv6 Routing Type",
3715 proto_ipv6_routing, FT_UINT8, BASE_DEC);
3716
3717 proto_ipv6_routing_rt0 = proto_register_protocol_in_name_only("IPv6 Routing Type - Source Route", "Source Route", "ipv6.routing.type.rt0", proto_ipv6, FT_BYTES);
3718 proto_ipv6_routing_mipv6 = proto_register_protocol_in_name_only("IPv6 Routing Type - Type 2", "Type 2", "ipv6.routing.type.mipv6", proto_ipv6, FT_BYTES);
3719 proto_ipv6_routing_rpl = proto_register_protocol_in_name_only("IPv6 Routing Type - RPL Source Route", "RPL Source Route", "ipv6.routing.type.mipv6", proto_ipv6, FT_BYTES);
3720 proto_ipv6_routing_srh = proto_register_protocol_in_name_only("IPv6 Routing Types - Segment Routing", "Segment Routing", "ipv6.routing.type.srh", proto_ipv6, FT_BYTES);
3721 proto_ipv6_routing_crh = proto_register_protocol_in_name_only("IPv6 Routing Types - Compact Routing", "Compact Routing", "ipv6.routing.type.crh", proto_ipv6, FT_BYTES);
3722
3723 proto_ipv6_fraghdr = proto_register_protocol("Fragment Header for IPv6", "IPv6 Fragment", "ipv6.fraghdr");
3724 proto_register_field_array(proto_ipv6_fraghdr, hf_ipv6_fraghdr, array_length(hf_ipv6_fraghdr));
3725 proto_register_subtree_array(ett_ipv6_fraghdr, array_length(ett_ipv6_fraghdr));
3726
3727 proto_ipv6_dstopts = proto_register_protocol("Destination Options for IPv6", "IPv6 Destination", "ipv6.dstopts");
3728 proto_register_field_array(proto_ipv6_dstopts, hf_ipv6_dstopts, array_length(hf_ipv6_dstopts));
3729 proto_register_subtree_array(ett_ipv6_dstopts, array_length(ett_ipv6_dstopts));
3730
3731 /* Register configuration options */
3732 ipv6_module = prefs_register_protocol(proto_ipv6, NULL);
3733 prefs_register_bool_preference(ipv6_module, "defragment",
3734 "Reassemble fragmented IPv6 datagrams",
3735 "Whether fragmented IPv6 datagrams should be reassembled",
3736 &ipv6_reassemble);
3737 prefs_register_bool_preference(ipv6_module, "summary_in_tree",
3738 "Show IPv6 summary in protocol tree",
3739 "Whether the IPv6 summary line should be shown in the protocol tree",
3740 &ipv6_summary_in_tree);
3741 prefs_register_bool_preference(ipv6_module, "use_geoip" ,
3742 "Enable IPv6 geolocation",
3743 "Whether to look up IPv6 addresses in each MaxMind database we have loaded",
3744 &ipv6_use_geoip);
3745
3746 /* RPL Strict Header Checking */
3747 prefs_register_bool_preference(ipv6_module, "perform_strict_rpl_srh_rfc_checking",
3748 "Perform strict checking for RPL Source Routing Headers (RFC 6554)",
3749 "Check that all RPL Source Routed packets conform to RFC 6554 and do not visit a node more than once",
3750 &g_ipv6_rpl_srh_strict_rfc_checking);
3751
3752 prefs_register_bool_preference(ipv6_module, "try_heuristic_first",
3753 "Try heuristic sub-dissectors first",
3754 "Try to decode a packet using an heuristic sub-dissector before using a sub-dissector registered to a specific port",
3755 &try_heuristic_first);
3756
3757 prefs_register_bool_preference(ipv6_module, "exthdr_under_root_protocol_tree",
3758 "Display IPv6 extension headers under the root protocol tree",
3759 "Whether to display IPv6 extension headers as a separate protocol or a sub-protocol of the IPv6 packet",
3760 &ipv6_exthdr_under_root);
3761
3762 prefs_register_bool_preference(ipv6_module, "exthdr_hide_len_oct_field",
3763 "Use a single field for IPv6 extension header length",
3764 "If enabled the Length field in octets will be hidden",
3765 &ipv6_exthdr_hide_len_oct_field);
3766
3767 prefs_register_bool_preference(ipv6_module, "tso_support",
3768 "Support packet-capture from IPv6 TSO-enabled hardware",
3769 "Whether to correct for TSO-enabled (TCP segmentation offload) hardware "
3770 "captures, such as spoofing the IPv6 packet length", &ipv6_tso_supported);
3771
3772 ipv6_handle = register_dissector("ipv6", dissect_ipv6, proto_ipv6);
3773 reassembly_table_register(&ipv6_reassembly_table,
3774 &addresses_reassembly_table_functions);
3775 ipv6_tap = register_tap("ipv6");
3776
3777 register_decode_as(&ipv6_da);
3778 register_decode_as(&ipv6_hopopts_da);
3779 register_decode_as(&ipv6_routing_da);
3780 register_decode_as(&ipv6_fraghdr_da);
3781 register_decode_as(&ipv6_dstopts_da);
3782
3783 register_conversation_table(proto_ipv6, TRUE, ipv6_conversation_packet, ipv6_hostlist_packet);
3784 register_conversation_filter("ipv6", "IPv6", ipv6_filter_valid, ipv6_build_filter);
3785
3786 register_capture_dissector("ipv6", capture_ipv6, proto_ipv6);
3787 }
3788
3789 void
3790 proto_reg_handoff_ipv6(void)
3791 {
3792 dissector_handle_t ipv6_hopopts_handle;
3793 dissector_handle_t ipv6_routing_handle;
3794 dissector_handle_t ipv6_fraghdr_handle;
3795 dissector_handle_t ipv6_dstopts_handle;
3796 capture_dissector_handle_t ipv6_cap_handle;
3797 capture_dissector_handle_t ipv6_ext_cap_handle;
3798 dissector_handle_t h;
3799
3800 dissector_add_uint("ethertype", ETHERTYPE_IPv6, ipv6_handle);
3801 dissector_add_uint("erf.types.type", ERF_TYPE_IPV6, ipv6_handle);
3802 dissector_add_uint("ppp.protocol", PPP_IPV6, ipv6_handle);
3803 dissector_add_uint("ppp.protocol", ETHERTYPE_IPv6, ipv6_handle);
3804 dissector_add_uint("gre.proto", ETHERTYPE_IPv6, ipv6_handle);
3805 dissector_add_uint("ip.proto", IP_PROTO_IPV6, ipv6_handle);
3806 dissector_add_uint("null.type", BSD_AF_INET6_BSD, ipv6_handle);
3807 dissector_add_uint("null.type", BSD_AF_INET6_FREEBSD, ipv6_handle);
3808 dissector_add_uint("null.type", BSD_AF_INET6_DARWIN, ipv6_handle);
3809 dissector_add_uint("chdlc.protocol", ETHERTYPE_IPv6, ipv6_handle);
3810 dissector_add_uint("fr.nlpid", NLPID_IP6, ipv6_handle);
3811 dissector_add_uint("osinl.excl", NLPID_IP6, ipv6_handle);
3812 dissector_add_uint("x.25.spi", NLPID_IP6, ipv6_handle);
3813 dissector_add_uint("arcnet.protocol_id", ARCNET_PROTO_IPv6, ipv6_handle);
3814 dissector_add_uint("juniper.proto", JUNIPER_PROTO_IP6, ipv6_handle);
3815 dissector_add_uint("juniper.proto", JUNIPER_PROTO_MPLS_IP6, ipv6_handle);
3816 dissector_add_uint("pwach.channel_type", PW_ACH_TYPE_IPV6, ipv6_handle);
3817 dissector_add_uint("mcc.proto", PW_ACH_TYPE_IPV6, ipv6_handle);
3818 dissector_add_uint("sflow_245.header_protocol", SFLOW_245_HEADER_IPv6, ipv6_handle);
3819 dissector_add_uint("wtap_encap", WTAP_ENCAP_RAW_IP6, ipv6_handle);
3820 dissector_add_uint("enc", BSD_AF_INET6_BSD, ipv6_handle);
3821 dissector_add_uint("vxlan.next_proto", VXLAN_IPV6, ipv6_handle);
3822 dissector_add_uint("nsh.next_proto", NSH_IPV6, ipv6_handle);
3823
3824 dissector_add_for_decode_as_with_preference("udp.port", ipv6_handle);
3825
3826 ipv6_hopopts_handle = create_dissector_handle(dissect_hopopts, proto_ipv6_hopopts);
3827 dissector_add_uint("ip.proto", IP_PROTO_HOPOPTS, ipv6_hopopts_handle);
3828
3829 ipv6_routing_handle = create_dissector_handle(dissect_routing6, proto_ipv6_routing);
3830 dissector_add_uint("ip.proto", IP_PROTO_ROUTING, ipv6_routing_handle);
3831
3832 ipv6_fraghdr_handle = create_dissector_handle(dissect_fraghdr, proto_ipv6_fraghdr);
3833 dissector_add_uint("ip.proto", IP_PROTO_FRAGMENT, ipv6_fraghdr_handle);
3834
3835 ipv6_dstopts_handle = create_dissector_handle(dissect_dstopts, proto_ipv6_dstopts);
3836 dissector_add_uint("ip.proto", IP_PROTO_DSTOPTS, ipv6_dstopts_handle);
3837
3838 ip_dissector_table = find_dissector_table("ip.proto");
3839
3840 ipv6_cap_handle = find_capture_dissector("ipv6");
3841 capture_dissector_add_uint("ethertype", ETHERTYPE_IPv6, ipv6_cap_handle);
3842 capture_dissector_add_uint("enc", BSD_AF_INET6_BSD, ipv6_cap_handle);
3843 capture_dissector_add_uint("null.bsd", BSD_AF_INET6_BSD, ipv6_cap_handle);
3844 capture_dissector_add_uint("null.bsd", BSD_AF_INET6_FREEBSD, ipv6_cap_handle);
3845 capture_dissector_add_uint("null.bsd", BSD_AF_INET6_DARWIN, ipv6_cap_handle);
3846 capture_dissector_add_uint("fr.nlpid", NLPID_IP6, ipv6_cap_handle);
3847
3848 ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_hopopts);
3849 capture_dissector_add_uint("ip.proto", IP_PROTO_HOPOPTS, ipv6_ext_cap_handle);
3850 ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_routing);
3851 capture_dissector_add_uint("ip.proto", IP_PROTO_ROUTING, ipv6_ext_cap_handle);
3852 ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_fraghdr);
3853 capture_dissector_add_uint("ip.proto", IP_PROTO_FRAGMENT, ipv6_ext_cap_handle);
3854 ipv6_ext_cap_handle = create_capture_dissector_handle(capture_ipv6_exthdr, proto_ipv6_dstopts);
3855 capture_dissector_add_uint("ip.proto", IP_PROTO_DSTOPTS, ipv6_ext_cap_handle);
3856
3857 h = create_dissector_handle(dissect_routing6_rt0, proto_ipv6_routing_rt0);
3858 dissector_add_uint("ipv6.routing.type", IPv6_RT_HEADER_SOURCE_ROUTING, h);
3859 h = create_dissector_handle(dissect_routing6_mipv6, proto_ipv6_routing_mipv6);
3860 dissector_add_uint("ipv6.routing.type", IPv6_RT_HEADER_MOBILE_IP, h);
3861 h = create_dissector_handle(dissect_routing6_rpl, proto_ipv6_routing_rpl);
3862 dissector_add_uint("ipv6.routing.type", IPv6_RT_HEADER_RPL, h);
3863 h = create_dissector_handle(dissect_routing6_srh, proto_ipv6_routing_srh);
3864 dissector_add_uint("ipv6.routing.type", IPv6_RT_HEADER_SEGMENT_ROUTING, h);
3865 h = create_dissector_handle(dissect_routing6_crh, proto_ipv6_routing_crh);
3866 dissector_add_uint("ipv6.routing.type", IPv6_RT_HEADER_COMPACT_16, h);
3867 dissector_add_uint("ipv6.routing.type", IPv6_RT_HEADER_COMPACT_32, h);
3868 }
3869
3870 /*
3871 * Editor modelines
3872 *
3873 * Local Variables:
3874 * c-basic-offset: 4
3875 * tab-width: 8
3876 * indent-tabs-mode: nil
3877 * End:
3878 *
3879 * ex: set shiftwidth=4 tabstop=8 expandtab:
3880 * :indentSize=4:tabSize=8:noTabs=true:
3881 */
3882