2 * Routines for Ethernet Global Data dissection
3 * EGD Home: www.gefanuc.com
6 * 29 July 2008 -- ryan wamsley
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
12 * SPDX-License-Identifier: GPL-2.0-or-later
17 #include <epan/packet.h>
19 #define EGD_PORT 18246 /* 0x4746 - Not IANA registered */
21 #define EGD_ST_NONEW 0
22 #define EGD_ST_NOERROR 1
23 #define EGD_ST_CONSUMED 2
24 #define EGD_ST_SNTPERR 3
25 #define EGD_ST_SPECERR 4
26 #define EGD_ST_REFRESHERR 6
27 #define EGD_ST_REFEXDERR 7
28 #define EGD_ST_IPERR 10
29 #define EGD_ST_RESOURSEERR 12
30 #define EGD_ST_NAMERES 16
31 #define EGD_ST_ETHERR 18
32 #define EGD_ST_NOSUPPORT 22
33 #define EGD_ST_NORESP 26
34 #define EGD_ST_CREATEERR 28
35 #define EGD_ST_DELETED 30
38 void proto_register_egd(void);
39 void proto_reg_handoff_egd(void);
41 /* Translate status to string */
42 static const value_string egd_stat_vals[] = {
43 { EGD_ST_NONEW, "No new status event has occurred" },
44 { EGD_ST_NOERROR, "No error currently exists" },
45 { EGD_ST_CONSUMED, "No error, data consumed" },
46 { EGD_ST_SNTPERR, "SNTP error" },
47 { EGD_ST_SPECERR, "Specification error" },
48 { EGD_ST_REFRESHERR, "Data refresh error" },
49 { EGD_ST_REFEXDERR, "Data refresh period exceeded" },
50 { EGD_ST_IPERR, "IP Layer not currently initialized" },
51 { EGD_ST_RESOURSEERR, "Lack of resource error" },
52 { EGD_ST_NAMERES, "Name Resolution in progress" },
53 { EGD_ST_ETHERR, "Loss of Ethernet Interface error" },
54 { EGD_ST_NOSUPPORT, "Ethernet Interface does not support EGD" },
55 { EGD_ST_NORESP, "No Response from Ethernet Interface" },
56 { EGD_ST_CREATEERR, "Failed to create an exchange." },
57 { EGD_ST_DELETED, "Configured exchange deleted." },
61 static int proto_egd = -1;
63 static int hf_egd_ver = -1;
64 static int hf_egd_type = -1;
65 static int hf_egd_rid = -1;
66 static int hf_egd_pid = -1;
67 static int hf_egd_exid = -1;
68 static int hf_egd_time = -1;
69 static int hf_egd_notime = -1;
70 static int hf_egd_stat = -1;
71 static int hf_egd_csig = -1;
72 static int hf_egd_resv = -1;
74 static gint ett_egd = -1;
75 static gint ett_status_item = -1;
77 static int dissect_egd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
79 /* replace UDP with EGD in display */
80 col_set_str(pinfo->cinfo, COL_PROTOCOL, "EGD");
82 /* Clear out stuff in the info column */
83 col_clear(pinfo->cinfo, COL_INFO);
84 col_add_fstr(pinfo->cinfo, COL_INFO, "Data Msg: ExchangeID=0x%08X, RequestID=%05u",
85 tvb_get_letohl(tvb, 8), tvb_get_letohs(tvb, 2));
89 proto_item *ti = NULL;
90 proto_item *notime = NULL;
91 proto_tree *egd_tree = NULL;
92 tvbuff_t *next_tvb = NULL;
93 gint offset, data_length;
98 ti = proto_tree_add_item(tree, proto_egd, tvb, 0, -1, ENC_NA);
99 egd_tree = proto_item_add_subtree(ti, ett_egd);
100 proto_tree_add_item(egd_tree, hf_egd_type, tvb, offset, 1, ENC_LITTLE_ENDIAN);
102 proto_tree_add_item(egd_tree, hf_egd_ver, tvb, offset, 1, ENC_LITTLE_ENDIAN);
104 proto_tree_add_item(egd_tree, hf_egd_rid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
106 proto_tree_add_item(egd_tree, hf_egd_pid, tvb, offset, 4, ENC_BIG_ENDIAN);
108 proto_tree_add_item(egd_tree, hf_egd_exid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
112 sectime = tvb_get_letohl(tvb, offset);
115 notime = proto_tree_add_item(egd_tree, hf_egd_notime, tvb, offset, 8, ENC_LITTLE_ENDIAN);
116 proto_item_append_text(notime, "--No TimeStamp");
120 proto_tree_add_item(egd_tree, hf_egd_time, tvb, offset, 8, ENC_LITTLE_ENDIAN);
124 proto_tree_add_item(egd_tree, hf_egd_stat, tvb, offset, 4, ENC_LITTLE_ENDIAN);
126 proto_tree_add_item(egd_tree, hf_egd_csig, tvb, offset, 4, ENC_LITTLE_ENDIAN);
128 proto_tree_add_item(egd_tree, hf_egd_resv, tvb, offset, 4, ENC_LITTLE_ENDIAN);
131 data_length = tvb_reported_length_remaining(tvb, offset);
134 next_tvb = tvb_new_subset_remaining(tvb, offset);
135 call_data_dissector(next_tvb, pinfo, egd_tree);
138 return tvb_captured_length(tvb);
141 void proto_register_egd(void)
143 static hf_register_info hf[] =
146 { "Version", "egd.ver",
152 { "Type", "egd.type",
158 { "RequestID", "egd.rid",
164 { "ProducerID", "egd.pid",
170 { "ExchangeID", "egd.exid",
176 { "Timestamp", "egd.time",
177 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
182 { "Timestamp", "egd.notime",
188 { "Status", "egd.stat",
190 VALS(egd_stat_vals), 0x0,
194 { "ConfigSignature", "egd.csig",
200 { "Reserved", "egd.rsrv",
213 proto_egd = proto_register_protocol ("Ethernet Global Data", "EGD", "egd");
214 proto_register_field_array(proto_egd, hf, array_length(hf));
215 proto_register_subtree_array(ett, array_length(ett));
218 void proto_reg_handoff_egd(void)
220 dissector_handle_t egd_handle;
222 egd_handle = create_dissector_handle(dissect_egd, proto_egd);
223 dissector_add_uint_with_preference("udp.port", EGD_PORT, egd_handle);
227 * Editor modelines - http://www.wireshark.org/tools/modelines.html
232 * indent-tabs-mode: nil
235 * ex: set shiftwidth=2 tabstop=8 expandtab:
236 * :indentSize=2:tabSize=8:noTabs=true: