2 * Routines for decoding CoSine IPNOS L2 debug output
4 * $Id: packet-cosine.c,v 1.4 2002/08/28 21:00:08 jmayer Exp $
6 * Motonori Shindo <mshindo@mshindo.net>
8 * Ethereal - Network traffic analyzer
9 * By Gerald Combs <gerald@ethereal.com>
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 * o PPoATM and PPoFR encapsulation needs more test.
38 #include <epan/packet.h>
40 static int proto_cosine = -1;
41 static int hf_pro = -1;
42 static int hf_off = -1;
43 static int hf_pri = -1;
44 static int hf_rm = -1;
45 static int hf_err = -1;
47 static gint ett_raw = -1;
49 static dissector_handle_t eth_handle;
50 static dissector_handle_t ppp_hdlc_handle;
51 static dissector_handle_t llc_handle;
52 static dissector_handle_t chdlc_handle;
53 static dissector_handle_t fr_handle;
54 static dissector_handle_t data_handle;
57 dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
61 union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
63 /* load the top pane info. This should be overwritten by
64 the next protocol in the stack */
65 if(check_col(pinfo->cinfo, COL_RES_DL_SRC))
66 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A" );
67 if(check_col(pinfo->cinfo, COL_RES_DL_DST))
68 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A" );
69 if(check_col(pinfo->cinfo, COL_PROTOCOL))
70 col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A" );
71 if(check_col(pinfo->cinfo, COL_INFO))
72 col_set_str(pinfo->cinfo, COL_INFO, "CoSine IPNOS L2 debug output" );
74 /* populate a tree in the second pane with the status of the link
77 ti = proto_tree_add_protocol_format(tree, proto_cosine, tvb, 0, 4,
78 "CoSine IPNOS L2 debug output (%s)",
79 pseudo_header->cosine.if_name);
80 fh_tree = proto_item_add_subtree(ti, ett_raw);
81 proto_tree_add_uint(fh_tree, hf_pro, tvb, 0, 0, pseudo_header->cosine.pro);
82 proto_tree_add_uint(fh_tree, hf_off, tvb, 0, 0, pseudo_header->cosine.off);
83 proto_tree_add_uint(fh_tree, hf_pri, tvb, 0, 0, pseudo_header->cosine.pri);
84 proto_tree_add_uint(fh_tree, hf_rm, tvb, 0, 0, pseudo_header->cosine.rm);
85 proto_tree_add_uint(fh_tree, hf_err, tvb, 0, 0, pseudo_header->cosine.err);
87 switch (pseudo_header->cosine.encap) {
88 case COSINE_ENCAP_ETH:
90 case COSINE_ENCAP_ATM:
91 case COSINE_ENCAP_PPoATM:
92 proto_tree_add_text(fh_tree, tvb, 0, 16, "SAR header");
94 case COSINE_ENCAP_PPP:
96 case COSINE_ENCAP_PPoFR:
97 proto_tree_add_text(fh_tree, tvb, 0, 4, "Channel handle ID");
99 case COSINE_ENCAP_HDLC:
100 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
101 proto_tree_add_text(fh_tree, tvb, 0, 2,
102 "Channel handle ID");
103 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
104 proto_tree_add_text(fh_tree, tvb, 0, 4,
105 "Channel handle ID");
113 switch (pseudo_header->cosine.encap) {
114 case COSINE_ENCAP_ETH:
115 call_dissector(eth_handle, tvb_new_subset(tvb, 0, -1, -1),
118 case COSINE_ENCAP_ATM:
119 case COSINE_ENCAP_PPoATM:
120 call_dissector(llc_handle, tvb_new_subset(tvb, 16, -1, -1),
123 case COSINE_ENCAP_PPP:
124 call_dissector(ppp_hdlc_handle, tvb_new_subset(tvb, 4, -1, -1),
127 case COSINE_ENCAP_HDLC:
128 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
129 call_dissector(chdlc_handle, tvb_new_subset(tvb, 2, -1, -1),
131 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
132 call_dissector(chdlc_handle, tvb_new_subset(tvb, 4, -1, -1),
136 case COSINE_ENCAP_FR:
137 case COSINE_ENCAP_PPoFR:
138 call_dissector(fr_handle, tvb_new_subset(tvb, 4, -1, -1),
141 case COSINE_ENCAP_TEST:
142 case COSINE_ENCAP_UNKNOWN:
143 call_dissector(data_handle, tvb, pinfo, tree);
151 proto_register_cosine(void)
153 static hf_register_info hf[] = {
155 { "Protocol", "cosine.pro", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}},
157 { "Offset", "cosine.off", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}},
159 { "Priority", "cosine.pri", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}},
161 { "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}},
163 { "Error Code", "cosine.err", FT_UINT8, BASE_DEC, NULL, 0x0, "", HFILL}},
166 static gint *ett[] = {
170 proto_cosine = proto_register_protocol("CoSine IPNOS L2 debug output",
172 proto_register_field_array(proto_cosine, hf, array_length(hf));
173 proto_register_subtree_array(ett, array_length(ett));
177 proto_reg_handoff_cosine(void)
179 dissector_handle_t cosine_handle;
182 * Get handles for dissectors.
184 eth_handle = find_dissector("eth");
185 ppp_hdlc_handle = find_dissector("ppp_hdlc");
186 llc_handle = find_dissector("llc");
187 chdlc_handle = find_dissector("chdlc");
188 fr_handle = find_dissector("fr");
189 data_handle = find_dissector("data");
191 cosine_handle = create_dissector_handle(dissect_cosine, proto_cosine);
192 dissector_add("wtap_encap", WTAP_ENCAP_COSINE, cosine_handle);