2 * Routines for IPv6 packet disassembly
4 * $Id: packet-ipv6.c,v 1.101 2004/01/21 08:39:29 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@ethereal.com>
8 * Copyright 1998 Gerald Combs
10 * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@siemens.hr>
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
35 #include "packet-ipsec.h"
36 #include "packet-ipv6.h"
38 #include <epan/resolv.h>
40 #include "reassemble.h"
46 #include "arcnet_pids.h"
49 * NOTE: ipv6.nxt is not very useful as we will have chained header.
50 * now testing ipv6.final, but it raises SEGV.
54 static int proto_ipv6 = -1;
55 static int hf_ipv6_version = -1;
56 static int hf_ipv6_class = -1;
57 static int hf_ipv6_flow = -1;
58 static int hf_ipv6_plen = -1;
59 static int hf_ipv6_nxt = -1;
60 static int hf_ipv6_hlim = -1;
61 static int hf_ipv6_src = -1;
62 static int hf_ipv6_dst = -1;
63 static int hf_ipv6_addr = -1;
65 static int hf_ipv6_final = -1;
67 static int hf_ipv6_fragments = -1;
68 static int hf_ipv6_fragment = -1;
69 static int hf_ipv6_fragment_overlap = -1;
70 static int hf_ipv6_fragment_overlap_conflict = -1;
71 static int hf_ipv6_fragment_multiple_tails = -1;
72 static int hf_ipv6_fragment_too_long_fragment = -1;
73 static int hf_ipv6_fragment_error = -1;
74 static int hf_ipv6_reassembled_in = -1;
76 static int hf_ipv6_mipv6_type = -1;
77 static int hf_ipv6_mipv6_length = -1;
78 static int hf_ipv6_mipv6_home_address = -1;
80 static gint ett_ipv6 = -1;
81 static gint ett_ipv6_fragments = -1;
82 static gint ett_ipv6_fragment = -1;
84 static const fragment_items ipv6_frag_items = {
89 &hf_ipv6_fragment_overlap,
90 &hf_ipv6_fragment_overlap_conflict,
91 &hf_ipv6_fragment_multiple_tails,
92 &hf_ipv6_fragment_too_long_fragment,
93 &hf_ipv6_fragment_error,
94 &hf_ipv6_reassembled_in,
98 static dissector_handle_t data_handle;
100 static dissector_table_t ip_dissector_table;
102 /* Reassemble fragmented datagrams */
103 static gboolean ipv6_reassemble = FALSE;
106 #define offsetof(type, member) ((size_t)(&((type *)0)->member))
110 * defragmentation of IPv6
112 static GHashTable *ipv6_fragment_table = NULL;
113 static GHashTable *ipv6_reassembled_table = NULL;
116 capture_ipv6(const guchar *pd, int offset, int len, packet_counts *ld)
121 if (!BYTES_ARE_IN_FRAME(offset, len, 4+4+16+16)) {
125 nxt = pd[offset+6]; /* get the "next header" value */
126 offset += 4+4+16+16; /* skip past the IPv6 header */
131 case IP_PROTO_HOPOPTS:
132 case IP_PROTO_ROUTING:
133 case IP_PROTO_DSTOPTS:
134 if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
139 advance = (pd[offset+1] + 1) << 3;
140 if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
147 case IP_PROTO_FRAGMENT:
148 if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
154 if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
162 if (!BYTES_ARE_IN_FRAME(offset, len, 2)) {
167 advance = 8 + ((pd[offset+1] - 1) << 2);
168 if (!BYTES_ARE_IN_FRAME(offset, len, advance)) {
188 case IP_PROTO_ICMPV6: /* XXX - separate counters? */
206 ipv6_reassemble_init(void)
208 fragment_table_init(&ipv6_fragment_table);
209 reassembled_table_init(&ipv6_reassembled_table);
213 dissect_routing6(tvbuff_t *tvb, int offset, proto_tree *tree) {
216 proto_tree *rthdr_tree;
218 char buf[sizeof(struct ip6_rthdr0) + sizeof(struct e_in6_addr) * 23];
220 tvb_memcpy(tvb, (guint8 *)&rt, offset, sizeof(rt));
221 len = (rt.ip6r_len + 1) << 3;
224 /* !!! specify length */
225 ti = proto_tree_add_text(tree, tvb, offset, len,
226 "Routing Header, Type %u", rt.ip6r_type);
227 rthdr_tree = proto_item_add_subtree(ti, ett_ipv6);
229 proto_tree_add_text(rthdr_tree, tvb,
230 offset + offsetof(struct ip6_rthdr, ip6r_nxt), 1,
231 "Next header: %s (0x%02x)", ipprotostr(rt.ip6r_nxt), rt.ip6r_nxt);
232 proto_tree_add_text(rthdr_tree, tvb,
233 offset + offsetof(struct ip6_rthdr, ip6r_len), 1,
234 "Length: %u (%d bytes)", rt.ip6r_len, len);
235 proto_tree_add_text(rthdr_tree, tvb,
236 offset + offsetof(struct ip6_rthdr, ip6r_type), 1,
237 "Type: %u", rt.ip6r_type);
238 proto_tree_add_text(rthdr_tree, tvb,
239 offset + offsetof(struct ip6_rthdr, ip6r_segleft), 1,
240 "Segments left: %u", rt.ip6r_segleft);
242 if (rt.ip6r_type == 0 && len <= sizeof(buf)) {
243 struct e_in6_addr *a;
245 struct ip6_rthdr0 *rt0;
247 tvb_memcpy(tvb, buf, offset, len);
248 rt0 = (struct ip6_rthdr0 *)buf;
249 for (a = rt0->ip6r0_addr, n = 0;
250 a < (struct e_in6_addr *)(buf + len);
252 proto_tree_add_text(rthdr_tree, tvb,
253 offset + offsetof(struct ip6_rthdr0, ip6r0_addr) + n * sizeof(struct e_in6_addr),
254 sizeof(struct e_in6_addr),
256 "address %d: %s (%s)",
257 n, get_hostname6(a), ip6_to_str(a)
259 "address %d: %s", n, ip6_to_str(a)
264 if (rt.ip6r_type == 2) {
265 proto_tree_add_ipv6(rthdr_tree, hf_ipv6_mipv6_home_address,
267 tvb_get_ptr(tvb, offset + 8, 16));
275 dissect_frag6(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree,
276 guint16 *offlg, guint32 *ident) {
277 struct ip6_frag frag;
280 proto_tree *rthdr_tree;
282 tvb_memcpy(tvb, (guint8 *)&frag, offset, sizeof(frag));
284 frag.ip6f_offlg = g_ntohs(frag.ip6f_offlg);
285 frag.ip6f_ident = g_ntohl(frag.ip6f_ident);
286 *offlg = frag.ip6f_offlg;
287 *ident = frag.ip6f_ident;
288 if (check_col(pinfo->cinfo, COL_INFO)) {
289 col_add_fstr(pinfo->cinfo, COL_INFO,
290 "IPv6 fragment (nxt=%s (0x%02x) off=%u id=0x%x)",
291 ipprotostr(frag.ip6f_nxt), frag.ip6f_nxt,
292 frag.ip6f_offlg & IP6F_OFF_MASK, frag.ip6f_ident);
295 ti = proto_tree_add_text(tree, tvb, offset, len,
296 "Fragmentation Header");
297 rthdr_tree = proto_item_add_subtree(ti, ett_ipv6);
299 proto_tree_add_text(rthdr_tree, tvb,
300 offset + offsetof(struct ip6_frag, ip6f_nxt), 1,
301 "Next header: %s (0x%02x)",
302 ipprotostr(frag.ip6f_nxt), frag.ip6f_nxt);
305 proto_tree_add_text(rthdr_tree, tvb,
306 offset + offsetof(struct ip6_frag, ip6f_reserved), 1,
311 proto_tree_add_text(rthdr_tree, tvb,
312 offset + offsetof(struct ip6_frag, ip6f_offlg), 2,
314 frag.ip6f_offlg & IP6F_OFF_MASK);
316 proto_tree_add_text(rthdr_tree, tvb,
317 offset + offsetof(struct ip6_frag, ip6f_offlg), 2,
318 "More fragments: %s",
319 frag.ip6f_offlg & IP6F_MORE_FRAG ?
322 proto_tree_add_text(rthdr_tree, tvb,
323 offset + offsetof(struct ip6_frag, ip6f_ident), 4,
324 "Identification: 0x%08x",
331 dissect_mipv6_hoa(tvbuff_t *tvb, proto_tree *dstopt_tree, int offset)
335 proto_tree_add_uint_format(dstopt_tree, hf_ipv6_mipv6_type, tvb,
337 tvb_get_guint8(tvb, offset + len),
338 "Option Type: %u (0x%02x) - Home Address Option",
339 tvb_get_guint8(tvb, offset + len),
340 tvb_get_guint8(tvb, offset + len));
343 proto_tree_add_uint(dstopt_tree, hf_ipv6_mipv6_length, tvb, offset + len,
344 1, tvb_get_guint8(tvb, offset + len));
347 proto_tree_add_ipv6(dstopt_tree, hf_ipv6_mipv6_home_address, tvb,
348 offset + len, 16, tvb_get_ptr(tvb, offset + len, 16));
353 static const value_string rtalertvals[] = {
354 { IP6OPT_RTALERT_MLD, "MLD" },
355 { IP6OPT_RTALERT_RSVP, "RSVP" },
359 /* Like "dissect_ip_tcp_options()", but assumes the length of an option
360 *doesn't* include the type and length bytes. */
362 dissect_ipv6_options(tvbuff_t *tvb, int offset, guint length,
363 const ip_tcp_opt *opttab, int nopts, int eol,
364 packet_info *pinfo, proto_tree *opt_tree)
367 const ip_tcp_opt *optp;
368 opt_len_type len_type;
371 char name_str[7+1+1+2+2+1+1]; /* "Unknown (0x%02x)" */
372 void (*dissect)(const struct ip_tcp_opt *, tvbuff_t *,
373 int, guint, packet_info *, proto_tree *);
377 opt = tvb_get_guint8(tvb, offset);
378 for (optp = &opttab[0]; optp < &opttab[nopts]; optp++) {
379 if (optp->optcode == opt)
382 if (optp == &opttab[nopts]) {
383 /* We assume that the only NO_LENGTH options are Pad1 options,
384 so that we can treat unknown options as VARIABLE_LENGTH with a
385 minimum of 0, and at least be able to move on to the next option
386 by using the length in the option. */
387 optp = NULL; /* indicate that we don't know this option */
388 len_type = VARIABLE_LENGTH;
390 snprintf(name_str, sizeof name_str, "Unknown (0x%02x)", opt);
394 len_type = optp->len_type;
395 optlen = optp->optlen;
397 dissect = optp->dissect;
399 --length; /* account for type byte */
400 if (len_type != NO_LENGTH) {
401 /* Option has a length. Is it in the packet? */
403 /* Bogus - packet must at least include option code byte and
405 proto_tree_add_text(opt_tree, tvb, offset, 1,
406 "%s (length byte past end of options)", name);
409 len = tvb_get_guint8(tvb, offset + 1); /* total including type, len */
410 --length; /* account for length byte */
412 /* Bogus - option goes past the end of the header. */
413 proto_tree_add_text(opt_tree, tvb, offset, length,
414 "%s (option length = %u byte%s says option goes past end of options)",
415 name, len, plurality(len, "", "s"));
417 } else if (len_type == FIXED_LENGTH && len != optlen) {
418 /* Bogus - option length isn't what it's supposed to be for this
420 proto_tree_add_text(opt_tree, tvb, offset, 2 + len,
421 "%s (with option length = %u byte%s; should be %u)", name,
422 len, plurality(len, "", "s"), optlen);
424 } else if (len_type == VARIABLE_LENGTH && len < optlen) {
425 /* Bogus - option length is less than what it's supposed to be for
427 proto_tree_add_text(opt_tree, tvb, offset, 2 + len,
428 "%s (with option length = %u byte%s; should be >= %u)", name,
429 len, plurality(len, "", "s"), optlen);
433 proto_tree_add_text(opt_tree, tvb, offset, 2 + len, "%s (%u byte%s)",
434 name, len, plurality(len, "", "s"));
436 if (dissect != NULL) {
437 /* Option has a dissector. */
438 (*dissect)(optp, tvb, offset, 2 + len, pinfo, opt_tree);
440 /* Option has no data, hence no dissector. */
441 proto_tree_add_text(opt_tree, tvb, offset, 2 + len, "%s", name);
448 proto_tree_add_text(opt_tree, tvb, offset, 1, "%s", name);
457 dissect_opts(tvbuff_t *tvb, int offset, proto_tree *tree, char *optname)
461 proto_tree *dstopt_tree;
465 int mip_offset = 0, delta = 0;
467 tvb_memcpy(tvb, (guint8 *)&ext, offset, sizeof(ext));
468 len = (ext.ip6e_len + 1) << 3;
471 /* !!! specify length */
472 ti = proto_tree_add_text(tree, tvb, offset, len, "%s Header ", optname);
474 dstopt_tree = proto_item_add_subtree(ti, ett_ipv6);
476 proto_tree_add_text(dstopt_tree, tvb,
477 offset + offsetof(struct ip6_ext, ip6e_nxt), 1,
478 "Next header: %s (0x%02x)", ipprotostr(ext.ip6e_nxt), ext.ip6e_nxt);
479 proto_tree_add_text(dstopt_tree, tvb,
480 offset + offsetof(struct ip6_ext, ip6e_len), 1,
481 "Length: %u (%d bytes)", ext.ip6e_len, len);
488 while (p < offset + len) {
489 switch (tvb_get_guint8(tvb, p)) {
491 proto_tree_add_text(dstopt_tree, tvb, p, 1, "Pad1");
496 tmp = tvb_get_guint8(tvb, p + 1);
497 proto_tree_add_text(dstopt_tree, tvb, p, tmp + 2,
498 "PadN: %u bytes", tmp + 2);
501 mip_offset += tvb_get_guint8(tvb, mip_offset + 1) + 2;
504 tmp = tvb_get_guint8(tvb, p + 1);
506 proto_tree_add_text(dstopt_tree, tvb, p, tmp + 2,
507 "Jumbo payload: %u (%u bytes)",
508 tvb_get_ntohl(tvb, p + 2), tmp + 2);
510 proto_tree_add_text(dstopt_tree, tvb, p, tmp + 2,
511 "Jumbo payload: Invalid length (%u bytes)",
516 mip_offset += tvb_get_guint8(tvb, mip_offset+1)+2;
522 tmp = tvb_get_guint8(tvb, p + 1);
524 rta = val_to_str(tvb_get_ntohs(tvb, p + 2), rtalertvals,
527 rta = "Invalid length";
528 ti = proto_tree_add_text(dstopt_tree, tvb, p , tmp + 2,
529 "Router alert: %s (%u bytes)", rta, tmp + 2);
532 mip_offset += tvb_get_guint8(tvb, mip_offset + 1) + 2;
535 case IP6OPT_HOME_ADDRESS:
536 delta = dissect_mipv6_hoa(tvb, dstopt_tree, mip_offset);
552 dissect_hopopts(tvbuff_t *tvb, int offset, proto_tree *tree)
554 return dissect_opts(tvb, offset, tree, "Hop-by-hop Option");
558 dissect_dstopts(tvbuff_t *tvb, int offset, proto_tree *tree)
560 return dissect_opts(tvb, offset, tree, "Destination Option");
564 dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
566 proto_tree *ipv6_tree = NULL;
572 gboolean hopopts, routing, frag, ah, dstopts;
576 fragment_data *ipfd_head;
578 gboolean update_col_info = TRUE;
579 gboolean save_fragmented;
583 if (check_col(pinfo->cinfo, COL_PROTOCOL))
584 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPv6");
585 if (check_col(pinfo->cinfo, COL_INFO))
586 col_clear(pinfo->cinfo, COL_INFO);
589 tvb_memcpy(tvb, (guint8 *)&ipv6, offset, sizeof(ipv6));
591 pinfo->ipproto = ipv6.ip6_nxt; /* XXX make work TCP follow (ipproto = 6) */
593 /* Get the payload length */
594 plen = g_ntohs(ipv6.ip6_plen);
596 /* Adjust the length of this tvbuff to include only the IPv6 datagram. */
597 set_actual_length(tvb, plen + sizeof (struct ip6_hdr));
599 SET_ADDRESS(&pinfo->net_src, AT_IPv6, 16, tvb_get_ptr(tvb, offset + IP6H_SRC, 16));
600 SET_ADDRESS(&pinfo->src, AT_IPv6, 16, tvb_get_ptr(tvb, offset + IP6H_SRC, 16));
601 SET_ADDRESS(&pinfo->net_dst, AT_IPv6, 16, tvb_get_ptr(tvb, offset + IP6H_DST, 16));
602 SET_ADDRESS(&pinfo->dst, AT_IPv6, 16, tvb_get_ptr(tvb, offset + IP6H_DST, 16));
605 /* !!! specify length */
606 ti = proto_tree_add_item(tree, proto_ipv6, tvb, offset, 40, FALSE);
607 ipv6_tree = proto_item_add_subtree(ti, ett_ipv6);
609 /* !!! warning: version also contains 4 Bit priority */
610 proto_tree_add_uint(ipv6_tree, hf_ipv6_version, tvb,
611 offset + offsetof(struct ip6_hdr, ip6_vfc), 1,
612 (ipv6.ip6_vfc >> 4) & 0x0f);
614 proto_tree_add_uint(ipv6_tree, hf_ipv6_class, tvb,
615 offset + offsetof(struct ip6_hdr, ip6_flow), 4,
616 (guint8)((g_ntohl(ipv6.ip6_flow) >> 20) & 0xff));
619 * there should be no alignment problems for ip6_flow, since it's the first
620 * guint32 in the ipv6 struct
622 proto_tree_add_uint_format(ipv6_tree, hf_ipv6_flow, tvb,
623 offset + offsetof(struct ip6_hdr, ip6_flow), 4,
624 (unsigned long)(g_ntohl(ipv6.ip6_flow) & IPV6_FLOWLABEL_MASK),
625 "Flowlabel: 0x%05lx",
626 (unsigned long)(g_ntohl(ipv6.ip6_flow) & IPV6_FLOWLABEL_MASK));
628 proto_tree_add_uint(ipv6_tree, hf_ipv6_plen, tvb,
629 offset + offsetof(struct ip6_hdr, ip6_plen), 2,
632 proto_tree_add_uint_format(ipv6_tree, hf_ipv6_nxt, tvb,
633 offset + offsetof(struct ip6_hdr, ip6_nxt), 1,
635 "Next header: %s (0x%02x)",
636 ipprotostr(ipv6.ip6_nxt), ipv6.ip6_nxt);
638 proto_tree_add_uint(ipv6_tree, hf_ipv6_hlim, tvb,
639 offset + offsetof(struct ip6_hdr, ip6_hlim), 1,
642 proto_tree_add_ipv6_hidden(ipv6_tree, hf_ipv6_addr, tvb,
643 offset + offsetof(struct ip6_hdr, ip6_src), 16,
644 ipv6.ip6_src.s6_addr8);
645 proto_tree_add_ipv6_hidden(ipv6_tree, hf_ipv6_addr, tvb,
646 offset + offsetof(struct ip6_hdr, ip6_dst), 16,
647 ipv6.ip6_dst.s6_addr8);
649 proto_tree_add_ipv6_format(ipv6_tree, hf_ipv6_src, tvb,
650 offset + offsetof(struct ip6_hdr, ip6_src), 16,
651 (guint8 *)&ipv6.ip6_src,
653 "Source address: %s (%s)",
654 get_hostname6(&ipv6.ip6_src),
656 "Source address: %s",
658 ip6_to_str(&ipv6.ip6_src));
660 proto_tree_add_ipv6_format(ipv6_tree, hf_ipv6_dst, tvb,
661 offset + offsetof(struct ip6_hdr, ip6_dst), 16,
662 (guint8 *)&ipv6.ip6_dst,
664 "Destination address: %s (%s)",
665 get_hostname6(&ipv6.ip6_dst),
667 "Destination address: %s",
669 ip6_to_str(&ipv6.ip6_dst));
672 /* start of the new header (could be a extension header) */
673 poffset = offset + offsetof(struct ip6_hdr, ip6_nxt);
674 nxt = tvb_get_guint8(tvb, poffset);
675 offset += sizeof(struct ip6_hdr);
679 /* start out assuming this isn't fragmented, and has none of the other
689 case IP_PROTO_HOPOPTS:
691 advance = dissect_hopopts(tvb, offset, tree);
692 nxt = tvb_get_guint8(tvb, offset);
697 case IP_PROTO_ROUTING:
699 advance = dissect_routing6(tvb, offset, tree);
700 nxt = tvb_get_guint8(tvb, offset);
705 case IP_PROTO_FRAGMENT:
707 advance = dissect_frag6(tvb, offset, pinfo, tree,
709 nxt = tvb_get_guint8(tvb, offset);
716 advance = dissect_ah_header(
717 tvb_new_subset(tvb, offset, -1, -1),
718 pinfo, tree, NULL, NULL);
719 nxt = tvb_get_guint8(tvb, offset);
724 case IP_PROTO_DSTOPTS:
726 advance = dissect_dstopts(tvb, offset, tree);
727 nxt = tvb_get_guint8(tvb, offset);
735 proto_tree_add_uint_hidden(ipv6_tree, hf_ipv6_final, tvb, poffset, 1, nxt);
738 /* If ipv6_reassemble is on, this is a fragment, and we have all the data
739 * in the fragment, then just add the fragment to the hashtable.
741 save_fragmented = pinfo->fragmented;
742 if (ipv6_reassemble && frag && tvb_bytes_exist(tvb, offset, plen)) {
743 ipfd_head = fragment_add_check(tvb, offset, pinfo, ident,
745 ipv6_reassembled_table,
746 offlg & IP6F_OFF_MASK,
748 offlg & IP6F_MORE_FRAG);
750 next_tvb = process_reassembled_data(tvb, offset, pinfo, "Reassembled IPv6",
751 ipfd_head, &ipv6_frag_items, &update_col_info, ipv6_tree);
753 /* If this is the first fragment, dissect its contents, otherwise
754 just show it as a fragment.
756 XXX - if we eventually don't save the reassembled contents of all
757 fragmented datagrams, we may want to always reassemble. */
758 if (offlg & IP6F_OFF_MASK) {
759 /* Not the first fragment - don't dissect it. */
762 /* First fragment, or not fragmented. Dissect what we have here. */
764 /* Get a tvbuff for the payload. */
765 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
768 * If this is the first fragment, but not the only fragment,
769 * tell the next protocol that.
771 if (offlg & IP6F_MORE_FRAG)
772 pinfo->fragmented = TRUE;
774 pinfo->fragmented = FALSE;
778 if (next_tvb == NULL) {
779 /* Just show this as a fragment. */
780 /* COL_INFO was filled in by "dissect_frag6()" */
781 call_dissector(data_handle, tvb_new_subset(tvb, offset, -1, -1), pinfo, tree);
783 /* As we haven't reassembled anything, we haven't changed "pi", so
784 we don't have to restore it. */
785 pinfo->fragmented = save_fragmented;
789 /* do lookup with the subdissector table */
790 if (!dissector_try_port(ip_dissector_table, nxt, next_tvb, pinfo, tree)) {
792 Handle "no next header" specially. */
793 if (nxt == IP_PROTO_NONE) {
794 if (check_col(pinfo->cinfo, COL_INFO)) {
795 /* If we had an Authentication Header, the AH dissector already
796 put something in the Info column; leave it there. */
798 if (hopopts || routing || dstopts) {
801 col_append_fstr(pinfo->cinfo, COL_INFO, "%shop-by-hop options",
806 col_append_fstr(pinfo->cinfo, COL_INFO, "%srouting", sep);
810 col_append_fstr(pinfo->cinfo, COL_INFO, "%sdestination options",
814 col_set_str(pinfo->cinfo, COL_INFO, "IPv6 no next header");
818 if (check_col(pinfo->cinfo, COL_INFO))
819 col_add_fstr(pinfo->cinfo, COL_INFO, "%s (0x%02x)", ipprotostr(nxt),nxt);
821 call_dissector(data_handle, next_tvb, pinfo, tree);
823 pinfo->fragmented = save_fragmented;
827 proto_register_ipv6(void)
829 static hf_register_info hf[] = {
831 { "Version", "ipv6.version",
832 FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
834 { "Traffic class", "ipv6.class",
835 FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
837 { "Flowlabel", "ipv6.flow",
838 FT_UINT32, BASE_HEX, NULL, 0x0, "", HFILL }},
840 { "Payload length", "ipv6.plen",
841 FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
843 { "Next header", "ipv6.nxt",
844 FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
846 { "Hop limit", "ipv6.hlim",
847 FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL }},
849 { "Source", "ipv6.src",
850 FT_IPv6, BASE_NONE, NULL, 0x0,
851 "Source IPv6 Address", HFILL }},
853 { "Destination", "ipv6.dst",
854 FT_IPv6, BASE_NONE, NULL, 0x0,
855 "Destination IPv6 Address", HFILL }},
857 { "Address", "ipv6.addr",
858 FT_IPv6, BASE_NONE, NULL, 0x0,
859 "Source or Destination IPv6 Address", HFILL }},
861 { &hf_ipv6_fragment_overlap,
862 { "Fragment overlap", "ipv6.fragment.overlap",
863 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
864 "Fragment overlaps with other fragments", HFILL }},
866 { &hf_ipv6_fragment_overlap_conflict,
867 { "Conflicting data in fragment overlap", "ipv6.fragment.overlap.conflict",
868 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
869 "Overlapping fragments contained conflicting data", HFILL }},
871 { &hf_ipv6_fragment_multiple_tails,
872 { "Multiple tail fragments found", "ipv6.fragment.multipletails",
873 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
874 "Several tails were found when defragmenting the packet", HFILL }},
876 { &hf_ipv6_fragment_too_long_fragment,
877 { "Fragment too long", "ipv6.fragment.toolongfragment",
878 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
879 "Fragment contained data past end of packet", HFILL }},
881 { &hf_ipv6_fragment_error,
882 { "Defragmentation error", "ipv6.fragment.error",
883 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
884 "Defragmentation error due to illegal fragments", HFILL }},
887 { "IPv6 Fragment", "ipv6.fragment",
888 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
889 "IPv6 Fragment", HFILL }},
891 { &hf_ipv6_fragments,
892 { "IPv6 Fragments", "ipv6.fragments",
893 FT_NONE, BASE_NONE, NULL, 0x0,
894 "IPv6 Fragments", HFILL }},
896 { &hf_ipv6_reassembled_in,
897 { "Reassembled IPv6 in frame", "ipv6.reassembled_in",
898 FT_FRAMENUM, BASE_NONE, NULL, 0x0,
899 "This IPv6 packet is reassembled in this frame", HFILL }},
902 { &hf_ipv6_mipv6_type,
903 { "Option Type ", "ipv6.mipv6_type",
904 FT_UINT8, BASE_DEC, NULL, 0x0,
906 { &hf_ipv6_mipv6_length,
907 { "Option Length ", "ipv6.mipv6_length",
908 FT_UINT8, BASE_DEC, NULL, 0x0,
910 { &hf_ipv6_mipv6_home_address,
911 { "Home Address ", "ipv6.mipv6_home_address",
912 FT_IPv6, BASE_HEX, NULL, 0x0,
917 { "Final next header", "ipv6.final",
918 FT_UINT8, BASE_HEX, NULL, 0x0, "", HFILL }},
921 static gint *ett[] = {
926 module_t *ipv6_module;
928 proto_ipv6 = proto_register_protocol("Internet Protocol Version 6", "IPv6", "ipv6");
929 proto_register_field_array(proto_ipv6, hf, array_length(hf));
930 proto_register_subtree_array(ett, array_length(ett));
932 /* Register configuration options */
933 ipv6_module = prefs_register_protocol(proto_ipv6, NULL);
934 prefs_register_bool_preference(ipv6_module, "defragment",
935 "Reassemble fragmented IPv6 datagrams",
936 "Whether fragmented IPv6 datagrams should be reassembled",
939 register_dissector("ipv6", dissect_ipv6, proto_ipv6);
940 register_init_routine(ipv6_reassemble_init);
944 proto_reg_handoff_ipv6(void)
946 dissector_handle_t ipv6_handle;
948 data_handle = find_dissector("data");
949 ipv6_handle = find_dissector("ipv6");
950 dissector_add("ethertype", ETHERTYPE_IPv6, ipv6_handle);
951 dissector_add("ppp.protocol", PPP_IPV6, ipv6_handle);
952 dissector_add("ppp.protocol", ETHERTYPE_IPv6, ipv6_handle);
953 dissector_add("gre.proto", ETHERTYPE_IPv6, ipv6_handle);
954 dissector_add("ip.proto", IP_PROTO_IPV6, ipv6_handle);
955 dissector_add("null.type", BSD_AF_INET6_BSD, ipv6_handle);
956 dissector_add("null.type", BSD_AF_INET6_FREEBSD, ipv6_handle);
957 dissector_add("null.type", BSD_AF_INET6_DARWIN, ipv6_handle);
958 dissector_add("chdlctype", ETHERTYPE_IPv6, ipv6_handle);
959 dissector_add("fr.ietf", NLPID_IP6, ipv6_handle);
960 dissector_add("x.25.spi", NLPID_IP6, ipv6_handle);
961 dissector_add("arcnet.protocol_id", ARCNET_PROTO_IPv6, ipv6_handle);
963 ip_dissector_table = find_dissector_table("ip.proto");