/src/wireshark/epan/dissectors/packet-wfleet-hdlc.c
Line | Count | Source |
1 | | /* packet-wfleet-hdlc.c |
2 | | * Routines for Wellfleet HDLC packet disassembly |
3 | | * Copied from the Cisco HDLC packet disassembly routines |
4 | | * |
5 | | * Wireshark - Network traffic analyzer |
6 | | * By Gerald Combs <gerald@wireshark.org> |
7 | | * Copyright 1998 Gerald Combs |
8 | | * |
9 | | * SPDX-License-Identifier: GPL-2.0-or-later |
10 | | */ |
11 | | |
12 | | #include "config.h" |
13 | | |
14 | | #include <epan/packet.h> |
15 | | #include <epan/addr_resolv.h> |
16 | | |
17 | | void proto_register_wfleet_hdlc(void); |
18 | | void proto_reg_handoff_wfleet_hdlc(void); |
19 | | |
20 | | static int proto_wfleet_hdlc; |
21 | | static int hf_wfleet_hdlc_addr; |
22 | | static int hf_wfleet_hdlc_cmd; |
23 | | |
24 | | static int ett_wfleet_hdlc; |
25 | | |
26 | | static dissector_handle_t eth_withoutfcs_handle; |
27 | | static dissector_handle_t wfleet_hdlc_handle; |
28 | | |
29 | | static const value_string wfleet_hdlc_cmd_vals[] = { |
30 | | { 0x03, "Un-numbered I frame"}, |
31 | | { 0, NULL} |
32 | | }; |
33 | | |
34 | | static int |
35 | | dissect_wfleet_hdlc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
36 | 0 | { |
37 | 0 | proto_item *ti; |
38 | 0 | proto_tree *fh_tree = NULL; |
39 | 0 | tvbuff_t *next_tvb; |
40 | 0 | uint8_t addr; |
41 | 0 | uint8_t cmd; |
42 | |
|
43 | 0 | col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A"); |
44 | 0 | col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A"); |
45 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "WHDLC"); |
46 | 0 | col_clear(pinfo->cinfo, COL_INFO); |
47 | |
|
48 | 0 | addr = tvb_get_uint8(tvb, 0); |
49 | 0 | cmd = tvb_get_uint8(tvb, 1); |
50 | |
|
51 | 0 | if (tree) { |
52 | 0 | ti = proto_tree_add_item(tree, proto_wfleet_hdlc, tvb, 0, 2, ENC_NA); |
53 | 0 | fh_tree = proto_item_add_subtree(ti, ett_wfleet_hdlc); |
54 | |
|
55 | 0 | proto_tree_add_uint(fh_tree, hf_wfleet_hdlc_addr, tvb, 0, 1, addr); |
56 | 0 | proto_tree_add_uint(fh_tree, hf_wfleet_hdlc_cmd, tvb, 1, 1, cmd); |
57 | |
|
58 | 0 | } |
59 | | |
60 | | /* |
61 | | * Build a tvb of the piece past the first two bytes and call the |
62 | | * ethernet dissector |
63 | | */ |
64 | |
|
65 | 0 | next_tvb = tvb_new_subset_remaining(tvb, 2); |
66 | |
|
67 | 0 | call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree); |
68 | 0 | return tvb_captured_length(tvb); |
69 | 0 | } |
70 | | |
71 | | void |
72 | | proto_register_wfleet_hdlc(void) |
73 | 16 | { |
74 | 16 | static hf_register_info hf[] = { |
75 | 16 | { &hf_wfleet_hdlc_addr, |
76 | 16 | { "Address", "wfleet_hdlc.address", FT_UINT8, BASE_HEX, |
77 | 16 | NULL, 0x0, NULL, HFILL }}, |
78 | 16 | { &hf_wfleet_hdlc_cmd, |
79 | 16 | { "Command", "wfleet_hdlc.command", FT_UINT8, BASE_HEX, |
80 | 16 | VALS(wfleet_hdlc_cmd_vals), 0x0, NULL, HFILL }}, |
81 | 16 | }; |
82 | 16 | static int *ett[] = { |
83 | 16 | &ett_wfleet_hdlc, |
84 | 16 | }; |
85 | | |
86 | 16 | proto_wfleet_hdlc = proto_register_protocol("Wellfleet HDLC", "WHDLC", "whdlc"); |
87 | 16 | proto_register_field_array(proto_wfleet_hdlc, hf, array_length(hf)); |
88 | 16 | proto_register_subtree_array(ett, array_length(ett)); |
89 | | |
90 | 16 | wfleet_hdlc_handle = register_dissector("wfleet_hdlc", dissect_wfleet_hdlc, proto_wfleet_hdlc); |
91 | | |
92 | 16 | } |
93 | | |
94 | | void |
95 | | proto_reg_handoff_wfleet_hdlc(void) |
96 | 16 | { |
97 | 16 | dissector_add_uint("wtap_encap", WTAP_ENCAP_WFLEET_HDLC, wfleet_hdlc_handle); |
98 | | |
99 | | /* |
100 | | * Find the eth dissector and save a ref to it |
101 | | */ |
102 | | |
103 | 16 | eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_wfleet_hdlc); |
104 | 16 | } |
105 | | |
106 | | /* |
107 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
108 | | * |
109 | | * Local Variables: |
110 | | * c-basic-offset: 2 |
111 | | * tab-width: 8 |
112 | | * indent-tabs-mode: nil |
113 | | * End: |
114 | | * |
115 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
116 | | * :indentSize=2:tabSize=8:noTabs=true: |
117 | | */ |