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
|
/* packet-qllc.c
* Routines for QLLC protocol - Qualified? LLC
* Gilbert Ramirez <gram@alumni.rice.edu>
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 2001 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <epan/packet.h>
void proto_register_qllc(void);
void proto_reg_handoff_qllc(void);
static int proto_qllc;
static int hf_qllc_address;
static int hf_qllc_control;
static int ett_qllc;
static dissector_handle_t sna_handle;
#define QSM 0x93
#define QDISC 0x53
#define QXID 0xbf
#define QTEST 0xf3
#define QRR 0xf1
#define QRD 0x53
#define QUA 0x73
#define QDM 0x1f
#define QFRMR 0x97
#define QUI 0x03
#define QUI_NO_REPLY 0x13
#define QSIM 0x17
#define QRD_QDISC_VALUE 0x53
#define QDISC_TEXT "QDISC"
#define QRD_TEXT "QRD"
/* Control Field */
static const value_string qllc_control_vals[] = {
{ QUI, "QUI" },
{ QUI_NO_REPLY, "QUI - reply required" },
{ QSIM, "QSIM" },
{ QDM, "QDM" },
{ QUA, "QUA" },
{ QSM, "QSM" },
{ QFRMR, "QFRMR" },
{ QXID, "QXID" },
{ QRR, "QRR" },
{ QTEST, "QTEST" },
{ QDISC, "QDISC / QRD" }, /* Same value for QDISC and QRD (following it is a COMMAND or RESPONSE) */
{ 0x00, NULL },
};
static int
dissect_qllc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
{
proto_tree *qllc_tree;
proto_item *qllc_ti;
bool *q_bit_set;
uint8_t addr, ctrl;
bool command = false;
/* Reject the packet if data is NULL */
if (data == NULL)
return 0;
q_bit_set = (bool *)data;
/*
* If the Q bit isn't set, this is just SNA data.
*/
if (!(*q_bit_set)) {
call_dissector(sna_handle, tvb, pinfo, tree);
return tvb_captured_length(tvb);
}
/* Summary information */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "QLLC");
col_clear(pinfo->cinfo, COL_INFO);
qllc_ti = proto_tree_add_item(tree, proto_qllc, tvb, 0, -1, ENC_NA);
qllc_tree = proto_item_add_subtree(qllc_ti, ett_qllc);
/* Get the address; we need it to determine if this is a
* COMMAND or a RESPONSE */
addr = tvb_get_uint8(tvb, 0);
proto_tree_add_item(qllc_tree, hf_qllc_address, tvb, 0, 1, ENC_BIG_ENDIAN);
/* The address field equals X'FF' in commands (except QRR)
* and anything in responses. */
ctrl = tvb_get_uint8(tvb, 1);
if (ctrl != QRR && addr == 0xff) {
command = true;
}
/* Disambiguate QRD_QDISC_VALUE, based on whether this packet is
* a COMMAND or RESPONSE. */
if (ctrl == QRD_QDISC_VALUE) {
if (command) {
col_set_str(pinfo->cinfo, COL_INFO, QDISC_TEXT);
proto_tree_add_uint_format_value(qllc_tree, hf_qllc_control, tvb,
1, 1, ctrl, "%s (0x%02x)", QDISC_TEXT, ctrl);
}
else {
col_set_str(pinfo->cinfo, COL_INFO, QRD_TEXT);
proto_tree_add_uint_format_value(qllc_tree, hf_qllc_control, tvb,
1, 1, ctrl, "%s (0x%02x)", QRD_TEXT, ctrl);
}
}
else {
/* Non-ambiguous control field value */
col_add_str(pinfo->cinfo, COL_INFO,
val_to_str(ctrl, qllc_control_vals,
"Control Field: 0x%02x (unknown)"));
proto_tree_add_uint(qllc_tree, hf_qllc_control, tvb,
1, 1, ctrl);
}
/* Do we have an I field ? */
/* XXX - I field exists for QUI too, but only for subarea nodes.
* Need to test for this. */
if (ctrl == QXID || ctrl == QTEST || ctrl == QFRMR) {
/* yes */
}
return tvb_captured_length(tvb);
}
void
proto_register_qllc(void)
{
static hf_register_info hf[] = {
{ &hf_qllc_address,
{ "Address Field", "qllc.address", FT_UINT8, BASE_HEX, NULL, 0x0,
NULL, HFILL }},
{ &hf_qllc_control,
{ "Control Field", "qllc.control", FT_UINT8, BASE_HEX,
VALS(qllc_control_vals), 0x0, NULL, HFILL }},
};
static int *ett[] = {
&ett_qllc,
};
proto_qllc = proto_register_protocol("Qualified Logical Link Control", "QLLC", "qllc");
proto_register_field_array(proto_qllc, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_dissector("qllc", dissect_qllc, proto_qllc);
}
void
proto_reg_handoff_qllc(void)
{
sna_handle = find_dissector_add_dependency("sna", proto_qllc);
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 4
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=4 tabstop=8 expandtab:
* :indentSize=4:tabSize=8:noTabs=true:
*/
|