diff options
author | Guy Harris <guy@alum.mit.edu> | 2001-06-29 09:46:54 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2001-06-29 09:46:54 +0000 |
commit | 556a11ad45f9f97d52273386290aa7cdae579c5e (patch) | |
tree | 146bc0d7a44d8f5d8b5e672a520865b17cf6466d /epan | |
parent | c94f0e130b3e4fdb4f4f6fdf82130166fa011392 (diff) | |
download | wireshark-556a11ad45f9f97d52273386290aa7cdae579c5e.tar.gz wireshark-556a11ad45f9f97d52273386290aa7cdae579c5e.tar.bz2 wireshark-556a11ad45f9f97d52273386290aa7cdae579c5e.zip |
Create a routine to do the tvbuff-length-adjusting and
"pinfo->{len,captured_len}"-adjusting currently done by the IP
dissector, make the IP dissector call that rather than doing the work
itself, make the IPv6 dissector call that rather than just adjusting the
tvbuff length itself, and make the IPX dissector call that rather than
just adjusting "pi.{len,captured_len}" itself.
This cleans things up a bit, and causes trailers to be properly reported
in IPX-over-Ethernet frames.
svn path=/trunk/; revision=3621
Diffstat (limited to 'epan')
-rw-r--r-- | epan/packet.c | 46 | ||||
-rw-r--r-- | epan/packet.h | 10 |
2 files changed, 54 insertions, 2 deletions
diff --git a/epan/packet.c b/epan/packet.c index e44fe8e33b..6b53e6fe8c 100644 --- a/epan/packet.c +++ b/epan/packet.c @@ -1,7 +1,7 @@ /* packet.c * Routines for packet disassembly * - * $Id: packet.c,v 1.35 2001/06/02 08:23:10 guy Exp $ + * $Id: packet.c,v 1.36 2001/06/29 09:46:54 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -96,6 +96,50 @@ packet_cleanup(void) /* nothing */ } +/* + * Given a tvbuff, a packet_info *, and a length from a packet header, + * adjust the length of the tvbuff, and the "len" and "captured_len" + * members of the "packet_info" structure, to reflect the specified + * length. + */ +void +set_actual_length(tvbuff_t *tvb, packet_info *pinfo, guint specified_len) +{ + guint payload_len, reported_payload_len; + int padding; + + /* Length of payload handed to us. */ + reported_payload_len = tvb_reported_length(tvb); + payload_len = tvb_length(tvb); + + if (specified_len < reported_payload_len) { + /* Adjust the length of this tvbuff to include only the specified + payload length. + + The dissector above the one calling us (the dissector above is + probably us) may use that to determine how much of its packet + was padding. */ + tvb_set_reported_length(tvb, specified_len); + + /* XXX - can we get rid of "pinfo->len" and "pinfo->captured_len" + when the last dissector is tvbuffified? */ + + /* Shrink the total payload by the amount of padding. */ + padding = reported_payload_len - specified_len; + if (pinfo->len >= padding) + pinfo->len -= padding; + + /* Shrink the captured payload by the amount of padding in the + captured payload (which may be less than the amount of padding, + as the padding may not have been captured). */ + if (specified_len < payload_len) { + padding = payload_len - specified_len; + if (pinfo->captured_len >= padding) + pinfo->captured_len -= padding; + } + } +} + /* Allow protocols to register "init" routines, which are called before we make a pass through a capture file and dissect all its packets (e.g., when we read in a new capture file, or run a "filter packets" diff --git a/epan/packet.h b/epan/packet.h index b3b02cb4d6..31e0dd0eb5 100644 --- a/epan/packet.h +++ b/epan/packet.h @@ -1,7 +1,7 @@ /* packet.h * Definitions for packet disassembly structures and routines * - * $Id: packet.h,v 1.34 2001/06/02 08:23:10 guy Exp $ + * $Id: packet.h,v 1.35 2001/06/29 09:46:54 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -206,6 +206,14 @@ void dissect_init(void); void dissect_cleanup(void); +/* + * Given a tvbuff, a packet_info *, and a length from a packet header, + * adjust the length of the tvbuff, and the "len" and "captured_len" + * members of the "packet_info" structure, to reflect the specified + * length. + */ +void set_actual_length(tvbuff_t *tvb, packet_info *pinfo, guint specified_len); + /* Allow protocols to register "init" routines, which are called before we make a pass through a capture file and dissect all its packets (e.g., when we read in a new capture file, or run a "filter packets" |