MSWSP: use GuidPropertySet_find_guid() in parse_CFullPropSpec()
[wireshark-wip.git] / asn1 / goose / packet-goose-template.c
blobc65a9b1d9f85bc9dd947a8ce152d805cb6c9e3db
1 /* packet-goose.c
2 * Routines for IEC 61850 GOOSE packet dissection
3 * Martin Lutz 2008
5 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "config.h"
28 #include <glib.h>
29 #include <epan/packet.h>
30 #include <epan/asn1.h>
31 #include <epan/etypes.h>
32 #include <epan/expert.h>
34 #include "packet-ber.h"
35 #include "packet-acse.h"
37 #define PNAME "GOOSE"
38 #define PSNAME "GOOSE"
39 #define PFNAME "goose"
41 /* Initialize the protocol and registered fields */
42 static int proto_goose = -1;
43 static int hf_goose_appid = -1;
44 static int hf_goose_length = -1;
45 static int hf_goose_reserve1 = -1;
46 static int hf_goose_reserve2 = -1;
48 static expert_field ei_goose_mal_utctime = EI_INIT;
50 #include "packet-goose-hf.c"
52 /* Initialize the subtree pointers */
53 static int ett_goose = -1;
55 #include "packet-goose-ett.c"
57 #include "packet-goose-fn.c"
60 * Dissect GOOSE PDUs inside a PPDU.
62 static void
63 dissect_goose(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
65 int offset = 0;
66 int old_offset;
67 guint16 length;
68 proto_item *item = NULL;
69 proto_tree *tree = NULL;
70 asn1_ctx_t asn1_ctx;
71 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
73 col_set_str(pinfo->cinfo, COL_PROTOCOL, PNAME);
74 col_clear(pinfo->cinfo, COL_INFO);
76 if (parent_tree){
77 item = proto_tree_add_item(parent_tree, proto_goose, tvb, 0, -1, ENC_NA);
78 tree = proto_item_add_subtree(item, ett_goose);
81 /* APPID */
82 proto_tree_add_item(tree, hf_goose_appid, tvb, offset, 2, ENC_BIG_ENDIAN);
84 /* Length */
85 length = tvb_get_ntohs(tvb, offset + 2);
86 proto_tree_add_item(tree, hf_goose_length, tvb, offset + 2, 2, ENC_BIG_ENDIAN);
88 /* Reserved 1 */
89 proto_tree_add_item(tree, hf_goose_reserve1, tvb, offset + 4, 2, ENC_BIG_ENDIAN);
91 /* Reserved 2 */
92 proto_tree_add_item(tree, hf_goose_reserve2, tvb, offset + 6, 2, ENC_BIG_ENDIAN);
94 offset = 8;
95 while (offset < length){
96 old_offset = offset;
97 offset = dissect_goose_GOOSEpdu(FALSE, tvb, offset, &asn1_ctx , tree, -1);
98 if (offset == old_offset) {
99 proto_tree_add_text(tree, tvb, offset, -1, "Internal error, zero-byte GOOSE PDU");
100 return;
107 /*--- proto_register_goose -------------------------------------------*/
108 void proto_register_goose(void) {
110 /* List of fields */
111 static hf_register_info hf[] =
113 { &hf_goose_appid,
114 { "APPID", "goose.appid", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
116 { &hf_goose_length,
117 { "Length", "goose.length", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }},
119 { &hf_goose_reserve1,
120 { "Reserved 1", "goose.reserve1", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
122 { &hf_goose_reserve2,
123 { "Reserved 2", "goose.reserve2", FT_UINT16, BASE_HEX_DEC, NULL, 0x0, NULL, HFILL }},
125 #include "packet-goose-hfarr.c"
128 /* List of subtrees */
129 static gint *ett[] = {
130 &ett_goose,
131 #include "packet-goose-ettarr.c"
134 static ei_register_info ei[] = {
135 { &ei_goose_mal_utctime, { "goose.malformed.utctime", PI_MALFORMED, PI_WARN, "BER Error: malformed UTCTime encoding", EXPFILL }},
138 expert_module_t* expert_goose;
140 /* Register protocol */
141 proto_goose = proto_register_protocol(PNAME, PSNAME, PFNAME);
142 register_dissector("goose", dissect_goose, proto_goose);
144 /* Register fields and subtrees */
145 proto_register_field_array(proto_goose, hf, array_length(hf));
146 proto_register_subtree_array(ett, array_length(ett));
147 expert_goose = expert_register_protocol(proto_goose);
148 expert_register_field_array(expert_goose, ei, array_length(ei));
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_uint("ethertype", ETHERTYPE_IEC61850_GOOSE, goose_handle);