Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-slowprotocols.c
blobd2ef4cbf01daab39377c2fd21cbaacf219e558d7
1 /* packet-slowprotocols.c
2 * Routines for EtherType (0x8809) Slow Protocols disassembly.
3 * IEEE Std 802.3, Annex 57A
5 * Copyright 2002 Steve Housley <steve_housley@3com.com>
6 * Copyright 2005 Dominique Bastien <dbastien@accedian.com>
7 * Copyright 2009 Artem Tamazov <artem.tamazov@telllabs.com>
8 * Copyright 2010 Roberto Morro <roberto.morro[AT]tilab.com>
9 * Copyright 2014 Philip Rosenberg-Watt <p.rosenberg-watt[at]cablelabs.com.>
11 * Wireshark - Network traffic analyzer
12 * By Gerald Combs <gerald@wireshark.org>
13 * Copyright 1998 Gerald Combs
15 * SPDX-License-Identifier: GPL-2.0-or-later
18 #include "config.h"
20 #include <epan/packet.h>
21 #include <epan/etypes.h>
22 #include <epan/slow_protocol_subtypes.h>
24 /* General declarations */
25 void proto_register_slow_protocols(void);
26 void proto_reg_handoff_slow_protocols(void);
28 static dissector_handle_t slow_protocols_handle;
30 static dissector_table_t slow_protocols_dissector_table;
32 static const value_string subtype_vals[] = {
33 { LACP_SUBTYPE , "LACP" },
34 { MARKER_SUBTYPE , "Marker Protocol" },
35 { OAM_SUBTYPE , "OAM" },
36 { OSSP_SUBTYPE , "Organization Specific Slow Protocol" },
37 { 0, NULL }
40 /* Initialise the protocol and registered fields */
41 static int proto_slow;
43 static int hf_slow_subtype;
45 /* Initialise the subtree pointers */
47 static int ett_slow;
50 * Name: dissect_slow_protocols
52 * Description:
53 * This function is used to dissect the slow protocols defined in IEEE802.3
54 * CSMA/CD. The current slow protocols subtypes are define in Annex 57A of
55 * the 802.3 document. In case of an unsupported slow protocol, we only
56 * fill the protocol and info columns.
58 * Input Arguments:
59 * tvb: buffer associated with the rcv packet (see tvbuff.h).
60 * pinfo: structure associated with the rcv packet (see packet_info.h).
61 * tree: the protocol tree associated with the rcv packet (see proto.h).
63 * Return Values:
64 * None
66 static int
67 dissect_slow_protocols(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
69 uint8_t subtype;
70 proto_tree *pdu_tree;
71 proto_item *pdu_item;
72 tvbuff_t *next_tvb;
74 col_set_str(pinfo->cinfo, COL_PROTOCOL, "Slow Protocols");
75 subtype = tvb_get_uint8(tvb, 0);
76 col_add_fstr(pinfo->cinfo, COL_INFO, "Subtype = %u", subtype);
78 if (tree)
80 pdu_item = proto_tree_add_item(tree, proto_slow, tvb, 0, 1, ENC_NA);
81 pdu_tree = proto_item_add_subtree(pdu_item, ett_slow);
83 /* Subtype */
84 proto_tree_add_item(pdu_tree, hf_slow_subtype, tvb, 0, 1, ENC_BIG_ENDIAN);
87 next_tvb = tvb_new_subset_remaining(tvb, 1);
88 if (!dissector_try_uint_with_data(slow_protocols_dissector_table, subtype,
89 next_tvb, pinfo, tree, true, NULL))
90 call_data_dissector(next_tvb, pinfo, tree);
91 set_actual_length(tvb, tvb_captured_length(next_tvb) + 1);
93 return tvb_captured_length(tvb);
97 /* Register the protocol with Wireshark */
98 void
99 proto_register_slow_protocols(void)
101 /* Setup list of header fields */
103 static hf_register_info hf[] = {
104 { &hf_slow_subtype,
105 { "Slow Protocols subtype", "slow.subtype",
106 FT_UINT8, BASE_HEX, VALS(subtype_vals), 0x0,
107 NULL, HFILL }},
110 /* Setup protocol subtree array */
112 static int *ett[] = {
113 &ett_slow,
117 /* Register the protocol name and description */
119 proto_slow = proto_register_protocol("802.3 Slow protocols", "Slow Protocols", "slow");
121 /* Required function calls to register the header fields and subtrees used */
123 proto_register_field_array(proto_slow, hf, array_length(hf));
124 proto_register_subtree_array(ett, array_length(ett));
126 /* Register the dissector handle */
127 slow_protocols_handle = register_dissector("slow", dissect_slow_protocols, proto_slow);
129 /* subdissector code */
130 slow_protocols_dissector_table = register_dissector_table("slow.subtype",
131 "Slow protocol subtype",
132 proto_slow, FT_UINT8, BASE_DEC);
135 void
136 proto_reg_handoff_slow_protocols(void)
138 dissector_add_uint("ethertype", ETHERTYPE_SLOW_PROTOCOLS, slow_protocols_handle);
142 * Editor modelines - https://www.wireshark.org/tools/modelines.html
144 * Local variables:
145 * c-basic-offset: 4
146 * tab-width: 8
147 * indent-tabs-mode: nil
148 * End:
150 * vi: set shiftwidth=4 tabstop=8 expandtab:
151 * :indentSize=4:tabSize=8:noTabs=true: