X.25 over TCP support, from Paul Ionescu.
[obnox/wireshark/wip.git] / packet-isis-clv.c
index 8cbfc6f53999d76648df082025fdf88f32938685..4b36e0f37c6c6248342433d40aa8aaf8a0e92beb 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-isis-clv.c
  * Common CLV decode routines.
  *
- * $Id: packet-isis-clv.c,v 1.2 1999/12/15 22:52:04 guy Exp $
+ * $Id: packet-isis-clv.c,v 1.8 2000/08/11 13:35:17 deniel Exp $
  * Stuart Stanley <stuarts@mxmail.net>
  *
  * Ethereal - Network traffic analyzer
 # include <sys/types.h>
 #endif
 
+#include <stdio.h>
+#include <string.h>
+#include <glib.h>
+
 #ifdef NEED_SNPRINTF_H
-# ifdef HAVE_STDARG_H
-#  include <stdarg.h>
-# else
-#  include <varargs.h>
-# endif
 # include "snprintf.h"
 #endif
 
-#include <stdio.h>
-#include <string.h>
-#include <glib.h>
 #include "packet.h"
+#include "packet-osi.h"
 #include "packet-isis.h"
 #include "packet-isis-clv.h"
 
@@ -93,10 +90,11 @@ isis_dissect_area_address_clv(const u_char *pd, int offset,
                 * Lets turn the area address into "standard" 0000.0000.etc
                 * format string.  
                 */
-               sbuf = isis_address_to_string ( pd, offset + 1, mylen );
+/*             sbuf = isis_address_to_string ( pd, offset + 1, mylen );*/
+      sbuf = print_nsap_net( pd + offset + 1, mylen );
                /* and spit it out */
                if ( tree ) {
-                       proto_tree_add_text ( tree, offset, mylen + 1,  
+                       proto_tree_add_text ( tree, NullTVB, offset, mylen + 1,  
                                "Area address (%d): %s", mylen, sbuf );
                }
                offset += mylen + 1;
@@ -165,7 +163,7 @@ isis_dissect_authentication_clv(const u_char *pd, int offset, guint length,
                }
        /* NOTE, s no longer valid */
        }
-       proto_tree_add_text ( tree, offset - 1, length + 1,
+       proto_tree_add_text ( tree, NullTVB, offset - 1, length + 1,
                        "%s %s", meaning, sbuf );
        if ( !use_cleartext ) {
                if ( length ) {
@@ -210,7 +208,7 @@ isis_dissect_ip_int_clv(const u_char *pd, int offset,
                }
                memcpy(&addr, &pd[offset], sizeof(addr));
                if ( tree ) {
-                       proto_tree_add_item(tree, tree_id, offset, 4, addr);
+                       proto_tree_add_ipv4(tree, tree_id, NullTVB, offset, 4, addr);
                }
                offset += 4;
                length -= 4;
@@ -256,7 +254,7 @@ isis_dissect_nlpid_clv(const u_char *pd, int offset,
                sprintf ( sbuf, "--none--" );
        }
 
-       proto_tree_add_text ( tree, old_offset, hlen,
+       proto_tree_add_text ( tree, NullTVB, old_offset, hlen,
                        "NLPID: %s", sbuf );
 }
 
@@ -286,7 +284,7 @@ isis_dissect_nlpid_clv(const u_char *pd, int offset,
  *     void, but we will add to proto tree if !NULL.
  */
 void 
-isis_dissect_clvs(const isis_clv_handle_t *opts, int len, 
+isis_dissect_clvs(const isis_clv_handle_t *opts, int len, int id_length,
                const u_char *pd, int offset, frame_data *fd, proto_tree *tree,
                gint unknown_tree_id ) { 
        guint8 code;
@@ -302,7 +300,7 @@ isis_dissect_clvs(const isis_clv_handle_t *opts, int len,
                length = pd[offset++];
                adj = (sizeof(code) + sizeof(length) + length);
                len -= adj;
-               if ( len < 0 ) {
+               if ( len < 0 || !BYTES_ARE_IN_FRAME(offset, length) ) {
                        isis_dissect_unknown(offset, adj, tree, fd,
                                "Short CLV header (%d vs %d)",
                                adj, len + adj );
@@ -317,19 +315,20 @@ isis_dissect_clvs(const isis_clv_handle_t *opts, int len,
                                /* adjust by 2 for code/len octets */
                                snprintf ( sbuf, sizeof(sbuf), "%s (%d)", 
                                        opts[q].tree_text, length ); 
-                               ti = proto_tree_add_text(tree, offset - 2, 
+                               ti = proto_tree_add_text(tree, NullTVB, offset - 2, 
                                        length + 2, sbuf);
                                clv_tree = proto_item_add_subtree(ti, 
                                        *opts[q].tree_id );
                        } else {
                                clv_tree = NULL;
                        }
-                       opts[q].dissect(pd, offset, length, fd, clv_tree );
+                       opts[q].dissect(pd, offset, length, id_length, fd,
+                               clv_tree );
                } else {
                        if (tree) { 
                                snprintf ( sbuf, sizeof(sbuf), 
                                        "Unknown code (%d:%d)", code, length ); 
-                               ti = proto_tree_add_text(tree, offset - 2, 
+                               ti = proto_tree_add_text(tree, NullTVB, offset - 2, 
                                        length + 2, sbuf);
                                clv_tree = proto_item_add_subtree(ti, 
                                        unknown_tree_id );