Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-qllc.c
blob8e9d360d81fccdb8def5c882daa60d38e4797fb7
1 /* packet-qllc.c
2 * Routines for QLLC protocol - Qualified? LLC
3 * Gilbert Ramirez <gram@alumni.rice.edu>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 2001 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
16 void proto_register_qllc(void);
17 void proto_reg_handoff_qllc(void);
19 static int proto_qllc;
20 static int hf_qllc_address;
21 static int hf_qllc_control;
23 static int ett_qllc;
25 static dissector_handle_t sna_handle;
27 #define QSM 0x93
28 #define QDISC 0x53
29 #define QXID 0xbf
30 #define QTEST 0xf3
31 #define QRR 0xf1
32 #define QRD 0x53
33 #define QUA 0x73
34 #define QDM 0x1f
35 #define QFRMR 0x97
36 #define QUI 0x03
37 #define QUI_NO_REPLY 0x13
38 #define QSIM 0x17
40 #define QRD_QDISC_VALUE 0x53
41 #define QDISC_TEXT "QDISC"
42 #define QRD_TEXT "QRD"
44 /* Control Field */
45 static const value_string qllc_control_vals[] = {
46 { QUI, "QUI" },
47 { QUI_NO_REPLY, "QUI - reply required" },
48 { QSIM, "QSIM" },
49 { QDM, "QDM" },
50 { QUA, "QUA" },
51 { QSM, "QSM" },
52 { QFRMR, "QFRMR" },
53 { QXID, "QXID" },
54 { QRR, "QRR" },
55 { QTEST, "QTEST" },
56 { QDISC, "QDISC / QRD" }, /* Same value for QDISC and QRD (following it is a COMMAND or RESPONSE) */
57 { 0x00, NULL },
61 static int
62 dissect_qllc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
64 proto_tree *qllc_tree;
65 proto_item *qllc_ti;
66 bool *q_bit_set;
67 uint8_t addr, ctrl;
68 bool command = false;
70 /* Reject the packet if data is NULL */
71 if (data == NULL)
72 return 0;
73 q_bit_set = (bool *)data;
76 * If the Q bit isn't set, this is just SNA data.
78 if (!(*q_bit_set)) {
79 call_dissector(sna_handle, tvb, pinfo, tree);
80 return tvb_captured_length(tvb);
83 /* Summary information */
84 col_set_str(pinfo->cinfo, COL_PROTOCOL, "QLLC");
85 col_clear(pinfo->cinfo, COL_INFO);
87 qllc_ti = proto_tree_add_item(tree, proto_qllc, tvb, 0, -1, ENC_NA);
88 qllc_tree = proto_item_add_subtree(qllc_ti, ett_qllc);
90 /* Get the address; we need it to determine if this is a
91 * COMMAND or a RESPONSE */
92 addr = tvb_get_uint8(tvb, 0);
93 proto_tree_add_item(qllc_tree, hf_qllc_address, tvb, 0, 1, ENC_BIG_ENDIAN);
95 /* The address field equals X'FF' in commands (except QRR)
96 * and anything in responses. */
97 ctrl = tvb_get_uint8(tvb, 1);
98 if (ctrl != QRR && addr == 0xff) {
99 command = true;
103 /* Disambiguate QRD_QDISC_VALUE, based on whether this packet is
104 * a COMMAND or RESPONSE. */
105 if (ctrl == QRD_QDISC_VALUE) {
106 if (command) {
107 col_set_str(pinfo->cinfo, COL_INFO, QDISC_TEXT);
108 proto_tree_add_uint_format_value(qllc_tree, hf_qllc_control, tvb,
109 1, 1, ctrl, "%s (0x%02x)", QDISC_TEXT, ctrl);
111 else {
112 col_set_str(pinfo->cinfo, COL_INFO, QRD_TEXT);
113 proto_tree_add_uint_format_value(qllc_tree, hf_qllc_control, tvb,
114 1, 1, ctrl, "%s (0x%02x)", QRD_TEXT, ctrl);
117 else {
118 /* Non-ambiguous control field value */
119 col_add_str(pinfo->cinfo, COL_INFO,
120 val_to_str(ctrl, qllc_control_vals,
121 "Control Field: 0x%02x (unknown)"));
123 proto_tree_add_uint(qllc_tree, hf_qllc_control, tvb,
124 1, 1, ctrl);
127 /* Do we have an I field ? */
128 /* XXX - I field exists for QUI too, but only for subarea nodes.
129 * Need to test for this. */
130 if (ctrl == QXID || ctrl == QTEST || ctrl == QFRMR) {
131 /* yes */
134 return tvb_captured_length(tvb);
137 void
138 proto_register_qllc(void)
140 static hf_register_info hf[] = {
141 { &hf_qllc_address,
142 { "Address Field", "qllc.address", FT_UINT8, BASE_HEX, NULL, 0x0,
143 NULL, HFILL }},
145 { &hf_qllc_control,
146 { "Control Field", "qllc.control", FT_UINT8, BASE_HEX,
147 VALS(qllc_control_vals), 0x0, NULL, HFILL }},
150 static int *ett[] = {
151 &ett_qllc,
154 proto_qllc = proto_register_protocol("Qualified Logical Link Control", "QLLC", "qllc");
155 proto_register_field_array(proto_qllc, hf, array_length(hf));
156 proto_register_subtree_array(ett, array_length(ett));
157 register_dissector("qllc", dissect_qllc, proto_qllc);
160 void
161 proto_reg_handoff_qllc(void)
163 sna_handle = find_dissector_add_dependency("sna", proto_qllc);
167 * Editor modelines - https://www.wireshark.org/tools/modelines.html
169 * Local variables:
170 * c-basic-offset: 4
171 * tab-width: 8
172 * indent-tabs-mode: nil
173 * End:
175 * vi: set shiftwidth=4 tabstop=8 expandtab:
176 * :indentSize=4:tabSize=8:noTabs=true: