2 * Common functions for other PROFINET protocols like IO, CBA, DCP, ...
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1999 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include <epan/packet.h>
17 #include <epan/expert.h>
18 #include <epan/wmem_scopes.h>
19 #include <epan/dissectors/packet-dcerpc.h>
21 #include "packet-pn.h"
23 static int hf_pn_padding
;
24 static int hf_pn_undecoded_data
;
25 static int hf_pn_user_data
;
26 static int hf_pn_user_bytes
;
27 static int hf_pn_frag_bytes
;
28 static int hf_pn_malformed
;
30 static int hf_pn_io_status
;
32 static int hf_pn_io_error_code
;
33 static int hf_pn_io_error_decode
;
34 static int hf_pn_io_error_code1
;
35 static int hf_pn_io_error_code1_pniorw
;
36 static int hf_pn_io_error_code1_pnio
;
37 static int hf_pn_io_error_code2
;
38 static int hf_pn_io_error_code2_pniorw
;
39 static int hf_pn_io_error_code2_pnio_1
;
40 static int hf_pn_io_error_code2_pnio_2
;
41 static int hf_pn_io_error_code2_pnio_3
;
42 static int hf_pn_io_error_code2_pnio_4
;
43 static int hf_pn_io_error_code2_pnio_5
;
44 static int hf_pn_io_error_code2_pnio_6
;
45 static int hf_pn_io_error_code2_pnio_7
;
46 static int hf_pn_io_error_code2_pnio_8
;
47 static int hf_pn_io_error_code2_pnio_13
;
48 static int hf_pn_io_error_code2_pnio_20
;
49 static int hf_pn_io_error_code2_pnio_21
;
50 static int hf_pn_io_error_code2_pnio_22
;
51 static int hf_pn_io_error_code2_pnio_23
;
52 static int hf_pn_io_error_code2_pnio_40
;
53 static int hf_pn_io_error_code2_pnio_60
;
54 static int hf_pn_io_error_code2_pnio_61
;
55 static int hf_pn_io_error_code2_pnio_62
;
56 static int hf_pn_io_error_code2_pnio_63
;
57 static int hf_pn_io_error_code2_pnio_64
;
58 static int hf_pn_io_error_code2_pnio_65
;
59 static int hf_pn_io_error_code2_pnio_66
;
60 static int hf_pn_io_error_code2_pnio_70
;
61 static int hf_pn_io_error_code2_pnio_71
;
62 static int hf_pn_io_error_code2_pnio_72
;
63 static int hf_pn_io_error_code2_pnio_73
;
64 static int hf_pn_io_error_code2_pnio_74
;
65 static int hf_pn_io_error_code2_pnio_75
;
66 static int hf_pn_io_error_code2_pnio_76
;
67 static int hf_pn_io_error_code2_pnio_77
;
68 static int hf_pn_io_error_code2_pnio_253
;
69 static int hf_pn_io_error_code2_pnio_255
;
71 static int ett_pn_io_status
;
73 static expert_field ei_pn_undecoded_data
;
74 static expert_field ei_pn_io_error_code1
;
75 static expert_field ei_pn_io_error_code2
;
77 static const value_string pn_io_error_code
[] = {
80 { 0xCF, "RTA error" },
82 { 0xDB, "IODConnectRes" },
83 { 0xDC, "IODReleaseRes" },
84 { 0xDD, "IODControlRes" },
85 { 0xDE, "IODReadRes" },
86 { 0xDF, "IODWriteRes" },
90 static const value_string pn_io_error_decode
[] = {
97 /* dummy for unknown decode */
98 static const value_string pn_io_error_code1
[] = {
103 /* dummy for unknown decode/code1 combination */
104 static const value_string pn_io_error_code2
[] = {
109 static const value_string pn_io_error_code1_pniorw
[] = {
110 /* high nibble 0-9 not specified -> legacy codes */
111 { 0xa0, "application: read error" },
112 { 0xa1, "application: write error" },
113 { 0xa2, "application: module failure" },
114 { 0xa3, "application: not specified" },
115 { 0xa4, "application: not specified" },
116 { 0xa5, "application: not specified" },
117 { 0xa6, "application: not specified" },
118 { 0xa7, "application: busy" },
119 { 0xa8, "application: version conflict" },
120 { 0xa9, "application: feature not supported" },
121 { 0xaa, "application: User specific 1" },
122 { 0xab, "application: User specific 2" },
123 { 0xac, "application: User specific 3" },
124 { 0xad, "application: User specific 4" },
125 { 0xae, "application: User specific 5" },
126 { 0xaf, "application: User specific 6" },
127 { 0xb0, "access: invalid index" },
128 { 0xb1, "access: write length error" },
129 { 0xb2, "access: invalid slot/subslot" },
130 { 0xb3, "access: type conflict" },
131 { 0xb4, "access: invalid area" },
132 { 0xb5, "access: state conflict" },
133 { 0xb6, "access: access denied" },
134 { 0xb7, "access: invalid range" },
135 { 0xb8, "access: invalid parameter" },
136 { 0xb9, "access: invalid type" },
137 { 0xba, "access: backup" },
138 { 0xbb, "access: User specific 7" },
139 { 0xbc, "access: User specific 8" },
140 { 0xbd, "access: User specific 9" },
141 { 0xbe, "access: User specific 10" },
142 { 0xbf, "access: User specific 11" },
143 { 0xc0, "resource: read constrain conflict" },
144 { 0xc1, "resource: write constrain conflict" },
145 { 0xc2, "resource: resource busy" },
146 { 0xc3, "resource: resource unavailable" },
147 { 0xc4, "resource: not specified" },
148 { 0xc5, "resource: not specified" },
149 { 0xc6, "resource: not specified" },
150 { 0xc7, "resource: not specified" },
151 { 0xc8, "resource: User specific 12" },
152 { 0xc9, "resource: User specific 13" },
153 { 0xca, "resource: User specific 14" },
154 { 0xcb, "resource: User specific 15" },
155 { 0xcc, "resource: User specific 16" },
156 { 0xcd, "resource: User specific 17" },
157 { 0xce, "resource: User specific 18" },
158 { 0xcf, "resource: User specific 19" },
159 /* high nibble d-f user specific */
163 static const value_string pn_io_error_code2_pniorw
[] = {
164 /* all values are user specified */
168 static const value_string pn_io_error_code1_pnio
[] = {
169 { 0x00 /* 0*/, "Reserved" },
170 { 0x01 /* 1*/, "Connect: Faulty ARBlockReq" },
171 { 0x02 /* 2*/, "Connect: Faulty IOCRBlockReq" },
172 { 0x03 /* 3*/, "Connect: Faulty ExpectedSubmoduleBlockReq" },
173 { 0x04 /* 4*/, "Connect: Faulty AlarmCRBlockReq" },
174 { 0x05 /* 5*/, "Connect: Faulty PrmServerBlockReq" },
175 { 0x06 /* 6*/, "Connect: Faulty MCRBlockReq" },
176 { 0x07 /* 7*/, "Connect: Faulty ARRPCBlockReq" },
177 { 0x08 /* 8*/, "Read/Write Record: Faulty Record" },
178 { 0x09 /* 9*/, "Connect: Faulty IRInfoBlock" },
179 { 0x0A /* 10*/, "Connect: Faulty SRInfoBlock" },
180 { 0x0B /* 11*/, "Connect: Faulty ARFSUBlock" },
181 { 0x0C /* 12*/, "Connect: Faulty ARVendorBlockReq" },
182 { 0x0D /* 13*/, "Connect: Faulty RSInfoBlock" },
183 { 0x14 /* 20*/, "IODControl: Faulty ControlBlockConnect" },
184 { 0x15 /* 21*/, "IODControl: Faulty ControlBlockPlug" },
185 { 0x16 /* 22*/, "IOXControl: Faulty ControlBlock after a connect est." },
186 { 0x17 /* 23*/, "IOXControl: Faulty ControlBlock a plug alarm" },
187 { 0x18 /* 24*/, "IOXControl: Faulty ControlBlockPrmBegin" },
188 { 0x19 /* 25*/, "IOXControl: Faulty SubmoduleListBlock" },
190 { 0x28 /* 40*/, "Release: Faulty ReleaseBlock" },
192 { 0x32 /* 50*/, "Response: Faulty ARBlockRes" },
193 { 0x33 /* 51*/, "Response: Faulty IOCRBlockRes" },
194 { 0x34 /* 52*/, "Response: Faulty AlarmCRBlockRes" },
195 { 0x35 /* 53*/, "Response: Faulty ModuleDifflock" },
196 { 0x36 /* 54*/, "Response: Faulty ARRPCBlockRes" },
197 { 0x37 /* 55*/, "Response: Faulty ARServerBlockRes" },
198 { 0x38 /* 56*/, "Response: Faulty ARVendorBlockRes" },
200 { 0x3c /* 60*/, "AlarmAck Error Codes" },
201 { 0x3d /* 61*/, "CMDEV" },
202 { 0x3e /* 62*/, "CMCTL" },
203 { 0x3f /* 63*/, "CTLDINA" },
204 { 0x40 /* 64*/, "CMRPC" },
205 { 0x41 /* 65*/, "ALPMI" },
206 { 0x42 /* 66*/, "ALPMR" },
207 { 0x43 /* 67*/, "LMPM" },
208 { 0x44 /* 68*/, "MAC" },
209 { 0x45 /* 69*/, "RPC" },
210 { 0x46 /* 70*/, "APMR" },
211 { 0x47 /* 71*/, "APMS" },
212 { 0x48 /* 72*/, "CPM" },
213 { 0x49 /* 73*/, "PPM" },
214 { 0x4a /* 74*/, "DCPUCS" },
215 { 0x4b /* 75*/, "DCPUCR" },
216 { 0x4c /* 76*/, "DCPMCS" },
217 { 0x4d /* 77*/, "DCPMCR" },
218 { 0x4e /* 78*/, "FSPM" },
219 { 0x4f /* 79*/, "RSI" },
220 { 0x50 /* 80*/, "RSIR" },
222 { 0x64 /*100*/, "CTLSM" },
223 { 0x65 /*101*/, "CTLRDI" },
224 { 0x66 /*102*/, "CTLRDR" },
225 { 0x67 /*103*/, "CTLWRI" },
226 { 0x68 /*104*/, "CTLWRR" },
227 { 0x69 /*105*/, "CTLIO" },
228 { 0x6a /*106*/, "CTLSU" },
229 { 0x6b /*107*/, "CTLRPC" },
230 { 0x6c /*108*/, "CTLBE" },
231 { 0x6d /*109*/, "CTLSRL" },
232 { 0x6e /*110*/, "NME" },
233 { 0x6f /*111*/, "TDE" },
234 { 0x70 /*112*/, "PCE" },
235 { 0x71 /*113*/, "NCE" },
236 { 0x72 /*114*/, "NUE" },
237 { 0x73 /*115*/, "BNME" },
238 { 0x74 /*116*/, "CTLSAM" },
240 { 0xc8 /*200*/, "CMSM" },
241 { 0xca /*202*/, "CMRDR" },
242 { 0xcc /*204*/, "CMWRR" },
243 { 0xcd /*205*/, "CMIO" },
244 { 0xce /*206*/, "CMSU" },
245 { 0xd0 /*208*/, "CMINA" },
246 { 0xd1 /*209*/, "CMPBE" },
247 { 0xd2 /*210*/, "CMSRL" },
248 { 0xd3 /*211*/, "CMDMC" },
249 { 0xd4 /*212*/, "CMSAM" },
251 { 0xfd /*253*/, "RTA_ERR_CLS_PROTOCOL" },
252 { 0xff /*255*/, "User specific" },
256 static const value_string pn_io_error_code2_pnio_1
[] = {
257 /* CheckingRules for ARBlockReq */
258 { 0, "Error in Parameter BlockType" },
259 { 1, "Error in Parameter BlockLength" },
260 { 2, "Error in Parameter BlockVersionHigh" },
261 { 3, "Error in Parameter BlockVersionLow" },
262 { 4, "Error in Parameter ARType" },
263 { 5, "Error in Parameter ARUUID" },
264 { 7, "Error in Parameter CMInitiatorMACAddress" },
265 { 8, "Error in Parameter CMInitiatorObjectUUID" },
266 { 9, "Error in Parameter ARProperties" },
267 { 10, "Error in Parameter CMInitiatorActivityTimeoutFactor" },
268 { 11, "Error in Parameter InitiatorUDPRTPort" },
269 { 12, "Error in Parameter StationNameLength" },
270 { 13, "Error in Parameter CMInitiatorStationName" },
274 static const value_string pn_io_error_code2_pnio_2
[] = {
275 /* CheckingRules for IOCRBlockReq */
276 { 0, "Error in Parameter BlockType" },
277 { 1, "Error in Parameter BlockLength" },
278 { 2, "Error in Parameter BlockVersionHigh" },
279 { 3, "Error in Parameter BlockVersionLow" },
280 { 4, "Error in Parameter IOCRType" },
281 { 5, "Error in Parameter IOCRReference" },
282 { 6, "Error in Parameter LT" },
283 { 7, "Error in Parameter IOCRProperties" },
284 { 8, "Error in Parameter DataLength" },
285 { 9, "Error in Parameter FrameID" },
286 { 10, "Error in Parameter SendClockFactor" },
287 { 11, "Error in Parameter ReductionRatio" },
288 { 12, "Error in Parameter Phase" },
289 { 14, "Error in Parameter FrameSendOffset" },
290 { 15, "Error in Parameter WatchdogFactor" },
291 { 16, "Error in Parameter DataHoldFactor" },
292 { 17, "Error in Parameter IOCRTagHeader" },
293 { 18, "Error in Parameter IOCRMulticastMacAddress" },
294 { 19, "Error in Parameter NumberOfAPI" },
295 { 20, "Error in Parameter API" },
296 { 21, "Error in Parameter NumberOfIODataObjects" },
297 { 22, "Error in Parameter SlotNumber" },
298 { 23, "Error in Parameter SubslotNumber" },
299 { 24, "Error in Parameter IODataObjectFrameOffset" },
300 { 25, "Error in Parameter NumberOfIOCS" },
301 { 26, "Error in Parameter SlotNumber" },
302 { 27, "Error in Parameter SubslotNumber" },
303 { 28, "Error in Parameter IOCSFrameOffset" },
307 static const value_string pn_io_error_code2_pnio_3
[] = {
308 /* CheckingRules for ExpectedSubmoduleBlockReq */
309 { 0, "Error in Parameter BlockType" },
310 { 1, "Error in Parameter BlockLength" },
311 { 2, "Error in Parameter BlockVersionHigh" },
312 { 3, "Error in Parameter BlockVersionLow" },
313 { 4, "Error in Parameter NumberOfAPI" },
314 { 5, "Error in Parameter API" },
315 { 6, "Error in Parameter SlotNumber" },
316 { 7, "Error in Parameter ModuleIdentNumber" },
317 { 8, "Error in Parameter ModuleProperties" },
318 { 9, "Error in Parameter NumberOfSubmodules" },
319 { 10, "Error in Parameter SubslotNumber" },
320 { 12, "Error in Parameter SubmoduleProperties" },
321 { 13, "Error in Parameter DataDescription" },
322 { 14, "Error in Parameter SubmoduleDataLength" },
323 { 15, "Error in Parameter LengthIOPS" },
324 { 16, "Error in Parameter LengthIOCS" },
329 static const value_string pn_io_error_code2_pnio_4
[] = {
330 /* CheckingRules for AlarmCRBlockReq */
331 { 0, "Error in Parameter BlockType" },
332 { 1, "Error in Parameter BlockLength" },
333 { 2, "Error in Parameter BlockVersionHigh" },
334 { 3, "Error in Parameter BlockVersionLow" },
335 { 4, "Error in Parameter AlarmCRType" },
336 { 5, "Error in Parameter LT" },
337 { 6, "Error in Parameter AlarmCRProperties" },
338 { 7, "Error in Parameter RTATimeoutFactor" },
339 { 8, "Error in Parameter RTARetries" },
340 { 10, "Error in Parameter MaxAlarmDataLength" },
341 { 11, "Error in Parameter AlarmCRTagHeaderHigh" },
342 { 12, "Error in Parameter AlarmCRTagHeaderLow" },
346 static const value_string pn_io_error_code2_pnio_5
[] = {
347 /* CheckingRules for PrmServerBlockReq */
348 { 0, "Error in Parameter BlockType" },
349 { 1, "Error in Parameter BlockLength" },
350 { 2, "Error in Parameter BlockVersionHigh" },
351 { 3, "Error in Parameter BlockVersionLow" },
352 { 6, "Error in Parameter CMInitiatorActivityTimeoutFactor" },
353 { 7, "Error in Parameter StationNameLength" },
354 { 8, "Error in Parameter ParameterServerStationName" },
358 static const value_string pn_io_error_code2_pnio_6
[] = {
359 /* CheckingRules for MCRBlockReq */
360 { 0, "Error in Parameter BlockType" },
361 { 1, "Error in Parameter BlockLength" },
362 { 2, "Error in Parameter BlockVersionHigh" },
363 { 3, "Error in Parameter BlockVersionLow" },
364 { 4, "Error in Parameter IOCRReference" },
365 { 5, "Error in Parameter AddressResolutionProperties" },
366 { 6, "Error in Parameter MCITimeoutFactor" },
367 { 7, "Error in Parameter StationNameLength" },
368 { 8, "Error in Parameter ProviderStationName" },
372 static const value_string pn_io_error_code2_pnio_7
[] = {
373 /* CheckingRules for MCRBlockReq */
374 { 0, "Error in Parameter BlockType" },
375 { 1, "Error in Parameter BlockLength" },
376 { 2, "Error in Parameter BlockVersionHigh" },
377 { 3, "Error in Parameter BlockVersionLow" },
378 { 4, "Error in Parameter InitiatorRPCServerPort" },
382 static const value_string pn_io_error_code2_pnio_8
[] = {
383 /* CheckingRules for Read/Write ParameterReqHeader */
384 { 0, "Error in Parameter BlockType" },
385 { 1, "Error in Parameter BlockLength" },
386 { 2, "Error in Parameter BlockVersionHigh" },
387 { 3, "Error in Parameter BlockVersionLow" },
388 { 5, "Error in Parameter ARUUID" },
389 { 6, "Error in Parameter API" },
390 { 7, "Error in Parameter SlotNumber" },
391 { 8, "Error in Parameter SubslotNumber" },
392 { 9, "Error in Parameter Padding" },
393 { 10, "Error in Parameter Index" },
394 { 11, "Error in Parameter RecordDataLength" },
395 { 12, "Error in Parameter TargetARUUID" },
399 static const value_string pn_io_error_code2_pnio_13
[] = {
400 /* CheckingRules for RSInfoBlock */
401 { 0, "Error in Parameter BlockType" },
402 { 1, "Error in Parameter BlockLength" },
403 { 2, "Error in Parameter BlockVersionHigh" },
404 { 3, "Error in Parameter BlockVersionLow" },
405 { 4, "Error in Parameter Padding" },
406 { 5, "Error in Parameter RSProperties" },
410 static const value_string pn_io_error_code2_pnio_20
[] = {
411 /* CheckingRules for ControlBlockConnect */
412 { 0, "Error in Parameter BlockType" },
413 { 1, "Error in Parameter BlockLength" },
414 { 2, "Error in Parameter BlockVersionHigh" },
415 { 3, "Error in Parameter BlockVersionLow" },
416 { 4, "Error in Parameter Padding" },
417 { 6, "Error in Parameter SessionKey" },
418 { 7, "Error in Parameter Padding" },
419 { 8, "Error in Parameter ControlCommand" },
420 { 9, "Error in Parameter ControlBlockProperties" },
424 static const value_string pn_io_error_code2_pnio_21
[] = {
425 /* CheckingRules for ControlBlockPlug */
426 { 0, "Error in Parameter BlockType" },
427 { 1, "Error in Parameter BlockLength" },
428 { 2, "Error in Parameter BlockVersionHigh" },
429 { 3, "Error in Parameter BlockVersionLow" },
430 { 4, "Error in Parameter Padding" },
431 { 6, "Error in Parameter SessionKey" },
432 { 7, "Error in Parameter AlarmSequenceNumber" },
433 { 8, "Error in Parameter ControlCommand" },
434 { 9, "Error in Parameter ControlBlockProperties" },
438 static const value_string pn_io_error_code2_pnio_22
[] = {
439 /* CheckingRule for ControlBlockConnect */
440 { 0, "Error in Parameter BlockType" },
441 { 1, "Error in Parameter BlockLength" },
442 { 2, "Error in Parameter BlockVersionHigh" },
443 { 3, "Error in Parameter BlockVersionLow" },
444 { 4, "Error in Parameter Padding" },
445 { 6, "Error in Parameter SessionKey" },
446 { 7, "Error in Parameter Padding" },
447 { 8, "Error in Parameter ControlCommand" },
448 { 9, "Error in Parameter ControlBlockProperties" },
452 static const value_string pn_io_error_code2_pnio_23
[] = {
453 /* CheckingRules for ControlBlockPlug */
454 { 0, "Error in Parameter BlockType" },
455 { 1, "Error in Parameter BlockLength" },
456 { 2, "Error in Parameter BlockVersionHigh" },
457 { 3, "Error in Parameter BlockVersionLow" },
458 { 4, "Error in Parameter Padding" },
459 { 6, "Error in Parameter SessionKey" },
460 { 7, "Error in Parameter AlarmSequenceNumber" },
461 { 8, "Error in Parameter ControlCommand" },
462 { 9, "Error in Parameter ControlBlockProperties" },
466 static const value_string pn_io_error_code2_pnio_40
[] = {
467 /* CheckingRules for ReleaseBlock */
468 { 0, "Error in Parameter BlockType" },
469 { 1, "Error in Parameter BlockLength" },
470 { 2, "Error in Parameter BlockVersionHigh" },
471 { 3, "Error in Parameter BlockVersionLow" },
472 { 4, "Error in Parameter Padding" },
473 { 6, "Error in Parameter SessionKey" },
474 { 7, "Error in Parameter Padding" },
475 { 8, "Error in Parameter ControlCommand" },
476 { 9, "Error in Parameter ControlBlockProperties" },
480 static const value_string pn_io_error_code2_pnio_60
[] = {
481 /* AlarmAck Error Codes */
482 { 0, "Alarm Type Not Supported" },
483 { 1, "Wrong Submodule State" },
484 { 2, "IOCARSR Backup - Alarm not executed" },
488 static const value_string pn_io_error_code2_pnio_61
[] = {
490 { 0, "State Conflict" },
495 static const value_string pn_io_error_code2_pnio_62
[] = {
497 { 0, "State Conflict" },
499 { 2, "No data send" },
503 static const value_string pn_io_error_code2_pnio_63
[] = {
505 { 0, "No DCP active" },
506 { 1, "DNS Unknown_RealStationName" },
507 { 2, "DCP No_RealStationName" },
508 { 3, "DCP Multiple_RealStationName" },
509 { 4, "DCP No_StationName" },
511 { 6, "DCP_Set_Error" },
515 static const value_string pn_io_error_code2_pnio_64
[] = {
517 { 0, "ArgsLength invalid" },
518 { 1, "Unknown Blocks" },
519 { 2, "IOCR Missing" },
520 { 3, "Wrong AlarmCRBlock count" },
521 { 4, "Out of AR Resources" },
522 { 5, "AR UUID unknown" },
523 { 6, "State conflict" },
524 { 7, "Out of Provider, Consumer or Alarm Resources" },
525 { 8, "Out of Memory" },
526 { 9, "Pdev already owned" },
527 { 10, "ARset State conflict during connection establishment" },
528 { 11, "ARset Parameter conflict during connection establishment" },
529 { 12, "Pdev, port(s) without interface" },
533 static const value_string pn_io_error_code2_pnio_65
[] = {
535 { 0, "Invalid State" },
536 { 1, "Wrong ACK-PDU" },
540 static const value_string pn_io_error_code2_pnio_66
[] = {
542 { 0, "Invalid State" },
543 { 1, "Wrong Notification PDU" },
547 static const value_string pn_io_error_code2_pnio_70
[] = {
549 { 0, "Invalid State" },
550 { 1, "LMPM signaled error" },
554 static const value_string pn_io_error_code2_pnio_71
[] = {
556 { 0, "Invalid State" },
557 { 1, "LMPM signaled error" },
562 static const value_string pn_io_error_code2_pnio_72
[] = {
564 { 1, "Invalid State" },
568 static const value_string pn_io_error_code2_pnio_73
[] = {
570 { 1, "Invalid State" },
574 static const value_string pn_io_error_code2_pnio_74
[] = {
576 { 0, "Invalid State" },
577 { 1, "LMPM signaled an error" },
582 static const value_string pn_io_error_code2_pnio_75
[] = {
584 { 0, "Invalid State" },
585 { 1, "LMPM signaled an error" },
589 static const value_string pn_io_error_code2_pnio_76
[] = {
591 { 0, "Invalid State" },
592 { 1, "LMPM signaled an error" },
596 static const value_string pn_io_error_code2_pnio_77
[] = {
598 { 0, "Invalid State" },
599 { 1, "LMPM signaled an error" },
603 static const value_string pn_io_error_code2_pnio_253
[] = {
605 { 1, "Error within the coordination of sequence numbers (RTA_ERR_CODE_SEQ) error" },
606 { 2, "Instance closed (RTA_ERR_ABORT)" },
607 { 3, "AR out of memory (RTA_ERR_ABORT)" },
608 { 4, "AR add provider or consumer failed (RTA_ERR_ABORT)" },
609 { 5, "AR consumer DHT/WDT expired (RTA_ERR_ABORT)" },
610 { 6, "AR cmi timeout (RTA_ERR_ABORT)" },
611 { 7, "AR alarm-open failed (RTA_ERR_ABORT)" },
612 { 8, "AR alarm-send.cnf(-) (RTA_ERR_ABORT)" },
613 { 9, "AR alarm-ack-send.cnf(-) (RTA_ERR_ABORT)" },
614 { 10, "AR alarm data too long (RTA_ERR_ABORT)" },
615 { 11, "AR alarm.ind(err) (RTA_ERR_ABORT)" },
616 { 12, "AR rpc-client call.cnf(-) (RTA_ERR_ABORT)" },
617 { 13, "AR abort.req (RTA_ERR_ABORT)" },
618 { 14, "AR re-run aborts existing (RTA_ERR_ABORT)" },
619 { 15, "AR release.ind received (RTA_ERR_ABORT)" },
620 { 16, "AR device deactivated (RTA_ERR_ABORT)" },
621 { 17, "AR removed (RTA_ERR_ABORT)" },
622 { 18, "AR protocol violation (RTA_ERR_ABORT)" },
623 { 19, "AR name resolution error (RTA_ERR_ABORT)" },
624 { 20, "AR RPC-Bind error (RTA_ERR_ABORT)" },
625 { 21, "AR RPC-Connect error (RTA_ERR_ABORT)" },
626 { 22, "AR RPC-Read error (RTA_ERR_ABORT)" },
627 { 23, "AR RPC-Write error (RTA_ERR_ABORT)" },
628 { 24, "AR RPC-Control error (RTA_ERR_ABORT)" },
629 { 25, "AR forbidden pull or plug after check.rsp and before in-data.ind (RTA_ERR_ABORT)" },
630 { 26, "AR AP removed (RTA_ERR_ABORT)" },
631 { 27, "AR link down (RTA_ERR_ABORT)" },
632 { 28, "AR could not register multicast-mac address (RTA_ERR_ABORT)" },
633 { 29, "not synchronized (cannot start companion-ar) (RTA_ERR_ABORT)" },
634 { 30, "wrong topology (cannot start companion-ar) (RTA_ERR_ABORT)" },
635 { 31, "dcp, station-name changed (RTA_ERR_ABORT)" },
636 { 32, "dcp, reset to factory-settings (RTA_ERR_ABORT)" },
637 { 33, "cannot start companion-AR because a 0x8ipp submodule in the first AR... (RTA_ERR_ABORT)" },
638 { 34, "no irdata record yet (RTA_ERR_ABORT)" },
639 { 35, "PDEV (RTA_ERROR_ABORT)" },
640 { 36, "PDEV, no port offers required speed/duplexity (RTA_ERROR_ABORT)" },
641 { 37, "IP-Suite [of the IOC] changed by means of DCP_Set(IPParameter) or local engineering (RTA_ERROR_ABORT)" },
642 { 38, "IOCARSR, RDHT expired" },
643 { 39, "IOCARSR, Pdev, parameterization impossible" },
644 { 40, "Remote application ready timeout expired" },
645 { 41, "IOCARSR, Redundant interface list or access to the peripherals impossible" },
646 { 42, "IOCARSR, MTOT expired" },
647 { 43, "IOCARSR, AR protocol violation" },
648 { 44, "PDEV, plug port without CombinedObjectContainer" },
649 { 45, "NME, no or wrong configuration" },
653 static const value_string pn_io_error_code2_pnio_255
[] = {
655 { 255, "User abort" },
660 /* Initialize PNIO RTC1 stationInfo memory */
662 init_pnio_rtc1_station(stationInfo
*station_info
) {
663 station_info
->iocs_data_in
= wmem_list_new(wmem_file_scope());
664 station_info
->iocs_data_out
= wmem_list_new(wmem_file_scope());
665 station_info
->ioobject_data_in
= wmem_list_new(wmem_file_scope());
666 station_info
->ioobject_data_out
= wmem_list_new(wmem_file_scope());
667 station_info
->diff_module
= wmem_list_new(wmem_file_scope());
670 /* dissect an 8 bit unsigned integer */
672 dissect_pn_uint8(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
673 proto_tree
*tree
, int hfindex
, uint8_t *pdata
)
677 data
= tvb_get_uint8 (tvb
, offset
);
678 proto_tree_add_uint(tree
, hfindex
, tvb
, offset
, 1, data
);
684 /* dissect a 16 bit unsigned integer; return the item through a pointer as well */
686 dissect_pn_uint16_ret_item(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
687 proto_tree
*tree
, int hfindex
, uint16_t *pdata
, proto_item
** new_item
)
690 proto_item
*item
= NULL
;
692 data
= tvb_get_ntohs (tvb
, offset
);
694 item
= proto_tree_add_uint(tree
, hfindex
, tvb
, offset
, 2, data
);
702 /* dissect a 16 bit unsigned integer */
704 dissect_pn_uint16(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
705 proto_tree
*tree
, int hfindex
, uint16_t *pdata
)
709 data
= tvb_get_ntohs (tvb
, offset
);
711 proto_tree_add_uint(tree
, hfindex
, tvb
, offset
, 2, data
);
717 /* dissect a 16 bit signed integer */
719 dissect_pn_int16(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
720 proto_tree
*tree
, int hfindex
, int16_t *pdata
)
724 data
= tvb_get_ntohs (tvb
, offset
);
726 proto_tree_add_int(tree
, hfindex
, tvb
, offset
, 2, data
);
732 /* dissect a 24bit OUI (IEC organizational unique id) */
734 dissect_pn_oid(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
735 proto_tree
*tree
, int hfindex
, uint32_t *pdata
)
739 data
= tvb_get_ntoh24(tvb
, offset
);
741 proto_tree_add_uint(tree
, hfindex
, tvb
, offset
, 3, data
);
747 /* dissect a 6 byte MAC address */
749 dissect_pn_mac(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
750 proto_tree
*tree
, int hfindex
, uint8_t *pdata
)
754 tvb_memcpy(tvb
, data
, offset
, 6);
755 proto_tree_add_ether(tree
, hfindex
, tvb
, offset
, 6, data
);
758 memcpy(pdata
, data
, 6);
763 /* dissect an IPv4 address */
765 dissect_pn_ipv4(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
766 proto_tree
*tree
, int hfindex
, uint32_t *pdata
)
770 data
= tvb_get_ipv4(tvb
, offset
);
771 proto_tree_add_ipv4(tree
, hfindex
, tvb
, offset
, 4, data
);
779 /* dissect a 16 byte UUID address */
781 dissect_pn_uuid(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
782 proto_tree
*tree
, int hfindex
, e_guid_t
*uuid
)
784 uint8_t drep
[2] = { 0,0 };
786 offset
= dissect_dcerpc_uuid_t(tvb
, offset
, pinfo
, tree
, drep
,
792 /* "dissect" some bytes still undecoded (with Expert warning) */
794 dissect_pn_undecoded(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
795 proto_tree
*tree
, uint32_t length
)
800 item
= proto_tree_add_string_format(tree
, hf_pn_undecoded_data
, tvb
, offset
, length
, "data",
801 "Undecoded Data: %d bytes", length
);
803 expert_add_info_format(pinfo
, item
, &ei_pn_undecoded_data
,
804 "Undecoded Data, %u bytes", length
);
806 return offset
+ length
;
809 /* "dissect" some user bytes */
811 dissect_pn_user_data_bytes(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
812 proto_tree
*tree
, uint32_t length
, int iSelect
)
814 if(iSelect
== FRAG_DATA
)
815 proto_tree_add_item(tree
, hf_pn_frag_bytes
, tvb
, offset
, length
, ENC_NA
);
817 proto_tree_add_item(tree
, hf_pn_user_bytes
, tvb
, offset
, length
, ENC_NA
);
819 return offset
+ length
;
823 dissect_pn_user_data(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
824 proto_tree
*tree
, uint32_t length
, const char *text
)
827 proto_tree_add_string_format(tree
, hf_pn_user_data
, tvb
, offset
, length
, "data",
828 "%s: %d byte", text
, length
);
830 return offset
+ length
;
833 /* packet is malformed, mark it as such */
835 dissect_pn_malformed(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
836 proto_tree
*tree
, uint32_t length
)
838 proto_tree_add_item(tree
, hf_pn_malformed
, tvb
, 0, 10000, ENC_NA
);
840 return offset
+ length
;
844 /* dissect some padding data (with the given length) */
846 dissect_pn_padding(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
,
847 proto_tree
*tree
, int length
)
849 proto_tree_add_string_format(tree
, hf_pn_padding
, tvb
, offset
, length
, "data",
850 "Padding: %u byte", length
);
852 return offset
+ length
;
855 /* align offset to 4 */
857 dissect_pn_align4(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
, proto_tree
*tree
)
859 unsigned padding
= 0;
863 padding
= 4 - (offset
% 4);
865 proto_tree_add_string_format(tree
, hf_pn_padding
, tvb
, offset
, padding
, "data",
866 "Padding: %u byte", padding
);
869 return offset
+ padding
;
872 /* dissect the four status (error) fields */
874 dissect_PNIO_status(tvbuff_t
*tvb
, int offset
,
875 packet_info
*pinfo
, proto_tree
*tree
, uint8_t *drep
)
878 uint8_t u8ErrorDecode
;
879 uint8_t u8ErrorCode1
;
880 uint8_t u8ErrorCode2
;
882 proto_item
*sub_item
;
883 proto_tree
*sub_tree
;
884 uint32_t u32SubStart
;
885 int bytemask
= (drep
[0] & DREP_LITTLE_ENDIAN
) ? 3 : 0;
887 const value_string
*error_code1_vals
;
888 const value_string
*error_code2_vals
= pn_io_error_code2
; /* defaults */
893 sub_item
= proto_tree_add_item(tree
, hf_pn_io_status
, tvb
, offset
, 0, ENC_NA
);
894 sub_tree
= proto_item_add_subtree(sub_item
, ett_pn_io_status
);
895 u32SubStart
= offset
;
897 /* the PNIOStatus field is existing in both the RPC and the application data,
898 * depending on the current PDU.
899 * As the byte representation of these layers are different, this has to be handled
900 * in a somewhat different way than elsewhere. */
902 dissect_dcerpc_uint8(tvb
, offset
+ (0 ^ bytemask
), pinfo
, sub_tree
, drep
,
903 hf_pn_io_error_code
, &u8ErrorCode
);
904 dissect_dcerpc_uint8(tvb
, offset
+ (1 ^ bytemask
), pinfo
, sub_tree
, drep
,
905 hf_pn_io_error_decode
, &u8ErrorDecode
);
907 switch (u8ErrorDecode
) {
908 case(0x80): /* PNIORW */
909 dissect_dcerpc_uint8(tvb
, offset
+ (2 ^ bytemask
), pinfo
, sub_tree
, drep
,
910 hf_pn_io_error_code1_pniorw
, &u8ErrorCode1
);
911 error_code1_vals
= pn_io_error_code1_pniorw
;
913 /* u8ErrorCode2 for PNIORW is always user specific */
914 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
915 hf_pn_io_error_code2_pniorw
, &u8ErrorCode2
);
917 error_code2_vals
= pn_io_error_code2_pniorw
;
920 case(0x81): /* PNIO */
921 dissect_dcerpc_uint8(tvb
, offset
+ (2 ^ bytemask
), pinfo
, sub_tree
, drep
,
922 hf_pn_io_error_code1_pnio
, &u8ErrorCode1
);
923 error_code1_vals
= pn_io_error_code1_pnio
;
925 switch (u8ErrorCode1
) {
927 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
928 hf_pn_io_error_code2_pnio_1
, &u8ErrorCode2
);
929 error_code2_vals
= pn_io_error_code2_pnio_1
;
932 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
933 hf_pn_io_error_code2_pnio_2
, &u8ErrorCode2
);
934 error_code2_vals
= pn_io_error_code2_pnio_2
;
937 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
938 hf_pn_io_error_code2_pnio_3
, &u8ErrorCode2
);
939 error_code2_vals
= pn_io_error_code2_pnio_3
;
942 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
943 hf_pn_io_error_code2_pnio_4
, &u8ErrorCode2
);
944 error_code2_vals
= pn_io_error_code2_pnio_4
;
947 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
948 hf_pn_io_error_code2_pnio_5
, &u8ErrorCode2
);
949 error_code2_vals
= pn_io_error_code2_pnio_5
;
952 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
953 hf_pn_io_error_code2_pnio_6
, &u8ErrorCode2
);
954 error_code2_vals
= pn_io_error_code2_pnio_6
;
957 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
958 hf_pn_io_error_code2_pnio_7
, &u8ErrorCode2
);
959 error_code2_vals
= pn_io_error_code2_pnio_7
;
962 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
963 hf_pn_io_error_code2_pnio_8
, &u8ErrorCode2
);
964 error_code2_vals
= pn_io_error_code2_pnio_8
;
967 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
968 hf_pn_io_error_code2_pnio_13
, &u8ErrorCode2
);
969 error_code2_vals
= pn_io_error_code2_pnio_13
;
972 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
973 hf_pn_io_error_code2_pnio_20
, &u8ErrorCode2
);
974 error_code2_vals
= pn_io_error_code2_pnio_20
;
977 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
978 hf_pn_io_error_code2_pnio_21
, &u8ErrorCode2
);
979 error_code2_vals
= pn_io_error_code2_pnio_21
;
982 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
983 hf_pn_io_error_code2_pnio_22
, &u8ErrorCode2
);
984 error_code2_vals
= pn_io_error_code2_pnio_22
;
987 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
988 hf_pn_io_error_code2_pnio_23
, &u8ErrorCode2
);
989 error_code2_vals
= pn_io_error_code2_pnio_23
;
992 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
993 hf_pn_io_error_code2_pnio_40
, &u8ErrorCode2
);
994 error_code2_vals
= pn_io_error_code2_pnio_40
;
997 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
998 hf_pn_io_error_code2_pnio_60
, &u8ErrorCode2
);
999 error_code2_vals
= pn_io_error_code2_pnio_60
;
1002 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1003 hf_pn_io_error_code2_pnio_61
, &u8ErrorCode2
);
1004 error_code2_vals
= pn_io_error_code2_pnio_61
;
1007 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1008 hf_pn_io_error_code2_pnio_62
, &u8ErrorCode2
);
1009 error_code2_vals
= pn_io_error_code2_pnio_62
;
1012 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1013 hf_pn_io_error_code2_pnio_63
, &u8ErrorCode2
);
1014 error_code2_vals
= pn_io_error_code2_pnio_63
;
1017 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1018 hf_pn_io_error_code2_pnio_64
, &u8ErrorCode2
);
1019 error_code2_vals
= pn_io_error_code2_pnio_64
;
1022 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1023 hf_pn_io_error_code2_pnio_65
, &u8ErrorCode2
);
1024 error_code2_vals
= pn_io_error_code2_pnio_65
;
1027 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1028 hf_pn_io_error_code2_pnio_66
, &u8ErrorCode2
);
1029 error_code2_vals
= pn_io_error_code2_pnio_66
;
1032 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1033 hf_pn_io_error_code2_pnio_70
, &u8ErrorCode2
);
1034 error_code2_vals
= pn_io_error_code2_pnio_70
;
1037 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1038 hf_pn_io_error_code2_pnio_71
, &u8ErrorCode2
);
1039 error_code2_vals
= pn_io_error_code2_pnio_71
;
1042 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1043 hf_pn_io_error_code2_pnio_72
, &u8ErrorCode2
);
1044 error_code2_vals
= pn_io_error_code2_pnio_72
;
1047 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1048 hf_pn_io_error_code2_pnio_73
, &u8ErrorCode2
);
1049 error_code2_vals
= pn_io_error_code2_pnio_73
;
1052 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1053 hf_pn_io_error_code2_pnio_74
, &u8ErrorCode2
);
1054 error_code2_vals
= pn_io_error_code2_pnio_74
;
1057 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1058 hf_pn_io_error_code2_pnio_75
, &u8ErrorCode2
);
1059 error_code2_vals
= pn_io_error_code2_pnio_75
;
1062 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1063 hf_pn_io_error_code2_pnio_76
, &u8ErrorCode2
);
1064 error_code2_vals
= pn_io_error_code2_pnio_76
;
1067 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1068 hf_pn_io_error_code2_pnio_77
, &u8ErrorCode2
);
1069 error_code2_vals
= pn_io_error_code2_pnio_77
;
1072 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1073 hf_pn_io_error_code2_pnio_253
, &u8ErrorCode2
);
1074 error_code2_vals
= pn_io_error_code2_pnio_253
;
1077 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1078 hf_pn_io_error_code2_pnio_255
, &u8ErrorCode2
);
1079 error_code2_vals
= pn_io_error_code2_pnio_255
;
1082 /* don't know this u8ErrorCode1 for PNIO, use defaults */
1083 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1084 hf_pn_io_error_code2
, &u8ErrorCode2
);
1085 expert_add_info_format(pinfo
, sub_item
, &ei_pn_io_error_code1
, "Unknown ErrorCode1 0x%x (for ErrorDecode==PNIO)", u8ErrorCode1
);
1090 dissect_dcerpc_uint8(tvb
, offset
+ (2 ^ bytemask
), pinfo
, sub_tree
, drep
,
1091 hf_pn_io_error_code1
, &u8ErrorCode1
);
1092 if (u8ErrorDecode
!= 0) {
1093 expert_add_info_format(pinfo
, sub_item
, &ei_pn_io_error_code1
, "Unknown ErrorDecode 0x%x", u8ErrorDecode
);
1095 error_code1_vals
= pn_io_error_code1
;
1097 /* don't know this u8ErrorDecode, use defaults */
1098 dissect_dcerpc_uint8(tvb
, offset
+ (3 ^ bytemask
), pinfo
, sub_tree
, drep
,
1099 hf_pn_io_error_code2
, &u8ErrorCode2
);
1100 if (u8ErrorDecode
!= 0) {
1101 expert_add_info_format(pinfo
, sub_item
, &ei_pn_io_error_code2
, "Unknown ErrorDecode 0x%x", u8ErrorDecode
);
1107 if ((u8ErrorCode
== 0) && (u8ErrorDecode
== 0) && (u8ErrorCode1
== 0) && (u8ErrorCode2
== 0)) {
1108 proto_item_append_text(sub_item
, ": OK");
1109 col_append_str(pinfo
->cinfo
, COL_INFO
, ", OK");
1112 proto_item_append_text(sub_item
, ": Error: \"%s\", \"%s\", \"%s\", \"%s\"",
1113 val_to_str(u8ErrorCode
, pn_io_error_code
, "(0x%x)"),
1114 val_to_str(u8ErrorDecode
, pn_io_error_decode
, "(0x%x)"),
1115 val_to_str(u8ErrorCode1
, error_code1_vals
, "(0x%x)"),
1116 val_to_str(u8ErrorCode2
, error_code2_vals
, "(0x%x)"));
1117 col_append_fstr(pinfo
->cinfo
, COL_INFO
, ", Error: \"%s\", \"%s\", \"%s\", \"%s\"",
1118 val_to_str(u8ErrorCode
, pn_io_error_code
, "(0x%x)"),
1119 val_to_str(u8ErrorDecode
, pn_io_error_decode
, "(0x%x)"),
1120 val_to_str(u8ErrorCode1
, error_code1_vals
, "(0x%x)"),
1121 val_to_str(u8ErrorCode2
, error_code2_vals
, "(0x%x)"));
1123 proto_item_set_len(sub_item
, offset
- u32SubStart
);
1130 /* append the given info text to item and column */
1132 pn_append_info(packet_info
*pinfo
, proto_item
*dcp_item
, const char *text
)
1134 col_append_str(pinfo
->cinfo
, COL_INFO
, text
);
1136 proto_item_append_text(dcp_item
, "%s", text
);
1139 void pn_init_append_aruuid_frame_setup_list(e_guid_t aruuid
, uint32_t setup
) {
1141 ARUUIDFrame
* aruuid_frame
;
1143 aruuid_frame
= wmem_new0(wmem_file_scope(), ARUUIDFrame
);
1144 aruuid_frame
->aruuid
= aruuid
;
1145 aruuid_frame
->setupframe
= setup
;
1146 aruuid_frame
->releaseframe
= 0;
1147 aruuid_frame
->inputframe
= 0;
1148 aruuid_frame
->outputframe
= 0;
1150 wmem_list_append(aruuid_frame_setup_list
, aruuid_frame
);
1153 ARUUIDFrame
* pn_find_aruuid_frame_setup(packet_info
* pinfo
) {
1155 wmem_list_frame_t
* aruuid_frame
;
1156 ARUUIDFrame
* current_aruuid_frame
= NULL
;
1158 if (aruuid_frame_setup_list
!= NULL
) {
1159 for (aruuid_frame
= wmem_list_head(aruuid_frame_setup_list
); aruuid_frame
!= NULL
; aruuid_frame
= wmem_list_frame_next(aruuid_frame
)) {
1160 current_aruuid_frame
= (ARUUIDFrame
*)wmem_list_frame_data(aruuid_frame
);
1161 if (current_aruuid_frame
->setupframe
== pinfo
->num
) {
1167 return current_aruuid_frame
;
1170 void pn_find_dcp_station_info(stationInfo
* station_info
, conversation_t
* conversation
) {
1171 stationInfo
* dcp_station_info
= NULL
;
1172 /* search for DCP Station Info */
1173 dcp_station_info
= (stationInfo
*)conversation_get_proto_data(conversation
, proto_pn_dcp
);
1174 if (dcp_station_info
!= NULL
) {
1175 if (dcp_station_info
->typeofstation
!= NULL
) {
1176 if (station_info
->typeofstation
== NULL
|| strcmp(dcp_station_info
->typeofstation
, station_info
->typeofstation
) != 0) {
1177 station_info
->typeofstation
= wmem_strdup(wmem_file_scope(), dcp_station_info
->typeofstation
);
1180 if (dcp_station_info
->nameofstation
!= NULL
) {
1181 if (station_info
->nameofstation
== NULL
|| strcmp(dcp_station_info
->nameofstation
, station_info
->nameofstation
) != 0) {
1182 station_info
->nameofstation
= wmem_strdup(wmem_file_scope(), dcp_station_info
->nameofstation
);
1185 if (dcp_station_info
->u16Vendor_id
!= station_info
->u16Vendor_id
|| dcp_station_info
->u16Device_id
!= station_info
->u16Device_id
) {
1186 station_info
->u16Vendor_id
= dcp_station_info
->u16Vendor_id
;
1187 station_info
->u16Device_id
= dcp_station_info
->u16Device_id
;
1196 static hf_register_info hf
[] = {
1198 { "Padding", "pn.padding",
1199 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1202 { &hf_pn_undecoded_data
,
1203 { "Undecoded Data", "pn.undecoded",
1204 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1208 { "User Data", "pn.user_data",
1209 FT_STRING
, BASE_NONE
, NULL
, 0x0,
1212 { &hf_pn_user_bytes
,
1213 { "Substitute Data", "pn.user_bytes",
1214 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1217 { &hf_pn_frag_bytes
,
1218 { "Fragment Data", "pn.frag_bytes",
1219 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1223 { "Malformed", "pn_rt.malformed",
1224 FT_BYTES
, BASE_NONE
, NULL
, 0x0,
1228 { "Status", "pn_io.status",
1229 FT_NONE
, BASE_NONE
, NULL
, 0x0,
1232 { &hf_pn_io_error_code
,
1233 { "ErrorCode", "pn_io.error_code",
1234 FT_UINT8
, BASE_HEX
, VALS(pn_io_error_code
), 0x0,
1237 { &hf_pn_io_error_decode
,
1238 { "ErrorDecode", "pn_io.error_decode",
1239 FT_UINT8
, BASE_HEX
, VALS(pn_io_error_decode
), 0x0,
1242 { &hf_pn_io_error_code1
,
1243 { "ErrorCode1", "pn_io.error_code1",
1244 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code1
), 0x0,
1247 { &hf_pn_io_error_code2
,
1248 { "ErrorCode2", "pn_io.error_code2",
1249 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2
), 0x0,
1252 { &hf_pn_io_error_code1_pniorw
,
1253 { "ErrorCode1", "pn_io.error_code1",
1254 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code1_pniorw
), 0x0,
1257 { &hf_pn_io_error_code2_pniorw
,
1258 { "ErrorCode2 for PNIORW is user specified!", "pn_io.error_code2",
1259 FT_UINT8
, BASE_DEC
, NULL
, 0x0,
1262 { &hf_pn_io_error_code1_pnio
,
1263 { "ErrorCode1", "pn_io.error_code1",
1264 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code1_pnio
), 0x0,
1267 { &hf_pn_io_error_code2_pnio_1
,
1268 { "ErrorCode2", "pn_io.error_code2",
1269 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_1
), 0x0,
1272 { &hf_pn_io_error_code2_pnio_2
,
1273 { "ErrorCode2", "pn_io.error_code2",
1274 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_2
), 0x0,
1277 { &hf_pn_io_error_code2_pnio_3
,
1278 { "ErrorCode2", "pn_io.error_code2",
1279 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_3
), 0x0,
1282 { &hf_pn_io_error_code2_pnio_4
,
1283 { "ErrorCode2", "pn_io.error_code2",
1284 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_4
), 0x0,
1287 { &hf_pn_io_error_code2_pnio_5
,
1288 { "ErrorCode2", "pn_io.error_code2",
1289 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_5
), 0x0,
1292 { &hf_pn_io_error_code2_pnio_6
,
1293 { "ErrorCode2", "pn_io.error_code2",
1294 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_6
), 0x0,
1297 { &hf_pn_io_error_code2_pnio_7
,
1298 { "ErrorCode2", "pn_io.error_code2",
1299 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_7
), 0x0,
1302 { &hf_pn_io_error_code2_pnio_8
,
1303 { "ErrorCode2", "pn_io.error_code2",
1304 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_8
), 0x0,
1307 { &hf_pn_io_error_code2_pnio_13
,
1308 { "ErrorCode2", "pn_io.error_code2",
1309 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_13
), 0x0,
1312 { &hf_pn_io_error_code2_pnio_20
,
1313 { "ErrorCode2", "pn_io.error_code2",
1314 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_20
), 0x0,
1317 { &hf_pn_io_error_code2_pnio_21
,
1318 { "ErrorCode2", "pn_io.error_code2",
1319 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_21
), 0x0,
1322 { &hf_pn_io_error_code2_pnio_22
,
1323 { "ErrorCode2", "pn_io.error_code2",
1324 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_22
), 0x0,
1327 { &hf_pn_io_error_code2_pnio_23
,
1328 { "ErrorCode2", "pn_io.error_code2",
1329 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_23
), 0x0,
1332 { &hf_pn_io_error_code2_pnio_40
,
1333 { "ErrorCode2", "pn_io.error_code2",
1334 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_40
), 0x0,
1337 { &hf_pn_io_error_code2_pnio_60
,
1338 { "ErrorCode2", "pn_io.error_code2",
1339 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_60
), 0x0,
1342 { &hf_pn_io_error_code2_pnio_61
,
1343 { "ErrorCode2", "pn_io.error_code2",
1344 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_61
), 0x0,
1347 { &hf_pn_io_error_code2_pnio_62
,
1348 { "ErrorCode2", "pn_io.error_code2",
1349 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_62
), 0x0,
1352 { &hf_pn_io_error_code2_pnio_63
,
1353 { "ErrorCode2", "pn_io.error_code2",
1354 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_63
), 0x0,
1357 { &hf_pn_io_error_code2_pnio_64
,
1358 { "ErrorCode2", "pn_io.error_code2",
1359 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_64
), 0x0,
1362 { &hf_pn_io_error_code2_pnio_65
,
1363 { "ErrorCode2", "pn_io.error_code2",
1364 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_65
), 0x0,
1367 { &hf_pn_io_error_code2_pnio_66
,
1368 { "ErrorCode2", "pn_io.error_code2",
1369 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_66
), 0x0,
1372 { &hf_pn_io_error_code2_pnio_70
,
1373 { "ErrorCode2", "pn_io.error_code2",
1374 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_70
), 0x0,
1377 { &hf_pn_io_error_code2_pnio_71
,
1378 { "ErrorCode2", "pn_io.error_code2",
1379 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_71
), 0x0,
1382 { &hf_pn_io_error_code2_pnio_72
,
1383 { "ErrorCode2", "pn_io.error_code2",
1384 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_72
), 0x0,
1387 { &hf_pn_io_error_code2_pnio_73
,
1388 { "ErrorCode2", "pn_io.error_code2",
1389 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_73
), 0x0,
1392 { &hf_pn_io_error_code2_pnio_74
,
1393 { "ErrorCode2", "pn_io.error_code2",
1394 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_74
), 0x0,
1397 { &hf_pn_io_error_code2_pnio_75
,
1398 { "ErrorCode2", "pn_io.error_code2",
1399 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_75
), 0x0,
1402 { &hf_pn_io_error_code2_pnio_76
,
1403 { "ErrorCode2", "pn_io.error_code2",
1404 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_76
), 0x0,
1407 { &hf_pn_io_error_code2_pnio_77
,
1408 { "ErrorCode2", "pn_io.error_code2",
1409 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_77
), 0x0,
1412 { &hf_pn_io_error_code2_pnio_253
,
1413 { "ErrorCode2", "pn_io.error_code2",
1414 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_253
), 0x0,
1417 { &hf_pn_io_error_code2_pnio_255
,
1418 { "ErrorCode2", "pn_io.error_code2",
1419 FT_UINT8
, BASE_DEC
, VALS(pn_io_error_code2_pnio_255
), 0x0,
1425 static int *ett
[] = {
1429 static ei_register_info ei
[] = {
1430 { &ei_pn_undecoded_data
, { "pn.undecoded_data", PI_UNDECODED
, PI_WARN
, "Undecoded Data", EXPFILL
}},
1431 { &ei_pn_io_error_code1
, { "pn_io.error_code1.expert", PI_UNDECODED
, PI_WARN
, "Unknown ErrorCode1", EXPFILL
}},
1432 { &ei_pn_io_error_code2
, { "pn_io.error_code2.expert", PI_UNDECODED
, PI_WARN
, "Unknown ErrorDecode", EXPFILL
} },
1436 expert_module_t
* expert_pn
;
1439 proto_register_field_array (proto
, hf
, array_length (hf
));
1440 proto_register_subtree_array (ett
, array_length (ett
));
1441 expert_pn
= expert_register_protocol(proto
);
1442 expert_register_field_array(expert_pn
, ei
, array_length(ei
));
1445 /* Read a string from an "xml" file, dropping xml comment blocks */
1446 char *pn_fgets(char *str
, int n
, FILE *stream
, wmem_allocator_t
*scope
)
1448 const char XML_COMMENT_START
[] = "<!--";
1449 const char XML_COMMENT_END
[] = "-->";
1451 char *retVal
= fgets(str
, n
, stream
);
1452 if (retVal
== NULL
) {
1453 /* No input, we're done */
1457 /* Search for the XML begin comment marker */
1458 char *comment_start
= strstr(str
, XML_COMMENT_START
);
1459 char *common_start_end
= comment_start
+ sizeof(XML_COMMENT_START
) - 1;
1460 if(comment_start
== NULL
) {
1461 /* No comment start, we're done */
1465 /* Terminate the input buffer at the comment start */
1466 *comment_start
= '\0';
1467 size_t used_space
= comment_start
- str
;
1468 size_t remaining_space
= n
- used_space
;
1470 /* Read more data looking for the comment end */
1471 char *comment_end
= strstr(common_start_end
, XML_COMMENT_END
);
1472 if (comment_end
== NULL
) {
1473 // Not found in this line, read more lines until we do find it */
1474 char *temp
= (char*)wmem_alloc(scope
, MAX_LINE_LENGTH
);
1475 char *next_line
= temp
;
1476 while((comment_end
== NULL
) && (next_line
!= NULL
)) {
1477 next_line
= fgets(temp
, MAX_LINE_LENGTH
, stream
);
1478 if (next_line
== NULL
) {
1479 /* No more data, exit now */
1482 comment_end
= strstr(next_line
, XML_COMMENT_END
);
1486 if (comment_end
== NULL
) {
1487 /* We didn't find the comment end, return what we have */
1491 /* We did find a comment end, skip past the comment */
1492 char *comment_end_end
= comment_end
+ sizeof(XML_COMMENT_END
) - 1;
1494 /* Check we have space left in the buffer to move the trailing bytes after the comment end */
1495 size_t remaining_bytes
= strlen(comment_end_end
) + 1;
1496 if (remaining_bytes
< remaining_space
) {
1497 (void) g_strlcat(str
, comment_end_end
, n
);
1500 /* Seek the file back to the comment end so the next read picks it up */
1501 fseek(stream
, -(long)(remaining_bytes
), SEEK_CUR
);
1508 * Editor modelines - https://www.wireshark.org/tools/modelines.html
1513 * indent-tabs-mode: nil
1516 * vi: set shiftwidth=4 tabstop=8 expandtab:
1517 * :indentSize=4:tabSize=8:noTabs=true: