-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
packet-cip.c
10368 lines (9143 loc) · 454 KB
/
packet-cip.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* packet-cip.c
* Routines for Common Industrial Protocol (CIP) dissection
* CIP Home: www.odva.org
*
* This dissector includes items from:
* CIP Volume 1: Common Industrial Protocol, Edition 3.34
* CIP Volume 5: CIP Safety, Edition 2.25
* CIP Volume 7A: Integration of Modbus Devices into the CIP Architecture, Edition 1.9
* CIP Volume 8: CIP Security, Edition 1.11
*
* Copyright 2004
* Magnus Hansson <mah@hms.se>
* Joakim Wiberg <jow@hms.se>
*
* Added support for Connection Configuration Object
* ryan wamsley * Copyright 2007
*
* Object dependend services based on IOI
* Jan Bartels, Siempelkamp Maschinen- und Anlagenbau GmbH & Co. KG
* Copyright 2007
*
* Improved support for CoCo, CM, MB objects
* Heuristic object support for common services
* Michael Mann * Copyright 2011
*
* Added support for PCCC Objects
* Jared Rittle - Cisco Talos
* Copyright 2017
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
// There are multiple different ways to add functionality based on CIP class-specific behavior:
// 1. Dissector Table "cip.io.iface" - Use this when Class 0/1 I/O needs different parsing based on
// the CIP Class in the Forward Open
// 2. Dissector Table "cip.connection.class" - Use this when Class 2/3 data needs different parsing
// based on the CIP Class in the Forward Open
// 3. Dissector Table "cip.class.iface" - Use this when a CIP Class has significantly different
// behavior that would be best handled through a separate dissector
// 4. Dissector Table "cip.data_segment.iface" - Unknown. This may be removed in the future
// 5. attribute_info_t: Use this to add handling for an attribute, using a 3 tuple key (Class, Instance, Attribute)
// See 'cip_attribute_vals' for an example.
// 6. cip_service_info_t: Use this to add handling for a service, using a 2 tuple key (Class, Service)
// See 'cip_obj_spec_service_table' for an example.
#include "config.h"
#include <epan/packet.h>
#include <epan/expert.h>
#include <epan/prefs.h>
#include <epan/proto_data.h>
#include <epan/wmem_scopes.h>
#include "packet-cip.h"
#include "packet-cipmotion.h"
#include "packet-cipsafety.h"
#include "packet-mbtcp.h"
void proto_register_cip(void);
void proto_reg_handoff_cip(void);
typedef struct mr_mult_req_info {
guint8 service;
int num_services;
cip_req_info_t *requests;
} mr_mult_req_info_t;
static dissector_handle_t cip_handle;
static dissector_handle_t cip_class_generic_handle;
static dissector_handle_t cip_class_cm_handle;
static dissector_handle_t cip_class_pccc_handle;
static dissector_handle_t cip_class_mb_handle;
static dissector_handle_t modbus_handle;
static dissector_handle_t cip_class_cco_handle;
static heur_dissector_list_t heur_subdissector_service;
static bool cip_enhanced_info_column = true;
/* Initialize the protocol and registered fields */
static int proto_cip;
static int proto_cip_class_generic;
static int proto_cip_class_cm;
static int proto_cip_class_pccc;
static int proto_cip_class_mb;
static int proto_cip_class_cco;
static int proto_enip;
static int proto_modbus;
int hf_attr_class_revision;
int hf_attr_class_max_instance;
int hf_attr_class_num_instance;
int hf_attr_class_opt_attr_num;
int hf_attr_class_attr_num;
int hf_attr_class_opt_service_num;
int hf_attr_class_service_code;
int hf_attr_class_num_class_attr;
int hf_attr_class_num_inst_attr;
static int hf_cip_data;
static int hf_cip_service;
static int hf_cip_service_code;
static int hf_cip_reqrsp;
static int hf_cip_epath;
static int hf_cip_genstat;
static int hf_cip_addstat_size;
static int hf_cip_add_stat;
static int hf_cip_request_path_size;
static int hf_cip_cm_sc;
static int hf_cip_cm_genstat;
static int hf_cip_cm_addstat_size;
static int hf_cip_cm_add_status;
static int hf_cip_cm_ext_status;
static int hf_cip_cm_priority;
static int hf_cip_cm_tick_time;
static int hf_cip_cm_timeout_tick;
static int hf_cip_cm_timeout;
static int hf_cip_cm_ot_connid;
static int hf_cip_cm_to_connid;
static int hf_cip_connid;
static int hf_cip_cm_conn_serial_num;
static int hf_cip_cm_orig_serial_num;
static int hf_cip_cm_vendor;
static int hf_cip_cm_timeout_multiplier;
static int hf_cip_cm_ot_rpi;
static int hf_cip_cm_ot_timeout;
static int hf_cip_cm_ot_net_params32;
static int hf_cip_cm_ot_net_params16;
static int hf_cip_cm_to_rpi;
static int hf_cip_cm_to_timeout;
static int hf_cip_safety_nte_ms;
static int hf_cip_cm_to_net_params32;
static int hf_cip_cm_to_net_params16;
static int hf_cip_cm_transport_type_trigger;
static int hf_cip_cm_conn_path_size;
static int hf_cip_cm_ot_api;
static int hf_cip_cm_to_api;
static int hf_cip_cm_app_reply_size;
static int hf_cip_cm_app_reply_data;
static int hf_cip_cm_consumer_number;
static int hf_cip_cm_targ_vendor_id;
static int hf_cip_cm_targ_dev_serial_num;
static int hf_cip_cm_targ_conn_serial_num;
static int hf_cip_cm_initial_timestamp;
static int hf_cip_cm_initial_rollover;
static int hf_cip_cm_remain_path_size;
static int hf_cip_cm_msg_req_size;
static int hf_cip_cm_route_path_size;
static int hf_cip_cm_fwo_con_size;
static int hf_cip_cm_lfwo_con_size;
static int hf_cip_cm_fwo_fixed_var;
static int hf_cip_cm_lfwo_fixed_var;
static int hf_cip_cm_fwo_prio;
static int hf_cip_cm_lfwo_prio;
static int hf_cip_cm_fwo_typ;
static int hf_cip_cm_lfwo_typ;
static int hf_cip_cm_fwo_own;
static int hf_cip_cm_lfwo_own;
static int hf_cip_cm_fwo_dir;
static int hf_cip_cm_fwo_trigg;
static int hf_cip_cm_fwo_class;
static int hf_cip_cm_gco_conn;
static int hf_cip_cm_gco_coo_conn;
static int hf_cip_cm_gco_roo_conn;
static int hf_cip_cm_gco_last_action;
static int hf_cip_cm_ext112_ot_rpi_type;
static int hf_cip_cm_ext112_to_rpi_type;
static int hf_cip_cm_ext112_ot_rpi;
static int hf_cip_cm_ext112_to_rpi;
static int hf_cip_cm_ext126_size;
static int hf_cip_cm_ext127_size;
static int hf_cip_cm_ext128_size;
static int hf_cip_pccc_sc;
static int hf_cip_pccc_req_id_len;
static int hf_cip_pccc_cip_vend_id;
static int hf_cip_pccc_cip_serial_num;
static int hf_cip_pccc_cmd_code;
static int hf_cip_pccc_sts_code;
static int hf_cip_pccc_ext_sts_code;
static int hf_cip_pccc_tns_code;
static int hf_cip_pccc_fnc_code_06;
static int hf_cip_pccc_fnc_code_07;
static int hf_cip_pccc_fnc_code_0f;
static int hf_cip_pccc_byte_size;
static int hf_cip_pccc_file_num;
static int hf_cip_pccc_file_type;
static int hf_cip_pccc_element_num;
static int hf_cip_pccc_subelement_num;
#if 0
static int hf_cip_pccc_cpu_mode_3a;
#endif
static int hf_cip_pccc_cpu_mode_80;
static int hf_cip_pccc_resp_code;
static int hf_cip_pccc_execute_multi_count;
static int hf_cip_pccc_execute_multi_len;
static int hf_cip_pccc_execute_multi_fnc;
static int hf_cip_pccc_data;
static int hf_cip_mb_sc;
static int hf_cip_mb_read_coils_start_addr;
static int hf_cip_mb_read_coils_num_coils;
static int hf_cip_mb_read_coils_data;
static int hf_cip_mb_read_discrete_inputs_start_addr;
static int hf_cip_mb_read_discrete_inputs_num_inputs;
static int hf_cip_mb_read_discrete_inputs_data;
static int hf_cip_mb_read_holding_register_start_addr;
static int hf_cip_mb_read_holding_register_num_registers;
static int hf_cip_mb_read_holding_register_data;
static int hf_cip_mb_read_input_register_start_addr;
static int hf_cip_mb_read_input_register_num_registers;
static int hf_cip_mb_read_input_register_data;
static int hf_cip_mb_write_coils_start_addr;
static int hf_cip_mb_write_coils_outputs_forced;
static int hf_cip_mb_write_coils_num_coils;
static int hf_cip_mb_write_coils_data;
static int hf_cip_mb_write_registers_start_addr;
static int hf_cip_mb_write_registers_outputs_forced;
static int hf_cip_mb_write_registers_num_registers;
static int hf_cip_mb_write_registers_data;
static int hf_cip_mb_data;
static int hf_cip_cco_con_type;
static int hf_cip_cco_ot_rtf;
static int hf_cip_cco_to_rtf;
static int hf_cip_cco_sc;
static int hf_cip_cco_format_number;
static int hf_cip_cco_edit_signature;
static int hf_cip_cco_con_flags;
static int hf_cip_cco_tdi_vendor;
static int hf_cip_cco_tdi_devtype;
static int hf_cip_cco_tdi_prodcode;
static int hf_cip_cco_tdi_compatibility;
static int hf_cip_cco_tdi_comp_bit;
static int hf_cip_cco_tdi_majorrev;
static int hf_cip_cco_tdi_minorrev;
static int hf_cip_cco_pdi_vendor;
static int hf_cip_cco_pdi_devtype;
static int hf_cip_cco_pdi_prodcode;
static int hf_cip_cco_pdi_compatibility;
static int hf_cip_cco_pdi_comp_bit;
static int hf_cip_cco_pdi_majorrev;
static int hf_cip_cco_pdi_minorrev;
static int hf_cip_cco_cs_data_index;
static int hf_cip_cco_ot_rpi;
static int hf_cip_cco_to_rpi;
static int hf_cip_cco_ot_net_param16;
static int hf_cip_cco_to_net_param16;
static int hf_cip_cco_fwo_own;
static int hf_cip_cco_fwo_typ;
static int hf_cip_cco_fwo_prio;
static int hf_cip_cco_fwo_fixed_var;
static int hf_cip_cco_fwo_con_size;
static int hf_cip_cco_ot_net_param32;
static int hf_cip_cco_to_net_param32;
static int hf_cip_cco_lfwo_own;
static int hf_cip_cco_lfwo_typ;
static int hf_cip_cco_lfwo_prio;
static int hf_cip_cco_lfwo_fixed_var;
static int hf_cip_cco_lfwo_con_size;
static int hf_cip_cco_conn_path_size;
static int hf_cip_cco_proxy_config_size;
static int hf_cip_cco_target_config_size;
static int hf_cip_cco_iomap_format_number;
static int hf_cip_cco_iomap_size;
static int hf_cip_cco_connection_disable;
static int hf_cip_cco_net_conn_param_attr;
static int hf_cip_cco_timeout_multiplier;
static int hf_cip_cco_transport_type_trigger;
static int hf_cip_cco_fwo_dir;
static int hf_cip_cco_fwo_trigger;
static int hf_cip_cco_fwo_class;
static int hf_cip_cco_proxy_config_data;
static int hf_cip_cco_target_config_data;
static int hf_cip_cco_iomap_attribute;
static int hf_cip_cco_safety;
static int hf_cip_cco_change_type;
static int hf_cip_cco_connection_name;
static int hf_cip_cco_ext_status;
static int hf_cip_path_segment;
static int hf_cip_path_segment_type;
static int hf_cip_port_ex_link_addr;
static int hf_cip_port;
static int hf_cip_port_extended;
static int hf_cip_link_address_size;
static int hf_cip_link_address_byte;
static int hf_cip_link_address_string;
static int hf_cip_logical_seg_type;
static int hf_cip_logical_seg_format;
static int hf_cip_class8;
static int hf_cip_class16;
static int hf_cip_class32;
static int hf_cip_instance8;
static int hf_cip_instance16;
static int hf_cip_instance32;
static int hf_cip_member8;
static int hf_cip_member16;
static int hf_cip_member32;
static int hf_cip_attribute8;
static int hf_cip_attribute16;
static int hf_cip_attribute32;
static int hf_cip_conpoint8;
static int hf_cip_conpoint16;
static int hf_cip_conpoint32;
static int hf_cip_serviceid8;
static int hf_cip_ekey_format;
static int hf_cip_ekey_vendor;
static int hf_cip_ekey_devtype;
static int hf_cip_ekey_prodcode;
static int hf_cip_ekey_compatibility;
static int hf_cip_ekey_comp_bit;
static int hf_cip_ekey_majorrev;
static int hf_cip_ekey_minorrev;
static int hf_cip_ekey_serial_number;
static int hf_cip_ext_logical8;
static int hf_cip_ext_logical16;
static int hf_cip_ext_logical32;
static int hf_cip_ext_logical_type;
static int hf_cip_data_seg_type;
static int hf_cip_data_seg_size_simple;
static int hf_cip_data_seg_size_extended;
static int hf_cip_data_seg_item;
static int hf_cip_symbol;
static int hf_cip_symbol_size;
static int hf_cip_symbol_ascii;
static int hf_cip_symbol_extended_format;
static int hf_cip_symbol_numeric_format;
static int hf_cip_symbol_double_size;
static int hf_cip_symbol_triple_size;
static int hf_cip_numeric_usint;
static int hf_cip_numeric_uint;
static int hf_cip_numeric_udint;
static int hf_cip_network_seg_type;
static int hf_cip_seg_schedule;
static int hf_cip_seg_fixed_tag;
static int hf_cip_seg_prod_inhibit_time;
static int hf_cip_seg_prod_inhibit_time_us;
static int hf_cip_seg_network_size;
static int hf_cip_seg_network_subtype;
static int hf_cip_seg_safety_format;
static int hf_cip_seg_safety_reserved;
static int hf_cip_seg_safety_configuration_crc;
static int hf_cip_seg_safety_configuration_timestamp;
static int hf_cip_seg_safety_configuration_date;
static int hf_cip_seg_safety_configuration_time;
static int hf_cip_seg_safety_time_correction_epi;
static int hf_cip_seg_safety_time_correction_net_params;
static int hf_cip_seg_safety_time_correction_own;
static int hf_cip_seg_safety_time_correction_typ;
static int hf_cip_seg_safety_time_correction_prio;
static int hf_cip_seg_safety_time_correction_fixed_var;
static int hf_cip_seg_safety_time_correction_con_size;
static int hf_cip_seg_safety_tunid;
static int hf_cip_seg_safety_tunid_snn_timestamp;
static int hf_cip_seg_safety_tunid_snn_date;
static int hf_cip_seg_safety_tunid_snn_time;
static int hf_cip_seg_safety_tunid_nodeid;
static int hf_cip_seg_safety_ounid;
static int hf_cip_seg_safety_ounid_snn_timestamp;
static int hf_cip_seg_safety_ounid_snn_date;
static int hf_cip_seg_safety_ounid_snn_time;
static int hf_cip_seg_safety_ounid_nodeid;
static int hf_cip_seg_safety_ping_epi_multiplier;
static int hf_cip_seg_safety_time_coord_msg_min_multiplier;
static int hf_cip_seg_safety_network_time_expected_multiplier;
static int hf_cip_seg_safety_timeout_multiplier;
static int hf_cip_seg_safety_max_consumer_number;
static int hf_cip_seg_safety_conn_param_crc;
static int hf_cip_seg_safety_time_correction_conn_id;
static int hf_cip_seg_safety_max_fault_number;
static int hf_cip_seg_safety_init_timestamp;
static int hf_cip_seg_safety_init_rollover;
static int hf_cip_seg_safety_data;
static int hf_cip_class_max_inst32;
static int hf_cip_class_num_inst32;
static int hf_cip_reserved8;
static int hf_cip_reserved24;
static int hf_cip_pad8;
static int hf_cip_sc_get_attr_list_attr_count;
static int hf_cip_sc_get_attr_list_attr_status;
static int hf_cip_sc_set_attr_list_attr_count;
static int hf_cip_sc_set_attr_list_attr_status;
static int hf_cip_sc_reset_param;
static int hf_cip_sc_create_instance;
static int hf_cip_sc_mult_serv_pack_num_services;
static int hf_cip_sc_mult_serv_pack_offset;
static int hf_cip_find_next_object_max_instance;
static int hf_cip_find_next_object_num_instances;
static int hf_cip_find_next_object_instance_item;
static int hf_cip_sc_group_sync_is_sync;
/* Parsed Attributes */
static int hf_id_vendor_id;
static int hf_id_device_type;
static int hf_id_product_code;
static int hf_id_major_rev;
static int hf_id_minor_rev;
static int hf_id_status;
static int hf_id_serial_number;
static int hf_id_product_name;
static int hf_id_state;
static int hf_id_config_value;
static int hf_id_heartbeat;
static int hf_id_status_owned;
static int hf_id_status_conf;
static int hf_id_status_extended1;
static int hf_id_status_minor_fault_rec;
static int hf_id_status_minor_fault_unrec;
static int hf_id_status_major_fault_rec;
static int hf_id_status_major_fault_unrec;
static int hf_id_status_extended2;
static int hf_msg_rout_num_classes;
static int hf_msg_rout_classes;
static int hf_msg_rout_num_available;
static int hf_msg_rout_num_active;
static int hf_msg_rout_active_connections;
static int hf_conn_mgr_open_requests;
static int hf_conn_mgr_open_format_rejects;
static int hf_conn_mgr_open_resource_rejects;
static int hf_conn_mgr_other_open_rejects;
static int hf_conn_mgr_close_requests;
static int hf_conn_close_format_requests;
static int hf_conn_mgr_close_other_requests;
static int hf_conn_mgr_conn_timouts;
static int hf_conn_mgr_num_conn_entries;
static int hf_conn_mgr_num_conn_entries_bytes;
static int hf_conn_mgr_conn_open_bits;
static int hf_conn_mgr_cpu_utilization;
static int hf_conn_mgr_max_buff_size;
static int hf_conn_mgr_buff_size_remaining;
static int hf_stringi_number_char;
static int hf_stringi_language_char;
static int hf_stringi_char_string_struct;
static int hf_stringi_char_set;
static int hf_stringi_international_string;
static int hf_file_filename;
static int hf_time_sync_ptp_enable;
static int hf_time_sync_is_synchronized;
static int hf_time_sync_sys_time_micro;
static int hf_time_sync_sys_time_nano;
static int hf_time_sync_offset_from_master;
static int hf_time_sync_max_offset_from_master;
static int hf_time_sync_mean_path_delay_to_master;
static int hf_time_sync_gm_clock_clock_id;
static int hf_time_sync_gm_clock_clock_class;
static int hf_time_sync_gm_clock_time_accuracy;
static int hf_time_sync_gm_clock_offset_scaled_log_variance;
static int hf_time_sync_gm_clock_current_utc_offset;
static int hf_time_sync_gm_clock_time_property_flags;
static int hf_time_sync_gm_clock_time_property_flags_leap61;
static int hf_time_sync_gm_clock_time_property_flags_leap59;
static int hf_time_sync_gm_clock_time_property_flags_current_utc_valid;
static int hf_time_sync_gm_clock_time_property_flags_ptp_timescale;
static int hf_time_sync_gm_clock_time_property_flags_time_traceable;
static int hf_time_sync_gm_clock_time_property_flags_freq_traceable;
static int hf_time_sync_gm_clock_time_source;
static int hf_time_sync_gm_clock_priority1;
static int hf_time_sync_gm_clock_priority2;
static int hf_time_sync_parent_clock_clock_id;
static int hf_time_sync_parent_clock_port_number;
static int hf_time_sync_parent_clock_observed_offset_scaled_log_variance;
static int hf_time_sync_parent_clock_observed_phase_change_rate;
static int hf_time_sync_local_clock_clock_id;
static int hf_time_sync_local_clock_clock_class;
static int hf_time_sync_local_clock_time_accuracy;
static int hf_time_sync_local_clock_offset_scaled_log_variance;
static int hf_time_sync_local_clock_current_utc_offset;
static int hf_time_sync_local_clock_time_property_flags;
static int hf_time_sync_local_clock_time_property_flags_leap61;
static int hf_time_sync_local_clock_time_property_flags_leap59;
static int hf_time_sync_local_clock_time_property_flags_current_utc_valid;
static int hf_time_sync_local_clock_time_property_flags_ptp_timescale;
static int hf_time_sync_local_clock_time_property_flags_time_traceable;
static int hf_time_sync_local_clock_time_property_flags_freq_traceable;
static int hf_time_sync_local_clock_time_source;
static int hf_time_sync_num_ports;
static int hf_time_sync_port_state_info_num_ports;
static int hf_time_sync_port_state_info_port_num;
static int hf_time_sync_port_state_info_port_state;
static int hf_time_sync_port_enable_cfg_num_ports;
static int hf_time_sync_port_enable_cfg_port_num;
static int hf_time_sync_port_enable_cfg_port_enable;
static int hf_time_sync_port_log_announce_num_ports;
static int hf_time_sync_port_log_announce_port_num;
static int hf_time_sync_port_log_announce_interval;
static int hf_time_sync_port_log_sync_num_ports;
static int hf_time_sync_port_log_sync_port_num;
static int hf_time_sync_port_log_sync_port_log_sync_interval;
static int hf_time_sync_priority1;
static int hf_time_sync_priority2;
static int hf_time_sync_domain_number;
static int hf_time_sync_clock_type;
static int hf_time_sync_clock_type_ordinary;
static int hf_time_sync_clock_type_boundary;
static int hf_time_sync_clock_type_end_to_end;
static int hf_time_sync_clock_type_management;
static int hf_time_sync_clock_type_slave_only;
static int hf_time_sync_manufacture_id_oui;
static int hf_time_sync_manufacture_id_reserved;
static int hf_time_sync_prod_desc_size;
static int hf_time_sync_prod_desc_str;
static int hf_time_sync_revision_data_size;
static int hf_time_sync_revision_data_str;
static int hf_time_sync_user_desc_size;
static int hf_time_sync_user_desc_str;
static int hf_time_sync_port_profile_id_info_num_ports;
static int hf_time_sync_port_profile_id_info_port_num;
static int hf_time_sync_port_profile_id_info_profile_id;
static int hf_time_sync_port_phys_addr_info_num_ports;
static int hf_time_sync_port_phys_addr_info_port_num;
static int hf_time_sync_port_phys_addr_info_phys_proto;
static int hf_time_sync_port_phys_addr_info_addr_size;
static int hf_time_sync_port_phys_addr_info_phys_addr;
static int hf_time_sync_port_proto_addr_info_num_ports;
static int hf_time_sync_port_proto_addr_info_port_num;
static int hf_time_sync_port_proto_addr_info_network_proto;
static int hf_time_sync_port_proto_addr_info_addr_size;
static int hf_time_sync_port_proto_addr_info_port_proto_addr;
static int hf_time_sync_steps_removed;
static int hf_time_sync_sys_time_and_offset_time;
static int hf_time_sync_sys_time_and_offset_offset;
static int hf_port_entry_port;
static int hf_port_type;
static int hf_port_number;
static int hf_port_min_node_num;
static int hf_port_max_node_num;
static int hf_port_name;
static int hf_port_num_comm_object_entries;
static int hf_path_len_usint;
static int hf_path_len_uint;
static int hf_32bitheader;
static int hf_32bitheader_roo;
static int hf_32bitheader_coo;
static int hf_32bitheader_run_idle;
static int hf_cip_connection;
static int hf_cip_fwd_open_in;
static int hf_cip_fwd_close_in;
/* Initialize the subtree pointers */
static gint ett_cip;
static gint ett_cip_class_generic;
static gint ett_cip_class_cm;
static gint ett_cip_class_pccc;
static gint ett_cip_class_mb;
static gint ett_cip_class_cco;
static gint ett_path;
static gint ett_path_seg;
static gint ett_mcsc;
static gint ett_cia_path;
static gint ett_data_seg;
static gint ett_port_path;
static gint ett_network_seg;
static gint ett_network_seg_safety;
static gint ett_network_seg_safety_time_correction_net_params;
static gint ett_cip_seg_safety_tunid;
static gint ett_cip_seg_safety_tunid_snn;
static gint ett_cip_seg_safety_ounid;
static gint ett_cip_seg_safety_ounid_snn;
static gint ett_rrsc;
static gint ett_status_item;
static gint ett_add_status_item;
static gint ett_cmd_data;
static gint ett_cip_get_attributes_all_item;
static gint ett_cip_get_attribute_list;
static gint ett_cip_get_attribute_list_item;
static gint ett_cip_set_attribute_list;
static gint ett_cip_set_attribute_list_item;
static gint ett_cip_mult_service_packet;
static gint ett_cip_msp_offset;
static gint ett_cm_rrsc;
static gint ett_cm_ncp;
static gint ett_cm_mes_req;
static gint ett_cm_cmd_data;
static gint ett_cm_ttt;
static gint ett_cm_add_status_item;
static gint ett_cip_cm_pid;
static gint ett_cip_cm_safety;
static gint ett_pccc_rrsc;
static gint ett_pccc_req_id;
static gint ett_pccc_cmd_data;
static gint ett_mb_rrsc;
static gint ett_mb_cmd_data;
static gint ett_cco_iomap;
static gint ett_cco_con_status;
static gint ett_cco_con_flag;
static gint ett_cco_tdi;
static gint ett_cco_pdi;
static gint ett_cco_ncp;
static gint ett_cco_rrsc;
static gint ett_cco_cmd_data;
static gint ett_cco_ttt;
static gint ett_time_sync_gm_clock_flags;
static gint ett_time_sync_local_clock_flags;
static gint ett_time_sync_port_state_info;
static gint ett_time_sync_port_enable_cfg;
static gint ett_time_sync_port_log_announce;
static gint ett_time_sync_port_log_sync;
static gint ett_time_sync_clock_type;
static gint ett_time_sync_port_profile_id_info;
static gint ett_time_sync_port_phys_addr_info;
static gint ett_time_sync_port_proto_addr_info;
static gint ett_id_status;
static gint ett_32bitheader_tree;
static gint ett_connection_info;
static expert_field ei_mal_identity_revision;
static expert_field ei_mal_identity_status;
static expert_field ei_mal_msg_rout_num_classes;
static expert_field ei_mal_time_sync_gm_clock;
static expert_field ei_mal_time_sync_parent_clock;
static expert_field ei_mal_time_sync_local_clock;
static expert_field ei_mal_time_sync_port_state_info;
static expert_field ei_mal_time_sync_port_state_info_ports;
static expert_field ei_mal_time_sync_port_enable_cfg;
static expert_field ei_mal_time_sync_port_enable_cfg_ports;
static expert_field ei_mal_time_sync_port_log_announce;
static expert_field ei_mal_time_sync_port_log_announce_ports;
static expert_field ei_mal_time_sync_port_log_sync;
static expert_field ei_mal_time_sync_port_log_sync_ports;
static expert_field ei_mal_time_sync_clock_type;
static expert_field ei_mal_time_sync_manufacture_id;
static expert_field ei_mal_time_sync_prod_desc;
static expert_field ei_mal_time_sync_prod_desc_64;
static expert_field ei_mal_time_sync_prod_desc_size;
static expert_field ei_mal_time_sync_revision_data;
static expert_field ei_mal_time_sync_revision_data_32;
static expert_field ei_mal_time_sync_revision_data_size;
static expert_field ei_mal_time_sync_user_desc;
static expert_field ei_mal_time_sync_user_desc_128;
static expert_field ei_mal_time_sync_user_desc_size;
static expert_field ei_mal_time_sync_port_profile_id_info;
static expert_field ei_mal_time_sync_port_profile_id_info_ports;
static expert_field ei_mal_time_sync_port_phys_addr_info;
static expert_field ei_mal_time_sync_port_phys_addr_info_ports;
static expert_field ei_mal_time_sync_port_proto_addr_info;
static expert_field ei_mal_time_sync_port_proto_addr_info_ports;
static expert_field ei_mal_time_sync_sys_time_and_offset;
static expert_field ei_proto_log_seg_format;
static expert_field ei_mal_incomplete_epath;
static expert_field ei_proto_electronic_key_format;
static expert_field ei_proto_special_segment_format;
static expert_field ei_proto_log_seg_type;
static expert_field ei_proto_log_sub_seg_type;
static expert_field ei_proto_ext_string_format;
static expert_field ei_proto_ext_network;
static expert_field ei_proto_seg_type;
static expert_field ei_proto_unsupported_datatype;
static expert_field ei_mal_serv_gal;
static expert_field ei_mal_serv_gal_count;
static expert_field ei_mal_serv_sal;
static expert_field ei_mal_serv_sal_count;
static expert_field ei_mal_msp_services;
static expert_field ei_mal_msp_inv_offset;
static expert_field ei_mal_msp_missing_services;
static expert_field ei_mal_serv_find_next_object;
static expert_field ei_mal_serv_find_next_object_count;
static expert_field ei_mal_rpi_no_data;
static expert_field ei_mal_fwd_close_missing_data;
static expert_field ei_mal_opt_attr_list;
static expert_field ei_mal_opt_service_list;
static expert_field ei_mal_padded_epath_size;
static expert_field ei_mal_missing_string_data;
static expert_field ei_cip_null_fwd_open;
static expert_field ei_cip_safety_open_type1;
static expert_field ei_cip_safety_open_type2a;
static expert_field ei_cip_safety_open_type2b;
static expert_field ei_cip_no_fwd_close;
static expert_field ei_cip_safety_input;
static expert_field ei_cip_safety_output;
static expert_field ei_cip_listen_input_connection;
//// Concurrent Connections
static int hf_cip_cm_cc_version;
static int hf_cip_cc_packet_length;
static int hf_cip_cc_packet_options;
static int hf_cip_cc_packet_type;
static int hf_cip_cc_packet_keepalive;
static int hf_cip_cc_packet_keepalive_hop_count;
static int hf_cip_cc_packet_reserved;
static int hf_cip_cc_packet_seq_number;
static int hf_cip_cc_crc;
// Parameters for Concurrent Extended Network Segment
static int hf_ext_net_seg_hops_count;
static int hf_ext_net_seg_length;
static int hf_ext_net_seg_hop;
static int hf_ext_net_seg_hop_egress_cip_port;
static int hf_ext_net_seg_hop_link_adr_type;
static int hf_ext_net_seg_hop_number_of_linkadr;
static int hf_ext_net_seg_link_address;
static int hf_ext_net_seg_link_ipv4;
static int hf_ext_net_seg_link_hostname;
static int proto_cc;
/* Define the tree for the frame */
static gint ett_cc_header;
static gint ett_cc_hop;
static expert_field ei_cc_invalid_header_type;
static const value_string cc_link_adr_type[] = {
{ 0, "8-bit numeric link addresses" },
{ 1, "IPv4 addresses" },
{ 2, "Hostnames" },
{ 0, NULL }
};
static const value_string cc_packet_type_vals[] = {
{ 0, "Invalid" },
{ 1, "Concurrent Connection Packet Format" },
{ 0, NULL }
};
static gint* ett_cc[] =
{
&ett_cc_header,
&ett_cc_hop,
};
static dissector_table_t subdissector_class_table;
static dissector_table_t subdissector_symbol_table;
/* Translate function to string - CIP Service codes */
static const value_string cip_sc_vals[] = {
GENERIC_SC_LIST
{ 0, NULL }
};
/* Translate function to string - CIP Service codes for CM */
static const value_string cip_sc_vals_cm[] = {
GENERIC_SC_LIST
/* Some class specific services */
{ SC_CM_FWD_CLOSE, "Forward Close" },
{ SC_CM_FWD_OPEN, "Forward Open" },
{ SC_CM_UNCON_SEND, "Unconnected Send" },
{ SC_CM_LARGE_FWD_OPEN, "Large Forward Open" },
{ SC_CM_GET_CONN_DATA, "Get Connection Data" },
{ SC_CM_SEARCH_CONN_DATA, "Search Connection Data" },
{ SC_CM_GET_CONN_OWNER, "Get Connection Owner" },
{ SC_CM_CONCURRENT_FWD_OPEN, "Concurrent Forward Open" },
{ SC_CM_CONCURRENT_FWD_CLOSE, "Concurrent Forward Close" },
{ 0, NULL }
};
/* Translate function to string - CIP Service codes for PCCC */
static const value_string cip_sc_vals_pccc[] = {
GENERIC_SC_LIST
/* Some class specific services */
{ SC_PCCC_EXECUTE_PCCC, "Execute PCCC" },
{ 0, NULL }
};
/* Translate function to string - CIP Service codes for MB */
static const value_string cip_sc_vals_mb[] = {
GENERIC_SC_LIST
/* Some class specific services */
{ SC_MB_READ_DISCRETE_INPUTS, "Read Discrete" },
{ SC_MB_READ_COILS, "Read Coils" },
{ SC_MB_READ_INPUT_REGISTERS, "Read Input Registers" },
{ SC_MB_READ_HOLDING_REGISTERS, "Read Holding Registers" },
{ SC_MB_WRITE_COILS, "Write Coils" },
{ SC_MB_WRITE_HOLDING_REGISTERS, "Write Holding Registers" },
{ SC_MB_PASSTHROUGH, "Modbus Passthrough" },
{ 0, NULL }
};
/* Translate function to string - CIP Service codes for CCO */
static const value_string cip_sc_vals_cco[] = {
GENERIC_SC_LIST
/* Some class specific services */
{ SC_CCO_KICK_TIMER, "Kick Timer" },
{ SC_CCO_OPEN_CONN, "Open Connection" },
{ SC_CCO_CLOSE_CONN, "Close Connection" },
{ SC_CCO_STOP_CONN, "Stop Connection" },
{ SC_CCO_CHANGE_START, "Change Start" },
{ SC_CCO_GET_STATUS, "Get Status" },
{ SC_CCO_CHANGE_COMPLETE, "Change Complete" },
{ SC_CCO_AUDIT_CHANGE, "Audit Changes" },
{ 0, NULL }
};
/* Translate function to string - CIP Request/Response */
const value_string cip_sc_rr[] = {
{ 0, "Request" },
{ 1, "Response" },
{ 0, NULL }
};
/* Translate function to string - Compatibility */
static const value_string cip_com_bit_vals[] = {
{ 0, "Bit Cleared" },
{ 1, "Bit Set" },
{ 0, NULL }
};
const value_string cip_reset_type_vals[] = {
{ 0, "Cycle Power" },
{ 1, "Factory Default" },
{ 2, "Keep Communication Parameters" },
{ 0, NULL }
};
/* Translate function to string - Connection priority */
const value_string cip_con_prio_vals[] = {
{ 0, "Low Priority" },
{ 1, "High Priority" },
{ 2, "Scheduled" },
{ 3, "Urgent" },
{ 0, NULL }
};
/* Translate function to string - Connection size fixed or variable */
static const value_string cip_con_fw_vals[] = {
{ 0, "Fixed" },
{ 1, "Variable" },
{ 0, NULL }
};
/* Translate function to string - Connection owner */
static const value_string cip_con_owner_vals[] = {
{ 0, "Non-Redundant" },
{ 1, "Redundant" },
{ 0, NULL }
};
/* Translate function to string - Connection type*/
static const value_string cip_con_vals[] = {
{ 0, "Originator" },
{ 1, "Target" },
{ 0, NULL }
};
/* Translate function to string - Production trigger */
static const value_string cip_con_trigg_vals[] = {
{ 0, "Cyclic" },
{ 1, "Change-Of-State" },
{ 2, "Application Object" },
{ 0, NULL }
};
/* Translate function to string - Transport class */
static const value_string cip_con_class_vals[] = {
{ 0, "0" },
{ 1, "1" },
{ 2, "2" },
{ 3, "3" },
{ 0, NULL }
};
/* Translate function to string - Connection type */
const value_string cip_con_type_vals[] = {
{ CONN_TYPE_NULL, "Null" },
{ CONN_TYPE_MULTICAST, "Multicast" },
{ CONN_TYPE_P2P, "Point to Point" },
{ CONN_TYPE_RESERVED, "Reserved" },
{ 0, NULL }
};
/* Translate function to string - Timeout Multiplier */
const value_string cip_con_time_mult_vals[] = {
{ 0, "*4" },
{ 1, "*8" },
{ 2, "*16" },
{ 3, "*32" },
{ 4, "*64" },
{ 5, "*128" },
{ 6, "*256" },
{ 7, "*512" },
{ 0, NULL }
};
/* Translate function to string - Connection Last Action */
static const value_string cip_con_last_action_vals[] = {
{ 0, "No Owner" },
{ 1, "Owner Is Idle Mode" },
{ 2, "Owner Is Run Mode" },
{ 255, "Implementation not supported" },
{ 0, NULL }
};
/* Translate function to string - real time transfer format type */
static const value_string cip_con_rtf_vals[] = {
{ 0, "32-bit Header" },
{ 1, "Zero data length idle mode"},
{ 2, "Modeless" },
{ 3, "Heartbeat" },
{ 5, "Safety" },
{ 0, NULL }
};
/* Translate function to string - CCO change type */
static const value_string cip_cco_change_type_vals[] = {
{ 0, "Full" },
{ 1, "Incremental" },
{ 0, NULL }
};
static const value_string cip_time_sync_clock_class_vals[] = {
{ 6, "Primary Reference" },
{ 7, "Primary Reference (Hold)" },
{ 52, "Degraded Reference A (Master only)" },
{ 187, "Degraded Reference B (Master/Slave)" },
{ 248, "Default" },
{ 255, "Slave Only" },
{ 0, NULL }
};
static const value_string cip_time_sync_time_accuracy_vals[] = {
{ 0x20, "Accurate to within 25ns" },
{ 0x21, "Accurate to within 100ns" },
{ 0x22, "Accurate to within 250ns" },
{ 0x23, "Accurate to within 1us" },
{ 0x24, "Accurate to within 2.5us" },
{ 0x25, "Accurate to within 10us" },
{ 0x26, "Accurate to within 25us" },
{ 0x27, "Accurate to within 100us" },
{ 0x28, "Accurate to within 250us" },
{ 0x29, "Accurate to within 1ms" },
{ 0x2A, "Accurate to within 2.5ms" },
{ 0x2B, "Accurate to within 10ms" },
{ 0x2C, "Accurate to within 25ms" },
{ 0x2D, "Accurate to within 100ms" },
{ 0x2E, "Accurate to within 250ms" },
{ 0x2F, "Accurate to within 1s" },
{ 0x30, "Accurate to within 10s" },
{ 0x31, "Accurate to >10s" },
{ 0, NULL }
};
static const value_string cip_time_sync_time_source_vals[] = {
{ 0x10, "Atomic Clock" },
{ 0x20, "GPS" },
{ 0x30, "Terrestrial Radio" },
{ 0x40, "PTP" },
{ 0x50, "NTP" },
{ 0x60, "Hand Set" },
{ 0x90, "Other" },
{ 0xA0, "Internal Oscillator" },
{ 0, NULL }
};
static const value_string cip_time_sync_port_state_vals[] = {
{ 1, "INITIALIZING" },
{ 2, "FAULTY" },
{ 3, "DISABLED" },
{ 4, "LISTENING" },
{ 5, "PRE_MASTER" },
{ 6, "MASTER" },
{ 7, "PASSIVE" },
{ 8, "UNCALIBRATED" },
{ 9, "SLAVE" },
{ 0, NULL }
};