2003-03-07 16:52:46 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2003 Markus Friedl. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2003-10-02 22:44:19 +00:00
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2003-03-07 16:52:46 +00:00
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <glib.h>
|
|
|
|
#include <epan/packet.h>
|
2004-09-29 00:52:45 +00:00
|
|
|
#include <epan/ipproto.h>
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
static int proto_etherip = -1;
|
|
|
|
static int hf_etherip_ver = -1;
|
|
|
|
|
|
|
|
static gint ett_etherip = -1;
|
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
static dissector_handle_t eth_withoutfcs_handle;
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
#ifndef offsetof
|
|
|
|
#define offsetof(type, member) ((size_t)(&((type *)0)->member))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* RFC 3378: EtherIP: Tunneling Ethernet Frames in IP Datagrams
|
|
|
|
*
|
|
|
|
* Bits 0-3: Protocol version
|
|
|
|
* Bits 4-15: Reserved for future use
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct etheriphdr {
|
|
|
|
guint8 ver; /* version/reserved */
|
|
|
|
guint8 pad; /* required padding byte */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define ETHERIP_VERS_MASK 0x0f
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
dissect_etherip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
struct etheriphdr etheriph;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
proto_tree *etherip_tree;
|
|
|
|
proto_item *ti;
|
|
|
|
|
2009-08-09 06:26:46 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ETHERIP");
|
2003-03-07 16:52:46 +00:00
|
|
|
|
|
|
|
/* Copy out the etherip header to insure alignment */
|
|
|
|
tvb_memcpy(tvb, (guint8 *)ðeriph, 0, sizeof(etheriph));
|
|
|
|
|
|
|
|
/* mask out reserved bits */
|
|
|
|
etheriph.ver &= ETHERIP_VERS_MASK;
|
|
|
|
|
|
|
|
if (tree) {
|
|
|
|
ti = proto_tree_add_protocol_format(tree, proto_etherip, tvb, 0,
|
|
|
|
sizeof(etheriph),
|
|
|
|
"EtherIP, Version %d",
|
|
|
|
etheriph.ver
|
|
|
|
);
|
|
|
|
etherip_tree = proto_item_add_subtree(ti, ett_etherip);
|
|
|
|
|
|
|
|
proto_tree_add_uint(etherip_tree, hf_etherip_ver, tvb,
|
|
|
|
offsetof(struct etheriphdr, ver), sizeof(etheriph.ver),
|
|
|
|
etheriph.ver);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set the tvbuff for the payload after the header */
|
|
|
|
next_tvb = tvb_new_subset(tvb, sizeof(etheriph), -1, -1);
|
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
|
2003-03-07 16:52:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_etherip(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf_etherip[] = {
|
|
|
|
{ &hf_etherip_ver,
|
|
|
|
{ "Version", "etherip.ver", FT_UINT8, BASE_HEX, NULL, 0x0,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
NULL, HFILL }},
|
2003-03-07 16:52:46 +00:00
|
|
|
};
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_etherip,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_etherip = proto_register_protocol("Ethernet over IP",
|
|
|
|
"ETHERIP", "etherip");
|
|
|
|
proto_register_field_array(proto_etherip, hf_etherip, array_length(hf_etherip));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
|
|
|
|
register_dissector("etherip", dissect_etherip, proto_etherip);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_etherip(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t etherip_handle;
|
|
|
|
|
2004-11-24 09:13:52 +00:00
|
|
|
eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
|
2003-03-07 16:52:46 +00:00
|
|
|
etherip_handle = find_dissector("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
|
|
|
}
|