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
14 * o PPoATM and PPoFR encapsulation needs more test.
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 = -1;
27 static int hf_pro = -1;
28 static int hf_off = -1;
29 static int hf_pri = -1;
30 static int hf_rm = -1;
31 static int hf_err = -1;
32 static int hf_sar = -1;
33 static int hf_channel_id = -1;
35 static gint ett_raw = -1;
37 static dissector_handle_t eth_withoutfcs_handle;
38 static dissector_handle_t ppp_hdlc_handle;
39 static dissector_handle_t llc_handle;
40 static dissector_handle_t chdlc_handle;
41 static dissector_handle_t fr_handle;
44 dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
48 union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
50 /* load the top pane info. This should be overwritten by
51 the next protocol in the stack */
52 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
53 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
54 col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A");
55 col_set_str(pinfo->cinfo, COL_INFO, "CoSine IPNOS L2 debug output");
57 /* populate a tree in the second pane with the status of the link
60 ti = proto_tree_add_protocol_format(tree, proto_cosine, tvb, 0, 0,
61 "CoSine IPNOS L2 debug output (%s)",
62 pseudo_header->cosine.if_name);
63 fh_tree = proto_item_add_subtree(ti, ett_raw);
64 proto_tree_add_uint(fh_tree, hf_pro, tvb, 0, 0, pseudo_header->cosine.pro);
65 proto_tree_add_uint(fh_tree, hf_off, tvb, 0, 0, pseudo_header->cosine.off);
66 proto_tree_add_uint(fh_tree, hf_pri, tvb, 0, 0, pseudo_header->cosine.pri);
67 proto_tree_add_uint(fh_tree, hf_rm, tvb, 0, 0, pseudo_header->cosine.rm);
68 proto_tree_add_uint(fh_tree, hf_err, tvb, 0, 0, pseudo_header->cosine.err);
70 switch (pseudo_header->cosine.encap) {
71 case COSINE_ENCAP_ETH:
73 case COSINE_ENCAP_ATM:
74 case COSINE_ENCAP_PPoATM:
75 proto_tree_add_item(fh_tree, hf_sar, tvb, 0, 16, ENC_NA);
77 case COSINE_ENCAP_PPP:
79 case COSINE_ENCAP_PPoFR:
80 proto_tree_add_item(fh_tree, hf_channel_id, tvb, 0, 4, ENC_NA);
82 case COSINE_ENCAP_HDLC:
83 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
84 proto_tree_add_item(fh_tree, hf_channel_id, tvb, 0, 2, ENC_NA);
85 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
86 proto_tree_add_item(fh_tree, hf_channel_id, tvb, 0, 4, ENC_NA);
94 switch (pseudo_header->cosine.encap) {
95 case COSINE_ENCAP_ETH:
96 call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, 0),
99 case COSINE_ENCAP_ATM:
100 case COSINE_ENCAP_PPoATM:
101 call_dissector(llc_handle, tvb_new_subset_remaining(tvb, 16),
104 case COSINE_ENCAP_PPP:
105 call_dissector(ppp_hdlc_handle, tvb_new_subset_remaining(tvb, 4),
108 case COSINE_ENCAP_HDLC:
109 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
110 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 2),
112 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
113 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 4),
117 case COSINE_ENCAP_FR:
118 case COSINE_ENCAP_PPoFR:
119 call_dissector(fr_handle, tvb_new_subset_remaining(tvb, 4),
122 case COSINE_ENCAP_TEST:
123 case COSINE_ENCAP_UNKNOWN:
124 call_data_dissector(tvb, pinfo, tree);
129 return tvb_captured_length(tvb);
133 proto_register_cosine(void)
135 static hf_register_info hf[] = {
137 { "Protocol", "cosine.pro", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
139 { "Offset", "cosine.off", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
141 { "Priority", "cosine.pri", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
143 { "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
145 { "Error Code", "cosine.err", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
147 { "SAR header", "cosine.sar", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}},
149 { "Channel handle ID", "cosine.channel_id", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL}},
152 static gint *ett[] = {
156 proto_cosine = proto_register_protocol("CoSine IPNOS L2 debug output",
158 proto_register_field_array(proto_cosine, hf, array_length(hf));
159 proto_register_subtree_array(ett, array_length(ett));
163 proto_reg_handoff_cosine(void)
165 dissector_handle_t cosine_handle;
168 * Get handles for dissectors.
170 eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_cosine);
171 ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_cosine);
172 llc_handle = find_dissector_add_dependency("llc", proto_cosine);
173 chdlc_handle = find_dissector_add_dependency("chdlc", proto_cosine);
174 fr_handle = find_dissector_add_dependency("fr", proto_cosine);
176 cosine_handle = create_dissector_handle(dissect_cosine, proto_cosine);
177 dissector_add_uint("wtap_encap", WTAP_ENCAP_COSINE, cosine_handle);
181 * Editor modelines - http://www.wireshark.org/tools/modelines.html
186 * indent-tabs-mode: nil
189 * ex: set shiftwidth=2 tabstop=8 expandtab:
190 * :indentSize=2:tabSize=8:noTabs=true: