Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-3com-xns.c
blob4ed145ab8e523b7ee87643ac88aeadeead2f60ab
1 /* packet-xns-llc.c
2 * Routines for 3Com's encapsulation of XNS over 802.2 LLC
3 * (and other protocols using DSAP 80)
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 #include "config.h"
14 #include <epan/packet.h>
15 #include <epan/etypes.h>
17 /* Forward declarations */
18 void proto_register_3com_xns(void);
19 void proto_reg_handoff_3com_xns(void);
21 static dissector_handle_t our_xns_handle;
23 static int proto_3com_xns;
25 static int hf_3com_xns_type_ethertype;
26 static int hf_3com_xns_type_retix_bpdu;
28 static int ett_3com_xns;
30 static const value_string retix_bpdu_type_vals[] = {
31 { 0x0004, "Retix Spanning Tree" },
32 { 0, NULL }
35 static dissector_table_t ethertype_subdissector_table;
37 static dissector_handle_t retix_bpdu_handle;
40 * Apparently 3Com had some scheme for encapsulating XNS in 802.2 LLC,
41 * using a DSAP and SSAP of 0x80, and putting a 2-byte field that appeared
42 * to contain, at least for IPP, the Ethertype value for IPP.
44 * We assume that the value there is an Ethertype value, except for
45 * the Retix spanning tree protocol, which also uses a DSAP and SSAP
46 * of 0x80 but has, at least in one capture, 0x0004 as the type
47 * field. We handle that specially.
49 * XXX - I've also seen packets on 802.11 with a DSAP and SSAP of 0x80,
50 * but with random stuff that appears neither to be XNS nor Retix
51 * spanning tree.
53 static int
54 dissect_3com_xns(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
56 proto_tree *subtree;
57 proto_tree *ti;
58 uint16_t type;
59 tvbuff_t *next_tvb;
61 col_set_str(pinfo->cinfo, COL_PROTOCOL, "3Com XNS");
62 col_clear(pinfo->cinfo, COL_INFO);
64 ti = proto_tree_add_item(tree, proto_3com_xns, tvb, 0, 4, ENC_NA);
65 subtree = proto_item_add_subtree(ti, ett_3com_xns);
67 type = tvb_get_ntohs(tvb, 0);
68 next_tvb = tvb_new_subset_remaining(tvb, 2);
69 if (type == 0x0004) {
70 proto_tree_add_uint(subtree, hf_3com_xns_type_retix_bpdu,
71 tvb, 0, 2, type);
72 call_dissector(retix_bpdu_handle, next_tvb, pinfo, tree);
73 } else {
74 proto_tree_add_uint(subtree, hf_3com_xns_type_ethertype,
75 tvb, 0, 2, type);
76 if (!dissector_try_uint(ethertype_subdissector_table,
77 type, next_tvb, pinfo, tree))
78 call_data_dissector(next_tvb, pinfo, tree);
80 return tvb_captured_length(tvb);
83 void
84 proto_register_3com_xns(void)
86 static hf_register_info hf[] = {
87 /* registered here but handled in ethertype.c */
88 { &hf_3com_xns_type_ethertype,
89 { "Type", "3comxns.type", FT_UINT16, BASE_HEX,
90 VALS(etype_vals), 0x0, NULL, HFILL }},
92 { &hf_3com_xns_type_retix_bpdu,
93 { "Type", "3comxns.type", FT_UINT16, BASE_HEX,
94 VALS(retix_bpdu_type_vals), 0x0, NULL, HFILL }},
97 static int *ett[] ={
98 &ett_3com_xns,
101 proto_3com_xns = proto_register_protocol("3Com XNS Encapsulation", "3COMXNS", "3comxns");
102 proto_register_field_array(proto_3com_xns, hf, array_length(hf));
103 proto_register_subtree_array(ett, array_length(ett));
105 our_xns_handle = register_dissector("3comxns", dissect_3com_xns, proto_3com_xns);
108 void
109 proto_reg_handoff_3com_xns(void)
111 retix_bpdu_handle = find_dissector_add_dependency("rbpdu", proto_3com_xns);
112 ethertype_subdissector_table = find_dissector_table("ethertype");
113 dissector_add_uint("llc.dsap", 0x80, our_xns_handle);
117 * Editor modelines - https://www.wireshark.org/tools/modelines.html
119 * Local variables:
120 * c-basic-offset: 8
121 * tab-width: 8
122 * indent-tabs-mode: t
123 * End:
125 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
126 * :indentSize=8:tabSize=8:noTabs=false: