1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
/* packet-dpnss-link.c
* Routines for DPNSS/DASS2 link layer dissection
* Copyright 2009, Rolf Fiedler <rolf.fiedler[at]innoventif[dot]de>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
/* References:
* BTNR188
* ND1301:2001/03 http://www.nicc.org.uk/nicc-public/Public/interconnectstandards/dpnss/nd1301_2004_11.pdf
*/
#include "config.h"
#include <epan/packet.h>
#include <wiretap/wtap.h>
void proto_register_dpnss_link(void);
void proto_reg_handoff_dpnss_link(void);
static dissector_handle_t dpnss_handle; /* DPNSS UI frame dissector */
#define LINK_HEADER_SIZE 3
static int proto_dpnss_link;
static int hf_dpnss_link_address_framegroup;
static int hf_dpnss_link_address_crbit;
static int hf_dpnss_link_address_extension;
static int hf_dpnss_link_address2_reserved;
static int hf_dpnss_link_address2_dlcId;
static int hf_dpnss_link_address2_dlcIdNr;
static int hf_dpnss_link_address2_extension;
static int hf_dpnss_link_control_frameType;
static const value_string dpnss_link_framegroup_vals[] = {
{ 0x11, "Information Frame" },
{ 0x03, "Control Frame" },
{ 0, NULL }
};
static const value_string dpnss_link_crbit_vals[] = {
{ 0x0, "Command/Response Bit Cleared" },
{ 0x1, "Command/Response Bit Set" },
{ 0, NULL }
};
static const value_string dpnss_link_extend_vals[] = {
{ 0x0, "Extended to next octet" },
{ 0x1, "Final octet" },
{ 0, NULL }
};
static const value_string dpnss_link_reserved_vals[] = {
{ 0x0, "Reserved" },
{ 0x1, "Reserved" },
{ 0, NULL }
};
static const value_string dpnss_link_dlcId_vals[] = {
{ 0x0, "Real Channel" },
{ 0x1, "Virtual Channel" },
{ 0, NULL }
};
#define FRAME_TYPE_UI_EVEN 0x03
#define FRAME_TYPE_UI_ODD 0x13
#define FRAME_TYPE_SABMR 0xef
#define FRAME_TYPE_UA 0x63
static const value_string dpnss_link_frameType_vals[] = {
{ FRAME_TYPE_UI_EVEN, "UI (even)" },
{ FRAME_TYPE_UI_ODD, "UI (odd)" },
{ FRAME_TYPE_SABMR, "SABMR" },
{ FRAME_TYPE_UA, "UA" },
{ 0, NULL }
};
static int ett_dpnss_link;
static dissector_handle_t dpnss_link_handle;
/* Code to actually dissect the packets */
static int
dissect_dpnss_link(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
proto_item *item;
proto_tree *dpnss_link_tree;
uint8_t octet;
tvbuff_t *protocol_data_tvb;
uint16_t protocol_data_length;
bool uton;
uton = pinfo->pseudo_header->l1event.uton;
/* Make entries in src and dst column */
col_set_str(pinfo->cinfo, COL_DEF_SRC, uton?"TE":"NT");
col_set_str(pinfo->cinfo, COL_DEF_DST, uton?"NT":"TE");
/* Make entries in Protocol column and Info column on summary display */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DPNSS");
item = proto_tree_add_item(tree, proto_dpnss_link, tvb, 0, -1, ENC_NA);
dpnss_link_tree = proto_item_add_subtree(item, ett_dpnss_link);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address_framegroup,
tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address_crbit,
tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address_extension,
tvb, 0, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_reserved,
tvb, 1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_dlcId,
tvb, 1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_dlcIdNr,
tvb, 1, 1, ENC_BIG_ENDIAN);
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_address2_extension,
tvb, 1, 1, ENC_BIG_ENDIAN);
/*
* XXX - DPNSS's layer 2 protocol appears to be Yet Another
* HDLC Derivative; should this use the xDLC control field
* dissector code?
*/
proto_tree_add_item(dpnss_link_tree, hf_dpnss_link_control_frameType,
tvb, 2, 1, ENC_BIG_ENDIAN);
octet = tvb_get_uint8(tvb, 2);
switch (octet){
case FRAME_TYPE_UI_EVEN:
case FRAME_TYPE_UI_ODD:
protocol_data_length=tvb_reported_length(tvb)-LINK_HEADER_SIZE;
protocol_data_tvb=tvb_new_subset_length(tvb, LINK_HEADER_SIZE,
protocol_data_length);
if (dpnss_handle && protocol_data_length>0) {
call_dissector(dpnss_handle, protocol_data_tvb, pinfo, tree);
}
break;
default:
break;
}
return tvb_captured_length(tvb);
}
/* Register the protocol with Wireshark */
void
proto_register_dpnss_link(void)
{
static hf_register_info hf[] = {
{ &hf_dpnss_link_address_framegroup,
{ "Frame Group", "dpnss_link.framegroup",
FT_UINT8, BASE_DEC, VALS(dpnss_link_framegroup_vals), 0xfc,
NULL, HFILL }
},
{ &hf_dpnss_link_address_crbit,
{ "C/R Bit", "dpnss_link.crbit",
FT_UINT8, BASE_DEC, VALS(dpnss_link_crbit_vals), 0x02,
NULL, HFILL }
},
{ &hf_dpnss_link_address_extension,
{ "Extension", "dpnss_link.extension",
FT_UINT8, BASE_DEC, VALS(dpnss_link_extend_vals), 0x01,
NULL, HFILL }
},
{ &hf_dpnss_link_address2_reserved,
{ "Reserved", "dpnss_link.reserved",
FT_UINT8, BASE_DEC, VALS(dpnss_link_reserved_vals), 0x80,
NULL, HFILL }
},
{ &hf_dpnss_link_address2_dlcId,
{ "DLC ID", "dpnss_link.dlcId",
FT_UINT8, BASE_DEC, VALS(dpnss_link_dlcId_vals), 0x40,
NULL, HFILL }
},
{ &hf_dpnss_link_address2_dlcIdNr,
{ "DLC ID Number", "dpnss_link.dlcIdNr",
FT_UINT8, BASE_DEC, NULL, 0x3e,
NULL, HFILL }
},
{ &hf_dpnss_link_address2_extension,
{ "Extension", "dpnss_link.extension2",
FT_UINT8, BASE_DEC, VALS(dpnss_link_extend_vals), 0x01,
NULL, HFILL }
},
{ &hf_dpnss_link_control_frameType,
{ "Frame Type", "dpnss_link.frameType",
FT_UINT8, BASE_DEC, VALS(dpnss_link_frameType_vals), 0x0,
NULL, HFILL }
}
};
static int *ett[] = { &ett_dpnss_link };
/* Register the protocol name and description */
proto_dpnss_link = proto_register_protocol("Digital Private Signalling System No 1 Link Layer",
"DPNSS Link", "dpnss_link");
dpnss_link_handle = register_dissector("dpnss_link", dissect_dpnss_link, proto_dpnss_link);
/* Required function calls to register the header fields and subtrees used */
proto_register_field_array(proto_dpnss_link, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
}
void
proto_reg_handoff_dpnss_link(void)
{
dissector_add_uint("wtap_encap", WTAP_ENCAP_DPNSS, dpnss_link_handle);
dpnss_handle = find_dissector_add_dependency("dpnss", proto_dpnss_link);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: t
* End:
*
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
* :indentSize=8:tabSize=8:noTabs=false:
*/
|