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 "GF" for GE Fanuc - Not IANA registered */
20 /* The above port is used for data packets. UDP port 7937 (also not registered)
21 * is used for configuration commands, but this dissector doesn't support them.
24 #define EGD_ST_NONEW 0
25 #define EGD_ST_NOERROR 1
26 #define EGD_ST_CONSUMED 2
27 #define EGD_ST_SNTPERR 3
28 #define EGD_ST_SPECERR 4
29 #define EGD_ST_REFRESHERR 6
30 #define EGD_ST_REFEXDERR 7
31 #define EGD_ST_IPERR 10
32 #define EGD_ST_RESOURSEERR 12
33 #define EGD_ST_NAMERES 16
34 #define EGD_ST_ETHERR 18
35 #define EGD_ST_NOSUPPORT 22
36 #define EGD_ST_NORESP 26
37 #define EGD_ST_CREATEERR 28
38 #define EGD_ST_DELETED 30
41 void proto_register_egd(void);
42 void proto_reg_handoff_egd(void);
44 static dissector_handle_t egd_handle
;
46 /* Translate status to string */
47 static const value_string egd_stat_vals
[] = {
48 { EGD_ST_NONEW
, "No new status event has occurred" },
49 { EGD_ST_NOERROR
, "No error currently exists" },
50 { EGD_ST_CONSUMED
, "No error, data consumed" },
51 { EGD_ST_SNTPERR
, "SNTP error" },
52 { EGD_ST_SPECERR
, "Specification error" },
53 { EGD_ST_REFRESHERR
, "Data refresh error" },
54 { EGD_ST_REFEXDERR
, "Data refresh period exceeded" },
55 { EGD_ST_IPERR
, "IP Layer not currently initialized" },
56 { EGD_ST_RESOURSEERR
, "Lack of resource error" },
57 { EGD_ST_NAMERES
, "Name Resolution in progress" },
58 { EGD_ST_ETHERR
, "Loss of Ethernet Interface error" },
59 { EGD_ST_NOSUPPORT
, "Ethernet Interface does not support EGD" },
60 { EGD_ST_NORESP
, "No Response from Ethernet Interface" },
61 { EGD_ST_CREATEERR
, "Failed to create an exchange." },
62 { EGD_ST_DELETED
, "Configured exchange deleted." },
68 static int hf_egd_ver
;
69 static int hf_egd_type
;
70 static int hf_egd_rid
;
71 static int hf_egd_pid
;
72 static int hf_egd_exid
;
73 static int hf_egd_time
;
74 static int hf_egd_notime
;
75 static int hf_egd_stat
;
76 static int hf_egd_csig
;
77 static int hf_egd_resv
;
80 static int ett_status_item
;
82 static int dissect_egd(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
84 /* EGD Data messages are PDU type 13 (0x0d) and version 1.
85 * All other PDU types are Control messages, which are sent to a different
86 * port, each have a different format, and not handled by this dissector.
88 if (tvb_get_ntohs(tvb
, 0) != 0x0d01) {
92 /* replace UDP with EGD in display */
93 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "EGD");
95 /* Clear out stuff in the info column */
96 col_clear(pinfo
->cinfo
, COL_INFO
);
97 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Data Msg: ExchangeID=0x%08X, RequestID=%05u",
98 tvb_get_letohl(tvb
, 8), tvb_get_letohs(tvb
, 2));
102 proto_item
*ti
= NULL
;
103 proto_item
*notime
= NULL
;
104 proto_tree
*egd_tree
= NULL
;
105 tvbuff_t
*next_tvb
= NULL
;
106 int offset
, data_length
;
111 ti
= proto_tree_add_item(tree
, proto_egd
, tvb
, 0, -1, ENC_NA
);
112 egd_tree
= proto_item_add_subtree(ti
, ett_egd
);
113 proto_tree_add_item(egd_tree
, hf_egd_type
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
115 proto_tree_add_item(egd_tree
, hf_egd_ver
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
117 proto_tree_add_item(egd_tree
, hf_egd_rid
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
119 proto_tree_add_item(egd_tree
, hf_egd_pid
, tvb
, offset
, 4, ENC_BIG_ENDIAN
);
121 proto_tree_add_item(egd_tree
, hf_egd_exid
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
125 sectime
= tvb_get_letohl(tvb
, offset
);
128 notime
= proto_tree_add_item(egd_tree
, hf_egd_notime
, tvb
, offset
, 8, ENC_LITTLE_ENDIAN
);
129 proto_item_append_text(notime
, "--No TimeStamp");
133 proto_tree_add_item(egd_tree
, hf_egd_time
, tvb
, offset
, 8, ENC_LITTLE_ENDIAN
);
137 proto_tree_add_item(egd_tree
, hf_egd_stat
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
139 proto_tree_add_item(egd_tree
, hf_egd_csig
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
141 proto_tree_add_item(egd_tree
, hf_egd_resv
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
144 data_length
= tvb_reported_length_remaining(tvb
, offset
);
147 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
148 call_data_dissector(next_tvb
, pinfo
, egd_tree
);
151 return tvb_captured_length(tvb
);
154 void proto_register_egd(void)
156 static hf_register_info hf
[] =
159 { "Version", "egd.ver",
165 { "Type", "egd.type",
171 { "RequestID", "egd.rid",
177 { "ProducerID", "egd.pid",
183 { "ExchangeID", "egd.exid",
189 { "Timestamp", "egd.time",
190 FT_ABSOLUTE_TIME
, ABSOLUTE_TIME_LOCAL
,
195 { "Timestamp", "egd.notime",
201 { "Status", "egd.stat",
203 VALS(egd_stat_vals
), 0x0,
207 { "ConfigSignature", "egd.csig",
213 { "Reserved", "egd.rsrv",
226 proto_egd
= proto_register_protocol ("Ethernet Global Data", "EGD", "egd");
227 proto_register_field_array(proto_egd
, hf
, array_length(hf
));
228 proto_register_subtree_array(ett
, array_length(ett
));
230 egd_handle
= register_dissector("egd", dissect_egd
, proto_egd
);
233 void proto_reg_handoff_egd(void)
235 dissector_add_uint_with_preference("udp.port", EGD_PORT
, egd_handle
);
239 * Editor modelines - https://www.wireshark.org/tools/modelines.html
244 * indent-tabs-mode: nil
247 * ex: set shiftwidth=2 tabstop=8 expandtab:
248 * :indentSize=2:tabSize=8:noTabs=true: