From 0a2817cebacb5352ff348434db2571e218a21bdb Mon Sep 17 00:00:00 2001 From: Gilbert Ramirez Date: Tue, 16 May 2000 04:44:14 +0000 Subject: Have tvbuff's keep track of cap_len and pkt_len ('length' and 'reported_length' in tvbuff terminology). This is implemented for TVBUFF_REAL and TVBUFF_SUBSET so far; support for TVBUFF_COMPOSITE is coming soon. Throw either ReportedBoundsError or BoundsError. A ReportedBoundsError is reported as "Malformed Frame" since the protocol stated that a certain number of bytes should be available but they weren't. A BoundsError is reported as a "Short Frame" since the snaplen was too short. Register proto_short (BoundsError) and proto_malformed (ReportedBounds) so searches can be made on "short" and "malformed". svn path=/trunk/; revision=1965 --- packet.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'packet.c') diff --git a/packet.c b/packet.c index 3a92ff7fe4..98d4064f0e 100644 --- a/packet.c +++ b/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.82 2000/05/15 06:22:07 gram Exp $ + * $Id: packet.c,v 1.83 2000/05/16 04:44:13 gram Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -104,6 +104,8 @@ static int hf_frame_time_delta = -1; static int hf_frame_number = -1; static int hf_frame_packet_len = -1; static int hf_frame_capture_len = -1; +static int proto_short = -1; +static int proto_malformed = -1; static gint ett_frame = -1; @@ -1165,7 +1167,7 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree) pi.len = fd->pkt_len; pi.captured_len = fd->cap_len; - tvb = tvb_new_real_data(pd, fd->cap_len); + tvb = tvb_new_real_data(pd, fd->cap_len, -1); pi.fd = fd; pi.compat_top_tvb = tvb; @@ -1214,7 +1216,12 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree) } } CATCH(BoundsError) { - proto_tree_add_text(tree, NullTVB, 0, 0, "[Short Frame: %s]", pi.current_proto ); + proto_tree_add_protocol_format(tree, proto_short, NullTVB, 0, 0, + "[Short Frame: %s]", pi.current_proto ); + } + CATCH(ReportedBoundsError) { + proto_tree_add_protocol_format(tree, proto_malformed, NullTVB, 0, 0, + "[Malformed Frame: %s]", pi.current_proto ); } ENDTRY; @@ -1313,6 +1320,8 @@ proto_register_frame(void) proto_register_field_array(proto_frame, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); + proto_short = proto_register_protocol("Short Frame", "short"); + proto_malformed = proto_register_protocol("Malformed Frame", "malformed"); register_init_routine(&packet_init_protocol); } -- cgit v1.2.3