forked from osmocom/wireshark
Add support for IEEE-11073 FLOATs
Add support for IEEE-11073 32-bit FLOAT and 16 bit SFLOAT field types. Use them in Bluetooth ATT dissector. Change-Id: Ife0f3843da84a9af23483b0a0d9b69cd2f511d08 Reviewed-on: https://code.wireshark.org/review/12680 Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com> Tested-by: Michal Labedzki <michal.labedzki@tieto.com> Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
parent
399d29695b
commit
22d561c436
|
@ -1518,6 +1518,7 @@ set(FTYPE_FILES
|
|||
ftypes/ftypes.c
|
||||
ftypes/ftype-bytes.c
|
||||
ftypes/ftype-double.c
|
||||
ftypes/ftype-ieee-11073-float.c
|
||||
ftypes/ftype-integer.c
|
||||
ftypes/ftype-ipv4.c
|
||||
ftypes/ftype-ipv6.c
|
||||
|
|
|
@ -68,6 +68,8 @@ compatible_ftypes(ftenum_t a, ftenum_t b)
|
|||
case FT_DOUBLE: /* XXX - should be able to compare with INT */
|
||||
case FT_ABSOLUTE_TIME:
|
||||
case FT_RELATIVE_TIME:
|
||||
case FT_IEEE_11073_SFLOAT:
|
||||
case FT_IEEE_11073_FLOAT:
|
||||
case FT_IPv4:
|
||||
case FT_IPv6:
|
||||
case FT_IPXNET:
|
||||
|
@ -202,6 +204,8 @@ mk_fvalue_from_val_string(dfwork_t *dfw, header_field_info *hfinfo, char *s)
|
|||
case FT_PROTOCOL:
|
||||
case FT_FLOAT:
|
||||
case FT_DOUBLE:
|
||||
case FT_IEEE_11073_SFLOAT:
|
||||
case FT_IEEE_11073_FLOAT:
|
||||
case FT_ABSOLUTE_TIME:
|
||||
case FT_RELATIVE_TIME:
|
||||
case FT_IPv4:
|
||||
|
@ -351,6 +355,8 @@ is_bytes_type(enum ftenum type)
|
|||
case FT_PROTOCOL:
|
||||
case FT_FLOAT:
|
||||
case FT_DOUBLE:
|
||||
case FT_IEEE_11073_SFLOAT:
|
||||
case FT_IEEE_11073_FLOAT:
|
||||
case FT_ABSOLUTE_TIME:
|
||||
case FT_RELATIVE_TIME:
|
||||
case FT_IPv4:
|
||||
|
|
|
@ -8453,16 +8453,14 @@ proto_register_btatt(void)
|
|||
FT_INT16, BASE_DEC, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_glucose_measurement_glucose_concentration_kg_per_l,
|
||||
{"Glucose Concentration [kg/l]", "btatt.glucose_measurement.glucose_concentration.kg_per_l",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_glucose_measurement_glucose_concentration_mol_per_l,
|
||||
{"Glucose Concentration [mol/l]", "btatt.glucose_measurement.glucose_concentration.mol_per_l",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_glucose_measurement_type_and_sample_location,
|
||||
|
@ -8710,16 +8708,14 @@ proto_register_btatt(void)
|
|||
FT_UINT8, BASE_HEX, VALS(temperature_measurement_flags_temperature_unit_vals), 0x01,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be FLOAT: IEEE-11073 32-bit SFLOAT */
|
||||
{&hf_btatt_temperature_measurement_value_celsius,
|
||||
{"Value [Celsius]", "btatt.temperature_measurement.value.celsius",
|
||||
FT_UINT32, BASE_HEX, NULL, 0x00,
|
||||
FT_IEEE_11073_FLOAT, BASE_FLOAT, NULL, 0x00,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be FLOAT: IEEE-11073 32-bit SFLOAT */
|
||||
{&hf_btatt_temperature_measurement_value_fahrenheit,
|
||||
{"Value [Fahrenheit]", "btatt.temperature_measurement.value.fahrenheit",
|
||||
FT_UINT32, BASE_HEX, NULL, 0x00,
|
||||
FT_IEEE_11073_FLOAT, BASE_FLOAT, NULL, 0x00,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_temperature_measurement_timestamp,
|
||||
|
@ -8792,10 +8788,9 @@ proto_register_btatt(void)
|
|||
FT_UINT8, BASE_HEX, VALS(glucose_measurement_context_carbohydrate_id_vals), 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_glucose_measurement_context_carbohydrate_kg,
|
||||
{"Carbohydrate [kg]", "btatt.glucose_measurement_context.carbohydrate.kg",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_glucose_measurement_context_meal,
|
||||
|
@ -8833,22 +8828,19 @@ proto_register_btatt(void)
|
|||
FT_UINT8, BASE_HEX, VALS(glucose_measurement_context_medication_id_vals), 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_glucose_measurement_context_medication_l,
|
||||
{"Medication [l]", "btatt.glucose_measurement_context.medication.l",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_glucose_measurement_context_medication_kg,
|
||||
{"Medication [kg]", "btatt.glucose_measurement_context.medication.kg",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_glucose_measurement_context_hba1c,
|
||||
{"HbA1c", "btatt.glucose_measurement_context.hba1c",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_blood_pressure_measurement_flags,
|
||||
|
@ -8886,40 +8878,34 @@ proto_register_btatt(void)
|
|||
FT_UINT8, BASE_HEX, VALS(blood_pressure_measurement_unit_vals), 0x01,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_blood_pressure_measurement_compound_value_systolic_kpa,
|
||||
{"Systolic [kPa]", "btatt.blood_pressure_measurement.compound_value.systolic.kpa",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_blood_pressure_measurement_compound_value_diastolic_kpa,
|
||||
{"Diastolic [kPa]", "btatt.blood_pressure_measurement.compound_value.diastolic.kpa",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_blood_pressure_measurement_compound_value_mean_arterial_pressure_kpa,
|
||||
{"Arterial Pressure [kPa]", "btatt.blood_pressure_measurement.compound_value.arterial_pressure.kpa",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_blood_pressure_measurement_compound_value_systolic_mmhg,
|
||||
{"Systolic [mmHg]", "btatt.blood_pressure_measurement.compound_value.systolic.mmhg",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_blood_pressure_measurement_compound_value_diastolic_mmhg,
|
||||
{"Diastolic [mmHg]", "btatt.blood_pressure_measurement.compound_value.diastolic.mmhg",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_blood_pressure_measurement_compound_value_mean_arterial_pressure_mmhg,
|
||||
{"Arterial Pressure [mmHg]", "btatt.blood_pressure_measurement.compound_value.arterial_pressure.mmhg",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_blood_pressure_measurement_timestamp,
|
||||
|
@ -8927,10 +8913,9 @@ proto_register_btatt(void)
|
|||
FT_NONE, BASE_NONE, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_blood_pressure_measurement_pulse_rate,
|
||||
{"Pulse Rate", "btatt.blood_pressure_measurement.pulse_rate",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_blood_pressure_measurement_user_id,
|
||||
|
@ -10315,10 +10300,9 @@ proto_register_btatt(void)
|
|||
FT_BOOLEAN, 8, NULL, 0x01,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_cgm_measurement_glucose_concentration,
|
||||
{"Glucose Concentration", "btatt.cgm_measurement.glucose_concentration",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_cgm_measurement_time_offset,
|
||||
|
@ -10456,16 +10440,14 @@ proto_register_btatt(void)
|
|||
FT_BOOLEAN, 8, NULL, 0x01,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_cgm_measurement_trend_information,
|
||||
{"Trend Information", "btatt.cgm_measurement.trend_information",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_cgm_measurement_quality,
|
||||
{"Quality", "btatt.cgm_measurement.quality",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_cgm_e2e_crc,
|
||||
|
@ -10618,10 +10600,9 @@ proto_register_btatt(void)
|
|||
FT_UINT8, BASE_DEC, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_cgm_specific_ops_control_point_calibration_glucose_concentration,
|
||||
{"Calibration Glucose Concentration", "btatt.cgm_specific_ops_control_point.operand.calibration_glucose_concentration",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_cgm_specific_ops_control_point_calibration_time,
|
||||
|
@ -10669,16 +10650,14 @@ proto_register_btatt(void)
|
|||
FT_UINT16, BASE_DEC, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_cgm_specific_ops_control_point_operand_alert_level,
|
||||
{"Alert Level [mg/dL]", "btatt.cgm_specific_ops_control_point.operand.alert_level",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
/* TODO: This field should be SFLOAT: IEEE-11073 16-bit SFLOAT */
|
||||
{&hf_btatt_cgm_specific_ops_control_point_operand_alert_level_rate,
|
||||
{"Alert Level Rate [mg/dL/min]", "btatt.cgm_specific_ops_control_point.operand.alert_level_rate",
|
||||
FT_UINT16, BASE_HEX, NULL, 0x0,
|
||||
FT_IEEE_11073_SFLOAT, BASE_FLOAT, NULL, 0x0,
|
||||
NULL, HFILL}
|
||||
},
|
||||
{&hf_btatt_cgm_specific_ops_control_point_request_opcode,
|
||||
|
|
|
@ -30,6 +30,7 @@ NONGENERATED_C_FILES = \
|
|||
ftypes.c \
|
||||
ftype-bytes.c \
|
||||
ftype-double.c \
|
||||
ftype-ieee-11073-float.c \
|
||||
ftype-integer.c \
|
||||
ftype-ipv4.c \
|
||||
ftype-ipv6.c \
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,6 +34,7 @@ ftype_register(enum ftenum ftype, ftype_t *ft);
|
|||
* that I don't mind doing it by hand for now. */
|
||||
void ftype_register_bytes(void);
|
||||
void ftype_register_double(void);
|
||||
void ftype_register_ieee_11073_float(void);
|
||||
void ftype_register_fc(void);
|
||||
void ftype_register_integers(void);
|
||||
void ftype_register_ipv4(void);
|
||||
|
|
|
@ -34,6 +34,7 @@ ftypes_initialize(void)
|
|||
{
|
||||
ftype_register_bytes();
|
||||
ftype_register_double();
|
||||
ftype_register_ieee_11073_float();
|
||||
ftype_register_integers();
|
||||
ftype_register_ipv4();
|
||||
ftype_register_ipv6();
|
||||
|
|
|
@ -52,6 +52,8 @@ enum ftenum {
|
|||
FT_INT48, /* same as for UINT48 */
|
||||
FT_INT56, /* same as for UINT56 */
|
||||
FT_INT64,
|
||||
FT_IEEE_11073_SFLOAT,
|
||||
FT_IEEE_11073_FLOAT,
|
||||
FT_FLOAT,
|
||||
FT_DOUBLE,
|
||||
FT_ABSOLUTE_TIME,
|
||||
|
@ -214,6 +216,8 @@ typedef struct _fvalue_t {
|
|||
nstime_t time;
|
||||
tvbuff_t *tvb;
|
||||
GRegex *re;
|
||||
guint16 sfloat_ieee_11073;
|
||||
guint32 float_ieee_11073;
|
||||
} value;
|
||||
|
||||
/* The following is provided for private use
|
||||
|
|
63
epan/proto.c
63
epan/proto.c
|
@ -2126,7 +2126,26 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree,
|
|||
|
||||
proto_tree_set_time(new_fi, &time_stamp);
|
||||
break;
|
||||
case FT_IEEE_11073_SFLOAT:
|
||||
if (encoding)
|
||||
encoding = ENC_LITTLE_ENDIAN;
|
||||
if (length != 2) {
|
||||
length_error = length < 2 ? TRUE : FALSE;
|
||||
report_type_length_mismatch(tree, "a IEEE 11073 SFLOAT", length, length_error);
|
||||
}
|
||||
|
||||
fvalue_set_uinteger(&new_fi->value, tvb_get_guint16(tvb, start, encoding));
|
||||
|
||||
break;
|
||||
case FT_IEEE_11073_FLOAT:
|
||||
if (encoding)
|
||||
encoding = ENC_LITTLE_ENDIAN;
|
||||
if (length != 4) {
|
||||
length_error = length < 4 ? TRUE : FALSE;
|
||||
report_type_length_mismatch(tree, "a IEEE 11073 FLOAT", length, length_error);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
g_error("new_fi->hfinfo->type %d (%s) not handled\n",
|
||||
new_fi->hfinfo->type,
|
||||
|
@ -4859,6 +4878,28 @@ proto_custom_set(proto_tree* tree, GSList *field_ids, gint occurrence,
|
|||
size-offset_r);
|
||||
break;
|
||||
|
||||
case FT_IEEE_11073_SFLOAT:
|
||||
{
|
||||
guint8 buf[240];
|
||||
fvalue_to_string_repr(&finfo->value, FTREPR_DISPLAY, hfinfo->display, buf);
|
||||
g_snprintf(result+offset_r, size-offset_r,
|
||||
"%s: %s",
|
||||
hfinfo->name, buf);
|
||||
}
|
||||
offset_r = (int)strlen(result);
|
||||
break;
|
||||
|
||||
case FT_IEEE_11073_FLOAT:
|
||||
{
|
||||
guint8 buf[240];
|
||||
fvalue_to_string_repr(&finfo->value, FTREPR_DISPLAY, hfinfo->display, buf);
|
||||
g_snprintf(result+offset_r, size-offset_r,
|
||||
"%s: %s",
|
||||
hfinfo->name, buf);
|
||||
}
|
||||
offset_r = (int)strlen(result);
|
||||
break;
|
||||
|
||||
case FT_IPXNET: /*XXX really No column custom ?*/
|
||||
case FT_PCRE:
|
||||
default:
|
||||
|
@ -5974,7 +6015,8 @@ static const value_string hf_display[] = {
|
|||
{ BASE_DEC_HEX|BASE_VAL64_STRING, "BASE_DEC_HEX|BASE_VAL64_STRING" },
|
||||
{ BASE_HEX_DEC|BASE_VAL64_STRING, "BASE_HEX_DEC|BASE_VAL64_STRING" },
|
||||
{ BASE_CUSTOM|BASE_VAL64_STRING, "BASE_CUSTOM|BASE_VAL64_STRING" },
|
||||
/* { STR_ASCII, "STR_ASCII" }, */
|
||||
/* Alias: BASE_NONE { BASE_FLOAT, "BASE_FLOAT" }, */
|
||||
/* Alias: BASE_NONE { STR_ASCII, "STR_ASCII" }, */
|
||||
{ STR_UNICODE, "STR_UNICODE" },
|
||||
{ ABSOLUTE_TIME_LOCAL, "ABSOLUTE_TIME_LOCAL" },
|
||||
{ ABSOLUTE_TIME_UTC, "ABSOLUTE_TIME_UTC" },
|
||||
|
@ -6870,6 +6912,25 @@ proto_item_fill_label(field_info *fi, gchar *label_str)
|
|||
label_fill(label_str, 0, hfinfo, hfinfo_format_text(hfinfo, bytes));
|
||||
break;
|
||||
|
||||
case FT_IEEE_11073_SFLOAT:
|
||||
{
|
||||
guint8 buf[240];
|
||||
fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, hfinfo->display, buf);
|
||||
g_snprintf(label_str, ITEM_LABEL_LENGTH,
|
||||
"%s: %s",
|
||||
hfinfo->name, buf);
|
||||
}
|
||||
break;
|
||||
case FT_IEEE_11073_FLOAT:
|
||||
{
|
||||
guint8 buf[240];
|
||||
fvalue_to_string_repr(&fi->value, FTREPR_DISPLAY, hfinfo->display, buf);
|
||||
g_snprintf(label_str, ITEM_LABEL_LENGTH,
|
||||
"%s: %s",
|
||||
hfinfo->name, buf);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
g_error("hfinfo->type %d (%s) not handled\n",
|
||||
hfinfo->type, ftype_name(hfinfo->type));
|
||||
|
|
|
@ -510,6 +510,9 @@ typedef enum {
|
|||
BASE_HEX_DEC = 5, /**< hexadecimal (decimal) */
|
||||
BASE_CUSTOM = 6, /**< call custom routine (in ->strings) to format */
|
||||
|
||||
/* Float types */
|
||||
BASE_FLOAT = BASE_NONE, /**< decimal-format float */
|
||||
|
||||
/* String types */
|
||||
STR_ASCII = BASE_NONE, /**< shows non-printable ASCII characters as C-style escapes */
|
||||
/* XXX, support for format_text_wsp() ? */
|
||||
|
|
Loading…
Reference in New Issue