Joerg Mayer's updates to the VINES dissector and to protocol layers
[obnox/wireshark/wip.git] / packet-radius.c
index 8ea0bfaf25a71242d4ef6d47990a9ff6bac05762..e0ce3ae05fb732a38f8d2b9bcf617af368a3c913 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-radius.c
  * Routines for RADIUS packet disassembly
  *
- * $Id: packet-radius.c,v 1.3 1999/08/03 14:59:16 gram Exp $
+ * $Id: packet-radius.c,v 1.6 1999/12/02 23:25:29 gram Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Johan Feyaerts
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  */
-int proto_radius = -1;
-int hf_radius_length = -1;
-int hf_radius_code = -1;
-int hf_radius_id =-1;
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -44,6 +40,14 @@ int hf_radius_id =-1;
 #include "packet.h"
 #include "resolv.h"
 
+static int proto_radius = -1;
+static int hf_radius_length = -1;
+static int hf_radius_code = -1;
+static int hf_radius_id =-1;
+
+static gint ett_radius = -1;
+static gint ett_radius_avp = -1;
+
 typedef struct _e_radiushdr {
         guint8 rh_code;
         guint8 rh_ident;
@@ -525,10 +529,16 @@ void dissect_attribute_value_pairs(const u_char *pd, int offset, frame_data
      avptpstrval=match_strval(avph.avp_type, radius_attrib_type_vals);
      if (avptpstrval == NULL) avptpstrval="Unknown Type";
      valstr=rd_value_to_str(&avph, pd, offset);
+     if (!BYTES_ARE_IN_FRAME(offset, avph.avp_length)) {
+       break;
+     }
      proto_tree_add_text(tree,offset,avph.avp_length,
         "t:%s(%d) l:%d, value:%s",
         avptpstrval,avph.avp_type,avph.avp_length,valstr);
      offset=offset+avph.avp_length;
+     if (avph.avp_length == 0) {
+       break;
+     }
   }
 }
 
@@ -572,7 +582,7 @@ proto_tree
         ti = proto_tree_add_item(tree,proto_radius, offset, rhlength,
                        NULL);
 
-        radius_tree = proto_item_add_subtree(ti, ETT_RADIUS);
+        radius_tree = proto_item_add_subtree(ti, ett_radius);
 
        proto_tree_add_item_format(radius_tree,hf_radius_code, offset,      1,
                 rh.rh_code, "Packet code:0x%01x (%s)",rhcode, codestrval);
@@ -599,7 +609,7 @@ proto_tree
         avptf = proto_tree_add_text(radius_tree
                         ,offset+hdrlength,avplength,
                         "Attribute value pairs");
-        avptree = proto_item_add_subtree(avptf, ETT_RADIUS_AVP);
+        avptree = proto_item_add_subtree(avptf, ett_radius_avp);
 
         if (avptree !=NULL)
         {
@@ -614,14 +624,23 @@ proto_register_radius(void)
 {
        static hf_register_info hf[] = {
                { &hf_radius_code,
-               { "Code","radius.code", FT_UINT8, NULL }},
+               { "Code","radius.code", FT_UINT8, BASE_DEC, NULL, 0x0,
+                       "" }},
+
                { &hf_radius_id,
-               { "Identifier", "radius.id", FT_UINT8, NULL }},
+               { "Identifier", "radius.id", FT_UINT8, BASE_DEC, NULL, 0x0,
+                       "" }},
+
                { &hf_radius_length,
-               { "Length","radius.length", FT_UINT16, NULL }}
+               { "Length","radius.length", FT_UINT16, BASE_DEC, NULL, 0x0,
+                       "" }}
+       };
+       static gint *ett[] = {
+               &ett_radius,
+               &ett_radius_avp,
        };
 
        proto_radius = proto_register_protocol ("Radius Protocol", "radius");
        proto_register_field_array(proto_radius, hf, array_length(hf));
+       proto_register_subtree_array(ett, array_length(ett));
 }
-