1999-03-29 02:21:34 +00:00
|
|
|
/* packet-icmpv6.c
|
2000-10-12 14:58:02 +00:00
|
|
|
* Routines for ICMPv6 packet disassembly
|
1999-03-29 02:21:34 +00:00
|
|
|
*
|
2001-01-03 06:56:03 +00:00
|
|
|
* $Id: packet-icmpv6.c,v 1.33 2001/01/03 06:55:28 guy Exp $
|
1999-03-29 02:21:34 +00:00
|
|
|
*
|
|
|
|
* Ethereal - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@zing.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2000-10-12 14:58:02 +00:00
|
|
|
*
|
1999-03-29 02:21:34 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2000-10-12 14:58:02 +00:00
|
|
|
*
|
1999-03-29 02:21:34 +00:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2000-10-12 14:58:02 +00:00
|
|
|
*
|
1999-03-29 02:21:34 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdio.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
1999-03-29 02:21:34 +00:00
|
|
|
#include <unistd.h>
|
1999-07-13 02:53:26 +00:00
|
|
|
#endif
|
|
|
|
|
1999-03-29 02:21:34 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
|
|
# include <sys/types.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_NETINET_IN_H
|
|
|
|
# include <netinet/in.h>
|
|
|
|
#endif
|
|
|
|
|
2000-08-11 13:37:21 +00:00
|
|
|
#include <glib.h>
|
|
|
|
|
1999-03-29 02:24:29 +00:00
|
|
|
#ifdef NEED_SNPRINTF_H
|
|
|
|
# include "snprintf.h"
|
|
|
|
#endif
|
|
|
|
|
1999-03-29 02:21:34 +00:00
|
|
|
#include "packet.h"
|
|
|
|
#include "packet-ipv6.h"
|
2000-04-20 07:05:58 +00:00
|
|
|
#include "packet-ip.h"
|
2000-08-22 08:30:00 +00:00
|
|
|
#include "packet-dns.h"
|
2000-12-14 21:45:12 +00:00
|
|
|
#include "in_cksum.h"
|
1999-03-29 02:21:34 +00:00
|
|
|
#include "resolv.h"
|
|
|
|
|
|
|
|
#ifndef offsetof
|
|
|
|
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
|
|
|
#endif
|
|
|
|
|
1999-07-29 05:47:07 +00:00
|
|
|
static int proto_icmpv6 = -1;
|
1999-10-10 16:09:33 +00:00
|
|
|
static int hf_icmpv6_type = -1;
|
|
|
|
static int hf_icmpv6_code = -1;
|
|
|
|
static int hf_icmpv6_checksum = -1;
|
1999-07-29 05:47:07 +00:00
|
|
|
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint ett_icmpv6 = -1;
|
|
|
|
static gint ett_icmpv6opt = -1;
|
|
|
|
static gint ett_icmpv6flag = -1;
|
2000-08-18 12:05:27 +00:00
|
|
|
static gint ett_nodeinfo_flag = -1;
|
|
|
|
static gint ett_nodeinfo_subject4 = -1;
|
|
|
|
static gint ett_nodeinfo_subject6 = -1;
|
|
|
|
static gint ett_nodeinfo_node4 = -1;
|
|
|
|
static gint ett_nodeinfo_node6 = -1;
|
2000-08-22 08:30:00 +00:00
|
|
|
static gint ett_nodeinfo_nodebitmap = -1;
|
|
|
|
static gint ett_nodeinfo_nodedns = -1;
|
2000-08-18 12:05:27 +00:00
|
|
|
|
|
|
|
static const value_string names_nodeinfo_qtype[] = {
|
|
|
|
{ NI_QTYPE_NOOP, "NOOP" },
|
|
|
|
{ NI_QTYPE_SUPTYPES, "Supported query types" },
|
|
|
|
{ NI_QTYPE_DNSNAME, "DNS name" },
|
|
|
|
{ NI_QTYPE_NODEADDR, "Node addresses" },
|
|
|
|
{ NI_QTYPE_IPV4ADDR, "IPv4 node addresses" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
1999-11-16 11:44:20 +00:00
|
|
|
|
2000-11-09 16:39:59 +00:00
|
|
|
static const value_string names_rrenum_matchcode[] = {
|
|
|
|
{ RPM_PCO_ADD, "Add" },
|
|
|
|
{ RPM_PCO_CHANGE, "Change" },
|
|
|
|
{ RPM_PCO_SETGLOBAL, "Set Global" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
1999-03-29 02:21:34 +00:00
|
|
|
static void
|
|
|
|
dissect_icmpv6opt(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree *icmp6opt_tree, *field_tree;
|
|
|
|
proto_item *ti, *tf;
|
|
|
|
struct nd_opt_hdr *opt;
|
|
|
|
int len;
|
|
|
|
char *typename;
|
|
|
|
|
|
|
|
if (!tree)
|
|
|
|
return;
|
|
|
|
|
|
|
|
again:
|
2000-01-24 03:51:35 +00:00
|
|
|
if (!IS_DATA_IN_FRAME(offset))
|
1999-03-29 02:21:34 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
opt = (struct nd_opt_hdr *)&pd[offset];
|
|
|
|
len = opt->nd_opt_len << 3;
|
|
|
|
|
|
|
|
/* !!! specify length */
|
2000-05-11 08:18:09 +00:00
|
|
|
ti = proto_tree_add_text(tree, NullTVB, offset, len, "ICMPv6 options");
|
1999-11-16 11:44:20 +00:00
|
|
|
icmp6opt_tree = proto_item_add_subtree(ti, ett_icmpv6opt);
|
1999-03-29 02:21:34 +00:00
|
|
|
|
|
|
|
switch (opt->nd_opt_type) {
|
|
|
|
case ND_OPT_SOURCE_LINKADDR:
|
|
|
|
typename = "Source link-layer address";
|
|
|
|
break;
|
|
|
|
case ND_OPT_TARGET_LINKADDR:
|
|
|
|
typename = "Target link-layer address";
|
|
|
|
break;
|
|
|
|
case ND_OPT_PREFIX_INFORMATION:
|
|
|
|
typename = "Prefix information";
|
|
|
|
break;
|
|
|
|
case ND_OPT_REDIRECTED_HEADER:
|
|
|
|
typename = "Redirected header";
|
|
|
|
break;
|
|
|
|
case ND_OPT_MTU:
|
|
|
|
typename = "MTU";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
typename = "Unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_opt_hdr, nd_opt_type), 1,
|
|
|
|
"Type: 0x%02x (%s)", opt->nd_opt_type, typename);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_opt_hdr, nd_opt_len), 1,
|
|
|
|
"Length: %d bytes (0x%02x)", opt->nd_opt_len << 3, opt->nd_opt_len);
|
|
|
|
|
|
|
|
/* decode... */
|
|
|
|
switch (opt->nd_opt_type) {
|
|
|
|
case ND_OPT_SOURCE_LINKADDR:
|
|
|
|
case ND_OPT_TARGET_LINKADDR:
|
|
|
|
{
|
|
|
|
char *t;
|
|
|
|
const char *p;
|
|
|
|
int len, i;
|
|
|
|
len = (opt->nd_opt_len << 3) - sizeof(*opt);
|
|
|
|
t = (char *)malloc(len * 3);
|
|
|
|
memset(t, 0, len * 3);
|
|
|
|
p = &pd[offset + sizeof(*opt)];
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (i)
|
|
|
|
t[i * 3 - 1] = ':';
|
|
|
|
sprintf(&t[i * 3], "%02x", p[i] & 0xff);
|
|
|
|
}
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + sizeof(*opt), len, "Link-layer address: %s", t);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ND_OPT_PREFIX_INFORMATION:
|
|
|
|
{
|
|
|
|
struct nd_opt_prefix_info *pi = (struct nd_opt_prefix_info *)opt;
|
|
|
|
int flagoff;
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_prefix_len),
|
|
|
|
1, "Prefix length: %d", pi->nd_opt_pi_prefix_len);
|
|
|
|
|
|
|
|
flagoff = offsetof(struct nd_opt_prefix_info, nd_opt_pi_flags_reserved);
|
2000-05-11 08:18:09 +00:00
|
|
|
tf = proto_tree_add_text(icmp6opt_tree, NullTVB, flagoff, 1, "Flags: 0x%02x",
|
1999-03-29 02:21:34 +00:00
|
|
|
pntohl(&pi->nd_opt_pi_flags_reserved));
|
1999-11-16 11:44:20 +00:00
|
|
|
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
1999-03-29 02:21:34 +00:00
|
|
|
decode_boolean_bitfield(pi->nd_opt_pi_flags_reserved,
|
|
|
|
0x80, 8, "Onlink", "Not onlink"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
1999-03-29 02:21:34 +00:00
|
|
|
decode_boolean_bitfield(pi->nd_opt_pi_flags_reserved,
|
|
|
|
0x40, 8, "Auto", "Not auto"));
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_valid_time),
|
|
|
|
4, "Valid lifetime: 0x%08x",
|
|
|
|
pntohl(&pi->nd_opt_pi_valid_time));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_preferred_time),
|
|
|
|
4, "Preferred lifetime: 0x%08x",
|
|
|
|
pntohl(&pi->nd_opt_pi_preferred_time));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_opt_prefix_info, nd_opt_pi_prefix),
|
|
|
|
16, "Prefix: %s", ip6_to_str(&pi->nd_opt_pi_prefix));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ND_OPT_REDIRECTED_HEADER:
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + 8, (opt->nd_opt_len << 3) - 8, "Redirected packet");
|
|
|
|
/* tiny sanity check */
|
|
|
|
if ((pd[offset + 8] & 0xf0) == 0x60)
|
|
|
|
dissect_ipv6(pd, offset + 8, fd, icmp6opt_tree);
|
|
|
|
else
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissect_data(pd, offset + 8, fd, icmp6opt_tree);
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ND_OPT_MTU:
|
|
|
|
{
|
|
|
|
struct nd_opt_mtu *pi = (struct nd_opt_mtu *)opt;
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_opt_mtu, nd_opt_mtu_mtu), 4,
|
1999-07-28 02:14:14 +00:00
|
|
|
"MTU: %d", pntohl(&pi->nd_opt_mtu_mtu));
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-10-12 14:58:02 +00:00
|
|
|
if (opt->nd_opt_len == 0) {
|
|
|
|
proto_tree_add_text(icmp6opt_tree, NullTVB,
|
|
|
|
offset + offsetof(struct nd_opt_hdr, nd_opt_len), 1,
|
|
|
|
"Invalid option length: %d",
|
|
|
|
opt->nd_opt_len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-03-29 02:21:34 +00:00
|
|
|
offset += (opt->nd_opt_len << 3);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
|
2000-08-18 12:05:27 +00:00
|
|
|
/*
|
|
|
|
* draft-ietf-ipngwg-icmp-name-lookups-06.txt
|
|
|
|
* Note that the packet format was changed several times in the past.
|
|
|
|
*/
|
2000-08-22 08:30:00 +00:00
|
|
|
|
|
|
|
static const char *
|
|
|
|
bitrange0(v, s, buf, buflen)
|
2000-08-22 15:07:33 +00:00
|
|
|
guint32 v;
|
2000-08-22 08:30:00 +00:00
|
|
|
int s;
|
|
|
|
char *buf;
|
|
|
|
int buflen;
|
|
|
|
{
|
2000-08-22 15:07:33 +00:00
|
|
|
guint32 v0;
|
2000-08-22 08:30:00 +00:00
|
|
|
char *p, *ep;
|
|
|
|
int off;
|
|
|
|
int i, l;
|
|
|
|
|
|
|
|
if (buflen < 1)
|
|
|
|
return NULL;
|
|
|
|
if (buflen == 1) {
|
|
|
|
buf[0] = '\0';
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
v0 = v;
|
|
|
|
p = buf;
|
|
|
|
ep = buf + buflen - 1;
|
|
|
|
memset(buf, 0, buflen);
|
|
|
|
off = 0;
|
|
|
|
while (off < 32) {
|
|
|
|
/* shift till we have 0x01 */
|
|
|
|
if ((v & 0x01) == 0) {
|
|
|
|
switch (v & 0x0f) {
|
|
|
|
case 0x00:
|
|
|
|
v >>= 4; off += 4; continue;
|
|
|
|
case 0x08:
|
|
|
|
v >>= 3; off += 3; continue;
|
|
|
|
case 0x04: case 0x0c:
|
|
|
|
v >>= 2; off += 2; continue;
|
|
|
|
default:
|
|
|
|
v >>= 1; off += 1; continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* we have 0x01 with us */
|
|
|
|
for (i = 0; i < 32 - off; i++) {
|
|
|
|
if ((v & (0x01 << i)) == 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i == 1)
|
|
|
|
l = snprintf(p, ep - p, ",%d", s + off);
|
|
|
|
else {
|
|
|
|
l = snprintf(p, ep - p, ",%d-%d", s + off,
|
|
|
|
s + off + i - 1);
|
|
|
|
}
|
|
|
|
if (l > ep - p) {
|
|
|
|
buf[0] = '\0';
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
v >>= i; off += i;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
bitrange(u_char *p, int l, int s)
|
|
|
|
{
|
|
|
|
static char buf[1024];
|
|
|
|
char *q, *eq;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
q = buf;
|
|
|
|
eq = buf + sizeof(buf) - 1;
|
|
|
|
for (i = 0; i < l; i++) {
|
|
|
|
if (bitrange0(pntohl(p + i * 4), s + i * 4, q, eq - q) == NULL) {
|
|
|
|
if (q != buf && q + 5 < buf + sizeof(buf))
|
|
|
|
strncpy(q, ",...", 5);
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return buf + 1;
|
|
|
|
}
|
|
|
|
|
2000-08-18 12:05:27 +00:00
|
|
|
static void
|
2000-08-18 15:52:02 +00:00
|
|
|
dissect_nodeinfo(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
2000-08-18 12:05:27 +00:00
|
|
|
{
|
|
|
|
proto_tree *field_tree;
|
|
|
|
proto_item *tf;
|
|
|
|
struct icmp6_nodeinfo *ni;
|
|
|
|
int off;
|
2000-08-22 08:30:00 +00:00
|
|
|
int i, n, l;
|
2000-08-18 12:05:27 +00:00
|
|
|
guint16 flags;
|
|
|
|
u_char *p;
|
2000-08-22 08:30:00 +00:00
|
|
|
char dname[MAXDNAME];
|
2000-08-18 12:05:27 +00:00
|
|
|
|
|
|
|
ni = (struct icmp6_nodeinfo *)&pd[offset];
|
|
|
|
|
|
|
|
/* flags */
|
|
|
|
flags = pntohs(&ni->ni_flags);
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "Flags: 0x%04x", flags);
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_nodeinfo_flag);
|
|
|
|
switch (pntohs(&ni->ni_qtype)) {
|
|
|
|
case NI_QTYPE_SUPTYPES:
|
|
|
|
if (ni->ni_type == ICMP6_NI_QUERY) {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_SUPTYPE_FLAG_COMPRESS, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"Compressed reply supported",
|
|
|
|
"No compressed reply support"));
|
|
|
|
} else {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_SUPTYPE_FLAG_COMPRESS, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"Compressed", "Not compressed"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NI_QTYPE_DNSNAME:
|
|
|
|
if (ni->ni_type == ICMP6_NI_REPLY) {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_FQDN_FLAG_VALIDTTL, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"Valid TTL field", "Meaningless TTL field"));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case NI_QTYPE_NODEADDR:
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_GLOBAL, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"Global address",
|
|
|
|
"Not global address"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_SITELOCAL, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"Site-local address",
|
|
|
|
"Not site-local address"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_LINKLOCAL, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"Link-local address",
|
|
|
|
"Not link-local address"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_COMPAT, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"IPv4 compatible/mapped address",
|
|
|
|
"Not IPv4 compatible/mapped address"));
|
|
|
|
/* fall through */
|
|
|
|
case NI_QTYPE_IPV4ADDR:
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_ALL, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"All unicast address",
|
|
|
|
"Unicast addresses on the queried interface"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_flags),
|
|
|
|
sizeof(ni->ni_flags), "%s",
|
2000-11-11 10:23:43 +00:00
|
|
|
decode_boolean_bitfield(flags, NI_NODEADDR_FLAG_TRUNCATE, sizeof(flags) * 8,
|
2000-08-18 12:05:27 +00:00
|
|
|
"Truncated", "Not truncated"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* nonce */
|
|
|
|
proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, icmp6_ni_nonce[0]),
|
|
|
|
sizeof(ni->icmp6_ni_nonce), "Nonce: 0x%08x%08x",
|
|
|
|
pntohl(&ni->icmp6_ni_nonce[0]), pntohl(&ni->icmp6_ni_nonce[4]));
|
|
|
|
|
|
|
|
/* offset for "the rest of data" */
|
|
|
|
off = sizeof(*ni);
|
|
|
|
|
2000-08-22 08:30:00 +00:00
|
|
|
/* rest of data */
|
|
|
|
if (!IS_DATA_IN_FRAME(offset + sizeof(*ni)))
|
|
|
|
goto nodata;
|
2000-08-18 12:05:27 +00:00
|
|
|
if (ni->ni_type == ICMP6_NI_QUERY) {
|
|
|
|
switch (ni->ni_code) {
|
|
|
|
case ICMP6_NI_SUBJ_IPV6:
|
|
|
|
n = pi.captured_len - (offset + sizeof(*ni));
|
|
|
|
n /= sizeof(struct e_in6_addr);
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + sizeof(*ni), END_OF_FRAME, "IPv6 subject addresses");
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_nodeinfo_subject6);
|
|
|
|
p = (u_char *)(ni + 1);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
p - pd, sizeof(struct e_in6_addr),
|
|
|
|
"%s", ip6_to_str((struct e_in6_addr *)p));
|
|
|
|
p += sizeof(struct e_in6_addr);
|
|
|
|
}
|
|
|
|
off = pi.captured_len - offset;
|
|
|
|
break;
|
|
|
|
case ICMP6_NI_SUBJ_FQDN:
|
2000-08-22 08:30:00 +00:00
|
|
|
l = get_dns_name(pd, offset + sizeof(*ni), offset + sizeof(*ni),
|
|
|
|
dname, sizeof(dname));
|
|
|
|
if (IS_DATA_IN_FRAME(offset + sizeof(*ni) + l) &&
|
|
|
|
pd[offset + sizeof(*ni) + l] == 0) {
|
|
|
|
l++;
|
|
|
|
proto_tree_add_text(tree, NullTVB, offset + sizeof(*ni), l,
|
|
|
|
"DNS label: %s (truncated)", dname);
|
|
|
|
} else {
|
|
|
|
proto_tree_add_text(tree, NullTVB, offset + sizeof(*ni), l,
|
|
|
|
"DNS label: %s", dname);
|
|
|
|
}
|
|
|
|
off = offset + sizeof(*ni) + l;
|
2000-08-18 12:05:27 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_NI_SUBJ_IPV4:
|
|
|
|
n = pi.captured_len - (offset + sizeof(*ni));
|
|
|
|
n /= sizeof(guint32);
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + sizeof(*ni), END_OF_FRAME, "IPv4 subject addresses");
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_nodeinfo_subject4);
|
|
|
|
p = (u_char *)(ni + 1);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
p - pd, sizeof(guint32), "%s", ip_to_str(p));
|
|
|
|
p += sizeof(guint32);
|
|
|
|
}
|
|
|
|
off = pi.captured_len - offset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
switch (pntohs(&ni->ni_qtype)) {
|
|
|
|
case NI_QTYPE_NOOP:
|
2000-08-22 08:30:00 +00:00
|
|
|
break;
|
2000-08-18 12:05:27 +00:00
|
|
|
case NI_QTYPE_SUPTYPES:
|
2000-08-22 08:30:00 +00:00
|
|
|
p = (u_char *)(ni + 1);
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + sizeof(*ni), END_OF_FRAME,
|
|
|
|
"Supported type bitmap%s",
|
|
|
|
(flags & 0x0001) ? ", compressed" : "");
|
|
|
|
field_tree = proto_item_add_subtree(tf,
|
|
|
|
ett_nodeinfo_nodebitmap);
|
|
|
|
n = 0;
|
|
|
|
while (IS_DATA_IN_FRAME(p - pd)) {
|
|
|
|
if ((flags & 0x0001) == 0) {
|
|
|
|
l = pi.captured_len - (offset + sizeof(*ni));
|
|
|
|
l /= sizeof(guint32);
|
|
|
|
i = 0;
|
|
|
|
} else {
|
|
|
|
if (!IS_DATA_IN_FRAME(p + sizeof(guint32) - 1 - pd))
|
|
|
|
break;
|
|
|
|
l = pntohs(p);
|
|
|
|
i = pntohs(p + sizeof(guint16)); /*skip*/
|
|
|
|
}
|
|
|
|
if (n + l * 32 > (1 << 16))
|
|
|
|
break;
|
|
|
|
if (n + (l + i) * 32 > (1 << 16))
|
|
|
|
break;
|
|
|
|
if ((flags & 0x0001) == 0) {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, p - pd,
|
|
|
|
l * 4, "Bitmap (%d to %d): %s", n, n + l * 32 - 1,
|
|
|
|
bitrange(p, l, n));
|
|
|
|
p += l * 4;
|
|
|
|
} else {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, p - pd,
|
|
|
|
4 + l * 4, "Bitmap (%d to %d): %s", n, n + l * 32 - 1,
|
|
|
|
bitrange(p + 4, l, n));
|
|
|
|
p += (4 + l * 4);
|
|
|
|
}
|
|
|
|
n += l * 32 + i * 32;
|
|
|
|
}
|
|
|
|
off = pi.captured_len - offset;
|
|
|
|
break;
|
2000-08-18 12:05:27 +00:00
|
|
|
case NI_QTYPE_DNSNAME:
|
2000-08-22 08:30:00 +00:00
|
|
|
proto_tree_add_text(tree, NullTVB, offset + sizeof(*ni),
|
|
|
|
sizeof(gint32), "TTL: %d", (gint32)pntohl(ni + 1));
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + sizeof(*ni) + sizeof(guint32), END_OF_FRAME,
|
|
|
|
"DNS labels");
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_nodeinfo_nodedns);
|
|
|
|
n = pi.captured_len;
|
|
|
|
i = offset + sizeof(*ni) + sizeof(guint32);
|
|
|
|
while (i < pi.captured_len) {
|
|
|
|
l = get_dns_name(pd, i, offset + sizeof(*ni), dname,
|
|
|
|
sizeof(dname));
|
|
|
|
if (IS_DATA_IN_FRAME(i + l) && pd[i + l] == 0) {
|
|
|
|
l++;
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, i, l,
|
|
|
|
"DNS label: %s (truncated)", dname);
|
|
|
|
} else {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, i, l,
|
|
|
|
"DNS label: %s", dname);
|
|
|
|
}
|
|
|
|
i += l;
|
|
|
|
}
|
|
|
|
off = pi.captured_len - offset;
|
2000-08-18 12:05:27 +00:00
|
|
|
break;
|
|
|
|
case NI_QTYPE_NODEADDR:
|
|
|
|
n = pi.captured_len - (offset + sizeof(*ni));
|
2000-08-29 14:17:12 +00:00
|
|
|
n /= sizeof(struct e_in6_addr) + sizeof(gint32);;
|
2000-08-18 12:05:27 +00:00
|
|
|
tf = proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + sizeof(*ni), END_OF_FRAME, "IPv6 node addresses");
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_nodeinfo_node6);
|
|
|
|
p = (u_char *)(ni + 1);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
2000-08-29 14:17:12 +00:00
|
|
|
p - pd, sizeof(struct e_in6_addr) + sizeof(gint32),
|
|
|
|
"%s (TTL %d)", ip6_to_str((struct e_in6_addr *)p),
|
|
|
|
(gint32)pntohl(p + sizeof(struct e_in6_addr)));
|
|
|
|
p += sizeof(struct e_in6_addr) + sizeof(gint32);
|
2000-08-18 12:05:27 +00:00
|
|
|
}
|
|
|
|
off = pi.captured_len - offset;
|
|
|
|
break;
|
|
|
|
case NI_QTYPE_IPV4ADDR:
|
|
|
|
n = pi.captured_len - (offset + sizeof(*ni));
|
|
|
|
n /= sizeof(guint32);
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + sizeof(*ni), END_OF_FRAME, "IPv4 node addresses");
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_nodeinfo_node4);
|
|
|
|
p = (u_char *)(ni + 1);
|
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
proto_tree_add_text(field_tree, NullTVB,
|
|
|
|
p - pd, sizeof(guint32), "%s", ip_to_str(p));
|
|
|
|
p += sizeof(guint32);
|
|
|
|
}
|
|
|
|
off = pi.captured_len - offset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2000-08-22 08:30:00 +00:00
|
|
|
nodata:;
|
2000-08-18 12:05:27 +00:00
|
|
|
|
|
|
|
/* the rest of data */
|
2000-08-18 15:52:02 +00:00
|
|
|
old_dissect_data(pd, offset + off, fd, tree);
|
2000-08-18 12:05:27 +00:00
|
|
|
}
|
|
|
|
|
2000-11-09 16:39:59 +00:00
|
|
|
static void
|
|
|
|
dissect_rrenum(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree *field_tree, *opt_tree;
|
|
|
|
proto_item *tf;
|
|
|
|
struct icmp6_router_renum *rr = (struct icmp6_router_renum *)&pd[offset];
|
|
|
|
struct rr_pco_match *match;
|
|
|
|
struct rr_pco_use *use;
|
|
|
|
int flagoff, off, l;
|
|
|
|
|
|
|
|
proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_router_renum, rr_seqnum), 4,
|
|
|
|
"Sequence number: 0x%08x", pntohl(&rr->rr_seqnum));
|
|
|
|
proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_router_renum, rr_segnum), 1,
|
|
|
|
"Segment number: 0x%02x", rr->rr_segnum);
|
|
|
|
|
|
|
|
flagoff = offset + offsetof(struct icmp6_router_renum, rr_flags);
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB, flagoff, 1,
|
|
|
|
"Flags: 0x%02x", pd[flagoff]);
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff], 0x80, 8,
|
|
|
|
"Test command", "Not test command"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff], 0x40, 8,
|
|
|
|
"Result requested", "Result not requested"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff], 0x20, 8,
|
|
|
|
"All interfaces", "Not all interfaces"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff], 0x10, 8,
|
|
|
|
"Site specific", "Not site specific"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff], 0x08, 8,
|
|
|
|
"Processed previously", "Complete result"));
|
|
|
|
|
|
|
|
proto_tree_add_text(tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_router_renum, rr_maxdelay), 2,
|
|
|
|
"Max delay: 0x%04x", pntohs(&rr->rr_maxdelay));
|
|
|
|
old_dissect_data(pd, offset + sizeof(*rr), fd, tree); /*XXX*/
|
|
|
|
|
|
|
|
if (rr->rr_code == ICMP6_ROUTER_RENUMBERING_COMMAND) {
|
|
|
|
off = offset + sizeof(*rr);
|
|
|
|
match = (struct rr_pco_match *)&pd[off];
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB, off, sizeof(*match),
|
|
|
|
"Match-Prefix: %s/%u (%u-%u)", ip6_to_str(&match->rpm_prefix),
|
|
|
|
match->rpm_matchlen, match->rpm_minlen, match->rpm_maxlen);
|
|
|
|
opt_tree = proto_item_add_subtree(tf, ett_icmpv6opt);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_match, rpm_code),
|
2000-11-09 21:57:35 +00:00
|
|
|
sizeof(match->rpm_code), "OpCode: %s (%u)",
|
2000-11-09 16:39:59 +00:00
|
|
|
val_to_str(match->rpm_code, names_rrenum_matchcode, "Unknown"),
|
|
|
|
match->rpm_code);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_match, rpm_len),
|
|
|
|
sizeof(match->rpm_len), "OpLength: %u (%u octets)",
|
|
|
|
match->rpm_len, match->rpm_len * 8);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_match, rpm_ordinal),
|
|
|
|
sizeof(match->rpm_ordinal), "Ordinal: %u", match->rpm_ordinal);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_match, rpm_matchlen),
|
|
|
|
sizeof(match->rpm_matchlen), "MatchLen: %u", match->rpm_matchlen);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_match, rpm_minlen),
|
|
|
|
sizeof(match->rpm_minlen), "MinLen: %u", match->rpm_minlen);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_match, rpm_maxlen),
|
|
|
|
sizeof(match->rpm_maxlen), "MaxLen: %u", match->rpm_maxlen);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_match, rpm_prefix),
|
|
|
|
sizeof(match->rpm_prefix), "MatchPrefix: %s",
|
|
|
|
ip6_to_str(&match->rpm_prefix));
|
|
|
|
|
|
|
|
off += sizeof(*match);
|
|
|
|
use = (struct rr_pco_use *)&pd[off];
|
|
|
|
for (l = match->rpm_len * 8 - sizeof(*match);
|
|
|
|
l >= sizeof(*use); l -= sizeof(*use), off += sizeof(*use)) {
|
|
|
|
tf = proto_tree_add_text(tree, NullTVB, off, sizeof(*use),
|
|
|
|
"Use-Prefix: %s/%u (keep %u)", ip6_to_str(&use->rpu_prefix),
|
|
|
|
use->rpu_uselen, use->rpu_keeplen);
|
|
|
|
opt_tree = proto_item_add_subtree(tf, ett_icmpv6opt);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_use, rpu_uselen),
|
|
|
|
sizeof(use->rpu_uselen), "UseLen: %u", use->rpu_uselen);
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_use, rpu_keeplen),
|
|
|
|
sizeof(use->rpu_keeplen), "KeepLen: %u", use->rpu_keeplen);
|
|
|
|
tf = proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
flagoff = off + offsetof(struct rr_pco_use, rpu_ramask),
|
|
|
|
sizeof(use->rpu_ramask), "FlagMask: 0x%x", use->rpu_ramask);
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff],
|
|
|
|
ICMP6_RR_PCOUSE_RAFLAGS_ONLINK, 8,
|
|
|
|
"Onlink", "Not onlink"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff],
|
|
|
|
ICMP6_RR_PCOUSE_RAFLAGS_AUTO, 8,
|
|
|
|
"Auto", "Not auto"));
|
|
|
|
tf = proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
flagoff = off + offsetof(struct rr_pco_use, rpu_raflags),
|
|
|
|
sizeof(use->rpu_raflags), "RAFlags: 0x%x", use->rpu_raflags);
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff],
|
|
|
|
ICMP6_RR_PCOUSE_RAFLAGS_ONLINK, 8,
|
|
|
|
"Onlink", "Not onlink"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 1, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff],
|
|
|
|
ICMP6_RR_PCOUSE_RAFLAGS_AUTO, 8, "Auto", "Not auto"));
|
|
|
|
if (pntohl(&use->rpu_vltime) == 0xffffffff)
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_use, rpu_vltime),
|
|
|
|
sizeof(use->rpu_vltime), "Valid Lifetime: infinity");
|
|
|
|
else
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_use, rpu_vltime),
|
|
|
|
sizeof(use->rpu_vltime), "Valid Lifetime: %u",
|
|
|
|
pntohl(&use->rpu_vltime));
|
|
|
|
if (pntohl(&use->rpu_pltime) == 0xffffffff)
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_use, rpu_pltime),
|
|
|
|
sizeof(use->rpu_pltime), "Preferred Lifetime: infinity");
|
|
|
|
else
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_use, rpu_pltime),
|
|
|
|
sizeof(use->rpu_pltime), "Preferred Lifetime: %u",
|
|
|
|
pntohl(&use->rpu_pltime));
|
|
|
|
tf = proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
flagoff = off + offsetof(struct rr_pco_use, rpu_flags),
|
|
|
|
sizeof(use->rpu_flags), "Flags: 0x%08x",
|
|
|
|
pntohl(&use->rpu_flags));
|
|
|
|
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff],
|
|
|
|
ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME, 32,
|
|
|
|
"Decrement valid lifetime", "No decrement valid lifetime"));
|
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
|
|
|
|
decode_boolean_bitfield(pd[flagoff],
|
|
|
|
ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME, 32,
|
|
|
|
"Decrement preferred lifetime",
|
|
|
|
"No decrement preferred lifetime"));
|
|
|
|
proto_tree_add_text(opt_tree, NullTVB,
|
|
|
|
off + offsetof(struct rr_pco_use, rpu_prefix),
|
|
|
|
sizeof(use->rpu_prefix), "UsePrefix: %s",
|
|
|
|
ip6_to_str(&use->rpu_prefix));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-04-20 07:05:58 +00:00
|
|
|
static void
|
1999-03-29 02:21:34 +00:00
|
|
|
dissect_icmpv6(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
|
|
|
|
{
|
|
|
|
proto_tree *icmp6_tree, *field_tree;
|
2000-12-14 21:45:12 +00:00
|
|
|
proto_item *ti, *tf = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
struct icmp6_hdr *dp;
|
2000-08-18 12:05:27 +00:00
|
|
|
struct icmp6_nodeinfo *ni = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
char *codename, *typename;
|
2000-08-18 12:05:27 +00:00
|
|
|
char *colcodename, *coltypename;
|
1999-03-29 02:21:34 +00:00
|
|
|
int len;
|
2000-12-14 21:45:12 +00:00
|
|
|
guint length, reported_length;
|
|
|
|
vec_t cksum_vec[4];
|
|
|
|
guint32 phdr[2];
|
|
|
|
guint16 cksum, computed_cksum;
|
1999-03-29 02:21:34 +00:00
|
|
|
|
Add the "Edit:Protocols..." feature which currently only implements
the following:
It is now possible to enable/disable a particular protocol decoding
(i.e. the protocol dissector is void or not). When a protocol
is disabled, it is displayed as Data and of course, all linked
sub-protocols are disabled as well.
Disabling a protocol could be interesting:
- in case of buggy dissectors
- in case of wrong heuristics
- for performance reasons
- to decode the data as another protocol (TODO)
Currently (if I am not wrong), all dissectors but NFS can be disabled
(and dissectors that do not register protocols :-)
I do not like the way the RPC sub-dissectors are disabled (in the
sub-dissectors) since this could be done in the RPC dissector itself,
knowing the sub-protocol hfinfo entry (this is why, I've not modified
the NFS one yet).
Two functions are added in proto.c :
gboolean proto_is_protocol_enabled(int n);
void proto_set_decoding(int n, gboolean enabled);
and two MACROs which can be used in dissectors:
OLD_CHECK_DISPLAY_AS_DATA(index, pd, offset, fd, tree)
CHECK_DISPLAY_AS_DATA(index, tvb, pinfo, tree)
See also the XXX in proto_dlg.c and proto.c around the new functions.
svn path=/trunk/; revision=2267
2000-08-13 14:09:15 +00:00
|
|
|
OLD_CHECK_DISPLAY_AS_DATA(proto_icmpv6, pd, offset, fd, tree);
|
|
|
|
|
1999-03-29 02:21:34 +00:00
|
|
|
dp = (struct icmp6_hdr *)&pd[offset];
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = typename = colcodename = coltypename = "Unknown";
|
1999-03-29 02:21:34 +00:00
|
|
|
len = sizeof(*dp);
|
|
|
|
switch (dp->icmp6_type) {
|
|
|
|
case ICMP6_DST_UNREACH:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Unreachable";
|
1999-03-29 02:21:34 +00:00
|
|
|
switch (dp->icmp6_code) {
|
|
|
|
case ICMP6_DST_UNREACH_NOROUTE:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Route unreachable";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_DST_UNREACH_ADMIN:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Administratively prohibited";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_DST_UNREACH_NOTNEIGHBOR:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Not a neighbor";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_DST_UNREACH_ADDR:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Address unreachable";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_DST_UNREACH_NOPORT:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Port unreachable";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICMP6_PACKET_TOO_BIG:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Too big";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_TIME_EXCEEDED:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Time exceeded";
|
1999-03-29 02:21:34 +00:00
|
|
|
switch (dp->icmp6_code) {
|
|
|
|
case ICMP6_TIME_EXCEED_TRANSIT:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "In-transit";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_TIME_EXCEED_REASSEMBLY:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Reassembly";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-07-28 02:32:25 +00:00
|
|
|
break;
|
1999-03-29 02:21:34 +00:00
|
|
|
case ICMP6_PARAM_PROB:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Parameter problem";
|
1999-03-29 02:21:34 +00:00
|
|
|
switch (dp->icmp6_code) {
|
|
|
|
case ICMP6_PARAMPROB_HEADER:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Header";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_PARAMPROB_NEXTHEADER:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Next header";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_PARAMPROB_OPTION:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Option";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
}
|
1999-07-28 02:32:25 +00:00
|
|
|
break;
|
1999-03-29 02:21:34 +00:00
|
|
|
case ICMP6_ECHO_REQUEST:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Echo request";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_ECHO_REPLY:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Echo reply";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_MEMBERSHIP_QUERY:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Multicast listener query";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_MEMBERSHIP_REPORT:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Multicast listener report";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_MEMBERSHIP_REDUCTION:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Multicast listener done";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ND_ROUTER_SOLICIT:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Router solicitation";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
len = sizeof(struct nd_router_solicit);
|
|
|
|
break;
|
|
|
|
case ND_ROUTER_ADVERT:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Router advertisement";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
len = sizeof(struct nd_router_advert);
|
|
|
|
break;
|
|
|
|
case ND_NEIGHBOR_SOLICIT:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Neighbor solicitation";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
len = sizeof(struct nd_neighbor_solicit);
|
|
|
|
break;
|
|
|
|
case ND_NEIGHBOR_ADVERT:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Neighbor advertisement";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
len = sizeof(struct nd_neighbor_advert);
|
|
|
|
break;
|
|
|
|
case ND_REDIRECT:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Redirect";
|
|
|
|
codename = colcodename = NULL;
|
1999-03-29 02:21:34 +00:00
|
|
|
len = sizeof(struct nd_redirect);
|
|
|
|
break;
|
|
|
|
case ICMP6_ROUTER_RENUMBERING:
|
2000-08-18 12:05:27 +00:00
|
|
|
typename = coltypename = "Router renumbering";
|
1999-03-29 02:21:34 +00:00
|
|
|
switch (dp->icmp6_code) {
|
|
|
|
case ICMP6_ROUTER_RENUMBERING_COMMAND:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Command";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_ROUTER_RENUMBERING_RESULT:
|
2000-08-18 12:05:27 +00:00
|
|
|
codename = colcodename = "Result";
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
2000-11-09 16:39:59 +00:00
|
|
|
case ICMP6_ROUTER_RENUMBERING_SEQNUM_RESET:
|
|
|
|
codename = colcodename = "Sequence number reset";
|
|
|
|
break;
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
|
|
|
len = sizeof(struct icmp6_router_renum);
|
|
|
|
break;
|
2000-08-18 12:05:27 +00:00
|
|
|
case ICMP6_NI_QUERY:
|
|
|
|
case ICMP6_NI_REPLY:
|
|
|
|
ni = (struct icmp6_nodeinfo *)dp;
|
|
|
|
if (ni->ni_type == ICMP6_NI_QUERY) {
|
|
|
|
typename = coltypename = "Node information query";
|
|
|
|
switch (ni->ni_code) {
|
|
|
|
case ICMP6_NI_SUBJ_IPV6:
|
|
|
|
codename = "Query subject = IPv6 addresses";
|
|
|
|
break;
|
|
|
|
case ICMP6_NI_SUBJ_FQDN:
|
|
|
|
if (IS_DATA_IN_FRAME(offset + sizeof(*ni)))
|
|
|
|
codename = "Query subject = DNS name";
|
|
|
|
else
|
|
|
|
codename = "Query subject = empty";
|
|
|
|
break;
|
|
|
|
case ICMP6_NI_SUBJ_IPV4:
|
|
|
|
codename = "Query subject = IPv4 addresses";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
typename = coltypename = "Node information reply";
|
|
|
|
switch (ni->ni_code) {
|
|
|
|
case ICMP6_NI_SUCCESS:
|
|
|
|
codename = "Successful";
|
|
|
|
break;
|
|
|
|
case ICMP6_NI_REFUSED:
|
|
|
|
codename = "Refused";
|
|
|
|
break;
|
|
|
|
case ICMP6_NI_UNKNOWN:
|
|
|
|
codename = "Unknown query type";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
colcodename = val_to_str(pntohs(&ni->ni_qtype), names_nodeinfo_qtype,
|
|
|
|
"Unknown");
|
|
|
|
len = sizeof(struct icmp6_nodeinfo);
|
|
|
|
break;
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (check_col(fd, COL_PROTOCOL))
|
2000-11-19 08:54:37 +00:00
|
|
|
col_set_str(fd, COL_PROTOCOL, "ICMPv6");
|
1999-03-29 02:21:34 +00:00
|
|
|
if (check_col(fd, COL_INFO)) {
|
|
|
|
char typebuf[256], codebuf[256];
|
|
|
|
|
2000-08-18 12:05:27 +00:00
|
|
|
if (coltypename && strcmp(coltypename, "Unknown") == 0) {
|
1999-03-29 02:21:34 +00:00
|
|
|
snprintf(typebuf, sizeof(typebuf), "Unknown (0x%02x)",
|
|
|
|
dp->icmp6_type);
|
2000-08-18 12:05:27 +00:00
|
|
|
coltypename = typebuf;
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
2000-08-18 12:05:27 +00:00
|
|
|
if (colcodename && strcmp(colcodename, "Unknown") == 0) {
|
1999-03-29 02:21:34 +00:00
|
|
|
snprintf(codebuf, sizeof(codebuf), "Unknown (0x%02x)",
|
|
|
|
dp->icmp6_code);
|
2000-08-18 12:05:27 +00:00
|
|
|
colcodename = codebuf;
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
2000-08-18 12:05:27 +00:00
|
|
|
if (colcodename) {
|
|
|
|
col_add_fstr(fd, COL_INFO, "%s (%s)", coltypename, colcodename);
|
1999-03-29 02:21:34 +00:00
|
|
|
} else {
|
2000-08-18 12:05:27 +00:00
|
|
|
col_add_fstr(fd, COL_INFO, "%s", coltypename);
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
/* !!! specify length */
|
2000-05-31 05:09:07 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_icmpv6, NullTVB, offset, len, FALSE);
|
1999-11-16 11:44:20 +00:00
|
|
|
icmp6_tree = proto_item_add_subtree(ti, ett_icmpv6);
|
1999-03-29 02:21:34 +00:00
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_uint_format(icmp6_tree, hf_icmpv6_type, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_type), 1,
|
1999-10-10 16:09:33 +00:00
|
|
|
dp->icmp6_type,
|
1999-03-29 02:21:34 +00:00
|
|
|
"Type: 0x%02x (%s)", dp->icmp6_type, typename);
|
|
|
|
if (codename) {
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_uint_format(icmp6_tree, hf_icmpv6_code, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_code), 1,
|
1999-10-10 16:09:33 +00:00
|
|
|
dp->icmp6_code,
|
1999-03-29 02:21:34 +00:00
|
|
|
"Code: 0x%02x (%s)", dp->icmp6_code, codename);
|
2000-08-18 12:05:27 +00:00
|
|
|
} else {
|
|
|
|
proto_tree_add_uint_format(icmp6_tree, hf_icmpv6_code, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_code), 1,
|
|
|
|
dp->icmp6_code,
|
|
|
|
"Code: 0x%02x", dp->icmp6_code);
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
2000-12-14 21:45:12 +00:00
|
|
|
cksum = (guint16)htons(dp->icmp6_cksum);
|
|
|
|
length = pi.captured_len - offset;
|
|
|
|
reported_length = pi.len - offset;
|
|
|
|
if (!pi.fragmented && length >= reported_length) {
|
|
|
|
/* The packet isn't part of a fragmented datagram and isn't
|
|
|
|
truncated, so we can checksum it. */
|
|
|
|
|
|
|
|
/* Set up the fields of the pseudo-header. */
|
|
|
|
cksum_vec[0].ptr = pi.src.data;
|
|
|
|
cksum_vec[0].len = pi.src.len;
|
|
|
|
cksum_vec[1].ptr = pi.dst.data;
|
|
|
|
cksum_vec[1].len = pi.dst.len;
|
|
|
|
cksum_vec[2].ptr = (const guint8 *)&phdr;
|
|
|
|
phdr[0] = htonl(reported_length);
|
|
|
|
phdr[1] = htonl(IP_PROTO_ICMPV6);
|
|
|
|
cksum_vec[2].len = 8;
|
|
|
|
cksum_vec[3].ptr = &pd[offset];
|
|
|
|
cksum_vec[3].len = reported_length;
|
|
|
|
computed_cksum = in_cksum(cksum_vec, 4);
|
|
|
|
if (computed_cksum == 0) {
|
|
|
|
proto_tree_add_uint_format(icmp6_tree, hf_icmpv6_checksum,
|
|
|
|
NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_cksum), 2,
|
|
|
|
cksum,
|
|
|
|
"Checksum: 0x%04x (correct)", cksum);
|
|
|
|
} else {
|
|
|
|
proto_tree_add_uint_format(icmp6_tree, hf_icmpv6_checksum,
|
|
|
|
NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_cksum), 2,
|
|
|
|
cksum,
|
|
|
|
"Checksum: 0x%04x (incorrect, should be 0x%04x)",
|
|
|
|
cksum, in_cksum_shouldbe(cksum, computed_cksum));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
proto_tree_add_uint(icmp6_tree, hf_icmpv6_checksum, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_cksum), 2,
|
|
|
|
cksum);
|
|
|
|
}
|
1999-03-29 02:21:34 +00:00
|
|
|
|
|
|
|
/* decode... */
|
|
|
|
switch (dp->icmp6_type) {
|
|
|
|
case ICMP6_DST_UNREACH:
|
|
|
|
case ICMP6_TIME_EXCEEDED:
|
|
|
|
/* tiny sanity check */
|
|
|
|
if ((pd[offset + sizeof(*dp)] & 0xf0) == 0x60) {
|
|
|
|
dissect_ipv6(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
|
|
|
} else {
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissect_data(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICMP6_PACKET_TOO_BIG:
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_mtu), 4,
|
|
|
|
"MTU: %d", pntohl(&dp->icmp6_mtu));
|
|
|
|
/* tiny sanity check */
|
|
|
|
if ((pd[offset + sizeof(*dp)] & 0xf0) == 0x60) {
|
|
|
|
dissect_ipv6(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
|
|
|
} else {
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissect_data(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICMP6_PARAM_PROB:
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_pptr), 4,
|
|
|
|
"Problem pointer: 0x%04x", pntohl(&dp->icmp6_pptr));
|
|
|
|
/* tiny sanity check */
|
|
|
|
if ((pd[offset + sizeof(*dp)] & 0xf0) == 0x60) {
|
|
|
|
dissect_ipv6(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
|
|
|
} else {
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissect_data(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
1999-03-29 02:21:34 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ICMP6_ECHO_REQUEST:
|
|
|
|
case ICMP6_ECHO_REPLY:
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_id), 2,
|
|
|
|
"ID: 0x%04x", (guint16)ntohs(dp->icmp6_id));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_seq), 2,
|
|
|
|
"Sequence: 0x%04x", (guint16)ntohs(dp->icmp6_seq));
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissect_data(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
case ICMP6_MEMBERSHIP_QUERY:
|
|
|
|
case ICMP6_MEMBERSHIP_REPORT:
|
|
|
|
case ICMP6_MEMBERSHIP_REDUCTION:
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct icmp6_hdr, icmp6_maxdelay), 2,
|
|
|
|
"Maximum response delay: %d",
|
|
|
|
(guint16)ntohs(dp->icmp6_maxdelay));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB, offset + sizeof(*dp), 16,
|
1999-03-29 02:21:34 +00:00
|
|
|
"Multicast Address: %s",
|
|
|
|
ip6_to_str((struct e_in6_addr *)(dp + 1)));
|
|
|
|
break;
|
|
|
|
case ND_ROUTER_SOLICIT:
|
|
|
|
dissect_icmpv6opt(pd, offset + sizeof(*dp), fd, icmp6_tree);
|
|
|
|
break;
|
|
|
|
case ND_ROUTER_ADVERT:
|
|
|
|
{
|
|
|
|
struct nd_router_advert *ra = (struct nd_router_advert *)dp;
|
|
|
|
int flagoff;
|
|
|
|
guint32 ra_flags;
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_router_advert, nd_ra_curhoplimit),
|
|
|
|
1, "Cur hop limit: %d", ra->nd_ra_curhoplimit);
|
|
|
|
|
|
|
|
flagoff = offset + offsetof(struct nd_router_advert, nd_ra_flags_reserved);
|
|
|
|
ra_flags = pntohl(&pd[flagoff]);
|
2000-05-11 08:18:09 +00:00
|
|
|
tf = proto_tree_add_text(icmp6_tree, NullTVB, flagoff, 4, "Flags: 0x%08x", ra_flags);
|
1999-11-16 11:44:20 +00:00
|
|
|
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
|
1999-03-29 02:21:34 +00:00
|
|
|
decode_boolean_bitfield(ra_flags,
|
|
|
|
0x80000000, 32, "Managed", "Not managed"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
|
1999-03-29 02:21:34 +00:00
|
|
|
decode_boolean_bitfield(ra_flags,
|
|
|
|
0x40000000, 32, "Other", "Not other"));
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_router_advert, nd_ra_router_lifetime),
|
|
|
|
2, "Router lifetime: %d",
|
|
|
|
(guint16)ntohs(ra->nd_ra_router_lifetime));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_router_advert, nd_ra_reachable), 4,
|
|
|
|
"Reachable time: %d", pntohl(&ra->nd_ra_reachable));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_router_advert, nd_ra_retransmit), 4,
|
|
|
|
"Retrans time: %d", pntohl(&ra->nd_ra_retransmit));
|
|
|
|
dissect_icmpv6opt(pd, offset + sizeof(struct nd_router_advert), fd, icmp6_tree);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ND_NEIGHBOR_SOLICIT:
|
|
|
|
{
|
|
|
|
struct nd_neighbor_solicit *ns = (struct nd_neighbor_solicit *)dp;
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_neighbor_solicit, nd_ns_target), 16,
|
|
|
|
#ifdef INET6
|
|
|
|
"Target: %s (%s)",
|
|
|
|
get_hostname6(&ns->nd_ns_target),
|
|
|
|
#else
|
|
|
|
"Target: %s",
|
|
|
|
#endif
|
|
|
|
ip6_to_str(&ns->nd_ns_target));
|
|
|
|
|
|
|
|
dissect_icmpv6opt(pd, offset + sizeof(*ns), fd, icmp6_tree);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ND_NEIGHBOR_ADVERT:
|
|
|
|
{
|
|
|
|
int flagoff, targetoff;
|
|
|
|
guint32 na_flags;
|
|
|
|
struct e_in6_addr *na_target_p;
|
|
|
|
|
|
|
|
flagoff = offset + offsetof(struct nd_neighbor_advert, nd_na_flags_reserved);
|
|
|
|
na_flags = pntohl(&pd[flagoff]);
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
tf = proto_tree_add_text(icmp6_tree, NullTVB, flagoff, 4, "Flags: 0x%08x", na_flags);
|
1999-11-16 11:44:20 +00:00
|
|
|
field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
|
1999-03-29 02:21:34 +00:00
|
|
|
decode_boolean_bitfield(na_flags,
|
2000-11-11 10:23:43 +00:00
|
|
|
ND_NA_FLAG_ROUTER, 32, "Router", "Not router"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
|
1999-03-29 02:21:34 +00:00
|
|
|
decode_boolean_bitfield(na_flags,
|
2000-11-11 10:23:43 +00:00
|
|
|
ND_NA_FLAG_SOLICITED, 32, "Solicited", "Not adverted"));
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(field_tree, NullTVB, flagoff, 4, "%s",
|
1999-03-29 02:21:34 +00:00
|
|
|
decode_boolean_bitfield(na_flags,
|
2000-11-11 10:23:43 +00:00
|
|
|
ND_NA_FLAG_OVERRIDE, 32, "Override", "Not override"));
|
1999-03-29 02:21:34 +00:00
|
|
|
|
|
|
|
targetoff = offset + offsetof(struct nd_neighbor_advert, nd_na_target);
|
|
|
|
na_target_p = (struct e_in6_addr*) &pd[targetoff];
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB, targetoff, 16,
|
1999-03-29 02:21:34 +00:00
|
|
|
#ifdef INET6
|
|
|
|
"Target: %s (%s)",
|
|
|
|
get_hostname6(na_target_p),
|
|
|
|
#else
|
|
|
|
"Target: %s",
|
|
|
|
#endif
|
|
|
|
ip6_to_str(na_target_p));
|
|
|
|
|
|
|
|
dissect_icmpv6opt(pd, offset + sizeof(struct nd_neighbor_advert), fd, icmp6_tree);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ND_REDIRECT:
|
|
|
|
{
|
|
|
|
struct nd_redirect *rd = (struct nd_redirect *)dp;
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_redirect, nd_rd_target), 16,
|
|
|
|
#ifdef INET6
|
|
|
|
"Target: %s (%s)",
|
|
|
|
get_hostname6(&rd->nd_rd_target),
|
|
|
|
#else
|
|
|
|
"Target: %s",
|
|
|
|
#endif
|
|
|
|
ip6_to_str(&rd->nd_rd_target));
|
|
|
|
|
2000-05-11 08:18:09 +00:00
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
1999-03-29 02:21:34 +00:00
|
|
|
offset + offsetof(struct nd_redirect, nd_rd_dst), 16,
|
|
|
|
#ifdef INET6
|
|
|
|
"Destination: %s (%s)",
|
|
|
|
get_hostname6(&rd->nd_rd_dst),
|
|
|
|
#else
|
|
|
|
"Destination: %s",
|
|
|
|
#endif
|
|
|
|
ip6_to_str(&rd->nd_rd_dst));
|
|
|
|
|
|
|
|
dissect_icmpv6opt(pd, offset + sizeof(*rd), fd, icmp6_tree);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ICMP6_ROUTER_RENUMBERING:
|
2000-11-09 16:39:59 +00:00
|
|
|
dissect_rrenum(pd, offset, fd, icmp6_tree);
|
2000-11-09 14:09:41 +00:00
|
|
|
break;
|
2000-08-18 12:05:27 +00:00
|
|
|
case ICMP6_NI_QUERY:
|
|
|
|
case ICMP6_NI_REPLY:
|
|
|
|
ni = (struct icmp6_nodeinfo *)dp;
|
|
|
|
proto_tree_add_text(icmp6_tree, NullTVB,
|
|
|
|
offset + offsetof(struct icmp6_nodeinfo, ni_qtype),
|
|
|
|
sizeof(ni->ni_qtype),
|
|
|
|
"Query type: 0x%04x (%s)", pntohs(&ni->ni_qtype),
|
|
|
|
val_to_str(pntohs(&ni->ni_qtype), names_nodeinfo_qtype,
|
|
|
|
"Unknown"));
|
2000-08-18 15:52:02 +00:00
|
|
|
dissect_nodeinfo(pd, offset, fd, icmp6_tree);
|
2000-08-18 12:05:27 +00:00
|
|
|
break;
|
1999-03-29 02:21:34 +00:00
|
|
|
default:
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissect_data(pd, offset + sizeof(*dp), fd, tree);
|
1999-03-29 02:21:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-07-29 05:47:07 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_icmpv6(void)
|
|
|
|
{
|
1999-10-10 16:09:33 +00:00
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_icmpv6_type,
|
1999-10-12 06:21:15 +00:00
|
|
|
{ "Type", "icmpv6.type", FT_UINT8, BASE_HEX, NULL, 0x0,
|
|
|
|
"" }},
|
1999-10-10 16:09:33 +00:00
|
|
|
{ &hf_icmpv6_code,
|
1999-10-12 06:21:15 +00:00
|
|
|
{ "Code", "icmpv6.code", FT_UINT8, BASE_HEX, NULL, 0x0,
|
|
|
|
"" }},
|
1999-10-10 16:09:33 +00:00
|
|
|
{ &hf_icmpv6_checksum,
|
1999-10-12 06:21:15 +00:00
|
|
|
{ "Checksum", "icmpv6.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
|
|
|
|
"" }}
|
1999-10-10 16:09:33 +00:00
|
|
|
};
|
1999-11-16 11:44:20 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_icmpv6,
|
|
|
|
&ett_icmpv6opt,
|
|
|
|
&ett_icmpv6flag,
|
2000-08-18 12:05:27 +00:00
|
|
|
&ett_nodeinfo_flag,
|
|
|
|
&ett_nodeinfo_subject4,
|
|
|
|
&ett_nodeinfo_subject6,
|
|
|
|
&ett_nodeinfo_node4,
|
|
|
|
&ett_nodeinfo_node6,
|
2000-08-22 08:30:00 +00:00
|
|
|
&ett_nodeinfo_nodebitmap,
|
|
|
|
&ett_nodeinfo_nodedns,
|
1999-11-16 11:44:20 +00:00
|
|
|
};
|
1999-10-10 16:09:33 +00:00
|
|
|
|
|
|
|
proto_icmpv6 = proto_register_protocol("Internet Control Message Protocol v6",
|
2001-01-03 06:56:03 +00:00
|
|
|
"ICMPv6", "icmpv6");
|
1999-10-10 16:09:33 +00:00
|
|
|
proto_register_field_array(proto_icmpv6, hf, array_length(hf));
|
1999-11-16 11:44:20 +00:00
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
1999-07-29 05:47:07 +00:00
|
|
|
}
|
2000-04-20 07:05:58 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_icmpv6(void)
|
|
|
|
{
|
Allow either old-style (pre-tvbuff) or new-style (tvbuffified)
dissectors to be registered as dissectors for particular ports,
registered as heuristic dissectors, and registered as dissectors for
conversations, and have routines to be used both by old-style and
new-style dissectors to call registered dissectors.
Have the code that calls those dissectors translate the arguments as
necessary. (For conversation dissectors, replace
"find_conversation_dissector()", which just returns a pointer to the
dissector, with "old_try_conversation_dissector()" and
"try_conversation_dissector()", which actually call the dissector, so
that there's a single place at which we can do that translation. Also
make "dissector_lookup()" static and, instead of calling it and, if it
returns a non-null pointer, calling that dissector, just use
"old_dissector_try_port()" or "dissector_try_port()", for the same
reason.)
This allows some dissectors that took old-style arguments and
immediately translated them to new-style arguments to just take
new-style arguments; make them do so. It also allows some new-style
dissectors not to have to translate arguments before calling routines to
look up and call dissectors; make them not do so.
Get rid of checks for too-short frames in new-style dissectors - the
tvbuff code does those checks for you.
Give the routines to register old-style dissectors, and to call
dissectors from old-style dissectors, names beginning with "old_", with
the routines for new-style dissectors not having the "old_". Update the
dissectors that use those routines appropriately.
Rename "dissect_data()" to "old_dissect_data()", and
"dissect_data_tvb()" to "dissect_data()".
svn path=/trunk/; revision=2218
2000-08-07 03:21:25 +00:00
|
|
|
old_dissector_add("ip.proto", IP_PROTO_ICMPV6, dissect_icmpv6);
|
2000-04-20 07:05:58 +00:00
|
|
|
}
|