aboutsummaryrefslogtreecommitdiffstats
path: root/packet-dns.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-05-05 00:16:38 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2002-05-05 00:16:38 +0000
commit6fa14c036b5d69ae1de5498ba1cab664c3697ec4 (patch)
treee3b201865b9c3108cf90f7953b3c85c4dad0066e /packet-dns.c
parenta15ae597b59cbc80335fece3f2a4d3888ba2ae84 (diff)
Make a "tcp_dissect_pdus()" with the standard loop for a TCP segment,
extracting PDUs from it and possibly doing reassembly. Make the COPS, DNS, DSI, Gryphon, and SCCP dissectors use it. Add "set_actual_length()", "tcp_dissect_pdus()", "decode_boolean_bitfield()", "decode_numeric_bitfield()", and "decode_enumerated_bitfield()" to the list of routines available to dissectors on platforms where routines in the main program aren't available to dynamically-loaded code. Declare routines in "to_str.h" as "extern"; as I remember, that's necessary to allow the "decode_XXX_bitfield()" routines declared therein to be made available to plugins as per the above. Note that new exported routines should be added to the end of the table if that's the only change being made to the table. Create a new "plugin_api_decls.h" header file, used to declare both the "p_" variables and the "p_" structure members in the routine-exporting mechanism; this reduces the number of places you have to change to change the list of exported routines. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@5394 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-dns.c')
-rw-r--r--packet-dns.c143
1 files changed, 30 insertions, 113 deletions
diff --git a/packet-dns.c b/packet-dns.c
index f95e0e553c..0ef668a35b 100644
--- a/packet-dns.c
+++ b/packet-dns.c
@@ -1,7 +1,7 @@
/* packet-dns.c
* Routines for DNS packet disassembly
*
- * $Id: packet-dns.c,v 1.84 2002/03/19 09:18:42 guy Exp $
+ * $Id: packet-dns.c,v 1.85 2002/05/05 00:16:32 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -39,7 +39,7 @@
#include "ipproto.h"
#include <epan/resolv.h>
#include "packet-dns.h"
-#include "packet-frame.h"
+#include "packet-tcp.h"
#include "prefs.h"
static int proto_dns = -1;
@@ -1753,8 +1753,8 @@ dissect_answer_records(tvbuff_t *tvb, int cur_off, int dns_data_offset,
}
static void
-dissect_dns_common(tvbuff_t *tvb, int msg_len, packet_info *pinfo,
- proto_tree *tree, gboolean is_tcp)
+dissect_dns_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
+ gboolean is_tcp)
{
int offset = is_tcp ? 2 : 0;
int dns_data_offset;
@@ -1816,7 +1816,7 @@ dissect_dns_common(tvbuff_t *tvb, int msg_len, packet_info *pinfo,
if (is_tcp) {
/* Put the length indication into the tree. */
- proto_tree_add_uint(dns_tree, hf_dns_length, tvb, offset - 2, 2, msg_len);
+ proto_tree_add_item(dns_tree, hf_dns_length, tvb, offset - 2, 2, FALSE);
}
if (flags & F_RESPONSE)
@@ -1946,119 +1946,36 @@ dissect_dns_common(tvbuff_t *tvb, int msg_len, packet_info *pinfo,
static void
dissect_dns_udp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- dissect_dns_common(tvb, -1, pinfo, tree, FALSE);
+ dissect_dns_common(tvb, pinfo, tree, FALSE);
+}
+
+static guint
+get_dns_pdu_len(tvbuff_t *tvb, int offset)
+{
+ guint16 plen;
+
+ /*
+ * Get the length of the DNS packet.
+ */
+ plen = tvb_get_ntohs(tvb, offset);
+
+ /*
+ * That length doesn't include the length field itself; add that in.
+ */
+ return plen + 2;
+}
+
+static void
+dissect_dns_tcp_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ dissect_dns_common(tvb, pinfo, tree, TRUE);
}
static void
dissect_dns_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- volatile int offset = 0;
- int length_remaining;
- guint16 plen;
- int length;
- tvbuff_t *next_tvb;
-
- while (tvb_reported_length_remaining(tvb, offset) != 0) {
- length_remaining = tvb_length_remaining(tvb, offset);
-
- /*
- * Can we do reassembly?
- */
- if (dns_desegment && pinfo->can_desegment) {
- /*
- * Yes - is the DNS-over-TCP header split across
- * segment boundaries?
- */
- if (length_remaining < 2) {
- /*
- * Yes. 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 = 2 - length_remaining;
- return;
- }
- }
-
- /*
- * Get the length of the DNS packet.
- */
- plen = tvb_get_ntohs(tvb, offset);
-
- /*
- * Can we do reassembly?
- */
- if (dns_desegment && pinfo->can_desegment) {
- /*
- * Yes - is the DNS packet split across segment
- * boundaries?
- */
- if (length_remaining < plen + 2) {
- /*
- * Yes. 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 + 2) - length_remaining;
- return;
- }
- }
-
- /*
- * Construct a tvbuff containing the amount of the payload
- * we have available. Make its reported length the
- * amount of data in the DNS-over-TCP packet.
- *
- * XXX - if reassembly isn't enabled. the subdissector
- * will throw a BoundsError exception, rather than a
- * ReportedBoundsError exception. We really want
- * a tvbuff where the length is "length", the reported
- * length is "plen + 2", and the "if the snapshot length
- * were infinite" length is the minimum of the
- * reported length of the tvbuff handed to us and "plen+2",
- * with a new type of exception thrown if the offset is
- * within the reported length but beyond that third length,
- * with that exception getting the "Unreassembled Packet"
- * error.
- */
- length = length_remaining;
- if (length > plen + 2)
- length = plen + 2;
- next_tvb = tvb_new_subset(tvb, offset, length, plen + 2);
-
- /*
- * Dissect the DNS-over-TCP packet.
- *
- * Catch the ReportedBoundsError exception; if this
- * particular message happens to get a ReportedBoundsError
- * exception, that doesn't mean that we should stop
- * dissecting DNS-over-TCP messages within this frame or
- * chunk of reassembled data.
- *
- * If it gets a BoundsError, we can stop, as there's nothing
- * more to see, so we just re-throw it.
- */
- TRY {
- dissect_dns_common(next_tvb, plen, pinfo, tree, TRUE);
- }
- CATCH(BoundsError) {
- RETHROW;
- }
- CATCH(ReportedBoundsError) {
- show_reported_bounds_error(tvb, pinfo, tree);
- }
- ENDTRY;
-
- /*
- * Skip the DNS-over-TCP header and the payload.
- */
- offset += plen + 2;
- }
+ tcp_dissect_pdus(tvb, pinfo, tree, dns_desegment, 2, get_dns_pdu_len,
+ dissect_dns_tcp_pdu);
}
void