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);
74 col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);
75 col_clear(pinfo->cinfo, COL_INFO);
78 item = proto_tree_add_item(parent_tree, proto_goose, tvb, 0, -1, ENC_NA);
79 tree = proto_item_add_subtree(item, ett_goose);
83 proto_tree_add_item(tree, hf_goose_appid, tvb, offset, 2, ENC_BIG_ENDIAN);
86 length = tvb_get_ntohs(tvb, offset + 2);
87 proto_tree_add_item(tree, hf_goose_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
90 proto_tree_add_item(tree, hf_goose_reserve1, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
93 proto_tree_add_item(tree, hf_goose_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
96 while (offset < length){
98 offset = dissect_goose_GOOSEpdu(FALSE, tvb, offset, &asn1_ctx , tree, -1);
99 if (offset == old_offset) {
100 proto_tree_add_text(tree, tvb, offset, -1, "Internal error, zero-byte GOOSE PDU");
108 /*--- proto_register_goose -------------------------------------------*/
109 void proto_register_goose(void) {
112 static hf_register_info hf[] =
115 { "APPID", "goose.appid", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
118 { "Length", "goose.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
120 { &hf_goose_reserve1,
121 { "Reserved 1", "goose.reserve1", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
123 { &hf_goose_reserve2,
124 { "Reserved 2", "goose.reserve2", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
126 #include "packet-goose-hfarr.c"
129 /* List of subtrees */
130 static gint *ett[] = {
132 #include "packet-goose-ettarr.c"
135 /* Register protocol */
136 proto_goose = proto_register_protocol(PNAME, PSNAME, PFNAME);
137 register_dissector("goose", dissect_goose, proto_goose);
139 /* Register fields and subtrees */
140 proto_register_field_array(proto_goose, hf, array_length(hf));
141 proto_register_subtree_array(ett, array_length(ett));
145 /*--- proto_reg_handoff_goose --- */
146 void proto_reg_handoff_goose(void) {
148 dissector_handle_t goose_handle;
149 goose_handle = find_dissector("goose");
151 dissector_add_uint("ethertype", ETHERTYPE_IEC61850_GOOSE, goose_handle);