From 84a8c1d83a3d3b550e7feb030d8d113da317ac5e Mon Sep 17 00:00:00 2001 From: Anders Broman Date: Thu, 10 Jan 2013 12:13:16 +0000 Subject: From an.huang: (1) support for optional attribute in Sample Value: datSet (0x81), refrTm (0x84), smpRate (0x86), smpMod (0x88). New attribute in 9-2 Ed2 (2) Data (0x87) decoded as PhsMeas in 9-2 LE(Lite Edition) recommemdation is removed, now the data is decoded as simply OctString, just as 9-2, further details should refer to the data set definition and Table 14 in Ed1 / Table 15 in Ed2 Encoding for the basic data types; https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5696 svn path=/trunk/; revision=47016 --- asn1/sv/packet-sv-template.c | 2 ++ asn1/sv/packet-sv-template.h | 1 + asn1/sv/sv.asn | 10 +++++--- asn1/sv/sv.cnf | 59 +++++++++++++++++++++++++++++++++++++++----- 4 files changed, 63 insertions(+), 9 deletions(-) (limited to 'asn1/sv') diff --git a/asn1/sv/packet-sv-template.c b/asn1/sv/packet-sv-template.c index 02f3b5fa76..b0e5ccec9b 100644 --- a/asn1/sv/packet-sv-template.c +++ b/asn1/sv/packet-sv-template.c @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include diff --git a/asn1/sv/packet-sv-template.h b/asn1/sv/packet-sv-template.h index e0d4c80808..601a2619a7 100644 --- a/asn1/sv/packet-sv-template.h +++ b/asn1/sv/packet-sv-template.h @@ -38,6 +38,7 @@ typedef struct _sv_frame_data { guint8 smpSynch; guint8 num_phsMeas; sv_phs_meas phsMeas[IEC61850_SV_MAX_PHSMEAS_ENTRIES]; + guint16 smpMod; } sv_frame_data; #endif /*__PACKET_SV_H__*/ diff --git a/asn1/sv/sv.asn b/asn1/sv/sv.asn index e2fbe13053..c68ce2af30 100644 --- a/asn1/sv/sv.asn +++ b/asn1/sv/sv.asn @@ -13,13 +13,17 @@ SavPdu ::= SEQUENCE { ASDU ::= SEQUENCE { svID [0] IMPLICIT VisibleString, + datSet [1] IMPLICIT VisibleString OPTIONAL, smpCnt [2] IMPLICIT INTEGER(0..65535), confRef [3] IMPLICIT INTEGER(0..4294967295), - smpSynch [5] IMPLICIT INTEGER{none(0),local(1),global(2)}, + refrTm [4] IMPLICIT UtcTime OPTIONAL, + smpSynch [5] IMPLICIT INTEGER{none(0),local(1),global(2)} OPTIONAL, + smpRate [6] IMPLICIT INTEGER(0..65535) OPTIONAL, seqData [7] IMPLICIT Data, + smpMod [8] IMPLICIT INTEGER{samplesPerNormalPeriod(0),samplesPerSecond(1),secondsPerSample(2)} OPTIONAL, ... } - +UtcTime ::= OCTET STRING Data ::= OCTET STRING - END + diff --git a/asn1/sv/sv.cnf b/asn1/sv/sv.cnf index c728affb85..2aa8afb41f 100644 --- a/asn1/sv/sv.cnf +++ b/asn1/sv/sv.cnf @@ -15,20 +15,67 @@ #.FIELD_RENAME -#.FN_BODY ASDU/smpCnt +#.FN_BODY ASDU/smpCnt VAL_PTR = &value guint32 value; - offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, &value); +%(DEFAULT_BODY)s sv_data.smpCnt = value; #.END -#.FN_BODY ASDU/smpSynch +#.FN_BODY UtcTime + guint32 len; + proto_item *cause; + guint32 seconds; + guint32 fraction; + guint32 nanoseconds; + nstime_t ts; + gchar * ptime; + + len = tvb_length_remaining(tvb, offset); + + if(len != 8) + { + cause = proto_tree_add_text(tree, tvb, offset, len, + "BER Error: malformed UTCTime encoding, " + "length must be 8 bytes"); + proto_item_set_expert_flags(cause, PI_MALFORMED, PI_WARN); + expert_add_info_format(actx->pinfo, cause, PI_MALFORMED, PI_WARN, "BER Error: malformed UTCTime encoding"); + if(hf_index >= 0) + { + proto_tree_add_string(tree, hf_index, tvb, offset, len, "????"); + } + return offset; + } + + seconds = tvb_get_ntohl(tvb, offset); + fraction = tvb_get_ntoh24(tvb, offset+4) * 0x100; /* Only 3 bytes are recommended */ + nanoseconds = (guint32)( ((guint64)fraction * G_GINT64_CONSTANT(1000000000U)) / G_GINT64_CONSTANT(0x100000000U) ) ; + + ts.secs = seconds; + ts.nsecs = nanoseconds; + + ptime = abs_time_to_str(&ts, ABSOLUTE_TIME_UTC, TRUE); + + if(hf_index >= 0) + { + proto_tree_add_string(tree, hf_index, tvb, offset, len, ptime); + } + offset += 8; + return offset; +#.END + +#.TYPE_ATTR +UtcTime TYPE = FT_STRING DISPLAY = BASE_NONE + +#.FN_BODY ASDU/smpSynch VAL_PTR = &value guint32 value; - offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, &value); +%(DEFAULT_BODY)s sv_data.smpSynch = value; #.END -#.FN_BODY Data - offset = dissect_PhsMeas1(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index); +#.FN_BODY ASDU/smpMod VAL_PTR = &value + guint32 value; +%(DEFAULT_BODY)s + sv_data.smpMod = value; #.END #.END_OF_CNF \ No newline at end of file -- cgit v1.2.3