aboutsummaryrefslogtreecommitdiffstats
path: root/asn1
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2008-10-13 19:31:12 +0000
committerAnders Broman <anders.broman@ericsson.com>2008-10-13 19:31:12 +0000
commit61fdd2f1f6c2ec509e78edeaa707ade77975f404 (patch)
tree121693e3d2789d50d4123c6e62a915e0e5cb1a9d /asn1
parent13843b56dfd822d967e0dd36b4d8650b47b9460b (diff)
From Martin Lutz:
IEC 61850 GOOSE protocol svn path=/trunk/; revision=26440
Diffstat (limited to 'asn1')
-rw-r--r--asn1/goose/Makefile.am26
-rw-r--r--asn1/goose/Makefile.common45
-rw-r--r--asn1/goose/Makefile.nmake29
-rw-r--r--asn1/goose/goose.asn136
-rw-r--r--asn1/goose/goose.cnf18
-rw-r--r--asn1/goose/packet-goose-template.c163
6 files changed, 417 insertions, 0 deletions
diff --git a/asn1/goose/Makefile.am b/asn1/goose/Makefile.am
new file mode 100644
index 0000000000..462af31e88
--- /dev/null
+++ b/asn1/goose/Makefile.am
@@ -0,0 +1,26 @@
+# $Id$
+#
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+include ../Makefile.preinc
+include Makefile.common
+include ../Makefile.inc
+
diff --git a/asn1/goose/Makefile.common b/asn1/goose/Makefile.common
new file mode 100644
index 0000000000..cf92a45385
--- /dev/null
+++ b/asn1/goose/Makefile.common
@@ -0,0 +1,45 @@
+# $Id$
+#
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+PROTOCOL_NAME=goose
+
+DISSECTOR_FILES=packet-$(PROTOCOL_NAME).c \
+ packet-$(PROTOCOL_NAME).h
+
+
+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 = \
+ Makefile.nmake \
+ $(ASN_FILE_LIST) \
+ packet-$(PROTOCOL_NAME)-template.c \
+ $(PROTOCOL_NAME).cnf
+
+SRC_FILES = \
+ $(EXTRA_DIST) \
+ $(EXT_ASN_FILE_LIST)
+
+A2W_FLAGS= -b
diff --git a/asn1/goose/Makefile.nmake b/asn1/goose/Makefile.nmake
new file mode 100644
index 0000000000..5a32997c60
--- /dev/null
+++ b/asn1/goose/Makefile.nmake
@@ -0,0 +1,29 @@
+## Use: $(MAKE) /$(MAKEFLAGS) -f makefile.nmake
+#
+# $Id$
+#
+#
+# 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+
+include ../../config.nmake
+include ../Makefile.preinc.nmake
+include Makefile.common
+include ../Makefile.inc.nmake
+
diff --git a/asn1/goose/goose.asn b/asn1/goose/goose.asn
new file mode 100644
index 0000000000..5247ac98a6
--- /dev/null
+++ b/asn1/goose/goose.asn
@@ -0,0 +1,136 @@
+-- $Id$
+IEC61850 DEFINITIONS ::= BEGIN
+
+GOOSEpdu ::= CHOICE {
+ gseMngtPdu [APPLICATION 0] IMPLICIT GSEMngtPdu,
+ goosePdu [APPLICATION 1] IMPLICIT IECGoosePdu,
+ ...
+}
+
+GSEMngtPdu ::= SEQUENCE {
+ stateID [0] IMPLICIT INTEGER,
+-- security [3] ANY OPTIONAL,
+ -- reserved for future definition
+ requestResp RequestResponse
+-- CHOICE {
+-- requests [1] IMPLICIT GSEMngtRequests,
+-- responses [2] IMPLICIT GSEMngtResponses
+-- }
+}
+
+RequestResponse ::= CHOICE {
+ requests [1] IMPLICIT GSEMngtRequests,
+ responses [2] IMPLICIT GSEMngtResponses
+}
+
+GSEMngtRequests ::= CHOICE {
+ getGoReference [1] IMPLICIT GetReferenceRequestPdu,
+ getGOOSEElementNumber [2] IMPLICIT GetElementRequestPdu,
+ getGsReference [3] IMPLICIT GetReferenceRequestPdu,
+ getGSSEDataOffset [4] IMPLICIT GetElementRequestPdu,
+ ...
+}
+
+GSEMngtResponses ::= CHOICE {
+ gseMngtNotSupported [0] IMPLICIT NULL,
+ getGoReference [1] IMPLICIT GSEMngtResponsePdu,
+ getGOOSEElementNumber [2] IMPLICIT GSEMngtResponsePdu,
+ getGsReference [3] IMPLICIT GSEMngtResponsePdu,
+ getGSSEDataOffset [4] IMPLICIT GSEMngtResponsePdu,
+ ...
+}
+
+GetReferenceRequestPdu ::= SEQUENCE {
+ ident [0] IMPLICIT VisibleString, -- size shall support up to 65 octets
+ offset [1] IMPLICIT SEQUENCE OF INTEGER,
+ ...
+}
+
+GetElementRequestPdu ::= SEQUENCE {
+ ident [0] IMPLICIT VisibleString, -- size shall support up to 65 octets
+ references [1] IMPLICIT SEQUENCE OF VisibleString,
+ ...
+}
+
+GSEMngtResponsePdu ::= SEQUENCE {
+ ident [0] IMPLICIT VisibleString, -- echos the value of the request
+ confRev [1] IMPLICIT INTEGER OPTIONAL,
+ posNeg PositiveNegative,
+-- CHOICE {
+-- responsePositive [2] IMPLICIT SEQUENCE {
+-- datSet [0] IMPLICIT VisibleString OPTIONAL,
+-- result [1] IMPLICIT SEQUENCE OF RequestResults
+-- },
+-- responseNegative [3] IMPLICIT GlbErrors
+-- },
+ ...
+}
+
+PositiveNegative ::= CHOICE {
+ responsePositive [2] IMPLICIT SEQUENCE {
+ datSet [0] IMPLICIT VisibleString OPTIONAL,
+ result [1] IMPLICIT SEQUENCE OF RequestResults
+ },
+ responseNegative [3] IMPLICIT GlbErrors
+}
+
+RequestResults::= CHOICE {
+ offset [0] IMPLICIT INTEGER,
+ reference [1] IMPLICIT IA5String,
+ error [2] IMPLICIT ErrorReason
+}
+
+GlbErrors ::= INTEGER {
+ other(0),
+ unknownControlBlock(1),
+ responseTooLarge(2),
+ controlBlockConfigurationError(3) --,
+-- ...
+}
+
+ErrorReason ::= INTEGER {
+ other (0),
+ notFound (1) --,
+-- ...
+}
+
+IECGoosePdu ::= SEQUENCE {
+ gocbRef [0] IMPLICIT VisibleString,
+ timeAllowedtoLive [1] IMPLICIT INTEGER,
+ datSet [2] IMPLICIT VisibleString,
+ goID [3] IMPLICIT VisibleString OPTIONAL,
+ t [4] IMPLICIT UtcTime,
+ stNum [5] IMPLICIT INTEGER,
+ sqNum [6] IMPLICIT INTEGER,
+ test [7] IMPLICIT BOOLEAN DEFAULT FALSE,
+ confRev [8] IMPLICIT INTEGER,
+ ndsCom [9] IMPLICIT BOOLEAN DEFAULT FALSE,
+ numDatSetEntries [10] IMPLICIT INTEGER,
+ allData [11] IMPLICIT SEQUENCE OF Data --,
+-- security [12] ANY OPTIONAL
+ -- reserved for digital signature
+}
+
+UtcTime ::= OCTET STRING -- format and size defined in 8.1.3.6.
+
+TimeOfDay ::= OCTET STRING -- (SIZE (4 | 6))
+FloatingPoint ::= OCTET STRING
+
+Data ::= CHOICE {
+ -- context tag 0 is reserved for AccessResult
+ array [1] IMPLICIT SEQUENCE OF Data,
+ structure [2] IMPLICIT SEQUENCE OF Data,
+ boolean [3] IMPLICIT BOOLEAN,
+ bit-string [4] IMPLICIT BIT STRING,
+ integer [5] IMPLICIT INTEGER,
+ unsigned [6] IMPLICIT INTEGER,
+ floating-point [7] IMPLICIT FloatingPoint,
+ real [8] IMPLICIT REAL,
+ octet-string [9] IMPLICIT OCTET STRING,
+ visible-string [10] IMPLICIT VisibleString,
+ binary-time [12] IMPLICIT TimeOfDay,
+ bcd [13] IMPLICIT INTEGER,
+ booleanArray [14] IMPLICIT BIT STRING
+}
+
+END
diff --git a/asn1/goose/goose.cnf b/asn1/goose/goose.cnf
new file mode 100644
index 0000000000..dc8fa6ebd4
--- /dev/null
+++ b/asn1/goose/goose.cnf
@@ -0,0 +1,18 @@
+# goose.cnf
+# goose conformation file
+
+# $Id$
+
+#.MODULE_IMPORT
+
+#.EXPORTS
+
+#.PDU
+
+#.NO_EMIT
+
+#.TYPE_RENAME
+
+#.FIELD_RENAME
+
+#.END
diff --git a/asn1/goose/packet-goose-template.c b/asn1/goose/packet-goose-template.c
new file mode 100644
index 0000000000..4afe021439
--- /dev/null
+++ b/asn1/goose/packet-goose-template.c
@@ -0,0 +1,163 @@
+/* packet-goose.c
+ * Routines for IEC 61850 GOOSE packet dissection
+ * Martin Lutz 2008
+ *
+ * $Id$
+ *
+ * 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <glib.h>
+#include <epan/packet.h>
+#include <epan/conversation.h>
+#include <epan/asn1.h>
+#include <epan/etypes.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "packet-ber.h"
+#include "packet-acse.h"
+
+#define PNAME "GOOSE"
+#define PSNAME "GOOSE"
+#define PFNAME "goose"
+
+/* Initialize the protocol and registered fields */
+static int proto_goose = -1;
+static int hf_goose_appid = -1;
+static int hf_goose_length = -1;
+static int hf_goose_reserve1 = -1;
+static int hf_goose_reserve2 = -1;
+
+#include "packet-goose-hf.c"
+
+/* Initialize the subtree pointers */
+static int ett_goose = -1;
+
+#include "packet-goose-ett.c"
+
+#include "packet-goose-fn.c"
+
+/*
+* Dissect GOOSE PDUs inside a PPDU.
+*/
+static void
+dissect_goose(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
+{
+ int offset = 0;
+ int old_offset;
+ guint16 data;
+ proto_item *item = NULL;
+ proto_tree *tree = NULL;
+ asn1_ctx_t asn1_ctx;
+ asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
+
+ if (parent_tree){
+ item = proto_tree_add_item(parent_tree, proto_goose, tvb, 0, -1, FALSE);
+ tree = proto_item_add_subtree(item, ett_goose);
+ }
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);
+ if (check_col(pinfo->cinfo, COL_INFO))
+ col_clear(pinfo->cinfo, COL_INFO);
+
+ /* APPID */
+ if (tree && tvb_reported_length_remaining(tvb, offset) >= 2) {
+ data = tvb_get_ntohs(tvb, offset);
+ proto_tree_add_uint(tree, hf_goose_appid, tvb, offset, 2, data);
+ }
+ /* Length */
+ if (tree && tvb_reported_length_remaining(tvb, offset) >= 4) {
+ data = tvb_get_ntohs(tvb, offset + 2);
+ proto_tree_add_uint(tree, hf_goose_length, tvb, offset + 2, 2, data);
+ }
+ /* Reserved 1 */
+ if (tree && tvb_reported_length_remaining(tvb, offset) >= 6) {
+ data = tvb_get_ntohs(tvb, offset + 4);
+ proto_tree_add_uint(tree, hf_goose_reserve1, tvb, offset + 4, 2, data);
+ }
+ /* Reserved 2 */
+ if (tree && tvb_reported_length_remaining(tvb, offset) >= 8) {
+ data = tvb_get_ntohs(tvb, offset + 6);
+ proto_tree_add_uint(tree, hf_goose_reserve2, tvb, offset + 6, 2, data);
+ }
+
+ offset = 8;
+ while (tree && tvb_reported_length_remaining(tvb, offset) > 0){
+ old_offset = offset;
+ offset = dissect_goose_GOOSEpdu(FALSE, tvb, offset, &asn1_ctx , tree, -1);
+ if (offset == old_offset) {
+ proto_tree_add_text(tree, tvb, offset, -1, "Internal error, zero-byte GOOSE PDU");
+ offset = tvb_length(tvb);
+ break;
+ }
+ }
+}
+
+
+/*--- proto_register_goose -------------------------------------------*/
+void proto_register_goose(void) {
+
+ /* List of fields */
+ static hf_register_info hf[] =
+ {
+ { &hf_goose_appid,
+ { "APPID", "goose.appid", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, "", HFILL }},
+
+ { &hf_goose_length,
+ { "Length", "goose.length", FT_UINT16, BASE_DEC, NULL, 0x0, "", HFILL }},
+
+ { &hf_goose_reserve1,
+ { "Reserved 1", "goose.reserve1", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, "", HFILL }},
+
+ { &hf_goose_reserve2,
+ { "Reserved 2", "goose.reserve2", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, "", HFILL }},
+
+#include "packet-goose-hfarr.c"
+ };
+
+ /* List of subtrees */
+ static gint *ett[] = {
+ &ett_goose,
+#include "packet-goose-ettarr.c"
+ };
+
+ /* Register protocol */
+ proto_goose = proto_register_protocol(PNAME, PSNAME, PFNAME);
+ register_dissector("goose", dissect_goose, proto_goose);
+
+ /* Register fields and subtrees */
+ proto_register_field_array(proto_goose, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+
+}
+
+/*--- proto_reg_handoff_goose --- */
+void proto_reg_handoff_goose(void) {
+
+ dissector_handle_t goose_handle;
+ goose_handle = find_dissector("goose");
+
+ dissector_add("ethertype", ETHERTYPE_IEC61850_GOOSE, goose_handle);
+}