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>
This commit is contained in:
Guy Harris 2018-04-09 23:06:47 -07:00 committed by Anders Broman
parent 2cb93e2121
commit c7970d9356
29 changed files with 268 additions and 141 deletions

View File

@ -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;

View File

@ -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) {

View File

@ -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));
}

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);

View File

@ -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> */

View File

@ -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;

View File

@ -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);
}

View File

@ -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,

View File

@ -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;

View File

@ -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;

View File

@ -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 */

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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 {

View File

@ -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;

View File

@ -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++;

View File

@ -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);

View File

@ -1493,26 +1493,22 @@ get_int_value(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, const g
switch (length) {
case 1:
value = (gint8)tvb_get_guint8(tvb, offset);
value = tvb_get_gint8(tvb, offset);
break;
case 2:
value = (gint16) (encoding ? tvb_get_letohs(tvb, offset)
: tvb_get_ntohs(tvb, offset));
value = encoding ? tvb_get_letohis(tvb, offset)
: tvb_get_ntohis(tvb, offset);
break;
case 3:
value = encoding ? tvb_get_letoh24(tvb, offset)
: tvb_get_ntoh24(tvb, offset);
if (value & 0x00800000) {
/* Sign bit is set; sign-extend it. */
value |= 0xFF000000;
}
value = encoding ? tvb_get_letohi24(tvb, offset)
: tvb_get_ntohi24(tvb, offset);
break;
case 4:
value = encoding ? tvb_get_letohl(tvb, offset)
: tvb_get_ntohl(tvb, offset);
value = encoding ? tvb_get_letohil(tvb, offset)
: tvb_get_ntohil(tvb, offset);
break;
default:
@ -1521,8 +1517,8 @@ get_int_value(proto_tree *tree, tvbuff_t *tvb, gint offset, gint length, const g
value = 0;
} else {
length_error = FALSE;
value = encoding ? tvb_get_letohl(tvb, offset)
: tvb_get_ntohl(tvb, offset);
value = encoding ? tvb_get_letohil(tvb, offset)
: tvb_get_ntohil(tvb, offset);
}
report_type_length_mismatch(tree, "a signed integer", length, length_error);
break;

View File

@ -832,7 +832,16 @@ tvb_get_guint8(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, sizeof(guint8));
ptr = fast_ensure_contiguous(tvb, offset, 1);
return *ptr;
}
gint8
tvb_get_gint8(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, 1);
return *ptr;
}
@ -841,7 +850,16 @@ tvb_get_ntohs(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, sizeof(guint16));
ptr = fast_ensure_contiguous(tvb, offset, 2);
return pntoh16(ptr);
}
gint16
tvb_get_ntohis(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, 2);
return pntoh16(ptr);
}
@ -854,12 +872,31 @@ tvb_get_ntoh24(tvbuff_t *tvb, const gint offset)
return pntoh24(ptr);
}
gint32
tvb_get_ntohi24(tvbuff_t *tvb, const gint offset)
{
guint32 ret;
ret = ws_sign_ext32(tvb_get_ntoh24(tvb, offset), 24);
return (gint32)ret;
}
guint32
tvb_get_ntohl(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, sizeof(guint32));
ptr = fast_ensure_contiguous(tvb, offset, 4);
return pntoh32(ptr);
}
gint32
tvb_get_ntohil(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, 4);
return pntoh32(ptr);
}
@ -925,7 +962,16 @@ tvb_get_ntoh64(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, sizeof(guint64));
ptr = fast_ensure_contiguous(tvb, offset, 8);
return pntoh64(ptr);
}
gint64
tvb_get_ntohi64(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, 8);
return pntoh64(ptr);
}
@ -938,6 +984,15 @@ tvb_get_guint16(tvbuff_t *tvb, const gint offset, const guint encoding) {
}
}
gint16
tvb_get_gint16(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
return tvb_get_letohis(tvb, offset);
} else {
return tvb_get_ntohis(tvb, offset);
}
}
guint32
tvb_get_guint24(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
@ -947,6 +1002,15 @@ tvb_get_guint24(tvbuff_t *tvb, const gint offset, const guint encoding) {
}
}
gint32
tvb_get_gint24(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
return tvb_get_letohi24(tvb, offset);
} else {
return tvb_get_ntohi24(tvb, offset);
}
}
guint32
tvb_get_guint32(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
@ -956,6 +1020,15 @@ tvb_get_guint32(tvbuff_t *tvb, const gint offset, const guint encoding) {
}
}
gint32
tvb_get_gint32(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
return tvb_get_letohil(tvb, offset);
} else {
return tvb_get_ntohil(tvb, offset);
}
}
guint64
tvb_get_guint40(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
@ -1019,6 +1092,15 @@ tvb_get_guint64(tvbuff_t *tvb, const gint offset, const guint encoding) {
}
}
gint64
tvb_get_gint64(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
return tvb_get_letohi64(tvb, offset);
} else {
return tvb_get_ntohi64(tvb, offset);
}
}
gfloat
tvb_get_ieee_float(tvbuff_t *tvb, const gint offset, const guint encoding) {
if (encoding & ENC_LITTLE_ENDIAN) {
@ -1043,19 +1125,19 @@ tvb_get_ieee_double(tvbuff_t *tvb, const gint offset, const guint encoding) {
*
* For now, we treat only the VAX as such a platform.
*
* XXX - other non-IEEE boxes that can run UNIX include some Crays,
* and possibly other machines.
*
* It appears that the official Linux port to System/390 and
* zArchitecture uses IEEE format floating point (not a
* huge surprise).
*
* I don't know whether there are any other machines that
* could run Wireshark and that don't use IEEE format.
* As far as I know, all of the main commercial microprocessor
* families on which OSes that support Wireshark can run
* use IEEE format (x86, 68k, SPARC, MIPS, PA-RISC, Alpha,
* IA-64, and so on).
* XXX - other non-IEEE boxes that can run UN*X include some Crays,
* and possibly other machines. However, I don't know whether there
* are any other machines that could run Wireshark and that don't use
* IEEE format. As far as I know, all of the main current and past
* commercial microprocessor families on which OSes that support
* Wireshark can run use IEEE format (x86, ARM, 68k, SPARC, MIPS,
* PA-RISC, Alpha, IA-64, and so on), and it appears that the official
* Linux port to System/390 and zArchitecture uses IEEE format floating-
* point rather than IBM hex floating-point (not a huge surprise), so
* I'm not sure that leaves any 32-bit or larger UN*X or Windows boxes,
* other than VAXes, that don't use IEEE format. If you're not running
* UN*X or Windows, the floating-point format is probably going to be
* the least of your problems in a port.
*/
#if defined(vax)
@ -1245,7 +1327,16 @@ tvb_get_letohs(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, sizeof(guint16));
ptr = fast_ensure_contiguous(tvb, offset, 2);
return pletoh16(ptr);
}
gint16
tvb_get_letohis(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, 2);
return pletoh16(ptr);
}
@ -1258,12 +1349,31 @@ tvb_get_letoh24(tvbuff_t *tvb, const gint offset)
return pletoh24(ptr);
}
gint32
tvb_get_letohi24(tvbuff_t *tvb, const gint offset)
{
guint32 ret;
ret = ws_sign_ext32(tvb_get_letoh24(tvb, offset), 24);
return (gint32)ret;
}
guint32
tvb_get_letohl(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, sizeof(guint32));
ptr = fast_ensure_contiguous(tvb, offset, 4);
return pletoh32(ptr);
}
gint32
tvb_get_letohil(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, 4);
return pletoh32(ptr);
}
@ -1329,7 +1439,16 @@ tvb_get_letoh64(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, sizeof(guint64));
ptr = fast_ensure_contiguous(tvb, offset, 8);
return pletoh64(ptr);
}
gint64
tvb_get_letohi64(tvbuff_t *tvb, const gint offset)
{
const guint8 *ptr;
ptr = fast_ensure_contiguous(tvb, offset, 8);
return pletoh64(ptr);
}

View File

@ -276,10 +276,14 @@ WS_DLL_PUBLIC struct tvbuff *tvb_get_ds_tvb(tvbuff_t *tvb);
/* All accessors will throw an exception if appropriate */
WS_DLL_PUBLIC guint8 tvb_get_guint8(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint8 tvb_get_gint8(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint16 tvb_get_ntohs(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint16 tvb_get_ntohis(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint32 tvb_get_ntoh24(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint32 tvb_get_ntohi24(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint32 tvb_get_ntohl(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint32 tvb_get_ntohil(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_ntoh40(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint64 tvb_get_ntohi40(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_ntoh48(tvbuff_t *tvb, const gint offset);
@ -287,13 +291,17 @@ WS_DLL_PUBLIC gint64 tvb_get_ntohi48(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_ntoh56(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint64 tvb_get_ntohi56(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_ntoh64(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint64 tvb_get_ntohi64(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gfloat tvb_get_ntohieee_float(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gdouble tvb_get_ntohieee_double(tvbuff_t *tvb,
const gint offset);
WS_DLL_PUBLIC guint16 tvb_get_letohs(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint16 tvb_get_letohis(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint32 tvb_get_letoh24(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint32 tvb_get_letohi24(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint32 tvb_get_letohl(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint32 tvb_get_letohil(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_letoh40(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint64 tvb_get_letohi40(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_letoh48(tvbuff_t *tvb, const gint offset);
@ -301,13 +309,17 @@ WS_DLL_PUBLIC gint64 tvb_get_letohi48(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_letoh56(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint64 tvb_get_letohi56(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC guint64 tvb_get_letoh64(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gint64 tvb_get_letohi64(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gfloat tvb_get_letohieee_float(tvbuff_t *tvb, const gint offset);
WS_DLL_PUBLIC gdouble tvb_get_letohieee_double(tvbuff_t *tvb,
const gint offset);
WS_DLL_PUBLIC guint16 tvb_get_guint16(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gint16 tvb_get_gint16(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC guint32 tvb_get_guint24(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gint32 tvb_get_gint24(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC guint32 tvb_get_guint32(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gint32 tvb_get_gint32(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC guint64 tvb_get_guint40(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gint64 tvb_get_gint40(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC guint64 tvb_get_guint48(tvbuff_t *tvb, const gint offset, const guint encoding);
@ -315,6 +327,7 @@ WS_DLL_PUBLIC gint64 tvb_get_gint48(tvbuff_t *tvb, const gint offset, const guin
WS_DLL_PUBLIC guint64 tvb_get_guint56(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gint64 tvb_get_gint56(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC guint64 tvb_get_guint64(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gint64 tvb_get_gint64(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gfloat tvb_get_ieee_float(tvbuff_t *tvb, const gint offset, const guint encoding);
WS_DLL_PUBLIC gdouble tvb_get_ieee_double(tvbuff_t *tvb, const gint offset, const guint encoding);

View File

@ -575,16 +575,16 @@ WSLUA_METHOD TvbRange_int(lua_State* L) {
switch (tvbr->len) {
case 1:
lua_pushnumber(L,(gchar)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
lua_pushnumber(L,(gshort)tvb_get_ntohs(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_ntohis(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
lua_pushnumber(L,(gint)tvb_get_ntoh24(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_ntohi24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
lua_pushnumber(L,(gint)tvb_get_ntohl(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The signed integer value */
/*
* XXX:
@ -614,16 +614,16 @@ WSLUA_METHOD TvbRange_le_int(lua_State* L) {
switch (tvbr->len) {
case 1:
lua_pushnumber(L,(gchar)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
lua_pushnumber(L,(gshort)tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_letohis(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
lua_pushnumber(L,(gint)tvb_get_letoh24(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_letohi24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
lua_pushnumber(L,(gint)tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
lua_pushnumber(L,tvb_get_letohil(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The signed integer value. */
default:
luaL_error(L,"TvbRange:le_int() does not handle %d byte integers",tvbr->len);
@ -646,28 +646,28 @@ WSLUA_METHOD TvbRange_int64(lua_State* L) {
switch (tvbr->len) {
case 1:
pushInt64(L,(gint8)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
pushInt64(L,(gint16)tvb_get_ntohs(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_ntohis(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
pushInt64(L,(gint)tvb_get_ntoh24(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_ntohi24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
pushInt64(L,(gint32)tvb_get_ntohl(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_ntohil(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 5:
pushInt64(L,(gint64)tvb_get_ntoh40(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_ntohi40(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 6:
pushInt64(L,(gint64)tvb_get_ntoh48(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_ntohi48(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 7:
pushInt64(L,(gint64)tvb_get_ntoh56(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_ntohi56(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 8:
pushInt64(L,(gint64)tvb_get_ntoh64(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_ntohi64(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The `Int64` object. */
default:
luaL_error(L,"TvbRange:int64() does not handle %d byte integers",tvbr->len);
@ -690,28 +690,28 @@ WSLUA_METHOD TvbRange_le_int64(lua_State* L) {
switch (tvbr->len) {
case 1:
pushInt64(L,(gint8)tvb_get_guint8(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_gint8(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 2:
pushInt64(L,(gint16)tvb_get_letohs(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_letohis(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 3:
pushInt64(L,(gint)tvb_get_letoh24(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_letohi24(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 4:
pushInt64(L,(gint32)tvb_get_letohl(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_letohil(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 5:
pushInt64(L,(gint64)tvb_get_letoh40(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_letohi40(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 6:
pushInt64(L,(gint64)tvb_get_letoh48(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_letohi48(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 7:
pushInt64(L,(gint64)tvb_get_letoh56(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_letohi56(tvbr->tvb->ws_tvb,tvbr->offset));
return 1;
case 8:
pushInt64(L,(gint64)tvb_get_letoh64(tvbr->tvb->ws_tvb,tvbr->offset));
pushInt64(L,tvb_get_letohi64(tvbr->tvb->ws_tvb,tvbr->offset));
WSLUA_RETURN(1); /* The `Int64` object. */
default:
luaL_error(L,"TvbRange:le_int64() does not handle %d byte integers",tvbr->len);

View File

@ -67,7 +67,7 @@ static int dissect_mac_mgmt_msg_fpc_decoder(tvbuff_t *tvb, packet_info *pinfo _U
offset += 2;
/* display the Power adjust value */
value = (gint8)tvb_get_guint8(tvb, offset);
value = tvb_get_gint8(tvb, offset);
power_change = (float)0.25 * value; /* 0.25dB incr */
/* display the Power adjust value in dB */

View File

@ -206,7 +206,7 @@ static int dissect_mac_mgmt_msg_pmc_rsp_decoder(tvbuff_t *tvb, packet_info *pinf
pwr_control_mode = 0xC0 & tvb_get_guint8(tvb, offset);
offset++;
value = (gint8)tvb_get_guint8(tvb, offset);
value = tvb_get_gint8(tvb, offset);
power_change = (float)0.25 * value; /* 0.25dB incr */
/* Check if Power Control Mode is 0 */
if (pwr_control_mode == 0) {