Add escaping of an apostrophe in XML output.
[obnox/wireshark/wip.git] / packet-netbios.c
index 4ea49b0e621dc8eea292fe7ff34904b2cc81244e..27e4acc66eb255f3f204a3c1bb0cba6ebe75d016 100644 (file)
@@ -5,7 +5,7 @@
  *
  * derived from the packet-nbns.c
  *
- * $Id: packet-netbios.c,v 1.53 2002/12/03 08:24:58 guy Exp $
+ * $Id: packet-netbios.c,v 1.57 2003/04/20 11:36:14 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -131,6 +131,7 @@ static const fragment_items netbios_frag_items = {
        &hf_netb_fragment_multiple_tails,
        &hf_netb_fragment_too_long_fragment,
        &hf_netb_fragment_error,
+       NULL,
        "fragments"
 };
 
@@ -1191,8 +1192,9 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                        /*
                         * Possibly fragmented.
                         */
-                       if (netbios_defragment) {
-                               len = tvb_length_remaining(tvb, offset);
+                       len = tvb_reported_length_remaining(tvb, offset);
+                       if (netbios_defragment &&
+                           tvb_bytes_exist(tvb, offset, len)) {
                                fd_head = fragment_add_seq_next(tvb, offset,
                                    pinfo, session_id,
                                    netbios_fragment_table,
@@ -1223,26 +1225,21 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                                }
                        } else {
                                /*
-                                * If this is NB_DATA_FIRST_MIDDLE,
-                                * just show it as a fragment.
-                                * (XXX - it'd be nice to dissect it
-                                * if it's the first fragment, but we'd
-                                * need to do reassembly in order to
-                                * discover that.)
+                                * Dissect this, regardless of whether
+                                * it's NB_DATA_FIRST_MIDDLE or
+                                * NB_DATA_ONLY_LAST.
                                 *
-                                * If this is NB_DATA_ONLY_LAST, dissect
-                                * it.  (XXX - it'd be nice to show it
-                                * as a fragment if it's part of a
-                                * fragmented datagram, but we'd need
-                                * to do reassembly in order to discover
-                                * that.)
+                                * XXX - it'd be nice to show
+                                * NB_DATA_FIRST_MIDDLE as a fragment
+                                * if it's not the first fragment (i.e.,
+                                * MIDDLE rather than FIRST), and show
+                                * NB_DATA_ONLY_LAST as a fragment if
+                                * it's part of a fragmented datagram
+                                * (i.e, LAST rather than ONLY), but
+                                * we'd have to do reassembly to
+                                * be able to determine that.
                                 */
-                               if (command == NB_DATA_FIRST_MIDDLE)
-                                       next_tvb = NULL;
-                               else {
-                                       next_tvb = tvb_new_subset(tvb, offset,
-                                           -1, -1);
-                               }
+                               next_tvb = tvb_new_subset(tvb, offset, -1, -1);
                        }
                        if (next_tvb != NULL)
                                dissect_netbios_payload(next_tvb, pinfo, tree);
@@ -1393,11 +1390,11 @@ void proto_register_netbios(void)
                        NULL, 0x0, "Fragment contained data past end of packet", HFILL }},
 
                { &hf_netb_fragment_error,
-               {"Defragmentation error",       "netbios.fragment.error", FT_NONE, BASE_NONE,
+               {"Defragmentation error",       "netbios.fragment.error", FT_FRAMENUM, BASE_NONE,
                        NULL, 0x0, "Defragmentation error due to illegal fragments", HFILL }},
 
                { &hf_netb_fragment,
-               { "NetBIOS Fragment",           "netbios.fragment", FT_NONE, BASE_NONE,
+               { "NetBIOS Fragment",           "netbios.fragment", FT_FRAMENUM, BASE_NONE,
                        NULL, 0x0, "NetBIOS Fragment", HFILL }},
 
                { &hf_netb_fragments,