aboutsummaryrefslogtreecommitdiffstats
path: root/packet-vlan.c
diff options
context:
space:
mode:
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-11-18 10:38:33 +0000
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>2000-11-18 10:38:33 +0000
commitf4fc5ac736a773f41e683e59d4431b1fbfa43c9d (patch)
tree5e117f446c6e233d14b642596d67c985e685f328 /packet-vlan.c
parent92c209a221b63e9fd8b07684cec124efc0e01597 (diff)
Tvbuffify the IP, ICMP, TCP, UDP, OSI CLNP, OSI COTP, OSI CLTP, and OSI
ESIS dissectors. Register the IP dissector and have dissectors that call it directly (rather than through a port table) call it through a handle. Add a routine "tvb_set_reported_length()" which a dissector can use if it was handed a tvbuff that contains more data than is actually in its part of the packet - for example, handing a padded Ethernet frame to IP; the routine sets the reported length of the tvbuff (and also adjusts the actual length, as appropriate). Then use it in IP. Given that, "ethertype()" can determine how much of the Ethernet frame was actually part of an IP datagram (and can do the same for other protocols under Ethernet that use "tvb_set_reported_length()"; have it return the actual length, and have "dissect_eth()" and "dissect_vlan()" use that to mark trailer data in Ethernet II frames as well as in 802.3 frames. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2658 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'packet-vlan.c')
-rw-r--r--packet-vlan.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/packet-vlan.c b/packet-vlan.c
index adcbfdb96d..c0ffdcff7b 100644
--- a/packet-vlan.c
+++ b/packet-vlan.c
@@ -1,7 +1,7 @@
/* packet-vlan.c
* Routines for VLAN 802.1Q ethernet header disassembly
*
- * $Id: packet-vlan.c,v 1.23 2000/11/13 05:22:58 guy Exp $
+ * $Id: packet-vlan.c,v 1.24 2000/11/18 10:38:25 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -79,6 +79,7 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
tvbuff_t *volatile next_tvb;
tvbuff_t *volatile trailer_tvb;
proto_tree *volatile vlan_tree;
+ guint length_before, length;
CHECK_DISPLAY_AS_DATA(proto_vlan, tvb, pinfo, tree);
@@ -107,7 +108,7 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
if ( encap_proto <= IEEE_802_3_MAX_LEN) {
- /* Give the next dissector only 'length' number of bytes */
+ /* Give the next dissector only 'encap_proto' number of bytes */
proto_tree_add_uint(vlan_tree, hf_vlan_len, tvb, 2, 2, encap_proto);
TRY {
next_tvb = tvb_new_subset(tvb, 4, encap_proto, encap_proto);
@@ -160,21 +161,40 @@ dissect_vlan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
} else {
dissect_ipx(next_tvb, pinfo, tree);
}
+ } else {
+ length_before = tvb_reported_length(tvb);
+ length = ethertype(encap_proto, tvb, 4, pinfo, tree, vlan_tree,
+ hf_vlan_etype) + 4;
+ if (length < length_before) {
+ /*
+ * Create a tvbuff for the padding.
+ */
+ TRY {
+ trailer_tvb = tvb_new_subset(tvb, length, -1, -1);
+ }
+ CATCH2(BoundsError, ReportedBoundsError) {
+ /* The packet doesn't have "length" bytes worth of captured
+ data left in it. No trailer to display. */
+ trailer_tvb = NULL;
+ }
+ ENDTRY;
+ } else {
+ /* No padding. */
+ trailer_tvb = NULL;
+ }
+ }
- /* If there's some bytes left over, mark them. */
- if (trailer_tvb && tree) {
- int trailer_length;
- const guint8 *ptr;
+ /* If there's some bytes left over, mark them. */
+ if (trailer_tvb && tree) {
+ int trailer_length;
+ const guint8 *ptr;
- trailer_length = tvb_length(trailer_tvb);
- if (trailer_length > 0) {
- ptr = tvb_get_ptr(trailer_tvb, 0, trailer_length);
- proto_tree_add_bytes(vlan_tree, hf_vlan_trailer, tvb, 4 + encap_proto,
- trailer_length, ptr);
- }
+ trailer_length = tvb_length(trailer_tvb);
+ if (trailer_length > 0) {
+ ptr = tvb_get_ptr(trailer_tvb, 0, trailer_length);
+ proto_tree_add_bytes(vlan_tree, hf_vlan_trailer, trailer_tvb, 0,
+ trailer_length, ptr);
}
- } else {
- ethertype(encap_proto, tvb, 4, pinfo, tree, vlan_tree, hf_vlan_etype);
}
}