3 * 802.1BR E-Tag dissector
4 * Inspired by packet-vntag.c
6 * Copyright 2016 APCON, Inc.
7 * Kim Kempf <kim.kempf@apcon.com>
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * SPDX-License-Identifier: GPL-2.0-or-later
19 #include <epan/packet.h>
20 #include <epan/etypes.h>
21 #include <epan/prefs.h>
23 void proto_register_etag(void);
24 void proto_reg_handoff_etag(void);
26 static dissector_handle_t etag_handle
;
27 static dissector_handle_t ethertype_handle
;
29 static int proto_etag
;
31 static bool etag_summary_in_tree
= true;
33 static int hf_etag_etype
;
34 static int hf_etag_pcp
;
35 static int hf_etag_dei
;
36 static int hf_etag_res
;
37 static int hf_etag_grp
;
38 static int hf_etag_iecid_base
;
39 static int hf_etag_iecid_ext
;
40 static int hf_etag_ecid_base
;
41 static int hf_etag_ecid_ext
;
43 static int hf_etag_trailer
;
47 #define IEEE8021BR_LEN 8 /* length including ethertype */
49 /* From Table G-2 of IEEE standard 802.1D-2004 */
50 static const value_string pri_vals
[] = {
53 { 0, "Best Effort (default)" },
54 { 3, "Excellent Effort" },
55 { 4, "Controlled Load" },
56 { 5, "Video, < 100ms latency and jitter" },
57 { 6, "Voice, < 10ms latency and jitter" },
58 { 7, "Network Control" },
63 static const value_string grp_vals
[] = {
64 { 0, "Point-to-point" },
65 { 1, "Point-to-multipoint" },
66 { 2, "Point-to-multipoint" },
67 { 3, "Point-to-multipoint" },
72 From 801.2BR 7.5 E-TAG Control Information
74 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
75 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
84 |E-PCP|D| Ingress_E-CID_base |
87 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
90 | E | R | E-CID_base |
93 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
96 |Ingress_E-CID_ | E_CID_ext |
99 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
103 dissect_etag(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
105 uint16_t encap_proto
;
106 proto_tree
*etag_tree
= NULL
;
107 ethertype_data_t ethertype_data
;
111 /* Decoding per IEEE802.1BR-2012 */
112 static int * const fields1
[] = {
119 static int * const fields2
[] = {
126 tci
= tvb_get_ntoh48( tvb
, 0);
128 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ETAG");
129 col_clear(pinfo
->cinfo
, COL_INFO
);
132 uint32_t e_cid
, ing_e_cid
;
134 proto_item
*ti
= proto_tree_add_item(tree
, proto_etag
, tvb
, 0, IEEE8021BR_LEN
- 2, ENC_NA
);
136 e_cid
= (uint32_t)((((tci
>> 16) & 0xFFF) | (tci
<< 12)) & 0xFFFFF); /* E-CID_base | E-CID_ext */
137 ing_e_cid
= (uint32_t)((((tci
>> 32) & 0xFFF) | ((tci
<< 4) & 0xFF000)) & 0xFFFFF); /* Ingress_E-CID_base | Ingress_E-CID ext */
139 if (etag_summary_in_tree
) {
140 proto_item_append_text(ti
, ", TCI: 0x%" PRIx64
" Ingress_E-CID: %u E-CID: %u", tci
, ing_e_cid
, e_cid
);
142 etag_tree
= proto_item_add_subtree(ti
, ett_etag
);
144 proto_tree_add_bitmask_list(etag_tree
, tvb
, 0, 2, fields1
, ENC_BIG_ENDIAN
);
145 proto_tree_add_bitmask_list(etag_tree
, tvb
, 2, 2, fields2
, ENC_BIG_ENDIAN
);
147 proto_tree_add_item(etag_tree
, hf_etag_iecid_ext
, tvb
, 4, 1, ENC_BIG_ENDIAN
);
148 proto_tree_add_item(etag_tree
, hf_etag_ecid_ext
, tvb
, 5, 1, ENC_BIG_ENDIAN
);
151 encap_proto
= tvb_get_ntohs(tvb
, IEEE8021BR_LEN
- 2);
152 proto_tree_add_uint(etag_tree
, hf_etag_etype
, tvb
, IEEE8021BR_LEN
- 2, 2, encap_proto
);
154 ethertype_data
.etype
= encap_proto
;
155 ethertype_data
.payload_offset
= IEEE8021BR_LEN
;
156 ethertype_data
.fh_tree
= etag_tree
;
157 ethertype_data
.trailer_id
= hf_etag_trailer
;
158 ethertype_data
.fcs_len
= 0;
160 call_dissector_with_data(ethertype_handle
, tvb
, pinfo
, tree
, ðertype_data
);
162 return tvb_captured_length(tvb
);
166 proto_register_etag(void)
168 static hf_register_info hf
[] = {
170 { "E-PCP", "etag.pcp", FT_UINT16
, BASE_DEC
, VALS(pri_vals
), 0xE000,
171 "Descriptions are recommendations from IEEE standard 802.1D-2004", HFILL
}
174 { "E-DEI", "etag.dei", FT_UINT16
, BASE_DEC
, NULL
, 0x1000, NULL
, HFILL
}
176 { &hf_etag_iecid_base
,
177 { "Ingress_E-CID_base", "etag.iecid_base", FT_UINT16
, BASE_HEX
, NULL
, 0x0FFF, NULL
, HFILL
}
180 { "Reserved", "etag.resv", FT_UINT16
, BASE_DEC
, NULL
, 0xC000, NULL
, HFILL
}
183 { "GRP", "etag.group", FT_UINT16
, BASE_DEC
, VALS(grp_vals
), 0x3000, NULL
, HFILL
}
185 { &hf_etag_ecid_base
,
186 { "E-CID_base", "etag.ecid_base", FT_UINT16
, BASE_HEX
, NULL
, 0x0FFF, NULL
, HFILL
}
188 { &hf_etag_iecid_ext
,
189 { "Ingress_E-CID_ext", "etag.iecid_ext", FT_UINT8
, BASE_HEX
, NULL
, 0, NULL
, HFILL
}
192 { "E-CID_ext", "etag.ecid_ext", FT_UINT8
, BASE_HEX
, NULL
, 0, NULL
, HFILL
}
195 { "Type", "etag.etype", FT_UINT16
, BASE_HEX
, VALS(etype_vals
), 0x0, NULL
, HFILL
}
198 { "Trailer", "etag.trailer", FT_BYTES
, BASE_NONE
, NULL
, 0x0, NULL
, HFILL
}
202 static int *ett
[] = {
206 module_t
*etag_module
;
208 proto_etag
= proto_register_protocol("802.1BR E-Tag", "ETAG", "etag");
209 etag_handle
= register_dissector("etag", dissect_etag
, proto_etag
);
210 proto_register_field_array(proto_etag
, hf
, array_length(hf
));
211 proto_register_subtree_array(ett
, array_length(ett
));
213 etag_module
= prefs_register_protocol(proto_etag
, NULL
);
214 prefs_register_bool_preference(etag_module
, "summary_in_tree",
215 "Show E-Tag summary in protocol tree",
216 "Whether the E-Tag summary line should be shown in the protocol tree",
217 &etag_summary_in_tree
);
221 proto_reg_handoff_etag(void)
223 dissector_add_uint("ethertype", ETHERTYPE_IEEE_802_1BR
, etag_handle
);
225 ethertype_handle
= find_dissector_add_dependency("ethertype", proto_etag
);
229 * Editor modelines - https://www.wireshark.org/tools/modelines.html
234 * indent-tabs-mode: t
237 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
238 * :indentSize=8:tabSize=8:noTabs=false: