2008-08-07 22:38:19 +00:00
|
|
|
/* packet-egd.c
|
|
|
|
* Routines for Ethernet Global Data dissection
|
|
|
|
* EGD Home: www.gefanuc.com
|
|
|
|
*
|
|
|
|
* Copyright 2008
|
|
|
|
* 29 July 2008 -- ryan wamsley
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-06-28 23:18:38 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2008-08-07 22:38:19 +00:00
|
|
|
*/
|
|
|
|
|
2012-09-20 02:03:38 +00:00
|
|
|
#include "config.h"
|
2008-08-07 22:38:19 +00:00
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
2016-10-05 20:33:54 +00:00
|
|
|
#define EGD_PORT 18246 /* 0x4746 - Not IANA registered */
|
2008-09-26 22:07:45 +00:00
|
|
|
|
2008-08-07 22:38:19 +00:00
|
|
|
#define EGD_ST_NONEW 0
|
|
|
|
#define EGD_ST_NOERROR 1
|
|
|
|
#define EGD_ST_CONSUMED 2
|
|
|
|
#define EGD_ST_SNTPERR 3
|
|
|
|
#define EGD_ST_SPECERR 4
|
|
|
|
#define EGD_ST_REFRESHERR 6
|
|
|
|
#define EGD_ST_REFEXDERR 7
|
|
|
|
#define EGD_ST_IPERR 10
|
|
|
|
#define EGD_ST_RESOURSEERR 12
|
|
|
|
#define EGD_ST_NAMERES 16
|
|
|
|
#define EGD_ST_ETHERR 18
|
|
|
|
#define EGD_ST_NOSUPPORT 22
|
|
|
|
#define EGD_ST_NORESP 26
|
|
|
|
#define EGD_ST_CREATEERR 28
|
|
|
|
#define EGD_ST_DELETED 30
|
|
|
|
|
2013-03-17 09:11:21 +00:00
|
|
|
|
|
|
|
void proto_register_egd(void);
|
|
|
|
void proto_reg_handoff_egd(void);
|
|
|
|
|
2008-08-07 22:38:19 +00:00
|
|
|
/* Translate status to string */
|
|
|
|
static const value_string egd_stat_vals[] = {
|
|
|
|
{ EGD_ST_NONEW, "No new status event has occurred" },
|
|
|
|
{ EGD_ST_NOERROR, "No error currently exists" },
|
|
|
|
{ EGD_ST_CONSUMED, "No error, data consumed" },
|
|
|
|
{ EGD_ST_SNTPERR, "SNTP error" },
|
|
|
|
{ EGD_ST_SPECERR, "Specification error" },
|
|
|
|
{ EGD_ST_REFRESHERR, "Data refresh error" },
|
|
|
|
{ EGD_ST_REFEXDERR, "Data refresh period exceeded" },
|
|
|
|
{ EGD_ST_IPERR, "IP Layer not currently initialized" },
|
|
|
|
{ EGD_ST_RESOURSEERR, "Lack of resource error" },
|
|
|
|
{ EGD_ST_NAMERES, "Name Resolution in progress" },
|
|
|
|
{ EGD_ST_ETHERR, "Loss of Ethernet Interface error" },
|
|
|
|
{ EGD_ST_NOSUPPORT, "Ethernet Interface does not support EGD" },
|
|
|
|
{ EGD_ST_NORESP, "No Response from Ethernet Interface" },
|
|
|
|
{ EGD_ST_CREATEERR, "Failed to create an exchange." },
|
|
|
|
{ EGD_ST_DELETED, "Configured exchange deleted." },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
static int proto_egd = -1;
|
2008-09-26 22:07:45 +00:00
|
|
|
|
2008-08-07 22:38:19 +00:00
|
|
|
static int hf_egd_ver = -1;
|
|
|
|
static int hf_egd_type = -1;
|
|
|
|
static int hf_egd_rid = -1;
|
|
|
|
static int hf_egd_pid = -1;
|
|
|
|
static int hf_egd_exid = -1;
|
|
|
|
static int hf_egd_time = -1;
|
|
|
|
static int hf_egd_notime = -1;
|
|
|
|
static int hf_egd_stat = -1;
|
|
|
|
static int hf_egd_csig = -1;
|
|
|
|
static int hf_egd_resv = -1;
|
|
|
|
|
|
|
|
static gint ett_egd = -1;
|
|
|
|
static gint ett_status_item = -1;
|
|
|
|
|
2015-11-15 13:00:10 +00:00
|
|
|
static int dissect_egd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2008-08-07 22:38:19 +00:00
|
|
|
{
|
|
|
|
/* replace UDP with EGD in display */
|
2009-08-09 07:59:51 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "EGD");
|
2008-08-07 22:38:19 +00:00
|
|
|
|
|
|
|
/* Clear out stuff in the info column */
|
2013-06-14 01:02:11 +00:00
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
|
|
|
col_add_fstr(pinfo->cinfo, COL_INFO, "Data Msg: ExchangeID=0x%08X, RequestID=%05u",
|
2008-08-07 22:38:19 +00:00
|
|
|
tvb_get_letohl(tvb, 8), tvb_get_letohs(tvb, 2));
|
|
|
|
|
|
|
|
if (tree)
|
|
|
|
{
|
|
|
|
proto_item *ti = NULL;
|
|
|
|
proto_item *notime = NULL;
|
|
|
|
proto_tree *egd_tree = NULL;
|
|
|
|
tvbuff_t *next_tvb = NULL;
|
|
|
|
gint offset, data_length;
|
2010-01-18 21:49:47 +00:00
|
|
|
guint32 sectime;
|
2008-08-07 22:38:19 +00:00
|
|
|
nstime_t egd_time;
|
|
|
|
|
|
|
|
memset(&egd_time, 0, sizeof(nstime_t));
|
|
|
|
offset = 0;
|
|
|
|
|
2011-10-21 02:10:19 +00:00
|
|
|
ti = proto_tree_add_item(tree, proto_egd, tvb, 0, -1, ENC_NA);
|
2008-08-07 22:38:19 +00:00
|
|
|
egd_tree = proto_item_add_subtree(ti, ett_egd);
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset++;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_ver, tvb, offset, 1, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset++;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_rid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset += 2;
|
2011-10-10 00:39:31 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_pid, tvb, offset, 4, ENC_BIG_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset += 4;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_exid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset += 4;
|
|
|
|
|
|
|
|
/* time */
|
2010-05-10 21:31:12 +00:00
|
|
|
sectime = tvb_get_letohl(tvb, offset);
|
2010-01-18 21:49:47 +00:00
|
|
|
if (0 == sectime)
|
2008-08-07 22:38:19 +00:00
|
|
|
{
|
2011-10-06 03:35:44 +00:00
|
|
|
notime = proto_tree_add_item(egd_tree, hf_egd_notime, tvb, offset, 8, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
proto_item_append_text(notime, "--No TimeStamp");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-05-10 21:31:12 +00:00
|
|
|
egd_time.secs = tvb_get_letohl(tvb, offset);
|
|
|
|
egd_time.nsecs = tvb_get_letohl(tvb, offset+4);
|
2008-08-07 22:38:19 +00:00
|
|
|
proto_tree_add_time(egd_tree, hf_egd_time, tvb, offset, 8, &egd_time);
|
|
|
|
}
|
|
|
|
offset += 8;
|
|
|
|
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_stat, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset += 4;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_csig, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset += 4;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(egd_tree, hf_egd_resv, tvb, offset, 4, ENC_LITTLE_ENDIAN);
|
2008-08-07 22:38:19 +00:00
|
|
|
offset += 4;
|
|
|
|
|
2015-06-23 00:19:23 +00:00
|
|
|
data_length = tvb_reported_length_remaining(tvb, offset);
|
2008-08-07 22:38:19 +00:00
|
|
|
if (data_length > 0)
|
|
|
|
{
|
2009-08-16 12:36:22 +00:00
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
2016-03-20 00:33:14 +00:00
|
|
|
call_data_dissector(next_tvb, pinfo, egd_tree);
|
2008-08-07 22:38:19 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-15 13:00:10 +00:00
|
|
|
return tvb_captured_length(tvb);
|
2008-08-07 22:38:19 +00:00
|
|
|
}
|
2009-01-28 21:52:57 +00:00
|
|
|
|
|
|
|
void proto_register_egd(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] =
|
|
|
|
{
|
|
|
|
{ &hf_egd_ver,
|
|
|
|
{ "Version", "egd.ver",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_egd_type,
|
|
|
|
{ "Type", "egd.type",
|
|
|
|
FT_UINT8, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_egd_rid,
|
|
|
|
{ "RequestID", "egd.rid",
|
|
|
|
FT_UINT16, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_egd_pid,
|
|
|
|
{ "ProducerID", "egd.pid",
|
|
|
|
FT_IPv4, BASE_NONE,
|
|
|
|
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 }
|
2009-01-28 21:52:57 +00:00
|
|
|
},
|
|
|
|
{ &hf_egd_exid,
|
|
|
|
{ "ExchangeID", "egd.exid",
|
|
|
|
FT_UINT32, BASE_HEX,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_egd_time,
|
|
|
|
{ "Timestamp", "egd.time",
|
2009-12-19 03:17:44 +00:00
|
|
|
FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
|
2009-01-28 21:52:57 +00:00
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_egd_notime,
|
2012-01-19 21:01:52 +00:00
|
|
|
{ "Timestamp", "egd.notime",
|
2009-01-28 21:52:57 +00:00
|
|
|
FT_UINT64, BASE_HEX,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_egd_stat,
|
|
|
|
{ "Status", "egd.stat",
|
|
|
|
FT_UINT32, BASE_DEC,
|
|
|
|
VALS(egd_stat_vals), 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 }
|
2009-01-28 21:52:57 +00:00
|
|
|
},
|
|
|
|
{ &hf_egd_csig,
|
|
|
|
{ "ConfigSignature", "egd.csig",
|
|
|
|
FT_UINT32, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
},
|
|
|
|
{ &hf_egd_resv,
|
|
|
|
{ "Reserved", "egd.rsrv",
|
|
|
|
FT_UINT32, BASE_DEC,
|
|
|
|
NULL, 0x0,
|
|
|
|
NULL, HFILL }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] =
|
|
|
|
{
|
|
|
|
&ett_egd,
|
|
|
|
&ett_status_item
|
|
|
|
};
|
|
|
|
|
2016-10-05 20:33:54 +00:00
|
|
|
proto_egd = proto_register_protocol ("Ethernet Global Data", "EGD", "egd");
|
2009-01-28 21:52:57 +00:00
|
|
|
proto_register_field_array(proto_egd, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void proto_reg_handoff_egd(void)
|
|
|
|
{
|
|
|
|
dissector_handle_t egd_handle;
|
|
|
|
|
2015-12-09 03:49:44 +00:00
|
|
|
egd_handle = create_dissector_handle(dissect_egd, proto_egd);
|
2016-10-05 20:33:54 +00:00
|
|
|
dissector_add_uint_with_preference("udp.port", EGD_PORT, egd_handle);
|
2009-01-28 21:52:57 +00:00
|
|
|
}
|
|
|
|
|
2014-09-29 18:07:49 +00:00
|
|
|
/*
|
|
|
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
|
|
|
*
|
|
|
|
* 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:
|
|
|
|
*/
|