2 * Routines for DPNSS/DASS2 link layer dissection
3 * Copyright 2009, Rolf Fiedler <rolf.fiedler[at]innoventif[dot]de>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
13 * ND1301:2001/03 http://www.nicc.org.uk/nicc-public/Public/interconnectstandards/dpnss/nd1301_2004_11.pdf
18 #include <epan/packet.h>
19 #include <wiretap/wtap.h>
21 void proto_register_dpnss_link(void);
22 void proto_reg_handoff_dpnss_link(void);
24 static dissector_handle_t dpnss_handle
; /* DPNSS UI frame dissector */
25 #define LINK_HEADER_SIZE 3
27 static int proto_dpnss_link
;
29 static int hf_dpnss_link_address_framegroup
;
30 static int hf_dpnss_link_address_crbit
;
31 static int hf_dpnss_link_address_extension
;
32 static int hf_dpnss_link_address2_reserved
;
33 static int hf_dpnss_link_address2_dlcId
;
34 static int hf_dpnss_link_address2_dlcIdNr
;
35 static int hf_dpnss_link_address2_extension
;
36 static int hf_dpnss_link_control_frameType
;
38 static const value_string dpnss_link_framegroup_vals
[] = {
39 { 0x11, "Information Frame" },
40 { 0x03, "Control Frame" },
44 static const value_string dpnss_link_crbit_vals
[] = {
45 { 0x0, "Command/Response Bit Cleared" },
46 { 0x1, "Command/Response Bit Set" },
50 static const value_string dpnss_link_extend_vals
[] = {
51 { 0x0, "Extended to next octet" },
52 { 0x1, "Final octet" },
56 static const value_string dpnss_link_reserved_vals
[] = {
62 static const value_string dpnss_link_dlcId_vals
[] = {
63 { 0x0, "Real Channel" },
64 { 0x1, "Virtual Channel" },
68 #define FRAME_TYPE_UI_EVEN 0x03
69 #define FRAME_TYPE_UI_ODD 0x13
70 #define FRAME_TYPE_SABMR 0xef
71 #define FRAME_TYPE_UA 0x63
73 static const value_string dpnss_link_frameType_vals
[] = {
74 { FRAME_TYPE_UI_EVEN
, "UI (even)" },
75 { FRAME_TYPE_UI_ODD
, "UI (odd)" },
76 { FRAME_TYPE_SABMR
, "SABMR" },
77 { FRAME_TYPE_UA
, "UA" },
81 static int ett_dpnss_link
;
83 static dissector_handle_t dpnss_link_handle
;
85 /* Code to actually dissect the packets */
87 dissect_dpnss_link(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
90 proto_tree
*dpnss_link_tree
;
92 tvbuff_t
*protocol_data_tvb
;
93 uint16_t protocol_data_length
;
96 uton
= pinfo
->pseudo_header
->l1event
.uton
;
97 /* Make entries in src and dst column */
99 col_set_str(pinfo
->cinfo
, COL_DEF_SRC
, uton
?"TE":"NT");
100 col_set_str(pinfo
->cinfo
, COL_DEF_DST
, uton
?"NT":"TE");
102 /* Make entries in Protocol column and Info column on summary display */
103 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DPNSS");
105 item
= proto_tree_add_item(tree
, proto_dpnss_link
, tvb
, 0, -1, ENC_NA
);
106 dpnss_link_tree
= proto_item_add_subtree(item
, ett_dpnss_link
);
107 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_address_framegroup
,
108 tvb
, 0, 1, ENC_BIG_ENDIAN
);
109 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_address_crbit
,
110 tvb
, 0, 1, ENC_BIG_ENDIAN
);
111 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_address_extension
,
112 tvb
, 0, 1, ENC_BIG_ENDIAN
);
113 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_address2_reserved
,
114 tvb
, 1, 1, ENC_BIG_ENDIAN
);
115 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_address2_dlcId
,
116 tvb
, 1, 1, ENC_BIG_ENDIAN
);
117 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_address2_dlcIdNr
,
118 tvb
, 1, 1, ENC_BIG_ENDIAN
);
119 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_address2_extension
,
120 tvb
, 1, 1, ENC_BIG_ENDIAN
);
122 * XXX - DPNSS's layer 2 protocol appears to be Yet Another
123 * HDLC Derivative; should this use the xDLC control field
126 proto_tree_add_item(dpnss_link_tree
, hf_dpnss_link_control_frameType
,
127 tvb
, 2, 1, ENC_BIG_ENDIAN
);
128 octet
= tvb_get_uint8(tvb
, 2);
130 case FRAME_TYPE_UI_EVEN
:
131 case FRAME_TYPE_UI_ODD
:
132 protocol_data_length
=tvb_reported_length(tvb
)-LINK_HEADER_SIZE
;
133 protocol_data_tvb
=tvb_new_subset_length(tvb
, LINK_HEADER_SIZE
,
134 protocol_data_length
);
135 if (dpnss_handle
&& protocol_data_length
>0) {
136 call_dissector(dpnss_handle
, protocol_data_tvb
, pinfo
, tree
);
142 return tvb_captured_length(tvb
);
146 /* Register the protocol with Wireshark */
148 proto_register_dpnss_link(void)
150 static hf_register_info hf
[] = {
151 { &hf_dpnss_link_address_framegroup
,
152 { "Frame Group", "dpnss_link.framegroup",
153 FT_UINT8
, BASE_DEC
, VALS(dpnss_link_framegroup_vals
), 0xfc,
156 { &hf_dpnss_link_address_crbit
,
157 { "C/R Bit", "dpnss_link.crbit",
158 FT_UINT8
, BASE_DEC
, VALS(dpnss_link_crbit_vals
), 0x02,
161 { &hf_dpnss_link_address_extension
,
162 { "Extension", "dpnss_link.extension",
163 FT_UINT8
, BASE_DEC
, VALS(dpnss_link_extend_vals
), 0x01,
166 { &hf_dpnss_link_address2_reserved
,
167 { "Reserved", "dpnss_link.reserved",
168 FT_UINT8
, BASE_DEC
, VALS(dpnss_link_reserved_vals
), 0x80,
171 { &hf_dpnss_link_address2_dlcId
,
172 { "DLC ID", "dpnss_link.dlcId",
173 FT_UINT8
, BASE_DEC
, VALS(dpnss_link_dlcId_vals
), 0x40,
176 { &hf_dpnss_link_address2_dlcIdNr
,
177 { "DLC ID Number", "dpnss_link.dlcIdNr",
178 FT_UINT8
, BASE_DEC
, NULL
, 0x3e,
181 { &hf_dpnss_link_address2_extension
,
182 { "Extension", "dpnss_link.extension2",
183 FT_UINT8
, BASE_DEC
, VALS(dpnss_link_extend_vals
), 0x01,
186 { &hf_dpnss_link_control_frameType
,
187 { "Frame Type", "dpnss_link.frameType",
188 FT_UINT8
, BASE_DEC
, VALS(dpnss_link_frameType_vals
), 0x0,
193 static int *ett
[] = { &ett_dpnss_link
};
196 /* Register the protocol name and description */
197 proto_dpnss_link
= proto_register_protocol("Digital Private Signalling System No 1 Link Layer",
198 "DPNSS Link", "dpnss_link");
199 dpnss_link_handle
= register_dissector("dpnss_link", dissect_dpnss_link
, proto_dpnss_link
);
201 /* Required function calls to register the header fields and subtrees used */
202 proto_register_field_array(proto_dpnss_link
, hf
, array_length(hf
));
203 proto_register_subtree_array(ett
, array_length(ett
));
207 proto_reg_handoff_dpnss_link(void)
209 dissector_add_uint("wtap_encap", WTAP_ENCAP_DPNSS
, dpnss_link_handle
);
211 dpnss_handle
= find_dissector_add_dependency("dpnss", proto_dpnss_link
);
215 * Editor modelines - https://www.wireshark.org/tools/modelines.html
220 * indent-tabs-mode: t
223 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
224 * :indentSize=8:tabSize=8:noTabs=false: