2003-03-07 16:52:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2003 Markus Friedl. All rights reserved.
|
|
|
|
*
|
2018-03-07 13:08:18 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2014-03-04 15:43:25 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
2004-09-29 00:52:45 +00:00
|
|
|
#include <epan/ipproto.h>
|
2013-01-16 13:27:23 +00:00
|
|
|
#include <epan/expert.h>
|
2003-03-07 16:52:46 +00:00
|
|
|
|
2013-03-17 09:11:21 +00:00
|
|
|
void proto_register_etherip(void);
|
|
|
|
void proto_reg_handoff_etherip(void);
|
|
|
|
|
2003-03-07 16:52:46 +00:00
|
|
|
static int proto_etherip = -1;
|
|
|
|
static int hf_etherip_ver = -1;
|
2013-01-16 13:27:23 +00:00
|
|
|
static int hf_etherip_reserved = -1;
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
static gint ett_etherip = -1;
|
|
|
|
|
2013-05-26 03:29:07 +00:00
|
|
|
static expert_field ei_etherip_ver_3 = EI_INIT;
|
|
|
|
static expert_field ei_etherip_reserved_0 = EI_INIT;
|
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
static dissector_handle_t eth_withoutfcs_handle;
|
2016-12-17 01:06:11 +00:00
|
|
|
static dissector_handle_t etherip_handle;
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* RFC 3378: EtherIP: Tunneling Ethernet Frames in IP Datagrams
|
|
|
|
*
|
2012-03-06 16:58:09 +00:00
|
|
|
* Bits 0-3: Protocol version
|
|
|
|
* Bits 4-15: Reserved for future use
|
2003-03-07 16:52:46 +00:00
|
|
|
*/
|
|
|
|
|
2013-01-16 13:27:23 +00:00
|
|
|
#define ETHERIP_VERS_MASK 0xF000
|
|
|
|
#define ETHERIP_RESERVE_MASK 0x0FFF
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
|
2015-11-10 04:01:28 +00:00
|
|
|
static int
|
|
|
|
dissect_etherip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2003-03-07 16:52:46 +00:00
|
|
|
{
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
proto_tree *etherip_tree;
|
|
|
|
proto_item *ti;
|
2013-01-16 13:27:23 +00:00
|
|
|
guint16 field, version;
|
2003-03-07 16:52:46 +00:00
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ETHERIP");
|
2003-03-07 16:52:46 +00:00
|
|
|
|
2013-01-16 13:27:23 +00:00
|
|
|
field = tvb_get_ntohs(tvb, 0);
|
|
|
|
version = (field & ETHERIP_VERS_MASK) >> 12;
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_etherip, tvb, 0,
|
2013-01-16 13:27:23 +00:00
|
|
|
2,
|
2003-03-07 16:52:46 +00:00
|
|
|
"EtherIP, Version %d",
|
2013-01-16 13:27:23 +00:00
|
|
|
version
|
2012-03-06 16:58:09 +00:00
|
|
|
);
|
2003-03-07 16:52:46 +00:00
|
|
|
etherip_tree = proto_item_add_subtree(ti, ett_etherip);
|
|
|
|
|
2013-01-16 13:27:23 +00:00
|
|
|
ti = proto_tree_add_item(etherip_tree, hf_etherip_ver, tvb,
|
|
|
|
0, 2, ENC_BIG_ENDIAN);
|
|
|
|
if (version != 3) {
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_add_info(pinfo, ti, &ei_etherip_ver_3);
|
2013-01-16 13:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ti = proto_tree_add_item(etherip_tree, hf_etherip_reserved, tvb,
|
|
|
|
0, 2, ENC_BIG_ENDIAN);
|
|
|
|
if ((field & ETHERIP_RESERVE_MASK) != 0) {
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_add_info(pinfo, ti, &ei_etherip_reserved_0);
|
2013-01-16 13:27:23 +00:00
|
|
|
}
|
2003-03-07 16:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the tvbuff for the payload after the header */
|
2013-01-16 13:27:23 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, 2);
|
2003-03-07 16:52:46 +00:00
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
|
2015-11-10 04:01:28 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2003-03-07 16:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_etherip(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf_etherip[] = {
|
|
|
|
{ &hf_etherip_ver,
|
2013-01-16 13:27:23 +00:00
|
|
|
{ "Version", "etherip.ver", FT_UINT16, BASE_DEC, NULL, ETHERIP_VERS_MASK,
|
2012-03-06 16:58:09 +00:00
|
|
|
NULL, HFILL }},
|
2013-01-16 13:27:23 +00:00
|
|
|
{ &hf_etherip_reserved,
|
|
|
|
{ "Reserved", "etherip.reserved", FT_UINT16, BASE_HEX, NULL, ETHERIP_RESERVE_MASK,
|
|
|
|
"Reserved (must be 0)", HFILL }},
|
2003-03-07 16:52:46 +00:00
|
|
|
};
|
2013-01-16 13:27:23 +00:00
|
|
|
|
2003-03-07 16:52:46 +00:00
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_etherip,
|
|
|
|
};
|
|
|
|
|
2013-05-26 03:29:07 +00:00
|
|
|
static ei_register_info ei[] = {
|
|
|
|
{ &ei_etherip_ver_3, { "etherip.ver.not3", PI_PROTOCOL, PI_WARN, "Version must be 3", EXPFILL }},
|
|
|
|
{ &ei_etherip_reserved_0, { "etherip.reserved.not0", PI_PROTOCOL, PI_WARN, "Reserved field must be 0", EXPFILL }},
|
|
|
|
};
|
|
|
|
|
|
|
|
expert_module_t* expert_etherip;
|
|
|
|
|
2003-03-07 16:52:46 +00:00
|
|
|
proto_etherip = proto_register_protocol("Ethernet over IP",
|
2012-03-06 16:58:09 +00:00
|
|
|
"ETHERIP", "etherip");
|
2003-03-07 16:52:46 +00:00
|
|
|
proto_register_field_array(proto_etherip, hf_etherip, array_length(hf_etherip));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2013-05-26 03:29:07 +00:00
|
|
|
expert_etherip = expert_register_protocol(proto_etherip);
|
|
|
|
expert_register_field_array(expert_etherip, ei, array_length(ei));
|
2003-03-07 16:52:46 +00:00
|
|
|
|
2016-12-17 01:06:11 +00:00
|
|
|
etherip_handle = register_dissector("etherip", dissect_etherip, proto_etherip);
|
2003-03-07 16:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_etherip(void)
|
|
|
|
{
|
2016-03-16 13:02:52 +00:00
|
|
|
eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_etherip);
|
2010-12-20 05:35:29 +00:00
|
|
|
dissector_add_uint("ip.proto", IP_PROTO_ETHERIP, etherip_handle);
|
2003-03-07 16:52:46 +00:00
|
|
|
}
|
2014-09-29 18:07:49 +00:00
|
|
|
|
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2014-09-29 18:07:49 +00:00
|
|
|
*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 2
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: nil
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* ex: set shiftwidth=2 tabstop=8 expandtab:
|
|
|
|
* :indentSize=2:tabSize=8:noTabs=true:
|
|
|
|
*/
|