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