HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-telkonet.c
bloba6109e5fb2312f7fbcec0f15d83271b937103701
1 /* packet-telkonet.c
2 * Routines for ethertype 0x88A1 tunneling dissection
4 * $Id$
6 * Copyright 2006 Joerg Mayer (see AUTHORS file)
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 /* 2do:
28 * - find out more about the real meaning of the 8 bytes
29 * and possible other packet types
30 * - Telkonet (www.telkonet.com) has registered other ethertypes
31 * as well: find out what they do
34 #include "config.h"
36 #include <glib.h>
37 #include <epan/packet.h>
38 #include <epan/etypes.h>
40 static int proto_telkonet = -1;
41 static int hf_telkonet_type = -1;
43 static gint ett_telkonet = -1;
45 static dissector_handle_t eth_withoutfcs_handle;
47 typedef enum {
48 TELKONET_TYPE_TUNNEL = 0x78
49 } telkonet_type_t;
51 static const value_string telkonet_type_vals[] = {
52 { TELKONET_TYPE_TUNNEL, "tunnel" },
54 { 0x00, NULL }
57 static void
58 dissect_telkonet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
60 proto_tree *ti, *telkonet_tree;
61 int offset = 0;
62 telkonet_type_t type;
64 col_set_str(pinfo->cinfo, COL_PROTOCOL, "TELKONET");
65 col_clear(pinfo->cinfo, COL_INFO);
67 type = (telkonet_type_t)tvb_get_guint8(tvb, offset);
68 col_add_fstr(pinfo->cinfo, COL_INFO, "Telkonet type: %s",
69 val_to_str(type, telkonet_type_vals, "Unknown (0x%02x)"));
71 ti = proto_tree_add_item(tree, proto_telkonet, tvb, 0, 8, ENC_NA);
72 telkonet_tree = proto_item_add_subtree(ti, ett_telkonet);
74 proto_tree_add_item(telkonet_tree, hf_telkonet_type, tvb, 0, 8, ENC_NA);
75 offset += 8;
77 if (type == TELKONET_TYPE_TUNNEL)
78 call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, offset),
79 pinfo, tree);
82 void
83 proto_register_telkonet(void)
85 static hf_register_info hf[] = {
86 { &hf_telkonet_type,
87 { "Type", "telkonet.type", FT_BYTES, BASE_NONE, NULL,
88 0x0, "TELKONET type", HFILL }},
90 static gint *ett[] = {
91 &ett_telkonet,
94 proto_telkonet = proto_register_protocol("Telkonet powerline", "TELKONET", "telkonet");
95 proto_register_field_array(proto_telkonet, hf, array_length(hf));
96 proto_register_subtree_array(ett, array_length(ett));
99 void
100 proto_reg_handoff_telkonet(void)
102 dissector_handle_t telkonet_handle;
104 eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
106 telkonet_handle = create_dissector_handle(dissect_telkonet, proto_telkonet);
107 dissector_add_uint("ethertype", ETHERTYPE_TELKONET, telkonet_handle);