aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2016-09-27 23:57:29 +0200
committerAnders Broman <a.broman58@gmail.com>2016-09-28 06:07:01 +0000
commit152e245804397bfcd0fc3e4cfac22e1d49b0b169 (patch)
tree3ed21c5c6178a39c59409ddaa7859c2d59de5163 /epan
parentf8b32e5b4edac7c4ca9932aacef64b48e514b577 (diff)
proto_tree_add_item_ret_(u)int/proto_tree_add_bitmask_with_flags_ret_uint64: return real value
Apply mask and bit shift on the returned value. Change-Id: I00aebc854756f01a25199a259d6d5252abea4349 Reviewed-on: https://code.wireshark.org/review/17958 Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/asn1/rrc/rrc.cnf2
-rw-r--r--epan/dissectors/packet-enip.c2
-rw-r--r--epan/dissectors/packet-gsm_abis_pgsl.c2
-rw-r--r--epan/dissectors/packet-gsm_abis_tfp.c11
-rw-r--r--epan/dissectors/packet-gtpv2.c2
-rw-r--r--epan/dissectors/packet-ieee1722.c1
-rw-r--r--epan/dissectors/packet-mac-lte.c13
-rw-r--r--epan/dissectors/packet-nas_eps.c6
-rw-r--r--epan/dissectors/packet-pdcp-lte.c13
-rw-r--r--epan/dissectors/packet-rrc.c2
-rw-r--r--epan/dissectors/packet-rsl.c1
-rw-r--r--epan/proto.c28
-rw-r--r--epan/proto.h6
13 files changed, 49 insertions, 40 deletions
diff --git a/epan/dissectors/asn1/rrc/rrc.cnf b/epan/dissectors/asn1/rrc/rrc.cnf
index 32bf9c9556..444db4e0d5 100644
--- a/epan/dissectors/asn1/rrc/rrc.cnf
+++ b/epan/dissectors/asn1/rrc/rrc.cnf
@@ -669,7 +669,7 @@ fp_info *fpinf ;
subtree = proto_item_add_subtree(actx->created_item, ett_rrc_ims_info);
proto_tree_add_item_ret_uint(subtree, hf_rrc_ims_info_atgw_trans_det_cont_type, imsInformation_tvb, curr_offset, 1, ENC_BIG_ENDIAN, &atgw_trans_det_cont);
curr_offset++;
- switch (atgw_trans_det_cont & 0x03) {
+ switch (atgw_trans_det_cont) {
case 0:
proto_tree_add_item(subtree, hf_rrc_ims_info_atgw_udp_port, imsInformation_tvb, curr_offset, 2, ENC_BIG_ENDIAN);
curr_offset+=2;
diff --git a/epan/dissectors/packet-enip.c b/epan/dissectors/packet-enip.c
index c4c9a266ee..f94418c352 100644
--- a/epan/dissectors/packet-enip.c
+++ b/epan/dissectors/packet-enip.c
@@ -2270,7 +2270,7 @@ dissect_cpf(enip_request_key_t *request_key, int command, tvbuff_t *tvb,
* it to the list of information structures later before dissection.
*/
request_key = wmem_new0(wmem_packet_scope(), enip_request_key_t);
- request_key->requesttype = (ucmm_request & 0x8000) ? ENIP_RESPONSE_PACKET : ENIP_REQUEST_PACKET;
+ request_key->requesttype = ucmm_request ? ENIP_RESPONSE_PACKET : ENIP_REQUEST_PACKET;
request_key->type = EPDT_UNKNOWN;
/* UCMM over UDP doesn't have a session handle, so use conversation
diff --git a/epan/dissectors/packet-gsm_abis_pgsl.c b/epan/dissectors/packet-gsm_abis_pgsl.c
index d6bf2fccd1..a9b8c9cf1d 100644
--- a/epan/dissectors/packet-gsm_abis_pgsl.c
+++ b/epan/dissectors/packet-gsm_abis_pgsl.c
@@ -137,7 +137,6 @@ dissect_abis_pgsl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
proto_tree_add_item(pgsl_tree, hf_pgsl_version, tvb, offset, 1, ENC_NA);
proto_tree_add_item_ret_uint(pgsl_tree, hf_pgsl_msg_disc, tvb, offset, 1, ENC_NA, &msg_disc);
- msg_disc &= 0xF;
offset++;
col_append_str(pinfo->cinfo, COL_INFO, val_to_str(msg_disc, pgsl_msg_disc_vals, "Unknown (%u)"));
@@ -187,7 +186,6 @@ dissect_abis_pgsl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat
/* Codec Status */
proto_tree_add_item(pgsl_tree, hf_pgsl_codec_delay, tvb, offset, 1, ENC_NA);
proto_tree_add_item_ret_uint(pgsl_tree, hf_pgsl_codec_cs, tvb, offset, 1, ENC_NA, &cs);
- cs &= 0x1f;
proto_tree_add_item(pgsl_tree, hf_pgsl_codec_rxlev, tvb, offset+1, 1, ENC_NA);
if (cs <= 4) {
/* GPRS */
diff --git a/epan/dissectors/packet-gsm_abis_tfp.c b/epan/dissectors/packet-gsm_abis_tfp.c
index 29e7895f28..1a6587d1c3 100644
--- a/epan/dissectors/packet-gsm_abis_tfp.c
+++ b/epan/dissectors/packet-gsm_abis_tfp.c
@@ -96,7 +96,7 @@ dissect_abis_tfp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
proto_item *ti;
proto_tree *tfp_tree;
int offset = 0;
- guint32 slot_rate, frame_bits, hdr2, atsr, seq_nr;
+ guint32 slot_rate, frame_bits, atsr, seq_nr;
guint8 ftype;
tvbuff_t *next_tvb;
@@ -105,12 +105,9 @@ dissect_abis_tfp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data
ti = proto_tree_add_item(tree, proto_abis_tfp, tvb, 0, -1, ENC_NA);
tfp_tree = proto_item_add_subtree(ti, ett_tfp);
- proto_tree_add_item_ret_uint(tfp_tree, hf_tfp_hdr_atsr, tvb, offset, 2, ENC_BIG_ENDIAN, &hdr2);
- proto_tree_add_item(tfp_tree, hf_tfp_hdr_slot_rate, tvb, offset, 2, ENC_BIG_ENDIAN);
- proto_tree_add_item(tfp_tree, hf_tfp_hdr_seq_nr, tvb, offset, 2, ENC_BIG_ENDIAN);
- atsr = hdr2 >> 13;
- slot_rate = (hdr2 >> 11) & 3;
- seq_nr = (hdr2 >> 6) & 0x1f;
+ proto_tree_add_item_ret_uint(tfp_tree, hf_tfp_hdr_atsr, tvb, offset, 2, ENC_BIG_ENDIAN, &atsr);
+ proto_tree_add_item_ret_uint(tfp_tree, hf_tfp_hdr_slot_rate, tvb, offset, 2, ENC_BIG_ENDIAN, &slot_rate);
+ proto_tree_add_item_ret_uint(tfp_tree, hf_tfp_hdr_seq_nr, tvb, offset, 2, ENC_BIG_ENDIAN, &seq_nr);
proto_tree_add_item(tfp_tree, hf_tfp_hdr_delay_info, tvb, offset+1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tfp_tree, hf_tfp_hdr_p, tvb, offset+1, 2, ENC_BIG_ENDIAN);
proto_tree_add_item(tfp_tree, hf_tfp_hdr_s, tvb, offset+2, 1, ENC_NA);
diff --git a/epan/dissectors/packet-gtpv2.c b/epan/dissectors/packet-gtpv2.c
index 867467fa8c..2a904453b0 100644
--- a/epan/dissectors/packet-gtpv2.c
+++ b/epan/dissectors/packet-gtpv2.c
@@ -3972,7 +3972,7 @@ dissect_gtpv2_mm_context_eps_qq(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tre
proto_tree_add_item(tree, hf_gtpv2_mm_context_old_kasme, tvb, offset, 32, ENC_NA);
offset += 32;
/* (s+33) to (s+64) old NH */
- if ((dword & 1) == 1) {
+ if (dword) {
proto_tree_add_item(tree, hf_gtpv2_mm_context_old_nh, tvb, offset, 32, ENC_NA);
offset += 32;
}
diff --git a/epan/dissectors/packet-ieee1722.c b/epan/dissectors/packet-ieee1722.c
index 9c5df24fe7..eda70313b7 100644
--- a/epan/dissectors/packet-ieee1722.c
+++ b/epan/dissectors/packet-ieee1722.c
@@ -1064,7 +1064,6 @@ static int dissect_1722_aaf (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree
{
proto_tree_add_item(ti_aaf_tree, hf_1722_aaf_nominal_sample_rate, tvb, offset, 2, ENC_BIG_ENDIAN);
ti_channels_per_frame = proto_tree_add_item_ret_uint(ti_aaf_tree, hf_1722_aaf_channels_per_frame, tvb, offset, 2, ENC_BIG_ENDIAN, &channels_per_frame);
- channels_per_frame &= IEEE_1722_CHANNEL_PER_FRAME_MASK;
if (channels_per_frame == 0)
{
expert_add_info(pinfo, ti_channels_per_frame, &ei_aaf_channels_per_frame);
diff --git a/epan/dissectors/packet-mac-lte.c b/epan/dissectors/packet-mac-lte.c
index b98e6ad4e9..07c709ce1b 100644
--- a/epan/dissectors/packet-mac-lte.c
+++ b/epan/dissectors/packet-mac-lte.c
@@ -4823,7 +4823,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
it = proto_tree_add_item_ret_uint(slbsr_tree, hf_mac_lte_control_sidelink_reserved,
tvb, curr_offset, 1, ENC_BIG_ENDIAN, &reserved);
- if (reserved & 0x0f) {
+ if (reserved) {
if (lcids[n] == SIDELINK_BSR) {
expert_add_info_format(pinfo, it, &ei_mac_lte_reserved_not_zero,
"Sidelink BSR Reserved bits not zero");
@@ -5517,7 +5517,7 @@ static void dissect_ulsch_or_dlsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree
dpr_tree = proto_item_add_subtree(dpr_ti, ett_mac_lte_data_vol_power_headroom);
dpr_ti = proto_tree_add_item_ret_uint(dpr_tree, hf_mac_lte_data_vol_power_headroom_reserved,
tvb, offset, 1, ENC_BIG_ENDIAN, &reserved);
- if (reserved & 0xc0) {
+ if (reserved) {
expert_add_info_format(pinfo, dpr_ti, &ei_mac_lte_reserved_not_zero,
"Data Volume and Power Headroom Report Reserved bits not zero");
}
@@ -6245,7 +6245,7 @@ static void dissect_slsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
ti = proto_tree_add_item_ret_uint(pdu_subheader_tree, hf_mac_lte_slsch_reserved,
tvb, offset, 1, ENC_BIG_ENDIAN, &reserved);
offset++;
- if (reserved & 0x0f) {
+ if (reserved) {
expert_add_info_format(pinfo, ti, &ei_mac_lte_reserved_not_zero,
"SL-SCH header Reserved bits not zero");
}
@@ -6274,8 +6274,9 @@ static void dissect_slsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
ett_mac_lte_slsch_subheader);
/* Check 1st 2 reserved bits */
- ti = proto_tree_add_item_ret_uint(pdu_subheader_tree, hf_mac_lte_slsch_reserved2,
- tvb, offset, 1, ENC_BIG_ENDIAN, &first_byte);
+ ti = proto_tree_add_item(pdu_subheader_tree, hf_mac_lte_slsch_reserved2,
+ tvb, offset, 1, ENC_BIG_ENDIAN);
+ first_byte = tvb_get_guint8(tvb, offset);
if ((first_byte & 0xc0) != 0) {
expert_add_info_format(pinfo, ti, &ei_mac_lte_reserved_not_zero,
"SL-SCH header Reserved bits not zero");
@@ -6333,7 +6334,7 @@ static void dissect_slsch(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
tvb, offset, 1, ENC_BIG_ENDIAN, &format);
/* Now read length field itself */
- if (format & 0x80) {
+ if (format) {
/* >= 128 - use 15 bits */
proto_tree_add_bits_ret_val(pdu_subheader_tree, hf_mac_lte_slsch_length,
tvb, offset*8 + 1, 15, &length, ENC_BIG_ENDIAN);
diff --git a/epan/dissectors/packet-nas_eps.c b/epan/dissectors/packet-nas_eps.c
index b8cad8e2f1..abd1d8ea2d 100644
--- a/epan/dissectors/packet-nas_eps.c
+++ b/epan/dissectors/packet-nas_eps.c
@@ -2977,7 +2977,7 @@ de_esm_remote_ue_context_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinf
curr_offset ++;
proto_tree_add_item(subtree, hf_nas_eps_esm_remote_ue_context_list_ue_context_odd_even_indic, tvb, curr_offset, 1, ENC_BIG_ENDIAN);
proto_tree_add_item_ret_uint(subtree, hf_nas_eps_esm_remote_ue_context_list_ue_context_user_id_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &user_id_type);
- switch (user_id_type & 0x07) {
+ switch (user_id_type) {
case 1:
proto_tree_add_bits_item(subtree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 4, ENC_BIG_ENDIAN);
curr_offset++;
@@ -3017,7 +3017,7 @@ de_esm_remote_ue_context_list(tvbuff_t *tvb, proto_tree *tree, packet_info *pinf
proto_tree_add_bits_item(subtree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 5, ENC_BIG_ENDIAN);
proto_tree_add_item_ret_uint(subtree, hf_nas_eps_esm_remote_ue_context_list_ue_context_address_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &remote_address_type);
curr_offset++;
- switch (remote_address_type & 0x07) {
+ switch (remote_address_type) {
case 1:
proto_tree_add_item(subtree, hf_nas_eps_esm_remote_ue_context_list_ue_context_ipv4, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
curr_offset += 4;
@@ -3055,7 +3055,7 @@ de_esm_pkmf_address(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo _U_,
proto_tree_add_bits_item(tree, hf_nas_eps_spare_bits, tvb, curr_offset<<3, 5, ENC_BIG_ENDIAN);
proto_tree_add_item_ret_uint(tree, hf_nas_eps_esm_pkmf_address_type, tvb, curr_offset, 1, ENC_BIG_ENDIAN, &pkmf_address_type);
curr_offset++;
- switch (pkmf_address_type & 0x07) {
+ switch (pkmf_address_type) {
case 1:
proto_tree_add_item(tree, hf_nas_eps_esm_pkmf_ipv4, tvb, curr_offset, 4, ENC_BIG_ENDIAN);
break;
diff --git a/epan/dissectors/packet-pdcp-lte.c b/epan/dissectors/packet-pdcp-lte.c
index b98316aac8..f824a88ad7 100644
--- a/epan/dissectors/packet-pdcp-lte.c
+++ b/epan/dissectors/packet-pdcp-lte.c
@@ -2063,7 +2063,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* First-Missing-Sequence SN */
proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_fms, tvb,
offset, 2, ENC_BIG_ENDIAN, &fms);
- fms &= 0x0fff;
offset += 2;
/* HRW */
@@ -2074,7 +2073,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* NMP */
proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_nmp, tvb,
offset, 2, ENC_BIG_ENDIAN, &nmp);
- nmp &= 0x0fff;
offset += 2;
} else if (p_pdcp_info->seqnum_length == PDCP_SN_LENGTH_15_BITS) {
proto_item *ti;
@@ -2083,7 +2081,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* 5 reserved bits */
ti = proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_reserved4, tvb,
offset, 2, ENC_BIG_ENDIAN, &reserved_value);
- reserved_value = (reserved_value & 0x0f80) >> 7;
offset++;
/* Complain if not 0 */
if (reserved_value != 0) {
@@ -2095,14 +2092,13 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* First-Missing-Sequence SN */
proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_fms2, tvb,
offset, 2, ENC_BIG_ENDIAN, &fms);
- fms &= 0x7fff;
offset += 2;
/* 1 reserved bit */
ti = proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_reserved7, tvb,
offset, 1, ENC_BIG_ENDIAN, &reserved_value);
/* Complain if not 0 */
- if (reserved_value & 0x80) {
+ if (reserved_value) {
expert_add_info_format(pinfo, ti, &ei_pdcp_lte_reserved_bits_not_zero,
"Reserved bits have value 0x1 - should be 0x0");
}
@@ -2116,7 +2112,7 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
ti = proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_reserved7, tvb,
offset, 1, ENC_BIG_ENDIAN, &reserved_value);
/* Complain if not 0 */
- if (reserved_value & 0x80) {
+ if (reserved_value) {
expert_add_info_format(pinfo, ti, &ei_pdcp_lte_reserved_bits_not_zero,
"Reserved bits have value 0x1 - should be 0x0");
}
@@ -2124,7 +2120,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* NMP */
proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_nmp2, tvb,
offset, 2, ENC_BIG_ENDIAN, &nmp);
- nmp &= 0x7fff;
offset += 2;
} else {
proto_item *ti;
@@ -2133,7 +2128,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* 2 reserved bits */
ti = proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_reserved6,
tvb, offset, 1, ENC_BIG_ENDIAN, &reserved_value);
- reserved_value = (reserved_value & 0x0c) >> 2;
/* Complain if not 0 */
if (reserved_value != 0) {
expert_add_info_format(pinfo, ti, &ei_pdcp_lte_reserved_bits_not_zero,
@@ -2144,7 +2138,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* First-Missing-Sequence SN */
proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_fms3, tvb,
offset, 3, ENC_BIG_ENDIAN, &fms);
- fms &= 0x03ffff;
offset += 3;
/* HRW */
@@ -2155,7 +2148,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* 4 reserved bits */
ti = proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_reserved8,
tvb, offset, 1, ENC_BIG_ENDIAN, &reserved_value);
- reserved_value = (reserved_value & 0x3c) >> 2;
/* Complain if not 0 */
if (reserved_value != 0) {
expert_add_info_format(pinfo, ti, &ei_pdcp_lte_reserved_bits_not_zero,
@@ -2166,7 +2158,6 @@ static int dissect_pdcp_lte(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
/* NMP */
proto_tree_add_item_ret_uint(pdcp_tree, hf_pdcp_lte_nmp3, tvb,
offset, 3, ENC_BIG_ENDIAN, &nmp);
- nmp &= 0x03ffff;
offset += 3;
}
diff --git a/epan/dissectors/packet-rrc.c b/epan/dissectors/packet-rrc.c
index 16a449ad54..783e56d7aa 100644
--- a/epan/dissectors/packet-rrc.c
+++ b/epan/dissectors/packet-rrc.c
@@ -96604,7 +96604,7 @@ dissect_rrc_T_ims_Information(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *act
subtree = proto_item_add_subtree(actx->created_item, ett_rrc_ims_info);
proto_tree_add_item_ret_uint(subtree, hf_rrc_ims_info_atgw_trans_det_cont_type, imsInformation_tvb, curr_offset, 1, ENC_BIG_ENDIAN, &atgw_trans_det_cont);
curr_offset++;
- switch (atgw_trans_det_cont & 0x03) {
+ switch (atgw_trans_det_cont) {
case 0:
proto_tree_add_item(subtree, hf_rrc_ims_info_atgw_udp_port, imsInformation_tvb, curr_offset, 2, ENC_BIG_ENDIAN);
curr_offset+=2;
diff --git a/epan/dissectors/packet-rsl.c b/epan/dissectors/packet-rsl.c
index 8598b98d1c..3d7895ab11 100644
--- a/epan/dissectors/packet-rsl.c
+++ b/epan/dissectors/packet-rsl.c
@@ -3125,7 +3125,6 @@ dissct_rsl_ipaccess_msg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
case RSL_IE_IPAC_SPEECH_MODE:
proto_tree_add_item_ret_uint(ie_tree, hf_rsl_speech_mode_s, tvb,
offset, len, ENC_BIG_ENDIAN, &rtp_codec);
- rtp_codec &= 0x0f;
conv = find_or_create_conversation(pinfo);
dyn_pl_info = (struct dyn_pl_info_t *)conversation_get_proto_data(conv, proto_rsl);
if (!dyn_pl_info) {
diff --git a/epan/proto.c b/epan/proto.c
index d610e08a5f..dfbff4bc34 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -2324,8 +2324,18 @@ proto_tree_add_item_ret_int(proto_tree *tree, int hfindex, tvbuff_t *tvb,
/* I believe it's ok if this is called with a NULL tree */
value = get_int_value(tree, tvb, start, length, encoding);
- if (retval)
+ if (retval) {
+ gint no_of_bits;
*retval = value;
+ if (hfinfo->bitmask) {
+ /* Mask out irrelevant portions */
+ *retval &= (guint32)(hfinfo->bitmask);
+ /* Shift bits */
+ *retval >>= hfinfo_bitshift(hfinfo);
+ }
+ no_of_bits = ws_count_ones(hfinfo->bitmask);
+ *retval = ws_sign_ext32(*retval, no_of_bits);
+ }
CHECK_FOR_NULL_TREE(tree);
@@ -2376,8 +2386,15 @@ proto_tree_add_item_ret_uint(proto_tree *tree, int hfindex, tvbuff_t *tvb,
/* XXX - modify if we ever support EBCDIC FT_CHAR */
value = get_uint_value(tree, tvb, start, length, encoding);
- if (retval)
+ if (retval) {
*retval = value;
+ if (hfinfo->bitmask) {
+ /* Mask out irrelevant portions */
+ *retval &= (guint32)(hfinfo->bitmask);
+ /* Shift bits */
+ *retval >>= hfinfo_bitshift(hfinfo);
+ }
+ }
CHECK_FOR_NULL_TREE(tree);
@@ -9531,6 +9548,13 @@ proto_tree_add_bitmask_with_flags_ret_uint64(proto_tree *parent_tree, tvbuff_t *
}
*retval = value;
+ if (hf->bitmask) {
+ /* Mask out irrelevant portions */
+ *retval &= hf->bitmask;
+ /* Shift bits */
+ *retval >>= hfinfo_bitshift(hf);
+ }
+
return item;
}
diff --git a/epan/proto.h b/epan/proto.h
index 18d8161265..f1f998709f 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1055,7 +1055,7 @@ Integers of 8, 16, 24 and 32 bits can be retrieved with these functions.
@param length length of data in tvb (for strings can be -1 for remaining)
@param encoding data encoding (e.g, ENC_LITTLE_ENDIAN, ENC_BIG_ENDIAN, ENC_ASCII|ENC_STRING, etc.)
@param[out] retval points to a gint32 or guint32 which will be set to the value
-@return the newly created item, and *retval is set to the decoded value
+@return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask
*/
WS_DLL_PUBLIC proto_item *
proto_tree_add_item_ret_int(proto_tree *tree, int hfindex, tvbuff_t *tvb,
@@ -2461,7 +2461,7 @@ proto_tree_add_bitmask(proto_tree *tree, tvbuff_t *tvb, const guint offset,
matched string displayed on the expansion line.
@param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
@param[out] retval points to a guint64 which will be set
- @return the newly created item, and *retval is set to the decoded value
+ @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask
*/
WS_DLL_PUBLIC proto_item *
proto_tree_add_bitmask_ret_uint64(proto_tree *tree, tvbuff_t *tvb, const guint offset,
@@ -2520,7 +2520,7 @@ proto_tree_add_bitmask_with_flags(proto_tree *tree, tvbuff_t *tvb, const guint o
@param encoding big or little endian byte representation (ENC_BIG_ENDIAN/ENC_LITTLE_ENDIAN/ENC_HOST_ENDIAN)
@param flags bitmask field using BMT_NO_* flags to determine behavior
@param[out] retval points to a guint64 which will be set
- @return the newly created item, and *retval is set to the decoded value
+ @return the newly created item, and *retval is set to the decoded value masked/shifted according to bitmask
*/
WS_DLL_PUBLIC proto_item *
proto_tree_add_bitmask_with_flags_ret_uint64(proto_tree *tree, tvbuff_t *tvb, const guint offset,