diff options
author | jake <jake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-09-10 18:54:12 +0000 |
---|---|---|
committer | jake <jake@f5534014-38df-0310-8fa8-9805f1628bb7> | 2009-09-10 18:54:12 +0000 |
commit | 329d8d4994f3c70d91113e11c6e87ae1c31395f5 (patch) | |
tree | c6bed1b9f1447b4985116a50d703c18ca22c00e0 | |
parent | 601ec96400005233cddf44db1cd14de65a081a1d (diff) |
From Jean-François Wauthy:
This patch fixes a bug in the dissection of the TI CC24xx FCS where the
endianness of the bitmasks used was wrong.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29847 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r-- | epan/dissectors/packet-ieee802154.c | 49 | ||||
-rw-r--r-- | epan/dissectors/packet-ieee802154.h | 6 |
2 files changed, 14 insertions, 41 deletions
diff --git a/epan/dissectors/packet-ieee802154.c b/epan/dissectors/packet-ieee802154.c index d085b34e4a..f4474c2c8d 100644 --- a/epan/dissectors/packet-ieee802154.c +++ b/epan/dissectors/packet-ieee802154.c @@ -228,33 +228,6 @@ static const value_string ieee802154_cmd_names[] = { #define IEEE802154_CRC_XOROUT 0xFFFF #define ieee802154_crc_tvb(tvb, offset) (crc16_ccitt_tvb_seed(tvb, offset, IEEE802154_CRC_SEED) ^ IEEE802154_CRC_XOROUT) -/*FUNCTION:------------------------------------------------------ - * NAME - * get_by_mask - * DESCRIPTION - * Extracts an integer sub-field from an int with a given mask - * if the mask is 0, this will return 0, if the mask is non- - * continuos the output is undefined. - * PARAMETERS - * guint input - * guint mask - * RETURNS - * guint - *--------------------------------------------------------------- - */ -guint -get_by_mask(guint input, guint mask) -{ - /* Sanity Check, don't want infinite loops. */ - if (mask == 0) return 0; - /* Shift input and mask together. */ - while (!(mask & 0x1)) { - input >>= 1; - mask >>=1; - } /* while */ - return (input & mask); -} /* get_by_mask */ - #define EUI64_STRLEN (3*(sizeof(guint64)+1)) /*FUNCTION:------------------------------------------------------ * NAME @@ -355,14 +328,14 @@ dissect_ieee802154_fcf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ieee fcf = tvb_get_letohs(tvb, *offset); /* Parse FCF Flags. */ - packet->frame_type = get_by_mask(fcf, IEEE802154_FCF_TYPE_MASK); - packet->security_enable = get_by_mask(fcf, IEEE802154_FCF_SEC_EN); - packet->frame_pending = get_by_mask(fcf, IEEE802154_FCF_FRAME_PND); - packet->ack_request = get_by_mask(fcf, IEEE802154_FCF_ACK_REQ); - packet->intra_pan = get_by_mask(fcf, IEEE802154_FCF_INTRA_PAN); - packet->version = get_by_mask(fcf, IEEE802154_FCF_VERSION); - packet->dst_addr_mode = get_by_mask(fcf, IEEE802154_FCF_DADDR_MASK); - packet->src_addr_mode = get_by_mask(fcf, IEEE802154_FCF_SADDR_MASK); + packet->frame_type = fcf & IEEE802154_FCF_TYPE_MASK; + packet->security_enable = (fcf & IEEE802154_FCF_SEC_EN) >> 3; + packet->frame_pending = (fcf & IEEE802154_FCF_FRAME_PND) >> 4; + packet->ack_request = (fcf & IEEE802154_FCF_ACK_REQ) >> 5; + packet->intra_pan = (fcf & IEEE802154_FCF_INTRA_PAN) >> 6; + packet->version = (fcf & IEEE802154_FCF_VERSION) >> 12; + packet->dst_addr_mode = (fcf & IEEE802154_FCF_DADDR_MASK) >> 10; + packet->src_addr_mode = (fcf & IEEE802154_FCF_SADDR_MASK) >> 14; /* Display the frame type. */ if (tree) proto_item_append_text(tree, " %s", val_to_str(packet->frame_type, ieee802154_frame_types, "Reserved")); @@ -884,10 +857,10 @@ dissect_ieee802154_fcs: ti = proto_tree_add_text(ieee802154_tree, tvb, offset, sizeof(guint16), "Frame Check Sequence: FCS %s", (fcs_ok) ? "OK" : "Bad"); field_tree = proto_item_add_subtree(ti, ett_ieee802154_fcs); /* Display FCS contents. */ - ti = proto_tree_add_int(field_tree, hf_ieee802154_rssi, tvb, offset, sizeof(guint16), get_by_mask(fcs, IEEE802154_CC24xx_RSSI)); + ti = proto_tree_add_int(field_tree, hf_ieee802154_rssi, tvb, offset, 1, (gint8) (fcs & IEEE802154_CC24xx_RSSI)); proto_item_append_text(ti, " dBm"); /* Displaying Units */ - proto_tree_add_boolean(field_tree, hf_ieee802154_fcs_ok, tvb, offset, sizeof(guint16), get_by_mask(fcs, IEEE802154_CC24xx_CRC_OK)); - proto_tree_add_uint(field_tree, hf_ieee802154_correlation, tvb, offset, sizeof(guint16), get_by_mask(fcs, IEEE802154_CC24xx_CORRELATION)); + proto_tree_add_boolean(field_tree, hf_ieee802154_fcs_ok, tvb, offset + 1, 1, (gboolean) (fcs & IEEE802154_CC24xx_CRC_OK)); + proto_tree_add_uint(field_tree, hf_ieee802154_correlation, tvb, offset + 1, 1, (guint8) ((fcs & IEEE802154_CC24xx_CORRELATION) >> 8)); } else { ti = proto_tree_add_uint(ieee802154_tree, hf_ieee802154_fcs, tvb, offset, sizeof(guint16), fcs); diff --git a/epan/dissectors/packet-ieee802154.h b/epan/dissectors/packet-ieee802154.h index 7d13565d8c..006c0ef3c0 100644 --- a/epan/dissectors/packet-ieee802154.h +++ b/epan/dissectors/packet-ieee802154.h @@ -115,9 +115,9 @@ #define IEEE802154_FCF_ADDR_EXT 0x0003 /* Bit-masks for CC24xx style FCS */ -#define IEEE802154_CC24xx_CORRELATION 0x007F -#define IEEE802154_CC24xx_CRC_OK 0x0080 -#define IEEE802154_CC24xx_RSSI 0xFF00 +#define IEEE802154_CC24xx_CORRELATION 0x7F00 +#define IEEE802154_CC24xx_CRC_OK 0x8000 +#define IEEE802154_CC24xx_RSSI 0x00FF /* Special IEEE802.15.4 Addresses */ #define IEEE802154_NO_ADDR16 0xFFFE |