/src/wireshark/epan/dissectors/packet-openthread.c
Line | Count | Source |
1 | | /* packet-openthread.c |
2 | | * Simple dissector for OpenThread loopback interface |
3 | | * |
4 | | * Robert Cragie <robert.cragie@arm.com> |
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 | | #include "config.h" |
14 | | |
15 | | #include <epan/packet.h> |
16 | | |
17 | | /* Forward declarations */ |
18 | | void proto_register_openthread(void); |
19 | | void proto_reg_handoff_openthread(void); |
20 | | |
21 | | static int proto_openthread; |
22 | | |
23 | | static dissector_handle_t openthread_handle; |
24 | | static dissector_handle_t wpan_handle; |
25 | | |
26 | | static int hf_openthread_channel; |
27 | | /* static int hf_openthread_psdu; */ |
28 | | |
29 | | static int ett_openthread; |
30 | | |
31 | | static int |
32 | | dissect_openthread(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) |
33 | 0 | { |
34 | 0 | proto_item *proto_root; |
35 | 0 | proto_tree *openthread_tree; |
36 | 0 | tvbuff_t *sub_tvb; |
37 | | |
38 | | /* Create the protocol tree. */ |
39 | 0 | proto_root = proto_tree_add_item(tree, proto_openthread, tvb, 0, -1, ENC_NA); |
40 | 0 | openthread_tree = proto_item_add_subtree(proto_root, ett_openthread); |
41 | |
|
42 | 0 | proto_tree_add_item(openthread_tree, hf_openthread_channel, tvb, 0, 1, ENC_NA); |
43 | 0 | sub_tvb = tvb_new_subset_length(tvb, 1, tvb_reported_length_remaining(tvb, 3)); /* Note - truncate the last two "phoney" CRC bytes */ |
44 | 0 | call_dissector(wpan_handle, sub_tvb, pinfo, tree); |
45 | |
|
46 | 0 | return tvb_captured_length(tvb); |
47 | 0 | } |
48 | | |
49 | | void |
50 | | proto_register_openthread(void) |
51 | 16 | { |
52 | 16 | static hf_register_info hf[] = { |
53 | | |
54 | | /* Generic TLV */ |
55 | 16 | { &hf_openthread_channel, |
56 | 16 | { "Channel", |
57 | 16 | "openthread.channel", |
58 | 16 | FT_UINT8, BASE_DEC, NULL, 0x0, |
59 | 16 | NULL, |
60 | 16 | HFILL } |
61 | 16 | }, |
62 | | #if 0 |
63 | | { &hf_openthread_psdu, |
64 | | { "PSDU", |
65 | | "openthread.psdu", |
66 | | FT_NONE, BASE_NONE, NULL, 0x0, |
67 | | NULL, |
68 | | HFILL } |
69 | | } |
70 | | #endif |
71 | 16 | }; |
72 | | |
73 | 16 | static int *ett[] = { |
74 | 16 | &ett_openthread |
75 | 16 | }; |
76 | | |
77 | 16 | proto_openthread = proto_register_protocol("OpenThread", "OpenThread", "openthread"); |
78 | 16 | proto_register_field_array(proto_openthread, hf, array_length(hf)); |
79 | 16 | proto_register_subtree_array(ett, array_length(ett)); |
80 | 16 | openthread_handle = register_dissector("openthread", dissect_openthread, proto_openthread); |
81 | 16 | } |
82 | | |
83 | | void |
84 | | proto_reg_handoff_openthread(void) |
85 | 16 | { |
86 | 16 | wpan_handle = find_dissector_add_dependency("wpan_nofcs", proto_openthread); |
87 | 16 | dissector_add_for_decode_as("udp.port", openthread_handle); |
88 | 16 | } |
89 | | |
90 | | /* |
91 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
92 | | * |
93 | | * Local variables: |
94 | | * c-basic-offset: 4 |
95 | | * tab-width: 8 |
96 | | * indent-tabs-mode: nil |
97 | | * End: |
98 | | * |
99 | | * vi: set shiftwidth=4 tabstop=8 expandtab: |
100 | | * :indentSize=4:tabSize=8:noTabs=true: |
101 | | */ |