Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-marker.c
blob75ee22c8022dbf2cd5396428233e0ab0dd97ee3c
1 /* packet-marker.c
2 * Routines for Link Aggregation Marker protocol dissection.
3 * IEEE Std 802.1AX-2014 Section 6.5
5 * Copyright 2002 Steve Housley <steve_housley@3com.com>
6 * Copyright 2005 Dominique Bastien <dbastien@accedian.com>
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include "config.h"
17 #include <epan/packet.h>
18 #include <epan/to_str.h>
19 #include <epan/expert.h>
20 #include <epan/slow_protocol_subtypes.h>
22 /* General declarations */
23 void proto_register_marker(void);
24 void proto_reg_handoff_marker(void);
26 static dissector_handle_t marker_handle;
28 /* MARKER TLVs subtype */
29 #define MARKER_TERMINATOR 0x0
30 #define MARKERPDU_MARKER_INFO 0x1
31 #define MARKERPDU_MARKER_RESPONSE 0x2
33 static const value_string marker_vals[] = {
34 { MARKER_TERMINATOR, "Marker Terminator" },
35 { MARKERPDU_MARKER_INFO, "Marker Information" },
36 { MARKERPDU_MARKER_RESPONSE, "Marker Response Information" },
37 { 0, NULL }
40 /* Initialise the protocol and registered fields */
41 static int proto_marker;
43 static int hf_marker_version_number;
44 static int hf_marker_tlv_type;
45 static int hf_marker_tlv_length;
46 static int hf_marker_req_port;
47 static int hf_marker_req_system;
48 static int hf_marker_req_trans_id;
49 static int hf_marker_req_pad;
50 static int hf_marker_reserved;
52 /* Expert Items */
53 static expert_field ei_marker_wrong_tlv_type;
54 static expert_field ei_marker_wrong_tlv_length;
55 static expert_field ei_marker_wrong_pad_value;
57 /* Initialise the subtree pointers */
58 static int ett_marker;
60 static int
61 dissect_marker(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
63 int offset = 0;
64 unsigned tlv_type, tlv_length;
65 unsigned port, transactionid, pad;
66 const char *sysidstr;
68 proto_tree *marker_tree;
69 proto_item *marker_item, *tlv_type_item, *tlv_length_item, *pad_item;
71 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Marker");
72 col_set_str(pinfo->cinfo, COL_INFO, "Marker Protocol");
74 marker_item = proto_tree_add_protocol_format(tree, proto_marker, tvb,
75 0, -1, "Marker Protocol");
76 marker_tree = proto_item_add_subtree(marker_item, ett_marker);
78 proto_tree_add_item(marker_tree, hf_marker_version_number, tvb,
79 offset, 1, ENC_BIG_ENDIAN);
80 offset += 1;
82 tlv_type_item = proto_tree_add_item_ret_uint(marker_tree, hf_marker_tlv_type, tvb,
83 offset, 1, ENC_BIG_ENDIAN, &tlv_type);
84 offset += 1;
86 tlv_length_item = proto_tree_add_item_ret_uint(marker_tree, hf_marker_tlv_length, tvb,
87 offset, 1, ENC_BIG_ENDIAN, &tlv_length);
88 offset += 1;
90 if (tlv_type == MARKERPDU_MARKER_INFO) {
91 col_set_str(pinfo->cinfo, COL_INFO, "Information");
92 } else if (tlv_type == MARKERPDU_MARKER_RESPONSE) {
93 col_set_str(pinfo->cinfo, COL_INFO, "Response");
94 } else {
95 expert_add_info(pinfo, tlv_type_item, &ei_marker_wrong_tlv_type);
97 if (tlv_length != 16) {
98 expert_add_info(pinfo, tlv_length_item, &ei_marker_wrong_tlv_length);
100 proto_tree_add_item_ret_uint(marker_tree, hf_marker_req_port, tvb,
101 offset, 2, ENC_BIG_ENDIAN, &port);
102 offset += 2;
104 proto_tree_add_item(marker_tree, hf_marker_req_system, tvb,
105 offset, 6, ENC_NA);
106 sysidstr = tvb_ether_to_str(pinfo->pool, tvb, offset);
107 offset += 6;
109 proto_tree_add_item_ret_uint(marker_tree, hf_marker_req_trans_id, tvb,
110 offset, 4, ENC_BIG_ENDIAN, &transactionid);
111 offset += 4;
113 col_append_fstr(pinfo->cinfo, COL_INFO, " SysId=%s, P=%d, TId=%d",
114 sysidstr, port, transactionid);
116 pad_item = proto_tree_add_item_ret_uint(marker_tree, hf_marker_req_pad, tvb,
117 offset, 2, ENC_BIG_ENDIAN, &pad);
118 if (pad != 0) {
119 expert_add_info(pinfo, pad_item, &ei_marker_wrong_pad_value);
121 offset += 2;
123 proto_tree_add_item_ret_uint(marker_tree, hf_marker_tlv_type, tvb,
124 offset, 1, ENC_BIG_ENDIAN, &tlv_type);
125 offset += 1;
127 proto_tree_add_item_ret_uint(marker_tree, hf_marker_tlv_length, tvb,
128 offset, 1, ENC_BIG_ENDIAN, &tlv_length);
129 offset += 1;
131 if (tlv_type == MARKER_TERMINATOR) {
132 if (tlv_length != 0) {
133 expert_add_info(pinfo, tlv_type_item, &ei_marker_wrong_tlv_length);
135 } else {
136 expert_add_info(pinfo, tlv_type_item, &ei_marker_wrong_tlv_type);
139 proto_tree_add_item(marker_tree, hf_marker_reserved, tvb,
140 offset, 90, ENC_NA);
141 offset += 90;
142 return offset;
145 /* Register the protocol with Wireshark */
146 void
147 proto_register_marker(void)
149 /* Setup list of header fields */
151 static hf_register_info hf[] = {
152 { &hf_marker_version_number,
153 { "Version Number", "marker.version",
154 FT_UINT8, BASE_HEX, NULL, 0x0,
155 "Marker protocol version", HFILL }},
157 { &hf_marker_tlv_type,
158 { "TLV Type", "marker.tlvType",
159 FT_UINT8, BASE_HEX, VALS(marker_vals), 0x0,
160 NULL, HFILL }},
162 { &hf_marker_tlv_length,
163 { "TLV Length", "marker.tlvLen",
164 FT_UINT8, BASE_HEX, NULL, 0x0,
165 "Length of the Actor TLV", HFILL }},
167 { &hf_marker_req_port,
168 { "Requester Port", "marker.requesterPort",
169 FT_UINT16, BASE_DEC, NULL, 0x0,
170 NULL, HFILL }},
172 { &hf_marker_req_system,
173 { "Requester System", "marker.requesterSystem",
174 FT_ETHER, BASE_NONE, NULL, 0x0,
175 "Requester System ID encoded as a MAC address", HFILL }},
177 { &hf_marker_req_trans_id,
178 { "Requester Transaction ID", "marker.requesterTransId",
179 FT_UINT32, BASE_DEC, NULL, 0x0,
180 NULL, HFILL }},
182 { &hf_marker_req_pad,
183 { "Requester Pad", "marker.requesterPad",
184 FT_UINT32, BASE_DEC, NULL, 0x0,
185 NULL, HFILL }},
187 { &hf_marker_reserved,
188 { "Reserved", "marker.reserved",
189 FT_BYTES, BASE_NONE, NULL, 0x0,
190 NULL, HFILL }},
193 /* Setup protocol subtree array */
195 static int *ett[] = {
196 &ett_marker,
199 static ei_register_info ei[] = {
200 { &ei_marker_wrong_tlv_type, { "marker.wrong_tlv_type", PI_MALFORMED, PI_ERROR, "TLV is not expected type", EXPFILL }},
201 { &ei_marker_wrong_tlv_length, { "marker.wrong_tlv_length", PI_MALFORMED, PI_ERROR, "TLV is not expected length", EXPFILL }},
202 { &ei_marker_wrong_pad_value, { "marker.wrong_pad_value", PI_PROTOCOL, PI_WARN, "pad value is not 0", EXPFILL }},
205 expert_module_t* expert_marker;
209 /* Register the protocol name and description */
211 proto_marker = proto_register_protocol("Link Aggregation Marker Protocol", "Marker", "marker");
213 /* Required function calls to register the header fields and subtrees used */
215 proto_register_field_array(proto_marker, hf, array_length(hf));
216 proto_register_subtree_array(ett, array_length(ett));
217 expert_marker = expert_register_protocol(proto_marker);
218 expert_register_field_array(expert_marker, ei, array_length(ei));
220 marker_handle = register_dissector("marker", dissect_marker, proto_marker);
223 void
224 proto_reg_handoff_marker(void)
226 dissector_add_uint("slow.subtype", MARKER_SUBTYPE, marker_handle);
230 * Editor modelines - https://www.wireshark.org/tools/modelines.html
232 * Local variables:
233 * c-basic-offset: 4
234 * tab-width: 8
235 * indent-tabs-mode: nil
236 * End:
238 * vi: set shiftwidth=4 tabstop=8 expandtab:
239 * :indentSize=4:tabSize=8:noTabs=true: