Bug Summary

File:plugins/epan/ethercat/packet-ams.c
Warning:line 673, column 19
Value stored to 'offset' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name packet-ams.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-21/lib/clang/21 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D PLUGIN_VERSION="0.1.0" -D WS_DEBUG -D WS_DEBUG_UTF_8 -D ethercat_EXPORTS -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -I /builds/wireshark/wireshark/plugins/epan/ethercat -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-truncation -Wno-format-nonliteral -Wno-pointer-sign -std=gnu11 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /builds/wireshark/wireshark/sbout/2025-10-13-100350-3623-1 -x c /builds/wireshark/wireshark/plugins/epan/ethercat/packet-ams.c
1/* packet-ams.c
2 * Routines for ethercat packet disassembly
3 *
4 * Copyright (c) 2007 by Beckhoff Automation GmbH
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13/* Include files */
14
15#include "config.h"
16
17#include <epan/packet.h>
18#include <epan/conversation.h>
19#include <epan/tfs.h>
20#include <wsutil/array.h>
21
22#include "packet-ams.h"
23
24#include "epan/dissectors/packet-tcp.h"
25
26void proto_register_ams(void);
27void proto_reg_handoff_ams(void);
28
29#define AMS_TCP_PORT_RANGE"48898" "48898" /* Not IANA registered */
30
31/* Define the ams proto */
32int proto_ams;
33
34static dissector_handle_t amstcp_handle;
35
36/* Define the tree for ams */
37static int ett_ams;
38static int ett_ams_stateflags;
39static int ett_ams_adsreadrequest;
40static int ett_ams_adsreadresponse;
41static int ett_ams_adswriterequest;
42static int ett_ams_adswriteresponse;
43static int ett_ams_adsreadwriterequest;
44static int ett_ams_adsreadwriteresponse;
45static int ett_ams_adsreadstaterequest;
46static int ett_ams_adsreadstateresponse;
47static int ett_ams_adswritectrlrequest;
48static int ett_ams_adswritectrlresponse;
49static int ett_ams_adsreaddinforequest;
50static int ett_ams_adsreaddinforesponse;
51static int ett_ams_adsadddnrequest;
52static int ett_ams_adsadddnresponse;
53static int ett_ams_adsdeldnrequest;
54static int ett_ams_adsdeldnresponse;
55static int ett_ams_adsdnrequest;
56
57static int hf_ams_sendernetid;
58static int hf_ams_senderport;
59static int hf_ams_targetnetid;
60static int hf_ams_targetport;
61static int hf_ams_cmdid;
62static int hf_ams_stateflags;
63static int hf_ams_stateresponse;
64static int hf_ams_statenoreturn;
65static int hf_ams_stateadscmd;
66static int hf_ams_statesyscmd;
67static int hf_ams_statehighprio;
68static int hf_ams_statetimestampadded;
69static int hf_ams_stateudp;
70static int hf_ams_stateinitcmd;
71static int hf_ams_statebroadcast;
72static int hf_ams_cbdata;
73static int hf_ams_errorcode;
74static int hf_ams_invokeid;
75static int hf_ams_response_in;
76static int hf_ams_response_to;
77static int hf_ams_response_time;
78static int hf_ams_data;
79
80/*ads Commands */
81static int hf_ams_adsindexgroup;
82static int hf_ams_adsindexoffset;
83static int hf_ams_adscblength;
84static int hf_ams_adsreadrequest;
85static int hf_ams_adsreadresponse;
86static int hf_ams_adsinvokeid;
87static int hf_ams_adsresult;
88static int hf_ams_adsdata;
89static int hf_ams_adswriterequest;
90static int hf_ams_adswriteresponse;
91static int hf_ams_adsreadwriterequest;
92static int hf_ams_adsreadwriteresponse;
93static int hf_ams_adscbreadlength;
94static int hf_ams_adscbwritelength;
95static int hf_ams_adsstate;
96static int hf_ams_adsdevicestate;
97static int hf_ams_adsnotificationhandle;
98static int hf_ams_adsreadstaterequest;
99static int hf_ams_adsreadstateresponse;
100static int hf_ams_adswritectrlrequest;
101static int hf_ams_adswritectrlresponse;
102static int hf_ams_adsreaddinforequest;
103static int hf_ams_adsreaddinforesponse;
104static int hf_ams_adsadddnrequest;
105static int hf_ams_adsadddnresponse;
106static int hf_ams_adsdeldnrequest;
107static int hf_ams_adsdeldnresponse;
108static int hf_ams_adsdnrequest;
109/* static int hf_ams_adsdnresponse; */
110/* static int hf_ams_adsnoteattrib; */
111/* static int hf_ams_adsnoteblocks; */
112/* static int hf_ams_adsversion; */
113static int hf_ams_adsdevicename;
114static int hf_ams_adsversionversion;
115static int hf_ams_adsversionrevision;
116static int hf_ams_adsversionbuild;
117static int hf_ams_adsnoteblocksstamps;
118/* static int hf_ams_adsnoteblocksstamp; */
119/* static int hf_ams_adstimestamp; */
120/* static int hf_ams_adssamplecnt; */
121/* static int hf_ams_adsnoteblockssample; */
122static int hf_ams_adstransmode;
123static int hf_ams_adsmaxdelay;
124static int hf_ams_adscycletime;
125/* static int hf_ams_adscmpmax; */
126/* static int hf_ams_adscmpmin; */
127
128static dissector_handle_t ams_handle;
129
130/* Structure for tracking request/response transactions */
131typedef struct _ams_transaction_t {
132 uint32_t req_frame;
133 uint32_t rep_frame;
134 nstime_t req_time;
135} ams_transaction_t;
136
137/* Structure for per-conversation data */
138typedef struct _ams_conv_info_t {
139 wmem_map_t *transactions; /* Maps invokeId -> ams_transaction_t */
140} ams_conv_info_t;
141
142static const value_string TransMode[] =
143{
144 { 0, "NO TRANS"},
145 { 1, "CLIENT CYCLE"},
146 { 2, "CLIENT ON CHANGE"},
147 { 3, "SERVER CYCLE"},
148 { 4, "SERVER ON CHANGE"},
149 { 10, "CLIENT FIRST REQUEST"},
150 { 0, NULL((void*)0) }
151};
152
153static const value_string ErrorCode[] =
154{
155 { ERR_NOERROR0, "NO ERROR"},
156 { ERR_INTERNAL1, "INTERNAL"},
157 { ERR_NORTIME2, "NO RTIME"},
158 { ERR_ALLOCLOCKEDMEM3, "ALLOC LOCKED MEM"},
159 { ERR_INSERTMAILBOX4, "INSERT MAILBOX"},
160 { ERR_WRONGRECEIVEHMSG5, "WRONGRECEIVEHMSG"},
161 { ERR_TARGETPORTNOTFOUND6, "TARGET PORT NOT FOUND"},
162 { ERR_TARGETMACHINENOTFOUND7, "TARGET MACHINE NOT FOUND"},
163 { ERR_UNKNOWNCMDID8, "UNKNOWN CMDID"},
164 { ERR_BADTASKID9, "BAD TASKID"},
165 { ERR_NOIO10, "NOIO"},
166 { ERR_UNKNOWNAMSCMD11, "UNKNOWN AMSCMD"},
167 { ERR_WIN32ERROR12, "WIN32 ERROR"},
168 { ERR_PORTNOTCONNECTED13, "PORT NOT CONNECTED"},
169 { ERR_INVALIDAMSLENGTH14, "INVALID AMS LENGTH"},
170 { ERR_INVALIDAMSNETID15, "INVALID AMS NETID"},
171 { ERR_LOWINSTLEVEL16, "LOW INST LEVEL"},
172 { ERR_NODEBUGINTAVAILABLE17, "NO DEBUG INT AVAILABLE"},
173 { ERR_PORTDISABLED18, "PORT DISABLED"},
174 { ERR_PORTALREADYCONNECTED19, "PORT ALREADY CONNECTED"},
175 { ERR_AMSSYNC_W32ERROR20, "AMSSYNC_W32ERROR"},
176 { ERR_AMSSYNC_TIMEOUT21, "AMSSYNC_TIMEOUT"},
177 { ERR_AMSSYNC_AMSERROR22, "AMSSYNC_AMSERROR"},
178 { ERR_AMSSYNC_NOINDEXINMAP23, "AMSSYNC_NOINDEXINMAP"},
179 { ERR_INVALIDAMSPORT24, "INVALID AMSPORT"},
180 { ERR_NOMEMORY25, "NO MEMORY"},
181 { ERR_TCPSEND26, "TCP SEND"},
182 { ERR_HOSTUNREACHABLE27, "HOST UNREACHABLE"},
183 { ROUTERERR_NOLOCKEDMEMORY0 + 0x0500, "ROUTERERR_NOLOCKEDMEMORY"},
184 { ROUTERERR_RESIZEMEMORY1 + 0x0500, "ROUTERERR_RESIZEMEMORY"},
185 { ROUTERERR_MAILBOXFULL2 + 0x0500, "ROUTERERR_MAILBOXFULL"},
186 { ROUTERERR_DEBUGBOXFULL3 + 0x0500, "ROUTERERR_DEBUGBOXFULL"},
187 { ROUTERERR_UNKNOWNPORTTYPE4 + 0x0500, "ROUTERERR_UNKNOWNPORTTYPE"},
188 { ROUTERERR_NOTINITIALIZED5 + 0x0500, "ROUTERERR_NOTINITIALIZED"},
189 { ROUTERERR_PORTALREADYINUSE6 + 0x0500, "ROUTERERR_PORTALREADYINUSE"},
190 { ROUTERERR_NOTREGISTERED7 + 0x0500, "ROUTERERR_NOTREGISTERED "},
191 { ROUTERERR_NOMOREQUEUES8 + 0x0500, "ROUTERERR_NOMOREQUEUES"},
192 { ROUTERERR_INVALIDPORT9 + 0x0500, "ROUTERERR_INVALIDPORT"},
193 { ROUTERERR_NOTACTIVATED10 + 0x0500, "ROUTERERR_NOTACTIVATED"},
194 { IOERR_INTERNAL(0 + 0x2000), "IOERR_INTERNAL"},
195 { IOERR_BADCARDNO(1 + 0x2000), "IOERR_BADCARDNO"},
196 { IOERR_INVALIDCARDADDR(2 + 0x2000), "IOERR_INVALIDCARDADDR"},
197 { IOERR_CDLLISTFULL(3 + 0x2000), "IOERR_CDLLISTFULL"},
198 { IOERR_BADCDLPARAM(4 + 0x2000), "IOERR_BADCDLPARAM"},
199 { IOERR_OPENIOFAILED(5 + 0x2000), "IOERR_OPENIOFAILED"},
200 { IOERR_RESETIOFAILED(6 + 0x2000), "IOERR_RESETIOFAILED"},
201 { IOERR_UNKNOWNDEVICE(7 + 0x2000), "IOERR_UNKNOWNDEVICE"},
202 { IOERR_UNKNOWNDEVICEID(8 + 0x2000), "IOERR_UNKNOWNDEVICEID"},
203 { IOERR_UNKNOWNIMAGEID(9 + 0x2000), "IOERR_UNKNOWNIMAGEID"},
204 { IOERR_GETIOSTATE(10 + 0x2000), "IOERR_GETIOSTATE"},
205 { IOERR_BADIMAGEID(11 + 0x2000), "IOERR_BADIMAGEID"},
206 { IOERR_NOMORECLIENTSPACE(12 + 0x2000), "IOERR_NOMORECLIENTSPACE"},
207 { IOERR_CLIENTINFONOTFOUND(13 + 0x2000), "IOERR_CLIENTINFONOTFOUND"},
208 { IOERR_CDLNOTINUSE(14 + 0x2000), "IOERR_CDLNOTINUSE"},
209 { IOERR_TIMEOUTWITHDEVICE(15 + 0x2000), "IOERR_TIMEOUTWITHDEVICE"},
210 { IOERR_C1220FUNC_1(16 + 0x2000), "IOERR_C1220FUNC_1"},
211 { IOERR_C1220FUNC_9(17 + 0x2000), "IOERR_C1220FUNC_9"},
212 { IOERR_C1220FUNC_C(18 + 0x2000), "IOERR_C1220FUNC_C"},
213 { IOERR_C1220FUNC_10(19 + 0x2000), "IOERR_C1220FUNC_10"},
214 { IOERR_C1220FUNC_1_MAXSEND(20 + 0x2000), "IOERR_C1220FUNC_1_MAXSEND"},
215 { IOERR_C1220FUNC_1_ADDRSET(21 + 0x2000), "IOERR_C1220FUNC_1_ADDRSET"},
216 { IOERR_C1220FUNC_1_BREAK(22 + 0x2000), "IOERR_C1220FUNC_1_BREAK"},
217 { IOERR_C1220FUNC_1_BREAK0(23 + 0x2000), "IOERR_C1220FUNC_1_BREAK0"},
218 { IOERR_C1220FUNC_1_BREAK1(24 + 0x2000), "IOERR_C1220FUNC_1_BREAK1"},
219 { IOERR_C1220FUNC_1_BREAK2(25 + 0x2000), "IOERR_C1220FUNC_1_BREAK2"},
220 { IOERR_C1220FUNC_1_BREAK3(26 + 0x2000), "IOERR_C1220FUNC_1_BREAK3"},
221 { IOERR_C1220FUNC_1_BREAK4(27 + 0x2000), "IOERR_C1220FUNC_1_BREAK4"},
222 { IOERR_C1220FUNC_1_BREAK5(28 + 0x2000), "IOERR_C1220FUNC_1_BREAK5"},
223 { IOERR_C1220FUNC_1_BREAK6(29 + 0x2000), "IOERR_C1220FUNC_1_BREAK6"},
224 { IOERR_C1220FUNC_1_BREAK7(30 + 0x2000), "IOERR_C1220FUNC_1_BREAK7"},
225 { IOERR_C1220FUNC_1_BREAK8(31 + 0x2000), "IOERR_C1220FUNC_1_BREAK8"},
226 { IOERR_C1220FUNC_1_BREAK9(32 + 0x2000), "IOERR_C1220FUNC_1_BREAK9"},
227 { IOERR_C1220FUNC_1_BREAK10(33 + 0x2000), "IOERR_C1220FUNC_1_BREAK10"},
228 { IOERR_C1220FUNC_1_BREAK11(34 + 0x2000), "IOERR_C1220FUNC_1_BREAK11"},
229 { IOERR_C1220FUNC_1_BREAK12(35 + 0x2000), "IOERR_C1220FUNC_1_BREAK12"},
230 { IOERR_C1220FUNC_1_BREAK13(36 + 0x2000), "IOERR_C1220FUNC_1_BREAK13"},
231 { IOERR_C1220FUNC_1_BREAK14(37 + 0x2000), "IOERR_C1220FUNC_1_BREAK14"},
232 { IOERR_C1220FUNC_1_BREAK15(38 + 0x2000), "IOERR_C1220FUNC_1_BREAK15"},
233 { IOERR_C1220FUNC_1_BREAK16(39 + 0x2000), "IOERR_C1220FUNC_1_BREAK16"},
234 { IOERR_SPC3DEVINITDP(40 + 0x2000), "IOERR_SPC3DEVINITDP"},
235 { IOERR_SPC3UPDATEOUTPUT(41 + 0x2000), "IOERR_SPC3UPDATEOUTPUT"},
236 { IOERR_CIF30READDIAG(42 + 0x2000), "IOERR_CIF30READDIAG"},
237 { IOERR_CIF30COMMNOTSTARTED(43 + 0x2000), "IOERR_CIF30COMMNOTSTARTED"},
238 { IOERR_CIF30SLAVEPARASIZE(44 + 0x2000), "IOERR_CIF30SLAVEPARASIZE"},
239 { IOERR_CIF30NOPARAS(45 + 0x2000), "IOERR_CIF30NOPARAS"},
240 { IOERR_CIF30SLAVEERROR(46 + 0x2000), "IOERR_CIF30SLAVEERROR"},
241 { IOERR_CIF30WATCHDOGEXPIRED(47 + 0x2000), "IOERR_CIF30WATCHDOGEXPIRED"},
242 { IOERR_UNKNOWNDEVICECMD(48 + 0x2000), "IOERR_UNKNOWNDEVICECMD"},
243 { IOERR_CIF40MESSAGEHANDLING(49 + 0x2000), "IOERR_CIF40MESSAGEHANDLING"},
244 { IOERR_CIF40PARAERROR(50 + 0x2000), "IOERR_CIF40PARAERROR"},
245 { IOERR_CIF40WATCHDOGEXPIRED(51 + 0x2000), "IOERR_CIF40WATCHDOGEXPIRED"},
246 { IOERR_CIF40FLAGERROR(52 + 0x2000), "IOERR_CIF40FLAGERROR"},
247 { IOERR_CIF40COMMNOTSTARTED(53 + 0x2000), "IOERR_CIF40COMMNOTSTARTED"},
248 { IOERR_CIF40READDIAG(54 + 0x2000), "IOERR_CIF40READDIAG"},
249 { IOERR_CIF40SLAVEERROR(55 + 0x2000), "IOERR_CIF40SLAVEERROR"},
250 { IOERR_CIF40GLOBALERROR(56 + 0x2000), "IOERR_CIF40GLOBALERROR"},
251 { IOERR_CIF40CONFIGLIST(57 + 0x2000), "IOERR_CIF40CONFIGLIST"},
252 { IOERR_CP5412A2SLAVEPARASIZE(58 + 0x2000), "IOERR_CP5412A2SLAVEPARASIZE"},
253 { IOERR_CP5412A2NOPARAS(59 + 0x2000), "IOERR_CP5412A2NOPARAS"},
254 { IOERR_CP5412A2SLAVEERROR(60 + 0x2000), "IOERR_CP5412A2SLAVEERROR"},
255 { IOERR_CP5412A2FATAL(61 + 0x2000), "IOERR_CP5412A2FATAL"},
256 { IOERR_CP5412A2MAILBOXUSED(62 + 0x2000), "IOERR_CP5412A2MAILBOXUSED"},
257 { IOERR_BEGINCONFIGWHILETICKER(63 + 0x2000), "IOERR_BEGINCONFIGWHILETICKER"},
258 { IOERR_UNEXPECTEDBOXCOUNT(64 + 0x2000), "IOERR_UNEXPECTEDBOXCOUNT"},
259 { IOERR_C1200CHECKADDR(65 + 0x2000), "IOERR_C1200CHECKADDR"},
260 { IOERR_C1200INTENSITYTEST(66 + 0x2000), "IOERR_C1200INTENSITYTEST"},
261 { IOERR_NOIMAGE(67 + 0x2000), "IOERR_NOIMAGE"},
262 { IOERR_INVALIDIMAGEOFFSSIZE(68 + 0x2000), "IOERR_INVALIDIMAGEOFFSSIZE"},
263 { IOERR_FORCESCOUNTEXCEEDEDMAXIMUM(69 + 0x2000), "IOERR_FORCESCOUNTEXCEEDEDMAXIMUM"},
264 { IOERR_SERCOSLIFECOUNTERERR(70 + 0x2000), "IOERR_SERCOSLIFECOUNTERERR"},
265 { IOERR_C1220NOTFOUND(71 + 0x2000), "IOERR_C1220NOTFOUND"},
266 { IOERR_AMSDEVICENOAMSINTF(72 + 0x2000), "IOERR_AMSDEVICENOAMSINTF"},
267 { IOERR_AMSDEVICEAMSCMDIDNOTSUPP(73 + 0x2000), "IOERR_AMSDEVICEAMSCMDIDNOTSUPP"},
268 { IOERR_AMSDEVICEAMSSERVICERUNNING(74 + 0x2000), "IOERR_AMSDEVICEAMSSERVICERUNNING"},
269 { IOERR_PLCINTERFACE_BUSY(75 + 0x2000), "IOERR_PLCINTERFACE_BUSY"},
270 { IOERR_PLCINTERFACE_FAULT(76 + 0x2000), "IOERR_PLCINTERFACE_FAULT"},
271 { IOERR_PLCINTERFACE_TIMEOUT(77 + 0x2000), "IOERR_PLCINTERFACE_TIMEOUT"},
272 { IOERR_PLCINTERFACE_RESETTIMEOUT(78 + 0x2000), "IOERR_PLCINTERFACE_RESETTIMEOUT"},
273 { IOERR_PLCINTERFACE_NODATAEXCH(79 + 0x2000), "IOERR_PLCINTERFACE_NODATAEXCH"},
274 { IOERR_PLCINTERFACE_RESET(80 + 0x2000), "IOERR_PLCINTERFACE_RESET"},
275 { IOERR_CP5412A2INVALIDADDR(81 + 0x2000), "IOERR_CP5412A2INVALIDADDR"},
276 { IOERR_CP5412A2INVALIDPORT(82 + 0x2000), "IOERR_CP5412A2INVALIDPORT"},
277 { IOERR_AMSDEVICEBADBOXNO(83 + 0x2000), "IOERR_AMSDEVICEBADBOXNO"},
278 { IOERR_AMSDEVICEBADTYPE(84 + 0x2000), "IOERR_AMSDEVICEBADTYPE"},
279 { IOERR_AMSDEVICEILLEGALADDRESS(85 + 0x2000), "IOERR_AMSDEVICEILLEGALADDRESS"},
280 { IOERR_CP5412A2INVALIDBOX(86 + 0x2000), "IOERR_CP5412A2INVALIDBOX"},
281 { IOERR_AMSDEVICEFIFOOVERFLOW(87 + 0x2000), "IOERR_AMSDEVICEFIFOOVERFLOW"},
282 { IOERR_AMSDEVICEAMSSEQUENCEERROR(88 + 0x2000), "IOERR_AMSDEVICEAMSSEQUENCEERROR"},
283 { IOERR_CP5412A2DPV1SYNTAXERROR(89 + 0x2000), "IOERR_CP5412A2DPV1SYNTAXERROR"},
284 { IOERR_CP5412A2DEVICENOTRUNNING(90 + 0x2000), "IOERR_CP5412A2DEVICENOTRUNNING"},
285 { IOERR_AMSDEVICENOTRUNNING(91 + 0x2000), "IOERR_AMSDEVICENOTRUNNING"},
286 { IOERR_AMSDEVICEBOXNOTDEFINED(92 + 0x2000), "IOERR_AMSDEVICEBOXNOTDEFINED"},
287 { IOERR_CP5412A2BADSERVICEPARA(93 + 0x2000), "IOERR_CP5412A2BADSERVICEPARA"},
288 { IOERR_CP5412A2FIFOOVERFLOW(94 + 0x2000), "IOERR_CP5412A2FIFOOVERFLOW"},
289 { IOERR_COMPORTOPENFAILED(95 + 0x2000), "IOERR_COMPORTOPENFAILED"},
290 { IOERR_CIF30BADMESSAGERESPONSE(96 + 0x2000), "IOERR_CIF30BADMESSAGERESPONSE"},
291 { IOERR_CIF30DELETEDATABASE(97 + 0x2000), "IOERR_CIF30DELETEDATABASE"},
292 { IOERR_CIF30STARTSEQFAILED(98 + 0x2000), "IOERR_CIF30STARTSEQFAILED"},
293 { IOERR_CIF30DOWNLOADFAILED(99 + 0x2000), "IOERR_CIF30DOWNLOADFAILED"},
294 { IOERR_CIF30ENDSEQFAILED(100 + 0x2000), "IOERR_CIF30ENDSEQFAILED"},
295 { IOERR_CIF30BUSLOADFAILED(101 + 0x2000), "IOERR_CIF30BUSLOADFAILED"},
296 { IOERR_PLCINTERFACE_RESETREQ(102 + 0x2000), "IOERR_PLCINTERFACE_RESETREQ"},
297 { IOERR_CP5412A2INVALIDCYCLETICKS(103 + 0x2000), "IOERR_CP5412A2INVALIDCYCLETICKS"},
298 { IOERR_CP5412A2DPBUSFAULT(104 + 0x2000), "IOERR_CP5412A2DPBUSFAULT"},
299 { IOERR_INVALIDTERMCONFIG(105 + 0x2000), "IOERR_INVALIDTERMCONFIG"},
300 { IOERR_SERCANSBREAK(106 + 0x2000), "IOERR_SERCANSBREAK"},
301 { IOERR_SERCANSPHASE0(107 + 0x2000), "IOERR_SERCANSPHASE0"},
302 { IOERR_SERCANSPHASE1(108 + 0x2000), "IOERR_SERCANSPHASE1"},
303 { IOERR_SERCANSPHASE2(109 + 0x2000), "IOERR_SERCANSPHASE2"},
304 { IOERR_SERCANSPHASE3(110 + 0x2000), "IOERR_SERCANSPHASE3"},
305 { IOERR_SERCANSPHASE4(111 + 0x2000), "IOERR_SERCANSPHASE4"},
306 { IOERR_SERCANSNCSERVICECHNFAILED(112 + 0x2000), "IOERR_SERCANSNCSERVICECHNFAILED"},
307 { IOERR_RESOURCECONFICT(113 + 0x2000), "IOERR_RESOURCECONFICT"},
308 { IOERR_C1220INITSTRINGCOMM(114 + 0x2000), "IOERR_C1220INITSTRINGCOMM"},
309 { IOERR_C1220REGSTRINGSLAVE(115 + 0x2000), "IOERR_C1220REGSTRINGSLAVE"},
310 { IOERR_C1220STRREGFAULT(116 + 0x2000), "IOERR_C1220STRREGFAULT"},
311 { IOERR_IOSTATEBUSY(117 + 0x2000), "IOERR_IOSTATEBUSY"},
312 { IOERR_IBSSCITWATCHDOGEXPIRED(118 + 0x2000), "IOERR_IBSSCITWATCHDOGEXPIRED"},
313 { IOERR_IBSSCITSYNCMAILBOXERROR(119 + 0x2000), "IOERR_IBSSCITSYNCMAILBOXERROR"},
314 { IOERR_IBSSCITCONFIRMDIAGERROR(120 + 0x2000), "IOERR_IBSSCITCONFIRMDIAGERROR"},
315 { IOERR_IBSSCITCREATECFGERROR(121 + 0x2000), "IOERR_IBSSCITCREATECFGERROR"},
316 { 0, NULL((void*)0) }
317};
318
319static const value_string AdsErrorMode[] =
320{
321 { ADSERR_NOERR0x00, "NO ERROR", },
322 { ADSERR_DEVICE_ERROR(0x700), "ERROR", },
323 { ADSERR_DEVICE_SRVNOTSUPP(0x701), "SRV NOT SUPP", },
324 { ADSERR_DEVICE_INVALIDGRP(0x702), "INVALID GRP", },
325 { ADSERR_DEVICE_INVALIDOFFSET(0x703), "INVALID OFFSET", },
326 { ADSERR_DEVICE_INVALIDACCESS(0x704), "INVALID ACCESS", },
327 { ADSERR_DEVICE_INVALIDSIZE(0x705), "INVALID SIZE", },
328 { ADSERR_DEVICE_INVALIDDATA(0x706), "INVALID DATA", },
329 { ADSERR_DEVICE_NOTREADY(0x707), "NOT READY", },
330 { ADSERR_DEVICE_BUSY(0x708), "BUSY", },
331 { ADSERR_DEVICE_INVALIDCONTEXT(0x709), "INVALID CONTEXT", },
332 { ADSERR_DEVICE_NOMEMORY(0x70A), "NO MEMORY", },
333 { ADSERR_DEVICE_INVALIDPARM(0x70B), "INVALID PARM", },
334 { ADSERR_DEVICE_NOTFOUND(0x70C), "NOT FOUND", },
335 { ADSERR_DEVICE_SYNTAX(0x70D), "SYNTAX", },
336 { ADSERR_DEVICE_INCOMPATIBLE(0x70E), "INCOMPATIBLE", },
337 { ADSERR_DEVICE_EXISTS(0x70F), "EXISTS", },
338 { ADSERR_DEVICE_SYMBOLNOTFOUND(0x710), "SYMBOL NOT FOUND", },
339 { ADSERR_DEVICE_SYMBOLVERSIONINVALID(0x711), "SYMBOL VERSION INVALID", },
340 { ADSERR_DEVICE_INVALIDSTATE(0x712), "INVALID STATE", },
341 { ADSERR_DEVICE_TRANSMODENOTSUPP(0x713), "TRANS MODE NOT SUPP", },
342 { ADSERR_DEVICE_NOTIFYHNDINVALID(0x714), "NOTIFY HND INVALID", },
343 { ADSERR_DEVICE_CLIENTUNKNOWN(0x715), "CLIENT UNKNOWN", },
344 { ADSERR_DEVICE_NOMOREHDLS(0x716), "NO MORE HDLS", },
345 { ADSERR_DEVICE_INVALIDWATCHSIZE(0x717), "INVALID WATCHSIZE", },
346 { ADSERR_DEVICE_NOTINIT(0x718), "NOT INIT", },
347 { ADSERR_DEVICE_TIMEOUT(0x719), "TIMEOUT", },
348 { ADSERR_DEVICE_NOINTERFACE(0x71A), "NO INTERFACE", },
349 { ADSERR_DEVICE_INVALIDINTERFACE(0x71B), "INVALID INTERFACE", },
350 { ADSERR_DEVICE_INVALIDCLSID(0x71C), "INVALID CLSID", },
351 { ADSERR_DEVICE_INVALIDOBJID(0x71D), "INVALID OBJID", },
352 { ADSERR_DEVICE_PENDING(0x71E), "PENDING", },
353 { ADSERR_DEVICE_ABORTED(0x71F), "ABORTED", },
354 { ADSERR_DEVICE_WARNING(0x720), "WARNING", },
355 { ADSERR_DEVICE_INVALIDARRAYIDX(0x721), "INVALID ARRAY IDX", },
356 { ADSERR_CLIENT_ERROR(0x740), "CLIENT ERROR", },
357 { ADSERR_CLIENT_INVALIDPARM(0x741), "CLIENT INVALID PARM", },
358 { ADSERR_CLIENT_LISTEMPTY(0x742), "CLIENT LIST EMPTY", },
359 { ADSERR_CLIENT_VARUSED(0x743), "CLIENT VAR USED", },
360 { ADSERR_CLIENT_DUPLINVOKEID(0x744), "CLIENT DUPL INVOKEID", },
361 { ADSERR_CLIENT_SYNCTIMEOUT(0x745), "CLIENT SYNC TIMEOUT", },
362 { ADSERR_CLIENT_W32ERROR(0x746), "CLIENT W32ERROR", },
363 { ADSERR_CLIENT_TIMEOUTINVALID(0x747), "CLIENT TIMEOUT INVALID", },
364 { ADSERR_CLIENT_PORTNOTOPEN(0x748), "CLIENT PORT NOT OPEN", },
365 { ADSERR_CLIENT_NOAMSADDR(0x749), "CLIENT NO AMS ADDR", },
366 { ADSERR_CLIENT_SYNCINTERNAL(0x750), "CLIENT SYNC INTERNAL", },
367 { ADSERR_CLIENT_ADDHASH(0x751), "CLIENT ADD HASH", },
368 { ADSERR_CLIENT_REMOVEHASH(0x752), "CLIENT REMOVE HASH", },
369 { ADSERR_CLIENT_NOMORESYM(0x753), "CLIENT NO MORE SYM", },
370 { ADSERR_CLIENT_SYNCRESINVALID(0x754), "CLIENT SYNC RES INVALID", },
371 { ADSERR_CLIENT_SYNCPORTLOCKED(0x755), "CLIENT SYNC PORT LOCKED", },
372 { 0, NULL((void*)0) }
373};
374
375
376/* AMS Command Id
377 * https://infosys.beckhoff.com/english.php?content=../content/1033/tcadsamsspec/html/tcadsamsspec_adscmd_readstate.htm&id=10652
378 */
379static const value_string AMS_CommandId_vals[] =
380{
381 { ADSSRVID_INVALID0x00, "Invalid", },
382 { ADSSRVID_READDEVICEINFO0x01, "ADS Read Device Info", },
383 { ADSSRVID_READ0x02, "ADS Read", },
384 { ADSSRVID_WRITE0x03, "ADS Write", },
385 { ADSSRVID_READSTATE0x04, "ADS Read State", },
386 { ADSSRVID_WRITECTRL0x05, "ADS Write Control", },
387 { ADSSRVID_ADDDEVICENOTE0x06, "ADS Add Device Notification", },
388 { ADSSRVID_DELDEVICENOTE0x07, "ADS Delete Device Notification", },
389 { ADSSRVID_DEVICENOTE0x08, "ADS Device Notification", },
390 { ADSSRVID_READWRITE0x09, "ADS Read Write", },
391 { 0, NULL((void*)0) }
392};
393
394
395static const char* NetIdFormater(wmem_allocator_t* scope, tvbuff_t *tvb, unsigned offset)
396{
397 return wmem_strdup_printf (scope, "%d.%d.%d.%d.%d.%d", tvb_get_uint8(tvb, offset),
398 tvb_get_uint8(tvb, offset+1),
399 tvb_get_uint8(tvb, offset+2),
400 tvb_get_uint8(tvb, offset+3),
401 tvb_get_uint8(tvb, offset+4),
402 tvb_get_uint8(tvb, offset+5)
403 );
404}
405
406
407
408/*ams*/
409static int dissect_ams_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int offset)
410{
411 proto_item *ti, *anItem;
412 proto_tree *ams_tree, *ams_adstree;
413 unsigned ams_length = tvb_reported_length(tvb);
414 uint16_t stateflags;
415 uint32_t cmdId, cbdata = 0;
416 uint32_t invokeId;
417 conversation_t *conversation;
418 ams_conv_info_t *ams_info;
419 ams_transaction_t *ams_trans = NULL((void*)0);
420 static int* const state_flags[] = {
421 &hf_ams_stateresponse,
422 &hf_ams_statenoreturn,
423 &hf_ams_stateadscmd,
424 &hf_ams_statesyscmd,
425 &hf_ams_statehighprio,
426 &hf_ams_statetimestampadded,
427 &hf_ams_stateudp,
428 &hf_ams_stateinitcmd,
429 &hf_ams_statebroadcast,
430 NULL((void*)0)
431 };
432
433 col_set_str(pinfo->cinfo, COL_PROTOCOL, "AMS");
434 col_clear(pinfo->cinfo, COL_INFO);
435
436 if( ams_length < AmsHead_Len(int)sizeof(AmsHead) )
437 return offset;
438
439 ti = proto_tree_add_item(tree, proto_ams, tvb, 0, -1, ENC_NA0x00000000);
440 ams_tree = proto_item_add_subtree(ti, ett_ams);
441
442 proto_tree_add_string(ams_tree, hf_ams_targetnetid, tvb, offset, AmsNetId_Len(int)sizeof(AmsNetId), NetIdFormater(pinfo->pool, tvb, offset));
443 offset += AmsNetId_Len(int)sizeof(AmsNetId);
444
445 proto_tree_add_item(ams_tree, hf_ams_targetport, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
446 offset += 2;
447
448 proto_tree_add_string(ams_tree, hf_ams_sendernetid, tvb, offset, AmsNetId_Len(int)sizeof(AmsNetId), NetIdFormater(pinfo->pool, tvb, offset));
449 offset += AmsNetId_Len(int)sizeof(AmsNetId);
450
451 proto_tree_add_item(ams_tree, hf_ams_senderport, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
452 offset += 2;
453
454 proto_tree_add_item_ret_uint(ams_tree, hf_ams_cmdid, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000, &cmdId);
455 offset += 2;
456
457 proto_tree_add_bitmask(ams_tree, tvb, offset, hf_ams_stateflags, ett_ams_stateflags, state_flags, ENC_LITTLE_ENDIAN0x80000000);
458 stateflags = tvb_get_letohs(tvb, offset);
459 offset += 2;
460
461 proto_tree_add_item_ret_uint(ams_tree, hf_ams_cbdata, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &cbdata);
462 offset += 4;
463
464 proto_tree_add_item(ams_tree, hf_ams_errorcode, tvb, offset, 4,ENC_LITTLE_ENDIAN0x80000000);
465 offset += 4;
466
467 proto_tree_add_item_ret_uint(ams_tree, hf_ams_invokeid, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &invokeId);
468 offset += 4;
469
470 /* Track request/response using conversation */
471 conversation = find_or_create_conversation(pinfo);
472 ams_info = (ams_conv_info_t *)conversation_get_proto_data(conversation, proto_ams);
473 if (!ams_info) {
474 /* No conversation data yet, create it */
475 ams_info = wmem_new(wmem_file_scope(), ams_conv_info_t)((ams_conv_info_t*)wmem_alloc((wmem_file_scope()), sizeof(ams_conv_info_t
)))
;
476 ams_info->transactions = wmem_map_new(wmem_file_scope(), g_direct_hash, g_direct_equal);
477 conversation_add_proto_data(conversation, proto_ams, ams_info);
478 }
479
480 if (!PINFO_FD_VISITED(pinfo)((pinfo)->fd->visited)) {
481 /* First pass - track the transaction */
482 if ((stateflags & AMSCMDSF_RESPONSE0x0001) == 0) {
483 /* This is a request */
484 ams_trans = wmem_new(wmem_file_scope(), ams_transaction_t)((ams_transaction_t*)wmem_alloc((wmem_file_scope()), sizeof(ams_transaction_t
)))
;
485 ams_trans->req_frame = pinfo->num;
486 ams_trans->rep_frame = 0;
487 ams_trans->req_time = pinfo->abs_ts;
488 wmem_map_insert(ams_info->transactions, GUINT_TO_POINTER(invokeId)((gpointer) (gulong) (invokeId)), ams_trans);
489 } else {
490 /* This is a response */
491 ams_trans = (ams_transaction_t *)wmem_map_lookup(ams_info->transactions, GUINT_TO_POINTER(invokeId)((gpointer) (gulong) (invokeId)));
492 if (ams_trans && ams_trans->rep_frame == 0) {
493 ams_trans->rep_frame = pinfo->num;
494 }
495 }
496 } else {
497 /* Subsequent pass - retrieve the transaction */
498 ams_trans = (ams_transaction_t *)wmem_map_lookup(ams_info->transactions, GUINT_TO_POINTER(invokeId)((gpointer) (gulong) (invokeId)));
499 }
500
501 if (!ams_trans) {
502 /* Create a "fake" transaction structure for this packet */
503 ams_trans = wmem_new(pinfo->pool, ams_transaction_t)((ams_transaction_t*)wmem_alloc((pinfo->pool), sizeof(ams_transaction_t
)))
;
504 ams_trans->req_frame = 0;
505 ams_trans->rep_frame = 0;
506 ams_trans->req_time = pinfo->abs_ts;
507 }
508
509 if ( (stateflags & AMSCMDSF_ADSCMD0x0004) != 0 )
510 {
511 /* ADS */
512 if ( (stateflags & AMSCMDSF_RESPONSE0x0001) == 0 )
513 {
514 col_append_fstr(pinfo->cinfo, COL_INFO, "%s Request", val_to_str_const(cmdId, AMS_CommandId_vals, "Unknown"));
515
516 /* Add request state tracking info to the tree */
517 if (ams_trans->rep_frame) {
518 proto_item *it;
519 it = proto_tree_add_uint(ams_tree, hf_ams_response_in, tvb, 0, 0, ams_trans->rep_frame);
520 proto_item_set_generated(it);
521 }
522
523 /* Request */
524 switch ( cmdId )
525 {
526 case ADSSRVID_READ0x02:
527 {
528 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreadrequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
529 if( ams_length-offset >= TAdsReadReq_Len(int)sizeof(TAdsReadReq) )
530 {
531 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreadrequest);
532 proto_tree_add_item(ams_adstree, hf_ams_adsindexgroup, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
533 offset += 4;
534
535 proto_tree_add_item(ams_adstree, hf_ams_adsindexoffset, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
536 offset += 4;
537
538 proto_tree_add_item(ams_adstree, hf_ams_adscblength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
539 }
540 }
541 break;
542 case ADSSRVID_WRITE0x03:
543 {
544 anItem = proto_tree_add_item(ams_tree, hf_ams_adswriterequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
545 if( ams_length-offset >= TAdsWriteReq_Len14 - 2 )
546 {
547 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adswriterequest);
548 proto_tree_add_item(ams_adstree, hf_ams_adsindexgroup, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
549 offset += 4;
550
551 proto_tree_add_item(ams_adstree, hf_ams_adsindexoffset, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
552 offset += 4;
553
554 proto_tree_add_item(ams_adstree, hf_ams_adscblength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
555 offset += 4;
556
557 proto_tree_add_item(ams_adstree, hf_ams_adsdata, tvb, offset, ams_length-offset, ENC_NA0x00000000);
558 }
559 }
560 break;
561 case ADSSRVID_READWRITE0x09:
562 {
563 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreadwriterequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
564 if( ams_length-offset >= TAdsReadWriteReq_Len18 - 2)
565 {
566 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreadwriterequest);
567 proto_tree_add_item(ams_adstree, hf_ams_adsindexgroup, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
568 offset += 4;
569
570 proto_tree_add_item(ams_adstree, hf_ams_adsindexoffset, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
571 offset += 4;
572
573 proto_tree_add_item(ams_adstree, hf_ams_adscbreadlength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
574 offset += 4;
575
576 proto_tree_add_item(ams_adstree, hf_ams_adscbwritelength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
577 offset += 4;
578
579 proto_tree_add_item(ams_adstree, hf_ams_adsdata, tvb, offset, ams_length-offset, ENC_NA0x00000000);
580 }
581 }
582 break;
583 case ADSSRVID_READSTATE0x04:
584 {
585 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreadstaterequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
586 if( ams_length-offset >= TAdsReadStateReq_Len(int)sizeof(TAdsReadStateReq) )
587 {
588 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreadstaterequest);
589 proto_tree_add_item(ams_adstree, hf_ams_adsinvokeid, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
590 }
591 }
592 break;
593 case ADSSRVID_WRITECTRL0x05:
594 {
595 anItem = proto_tree_add_item(ams_tree, hf_ams_adswritectrlrequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
596 if( ams_length-offset >= TAdsWriteControlReq_Len10 - 2 )
597 {
598 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adswritectrlrequest);
599 proto_tree_add_item(ams_adstree, hf_ams_adsstate, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
600 offset += 2;
601
602 proto_tree_add_item(ams_adstree, hf_ams_adsdevicestate, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
603 offset += 2;
604
605 proto_tree_add_item(ams_adstree, hf_ams_adscblength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
606 offset += 4;
607
608 proto_tree_add_item(ams_adstree, hf_ams_adsdata, tvb, offset, ams_length-offset, ENC_NA0x00000000);
609 }
610 }
611 break;
612 case ADSSRVID_READDEVICEINFO0x01:
613 {
614 if (cbdata !=0 )
615 {
616 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreaddinforequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
617 if( ams_length-offset >= TAdsReadDeviceInfoReq_Len(int)sizeof(TAdsReadDeviceInfoReq) )
618 {
619 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreaddinforequest);
620 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
621 }
622 }
623 }
624 break;
625 case ADSSRVID_ADDDEVICENOTE0x06:
626 {
627 anItem = proto_tree_add_item(ams_tree, hf_ams_adsadddnrequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
628 if( ams_length-offset >= TAdsAddDeviceNotificationReq_Len(int)sizeof(TAdsAddDeviceNotificationReq) )
629 {
630 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsadddnrequest);
631 proto_tree_add_item(ams_adstree, hf_ams_adsindexgroup, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
632 offset += 4;
633
634 proto_tree_add_item(ams_adstree, hf_ams_adsindexoffset, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
635 offset += 4;
636
637 proto_tree_add_item(ams_adstree, hf_ams_adscblength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
638 offset += 4;
639
640 proto_tree_add_item(ams_adstree, hf_ams_adstransmode, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
641 offset += 4;
642
643 proto_tree_add_item(ams_adstree, hf_ams_adsmaxdelay, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
644 offset += 4;
645
646 proto_tree_add_item(ams_adstree, hf_ams_adscycletime, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
647 offset += 4;
648 }
649 }
650 break;
651 case ADSSRVID_DELDEVICENOTE0x07:
652 {
653 anItem = proto_tree_add_item(ams_tree, hf_ams_adsdeldnrequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
654 if( ams_length-offset >= TAdsDelDeviceNotificationReq_Len(int)sizeof(TAdsDelDeviceNotificationReq) )
655 {
656 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsdeldnrequest);
657 proto_tree_add_item(ams_adstree, hf_ams_adsnotificationhandle, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
658 }
659 }
660 break;
661 case ADSSRVID_DEVICENOTE0x08:
662 {
663 uint32_t cbLength, nStamps;
664
665 anItem = proto_tree_add_item(ams_tree, hf_ams_adsdnrequest, tvb, offset, ams_length-offset, ENC_NA0x00000000);
666 if( ams_length-offset >= TAdsDeviceNotificationReq_Len(int)sizeof(TAdsDeviceNotificationReq) )
667 {
668 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsdnrequest);
669 proto_tree_add_item_ret_uint(ams_adstree, hf_ams_adscblength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &cbLength);
670 offset += 4;
671
672 proto_tree_add_item_ret_uint(ams_adstree, hf_ams_adsnoteblocksstamps, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000, &nStamps);
673 offset += 4;
Value stored to 'offset' is never read
674
675 /*ToDo: dissect noteblocks*/
676 }
677 }
678 break;
679 }
680 }
681 else
682 {
683 col_append_fstr(pinfo->cinfo, COL_INFO, "%s Response", val_to_str_const(cmdId, AMS_CommandId_vals, "Unknown"));
684
685 /* Add response state tracking info to the tree */
686 if (ams_trans->req_frame) {
687 proto_item *it;
688 nstime_t ns;
689
690 it = proto_tree_add_uint(ams_tree, hf_ams_response_to, tvb, 0, 0, ams_trans->req_frame);
691 proto_item_set_generated(it);
692
693 nstime_delta(&ns, &pinfo->abs_ts, &ams_trans->req_time);
694 it = proto_tree_add_time(ams_tree, hf_ams_response_time, tvb, 0, 0, &ns);
695 proto_item_set_generated(it);
696 }
697
698 /* Response */
699 switch ( cmdId )
700 {
701 case ADSSRVID_READ0x02:
702 {
703 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreadresponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
704 if( ams_length-offset >= TAdsReadRes_Len(int)sizeof(TAdsReadRes) - 2 )
705 {
706 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreadresponse);
707 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
708 offset += 4;
709
710 proto_tree_add_item(ams_adstree, hf_ams_adscblength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
711 offset += 4;
712
713 proto_tree_add_item(ams_adstree, hf_ams_adsdata, tvb, offset, ams_length-offset, ENC_NA0x00000000);
714 }
715 }
716 break;
717 case ADSSRVID_WRITE0x03:
718 {
719 anItem = proto_tree_add_item(ams_tree, hf_ams_adswriteresponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
720 if( ams_length-offset >= TAdsWriteRes_Len(int)sizeof(TAdsWriteRes) )
721 {
722 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adswriteresponse);
723 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
724 }
725 }
726 break;
727 case ADSSRVID_READWRITE0x09:
728 {
729 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreadwriteresponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
730 if( ams_length-offset >= TAdsReadWriteRes_Len(int)sizeof(TAdsReadWriteRes) - 2 )
731 {
732 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreadwriteresponse);
733 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
734 offset += 4;
735
736 proto_tree_add_item(ams_adstree, hf_ams_adscblength, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
737 offset += 4;
738
739 proto_tree_add_item(ams_adstree, hf_ams_adsdata, tvb, offset, ams_length-offset, ENC_NA0x00000000);
740 }
741 }
742 break;
743 case ADSSRVID_READSTATE0x04:
744 {
745 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreadstateresponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
746 if( ams_length-offset >= TAdsReadStateRes_Len(int)sizeof(TAdsReadStateRes) )
747 {
748 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreadstateresponse);
749 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
750 offset += 4;
751
752 proto_tree_add_item(ams_adstree, hf_ams_adsstate, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
753 offset += 2;
754
755 proto_tree_add_item(ams_adstree, hf_ams_adsdevicestate, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
756 }
757 }
758 break;
759 case ADSSRVID_WRITECTRL0x05:
760 {
761 anItem = proto_tree_add_item(ams_tree, hf_ams_adswritectrlresponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
762 if( ams_length-offset >= TAdsWriteControlRes_Len(int)sizeof(TAdsWriteControlRes) )
763 {
764 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adswritectrlresponse);
765 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
766 }
767 }
768 break;
769 case ADSSRVID_READDEVICEINFO0x01:
770 {
771 anItem = proto_tree_add_item(ams_tree, hf_ams_adsreaddinforesponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
772 if( ams_length-offset >= TAdsReadDeviceInfoRes_Len(int)sizeof(TAdsReadDeviceInfoRes) )
773 {
774 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsreaddinforesponse);
775 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
776 offset += 4;
777
778 proto_tree_add_item(ams_adstree, hf_ams_adsversionversion, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
779 offset += 1;
780 proto_tree_add_item(ams_adstree, hf_ams_adsversionrevision, tvb, offset, 1, ENC_LITTLE_ENDIAN0x80000000);
781 offset += 1;
782 proto_tree_add_item(ams_adstree, hf_ams_adsversionbuild, tvb, offset, 2, ENC_LITTLE_ENDIAN0x80000000);
783 offset += 2;
784
785 proto_tree_add_item(ams_adstree, hf_ams_adsdevicename, tvb, offset, ams_length-offset, ENC_ASCII0x00000000);
786 }
787 }
788 break;
789 case ADSSRVID_ADDDEVICENOTE0x06:
790 {
791 anItem = proto_tree_add_item(ams_tree, hf_ams_adsadddnresponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
792 if( ams_length-offset >= TAdsAddDeviceNotificationRes_Len(int)sizeof(TAdsAddDeviceNotificationRes) )
793 {
794 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsadddnresponse);
795 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
796 offset += 4;
797
798 proto_tree_add_item(ams_adstree, hf_ams_adsnotificationhandle, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
799 }
800 }
801 break;
802 case ADSSRVID_DELDEVICENOTE0x07:
803 {
804 anItem = proto_tree_add_item(ams_tree, hf_ams_adsdeldnresponse, tvb, offset, ams_length-offset, ENC_NA0x00000000);
805 if( ams_length-offset >= TAdsDelDeviceNotificationRes_Len(int)sizeof(TAdsDelDeviceNotificationRes) )
806 {
807 ams_adstree = proto_item_add_subtree(anItem, ett_ams_adsdeldnresponse);
808 proto_tree_add_item(ams_adstree, hf_ams_adsresult, tvb, offset, 4, ENC_LITTLE_ENDIAN0x80000000);
809 }
810 }
811 break;
812 }
813 }
814 }
815 else
816 {
817 if ( (stateflags & AMSCMDSF_RESPONSE0x0001) == 0 )
818 col_append_str(pinfo->cinfo, COL_INFO, "AMS Request");
819 else
820 col_append_str(pinfo->cinfo, COL_INFO, "AMS Response");
821 if (ams_length-offset > 0 )
822 proto_tree_add_item(ams_tree, hf_ams_data, tvb, offset, ams_length-offset, ENC_NA0x00000000);
823 }
824
825 return ams_length;
826}
827
828
829/*ams*/
830static int dissect_ams(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U___attribute__((unused)))
831{
832 return dissect_ams_pdu(tvb, pinfo, tree, 0);
833}
834
835static unsigned get_amstcp_length(packet_info* pinfo _U___attribute__((unused)), tvbuff_t* tvb, int offset, void* data _U___attribute__((unused)))
836{
837 // The 6-byte AMS/TCP header is 2 reserved bytes followed by 4 bytes
838 // indicating the length of the AMS header and data that follows.
839
840 return tvb_get_letohl(tvb, offset + 2) + TcpAdsParserHDR_Len6;
841}
842
843static int dissect_amstcp_reassembled(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U___attribute__((unused)))
844{
845 return dissect_ams_pdu(tvb, pinfo, tree, TcpAdsParserHDR_Len6);
846}
847
848static int dissect_amstcp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U___attribute__((unused)))
849{
850 tcp_dissect_pdus(tvb, pinfo, tree, true1, TcpAdsParserHDR_Len6, get_amstcp_length, dissect_amstcp_reassembled, NULL((void*)0));
851
852 return tvb_captured_length(tvb);
853}
854
855void proto_register_ams(void)
856{
857 static const true_false_string flags_set_truth =
858 {
859 "Set",
860 "Not set"
861 };
862
863 static hf_register_info hf[] =
864 {
865 { &hf_ams_sendernetid,
866 { "AMS Sender Net Id", "ams.sendernetid",
867 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
868 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
869 },
870 { &hf_ams_senderport,
871 { "AMS Sender port", "ams.senderport",
872 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
873 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
874 },
875 { &hf_ams_targetnetid,
876 { "AMS Target Net Id", "ams.targetnetid",
877 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
878 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
879 },
880 { &hf_ams_targetport,
881 { "AMS Target port", "ams.targetport",
882 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
883 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
884 },
885 { &hf_ams_cmdid,
886 { "CmdId", "ams.cmdid",
887 FT_UINT16, BASE_DEC, VALS(AMS_CommandId_vals)((0 ? (const struct _value_string*)0 : ((AMS_CommandId_vals))
))
, 0x0,
888 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
889 },
890 { &hf_ams_stateflags,
891 { "StateFlags", "ams.stateflags",
892 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
893 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
894 },
895 { &hf_ams_stateresponse,
896 { "RESPONSE", "ams.state_response",
897 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_RESPONSE0x0001,
898 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
899 },
900 { &hf_ams_statenoreturn,
901 { "NO RETURN", "ams.state_noreturn",
902 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_NORETURN0x0002,
903 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
904 },
905 { &hf_ams_stateadscmd,
906 { "ADS COMMAND", "ams.state_adscmd",
907 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_ADSCMD0x0004,
908 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
909 },
910 { &hf_ams_statesyscmd,
911 { "SYSTEM COMMAND", "ams.state_syscmd",
912 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_SYSCMD0x0008,
913 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
914 },
915 { &hf_ams_statehighprio,
916 { "HIGH PRIORITY COMMAND", "ams.state_highprio",
917 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_HIGHPRIO0x0010,
918 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
919 },
920 { &hf_ams_statetimestampadded,
921 { "TIMESTAMP ADDED", "ams.state_timestampadded",
922 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_TIMESTAMPADDED0x0020,
923 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
924 },
925 { &hf_ams_stateudp,
926 { "UDP COMMAND", "ams.state_udp",
927 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_UDP0x0040,
928 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
929 },
930 { &hf_ams_stateinitcmd,
931 { "INIT COMMAND", "ams.state_initcmd",
932 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_INITCMD0x0080,
933 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
934 },
935 { &hf_ams_statebroadcast,
936 { "BROADCAST", "ams.state_broadcast",
937 FT_BOOLEAN, 16, TFS(&flags_set_truth)((0 ? (const struct true_false_string*)0 : ((&flags_set_truth
))))
, AMSCMDSF_BROADCAST0x8000,
938 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
939 },
940 { &hf_ams_cbdata,
941 { "cbData", "ams.cbdata",
942 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
943 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
944 },
945 { &hf_ams_errorcode,
946 { "ErrorCode", "ams.errorcode",
947 FT_UINT32, BASE_HEX, VALS(ErrorCode)((0 ? (const struct _value_string*)0 : ((ErrorCode)))), 0x0,
948 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
949 },
950 { &hf_ams_invokeid,
951 { "InvokeId", "ams.invokeid",
952 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
953 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
954 },
955 { &hf_ams_response_in,
956 { "Response In", "ams.response_in",
957 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_RESPONSE)((gpointer) (glong) (FT_FRAMENUM_RESPONSE)), 0x0,
958 "The response to this AMS request is in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
959 },
960 { &hf_ams_response_to,
961 { "Request In", "ams.response_to",
962 FT_FRAMENUM, BASE_NONE, FRAMENUM_TYPE(FT_FRAMENUM_REQUEST)((gpointer) (glong) (FT_FRAMENUM_REQUEST)), 0x0,
963 "This is a response to the AMS request in this frame", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
964 },
965 { &hf_ams_response_time,
966 { "Response Time", "ams.response_time",
967 FT_RELATIVE_TIME, BASE_NONE, NULL((void*)0), 0x0,
968 "The time between the Request and the Response", HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
969 },
970 { &hf_ams_adsdata,
971 { "Data", "ams.ads_data",
972 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
973 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
974 },
975 { &hf_ams_data,
976 { "Data", "ams.data",
977 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
978 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
979 },
980 { &hf_ams_adsindexgroup,
981 { "IndexGroup", "ams.ads_indexgroup",
982 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
983 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
984 },
985 { &hf_ams_adsindexoffset,
986 { "IndexOffset", "ams.ads_indexoffset",
987 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
988 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
989 },
990 { &hf_ams_adscblength,
991 { "CbLength", "ams.ads_cblength",
992 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
993 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
994 },
995 { &hf_ams_adsreadrequest,
996 { "ADS Read Request", "ams.ads_read_req",
997 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
998 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
999 },
1000 { &hf_ams_adsreadresponse,
1001 { "ADS Read Response", "ams.ads_read_res",
1002 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1003 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1004 },
1005 { &hf_ams_adsinvokeid,
1006 { "InvokeId", "ams.ads_invokeid",
1007 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
1008 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1009 },
1010 { &hf_ams_adsresult,
1011 { "Result", "ams.adsresult",
1012 FT_UINT32, BASE_HEX, VALS(AdsErrorMode)((0 ? (const struct _value_string*)0 : ((AdsErrorMode)))), 0x0,
1013 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1014 },
1015 { &hf_ams_adswriterequest,
1016 { "ADS Write Request", "ams.ads_write_req",
1017 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1018 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1019 },
1020 { &hf_ams_adswriteresponse,
1021 { "ADS Write Response", "ams.ads_write_res",
1022 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1023 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1024 },
1025 { &hf_ams_adsreadwriterequest,
1026 { "ADS ReadWrite Request", "ams.ads_readwrite_req",
1027 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1028 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1029 },
1030 { &hf_ams_adsreadwriteresponse,
1031 { "ADS ReadWrite Response", "ams.ads_readwrite_res",
1032 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1033 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1034 },
1035 { &hf_ams_adscbreadlength,
1036 { "CBReadLength", "ams.ads_cbreadlength",
1037 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
1038 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1039 },
1040 { &hf_ams_adscbwritelength,
1041 { "CBWriteLength", "ams.ads_cbwritelength",
1042 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
1043 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1044 },
1045 { &hf_ams_adsstate,
1046 { "AdsState", "ams.ads_state",
1047 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
1048 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1049 },
1050 { &hf_ams_adsdevicestate,
1051 { "DeviceState", "ams.ads_devicestate",
1052 FT_UINT16, BASE_HEX, NULL((void*)0), 0x0,
1053 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1054 },
1055 { &hf_ams_adsnotificationhandle,
1056 { "NotificationHandle", "ams.ads_notificationhandle",
1057 FT_UINT32, BASE_HEX, NULL((void*)0), 0x0,
1058 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1059 },
1060 { &hf_ams_adsreadstaterequest,
1061 { "ADS Read State Request", "ams.ads_readstate_req",
1062 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1063 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1064 },
1065 { &hf_ams_adsreadstateresponse,
1066 { "ADS Read State Response", "ams.ads_readstate_res",
1067 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1068 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1069 },
1070 { &hf_ams_adswritectrlrequest,
1071 { "ADS Write Ctrl Request", "ams.ads_writectrl_req",
1072 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1073 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1074 },
1075 { &hf_ams_adswritectrlresponse,
1076 { "ADS Write Ctrl Response", "ams.ads_writectrl_res",
1077 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1078 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1079 },
1080 { &hf_ams_adsreaddinforequest,
1081 { "ADS Read Device Info Request", "ams.ads_readdinfo_req",
1082 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1083 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1084 },
1085 { &hf_ams_adsreaddinforesponse,
1086 { "ADS Read Device Info Response", "ams.ads_readdinfo_res",
1087 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1088 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1089 },
1090 { &hf_ams_adsadddnrequest,
1091 { "ADS Add Device Notification Request", "ams.ads_adddn_req",
1092 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1093 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1094 },
1095 { &hf_ams_adsadddnresponse,
1096 { "ADS Add Device Notification Response", "ams.ads_adddn_res",
1097 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1098 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1099 },
1100 { &hf_ams_adsdeldnrequest,
1101 { "ADS Delete Device Notification Request", "ams.ads_deldn_req",
1102 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1103 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1104 },
1105 { &hf_ams_adsdeldnresponse,
1106 { "ADS Delete Device Notification Response", "ams.ads_deldn_res",
1107 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1108 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1109 },
1110 { &hf_ams_adsdnrequest,
1111 { "ADS Device Notification Request", "ams.ads_dn_req",
1112 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1113 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1114 },
1115#if 0
1116 { &hf_ams_adsdnresponse,
1117 { "ADS Device Notification Response", "ams.ads_dn_res",
1118 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1119 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1120 },
1121 { &hf_ams_adsnoteattrib,
1122 { "InvokeId", "ams.ads_noteattrib",
1123 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1124 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1125 },
1126 { &hf_ams_adsnoteblocks,
1127 { "InvokeId", "ams.ads_noteblocks",
1128 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1129 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1130 },
1131 { &hf_ams_adsversion,
1132 { "ADS Version", "ams.ads_version",
1133 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
1134 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1135 },
1136#endif
1137 { &hf_ams_adsdevicename,
1138 { "Device Name","ams.ads_devicename",
1139 FT_STRING, BASE_NONE, NULL((void*)0), 0x0,
1140 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1141 },
1142 { &hf_ams_adsversionversion,
1143 { "ADS Major Version", "ams.ads_versionversion",
1144 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
1145 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1146 },
1147 { &hf_ams_adsversionrevision,
1148 { "ADS Minor Version", "ams.ads_versionrevision",
1149 FT_UINT8, BASE_DEC, NULL((void*)0), 0x0,
1150 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1151 },
1152 { &hf_ams_adsversionbuild,
1153 { "ADS Version Build", "ams.ads_versionbuild",
1154 FT_UINT16, BASE_DEC, NULL((void*)0), 0x0,
1155 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1156 },
1157 { &hf_ams_adsnoteblocksstamps,
1158 { "Count of Stamps", "ams.ads_noteblocksstamps",
1159 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
1160 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1161 },
1162#if 0
1163 { &hf_ams_adsnoteblocksstamp,
1164 { "Notification Stamp", "ams.ads_noteblocksstamp",
1165 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1166 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1167 },
1168 { &hf_ams_adstimestamp,
1169 { "Time Stamp", "ams.ads_timestamp",
1170 FT_UINT64, BASE_DEC, NULL((void*)0), 0x0,
1171 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1172 },
1173 { &hf_ams_adssamplecnt,
1174 { "Count of Stamps", "ams.ads_samplecnt",
1175 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
1176 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1177 },
1178 { &hf_ams_adsnoteblockssample,
1179 { "Notification Sample", "ams.ads_noteblockssample",
1180 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1181 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1182 },
1183#endif
1184 { &hf_ams_adstransmode,
1185 { "Trans Mode", "ams.ads_transmode",
1186 FT_UINT32, BASE_DEC, VALS(TransMode)((0 ? (const struct _value_string*)0 : ((TransMode)))), 0x0,
1187 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1188 },
1189 { &hf_ams_adsmaxdelay,
1190 { "Max Delay", "ams.ads_maxdelay",
1191 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
1192 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1193 },
1194 { &hf_ams_adscycletime,
1195 { "Cycle Time", "ams.ads_cycletime",
1196 FT_UINT32, BASE_DEC, NULL((void*)0), 0x0,
1197 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1198 },
1199#if 0
1200 { &hf_ams_adscmpmax,
1201 { "Cmp Mad", "ams.ads_cmpmax",
1202 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1203 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1204 },
1205 { &hf_ams_adscmpmin,
1206 { "Cmp Min", "ams.ads_cmpmin",
1207 FT_NONE, BASE_NONE, NULL((void*)0), 0x0,
1208 NULL((void*)0), HFILL-1, 0, HF_REF_TYPE_NONE, -1, ((void*)0) }
1209 }
1210#endif
1211 };
1212
1213 static int *ett[] =
1214 {
1215 &ett_ams,
1216 &ett_ams_stateflags,
1217 &ett_ams_adsreadrequest,
1218 &ett_ams_adsreadresponse,
1219 &ett_ams_adswriterequest,
1220 &ett_ams_adswriteresponse,
1221 &ett_ams_adsreadwriterequest,
1222 &ett_ams_adsreadwriteresponse,
1223 &ett_ams_adsreadstaterequest,
1224 &ett_ams_adsreadstateresponse,
1225 &ett_ams_adswritectrlrequest,
1226 &ett_ams_adswritectrlresponse,
1227 &ett_ams_adsreaddinforequest,
1228 &ett_ams_adsreaddinforesponse,
1229 &ett_ams_adsadddnrequest,
1230 &ett_ams_adsadddnresponse,
1231 &ett_ams_adsdeldnrequest,
1232 &ett_ams_adsdeldnresponse,
1233 &ett_ams_adsdnrequest
1234 };
1235
1236 proto_ams = proto_register_protocol("AMS", "AMS", "ams");
1237 proto_register_field_array(proto_ams, hf, array_length(hf)(sizeof (hf) / sizeof (hf)[0]));
1238 proto_register_subtree_array(ett, array_length(ett)(sizeof (ett) / sizeof (ett)[0]));
1239
1240 ams_handle = register_dissector("ams", dissect_ams, proto_ams);
1241 amstcp_handle = register_dissector("ams.tcp", dissect_amstcp, proto_ams );
1242}
1243
1244/* The registration hand-off routing */
1245
1246void proto_reg_handoff_ams(void)
1247{
1248 dissector_add_uint_range_with_preference("tcp.port", AMS_TCP_PORT_RANGE"48898", amstcp_handle);
1249 dissector_add_uint("ecatf.type", 2, ams_handle);
1250}
1251
1252/*
1253 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1254 *
1255 * Local Variables:
1256 * c-basic-offset: 3
1257 * tab-width: 8
1258 * indent-tabs-mode: nil
1259 * End:
1260 *
1261 * ex: set shiftwidth=3 tabstop=8 expandtab:
1262 * :indentSize=3:tabSize=8:noTabs=true:
1263 */