Ethereal-dev: [Ethereal-dev] Add support for HMIPv6

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Martti Kuparinen <martti.kuparinen@xxxxxx>
Date: Tue, 4 Sep 2001 15:22:53 +0300 (EEST)
Hi!

Could someone take a look at the attched patch and commit it to the
ethereal source tree...

Martti

PS. I changed the ND_OPT_ROUTE_INFO to match the current KAME value.

---
Martti Kuparinen <martti.kuparinen@xxxxxx>              NetBSD - No media hype
http://www.iki.fi/~kuparine/                            http://www.netbsd.org/
--- packet-ipv6.c.orig	Tue Sep  4 14:02:00 2001
+++ packet-ipv6.c	Tue Sep  4 14:02:15 2001
@@ -972,7 +972,7 @@
 {
     if (hf_ipv6_mipv6_length != -1) {
 	if (check_col(pinfo->fd, COL_INFO))
-	    col_add_fstr(pinfo->fd, COL_INFO, "MobileIPv6 Destination Option");
+	    col_add_fstr(pinfo->fd, COL_INFO, "Mobile IPv6 Destination Option");
     } else {
 	if (check_col(pinfo->fd, COL_INFO))
 	    col_add_fstr(pinfo->fd, COL_INFO, "IPv6 no next header");
--- packet-ipv6.h.orig	Tue Sep  4 13:05:52 2001
+++ packet-ipv6.h	Tue Sep  4 14:01:20 2001
@@ -9,6 +9,8 @@
  * Copyright 1998 Gerald Combs
  *
  * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@xxxxxxxxxx>
+ *
+ * HMIPv6 support added by Martti Kuparinen <martti.kuparinen@xxxxxx>
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -390,8 +392,13 @@
 #define ND_OPT_MTU			5
 #define ND_OPT_ADVINTERVAL		7
 #define ND_OPT_HOMEAGENT_INFO		8
+#define ND_OPT_SOURCE_ADDRLIST		9
+#define ND_OPT_TARGET_ADDRLIST		10
+
 /* draft-ietf-ipngwg-router-preference, not officially assigned yet */
-#define ND_OPT_ROUTE_INFO		9
+#define ND_OPT_ROUTE_INFO		200
+/* draft-ietf-mobileip-hmipv6, not officially assigned yet */
+#define ND_OPT_MAP			201
 
 struct nd_opt_prefix_info {	/* prefix information */
 	guint8	nd_opt_pi_type;
@@ -447,6 +454,24 @@
 	guint32	nd_opt_rti_lifetime;
 	/* prefix follows */
 };
+
+struct nd_opt_map_info {	/* HMIPv6 MAP option */
+	guint8			nd_opt_map_type;
+	guint8			nd_opt_map_len;
+	guint8			nd_opt_map_distance;
+	guint8			nd_opt_map_preference;
+	guint8			nd_opt_map_prefixlen;
+	guint8			nd_opt_map_flags;
+	guint16			nd_opt_map_unused;
+	guint32			nd_opt_map_lifetime;
+	struct e_in6_addr	nd_opt_map_address;
+};
+
+#define ND_OPT_MAP_FLAG_R	0x80
+#define ND_OPT_MAP_FLAG_M	0x40
+#define ND_OPT_MAP_FLAG_I	0x20
+#define ND_OPT_MAP_FLAG_T	0x10
+#define ND_OPT_MAP_FLAG_P	0x08
 
 /*
  * icmp6 node information
--- packet-icmpv6.c.orig	Tue Sep  4 13:05:52 2001
+++ packet-icmpv6.c	Tue Sep  4 14:00:43 2001
@@ -9,6 +9,8 @@
  *
  * MobileIPv6 support added by Tomislav Borosa <tomislav.borosa@xxxxxxxxxx>
  *
+ * HMIPv6 support added by Martti Kuparinen <martti.kuparinen@xxxxxx>
+ *
  * 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
@@ -155,7 +157,7 @@
 dissect_icmpv6opt(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
 {
     proto_tree *icmp6opt_tree, *field_tree;
-	proto_item *ti, *tf;
+    proto_item *ti, *tf;
     struct nd_opt_hdr nd_opt_hdr, *opt;
     int len;
     char *typename;
@@ -205,6 +207,9 @@
     case ND_OPT_HOMEAGENT_INFO:
 	typename = "Home Agent Information";
 	break;
+    case ND_OPT_MAP:
+	typename = "HMIPv6 MAP option";
+	break;
     default:
 	typename = "Unknown";
 	break;
@@ -310,6 +315,59 @@
 	    offset + offsetof(struct nd_opt_ha_info, nd_opt_ha_info_ha_life),
 	    2, "Home Agent Lifetime: %d",
 	    pntohs(&pi->nd_opt_ha_info_ha_life));
+	break;
+      }
+    case ND_OPT_MAP:
+      {
+	struct nd_opt_map_info mapbuf, *map;
+	int flagoff;
+
+	map = &mapbuf;
+	tvb_memcpy(tvb, (guint8 *)map, offset, sizeof *map);
+	proto_tree_add_text(icmp6opt_tree, tvb,
+	    offset + offsetof(struct nd_opt_map_info, nd_opt_map_distance),
+	    1, "Distance: %d", map->nd_opt_map_distance);
+	proto_tree_add_text(icmp6opt_tree, tvb,
+	    offset + offsetof(struct nd_opt_map_info, nd_opt_map_preference),
+	    1, "Preference: %d", map->nd_opt_map_preference);
+	proto_tree_add_text(icmp6opt_tree, tvb,
+	    offset + offsetof(struct nd_opt_map_info, nd_opt_map_prefixlen),
+	    1, "Prefix Length: %d", map->nd_opt_map_prefixlen);
+	flagoff = offset + offsetof(struct nd_opt_map_info,
+	    nd_opt_map_flags);
+	tf = proto_tree_add_text(icmp6opt_tree, tvb, flagoff, 1,
+	    "Flags: 0x%02x",
+	    tvb_get_guint8(tvb, offset + offsetof(struct nd_opt_map_info,
+	    nd_opt_map_flags)));
+	field_tree = proto_item_add_subtree(tf, ett_icmpv6flag);
+	proto_tree_add_text(field_tree, tvb, flagoff, 1, "%s",
+	    decode_boolean_bitfield(map->nd_opt_map_flags,
+		ND_OPT_MAP_FLAG_R, 8, "R", ""));
+	proto_tree_add_text(field_tree, tvb, flagoff, 1, "%s",
+	    decode_boolean_bitfield(map->nd_opt_map_flags,
+		ND_OPT_MAP_FLAG_M, 8, "M", ""));
+	proto_tree_add_text(field_tree, tvb, flagoff, 1, "%s",
+	    decode_boolean_bitfield(map->nd_opt_map_flags,
+		ND_OPT_MAP_FLAG_I, 8, "I", ""));
+	proto_tree_add_text(field_tree, tvb, flagoff, 1, "%s",
+	    decode_boolean_bitfield(map->nd_opt_map_flags,
+		ND_OPT_MAP_FLAG_T, 8, "T", ""));
+	proto_tree_add_text(field_tree, tvb, flagoff, 1, "%s",
+	    decode_boolean_bitfield(map->nd_opt_map_flags,
+		ND_OPT_MAP_FLAG_P, 8, "P", ""));
+	proto_tree_add_text(icmp6opt_tree, tvb,
+	    offset + offsetof(struct nd_opt_map_info, nd_opt_map_lifetime),
+	    4, "Lifetime: %d", pntohs(&map->nd_opt_map_lifetime));
+
+	proto_tree_add_text(icmp6opt_tree, tvb,
+	    offset + offsetof(struct nd_opt_map_info, nd_opt_map_address), 16,
+#ifdef INET6
+	    "Address of MAP: %s (%s)",
+	    get_hostname6(&map->nd_opt_map_address),
+#else
+	    "Address of MAP: %s",
+#endif
+	    ip6_to_str(&map->nd_opt_map_address));
 	break;
       }
     case ND_OPT_ROUTE_INFO: