2 * Routines for decoding CoSine IPNOS L2 debug output
6 * Motonori Shindo <motonori@shin.do>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * o PPoATM and PPoFR encapsulation needs more test.
35 #include <epan/packet.h>
37 static int proto_cosine = -1;
38 static int hf_pro = -1;
39 static int hf_off = -1;
40 static int hf_pri = -1;
41 static int hf_rm = -1;
42 static int hf_err = -1;
44 static gint ett_raw = -1;
46 static dissector_handle_t eth_withoutfcs_handle;
47 static dissector_handle_t ppp_hdlc_handle;
48 static dissector_handle_t llc_handle;
49 static dissector_handle_t chdlc_handle;
50 static dissector_handle_t fr_handle;
51 static dissector_handle_t data_handle;
54 dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
58 union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
60 /* load the top pane info. This should be overwritten by
61 the next protocol in the stack */
62 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
63 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
64 col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A");
65 col_set_str(pinfo->cinfo, COL_INFO, "CoSine IPNOS L2 debug output");
67 /* populate a tree in the second pane with the status of the link
70 ti = proto_tree_add_protocol_format(tree, proto_cosine, tvb, 0, 0,
71 "CoSine IPNOS L2 debug output (%s)",
72 pseudo_header->cosine.if_name);
73 fh_tree = proto_item_add_subtree(ti, ett_raw);
74 proto_tree_add_uint(fh_tree, hf_pro, tvb, 0, 0, pseudo_header->cosine.pro);
75 proto_tree_add_uint(fh_tree, hf_off, tvb, 0, 0, pseudo_header->cosine.off);
76 proto_tree_add_uint(fh_tree, hf_pri, tvb, 0, 0, pseudo_header->cosine.pri);
77 proto_tree_add_uint(fh_tree, hf_rm, tvb, 0, 0, pseudo_header->cosine.rm);
78 proto_tree_add_uint(fh_tree, hf_err, tvb, 0, 0, pseudo_header->cosine.err);
80 switch (pseudo_header->cosine.encap) {
81 case COSINE_ENCAP_ETH:
83 case COSINE_ENCAP_ATM:
84 case COSINE_ENCAP_PPoATM:
85 proto_tree_add_text(fh_tree, tvb, 0, 16, "SAR header");
87 case COSINE_ENCAP_PPP:
89 case COSINE_ENCAP_PPoFR:
90 proto_tree_add_text(fh_tree, tvb, 0, 4, "Channel handle ID");
92 case COSINE_ENCAP_HDLC:
93 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
94 proto_tree_add_text(fh_tree, tvb, 0, 2,
96 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
97 proto_tree_add_text(fh_tree, tvb, 0, 4,
106 switch (pseudo_header->cosine.encap) {
107 case COSINE_ENCAP_ETH:
108 call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, 0),
111 case COSINE_ENCAP_ATM:
112 case COSINE_ENCAP_PPoATM:
113 call_dissector(llc_handle, tvb_new_subset_remaining(tvb, 16),
116 case COSINE_ENCAP_PPP:
117 call_dissector(ppp_hdlc_handle, tvb_new_subset_remaining(tvb, 4),
120 case COSINE_ENCAP_HDLC:
121 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
122 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 2),
124 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
125 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 4),
129 case COSINE_ENCAP_FR:
130 case COSINE_ENCAP_PPoFR:
131 call_dissector(fr_handle, tvb_new_subset_remaining(tvb, 4),
134 case COSINE_ENCAP_TEST:
135 case COSINE_ENCAP_UNKNOWN:
136 call_dissector(data_handle, tvb, pinfo, tree);
144 proto_register_cosine(void)
146 static hf_register_info hf[] = {
148 { "Protocol", "cosine.pro", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
150 { "Offset", "cosine.off", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
152 { "Priority", "cosine.pri", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
154 { "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
156 { "Error Code", "cosine.err", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
159 static gint *ett[] = {
163 proto_cosine = proto_register_protocol("CoSine IPNOS L2 debug output",
165 proto_register_field_array(proto_cosine, hf, array_length(hf));
166 proto_register_subtree_array(ett, array_length(ett));
170 proto_reg_handoff_cosine(void)
172 dissector_handle_t cosine_handle;
175 * Get handles for dissectors.
177 eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
178 ppp_hdlc_handle = find_dissector("ppp_hdlc");
179 llc_handle = find_dissector("llc");
180 chdlc_handle = find_dissector("chdlc");
181 fr_handle = find_dissector("fr");
182 data_handle = find_dissector("data");
184 cosine_handle = create_dissector_handle(dissect_cosine, proto_cosine);
185 dissector_add_uint("wtap_encap", WTAP_ENCAP_COSINE, cosine_handle);