aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-05-28 22:02:17 +0000
committerGuy Harris <guy@alum.mit.edu>2000-05-28 22:02:17 +0000
commit713245f76cfcd264419e2331b5ec25c34b71d673 (patch)
treed3d72f748b6a9ea7da75550f823811d347f10827
parenta2b30d028c225a301eaddaeeee9ee55a24415725 (diff)
In the FDDI and LLC dissectors, extract fields as we use them, so that
we don't get an exception (and thus a "Short Frame" or "Malformed Frame" entry) until we get to a field that isn't in the frame. svn path=/trunk/; revision=2021
-rw-r--r--packet-fddi.c64
-rw-r--r--packet-llc.c15
2 files changed, 46 insertions, 33 deletions
diff --git a/packet-fddi.c b/packet-fddi.c
index 4a8ad2785b..c19f3573bf 100644
--- a/packet-fddi.c
+++ b/packet-fddi.c
@@ -3,7 +3,7 @@
*
* Laurent Deniel <deniel@worldnet.fr>
*
- * $Id: packet-fddi.c,v 1.34 2000/05/19 05:29:44 guy Exp $
+ * $Id: packet-fddi.c,v 1.35 2000/05/28 22:02:16 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -258,7 +258,7 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
gboolean bitswapped)
{
int fc;
- proto_tree *fh_tree;
+ proto_tree *fh_tree = NULL;
proto_item *ti;
gchar *fc_str;
static u_char src[6], dst[6];
@@ -269,49 +269,59 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (check_col(pinfo->fd, COL_PROTOCOL))
col_add_str(pinfo->fd, COL_PROTOCOL, "FDDI");
- /* Extract the source and destination addresses, possibly bit-swapping
- them. */
- if (bitswapped) {
- swap_mac_addr(dst, (u_char *) tvb_get_ptr(tvb, FDDI_P_DHOST, 6));
- swap_mac_addr(src, (u_char *) tvb_get_ptr(tvb, FDDI_P_SHOST, 6));
- } else {
- memcpy(dst, (u_char *) tvb_get_ptr(tvb, FDDI_P_DHOST, 6), sizeof dst);
- memcpy(src, (u_char *) tvb_get_ptr(tvb, FDDI_P_SHOST, 6), sizeof src);
- }
-
fc = (int) tvb_get_guint8(tvb, FDDI_P_FC);
fc_str = fddifc_to_str(fc);
if (check_col(pinfo->fd, COL_INFO))
col_add_str(pinfo->fd, COL_INFO, fc_str);
+ if (tree) {
+ ti = proto_tree_add_protocol_format(tree, proto_fddi, tvb, 0, FDDI_HEADER_SIZE,
+ "Fiber Distributed Data Interface, %s", fc_str);
+ fh_tree = proto_item_add_subtree(ti, ett_fddi);
+ proto_tree_add_item(fh_tree, hf_fddi_fc, tvb, FDDI_P_FC, 1, fc);
+ }
+
+ /* Extract the destination address, possibly bit-swapping it. */
+ if (bitswapped)
+ swap_mac_addr(dst, (u_char *) tvb_get_ptr(tvb, FDDI_P_DHOST, 6));
+ else
+ memcpy(dst, (u_char *) tvb_get_ptr(tvb, FDDI_P_DHOST, 6), sizeof dst);
+ swap_mac_addr(dst_swapped, (u_char*) tvb_get_ptr(tvb, FDDI_P_DHOST, 6));
+
/* XXX - copy them to some buffer associated with "pi", rather than
- just making "src" and "dst" static? */
- SET_ADDRESS(&pi.dl_src, AT_ETHER, 6, &src[0]);
- SET_ADDRESS(&pi.src, AT_ETHER, 6, &src[0]);
+ just making "dst" static? */
SET_ADDRESS(&pi.dl_dst, AT_ETHER, 6, &dst[0]);
SET_ADDRESS(&pi.dst, AT_ETHER, 6, &dst[0]);
- if (tree) {
- ti = proto_tree_add_protocol_format(tree, proto_fddi, tvb, 0, FDDI_HEADER_SIZE,
- "Fiber Distributed Data Interface, %s", fc_str);
+ if (fh_tree) {
+ proto_tree_add_item(fh_tree, hf_fddi_dst, tvb, FDDI_P_DHOST, 6, dst);
+ proto_tree_add_item_hidden(fh_tree, hf_fddi_addr, tvb, FDDI_P_DHOST, 6, dst);
- swap_mac_addr(dst_swapped, (u_char*) tvb_get_ptr(tvb, FDDI_P_DHOST, 6));
- swap_mac_addr(src_swapped, (u_char*) tvb_get_ptr(tvb, FDDI_P_SHOST, 6));
+ /* hide some bit-swapped mac address fields in the proto_tree, just in case */
+ proto_tree_add_item_hidden(fh_tree, hf_fddi_dst, tvb, FDDI_P_DHOST, 6, dst_swapped);
+ proto_tree_add_item_hidden(fh_tree, hf_fddi_addr, tvb, FDDI_P_DHOST, 6, dst_swapped);
+ }
- fh_tree = proto_item_add_subtree(ti, ett_fddi);
- proto_tree_add_item(fh_tree, hf_fddi_fc, tvb, FDDI_P_FC, 1, fc);
- proto_tree_add_item(fh_tree, hf_fddi_dst, tvb, FDDI_P_DHOST, 6, dst);
+ /* Extract the source address, possibly bit-swapping it. */
+ if (bitswapped)
+ swap_mac_addr(src, (u_char *) tvb_get_ptr(tvb, FDDI_P_SHOST, 6));
+ else
+ memcpy(src, (u_char *) tvb_get_ptr(tvb, FDDI_P_SHOST, 6), sizeof src);
+ swap_mac_addr(src_swapped, (u_char*) tvb_get_ptr(tvb, FDDI_P_SHOST, 6));
+
+ /* XXX - copy them to some buffer associated with "pi", rather than
+ just making "src" static? */
+ SET_ADDRESS(&pi.dl_src, AT_ETHER, 6, &src[0]);
+ SET_ADDRESS(&pi.src, AT_ETHER, 6, &src[0]);
+
+ if (fh_tree) {
proto_tree_add_item(fh_tree, hf_fddi_src, tvb, FDDI_P_SHOST, 6, src);
- proto_tree_add_item_hidden(fh_tree, hf_fddi_addr, tvb, FDDI_P_DHOST, 6, dst);
proto_tree_add_item_hidden(fh_tree, hf_fddi_addr, tvb, FDDI_P_SHOST, 6, src);
/* hide some bit-swapped mac address fields in the proto_tree, just in case */
- proto_tree_add_item_hidden(fh_tree, hf_fddi_dst, tvb, FDDI_P_DHOST, 6, dst_swapped);
proto_tree_add_item_hidden(fh_tree, hf_fddi_src, tvb, FDDI_P_SHOST, 6, src_swapped);
- proto_tree_add_item_hidden(fh_tree, hf_fddi_addr, tvb, FDDI_P_DHOST, 6, dst_swapped);
proto_tree_add_item_hidden(fh_tree, hf_fddi_addr, tvb, FDDI_P_SHOST, 6, src_swapped);
-
}
next_tvb = tvb_new_subset(tvb, FDDI_HEADER_SIZE, -1, -1);
diff --git a/packet-llc.c b/packet-llc.c
index df9a7a6394..8ea2942d69 100644
--- a/packet-llc.c
+++ b/packet-llc.c
@@ -2,7 +2,7 @@
* Routines for IEEE 802.2 LLC layer
* Gilbert Ramirez <gram@xiexie.org>
*
- * $Id: packet-llc.c,v 1.62 2000/05/28 21:21:23 guy Exp $
+ * $Id: packet-llc.c,v 1.63 2000/05/28 22:02:17 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -285,11 +285,6 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
dsap = tvb_get_guint8(tvb, 0);
- ssap = tvb_get_guint8(tvb, 1);
-
- is_snap = (dsap == SAP_SNAP) && (ssap == SAP_SNAP);
- llc_header_len = 2; /* DSAP + SSAP */
-
if (tree) {
ti = proto_tree_add_item(tree, proto_llc, tvb, 0, 0, NULL);
llc_tree = proto_item_add_subtree(ti, ett_llc);
@@ -297,6 +292,11 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
1, dsap & SAP_MASK);
proto_tree_add_item(llc_tree, hf_llc_dsap_ig, tvb, 0,
1, dsap & DSAP_GI_BIT);
+ } else
+ llc_tree = NULL;
+
+ ssap = tvb_get_guint8(tvb, 1);
+ if (tree) {
proto_tree_add_item(llc_tree, hf_llc_ssap, tvb, 1,
1, ssap & SAP_MASK);
proto_tree_add_item(llc_tree, hf_llc_ssap_cr, tvb, 1,
@@ -304,6 +304,9 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
} else
llc_tree = NULL;
+ is_snap = (dsap == SAP_SNAP) && (ssap == SAP_SNAP);
+ llc_header_len = 2; /* DSAP + SSAP */
+
/*
* XXX - the page referred to in the comment above about the
* Command/Response bit also implies that LLC Type 2 always