forked from osmocom/wireshark
Adjust proto_tree_add_[float|double]_format_value calls to use unit string
Several calls to proto_tree_add_[float|double]_xxx could be better served using BASE_UNIT_STRING with a "unit string" in hf_ field. Added a few more "common" unit string values to unit_strings.[ch] Change-Id: Id0da7b579403898d20c2667d6c4abcd59d5a48d4 Reviewed-on: https://code.wireshark.org/review/19241 Reviewed-by: Michael Mann <mmann78@netscape.net>
This commit is contained in:
parent
e150235ef1
commit
a869ec6f55
|
@ -1643,9 +1643,14 @@ libwireshark.so.0 libwireshark0 #MINVER#
|
|||
unit_name_string_get_value64@Base 2.3.0
|
||||
units_bit_bits@Base 2.3.0
|
||||
units_byte_bytes@Base 2.3.0
|
||||
units_degree_degrees@Base 2.3.0
|
||||
units_foot_feet@Base 2.3.0
|
||||
units_ghz@Base 2.3.0
|
||||
units_hz@Base 2.3.0
|
||||
units_hz_s@Base 2.3.0
|
||||
units_millisecond_milliseconds@Base 2.3.0
|
||||
units_milliseconds@Base 2.3.0
|
||||
units_nanosecond_nanoseconds@Base 2.3.0
|
||||
units_second_seconds@Base 2.3.0
|
||||
units_seconds@Base 2.3.0
|
||||
units_word_words@Base 2.3.0
|
||||
|
|
|
@ -217,15 +217,13 @@ dissect_mp4_mvhd_body(tvbuff_t *tvb, gint offset, gint len _U_,
|
|||
rate = tvb_get_ntohs(tvb, offset);
|
||||
fract_dec = tvb_get_ntohs(tvb, offset+2);
|
||||
rate += make_fract(fract_dec);
|
||||
proto_tree_add_double_format_value(tree, hf_mp4_mvhd_rate,
|
||||
tvb, offset, 4, rate, "%f", rate);
|
||||
proto_tree_add_double(tree, hf_mp4_mvhd_rate, tvb, offset, 4, rate);
|
||||
offset += 4;
|
||||
|
||||
vol = tvb_get_guint8(tvb, offset);
|
||||
fract_dec = tvb_get_guint8(tvb, offset+1);
|
||||
vol += make_fract(fract_dec);
|
||||
proto_tree_add_double_format_value(tree, hf_mp4_mvhd_vol,
|
||||
tvb, offset, 4, vol, "%f", vol);
|
||||
proto_tree_add_double(tree, hf_mp4_mvhd_vol, tvb, offset, 4, vol);
|
||||
offset += 2;
|
||||
|
||||
offset += 2; /* 16 bits reserved */
|
||||
|
@ -314,15 +312,13 @@ dissect_mp4_tkhd_body(tvbuff_t *tvb, gint offset, gint len _U_,
|
|||
width = tvb_get_ntohs(tvb, offset);
|
||||
fract_dec = tvb_get_ntohs(tvb, offset+2);
|
||||
width += make_fract(fract_dec);
|
||||
proto_tree_add_double_format_value(tree, hf_mp4_tkhd_width,
|
||||
tvb, offset, 4, width, "%f", width);
|
||||
proto_tree_add_double(tree, hf_mp4_tkhd_width, tvb, offset, 4, width);
|
||||
offset += 4;
|
||||
|
||||
height = tvb_get_ntohs(tvb, offset);
|
||||
fract_dec = tvb_get_ntohs(tvb, offset+2);
|
||||
height += make_fract(fract_dec);
|
||||
proto_tree_add_double_format_value(tree, hf_mp4_tkhd_height,
|
||||
tvb, offset, 4, height, "%f", height);
|
||||
proto_tree_add_double(tree, hf_mp4_tkhd_height, tvb, offset, 4, height);
|
||||
offset += 4;
|
||||
|
||||
return offset-offset_start;
|
||||
|
|
|
@ -386,43 +386,43 @@ dissect_png_chrm(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
|
|||
gint offset = 0;
|
||||
|
||||
wx = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_white_x,
|
||||
tvb, offset, 4, wx, "%f", wx);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_white_x,
|
||||
tvb, offset, 4, wx);
|
||||
offset += 4;
|
||||
|
||||
wy = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_white_y,
|
||||
tvb, offset, 4, wy, "%f", wy);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_white_y,
|
||||
tvb, offset, 4, wy);
|
||||
offset += 4;
|
||||
|
||||
rx = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_red_x,
|
||||
tvb, offset, 4, rx, "%f", rx);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_red_x,
|
||||
tvb, offset, 4, rx);
|
||||
offset += 4;
|
||||
|
||||
ry = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_red_y,
|
||||
tvb, offset, 4, ry, "%f", ry);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_red_y,
|
||||
tvb, offset, 4, ry);
|
||||
offset += 4;
|
||||
|
||||
gx = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_green_x,
|
||||
tvb, offset, 4, gx, "%f", gx);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_green_x,
|
||||
tvb, offset, 4, gx);
|
||||
offset += 4;
|
||||
|
||||
gy = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_green_y,
|
||||
tvb, offset, 4, gy, "%f", gy);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_green_y,
|
||||
tvb, offset, 4, gy);
|
||||
offset += 4;
|
||||
|
||||
bx = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_blue_x,
|
||||
tvb, offset, 4, bx, "%f", bx);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_blue_x,
|
||||
tvb, offset, 4, bx);
|
||||
offset += 4;
|
||||
|
||||
by = tvb_get_ntohl(tvb, offset) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_chrm_blue_y,
|
||||
tvb, offset, 4, by, "%f", by);
|
||||
proto_tree_add_float(tree, &hfi_png_chrm_blue_y,
|
||||
tvb, offset, 4, by);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -431,8 +431,8 @@ dissect_png_gama(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree)
|
|||
float gamma;
|
||||
|
||||
gamma = tvb_get_ntohl(tvb, 0) / 100000.0f;
|
||||
proto_tree_add_float_format_value(tree, &hfi_png_gama_gamma,
|
||||
tvb, 0, 4, gamma, "%f", gamma);
|
||||
proto_tree_add_float(tree, &hfi_png_gama_gamma,
|
||||
tvb, 0, 4, gamma);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
|
|
@ -138,7 +138,7 @@ static header_field_info hfi_dbus_value_str DBUS_HFI_INIT =
|
|||
{ "Value", "dbus.value.str", FT_STRING, BASE_NONE, NULL, 0x00, NULL, HFILL };
|
||||
|
||||
static header_field_info hfi_dbus_value_double DBUS_HFI_INIT =
|
||||
{ "Value", "dbus.value.double", FT_DOUBLE, BASE_NONE, NULL, 0x00, NULL, HFILL };
|
||||
{ "DOUBLE", "dbus.value.double", FT_DOUBLE, BASE_NONE, NULL, 0x00, NULL, HFILL };
|
||||
|
||||
|
||||
static int ett_dbus = -1;
|
||||
|
@ -324,7 +324,7 @@ dissect_dbus_sig(tvbuff_t *tvb, dbus_info_t *dinfo, proto_tree *tree, int offset
|
|||
val = dinfo->getdouble(tvb, offset);
|
||||
offset += 8;
|
||||
|
||||
proto_tree_add_double_format(tree, hfi_dbus_value_double.id, tvb, org_offset, offset - org_offset, val, "DOUBLE: %." G_STRINGIFY(DBL_DIG) "g", val);
|
||||
proto_tree_add_double(tree, hfi_dbus_value_double.id, tvb, org_offset, offset - org_offset, val);
|
||||
/* XXX ret */
|
||||
return offset;
|
||||
}
|
||||
|
|
|
@ -749,14 +749,14 @@ proto_mpeg_descriptor_dissect_satellite_delivery(tvbuff_t *tvb, guint offset, pr
|
|||
MPEG_SECT_BCD44_TO_DEC(tvb_get_guint8(tvb, offset+1)) / 10.0 +
|
||||
MPEG_SECT_BCD44_TO_DEC(tvb_get_guint8(tvb, offset+2)) / 1000.0 +
|
||||
MPEG_SECT_BCD44_TO_DEC(tvb_get_guint8(tvb, offset+3)) / 100000.0;
|
||||
proto_tree_add_double_format_value(tree, hf_mpeg_descr_satellite_delivery_frequency,
|
||||
tvb, offset, 4, frequency, "%f GHz", frequency);
|
||||
proto_tree_add_double(tree, hf_mpeg_descr_satellite_delivery_frequency,
|
||||
tvb, offset, 4, frequency);
|
||||
offset += 4;
|
||||
|
||||
orbital_position = MPEG_SECT_BCD44_TO_DEC(tvb_get_guint8(tvb, offset)) * 10.0f +
|
||||
MPEG_SECT_BCD44_TO_DEC(tvb_get_guint8(tvb, offset+1)) / 10.0f;
|
||||
proto_tree_add_float_format_value(tree, hf_mpeg_descr_satellite_delivery_orbital_position,
|
||||
tvb, offset, 2, orbital_position, "%f degrees", orbital_position);
|
||||
proto_tree_add_float(tree, hf_mpeg_descr_satellite_delivery_orbital_position,
|
||||
tvb, offset, 2, orbital_position);
|
||||
offset += 2;
|
||||
|
||||
modulation_system = tvb_get_guint8(tvb, offset) & MPEG_DESCR_SATELLITE_DELIVERY_MODULATION_SYSTEM_MASK;
|
||||
|
@ -3481,12 +3481,12 @@ proto_register_mpeg_descriptor(void)
|
|||
/* 0x43 Satellite Delivery System Descriptor */
|
||||
{ &hf_mpeg_descr_satellite_delivery_frequency, {
|
||||
"Frequency", "mpeg_descr.sat_delivery.freq",
|
||||
FT_DOUBLE, BASE_NONE, NULL, 0, NULL, HFILL
|
||||
FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING, &units_ghz, 0, NULL, HFILL
|
||||
} },
|
||||
|
||||
{ &hf_mpeg_descr_satellite_delivery_orbital_position, {
|
||||
"Orbital Position", "mpeg_descr.sat_delivery.orbital_pos",
|
||||
FT_FLOAT, BASE_NONE, NULL, 0, NULL, HFILL
|
||||
FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, &units_degree_degrees, 0, NULL, HFILL
|
||||
} },
|
||||
|
||||
{ &hf_mpeg_descr_satellite_delivery_west_east_flag, {
|
||||
|
|
|
@ -2403,9 +2403,8 @@ dissect_ptp_v2_timeInterval(tvbuff_t *tvb, guint16 *cur_offset, proto_tree *tree
|
|||
proto_tree_add_uint64_format_value(ptptimeInterval_subtree,
|
||||
hf_ptp_v2_timeInterval_ns, tvb, *cur_offset, 6, time_ns, "Ns: %" G_GINT64_MODIFIER "d nanoseconds", time_ns);
|
||||
|
||||
proto_tree_add_double_format_value(ptptimeInterval_subtree,
|
||||
hf_ptp_v2_timeInterval_subns, tvb, *cur_offset+6, 2, (time_subns/65536.0),
|
||||
"%f nanoseconds", (time_subns/65536.0));
|
||||
proto_tree_add_double(ptptimeInterval_subtree,
|
||||
hf_ptp_v2_timeInterval_subns, tvb, *cur_offset+6, 2, (time_subns/65536.0));
|
||||
|
||||
*cur_offset = *cur_offset + 8;
|
||||
}
|
||||
|
@ -5032,7 +5031,7 @@ proto_register_ptp(void)
|
|||
},
|
||||
{ &hf_ptp_v2_correctionsubns,
|
||||
{ "correctionSubNs", "ptp.v2.correction.subns",
|
||||
FT_DOUBLE, BASE_NONE, NULL, 0x00,
|
||||
FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING, &units_nanosecond_nanoseconds, 0x00,
|
||||
NULL, HFILL }
|
||||
},
|
||||
{ &hf_ptp_v2_clockidentity,
|
||||
|
@ -5933,7 +5932,7 @@ proto_register_ptp(void)
|
|||
},
|
||||
{ &hf_ptp_v2_mm_offset_subns,
|
||||
{ "SubNs", "ptp.v2.mm.offset.subns",
|
||||
FT_DOUBLE, BASE_NONE, NULL, 0x00,
|
||||
FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING, &units_nanosecond_nanoseconds, 0x00,
|
||||
NULL, HFILL }
|
||||
},
|
||||
{ &hf_ptp_v2_mm_pathDelay_ns,
|
||||
|
@ -5943,7 +5942,7 @@ proto_register_ptp(void)
|
|||
},
|
||||
{ &hf_ptp_v2_mm_pathDelay_subns,
|
||||
{ "SubNs", "ptp.v2.mm.pathDelay.subns",
|
||||
FT_DOUBLE, BASE_NONE, NULL, 0x00,
|
||||
FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING, &units_nanosecond_nanoseconds, 0x00,
|
||||
NULL, HFILL }
|
||||
},
|
||||
{ &hf_ptp_v2_mm_PortNumber,
|
||||
|
@ -5968,7 +5967,7 @@ proto_register_ptp(void)
|
|||
},
|
||||
{ &hf_ptp_v2_mm_peerMeanPathDelay_subns,
|
||||
{ "SubNs", "ptp.v2.mm.peerMeanPathDelay.subns",
|
||||
FT_DOUBLE, BASE_NONE, NULL, 0x00,
|
||||
FT_DOUBLE, BASE_NONE|BASE_UNIT_STRING, &units_nanosecond_nanoseconds, 0x00,
|
||||
NULL, HFILL }
|
||||
},
|
||||
{ &hf_ptp_v2_mm_logAnnounceInterval,
|
||||
|
|
|
@ -965,17 +965,15 @@ static gint dissect_PHASORS(tvbuff_t *tvb, proto_tree *tree, config_block *block
|
|||
static gint dissect_DFREQ(tvbuff_t *tvb, proto_tree *tree, config_block *block, gint offset)
|
||||
{
|
||||
if (floating_point == block->format_fr) {
|
||||
gfloat tmp;
|
||||
|
||||
tmp = tvb_get_ntohieee_float(tvb, offset);
|
||||
proto_tree_add_float_format_value(tree, hf_synphasor_actual_frequency_value, tvb, offset, 4, tmp, "%fHz", tmp); offset += 4;
|
||||
proto_tree_add_item(tree, hf_synphasor_actual_frequency_value, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
offset += 4;
|
||||
|
||||
/* The standard doesn't clearly say how to interpret this value, but
|
||||
* http://www.pes-psrc.org/h/C37_118_H11_FAQ_Jan2008.pdf provides further information.
|
||||
* --> no scaling factor is applied to DFREQ
|
||||
*/
|
||||
tmp = tvb_get_ntohieee_float(tvb, offset);
|
||||
proto_tree_add_float_format_value(tree, hf_synphasor_rate_change_frequency, tvb, offset, 4, tmp, "%fHz/s", tmp); offset += 4;
|
||||
proto_tree_add_item(tree, hf_synphasor_rate_change_frequency, tvb, offset, 4, ENC_BIG_ENDIAN);
|
||||
offset += 4;
|
||||
}
|
||||
else {
|
||||
gint16 tmp;
|
||||
|
@ -1304,8 +1302,8 @@ void proto_register_synphasor(void)
|
|||
{ &hf_synphasor_num_digital_status_words, { "Number of digital status words", "synphasor.num_digital_status_words", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_rate_of_transmission, { "Rate of transmission", "synphasor.rate_of_transmission", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_phasor, { "Phasor", "synphasor.phasor", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_actual_frequency_value, { "Actual frequency value", "synphasor.actual_frequency_value", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_rate_change_frequency, { "Rate of change of frequency", "synphasor.rate_change_frequency", FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_actual_frequency_value, { "Actual frequency value", "synphasor.actual_frequency_value", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, &units_hz, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_rate_change_frequency, { "Rate of change of frequency", "synphasor.rate_change_frequency", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, &units_hz_s, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_frequency_deviation_from_nominal, { "Frequency deviation from nominal", "synphasor.frequency_deviation_from_nominal", FT_INT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_analog_value, { "Analog value", "synphasor.analog_value", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL }},
|
||||
{ &hf_synphasor_digital_status_word, { "Digital status word", "synphasor.digital_status_word", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
|
||||
|
|
|
@ -2963,6 +2963,9 @@ proto_custom_set(proto_tree* tree, GSList *field_id,
|
|||
#define proto_tree_add_uint(tree, hfinfo, tvb, start, length, value) \
|
||||
proto_tree_add_uint(tree, (hfinfo)->id, tvb, start, length, value)
|
||||
|
||||
#define proto_tree_add_float(tree, hfinfo, tvb, start, length, value) \
|
||||
proto_tree_add_float(tree, (hfinfo)->id, tvb, start, length, value)
|
||||
|
||||
#define proto_tree_add_float_format_value(tree, hfinfo, \
|
||||
tvb, start, length, value, format, ...) \
|
||||
proto_tree_add_float_format_value(tree, (hfinfo)->id, \
|
||||
|
|
|
@ -54,6 +54,12 @@ const unit_name_string units_second_seconds = { " second", " seconds" };
|
|||
const unit_name_string units_seconds = { "s", NULL };
|
||||
const unit_name_string units_millisecond_milliseconds = { " millisecond", " milliseconds" };
|
||||
const unit_name_string units_milliseconds = { "ms", NULL };
|
||||
const unit_name_string units_nanosecond_nanoseconds = { " nanosecond", " nanoseconds" };
|
||||
const unit_name_string units_degree_degrees = { " degree", " degrees" };
|
||||
const unit_name_string units_ghz = { "GHz", NULL };
|
||||
const unit_name_string units_hz = { "Hz", NULL };
|
||||
const unit_name_string units_hz_s = { "Hz/s", NULL };
|
||||
|
||||
|
||||
/*
|
||||
* Editor modelines
|
||||
|
|
|
@ -54,6 +54,11 @@ WS_DLL_PUBLIC const unit_name_string units_second_seconds; // full unit name "se
|
|||
WS_DLL_PUBLIC const unit_name_string units_seconds; //only seconds abbreviation "s"
|
||||
WS_DLL_PUBLIC const unit_name_string units_millisecond_milliseconds; // full unit name "millisecond[s?]"
|
||||
WS_DLL_PUBLIC const unit_name_string units_milliseconds; //only seconds abbreviation "ms"
|
||||
WS_DLL_PUBLIC const unit_name_string units_nanosecond_nanoseconds; // full unit name "nanosecond[s?]"
|
||||
WS_DLL_PUBLIC const unit_name_string units_degree_degrees;
|
||||
WS_DLL_PUBLIC const unit_name_string units_ghz;
|
||||
WS_DLL_PUBLIC const unit_name_string units_hz;
|
||||
WS_DLL_PUBLIC const unit_name_string units_hz_s;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue