2 * Routines for IEC 61850 GOOSE packet dissection
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include <epan/asn1.h>
33 #include <epan/etypes.h>
34 #include <epan/expert.h>
35 #include <epan/nstime.h>
37 #include "packet-ber.h"
38 #include "packet-acse.h"
41 #define PSNAME "GOOSE"
42 #define PFNAME "goose"
44 /* Initialize the protocol and registered fields */
45 static int proto_goose = -1;
46 static int hf_goose_appid = -1;
47 static int hf_goose_length = -1;
48 static int hf_goose_reserve1 = -1;
49 static int hf_goose_reserve2 = -1;
51 #include "packet-goose-hf.c"
53 /* Initialize the subtree pointers */
54 static int ett_goose = -1;
56 #include "packet-goose-ett.c"
58 #include "packet-goose-fn.c"
61 * Dissect GOOSE PDUs inside a PPDU.
64 dissect_goose(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
69 proto_item *item = NULL;
70 proto_tree *tree = NULL;
72 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
75 item = proto_tree_add_item(parent_tree, proto_goose, tvb, 0, -1, FALSE);
76 tree = proto_item_add_subtree(item, ett_goose);
78 col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);
79 col_clear(pinfo->cinfo, COL_INFO);
82 if (tree && tvb_reported_length_remaining(tvb, offset) >= 2) {
83 data = tvb_get_ntohs(tvb, offset);
84 proto_tree_add_uint(tree, hf_goose_appid, tvb, offset, 2, data);
87 if (tree && tvb_reported_length_remaining(tvb, offset) >= 4) {
88 data = tvb_get_ntohs(tvb, offset + 2);
89 proto_tree_add_uint(tree, hf_goose_length, tvb, offset + 2, 2, data);
92 if (tree && tvb_reported_length_remaining(tvb, offset) >= 6) {
93 data = tvb_get_ntohs(tvb, offset + 4);
94 proto_tree_add_uint(tree, hf_goose_reserve1, tvb, offset + 4, 2, data);
97 if (tree && tvb_reported_length_remaining(tvb, offset) >= 8) {
98 data = tvb_get_ntohs(tvb, offset + 6);
99 proto_tree_add_uint(tree, hf_goose_reserve2, tvb, offset + 6, 2, data);
103 while (tree && tvb_reported_length_remaining(tvb, offset) > 0){
105 offset = dissect_goose_GOOSEpdu(FALSE, tvb, offset, &asn1_ctx , tree, -1);
106 if (offset == old_offset) {
107 proto_tree_add_text(tree, tvb, offset, -1, "Internal error, zero-byte GOOSE PDU");
114 /*--- proto_register_goose -------------------------------------------*/
115 void proto_register_goose(void) {
118 static hf_register_info hf[] =
121 { "APPID", "goose.appid", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
124 { "Length", "goose.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
126 { &hf_goose_reserve1,
127 { "Reserved 1", "goose.reserve1", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
129 { &hf_goose_reserve2,
130 { "Reserved 2", "goose.reserve2", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
132 #include "packet-goose-hfarr.c"
135 /* List of subtrees */
136 static gint *ett[] = {
138 #include "packet-goose-ettarr.c"
141 /* Register protocol */
142 proto_goose = proto_register_protocol(PNAME, PSNAME, PFNAME);
143 register_dissector("goose", dissect_goose, proto_goose);
145 /* Register fields and subtrees */
146 proto_register_field_array(proto_goose, hf, array_length(hf));
147 proto_register_subtree_array(ett, array_length(ett));
151 /*--- proto_reg_handoff_goose --- */
152 void proto_reg_handoff_goose(void) {
154 dissector_handle_t goose_handle;
155 goose_handle = find_dissector("goose");
157 dissector_add("ethertype", ETHERTYPE_IEC61850_GOOSE, goose_handle);