/src/wireshark/epan/dissectors/packet-telkonet.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* packet-telkonet.c |
2 | | * Routines for ethertype 0x88A1 tunneling dissection |
3 | | * |
4 | | * Copyright 2006 Joerg Mayer (see AUTHORS file) |
5 | | * |
6 | | * Wireshark - Network traffic analyzer |
7 | | * By Gerald Combs <gerald@wireshark.org> |
8 | | * Copyright 1998 Gerald Combs |
9 | | * |
10 | | * SPDX-License-Identifier: GPL-2.0-or-later |
11 | | */ |
12 | | |
13 | | /* 2do: |
14 | | * - find out more about the real meaning of the 8 bytes |
15 | | * and possible other packet types |
16 | | * - Telkonet (www.telkonet.com) has registered other ethertypes |
17 | | * as well: find out what they do |
18 | | */ |
19 | | |
20 | | #include "config.h" |
21 | | |
22 | | #include <epan/packet.h> |
23 | | #include <epan/etypes.h> |
24 | | |
25 | | void proto_reg_handoff_telkonet(void); |
26 | | void proto_register_telkonet(void); |
27 | | |
28 | | static int proto_telkonet; |
29 | | static int hf_telkonet_type; |
30 | | |
31 | | static int ett_telkonet; |
32 | | |
33 | | static dissector_handle_t telkonet_handle; |
34 | | static dissector_handle_t eth_withoutfcs_handle; |
35 | | |
36 | | typedef enum { |
37 | | TELKONET_TYPE_TUNNEL = 0x78 |
38 | | } telkonet_type_t; |
39 | | |
40 | | static const value_string telkonet_type_vals[] = { |
41 | | { TELKONET_TYPE_TUNNEL, "tunnel" }, |
42 | | |
43 | | { 0x00, NULL } |
44 | | }; |
45 | | |
46 | | static int |
47 | | dissect_telkonet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
48 | 5 | { |
49 | 5 | proto_tree *ti, *telkonet_tree; |
50 | 5 | int offset = 0; |
51 | 5 | telkonet_type_t type; |
52 | | |
53 | 5 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "TELKONET"); |
54 | 5 | col_clear(pinfo->cinfo, COL_INFO); |
55 | | |
56 | 5 | type = (telkonet_type_t)tvb_get_uint8(tvb, offset); |
57 | 5 | col_add_fstr(pinfo->cinfo, COL_INFO, "Telkonet type: %s", |
58 | 5 | val_to_str(type, telkonet_type_vals, "Unknown (0x%02x)")); |
59 | | |
60 | 5 | ti = proto_tree_add_item(tree, proto_telkonet, tvb, 0, 8, ENC_NA); |
61 | 5 | telkonet_tree = proto_item_add_subtree(ti, ett_telkonet); |
62 | | |
63 | 5 | proto_tree_add_item(telkonet_tree, hf_telkonet_type, tvb, 0, 8, ENC_NA); |
64 | 5 | offset += 8; |
65 | | |
66 | 5 | if (type == TELKONET_TYPE_TUNNEL) |
67 | 0 | call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, offset), |
68 | 0 | pinfo, tree); |
69 | | |
70 | 5 | return tvb_captured_length(tvb); |
71 | 5 | } |
72 | | |
73 | | void |
74 | | proto_register_telkonet(void) |
75 | 14 | { |
76 | 14 | static hf_register_info hf[] = { |
77 | 14 | { &hf_telkonet_type, |
78 | 14 | { "Type", "telkonet.type", FT_BYTES, BASE_NONE, NULL, |
79 | 14 | 0x0, "TELKONET type", HFILL }}, |
80 | 14 | }; |
81 | 14 | static int *ett[] = { |
82 | 14 | &ett_telkonet, |
83 | 14 | }; |
84 | | |
85 | 14 | proto_telkonet = proto_register_protocol("Telkonet powerline", "TELKONET", "telkonet"); |
86 | 14 | proto_register_field_array(proto_telkonet, hf, array_length(hf)); |
87 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
88 | 14 | telkonet_handle = register_dissector("telkonet", dissect_telkonet, proto_telkonet); |
89 | 14 | } |
90 | | |
91 | | void |
92 | | proto_reg_handoff_telkonet(void) |
93 | 14 | { |
94 | 14 | eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_telkonet); |
95 | | |
96 | 14 | dissector_add_uint("ethertype", ETHERTYPE_TELKONET, telkonet_handle); |
97 | 14 | } |
98 | | |
99 | | /* |
100 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
101 | | * |
102 | | * Local variables: |
103 | | * c-basic-offset: 8 |
104 | | * tab-width: 8 |
105 | | * indent-tabs-mode: t |
106 | | * End: |
107 | | * |
108 | | * vi: set shiftwidth=8 tabstop=8 noexpandtab: |
109 | | * :indentSize=8:tabSize=8:noTabs=false: |
110 | | */ |