diff options
author | Gilbert Ramirez <gram@alumni.rice.edu> | 2000-05-16 04:44:14 +0000 |
---|---|---|
committer | Gilbert Ramirez <gram@alumni.rice.edu> | 2000-05-16 04:44:14 +0000 |
commit | 0a2817cebacb5352ff348434db2571e218a21bdb (patch) | |
tree | 50401d28646b843ea7fdfac3e1487613b2bdc9af /packet.c | |
parent | 9d92bf4eeb0ee6dfe7add0e88632eacac205feb3 (diff) | |
download | wireshark-0a2817cebacb5352ff348434db2571e218a21bdb.tar.gz wireshark-0a2817cebacb5352ff348434db2571e218a21bdb.tar.bz2 wireshark-0a2817cebacb5352ff348434db2571e218a21bdb.zip |
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
Diffstat (limited to 'packet.c')
-rw-r--r-- | packet.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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 <gerald@zing.org> @@ -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); } |