HACK: 2nd try to match RowsetProperties
[wireshark-wip.git] / epan / dissectors / packet-cosine.c
blob8e8381f8b845da48791dd93ce55580311d4bbce4
1 /* packet-cosine.c
2 * Routines for decoding CoSine IPNOS L2 debug output
4 * $Id$
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.
27 * XXX TODO:
28 * o PPoATM and PPoFR encapsulation needs more test.
32 #include "config.h"
34 #include <glib.h>
35 #include <epan/packet.h>
37 void proto_register_cosine(void);
38 void proto_reg_handoff_cosine(void);
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_withoutfcs_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;
56 static void
57 dissect_cosine(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
59 proto_tree *fh_tree;
60 proto_item *ti;
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 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
66 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
67 col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A");
68 col_set_str(pinfo->cinfo, COL_INFO, "CoSine IPNOS L2 debug output");
70 /* populate a tree in the second pane with the status of the link
71 layer (ie none) */
72 if(tree) {
73 ti = proto_tree_add_protocol_format(tree, proto_cosine, tvb, 0, 0,
74 "CoSine IPNOS L2 debug output (%s)",
75 pseudo_header->cosine.if_name);
76 fh_tree = proto_item_add_subtree(ti, ett_raw);
77 proto_tree_add_uint(fh_tree, hf_pro, tvb, 0, 0, pseudo_header->cosine.pro);
78 proto_tree_add_uint(fh_tree, hf_off, tvb, 0, 0, pseudo_header->cosine.off);
79 proto_tree_add_uint(fh_tree, hf_pri, tvb, 0, 0, pseudo_header->cosine.pri);
80 proto_tree_add_uint(fh_tree, hf_rm, tvb, 0, 0, pseudo_header->cosine.rm);
81 proto_tree_add_uint(fh_tree, hf_err, tvb, 0, 0, pseudo_header->cosine.err);
83 switch (pseudo_header->cosine.encap) {
84 case COSINE_ENCAP_ETH:
85 break;
86 case COSINE_ENCAP_ATM:
87 case COSINE_ENCAP_PPoATM:
88 proto_tree_add_text(fh_tree, tvb, 0, 16, "SAR header");
89 break;
90 case COSINE_ENCAP_PPP:
91 case COSINE_ENCAP_FR:
92 case COSINE_ENCAP_PPoFR:
93 proto_tree_add_text(fh_tree, tvb, 0, 4, "Channel handle ID");
94 break;
95 case COSINE_ENCAP_HDLC:
96 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
97 proto_tree_add_text(fh_tree, tvb, 0, 2,
98 "Channel handle ID");
99 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
100 proto_tree_add_text(fh_tree, tvb, 0, 4,
101 "Channel handle ID");
103 break;
104 default:
105 break;
109 switch (pseudo_header->cosine.encap) {
110 case COSINE_ENCAP_ETH:
111 call_dissector(eth_withoutfcs_handle, tvb_new_subset_remaining(tvb, 0),
112 pinfo, tree);
113 break;
114 case COSINE_ENCAP_ATM:
115 case COSINE_ENCAP_PPoATM:
116 call_dissector(llc_handle, tvb_new_subset_remaining(tvb, 16),
117 pinfo, tree);
118 break;
119 case COSINE_ENCAP_PPP:
120 call_dissector(ppp_hdlc_handle, tvb_new_subset_remaining(tvb, 4),
121 pinfo, tree);
122 break;
123 case COSINE_ENCAP_HDLC:
124 if (pseudo_header->cosine.direction == COSINE_DIR_TX) {
125 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 2),
126 pinfo, tree);
127 } else if (pseudo_header->cosine.direction == COSINE_DIR_RX) {
128 call_dissector(chdlc_handle, tvb_new_subset_remaining(tvb, 4),
129 pinfo, tree);
131 break;
132 case COSINE_ENCAP_FR:
133 case COSINE_ENCAP_PPoFR:
134 call_dissector(fr_handle, tvb_new_subset_remaining(tvb, 4),
135 pinfo, tree);
136 break;
137 case COSINE_ENCAP_TEST:
138 case COSINE_ENCAP_UNKNOWN:
139 call_dissector(data_handle, tvb, pinfo, tree);
140 break;
141 default:
142 break;
146 void
147 proto_register_cosine(void)
149 static hf_register_info hf[] = {
150 { &hf_pro,
151 { "Protocol", "cosine.pro", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
152 { &hf_off,
153 { "Offset", "cosine.off", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
154 { &hf_pri,
155 { "Priority", "cosine.pri", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
156 { &hf_rm,
157 { "Rate Marking", "cosine.rm", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
158 { &hf_err,
159 { "Error Code", "cosine.err", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL}},
162 static gint *ett[] = {
163 &ett_raw,
166 proto_cosine = proto_register_protocol("CoSine IPNOS L2 debug output",
167 "CoSine", "cosine");
168 proto_register_field_array(proto_cosine, hf, array_length(hf));
169 proto_register_subtree_array(ett, array_length(ett));
172 void
173 proto_reg_handoff_cosine(void)
175 dissector_handle_t cosine_handle;
178 * Get handles for dissectors.
180 eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
181 ppp_hdlc_handle = find_dissector("ppp_hdlc");
182 llc_handle = find_dissector("llc");
183 chdlc_handle = find_dissector("chdlc");
184 fr_handle = find_dissector("fr");
185 data_handle = find_dissector("data");
187 cosine_handle = create_dissector_handle(dissect_cosine, proto_cosine);
188 dissector_add_uint("wtap_encap", WTAP_ENCAP_COSINE, cosine_handle);