diff options
author | Aitor Garcia <garcia.aitor@gmail.com> | 2021-02-01 23:08:06 +0000 |
---|---|---|
committer | AndersBroman <a.broman58@gmail.com> | 2021-02-01 23:08:06 +0000 |
commit | 5837bcea5e347afd2a6e5860296de09cbb5a0b28 (patch) | |
tree | 954e377806c6a36bd00297d8cb4a08f7ec44d076 /epan/dissectors/asn1/goose | |
parent | fb2a0b4a71b134a2830e39b6493a4007818ceda6 (diff) |
GOOSE: New option to display float values
Added to the protocol a new option to display the decimal representation
of floating-point values.
Minor fixes: Avoid the double 'return' on dissect_goose_UtcTime function
and fix the simulation BLURB to follow other fields approach.
Diffstat (limited to 'epan/dissectors/asn1/goose')
-rw-r--r-- | epan/dissectors/asn1/goose/goose.cnf | 16 | ||||
-rw-r--r-- | epan/dissectors/asn1/goose/packet-goose-template.c | 12 |
2 files changed, 25 insertions, 3 deletions
diff --git a/epan/dissectors/asn1/goose/goose.cnf b/epan/dissectors/asn1/goose/goose.cnf index ab54932b36..27b12d92af 100644 --- a/epan/dissectors/asn1/goose/goose.cnf +++ b/epan/dissectors/asn1/goose/goose.cnf @@ -62,9 +62,21 @@ GOOSEpdu proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime); } - return offset; +#.END + +#.FN_BODY FloatingPoint + + int len = tvb_reported_length_remaining(tvb, offset); + if ((len == FLOAT_ENC_LENGTH) && (tvb_get_guint8(tvb,0) == SINGLE_FLOAT_EXP_BITS) ){ + /* IEEE 754 single precision floating point */ + proto_tree_add_item(tree, hf_goose_float_value, tvb, 1, (FLOAT_ENC_LENGTH-1), ENC_BIG_ENDIAN); + offset = len; + }else{ + %(DEFAULT_BODY)s + } +#.END #.TYPE_ATTR UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE @@ -81,5 +93,5 @@ GSEMngtResponses/getGOOSEElementNumber gseMngtResponses_GetGOOSEElementNumber IECGoosePdu/stNum TYPE = FT_UINT32 DISPLAY = BASE_DEC IECGoosePdu/sqNum TYPE = FT_UINT32 DISPLAY = BASE_DEC GetReferenceRequestPdu/offset ABBREV=getReferenceRequest.offset - +IECGoosePdu/simulation BLURB = "BOOLEAN" #.END diff --git a/epan/dissectors/asn1/goose/packet-goose-template.c b/epan/dissectors/asn1/goose/packet-goose-template.c index 5a8360c0b7..665ad0115a 100644 --- a/epan/dissectors/asn1/goose/packet-goose-template.c +++ b/epan/dissectors/asn1/goose/packet-goose-template.c @@ -67,6 +67,8 @@ static int hf_goose_length = -1; static int hf_goose_reserve1 = -1; static int hf_goose_reserve1_s_bit = -1; static int hf_goose_reserve2 = -1; +static int hf_goose_float_value = -1; + /* Bit fields in the Reserved fields */ #define F_RESERVE1_S_BIT 0x8000 @@ -81,6 +83,9 @@ static expert_field ei_goose_mal_utctime = EI_INIT; static expert_field ei_goose_zero_pdu = EI_INIT; static expert_field ei_goose_invalid_sim = EI_INIT; +#define SINGLE_FLOAT_EXP_BITS 8 +#define FLOAT_ENC_LENGTH 5 + #include "packet-goose-hf.c" /* Initialize the subtree pointers */ @@ -547,12 +552,16 @@ void proto_register_goose(void) { { &hf_goose_reserve1_s_bit, { "Simulated", "goose.reserve1.s_bit", - FT_BOOLEAN, 16, NULL, F_RESERVE1_S_BIT, "BOOLEAN", HFILL } }, + FT_BOOLEAN, 16, NULL, F_RESERVE1_S_BIT, NULL, HFILL } }, { &hf_goose_reserve2, { "Reserved 2", "goose.reserve2", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }}, + { &hf_goose_float_value, + { "float value", "goose.float_value", + FT_FLOAT, BASE_NONE, NULL, 0x0, NULL, HFILL }}, + #include "packet-goose-hfarr.c" }; @@ -595,6 +604,7 @@ void proto_register_goose(void) { proto_register_subtree_array(ett, array_length(ett)); expert_goose = expert_register_protocol(proto_goose); expert_register_field_array(expert_goose, ei, array_length(ei)); + } /*--- proto_reg_handoff_goose --- */ |