Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-etherip.c
blob28b8ce72487e0cf737174edf044ed1d043fd3fa4
1 /*
2 * Copyright (c) 2003 Markus Friedl. All rights reserved.
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
7 #include "config.h"
9 #include <epan/packet.h>
10 #include <epan/ipproto.h>
11 #include <epan/expert.h>
13 void proto_register_etherip(void);
14 void proto_reg_handoff_etherip(void);
16 static int proto_etherip;
17 static int hf_etherip_ver;
18 static int hf_etherip_reserved;
20 static int ett_etherip;
22 static expert_field ei_etherip_ver_3;
23 static expert_field ei_etherip_reserved_0;
25 static dissector_handle_t eth_withoutfcs_handle;
26 static dissector_handle_t etherip_handle;
29 * RFC 3378: EtherIP: Tunneling Ethernet Frames in IP Datagrams
31 * Bits 0-3: Protocol version
32 * Bits 4-15: Reserved for future use
35 #define ETHERIP_VERS_MASK 0xF000
36 #define ETHERIP_RESERVE_MASK 0x0FFF
39 static int
40 dissect_etherip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
42 tvbuff_t *next_tvb;
43 proto_tree *etherip_tree;
44 proto_item *ti;
45 uint16_t field, version;
47 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ETHERIP");
49 field = tvb_get_ntohs(tvb, 0);
50 version = (field & ETHERIP_VERS_MASK) >> 12;
52 if (tree) {
53 ti = proto_tree_add_protocol_format(tree, proto_etherip, tvb, 0,
55 "EtherIP, Version %d",
56 version
58 etherip_tree = proto_item_add_subtree(ti, ett_etherip);
60 ti = proto_tree_add_item(etherip_tree, hf_etherip_ver, tvb,
61 0, 2, ENC_BIG_ENDIAN);
62 if (version != 3) {
63 expert_add_info(pinfo, ti, &ei_etherip_ver_3);
66 ti = proto_tree_add_item(etherip_tree, hf_etherip_reserved, tvb,
67 0, 2, ENC_BIG_ENDIAN);
68 if ((field & ETHERIP_RESERVE_MASK) != 0) {
69 expert_add_info(pinfo, ti, &ei_etherip_reserved_0);
73 /* Set the tvbuff for the payload after the header */
74 next_tvb = tvb_new_subset_remaining(tvb, 2);
76 call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
77 return tvb_captured_length(tvb);
80 void
81 proto_register_etherip(void)
83 static hf_register_info hf_etherip[] = {
84 { &hf_etherip_ver,
85 { "Version", "etherip.ver", FT_UINT16, BASE_DEC, NULL, ETHERIP_VERS_MASK,
86 NULL, HFILL }},
87 { &hf_etherip_reserved,
88 { "Reserved", "etherip.reserved", FT_UINT16, BASE_HEX, NULL, ETHERIP_RESERVE_MASK,
89 "Reserved (must be 0)", HFILL }},
92 static int *ett[] = {
93 &ett_etherip,
96 static ei_register_info ei[] = {
97 { &ei_etherip_ver_3, { "etherip.ver.not3", PI_PROTOCOL, PI_WARN, "Version must be 3", EXPFILL }},
98 { &ei_etherip_reserved_0, { "etherip.reserved.not0", PI_PROTOCOL, PI_WARN, "Reserved field must be 0", EXPFILL }},
101 expert_module_t* expert_etherip;
103 proto_etherip = proto_register_protocol("Ethernet over IP",
104 "ETHERIP", "etherip");
105 proto_register_field_array(proto_etherip, hf_etherip, array_length(hf_etherip));
106 proto_register_subtree_array(ett, array_length(ett));
107 expert_etherip = expert_register_protocol(proto_etherip);
108 expert_register_field_array(expert_etherip, ei, array_length(ei));
110 etherip_handle = register_dissector("etherip", dissect_etherip, proto_etherip);
113 void
114 proto_reg_handoff_etherip(void)
116 eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_etherip);
117 dissector_add_uint("ip.proto", IP_PROTO_ETHERIP, etherip_handle);
121 * Editor modelines - https://www.wireshark.org/tools/modelines.html
123 * Local Variables:
124 * c-basic-offset: 2
125 * tab-width: 8
126 * indent-tabs-mode: nil
127 * End:
129 * ex: set shiftwidth=2 tabstop=8 expandtab:
130 * :indentSize=2:tabSize=8:noTabs=true: