Ethereal-dev: [Ethereal-dev] ICMP Router Advertisements (Mobile-IP)
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: David Frascone <dave@xxxxxxxxxxxx>
Date: Wed, 31 Oct 2001 11:21:53 -0600
I added dissection of Mobile-IP Advertisements, as defined in RFC-2002 and RFC-3012. The extensions 0, 16, 19, and 24 are now dissected properly. Attached are diffs, and packet dumps containing examples of all processed extensions.
Index: packet-ip.c
===================================================================
RCS file: /cvsroot/ethereal/packet-ip.c,v
retrieving revision 1.142
diff -r1.142 packet-ip.c
126a127,146
> /* Mobile ip */
> static int hf_icmp_mip_type = -1;
> static int hf_icmp_mip_length = -1;
> static int hf_icmp_mip_prefix_length = -1;
> static int hf_icmp_mip_seq = -1;
> static int hf_icmp_mip_life = -1;
> static int hf_icmp_mip_flags = -1;
> static int hf_icmp_mip_r = -1;
> static int hf_icmp_mip_b = -1;
> static int hf_icmp_mip_h = -1;
> static int hf_icmp_mip_f = -1;
> static int hf_icmp_mip_m = -1;
> static int hf_icmp_mip_g = -1;
> static int hf_icmp_mip_v = -1;
> static int hf_icmp_mip_res = -1;
> static int hf_icmp_mip_reserved = -1;
> static int hf_icmp_mip_coa = -1;
> static int hf_icmp_mip_challenge = -1;
>
>
127a148,149
> static gint ett_icmp_mip = -1;
> static gint ett_icmp_mip_flags = -1;
1121a1144,1282
> static value_string mip_extensions[] = {
> { 0, "One byte padding extension"}, /* RFC 2002 */
> { 16, "Mobility Agent Advertisement Extension"}, /* RFC 2002 */
> { 19, "Prefix Lengths Extension"}, /* RFC 2002 */
> { 24, "Challenge Extension"}, /* RFC 3012 */
> { 0, NULL}
> };
>
> /*
> * Dissect the mobile ip advertisement extensions.
> */
> static void
> dissect_mip_extensions(tvbuff_t *tvb, size_t offset, packet_info *pinfo,
> proto_tree *tree)
> {
> guint8 type;
> guint8 length;
> guint8 flags;
> proto_item *ti;
> proto_tree *mip_tree=NULL;
> proto_tree *flags_tree=NULL;
> gint numCOAs;
> gint i;
>
> /* Not much to do if we're not parsing everything */
> if (!tree) return;
>
> while ((tvb_length(tvb) - offset) > 0) {
>
> type = tvb_get_guint8(tvb, offset + 0);
> if (type)
> length = tvb_get_guint8(tvb, offset + 1);
> else
> length=0;
>
> ti = proto_tree_add_text(tree, tvb, offset,
> type?(length + 2):1,
> "Ext: %s",
> val_to_str(type, mip_extensions,
> "Unknown ext %d"));
> mip_tree = proto_item_add_subtree(ti, ett_icmp_mip);
>
>
> switch (type) {
> case 0: /* One byte padding extension */
> /* Add our fields */
> /* type */
> proto_tree_add_item(mip_tree, hf_icmp_mip_type, tvb, offset,
> 1, FALSE);
> offset++;
> break;
> case 16: /* Mobility Agent Advertisement Extension (RFC 2002)*/
> /* Add our fields */
> /* type */
> proto_tree_add_item(mip_tree, hf_icmp_mip_type, tvb, offset,
> 1, FALSE);
> offset++;
> /* length */
> proto_tree_add_item(mip_tree, hf_icmp_mip_length, tvb, offset,
> 1, FALSE);
> offset++;
> /* sequence number */
> proto_tree_add_item(mip_tree, hf_icmp_mip_seq, tvb, offset,
> 2, FALSE);
> offset+=2;
> /* Registration Lifetime */
> proto_tree_add_item(mip_tree, hf_icmp_mip_life, tvb, offset,
> 2, FALSE);
> offset+=2;
> /* flags */
> flags = tvb_get_guint8(tvb, offset);
> ti = proto_tree_add_item(mip_tree, hf_icmp_mip_flags, tvb, offset,
> 1, FALSE);
> flags_tree = proto_item_add_subtree(ti, ett_icmp_mip_flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_r, tvb, offset, 1, flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_b, tvb, offset, 1, flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_h, tvb, offset, 1, flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_f, tvb, offset, 1, flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_m, tvb, offset, 1, flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_g, tvb, offset, 1, flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_v, tvb, offset, 1, flags);
> proto_tree_add_boolean(flags_tree, hf_icmp_mip_res, tvb, offset, 1, flags);
> offset++;
>
> /* Reserved */
> proto_tree_add_item(mip_tree, hf_icmp_mip_reserved, tvb, offset,
> 1, FALSE);
> offset++;
>
> /* COAs */
> numCOAs = (length - 6) / 4;
> for (i=0; i<numCOAs; i++) {
> proto_tree_add_item(mip_tree, hf_icmp_mip_coa, tvb, offset,
> 4, FALSE);
> offset+=4;
> }
> break;
> case 19: /* Prefix-Lengths Extension (RFC 2002)*/
> /* Add our fields */
> /* type */
> proto_tree_add_item(mip_tree, hf_icmp_mip_type, tvb, offset,
> 1, FALSE);
> offset++;
> /* length */
> proto_tree_add_item(mip_tree, hf_icmp_mip_length, tvb, offset,
> 1, FALSE);
> offset++;
>
> /* prefix lengths */
> for(i=0; i<length; i++) {
> proto_tree_add_item(mip_tree, hf_icmp_mip_prefix_length, tvb, offset,
> 1, FALSE);
> offset++;
> }
> break;
> case 24: /* Challenge Extension (RFC 3012)*/
> /* type */
> proto_tree_add_item(mip_tree, hf_icmp_mip_type, tvb, offset,
> 1, FALSE);
> offset++;
> /* length */
> proto_tree_add_item(mip_tree, hf_icmp_mip_length, tvb, offset,
> 1, FALSE);
> offset++;
> /* challenge */
> proto_tree_add_item(mip_tree, hf_icmp_mip_challenge, tvb, offset,
> length, FALSE);
> offset+=length;
>
> break;
> default:
> g_warning("Unknown type(%d)! I hope the length is right (%d)",
> type, length);
> offset += length;
> break;
> } /* switch type */
> } /* end while */
>
> } /* dissect_mip_extensions */
1217c1378,1384
< strcpy(type_str, "Router advertisement");
---
> switch(icmp_code) {
> case 16: /* Mobile-Ip */
> strcpy(type_str, "Mobile-ip Advertisement");
> break;
> default:
> strcpy(type_str, "Router advertisement");
> } /* switch icmp_code */
1324,1332c1491,1499
< case ICMP_RTRADVERT:
< num_addrs = tvb_get_guint8(tvb, 4);
< proto_tree_add_text(icmp_tree, tvb, 4, 1, "Number of addresses: %u",
< num_addrs);
< addr_entry_size = tvb_get_guint8(tvb, 5);
< proto_tree_add_text(icmp_tree, tvb, 5, 1, "Address entry size: %u",
< addr_entry_size);
< proto_tree_add_text(icmp_tree, tvb, 6, 2, "Lifetime: %s",
< time_secs_to_str(tvb_get_ntohs(tvb, 6)));
---
> case ICMP_RTRADVERT:
> num_addrs = tvb_get_guint8(tvb, 4);
> proto_tree_add_text(icmp_tree, tvb, 4, 1, "Number of addresses: %u",
> num_addrs);
> addr_entry_size = tvb_get_guint8(tvb, 5);
> proto_tree_add_text(icmp_tree, tvb, 5, 1, "Address entry size: %u",
> addr_entry_size);
> proto_tree_add_text(icmp_tree, tvb, 6, 2, "Lifetime: %s",
> time_secs_to_str(tvb_get_ntohs(tvb, 6)));
1412a1580
>
1414,1422c1582,1595
< for (i = 0; i < num_addrs; i++) {
< proto_tree_add_text(icmp_tree, tvb, 8 + (i*8), 4,
< "Router address: %s",
< ip_to_str(tvb_get_ptr(tvb, 8 + (i*8), 4)));
< proto_tree_add_text(icmp_tree, tvb, 12 + (i*8), 4,
< "Preference level: %u", tvb_get_ntohl(tvb, 12 + (i*8)));
< }
< } else
< dissect_data(tvb, 8, pinfo, icmp_tree);
---
> for (i = 0; i < num_addrs; i++) {
> proto_tree_add_text(icmp_tree, tvb, 8 + (i*8), 4,
> "Router address: %s",
> ip_to_str(tvb_get_ptr(tvb, 8 + (i*8), 4)));
> proto_tree_add_text(icmp_tree, tvb, 12 + (i*8), 4,
> "Preference level: %u", tvb_get_ntohl(tvb, 12 + (i*8)));
> }
> if (icmp_code == 16) {
> /* Mobile-Ip */
> dissect_mip_extensions(tvb,8 + i*8, pinfo, icmp_tree);
> }
>
> } else
> dissect_data(tvb, 8, pinfo, icmp_tree);
1659a1833,1885
>
> { &hf_icmp_mip_type,
> { "Type", "icmp.mip.type", FT_UINT8, BASE_DEC,
> VALS(mip_extensions), 0x0,"", HFILL}},
> { &hf_icmp_mip_length,
> { "Length", "icmp.mip.length", FT_UINT8, BASE_DEC, NULL, 0x0,
> "", HFILL}},
> { &hf_icmp_mip_prefix_length,
> { "Prefix Length", "icmp.mip.prefixlength", FT_UINT8, BASE_HEX, NULL, 0x0,
> "", HFILL}},
> { &hf_icmp_mip_seq,
> { "Sequence Number", "icmp.mip.seq", FT_UINT16, BASE_HEX, NULL, 0x0,
> "", HFILL}},
> { &hf_icmp_mip_life,
> { "Registration Lifetime", "icmp.mip.life", FT_UINT16, BASE_DEC, NULL, 0x0,
> "", HFILL}},
> { &hf_icmp_mip_flags,
> { "Flags", "icmp.mip.flags", FT_UINT8, BASE_HEX, NULL, 0x0,
> "", HFILL}},
> { &hf_icmp_mip_r,
> {"Registration Required", "icmp.mip.r", FT_BOOLEAN, 8, NULL, 128,
> "Registration with this FA is required", HFILL }},
> { &hf_icmp_mip_b,
> {"Busy", "icmp.mip.b", FT_BOOLEAN, 8, NULL, 64,
> "This FA will not accept requests at this time", HFILL }},
> { &hf_icmp_mip_h,
> {"Home Agent", "icmp.mip.h", FT_BOOLEAN, 8, NULL, 32,
> "Home Agent Services Offered", HFILL }},
> { &hf_icmp_mip_f,
> {"Foreign Agent", "icmp.mip.f", FT_BOOLEAN, 8, NULL, 16,
> "Foreign Agent Services Offered", HFILL }},
> { &hf_icmp_mip_m,
> {"Minimal Encapsulation", "icmp.mip.m", FT_BOOLEAN, 8, NULL, 8,
> "Minimal encapsulation tunneled datagram support", HFILL }},
> { &hf_icmp_mip_g,
> {"GRE", "icmp.mip.g", FT_BOOLEAN, 8, NULL, 4,
> "GRE encapsulated tunneled datagram support", HFILL }},
> { &hf_icmp_mip_v,
> {"VJ Comp", "icmp.mip.v", FT_BOOLEAN, 8, NULL, 2,
> "Van Jackobson Header Compression Support", HFILL }},
> { &hf_icmp_mip_res,
> {"Reserved", "icmp.mip.res", FT_BOOLEAN, 8, NULL, 1,
> "Reserved", HFILL }},
>
> { &hf_icmp_mip_reserved,
> { "Reserved", "icmp.mip.reserved", FT_UINT8, BASE_HEX, NULL, 0x0,
> "", HFILL}},
> { &hf_icmp_mip_coa,
> { "Care-Of-Address", "icmp.mip.coa", FT_IPv4, BASE_NONE, NULL, 0x0,
> "", HFILL}},
> { &hf_icmp_mip_challenge,
> { "Challenge", "icmp.mip.challenge", FT_BYTES, BASE_NONE, NULL, 0x0,
> "", HFILL}},
1662a1889,1890
> &ett_icmp_mip,
> &ett_icmp_mip_flags
Attachment:
icmp_mip_adv
Description: Binary data
Attachment:
mip_reg.so
Description: Binary data
- Follow-Ups:
- Re: [Ethereal-dev] ICMP Router Advertisements (Mobile-IP)
- From: Guy Harris
- Re: [Ethereal-dev] ICMP Router Advertisements (Mobile-IP)
- Prev by Date: RE: [Ethereal-dev] yhoo broke?
- Next by Date: Re: [Ethereal-dev] ICMP Router Advertisements (Mobile-IP)
- Previous by thread: Re: [Ethereal-dev] Re: compiling on MS Visual C für Microsoft
- Next by thread: Re: [Ethereal-dev] ICMP Router Advertisements (Mobile-IP)
- Index(es):





