aboutsummaryrefslogtreecommitdiffstats
path: root/packet-cpfi.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-11-19 04:26:13 +0000
committerGuy Harris <guy@alum.mit.edu>2003-11-19 04:26:13 +0000
commit9e097e07e710606e176f1d247136aa62fc24f1f4 (patch)
tree3b2ff7aadc93df2f79ab48377250e97ec691b481 /packet-cpfi.c
parent7d4ec012d977d1af3780c0b592db2f9b2a6c6481 (diff)
Get rid of some unused arguments and variables.
Clean up the handling of the footer, so that it works even with short frames. svn path=/trunk/; revision=9031
Diffstat (limited to 'packet-cpfi.c')
-rw-r--r--packet-cpfi.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/packet-cpfi.c b/packet-cpfi.c
index e8c448f45c..06c7d53d5e 100644
--- a/packet-cpfi.c
+++ b/packet-cpfi.c
@@ -5,7 +5,7 @@
*
* Copyright 2003, Dave Sclarsky <dave_sclarsky[AT]cnt.com>
*
- * $Id: packet-cpfi.c,v 1.3 2003/11/19 04:05:09 guy Exp $
+ * $Id: packet-cpfi.c,v 1.4 2003/11/19 04:26:13 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -185,7 +185,7 @@ dissect_cpfi_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* Footer */
static void
-dissect_cpfi_footer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_cpfi_footer(tvbuff_t *tvb, proto_tree *tree)
{
proto_item *extra_item = NULL;
proto_tree *extra_tree = NULL;
@@ -210,8 +210,7 @@ dissect_cpfi(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree)
tvbuff_t *header_tvb, *body_tvb, *footer_tvb;
proto_item *cpfi_item = NULL;
proto_tree *cpfi_tree = NULL;
- proto_item *extra_item = NULL;
- proto_tree *extra_tree = NULL;
+ gint length, reported_length, body_length, reported_body_length;
/* In the interest of speed, if "tree" is NULL, don't do any work not
necessary to generate protocol tree items. */
@@ -233,12 +232,26 @@ dissect_cpfi(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree)
header_tvb = tvb_new_subset(message_tvb, 0, 8, 8);
dissect_cpfi_header(header_tvb, pinfo, cpfi_tree);
-
/* Got good CPFI frame? */
if ( (frame_type == 9) && fc_handle )
{
/* create a tvb for the rest of the fc frame (exclude the checksum and CPFI trailer) */
- body_tvb = tvb_new_subset(message_tvb, 8, tvb_length(message_tvb)-16, -1);
+ length = tvb_length_remaining(message_tvb, 8);
+ reported_length = tvb_reported_length_remaining(message_tvb, 8);
+ if (reported_length < 8)
+ {
+ /* We don't even have enough for the footer. */
+ body_tvb = tvb_new_subset(message_tvb, 8, -1, -1);
+ call_dissector(data_handle, body_tvb, pinfo, tree);
+ return;
+ }
+ /* Length of packet, minus the footer. */
+ reported_body_length = reported_length - 8;
+ /* How much of that do we have in the tvbuff? */
+ body_length = length;
+ if (body_length > reported_body_length)
+ body_length = reported_body_length;
+ body_tvb = tvb_new_subset(message_tvb, 8, body_length, reported_body_length);
call_dissector(fc_handle, body_tvb, pinfo, tree);
/* add more info, now that FC added it's */
@@ -249,9 +262,15 @@ dissect_cpfi(tvbuff_t *message_tvb, packet_info *pinfo, proto_tree *tree)
}
/* Do the footer */
- footer_tvb = tvb_new_subset(message_tvb, tvb_length(message_tvb)-8, 8, -1);
- dissect_cpfi_footer(footer_tvb, pinfo, cpfi_tree);
-
+ length = tvb_length_remaining(message_tvb, 8+body_length);
+ if (length < 0)
+ {
+ /* The footer wasn't captured at all.
+ XXX - we'd like to throw a BoundsError if that's the case. */
+ return;
+ }
+ footer_tvb = tvb_new_subset(message_tvb, 8+body_length, length, 8);
+ dissect_cpfi_footer(footer_tvb, cpfi_tree);
}
else if ( data_handle )
{