Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-egd.c
blob2df353e710ea6145452d9efda4f5e94160b04077
1 /* packet-egd.c
2 * Routines for Ethernet Global Data dissection
3 * EGD Home: www.gefanuc.com
5 * Copyright 2008
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
15 #include "config.h"
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." },
63 { 0, NULL }
66 static int proto_egd;
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;
79 static int ett_egd;
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) {
89 return 0;
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));
100 if (tree)
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;
107 uint32_t sectime;
109 offset = 0;
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);
114 offset++;
115 proto_tree_add_item(egd_tree, hf_egd_ver, tvb, offset, 1, ENC_LITTLE_ENDIAN);
116 offset++;
117 proto_tree_add_item(egd_tree, hf_egd_rid, tvb, offset, 2, ENC_LITTLE_ENDIAN);
118 offset += 2;
119 proto_tree_add_item(egd_tree, hf_egd_pid, tvb, offset, 4, ENC_BIG_ENDIAN);
120 offset += 4;
121 proto_tree_add_item(egd_tree, hf_egd_exid, tvb, offset, 4, ENC_LITTLE_ENDIAN);
122 offset += 4;
124 /* time */
125 sectime = tvb_get_letohl(tvb, offset);
126 if (0 == sectime)
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");
131 else
133 proto_tree_add_item(egd_tree, hf_egd_time, tvb, offset, 8, ENC_LITTLE_ENDIAN);
135 offset += 8;
137 proto_tree_add_item(egd_tree, hf_egd_stat, tvb, offset, 4, ENC_LITTLE_ENDIAN);
138 offset += 4;
139 proto_tree_add_item(egd_tree, hf_egd_csig, tvb, offset, 4, ENC_LITTLE_ENDIAN);
140 offset += 4;
141 proto_tree_add_item(egd_tree, hf_egd_resv, tvb, offset, 4, ENC_LITTLE_ENDIAN);
142 offset += 4;
144 data_length = tvb_reported_length_remaining(tvb, offset);
145 if (data_length > 0)
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[] =
158 { &hf_egd_ver,
159 { "Version", "egd.ver",
160 FT_UINT8, BASE_DEC,
161 NULL, 0x0,
162 NULL, HFILL }
164 { &hf_egd_type,
165 { "Type", "egd.type",
166 FT_UINT8, BASE_DEC,
167 NULL, 0x0,
168 NULL, HFILL }
170 { &hf_egd_rid,
171 { "RequestID", "egd.rid",
172 FT_UINT16, BASE_DEC,
173 NULL, 0x0,
174 NULL, HFILL }
176 { &hf_egd_pid,
177 { "ProducerID", "egd.pid",
178 FT_IPv4, BASE_NONE,
179 NULL, 0x0,
180 NULL, HFILL }
182 { &hf_egd_exid,
183 { "ExchangeID", "egd.exid",
184 FT_UINT32, BASE_HEX,
185 NULL, 0x0,
186 NULL, HFILL }
188 { &hf_egd_time,
189 { "Timestamp", "egd.time",
190 FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL,
191 NULL, 0x0,
192 NULL, HFILL }
194 { &hf_egd_notime,
195 { "Timestamp", "egd.notime",
196 FT_UINT64, BASE_HEX,
197 NULL, 0x0,
198 NULL, HFILL }
200 { &hf_egd_stat,
201 { "Status", "egd.stat",
202 FT_UINT32, BASE_DEC,
203 VALS(egd_stat_vals), 0x0,
204 NULL, HFILL }
206 { &hf_egd_csig,
207 { "ConfigSignature", "egd.csig",
208 FT_UINT32, BASE_DEC,
209 NULL, 0x0,
210 NULL, HFILL }
212 { &hf_egd_resv,
213 { "Reserved", "egd.rsrv",
214 FT_UINT32, BASE_DEC,
215 NULL, 0x0,
216 NULL, HFILL }
220 static int *ett[] =
222 &ett_egd,
223 &ett_status_item
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
241 * Local Variables:
242 * c-basic-offset: 2
243 * tab-width: 8
244 * indent-tabs-mode: nil
245 * End:
247 * ex: set shiftwidth=2 tabstop=8 expandtab:
248 * :indentSize=2:tabSize=8:noTabs=true: