tvb_length() is *not* the length of the packet; it's the amount of

captured data for the packet, which could well be less then the length
of the packet if a slice/snapshot length was used. 
tvb_reported_length() is the length as the packet appeared on the
{wire,air}.

If a > b, and you want to report how much a was greater than b, subtract
b from a, don't take the negative of b-a, especially if a and b are
unsigned....

svn path=/trunk/; revision=32199
This commit is contained in:
Guy Harris 2010-03-15 21:36:56 +00:00
parent ecb18edf04
commit 1f1a9ef2cc
1 changed files with 6 additions and 6 deletions

View File

@ -147,15 +147,15 @@ dissect_gvcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
info = ep_strbuf_new(val_to_str(packet_opcode, opcode_names, "Unknown opcode (0x%04x)"));
/* check that GVCP header+payload match total packet size */
if (tvb_length(tvb) < 8+(guint32)packet_plsize) {
ep_strbuf_append_printf(info, " (truncated? %d bytes missing)",
packet_plsize + 8 - tvb_length(tvb));
if (tvb_reported_length(tvb) < 8+(guint32)packet_plsize) {
ep_strbuf_append_printf(info, " (truncated? %u bytes missing)",
(8 + packet_plsize) - tvb_reported_length(tvb));
col_add_str(pinfo->cinfo, COL_INFO, info->str);
return tvb_length(tvb);/* or should we assume this is not GVCP, return 0?*/
}
if (tvb_length(tvb) > 8+(guint32)packet_plsize) {
ep_strbuf_append_printf(info, " (%d excess bytes)",
-(packet_plsize + 8 - tvb_length(tvb)));
if (tvb_reported_length(tvb) > 8+(guint32)packet_plsize) {
ep_strbuf_append_printf(info, " (%u excess bytes)",
tvb_reported_length(tvb) - (8 + packet_plsize));
col_add_str(pinfo->cinfo, COL_INFO, info->str);
return tvb_length(tvb);/* or should we assume this is not GVCP, return 0?*/
}