From Andy Hood: in the AODV6 dissector, rename "ext_t" to "aodv6_ext_t",
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 22 Aug 2002 07:32:22 +0000 (07:32 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 22 Aug 2002 07:32:22 +0000 (07:32 +0000)
as "ext_t" is defined by a system header file on AIX.

Get rid of the bitfields in "struct aodv_rrep" and "rrep_t", as some
compilers don't allow any type other than "int" or "unsigned int" for
bitfields (so "guint8" won't work), and as there's no guarantee of the
order of bitfields in a structure.

Make "rreq", "rrep", and "rerr" local to "dissect_aodv()" and
"dissect_aodv6()", as they're not used outside them.

Add a protocol tree item for the prefix size field in AODV and AODV6 replies.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@6060 f5534014-38df-0310-8fa8-9805f1628bb7

packet-aodv.c
packet-aodv6.c

index 9b1ce4d6b6aa6ac41ffd31779f011329f75a8d5e..4b893eff0512de8390375b6e362f47d7b649d390 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for AODV dissection
  * Copyright 2000, Erik Nordström <erik.nordstrom@it.uu.se>
  *
- * $Id: packet-aodv.c,v 1.4 2002/08/21 21:25:23 tpot Exp $
+ * $Id: packet-aodv.c,v 1.5 2002/08/22 07:32:22 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -73,8 +73,7 @@ struct aodv_rreq {
 struct aodv_rrep {
     guint8 type;
     guint8 flags;
-    guint8 res2:3;
-    guint8 prefix:5;
+    guint8 prefix_sz;
     guint8 hop_count;
     guint32 dest_addr;
     guint32 dest_seqno;
@@ -91,14 +90,11 @@ struct aodv_rerr {
     guint32 dest_seqno;
 };
 
-static struct aodv_rreq rreq;
-static struct aodv_rrep rrep;
-static struct aodv_rerr rerr;
-                   
 /* Initialize the protocol and registered fields */
 static int proto_aodv = -1;
 static int hf_aodv_type = -1;
 static int hf_aodv_flags = -1;
+static int hf_aodv_prefix_sz = -1;
 static int hf_aodv_hopcount = -1;
 static int hf_aodv_rreq_id = -1;
 static int hf_aodv_dest_ip = -1;
@@ -130,6 +126,9 @@ dissect_aodv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        *aodv_unreach_dest_tree = NULL;
     guint8 type;
     int i;
+    struct aodv_rreq rreq;
+    struct aodv_rrep rrep;
+    struct aodv_rerr rerr;
 
 /* Make entries in Protocol column and Info column on summary display */
     if (check_col(pinfo->cinfo, COL_PROTOCOL)) 
@@ -204,6 +203,7 @@ dissect_aodv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     case RREP:
        rrep.type = type;
        rrep.flags = tvb_get_guint8(tvb, 1);
+       rrep.prefix_sz = tvb_get_guint8(tvb, 2) & 0x1F;
        rrep.hop_count = tvb_get_guint8(tvb, 3);
        tvb_memcpy(tvb, (guint8 *)&rrep.dest_addr, 4, 4);
        rrep.dest_seqno = tvb_get_ntohl(tvb, 8);
@@ -217,6 +217,7 @@ dissect_aodv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                proto_item_append_text(tj, " R");
            if (rrep.flags & RREP_ACK)
                proto_item_append_text(tj, " A");
+           proto_tree_add_uint(aodv_tree, hf_aodv_prefix_sz, tvb, 3, 1, rrep.prefix_sz);
            proto_tree_add_uint(aodv_tree, hf_aodv_hopcount, tvb, 3, 1, rrep.hop_count);
            proto_tree_add_ipv4(aodv_tree, hf_aodv_dest_ip, tvb, 4, 4, rrep.dest_addr);
            proto_tree_add_uint(aodv_tree, hf_aodv_dest_seqno, tvb, 8, 4, rrep.dest_seqno);
@@ -317,6 +318,11 @@ proto_register_aodv(void)
            FT_BOOLEAN, 8, TFS(&flags_set_truth), RERR_NODEL,    
            "", HFILL }
        },
+       { &hf_aodv_prefix_sz,
+         { "Prefix Size", "aodv.prefix_sz",
+           FT_UINT8, BASE_DEC, NULL, 0x0,    
+           "Prefix_size", HFILL }
+       },
        { &hf_aodv_hopcount,
          { "Hop Count", "aodv.hopcount",
            FT_UINT8, BASE_DEC, NULL, 0x0,    
index 6e8fc4bc6afb155704213346ab230e63235933f9..6f8f3995804e4ab41cbfe58d55e225ba986dcbab 100644 (file)
@@ -3,7 +3,7 @@
  * Copyright 2002, Antti J. Tuominen <ajtuomin@tml.hut.fi>
  * Loosely based on packet-aodv.c.
  *
- * $Id: packet-aodv6.c,v 1.3 2002/08/21 21:25:23 tpot Exp $
+ * $Id: packet-aodv6.c,v 1.4 2002/08/22 07:32:22 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -92,8 +92,7 @@ typedef struct aodv6_rreq {
 typedef struct aodv6_rrep {
     guint8 type;
     guint8 flags;
-    guint8 res2:1;
-    guint8 prefix:7;
+    guint8 prefix_sz;
     guint8 hop_count;
     guint32 dest_seqno;
     struct e_in6_addr dest_addr;
@@ -118,16 +117,13 @@ typedef struct aodv6_rrep_ack {
 typedef struct aodv6_ext {
     guint8 type;
     guint8 length;
-} ext_t;
-
-static rreq_t rreq;
-static rrep_t rrep;
-static rerr_t rerr;
+} aodv6_ext_t;
 
 /* Initialize the protocol and registered fields */
 static int proto_aodv6 = -1;
 static int hf_aodv6_type = -1;
 static int hf_aodv6_flags = -1;
+static int hf_aodv6_prefix_sz = -1;
 static int hf_aodv6_hopcount = -1;
 static int hf_aodv6_rreq_id = -1;
 static int hf_aodv6_dest_ip = -1;
@@ -161,7 +157,7 @@ dissect_aodv6ext(tvbuff_t * tvb, int offset, proto_tree * tree)
 {
     proto_tree *aodv6ext_tree;
     proto_item *ti;
-    ext_t aodv6ext, *ext;
+    aodv6_ext_t aodv6ext, *ext;
     char *typename;
     int len;
 
@@ -176,13 +172,13 @@ dissect_aodv6ext(tvbuff_t * tvb, int offset, proto_tree * tree)
     tvb_memcpy(tvb, (guint8 *) ext, offset, sizeof(*ext));
     len = ext->length;
 
-    ti = proto_tree_add_text(tree, tvb, offset, sizeof(ext_t) +
+    ti = proto_tree_add_text(tree, tvb, offset, sizeof(aodv6_ext_t) +
                             len, "AODV6 Extensions");
     aodv6ext_tree = proto_item_add_subtree(ti, ett_aodv6_extensions);
 
     if (len == 0) {
        proto_tree_add_text(aodv6ext_tree, tvb,
-                           offset + offsetof(ext_t, length), 1,
+                           offset + offsetof(aodv6_ext_t, length), 1,
                            "Invalid option length: %u", ext->length);
        return;                 /* we must not try to decode this */
     }
@@ -199,13 +195,13 @@ dissect_aodv6ext(tvbuff_t * tvb, int offset, proto_tree * tree)
        break;
     }
     proto_tree_add_text(aodv6ext_tree, tvb,
-                       offset + offsetof(ext_t, type), 1,
+                       offset + offsetof(aodv6_ext_t, type), 1,
                        "Type: %u (%s)", ext->type, typename);
     proto_tree_add_text(aodv6ext_tree, tvb,
-                       offset + offsetof(ext_t, length), 1,
+                       offset + offsetof(aodv6_ext_t, length), 1,
                        "Length: %u bytes", ext->length);
 
-    offset += sizeof(ext_t);
+    offset += sizeof(aodv6_ext_t);
 
     switch (ext->type) {
     case AODV6_EXT_INT:
@@ -234,6 +230,9 @@ dissect_aodv6(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
        *aodv6_unreach_dest_tree = NULL;
     guint8 type;
     int i, extlen;
+    rreq_t rreq;
+    rrep_t rrep;
+    rerr_t rerr;
 
     /* Make entries in Protocol column and Info column on summary
      * display 
@@ -336,6 +335,7 @@ dissect_aodv6(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
     case AODV6_RREP:
        rrep.type = type;
        rrep.flags = tvb_get_guint8(tvb, offsetof(rrep_t, flags));
+       rrep.prefix_sz = tvb_get_guint8(tvb, offsetof(rrep_t, prefix_sz)) & 0x1F;
        rrep.hop_count = tvb_get_guint8(tvb, offsetof(rrep_t, hop_count));
        rrep.dest_seqno = tvb_get_ntohl(tvb, offsetof(rrep_t, dest_seqno));
        tvb_memcpy(tvb, (guint8 *) & rrep.dest_addr,
@@ -355,6 +355,9 @@ dissect_aodv6(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree)
                proto_item_append_text(tj, " R");
            if (rrep.flags & RREP_ACK)
                proto_item_append_text(tj, " A");
+           proto_tree_add_uint(aodv6_tree, hf_aodv6_prefix_sz,
+                               tvb, offsetof(rrep_t, prefix_sz), 1,
+                               rrep.prefix_sz);
            proto_tree_add_uint(aodv6_tree, hf_aodv6_hopcount,
                                tvb, offsetof(rrep_t, hop_count), 1,
                                rrep.hop_count);
@@ -502,6 +505,11 @@ proto_register_aodv6(void)
          FT_BOOLEAN, 8, TFS(&flags_set_truth), RERR_NODEL,
          "", HFILL}
         },
+       {&hf_aodv6_prefix_sz,
+        {"Prefix Size", "aodv6.prefix_sz",
+         FT_UINT8, BASE_DEC, NULL, 0x0,
+         "Prefix Size", HFILL}
+        },
        {&hf_aodv6_hopcount,
         {"Hop Count", "aodv6.hopcount",
          FT_UINT8, BASE_DEC, NULL, 0x0,