-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
packet-dnp.c
5784 lines (5049 loc) · 252 KB
/
packet-dnp.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-dnp.c
* Routines for DNP dissection
* Copyright 2003, 2006, 2007, 2013 Graham Bloice <graham.bloice<at>trihedral.com>
*
* DNP3.0 Application Layer Object dissection added by Chris Bontje (cbontje<at>gmail.com)
* Device attribute and Secure Authentication object dissection added by Chris Bontje
* Copyright 2005, 2013, 2023
*
* Major updates: tcp and application layer defragmentation, more object dissections by Graham Bloice
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
* Copyright 1998 Gerald Combs
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "config.h"
#include <math.h>
#include <epan/packet.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
#include "packet-tcp.h"
#include "packet-udp.h"
#include <epan/expert.h>
#include <epan/to_str.h>
#include <epan/crc16-tvb.h>
#include <epan/tfs.h>
#include <epan/unit_strings.h>
#include <wsutil/crc16.h>
#include <wsutil/str_util.h>
#include <wsutil/utf8_entities.h>
#include <epan/conversation.h>
#include <epan/proto_data.h>
#include <epan/tap.h>
#include <epan/conversation_table.h>
#include "packet-tls.h"
/*
* See
*
* http://www.dnp.org/
*
* although note that you have to join the DNP organization to get to
* see the protocol specs online - otherwise, you have to buy a
* dead-tree version.
*
* ...Application Layer Notes...
*
* Application Layer Decoding based on information available in
* DNP3 Basic 4 Documentation Set, specifically the document:
* "DNP V3.00 Application Layer" v0.03 P009-0PD.APP & Technical Bulletins
*
* ---------------------------------------------------------------------------
*
* Several command codes were missing, causing the dissector to abort decoding
* on valid packets. Those commands have been added.
*
* The semantics of Variation 0 have been cleaned up. Variation 0 is the
* "Default Variation". It is used only in Master -> Slave read commands
* to request the data in whatever variation the Slave is configured to use by
* default. Decoder strings have been added to the Binary Output and
* Analog Output objects (10 and 40) so that group read commands will
* decode properly.
*
* Roy M. Silvernail <roy@rant-central.com> 01/05/2009
*
*/
/***************************************************************************/
/* DNP 3.0 Constants */
/***************************************************************************/
#define DNP_HDR_LEN 10
#define TCP_PORT_DNP 20000
#define UDP_PORT_DNP 20000
#define TCP_PORT_DNP_TLS 19999
/***************************************************************************/
/* Datalink and Transport Layer Bit-Masks */
/***************************************************************************/
#define DNP3_CTL_DIR 0x80
#define DNP3_CTL_PRM 0x40
#define DNP3_CTL_FCB 0x20
#define DNP3_CTL_FCV 0x10
#define DNP3_CTL_RES 0x20
#define DNP3_CTL_DFC 0x10
#define DNP3_CTL_FUNC 0x0f
#define DNP3_TR_FIR 0x40
#define DNP3_TR_FIN 0x80
#define DNP3_TR_SEQ 0x3f
#define AL_MAX_CHUNK_SIZE 16
/***************************************************************************/
/* Data Link Function codes */
/***************************************************************************/
/* Primary to Secondary */
#define DL_FUNC_RESET_LINK 0x00
#define DL_FUNC_RESET_PROC 0x01
#define DL_FUNC_TEST_LINK 0x02
#define DL_FUNC_USER_DATA 0x03
#define DL_FUNC_UNC_DATA 0x04
#define DL_FUNC_LINK_STAT 0x09
/* Secondary to Primary */
#define DL_FUNC_ACK 0x00
#define DL_FUNC_NACK 0x01
#define DL_FUNC_STAT_LINK 0x0B
#define DL_FUNC_NO_FUNC 0x0E
#define DL_FUNC_NOT_IMPL 0x0F
/***************************************************************************/
/* Application Layer Bit-Masks */
/***************************************************************************/
#define DNP3_AL_UNS 0x10
#define DNP3_AL_CON 0x20
#define DNP3_AL_FIN 0x40
#define DNP3_AL_FIR 0x80
#define DNP3_AL_SEQ 0x0f
#define DNP3_AL_FUNC 0xff
/***************************************************************************/
/* Application Layer Function codes */
/***************************************************************************/
#define AL_FUNC_CONFIRM 0x00 /* 00 - Confirm */
#define AL_FUNC_READ 0x01 /* 01 - Read */
#define AL_FUNC_WRITE 0x02 /* 02 - Write */
#define AL_FUNC_SELECT 0x03 /* 03 - Select */
#define AL_FUNC_OPERATE 0x04 /* 04 - Operate */
#define AL_FUNC_DIROP 0x05 /* 05 - Direct Operate */
#define AL_FUNC_DIROPNACK 0x06 /* 06 - Direct Operate No ACK */
#define AL_FUNC_FRZ 0x07 /* 07 - Immediate Freeze */
#define AL_FUNC_FRZNACK 0x08 /* 08 - Immediate Freeze No ACK */
#define AL_FUNC_FRZCLR 0x09 /* 09 - Freeze and Clear */
#define AL_FUNC_FRZCLRNACK 0x0A /* 10 - Freeze and Clear No ACK */
#define AL_FUNC_FRZT 0x0B /* 11 - Freeze With Time */
#define AL_FUNC_FRZTNACK 0x0C /* 12 - Freeze With Time No ACK */
#define AL_FUNC_COLDRST 0x0D /* 13 - Cold Restart */
#define AL_FUNC_WARMRST 0x0E /* 14 - Warm Restart */
#define AL_FUNC_INITDATA 0x0F /* 15 - Initialize Data */
#define AL_FUNC_INITAPP 0x10 /* 16 - Initialize Application */
#define AL_FUNC_STARTAPP 0x11 /* 17 - Start Application */
#define AL_FUNC_STOPAPP 0x12 /* 18 - Stop Application */
#define AL_FUNC_SAVECFG 0x13 /* 19 - Save Configuration */
#define AL_FUNC_ENSPMSG 0x14 /* 20 - Enable Spontaneous Msg */
#define AL_FUNC_DISSPMSG 0x15 /* 21 - Disable Spontaneous Msg */
#define AL_FUNC_ASSIGNCL 0x16 /* 22 - Assign Classes */
#define AL_FUNC_DELAYMST 0x17 /* 23 - Delay Measurement */
#define AL_FUNC_RECCT 0x18 /* 24 - Record Current Time */
#define AL_FUNC_OPENFILE 0x19 /* 25 - Open File */
#define AL_FUNC_CLOSEFILE 0x1A /* 26 - Close File */
#define AL_FUNC_DELETEFILE 0x1B /* 27 - Delete File */
#define AL_FUNC_GETFILEINF 0x1C /* 28 - Get File Info */
#define AL_FUNC_AUTHFILE 0x1D /* 29 - Authenticate File */
#define AL_FUNC_ABORTFILE 0x1E /* 30 - Abort File */
#define AL_FUNC_ACTCNF 0x1F /* 31 - Activate Config */
#define AL_FUNC_AUTHREQ 0x20 /* 32 - Authentication Request */
#define AL_FUNC_AUTHERR 0x21 /* 33 - Authentication Error */
#define AL_FUNC_RESPON 0x81 /* 129 - Response */
#define AL_FUNC_UNSOLI 0x82 /* 130 - Unsolicited Response */
#define AL_FUNC_AUTHRESP 0x83 /* 131 - Authentication Response */
/***************************************************************************/
/* Application Layer Internal Indication (IIN) bits */
/* 2 Bytes, message formatting: [First Octet] | [Second Octet] */
/***************************************************************************/
/* Octet 1 */
#define AL_IIN_BMSG 0x0100 /* Bit 0 - Broadcast message rx'd */
#define AL_IIN_CLS1D 0x0200 /* Bit 1 - Class 1 Data Available */
#define AL_IIN_CLS2D 0x0400 /* Bit 2 - Class 2 Data Available */
#define AL_IIN_CLS3D 0x0800 /* Bit 3 - Class 3 Data Available */
#define AL_IIN_TSR 0x1000 /* Bit 4 - Time Sync Req'd from Master */
#define AL_IIN_DOL 0x2000 /* Bit 5 - Outputs in Local Mode */
#define AL_IIN_DT 0x4000 /* Bit 6 - Device Trouble */
#define AL_IIN_RST 0x8000 /* Bit 7 - Device Restart */
/* Octet 2 */
#define AL_IIN_FCNI 0x0001 /* Bit 0 - Function code not implemented */
#define AL_IIN_OBJU 0x0002 /* Bit 1 - Requested Objects Unknown */
#define AL_IIN_PIOOR 0x0004 /* Bit 2 - Parameters Invalid or Out of Range */
#define AL_IIN_EBO 0x0008 /* Bit 3 - Event Buffer Overflow */
#define AL_IIN_OAE 0x0010 /* Bit 4 - Operation Already Executing */
#define AL_IIN_CC 0x0020 /* Bit 5 - Device Configuration Corrupt */
/* 0x0040 Bit 6 - Reserved */
/* 0x0080 Bit 7 - Reserved */
/***************************************************************************/
/* Application Layer Data Object Qualifier */
/***************************************************************************/
/* Bit-Masks */
#define AL_OBJQ_PREFIX 0x70 /* x111xxxx Masks Prefix from Qualifier */
#define AL_OBJQ_RANGE 0x0F /* xxxx1111 Masks Range from Qualifier */
/* Index Size (3-bits x111xxxx) */
/* When Qualifier Code != 11 */
#define AL_OBJQL_PREFIX_NI 0x00 /* Objects are Packed with no index */
#define AL_OBJQL_PREFIX_1O 0x01 /* Objects are prefixed w/ 1-octet index */
#define AL_OBJQL_PREFIX_2O 0x02 /* Objects are prefixed w/ 2-octet index */
#define AL_OBJQL_PREFIX_4O 0x03 /* Objects are prefixed w/ 4-octet index */
#define AL_OBJQL_PREFIX_1OS 0x04 /* Objects are prefixed w/ 1-octet object size */
#define AL_OBJQL_PREFIX_2OS 0x05 /* Objects are prefixed w/ 2-octet object size */
#define AL_OBJQL_PREFIX_4OS 0x06 /* Objects are prefixed w/ 4-octet object size */
/* When Qualifier Code == 11 */
#define AL_OBJQL_IDX11_1OIS 0x01 /* 1 octet identifier size */
#define AL_OBJQL_IDX11_2OIS 0x02 /* 2 octet identifier size */
#define AL_OBJQL_IDX11_4OIS 0x03 /* 4 octet identifier size */
/* Qualifier Code (4-bits) */
/* 4-bits ( xxxx1111 ) */
#define AL_OBJQL_RANGE_SSI8 0x00 /* 00 8-bit Start and Stop Indices in Range Field */
#define AL_OBJQL_RANGE_SSI16 0x01 /* 01 16-bit Start and Stop Indices in Range Field */
#define AL_OBJQL_RANGE_SSI32 0x02 /* 02 32-bit Start and Stop Indices in Range Field */
#define AL_OBJQL_RANGE_AA8 0x03 /* 03 8-bit Absolute Address in Range Field */
#define AL_OBJQL_RANGE_AA16 0x04 /* 04 16-bit Absolute Address in Range Field */
#define AL_OBJQL_RANGE_AA32 0x05 /* 05 32-bit Absolute Address in Range Field */
#define AL_OBJQL_RANGE_R0 0x06 /* 06 Length of Range field is 0 (no range field) */
#define AL_OBJQL_RANGE_SF8 0x07 /* 07 8-bit Single Field Quantity */
#define AL_OBJQL_RANGE_SF16 0x08 /* 08 16-bit Single Field Quantity */
#define AL_OBJQL_RANGE_SF32 0x09 /* 09 32-bit Single Field Quantity */
/* 0x0A 10 Reserved */
#define AL_OBJQL_RANGE_FF 0x0B /* 11 Free-format Qualifier, range field has 1 octet count of objects */
/* 0x0C 12 Reserved */
/* 0x0D 13 Reserved */
/* 0x0E 14 Reserved */
/* 0x0F 15 Reserved */
/***************************************************************************/
/* Application Layer Data Object Definitions */
/***************************************************************************/
/* Masks for Object group and variation */
#define AL_OBJ_GRP_MASK 0xFF00
#define AL_OBJ_VAR_MASK 0x00FF
/* Accessors for group and mask */
#define AL_OBJ_GROUP(GV) (((GV) & AL_OBJ_GRP_MASK) >> 8)
#define AL_OBJ_VARIATION(GV) ((GV) & AL_OBJ_VAR_MASK)
/* Data Type values */
#define AL_DATA_TYPE_NONE 0x0
#define AL_DATA_TYPE_VSTR 0x1
#define AL_DATA_TYPE_UINT 0x2
#define AL_DATA_TYPE_INT 0x3
#define AL_DATA_TYPE_FLT 0x4
#define AL_DATA_TYPE_OSTR 0x5
#define AL_DATA_TYPE_BSTR 0x6
#define AL_DATA_TYPE_TIME 0x7
#define AL_DATA_TYPE_UNCD 0x8
#define AL_DATA_TYPE_U8BS8LIST 0xFE
#define AL_DATA_TYPE_U8BS8EXLIST 0xFF
/* Device Attributes */
#define AL_OBJ_DA_GRP 0x0000 /* 00 00 Device Attributes Group and null variation */
#define AL_OBJ_DA_CFG_ID 0x00C4 /* 00 196 Device Attributes - Configuration ID */
#define AL_OBJ_DA_CFG_VER 0x00C5 /* 00 197 Device Attributes - Configuration version */
#define AL_OBJ_DA_CFG_BLD_DATE 0x00C6 /* 00 198 Device Attributes - Configuration build date */
#define AL_OBJ_DA_CFG_CHG_DATE 0x00C7 /* 00 199 Device Attributes - Configuration last change date */
#define AL_OBJ_DA_CFG_SIG 0x00C8 /* 00 200 Device Attributes - Configuration signature */
#define AL_OBJ_DA_CFG_SIG_ALG 0x00C9 /* 00 201 Device Attributes - Configuration signature algorithm */
#define AL_OBJ_DA_MRID 0x00CA /* 00 202 Device Attributes - Master Resource ID (mRID) */
#define AL_OBJ_DA_ALT 0x00CB /* 00 203 Device Attributes - Device altitude */
#define AL_OBJ_DA_LONG 0x00CC /* 00 204 Device Attributes - Device longitude */
#define AL_OBJ_DA_LAT 0x00CD /* 00 205 Device Attributes - Device latitude */
#define AL_OBJ_DA_SEC_OP 0x00CE /* 00 206 Device Attributes - User-assigned secondary operator name */
#define AL_OBJ_DA_PRM_OP 0x00CF /* 00 207 Device Attributes - User-assigned primary operator name */
#define AL_OBJ_DA_SYS_NAME 0x00D0 /* 00 208 Device Attributes - User-assigned system name */
#define AL_OBJ_DA_SEC_VER 0x00D1 /* 00 209 Device Attributes - Secure authentication version */
#define AL_OBJ_DA_SEC_STAT 0x00D2 /* 00 210 Device Attributes - Number of security statistics per association */
#define AL_OBJ_DA_USR_ATTR 0x00D3 /* 00 211 Device Attributes - Identifier of support for user-specific attributes */
#define AL_OBJ_DA_MSTR_DSP 0x00D4 /* 00 212 Device Attributes - Number of master-defined data set prototypes */
#define AL_OBJ_DA_OS_DSP 0x00D5 /* 00 213 Device Attributes - Number of outstation-defined data set prototypes */
#define AL_OBJ_DA_MSTR_DS 0x00D6 /* 00 214 Device Attributes - Number of master-defined data sets */
#define AL_OBJ_DA_OS_DS 0x00D7 /* 00 215 Device Attributes - Number of outstation-defined data sets */
#define AL_OBJ_DA_BO_REQ 0x00D8 /* 00 216 Device Attributes - Max number of binary outputs per request */
#define AL_OBJ_DA_LOC_TA 0x00D9 /* 00 217 Device Attributes - Local timing accuracy */
#define AL_OBJ_DA_DUR_TA 0x00DA /* 00 218 Device Attributes - Duration of timing accuracy */
#define AL_OBJ_DA_AO_EVT 0x00DB /* 00 219 Device Attributes - Support for analog output events */
#define AL_OBJ_DA_MAX_AO 0x00DC /* 00 220 Device Attributes - Max analog output index */
#define AL_OBJ_DA_NUM_AO 0x00DD /* 00 221 Device Attributes - Number of analog outputs */
#define AL_OBJ_DA_BO_EVT 0x00DE /* 00 222 Device Attributes - Support for binary output events */
#define AL_OBJ_DA_MAX_BO 0x00DF /* 00 223 Device Attributes - Max binary output index */
#define AL_OBJ_DA_NUM_BO 0x00E0 /* 00 224 Device Attributes - Number of binary outputs */
#define AL_OBJ_DA_FCTR_EVT 0x00E1 /* 00 225 Device Attributes - Support for frozen counter events */
#define AL_OBJ_DA_FCTR 0x00E2 /* 00 226 Device Attributes - Support for frozen counters */
#define AL_OBJ_DA_CTR_EVT 0x00E3 /* 00 227 Device Attributes - Support for counter events */
#define AL_OBJ_DA_MAX_CTR 0x00E4 /* 00 228 Device Attributes - Max counter index */
#define AL_OBJ_DA_NUM_CTR 0x00E5 /* 00 229 Device Attributes - Number of counter points */
#define AL_OBJ_DA_AIF 0x00E6 /* 00 230 Device Attributes - Support for frozen analog inputs */
#define AL_OBJ_DA_AI_EVT 0x00E7 /* 00 231 Device Attributes - Support for analog input events */
#define AL_OBJ_DA_MAX_AI 0x00E8 /* 00 232 Device Attributes - Maximum analog input index */
#define AL_OBJ_DA_NUM_AI 0x00E9 /* 00 233 Device Attributes - Number of analog input points */
#define AL_OBJ_DA_2BI_EVT 0x00EA /* 00 234 Device Attributes - Support for Double-Bit BI Events */
#define AL_OBJ_DA_MAX_2BI 0x00EB /* 00 235 Device Attributes - Max Double-bit BI Point Index */
#define AL_OBJ_DA_NUM_2BI 0x00EC /* 00 236 Device Attributes - Number of Double-bit BI Points */
#define AL_OBJ_DA_BI_EVT 0x00ED /* 00 237 Device Attributes - Support for Binary Input Events */
#define AL_OBJ_DA_MAX_BI 0x00EE /* 00 238 Device Attributes - Max Binary Input Point Index */
#define AL_OBJ_DA_NUM_BI 0x00EF /* 00 239 Device Attributes - Number of Binary Input Points */
#define AL_OBJ_DA_MXTX_FR 0x00F0 /* 00 240 Device Attributes - Maximum Transmit Fragment Size */
#define AL_OBJ_DA_MXRX_FR 0x00F1 /* 00 241 Device Attributes - Maximum Receive Fragment Size */
#define AL_OBJ_DA_SWVER 0x00F2 /* 00 242 Device Attributes - Device Manufacturers SW Version */
#define AL_OBJ_DA_HWVER 0x00F3 /* 00 243 Device Attributes - Device Manufacturers HW Version */
#define AL_OBJ_DA_OWNER 0x00F4 /* 00 244 Device Attributes - User-assigned owner name */
#define AL_OBJ_DA_LOC 0x00F5 /* 00 245 Device Attributes - User-Assigned Location */
#define AL_OBJ_DA_ID 0x00F6 /* 00 246 Device Attributes - User-Assigned ID code/number */
#define AL_OBJ_DA_DEVNAME 0x00F7 /* 00 247 Device Attributes - User-Assigned Device Name */
#define AL_OBJ_DA_SERNUM 0x00F8 /* 00 248 Device Attributes - Device Serial Number */
#define AL_OBJ_DA_CONF 0x00F9 /* 00 249 Device Attributes - DNP Subset and Conformance */
#define AL_OBJ_DA_PROD 0x00FA /* 00 250 Device Attributes - Device Product Name and Model */
/* 00 251 Future Assignment */
#define AL_OBJ_DA_MFG 0x00FC /* 00 252 Device Attributes - Device Manufacturers Name */
/* 00 253 Future Assignment */
#define AL_OBJ_DA_ALL 0x00FE /* 00 254 Device Attributes - Non-specific All-attributes Req */
#define AL_OBJ_DA_LVAR 0x00FF /* 00 255 Device Attributes - List of Attribute Variations */
/* Binary Input Objects */
#define AL_OBJ_BI_ALL 0x0100 /* 01 00 Binary Input Default Variation */
#define AL_OBJ_BI_1BIT 0x0101 /* 01 01 Single-bit Binary Input */
#define AL_OBJ_BI_STAT 0x0102 /* 01 02 Binary Input With Status */
#define AL_OBJ_BIC_ALL 0x0200 /* 02 00 Binary Input Change Default Variation */
#define AL_OBJ_BIC_NOTIME 0x0201 /* 02 01 Binary Input Change Without Time */
#define AL_OBJ_BIC_TIME 0x0202 /* 02 02 Binary Input Change With Time */
#define AL_OBJ_BIC_RTIME 0x0203 /* 02 03 Binary Input Change With Relative Time */
/* Double-bit Input Objects */
#define AL_OBJ_2BI_ALL 0x0300 /* 03 00 Double-bit Input Default Variation */
#define AL_OBJ_2BI_NF 0x0301 /* 03 01 Double-bit Input No Flags */
#define AL_OBJ_2BI_STAT 0x0302 /* 03 02 Double-bit Input With Status */
#define AL_OBJ_2BIC_ALL 0x0400 /* 04 00 Double-bit Input Change Default Variation */
#define AL_OBJ_2BIC_NOTIME 0x0401 /* 04 01 Double-bit Input Change Without Time */
#define AL_OBJ_2BIC_TIME 0x0402 /* 04 02 Double-bit Input Change With Time */
#define AL_OBJ_2BIC_RTIME 0x0403 /* 04 03 Double-bit Input Change With Relative Time */
/* Binary Input Quality Flags */
#define AL_OBJ_BI_FLAG0 0x01 /* Point Online (0=Offline; 1=Online) */
#define AL_OBJ_BI_FLAG1 0x02 /* Restart (0=Normal; 1=Restart) */
#define AL_OBJ_BI_FLAG2 0x04 /* Comms Lost (0=Normal; 1=Lost) */
#define AL_OBJ_BI_FLAG3 0x08 /* Remote Force (0=Normal; 1=Forced) */
#define AL_OBJ_BI_FLAG4 0x10 /* Local Force (0=Normal; 1=Forced) */
#define AL_OBJ_BI_FLAG5 0x20 /* Chatter Filter (0=Normal; 1=Filter On) */
#define AL_OBJ_BI_FLAG6 0x40 /* Double-bit LSB (0=Off; 1=On) */
#define AL_OBJ_BI_FLAG7 0x80 /* Point State (0=Off; 1=On) or Double-bit MSB */
#define AL_OBJ_2BI_STATE_INTERMEDIATE 0x00
#define AL_OBJ_2BI_STATE_OFF 0x01
#define AL_OBJ_2BI_STATE_ON 0x02
#define AL_OBJ_2BI_STATE_INDETERM 0x03
#define AL_OBJ_DBI_MASK 0xC0 /* Double bit point state mask
(0 = Intermediate, 1 = Determined off, 2 = Determined on, 3 = Indeterminate */
/***************************************************************************/
/* Binary Output Objects */
#define AL_OBJ_BO_ALL 0x0A00 /* 10 00 Binary Output Default Variation */
#define AL_OBJ_BO 0x0A01 /* 10 01 Binary Output */
#define AL_OBJ_BO_STAT 0x0A02 /* 10 02 Binary Output Status */
#define AL_OBJ_BOC_ALL 0x0B00 /* 11 00 Binary Output Change Default Variation */
#define AL_OBJ_BOC_NOTIME 0x0B01 /* 11 01 Binary Output Change Without Time */
#define AL_OBJ_BOC_TIME 0x0B02 /* 11 02 Binary Output Change With Time */
#define AL_OBJ_CTLOP_BLK 0x0C01 /* 12 01 Control Relay Output Block */
#define AL_OBJ_CTL_PCB 0x0C02 /* 12 02 Pattern Control Block */
#define AL_OBJ_CTL_PMASK 0x0C03 /* 12 03 Pattern Mask */
#define AL_OBJ_BOE_ALL 0x0D00 /* 13 00 Binary Output Command Event Default Variation */
#define AL_OBJ_BOE_NOTIME 0x0D01 /* 13 01 Binary Output Command Event Without Time */
#define AL_OBJ_BOE_TIME 0x0D02 /* 13 02 Binary Output Command Event With Time */
#define AL_OBJCTLC_CODE 0x0F /* Bit-Mask xxxx1111 for Control Code 'Code' */
#define AL_OBJCTLC_MISC 0x30 /* Bit-Mask xx11xxxx for Control Code Queue (obsolete) and Clear Fields */
#define AL_OBJCTLC_TC 0xC0 /* Bit-Mask 11xxxxxx for Control Code 'Trip/Close' */
#define AL_OBJCTLC_CODE0 0x00 /* xxxx0000 NUL Operation; only process R attribute */
#define AL_OBJCTLC_CODE1 0x01 /* xxxx0001 Pulse On ^On-Time -> vOff-Time, remain off */
#define AL_OBJCTLC_CODE2 0x02 /* xxxx0010 Pulse Off vOff-Time -> ^On-Time, remain on */
#define AL_OBJCTLC_CODE3 0x03 /* xxxx0011 Latch On */
#define AL_OBJCTLC_CODE4 0x04 /* xxxx0100 Latch Off */
/* 0x05-0x15 Reserved */
#define AL_OBJCTLC_NOTSET 0x00 /* xx00xxxx for Control Code, Clear and Queue not set */
#define AL_OBJCTLC_QUEUE 0x01 /* xxx1xxxx for Control Code, Clear Field 'Queue' */
#define AL_OBJCTLC_CLEAR 0x02 /* xx1xxxxx for Control Code, Clear Field 'Clear' */
#define AL_OBJCTLC_BOTHSET 0x03 /* xx11xxxx for Control Code, Clear and Queue both set */
#define AL_OBJCTLC_TC0 0x00 /* 00xxxxxx NUL */
#define AL_OBJCTLC_TC1 0x01 /* 01xxxxxx Close */
#define AL_OBJCTLC_TC2 0x02 /* 10xxxxxx Trip */
#define AL_OBJCTLC_TC3 0x03 /* 11xxxxxx Reserved */
#define AL_OBJCTL_STAT0 0x00 /* Request Accepted, Initiated or Queued */
#define AL_OBJCTL_STAT1 0x01 /* Request Not Accepted; Arm-timer expired */
#define AL_OBJCTL_STAT2 0x02 /* Request Not Accepted; No 'SELECT' rx'd */
#define AL_OBJCTL_STAT3 0x03 /* Request Not Accepted; Format errors in ctrl request */
#define AL_OBJCTL_STAT4 0x04 /* Control Operation Not Supported for this point */
#define AL_OBJCTL_STAT5 0x05 /* Request Not Accepted; Ctrl Queue full or pt. active */
#define AL_OBJCTL_STAT6 0x06 /* Request Not Accepted; Ctrl HW Problems */
#define AL_OBJCTL_STAT7 0x07 /* Request Not Accepted; Local/Remote switch in Local*/
#define AL_OBJCTL_STAT8 0x08 /* Request Not Accepted; Too many operations requested */
#define AL_OBJCTL_STAT9 0x09 /* Request Not Accepted; Insufficient authorization */
#define AL_OBJCTL_STAT10 0x0A /* Request Not Accepted; Local automation proc active */
#define AL_OBJCTL_STAT11 0x0B /* Request Not Accepted; Processing limited */
#define AL_OBJCTL_STAT12 0x0C /* Request Not Accepted; Out of range value */
#define AL_OBJCTL_STAT126 0x7E /* Non Participating (NOP request) */
#define AL_OBJCTL_STAT127 0x7F /* Request Not Accepted; Undefined error */
#define AL_OBJCTL_STATUS_MASK 0x7F
/* Binary Output Quality Flags */
#define AL_OBJ_BO_FLAG0 0x01 /* Point Online (0=Offline; 1=Online) */
#define AL_OBJ_BO_FLAG1 0x02 /* Restart (0=Normal; 1=Restart) */
#define AL_OBJ_BO_FLAG2 0x04 /* Comms Lost (0=Normal; 1=Lost) */
#define AL_OBJ_BO_FLAG3 0x08 /* Remote Force (0=Normal; 1=Forced) */
#define AL_OBJ_BO_FLAG4 0x10 /* Local Force (0=Normal; 1=Forced) */
#define AL_OBJ_BO_FLAG5 0x20 /* Reserved */
#define AL_OBJ_BO_FLAG6 0x40 /* Reserved */
#define AL_OBJ_BO_FLAG7 0x80 /* Point State (0=Off; 1=On) */
/***************************************************************************/
/* Counter Objects */
#define AL_OBJ_CTR_ALL 0x1400 /* 20 00 Binary Counter Default Variation */
#define AL_OBJ_CTR_32 0x1401 /* 20 01 32-Bit Binary Counter */
#define AL_OBJ_CTR_16 0x1402 /* 20 02 16-Bit Binary Counter */
#define AL_OBJ_DCTR_32 0x1403 /* 20 03 32-Bit Delta Counter */
#define AL_OBJ_DCTR_16 0x1404 /* 20 04 16-Bit Delta Counter */
#define AL_OBJ_CTR_32NF 0x1405 /* 20 05 32-Bit Binary Counter Without Flag */
#define AL_OBJ_CTR_16NF 0x1406 /* 20 06 16-Bit Binary Counter Without Flag */
#define AL_OBJ_DCTR_32NF 0x1407 /* 20 07 32-Bit Delta Counter Without Flag */
#define AL_OBJ_DCTR_16NF 0x1408 /* 20 08 16-Bit Delta Counter Without Flag */
#define AL_OBJ_FCTR_ALL 0x1500 /* 21 00 Frozen Binary Counter Default Variation */
#define AL_OBJ_FCTR_32 0x1501 /* 21 01 32-Bit Frozen Counter */
#define AL_OBJ_FCTR_16 0x1502 /* 21 02 16-Bit Frozen Counter */
#define AL_OBJ_FDCTR_32 0x1503 /* 21 03 32-Bit Frozen Delta Counter */
#define AL_OBJ_FDCTR_16 0x1504 /* 21 04 16-Bit Frozen Delta Counter */
#define AL_OBJ_FCTR_32T 0x1505 /* 21 05 32-Bit Frozen Counter w/ Time of Freeze */
#define AL_OBJ_FCTR_16T 0x1506 /* 21 06 16-Bit Frozen Counter w/ Time of Freeze */
#define AL_OBJ_FDCTR_32T 0x1507 /* 21 07 32-Bit Frozen Delta Counter w/ Time of Freeze */
#define AL_OBJ_FDCTR_16T 0x1508 /* 21 08 16-Bit Frozen Delta Counter w/ Time of Freeze */
#define AL_OBJ_FCTR_32NF 0x1509 /* 21 09 32-Bit Frozen Counter Without Flag */
#define AL_OBJ_FCTR_16NF 0x150A /* 21 10 16-Bit Frozen Counter Without Flag */
#define AL_OBJ_FDCTR_32NF 0x150B /* 21 11 32-Bit Frozen Delta Counter Without Flag */
#define AL_OBJ_FDCTR_16NF 0x150C /* 21 12 16-Bit Frozen Delta Counter Without Flag */
#define AL_OBJ_CTRC_ALL 0x1600 /* 22 00 Counter Change Event Default Variation */
#define AL_OBJ_CTRC_32 0x1601 /* 22 01 32-Bit Counter Change Event w/o Time */
#define AL_OBJ_CTRC_16 0x1602 /* 22 02 16-Bit Counter Change Event w/o Time */
#define AL_OBJ_DCTRC_32 0x1603 /* 22 03 32-Bit Delta Counter Change Event w/o Time */
#define AL_OBJ_DCTRC_16 0x1604 /* 22 04 16-Bit Delta Counter Change Event w/o Time */
#define AL_OBJ_CTRC_32T 0x1605 /* 22 05 32-Bit Counter Change Event with Time */
#define AL_OBJ_CTRC_16T 0x1606 /* 22 06 16-Bit Counter Change Event with Time */
#define AL_OBJ_DCTRC_32T 0x1607 /* 22 07 32-Bit Delta Counter Change Event with Time */
#define AL_OBJ_DCTRC_16T 0x1608 /* 22 08 16-Bit Delta Counter Change Event with Time */
#define AL_OBJ_FCTRC_ALL 0x1700 /* 23 00 Frozen Binary Counter Change Event Default Variation */
#define AL_OBJ_FCTRC_32 0x1701 /* 23 01 32-Bit Frozen Counter Change Event */
#define AL_OBJ_FCTRC_16 0x1702 /* 23 02 16-Bit Frozen Counter Change Event */
#define AL_OBJ_FDCTRC_32 0x1703 /* 23 03 32-Bit Frozen Delta Counter Change Event */
#define AL_OBJ_FDCTRC_16 0x1704 /* 23 04 16-Bit Frozen Delta Counter Change Event */
#define AL_OBJ_FCTRC_32T 0x1705 /* 23 05 32-Bit Frozen Counter Change Event w/ Time of Freeze */
#define AL_OBJ_FCTRC_16T 0x1706 /* 23 06 16-Bit Frozen Counter Change Event w/ Time of Freeze */
#define AL_OBJ_FDCTRC_32T 0x1707 /* 23 07 32-Bit Frozen Delta Counter Change Event w/ Time of Freeze */
#define AL_OBJ_FDCTRC_16T 0x1708 /* 23 08 16-Bit Frozen Delta Counter Change Event w/ Time of Freeze */
/* Counter Quality Flags */
#define AL_OBJ_CTR_FLAG0 0x01 /* Point Online (0=Offline; 1=Online) */
#define AL_OBJ_CTR_FLAG1 0x02 /* Restart (0=Normal; 1=Restart) */
#define AL_OBJ_CTR_FLAG2 0x04 /* Comms Lost (0=Normal; 1=Lost) */
#define AL_OBJ_CTR_FLAG3 0x08 /* Remote Force (0=Normal; 1=Forced) */
#define AL_OBJ_CTR_FLAG4 0x10 /* Local Force (0=Normal; 1=Forced) */
#define AL_OBJ_CTR_FLAG5 0x20 /* Roll-over (0=Normal; 1=Roll-Over) */
#define AL_OBJ_CTR_FLAG6 0x40 /* Discontinuity (0=Normal; 1=Discontinuity) */
#define AL_OBJ_CTR_FLAG7 0x80 /* Reserved */
/***************************************************************************/
/* Analog Input Objects */
#define AL_OBJ_AI_ALL 0x1E00 /* 30 00 Analog Input Default Variation */
#define AL_OBJ_AI_32 0x1E01 /* 30 01 32-Bit Analog Input */
#define AL_OBJ_AI_16 0x1E02 /* 30 02 16-Bit Analog Input */
#define AL_OBJ_AI_32NF 0x1E03 /* 30 03 32-Bit Analog Input Without Flag */
#define AL_OBJ_AI_16NF 0x1E04 /* 30 04 16-Bit Analog Input Without Flag */
#define AL_OBJ_AI_FLT 0x1E05 /* 30 05 32-Bit Floating Point Input */
#define AL_OBJ_AI_DBL 0x1E06 /* 30 06 64-Bit Floating Point Input */
#define AL_OBJ_AIF_ALL 0x1F00 /* 31 00 Frozen Analog Input Default Variation */
#define AL_OBJ_AIFC_32 0x1F01 /* 31 01 32-Bit Frozen Analog Input */
#define AL_OBJ_AIFC_16 0x1F02 /* 31 02 16-Bit Frozen Analog Input */
#define AL_OBJ_AIFC_32TOF 0x1F03 /* 31 03 32-Bit Frozen Analog Input w/ Time of Freeze */
#define AL_OBJ_AIFC_16TOF 0x1F04 /* 31 04 16-Bit Frozen Analog Input w/ Time of Freeze */
#define AL_OBJ_AIFC_32NF 0x1F05 /* 31 05 32-Bit Frozen Analog Input Without Flag */
#define AL_OBJ_AIFC_16NF 0x1F06 /* 31 06 16-Bit Frozen Analog Input Without Flag */
#define AL_OBJ_AIF_FLT 0x1F07 /* 31 07 32-Bit Frozen Floating Point Input */
#define AL_OBJ_AIF_DBL 0x1F08 /* 31 08 64-Bit Frozen Floating Point Input */
#define AL_OBJ_AIC_ALL 0x2000 /* 32 00 Analog Input Change Default Variation */
#define AL_OBJ_AIC_32NT 0x2001 /* 32 01 32-Bit Analog Change Event w/o Time */
#define AL_OBJ_AIC_16NT 0x2002 /* 32 02 16-Bit Analog Change Event w/o Time */
#define AL_OBJ_AIC_32T 0x2003 /* 32 03 32-Bit Analog Change Event w/ Time */
#define AL_OBJ_AIC_16T 0x2004 /* 32 04 16-Bit Analog Change Event w/ Time */
#define AL_OBJ_AIC_FLTNT 0x2005 /* 32 05 32-Bit Floating Point Change Event w/o Time*/
#define AL_OBJ_AIC_DBLNT 0x2006 /* 32 06 64-Bit Floating Point Change Event w/o Time*/
#define AL_OBJ_AIC_FLTT 0x2007 /* 32 07 32-Bit Floating Point Change Event w/ Time*/
#define AL_OBJ_AIC_DBLT 0x2008 /* 32 08 64-Bit Floating Point Change Event w/ Time*/
#define AL_OBJ_AIFC_ALL 0x2100 /* 33 00 Frozen Analog Event Default Variation */
#define AL_OBJ_AIFC_32NT 0x2101 /* 33 01 32-Bit Frozen Analog Event w/o Time */
#define AL_OBJ_AIFC_16NT 0x2102 /* 33 02 16-Bit Frozen Analog Event w/o Time */
#define AL_OBJ_AIFC_32T 0x2103 /* 33 03 32-Bit Frozen Analog Event w/ Time */
#define AL_OBJ_AIFC_16T 0x2104 /* 33 04 16-Bit Frozen Analog Event w/ Time */
#define AL_OBJ_AIFC_FLTNT 0x2105 /* 33 05 32-Bit Floating Point Frozen Change Event w/o Time*/
#define AL_OBJ_AIFC_DBLNT 0x2106 /* 33 06 64-Bit Floating Point Frozen Change Event w/o Time*/
#define AL_OBJ_AIFC_FLTT 0x2107 /* 33 07 32-Bit Floating Point Frozen Change Event w/ Time*/
#define AL_OBJ_AIFC_DBLT 0x2108 /* 33 08 64-Bit Floating Point Frozen Change Event w/ Time*/
/* Analog Input Quality Flags */
#define AL_OBJ_AI_FLAG0 0x01 /* Point Online (0=Offline; 1=Online) */
#define AL_OBJ_AI_FLAG1 0x02 /* Restart (0=Normal; 1=Restart) */
#define AL_OBJ_AI_FLAG2 0x04 /* Comms Lost (0=Normal; 1=Lost) */
#define AL_OBJ_AI_FLAG3 0x08 /* Remote Force (0=Normal; 1=Forced) */
#define AL_OBJ_AI_FLAG4 0x10 /* Local Force (0=Normal; 1=Forced) */
#define AL_OBJ_AI_FLAG5 0x20 /* Over-Range (0=Normal; 1=Over-Range) */
#define AL_OBJ_AI_FLAG6 0x40 /* Reference Check (0=Normal; 1=Error) */
#define AL_OBJ_AI_FLAG7 0x80 /* Reserved */
#define AL_OBJ_AIDB_ALL 0x2200 /* 34 00 Analog Input Deadband Default Variation */
#define AL_OBJ_AIDB_16 0x2201 /* 34 01 16-Bit Analog Input Deadband */
#define AL_OBJ_AIDB_32 0x2202 /* 34 02 32-Bit Analog Input Deadband */
#define AL_OBJ_AIDB_FLT 0x2203 /* 34 03 Floating Point Analog Input Deadband */
/***************************************************************************/
/* Analog Output Objects */
#define AL_OBJ_AO_ALL 0x2800 /* 40 00 Analog Output Default Variation */
#define AL_OBJ_AO_32 0x2801 /* 40 01 32-Bit Analog Output Status */
#define AL_OBJ_AO_16 0x2802 /* 40 02 16-Bit Analog Output Status */
#define AL_OBJ_AO_FLT 0x2803 /* 40 03 32-Bit Floating Point Output Status */
#define AL_OBJ_AO_DBL 0x2804 /* 40 04 64-Bit Floating Point Output Status */
#define AL_OBJ_AO_32OPB 0x2901 /* 41 01 32-Bit Analog Output Block */
#define AL_OBJ_AO_16OPB 0x2902 /* 41 02 16-Bit Analog Output Block */
#define AL_OBJ_AO_FLTOPB 0x2903 /* 41 03 32-Bit Floating Point Output Block */
#define AL_OBJ_AO_DBLOPB 0x2904 /* 41 04 64-Bit Floating Point Output Block */
#define AL_OBJ_AOC_ALL 0x2A00 /* 42 00 Analog Output Event Default Variation */
#define AL_OBJ_AOC_32NT 0x2A01 /* 42 01 32-Bit Analog Output Event w/o Time */
#define AL_OBJ_AOC_16NT 0x2A02 /* 42 02 16-Bit Analog Output Event w/o Time */
#define AL_OBJ_AOC_32T 0x2A03 /* 42 03 32-Bit Analog Output Event w/ Time */
#define AL_OBJ_AOC_16T 0x2A04 /* 42 04 16-Bit Analog Output Event w/ Time */
#define AL_OBJ_AOC_FLTNT 0x2A05 /* 42 05 32-Bit Floating Point Output Event w/o Time */
#define AL_OBJ_AOC_DBLNT 0x2A06 /* 42 06 64-Bit Floating Point Output Event w/o Time */
#define AL_OBJ_AOC_FLTT 0x2A07 /* 42 07 32-Bit Floating Point Output Event w/ Time */
#define AL_OBJ_AOC_DBLT 0x2A08 /* 42 08 64-Bit Floating Point Output Event w/ Time */
#define AL_OBJ_AOC_32EVNT 0x2B01 /* 43 01 32-Bit Analog Output Command Event w/o Time */
#define AL_OBJ_AOC_16EVNT 0x2B02 /* 43 02 16-Bit Analog Output Command Event w/o Time */
#define AL_OBJ_AOC_32EVTT 0x2B03 /* 43 03 32-Bit Analog Output Command Event w/ Time */
#define AL_OBJ_AOC_16EVTT 0x2B04 /* 43 04 16-Bit Analog Output Command Event w/ Time */
#define AL_OBJ_AOC_FLTEVNT 0x2B05 /* 43 05 32-Bit Floating Point Analog Output Command Event w/o Time */
#define AL_OBJ_AOC_DBLEVNT 0x2B06 /* 43 06 64-Bit Floating Point Analog Output Command Event w/o Time */
#define AL_OBJ_AOC_FLTEVTT 0x2B07 /* 43 07 32-Bit Floating Point Analog Output Command Event w/ Time */
#define AL_OBJ_AOC_DBLEVTT 0x2B08 /* 43 08 64-Bit Floating Point Analog Output Command Event w/ Time */
/* Analog Output Quality Flags */
#define AL_OBJ_AO_FLAG0 0x01 /* Point Online (0=Offline; 1=Online) */
#define AL_OBJ_AO_FLAG1 0x02 /* Restart (0=Normal; 1=Restart) */
#define AL_OBJ_AO_FLAG2 0x04 /* Comms Lost (0=Normal; 1=Lost) */
#define AL_OBJ_AO_FLAG3 0x08 /* Remote Force (0=Normal; 1=Forced) */
#define AL_OBJ_AO_FLAG4 0x10 /* Local Force (0=Normal; 1=Forced) */
#define AL_OBJ_AO_FLAG5 0x20 /* Reserved */
#define AL_OBJ_AO_FLAG6 0x40 /* Reserved */
#define AL_OBJ_AO_FLAG7 0x80 /* Reserved */
/***************************************************************************/
/* Time Objects */
#define AL_OBJ_TD_ALL 0x3200 /* 50 00 Time and Date Default Variation */
#define AL_OBJ_TD 0x3201 /* 50 01 Time and Date */
#define AL_OBJ_TDI 0x3202 /* 50 02 Time and Date w/ Interval */
#define AL_OBJ_TDR 0x3203 /* 50 03 Last Recorded Time and Date */
#define AL_OBJ_TDCTO 0x3301 /* 51 01 Time and Date CTO */
#define AL_OBJ_UTDCTO 0x3302 /* 51 02 Unsynchronized Time and Date CTO */
#define AL_OBJ_TDELAYC 0x3401 /* 52 01 Time Delay Coarse */
#define AL_OBJ_TDELAYF 0x3402 /* 52 02 Time Delay Fine */
/***************************************************************************/
/* Class Data Objects */
#define AL_OBJ_CLASS0 0x3C01 /* 60 01 Class 0 Data */
#define AL_OBJ_CLASS1 0x3C02 /* 60 02 Class 1 Data */
#define AL_OBJ_CLASS2 0x3C03 /* 60 03 Class 2 Data */
#define AL_OBJ_CLASS3 0x3C04 /* 60 04 Class 3 Data */
/***************************************************************************/
/* File Objects */
#define AL_OBJ_FILE_CMD 0x4603 /* 70 03 File Control - Command */
#define AL_OBJ_FILE_STAT 0x4604 /* 70 04 File Control - Status */
#define AL_OBJ_FILE_TRANS 0x4605 /* 70 05 File Control - Transport */
#define AL_OBJ_FILE_TRAN_ST 0x4606 /* 70 05 File Control - Transport Status */
/* File Control Mode flags */
#define AL_OBJ_FILE_MODE_NULL 0x00 /* NULL */
#define AL_OBJ_FILE_MODE_READ 0x01 /* READ */
#define AL_OBJ_FILE_MODE_WRITE 0x02 /* WRITE */
#define AL_OBJ_FILE_MODE_APPEND 0x03 /* APPEND */
/***************************************************************************/
/* Device Objects */
#define AL_OBJ_IIN 0x5001 /* 80 01 Internal Indications */
/***************************************************************************/
/* Data Sets */
#define AL_OBJ_DS_PROTO 0x5501 /* 85 01 Data-Set Prototype, with UUID */
#define AL_OBJ_DSD_CONT 0x5601 /* 86 01 Data-Set Descriptor, Data-Set Contents */
#define AL_OBJ_DSD_CHAR 0x5602 /* 86 02 Data-Set Descriptor, Characteristics */
#define AL_OBJ_DSD_PIDX 0x5603 /* 86 03 Data-Set Descriptor, Point Index Attributes */
#define AL_OBJ_DS_PV 0x5701 /* 87 01 Data-Set, Present Value */
#define AL_OBJ_DS_SS 0x5801 /* 88 01 Data-Set, Snapshot */
/***************************************************************************/
/* Octet String Objects */
#define AL_OBJ_OCT 0x6E00 /* 110 xx Octet string */
#define AL_OBJ_OCT_EVT 0x6F00 /* 111 xx Octet string event */
/***************************************************************************/
/* Virtual Terminal Objects */
#define AL_OBJ_VT_OBLK 0x7000 /* 112 xx Virtual Terminal Output Block */
#define AL_OBJ_VT_EVTD 0x7100 /* 113 xx Virtual Terminal Event Data */
/***************************************************************************/
/* Secure Authentication ('SA') Objects */
#define AL_OBJ_SA_AUTH_CH 0x7801 /* 120 01 Authentication Challenge */
#define AL_OBJ_SA_AUTH_RP 0x7802 /* 120 02 Authentication Reply */
#define AL_OBJ_SA_AUTH_AGMRQ 0x7803 /* 120 03 Authentication Aggressive Mode Request */
#define AL_OBJ_SA_AUTH_SKSR 0x7804 /* 120 04 Authentication Session Key Status Request */
#define AL_OBJ_SA_AUTH_SKS 0x7805 /* 120 05 Authentication Session Key Status */
#define AL_OBJ_SA_AUTH_SKC 0x7806 /* 120 06 Authentication Session Key Change */
#define AL_OBJ_SA_AUTH_ERR 0x7807 /* 120 07 Authentication Error */
#define AL_OBJ_SA_AUTH_MAC 0x7809 /* 120 09 Authentication Message Authentication Code */
#define AL_OBJ_SA_AUTH_USC 0x780A /* 120 10 Authentication User Status Change - Not supported */
#define AL_OBJ_SA_AUTH_UKCR 0x780B /* 120 11 Authentication Update Key Change Request */
#define AL_OBJ_SA_AUTH_UKCRP 0x780C /* 120 12 Authentication Update Key Change Reply */
#define AL_OBJ_SA_AUTH_UKC 0x780D /* 120 13 Authentication Update Key Change */
#define AL_OBJ_SA_AUTH_UKCC 0x780F /* 120 15 Authentication Update Key Change Confirmation */
#define AL_OBJ_SA_SECSTAT 0x7901 /* 121 01 Security Statistics */
#define AL_OBJ_SA_SECSTATEVT 0x7A01 /* 122 01 Security Statistic Event */
#define AL_OBJ_SA_SECSTATEVTT 0x7A02 /* 122 02 Security Statistic Event w/ Time */
/***************************************************************************/
/* End of Application Layer Data Object Definitions */
/***************************************************************************/
void proto_register_dnp3(void);
void proto_reg_handoff_dnp3(void);
/* Initialize the protocol and registered fields */
static int proto_dnp3;
static int hf_dnp3_start;
static int hf_dnp3_len;
static int hf_dnp3_ctl;
static int hf_dnp3_ctl_prifunc;
static int hf_dnp3_ctl_secfunc;
static int hf_dnp3_ctl_dir;
static int hf_dnp3_ctl_prm;
static int hf_dnp3_ctl_fcb;
static int hf_dnp3_ctl_fcv;
static int hf_dnp3_ctl_dfc;
static int hf_dnp3_dst;
static int hf_dnp3_src;
static int hf_dnp3_addr;
static int hf_dnp3_data_hdr_crc;
static int hf_dnp3_data_hdr_crc_status;
static int hf_dnp3_tr_ctl;
static int hf_dnp3_tr_fin;
static int hf_dnp3_tr_fir;
static int hf_dnp3_tr_seq;
static int hf_dnp3_data_chunk;
static int hf_dnp3_data_chunk_len;
static int hf_dnp3_data_chunk_crc;
static int hf_dnp3_data_chunk_crc_status;
/* Added for Application Layer Decoding */
static int hf_dnp3_al_ctl;
static int hf_dnp3_al_fir;
static int hf_dnp3_al_fin;
static int hf_dnp3_al_con;
static int hf_dnp3_al_uns;
static int hf_dnp3_al_seq;
static int hf_dnp3_al_func;
static int hf_dnp3_al_iin;
static int hf_dnp3_al_iin_bmsg;
static int hf_dnp3_al_iin_cls1d;
static int hf_dnp3_al_iin_cls2d;
static int hf_dnp3_al_iin_cls3d;
static int hf_dnp3_al_iin_tsr;
static int hf_dnp3_al_iin_dol;
static int hf_dnp3_al_iin_dt;
static int hf_dnp3_al_iin_rst;
static int hf_dnp3_al_iin_fcni;
static int hf_dnp3_al_iin_obju;
static int hf_dnp3_al_iin_pioor;
static int hf_dnp3_al_iin_ebo;
static int hf_dnp3_al_iin_oae;
static int hf_dnp3_al_iin_cc;
static int hf_dnp3_al_obj;
static int hf_dnp3_al_objq_prefix;
static int hf_dnp3_al_objq_range;
static int hf_dnp3_al_range_start8;
static int hf_dnp3_al_range_stop8;
static int hf_dnp3_al_range_start16;
static int hf_dnp3_al_range_stop16;
static int hf_dnp3_al_range_start32;
static int hf_dnp3_al_range_stop32;
static int hf_dnp3_al_range_abs8;
static int hf_dnp3_al_range_abs16;
static int hf_dnp3_al_range_abs32;
static int hf_dnp3_al_range_quant8;
static int hf_dnp3_al_range_quant16;
static int hf_dnp3_al_range_quant32;
static int hf_dnp3_al_index8;
static int hf_dnp3_al_index16;
static int hf_dnp3_al_index32;
static int hf_dnp3_al_size8;
static int hf_dnp3_al_size16;
static int hf_dnp3_al_size32;
static int hf_dnp3_bocs_bit;
/* static int hf_dnp3_al_objq;*/
/* static int hf_dnp3_al_nobj; */
static int hf_dnp3_al_biq_b0;
static int hf_dnp3_al_biq_b1;
static int hf_dnp3_al_biq_b2;
static int hf_dnp3_al_biq_b3;
static int hf_dnp3_al_biq_b4;
static int hf_dnp3_al_biq_b5;
static int hf_dnp3_al_biq_b6;
static int hf_dnp3_al_biq_b7;
static int hf_dnp3_al_boq_b0;
static int hf_dnp3_al_boq_b1;
static int hf_dnp3_al_boq_b2;
static int hf_dnp3_al_boq_b3;
static int hf_dnp3_al_boq_b4;
static int hf_dnp3_al_boq_b5;
static int hf_dnp3_al_boq_b6;
static int hf_dnp3_al_boq_b7;
static int hf_dnp3_al_ctrq_b0;
static int hf_dnp3_al_ctrq_b1;
static int hf_dnp3_al_ctrq_b2;
static int hf_dnp3_al_ctrq_b3;
static int hf_dnp3_al_ctrq_b4;
static int hf_dnp3_al_ctrq_b5;
static int hf_dnp3_al_ctrq_b6;
static int hf_dnp3_al_ctrq_b7;
static int hf_dnp3_al_aiq_b0;
static int hf_dnp3_al_aiq_b1;
static int hf_dnp3_al_aiq_b2;
static int hf_dnp3_al_aiq_b3;
static int hf_dnp3_al_aiq_b4;
static int hf_dnp3_al_aiq_b5;
static int hf_dnp3_al_aiq_b6;
static int hf_dnp3_al_aiq_b7;
static int hf_dnp3_al_aoq_b0;
static int hf_dnp3_al_aoq_b1;
static int hf_dnp3_al_aoq_b2;
static int hf_dnp3_al_aoq_b3;
static int hf_dnp3_al_aoq_b4;
static int hf_dnp3_al_aoq_b5;
static int hf_dnp3_al_aoq_b6;
static int hf_dnp3_al_aoq_b7;
static int hf_dnp3_al_timestamp;
static int hf_dnp3_al_file_perms;
static int hf_dnp3_al_file_perms_read_owner;
static int hf_dnp3_al_file_perms_write_owner;
static int hf_dnp3_al_file_perms_exec_owner;
static int hf_dnp3_al_file_perms_read_group;
static int hf_dnp3_al_file_perms_write_group;
static int hf_dnp3_al_file_perms_exec_group;
static int hf_dnp3_al_file_perms_read_world;
static int hf_dnp3_al_file_perms_write_world;
static int hf_dnp3_al_file_perms_exec_world;
static int hf_dnp3_al_rel_timestamp;
static int hf_dnp3_al_ana16;
static int hf_dnp3_al_ana32;
static int hf_dnp3_al_anaflt;
static int hf_dnp3_al_anadbl;
static int hf_dnp3_al_bit;
static int hf_dnp3_al_bit0;
static int hf_dnp3_al_bit1;
static int hf_dnp3_al_bit2;
static int hf_dnp3_al_bit3;
static int hf_dnp3_al_bit4;
static int hf_dnp3_al_bit5;
static int hf_dnp3_al_bit6;
static int hf_dnp3_al_bit7;
static int hf_dnp3_al_2bit;
static int hf_dnp3_al_2bit0;
static int hf_dnp3_al_2bit1;
static int hf_dnp3_al_2bit2;
static int hf_dnp3_al_2bit3;
static int hf_dnp3_al_cnt16;
static int hf_dnp3_al_cnt32;
static int hf_dnp3_al_ctrlstatus;
static int hf_dnp3_al_anaout16;
static int hf_dnp3_al_anaout32;
static int hf_dnp3_al_anaoutflt;
static int hf_dnp3_al_anaoutdbl;
static int hf_dnp3_al_file_mode;
static int hf_dnp3_al_file_auth;
static int hf_dnp3_al_file_size;
static int hf_dnp3_al_file_maxblk;
static int hf_dnp3_al_file_reqID;
static int hf_dnp3_al_file_handle;
static int hf_dnp3_al_file_status;
static int hf_dnp3_al_file_blocknum;
static int hf_dnp3_al_file_lastblock;
static int hf_dnp3_al_file_data;
static int hf_dnp3_ctlobj_code_c;
static int hf_dnp3_ctlobj_code_m;
static int hf_dnp3_ctlobj_code_tc;
static int hf_dnp3_al_datatype;
static int hf_dnp3_al_da_length;
static int hf_dnp3_al_da_uint8;
static int hf_dnp3_al_da_uint16;
static int hf_dnp3_al_da_uint32;
static int hf_dnp3_al_da_int8;
static int hf_dnp3_al_da_int16;
static int hf_dnp3_al_da_int32;
static int hf_dnp3_al_da_flt;
static int hf_dnp3_al_da_dbl;
static int hf_dnp3_al_sa_cd;
static int hf_dnp3_al_sa_cdl;
static int hf_dnp3_al_sa_csq;
static int hf_dnp3_al_sa_err;
static int hf_dnp3_al_sa_key;
static int hf_dnp3_al_sa_kcm;
static int hf_dnp3_al_sa_ks;
static int hf_dnp3_al_sa_ksq;
static int hf_dnp3_al_sa_kwa;
static int hf_dnp3_al_sa_mac;
static int hf_dnp3_al_sa_mal;
static int hf_dnp3_al_sa_rfc;
static int hf_dnp3_al_sa_seq;
static int hf_dnp3_al_sa_uk;
static int hf_dnp3_al_sa_ukl;
static int hf_dnp3_al_sa_usr;
static int hf_dnp3_al_sa_usrn;
static int hf_dnp3_al_sa_usrnl;
static int hf_dnp3_al_sa_assoc_id;
static int hf_dnp3_al_bi_index;
static int hf_dnp3_al_bi_static_index;
static int hf_dnp3_al_bi_event_index;
static int hf_dnp3_al_dbi_index;
static int hf_dnp3_al_dbi_static_index;
static int hf_dnp3_al_dbi_event_index;
static int hf_dnp3_al_bo_index;
static int hf_dnp3_al_bo_static_index;
static int hf_dnp3_al_bo_event_index;
static int hf_dnp3_al_bo_cmnd_index;
static int hf_dnp3_al_counter_index;
static int hf_dnp3_al_counter_static_index;
static int hf_dnp3_al_counter_event_index;
static int hf_dnp3_al_ai_index;
static int hf_dnp3_al_ai_static_index;
static int hf_dnp3_al_ai_event_index;
static int hf_dnp3_al_ao_index;
static int hf_dnp3_al_ao_static_index;
static int hf_dnp3_al_ao_event_index;
static int hf_dnp3_al_ao_cmnd_index;
static int hf_dnp3_al_os_index;
static int hf_dnp3_al_os_static_index;
static int hf_dnp3_al_os_event_index;
/* Generated from convert_proto_tree_add_text.pl */
static int hf_dnp3_al_point_index;
static int hf_dnp3_al_da_value;
static int hf_dnp3_al_count;
static int hf_dnp3_al_on_time;
static int hf_dnp3_al_off_time;
static int hf_dnp3_al_time_delay;
static int hf_dnp3_al_file_string_offset;
static int hf_dnp3_al_file_string_length;
static int hf_dnp3_al_file_name;
static int hf_dnp3_al_octet_string;
static int hf_dnp3_unknown_data_chunk;
/***************************************************************************/
/* Value String Look-Ups */
/***************************************************************************/
static const value_string dnp3_ctl_func_pri_vals[] = {
{ DL_FUNC_RESET_LINK, "Reset of Remote Link" },
{ DL_FUNC_RESET_PROC, "Reset of User Process" },
{ DL_FUNC_TEST_LINK, "Test Function For Link" },
{ DL_FUNC_USER_DATA, "User Data" },
{ DL_FUNC_UNC_DATA, "Unconfirmed User Data" },
{ DL_FUNC_LINK_STAT, "Request Link Status" },
{ 0, NULL }
};
static const value_string dnp3_ctl_func_sec_vals[] = {
{ DL_FUNC_ACK, "ACK" },
{ DL_FUNC_NACK, "NACK" },
{ DL_FUNC_STAT_LINK, "Status of Link" },
{ DL_FUNC_NO_FUNC, "Link Service Not Functioning" },
{ DL_FUNC_NOT_IMPL, "Link Service Not Used or Implemented" },
{ 0, NULL }
};
#if 0
static const value_string dnp3_ctl_flags_pri_vals[] = {
{ DNP3_CTL_DIR, "DIR" },
{ DNP3_CTL_PRM, "PRM" },
{ DNP3_CTL_FCB, "FCB" },
{ DNP3_CTL_FCV, "FCV" },
{ 0, NULL }
};
#endif
#if 0
static const value_string dnp3_ctl_flags_sec_vals[]= {
{ DNP3_CTL_DIR, "DIR" },
{ DNP3_CTL_PRM, "PRM" },
{ DNP3_CTL_RES, "RES" },
{ DNP3_CTL_DFC, "DFC" },
{ 0, NULL }
};
#endif
#if 0
static const value_string dnp3_tr_flags_vals[] = {
{ DNP3_TR_FIN, "FIN" },
{ DNP3_TR_FIR, "FIR" },
{ 0, NULL }
};
#endif
#if 0
static const value_string dnp3_al_flags_vals[] = {
{ DNP3_AL_FIR, "FIR" },
{ DNP3_AL_FIN, "FIN" },
{ DNP3_AL_CON, "CON" },
{ DNP3_AL_UNS, "UNS" },
{ 0, NULL }
};
#endif
/* Application Layer Function Code Values */
static const value_string dnp3_al_func_vals[] = {
{ AL_FUNC_CONFIRM, "Confirm" },
{ AL_FUNC_READ, "Read" },
{ AL_FUNC_WRITE, "Write" },
{ AL_FUNC_SELECT, "Select" },
{ AL_FUNC_OPERATE, "Operate" },
{ AL_FUNC_DIROP, "Direct Operate" },
{ AL_FUNC_DIROPNACK, "Direct Operate No Ack" },
{ AL_FUNC_FRZ, "Immediate Freeze" },
{ AL_FUNC_FRZNACK, "Immediate Freeze No Ack" },
{ AL_FUNC_FRZCLR, "Freeze and Clear" },
{ AL_FUNC_FRZCLRNACK, "Freeze and Clear No ACK" },
{ AL_FUNC_FRZT, "Freeze With Time" },
{ AL_FUNC_FRZTNACK, "Freeze With Time No ACK" },
{ AL_FUNC_COLDRST, "Cold Restart" },
{ AL_FUNC_WARMRST, "Warm Restart" },
{ AL_FUNC_INITDATA, "Initialize Data" },
{ AL_FUNC_INITAPP, "Initialize Application" },
{ AL_FUNC_STARTAPP, "Start Application" },
{ AL_FUNC_STOPAPP, "Stop Application" },
{ AL_FUNC_SAVECFG, "Save Configuration" },
{ AL_FUNC_ENSPMSG, "Enable Spontaneous Messages" },
{ AL_FUNC_DISSPMSG, "Disable Spontaneous Messages" },
{ AL_FUNC_ASSIGNCL, "Assign Classes" },
{ AL_FUNC_DELAYMST, "Delay Measurement" },
{ AL_FUNC_RECCT, "Record Current Time" },
{ AL_FUNC_OPENFILE, "Open File" },
{ AL_FUNC_CLOSEFILE, "Close File" },
{ AL_FUNC_DELETEFILE, "Delete File" },
{ AL_FUNC_GETFILEINF, "Get File Info" },
{ AL_FUNC_AUTHFILE, "Authenticate File" },
{ AL_FUNC_ABORTFILE, "Abort File" },
{ AL_FUNC_ACTCNF, "Activate Config" },
{ AL_FUNC_AUTHREQ, "Authentication Request" },
{ AL_FUNC_AUTHERR, "Authentication Error" },
{ AL_FUNC_RESPON, "Response" },
{ AL_FUNC_UNSOLI, "Unsolicited Response" },
{ AL_FUNC_AUTHRESP, "Authentication Response" },
{ 0, NULL }
};
static value_string_ext dnp3_al_func_vals_ext = VALUE_STRING_EXT_INIT(dnp3_al_func_vals);
/* Application Layer Internal Indication (IIN) bit Values */
static const value_string dnp3_al_iin_vals[] = {
{ AL_IIN_BMSG, "Broadcast message Rx'd" },
{ AL_IIN_CLS1D, "Class 1 Data Available" },
{ AL_IIN_CLS2D, "Class 2 Data Available" },
{ AL_IIN_CLS3D, "Class 3 Data Available" },
{ AL_IIN_TSR, "Time Sync Required from Master" },
{ AL_IIN_DOL, "Outputs in Local Mode" },
{ AL_IIN_DT, "Device Trouble" },
{ AL_IIN_RST, "Device Restart" },
{ AL_IIN_FCNI, "Function Code not implemented" },
{ AL_IIN_OBJU, "Requested Objects Unknown" },
{ AL_IIN_PIOOR, "Parameters Invalid or Out of Range" },
{ AL_IIN_EBO, "Event Buffer Overflow" },
{ AL_IIN_OAE, "Operation Already Executing" },
{ AL_IIN_CC, "Device Configuration Corrupt" },
{ 0, NULL }
};
/* Application Layer Object Qualifier Prefix Values When Qualifier Code != 11 */
static const value_string dnp3_al_objq_prefix_vals[] = {
{ AL_OBJQL_PREFIX_NI, "None" },
{ AL_OBJQL_PREFIX_1O, "1-Octet Index Prefix" },
{ AL_OBJQL_PREFIX_2O, "2-Octet Index Prefix" },