diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-04-09 23:06:47 -0700 |
---|---|---|
committer | Anders Broman <a.broman58@gmail.com> | 2018-04-10 14:55:45 +0000 |
commit | c7970d9356a494d847101c2bd92e4ca97a7d3d58 (patch) | |
tree | e894b469ecc2c26563fbce3a9512af9bad66c594 /epan/dissectors/packet-lldp.c | |
parent | 2cb93e2121eea20c1e443558d7175f1cab8e1f70 (diff) |
Add, and use, "fetch signed value" for lengths < 40 bits.
Add 8-bit, 16-bit, 24-bit, and 32-bit "fetch signed value" routines, and
use them rather than casting the result of the 8/16/24/32-bit "fetch
unsigned value" routines to a signed type (which, BTW, isn't sufficient
for 24-bit values, so this appears to fix a bug
in epan/dissectors/packet-zbee-zcl.c).
Use numbers rather than sizeof()s in various tvb_get_ routines.
Change-Id: I0e48a57fac9f70fe42de815c3fa915f1592548bd
Reviewed-on: https://code.wireshark.org/review/26844
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'epan/dissectors/packet-lldp.c')
-rw-r--r-- | epan/dissectors/packet-lldp.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/epan/dissectors/packet-lldp.c b/epan/dissectors/packet-lldp.c index d6edfdd97a..ba2e0e6683 100644 --- a/epan/dissectors/packet-lldp.c +++ b/epan/dissectors/packet-lldp.c @@ -3417,7 +3417,7 @@ dissect_hytec_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint case HYTEC_MD__TX_CURRENT_OUTPUT_POWER: if(msg_len == expected_data_length) { - temp_gint32 = (gint32) tvb_get_ntohl(tvb, offset); + temp_gint32 = tvb_get_ntohil(tvb, offset); float_value = (float) 0.1 * (float) temp_gint32; proto_tree_add_float(tree, hf_hytec_tx_current_output_power, tvb, offset, msg_len, float_value); } @@ -3430,7 +3430,7 @@ dissect_hytec_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint case HYTEC_MD__RX_CURRENT_INPUT_POWER: if(msg_len == expected_data_length) { - temp_gint32 = (gint32) tvb_get_ntohl(tvb, offset); + temp_gint32 = tvb_get_ntohil(tvb, offset); float_value = (float) 0.1 * (float) temp_gint32; proto_tree_add_float(tree, hf_hytec_rx_current_input_power, tvb, offset, msg_len, float_value); } @@ -3443,7 +3443,7 @@ dissect_hytec_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint case HYTEC_MD__RX_INPUT_SNR: if(msg_len == expected_data_length) { - temp_gint32 = (gint32) tvb_get_ntohl(tvb, offset); + temp_gint32 = tvb_get_ntohil(tvb, offset); if(temp_gint32 < 0) float_value = (float)-1.0 * (float)((~temp_gint32) >> 8); else float_value = (float) (temp_gint32 >> 8); float_value += (float)(temp_gint32 & 0xFF) * (float)0.00390625; /* 0.00390625 == 0.5 ^ 8 */ @@ -3458,7 +3458,7 @@ dissect_hytec_tlv(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, guint case HYTEC_MD__LINELOSS: if(msg_len == expected_data_length) { - temp_gint32 = (gint32) tvb_get_ntohl(tvb, offset); + temp_gint32 = tvb_get_ntohil(tvb, offset); if(temp_gint32 < 0) float_value = (float)-1.0 * (float)((~temp_gint32) >> 8); else float_value = (float) (temp_gint32 >> 8); float_value += (float)(temp_gint32 & 0xFF) * (float)0.00390625; /* 0.5 ^ 8 */ |