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
;
33 static int hf_channel_id
;
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
;
45 dissect_cosine(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
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
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
:
74 case COSINE_ENCAP_ATM
:
75 case COSINE_ENCAP_PPoATM
:
76 proto_tree_add_item(fh_tree
, hf_sar
, tvb
, 0, 16, ENC_NA
);
78 case COSINE_ENCAP_PPP
:
80 case COSINE_ENCAP_PPoFR
:
81 proto_tree_add_item(fh_tree
, hf_channel_id
, tvb
, 0, 4, ENC_NA
);
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
);
95 switch (pseudo_header
->cosine
.encap
) {
96 case COSINE_ENCAP_ETH
:
97 call_dissector(eth_withoutfcs_handle
, tvb_new_subset_remaining(tvb
, 0),
100 case COSINE_ENCAP_ATM
:
101 case COSINE_ENCAP_PPoATM
:
102 call_dissector(llc_handle
, tvb_new_subset_remaining(tvb
, 16),
105 case COSINE_ENCAP_PPP
:
106 call_dissector(ppp_hdlc_handle
, tvb_new_subset_remaining(tvb
, 4),
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),
113 } else if (pseudo_header
->cosine
.direction
== COSINE_DIR_RX
) {
114 call_dissector(chdlc_handle
, tvb_new_subset_remaining(tvb
, 4),
118 case COSINE_ENCAP_FR
:
119 case COSINE_ENCAP_PPoFR
:
120 call_dissector(fr_handle
, tvb_new_subset_remaining(tvb
, 4),
123 case COSINE_ENCAP_TEST
:
124 case COSINE_ENCAP_UNKNOWN
:
125 call_data_dissector(tvb
, pinfo
, tree
);
130 return tvb_captured_length(tvb
);
134 proto_register_cosine(void)
136 static hf_register_info hf
[] = {
138 { "Protocol", "cosine.pro", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
140 { "Offset", "cosine.off", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
142 { "Priority", "cosine.pri", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
144 { "Rate Marking", "cosine.rm", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
146 { "Error Code", "cosine.err", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
148 { "SAR header", "cosine.sar", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
150 { "Channel handle ID", "cosine.channel_id", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}},
153 static int *ett
[] = {
157 proto_cosine
= proto_register_protocol("CoSine IPNOS L2 debug output",
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
);
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
187 * indent-tabs-mode: nil
190 * ex: set shiftwidth=2 tabstop=8 expandtab:
191 * :indentSize=2:tabSize=8:noTabs=true: