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 | |
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.
-rw-r--r-- | epan/dissectors/asn1/goose/goose.cnf | 16 | ||||
-rw-r--r-- | epan/dissectors/asn1/goose/packet-goose-template.c | 12 | ||||
-rw-r--r-- | epan/dissectors/packet-goose.c | 43 |
3 files changed, 56 insertions, 15 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 --- */ diff --git a/epan/dissectors/packet-goose.c b/epan/dissectors/packet-goose.c index 62f86384b1..6490e066cb 100644 --- a/epan/dissectors/packet-goose.c +++ b/epan/dissectors/packet-goose.c @@ -75,6 +75,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 @@ -89,6 +91,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 + /*--- Included file: packet-goose-hf.c ---*/ #line 1 "./asn1/goose/packet-goose-hf.c" @@ -153,7 +158,7 @@ static int hf_goose_mMSString = -1; /* MMSString */ static int hf_goose_utc_time = -1; /* UtcTime */ /*--- End of included file: packet-goose-hf.c ---*/ -#line 85 "./asn1/goose/packet-goose-template.c" +#line 90 "./asn1/goose/packet-goose-template.c" /* Initialize the subtree pointers */ static int ett_r_goose = -1; @@ -188,7 +193,7 @@ static gint ett_goose_SEQUENCE_OF_Data = -1; static gint ett_goose_Data = -1; /*--- End of included file: packet-goose-ett.c ---*/ -#line 98 "./asn1/goose/packet-goose-template.c" +#line 103 "./asn1/goose/packet-goose-template.c" /*--- Included file: packet-goose-fn.c ---*/ @@ -550,10 +555,6 @@ dissect_goose_UtcTime(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _ proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime); } - return offset; - - - return offset; @@ -621,9 +622,22 @@ dissect_goose_BIT_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offse static int dissect_goose_FloatingPoint(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { - offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, +#line 68 "./asn1/goose/goose.cnf" + + 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{ + offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, NULL); + } + + + return offset; } @@ -770,7 +784,7 @@ dissect_goose_GOOSEpdu(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset /*--- End of included file: packet-goose-fn.c ---*/ -#line 100 "./asn1/goose/packet-goose-template.c" +#line 105 "./asn1/goose/packet-goose-template.c" static dissector_handle_t goose_handle = NULL; static dissector_handle_t ositp_handle = NULL; @@ -1221,12 +1235,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 }}, + /*--- Included file: packet-goose-hfarr.c ---*/ #line 1 "./asn1/goose/packet-goose-hfarr.c" @@ -1377,7 +1395,7 @@ void proto_register_goose(void) { { &hf_goose_simulation, { "simulation", "goose.simulation", FT_BOOLEAN, BASE_NONE, NULL, 0, - NULL, HFILL }}, + "BOOLEAN", HFILL }}, { &hf_goose_ndsCom, { "ndsCom", "goose.ndsCom", FT_BOOLEAN, BASE_NONE, NULL, 0, @@ -1468,7 +1486,7 @@ void proto_register_goose(void) { "UtcTime", HFILL }}, /*--- End of included file: packet-goose-hfarr.c ---*/ -#line 557 "./asn1/goose/packet-goose-template.c" +#line 566 "./asn1/goose/packet-goose-template.c" }; /* List of subtrees */ @@ -1504,7 +1522,7 @@ void proto_register_goose(void) { &ett_goose_Data, /*--- End of included file: packet-goose-ettarr.c ---*/ -#line 571 "./asn1/goose/packet-goose-template.c" +#line 580 "./asn1/goose/packet-goose-template.c" }; static ei_register_info ei[] = { @@ -1532,6 +1550,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 --- */ |