Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-cosine.c
blobd2cc0138c2c301215883c7549de07d0263d78989
1 /* packet-cosine.c
2 * Routines for decoding CoSine IPNOS L2 debug output
4 * Motonori Shindo <motonori@shin.do>
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
9 * SPDX-License-Identifier: GPL-2.0-or-later
13 * XXX TODO:
14 * o PPoATM and PPoFR encapsulation needs more test.
18 #include "config.h"
20 #include <epan/packet.h>
21 #include <wiretap/wtap.h>
23 void proto_register_cosine(void);
24 void proto_reg_handoff_cosine(void);
26 static int proto_cosine;
27 static int hf_pro;
28 static int hf_off;
29 static int hf_pri;
30 static int hf_rm;
31 static int hf_err;
32 static int hf_sar;
33 static int hf_channel_id;
35 static int ett_raw;
37 static dissector_handle_t cosine_handle;
38 static dissector_handle_t eth_withoutfcs_handle;
39 static dissector_handle_t ppp_hdlc_handle;
40 static dissector_handle_t llc_handle;
41 static dissector_handle_t chdlc_handle;
42 static dissector_handle_t fr_handle;
44 static int
45 dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
47 proto_tree *fh_tree;
48 proto_item *ti;
49 union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
51 /* load the top pane info. This should be overwritten by
52 the next protocol in the stack */
53 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
54 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
55 col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A");
56 col_set_str(pinfo->cinfo, COL_INFO, "CoSine IPNOS L2 debug output");
58 /* populate a tree in the second pane with the status of the link
59 layer (ie none) */
60 if(tree) {
61 ti = proto_tree_add_protocol_format(tree, proto_cosine, tvb, 0, 0,
62 "CoSine IPNOS L2 debug output (%s)",
63 pseudo_header->cosine.if_name);
64 fh_tree = proto_item_add_subtree(ti, ett_raw);
65 proto_tree_add_uint(fh_tree, hf_pro, tvb, 0, 0, pseudo_header->cosine.pro);
66 proto_tree_add_uint(fh_tree, hf_off, tvb, 0, 0, pseudo_header->cosine.off);
67 proto_tree_add_uint(fh_tree, hf_pri, tvb, 0, 0, pseudo_header->cosine.pri);
68 proto_tree_add_uint(fh_tree, hf_rm, tvb, 0, 0, pseudo_header->cosine.rm);
69 proto_tree_add_uint(fh_tree, hf_err, tvb, 0, 0, pseudo_header->cosine.err);
71 switch (pseudo_header->cosine.encap) {
72 case COSINE_ENCAP_ETH:
73 break;
74 case COSINE_ENCAP_ATM:
75 case COSINE_ENCAP_PPoATM:
76 proto_tree_add_item(fh_tree, hf_sar, tvb, 0, 16, ENC_NA);
77 break;
78 case COSINE_ENCAP_PPP:
79 case COSINE_ENCAP_FR:
80 case COSINE_ENCAP_PPoFR:
81 proto_tree_add_item(fh_tree, hf_channel_id, tvb, 0, 4, ENC_NA);
82 break;
83 case COSINE_ENCAP_HDLC:
84 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
85 proto_tree_add_item(fh_tree, hf_channel_id, tvb, 0, 2, ENC_NA);
86 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
87 proto_tree_add_item(fh_tree, hf_channel_id, tvb, 0, 4, ENC_NA);
89 break;
90 default:
91 break;
95 switch (pseudo_header->cosine.encap) {
96 case COSINE_ENCAP_ETH:
97 call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, 0),
98 pinfo, tree);
99 break;
100 case COSINE_ENCAP_ATM:
101 case COSINE_ENCAP_PPoATM:
102 call_dissector(llc_handle, tvb_new_subset_remaining(tvb, 16),
103 pinfo, tree);
104 break;
105 case COSINE_ENCAP_PPP:
106 call_dissector(ppp_hdlc_handle, tvb_new_subset_remaining(tvb, 4),
107 pinfo, tree);
108 break;
109 case COSINE_ENCAP_HDLC:
110 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
111 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 2),
112 pinfo, tree);
113 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
114 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 4),
115 pinfo, tree);
117 break;
118 case COSINE_ENCAP_FR:
119 case COSINE_ENCAP_PPoFR:
120 call_dissector(fr_handle, tvb_new_subset_remaining(tvb, 4),
121 pinfo, tree);
122 break;
123 case COSINE_ENCAP_TEST:
124 case COSINE_ENCAP_UNKNOWN:
125 call_data_dissector(tvb, pinfo, tree);
126 break;
127 default:
128 break;
130 return tvb_captured_length(tvb);
133 void
134 proto_register_cosine(void)
136 static hf_register_info hf[] = {
137 { &hf_pro,
138 { "Protocol", "cosine.pro", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
139 { &hf_off,
140 { "Offset", "cosine.off", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
141 { &hf_pri,
142 { "Priority", "cosine.pri", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
143 { &hf_rm,
144 { "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
145 { &hf_err,
146 { "Error Code", "cosine.err", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
147 { &hf_sar,
148 { "SAR header", "cosine.sar", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}},
149 { &hf_channel_id,
150 { "Channel handle ID", "cosine.channel_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}},
153 static int *ett[] = {
154 &ett_raw,
157 proto_cosine = proto_register_protocol("CoSine IPNOS L2 debug output",
158 "CoSine", "cosine");
159 proto_register_field_array(proto_cosine, hf, array_length(hf));
160 proto_register_subtree_array(ett, array_length(ett));
162 cosine_handle = register_dissector("cosine", dissect_cosine, proto_cosine);
165 void
166 proto_reg_handoff_cosine(void)
170 * Get handles for dissectors.
172 eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_cosine);
173 ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_cosine);
174 llc_handle = find_dissector_add_dependency("llc", proto_cosine);
175 chdlc_handle = find_dissector_add_dependency("chdlc", proto_cosine);
176 fr_handle = find_dissector_add_dependency("fr", proto_cosine);
178 dissector_add_uint("wtap_encap", WTAP_ENCAP_COSINE, cosine_handle);
182 * Editor modelines - https://www.wireshark.org/tools/modelines.html
184 * Local Variables:
185 * c-basic-offset: 2
186 * tab-width: 8
187 * indent-tabs-mode: nil
188 * End:
190 * ex: set shiftwidth=2 tabstop=8 expandtab:
191 * :indentSize=2:tabSize=8:noTabs=true: