Have "dissect_netbios_payload()" take as an argument a tvbuff containing
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 29 Sep 2001 00:57:36 +0000 (00:57 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 29 Sep 2001 00:57:36 +0000 (00:57 +0000)
only the NetBIOS payload, and have the NBSS dissector construct tvbuffs
of that sort (i.e., stop at the end of the NBSS session message, not at
the end of the data handed to the NBSS dissector).

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

packet-nbipx.c
packet-nbns.c
packet-netbios.c
packet-netbios.h

index 0f36201313efca3aa0366ca4c913b251c1022cfa..81092ae76f5416e430648e61b4d55f1b22fb296e 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for NetBIOS over IPX packet disassembly
  * Gilbert Ramirez <gram@xiexie.org>
  *
- * $Id: packet-nbipx.c,v 1.39 2001/09/28 22:43:56 guy Exp $
+ * $Id: packet-nbipx.c,v 1.40 2001/09/29 00:57:35 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -222,6 +222,7 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        char            name[(NETBIOS_NAME_LEN - 1)*4 + 1];
        int             name_type;
        gboolean        has_payload;
+       tvbuff_t        *next_tvb;
 
        if (check_col(pinfo->fd, COL_PROTOCOL))
                col_set_str(pinfo->fd, COL_PROTOCOL, "NBIPX");
@@ -466,8 +467,8 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                proto_item_set_len(ti, offset);
 
        if (has_payload && tvb_offset_exists(tvb, offset)) {
-               dissect_netbios_payload(tvb, offset, pinfo, tree,
-                       tvb_length_remaining(tvb, offset));
+               next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+               dissect_netbios_payload(next_tvb, pinfo, tree);
        }
 }
 
@@ -674,6 +675,7 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        int             name_type;
        char            node_name[(NETBIOS_NAME_LEN - 1)*4 + 1];
        int             node_name_type = 0;
+       tvbuff_t        *next_tvb;
 
        if (check_col(pinfo->fd, COL_PROTOCOL))
                col_set_str(pinfo->fd, COL_PROTOCOL, "NMPI");
@@ -767,8 +769,8 @@ dissect_nmpi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        offset += 1 + 1 + 2 + NETBIOS_NAME_LEN + NETBIOS_NAME_LEN;
 
        if (opcode == IMSLOT_SEND && tvb_offset_exists(tvb, offset)) {
-               dissect_netbios_payload(tvb, offset, pinfo, tree,
-                       tvb_length_remaining(tvb, offset));
+               next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+               dissect_netbios_payload(next_tvb, pinfo, tree);
        }
 }
 
index 986faf070519b61f99a30d37bda425529d2e8d1f..c0694fb1d4ea795b6952b42d02cefac1b1ba3fec 100644 (file)
@@ -4,7 +4,7 @@
  * Gilbert Ramirez <gram@xiexie.org>
  * Much stuff added by Guy Harris <guy@alum.mit.edu>
  *
- * $Id: packet-nbns.c,v 1.58 2001/09/29 00:00:26 guy Exp $
+ * $Id: packet-nbns.c,v 1.59 2001/09/29 00:57:36 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -1158,7 +1158,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        int                     msglen;
        int                     flags;
        int                     message_index;
-       int                     max_data = tvb_length_remaining(tvb, offset);
        tvbuff_t                *next_tvb;
 
        static const value_string error_codes[] = {
@@ -1241,7 +1240,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        }
 
        offset += 10;
-       max_data -= 10;
 
        switch (header.msg_type) {
 
@@ -1256,7 +1254,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                }
 
                offset += 4;
-               max_data -= 4;
 
                /* Source name */
                len = get_nbns_name(tvb, offset, offset, name, &name_type);
@@ -1266,7 +1263,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                            "Source name", name, name_type);
                }
                offset += len;
-               max_data -= len;
 
                /* Destination name */
                len = get_nbns_name(tvb, offset, offset, name, &name_type);
@@ -1276,7 +1272,6 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                            "Destination name", name, name_type);
                }
                offset += len;
-               max_data -= len;
 
                /*
                 * Here we can pass the packet off to the next protocol.
@@ -1284,7 +1279,8 @@ dissect_nbdgm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                 * only our stuff.
                 */
                proto_item_set_len(ti, offset);
-               dissect_netbios_payload(tvb, offset, pinfo, tree, max_data);
+               next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+               dissect_netbios_payload(next_tvb, pinfo, tree);
                break;
 
        case NBDS_ERROR:
@@ -1374,6 +1370,8 @@ dissect_nbss_packet(tvbuff_t *tvb, int offset, packet_info *pinfo,
        int             len;
        char            name[(NETBIOS_NAME_LEN - 1)*4 + MAXDNAME];
        int             name_type;
+       gint            reported_len;
+       tvbuff_t        *next_tvb;
 
        msg_type = tvb_get_guint8(tvb, offset);
 
@@ -1484,12 +1482,19 @@ dissect_nbss_packet(tvbuff_t *tvb, int offset, packet_info *pinfo,
 
        case SESSION_MESSAGE:
          /*
-          * Here we can pass the packet off to the next protocol.
+          * Here we can pass the message off to the next protocol.
           * Set the length of our top-level tree item to include
           * only our stuff.
           */
          proto_item_set_len(ti, offset);
-         dissect_netbios_payload(tvb, offset, pinfo, tree, length);
+         len = tvb_length_remaining(tvb, offset);
+         reported_len = tvb_reported_length_remaining(tvb, offset);
+         if (len > length)
+           len = length;
+         if (reported_len > length)
+           reported_len = length;
+         next_tvb = tvb_new_subset(tvb, offset, len, reported_len);
+         dissect_netbios_payload(next_tvb, pinfo, tree);
          break;
 
        }
index d21144ab869874b32aeb8e78de2c394fdbd94e95..c1671faee041df6cbcb3e68be4015185d55635ac 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * derived from the packet-nbns.c
  *
- * $Id: packet-netbios.c,v 1.36 2001/09/28 22:43:56 guy Exp $
+ * $Id: packet-netbios.c,v 1.37 2001/09/29 00:57:36 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -957,20 +957,17 @@ void (*dissect_netb[])(tvbuff_t *, int, proto_tree *) = {
 static heur_dissector_list_t netbios_heur_subdissector_list;
 
 void
-dissect_netbios_payload(tvbuff_t *tvb, int offset, packet_info *pinfo,
-   proto_tree *tree, int max_data)
+dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
-       tvbuff_t        *next_tvb;
-       const guint8    *next_pd;
-       int             next_offset;
-
-       next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+       const guint8    *pd;
+       int             offset;
+       int             max_data;
 
        /*
         * Try the heuristic dissectors for NetBIOS.
         */
        if (dissector_try_heuristic(netbios_heur_subdissector_list,
-                                   next_tvb, pinfo, tree))
+                                   tvb, pinfo, tree))
                return;
 
        /*
@@ -978,15 +975,16 @@ dissect_netbios_payload(tvbuff_t *tvb, int offset, packet_info *pinfo,
         * (XXX - once the SMB dissector is tvbuffified, it should
         * become a regular heuristic dissector.)
         */
-       tvb_compat(next_tvb, &next_pd, &next_offset);
+       tvb_compat(tvb, &pd, &offset);
+       max_data = tvb_length(tvb);
 
-       if (dissect_smb(next_pd, next_offset, pinfo->fd, tree, max_data))
+       if (dissect_smb(pd, offset, pinfo->fd, tree, max_data))
                return;
 
        /*
         * It's none of the above.  Dissect it as data.
         */
-       dissect_data(next_tvb, 0, pinfo, tree);
+       dissect_data(tvb, 0, pinfo, tree);
 }
 
 static void
@@ -998,6 +996,7 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        guint16                 hdr_len, command;
        char                    name[(NETBIOS_NAME_LEN - 1)*4 + 1];
        int                     name_type;
+       tvbuff_t                *next_tvb;
 
        int offset = 0;
 
@@ -1070,8 +1069,8 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        offset += hdr_len;                      /* move past header */
 
-       dissect_netbios_payload(tvb, offset, pinfo, tree,
-                       tvb_length_remaining(tvb, offset));
+       next_tvb = tvb_new_subset(tvb, offset, -1, -1);
+       dissect_netbios_payload(next_tvb, pinfo, tree);
 }
 
 
index a617f488ae0af533b9aa598d1fc042638d1d8be4..3b49807184d04c78547c6d295e418c53b82689cf 100644 (file)
@@ -5,7 +5,7 @@
  * 
  * derived from the packet-nbns.c
  *
- * $Id: packet-netbios.h,v 1.10 2001/09/28 22:43:56 guy Exp $
+ * $Id: packet-netbios.h,v 1.11 2001/09/29 00:57:36 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -40,7 +40,7 @@ extern int get_netbios_name(tvbuff_t *tvb, int offset,
 extern char *netbios_name_type_descr(int name_type);
 extern void netbios_add_name( char* label, tvbuff_t *tvb, int offset,
     proto_tree *tree);
-extern void dissect_netbios_payload(tvbuff_t *tvb, int offset,
-   packet_info *pinfo, proto_tree *tree, int max_data);
+extern void dissect_netbios_payload(tvbuff_t *tvb, packet_info *pinfo,
+    proto_tree *tree);
 
 #endif