aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2016-07-10 23:47:28 -0400
committerMichael Mann <mmann78@netscape.net>2016-07-21 12:35:22 +0000
commitad6fc87d64de30cdcdca18168a117d2ec24591da (patch)
treeb5df109654ae6806db7544933f8bf1a848a02ae7 /plugins
parent1e19f55f0c44b850bc6304be28d5b272a3553204 (diff)
Add proto_tree_add_checksum.
This is an attempt to standardize display/handling of checksum fields for all dissectors. The main target is for dissectors that do validation, but dissectors that just report the checksum were also included just to make them easier to find in the future. Bug: 10620 Bug: 12058 Ping-Bug: 8859 Change-Id: Ia8abd86e42eaf8ed50de6b173409e914b17993bf Reviewed-on: https://code.wireshark.org/review/16380 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/irda/packet-sir.c42
-rw-r--r--plugins/profinet/packet-pn-rt.c51
-rw-r--r--plugins/wimax/mac_hd_generic_decoder.c12
-rw-r--r--plugins/wimax/msg_dlmap.c96
-rw-r--r--plugins/wimax/msg_ulmap.c109
-rw-r--r--plugins/wimax/wimax_harq_map_decoder.c12
6 files changed, 110 insertions, 212 deletions
diff --git a/plugins/irda/packet-sir.c b/plugins/irda/packet-sir.c
index 98ee323390..11188a47bf 100644
--- a/plugins/irda/packet-sir.c
+++ b/plugins/irda/packet-sir.c
@@ -56,10 +56,20 @@ static int hf_sir_bof = -1;
/* static int hf_sir_ce = -1; */
static int hf_sir_eof = -1;
static int hf_sir_fcs = -1;
-static int hf_sir_fcs_bad = -1;
+static int hf_sir_fcs_status = -1;
static int hf_sir_length = -1;
static int hf_sir_preamble = -1;
+/* Copied and renamed from proto.c because global value_strings don't work for plugins */
+static const value_string plugin_proto_checksum_vals[] = {
+ { PROTO_CHECKSUM_E_BAD, "Bad" },
+ { PROTO_CHECKSUM_E_GOOD, "Good" },
+ { PROTO_CHECKSUM_E_UNVERIFIED, "Unverified" },
+ { PROTO_CHECKSUM_E_NOT_PRESENT, "Not present" },
+
+ { 0, NULL }
+};
+
/** Unescapes the data. */
static tvbuff_t *
@@ -94,29 +104,13 @@ unescape_data(tvbuff_t *tvb, packet_info *pinfo)
static tvbuff_t *
checksum_data(tvbuff_t *tvb, proto_tree *tree)
{
- proto_item *hidden_item;
int len = tvb_reported_length(tvb) - 2;
if (len < 0)
return tvb;
- if (tree) {
- guint16 actual_fcs = tvb_get_letohs(tvb, len);
- guint16 calculated_fcs = crc16_ccitt_tvb(tvb, len);
- if (calculated_fcs == actual_fcs) {
- proto_tree_add_uint_format(tree, hf_sir_fcs,
- tvb, len, 2, actual_fcs,
- "Frame check sequence: 0x%04x (correct)",
- actual_fcs);
- } else {
- hidden_item = proto_tree_add_boolean(tree,
- hf_sir_fcs_bad, tvb, len, 2, TRUE);
- PROTO_ITEM_SET_HIDDEN(hidden_item);
- proto_tree_add_uint_format(tree, hf_sir_fcs,
- tvb, len, 2, actual_fcs,
- "Frame check sequence: 0x%04x "
- "(incorrect, should be 0x%04x)",
- actual_fcs, calculated_fcs);
- }
- }
+
+ proto_tree_add_checksum(tree, tvb, len, hf_sir_fcs, hf_sir_fcs_status, NULL, NULL, crc16_ccitt_tvb(tvb, len),
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
return tvb_new_subset_length(tvb, 0, len);
}
@@ -209,9 +203,9 @@ proto_register_irsir(void)
{ "Frame check sequence", "sir.fcs",
FT_UINT16, BASE_HEX, NULL, 0,
NULL, HFILL }},
- { &hf_sir_fcs_bad,
- { "Bad frame check sequence", "sir.fcs_bad",
- FT_BOOLEAN, BASE_NONE, NULL, 0x0,
+ { &hf_sir_fcs_status,
+ { "Frame check sequence Status", "sir.fcs.status",
+ FT_UINT8, BASE_NONE, VALS(plugin_proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_sir_length,
{ "Length", "sir.length",
diff --git a/plugins/profinet/packet-pn-rt.c b/plugins/profinet/packet-pn-rt.c
index 8757a1a9ff..885cd9fc68 100644
--- a/plugins/profinet/packet-pn-rt.c
+++ b/plugins/profinet/packet-pn-rt.c
@@ -58,8 +58,7 @@ static int hf_pn_rt_data_status_redundancy = -1;
static int hf_pn_rt_data_status_primary = -1;
static int hf_pn_rt_sf_crc16 = -1;
-static int hf_pn_rt_sf_crc16_ok = -1;
-static int hf_pn_rt_sf_crc16_null = -1;
+static int hf_pn_rt_sf_crc16_status = -1;
static int hf_pn_rt_sf = -1;
static int hf_pn_rt_sf_position = -1;
/* static int hf_pn_rt_sf_position_control = -1; */
@@ -124,6 +123,16 @@ static const value_string pn_rt_frag_status_more_follows[] = {
{ 0, NULL }
};
+/* Copied and renamed from proto.c because global value_strings don't work for plugins */
+static const value_string plugin_proto_checksum_vals[] = {
+ { PROTO_CHECKSUM_E_BAD, "Bad" },
+ { PROTO_CHECKSUM_E_GOOD, "Good" },
+ { PROTO_CHECKSUM_E_UNVERIFIED, "Unverified" },
+ { PROTO_CHECKSUM_E_NOT_PRESENT, "Not present" },
+
+ { 0, NULL }
+};
+
static void
dissect_DataStatus(tvbuff_t *tvb, int offset, proto_tree *tree, guint8 u8DataStatus)
{
@@ -246,7 +255,6 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
guint32 u32SubStart;
proto_item *sub_item;
proto_tree *sub_tree;
- proto_item *item;
guint16 crc;
@@ -256,10 +264,16 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
if (IsDFP_Frame(tvb, pinfo, tree, u16FrameID)) {
/* can't check this CRC, as the checked data bytes are not available */
u16SFCRC16 = tvb_get_letohs(tvb, offset);
- if (u16SFCRC16 != 0)
- proto_tree_add_uint(tree, hf_pn_rt_sf_crc16_ok, tvb, offset, 2, u16SFCRC16);
- else
- proto_tree_add_uint(tree, hf_pn_rt_sf_crc16_null, tvb, offset, 2, u16SFCRC16);
+ if (u16SFCRC16 != 0) {
+ /* Checksum verify will always succeed */
+ /* XXX - should we combine the two calls to always show "unverified"? */
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, u16SFCRC16,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ }
+ else {
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, 0,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
+ }
offset += 2;
while (1) {
@@ -292,18 +306,14 @@ dissect_CSF_SDU_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *
offset = dissect_pn_user_data(tvb, offset, pinfo, sub_tree, u8SFDataLength, "DataItem");
u16SFCRC16 = tvb_get_letohs(tvb, offset);
- item = proto_tree_add_uint(sub_tree, hf_pn_rt_sf_crc16, tvb, offset, 2, u16SFCRC16);
if (u16SFCRC16 != 0 /* "old check": u8SFPosition & 0x80 */) {
crc = crc16_plain_tvb_offset_seed(tvb, u32SubStart, offset-u32SubStart, 0);
- if (crc != u16SFCRC16) {
- proto_item_append_text(item, " [Preliminary check: incorrect, should be: %u]", crc);
- expert_add_info(pinfo, item, &ei_pn_rt_sf_crc16);
- } else {
- proto_item_append_text(item, " [Preliminary check: Correct]");
- }
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, crc,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_VERIFY);
} else {
- proto_item_append_text(item, " [No check, supplied CRC == zero]");
+ proto_tree_add_checksum(tree, tvb, offset, hf_pn_rt_sf_crc16, hf_pn_rt_sf_crc16_status, &ei_pn_rt_sf_crc16, pinfo, 0,
+ ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
}
offset += 2;
@@ -872,14 +882,9 @@ proto_register_pn_rt(void)
FT_UINT16, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
- { &hf_pn_rt_sf_crc16_ok,
- { "SFCRC16 checked [ok]", "pn_rt.sf.crc16_ok",
- FT_UINT16, BASE_HEX, NULL, 0x0,
- NULL, HFILL }},
-
- { &hf_pn_rt_sf_crc16_null,
- { "SFCRC16 not checked but ok", "pn_rt.sf.crc16_null",
- FT_UINT16, BASE_HEX, NULL, 0x0,
+ { &hf_pn_rt_sf_crc16_status,
+ { "SFCRC16 status", "pn_rt.sf.crc16.status",
+ FT_UINT8, BASE_NONE, VALS(plugin_proto_checksum_vals), 0x0,
NULL, HFILL }},
{ &hf_pn_rt_sf_position,
diff --git a/plugins/wimax/mac_hd_generic_decoder.c b/plugins/wimax/mac_hd_generic_decoder.c
index b5fc149827..ad47a3915f 100644
--- a/plugins/wimax/mac_hd_generic_decoder.c
+++ b/plugins/wimax/mac_hd_generic_decoder.c
@@ -1218,16 +1218,12 @@ check_crc:
proto_item_append_text(parent_item, ", CRC");
/* check the length */
if (MIN(tvb_len, tvb_reported_length(tvb)) >= mac_len)
- { /* get the CRC */
- mac_crc = tvb_get_ntohl(tvb, mac_len - (int)sizeof(mac_crc));
- /* calculate the CRC */
+ {
+ /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc32(tvb_get_ptr(tvb, 0, mac_len - (int)sizeof(mac_crc)), mac_len - (int)sizeof(mac_crc));
/* display the CRC */
- generic_item = proto_tree_add_item(tree, hf_mac_header_generic_crc, tvb, mac_len - (int)sizeof(mac_crc), (int)sizeof(mac_crc), ENC_BIG_ENDIAN);
- if (mac_crc != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, mac_len - (int)sizeof(mac_crc), hf_mac_header_generic_crc, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else
{ /* display error message */
diff --git a/plugins/wimax/msg_dlmap.c b/plugins/wimax/msg_dlmap.c
index 8a3ae02371..6f022cbdf4 100644
--- a/plugins/wimax/msg_dlmap.c
+++ b/plugins/wimax/msg_dlmap.c
@@ -822,9 +822,7 @@ static gint DL_HARQ_IR_CTC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
{
/* offset of IE in nibbles, length is variable */
gint bit;
- guint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, ddci, dur;
gint j;
guint32 calculated_crc;
@@ -867,14 +865,9 @@ static gint DL_HARQ_IR_CTC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -885,9 +878,7 @@ static gint DL_HARQ_IR_CC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, sbdi, ddci, dur;
gint j;
guint16 calculated_crc;
@@ -938,14 +929,9 @@ static gint DL_HARQ_IR_CC_sub_burst_IE(proto_tree *diuc_tree, gint offset, gint
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -958,7 +944,6 @@ static gint MIMO_DL_Chase_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset,
gint bit;
gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, mui, dci, akd;
gint i, j;
guint16 calculated_crc;
@@ -1005,14 +990,9 @@ static gint MIMO_DL_Chase_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset,
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -1023,9 +1003,7 @@ static gint MIMO_DL_IR_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gin
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, mui, dci, akd;
gint i, j;
guint16 calculated_crc;
@@ -1066,14 +1044,9 @@ static gint MIMO_DL_IR_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gin
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -1084,9 +1057,7 @@ static gint MIMO_DL_IR_HARQ_for_CC_sub_burst_IE(proto_tree *diuc_tree, gint offs
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, mui, dci, akd;
gint i, j;
guint16 calculated_crc;
@@ -1128,14 +1099,9 @@ static gint MIMO_DL_IR_HARQ_for_CC_sub_burst_IE(proto_tree *diuc_tree, gint offs
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -1146,9 +1112,7 @@ static gint MIMO_DL_STC_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gi
{
/* offset of IE in nibbles, length is variable */
gint bit;
- gint data;
proto_tree *tree;
- proto_item *generic_item = NULL;
gint nsub, sbi, txc, akd, dmci;
gint j;
guint16 calculated_crc;
@@ -1188,14 +1152,9 @@ static gint MIMO_DL_STC_HARQ_sub_burst_IE(proto_tree *diuc_tree, gint offset, gi
if (include_cor2_changes)
{
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, NULL, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
}
@@ -2341,7 +2300,6 @@ gint wimax_decode_dlmapc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *base_tre
proto_item *ti = NULL;
proto_item *ti_phy = NULL;
proto_item *ti_dlmap_ies = NULL;
- proto_item *generic_item = NULL;
proto_tree *tree = NULL;
proto_tree *ie_tree = NULL;
proto_tree *phy_tree = NULL;
@@ -2424,16 +2382,11 @@ gint wimax_decode_dlmapc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *base_tre
/* CRC is always appended */
/* check the length */
if (MIN(tvb_len, tvb_reported_length(tvb)) >= mac_len)
- { /* get the CRC */
- mac_crc = tvb_get_ntohl(tvb, mac_len - (int)sizeof(mac_crc));
+ {
/* calculate the CRC */
calculated_crc = wimax_mac_calc_crc32(tvb_get_ptr(tvb, 0, mac_len - (int)sizeof(mac_crc)), mac_len - (int)sizeof(mac_crc));
- /* display the CRC */
- generic_item = proto_tree_add_item(base_tree, hf_mac_header_compress_dlmap_crc, tvb, mac_len - (int)sizeof(mac_crc), (int)sizeof(mac_crc), ENC_BIG_ENDIAN);
- if (mac_crc != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(base_tree, tvb, mac_len - (int)sizeof(mac_crc), hf_mac_header_compress_dlmap_crc, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
else
{ /* display error message */
@@ -2510,14 +2463,9 @@ static gint wimax_decode_sub_dl_ul_map(tvbuff_t *tvb, packet_info *pinfo, proto_
}
/* CRC-16 is always appended */
- data = TVB_NIB_WORD(nib, tvb);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, NIBHI(nib,4), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, NIB_TO_BYTE(nib)), NIB_TO_BYTE(nib));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, NIBHI(nib,4), hf_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
/* nib += 4; */
sub_dl_ul_map = 0; /* clear flag */
@@ -2533,7 +2481,6 @@ gint wimax_decode_dlmap_reduced_aas(tvbuff_t *tvb, packet_info *pinfo _U_, proto
guint offset = 0;
proto_item *ti = NULL;
proto_tree *tree = NULL;
- proto_item *generic_item = NULL;
gint ulmap_appended;
gint length;
gint tvb_len = tvb_reported_length(tvb);
@@ -2636,14 +2583,9 @@ gint wimax_decode_dlmap_reduced_aas(tvbuff_t *tvb, packet_info *pinfo _U_, proto
}
/* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
calculated_crc = wimax_mac_calc_crc16(tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, BIT_ADDR(bit), hf_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
bit += 16;
return BIT_TO_BYTE(bit) - offset;
diff --git a/plugins/wimax/msg_ulmap.c b/plugins/wimax/msg_ulmap.c
index afce354898..dd19011bd8 100644
--- a/plugins/wimax/msg_ulmap.c
+++ b/plugins/wimax/msg_ulmap.c
@@ -634,16 +634,10 @@ static gint UL_HARQ_Chase_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gint
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ bit += 16;
}
#endif
@@ -680,16 +674,11 @@ static gint UL_HARQ_IR_CTC_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gint
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+ bit += 16;
}
#endif
@@ -727,16 +716,12 @@ static gint UL_HARQ_IR_CC_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gint
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -784,16 +769,12 @@ static gint MIMO_UL_Chase_HARQ_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset,
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -841,16 +822,12 @@ static gint MIMO_UL_IR_HARQ__Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gi
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -899,16 +876,12 @@ static gint MIMO_UL_IR_HARQ_for_CC_Sub_Burst_UIE(proto_tree *uiuc_tree, gint off
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
@@ -949,16 +922,12 @@ static gint MIMO_UL_STC_HARQ_Sub_Burst_IE(proto_tree *uiuc_tree, gint offset, gi
#if 0
if (include_cor2_changes)
{
- /* CRC-16 is always appended */
- data = TVB_BIT_BITS(bit, tvb, 16);
- generic_item = proto_tree_add_uint(tree, hf_ulmap_crc16, tvb, BITHI(bit,16), data);
- /* calculate the CRC */
- calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
- if (data != calculated_crc)
- {
- proto_item_append_text(generic_item, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
- bit += 16;
+ /* CRC-16 is always appended */
+ calculated_crc = wimax_mac_calc_crc16((guint8 *)tvb_get_ptr(tvb, 0, BIT_TO_BYTE(bit)), BIT_TO_BYTE(bit));
+ proto_tree_add_checksum(tree, tvb, BITHI(bit,16), hf_ulmap_crc16, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
+
+ bit += 16;
}
#endif
diff --git a/plugins/wimax/wimax_harq_map_decoder.c b/plugins/wimax/wimax_harq_map_decoder.c
index dd643ff37d..0666515160 100644
--- a/plugins/wimax/wimax_harq_map_decoder.c
+++ b/plugins/wimax/wimax_harq_map_decoder.c
@@ -71,7 +71,6 @@ static int dissector_wimax_harq_map_decoder(tvbuff_t *tvb, packet_info *pinfo, p
proto_tree *harq_map_tree = NULL;
guint nibble_offset;
proto_item *parent_item = NULL;
- proto_item *it = NULL;
guint ulmap_appended;
guint32 harq_map_msg_crc, calculated_crc;
guint32 first_24bits;
@@ -150,17 +149,10 @@ static int dissector_wimax_harq_map_decoder(tvbuff_t *tvb, packet_info *pinfo, p
}
/* add the CRC info */
proto_item_append_text(parent_item, ",CRC");
- /* get the CRC */
- harq_map_msg_crc = tvb_get_ntohl(tvb, length - (int)sizeof(harq_map_msg_crc));
/* calculate the HARQ MAM Message CRC */
calculated_crc = wimax_mac_calc_crc32(tvb_get_ptr(tvb, 0, length - (int)sizeof(harq_map_msg_crc)), length - (int)sizeof(harq_map_msg_crc));
- /* display the CRC */
- it = proto_tree_add_item(harq_map_tree, hf_harq_map_msg_crc, tvb, length - (int)sizeof(harq_map_msg_crc), (int)sizeof(harq_map_msg_crc), ENC_BIG_ENDIAN);
- /* verify the CRC */
- if (harq_map_msg_crc != calculated_crc)
- {
- proto_item_append_text(it, " - incorrect! (should be: 0x%x)", calculated_crc);
- }
+ proto_tree_add_checksum(tree, tvb, length - (int)sizeof(harq_map_msg_crc), hf_harq_map_msg_crc, -1, NULL, pinfo, calculated_crc,
+ ENC_BIG_ENDIAN, PROTO_CHECKSUM_VERIFY);
}
return tvb_captured_length(tvb);
}