2 * Routines for Ethernet Global Data dissection
3 * EGD Home: www.gefanuc.com
6 * 29 July 2008 -- ryan wamsley
10 * Wireshark - Network traffic analyzer
11 * By Gerald Combs <gerald@wireshark.org>
12 * Copyright 1998 Gerald Combs
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34 #include <epan/packet.h>
36 #define EGD_PORT 18246 /* 0x4746 */
38 #define EGD_ST_NONEW 0
39 #define EGD_ST_NOERROR 1
40 #define EGD_ST_CONSUMED 2
41 #define EGD_ST_SNTPERR 3
42 #define EGD_ST_SPECERR 4
43 #define EGD_ST_REFRESHERR 6
44 #define EGD_ST_REFEXDERR 7
45 #define EGD_ST_IPERR 10
46 #define EGD_ST_RESOURSEERR 12
47 #define EGD_ST_NAMERES 16
48 #define EGD_ST_ETHERR 18
49 #define EGD_ST_NOSUPPORT 22
50 #define EGD_ST_NORESP 26
51 #define EGD_ST_CREATEERR 28
52 #define EGD_ST_DELETED 30
54 /* Translate status to string */
55 static const value_string egd_stat_vals[] = {
56 { EGD_ST_NONEW, "No new status event has occurred" },
57 { EGD_ST_NOERROR, "No error currently exists" },
58 { EGD_ST_CONSUMED, "No error, data consumed" },
59 { EGD_ST_SNTPERR, "SNTP error" },
60 { EGD_ST_SPECERR, "Specification error" },
61 { EGD_ST_REFRESHERR, "Data refresh error" },
62 { EGD_ST_REFEXDERR, "Data refresh period exceeded" },
63 { EGD_ST_IPERR, "IP Layer not currently initialized" },
64 { EGD_ST_RESOURSEERR, "Lack of resource error" },
65 { EGD_ST_NAMERES, "Name Resolution in progress" },
66 { EGD_ST_ETHERR, "Loss of Ethernet Interface error" },
67 { EGD_ST_NOSUPPORT, "Ethernet Interface does not support EGD" },
68 { EGD_ST_NORESP, "No Response from Ethernet Interface" },
69 { EGD_ST_CREATEERR, "Failed to create an exchange." },
70 { EGD_ST_DELETED, "Configured exchange deleted." },
74 static int proto_egd = -1;
76 static dissector_handle_t data_handle;
78 static int hf_egd_ver = -1;
79 static int hf_egd_type = -1;
80 static int hf_egd_rid = -1;
81 static int hf_egd_pid = -1;
82 static int hf_egd_exid = -1;
83 static int hf_egd_time = -1;
84 static int hf_egd_notime = -1;
85 static int hf_egd_stat = -1;
86 static int hf_egd_csig = -1;
87 static int hf_egd_resv = -1;
89 static gint ett_egd = -1;
90 static gint ett_status_item = -1;
92 static void dissect_egd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
94 /* replace UDP with EGD in display */
95 if (check_col(pinfo->cinfo, COL_PROTOCOL))
97 col_set_str(pinfo->cinfo, COL_PROTOCOL, "EGD");
100 /* Clear out stuff in the info column */
101 if (check_col(pinfo->cinfo,COL_INFO))
103 col_clear(pinfo->cinfo, COL_INFO);
104 col_add_fstr(pinfo->cinfo, COL_INFO, "Data Msg: ExchangeID=0x%08X, RequestID=%05u",
105 tvb_get_letohl(tvb, 8), tvb_get_letohs(tvb, 2));
110 proto_item *ti = NULL;
111 proto_item *notime = NULL;
112 proto_tree *egd_tree = NULL;
113 tvbuff_t *next_tvb = NULL;
114 gint offset, data_length;
118 memset(&egd_time, 0, sizeof(nstime_t));
121 ti = proto_tree_add_item(tree, proto_egd, tvb, 0, -1, FALSE);
122 egd_tree = proto_item_add_subtree(ti, ett_egd);
123 proto_tree_add_item(egd_tree, hf_egd_type, tvb, offset, 1, FALSE);
125 proto_tree_add_item(egd_tree, hf_egd_ver, tvb, offset, 1, FALSE);
127 proto_tree_add_item(egd_tree, hf_egd_rid, tvb, offset, 2, TRUE);
129 proto_tree_add_item(egd_tree, hf_egd_pid, tvb, offset, 4, FALSE);
131 proto_tree_add_item(egd_tree, hf_egd_exid, tvb, offset, 4, TRUE);
135 stime = tvb_get_ntohl(tvb, offset);
138 notime = proto_tree_add_item(egd_tree, hf_egd_notime, tvb, offset, 8, FALSE);
139 proto_item_append_text(notime, "--No TimeStamp");
143 egd_time.secs = tvb_get_ntohl(tvb, offset);
144 egd_time.nsecs = tvb_get_ntohl(tvb, offset+4);
145 proto_tree_add_time(egd_tree, hf_egd_time, tvb, offset, 8, &egd_time);
149 proto_tree_add_item(egd_tree, hf_egd_stat, tvb, offset, 4, FALSE);
151 proto_tree_add_item(egd_tree, hf_egd_csig, tvb, offset, 4, FALSE);
153 proto_tree_add_item(egd_tree, hf_egd_resv, tvb, offset, 4, FALSE);
156 data_length = tvb_length_remaining(tvb, offset);
159 next_tvb = tvb_new_subset(tvb, offset, -1, -1);
160 call_dissector(data_handle, next_tvb, pinfo, egd_tree);
165 void proto_register_egd(void)
167 static hf_register_info hf[] =
170 { "Version", "egd.ver",
176 { "Type", "egd.type",
182 { "RequestID", "egd.rid",
188 { "ProducerID", "egd.pid",
194 { "ExchangeID", "egd.exid",
200 { "Timestamp", "egd.time",
201 FT_ABSOLUTE_TIME, BASE_NONE,
206 { "Timestamp", "egd.time",
212 { "Status", "egd.stat",
214 VALS(egd_stat_vals), 0x0,
218 { "ConfigSignature", "egd.csig",
224 { "Reserved", "egd.rsrv",
237 proto_egd = proto_register_protocol (
238 "Ethernet Global Data", /* name */
239 "EGD", /* short name */
242 proto_register_field_array(proto_egd, hf, array_length(hf));
243 proto_register_subtree_array(ett, array_length(ett));
246 void proto_reg_handoff_egd(void)
248 dissector_handle_t egd_handle;
250 egd_handle = create_dissector_handle(dissect_egd, proto_egd);
251 dissector_add("udp.port", EGD_PORT, egd_handle);
253 /* find data dissector */
254 data_handle = find_dissector("data");