aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/asn1/sv
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/asn1/sv')
-rw-r--r--epan/dissectors/asn1/sv/CMakeLists.txt48
-rw-r--r--epan/dissectors/asn1/sv/Makefile.am23
-rw-r--r--epan/dissectors/asn1/sv/Makefile.common41
-rw-r--r--epan/dissectors/asn1/sv/Makefile.nmake26
-rw-r--r--epan/dissectors/asn1/sv/packet-sv-template.c340
-rw-r--r--epan/dissectors/asn1/sv/packet-sv-template.h42
-rw-r--r--epan/dissectors/asn1/sv/sv.asn28
-rw-r--r--epan/dissectors/asn1/sv/sv.cnf84
8 files changed, 632 insertions, 0 deletions
diff --git a/epan/dissectors/asn1/sv/CMakeLists.txt b/epan/dissectors/asn1/sv/CMakeLists.txt
new file mode 100644
index 0000000000..a567bd6b38
--- /dev/null
+++ b/epan/dissectors/asn1/sv/CMakeLists.txt
@@ -0,0 +1,48 @@
+# CMakeLists.txt
+#
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+
+set( PROTOCOL_NAME sv )
+
+set( PROTO_OPT )
+
+set( EXT_ASN_FILE_LIST
+)
+
+set( ASN_FILE_LIST
+ ${PROTOCOL_NAME}.asn
+)
+
+set( EXTRA_DIST
+ ${ASN_FILE_LIST}
+ packet-${PROTOCOL_NAME}-template.c
+ packet-${PROTOCOL_NAME}-template.h
+ ${PROTOCOL_NAME}.cnf
+)
+
+set( SRC_FILES
+ ${EXTRA_DIST}
+ ${EXT_ASN_FILE_LIST}
+)
+
+set( A2W_FLAGS -b )
+
+ASN2WRS()
+
diff --git a/epan/dissectors/asn1/sv/Makefile.am b/epan/dissectors/asn1/sv/Makefile.am
new file mode 100644
index 0000000000..72d28e600b
--- /dev/null
+++ b/epan/dissectors/asn1/sv/Makefile.am
@@ -0,0 +1,23 @@
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include ../Makefile.preinc
+include Makefile.common
+include ../Makefile.inc
+
diff --git a/epan/dissectors/asn1/sv/Makefile.common b/epan/dissectors/asn1/sv/Makefile.common
new file mode 100644
index 0000000000..828affa5de
--- /dev/null
+++ b/epan/dissectors/asn1/sv/Makefile.common
@@ -0,0 +1,41 @@
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+PROTOCOL_NAME=sv
+
+EXT_ASN_FILE_LIST =
+
+ASN_FILE_LIST = \
+ $(PROTOCOL_NAME).asn
+
+# The packet-$(PROTOCOL_NAME)-template.h and $(PROTOCOL_NAME).asn
+# files do not exist for all protocols: Please add/remove as required.
+EXTRA_DIST = \
+ $(EXTRA_DIST_COMMON) \
+ $(ASN_FILE_LIST) \
+ packet-$(PROTOCOL_NAME)-template.c \
+ packet-$(PROTOCOL_NAME)-template.h \
+ $(PROTOCOL_NAME).cnf
+
+SRC_FILES = \
+ $(EXTRA_DIST) \
+ $(EXT_ASN_FILE_LIST)
+
+A2W_FLAGS= -b
+
diff --git a/epan/dissectors/asn1/sv/Makefile.nmake b/epan/dissectors/asn1/sv/Makefile.nmake
new file mode 100644
index 0000000000..d296638ddd
--- /dev/null
+++ b/epan/dissectors/asn1/sv/Makefile.nmake
@@ -0,0 +1,26 @@
+## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
+#
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+
+include ../../../../config.nmake
+include ../Makefile.preinc.nmake
+include Makefile.common
+include ../Makefile.inc.nmake
+
diff --git a/epan/dissectors/asn1/sv/packet-sv-template.c b/epan/dissectors/asn1/sv/packet-sv-template.c
new file mode 100644
index 0000000000..3690ce20ba
--- /dev/null
+++ b/epan/dissectors/asn1/sv/packet-sv-template.c
@@ -0,0 +1,340 @@
+/* packet-sv.c
+ * Routines for IEC 61850 Sampled Values packet dissection
+ * Michael Bernhard 2008
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "config.h"
+
+#include <epan/packet.h>
+#include <epan/asn1.h>
+#include <epan/etypes.h>
+#include <epan/expert.h>
+#include <epan/prefs.h>
+
+#include "packet-ber.h"
+#include "packet-acse.h"
+
+#include "tap.h"
+
+#include "packet-sv.h"
+
+#define PNAME "IEC61850 Sampled Values"
+#define PSNAME "SV"
+#define PFNAME "sv"
+
+/* see IEC61850-8-1 8.2 */
+#define Q_VALIDITY_GOOD (0x0U << 0)
+#define Q_VALIDITY_INVALID (0x1U << 0)
+#define Q_VALIDITY_QUESTIONABLE (0x3U << 0)
+#define Q_VALIDITY_MASK (0x3U << 0)
+
+#define Q_OVERFLOW (1U << 2)
+#define Q_OUTOFRANGE (1U << 3)
+#define Q_BADREFERENCE (1U << 4)
+#define Q_OSCILLATORY (1U << 5)
+#define Q_FAILURE (1U << 6)
+#define Q_OLDDATA (1U << 7)
+#define Q_INCONSISTENT (1U << 8)
+#define Q_INACCURATE (1U << 9)
+
+#define Q_SOURCE_PROCESS (0U << 10)
+#define Q_SOURCE_SUBSTITUTED (1U << 10)
+#define Q_SOURCE_MASK (1U << 10)
+
+#define Q_TEST (1U << 11)
+#define Q_OPERATORBLOCKED (1U << 12)
+
+/* see UCA Implementation Guideline for IEC 61850-9-2 */
+#define Q_DERIVED (1U << 13)
+
+void proto_register_sv(void);
+void proto_reg_handoff_sv(void);
+
+/* Data for SV tap */
+static int sv_tap = -1;
+static sv_frame_data sv_data;
+
+/* Initialize the protocol and registered fields */
+static int proto_sv = -1;
+static int hf_sv_appid = -1;
+static int hf_sv_length = -1;
+static int hf_sv_reserve1 = -1;
+static int hf_sv_reserve2 = -1;
+static int hf_sv_phmeas_instmag_i = -1;
+static int hf_sv_phsmeas_q = -1;
+static int hf_sv_phsmeas_q_validity = -1;
+static int hf_sv_phsmeas_q_overflow = -1;
+static int hf_sv_phsmeas_q_outofrange = -1;
+static int hf_sv_phsmeas_q_badreference = -1;
+static int hf_sv_phsmeas_q_oscillatory = -1;
+static int hf_sv_phsmeas_q_failure = -1;
+static int hf_sv_phsmeas_q_olddata = -1;
+static int hf_sv_phsmeas_q_inconsistent = -1;
+static int hf_sv_phsmeas_q_inaccurate = -1;
+static int hf_sv_phsmeas_q_source = -1;
+static int hf_sv_phsmeas_q_test = -1;
+static int hf_sv_phsmeas_q_operatorblocked = -1;
+static int hf_sv_phsmeas_q_derived = -1;
+
+#include "packet-sv-hf.c"
+
+/* Initialize the subtree pointers */
+static int ett_sv = -1;
+static int ett_phsmeas = -1;
+static int ett_phsmeas_q = -1;
+
+#include "packet-sv-ett.c"
+
+static expert_field ei_sv_mal_utctime = EI_INIT;
+static expert_field ei_sv_zero_pdu = EI_INIT;
+
+static gboolean sv_decode_data_as_phsmeas = FALSE;
+
+static const value_string sv_q_validity_vals[] = {
+ { 0, "good" },
+ { 1, "invalid" },
+ { 3, "questionable" },
+ { 0, NULL }
+};
+
+static const value_string sv_q_source_vals[] = {
+ { 0, "process" },
+ { 1, "substituted" },
+ { 0, NULL }
+};
+
+static int
+dissect_PhsMeas1(gboolean implicit_tag, packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset, int hf_id _U_)
+{
+ gint8 ber_class;
+ gboolean pc;
+ gint32 tag;
+ guint32 len;
+ proto_tree *subtree;
+ gint32 value;
+ guint32 qual;
+ guint32 i;
+
+ static const int *q_flags[] = {
+ &hf_sv_phsmeas_q_validity,
+ &hf_sv_phsmeas_q_overflow,
+ &hf_sv_phsmeas_q_outofrange,
+ &hf_sv_phsmeas_q_badreference,
+ &hf_sv_phsmeas_q_oscillatory,
+ &hf_sv_phsmeas_q_failure,
+ &hf_sv_phsmeas_q_olddata,
+ &hf_sv_phsmeas_q_inconsistent,
+ &hf_sv_phsmeas_q_inaccurate,
+ &hf_sv_phsmeas_q_source,
+ &hf_sv_phsmeas_q_test,
+ &hf_sv_phsmeas_q_operatorblocked,
+ &hf_sv_phsmeas_q_derived,
+ NULL
+ };
+
+ if (!implicit_tag) {
+ offset=dissect_ber_identifier(pinfo, tree, tvb, offset, &ber_class, &pc, &tag);
+ offset=dissect_ber_length(pinfo, tree, tvb, offset, &len, NULL);
+ } else {
+ len=tvb_reported_length_remaining(tvb, offset);
+ }
+
+ subtree = proto_tree_add_subtree(tree, tvb, offset, len, ett_phsmeas, NULL, "PhsMeas1");
+
+ sv_data.num_phsMeas = 0;
+ for (i = 0; i < len/8; i++) {
+ if (tree && subtree) {
+ value = tvb_get_ntohl(tvb, offset);
+ qual = tvb_get_ntohl(tvb, offset + 4);
+
+ proto_tree_add_item(subtree, hf_sv_phmeas_instmag_i, tvb, offset, 4, ENC_BIG_ENDIAN);
+ proto_tree_add_bitmask(subtree, tvb, offset + 4, hf_sv_phsmeas_q, ett_phsmeas_q, q_flags, ENC_BIG_ENDIAN);
+
+ if (i < IEC61850_SV_MAX_PHSMEAS_ENTRIES) {
+ sv_data.phsMeas[i].value = value;
+ sv_data.phsMeas[i].qual = qual;
+ sv_data.num_phsMeas++;
+ }
+ }
+
+ offset += 8;
+ }
+
+ return offset;
+}
+
+#include "packet-sv-fn.c"
+
+/*
+* Dissect SV PDUs inside a PPDU.
+*/
+static int
+dissect_sv(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data _U_)
+{
+ int offset = 0;
+ int old_offset;
+ proto_item *item;
+ proto_tree *tree;
+ asn1_ctx_t asn1_ctx;
+
+ asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
+
+ item = proto_tree_add_item(parent_tree, proto_sv, tvb, 0, -1, ENC_NA);
+ tree = proto_item_add_subtree(item, ett_sv);
+
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ /* APPID */
+ proto_tree_add_item(tree, hf_sv_appid, tvb, offset, 2, ENC_BIG_ENDIAN);
+
+ /* Length */
+ proto_tree_add_item(tree, hf_sv_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
+
+ /* Reserved 1 */
+ proto_tree_add_item(tree, hf_sv_reserve1, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
+
+ /* Reserved 2 */
+ proto_tree_add_item(tree, hf_sv_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
+
+ offset = 8;
+ while (tvb_reported_length_remaining(tvb, offset) > 0){
+ old_offset = offset;
+ offset = dissect_sv_SampledValues(FALSE, tvb, offset, &asn1_ctx , tree, -1);
+ if (offset == old_offset) {
+ proto_tree_add_expert(tree, pinfo, &ei_sv_zero_pdu, tvb, offset, -1);
+ break;
+ }
+ }
+
+ tap_queue_packet(sv_tap, pinfo, &sv_data);
+ return tvb_captured_length(tvb);
+}
+
+
+/*--- proto_register_sv -------------------------------------------*/
+void proto_register_sv(void) {
+
+ /* List of fields */
+ static hf_register_info hf[] = {
+ { &hf_sv_appid,
+ { "APPID", "sv.appid", FT_UINT16, BASE_HEX, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_sv_length,
+ { "Length", "sv.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_sv_reserve1,
+ { "Reserved 1", "sv.reserve1", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_sv_reserve2,
+ { "Reserved 2", "sv.reserve2", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
+
+ { &hf_sv_phmeas_instmag_i,
+ { "value", "sv.meas_value", FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q,
+ { "quality", "sv.meas_quality", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_validity,
+ { "validity", "sv.meas_quality.validity", FT_UINT32, BASE_HEX, VALS(sv_q_validity_vals), Q_VALIDITY_MASK, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_overflow,
+ { "overflow", "sv.meas_quality.overflow", FT_BOOLEAN, 32, NULL, Q_OVERFLOW, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_outofrange,
+ { "out of range", "sv.meas_quality.outofrange", FT_BOOLEAN, 32, NULL, Q_OUTOFRANGE, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_badreference,
+ { "bad reference", "sv.meas_quality.badreference", FT_BOOLEAN, 32, NULL, Q_BADREFERENCE, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_oscillatory,
+ { "oscillatory", "sv.meas_quality.oscillatory", FT_BOOLEAN, 32, NULL, Q_OSCILLATORY, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_failure,
+ { "failure", "sv.meas_quality.failure", FT_BOOLEAN, 32, NULL, Q_FAILURE, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_olddata,
+ { "old data", "sv.meas_quality.olddata", FT_BOOLEAN, 32, NULL, Q_OLDDATA, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_inconsistent,
+ { "inconsistent", "sv.meas_quality.inconsistent", FT_BOOLEAN, 32, NULL, Q_INCONSISTENT, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_inaccurate,
+ { "inaccurate", "sv.meas_quality.inaccurate", FT_BOOLEAN, 32, NULL, Q_INACCURATE, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_source,
+ { "source", "sv.meas_quality.source", FT_UINT32, BASE_HEX, VALS(sv_q_source_vals), Q_SOURCE_MASK, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_test,
+ { "test", "sv.meas_quality.teset", FT_BOOLEAN, 32, NULL, Q_TEST, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_operatorblocked,
+ { "operator blocked", "sv.meas_quality.operatorblocked", FT_BOOLEAN, 32, NULL, Q_OPERATORBLOCKED, NULL, HFILL}},
+
+ { &hf_sv_phsmeas_q_derived,
+ { "derived", "sv.meas_quality.derived", FT_BOOLEAN, 32, NULL, Q_DERIVED, NULL, HFILL}},
+
+
+#include "packet-sv-hfarr.c"
+ };
+
+ /* List of subtrees */
+ static gint *ett[] = {
+ &ett_sv,
+ &ett_phsmeas,
+ &ett_phsmeas_q,
+#include "packet-sv-ettarr.c"
+ };
+
+ static ei_register_info ei[] = {
+ { &ei_sv_mal_utctime, { "sv.malformed.utctime", PI_MALFORMED, PI_WARN, "BER Error: malformed UTCTime encoding", EXPFILL }},
+ { &ei_sv_zero_pdu, { "sv.zero_pdu", PI_PROTOCOL, PI_ERROR, "Internal error, zero-byte SV PDU", EXPFILL }},
+ };
+
+ expert_module_t* expert_sv;
+ module_t *sv_module;
+
+ /* Register protocol */
+ proto_sv = proto_register_protocol(PNAME, PSNAME, PFNAME);
+ register_dissector("sv", dissect_sv, proto_sv);
+
+ /* Register fields and subtrees */
+ proto_register_field_array(proto_sv, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+ expert_sv = expert_register_protocol(proto_sv);
+ expert_register_field_array(expert_sv, ei, array_length(ei));
+ sv_module = prefs_register_protocol(proto_sv, NULL);
+ prefs_register_bool_preference(sv_module, "decode_data_as_phsmeas",
+ "Force decoding of seqData as PhsMeas",
+ NULL, &sv_decode_data_as_phsmeas);
+
+ /* Register tap */
+ sv_tap = register_tap("sv");
+}
+
+/*--- proto_reg_handoff_sv --- */
+void proto_reg_handoff_sv(void) {
+
+ dissector_handle_t sv_handle;
+ sv_handle = find_dissector("sv");
+
+ dissector_add_uint("ethertype", ETHERTYPE_IEC61850_SV, sv_handle);
+}
diff --git a/epan/dissectors/asn1/sv/packet-sv-template.h b/epan/dissectors/asn1/sv/packet-sv-template.h
new file mode 100644
index 0000000000..d19b86528c
--- /dev/null
+++ b/epan/dissectors/asn1/sv/packet-sv-template.h
@@ -0,0 +1,42 @@
+/* packet-sv.h
+ * Routines for IEC 61850 Sampled Vales packet dissection
+ * Michael Bernhard 2008
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#ifndef __PACKET_SV_H__
+#define __PACKET_SV_H__
+
+#define IEC61850_SV_MAX_PHSMEAS_ENTRIES 20
+
+typedef struct _sv_phs_meas {
+ gint32 value;
+ guint32 qual;
+} sv_phs_meas;
+
+typedef struct _sv_frame_data {
+ guint16 smpCnt;
+ 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/epan/dissectors/asn1/sv/sv.asn b/epan/dissectors/asn1/sv/sv.asn
new file mode 100644
index 0000000000..cf67100d3e
--- /dev/null
+++ b/epan/dissectors/asn1/sv/sv.asn
@@ -0,0 +1,28 @@
+IEC61850 DEFINITIONS ::= BEGIN
+
+SampledValues ::= CHOICE {
+ savPdu [APPLICATION 0] IMPLICIT SavPdu,
+ ...
+}
+
+SavPdu ::= SEQUENCE {
+ noASDU [0] IMPLICIT INTEGER(0..65535),
+ seqASDU [2] IMPLICIT SEQUENCE OF ASDU
+}
+
+ASDU ::= SEQUENCE {
+ svID [0] IMPLICIT VisibleString,
+ datSet [1] IMPLICIT VisibleString OPTIONAL,
+ smpCnt [2] IMPLICIT INTEGER(0..65535),
+ confRef [3] IMPLICIT INTEGER(0..4294967295),
+ 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/epan/dissectors/asn1/sv/sv.cnf b/epan/dissectors/asn1/sv/sv.cnf
new file mode 100644
index 0000000000..4b96de73e1
--- /dev/null
+++ b/epan/dissectors/asn1/sv/sv.cnf
@@ -0,0 +1,84 @@
+# sv.cnf
+# SampledValue conformation file
+
+#.MODULE_IMPORT
+
+#.EXPORTS
+
+#.PDU
+
+#.NO_EMIT ONLY_VALS
+SampledValues
+
+#.TYPE_RENAME
+
+#.FIELD_RENAME
+
+#.FN_BODY ASDU/smpCnt VAL_PTR = &value
+ guint32 value;
+%(DEFAULT_BODY)s
+ sv_data.smpCnt = value;
+#.END
+
+#.FN_BODY UtcTime
+ guint32 len;
+ guint32 seconds;
+ guint32 fraction;
+ guint32 nanoseconds;
+ nstime_t ts;
+ gchar * ptime;
+
+ len = tvb_reported_length_remaining(tvb, offset);
+
+ if(len != 8)
+ {
+ proto_tree_add_expert_format(tree, actx->pinfo, &ei_sv_mal_utctime, tvb, offset, len,
+ "BER Error: malformed UTCTime encoding, length must be 8 bytes");
+ 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_GUINT64_CONSTANT(1000000000)) / G_GUINT64_CONSTANT(0x100000000) ) ;
+
+ ts.secs = seconds;
+ ts.nsecs = nanoseconds;
+
+ ptime = abs_time_to_str(wmem_packet_scope(), &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;
+%(DEFAULT_BODY)s
+ sv_data.smpSynch = value;
+#.END
+
+#.FN_BODY ASDU/smpMod VAL_PTR = &value
+ guint32 value;
+%(DEFAULT_BODY)s
+ sv_data.smpMod = value;
+#.END
+
+#.FN_BODY Data
+ if (sv_decode_data_as_phsmeas) {
+ offset = dissect_PhsMeas1(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index);
+ } else {
+ offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
+ }
+#.END
+
+#.END_OF_CNF