Add support for desegmentation of DNS messages.
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 17 Sep 2001 02:07:00 +0000 (02:07 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Mon, 17 Sep 2001 02:07:00 +0000 (02:07 +0000)
Make the default for NBSS and ONC RPC-over-TCP desegmentation "on",
rather than "off"; the default for desegmentation in general is "off",
so this won't change the default behavior, but it lets you turn
desegmentation on by flipping only one switch (and turn it off for
particular protocols if you desire).

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

packet-dns.c
packet-nbns.c
packet-rpc.c

index 507ffca4ea813f93c7ba04589d123d4b6299e8d0..39b3ec55d07d2028516e8c730fa75b8431b44f0c 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-dns.c
  * Routines for DNS packet disassembly
  *
- * $Id: packet-dns.c,v 1.74 2001/09/17 00:36:04 guy Exp $
+ * $Id: packet-dns.c,v 1.75 2001/09/17 02:07:00 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -39,6 +39,7 @@
 #include "ipproto.h"
 #include "resolv.h"
 #include "packet-dns.h"
+#include "prefs.h"
 
 static int proto_dns = -1;
 static int hf_dns_length = -1;
@@ -59,6 +60,9 @@ static gint ett_dns_ans = -1;
 static gint ett_dns_flags = -1;
 static gint ett_t_key_flags = -1;
 
+/* desegmentation of DNS over TCP */
+static gboolean dns_desegment = TRUE;
+
 /* DNS structs and definitions */
 
 /* Ports used for DNS. */
@@ -1964,9 +1968,37 @@ dissect_dns_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        guint16 plen;
 
        for (;;) {
+               /*
+                * XXX - should handle a length field split across segment
+                * boundaries.
+                */
                if (!tvb_bytes_exist(tvb, offset, 2))
                        break;
                plen = tvb_get_ntohs(tvb, offset);
+
+               /*
+                * Desegmentation check.
+                */
+               if (dns_desegment) {
+                       if (pinfo->can_desegment
+                           && plen > tvb_length_remaining(tvb, offset+2)) {
+                               /*
+                                * This frame doesn't have all of the data
+                                * for this message, but we can do reassembly
+                                * on it.
+                                *
+                                * Tell the TCP dissector where the data for
+                                * this message starts in the data it handed
+                                * us, and how many more bytes we need, and
+                                * return.
+                                */
+                               pinfo->desegment_offset = offset;
+                               pinfo->desegment_len =
+                                   plen - tvb_length_remaining(tvb, offset+2);
+                               return;
+                       }
+               }
+
                offset += 2;
 
                /*
@@ -2033,10 +2065,17 @@ proto_register_dns(void)
     &ett_dns_flags,
     &ett_t_key_flags,
   };
+  module_t *dns_module;
 
   proto_dns = proto_register_protocol("Domain Name Service", "DNS", "dns");
   proto_register_field_array(proto_dns, hf, array_length(hf));
   proto_register_subtree_array(ett, array_length(ett));
+
+  dns_module = prefs_register_protocol(proto_dns, NULL);
+  prefs_register_bool_preference(dns_module, "desegment_dns_messages",
+    "Desegment all DNS messages spanning multiple TCP segments",
+    "Whether the DNS dissector should desegment all messages spanning multiple TCP segments",
+    &dns_desegment);
 }
 
 void
index 48cf6d54f57221300454e728a8032514d2c3afd5..15a2c1116c8a40a9c0236f41c8038025b5fefef4 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.55 2001/09/13 07:53:51 guy Exp $
+ * $Id: packet-nbns.c,v 1.56 2001/09/17 02:07:00 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -80,8 +80,7 @@ static gint ett_nbss = -1;
 static gint ett_nbss_flags = -1;
 
 /* desegmentation of NBSS over TCP */
-static gboolean nbss_desegment = FALSE;
-
+static gboolean nbss_desegment = TRUE;
 
 /* See RFC 1001 and 1002 for information on the first three, and see
 
@@ -1702,8 +1701,8 @@ proto_register_nbt(void)
 
   nbss_module = prefs_register_protocol(proto_nbss, NULL);
   prefs_register_bool_preference(nbss_module, "desegment_nbss_commands",
-    "Desegment all NBSS commands spanning multiple TCP segments",
-    "Whether NBSS dissector should desegment all commands spanning multiple TCP segments",
+    "Desegment all NBSS packets spanning multiple TCP segments",
+    "Whether NBSS dissector should desegment all packets spanning multiple TCP segments",
     &nbss_desegment);
 }
 
index dcd541266969500998db6a211dec6b02a6c1592a..b5acb171f104d2f305e20fedf523925bb77c27cf 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for rpc dissection
  * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de>
  * 
- * $Id: packet-rpc.c,v 1.71 2001/09/13 07:53:51 guy Exp $
+ * $Id: packet-rpc.c,v 1.72 2001/09/17 02:07:00 guy Exp $
  * 
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@ethereal.com>
@@ -62,7 +62,7 @@
 #define RPC_RM_FRAGLEN  0x7fffffffL
 
 /* desegmentation of RPC over TCP */
-static gboolean rpc_desegment = FALSE;
+static gboolean rpc_desegment = TRUE;
 
 static struct true_false_string yesno = { "Yes", "No" };