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 | |
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')
23 files changed, 81 insertions, 82 deletions
diff --git a/epan/dissectors/packet-amqp.c b/epan/dissectors/packet-amqp.c index 255baba26b..a627da165c 100644 --- a/epan/dissectors/packet-amqp.c +++ b/epan/dissectors/packet-amqp.c @@ -2408,7 +2408,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 4) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%" G_GINT32_MODIFIER "i", - (gint32)tvb_get_ntohl(tvb, offset)); + tvb_get_ntohil(tvb, offset)); offset += 4; break; case 'D': @@ -2474,7 +2474,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 1) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%d", - (gint8)tvb_get_guint8(tvb, offset)); + tvb_get_gint8(tvb, offset)); offset += 1; break; case 'B': /* unsigned 8-bit */ @@ -2490,7 +2490,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 2) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%" G_GINT16_MODIFIER "i", - (gint16)tvb_get_ntohs(tvb, offset)); + tvb_get_ntohis(tvb, offset)); offset += 2; break; case 'u': /* unsigned 16-bit */ @@ -2514,7 +2514,7 @@ dissect_amqp_0_9_field_value(tvbuff_t *tvb, packet_info *pinfo, int offset, guin if (length < 8) return 0; /* too short */ value = wmem_strdup_printf(wmem_packet_scope(), "%" G_GINT64_MODIFIER "i", - (gint64)tvb_get_ntoh64(tvb, offset)); + tvb_get_ntohi64(tvb, offset)); offset += 8; break; case 'f': /* 32-bit float */ @@ -10348,13 +10348,13 @@ format_amqp_1_0_int(tvbuff_t *tvb, gint64 val; if (length == 1) - val = (gint8)tvb_get_guint8(tvb, offset); + val = tvb_get_gint8(tvb, offset); else if (length == 2) - val = (gint16)tvb_get_ntohs(tvb, offset); + val = tvb_get_ntohis(tvb, offset); else if (length == 4) - val = (gint32)tvb_get_ntohl(tvb, offset); + val = tvb_get_ntohil(tvb, offset); else if (length == 8) - val = (gint64)tvb_get_ntoh64(tvb, offset); + val = tvb_get_ntohi64(tvb, offset); else { *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid int length %d!", length); return length; @@ -10529,11 +10529,11 @@ format_amqp_0_10_int(tvbuff_t *tvb, int val; if (length == 1) - val = (gint8)tvb_get_guint8(tvb, offset); + val = tvb_get_gint8(tvb, offset); else if (length == 2) - val = (gint16)tvb_get_ntohs(tvb, offset); + val = tvb_get_ntohis(tvb, offset); else if (length == 4) - val = (gint32)tvb_get_ntohl(tvb, offset); + val = tvb_get_ntohil(tvb, offset); else { *value = wmem_strdup_printf(wmem_packet_scope(), "Invalid int length %d!", length); return length; diff --git a/epan/dissectors/packet-bacapp.c b/epan/dissectors/packet-bacapp.c index 133783b65b..f2ae18d8e3 100644 --- a/epan/dissectors/packet-bacapp.c +++ b/epan/dissectors/packet-bacapp.c @@ -13520,15 +13520,15 @@ fStartConfirmed(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *bacapp_tree, guint extra = 2; bacapp_seq = 0; - tmp = (gint) tvb_get_guint8(tvb, offset); + tmp = tvb_get_gint8(tvb, offset); bacapp_flags = tmp & 0x0f; if (ack == 0) { extra = 3; } - *svc = (gint) tvb_get_guint8(tvb, offset+extra); + *svc = tvb_get_gint8(tvb, offset+extra); if (bacapp_flags & 0x08) - *svc = (gint) tvb_get_guint8(tvb, offset+extra+2); + *svc = tvb_get_gint8(tvb, offset+extra+2); proto_tree_add_item(bacapp_tree, hf_bacapp_type, tvb, offset, 1, ENC_BIG_ENDIAN); tc = proto_tree_add_item(bacapp_tree, hf_bacapp_pduflags, tvb, offset, 1, ENC_BIG_ENDIAN); @@ -13896,7 +13896,7 @@ do_the_dissection(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) guint8 flag, bacapp_type; guint offset = 0; - flag = (gint) tvb_get_guint8(tvb, 0); + flag = tvb_get_gint8(tvb, 0); bacapp_type = (flag >> 4) & 0x0f; if (tvb == NULL) { diff --git a/epan/dissectors/packet-bootp.c b/epan/dissectors/packet-bootp.c index 2bc1f50dba..616df09ad0 100644 --- a/epan/dissectors/packet-bootp.c +++ b/epan/dissectors/packet-bootp.c @@ -1741,7 +1741,7 @@ bootp_handle_basic_types(packet_info *pinfo, proto_tree *tree, proto_item *item, } if (hf != NULL) { - time_s_secs = (gint32) tvb_get_ntohl(tvb, offset); + time_s_secs = tvb_get_ntohil(tvb, offset); proto_tree_add_int_format_value(tree, *hf, tvb, offset, 4, time_s_secs, "(%ds) %s", time_s_secs, signed_time_secs_to_str(wmem_packet_scope(), time_s_secs)); } diff --git a/epan/dissectors/packet-btatt.c b/epan/dissectors/packet-btatt.c index fc49b5c6fa..3edcb2628c 100644 --- a/epan/dissectors/packet-btatt.c +++ b/epan/dissectors/packet-btatt.c @@ -10512,9 +10512,9 @@ dissect_btgatt_microbit_accelerometer_data(tvbuff_t *tvb, packet_info *pinfo _U_ if (bluetooth_gatt_has_no_parameter(att_data->opcode)) return -1; - x_axis = (gdouble) (gint16) tvb_get_guint16(tvb, offset, ENC_LITTLE_ENDIAN) / 1000.0; - y_axis = (gdouble) (gint16) tvb_get_guint16(tvb, offset+2, ENC_LITTLE_ENDIAN) / 1000.0; - z_axis = (gdouble) (gint16) tvb_get_guint16(tvb, offset+4, ENC_LITTLE_ENDIAN) / 1000.0; + x_axis = (gdouble) tvb_get_gint16(tvb, offset, ENC_LITTLE_ENDIAN) / 1000.0; + y_axis = (gdouble) tvb_get_gint16(tvb, offset+2, ENC_LITTLE_ENDIAN) / 1000.0; + z_axis = (gdouble) tvb_get_gint16(tvb, offset+4, ENC_LITTLE_ENDIAN) / 1000.0; sub_item = proto_tree_add_item(tree, hf_gatt_microbit_accelerometer_data, tvb, 0, tvb_captured_length(tvb), ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_btgatt_microbit_accelerometer); @@ -10557,9 +10557,9 @@ dissect_btgatt_microbit_magnetometer_data(tvbuff_t *tvb, packet_info *pinfo _U_, if (bluetooth_gatt_has_no_parameter(att_data->opcode)) return -1; - x_axis = (gdouble) (gint16) tvb_get_guint16(tvb, offset, ENC_LITTLE_ENDIAN) / 1000.0; - y_axis = (gdouble) (gint16) tvb_get_guint16(tvb, offset+2, ENC_LITTLE_ENDIAN) / 1000.0; - z_axis = (gdouble) (gint16) tvb_get_guint16(tvb, offset+4, ENC_LITTLE_ENDIAN) / 1000.0; + x_axis = (gdouble) tvb_get_gint16(tvb, offset, ENC_LITTLE_ENDIAN) / 1000.0; + y_axis = (gdouble) tvb_get_gint16(tvb, offset+2, ENC_LITTLE_ENDIAN) / 1000.0; + z_axis = (gdouble) tvb_get_gint16(tvb, offset+4, ENC_LITTLE_ENDIAN) / 1000.0; sub_item = proto_tree_add_item(tree, hf_gatt_microbit_magnetometer_data, tvb, 0, tvb_captured_length(tvb), ENC_NA); sub_tree = proto_item_add_subtree(sub_item, ett_btgatt_microbit_magnetometer); diff --git a/epan/dissectors/packet-btbredr_rf.c b/epan/dissectors/packet-btbredr_rf.c index 65a2e8dc83..ecf236010e 100644 --- a/epan/dissectors/packet-btbredr_rf.c +++ b/epan/dissectors/packet-btbredr_rf.c @@ -548,13 +548,13 @@ dissect_btbredr_rf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da if ((flags & (FLAGS_SIGNAL_POWER_VALID | FLAGS_NOISE_POWER_VALID)) == (FLAGS_SIGNAL_POWER_VALID | FLAGS_NOISE_POWER_VALID)) { col_append_fstr(pinfo->cinfo, COL_INFO, " (SP: %4i, NP: %4i)", - (gint)(gint8)tvb_get_guint8(tvb, 1), (gint)(gint8)tvb_get_guint8(tvb, 2)); + (gint)tvb_get_gint8(tvb, 1), (gint)tvb_get_gint8(tvb, 2)); } else if (flags & FLAGS_SIGNAL_POWER_VALID) { col_append_fstr(pinfo->cinfo, COL_INFO, " (SP: %4i)", - (gint)(gint8)tvb_get_guint8(tvb, 1)); + (gint)tvb_get_gint8(tvb, 1)); } else if (flags & FLAGS_NOISE_POWER_VALID) { col_append_fstr(pinfo->cinfo, COL_INFO, " (NP: %4i)", - (gint)(gint8)tvb_get_guint8(tvb, 2)); + (gint)tvb_get_gint8(tvb, 2)); } if (flags & FLAGS_PACKET_HEADER_AND_BR_EDR_PAYLOAD_DEWHITENED) diff --git a/epan/dissectors/packet-ceph.c b/epan/dissectors/packet-ceph.c index 4b10fa0c14..b360ce8790 100644 --- a/epan/dissectors/packet-ceph.c +++ b/epan/dissectors/packet-ceph.c @@ -2355,7 +2355,7 @@ guint c_dissect_object_locator(proto_tree *root, gint hf, off = c_dissect_encoded(tree, &enchdr, 3, 6, tvb, off, data); proto_item_append_text(ti, ", Pool: %"G_GINT64_MODIFIER"d", - (gint64)tvb_get_letoh64(tvb, off)); + tvb_get_letohi64(tvb, off)); proto_tree_add_item(tree, hf_pool, tvb, off, 8, ENC_LITTLE_ENDIAN); off += 8; diff --git a/epan/dissectors/packet-cp2179.c b/epan/dissectors/packet-cp2179.c index 5c4c717636..f5ecddc608 100644 --- a/epan/dissectors/packet-cp2179.c +++ b/epan/dissectors/packet-cp2179.c @@ -604,7 +604,7 @@ dissect_bs_response_frame(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, i /*Report the values of the requested SCAN inclusive data. To figure out which sequence ID the values in the response associated with, we read the bs_request_frame information and show the corresponding sequence ID of the data in response frame.*/ do{ - analogtestvalue = (gint16)tvb_get_letohs(tvb, offset); + analogtestvalue = tvb_get_letohis(tvb, offset); proto_tree_add_uint_format(cp2179_data_tree, hf_cp2179_analog_16bit, tvb, offset, 2, request_data->requested_points[point_num], "Analog (16 bit) %u : %i", request_data->requested_points[point_num], analogtestvalue); point_num += 1; @@ -638,7 +638,7 @@ dissect_bs_response_frame(tvbuff_t *tvb, proto_tree *tree, packet_info *pinfo, i case ANALOG_16_BIT: do{ - analogtestvalue =(gint16)tvb_get_letohs(tvb, offset); + analogtestvalue = tvb_get_letohis(tvb, offset); proto_tree_add_uint_format(cp2179_data_tree, hf_cp2179_analog_16bit, tvb, offset, 2, analog16_num, "Analog (16 bit) %u : %i", analog16_num, analogtestvalue); analog16_num += 1; diff --git a/epan/dissectors/packet-dns.c b/epan/dissectors/packet-dns.c index e2d869d752..735db5003f 100644 --- a/epan/dissectors/packet-dns.c +++ b/epan/dissectors/packet-dns.c @@ -2440,7 +2440,7 @@ dissect_dns_answer(tvbuff_t *tvb, int offsetx, int dns_data_offset, cur_offset += 4; ti = proto_tree_add_item(rr_tree, hf_dns_loc_altitude, tvb, cur_offset, 4, ENC_BIG_ENDIAN); - proto_item_append_text(ti, " (%g m)", ((gint32)tvb_get_ntohl(tvb, cur_offset) - 10000000)/100.0); + proto_item_append_text(ti, " (%g m)", (tvb_get_ntohil(tvb, cur_offset) - 10000000)/100.0); } else { proto_tree_add_item(rr_tree, hf_dns_loc_unknown_data, tvb, cur_offset, data_len, ENC_NA); } diff --git a/epan/dissectors/packet-ecmp.c b/epan/dissectors/packet-ecmp.c index 41b5ad9894..235e0eb496 100644 --- a/epan/dissectors/packet-ecmp.c +++ b/epan/dissectors/packet-ecmp.c @@ -1494,7 +1494,7 @@ static void get_parameter_definitions(packet_info* pinfo, int offset, guint8 com data_type = tvb_get_guint8(tvb, offset); proto_tree_add_item(ecmp_parameter_tree, hf_ecmp_data_type, tvb, offset, 1, ENC_BIG_ENDIAN); offset++; - dec = (gint8)tvb_get_guint8(tvb, offset); + dec = tvb_get_gint8(tvb, offset); if (dec != -1) { proto_tree_add_int(ecmp_parameter_tree, hf_ecmp_number_of_decimal_places, tvb, offset, 1, dec); } else { @@ -1695,7 +1695,7 @@ static int get_parameter_responses(packet_info* pinfo, int offset, guint8 comman offset = get_address_scheme(pinfo, offset, scheme, tvb, ecmp_parameter_response_tree); } else { /*if status is error */ - if ((gint8)tvb_get_guint8(tvb, offset+1) < 0) { + if (tvb_get_gint8(tvb, offset+1) < 0) { /*output status*/ st_error = 1; offset++; @@ -1727,7 +1727,7 @@ static int get_parameter_responses(packet_info* pinfo, int offset, guint8 comman if ((command_value == ECMP_COMMAND_READWITHTYPE) && (st_error!= 1)) { offset++; /*display decimal places*/ - dec = (gint8)tvb_get_guint8(tvb, offset); + dec = tvb_get_gint8(tvb, offset); if (dec != -1) { proto_tree_add_int(ecmp_parameter_response_tree, hf_ecmp_number_of_decimal_places, tvb, offset, 1, dec); } else { @@ -1804,7 +1804,7 @@ static void file_open(int offset, gboolean request, tvbuff_t *tvb, proto_tree* e /*display file status*/ proto_tree_add_item(ecmp_tree, hf_ecmp_file_status, tvb, offset, 1, ENC_BIG_ENDIAN); - if ((gint8)tvb_get_guint8(tvb, offset) >= 0) { + if (tvb_get_gint8(tvb, offset) >= 0) { offset++; /*display file handle*/ proto_tree_add_item(ecmp_tree, hf_ecmp_file_handle, tvb, offset, 2, ENC_BIG_ENDIAN); @@ -1830,7 +1830,7 @@ static void file_read(int offset, gboolean request, tvbuff_t *tvb, proto_tree* e /*display file status*/ proto_tree_add_item(ecmp_tree, hf_ecmp_file_status, tvb, offset, 1, ENC_BIG_ENDIAN); - if ((gint8)tvb_get_guint8(tvb, offset)>= 0) { + if (tvb_get_gint8(tvb, offset)>= 0) { offset++; /*display bytes for reading*/ @@ -2036,7 +2036,7 @@ static void file_pos(int offset, gboolean request, tvbuff_t *tvb, proto_tree* ec /*display file status*/ proto_tree_add_item(ecmp_tree, hf_ecmp_file_status, tvb, offset, 1, ENC_BIG_ENDIAN); - if((gint8)tvb_get_guint8(tvb,offset) >= 0) { + if(tvb_get_gint8(tvb,offset) >= 0) { offset++; /*display offset from ref point*/ @@ -2069,7 +2069,7 @@ static void file_list(packet_info* pinfo, int offset, gboolean request, tvbuff_t /*display file status*/ proto_tree_add_item(ecmp_tree, hf_ecmp_file_status, tvb, offset, 1, ENC_BIG_ENDIAN); - if ((gint8)tvb_get_guint8(tvb,offset) >= 0) { + if (tvb_get_gint8(tvb,offset) >= 0) { offset++; /*display number of files to list*/ @@ -2952,7 +2952,7 @@ static int dissect_ecmp_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint8 chunk_id_value = 0; gint8 status_value = 0; - status_value = (gint8)tvb_get_guint8(tvb, offset); /*stores a signed value for status */ + status_value = tvb_get_gint8(tvb, offset); /*stores a signed value for status */ proto_tree_add_item(ecmp_tree, hf_ecmp_status, tvb, offset, 1, ENC_BIG_ENDIAN); diff --git a/epan/dissectors/packet-iec104.c b/epan/dissectors/packet-iec104.c index 65c784e9cf..2248173bf1 100644 --- a/epan/dissectors/packet-iec104.c +++ b/epan/dissectors/packet-iec104.c @@ -1,7 +1,6 @@ /* packet-iec104.c * Routines for IEC-60870-5-104 (iec104) Protocol disassembly * - * * Copyright (c) 2008 by Joan Ramio <joan@ramio.cat> * Joan is a masculine catalan name. Search the Internet for Joan Pujol (alias Garbo). * @@ -884,7 +883,7 @@ static void get_NVA(tvbuff_t *tvb, guint8 *offset, proto_tree *iec104_header_tre gint16 value; float fvalue; - value = (gint16)tvb_get_letohs(tvb, *offset); + value = tvb_get_letohis(tvb, *offset); fvalue = (float)value / 32768; /* Normalized value F16[1..16]<-1..+1-2^-15> */ @@ -898,7 +897,7 @@ static void get_NVAspt(tvbuff_t *tvb, guint8 *offset, proto_tree *iec104_header_ gint16 value; float fvalue; - value = (gint16)tvb_get_letohs(tvb, *offset); + value = tvb_get_letohis(tvb, *offset); fvalue = (float)value / 32768; /* Normalized value F16[1..16]<-1..+1-2^-15> */ diff --git a/epan/dissectors/packet-ieee80211-radiotap.c b/epan/dissectors/packet-ieee80211-radiotap.c index 4745e0bf1c..b2f40fc543 100644 --- a/epan/dissectors/packet-ieee80211-radiotap.c +++ b/epan/dissectors/packet-ieee80211-radiotap.c @@ -1528,7 +1528,7 @@ dissect_radiotap_dbm_antsignal(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, struct _radiotap_info *radiotap_info, struct ieee_802_11_phdr *phdr) { - gint8 dbm = (gint8)tvb_get_guint8(tvb, offset); + gint8 dbm = tvb_get_gint8(tvb, offset); phdr->has_signal_dbm = TRUE; phdr->signal_dbm = dbm; @@ -1543,7 +1543,7 @@ dissect_radiotap_dbm_antnoise(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, int offset, struct _radiotap_info *radiotap_info, struct ieee_802_11_phdr *phdr) { - gint dbm = (gint8) tvb_get_guint8(tvb, offset); + gint dbm = tvb_get_gint8(tvb, offset); phdr->has_noise_dbm = TRUE; phdr->noise_dbm = dbm; diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c index 1a1f53add8..d947764de5 100644 --- a/epan/dissectors/packet-ieee80211.c +++ b/epan/dissectors/packet-ieee80211.c @@ -6109,7 +6109,7 @@ add_mimo_compressed_beamforming_feedback_report(proto_tree *tree, tvbuff_t *tvb, gint8 snr; char edge_sign; - snr = (gint8) tvb_get_guint8(tvb, offset); + snr = tvb_get_gint8(tvb, offset); switch(snr) { case -128: @@ -10347,7 +10347,7 @@ add_ff_vht_compressed_beamforming_report(proto_tree *tree, tvbuff_t *tvb, packet gint8 snr; char edge_sign; - snr = (gint8) tvb_get_guint8(tvb, offset); + snr = tvb_get_gint8(tvb, offset); switch(snr) { case -128: @@ -16462,11 +16462,11 @@ ieee80211_tag_power_capability(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tr } proto_tree_add_item(tree, hf_ieee80211_tag_power_capability_min, tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_item_append_text(field_data->item_tag, " Min: %d", (gint8)tvb_get_guint8(tvb, offset)); + proto_item_append_text(field_data->item_tag, " Min: %d", tvb_get_gint8(tvb, offset)); offset += 1; proto_tree_add_item(tree, hf_ieee80211_tag_power_capability_max, tvb, offset, 1, ENC_LITTLE_ENDIAN); - proto_item_append_text(field_data->item_tag, ", Max: %d", (gint8)tvb_get_guint8(tvb, offset)); + proto_item_append_text(field_data->item_tag, ", Max: %d", tvb_get_gint8(tvb, offset)); return tvb_captured_length(tvb); } diff --git a/epan/dissectors/packet-ixveriwave.c b/epan/dissectors/packet-ixveriwave.c index 0262deefd1..8534891351 100644 --- a/epan/dissectors/packet-ixveriwave.c +++ b/epan/dissectors/packet-ixveriwave.c @@ -1075,7 +1075,7 @@ dissect_ixveriwave(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* da noisevalidd = tvb_get_guint8(tvb, offset+71)& 0x01; /* - noisea = (gint16) tvb_get_ntohs(tvb, offset); + noisea = tvb_get_ntohis(tvb, offset); //noisevalida = tvb_get_guint8(tvb, offset+65)& 0x01; if (noisevalida == 1) rf_infot = proto_tree_add_float_format(vw_rfinfo_tree, hf_radiotap_rfinfo_noise, @@ -2040,7 +2040,7 @@ wlantap_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, col_add_fstr(pinfo->cinfo, COL_TX_RATE, "%.1f", phyRate); /* RSSI/antenna A RSSI */ - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); phdr.has_signal_dbm = TRUE; phdr.signal_dbm = dbm; col_add_fstr(pinfo->cinfo, COL_RSSI, "%d dBm", dbm); @@ -2048,21 +2048,21 @@ wlantap_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset++; /* Antenna B RSSI, or 100 if absent */ - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); if (dbm != 100) { proto_tree_add_item(tap_tree, hf_radiotap_dbm_antb, tvb, offset, 1, ENC_NA); } offset++; /* Antenna C RSSI, or 100 if absent */ - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); if (dbm != 100) { proto_tree_add_item(tap_tree, hf_radiotap_dbm_antc, tvb, offset, 1, ENC_NA); } offset++; /* Antenna D RSSI, or 100 if absent */ - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); if (dbm != 100) { proto_tree_add_item(tap_tree, hf_radiotap_dbm_antd, tvb, offset, 1, ENC_NA); } @@ -2430,7 +2430,7 @@ wlantap_dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } offset++; - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); phdr.has_signal_dbm = TRUE; phdr.signal_dbm = dbm; @@ -2445,7 +2445,7 @@ wlantap_dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, tvb, offset, 1, ENC_NA); offset++; - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); if (dbm != 100) { if (cmd_type != 1) proto_tree_add_item(vw_l1info_tree, hf_radiotap_dbm_antb, @@ -2457,7 +2457,7 @@ wlantap_dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } offset++; - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); if (dbm != 100) { if (cmd_type != 1) proto_tree_add_item(vw_l1info_tree, hf_radiotap_dbm_antc, @@ -2468,7 +2468,7 @@ wlantap_dissect_octo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, } offset++; - dbm = (gint8) tvb_get_guint8(tvb, offset); + dbm = tvb_get_gint8(tvb, offset); if (dbm != 100) { if (cmd_type != 1) proto_tree_add_item(vw_l1info_tree, hf_radiotap_dbm_antd, diff --git a/epan/dissectors/packet-lbmpdm.c b/epan/dissectors/packet-lbmpdm.c index 70bb6494cd..f6f9295ee9 100644 --- a/epan/dissectors/packet-lbmpdm.c +++ b/epan/dissectors/packet-lbmpdm.c @@ -583,8 +583,8 @@ static void dissect_field_value(tvbuff_t * tvb, int offset, proto_tree * tree, g guint64 fraction = 0; gint8 shift_count; - exponent = (gint8)tvb_get_guint8(tvb, offset); - mantissa = (gint64)tvb_get_guint64(tvb, offset + 1, encoding); + exponent = tvb_get_gint8(tvb, offset); + mantissa = tvb_get_gint64(tvb, offset + 1, encoding); if (exponent >= 0) { whole = mantissa; diff --git a/epan/dissectors/packet-lbmr.c b/epan/dissectors/packet-lbmr.c index 834b278cc7..c0541f0b85 100644 --- a/epan/dissectors/packet-lbmr.c +++ b/epan/dissectors/packet-lbmr.c @@ -5167,7 +5167,7 @@ static int dissect_lbmr(tvbuff_t * tvb, packet_info * pinfo, proto_tree * tree, gint packet_len; packet_len = tvb_reported_length_remaining(tvb, 0); - opt_total_len = (gint)tvb_get_ntohs(tvb, -L_LBMR_LBMR_OPT_LEN_T + O_LBMR_LBMR_OPT_LEN_T_TOTAL_LEN); + opt_total_len = tvb_get_ntohis(tvb, -L_LBMR_LBMR_OPT_LEN_T + O_LBMR_LBMR_OPT_LEN_T_TOTAL_LEN); if (packet_len > opt_total_len) { gint tvb_len = packet_len - opt_total_len; 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 */ diff --git a/epan/dissectors/packet-ntp.c b/epan/dissectors/packet-ntp.c index f5bfc3fc5f..2c0ec5129d 100644 --- a/epan/dissectors/packet-ntp.c +++ b/epan/dissectors/packet-ntp.c @@ -971,7 +971,7 @@ dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree) * the total roundtrip delay to the primary reference source, * in seconds with fraction point between bits 15 and 16. */ - rootdelay = ((gint16)tvb_get_ntohs(tvb, 4)) + + rootdelay = tvb_get_ntohis(tvb, 4) + (tvb_get_ntohs(tvb, 6) / 65536.0); proto_tree_add_double(ntp_tree, hf_ntp_rootdelay, tvb, 4, 4, rootdelay); @@ -979,7 +979,7 @@ dissect_ntp_std(tvbuff_t *tvb, packet_info *pinfo, proto_tree *ntp_tree) * the nominal error relative to the primary reference source, in * seconds with fraction point between bits 15 and 16. */ - rootdispersion = ((gint16)tvb_get_ntohs(tvb, 8)) + + rootdispersion = tvb_get_ntohis(tvb, 8) + (tvb_get_ntohs(tvb, 10) / 65536.0); proto_tree_add_double(ntp_tree, hf_ntp_rootdispersion, tvb, 8, 4, rootdispersion); diff --git a/epan/dissectors/packet-ossp.c b/epan/dissectors/packet-ossp.c index b412112f4b..a30a0c4f1b 100644 --- a/epan/dissectors/packet-ossp.c +++ b/epan/dissectors/packet-ossp.c @@ -476,7 +476,7 @@ dissect_esmc_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *treex) offset += 2; /* value */ - timestamp = (gint32)tvb_get_ntohl(tvb, offset); + timestamp = tvb_get_ntohil(tvb, offset); item_c = proto_tree_add_item(tree_b, hf_esmc_timestamp, tvb, offset, 4, ENC_BIG_ENDIAN); if (!timestamp_valid_flag) proto_item_append_text(item_c, " [invalid]"); offset += 4; diff --git a/epan/dissectors/packet-ppi.c b/epan/dissectors/packet-ppi.c index ac5ee97298..259d5621bd 100644 --- a/epan/dissectors/packet-ppi.c +++ b/epan/dissectors/packet-ppi.c @@ -570,7 +570,7 @@ dissect_80211_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of } ptvcursor_add(csr, hf_80211_common_fhss_pattern, 1, ENC_LITTLE_ENDIAN); - dbm_value = (gint8) tvb_get_guint8(tvb, ptvcursor_current_offset(csr)); + dbm_value = tvb_get_gint8(tvb, ptvcursor_current_offset(csr)); if (dbm_value != -128 && dbm_value != 0) { /* * XXX - the spec says -128 is invalid, presumably meaning "use @@ -584,7 +584,7 @@ dissect_80211_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int of } ptvcursor_add_invalid_check(csr, hf_80211_common_dbm_antsignal, 1, 0x80); /* -128 */ - dbm_value = (gint8) tvb_get_guint8(tvb, ptvcursor_current_offset(csr)); + dbm_value = tvb_get_gint8(tvb, ptvcursor_current_offset(csr)); if (dbm_value != -128 && dbm_value != 0) { /* * XXX - the spec says -128 is invalid, presumably meaning "use diff --git a/epan/dissectors/packet-synphasor.c b/epan/dissectors/packet-synphasor.c index bbd66f71a7..4105d3e2b3 100644 --- a/epan/dissectors/packet-synphasor.c +++ b/epan/dissectors/packet-synphasor.c @@ -719,7 +719,7 @@ static int dissect_config_frame(tvbuff_t *tvb, proto_item *config_item) /* DATA_RATE */ { - gint16 tmp = tvb_get_ntohs(tvb, offset); + gint16 tmp = tvb_get_ntohis(tvb, offset); if (tmp > 0) proto_tree_add_int_format_value(config_tree, hf_synphasor_rate_of_transmission, tvb, offset, 2, tmp, "%d frame(s) per second", tmp); @@ -881,8 +881,8 @@ static int dissect_single_phasor(tvbuff_t *tvb, int offset, else { if (polar == notation) { /* int, polar */ - *mag = (guint16)tvb_get_ntohs(tvb, offset ); - *phase = (gint16) tvb_get_ntohs(tvb, offset + 2); + *mag = tvb_get_ntohs(tvb, offset ); + *phase = tvb_get_ntohis(tvb, offset + 2); *phase /= 10000.0; /* angle is in radians*10^4 */ } else { diff --git a/epan/dissectors/packet-ubertooth.c b/epan/dissectors/packet-ubertooth.c index b13c7cdb2f..325459db40 100644 --- a/epan/dissectors/packet-ubertooth.c +++ b/epan/dissectors/packet-ubertooth.c @@ -1306,7 +1306,7 @@ dissect_usb_rx_packet(proto_tree *main_tree, proto_tree *tree, packet_info *pinf proto_tree_add_item(entry_tree, hf_rssi, tvb, offset, 1, ENC_NA); offset += 1; - proto_item_append_text(entry_item, " Frequency = %u MHz, RSSI = %i", tvb_get_ntohs(tvb, offset - 3), (gint8) tvb_get_guint8(tvb, offset - 1)); + proto_item_append_text(entry_item, " Frequency = %u MHz, RSSI = %i", tvb_get_ntohs(tvb, offset - 3), tvb_get_gint8(tvb, offset - 1)); } proto_tree_add_item(data_tree, hf_reserved, tvb, offset, 2, ENC_NA); @@ -1516,14 +1516,14 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 34: /* LED Spectrum Analyzer */ - proto_tree_add_int(main_tree, hf_rssi_threshold, tvb, offset, 2, (gint8) tvb_get_letohs(tvb, offset)); - col_append_fstr(pinfo->cinfo, COL_INFO, " = %i", (gint8) tvb_get_letohs(tvb, offset)); + proto_tree_add_item(main_tree, hf_rssi_threshold, tvb, offset, 2, ENC_LITTLE_ENDIAN); + col_append_fstr(pinfo->cinfo, COL_INFO, " = %i", tvb_get_letohis(tvb, offset)); offset += 2; break; case 36: /* Set Squelch */ proto_tree_add_item(main_tree, hf_squelch, tvb, offset, 2, ENC_LITTLE_ENDIAN); - col_append_fstr(pinfo->cinfo, COL_INFO, " = %i", (gint16) tvb_get_letohs(tvb, offset)); + col_append_fstr(pinfo->cinfo, COL_INFO, " = %i", tvb_get_letohis(tvb, offset)); offset += 2; break; @@ -1919,7 +1919,7 @@ dissect_ubertooth(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *dat break; case 37: /* Get Squelch */ proto_tree_add_item(main_tree, hf_squelch, tvb, offset, 1, ENC_NA); - col_append_fstr(pinfo->cinfo, COL_INFO, " = %i", (gint8) tvb_get_guint8(tvb, offset)); + col_append_fstr(pinfo->cinfo, COL_INFO, " = %i", tvb_get_gint8(tvb, offset)); offset += 1; break; diff --git a/epan/dissectors/packet-zbee-zcl-misc.c b/epan/dissectors/packet-zbee-zcl-misc.c index c1091c4a71..25dbda1d97 100644 --- a/epan/dissectors/packet-zbee-zcl-misc.c +++ b/epan/dissectors/packet-zbee-zcl-misc.c @@ -322,13 +322,13 @@ dissect_zcl_thermostat_schedule(proto_tree *tree, tvbuff_t *tvb, guint offset) offset += 2; if (mode_sequence & ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_HEAT) { - float setpoint = (gint16)tvb_get_letohs(tvb, offset); + float setpoint = tvb_get_letohis(tvb, offset); proto_tree_add_float(tree, hf_zbee_zcl_thermostat_schedule_heat, tvb, offset, 2, (setpoint / 100.0f)); offset += 2; } if (mode_sequence & ZBEE_ZCL_CMD_THERMOSTAT_SCHEDULE_MODE_SEQUENCE_COOL) { - float setpoint = (gint16)tvb_get_letohs(tvb, offset); + float setpoint = tvb_get_letohis(tvb, offset); proto_tree_add_float(tree, hf_zbee_zcl_thermostat_schedule_cool, tvb, offset, 2, (setpoint / 100.0f)); offset += 2; @@ -379,7 +379,7 @@ dissect_zbee_zcl_thermostat(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_tree_add_item(tree, hf_zbee_zcl_thermostat_setpoint_mode, tvb, offset, 1, ENC_NA); offset++; - amount = (gint8)tvb_get_guint8(tvb, offset); + amount = tvb_get_gint8(tvb, offset); proto_tree_add_float(tree, hf_zbee_zcl_thermostat_setpoint_amount, tvb, offset, 1, (amount / 100.0f)); offset++; diff --git a/epan/dissectors/packet-zbee-zcl.c b/epan/dissectors/packet-zbee-zcl.c index 4bd2914241..0363b1f797 100644 --- a/epan/dissectors/packet-zbee-zcl.c +++ b/epan/dissectors/packet-zbee-zcl.c @@ -1580,7 +1580,7 @@ void dissect_zcl_attr_data(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint case ZBEE_ZCL_8_BIT_INT: /* Display 8 bit integer */ - attr_int = (gint8)tvb_get_guint8(tvb, *offset); + attr_int = tvb_get_gint8(tvb, *offset); proto_item_append_text(tree, ", %s: %-d", val_to_str_ext_const(data_type, &zbee_zcl_short_data_type_names_ext, "Reserved"), attr_int); proto_tree_add_item(tree, hf_zbee_zcl_attr_int8, tvb, *offset, 1, ENC_NA); @@ -1618,7 +1618,7 @@ void dissect_zcl_attr_data(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint case ZBEE_ZCL_16_BIT_INT: /* Display 16 bit integer */ - attr_int = (gint16)tvb_get_letohs(tvb, *offset); + attr_int = tvb_get_letohis(tvb, *offset); proto_item_append_text(tree, ", %s: %-d", val_to_str_ext_const(data_type, &zbee_zcl_short_data_type_names_ext, "Reserved"), attr_int); proto_tree_add_item(tree, hf_zbee_zcl_attr_int16, tvb, *offset, 2, ENC_LITTLE_ENDIAN); @@ -1647,7 +1647,7 @@ void dissect_zcl_attr_data(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint case ZBEE_ZCL_24_BIT_INT: /* Display 24 bit signed integer */ - attr_int = (gint)tvb_get_letoh24(tvb, *offset); + attr_int = tvb_get_letohi24(tvb, *offset); /* sign extend into int32 */ if (attr_int & INT24_SIGN_BITS) attr_int |= INT24_SIGN_BITS; proto_item_append_text(tree, ", %s: %-d", @@ -1678,7 +1678,7 @@ void dissect_zcl_attr_data(tvbuff_t *tvb, proto_tree *tree, guint *offset, guint case ZBEE_ZCL_32_BIT_INT: /* Display 32 bit signed integer */ - attr_int = (gint)tvb_get_letohl(tvb, *offset); + attr_int = tvb_get_letohil(tvb, *offset); proto_item_append_text(tree, ", %s: %-d", val_to_str_ext_const(data_type, &zbee_zcl_short_data_type_names_ext, "Reserved"), attr_int); proto_tree_add_item(tree, hf_zbee_zcl_attr_int32, tvb, *offset, 4, ENC_LITTLE_ENDIAN); |