aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/gryphon
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 /plugins/gryphon
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 'plugins/gryphon')
-rw-r--r--plugins/gryphon/packet-gryphon.c143
1 files changed, 38 insertions, 105 deletions
diff --git a/plugins/gryphon/packet-gryphon.c b/plugins/gryphon/packet-gryphon.c
index d7e607d476..fddad1487e 100644
--- a/plugins/gryphon/packet-gryphon.c
+++ b/plugins/gryphon/packet-gryphon.c
@@ -3,7 +3,7 @@
* By Steve Limkemann <stevelim@dgtech.com>
* Copyright 1998 Steve Limkemann
*
- * $Id: packet-gryphon.c,v 1.32 2002/05/01 06:56:16 guy Exp $
+ * $Id: packet-gryphon.c,v 1.33 2002/05/05 00:16:38 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -46,7 +46,7 @@
#endif
#include <epan/packet.h>
#include "packet-gryphon.h"
-#include "packet-frame.h"
+#include "packet-tcp.h"
#include "prefs.h"
#include "plugins/plugin_api_defs.h"
@@ -154,115 +154,42 @@ static char *frame_type[] = {
"Text string"
};
-static void
-dissect_gryphon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+/*
+ * Length of the frame header.
+ */
+#define FRAME_HEADER_LEN 8
+
+static guint
+get_gryphon_pdu_len(tvbuff_t *tvb, int offset)
{
- volatile int offset = 0;
- int length_remaining;
guint16 plen;
int padded_len;
- int length;
- tvbuff_t *next_tvb;
-
- offset = 0;
- while (tvb_reported_length_remaining(tvb, offset) != 0) {
- length_remaining = tvb_length_remaining(tvb, offset);
-
- /*
- * Can we do reassembly?
- */
- if (gryphon_desegment && pinfo->can_desegment) {
- /*
- * Yes - is the Gryphon header split across segment boundaries?
- */
- if (length_remaining < 8) {
- /*
- * 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 = 8 - length_remaining;
- return;
- }
- }
-
- /*
- * Get the length of the Gryphon packet, and then
- * get the length as padded to a 4-byte boundary.
- */
- plen = tvb_get_ntohs(tvb, offset + 4);
- padded_len = plen + 3 - (plen + 3) % 4;
- /*
- * Can we do reassembly?
- */
- if (gryphon_desegment && pinfo->can_desegment) {
- /*
- * Yes - is the Gryphon packet split across segment boundaries?
- */
- if (length_remaining < padded_len + 8) {
- /*
- * 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 = (padded_len + 8) - 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 Gryphon 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 + 8", and the "if the snapshot length
- * were infinite" length is the minimum of the
- * reported length of the tvbuff handed to us and "plen+8",
- * 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 + 8)
- length = plen + 8;
- next_tvb = tvb_new_subset(tvb, offset, length, plen + 8);
+ /*
+ * Get the length of the Gryphon packet, and then get the length as
+ * padded to a 4-byte boundary.
+ */
+ plen = tvb_get_ntohs(tvb, offset + 4);
+ padded_len = plen + 3 - (plen + 3) % 4;
+
+ /*
+ * That length doesn't include the fixed-length part of the header;
+ * add that in.
+ */
+ return padded_len + FRAME_HEADER_LEN;
+}
- /*
- * Dissect the Gryphon packet.
- *
- * Catch the ReportedBoundsError exception; if this
- * particular message happens to get a ReportedBoundsError
- * exception, that doesn't mean that we should stop
- * dissecting Gryphon 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_gryphon_message(next_tvb, pinfo, tree, FALSE);
- }
- CATCH(BoundsError) {
- RETHROW;
- }
- CATCH(ReportedBoundsError) {
- show_reported_bounds_error(tvb, pinfo, tree);
- }
- ENDTRY;
+static void
+dissect_gryphon_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ dissect_gryphon_message(tvb, pinfo, tree, FALSE);
+}
- /*
- * Skip the Gryphon header and the payload.
- */
- offset += padded_len + 8;
- }
+static void
+dissect_gryphon(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ tcp_dissect_pdus(tvb, pinfo, tree, gryphon_desegment, FRAME_HEADER_LEN,
+ get_gryphon_pdu_len, dissect_gryphon_pdu);
}
static const value_string src_dest[] = {
@@ -313,6 +240,12 @@ dissect_gryphon_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
frmtyp = flags & ~RESPONSE_FLAGS;
if (!is_msgresp_add) {
+ /*
+ * This tvbuff includes padding to make its length a multiple
+ * of 4 bytes; set it to the actual length.
+ */
+ set_actual_length(tvb, msglen + FRAME_HEADER_LEN);
+
if (check_col(pinfo->cinfo, COL_INFO)) {
/*
* Indicate what kind of message this is.