]> git.ipfire.org Git - people/ms/suricata.git/blame - src/app-layer-dnp3-objects.c
DNP3: Application layer decoder.
[people/ms/suricata.git] / src / app-layer-dnp3-objects.c
CommitLineData
bbaa79b8
JI
1/* Copyright (C) 2015 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Jason Ish <jason.ish@oisf.net>
22 *
23 * This file contains the DNP3 object decoders.
24 */
25
26#include "suricata-common.h"
27
28#include "app-layer-dnp3.h"
29#include "app-layer-dnp3-objects.h"
30
31void DNP3FreeObjectPoint(int group, int variation, void *point);
32
33#if 0
34static void DNP3HexDump(uint8_t *data, int len)
35{
36 for (int i = 0; i < len; i++) {
37 printf("%02x ", data[i]);
38 }
39}
40#endif
41
42/**
43 * \brief Allocate a list for DNP3 points.
44 */
45DNP3PointList *DNP3PointListAlloc(void)
46{
47 DNP3PointList *items = SCCalloc(1, sizeof(*items));
48 if (unlikely(items == NULL)) {
49 return NULL;
50 }
51 TAILQ_INIT(items);
52 return items;
53}
54
55/**
56 * \brief Free a DNP3PointList.
57 */
58void DNP3FreeObjectPointList(int group, int variation, DNP3PointList *list)
59{
60 DNP3Point *point;
61 while ((point = TAILQ_FIRST(list)) != NULL) {
62 TAILQ_REMOVE(list, point, next);
63 if (point->data != NULL) {
64 DNP3FreeObjectPoint(group, variation, point->data);
65 }
66 SCFree(point);
67 }
68 SCFree(list);
69}
70
71/**
72 * \brief Read an uint8_t from a buffer.
73 *
74 * Reads a uint8_t from a buffer advancing the pointer and
75 * decrementing the length.
76 *
77 * \param buf A pointer to the buffer to read from.
78 * \param len A pointer to the buffer length.
79 * \param out A pointer to where the value will be stored.
80 *
81 * \retval Returns 1 if there was enough space in the buffer to read from,
82 * otherwise 0 is returned.
83 */
84static int DNP3ReadUint8(const uint8_t **buf, uint32_t *len, uint8_t *out)
85{
86 if (*len < (int)sizeof(*out)) {
87 return 0;
88 }
89 *out = *(uint8_t *)(*buf);
90 *buf += sizeof(*out);
91 *len -= sizeof(*out);
92 return 1;
93}
94
95/**
96 * \brief Read an uint16_t from a buffer.
97 *
98 * Reads an uint16_t from a buffer advancing the pointer and
99 * decrementing the length.
100 *
101 * \param buf A pointer to the buffer to read from.
102 * \param len A pointer to the buffer length.
103 * \param out A pointer to where the value will be stored.
104 *
105 * \retval Returns 1 if there was enough space in the buffer to read from,
106 * otherwise 0 is returned.
107 */
108static int DNP3ReadUint16(const uint8_t **buf, uint32_t *len, uint16_t *out)
109{
110 if (*len < (int)sizeof(*out)) {
111 return 0;
112 }
113 *out = DNP3_SWAP16(*(uint16_t *)(*buf));
114 *buf += sizeof(*out);
115 *len -= sizeof(*out);
116 return 1;
117}
118
119/**
120 * \brief Read an unsigned 24 bit integer from a buffer.
121 *
122 * Reads an an unsigned 24 bit integer from a buffer advancing the
123 * pointer and decrementing the length.
124 *
125 * \param buf A pointer to the buffer to read from.
126 * \param len A pointer to the buffer length.
127 * \param out A pointer to where the value will be stored.
128 *
129 * \retval Returns 1 if there was enough space in the buffer to read from,
130 * otherwise 0 is returned.
131 */
132static int DNP3ReadUint24(const uint8_t **buf, uint32_t *len, uint32_t *out)
133{
134 if (*len < (int)(sizeof(uint8_t) * 3)) {
135 return 0;
136 }
137
138#if __BYTE_ORDER__ == __BIG_ENDIAN
139 *out = ((uint32_t)(*buf)[0] << 16) | ((uint32_t)(*buf)[1] << 8) |
140 (uint32_t)(*buf)[2];
141#elif __BYTE_ORDER == __LITTLE_ENDIAN
142 *out = ((uint64_t)(*buf)[0]) | ((uint64_t)(*buf)[1] << 8) |
143 ((uint64_t)(*buf)[2] << 16);
144#endif
145
146 *buf += 3;
147 *len -= 3;
148
149 return 1;
150}
151
152/**
153 * \brief Read an uint32_t from a buffer.
154 *
155 * Reads an uint32_t from a buffer advancing the pointer and
156 * decrementing the length.
157 *
158 * \param buf A pointer to the buffer to read from.
159 * \param len A pointer to the buffer length.
160 * \param out A pointer to where the value will be stored.
161 *
162 * \retval Returns 1 if there was enough space in the buffer to read from,
163 * otherwise 0 is returned.
164 */
165static int DNP3ReadUint32(const uint8_t **buf, uint32_t *len, uint32_t *out)
166{
167 if (*len < (int)sizeof(*out)) {
168 return 0;
169 }
170 *out = DNP3_SWAP32(*(uint32_t *)(*buf));
171 *buf += sizeof(*out);
172 *len -= sizeof(*out);
173 return 1;
174}
175
176/**
177 * \brief Read an unsigned 48 bit integer from a buffer.
178 *
179 * Reads an an unsigned 48 bit integer from a buffer advancing the
180 * pointer and decrementing the length.
181 *
182 * \param buf A pointer to the buffer to read from.
183 * \param len A pointer to the buffer length.
184 * \param out A pointer to where the value will be stored.
185 *
186 * \retval Returns 1 if there was enough space in the buffer to read from,
187 * otherwise 0 is returned.
188 */
189static int DNP3ReadUint48(const uint8_t **buf, uint32_t *len, uint64_t *out)
190{
191 if (*len < (int)(sizeof(uint8_t) * 6)) {
192 return 0;
193 }
194
195#if __BYTE_ORDER__ == __BIG_ENDIAN
196 *out = ((uint64_t)(*buf)[0] << 40) | ((uint64_t)(*buf)[1] << 32) |
197 ((uint64_t)(*buf)[2] << 24) | ((uint64_t)(*buf)[3] << 16) |
198 ((uint64_t)(*buf)[4] << 8) | (uint64_t)(*buf)[5];
199#elif __BYTE_ORDER == __LITTLE_ENDIAN
200 *out = ((uint64_t)(*buf)[0]) | ((uint64_t)(*buf)[1] << 8) |
201 ((uint64_t)(*buf)[2] << 16) | ((uint64_t)(*buf)[3] << 24) |
202 ((uint64_t)(*buf)[4] << 32) | ((uint64_t)(*buf)[5] << 40);
203#endif
204
205 *buf += 6;
206 *len -= 6;
207
208 return 1;
209}
210
211/**
212 * \brief Read a 32 bit float from a buffer.
213 *
214 * Reads an 32 bit float from a buffer advancing the pointer and
215 * decrementing the length.
216 *
217 * \param buf A pointer to the buffer to read from.
218 * \param len A pointer to the buffer length.
219 * \param out A pointer to where the value will be stored.
220 *
221 * \retval Returns 1 if there was enough space in the buffer to read from,
222 * otherwise 0 is returned.
223 */
224static int DNP3ReadFloat32(const uint8_t **buf, uint32_t *len, float *out)
225{
226 if (*len < 4) {
227 return 0;
228 }
229
230#if __BYTE_ORDER == __LITTLE_ENDIAN
231 *((uint8_t *)out + 0) = (*buf)[0];
232 *((uint8_t *)out + 1) = (*buf)[1];
233 *((uint8_t *)out + 2) = (*buf)[2];
234 *((uint8_t *)out + 3) = (*buf)[3];
235#else
236 *((uint8_t *)out + 3) = (*buf)[0];
237 *((uint8_t *)out + 2) = (*buf)[1];
238 *((uint8_t *)out + 1) = (*buf)[2];
239 *((uint8_t *)out + 0) = (*buf)[3];
240#endif
241 *len -= 4;
242 *buf += 4;
243
244 return 1;
245}
246
247/**
248 * \brief Read a 64 bit float from a buffer.
249 *
250 * Reads an 64 bit float from a buffer advancing the pointer and
251 * decrementing the length.
252 *
253 * \param buf A pointer to the buffer to read from.
254 * \param len A pointer to the buffer length.
255 * \param out A pointer to where the value will be stored.
256 *
257 * \retval Returns 1 if there was enough space in the buffer to read from,
258 * otherwise 0 is returned.
259 */
260static int DNP3ReadFloat64(const uint8_t **buf, uint32_t *len, double *out)
261{
262 if (*len < 8) {
263 return 0;
264 }
265
266#if __BYTE_ORDER == __LITTLE_ENDIAN
267 *((uint8_t *)out + 0) = (*buf)[0];
268 *((uint8_t *)out + 1) = (*buf)[1];
269 *((uint8_t *)out + 2) = (*buf)[2];
270 *((uint8_t *)out + 3) = (*buf)[3];
271 *((uint8_t *)out + 4) = (*buf)[4];
272 *((uint8_t *)out + 5) = (*buf)[5];
273 *((uint8_t *)out + 6) = (*buf)[6];
274 *((uint8_t *)out + 7) = (*buf)[7];
275#else
276 *((uint8_t *)out + 7) = (*buf)[0];
277 *((uint8_t *)out + 6) = (*buf)[1];
278 *((uint8_t *)out + 5) = (*buf)[2];
279 *((uint8_t *)out + 4) = (*buf)[3];
280 *((uint8_t *)out + 3) = (*buf)[4];
281 *((uint8_t *)out + 2) = (*buf)[5];
282 *((uint8_t *)out + 1) = (*buf)[6];
283 *((uint8_t *)out + 0) = (*buf)[7];
284#endif
285 *len -= 8;
286 *buf += 8;
287
288 return 1;
289}
290
291/**
292 * \brief Get the prefix value and advance the buffer.
293 */
294static int DNP3ReadPrefix(
295 const uint8_t **buf, uint32_t *len, uint8_t prefix_code, uint32_t *out)
296{
297 uint8_t prefix_len = 0;
298
299 switch (prefix_code) {
300 case 0x01:
301 case 0x04:
302 prefix_len = 1;
303 break;
304 case 0x02:
305 case 0x05:
306 prefix_len = 2;
307 break;
308 case 0x03:
309 case 0x06:
310 prefix_len = 4;
311 default:
312 break;
313 }
314
315 if (*len < (uint32_t)prefix_len) {
316 return 0;
317 }
318
319 switch (prefix_len) {
320 case sizeof(uint32_t):
321 DNP3ReadUint32(buf, len, out);
322 break;
323 case sizeof(uint16_t): {
324 /* Temp value for strict-aliasing. */
325 uint16_t val = 0;
326 DNP3ReadUint16(buf, len, &val);
327 *out = val;
328 break;
329 }
330 case sizeof(uint8_t): {
331 /* Temp value for strict-aliasing. */
332 uint8_t val = 0;
333 DNP3ReadUint8(buf, len, &val);
334 *out = val;
335 break;
336 }
337 default:
338 *out = 0;
339 break;
340 }
341
342 return 1;
343}
344
345/**
346 * \brief Add an object to a DNP3PointList.
347 *
348 * \retval 1 if successfull, 0 on failure.
349 */
350static int DNP3AddPoint(DNP3PointList *list, void *object, uint32_t index,
351 uint8_t prefix_code, uint32_t prefix)
352{
353 DNP3Point *point = SCCalloc(1, sizeof(*point));
354 if (unlikely(point == NULL)) {
355 return 0;
356 }
357 TAILQ_INSERT_TAIL(list, point, next);
358 point->data = object;
359 point->prefix = prefix;
360 point->index = index;
361 switch (prefix_code) {
362 case 0x00:
363 break;
364 case 0x01:
365 case 0x02:
366 case 0x03:
367 point->index = prefix;
368 break;
369 case 0x04:
370 case 0x05:
371 case 0x06:
372 point->size = prefix;
373 break;
374 default:
375 break;
376 }
377
378 return 1;
379}
380
381/* START GENERATED CODE */
382
383/* Code generated by:
384 * ./scripts/dnp3-gen/dnp3-gen.py
385 */
386
387static int DNP3DecodeObjectG1V1(const uint8_t **buf, uint32_t *len,
388 uint8_t prefix_code, uint32_t start, uint32_t count,
389 DNP3PointList *points)
390{
391 DNP3ObjectG1V1 *object = NULL;
392 int bytes = (count / 8) + 1;
393 uint32_t prefix = 0;
394 int index = start;
395
396 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
397 goto error;
398 }
399
400 for (int i = 0; i < bytes; i++) {
401
402 uint8_t octet;
403
404 if (!DNP3ReadUint8(buf, len, &octet)) {
405 goto error;
406 }
407
408 for (int j = 0; j < 8 && count; j = j + 1) {
409
410 object = SCCalloc(1, sizeof(*object));
411 if (unlikely(object == NULL)) {
412 goto error;
413 }
414
415 object->state = (octet >> j) & 0x1;
416
417 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
418 goto error;
419 }
420
421 object = NULL;
422 count--;
423 index++;
424 }
425
426 }
427
428 return 1;
429error:
430 if (object != NULL) {
431 SCFree(object);
432 }
433 return 0;
434}
435
436static int DNP3DecodeObjectG1V2(const uint8_t **buf, uint32_t *len,
437 uint8_t prefix_code, uint32_t start, uint32_t count,
438 DNP3PointList *points)
439{
440 DNP3ObjectG1V2 *object = NULL;
441 uint32_t prefix = 0;
442 uint32_t index = start;
443
444 while (count--) {
445
446 object = SCCalloc(1, sizeof(*object));
447 if (unlikely(object == NULL)) {
448 goto error;
449 }
450
451 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
452 goto error;
453 }
454
455 {
456 uint8_t octet;
457 if (!DNP3ReadUint8(buf, len, &octet)) {
458 goto error;
459 }
460 object->online = (octet >> 0) & 0x1;
461 object->restart = (octet >> 1) & 0x1;
462 object->comm_lost = (octet >> 2) & 0x1;
463 object->remote_forced = (octet >> 3) & 0x1;
464 object->local_forced = (octet >> 4) & 0x1;
465 object->chatter_filter = (octet >> 5) & 0x1;
466 object->reserved = (octet >> 6) & 0x1;
467 object->state = (octet >> 7) & 0x1;
468 }
469
470 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
471 goto error;
472 }
473
474 object = NULL;
475 index++;
476 }
477
478 return 1;
479error:
480 if (object != NULL) {
481 SCFree(object);
482 }
483
484 return 0;
485}
486
487static int DNP3DecodeObjectG2V1(const uint8_t **buf, uint32_t *len,
488 uint8_t prefix_code, uint32_t start, uint32_t count,
489 DNP3PointList *points)
490{
491 DNP3ObjectG2V1 *object = NULL;
492 uint32_t prefix = 0;
493 uint32_t index = start;
494
495 while (count--) {
496
497 object = SCCalloc(1, sizeof(*object));
498 if (unlikely(object == NULL)) {
499 goto error;
500 }
501
502 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
503 goto error;
504 }
505
506 if (!DNP3ReadUint8(buf, len, &object->state)) {
507 goto error;
508 }
509
510 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
511 goto error;
512 }
513
514 object = NULL;
515 index++;
516 }
517
518 return 1;
519error:
520 if (object != NULL) {
521 SCFree(object);
522 }
523
524 return 0;
525}
526
527static int DNP3DecodeObjectG2V2(const uint8_t **buf, uint32_t *len,
528 uint8_t prefix_code, uint32_t start, uint32_t count,
529 DNP3PointList *points)
530{
531 DNP3ObjectG2V2 *object = NULL;
532 uint32_t prefix = 0;
533 uint32_t index = start;
534
535 while (count--) {
536
537 object = SCCalloc(1, sizeof(*object));
538 if (unlikely(object == NULL)) {
539 goto error;
540 }
541
542 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
543 goto error;
544 }
545
546 {
547 uint8_t octet;
548 if (!DNP3ReadUint8(buf, len, &octet)) {
549 goto error;
550 }
551 object->online = (octet >> 0) & 0x1;
552 object->restart = (octet >> 1) & 0x1;
553 object->comm_lost = (octet >> 2) & 0x1;
554 object->remote_forced = (octet >> 3) & 0x1;
555 object->local_forced = (octet >> 4) & 0x1;
556 object->chatter_filter = (octet >> 5) & 0x1;
557 object->reserved = (octet >> 6) & 0x1;
558 object->state = (octet >> 7) & 0x1;
559 }
560 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
561 goto error;
562 }
563
564 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
565 goto error;
566 }
567
568 object = NULL;
569 index++;
570 }
571
572 return 1;
573error:
574 if (object != NULL) {
575 SCFree(object);
576 }
577
578 return 0;
579}
580
581static int DNP3DecodeObjectG2V3(const uint8_t **buf, uint32_t *len,
582 uint8_t prefix_code, uint32_t start, uint32_t count,
583 DNP3PointList *points)
584{
585 DNP3ObjectG2V3 *object = NULL;
586 uint32_t prefix = 0;
587 uint32_t index = start;
588
589 while (count--) {
590
591 object = SCCalloc(1, sizeof(*object));
592 if (unlikely(object == NULL)) {
593 goto error;
594 }
595
596 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
597 goto error;
598 }
599
600 {
601 uint8_t octet;
602 if (!DNP3ReadUint8(buf, len, &octet)) {
603 goto error;
604 }
605 object->online = (octet >> 0) & 0x1;
606 object->restart = (octet >> 1) & 0x1;
607 object->comm_lost = (octet >> 2) & 0x1;
608 object->remote_forced = (octet >> 3) & 0x1;
609 object->local_forced = (octet >> 4) & 0x1;
610 object->chatter_filter = (octet >> 5) & 0x1;
611 object->reserved = (octet >> 6) & 0x1;
612 object->state = (octet >> 7) & 0x1;
613 }
614 if (!DNP3ReadUint16(buf, len, &object->timestamp)) {
615 goto error;
616 }
617
618 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
619 goto error;
620 }
621
622 object = NULL;
623 index++;
624 }
625
626 return 1;
627error:
628 if (object != NULL) {
629 SCFree(object);
630 }
631
632 return 0;
633}
634
635static int DNP3DecodeObjectG3V1(const uint8_t **buf, uint32_t *len,
636 uint8_t prefix_code, uint32_t start, uint32_t count,
637 DNP3PointList *points)
638{
639 DNP3ObjectG3V1 *object = NULL;
640 int bytes = (count / 8) + 1;
641 uint32_t prefix = 0;
642 int index = start;
643
644 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
645 goto error;
646 }
647
648 for (int i = 0; i < bytes; i++) {
649
650 uint8_t octet;
651
652 if (!DNP3ReadUint8(buf, len, &octet)) {
653 goto error;
654 }
655
656 for (int j = 0; j < 8 && count; j = j + 2) {
657
658 object = SCCalloc(1, sizeof(*object));
659 if (unlikely(object == NULL)) {
660 goto error;
661 }
662
663 object->state = (octet >> j) & 0x3;
664
665 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
666 goto error;
667 }
668
669 object = NULL;
670 count--;
671 index++;
672 }
673
674 }
675
676 return 1;
677error:
678 if (object != NULL) {
679 SCFree(object);
680 }
681 return 0;
682}
683
684static int DNP3DecodeObjectG3V2(const uint8_t **buf, uint32_t *len,
685 uint8_t prefix_code, uint32_t start, uint32_t count,
686 DNP3PointList *points)
687{
688 DNP3ObjectG3V2 *object = NULL;
689 uint32_t prefix = 0;
690 uint32_t index = start;
691
692 while (count--) {
693
694 object = SCCalloc(1, sizeof(*object));
695 if (unlikely(object == NULL)) {
696 goto error;
697 }
698
699 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
700 goto error;
701 }
702
703 {
704 uint8_t octet;
705 if (!DNP3ReadUint8(buf, len, &octet)) {
706 goto error;
707 }
708 object->online = (octet >> 0) & 0x1;
709 object->restart = (octet >> 1) & 0x1;
710 object->comm_lost = (octet >> 2) & 0x1;
711 object->remote_forced = (octet >> 3) & 0x1;
712 object->local_forced = (octet >> 4) & 0x1;
713 object->chatter_filter = (octet >> 5) & 0x1;
714 object->state = (octet >> 6) & 0x3;
715 }
716
717 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
718 goto error;
719 }
720
721 object = NULL;
722 index++;
723 }
724
725 return 1;
726error:
727 if (object != NULL) {
728 SCFree(object);
729 }
730
731 return 0;
732}
733
734static int DNP3DecodeObjectG4V1(const uint8_t **buf, uint32_t *len,
735 uint8_t prefix_code, uint32_t start, uint32_t count,
736 DNP3PointList *points)
737{
738 DNP3ObjectG4V1 *object = NULL;
739 uint32_t prefix = 0;
740 uint32_t index = start;
741
742 while (count--) {
743
744 object = SCCalloc(1, sizeof(*object));
745 if (unlikely(object == NULL)) {
746 goto error;
747 }
748
749 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
750 goto error;
751 }
752
753 {
754 uint8_t octet;
755 if (!DNP3ReadUint8(buf, len, &octet)) {
756 goto error;
757 }
758 object->online = (octet >> 0) & 0x1;
759 object->restart = (octet >> 1) & 0x1;
760 object->comm_lost = (octet >> 2) & 0x1;
761 object->remote_forced = (octet >> 3) & 0x1;
762 object->local_forced = (octet >> 4) & 0x1;
763 object->chatter_filter = (octet >> 5) & 0x1;
764 object->state = (octet >> 6) & 0x3;
765 }
766
767 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
768 goto error;
769 }
770
771 object = NULL;
772 index++;
773 }
774
775 return 1;
776error:
777 if (object != NULL) {
778 SCFree(object);
779 }
780
781 return 0;
782}
783
784static int DNP3DecodeObjectG4V2(const uint8_t **buf, uint32_t *len,
785 uint8_t prefix_code, uint32_t start, uint32_t count,
786 DNP3PointList *points)
787{
788 DNP3ObjectG4V2 *object = NULL;
789 uint32_t prefix = 0;
790 uint32_t index = start;
791
792 while (count--) {
793
794 object = SCCalloc(1, sizeof(*object));
795 if (unlikely(object == NULL)) {
796 goto error;
797 }
798
799 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
800 goto error;
801 }
802
803 {
804 uint8_t octet;
805 if (!DNP3ReadUint8(buf, len, &octet)) {
806 goto error;
807 }
808 object->online = (octet >> 0) & 0x1;
809 object->restart = (octet >> 1) & 0x1;
810 object->comm_lost = (octet >> 2) & 0x1;
811 object->remote_forced = (octet >> 3) & 0x1;
812 object->local_forced = (octet >> 4) & 0x1;
813 object->chatter_filter = (octet >> 5) & 0x1;
814 object->state = (octet >> 6) & 0x3;
815 }
816 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
817 goto error;
818 }
819
820 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
821 goto error;
822 }
823
824 object = NULL;
825 index++;
826 }
827
828 return 1;
829error:
830 if (object != NULL) {
831 SCFree(object);
832 }
833
834 return 0;
835}
836
837static int DNP3DecodeObjectG4V3(const uint8_t **buf, uint32_t *len,
838 uint8_t prefix_code, uint32_t start, uint32_t count,
839 DNP3PointList *points)
840{
841 DNP3ObjectG4V3 *object = NULL;
842 uint32_t prefix = 0;
843 uint32_t index = start;
844
845 while (count--) {
846
847 object = SCCalloc(1, sizeof(*object));
848 if (unlikely(object == NULL)) {
849 goto error;
850 }
851
852 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
853 goto error;
854 }
855
856 {
857 uint8_t octet;
858 if (!DNP3ReadUint8(buf, len, &octet)) {
859 goto error;
860 }
861 object->online = (octet >> 0) & 0x1;
862 object->restart = (octet >> 1) & 0x1;
863 object->comm_lost = (octet >> 2) & 0x1;
864 object->remote_forced = (octet >> 3) & 0x1;
865 object->local_forced = (octet >> 4) & 0x1;
866 object->chatter_filter = (octet >> 5) & 0x1;
867 object->state = (octet >> 6) & 0x3;
868 }
869 if (!DNP3ReadUint16(buf, len, &object->relative_time_ms)) {
870 goto error;
871 }
872
873 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
874 goto error;
875 }
876
877 object = NULL;
878 index++;
879 }
880
881 return 1;
882error:
883 if (object != NULL) {
884 SCFree(object);
885 }
886
887 return 0;
888}
889
890static int DNP3DecodeObjectG10V1(const uint8_t **buf, uint32_t *len,
891 uint8_t prefix_code, uint32_t start, uint32_t count,
892 DNP3PointList *points)
893{
894 DNP3ObjectG10V1 *object = NULL;
895 int bytes = (count / 8) + 1;
896 uint32_t prefix = 0;
897 int index = start;
898
899 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
900 goto error;
901 }
902
903 for (int i = 0; i < bytes; i++) {
904
905 uint8_t octet;
906
907 if (!DNP3ReadUint8(buf, len, &octet)) {
908 goto error;
909 }
910
911 for (int j = 0; j < 8 && count; j = j + 1) {
912
913 object = SCCalloc(1, sizeof(*object));
914 if (unlikely(object == NULL)) {
915 goto error;
916 }
917
918 object->state = (octet >> j) & 0x1;
919
920 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
921 goto error;
922 }
923
924 object = NULL;
925 count--;
926 index++;
927 }
928
929 }
930
931 return 1;
932error:
933 if (object != NULL) {
934 SCFree(object);
935 }
936 return 0;
937}
938
939static int DNP3DecodeObjectG10V2(const uint8_t **buf, uint32_t *len,
940 uint8_t prefix_code, uint32_t start, uint32_t count,
941 DNP3PointList *points)
942{
943 DNP3ObjectG10V2 *object = NULL;
944 uint32_t prefix = 0;
945 uint32_t index = start;
946
947 while (count--) {
948
949 object = SCCalloc(1, sizeof(*object));
950 if (unlikely(object == NULL)) {
951 goto error;
952 }
953
954 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
955 goto error;
956 }
957
958 {
959 uint8_t octet;
960 if (!DNP3ReadUint8(buf, len, &octet)) {
961 goto error;
962 }
963 object->online = (octet >> 0) & 0x1;
964 object->restart = (octet >> 1) & 0x1;
965 object->comm_lost = (octet >> 2) & 0x1;
966 object->remote_forced = (octet >> 3) & 0x1;
967 object->local_forced = (octet >> 4) & 0x1;
968 object->reserved0 = (octet >> 5) & 0x1;
969 object->reserved1 = (octet >> 6) & 0x1;
970 object->state = (octet >> 7) & 0x1;
971 }
972
973 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
974 goto error;
975 }
976
977 object = NULL;
978 index++;
979 }
980
981 return 1;
982error:
983 if (object != NULL) {
984 SCFree(object);
985 }
986
987 return 0;
988}
989
990static int DNP3DecodeObjectG11V1(const uint8_t **buf, uint32_t *len,
991 uint8_t prefix_code, uint32_t start, uint32_t count,
992 DNP3PointList *points)
993{
994 DNP3ObjectG11V1 *object = NULL;
995 uint32_t prefix = 0;
996 uint32_t index = start;
997
998 while (count--) {
999
1000 object = SCCalloc(1, sizeof(*object));
1001 if (unlikely(object == NULL)) {
1002 goto error;
1003 }
1004
1005 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1006 goto error;
1007 }
1008
1009 {
1010 uint8_t octet;
1011 if (!DNP3ReadUint8(buf, len, &octet)) {
1012 goto error;
1013 }
1014 object->online = (octet >> 0) & 0x1;
1015 object->restart = (octet >> 1) & 0x1;
1016 object->comm_lost = (octet >> 2) & 0x1;
1017 object->remote_forced = (octet >> 3) & 0x1;
1018 object->local_forced = (octet >> 4) & 0x1;
1019 object->reserved0 = (octet >> 5) & 0x1;
1020 object->reserved1 = (octet >> 6) & 0x1;
1021 object->state = (octet >> 7) & 0x1;
1022 }
1023
1024 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1025 goto error;
1026 }
1027
1028 object = NULL;
1029 index++;
1030 }
1031
1032 return 1;
1033error:
1034 if (object != NULL) {
1035 SCFree(object);
1036 }
1037
1038 return 0;
1039}
1040
1041static int DNP3DecodeObjectG11V2(const uint8_t **buf, uint32_t *len,
1042 uint8_t prefix_code, uint32_t start, uint32_t count,
1043 DNP3PointList *points)
1044{
1045 DNP3ObjectG11V2 *object = NULL;
1046 uint32_t prefix = 0;
1047 uint32_t index = start;
1048
1049 while (count--) {
1050
1051 object = SCCalloc(1, sizeof(*object));
1052 if (unlikely(object == NULL)) {
1053 goto error;
1054 }
1055
1056 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1057 goto error;
1058 }
1059
1060 {
1061 uint8_t octet;
1062 if (!DNP3ReadUint8(buf, len, &octet)) {
1063 goto error;
1064 }
1065 object->online = (octet >> 0) & 0x1;
1066 object->restart = (octet >> 1) & 0x1;
1067 object->comm_lost = (octet >> 2) & 0x1;
1068 object->remote_forced = (octet >> 3) & 0x1;
1069 object->local_forced = (octet >> 4) & 0x1;
1070 object->reserved0 = (octet >> 5) & 0x1;
1071 object->reserved1 = (octet >> 6) & 0x1;
1072 object->state = (octet >> 7) & 0x1;
1073 }
1074 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
1075 goto error;
1076 }
1077
1078 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1079 goto error;
1080 }
1081
1082 object = NULL;
1083 index++;
1084 }
1085
1086 return 1;
1087error:
1088 if (object != NULL) {
1089 SCFree(object);
1090 }
1091
1092 return 0;
1093}
1094
1095static int DNP3DecodeObjectG12V1(const uint8_t **buf, uint32_t *len,
1096 uint8_t prefix_code, uint32_t start, uint32_t count,
1097 DNP3PointList *points)
1098{
1099 DNP3ObjectG12V1 *object = NULL;
1100 uint32_t prefix = 0;
1101 uint32_t index = start;
1102
1103 while (count--) {
1104
1105 object = SCCalloc(1, sizeof(*object));
1106 if (unlikely(object == NULL)) {
1107 goto error;
1108 }
1109
1110 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1111 goto error;
1112 }
1113
1114 {
1115 uint8_t octet;
1116 if (!DNP3ReadUint8(buf, len, &octet)) {
1117 goto error;
1118 }
1119 object->op_type = (octet >> 0) & 0xf;
1120 object->qu = (octet >> 4) & 0x1;
1121 object->cr = (octet >> 5) & 0x1;
1122 object->tcc = (octet >> 6) & 0x3;
1123 }
1124 if (!DNP3ReadUint8(buf, len, &object->count)) {
1125 goto error;
1126 }
1127 if (!DNP3ReadUint32(buf, len, &object->ontime)) {
1128 goto error;
1129 }
1130 if (!DNP3ReadUint32(buf, len, &object->offtime)) {
1131 goto error;
1132 }
1133 {
1134 uint8_t octet;
1135 if (!DNP3ReadUint8(buf, len, &octet)) {
1136 goto error;
1137 }
1138 object->status_code = (octet >> 0) & 0x7f;
1139 object->reserved = (octet >> 7) & 0x1;
1140 }
1141
1142 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1143 goto error;
1144 }
1145
1146 object = NULL;
1147 index++;
1148 }
1149
1150 return 1;
1151error:
1152 if (object != NULL) {
1153 SCFree(object);
1154 }
1155
1156 return 0;
1157}
1158
1159static int DNP3DecodeObjectG12V2(const uint8_t **buf, uint32_t *len,
1160 uint8_t prefix_code, uint32_t start, uint32_t count,
1161 DNP3PointList *points)
1162{
1163 DNP3ObjectG12V2 *object = NULL;
1164 uint32_t prefix = 0;
1165 uint32_t index = start;
1166
1167 while (count--) {
1168
1169 object = SCCalloc(1, sizeof(*object));
1170 if (unlikely(object == NULL)) {
1171 goto error;
1172 }
1173
1174 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1175 goto error;
1176 }
1177
1178 {
1179 uint8_t octet;
1180 if (!DNP3ReadUint8(buf, len, &octet)) {
1181 goto error;
1182 }
1183 object->op_type = (octet >> 0) & 0xf;
1184 object->qu = (octet >> 4) & 0x1;
1185 object->cr = (octet >> 5) & 0x1;
1186 object->tcc = (octet >> 6) & 0x3;
1187 }
1188 if (!DNP3ReadUint8(buf, len, &object->count)) {
1189 goto error;
1190 }
1191 if (!DNP3ReadUint32(buf, len, &object->ontime)) {
1192 goto error;
1193 }
1194 if (!DNP3ReadUint32(buf, len, &object->offtime)) {
1195 goto error;
1196 }
1197 {
1198 uint8_t octet;
1199 if (!DNP3ReadUint8(buf, len, &octet)) {
1200 goto error;
1201 }
1202 object->status_code = (octet >> 0) & 0x7f;
1203 object->reserved = (octet >> 7) & 0x1;
1204 }
1205
1206 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1207 goto error;
1208 }
1209
1210 object = NULL;
1211 index++;
1212 }
1213
1214 return 1;
1215error:
1216 if (object != NULL) {
1217 SCFree(object);
1218 }
1219
1220 return 0;
1221}
1222
1223static int DNP3DecodeObjectG12V3(const uint8_t **buf, uint32_t *len,
1224 uint8_t prefix_code, uint32_t start, uint32_t count,
1225 DNP3PointList *points)
1226{
1227 DNP3ObjectG12V3 *object = NULL;
1228 int bytes = (count / 8) + 1;
1229 uint32_t prefix = 0;
1230 int index = start;
1231
1232 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1233 goto error;
1234 }
1235
1236 for (int i = 0; i < bytes; i++) {
1237
1238 uint8_t octet;
1239
1240 if (!DNP3ReadUint8(buf, len, &octet)) {
1241 goto error;
1242 }
1243
1244 for (int j = 0; j < 8 && count; j = j + 1) {
1245
1246 object = SCCalloc(1, sizeof(*object));
1247 if (unlikely(object == NULL)) {
1248 goto error;
1249 }
1250
1251 object->point = (octet >> j) & 0x1;
1252
1253 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1254 goto error;
1255 }
1256
1257 object = NULL;
1258 count--;
1259 index++;
1260 }
1261
1262 }
1263
1264 return 1;
1265error:
1266 if (object != NULL) {
1267 SCFree(object);
1268 }
1269 return 0;
1270}
1271
1272static int DNP3DecodeObjectG13V1(const uint8_t **buf, uint32_t *len,
1273 uint8_t prefix_code, uint32_t start, uint32_t count,
1274 DNP3PointList *points)
1275{
1276 DNP3ObjectG13V1 *object = NULL;
1277 uint32_t prefix = 0;
1278 uint32_t index = start;
1279
1280 while (count--) {
1281
1282 object = SCCalloc(1, sizeof(*object));
1283 if (unlikely(object == NULL)) {
1284 goto error;
1285 }
1286
1287 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1288 goto error;
1289 }
1290
1291 {
1292 uint8_t octet;
1293 if (!DNP3ReadUint8(buf, len, &octet)) {
1294 goto error;
1295 }
1296 object->status_code = (octet >> 0) & 0x7f;
1297 object->commanded_state = (octet >> 7) & 0x1;
1298 }
1299
1300 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1301 goto error;
1302 }
1303
1304 object = NULL;
1305 index++;
1306 }
1307
1308 return 1;
1309error:
1310 if (object != NULL) {
1311 SCFree(object);
1312 }
1313
1314 return 0;
1315}
1316
1317static int DNP3DecodeObjectG13V2(const uint8_t **buf, uint32_t *len,
1318 uint8_t prefix_code, uint32_t start, uint32_t count,
1319 DNP3PointList *points)
1320{
1321 DNP3ObjectG13V2 *object = NULL;
1322 uint32_t prefix = 0;
1323 uint32_t index = start;
1324
1325 while (count--) {
1326
1327 object = SCCalloc(1, sizeof(*object));
1328 if (unlikely(object == NULL)) {
1329 goto error;
1330 }
1331
1332 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1333 goto error;
1334 }
1335
1336 {
1337 uint8_t octet;
1338 if (!DNP3ReadUint8(buf, len, &octet)) {
1339 goto error;
1340 }
1341 object->status_code = (octet >> 0) & 0x7f;
1342 object->commanded_state = (octet >> 7) & 0x1;
1343 }
1344 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
1345 goto error;
1346 }
1347
1348 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1349 goto error;
1350 }
1351
1352 object = NULL;
1353 index++;
1354 }
1355
1356 return 1;
1357error:
1358 if (object != NULL) {
1359 SCFree(object);
1360 }
1361
1362 return 0;
1363}
1364
1365static int DNP3DecodeObjectG20V1(const uint8_t **buf, uint32_t *len,
1366 uint8_t prefix_code, uint32_t start, uint32_t count,
1367 DNP3PointList *points)
1368{
1369 DNP3ObjectG20V1 *object = NULL;
1370 uint32_t prefix = 0;
1371 uint32_t index = start;
1372
1373 while (count--) {
1374
1375 object = SCCalloc(1, sizeof(*object));
1376 if (unlikely(object == NULL)) {
1377 goto error;
1378 }
1379
1380 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1381 goto error;
1382 }
1383
1384 {
1385 uint8_t octet;
1386 if (!DNP3ReadUint8(buf, len, &octet)) {
1387 goto error;
1388 }
1389 object->online = (octet >> 0) & 0x1;
1390 object->restart = (octet >> 1) & 0x1;
1391 object->comm_lost = (octet >> 2) & 0x1;
1392 object->remote_forced = (octet >> 3) & 0x1;
1393 object->local_forced = (octet >> 4) & 0x1;
1394 object->rollover = (octet >> 5) & 0x1;
1395 object->discontinuity = (octet >> 6) & 0x1;
1396 object->reserved0 = (octet >> 7) & 0x1;
1397 }
1398 if (!DNP3ReadUint32(buf, len, &object->count)) {
1399 goto error;
1400 }
1401
1402 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1403 goto error;
1404 }
1405
1406 object = NULL;
1407 index++;
1408 }
1409
1410 return 1;
1411error:
1412 if (object != NULL) {
1413 SCFree(object);
1414 }
1415
1416 return 0;
1417}
1418
1419static int DNP3DecodeObjectG20V2(const uint8_t **buf, uint32_t *len,
1420 uint8_t prefix_code, uint32_t start, uint32_t count,
1421 DNP3PointList *points)
1422{
1423 DNP3ObjectG20V2 *object = NULL;
1424 uint32_t prefix = 0;
1425 uint32_t index = start;
1426
1427 while (count--) {
1428
1429 object = SCCalloc(1, sizeof(*object));
1430 if (unlikely(object == NULL)) {
1431 goto error;
1432 }
1433
1434 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1435 goto error;
1436 }
1437
1438 {
1439 uint8_t octet;
1440 if (!DNP3ReadUint8(buf, len, &octet)) {
1441 goto error;
1442 }
1443 object->online = (octet >> 0) & 0x1;
1444 object->restart = (octet >> 1) & 0x1;
1445 object->comm_lost = (octet >> 2) & 0x1;
1446 object->remote_forced = (octet >> 3) & 0x1;
1447 object->local_forced = (octet >> 4) & 0x1;
1448 object->rollover = (octet >> 5) & 0x1;
1449 object->discontinuity = (octet >> 6) & 0x1;
1450 object->reserved0 = (octet >> 7) & 0x1;
1451 }
1452 if (!DNP3ReadUint16(buf, len, &object->count)) {
1453 goto error;
1454 }
1455
1456 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1457 goto error;
1458 }
1459
1460 object = NULL;
1461 index++;
1462 }
1463
1464 return 1;
1465error:
1466 if (object != NULL) {
1467 SCFree(object);
1468 }
1469
1470 return 0;
1471}
1472
1473static int DNP3DecodeObjectG20V3(const uint8_t **buf, uint32_t *len,
1474 uint8_t prefix_code, uint32_t start, uint32_t count,
1475 DNP3PointList *points)
1476{
1477 DNP3ObjectG20V3 *object = NULL;
1478 uint32_t prefix = 0;
1479 uint32_t index = start;
1480
1481 while (count--) {
1482
1483 object = SCCalloc(1, sizeof(*object));
1484 if (unlikely(object == NULL)) {
1485 goto error;
1486 }
1487
1488 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1489 goto error;
1490 }
1491
1492 {
1493 uint8_t octet;
1494 if (!DNP3ReadUint8(buf, len, &octet)) {
1495 goto error;
1496 }
1497 object->online = (octet >> 0) & 0x1;
1498 object->restart = (octet >> 1) & 0x1;
1499 object->comm_lost = (octet >> 2) & 0x1;
1500 object->remote_forced = (octet >> 3) & 0x1;
1501 object->local_forced = (octet >> 4) & 0x1;
1502 object->rollover = (octet >> 5) & 0x1;
1503 object->reserved0 = (octet >> 6) & 0x1;
1504 object->reserved1 = (octet >> 7) & 0x1;
1505 }
1506 if (!DNP3ReadUint32(buf, len, &object->count)) {
1507 goto error;
1508 }
1509
1510 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1511 goto error;
1512 }
1513
1514 object = NULL;
1515 index++;
1516 }
1517
1518 return 1;
1519error:
1520 if (object != NULL) {
1521 SCFree(object);
1522 }
1523
1524 return 0;
1525}
1526
1527static int DNP3DecodeObjectG20V4(const uint8_t **buf, uint32_t *len,
1528 uint8_t prefix_code, uint32_t start, uint32_t count,
1529 DNP3PointList *points)
1530{
1531 DNP3ObjectG20V4 *object = NULL;
1532 uint32_t prefix = 0;
1533 uint32_t index = start;
1534
1535 while (count--) {
1536
1537 object = SCCalloc(1, sizeof(*object));
1538 if (unlikely(object == NULL)) {
1539 goto error;
1540 }
1541
1542 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1543 goto error;
1544 }
1545
1546 {
1547 uint8_t octet;
1548 if (!DNP3ReadUint8(buf, len, &octet)) {
1549 goto error;
1550 }
1551 object->online = (octet >> 0) & 0x1;
1552 object->restart = (octet >> 1) & 0x1;
1553 object->comm_lost = (octet >> 2) & 0x1;
1554 object->remote_forced = (octet >> 3) & 0x1;
1555 object->local_forced = (octet >> 4) & 0x1;
1556 object->rollover = (octet >> 5) & 0x1;
1557 object->reserved0 = (octet >> 6) & 0x1;
1558 object->reserved1 = (octet >> 7) & 0x1;
1559 }
1560 if (!DNP3ReadUint16(buf, len, &object->count)) {
1561 goto error;
1562 }
1563
1564 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1565 goto error;
1566 }
1567
1568 object = NULL;
1569 index++;
1570 }
1571
1572 return 1;
1573error:
1574 if (object != NULL) {
1575 SCFree(object);
1576 }
1577
1578 return 0;
1579}
1580
1581static int DNP3DecodeObjectG20V5(const uint8_t **buf, uint32_t *len,
1582 uint8_t prefix_code, uint32_t start, uint32_t count,
1583 DNP3PointList *points)
1584{
1585 DNP3ObjectG20V5 *object = NULL;
1586 uint32_t prefix = 0;
1587 uint32_t index = start;
1588
1589 while (count--) {
1590
1591 object = SCCalloc(1, sizeof(*object));
1592 if (unlikely(object == NULL)) {
1593 goto error;
1594 }
1595
1596 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1597 goto error;
1598 }
1599
1600 if (!DNP3ReadUint32(buf, len, &object->count)) {
1601 goto error;
1602 }
1603
1604 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1605 goto error;
1606 }
1607
1608 object = NULL;
1609 index++;
1610 }
1611
1612 return 1;
1613error:
1614 if (object != NULL) {
1615 SCFree(object);
1616 }
1617
1618 return 0;
1619}
1620
1621static int DNP3DecodeObjectG20V6(const uint8_t **buf, uint32_t *len,
1622 uint8_t prefix_code, uint32_t start, uint32_t count,
1623 DNP3PointList *points)
1624{
1625 DNP3ObjectG20V6 *object = NULL;
1626 uint32_t prefix = 0;
1627 uint32_t index = start;
1628
1629 while (count--) {
1630
1631 object = SCCalloc(1, sizeof(*object));
1632 if (unlikely(object == NULL)) {
1633 goto error;
1634 }
1635
1636 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1637 goto error;
1638 }
1639
1640 if (!DNP3ReadUint16(buf, len, &object->count)) {
1641 goto error;
1642 }
1643
1644 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1645 goto error;
1646 }
1647
1648 object = NULL;
1649 index++;
1650 }
1651
1652 return 1;
1653error:
1654 if (object != NULL) {
1655 SCFree(object);
1656 }
1657
1658 return 0;
1659}
1660
1661static int DNP3DecodeObjectG20V7(const uint8_t **buf, uint32_t *len,
1662 uint8_t prefix_code, uint32_t start, uint32_t count,
1663 DNP3PointList *points)
1664{
1665 DNP3ObjectG20V7 *object = NULL;
1666 uint32_t prefix = 0;
1667 uint32_t index = start;
1668
1669 while (count--) {
1670
1671 object = SCCalloc(1, sizeof(*object));
1672 if (unlikely(object == NULL)) {
1673 goto error;
1674 }
1675
1676 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1677 goto error;
1678 }
1679
1680 if (!DNP3ReadUint32(buf, len, &object->count)) {
1681 goto error;
1682 }
1683
1684 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1685 goto error;
1686 }
1687
1688 object = NULL;
1689 index++;
1690 }
1691
1692 return 1;
1693error:
1694 if (object != NULL) {
1695 SCFree(object);
1696 }
1697
1698 return 0;
1699}
1700
1701static int DNP3DecodeObjectG20V8(const uint8_t **buf, uint32_t *len,
1702 uint8_t prefix_code, uint32_t start, uint32_t count,
1703 DNP3PointList *points)
1704{
1705 DNP3ObjectG20V8 *object = NULL;
1706 uint32_t prefix = 0;
1707 uint32_t index = start;
1708
1709 while (count--) {
1710
1711 object = SCCalloc(1, sizeof(*object));
1712 if (unlikely(object == NULL)) {
1713 goto error;
1714 }
1715
1716 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1717 goto error;
1718 }
1719
1720 if (!DNP3ReadUint16(buf, len, &object->count)) {
1721 goto error;
1722 }
1723
1724 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1725 goto error;
1726 }
1727
1728 object = NULL;
1729 index++;
1730 }
1731
1732 return 1;
1733error:
1734 if (object != NULL) {
1735 SCFree(object);
1736 }
1737
1738 return 0;
1739}
1740
1741static int DNP3DecodeObjectG21V1(const uint8_t **buf, uint32_t *len,
1742 uint8_t prefix_code, uint32_t start, uint32_t count,
1743 DNP3PointList *points)
1744{
1745 DNP3ObjectG21V1 *object = NULL;
1746 uint32_t prefix = 0;
1747 uint32_t index = start;
1748
1749 while (count--) {
1750
1751 object = SCCalloc(1, sizeof(*object));
1752 if (unlikely(object == NULL)) {
1753 goto error;
1754 }
1755
1756 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1757 goto error;
1758 }
1759
1760 {
1761 uint8_t octet;
1762 if (!DNP3ReadUint8(buf, len, &octet)) {
1763 goto error;
1764 }
1765 object->online = (octet >> 0) & 0x1;
1766 object->restart = (octet >> 1) & 0x1;
1767 object->comm_lost = (octet >> 2) & 0x1;
1768 object->remote_forced = (octet >> 3) & 0x1;
1769 object->local_forced = (octet >> 4) & 0x1;
1770 object->rollover = (octet >> 5) & 0x1;
1771 object->discontinuity = (octet >> 6) & 0x1;
1772 object->reserved0 = (octet >> 7) & 0x1;
1773 }
1774 if (!DNP3ReadUint32(buf, len, &object->count)) {
1775 goto error;
1776 }
1777
1778 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1779 goto error;
1780 }
1781
1782 object = NULL;
1783 index++;
1784 }
1785
1786 return 1;
1787error:
1788 if (object != NULL) {
1789 SCFree(object);
1790 }
1791
1792 return 0;
1793}
1794
1795static int DNP3DecodeObjectG21V2(const uint8_t **buf, uint32_t *len,
1796 uint8_t prefix_code, uint32_t start, uint32_t count,
1797 DNP3PointList *points)
1798{
1799 DNP3ObjectG21V2 *object = NULL;
1800 uint32_t prefix = 0;
1801 uint32_t index = start;
1802
1803 while (count--) {
1804
1805 object = SCCalloc(1, sizeof(*object));
1806 if (unlikely(object == NULL)) {
1807 goto error;
1808 }
1809
1810 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1811 goto error;
1812 }
1813
1814 {
1815 uint8_t octet;
1816 if (!DNP3ReadUint8(buf, len, &octet)) {
1817 goto error;
1818 }
1819 object->online = (octet >> 0) & 0x1;
1820 object->restart = (octet >> 1) & 0x1;
1821 object->comm_lost = (octet >> 2) & 0x1;
1822 object->remote_forced = (octet >> 3) & 0x1;
1823 object->local_forced = (octet >> 4) & 0x1;
1824 object->rollover = (octet >> 5) & 0x1;
1825 object->discontinuity = (octet >> 6) & 0x1;
1826 object->reserved0 = (octet >> 7) & 0x1;
1827 }
1828 if (!DNP3ReadUint16(buf, len, &object->count)) {
1829 goto error;
1830 }
1831
1832 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1833 goto error;
1834 }
1835
1836 object = NULL;
1837 index++;
1838 }
1839
1840 return 1;
1841error:
1842 if (object != NULL) {
1843 SCFree(object);
1844 }
1845
1846 return 0;
1847}
1848
1849static int DNP3DecodeObjectG21V3(const uint8_t **buf, uint32_t *len,
1850 uint8_t prefix_code, uint32_t start, uint32_t count,
1851 DNP3PointList *points)
1852{
1853 DNP3ObjectG21V3 *object = NULL;
1854 uint32_t prefix = 0;
1855 uint32_t index = start;
1856
1857 while (count--) {
1858
1859 object = SCCalloc(1, sizeof(*object));
1860 if (unlikely(object == NULL)) {
1861 goto error;
1862 }
1863
1864 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1865 goto error;
1866 }
1867
1868 {
1869 uint8_t octet;
1870 if (!DNP3ReadUint8(buf, len, &octet)) {
1871 goto error;
1872 }
1873 object->online = (octet >> 0) & 0x1;
1874 object->restart = (octet >> 1) & 0x1;
1875 object->comm_lost = (octet >> 2) & 0x1;
1876 object->remote_forced = (octet >> 3) & 0x1;
1877 object->local_forced = (octet >> 4) & 0x1;
1878 object->rollover = (octet >> 5) & 0x1;
1879 object->reserved0 = (octet >> 6) & 0x1;
1880 object->reserved1 = (octet >> 7) & 0x1;
1881 }
1882 if (!DNP3ReadUint32(buf, len, &object->count)) {
1883 goto error;
1884 }
1885
1886 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1887 goto error;
1888 }
1889
1890 object = NULL;
1891 index++;
1892 }
1893
1894 return 1;
1895error:
1896 if (object != NULL) {
1897 SCFree(object);
1898 }
1899
1900 return 0;
1901}
1902
1903static int DNP3DecodeObjectG21V4(const uint8_t **buf, uint32_t *len,
1904 uint8_t prefix_code, uint32_t start, uint32_t count,
1905 DNP3PointList *points)
1906{
1907 DNP3ObjectG21V4 *object = NULL;
1908 uint32_t prefix = 0;
1909 uint32_t index = start;
1910
1911 while (count--) {
1912
1913 object = SCCalloc(1, sizeof(*object));
1914 if (unlikely(object == NULL)) {
1915 goto error;
1916 }
1917
1918 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1919 goto error;
1920 }
1921
1922 {
1923 uint8_t octet;
1924 if (!DNP3ReadUint8(buf, len, &octet)) {
1925 goto error;
1926 }
1927 object->online = (octet >> 0) & 0x1;
1928 object->restart = (octet >> 1) & 0x1;
1929 object->comm_lost = (octet >> 2) & 0x1;
1930 object->remote_forced = (octet >> 3) & 0x1;
1931 object->local_forced = (octet >> 4) & 0x1;
1932 object->rollover = (octet >> 5) & 0x1;
1933 object->reserved0 = (octet >> 6) & 0x1;
1934 object->reserved1 = (octet >> 7) & 0x1;
1935 }
1936 if (!DNP3ReadUint16(buf, len, &object->count)) {
1937 goto error;
1938 }
1939
1940 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1941 goto error;
1942 }
1943
1944 object = NULL;
1945 index++;
1946 }
1947
1948 return 1;
1949error:
1950 if (object != NULL) {
1951 SCFree(object);
1952 }
1953
1954 return 0;
1955}
1956
1957static int DNP3DecodeObjectG21V5(const uint8_t **buf, uint32_t *len,
1958 uint8_t prefix_code, uint32_t start, uint32_t count,
1959 DNP3PointList *points)
1960{
1961 DNP3ObjectG21V5 *object = NULL;
1962 uint32_t prefix = 0;
1963 uint32_t index = start;
1964
1965 while (count--) {
1966
1967 object = SCCalloc(1, sizeof(*object));
1968 if (unlikely(object == NULL)) {
1969 goto error;
1970 }
1971
1972 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1973 goto error;
1974 }
1975
1976 {
1977 uint8_t octet;
1978 if (!DNP3ReadUint8(buf, len, &octet)) {
1979 goto error;
1980 }
1981 object->online = (octet >> 0) & 0x1;
1982 object->restart = (octet >> 1) & 0x1;
1983 object->comm_lost = (octet >> 2) & 0x1;
1984 object->remote_forced = (octet >> 3) & 0x1;
1985 object->local_forced = (octet >> 4) & 0x1;
1986 object->rollover = (octet >> 5) & 0x1;
1987 object->discontinuity = (octet >> 6) & 0x1;
1988 object->reserved1 = (octet >> 7) & 0x1;
1989 }
1990 if (!DNP3ReadUint32(buf, len, &object->count)) {
1991 goto error;
1992 }
1993 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
1994 goto error;
1995 }
1996
1997 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
1998 goto error;
1999 }
2000
2001 object = NULL;
2002 index++;
2003 }
2004
2005 return 1;
2006error:
2007 if (object != NULL) {
2008 SCFree(object);
2009 }
2010
2011 return 0;
2012}
2013
2014static int DNP3DecodeObjectG21V6(const uint8_t **buf, uint32_t *len,
2015 uint8_t prefix_code, uint32_t start, uint32_t count,
2016 DNP3PointList *points)
2017{
2018 DNP3ObjectG21V6 *object = NULL;
2019 uint32_t prefix = 0;
2020 uint32_t index = start;
2021
2022 while (count--) {
2023
2024 object = SCCalloc(1, sizeof(*object));
2025 if (unlikely(object == NULL)) {
2026 goto error;
2027 }
2028
2029 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2030 goto error;
2031 }
2032
2033 {
2034 uint8_t octet;
2035 if (!DNP3ReadUint8(buf, len, &octet)) {
2036 goto error;
2037 }
2038 object->online = (octet >> 0) & 0x1;
2039 object->restart = (octet >> 1) & 0x1;
2040 object->comm_lost = (octet >> 2) & 0x1;
2041 object->remote_forced = (octet >> 3) & 0x1;
2042 object->local_forced = (octet >> 4) & 0x1;
2043 object->rollover = (octet >> 5) & 0x1;
2044 object->discontinuity = (octet >> 6) & 0x1;
2045 object->reserved1 = (octet >> 7) & 0x1;
2046 }
2047 if (!DNP3ReadUint16(buf, len, &object->count)) {
2048 goto error;
2049 }
2050 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2051 goto error;
2052 }
2053
2054 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2055 goto error;
2056 }
2057
2058 object = NULL;
2059 index++;
2060 }
2061
2062 return 1;
2063error:
2064 if (object != NULL) {
2065 SCFree(object);
2066 }
2067
2068 return 0;
2069}
2070
2071static int DNP3DecodeObjectG21V7(const uint8_t **buf, uint32_t *len,
2072 uint8_t prefix_code, uint32_t start, uint32_t count,
2073 DNP3PointList *points)
2074{
2075 DNP3ObjectG21V7 *object = NULL;
2076 uint32_t prefix = 0;
2077 uint32_t index = start;
2078
2079 while (count--) {
2080
2081 object = SCCalloc(1, sizeof(*object));
2082 if (unlikely(object == NULL)) {
2083 goto error;
2084 }
2085
2086 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2087 goto error;
2088 }
2089
2090 {
2091 uint8_t octet;
2092 if (!DNP3ReadUint8(buf, len, &octet)) {
2093 goto error;
2094 }
2095 object->online = (octet >> 0) & 0x1;
2096 object->restart = (octet >> 1) & 0x1;
2097 object->comm_lost = (octet >> 2) & 0x1;
2098 object->remote_forced = (octet >> 3) & 0x1;
2099 object->local_forced = (octet >> 4) & 0x1;
2100 object->rollover = (octet >> 5) & 0x1;
2101 object->reserved0 = (octet >> 6) & 0x1;
2102 object->reserved1 = (octet >> 7) & 0x1;
2103 }
2104 if (!DNP3ReadUint32(buf, len, &object->count)) {
2105 goto error;
2106 }
2107 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2108 goto error;
2109 }
2110
2111 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2112 goto error;
2113 }
2114
2115 object = NULL;
2116 index++;
2117 }
2118
2119 return 1;
2120error:
2121 if (object != NULL) {
2122 SCFree(object);
2123 }
2124
2125 return 0;
2126}
2127
2128static int DNP3DecodeObjectG21V8(const uint8_t **buf, uint32_t *len,
2129 uint8_t prefix_code, uint32_t start, uint32_t count,
2130 DNP3PointList *points)
2131{
2132 DNP3ObjectG21V8 *object = NULL;
2133 uint32_t prefix = 0;
2134 uint32_t index = start;
2135
2136 while (count--) {
2137
2138 object = SCCalloc(1, sizeof(*object));
2139 if (unlikely(object == NULL)) {
2140 goto error;
2141 }
2142
2143 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2144 goto error;
2145 }
2146
2147 {
2148 uint8_t octet;
2149 if (!DNP3ReadUint8(buf, len, &octet)) {
2150 goto error;
2151 }
2152 object->online = (octet >> 0) & 0x1;
2153 object->restart = (octet >> 1) & 0x1;
2154 object->comm_lost = (octet >> 2) & 0x1;
2155 object->remote_forced = (octet >> 3) & 0x1;
2156 object->local_forced = (octet >> 4) & 0x1;
2157 object->rollover = (octet >> 5) & 0x1;
2158 object->reserved0 = (octet >> 6) & 0x1;
2159 object->reserved1 = (octet >> 7) & 0x1;
2160 }
2161 if (!DNP3ReadUint16(buf, len, &object->count)) {
2162 goto error;
2163 }
2164 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2165 goto error;
2166 }
2167
2168 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2169 goto error;
2170 }
2171
2172 object = NULL;
2173 index++;
2174 }
2175
2176 return 1;
2177error:
2178 if (object != NULL) {
2179 SCFree(object);
2180 }
2181
2182 return 0;
2183}
2184
2185static int DNP3DecodeObjectG21V9(const uint8_t **buf, uint32_t *len,
2186 uint8_t prefix_code, uint32_t start, uint32_t count,
2187 DNP3PointList *points)
2188{
2189 DNP3ObjectG21V9 *object = NULL;
2190 uint32_t prefix = 0;
2191 uint32_t index = start;
2192
2193 while (count--) {
2194
2195 object = SCCalloc(1, sizeof(*object));
2196 if (unlikely(object == NULL)) {
2197 goto error;
2198 }
2199
2200 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2201 goto error;
2202 }
2203
2204 if (!DNP3ReadUint32(buf, len, &object->count)) {
2205 goto error;
2206 }
2207
2208 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2209 goto error;
2210 }
2211
2212 object = NULL;
2213 index++;
2214 }
2215
2216 return 1;
2217error:
2218 if (object != NULL) {
2219 SCFree(object);
2220 }
2221
2222 return 0;
2223}
2224
2225static int DNP3DecodeObjectG21V10(const uint8_t **buf, uint32_t *len,
2226 uint8_t prefix_code, uint32_t start, uint32_t count,
2227 DNP3PointList *points)
2228{
2229 DNP3ObjectG21V10 *object = NULL;
2230 uint32_t prefix = 0;
2231 uint32_t index = start;
2232
2233 while (count--) {
2234
2235 object = SCCalloc(1, sizeof(*object));
2236 if (unlikely(object == NULL)) {
2237 goto error;
2238 }
2239
2240 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2241 goto error;
2242 }
2243
2244 if (!DNP3ReadUint16(buf, len, &object->count)) {
2245 goto error;
2246 }
2247
2248 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2249 goto error;
2250 }
2251
2252 object = NULL;
2253 index++;
2254 }
2255
2256 return 1;
2257error:
2258 if (object != NULL) {
2259 SCFree(object);
2260 }
2261
2262 return 0;
2263}
2264
2265static int DNP3DecodeObjectG21V11(const uint8_t **buf, uint32_t *len,
2266 uint8_t prefix_code, uint32_t start, uint32_t count,
2267 DNP3PointList *points)
2268{
2269 DNP3ObjectG21V11 *object = NULL;
2270 uint32_t prefix = 0;
2271 uint32_t index = start;
2272
2273 while (count--) {
2274
2275 object = SCCalloc(1, sizeof(*object));
2276 if (unlikely(object == NULL)) {
2277 goto error;
2278 }
2279
2280 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2281 goto error;
2282 }
2283
2284 if (!DNP3ReadUint32(buf, len, &object->count)) {
2285 goto error;
2286 }
2287
2288 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2289 goto error;
2290 }
2291
2292 object = NULL;
2293 index++;
2294 }
2295
2296 return 1;
2297error:
2298 if (object != NULL) {
2299 SCFree(object);
2300 }
2301
2302 return 0;
2303}
2304
2305static int DNP3DecodeObjectG21V12(const uint8_t **buf, uint32_t *len,
2306 uint8_t prefix_code, uint32_t start, uint32_t count,
2307 DNP3PointList *points)
2308{
2309 DNP3ObjectG21V12 *object = NULL;
2310 uint32_t prefix = 0;
2311 uint32_t index = start;
2312
2313 while (count--) {
2314
2315 object = SCCalloc(1, sizeof(*object));
2316 if (unlikely(object == NULL)) {
2317 goto error;
2318 }
2319
2320 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2321 goto error;
2322 }
2323
2324 if (!DNP3ReadUint16(buf, len, &object->count)) {
2325 goto error;
2326 }
2327
2328 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2329 goto error;
2330 }
2331
2332 object = NULL;
2333 index++;
2334 }
2335
2336 return 1;
2337error:
2338 if (object != NULL) {
2339 SCFree(object);
2340 }
2341
2342 return 0;
2343}
2344
2345static int DNP3DecodeObjectG22V1(const uint8_t **buf, uint32_t *len,
2346 uint8_t prefix_code, uint32_t start, uint32_t count,
2347 DNP3PointList *points)
2348{
2349 DNP3ObjectG22V1 *object = NULL;
2350 uint32_t prefix = 0;
2351 uint32_t index = start;
2352
2353 while (count--) {
2354
2355 object = SCCalloc(1, sizeof(*object));
2356 if (unlikely(object == NULL)) {
2357 goto error;
2358 }
2359
2360 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2361 goto error;
2362 }
2363
2364 {
2365 uint8_t octet;
2366 if (!DNP3ReadUint8(buf, len, &octet)) {
2367 goto error;
2368 }
2369 object->online = (octet >> 0) & 0x1;
2370 object->restart = (octet >> 1) & 0x1;
2371 object->comm_lost = (octet >> 2) & 0x1;
2372 object->remote_forced = (octet >> 3) & 0x1;
2373 object->local_forced = (octet >> 4) & 0x1;
2374 object->rollover = (octet >> 5) & 0x1;
2375 object->discontinuity = (octet >> 6) & 0x1;
2376 object->reserved0 = (octet >> 7) & 0x1;
2377 }
2378 if (!DNP3ReadUint32(buf, len, &object->count)) {
2379 goto error;
2380 }
2381
2382 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2383 goto error;
2384 }
2385
2386 object = NULL;
2387 index++;
2388 }
2389
2390 return 1;
2391error:
2392 if (object != NULL) {
2393 SCFree(object);
2394 }
2395
2396 return 0;
2397}
2398
2399static int DNP3DecodeObjectG22V2(const uint8_t **buf, uint32_t *len,
2400 uint8_t prefix_code, uint32_t start, uint32_t count,
2401 DNP3PointList *points)
2402{
2403 DNP3ObjectG22V2 *object = NULL;
2404 uint32_t prefix = 0;
2405 uint32_t index = start;
2406
2407 while (count--) {
2408
2409 object = SCCalloc(1, sizeof(*object));
2410 if (unlikely(object == NULL)) {
2411 goto error;
2412 }
2413
2414 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2415 goto error;
2416 }
2417
2418 {
2419 uint8_t octet;
2420 if (!DNP3ReadUint8(buf, len, &octet)) {
2421 goto error;
2422 }
2423 object->online = (octet >> 0) & 0x1;
2424 object->restart = (octet >> 1) & 0x1;
2425 object->comm_lost = (octet >> 2) & 0x1;
2426 object->remote_forced = (octet >> 3) & 0x1;
2427 object->local_forced = (octet >> 4) & 0x1;
2428 object->rollover = (octet >> 5) & 0x1;
2429 object->discontinuity = (octet >> 6) & 0x1;
2430 object->reserved0 = (octet >> 7) & 0x1;
2431 }
2432 if (!DNP3ReadUint16(buf, len, &object->count)) {
2433 goto error;
2434 }
2435
2436 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2437 goto error;
2438 }
2439
2440 object = NULL;
2441 index++;
2442 }
2443
2444 return 1;
2445error:
2446 if (object != NULL) {
2447 SCFree(object);
2448 }
2449
2450 return 0;
2451}
2452
2453static int DNP3DecodeObjectG22V3(const uint8_t **buf, uint32_t *len,
2454 uint8_t prefix_code, uint32_t start, uint32_t count,
2455 DNP3PointList *points)
2456{
2457 DNP3ObjectG22V3 *object = NULL;
2458 uint32_t prefix = 0;
2459 uint32_t index = start;
2460
2461 while (count--) {
2462
2463 object = SCCalloc(1, sizeof(*object));
2464 if (unlikely(object == NULL)) {
2465 goto error;
2466 }
2467
2468 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2469 goto error;
2470 }
2471
2472 {
2473 uint8_t octet;
2474 if (!DNP3ReadUint8(buf, len, &octet)) {
2475 goto error;
2476 }
2477 object->online = (octet >> 0) & 0x1;
2478 object->restart = (octet >> 1) & 0x1;
2479 object->comm_lost = (octet >> 2) & 0x1;
2480 object->remote_forced = (octet >> 3) & 0x1;
2481 object->local_forced = (octet >> 4) & 0x1;
2482 object->rollover = (octet >> 5) & 0x1;
2483 object->reserved0 = (octet >> 6) & 0x1;
2484 object->reserved1 = (octet >> 7) & 0x1;
2485 }
2486 if (!DNP3ReadUint32(buf, len, &object->count)) {
2487 goto error;
2488 }
2489
2490 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2491 goto error;
2492 }
2493
2494 object = NULL;
2495 index++;
2496 }
2497
2498 return 1;
2499error:
2500 if (object != NULL) {
2501 SCFree(object);
2502 }
2503
2504 return 0;
2505}
2506
2507static int DNP3DecodeObjectG22V4(const uint8_t **buf, uint32_t *len,
2508 uint8_t prefix_code, uint32_t start, uint32_t count,
2509 DNP3PointList *points)
2510{
2511 DNP3ObjectG22V4 *object = NULL;
2512 uint32_t prefix = 0;
2513 uint32_t index = start;
2514
2515 while (count--) {
2516
2517 object = SCCalloc(1, sizeof(*object));
2518 if (unlikely(object == NULL)) {
2519 goto error;
2520 }
2521
2522 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2523 goto error;
2524 }
2525
2526 {
2527 uint8_t octet;
2528 if (!DNP3ReadUint8(buf, len, &octet)) {
2529 goto error;
2530 }
2531 object->online = (octet >> 0) & 0x1;
2532 object->restart = (octet >> 1) & 0x1;
2533 object->comm_lost = (octet >> 2) & 0x1;
2534 object->remote_forced = (octet >> 3) & 0x1;
2535 object->local_forced = (octet >> 4) & 0x1;
2536 object->rollover = (octet >> 5) & 0x1;
2537 object->reserved0 = (octet >> 6) & 0x1;
2538 object->reserved1 = (octet >> 7) & 0x1;
2539 }
2540 if (!DNP3ReadUint16(buf, len, &object->count)) {
2541 goto error;
2542 }
2543
2544 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2545 goto error;
2546 }
2547
2548 object = NULL;
2549 index++;
2550 }
2551
2552 return 1;
2553error:
2554 if (object != NULL) {
2555 SCFree(object);
2556 }
2557
2558 return 0;
2559}
2560
2561static int DNP3DecodeObjectG22V5(const uint8_t **buf, uint32_t *len,
2562 uint8_t prefix_code, uint32_t start, uint32_t count,
2563 DNP3PointList *points)
2564{
2565 DNP3ObjectG22V5 *object = NULL;
2566 uint32_t prefix = 0;
2567 uint32_t index = start;
2568
2569 while (count--) {
2570
2571 object = SCCalloc(1, sizeof(*object));
2572 if (unlikely(object == NULL)) {
2573 goto error;
2574 }
2575
2576 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2577 goto error;
2578 }
2579
2580 {
2581 uint8_t octet;
2582 if (!DNP3ReadUint8(buf, len, &octet)) {
2583 goto error;
2584 }
2585 object->online = (octet >> 0) & 0x1;
2586 object->restart = (octet >> 1) & 0x1;
2587 object->comm_lost = (octet >> 2) & 0x1;
2588 object->remote_forced = (octet >> 3) & 0x1;
2589 object->local_forced = (octet >> 4) & 0x1;
2590 object->rollover = (octet >> 5) & 0x1;
2591 object->reserved0 = (octet >> 6) & 0x1;
2592 object->reserved1 = (octet >> 7) & 0x1;
2593 }
2594 if (!DNP3ReadUint32(buf, len, &object->count)) {
2595 goto error;
2596 }
2597 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2598 goto error;
2599 }
2600
2601 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2602 goto error;
2603 }
2604
2605 object = NULL;
2606 index++;
2607 }
2608
2609 return 1;
2610error:
2611 if (object != NULL) {
2612 SCFree(object);
2613 }
2614
2615 return 0;
2616}
2617
2618static int DNP3DecodeObjectG22V6(const uint8_t **buf, uint32_t *len,
2619 uint8_t prefix_code, uint32_t start, uint32_t count,
2620 DNP3PointList *points)
2621{
2622 DNP3ObjectG22V6 *object = NULL;
2623 uint32_t prefix = 0;
2624 uint32_t index = start;
2625
2626 while (count--) {
2627
2628 object = SCCalloc(1, sizeof(*object));
2629 if (unlikely(object == NULL)) {
2630 goto error;
2631 }
2632
2633 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2634 goto error;
2635 }
2636
2637 {
2638 uint8_t octet;
2639 if (!DNP3ReadUint8(buf, len, &octet)) {
2640 goto error;
2641 }
2642 object->online = (octet >> 0) & 0x1;
2643 object->restart = (octet >> 1) & 0x1;
2644 object->comm_lost = (octet >> 2) & 0x1;
2645 object->remote_forced = (octet >> 3) & 0x1;
2646 object->local_forced = (octet >> 4) & 0x1;
2647 object->rollover = (octet >> 5) & 0x1;
2648 object->discontinuity = (octet >> 6) & 0x1;
2649 object->reserved0 = (octet >> 7) & 0x1;
2650 }
2651 if (!DNP3ReadUint16(buf, len, &object->count)) {
2652 goto error;
2653 }
2654 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2655 goto error;
2656 }
2657
2658 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2659 goto error;
2660 }
2661
2662 object = NULL;
2663 index++;
2664 }
2665
2666 return 1;
2667error:
2668 if (object != NULL) {
2669 SCFree(object);
2670 }
2671
2672 return 0;
2673}
2674
2675static int DNP3DecodeObjectG22V7(const uint8_t **buf, uint32_t *len,
2676 uint8_t prefix_code, uint32_t start, uint32_t count,
2677 DNP3PointList *points)
2678{
2679 DNP3ObjectG22V7 *object = NULL;
2680 uint32_t prefix = 0;
2681 uint32_t index = start;
2682
2683 while (count--) {
2684
2685 object = SCCalloc(1, sizeof(*object));
2686 if (unlikely(object == NULL)) {
2687 goto error;
2688 }
2689
2690 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2691 goto error;
2692 }
2693
2694 {
2695 uint8_t octet;
2696 if (!DNP3ReadUint8(buf, len, &octet)) {
2697 goto error;
2698 }
2699 object->online = (octet >> 0) & 0x1;
2700 object->restart = (octet >> 1) & 0x1;
2701 object->comm_lost = (octet >> 2) & 0x1;
2702 object->remote_forced = (octet >> 3) & 0x1;
2703 object->local_forced = (octet >> 4) & 0x1;
2704 object->rollover = (octet >> 5) & 0x1;
2705 object->reserved0 = (octet >> 6) & 0x1;
2706 object->reserved1 = (octet >> 7) & 0x1;
2707 }
2708 if (!DNP3ReadUint32(buf, len, &object->count)) {
2709 goto error;
2710 }
2711 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2712 goto error;
2713 }
2714
2715 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2716 goto error;
2717 }
2718
2719 object = NULL;
2720 index++;
2721 }
2722
2723 return 1;
2724error:
2725 if (object != NULL) {
2726 SCFree(object);
2727 }
2728
2729 return 0;
2730}
2731
2732static int DNP3DecodeObjectG22V8(const uint8_t **buf, uint32_t *len,
2733 uint8_t prefix_code, uint32_t start, uint32_t count,
2734 DNP3PointList *points)
2735{
2736 DNP3ObjectG22V8 *object = NULL;
2737 uint32_t prefix = 0;
2738 uint32_t index = start;
2739
2740 while (count--) {
2741
2742 object = SCCalloc(1, sizeof(*object));
2743 if (unlikely(object == NULL)) {
2744 goto error;
2745 }
2746
2747 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2748 goto error;
2749 }
2750
2751 {
2752 uint8_t octet;
2753 if (!DNP3ReadUint8(buf, len, &octet)) {
2754 goto error;
2755 }
2756 object->online = (octet >> 0) & 0x1;
2757 object->restart = (octet >> 1) & 0x1;
2758 object->comm_lost = (octet >> 2) & 0x1;
2759 object->remote_forced = (octet >> 3) & 0x1;
2760 object->local_forced = (octet >> 4) & 0x1;
2761 object->rollover = (octet >> 5) & 0x1;
2762 object->reserved0 = (octet >> 6) & 0x1;
2763 object->reserved1 = (octet >> 7) & 0x1;
2764 }
2765 if (!DNP3ReadUint16(buf, len, &object->count)) {
2766 goto error;
2767 }
2768 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2769 goto error;
2770 }
2771
2772 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2773 goto error;
2774 }
2775
2776 object = NULL;
2777 index++;
2778 }
2779
2780 return 1;
2781error:
2782 if (object != NULL) {
2783 SCFree(object);
2784 }
2785
2786 return 0;
2787}
2788
2789static int DNP3DecodeObjectG23V1(const uint8_t **buf, uint32_t *len,
2790 uint8_t prefix_code, uint32_t start, uint32_t count,
2791 DNP3PointList *points)
2792{
2793 DNP3ObjectG23V1 *object = NULL;
2794 uint32_t prefix = 0;
2795 uint32_t index = start;
2796
2797 while (count--) {
2798
2799 object = SCCalloc(1, sizeof(*object));
2800 if (unlikely(object == NULL)) {
2801 goto error;
2802 }
2803
2804 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2805 goto error;
2806 }
2807
2808 {
2809 uint8_t octet;
2810 if (!DNP3ReadUint8(buf, len, &octet)) {
2811 goto error;
2812 }
2813 object->online = (octet >> 0) & 0x1;
2814 object->restart = (octet >> 1) & 0x1;
2815 object->comm_lost = (octet >> 2) & 0x1;
2816 object->remote_forced = (octet >> 3) & 0x1;
2817 object->local_forced = (octet >> 4) & 0x1;
2818 object->rollover = (octet >> 5) & 0x1;
2819 object->discontinuity = (octet >> 6) & 0x1;
2820 object->reserved0 = (octet >> 7) & 0x1;
2821 }
2822 if (!DNP3ReadUint32(buf, len, &object->count)) {
2823 goto error;
2824 }
2825
2826 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2827 goto error;
2828 }
2829
2830 object = NULL;
2831 index++;
2832 }
2833
2834 return 1;
2835error:
2836 if (object != NULL) {
2837 SCFree(object);
2838 }
2839
2840 return 0;
2841}
2842
2843static int DNP3DecodeObjectG23V2(const uint8_t **buf, uint32_t *len,
2844 uint8_t prefix_code, uint32_t start, uint32_t count,
2845 DNP3PointList *points)
2846{
2847 DNP3ObjectG23V2 *object = NULL;
2848 uint32_t prefix = 0;
2849 uint32_t index = start;
2850
2851 while (count--) {
2852
2853 object = SCCalloc(1, sizeof(*object));
2854 if (unlikely(object == NULL)) {
2855 goto error;
2856 }
2857
2858 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2859 goto error;
2860 }
2861
2862 {
2863 uint8_t octet;
2864 if (!DNP3ReadUint8(buf, len, &octet)) {
2865 goto error;
2866 }
2867 object->online = (octet >> 0) & 0x1;
2868 object->restart = (octet >> 1) & 0x1;
2869 object->comm_lost = (octet >> 2) & 0x1;
2870 object->remote_forced = (octet >> 3) & 0x1;
2871 object->local_forced = (octet >> 4) & 0x1;
2872 object->rollover = (octet >> 5) & 0x1;
2873 object->reserved0 = (octet >> 6) & 0x1;
2874 object->reserved1 = (octet >> 7) & 0x1;
2875 }
2876 if (!DNP3ReadUint16(buf, len, &object->count)) {
2877 goto error;
2878 }
2879
2880 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2881 goto error;
2882 }
2883
2884 object = NULL;
2885 index++;
2886 }
2887
2888 return 1;
2889error:
2890 if (object != NULL) {
2891 SCFree(object);
2892 }
2893
2894 return 0;
2895}
2896
2897static int DNP3DecodeObjectG23V3(const uint8_t **buf, uint32_t *len,
2898 uint8_t prefix_code, uint32_t start, uint32_t count,
2899 DNP3PointList *points)
2900{
2901 DNP3ObjectG23V3 *object = NULL;
2902 uint32_t prefix = 0;
2903 uint32_t index = start;
2904
2905 while (count--) {
2906
2907 object = SCCalloc(1, sizeof(*object));
2908 if (unlikely(object == NULL)) {
2909 goto error;
2910 }
2911
2912 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2913 goto error;
2914 }
2915
2916 {
2917 uint8_t octet;
2918 if (!DNP3ReadUint8(buf, len, &octet)) {
2919 goto error;
2920 }
2921 object->online = (octet >> 0) & 0x1;
2922 object->restart = (octet >> 1) & 0x1;
2923 object->comm_lost = (octet >> 2) & 0x1;
2924 object->remote_forced = (octet >> 3) & 0x1;
2925 object->local_forced = (octet >> 4) & 0x1;
2926 object->rollover = (octet >> 5) & 0x1;
2927 object->reserved0 = (octet >> 6) & 0x1;
2928 object->reserved1 = (octet >> 7) & 0x1;
2929 }
2930 if (!DNP3ReadUint32(buf, len, &object->count)) {
2931 goto error;
2932 }
2933
2934 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2935 goto error;
2936 }
2937
2938 object = NULL;
2939 index++;
2940 }
2941
2942 return 1;
2943error:
2944 if (object != NULL) {
2945 SCFree(object);
2946 }
2947
2948 return 0;
2949}
2950
2951static int DNP3DecodeObjectG23V4(const uint8_t **buf, uint32_t *len,
2952 uint8_t prefix_code, uint32_t start, uint32_t count,
2953 DNP3PointList *points)
2954{
2955 DNP3ObjectG23V4 *object = NULL;
2956 uint32_t prefix = 0;
2957 uint32_t index = start;
2958
2959 while (count--) {
2960
2961 object = SCCalloc(1, sizeof(*object));
2962 if (unlikely(object == NULL)) {
2963 goto error;
2964 }
2965
2966 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2967 goto error;
2968 }
2969
2970 {
2971 uint8_t octet;
2972 if (!DNP3ReadUint8(buf, len, &octet)) {
2973 goto error;
2974 }
2975 object->online = (octet >> 0) & 0x1;
2976 object->restart = (octet >> 1) & 0x1;
2977 object->comm_lost = (octet >> 2) & 0x1;
2978 object->remote_forced = (octet >> 3) & 0x1;
2979 object->local_forced = (octet >> 4) & 0x1;
2980 object->rollover = (octet >> 5) & 0x1;
2981 object->reserved0 = (octet >> 6) & 0x1;
2982 object->reserved1 = (octet >> 7) & 0x1;
2983 }
2984 if (!DNP3ReadUint16(buf, len, &object->count)) {
2985 goto error;
2986 }
2987
2988 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
2989 goto error;
2990 }
2991
2992 object = NULL;
2993 index++;
2994 }
2995
2996 return 1;
2997error:
2998 if (object != NULL) {
2999 SCFree(object);
3000 }
3001
3002 return 0;
3003}
3004
3005static int DNP3DecodeObjectG23V5(const uint8_t **buf, uint32_t *len,
3006 uint8_t prefix_code, uint32_t start, uint32_t count,
3007 DNP3PointList *points)
3008{
3009 DNP3ObjectG23V5 *object = NULL;
3010 uint32_t prefix = 0;
3011 uint32_t index = start;
3012
3013 while (count--) {
3014
3015 object = SCCalloc(1, sizeof(*object));
3016 if (unlikely(object == NULL)) {
3017 goto error;
3018 }
3019
3020 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3021 goto error;
3022 }
3023
3024 {
3025 uint8_t octet;
3026 if (!DNP3ReadUint8(buf, len, &octet)) {
3027 goto error;
3028 }
3029 object->online = (octet >> 0) & 0x1;
3030 object->restart = (octet >> 1) & 0x1;
3031 object->comm_lost = (octet >> 2) & 0x1;
3032 object->remote_forced = (octet >> 3) & 0x1;
3033 object->local_forced = (octet >> 4) & 0x1;
3034 object->rollover = (octet >> 5) & 0x1;
3035 object->discontinuity = (octet >> 6) & 0x1;
3036 object->reserved0 = (octet >> 7) & 0x1;
3037 }
3038 if (!DNP3ReadUint32(buf, len, &object->count)) {
3039 goto error;
3040 }
3041 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3042 goto error;
3043 }
3044
3045 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3046 goto error;
3047 }
3048
3049 object = NULL;
3050 index++;
3051 }
3052
3053 return 1;
3054error:
3055 if (object != NULL) {
3056 SCFree(object);
3057 }
3058
3059 return 0;
3060}
3061
3062static int DNP3DecodeObjectG23V6(const uint8_t **buf, uint32_t *len,
3063 uint8_t prefix_code, uint32_t start, uint32_t count,
3064 DNP3PointList *points)
3065{
3066 DNP3ObjectG23V6 *object = NULL;
3067 uint32_t prefix = 0;
3068 uint32_t index = start;
3069
3070 while (count--) {
3071
3072 object = SCCalloc(1, sizeof(*object));
3073 if (unlikely(object == NULL)) {
3074 goto error;
3075 }
3076
3077 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3078 goto error;
3079 }
3080
3081 {
3082 uint8_t octet;
3083 if (!DNP3ReadUint8(buf, len, &octet)) {
3084 goto error;
3085 }
3086 object->online = (octet >> 0) & 0x1;
3087 object->restart = (octet >> 1) & 0x1;
3088 object->comm_lost = (octet >> 2) & 0x1;
3089 object->remote_forced = (octet >> 3) & 0x1;
3090 object->local_forced = (octet >> 4) & 0x1;
3091 object->rollover = (octet >> 5) & 0x1;
3092 object->discontinuity = (octet >> 6) & 0x1;
3093 object->reserved0 = (octet >> 7) & 0x1;
3094 }
3095 if (!DNP3ReadUint16(buf, len, &object->count)) {
3096 goto error;
3097 }
3098 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3099 goto error;
3100 }
3101
3102 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3103 goto error;
3104 }
3105
3106 object = NULL;
3107 index++;
3108 }
3109
3110 return 1;
3111error:
3112 if (object != NULL) {
3113 SCFree(object);
3114 }
3115
3116 return 0;
3117}
3118
3119static int DNP3DecodeObjectG23V7(const uint8_t **buf, uint32_t *len,
3120 uint8_t prefix_code, uint32_t start, uint32_t count,
3121 DNP3PointList *points)
3122{
3123 DNP3ObjectG23V7 *object = NULL;
3124 uint32_t prefix = 0;
3125 uint32_t index = start;
3126
3127 while (count--) {
3128
3129 object = SCCalloc(1, sizeof(*object));
3130 if (unlikely(object == NULL)) {
3131 goto error;
3132 }
3133
3134 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3135 goto error;
3136 }
3137
3138 {
3139 uint8_t octet;
3140 if (!DNP3ReadUint8(buf, len, &octet)) {
3141 goto error;
3142 }
3143 object->online = (octet >> 0) & 0x1;
3144 object->restart = (octet >> 1) & 0x1;
3145 object->comm_lost = (octet >> 2) & 0x1;
3146 object->remote_forced = (octet >> 3) & 0x1;
3147 object->local_forced = (octet >> 4) & 0x1;
3148 object->rollover = (octet >> 5) & 0x1;
3149 object->reserved0 = (octet >> 6) & 0x1;
3150 object->reserved1 = (octet >> 7) & 0x1;
3151 }
3152 if (!DNP3ReadUint32(buf, len, &object->count)) {
3153 goto error;
3154 }
3155 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3156 goto error;
3157 }
3158
3159 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3160 goto error;
3161 }
3162
3163 object = NULL;
3164 index++;
3165 }
3166
3167 return 1;
3168error:
3169 if (object != NULL) {
3170 SCFree(object);
3171 }
3172
3173 return 0;
3174}
3175
3176static int DNP3DecodeObjectG23V8(const uint8_t **buf, uint32_t *len,
3177 uint8_t prefix_code, uint32_t start, uint32_t count,
3178 DNP3PointList *points)
3179{
3180 DNP3ObjectG23V8 *object = NULL;
3181 uint32_t prefix = 0;
3182 uint32_t index = start;
3183
3184 while (count--) {
3185
3186 object = SCCalloc(1, sizeof(*object));
3187 if (unlikely(object == NULL)) {
3188 goto error;
3189 }
3190
3191 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3192 goto error;
3193 }
3194
3195 {
3196 uint8_t octet;
3197 if (!DNP3ReadUint8(buf, len, &octet)) {
3198 goto error;
3199 }
3200 object->online = (octet >> 0) & 0x1;
3201 object->restart = (octet >> 1) & 0x1;
3202 object->comm_lost = (octet >> 2) & 0x1;
3203 object->remote_forced = (octet >> 3) & 0x1;
3204 object->local_forced = (octet >> 4) & 0x1;
3205 object->rollover = (octet >> 5) & 0x1;
3206 object->reserved0 = (octet >> 6) & 0x1;
3207 object->reserved1 = (octet >> 7) & 0x1;
3208 }
3209 if (!DNP3ReadUint16(buf, len, &object->count)) {
3210 goto error;
3211 }
3212 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3213 goto error;
3214 }
3215
3216 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3217 goto error;
3218 }
3219
3220 object = NULL;
3221 index++;
3222 }
3223
3224 return 1;
3225error:
3226 if (object != NULL) {
3227 SCFree(object);
3228 }
3229
3230 return 0;
3231}
3232
3233static int DNP3DecodeObjectG30V1(const uint8_t **buf, uint32_t *len,
3234 uint8_t prefix_code, uint32_t start, uint32_t count,
3235 DNP3PointList *points)
3236{
3237 DNP3ObjectG30V1 *object = NULL;
3238 uint32_t prefix = 0;
3239 uint32_t index = start;
3240
3241 while (count--) {
3242
3243 object = SCCalloc(1, sizeof(*object));
3244 if (unlikely(object == NULL)) {
3245 goto error;
3246 }
3247
3248 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3249 goto error;
3250 }
3251
3252 {
3253 uint8_t octet;
3254 if (!DNP3ReadUint8(buf, len, &octet)) {
3255 goto error;
3256 }
3257 object->online = (octet >> 0) & 0x1;
3258 object->restart = (octet >> 1) & 0x1;
3259 object->comm_lost = (octet >> 2) & 0x1;
3260 object->remote_forced = (octet >> 3) & 0x1;
3261 object->local_forced = (octet >> 4) & 0x1;
3262 object->over_range = (octet >> 5) & 0x1;
3263 object->reference_err = (octet >> 6) & 0x1;
3264 object->reserved0 = (octet >> 7) & 0x1;
3265 }
3266 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3267 goto error;
3268 }
3269
3270 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3271 goto error;
3272 }
3273
3274 object = NULL;
3275 index++;
3276 }
3277
3278 return 1;
3279error:
3280 if (object != NULL) {
3281 SCFree(object);
3282 }
3283
3284 return 0;
3285}
3286
3287static int DNP3DecodeObjectG30V2(const uint8_t **buf, uint32_t *len,
3288 uint8_t prefix_code, uint32_t start, uint32_t count,
3289 DNP3PointList *points)
3290{
3291 DNP3ObjectG30V2 *object = NULL;
3292 uint32_t prefix = 0;
3293 uint32_t index = start;
3294
3295 while (count--) {
3296
3297 object = SCCalloc(1, sizeof(*object));
3298 if (unlikely(object == NULL)) {
3299 goto error;
3300 }
3301
3302 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3303 goto error;
3304 }
3305
3306 {
3307 uint8_t octet;
3308 if (!DNP3ReadUint8(buf, len, &octet)) {
3309 goto error;
3310 }
3311 object->online = (octet >> 0) & 0x1;
3312 object->restart = (octet >> 1) & 0x1;
3313 object->comm_lost = (octet >> 2) & 0x1;
3314 object->remote_forced = (octet >> 3) & 0x1;
3315 object->local_forced = (octet >> 4) & 0x1;
3316 object->over_range = (octet >> 5) & 0x1;
3317 object->reference_err = (octet >> 6) & 0x1;
3318 object->reserved0 = (octet >> 7) & 0x1;
3319 }
3320 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3321 goto error;
3322 }
3323
3324 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3325 goto error;
3326 }
3327
3328 object = NULL;
3329 index++;
3330 }
3331
3332 return 1;
3333error:
3334 if (object != NULL) {
3335 SCFree(object);
3336 }
3337
3338 return 0;
3339}
3340
3341static int DNP3DecodeObjectG30V3(const uint8_t **buf, uint32_t *len,
3342 uint8_t prefix_code, uint32_t start, uint32_t count,
3343 DNP3PointList *points)
3344{
3345 DNP3ObjectG30V3 *object = NULL;
3346 uint32_t prefix = 0;
3347 uint32_t index = start;
3348
3349 while (count--) {
3350
3351 object = SCCalloc(1, sizeof(*object));
3352 if (unlikely(object == NULL)) {
3353 goto error;
3354 }
3355
3356 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3357 goto error;
3358 }
3359
3360 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3361 goto error;
3362 }
3363
3364 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3365 goto error;
3366 }
3367
3368 object = NULL;
3369 index++;
3370 }
3371
3372 return 1;
3373error:
3374 if (object != NULL) {
3375 SCFree(object);
3376 }
3377
3378 return 0;
3379}
3380
3381static int DNP3DecodeObjectG30V4(const uint8_t **buf, uint32_t *len,
3382 uint8_t prefix_code, uint32_t start, uint32_t count,
3383 DNP3PointList *points)
3384{
3385 DNP3ObjectG30V4 *object = NULL;
3386 uint32_t prefix = 0;
3387 uint32_t index = start;
3388
3389 while (count--) {
3390
3391 object = SCCalloc(1, sizeof(*object));
3392 if (unlikely(object == NULL)) {
3393 goto error;
3394 }
3395
3396 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3397 goto error;
3398 }
3399
3400 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3401 goto error;
3402 }
3403
3404 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3405 goto error;
3406 }
3407
3408 object = NULL;
3409 index++;
3410 }
3411
3412 return 1;
3413error:
3414 if (object != NULL) {
3415 SCFree(object);
3416 }
3417
3418 return 0;
3419}
3420
3421static int DNP3DecodeObjectG30V5(const uint8_t **buf, uint32_t *len,
3422 uint8_t prefix_code, uint32_t start, uint32_t count,
3423 DNP3PointList *points)
3424{
3425 DNP3ObjectG30V5 *object = NULL;
3426 uint32_t prefix = 0;
3427 uint32_t index = start;
3428
3429 while (count--) {
3430
3431 object = SCCalloc(1, sizeof(*object));
3432 if (unlikely(object == NULL)) {
3433 goto error;
3434 }
3435
3436 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3437 goto error;
3438 }
3439
3440 {
3441 uint8_t octet;
3442 if (!DNP3ReadUint8(buf, len, &octet)) {
3443 goto error;
3444 }
3445 object->online = (octet >> 0) & 0x1;
3446 object->restart = (octet >> 1) & 0x1;
3447 object->comm_lost = (octet >> 2) & 0x1;
3448 object->remote_forced = (octet >> 3) & 0x1;
3449 object->local_forced = (octet >> 4) & 0x1;
3450 object->over_range = (octet >> 5) & 0x1;
3451 object->reference_err = (octet >> 6) & 0x1;
3452 object->reserved0 = (octet >> 7) & 0x1;
3453 }
3454 if (!DNP3ReadFloat32(buf, len, &object->value)) {
3455 goto error;
3456 }
3457
3458 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3459 goto error;
3460 }
3461
3462 object = NULL;
3463 index++;
3464 }
3465
3466 return 1;
3467error:
3468 if (object != NULL) {
3469 SCFree(object);
3470 }
3471
3472 return 0;
3473}
3474
3475static int DNP3DecodeObjectG30V6(const uint8_t **buf, uint32_t *len,
3476 uint8_t prefix_code, uint32_t start, uint32_t count,
3477 DNP3PointList *points)
3478{
3479 DNP3ObjectG30V6 *object = NULL;
3480 uint32_t prefix = 0;
3481 uint32_t index = start;
3482
3483 while (count--) {
3484
3485 object = SCCalloc(1, sizeof(*object));
3486 if (unlikely(object == NULL)) {
3487 goto error;
3488 }
3489
3490 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3491 goto error;
3492 }
3493
3494 {
3495 uint8_t octet;
3496 if (!DNP3ReadUint8(buf, len, &octet)) {
3497 goto error;
3498 }
3499 object->online = (octet >> 0) & 0x1;
3500 object->restart = (octet >> 1) & 0x1;
3501 object->comm_lost = (octet >> 2) & 0x1;
3502 object->remote_forced = (octet >> 3) & 0x1;
3503 object->local_forced = (octet >> 4) & 0x1;
3504 object->over_range = (octet >> 5) & 0x1;
3505 object->reference_err = (octet >> 6) & 0x1;
3506 object->reserved0 = (octet >> 7) & 0x1;
3507 }
3508 if (!DNP3ReadFloat64(buf, len, &object->value)) {
3509 goto error;
3510 }
3511
3512 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3513 goto error;
3514 }
3515
3516 object = NULL;
3517 index++;
3518 }
3519
3520 return 1;
3521error:
3522 if (object != NULL) {
3523 SCFree(object);
3524 }
3525
3526 return 0;
3527}
3528
3529static int DNP3DecodeObjectG31V1(const uint8_t **buf, uint32_t *len,
3530 uint8_t prefix_code, uint32_t start, uint32_t count,
3531 DNP3PointList *points)
3532{
3533 DNP3ObjectG31V1 *object = NULL;
3534 uint32_t prefix = 0;
3535 uint32_t index = start;
3536
3537 while (count--) {
3538
3539 object = SCCalloc(1, sizeof(*object));
3540 if (unlikely(object == NULL)) {
3541 goto error;
3542 }
3543
3544 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3545 goto error;
3546 }
3547
3548 {
3549 uint8_t octet;
3550 if (!DNP3ReadUint8(buf, len, &octet)) {
3551 goto error;
3552 }
3553 object->online = (octet >> 0) & 0x1;
3554 object->restart = (octet >> 1) & 0x1;
3555 object->comm_lost = (octet >> 2) & 0x1;
3556 object->remote_forced = (octet >> 3) & 0x1;
3557 object->local_forced = (octet >> 4) & 0x1;
3558 object->over_range = (octet >> 5) & 0x1;
3559 object->reference_err = (octet >> 6) & 0x1;
3560 object->reserved0 = (octet >> 7) & 0x1;
3561 }
3562 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3563 goto error;
3564 }
3565
3566 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3567 goto error;
3568 }
3569
3570 object = NULL;
3571 index++;
3572 }
3573
3574 return 1;
3575error:
3576 if (object != NULL) {
3577 SCFree(object);
3578 }
3579
3580 return 0;
3581}
3582
3583static int DNP3DecodeObjectG31V2(const uint8_t **buf, uint32_t *len,
3584 uint8_t prefix_code, uint32_t start, uint32_t count,
3585 DNP3PointList *points)
3586{
3587 DNP3ObjectG31V2 *object = NULL;
3588 uint32_t prefix = 0;
3589 uint32_t index = start;
3590
3591 while (count--) {
3592
3593 object = SCCalloc(1, sizeof(*object));
3594 if (unlikely(object == NULL)) {
3595 goto error;
3596 }
3597
3598 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3599 goto error;
3600 }
3601
3602 {
3603 uint8_t octet;
3604 if (!DNP3ReadUint8(buf, len, &octet)) {
3605 goto error;
3606 }
3607 object->online = (octet >> 0) & 0x1;
3608 object->restart = (octet >> 1) & 0x1;
3609 object->comm_lost = (octet >> 2) & 0x1;
3610 object->remote_forced = (octet >> 3) & 0x1;
3611 object->local_forced = (octet >> 4) & 0x1;
3612 object->over_range = (octet >> 5) & 0x1;
3613 object->reference_err = (octet >> 6) & 0x1;
3614 object->reserved0 = (octet >> 7) & 0x1;
3615 }
3616 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3617 goto error;
3618 }
3619
3620 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3621 goto error;
3622 }
3623
3624 object = NULL;
3625 index++;
3626 }
3627
3628 return 1;
3629error:
3630 if (object != NULL) {
3631 SCFree(object);
3632 }
3633
3634 return 0;
3635}
3636
3637static int DNP3DecodeObjectG31V3(const uint8_t **buf, uint32_t *len,
3638 uint8_t prefix_code, uint32_t start, uint32_t count,
3639 DNP3PointList *points)
3640{
3641 DNP3ObjectG31V3 *object = NULL;
3642 uint32_t prefix = 0;
3643 uint32_t index = start;
3644
3645 while (count--) {
3646
3647 object = SCCalloc(1, sizeof(*object));
3648 if (unlikely(object == NULL)) {
3649 goto error;
3650 }
3651
3652 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3653 goto error;
3654 }
3655
3656 {
3657 uint8_t octet;
3658 if (!DNP3ReadUint8(buf, len, &octet)) {
3659 goto error;
3660 }
3661 object->online = (octet >> 0) & 0x1;
3662 object->restart = (octet >> 1) & 0x1;
3663 object->comm_lost = (octet >> 2) & 0x1;
3664 object->remote_forced = (octet >> 3) & 0x1;
3665 object->local_forced = (octet >> 4) & 0x1;
3666 object->over_range = (octet >> 5) & 0x1;
3667 object->reference_err = (octet >> 6) & 0x1;
3668 object->reserved0 = (octet >> 7) & 0x1;
3669 }
3670 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3671 goto error;
3672 }
3673 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3674 goto error;
3675 }
3676
3677 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3678 goto error;
3679 }
3680
3681 object = NULL;
3682 index++;
3683 }
3684
3685 return 1;
3686error:
3687 if (object != NULL) {
3688 SCFree(object);
3689 }
3690
3691 return 0;
3692}
3693
3694static int DNP3DecodeObjectG31V4(const uint8_t **buf, uint32_t *len,
3695 uint8_t prefix_code, uint32_t start, uint32_t count,
3696 DNP3PointList *points)
3697{
3698 DNP3ObjectG31V4 *object = NULL;
3699 uint32_t prefix = 0;
3700 uint32_t index = start;
3701
3702 while (count--) {
3703
3704 object = SCCalloc(1, sizeof(*object));
3705 if (unlikely(object == NULL)) {
3706 goto error;
3707 }
3708
3709 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3710 goto error;
3711 }
3712
3713 {
3714 uint8_t octet;
3715 if (!DNP3ReadUint8(buf, len, &octet)) {
3716 goto error;
3717 }
3718 object->online = (octet >> 0) & 0x1;
3719 object->restart = (octet >> 1) & 0x1;
3720 object->comm_lost = (octet >> 2) & 0x1;
3721 object->remote_forced = (octet >> 3) & 0x1;
3722 object->local_forced = (octet >> 4) & 0x1;
3723 object->over_range = (octet >> 5) & 0x1;
3724 object->reference_err = (octet >> 6) & 0x1;
3725 object->reserved0 = (octet >> 7) & 0x1;
3726 }
3727 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3728 goto error;
3729 }
3730 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3731 goto error;
3732 }
3733
3734 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3735 goto error;
3736 }
3737
3738 object = NULL;
3739 index++;
3740 }
3741
3742 return 1;
3743error:
3744 if (object != NULL) {
3745 SCFree(object);
3746 }
3747
3748 return 0;
3749}
3750
3751static int DNP3DecodeObjectG31V5(const uint8_t **buf, uint32_t *len,
3752 uint8_t prefix_code, uint32_t start, uint32_t count,
3753 DNP3PointList *points)
3754{
3755 DNP3ObjectG31V5 *object = NULL;
3756 uint32_t prefix = 0;
3757 uint32_t index = start;
3758
3759 while (count--) {
3760
3761 object = SCCalloc(1, sizeof(*object));
3762 if (unlikely(object == NULL)) {
3763 goto error;
3764 }
3765
3766 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3767 goto error;
3768 }
3769
3770 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3771 goto error;
3772 }
3773
3774 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3775 goto error;
3776 }
3777
3778 object = NULL;
3779 index++;
3780 }
3781
3782 return 1;
3783error:
3784 if (object != NULL) {
3785 SCFree(object);
3786 }
3787
3788 return 0;
3789}
3790
3791static int DNP3DecodeObjectG31V6(const uint8_t **buf, uint32_t *len,
3792 uint8_t prefix_code, uint32_t start, uint32_t count,
3793 DNP3PointList *points)
3794{
3795 DNP3ObjectG31V6 *object = NULL;
3796 uint32_t prefix = 0;
3797 uint32_t index = start;
3798
3799 while (count--) {
3800
3801 object = SCCalloc(1, sizeof(*object));
3802 if (unlikely(object == NULL)) {
3803 goto error;
3804 }
3805
3806 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3807 goto error;
3808 }
3809
3810 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3811 goto error;
3812 }
3813
3814 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3815 goto error;
3816 }
3817
3818 object = NULL;
3819 index++;
3820 }
3821
3822 return 1;
3823error:
3824 if (object != NULL) {
3825 SCFree(object);
3826 }
3827
3828 return 0;
3829}
3830
3831static int DNP3DecodeObjectG31V7(const uint8_t **buf, uint32_t *len,
3832 uint8_t prefix_code, uint32_t start, uint32_t count,
3833 DNP3PointList *points)
3834{
3835 DNP3ObjectG31V7 *object = NULL;
3836 uint32_t prefix = 0;
3837 uint32_t index = start;
3838
3839 while (count--) {
3840
3841 object = SCCalloc(1, sizeof(*object));
3842 if (unlikely(object == NULL)) {
3843 goto error;
3844 }
3845
3846 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3847 goto error;
3848 }
3849
3850 {
3851 uint8_t octet;
3852 if (!DNP3ReadUint8(buf, len, &octet)) {
3853 goto error;
3854 }
3855 object->online = (octet >> 0) & 0x1;
3856 object->restart = (octet >> 1) & 0x1;
3857 object->comm_lost = (octet >> 2) & 0x1;
3858 object->remote_forced = (octet >> 3) & 0x1;
3859 object->local_forced = (octet >> 4) & 0x1;
3860 object->over_range = (octet >> 5) & 0x1;
3861 object->reference_err = (octet >> 6) & 0x1;
3862 object->reserved0 = (octet >> 7) & 0x1;
3863 }
3864 if (!DNP3ReadFloat32(buf, len, &object->value)) {
3865 goto error;
3866 }
3867
3868 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3869 goto error;
3870 }
3871
3872 object = NULL;
3873 index++;
3874 }
3875
3876 return 1;
3877error:
3878 if (object != NULL) {
3879 SCFree(object);
3880 }
3881
3882 return 0;
3883}
3884
3885static int DNP3DecodeObjectG31V8(const uint8_t **buf, uint32_t *len,
3886 uint8_t prefix_code, uint32_t start, uint32_t count,
3887 DNP3PointList *points)
3888{
3889 DNP3ObjectG31V8 *object = NULL;
3890 uint32_t prefix = 0;
3891 uint32_t index = start;
3892
3893 while (count--) {
3894
3895 object = SCCalloc(1, sizeof(*object));
3896 if (unlikely(object == NULL)) {
3897 goto error;
3898 }
3899
3900 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3901 goto error;
3902 }
3903
3904 {
3905 uint8_t octet;
3906 if (!DNP3ReadUint8(buf, len, &octet)) {
3907 goto error;
3908 }
3909 object->online = (octet >> 0) & 0x1;
3910 object->restart = (octet >> 1) & 0x1;
3911 object->comm_lost = (octet >> 2) & 0x1;
3912 object->remote_forced = (octet >> 3) & 0x1;
3913 object->local_forced = (octet >> 4) & 0x1;
3914 object->over_range = (octet >> 5) & 0x1;
3915 object->reference_err = (octet >> 6) & 0x1;
3916 object->reserved0 = (octet >> 7) & 0x1;
3917 }
3918 if (!DNP3ReadFloat64(buf, len, &object->value)) {
3919 goto error;
3920 }
3921
3922 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3923 goto error;
3924 }
3925
3926 object = NULL;
3927 index++;
3928 }
3929
3930 return 1;
3931error:
3932 if (object != NULL) {
3933 SCFree(object);
3934 }
3935
3936 return 0;
3937}
3938
3939static int DNP3DecodeObjectG32V1(const uint8_t **buf, uint32_t *len,
3940 uint8_t prefix_code, uint32_t start, uint32_t count,
3941 DNP3PointList *points)
3942{
3943 DNP3ObjectG32V1 *object = NULL;
3944 uint32_t prefix = 0;
3945 uint32_t index = start;
3946
3947 while (count--) {
3948
3949 object = SCCalloc(1, sizeof(*object));
3950 if (unlikely(object == NULL)) {
3951 goto error;
3952 }
3953
3954 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3955 goto error;
3956 }
3957
3958 {
3959 uint8_t octet;
3960 if (!DNP3ReadUint8(buf, len, &octet)) {
3961 goto error;
3962 }
3963 object->online = (octet >> 0) & 0x1;
3964 object->restart = (octet >> 1) & 0x1;
3965 object->comm_lost = (octet >> 2) & 0x1;
3966 object->remote_forced = (octet >> 3) & 0x1;
3967 object->local_forced = (octet >> 4) & 0x1;
3968 object->over_range = (octet >> 5) & 0x1;
3969 object->reference_err = (octet >> 6) & 0x1;
3970 object->reserved0 = (octet >> 7) & 0x1;
3971 }
3972 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3973 goto error;
3974 }
3975
3976 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
3977 goto error;
3978 }
3979
3980 object = NULL;
3981 index++;
3982 }
3983
3984 return 1;
3985error:
3986 if (object != NULL) {
3987 SCFree(object);
3988 }
3989
3990 return 0;
3991}
3992
3993static int DNP3DecodeObjectG32V2(const uint8_t **buf, uint32_t *len,
3994 uint8_t prefix_code, uint32_t start, uint32_t count,
3995 DNP3PointList *points)
3996{
3997 DNP3ObjectG32V2 *object = NULL;
3998 uint32_t prefix = 0;
3999 uint32_t index = start;
4000
4001 while (count--) {
4002
4003 object = SCCalloc(1, sizeof(*object));
4004 if (unlikely(object == NULL)) {
4005 goto error;
4006 }
4007
4008 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4009 goto error;
4010 }
4011
4012 {
4013 uint8_t octet;
4014 if (!DNP3ReadUint8(buf, len, &octet)) {
4015 goto error;
4016 }
4017 object->online = (octet >> 0) & 0x1;
4018 object->restart = (octet >> 1) & 0x1;
4019 object->comm_lost = (octet >> 2) & 0x1;
4020 object->remote_forced = (octet >> 3) & 0x1;
4021 object->local_forced = (octet >> 4) & 0x1;
4022 object->over_range = (octet >> 5) & 0x1;
4023 object->reference_err = (octet >> 6) & 0x1;
4024 object->reserved0 = (octet >> 7) & 0x1;
4025 }
4026 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4027 goto error;
4028 }
4029
4030 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4031 goto error;
4032 }
4033
4034 object = NULL;
4035 index++;
4036 }
4037
4038 return 1;
4039error:
4040 if (object != NULL) {
4041 SCFree(object);
4042 }
4043
4044 return 0;
4045}
4046
4047static int DNP3DecodeObjectG32V3(const uint8_t **buf, uint32_t *len,
4048 uint8_t prefix_code, uint32_t start, uint32_t count,
4049 DNP3PointList *points)
4050{
4051 DNP3ObjectG32V3 *object = NULL;
4052 uint32_t prefix = 0;
4053 uint32_t index = start;
4054
4055 while (count--) {
4056
4057 object = SCCalloc(1, sizeof(*object));
4058 if (unlikely(object == NULL)) {
4059 goto error;
4060 }
4061
4062 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4063 goto error;
4064 }
4065
4066 {
4067 uint8_t octet;
4068 if (!DNP3ReadUint8(buf, len, &octet)) {
4069 goto error;
4070 }
4071 object->online = (octet >> 0) & 0x1;
4072 object->restart = (octet >> 1) & 0x1;
4073 object->comm_lost = (octet >> 2) & 0x1;
4074 object->remote_forced = (octet >> 3) & 0x1;
4075 object->local_forced = (octet >> 4) & 0x1;
4076 object->over_range = (octet >> 5) & 0x1;
4077 object->reference_err = (octet >> 6) & 0x1;
4078 object->reserved0 = (octet >> 7) & 0x1;
4079 }
4080 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4081 goto error;
4082 }
4083 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4084 goto error;
4085 }
4086
4087 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4088 goto error;
4089 }
4090
4091 object = NULL;
4092 index++;
4093 }
4094
4095 return 1;
4096error:
4097 if (object != NULL) {
4098 SCFree(object);
4099 }
4100
4101 return 0;
4102}
4103
4104static int DNP3DecodeObjectG32V4(const uint8_t **buf, uint32_t *len,
4105 uint8_t prefix_code, uint32_t start, uint32_t count,
4106 DNP3PointList *points)
4107{
4108 DNP3ObjectG32V4 *object = NULL;
4109 uint32_t prefix = 0;
4110 uint32_t index = start;
4111
4112 while (count--) {
4113
4114 object = SCCalloc(1, sizeof(*object));
4115 if (unlikely(object == NULL)) {
4116 goto error;
4117 }
4118
4119 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4120 goto error;
4121 }
4122
4123 {
4124 uint8_t octet;
4125 if (!DNP3ReadUint8(buf, len, &octet)) {
4126 goto error;
4127 }
4128 object->online = (octet >> 0) & 0x1;
4129 object->restart = (octet >> 1) & 0x1;
4130 object->comm_lost = (octet >> 2) & 0x1;
4131 object->remote_forced = (octet >> 3) & 0x1;
4132 object->local_forced = (octet >> 4) & 0x1;
4133 object->over_range = (octet >> 5) & 0x1;
4134 object->reference_err = (octet >> 6) & 0x1;
4135 object->reserved0 = (octet >> 7) & 0x1;
4136 }
4137 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4138 goto error;
4139 }
4140 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4141 goto error;
4142 }
4143
4144 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4145 goto error;
4146 }
4147
4148 object = NULL;
4149 index++;
4150 }
4151
4152 return 1;
4153error:
4154 if (object != NULL) {
4155 SCFree(object);
4156 }
4157
4158 return 0;
4159}
4160
4161static int DNP3DecodeObjectG32V5(const uint8_t **buf, uint32_t *len,
4162 uint8_t prefix_code, uint32_t start, uint32_t count,
4163 DNP3PointList *points)
4164{
4165 DNP3ObjectG32V5 *object = NULL;
4166 uint32_t prefix = 0;
4167 uint32_t index = start;
4168
4169 while (count--) {
4170
4171 object = SCCalloc(1, sizeof(*object));
4172 if (unlikely(object == NULL)) {
4173 goto error;
4174 }
4175
4176 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4177 goto error;
4178 }
4179
4180 {
4181 uint8_t octet;
4182 if (!DNP3ReadUint8(buf, len, &octet)) {
4183 goto error;
4184 }
4185 object->online = (octet >> 0) & 0x1;
4186 object->restart = (octet >> 1) & 0x1;
4187 object->comm_lost = (octet >> 2) & 0x1;
4188 object->remote_forced = (octet >> 3) & 0x1;
4189 object->local_forced = (octet >> 4) & 0x1;
4190 object->over_range = (octet >> 5) & 0x1;
4191 object->reference_err = (octet >> 6) & 0x1;
4192 object->reserved0 = (octet >> 7) & 0x1;
4193 }
4194 if (!DNP3ReadFloat32(buf, len, &object->value)) {
4195 goto error;
4196 }
4197
4198 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4199 goto error;
4200 }
4201
4202 object = NULL;
4203 index++;
4204 }
4205
4206 return 1;
4207error:
4208 if (object != NULL) {
4209 SCFree(object);
4210 }
4211
4212 return 0;
4213}
4214
4215static int DNP3DecodeObjectG32V6(const uint8_t **buf, uint32_t *len,
4216 uint8_t prefix_code, uint32_t start, uint32_t count,
4217 DNP3PointList *points)
4218{
4219 DNP3ObjectG32V6 *object = NULL;
4220 uint32_t prefix = 0;
4221 uint32_t index = start;
4222
4223 while (count--) {
4224
4225 object = SCCalloc(1, sizeof(*object));
4226 if (unlikely(object == NULL)) {
4227 goto error;
4228 }
4229
4230 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4231 goto error;
4232 }
4233
4234 {
4235 uint8_t octet;
4236 if (!DNP3ReadUint8(buf, len, &octet)) {
4237 goto error;
4238 }
4239 object->online = (octet >> 0) & 0x1;
4240 object->restart = (octet >> 1) & 0x1;
4241 object->comm_lost = (octet >> 2) & 0x1;
4242 object->remote_forced = (octet >> 3) & 0x1;
4243 object->local_forced = (octet >> 4) & 0x1;
4244 object->over_range = (octet >> 5) & 0x1;
4245 object->reference_err = (octet >> 6) & 0x1;
4246 object->reserved0 = (octet >> 7) & 0x1;
4247 }
4248 if (!DNP3ReadFloat64(buf, len, &object->value)) {
4249 goto error;
4250 }
4251
4252 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4253 goto error;
4254 }
4255
4256 object = NULL;
4257 index++;
4258 }
4259
4260 return 1;
4261error:
4262 if (object != NULL) {
4263 SCFree(object);
4264 }
4265
4266 return 0;
4267}
4268
4269static int DNP3DecodeObjectG32V7(const uint8_t **buf, uint32_t *len,
4270 uint8_t prefix_code, uint32_t start, uint32_t count,
4271 DNP3PointList *points)
4272{
4273 DNP3ObjectG32V7 *object = NULL;
4274 uint32_t prefix = 0;
4275 uint32_t index = start;
4276
4277 while (count--) {
4278
4279 object = SCCalloc(1, sizeof(*object));
4280 if (unlikely(object == NULL)) {
4281 goto error;
4282 }
4283
4284 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4285 goto error;
4286 }
4287
4288 {
4289 uint8_t octet;
4290 if (!DNP3ReadUint8(buf, len, &octet)) {
4291 goto error;
4292 }
4293 object->online = (octet >> 0) & 0x1;
4294 object->restart = (octet >> 1) & 0x1;
4295 object->comm_lost = (octet >> 2) & 0x1;
4296 object->remote_forced = (octet >> 3) & 0x1;
4297 object->local_forced = (octet >> 4) & 0x1;
4298 object->over_range = (octet >> 5) & 0x1;
4299 object->reference_err = (octet >> 6) & 0x1;
4300 object->reserved0 = (octet >> 7) & 0x1;
4301 }
4302 if (!DNP3ReadFloat32(buf, len, &object->value)) {
4303 goto error;
4304 }
4305 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4306 goto error;
4307 }
4308
4309 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4310 goto error;
4311 }
4312
4313 object = NULL;
4314 index++;
4315 }
4316
4317 return 1;
4318error:
4319 if (object != NULL) {
4320 SCFree(object);
4321 }
4322
4323 return 0;
4324}
4325
4326static int DNP3DecodeObjectG32V8(const uint8_t **buf, uint32_t *len,
4327 uint8_t prefix_code, uint32_t start, uint32_t count,
4328 DNP3PointList *points)
4329{
4330 DNP3ObjectG32V8 *object = NULL;
4331 uint32_t prefix = 0;
4332 uint32_t index = start;
4333
4334 while (count--) {
4335
4336 object = SCCalloc(1, sizeof(*object));
4337 if (unlikely(object == NULL)) {
4338 goto error;
4339 }
4340
4341 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4342 goto error;
4343 }
4344
4345 {
4346 uint8_t octet;
4347 if (!DNP3ReadUint8(buf, len, &octet)) {
4348 goto error;
4349 }
4350 object->online = (octet >> 0) & 0x1;
4351 object->restart = (octet >> 1) & 0x1;
4352 object->comm_lost = (octet >> 2) & 0x1;
4353 object->remote_forced = (octet >> 3) & 0x1;
4354 object->local_forced = (octet >> 4) & 0x1;
4355 object->over_range = (octet >> 5) & 0x1;
4356 object->reference_err = (octet >> 6) & 0x1;
4357 object->reserved0 = (octet >> 7) & 0x1;
4358 }
4359 if (!DNP3ReadFloat64(buf, len, &object->value)) {
4360 goto error;
4361 }
4362 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4363 goto error;
4364 }
4365
4366 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4367 goto error;
4368 }
4369
4370 object = NULL;
4371 index++;
4372 }
4373
4374 return 1;
4375error:
4376 if (object != NULL) {
4377 SCFree(object);
4378 }
4379
4380 return 0;
4381}
4382
4383static int DNP3DecodeObjectG33V1(const uint8_t **buf, uint32_t *len,
4384 uint8_t prefix_code, uint32_t start, uint32_t count,
4385 DNP3PointList *points)
4386{
4387 DNP3ObjectG33V1 *object = NULL;
4388 uint32_t prefix = 0;
4389 uint32_t index = start;
4390
4391 while (count--) {
4392
4393 object = SCCalloc(1, sizeof(*object));
4394 if (unlikely(object == NULL)) {
4395 goto error;
4396 }
4397
4398 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4399 goto error;
4400 }
4401
4402 {
4403 uint8_t octet;
4404 if (!DNP3ReadUint8(buf, len, &octet)) {
4405 goto error;
4406 }
4407 object->online = (octet >> 0) & 0x1;
4408 object->restart = (octet >> 1) & 0x1;
4409 object->comm_lost = (octet >> 2) & 0x1;
4410 object->remote_forced = (octet >> 3) & 0x1;
4411 object->local_forced = (octet >> 4) & 0x1;
4412 object->over_range = (octet >> 5) & 0x1;
4413 object->reference_err = (octet >> 6) & 0x1;
4414 object->reserved0 = (octet >> 7) & 0x1;
4415 }
4416 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4417 goto error;
4418 }
4419
4420 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4421 goto error;
4422 }
4423
4424 object = NULL;
4425 index++;
4426 }
4427
4428 return 1;
4429error:
4430 if (object != NULL) {
4431 SCFree(object);
4432 }
4433
4434 return 0;
4435}
4436
4437static int DNP3DecodeObjectG33V2(const uint8_t **buf, uint32_t *len,
4438 uint8_t prefix_code, uint32_t start, uint32_t count,
4439 DNP3PointList *points)
4440{
4441 DNP3ObjectG33V2 *object = NULL;
4442 uint32_t prefix = 0;
4443 uint32_t index = start;
4444
4445 while (count--) {
4446
4447 object = SCCalloc(1, sizeof(*object));
4448 if (unlikely(object == NULL)) {
4449 goto error;
4450 }
4451
4452 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4453 goto error;
4454 }
4455
4456 {
4457 uint8_t octet;
4458 if (!DNP3ReadUint8(buf, len, &octet)) {
4459 goto error;
4460 }
4461 object->online = (octet >> 0) & 0x1;
4462 object->restart = (octet >> 1) & 0x1;
4463 object->comm_lost = (octet >> 2) & 0x1;
4464 object->remote_forced = (octet >> 3) & 0x1;
4465 object->local_forced = (octet >> 4) & 0x1;
4466 object->over_range = (octet >> 5) & 0x1;
4467 object->reference_err = (octet >> 6) & 0x1;
4468 object->reserved0 = (octet >> 7) & 0x1;
4469 }
4470 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4471 goto error;
4472 }
4473
4474 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4475 goto error;
4476 }
4477
4478 object = NULL;
4479 index++;
4480 }
4481
4482 return 1;
4483error:
4484 if (object != NULL) {
4485 SCFree(object);
4486 }
4487
4488 return 0;
4489}
4490
4491static int DNP3DecodeObjectG33V3(const uint8_t **buf, uint32_t *len,
4492 uint8_t prefix_code, uint32_t start, uint32_t count,
4493 DNP3PointList *points)
4494{
4495 DNP3ObjectG33V3 *object = NULL;
4496 uint32_t prefix = 0;
4497 uint32_t index = start;
4498
4499 while (count--) {
4500
4501 object = SCCalloc(1, sizeof(*object));
4502 if (unlikely(object == NULL)) {
4503 goto error;
4504 }
4505
4506 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4507 goto error;
4508 }
4509
4510 {
4511 uint8_t octet;
4512 if (!DNP3ReadUint8(buf, len, &octet)) {
4513 goto error;
4514 }
4515 object->online = (octet >> 0) & 0x1;
4516 object->restart = (octet >> 1) & 0x1;
4517 object->comm_lost = (octet >> 2) & 0x1;
4518 object->remote_forced = (octet >> 3) & 0x1;
4519 object->local_forced = (octet >> 4) & 0x1;
4520 object->over_range = (octet >> 5) & 0x1;
4521 object->reference_err = (octet >> 6) & 0x1;
4522 object->reserved0 = (octet >> 7) & 0x1;
4523 }
4524 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4525 goto error;
4526 }
4527 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4528 goto error;
4529 }
4530
4531 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4532 goto error;
4533 }
4534
4535 object = NULL;
4536 index++;
4537 }
4538
4539 return 1;
4540error:
4541 if (object != NULL) {
4542 SCFree(object);
4543 }
4544
4545 return 0;
4546}
4547
4548static int DNP3DecodeObjectG33V4(const uint8_t **buf, uint32_t *len,
4549 uint8_t prefix_code, uint32_t start, uint32_t count,
4550 DNP3PointList *points)
4551{
4552 DNP3ObjectG33V4 *object = NULL;
4553 uint32_t prefix = 0;
4554 uint32_t index = start;
4555
4556 while (count--) {
4557
4558 object = SCCalloc(1, sizeof(*object));
4559 if (unlikely(object == NULL)) {
4560 goto error;
4561 }
4562
4563 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4564 goto error;
4565 }
4566
4567 {
4568 uint8_t octet;
4569 if (!DNP3ReadUint8(buf, len, &octet)) {
4570 goto error;
4571 }
4572 object->online = (octet >> 0) & 0x1;
4573 object->restart = (octet >> 1) & 0x1;
4574 object->comm_lost = (octet >> 2) & 0x1;
4575 object->remote_forced = (octet >> 3) & 0x1;
4576 object->local_forced = (octet >> 4) & 0x1;
4577 object->over_range = (octet >> 5) & 0x1;
4578 object->reference_err = (octet >> 6) & 0x1;
4579 object->reserved0 = (octet >> 7) & 0x1;
4580 }
4581 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4582 goto error;
4583 }
4584 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4585 goto error;
4586 }
4587
4588 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4589 goto error;
4590 }
4591
4592 object = NULL;
4593 index++;
4594 }
4595
4596 return 1;
4597error:
4598 if (object != NULL) {
4599 SCFree(object);
4600 }
4601
4602 return 0;
4603}
4604
4605static int DNP3DecodeObjectG33V5(const uint8_t **buf, uint32_t *len,
4606 uint8_t prefix_code, uint32_t start, uint32_t count,
4607 DNP3PointList *points)
4608{
4609 DNP3ObjectG33V5 *object = NULL;
4610 uint32_t prefix = 0;
4611 uint32_t index = start;
4612
4613 while (count--) {
4614
4615 object = SCCalloc(1, sizeof(*object));
4616 if (unlikely(object == NULL)) {
4617 goto error;
4618 }
4619
4620 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4621 goto error;
4622 }
4623
4624 {
4625 uint8_t octet;
4626 if (!DNP3ReadUint8(buf, len, &octet)) {
4627 goto error;
4628 }
4629 object->online = (octet >> 0) & 0x1;
4630 object->restart = (octet >> 1) & 0x1;
4631 object->comm_lost = (octet >> 2) & 0x1;
4632 object->remote_forced = (octet >> 3) & 0x1;
4633 object->local_forced = (octet >> 4) & 0x1;
4634 object->over_range = (octet >> 5) & 0x1;
4635 object->reference_err = (octet >> 6) & 0x1;
4636 object->reserved0 = (octet >> 7) & 0x1;
4637 }
4638 if (!DNP3ReadFloat32(buf, len, &object->value)) {
4639 goto error;
4640 }
4641
4642 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4643 goto error;
4644 }
4645
4646 object = NULL;
4647 index++;
4648 }
4649
4650 return 1;
4651error:
4652 if (object != NULL) {
4653 SCFree(object);
4654 }
4655
4656 return 0;
4657}
4658
4659static int DNP3DecodeObjectG33V6(const uint8_t **buf, uint32_t *len,
4660 uint8_t prefix_code, uint32_t start, uint32_t count,
4661 DNP3PointList *points)
4662{
4663 DNP3ObjectG33V6 *object = NULL;
4664 uint32_t prefix = 0;
4665 uint32_t index = start;
4666
4667 while (count--) {
4668
4669 object = SCCalloc(1, sizeof(*object));
4670 if (unlikely(object == NULL)) {
4671 goto error;
4672 }
4673
4674 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4675 goto error;
4676 }
4677
4678 {
4679 uint8_t octet;
4680 if (!DNP3ReadUint8(buf, len, &octet)) {
4681 goto error;
4682 }
4683 object->online = (octet >> 0) & 0x1;
4684 object->restart = (octet >> 1) & 0x1;
4685 object->comm_lost = (octet >> 2) & 0x1;
4686 object->remote_forced = (octet >> 3) & 0x1;
4687 object->local_forced = (octet >> 4) & 0x1;
4688 object->over_range = (octet >> 5) & 0x1;
4689 object->reference_err = (octet >> 6) & 0x1;
4690 object->reserved0 = (octet >> 7) & 0x1;
4691 }
4692 if (!DNP3ReadFloat64(buf, len, &object->value)) {
4693 goto error;
4694 }
4695
4696 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4697 goto error;
4698 }
4699
4700 object = NULL;
4701 index++;
4702 }
4703
4704 return 1;
4705error:
4706 if (object != NULL) {
4707 SCFree(object);
4708 }
4709
4710 return 0;
4711}
4712
4713static int DNP3DecodeObjectG33V7(const uint8_t **buf, uint32_t *len,
4714 uint8_t prefix_code, uint32_t start, uint32_t count,
4715 DNP3PointList *points)
4716{
4717 DNP3ObjectG33V7 *object = NULL;
4718 uint32_t prefix = 0;
4719 uint32_t index = start;
4720
4721 while (count--) {
4722
4723 object = SCCalloc(1, sizeof(*object));
4724 if (unlikely(object == NULL)) {
4725 goto error;
4726 }
4727
4728 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4729 goto error;
4730 }
4731
4732 {
4733 uint8_t octet;
4734 if (!DNP3ReadUint8(buf, len, &octet)) {
4735 goto error;
4736 }
4737 object->online = (octet >> 0) & 0x1;
4738 object->restart = (octet >> 1) & 0x1;
4739 object->comm_lost = (octet >> 2) & 0x1;
4740 object->remote_forced = (octet >> 3) & 0x1;
4741 object->local_forced = (octet >> 4) & 0x1;
4742 object->over_range = (octet >> 5) & 0x1;
4743 object->reference_err = (octet >> 6) & 0x1;
4744 object->reserved0 = (octet >> 7) & 0x1;
4745 }
4746 if (!DNP3ReadFloat32(buf, len, &object->value)) {
4747 goto error;
4748 }
4749 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4750 goto error;
4751 }
4752
4753 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4754 goto error;
4755 }
4756
4757 object = NULL;
4758 index++;
4759 }
4760
4761 return 1;
4762error:
4763 if (object != NULL) {
4764 SCFree(object);
4765 }
4766
4767 return 0;
4768}
4769
4770static int DNP3DecodeObjectG33V8(const uint8_t **buf, uint32_t *len,
4771 uint8_t prefix_code, uint32_t start, uint32_t count,
4772 DNP3PointList *points)
4773{
4774 DNP3ObjectG33V8 *object = NULL;
4775 uint32_t prefix = 0;
4776 uint32_t index = start;
4777
4778 while (count--) {
4779
4780 object = SCCalloc(1, sizeof(*object));
4781 if (unlikely(object == NULL)) {
4782 goto error;
4783 }
4784
4785 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4786 goto error;
4787 }
4788
4789 {
4790 uint8_t octet;
4791 if (!DNP3ReadUint8(buf, len, &octet)) {
4792 goto error;
4793 }
4794 object->online = (octet >> 0) & 0x1;
4795 object->restart = (octet >> 1) & 0x1;
4796 object->comm_lost = (octet >> 2) & 0x1;
4797 object->remote_forced = (octet >> 3) & 0x1;
4798 object->local_forced = (octet >> 4) & 0x1;
4799 object->over_range = (octet >> 5) & 0x1;
4800 object->reference_err = (octet >> 6) & 0x1;
4801 object->reserved0 = (octet >> 7) & 0x1;
4802 }
4803 if (!DNP3ReadFloat64(buf, len, &object->value)) {
4804 goto error;
4805 }
4806 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4807 goto error;
4808 }
4809
4810 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4811 goto error;
4812 }
4813
4814 object = NULL;
4815 index++;
4816 }
4817
4818 return 1;
4819error:
4820 if (object != NULL) {
4821 SCFree(object);
4822 }
4823
4824 return 0;
4825}
4826
4827static int DNP3DecodeObjectG34V1(const uint8_t **buf, uint32_t *len,
4828 uint8_t prefix_code, uint32_t start, uint32_t count,
4829 DNP3PointList *points)
4830{
4831 DNP3ObjectG34V1 *object = NULL;
4832 uint32_t prefix = 0;
4833 uint32_t index = start;
4834
4835 while (count--) {
4836
4837 object = SCCalloc(1, sizeof(*object));
4838 if (unlikely(object == NULL)) {
4839 goto error;
4840 }
4841
4842 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4843 goto error;
4844 }
4845
4846 if (!DNP3ReadUint16(buf, len, &object->deadband_value)) {
4847 goto error;
4848 }
4849
4850 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4851 goto error;
4852 }
4853
4854 object = NULL;
4855 index++;
4856 }
4857
4858 return 1;
4859error:
4860 if (object != NULL) {
4861 SCFree(object);
4862 }
4863
4864 return 0;
4865}
4866
4867static int DNP3DecodeObjectG34V2(const uint8_t **buf, uint32_t *len,
4868 uint8_t prefix_code, uint32_t start, uint32_t count,
4869 DNP3PointList *points)
4870{
4871 DNP3ObjectG34V2 *object = NULL;
4872 uint32_t prefix = 0;
4873 uint32_t index = start;
4874
4875 while (count--) {
4876
4877 object = SCCalloc(1, sizeof(*object));
4878 if (unlikely(object == NULL)) {
4879 goto error;
4880 }
4881
4882 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4883 goto error;
4884 }
4885
4886 if (!DNP3ReadUint32(buf, len, &object->deadband_value)) {
4887 goto error;
4888 }
4889
4890 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4891 goto error;
4892 }
4893
4894 object = NULL;
4895 index++;
4896 }
4897
4898 return 1;
4899error:
4900 if (object != NULL) {
4901 SCFree(object);
4902 }
4903
4904 return 0;
4905}
4906
4907static int DNP3DecodeObjectG34V3(const uint8_t **buf, uint32_t *len,
4908 uint8_t prefix_code, uint32_t start, uint32_t count,
4909 DNP3PointList *points)
4910{
4911 DNP3ObjectG34V3 *object = NULL;
4912 uint32_t prefix = 0;
4913 uint32_t index = start;
4914
4915 while (count--) {
4916
4917 object = SCCalloc(1, sizeof(*object));
4918 if (unlikely(object == NULL)) {
4919 goto error;
4920 }
4921
4922 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4923 goto error;
4924 }
4925
4926 if (!DNP3ReadFloat32(buf, len, &object->deadband_value)) {
4927 goto error;
4928 }
4929
4930 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4931 goto error;
4932 }
4933
4934 object = NULL;
4935 index++;
4936 }
4937
4938 return 1;
4939error:
4940 if (object != NULL) {
4941 SCFree(object);
4942 }
4943
4944 return 0;
4945}
4946
4947static int DNP3DecodeObjectG40V1(const uint8_t **buf, uint32_t *len,
4948 uint8_t prefix_code, uint32_t start, uint32_t count,
4949 DNP3PointList *points)
4950{
4951 DNP3ObjectG40V1 *object = NULL;
4952 uint32_t prefix = 0;
4953 uint32_t index = start;
4954
4955 while (count--) {
4956
4957 object = SCCalloc(1, sizeof(*object));
4958 if (unlikely(object == NULL)) {
4959 goto error;
4960 }
4961
4962 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4963 goto error;
4964 }
4965
4966 {
4967 uint8_t octet;
4968 if (!DNP3ReadUint8(buf, len, &octet)) {
4969 goto error;
4970 }
4971 object->online = (octet >> 0) & 0x1;
4972 object->restart = (octet >> 1) & 0x1;
4973 object->comm_lost = (octet >> 2) & 0x1;
4974 object->remote_forced = (octet >> 3) & 0x1;
4975 object->local_forced = (octet >> 4) & 0x1;
4976 object->over_range = (octet >> 5) & 0x1;
4977 object->reference_err = (octet >> 6) & 0x1;
4978 object->reserved0 = (octet >> 7) & 0x1;
4979 }
4980 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4981 goto error;
4982 }
4983
4984 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
4985 goto error;
4986 }
4987
4988 object = NULL;
4989 index++;
4990 }
4991
4992 return 1;
4993error:
4994 if (object != NULL) {
4995 SCFree(object);
4996 }
4997
4998 return 0;
4999}
5000
5001static int DNP3DecodeObjectG40V2(const uint8_t **buf, uint32_t *len,
5002 uint8_t prefix_code, uint32_t start, uint32_t count,
5003 DNP3PointList *points)
5004{
5005 DNP3ObjectG40V2 *object = NULL;
5006 uint32_t prefix = 0;
5007 uint32_t index = start;
5008
5009 while (count--) {
5010
5011 object = SCCalloc(1, sizeof(*object));
5012 if (unlikely(object == NULL)) {
5013 goto error;
5014 }
5015
5016 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5017 goto error;
5018 }
5019
5020 {
5021 uint8_t octet;
5022 if (!DNP3ReadUint8(buf, len, &octet)) {
5023 goto error;
5024 }
5025 object->online = (octet >> 0) & 0x1;
5026 object->restart = (octet >> 1) & 0x1;
5027 object->comm_lost = (octet >> 2) & 0x1;
5028 object->remote_forced = (octet >> 3) & 0x1;
5029 object->local_forced = (octet >> 4) & 0x1;
5030 object->over_range = (octet >> 5) & 0x1;
5031 object->reference_err = (octet >> 6) & 0x1;
5032 object->reserved0 = (octet >> 7) & 0x1;
5033 }
5034 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5035 goto error;
5036 }
5037
5038 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5039 goto error;
5040 }
5041
5042 object = NULL;
5043 index++;
5044 }
5045
5046 return 1;
5047error:
5048 if (object != NULL) {
5049 SCFree(object);
5050 }
5051
5052 return 0;
5053}
5054
5055static int DNP3DecodeObjectG40V3(const uint8_t **buf, uint32_t *len,
5056 uint8_t prefix_code, uint32_t start, uint32_t count,
5057 DNP3PointList *points)
5058{
5059 DNP3ObjectG40V3 *object = NULL;
5060 uint32_t prefix = 0;
5061 uint32_t index = start;
5062
5063 while (count--) {
5064
5065 object = SCCalloc(1, sizeof(*object));
5066 if (unlikely(object == NULL)) {
5067 goto error;
5068 }
5069
5070 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5071 goto error;
5072 }
5073
5074 {
5075 uint8_t octet;
5076 if (!DNP3ReadUint8(buf, len, &octet)) {
5077 goto error;
5078 }
5079 object->online = (octet >> 0) & 0x1;
5080 object->restart = (octet >> 1) & 0x1;
5081 object->comm_lost = (octet >> 2) & 0x1;
5082 object->remote_forced = (octet >> 3) & 0x1;
5083 object->local_forced = (octet >> 4) & 0x1;
5084 object->over_range = (octet >> 5) & 0x1;
5085 object->reference_err = (octet >> 6) & 0x1;
5086 object->reserved0 = (octet >> 7) & 0x1;
5087 }
5088 if (!DNP3ReadFloat32(buf, len, &object->value)) {
5089 goto error;
5090 }
5091
5092 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5093 goto error;
5094 }
5095
5096 object = NULL;
5097 index++;
5098 }
5099
5100 return 1;
5101error:
5102 if (object != NULL) {
5103 SCFree(object);
5104 }
5105
5106 return 0;
5107}
5108
5109static int DNP3DecodeObjectG40V4(const uint8_t **buf, uint32_t *len,
5110 uint8_t prefix_code, uint32_t start, uint32_t count,
5111 DNP3PointList *points)
5112{
5113 DNP3ObjectG40V4 *object = NULL;
5114 uint32_t prefix = 0;
5115 uint32_t index = start;
5116
5117 while (count--) {
5118
5119 object = SCCalloc(1, sizeof(*object));
5120 if (unlikely(object == NULL)) {
5121 goto error;
5122 }
5123
5124 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5125 goto error;
5126 }
5127
5128 {
5129 uint8_t octet;
5130 if (!DNP3ReadUint8(buf, len, &octet)) {
5131 goto error;
5132 }
5133 object->online = (octet >> 0) & 0x1;
5134 object->restart = (octet >> 1) & 0x1;
5135 object->comm_lost = (octet >> 2) & 0x1;
5136 object->remote_forced = (octet >> 3) & 0x1;
5137 object->local_forced = (octet >> 4) & 0x1;
5138 object->over_range = (octet >> 5) & 0x1;
5139 object->reference_err = (octet >> 6) & 0x1;
5140 object->reserved0 = (octet >> 7) & 0x1;
5141 }
5142 if (!DNP3ReadFloat64(buf, len, &object->value)) {
5143 goto error;
5144 }
5145
5146 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5147 goto error;
5148 }
5149
5150 object = NULL;
5151 index++;
5152 }
5153
5154 return 1;
5155error:
5156 if (object != NULL) {
5157 SCFree(object);
5158 }
5159
5160 return 0;
5161}
5162
5163static int DNP3DecodeObjectG41V1(const uint8_t **buf, uint32_t *len,
5164 uint8_t prefix_code, uint32_t start, uint32_t count,
5165 DNP3PointList *points)
5166{
5167 DNP3ObjectG41V1 *object = NULL;
5168 uint32_t prefix = 0;
5169 uint32_t index = start;
5170
5171 while (count--) {
5172
5173 object = SCCalloc(1, sizeof(*object));
5174 if (unlikely(object == NULL)) {
5175 goto error;
5176 }
5177
5178 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5179 goto error;
5180 }
5181
5182 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
5183 goto error;
5184 }
5185 if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5186 goto error;
5187 }
5188
5189 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5190 goto error;
5191 }
5192
5193 object = NULL;
5194 index++;
5195 }
5196
5197 return 1;
5198error:
5199 if (object != NULL) {
5200 SCFree(object);
5201 }
5202
5203 return 0;
5204}
5205
5206static int DNP3DecodeObjectG41V2(const uint8_t **buf, uint32_t *len,
5207 uint8_t prefix_code, uint32_t start, uint32_t count,
5208 DNP3PointList *points)
5209{
5210 DNP3ObjectG41V2 *object = NULL;
5211 uint32_t prefix = 0;
5212 uint32_t index = start;
5213
5214 while (count--) {
5215
5216 object = SCCalloc(1, sizeof(*object));
5217 if (unlikely(object == NULL)) {
5218 goto error;
5219 }
5220
5221 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5222 goto error;
5223 }
5224
5225 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5226 goto error;
5227 }
5228 if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5229 goto error;
5230 }
5231
5232 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5233 goto error;
5234 }
5235
5236 object = NULL;
5237 index++;
5238 }
5239
5240 return 1;
5241error:
5242 if (object != NULL) {
5243 SCFree(object);
5244 }
5245
5246 return 0;
5247}
5248
5249static int DNP3DecodeObjectG41V3(const uint8_t **buf, uint32_t *len,
5250 uint8_t prefix_code, uint32_t start, uint32_t count,
5251 DNP3PointList *points)
5252{
5253 DNP3ObjectG41V3 *object = NULL;
5254 uint32_t prefix = 0;
5255 uint32_t index = start;
5256
5257 while (count--) {
5258
5259 object = SCCalloc(1, sizeof(*object));
5260 if (unlikely(object == NULL)) {
5261 goto error;
5262 }
5263
5264 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5265 goto error;
5266 }
5267
5268 if (!DNP3ReadFloat32(buf, len, &object->value)) {
5269 goto error;
5270 }
5271 if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5272 goto error;
5273 }
5274
5275 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5276 goto error;
5277 }
5278
5279 object = NULL;
5280 index++;
5281 }
5282
5283 return 1;
5284error:
5285 if (object != NULL) {
5286 SCFree(object);
5287 }
5288
5289 return 0;
5290}
5291
5292static int DNP3DecodeObjectG41V4(const uint8_t **buf, uint32_t *len,
5293 uint8_t prefix_code, uint32_t start, uint32_t count,
5294 DNP3PointList *points)
5295{
5296 DNP3ObjectG41V4 *object = NULL;
5297 uint32_t prefix = 0;
5298 uint32_t index = start;
5299
5300 while (count--) {
5301
5302 object = SCCalloc(1, sizeof(*object));
5303 if (unlikely(object == NULL)) {
5304 goto error;
5305 }
5306
5307 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5308 goto error;
5309 }
5310
5311 if (!DNP3ReadFloat64(buf, len, &object->value)) {
5312 goto error;
5313 }
5314 if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5315 goto error;
5316 }
5317
5318 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5319 goto error;
5320 }
5321
5322 object = NULL;
5323 index++;
5324 }
5325
5326 return 1;
5327error:
5328 if (object != NULL) {
5329 SCFree(object);
5330 }
5331
5332 return 0;
5333}
5334
5335static int DNP3DecodeObjectG42V1(const uint8_t **buf, uint32_t *len,
5336 uint8_t prefix_code, uint32_t start, uint32_t count,
5337 DNP3PointList *points)
5338{
5339 DNP3ObjectG42V1 *object = NULL;
5340 uint32_t prefix = 0;
5341 uint32_t index = start;
5342
5343 while (count--) {
5344
5345 object = SCCalloc(1, sizeof(*object));
5346 if (unlikely(object == NULL)) {
5347 goto error;
5348 }
5349
5350 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5351 goto error;
5352 }
5353
5354 {
5355 uint8_t octet;
5356 if (!DNP3ReadUint8(buf, len, &octet)) {
5357 goto error;
5358 }
5359 object->online = (octet >> 0) & 0x1;
5360 object->restart = (octet >> 1) & 0x1;
5361 object->comm_lost = (octet >> 2) & 0x1;
5362 object->remote_forced = (octet >> 3) & 0x1;
5363 object->local_forced = (octet >> 4) & 0x1;
5364 object->over_range = (octet >> 5) & 0x1;
5365 object->reference_err = (octet >> 6) & 0x1;
5366 object->reserved0 = (octet >> 7) & 0x1;
5367 }
5368 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
5369 goto error;
5370 }
5371
5372 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5373 goto error;
5374 }
5375
5376 object = NULL;
5377 index++;
5378 }
5379
5380 return 1;
5381error:
5382 if (object != NULL) {
5383 SCFree(object);
5384 }
5385
5386 return 0;
5387}
5388
5389static int DNP3DecodeObjectG42V2(const uint8_t **buf, uint32_t *len,
5390 uint8_t prefix_code, uint32_t start, uint32_t count,
5391 DNP3PointList *points)
5392{
5393 DNP3ObjectG42V2 *object = NULL;
5394 uint32_t prefix = 0;
5395 uint32_t index = start;
5396
5397 while (count--) {
5398
5399 object = SCCalloc(1, sizeof(*object));
5400 if (unlikely(object == NULL)) {
5401 goto error;
5402 }
5403
5404 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5405 goto error;
5406 }
5407
5408 {
5409 uint8_t octet;
5410 if (!DNP3ReadUint8(buf, len, &octet)) {
5411 goto error;
5412 }
5413 object->online = (octet >> 0) & 0x1;
5414 object->restart = (octet >> 1) & 0x1;
5415 object->comm_lost = (octet >> 2) & 0x1;
5416 object->remote_forced = (octet >> 3) & 0x1;
5417 object->local_forced = (octet >> 4) & 0x1;
5418 object->over_range = (octet >> 5) & 0x1;
5419 object->reference_err = (octet >> 6) & 0x1;
5420 object->reserved0 = (octet >> 7) & 0x1;
5421 }
5422 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5423 goto error;
5424 }
5425
5426 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5427 goto error;
5428 }
5429
5430 object = NULL;
5431 index++;
5432 }
5433
5434 return 1;
5435error:
5436 if (object != NULL) {
5437 SCFree(object);
5438 }
5439
5440 return 0;
5441}
5442
5443static int DNP3DecodeObjectG42V3(const uint8_t **buf, uint32_t *len,
5444 uint8_t prefix_code, uint32_t start, uint32_t count,
5445 DNP3PointList *points)
5446{
5447 DNP3ObjectG42V3 *object = NULL;
5448 uint32_t prefix = 0;
5449 uint32_t index = start;
5450
5451 while (count--) {
5452
5453 object = SCCalloc(1, sizeof(*object));
5454 if (unlikely(object == NULL)) {
5455 goto error;
5456 }
5457
5458 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5459 goto error;
5460 }
5461
5462 {
5463 uint8_t octet;
5464 if (!DNP3ReadUint8(buf, len, &octet)) {
5465 goto error;
5466 }
5467 object->online = (octet >> 0) & 0x1;
5468 object->restart = (octet >> 1) & 0x1;
5469 object->comm_lost = (octet >> 2) & 0x1;
5470 object->remote_forced = (octet >> 3) & 0x1;
5471 object->local_forced = (octet >> 4) & 0x1;
5472 object->over_range = (octet >> 5) & 0x1;
5473 object->reference_err = (octet >> 6) & 0x1;
5474 object->reserved0 = (octet >> 7) & 0x1;
5475 }
5476 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
5477 goto error;
5478 }
5479 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5480 goto error;
5481 }
5482
5483 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5484 goto error;
5485 }
5486
5487 object = NULL;
5488 index++;
5489 }
5490
5491 return 1;
5492error:
5493 if (object != NULL) {
5494 SCFree(object);
5495 }
5496
5497 return 0;
5498}
5499
5500static int DNP3DecodeObjectG42V4(const uint8_t **buf, uint32_t *len,
5501 uint8_t prefix_code, uint32_t start, uint32_t count,
5502 DNP3PointList *points)
5503{
5504 DNP3ObjectG42V4 *object = NULL;
5505 uint32_t prefix = 0;
5506 uint32_t index = start;
5507
5508 while (count--) {
5509
5510 object = SCCalloc(1, sizeof(*object));
5511 if (unlikely(object == NULL)) {
5512 goto error;
5513 }
5514
5515 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5516 goto error;
5517 }
5518
5519 {
5520 uint8_t octet;
5521 if (!DNP3ReadUint8(buf, len, &octet)) {
5522 goto error;
5523 }
5524 object->online = (octet >> 0) & 0x1;
5525 object->restart = (octet >> 1) & 0x1;
5526 object->comm_lost = (octet >> 2) & 0x1;
5527 object->remote_forced = (octet >> 3) & 0x1;
5528 object->local_forced = (octet >> 4) & 0x1;
5529 object->over_range = (octet >> 5) & 0x1;
5530 object->reference_err = (octet >> 6) & 0x1;
5531 object->reserved0 = (octet >> 7) & 0x1;
5532 }
5533 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5534 goto error;
5535 }
5536 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5537 goto error;
5538 }
5539
5540 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5541 goto error;
5542 }
5543
5544 object = NULL;
5545 index++;
5546 }
5547
5548 return 1;
5549error:
5550 if (object != NULL) {
5551 SCFree(object);
5552 }
5553
5554 return 0;
5555}
5556
5557static int DNP3DecodeObjectG42V5(const uint8_t **buf, uint32_t *len,
5558 uint8_t prefix_code, uint32_t start, uint32_t count,
5559 DNP3PointList *points)
5560{
5561 DNP3ObjectG42V5 *object = NULL;
5562 uint32_t prefix = 0;
5563 uint32_t index = start;
5564
5565 while (count--) {
5566
5567 object = SCCalloc(1, sizeof(*object));
5568 if (unlikely(object == NULL)) {
5569 goto error;
5570 }
5571
5572 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5573 goto error;
5574 }
5575
5576 {
5577 uint8_t octet;
5578 if (!DNP3ReadUint8(buf, len, &octet)) {
5579 goto error;
5580 }
5581 object->online = (octet >> 0) & 0x1;
5582 object->restart = (octet >> 1) & 0x1;
5583 object->comm_lost = (octet >> 2) & 0x1;
5584 object->remote_forced = (octet >> 3) & 0x1;
5585 object->local_forced = (octet >> 4) & 0x1;
5586 object->over_range = (octet >> 5) & 0x1;
5587 object->reference_err = (octet >> 6) & 0x1;
5588 object->reserved0 = (octet >> 7) & 0x1;
5589 }
5590 if (!DNP3ReadFloat32(buf, len, &object->value)) {
5591 goto error;
5592 }
5593
5594 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5595 goto error;
5596 }
5597
5598 object = NULL;
5599 index++;
5600 }
5601
5602 return 1;
5603error:
5604 if (object != NULL) {
5605 SCFree(object);
5606 }
5607
5608 return 0;
5609}
5610
5611static int DNP3DecodeObjectG42V6(const uint8_t **buf, uint32_t *len,
5612 uint8_t prefix_code, uint32_t start, uint32_t count,
5613 DNP3PointList *points)
5614{
5615 DNP3ObjectG42V6 *object = NULL;
5616 uint32_t prefix = 0;
5617 uint32_t index = start;
5618
5619 while (count--) {
5620
5621 object = SCCalloc(1, sizeof(*object));
5622 if (unlikely(object == NULL)) {
5623 goto error;
5624 }
5625
5626 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5627 goto error;
5628 }
5629
5630 {
5631 uint8_t octet;
5632 if (!DNP3ReadUint8(buf, len, &octet)) {
5633 goto error;
5634 }
5635 object->online = (octet >> 0) & 0x1;
5636 object->restart = (octet >> 1) & 0x1;
5637 object->comm_lost = (octet >> 2) & 0x1;
5638 object->remote_forced = (octet >> 3) & 0x1;
5639 object->local_forced = (octet >> 4) & 0x1;
5640 object->over_range = (octet >> 5) & 0x1;
5641 object->reference_err = (octet >> 6) & 0x1;
5642 object->reserved0 = (octet >> 7) & 0x1;
5643 }
5644 if (!DNP3ReadFloat64(buf, len, &object->value)) {
5645 goto error;
5646 }
5647
5648 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5649 goto error;
5650 }
5651
5652 object = NULL;
5653 index++;
5654 }
5655
5656 return 1;
5657error:
5658 if (object != NULL) {
5659 SCFree(object);
5660 }
5661
5662 return 0;
5663}
5664
5665static int DNP3DecodeObjectG42V7(const uint8_t **buf, uint32_t *len,
5666 uint8_t prefix_code, uint32_t start, uint32_t count,
5667 DNP3PointList *points)
5668{
5669 DNP3ObjectG42V7 *object = NULL;
5670 uint32_t prefix = 0;
5671 uint32_t index = start;
5672
5673 while (count--) {
5674
5675 object = SCCalloc(1, sizeof(*object));
5676 if (unlikely(object == NULL)) {
5677 goto error;
5678 }
5679
5680 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5681 goto error;
5682 }
5683
5684 {
5685 uint8_t octet;
5686 if (!DNP3ReadUint8(buf, len, &octet)) {
5687 goto error;
5688 }
5689 object->online = (octet >> 0) & 0x1;
5690 object->restart = (octet >> 1) & 0x1;
5691 object->comm_lost = (octet >> 2) & 0x1;
5692 object->remote_forced = (octet >> 3) & 0x1;
5693 object->local_forced = (octet >> 4) & 0x1;
5694 object->over_range = (octet >> 5) & 0x1;
5695 object->reference_err = (octet >> 6) & 0x1;
5696 object->reserved0 = (octet >> 7) & 0x1;
5697 }
5698 if (!DNP3ReadFloat32(buf, len, &object->value)) {
5699 goto error;
5700 }
5701 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5702 goto error;
5703 }
5704
5705 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5706 goto error;
5707 }
5708
5709 object = NULL;
5710 index++;
5711 }
5712
5713 return 1;
5714error:
5715 if (object != NULL) {
5716 SCFree(object);
5717 }
5718
5719 return 0;
5720}
5721
5722static int DNP3DecodeObjectG42V8(const uint8_t **buf, uint32_t *len,
5723 uint8_t prefix_code, uint32_t start, uint32_t count,
5724 DNP3PointList *points)
5725{
5726 DNP3ObjectG42V8 *object = NULL;
5727 uint32_t prefix = 0;
5728 uint32_t index = start;
5729
5730 while (count--) {
5731
5732 object = SCCalloc(1, sizeof(*object));
5733 if (unlikely(object == NULL)) {
5734 goto error;
5735 }
5736
5737 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5738 goto error;
5739 }
5740
5741 {
5742 uint8_t octet;
5743 if (!DNP3ReadUint8(buf, len, &octet)) {
5744 goto error;
5745 }
5746 object->online = (octet >> 0) & 0x1;
5747 object->restart = (octet >> 1) & 0x1;
5748 object->comm_lost = (octet >> 2) & 0x1;
5749 object->remote_forced = (octet >> 3) & 0x1;
5750 object->local_forced = (octet >> 4) & 0x1;
5751 object->over_range = (octet >> 5) & 0x1;
5752 object->reference_err = (octet >> 6) & 0x1;
5753 object->reserved0 = (octet >> 7) & 0x1;
5754 }
5755 if (!DNP3ReadFloat64(buf, len, &object->value)) {
5756 goto error;
5757 }
5758 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5759 goto error;
5760 }
5761
5762 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5763 goto error;
5764 }
5765
5766 object = NULL;
5767 index++;
5768 }
5769
5770 return 1;
5771error:
5772 if (object != NULL) {
5773 SCFree(object);
5774 }
5775
5776 return 0;
5777}
5778
5779static int DNP3DecodeObjectG43V1(const uint8_t **buf, uint32_t *len,
5780 uint8_t prefix_code, uint32_t start, uint32_t count,
5781 DNP3PointList *points)
5782{
5783 DNP3ObjectG43V1 *object = NULL;
5784 uint32_t prefix = 0;
5785 uint32_t index = start;
5786
5787 while (count--) {
5788
5789 object = SCCalloc(1, sizeof(*object));
5790 if (unlikely(object == NULL)) {
5791 goto error;
5792 }
5793
5794 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5795 goto error;
5796 }
5797
5798 {
5799 uint8_t octet;
5800 if (!DNP3ReadUint8(buf, len, &octet)) {
5801 goto error;
5802 }
5803 object->status_code = (octet >> 0) & 0x7f;
5804 object->reserved0 = (octet >> 7) & 0x1;
5805 }
5806 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->commanded_value)) {
5807 goto error;
5808 }
5809
5810 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5811 goto error;
5812 }
5813
5814 object = NULL;
5815 index++;
5816 }
5817
5818 return 1;
5819error:
5820 if (object != NULL) {
5821 SCFree(object);
5822 }
5823
5824 return 0;
5825}
5826
5827static int DNP3DecodeObjectG43V2(const uint8_t **buf, uint32_t *len,
5828 uint8_t prefix_code, uint32_t start, uint32_t count,
5829 DNP3PointList *points)
5830{
5831 DNP3ObjectG43V2 *object = NULL;
5832 uint32_t prefix = 0;
5833 uint32_t index = start;
5834
5835 while (count--) {
5836
5837 object = SCCalloc(1, sizeof(*object));
5838 if (unlikely(object == NULL)) {
5839 goto error;
5840 }
5841
5842 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5843 goto error;
5844 }
5845
5846 {
5847 uint8_t octet;
5848 if (!DNP3ReadUint8(buf, len, &octet)) {
5849 goto error;
5850 }
5851 object->status_code = (octet >> 0) & 0x7f;
5852 object->reserved0 = (octet >> 7) & 0x1;
5853 }
5854 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->commanded_value)) {
5855 goto error;
5856 }
5857
5858 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5859 goto error;
5860 }
5861
5862 object = NULL;
5863 index++;
5864 }
5865
5866 return 1;
5867error:
5868 if (object != NULL) {
5869 SCFree(object);
5870 }
5871
5872 return 0;
5873}
5874
5875static int DNP3DecodeObjectG43V3(const uint8_t **buf, uint32_t *len,
5876 uint8_t prefix_code, uint32_t start, uint32_t count,
5877 DNP3PointList *points)
5878{
5879 DNP3ObjectG43V3 *object = NULL;
5880 uint32_t prefix = 0;
5881 uint32_t index = start;
5882
5883 while (count--) {
5884
5885 object = SCCalloc(1, sizeof(*object));
5886 if (unlikely(object == NULL)) {
5887 goto error;
5888 }
5889
5890 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5891 goto error;
5892 }
5893
5894 {
5895 uint8_t octet;
5896 if (!DNP3ReadUint8(buf, len, &octet)) {
5897 goto error;
5898 }
5899 object->status_code = (octet >> 0) & 0x7f;
5900 object->reserved0 = (octet >> 7) & 0x1;
5901 }
5902 if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->commanded_value)) {
5903 goto error;
5904 }
5905 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5906 goto error;
5907 }
5908
5909 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5910 goto error;
5911 }
5912
5913 object = NULL;
5914 index++;
5915 }
5916
5917 return 1;
5918error:
5919 if (object != NULL) {
5920 SCFree(object);
5921 }
5922
5923 return 0;
5924}
5925
5926static int DNP3DecodeObjectG43V4(const uint8_t **buf, uint32_t *len,
5927 uint8_t prefix_code, uint32_t start, uint32_t count,
5928 DNP3PointList *points)
5929{
5930 DNP3ObjectG43V4 *object = NULL;
5931 uint32_t prefix = 0;
5932 uint32_t index = start;
5933
5934 while (count--) {
5935
5936 object = SCCalloc(1, sizeof(*object));
5937 if (unlikely(object == NULL)) {
5938 goto error;
5939 }
5940
5941 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5942 goto error;
5943 }
5944
5945 {
5946 uint8_t octet;
5947 if (!DNP3ReadUint8(buf, len, &octet)) {
5948 goto error;
5949 }
5950 object->status_code = (octet >> 0) & 0x7f;
5951 object->reserved0 = (octet >> 7) & 0x1;
5952 }
5953 if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->commanded_value)) {
5954 goto error;
5955 }
5956 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5957 goto error;
5958 }
5959
5960 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
5961 goto error;
5962 }
5963
5964 object = NULL;
5965 index++;
5966 }
5967
5968 return 1;
5969error:
5970 if (object != NULL) {
5971 SCFree(object);
5972 }
5973
5974 return 0;
5975}
5976
5977static int DNP3DecodeObjectG43V5(const uint8_t **buf, uint32_t *len,
5978 uint8_t prefix_code, uint32_t start, uint32_t count,
5979 DNP3PointList *points)
5980{
5981 DNP3ObjectG43V5 *object = NULL;
5982 uint32_t prefix = 0;
5983 uint32_t index = start;
5984
5985 while (count--) {
5986
5987 object = SCCalloc(1, sizeof(*object));
5988 if (unlikely(object == NULL)) {
5989 goto error;
5990 }
5991
5992 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5993 goto error;
5994 }
5995
5996 {
5997 uint8_t octet;
5998 if (!DNP3ReadUint8(buf, len, &octet)) {
5999 goto error;
6000 }
6001 object->status_code = (octet >> 0) & 0x7f;
6002 object->reserved0 = (octet >> 7) & 0x1;
6003 }
6004 if (!DNP3ReadFloat32(buf, len, &object->commanded_value)) {
6005 goto error;
6006 }
6007
6008 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6009 goto error;
6010 }
6011
6012 object = NULL;
6013 index++;
6014 }
6015
6016 return 1;
6017error:
6018 if (object != NULL) {
6019 SCFree(object);
6020 }
6021
6022 return 0;
6023}
6024
6025static int DNP3DecodeObjectG43V6(const uint8_t **buf, uint32_t *len,
6026 uint8_t prefix_code, uint32_t start, uint32_t count,
6027 DNP3PointList *points)
6028{
6029 DNP3ObjectG43V6 *object = NULL;
6030 uint32_t prefix = 0;
6031 uint32_t index = start;
6032
6033 while (count--) {
6034
6035 object = SCCalloc(1, sizeof(*object));
6036 if (unlikely(object == NULL)) {
6037 goto error;
6038 }
6039
6040 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6041 goto error;
6042 }
6043
6044 {
6045 uint8_t octet;
6046 if (!DNP3ReadUint8(buf, len, &octet)) {
6047 goto error;
6048 }
6049 object->status_code = (octet >> 0) & 0x7f;
6050 object->reserved0 = (octet >> 7) & 0x1;
6051 }
6052 if (!DNP3ReadFloat64(buf, len, &object->commanded_value)) {
6053 goto error;
6054 }
6055
6056 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6057 goto error;
6058 }
6059
6060 object = NULL;
6061 index++;
6062 }
6063
6064 return 1;
6065error:
6066 if (object != NULL) {
6067 SCFree(object);
6068 }
6069
6070 return 0;
6071}
6072
6073static int DNP3DecodeObjectG43V7(const uint8_t **buf, uint32_t *len,
6074 uint8_t prefix_code, uint32_t start, uint32_t count,
6075 DNP3PointList *points)
6076{
6077 DNP3ObjectG43V7 *object = NULL;
6078 uint32_t prefix = 0;
6079 uint32_t index = start;
6080
6081 while (count--) {
6082
6083 object = SCCalloc(1, sizeof(*object));
6084 if (unlikely(object == NULL)) {
6085 goto error;
6086 }
6087
6088 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6089 goto error;
6090 }
6091
6092 {
6093 uint8_t octet;
6094 if (!DNP3ReadUint8(buf, len, &octet)) {
6095 goto error;
6096 }
6097 object->status_code = (octet >> 0) & 0x7f;
6098 object->reserved0 = (octet >> 7) & 0x1;
6099 }
6100 if (!DNP3ReadFloat32(buf, len, &object->commanded_value)) {
6101 goto error;
6102 }
6103 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6104 goto error;
6105 }
6106
6107 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6108 goto error;
6109 }
6110
6111 object = NULL;
6112 index++;
6113 }
6114
6115 return 1;
6116error:
6117 if (object != NULL) {
6118 SCFree(object);
6119 }
6120
6121 return 0;
6122}
6123
6124static int DNP3DecodeObjectG43V8(const uint8_t **buf, uint32_t *len,
6125 uint8_t prefix_code, uint32_t start, uint32_t count,
6126 DNP3PointList *points)
6127{
6128 DNP3ObjectG43V8 *object = NULL;
6129 uint32_t prefix = 0;
6130 uint32_t index = start;
6131
6132 while (count--) {
6133
6134 object = SCCalloc(1, sizeof(*object));
6135 if (unlikely(object == NULL)) {
6136 goto error;
6137 }
6138
6139 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6140 goto error;
6141 }
6142
6143 {
6144 uint8_t octet;
6145 if (!DNP3ReadUint8(buf, len, &octet)) {
6146 goto error;
6147 }
6148 object->status_code = (octet >> 0) & 0x7f;
6149 object->reserved0 = (octet >> 7) & 0x1;
6150 }
6151 if (!DNP3ReadFloat64(buf, len, &object->commanded_value)) {
6152 goto error;
6153 }
6154 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6155 goto error;
6156 }
6157
6158 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6159 goto error;
6160 }
6161
6162 object = NULL;
6163 index++;
6164 }
6165
6166 return 1;
6167error:
6168 if (object != NULL) {
6169 SCFree(object);
6170 }
6171
6172 return 0;
6173}
6174
6175static int DNP3DecodeObjectG50V1(const uint8_t **buf, uint32_t *len,
6176 uint8_t prefix_code, uint32_t start, uint32_t count,
6177 DNP3PointList *points)
6178{
6179 DNP3ObjectG50V1 *object = NULL;
6180 uint32_t prefix = 0;
6181 uint32_t index = start;
6182
6183 while (count--) {
6184
6185 object = SCCalloc(1, sizeof(*object));
6186 if (unlikely(object == NULL)) {
6187 goto error;
6188 }
6189
6190 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6191 goto error;
6192 }
6193
6194 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6195 goto error;
6196 }
6197
6198 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6199 goto error;
6200 }
6201
6202 object = NULL;
6203 index++;
6204 }
6205
6206 return 1;
6207error:
6208 if (object != NULL) {
6209 SCFree(object);
6210 }
6211
6212 return 0;
6213}
6214
6215static int DNP3DecodeObjectG50V2(const uint8_t **buf, uint32_t *len,
6216 uint8_t prefix_code, uint32_t start, uint32_t count,
6217 DNP3PointList *points)
6218{
6219 DNP3ObjectG50V2 *object = NULL;
6220 uint32_t prefix = 0;
6221 uint32_t index = start;
6222
6223 while (count--) {
6224
6225 object = SCCalloc(1, sizeof(*object));
6226 if (unlikely(object == NULL)) {
6227 goto error;
6228 }
6229
6230 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6231 goto error;
6232 }
6233
6234 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6235 goto error;
6236 }
6237 if (!DNP3ReadUint32(buf, len, &object->interval)) {
6238 goto error;
6239 }
6240
6241 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6242 goto error;
6243 }
6244
6245 object = NULL;
6246 index++;
6247 }
6248
6249 return 1;
6250error:
6251 if (object != NULL) {
6252 SCFree(object);
6253 }
6254
6255 return 0;
6256}
6257
6258static int DNP3DecodeObjectG50V3(const uint8_t **buf, uint32_t *len,
6259 uint8_t prefix_code, uint32_t start, uint32_t count,
6260 DNP3PointList *points)
6261{
6262 DNP3ObjectG50V3 *object = NULL;
6263 uint32_t prefix = 0;
6264 uint32_t index = start;
6265
6266 while (count--) {
6267
6268 object = SCCalloc(1, sizeof(*object));
6269 if (unlikely(object == NULL)) {
6270 goto error;
6271 }
6272
6273 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6274 goto error;
6275 }
6276
6277 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6278 goto error;
6279 }
6280
6281 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6282 goto error;
6283 }
6284
6285 object = NULL;
6286 index++;
6287 }
6288
6289 return 1;
6290error:
6291 if (object != NULL) {
6292 SCFree(object);
6293 }
6294
6295 return 0;
6296}
6297
6298static int DNP3DecodeObjectG50V4(const uint8_t **buf, uint32_t *len,
6299 uint8_t prefix_code, uint32_t start, uint32_t count,
6300 DNP3PointList *points)
6301{
6302 DNP3ObjectG50V4 *object = NULL;
6303 uint32_t prefix = 0;
6304 uint32_t index = start;
6305
6306 while (count--) {
6307
6308 object = SCCalloc(1, sizeof(*object));
6309 if (unlikely(object == NULL)) {
6310 goto error;
6311 }
6312
6313 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6314 goto error;
6315 }
6316
6317 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6318 goto error;
6319 }
6320 if (!DNP3ReadUint32(buf, len, &object->interval_count)) {
6321 goto error;
6322 }
6323 if (!DNP3ReadUint8(buf, len, &object->interval_units)) {
6324 goto error;
6325 }
6326
6327 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6328 goto error;
6329 }
6330
6331 object = NULL;
6332 index++;
6333 }
6334
6335 return 1;
6336error:
6337 if (object != NULL) {
6338 SCFree(object);
6339 }
6340
6341 return 0;
6342}
6343
6344static int DNP3DecodeObjectG51V1(const uint8_t **buf, uint32_t *len,
6345 uint8_t prefix_code, uint32_t start, uint32_t count,
6346 DNP3PointList *points)
6347{
6348 DNP3ObjectG51V1 *object = NULL;
6349 uint32_t prefix = 0;
6350 uint32_t index = start;
6351
6352 while (count--) {
6353
6354 object = SCCalloc(1, sizeof(*object));
6355 if (unlikely(object == NULL)) {
6356 goto error;
6357 }
6358
6359 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6360 goto error;
6361 }
6362
6363 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6364 goto error;
6365 }
6366
6367 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6368 goto error;
6369 }
6370
6371 object = NULL;
6372 index++;
6373 }
6374
6375 return 1;
6376error:
6377 if (object != NULL) {
6378 SCFree(object);
6379 }
6380
6381 return 0;
6382}
6383
6384static int DNP3DecodeObjectG51V2(const uint8_t **buf, uint32_t *len,
6385 uint8_t prefix_code, uint32_t start, uint32_t count,
6386 DNP3PointList *points)
6387{
6388 DNP3ObjectG51V2 *object = NULL;
6389 uint32_t prefix = 0;
6390 uint32_t index = start;
6391
6392 while (count--) {
6393
6394 object = SCCalloc(1, sizeof(*object));
6395 if (unlikely(object == NULL)) {
6396 goto error;
6397 }
6398
6399 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6400 goto error;
6401 }
6402
6403 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6404 goto error;
6405 }
6406
6407 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6408 goto error;
6409 }
6410
6411 object = NULL;
6412 index++;
6413 }
6414
6415 return 1;
6416error:
6417 if (object != NULL) {
6418 SCFree(object);
6419 }
6420
6421 return 0;
6422}
6423
6424static int DNP3DecodeObjectG52V1(const uint8_t **buf, uint32_t *len,
6425 uint8_t prefix_code, uint32_t start, uint32_t count,
6426 DNP3PointList *points)
6427{
6428 DNP3ObjectG52V1 *object = NULL;
6429 uint32_t prefix = 0;
6430 uint32_t index = start;
6431
6432 while (count--) {
6433
6434 object = SCCalloc(1, sizeof(*object));
6435 if (unlikely(object == NULL)) {
6436 goto error;
6437 }
6438
6439 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6440 goto error;
6441 }
6442
6443 if (!DNP3ReadUint16(buf, len, &object->delay_secs)) {
6444 goto error;
6445 }
6446
6447 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6448 goto error;
6449 }
6450
6451 object = NULL;
6452 index++;
6453 }
6454
6455 return 1;
6456error:
6457 if (object != NULL) {
6458 SCFree(object);
6459 }
6460
6461 return 0;
6462}
6463
6464static int DNP3DecodeObjectG52V2(const uint8_t **buf, uint32_t *len,
6465 uint8_t prefix_code, uint32_t start, uint32_t count,
6466 DNP3PointList *points)
6467{
6468 DNP3ObjectG52V2 *object = NULL;
6469 uint32_t prefix = 0;
6470 uint32_t index = start;
6471
6472 while (count--) {
6473
6474 object = SCCalloc(1, sizeof(*object));
6475 if (unlikely(object == NULL)) {
6476 goto error;
6477 }
6478
6479 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6480 goto error;
6481 }
6482
6483 if (!DNP3ReadUint16(buf, len, &object->delay_ms)) {
6484 goto error;
6485 }
6486
6487 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6488 goto error;
6489 }
6490
6491 object = NULL;
6492 index++;
6493 }
6494
6495 return 1;
6496error:
6497 if (object != NULL) {
6498 SCFree(object);
6499 }
6500
6501 return 0;
6502}
6503
6504static int DNP3DecodeObjectG70V1(const uint8_t **buf, uint32_t *len,
6505 uint8_t prefix_code, uint32_t start, uint32_t count,
6506 DNP3PointList *points)
6507{
6508 DNP3ObjectG70V1 *object = NULL;
6509 uint32_t prefix = 0;
6510 uint32_t index = start;
6511
6512 while (count--) {
6513
6514 object = SCCalloc(1, sizeof(*object));
6515 if (unlikely(object == NULL)) {
6516 goto error;
6517 }
6518
6519 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6520 goto error;
6521 }
6522
6523 if (!DNP3ReadUint16(buf, len, &object->filename_size)) {
6524 goto error;
6525 }
6526 if (!DNP3ReadUint8(buf, len, &object->filetype_code)) {
6527 goto error;
6528 }
6529 if (!DNP3ReadUint8(buf, len, &object->attribute_code)) {
6530 goto error;
6531 }
6532 if (!DNP3ReadUint16(buf, len, &object->start_record)) {
6533 goto error;
6534 }
6535 if (!DNP3ReadUint16(buf, len, &object->end_record)) {
6536 goto error;
6537 }
6538 if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6539 goto error;
6540 }
6541 if (!DNP3ReadUint48(buf, len, &object->created_timestamp)) {
6542 goto error;
6543 }
6544 if (!DNP3ReadUint16(buf, len, &object->permission)) {
6545 goto error;
6546 }
6547 if (!DNP3ReadUint32(buf, len, &object->file_id)) {
6548 goto error;
6549 }
6550 if (!DNP3ReadUint32(buf, len, &object->owner_id)) {
6551 goto error;
6552 }
6553 if (!DNP3ReadUint32(buf, len, &object->group_id)) {
6554 goto error;
6555 }
6556 if (!DNP3ReadUint8(buf, len, &object->file_function_code)) {
6557 goto error;
6558 }
6559 if (!DNP3ReadUint8(buf, len, &object->status_code)) {
6560 goto error;
6561 }
6562 if (object->filename_size > 0) {
6563 memcpy(object->filename, *buf, object->filename_size);
6564 *buf += object->filename_size;
6565 *len -= object->filename_size;
6566 }
6567 object->filename[object->filename_size] = '\0';
6568 if (!DNP3ReadUint16(buf, len, &object->data_size)) {
6569 goto error;
6570 }
6571 if (object->data_size > 0) {
6572 memcpy(object->data, *buf, object->data_size);
6573 *buf += object->data_size;
6574 *len -= object->data_size;
6575 }
6576 object->data[object->data_size] = '\0';
6577
6578 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6579 goto error;
6580 }
6581
6582 object = NULL;
6583 index++;
6584 }
6585
6586 return 1;
6587error:
6588 if (object != NULL) {
6589 SCFree(object);
6590 }
6591
6592 return 0;
6593}
6594
6595static int DNP3DecodeObjectG70V2(const uint8_t **buf, uint32_t *len,
6596 uint8_t prefix_code, uint32_t start, uint32_t count,
6597 DNP3PointList *points)
6598{
6599 DNP3ObjectG70V2 *object = NULL;
6600 uint32_t prefix = 0;
6601 uint32_t index = start;
6602
6603 while (count--) {
6604
6605 object = SCCalloc(1, sizeof(*object));
6606 if (unlikely(object == NULL)) {
6607 goto error;
6608 }
6609
6610 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6611 goto error;
6612 }
6613
6614 if (!DNP3ReadUint16(buf, len, &object->username_offset)) {
6615 goto error;
6616 }
6617 if (!DNP3ReadUint16(buf, len, &object->username_size)) {
6618 goto error;
6619 }
6620 if (!DNP3ReadUint16(buf, len, &object->password_offset)) {
6621 goto error;
6622 }
6623 if (!DNP3ReadUint16(buf, len, &object->password_size)) {
6624 goto error;
6625 }
6626 if (!DNP3ReadUint32(buf, len, &object->authentication_key)) {
6627 goto error;
6628 }
6629 if (object->username_size > 0) {
6630 memcpy(object->username, *buf, object->username_size);
6631 *buf += object->username_size;
6632 *len -= object->username_size;
6633 }
6634 object->username[object->username_size] = '\0';
6635 if (object->password_size > 0) {
6636 memcpy(object->password, *buf, object->password_size);
6637 *buf += object->password_size;
6638 *len -= object->password_size;
6639 }
6640 object->password[object->password_size] = '\0';
6641
6642 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6643 goto error;
6644 }
6645
6646 object = NULL;
6647 index++;
6648 }
6649
6650 return 1;
6651error:
6652 if (object != NULL) {
6653 SCFree(object);
6654 }
6655
6656 return 0;
6657}
6658
6659static int DNP3DecodeObjectG70V3(const uint8_t **buf, uint32_t *len,
6660 uint8_t prefix_code, uint32_t start, uint32_t count,
6661 DNP3PointList *points)
6662{
6663 DNP3ObjectG70V3 *object = NULL;
6664 uint32_t prefix = 0;
6665 uint32_t index = start;
6666
6667 while (count--) {
6668
6669 object = SCCalloc(1, sizeof(*object));
6670 if (unlikely(object == NULL)) {
6671 goto error;
6672 }
6673
6674 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6675 goto error;
6676 }
6677
6678 if (!DNP3ReadUint16(buf, len, &object->filename_offset)) {
6679 goto error;
6680 }
6681 if (!DNP3ReadUint16(buf, len, &object->filename_size)) {
6682 goto error;
6683 }
6684 if (!DNP3ReadUint48(buf, len, &object->created)) {
6685 goto error;
6686 }
6687 if (!DNP3ReadUint16(buf, len, &object->permissions)) {
6688 goto error;
6689 }
6690 if (!DNP3ReadUint32(buf, len, &object->authentication_key)) {
6691 goto error;
6692 }
6693 if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6694 goto error;
6695 }
6696 if (!DNP3ReadUint16(buf, len, &object->operational_mode)) {
6697 goto error;
6698 }
6699 if (!DNP3ReadUint16(buf, len, &object->maximum_block_size)) {
6700 goto error;
6701 }
6702 if (!DNP3ReadUint16(buf, len, &object->request_id)) {
6703 goto error;
6704 }
6705 if (object->filename_size > 0) {
6706 memcpy(object->filename, *buf, object->filename_size);
6707 *buf += object->filename_size;
6708 *len -= object->filename_size;
6709 }
6710 object->filename[object->filename_size] = '\0';
6711
6712 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6713 goto error;
6714 }
6715
6716 object = NULL;
6717 index++;
6718 }
6719
6720 return 1;
6721error:
6722 if (object != NULL) {
6723 SCFree(object);
6724 }
6725
6726 return 0;
6727}
6728
6729static int DNP3DecodeObjectG70V4(const uint8_t **buf, uint32_t *len,
6730 uint8_t prefix_code, uint32_t start, uint32_t count,
6731 DNP3PointList *points)
6732{
6733 DNP3ObjectG70V4 *object = NULL;
6734 uint32_t prefix = 0;
6735 uint32_t index = start;
6736 uint32_t offset;
6737
6738 if (!DNP3PrefixIsSize(prefix_code)) {
6739 goto error;
6740 }
6741
6742 while (count--) {
6743
6744 object = SCCalloc(1, sizeof(*object));
6745 if (unlikely(object == NULL)) {
6746 goto error;
6747 }
6748
6749 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6750 goto error;
6751 }
6752
6753 offset = *len;
6754
6755 if (!DNP3ReadUint32(buf, len, &object->file_handle)) {
6756 goto error;
6757 }
6758 if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6759 goto error;
6760 }
6761 if (!DNP3ReadUint16(buf, len, &object->maximum_block_size)) {
6762 goto error;
6763 }
6764 if (!DNP3ReadUint16(buf, len, &object->request_id)) {
6765 goto error;
6766 }
6767 if (!DNP3ReadUint8(buf, len, &object->status_code)) {
6768 goto error;
6769 }
6770 object->optional_text_len = prefix - (offset - *len);
6771 if (object->optional_text_len > 0) {
6772 memcpy(object->optional_text, *buf, object->optional_text_len);
6773 *buf += object->optional_text_len;
6774 *len -= object->optional_text_len;
6775 }
6776 object->optional_text[object->optional_text_len] = '\0';
6777
6778 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6779 goto error;
6780 }
6781
6782 object = NULL;
6783 index++;
6784 }
6785
6786 return 1;
6787error:
6788 if (object != NULL) {
6789 SCFree(object);
6790 }
6791
6792 return 0;
6793}
6794
6795static int DNP3DecodeObjectG70V5(const uint8_t **buf, uint32_t *len,
6796 uint8_t prefix_code, uint32_t start, uint32_t count,
6797 DNP3PointList *points)
6798{
6799 DNP3ObjectG70V5 *object = NULL;
6800 uint32_t prefix = 0;
6801 uint32_t index = start;
6802 uint32_t offset;
6803
6804 if (!DNP3PrefixIsSize(prefix_code)) {
6805 goto error;
6806 }
6807
6808 while (count--) {
6809
6810 object = SCCalloc(1, sizeof(*object));
6811 if (unlikely(object == NULL)) {
6812 goto error;
6813 }
6814
6815 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6816 goto error;
6817 }
6818
6819 offset = *len;
6820
6821 if (!DNP3ReadUint32(buf, len, &object->file_handle)) {
6822 goto error;
6823 }
6824 if (!DNP3ReadUint32(buf, len, &object->block_number)) {
6825 goto error;
6826 }
6827 object->file_data_len = prefix - (offset - *len);
6828 if (object->file_data_len > 0) {
6829 memcpy(object->file_data, *buf, object->file_data_len);
6830 *buf += object->file_data_len;
6831 *len -= object->file_data_len;
6832 }
6833 object->file_data[object->file_data_len] = '\0';
6834
6835 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6836 goto error;
6837 }
6838
6839 object = NULL;
6840 index++;
6841 }
6842
6843 return 1;
6844error:
6845 if (object != NULL) {
6846 SCFree(object);
6847 }
6848
6849 return 0;
6850}
6851
6852static int DNP3DecodeObjectG70V6(const uint8_t **buf, uint32_t *len,
6853 uint8_t prefix_code, uint32_t start, uint32_t count,
6854 DNP3PointList *points)
6855{
6856 DNP3ObjectG70V6 *object = NULL;
6857 uint32_t prefix = 0;
6858 uint32_t index = start;
6859 uint32_t offset;
6860
6861 if (!DNP3PrefixIsSize(prefix_code)) {
6862 goto error;
6863 }
6864
6865 while (count--) {
6866
6867 object = SCCalloc(1, sizeof(*object));
6868 if (unlikely(object == NULL)) {
6869 goto error;
6870 }
6871
6872 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6873 goto error;
6874 }
6875
6876 offset = *len;
6877
6878 if (!DNP3ReadUint32(buf, len, &object->file_handle)) {
6879 goto error;
6880 }
6881 if (!DNP3ReadUint32(buf, len, &object->block_number)) {
6882 goto error;
6883 }
6884 if (!DNP3ReadUint8(buf, len, &object->status_code)) {
6885 goto error;
6886 }
6887 object->optional_text_len = prefix - (offset - *len);
6888 if (object->optional_text_len > 0) {
6889 memcpy(object->optional_text, *buf, object->optional_text_len);
6890 *buf += object->optional_text_len;
6891 *len -= object->optional_text_len;
6892 }
6893 object->optional_text[object->optional_text_len] = '\0';
6894
6895 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6896 goto error;
6897 }
6898
6899 object = NULL;
6900 index++;
6901 }
6902
6903 return 1;
6904error:
6905 if (object != NULL) {
6906 SCFree(object);
6907 }
6908
6909 return 0;
6910}
6911
6912static int DNP3DecodeObjectG70V7(const uint8_t **buf, uint32_t *len,
6913 uint8_t prefix_code, uint32_t start, uint32_t count,
6914 DNP3PointList *points)
6915{
6916 DNP3ObjectG70V7 *object = NULL;
6917 uint32_t prefix = 0;
6918 uint32_t index = start;
6919
6920 while (count--) {
6921
6922 object = SCCalloc(1, sizeof(*object));
6923 if (unlikely(object == NULL)) {
6924 goto error;
6925 }
6926
6927 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6928 goto error;
6929 }
6930
6931 if (!DNP3ReadUint16(buf, len, &object->filename_offset)) {
6932 goto error;
6933 }
6934 if (!DNP3ReadUint16(buf, len, &object->filename_size)) {
6935 goto error;
6936 }
6937 if (!DNP3ReadUint16(buf, len, &object->file_type)) {
6938 goto error;
6939 }
6940 if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6941 goto error;
6942 }
6943 if (!DNP3ReadUint48(buf, len, &object->created_timestamp)) {
6944 goto error;
6945 }
6946 if (!DNP3ReadUint16(buf, len, &object->permissions)) {
6947 goto error;
6948 }
6949 if (!DNP3ReadUint16(buf, len, &object->request_id)) {
6950 goto error;
6951 }
6952 if (object->filename_size > 0) {
6953 memcpy(object->filename, *buf, object->filename_size);
6954 *buf += object->filename_size;
6955 *len -= object->filename_size;
6956 }
6957 object->filename[object->filename_size] = '\0';
6958
6959 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
6960 goto error;
6961 }
6962
6963 object = NULL;
6964 index++;
6965 }
6966
6967 return 1;
6968error:
6969 if (object != NULL) {
6970 SCFree(object);
6971 }
6972
6973 return 0;
6974}
6975
6976static int DNP3DecodeObjectG70V8(const uint8_t **buf, uint32_t *len,
6977 uint8_t prefix_code, uint32_t start, uint32_t count,
6978 DNP3PointList *points)
6979{
6980 DNP3ObjectG70V8 *object = NULL;
6981 uint32_t prefix = 0;
6982 uint32_t index = start;
6983 uint32_t offset;
6984
6985 if (prefix_code != 5) {
6986 goto error;
6987 }
6988
6989 while (count--) {
6990
6991 object = SCCalloc(1, sizeof(*object));
6992 if (unlikely(object == NULL)) {
6993 goto error;
6994 }
6995
6996 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6997 goto error;
6998 }
6999
7000 offset = *len;
7001
7002 object->file_specification_len = prefix - (offset - *len);
7003 if (object->file_specification_len > 0) {
7004 memcpy(object->file_specification, *buf, object->file_specification_len);
7005 *buf += object->file_specification_len;
7006 *len -= object->file_specification_len;
7007 }
7008 object->file_specification[object->file_specification_len] = '\0';
7009
7010 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7011 goto error;
7012 }
7013
7014 object = NULL;
7015 index++;
7016 }
7017
7018 return 1;
7019error:
7020 if (object != NULL) {
7021 SCFree(object);
7022 }
7023
7024 return 0;
7025}
7026
7027static int DNP3DecodeObjectG80V1(const uint8_t **buf, uint32_t *len,
7028 uint8_t prefix_code, uint32_t start, uint32_t count,
7029 DNP3PointList *points)
7030{
7031 DNP3ObjectG80V1 *object = NULL;
7032 int bytes = (count / 8) + 1;
7033 uint32_t prefix = 0;
7034 int index = start;
7035
7036 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7037 goto error;
7038 }
7039
7040 for (int i = 0; i < bytes; i++) {
7041
7042 uint8_t octet;
7043
7044 if (!DNP3ReadUint8(buf, len, &octet)) {
7045 goto error;
7046 }
7047
7048 for (int j = 0; j < 8 && count; j = j + 1) {
7049
7050 object = SCCalloc(1, sizeof(*object));
7051 if (unlikely(object == NULL)) {
7052 goto error;
7053 }
7054
7055 object->state = (octet >> j) & 0x1;
7056
7057 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7058 goto error;
7059 }
7060
7061 object = NULL;
7062 count--;
7063 index++;
7064 }
7065
7066 }
7067
7068 return 1;
7069error:
7070 if (object != NULL) {
7071 SCFree(object);
7072 }
7073 return 0;
7074}
7075
7076static int DNP3DecodeObjectG81V1(const uint8_t **buf, uint32_t *len,
7077 uint8_t prefix_code, uint32_t start, uint32_t count,
7078 DNP3PointList *points)
7079{
7080 DNP3ObjectG81V1 *object = NULL;
7081 uint32_t prefix = 0;
7082 uint32_t index = start;
7083
7084 while (count--) {
7085
7086 object = SCCalloc(1, sizeof(*object));
7087 if (unlikely(object == NULL)) {
7088 goto error;
7089 }
7090
7091 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7092 goto error;
7093 }
7094
7095 {
7096 uint8_t octet;
7097 if (!DNP3ReadUint8(buf, len, &octet)) {
7098 goto error;
7099 }
7100 object->fill_percentage = (octet >> 0) & 0x7f;
7101 object->overflow_state = (octet >> 7) & 0x1;
7102 }
7103 if (!DNP3ReadUint8(buf, len, &object->group)) {
7104 goto error;
7105 }
7106 if (!DNP3ReadUint8(buf, len, &object->variation)) {
7107 goto error;
7108 }
7109
7110 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7111 goto error;
7112 }
7113
7114 object = NULL;
7115 index++;
7116 }
7117
7118 return 1;
7119error:
7120 if (object != NULL) {
7121 SCFree(object);
7122 }
7123
7124 return 0;
7125}
7126
7127static int DNP3DecodeObjectG83V1(const uint8_t **buf, uint32_t *len,
7128 uint8_t prefix_code, uint32_t start, uint32_t count,
7129 DNP3PointList *points)
7130{
7131 DNP3ObjectG83V1 *object = NULL;
7132 uint32_t prefix = 0;
7133 uint32_t index = start;
7134
7135 while (count--) {
7136
7137 object = SCCalloc(1, sizeof(*object));
7138 if (unlikely(object == NULL)) {
7139 goto error;
7140 }
7141
7142 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7143 goto error;
7144 }
7145
7146 if (*len < 4) {
7147 goto error;
7148 }
7149 memcpy(object->vendor_code, *buf, 4);
7150 object->vendor_code[4] = '\0';
7151 *buf += 4;
7152 *len -= 4;
7153 if (!DNP3ReadUint16(buf, len, &object->object_id)) {
7154 goto error;
7155 }
7156 if (!DNP3ReadUint16(buf, len, &object->length)) {
7157 goto error;
7158 }
7159 if (object->length > 0) {
7160 if (*len < object->length) {
7161 /* Not enough data. */
7162 goto error;
7163 }
7164 object->data_objects = SCCalloc(1, object->length);
7165 if (unlikely(object->data_objects == NULL)) {
7166 goto error;
7167 }
7168 memcpy(object->data_objects, *buf, object->length);
7169 *buf += object->length;
7170 *len -= object->length;
7171 }
7172
7173 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7174 goto error;
7175 }
7176
7177 object = NULL;
7178 index++;
7179 }
7180
7181 return 1;
7182error:
7183 if (object != NULL) {
7184 SCFree(object);
7185 }
7186
7187 return 0;
7188}
7189
7190static int DNP3DecodeObjectG86V2(const uint8_t **buf, uint32_t *len,
7191 uint8_t prefix_code, uint32_t start, uint32_t count,
7192 DNP3PointList *points)
7193{
7194 DNP3ObjectG86V2 *object = NULL;
7195 uint32_t prefix = 0;
7196 uint32_t index = start;
7197
7198 while (count--) {
7199
7200 object = SCCalloc(1, sizeof(*object));
7201 if (unlikely(object == NULL)) {
7202 goto error;
7203 }
7204
7205 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7206 goto error;
7207 }
7208
7209 {
7210 uint8_t octet;
7211 if (!DNP3ReadUint8(buf, len, &octet)) {
7212 goto error;
7213 }
7214 object->rd = (octet >> 0) & 0x1;
7215 object->wr = (octet >> 1) & 0x1;
7216 object->st = (octet >> 2) & 0x1;
7217 object->ev = (octet >> 3) & 0x1;
7218 object->df = (octet >> 4) & 0x1;
7219 object->padding0 = (octet >> 5) & 0x1;
7220 object->padding1 = (octet >> 6) & 0x1;
7221 object->padding2 = (octet >> 7) & 0x1;
7222 }
7223
7224 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7225 goto error;
7226 }
7227
7228 object = NULL;
7229 index++;
7230 }
7231
7232 return 1;
7233error:
7234 if (object != NULL) {
7235 SCFree(object);
7236 }
7237
7238 return 0;
7239}
7240
7241static int DNP3DecodeObjectG102V1(const uint8_t **buf, uint32_t *len,
7242 uint8_t prefix_code, uint32_t start, uint32_t count,
7243 DNP3PointList *points)
7244{
7245 DNP3ObjectG102V1 *object = NULL;
7246 uint32_t prefix = 0;
7247 uint32_t index = start;
7248
7249 while (count--) {
7250
7251 object = SCCalloc(1, sizeof(*object));
7252 if (unlikely(object == NULL)) {
7253 goto error;
7254 }
7255
7256 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7257 goto error;
7258 }
7259
7260 if (!DNP3ReadUint8(buf, len, &object->value)) {
7261 goto error;
7262 }
7263
7264 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7265 goto error;
7266 }
7267
7268 object = NULL;
7269 index++;
7270 }
7271
7272 return 1;
7273error:
7274 if (object != NULL) {
7275 SCFree(object);
7276 }
7277
7278 return 0;
7279}
7280
7281static int DNP3DecodeObjectG120V1(const uint8_t **buf, uint32_t *len,
7282 uint8_t prefix_code, uint32_t start, uint32_t count,
7283 DNP3PointList *points)
7284{
7285 DNP3ObjectG120V1 *object = NULL;
7286 uint32_t prefix = 0;
7287 uint32_t index = start;
7288 uint32_t offset;
7289
7290 if (prefix_code != 5) {
7291 goto error;
7292 }
7293
7294 while (count--) {
7295
7296 object = SCCalloc(1, sizeof(*object));
7297 if (unlikely(object == NULL)) {
7298 goto error;
7299 }
7300
7301 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7302 goto error;
7303 }
7304
7305 offset = *len;
7306
7307 if (!DNP3ReadUint32(buf, len, &object->csq)) {
7308 goto error;
7309 }
7310 if (!DNP3ReadUint16(buf, len, &object->usr)) {
7311 goto error;
7312 }
7313 if (!DNP3ReadUint8(buf, len, &object->mal)) {
7314 goto error;
7315 }
7316 if (!DNP3ReadUint8(buf, len, &object->reason)) {
7317 goto error;
7318 }
7319 object->challenge_data_len = prefix - (offset - *len);
7320 if (object->challenge_data_len > 0) {
7321 if (*len < object->challenge_data_len) {
7322 /* Not enough data. */
7323 goto error;
7324 }
7325 object->challenge_data = SCCalloc(1, object->challenge_data_len);
7326 if (unlikely(object->challenge_data == NULL)) {
7327 goto error;
7328 }
7329 memcpy(object->challenge_data, *buf, object->challenge_data_len);
7330 *buf += object->challenge_data_len;
7331 *len -= object->challenge_data_len;
7332 }
7333
7334 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7335 goto error;
7336 }
7337
7338 object = NULL;
7339 index++;
7340 }
7341
7342 return 1;
7343error:
7344 if (object != NULL) {
7345 SCFree(object);
7346 }
7347
7348 return 0;
7349}
7350
7351static int DNP3DecodeObjectG120V2(const uint8_t **buf, uint32_t *len,
7352 uint8_t prefix_code, uint32_t start, uint32_t count,
7353 DNP3PointList *points)
7354{
7355 DNP3ObjectG120V2 *object = NULL;
7356 uint32_t prefix = 0;
7357 uint32_t index = start;
7358 uint32_t offset;
7359
7360 if (prefix_code != 5) {
7361 goto error;
7362 }
7363
7364 while (count--) {
7365
7366 object = SCCalloc(1, sizeof(*object));
7367 if (unlikely(object == NULL)) {
7368 goto error;
7369 }
7370
7371 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7372 goto error;
7373 }
7374
7375 offset = *len;
7376
7377 if (!DNP3ReadUint32(buf, len, &object->csq)) {
7378 goto error;
7379 }
7380 if (!DNP3ReadUint16(buf, len, &object->usr)) {
7381 goto error;
7382 }
7383 object->mac_value_len = prefix - (offset - *len);
7384 if (object->mac_value_len > 0) {
7385 if (*len < object->mac_value_len) {
7386 /* Not enough data. */
7387 goto error;
7388 }
7389 object->mac_value = SCCalloc(1, object->mac_value_len);
7390 if (unlikely(object->mac_value == NULL)) {
7391 goto error;
7392 }
7393 memcpy(object->mac_value, *buf, object->mac_value_len);
7394 *buf += object->mac_value_len;
7395 *len -= object->mac_value_len;
7396 }
7397
7398 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7399 goto error;
7400 }
7401
7402 object = NULL;
7403 index++;
7404 }
7405
7406 return 1;
7407error:
7408 if (object != NULL) {
7409 SCFree(object);
7410 }
7411
7412 return 0;
7413}
7414
7415static int DNP3DecodeObjectG120V3(const uint8_t **buf, uint32_t *len,
7416 uint8_t prefix_code, uint32_t start, uint32_t count,
7417 DNP3PointList *points)
7418{
7419 DNP3ObjectG120V3 *object = NULL;
7420 uint32_t prefix = 0;
7421 uint32_t index = start;
7422
7423 while (count--) {
7424
7425 object = SCCalloc(1, sizeof(*object));
7426 if (unlikely(object == NULL)) {
7427 goto error;
7428 }
7429
7430 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7431 goto error;
7432 }
7433
7434 if (!DNP3ReadUint32(buf, len, &object->csq)) {
7435 goto error;
7436 }
7437 if (!DNP3ReadUint16(buf, len, &object->user_number)) {
7438 goto error;
7439 }
7440
7441 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7442 goto error;
7443 }
7444
7445 object = NULL;
7446 index++;
7447 }
7448
7449 return 1;
7450error:
7451 if (object != NULL) {
7452 SCFree(object);
7453 }
7454
7455 return 0;
7456}
7457
7458static int DNP3DecodeObjectG120V4(const uint8_t **buf, uint32_t *len,
7459 uint8_t prefix_code, uint32_t start, uint32_t count,
7460 DNP3PointList *points)
7461{
7462 DNP3ObjectG120V4 *object = NULL;
7463 uint32_t prefix = 0;
7464 uint32_t index = start;
7465
7466 while (count--) {
7467
7468 object = SCCalloc(1, sizeof(*object));
7469 if (unlikely(object == NULL)) {
7470 goto error;
7471 }
7472
7473 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7474 goto error;
7475 }
7476
7477 if (!DNP3ReadUint16(buf, len, &object->user_number)) {
7478 goto error;
7479 }
7480
7481 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7482 goto error;
7483 }
7484
7485 object = NULL;
7486 index++;
7487 }
7488
7489 return 1;
7490error:
7491 if (object != NULL) {
7492 SCFree(object);
7493 }
7494
7495 return 0;
7496}
7497
7498static int DNP3DecodeObjectG120V5(const uint8_t **buf, uint32_t *len,
7499 uint8_t prefix_code, uint32_t start, uint32_t count,
7500 DNP3PointList *points)
7501{
7502 DNP3ObjectG120V5 *object = NULL;
7503 uint32_t prefix = 0;
7504 uint32_t index = start;
7505 uint32_t offset;
7506
7507 if (prefix_code != 5) {
7508 goto error;
7509 }
7510
7511 while (count--) {
7512
7513 object = SCCalloc(1, sizeof(*object));
7514 if (unlikely(object == NULL)) {
7515 goto error;
7516 }
7517
7518 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7519 goto error;
7520 }
7521
7522 offset = *len;
7523
7524 if (!DNP3ReadUint32(buf, len, &object->ksq)) {
7525 goto error;
7526 }
7527 if (!DNP3ReadUint16(buf, len, &object->user_number)) {
7528 goto error;
7529 }
7530 if (!DNP3ReadUint8(buf, len, &object->key_wrap_alg)) {
7531 goto error;
7532 }
7533 if (!DNP3ReadUint8(buf, len, &object->key_status)) {
7534 goto error;
7535 }
7536 if (!DNP3ReadUint8(buf, len, &object->mal)) {
7537 goto error;
7538 }
7539 if (!DNP3ReadUint16(buf, len, &object->challenge_data_len)) {
7540 goto error;
7541 }
7542 if (object->challenge_data_len > 0) {
7543 if (*len < object->challenge_data_len) {
7544 /* Not enough data. */
7545 goto error;
7546 }
7547 object->challenge_data = SCCalloc(1, object->challenge_data_len);
7548 if (unlikely(object->challenge_data == NULL)) {
7549 goto error;
7550 }
7551 memcpy(object->challenge_data, *buf, object->challenge_data_len);
7552 *buf += object->challenge_data_len;
7553 *len -= object->challenge_data_len;
7554 }
7555 object->mac_value_len = prefix - (offset - *len);
7556 if (object->mac_value_len > 0) {
7557 if (*len < object->mac_value_len) {
7558 /* Not enough data. */
7559 goto error;
7560 }
7561 object->mac_value = SCCalloc(1, object->mac_value_len);
7562 if (unlikely(object->mac_value == NULL)) {
7563 goto error;
7564 }
7565 memcpy(object->mac_value, *buf, object->mac_value_len);
7566 *buf += object->mac_value_len;
7567 *len -= object->mac_value_len;
7568 }
7569
7570 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7571 goto error;
7572 }
7573
7574 object = NULL;
7575 index++;
7576 }
7577
7578 return 1;
7579error:
7580 if (object != NULL) {
7581 SCFree(object);
7582 }
7583
7584 return 0;
7585}
7586
7587static int DNP3DecodeObjectG120V6(const uint8_t **buf, uint32_t *len,
7588 uint8_t prefix_code, uint32_t start, uint32_t count,
7589 DNP3PointList *points)
7590{
7591 DNP3ObjectG120V6 *object = NULL;
7592 uint32_t prefix = 0;
7593 uint32_t index = start;
7594 uint32_t offset;
7595
7596 if (prefix_code != 5) {
7597 goto error;
7598 }
7599
7600 while (count--) {
7601
7602 object = SCCalloc(1, sizeof(*object));
7603 if (unlikely(object == NULL)) {
7604 goto error;
7605 }
7606
7607 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7608 goto error;
7609 }
7610
7611 offset = *len;
7612
7613 if (!DNP3ReadUint24(buf, len, &object->ksq)) {
7614 goto error;
7615 }
7616 if (!DNP3ReadUint16(buf, len, &object->usr)) {
7617 goto error;
7618 }
7619 object->wrapped_key_data_len = prefix - (offset - *len);
7620 if (object->wrapped_key_data_len > 0) {
7621 if (*len < object->wrapped_key_data_len) {
7622 /* Not enough data. */
7623 goto error;
7624 }
7625 object->wrapped_key_data = SCCalloc(1, object->wrapped_key_data_len);
7626 if (unlikely(object->wrapped_key_data == NULL)) {
7627 goto error;
7628 }
7629 memcpy(object->wrapped_key_data, *buf, object->wrapped_key_data_len);
7630 *buf += object->wrapped_key_data_len;
7631 *len -= object->wrapped_key_data_len;
7632 }
7633
7634 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7635 goto error;
7636 }
7637
7638 object = NULL;
7639 index++;
7640 }
7641
7642 return 1;
7643error:
7644 if (object != NULL) {
7645 SCFree(object);
7646 }
7647
7648 return 0;
7649}
7650
7651static int DNP3DecodeObjectG120V7(const uint8_t **buf, uint32_t *len,
7652 uint8_t prefix_code, uint32_t start, uint32_t count,
7653 DNP3PointList *points)
7654{
7655 DNP3ObjectG120V7 *object = NULL;
7656 uint32_t prefix = 0;
7657 uint32_t index = start;
7658 uint32_t offset;
7659
7660 if (prefix_code != 5) {
7661 goto error;
7662 }
7663
7664 while (count--) {
7665
7666 object = SCCalloc(1, sizeof(*object));
7667 if (unlikely(object == NULL)) {
7668 goto error;
7669 }
7670
7671 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7672 goto error;
7673 }
7674
7675 offset = *len;
7676
7677 if (!DNP3ReadUint32(buf, len, &object->sequence_number)) {
7678 goto error;
7679 }
7680 if (!DNP3ReadUint16(buf, len, &object->usr)) {
7681 goto error;
7682 }
7683 if (!DNP3ReadUint16(buf, len, &object->association_id)) {
7684 goto error;
7685 }
7686 if (!DNP3ReadUint8(buf, len, &object->error_code)) {
7687 goto error;
7688 }
7689 if (!DNP3ReadUint48(buf, len, &object->time_of_error)) {
7690 goto error;
7691 }
7692 object->error_text_len = prefix - (offset - *len);
7693 if (object->error_text_len > 0) {
7694 memcpy(object->error_text, *buf, object->error_text_len);
7695 *buf += object->error_text_len;
7696 *len -= object->error_text_len;
7697 }
7698 object->error_text[object->error_text_len] = '\0';
7699
7700 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7701 goto error;
7702 }
7703
7704 object = NULL;
7705 index++;
7706 }
7707
7708 return 1;
7709error:
7710 if (object != NULL) {
7711 SCFree(object);
7712 }
7713
7714 return 0;
7715}
7716
7717static int DNP3DecodeObjectG120V8(const uint8_t **buf, uint32_t *len,
7718 uint8_t prefix_code, uint32_t start, uint32_t count,
7719 DNP3PointList *points)
7720{
7721 DNP3ObjectG120V8 *object = NULL;
7722 uint32_t prefix = 0;
7723 uint32_t index = start;
7724 uint32_t offset;
7725
7726 if (prefix_code != 5) {
7727 goto error;
7728 }
7729
7730 while (count--) {
7731
7732 object = SCCalloc(1, sizeof(*object));
7733 if (unlikely(object == NULL)) {
7734 goto error;
7735 }
7736
7737 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7738 goto error;
7739 }
7740
7741 offset = *len;
7742
7743 if (!DNP3ReadUint8(buf, len, &object->key_change_method)) {
7744 goto error;
7745 }
7746 if (!DNP3ReadUint8(buf, len, &object->certificate_type)) {
7747 goto error;
7748 }
7749 object->certificate_len = prefix - (offset - *len);
7750 if (object->certificate_len > 0) {
7751 if (*len < object->certificate_len) {
7752 /* Not enough data. */
7753 goto error;
7754 }
7755 object->certificate = SCCalloc(1, object->certificate_len);
7756 if (unlikely(object->certificate == NULL)) {
7757 goto error;
7758 }
7759 memcpy(object->certificate, *buf, object->certificate_len);
7760 *buf += object->certificate_len;
7761 *len -= object->certificate_len;
7762 }
7763
7764 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7765 goto error;
7766 }
7767
7768 object = NULL;
7769 index++;
7770 }
7771
7772 return 1;
7773error:
7774 if (object != NULL) {
7775 SCFree(object);
7776 }
7777
7778 return 0;
7779}
7780
7781static int DNP3DecodeObjectG120V9(const uint8_t **buf, uint32_t *len,
7782 uint8_t prefix_code, uint32_t start, uint32_t count,
7783 DNP3PointList *points)
7784{
7785 DNP3ObjectG120V9 *object = NULL;
7786 uint32_t prefix = 0;
7787 uint32_t index = start;
7788 uint32_t offset;
7789
7790 while (count--) {
7791
7792 object = SCCalloc(1, sizeof(*object));
7793 if (unlikely(object == NULL)) {
7794 goto error;
7795 }
7796
7797 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7798 goto error;
7799 }
7800
7801 offset = *len;
7802
7803 object->mac_value_len = prefix - (offset - *len);
7804 if (object->mac_value_len > 0) {
7805 if (*len < object->mac_value_len) {
7806 /* Not enough data. */
7807 goto error;
7808 }
7809 object->mac_value = SCCalloc(1, object->mac_value_len);
7810 if (unlikely(object->mac_value == NULL)) {
7811 goto error;
7812 }
7813 memcpy(object->mac_value, *buf, object->mac_value_len);
7814 *buf += object->mac_value_len;
7815 *len -= object->mac_value_len;
7816 }
7817
7818 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7819 goto error;
7820 }
7821
7822 object = NULL;
7823 index++;
7824 }
7825
7826 return 1;
7827error:
7828 if (object != NULL) {
7829 SCFree(object);
7830 }
7831
7832 return 0;
7833}
7834
7835static int DNP3DecodeObjectG120V10(const uint8_t **buf, uint32_t *len,
7836 uint8_t prefix_code, uint32_t start, uint32_t count,
7837 DNP3PointList *points)
7838{
7839 DNP3ObjectG120V10 *object = NULL;
7840 uint32_t prefix = 0;
7841 uint32_t index = start;
7842
7843 if (prefix_code != 5) {
7844 goto error;
7845 }
7846
7847 while (count--) {
7848
7849 object = SCCalloc(1, sizeof(*object));
7850 if (unlikely(object == NULL)) {
7851 goto error;
7852 }
7853
7854 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7855 goto error;
7856 }
7857
7858 if (!DNP3ReadUint8(buf, len, &object->key_change_method)) {
7859 goto error;
7860 }
7861 if (!DNP3ReadUint8(buf, len, &object->operation)) {
7862 goto error;
7863 }
7864 if (!DNP3ReadUint32(buf, len, &object->scs)) {
7865 goto error;
7866 }
7867 if (!DNP3ReadUint16(buf, len, &object->user_role)) {
7868 goto error;
7869 }
7870 if (!DNP3ReadUint16(buf, len, &object->user_role_expiry_interval)) {
7871 goto error;
7872 }
7873 if (!DNP3ReadUint16(buf, len, &object->username_len)) {
7874 goto error;
7875 }
7876 if (!DNP3ReadUint16(buf, len, &object->user_public_key_len)) {
7877 goto error;
7878 }
7879 if (!DNP3ReadUint16(buf, len, &object->certification_data_len)) {
7880 goto error;
7881 }
7882 if (object->username_len > 0) {
7883 memcpy(object->username, *buf, object->username_len);
7884 *buf += object->username_len;
7885 *len -= object->username_len;
7886 }
7887 object->username[object->username_len] = '\0';
7888 if (object->user_public_key_len > 0) {
7889 if (*len < object->user_public_key_len) {
7890 /* Not enough data. */
7891 goto error;
7892 }
7893 object->user_public_key = SCCalloc(1, object->user_public_key_len);
7894 if (unlikely(object->user_public_key == NULL)) {
7895 goto error;
7896 }
7897 memcpy(object->user_public_key, *buf, object->user_public_key_len);
7898 *buf += object->user_public_key_len;
7899 *len -= object->user_public_key_len;
7900 }
7901 if (object->certification_data_len > 0) {
7902 if (*len < object->certification_data_len) {
7903 /* Not enough data. */
7904 goto error;
7905 }
7906 object->certification_data = SCCalloc(1, object->certification_data_len);
7907 if (unlikely(object->certification_data == NULL)) {
7908 goto error;
7909 }
7910 memcpy(object->certification_data, *buf, object->certification_data_len);
7911 *buf += object->certification_data_len;
7912 *len -= object->certification_data_len;
7913 }
7914
7915 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7916 goto error;
7917 }
7918
7919 object = NULL;
7920 index++;
7921 }
7922
7923 return 1;
7924error:
7925 if (object != NULL) {
7926 SCFree(object);
7927 }
7928
7929 return 0;
7930}
7931
7932static int DNP3DecodeObjectG120V11(const uint8_t **buf, uint32_t *len,
7933 uint8_t prefix_code, uint32_t start, uint32_t count,
7934 DNP3PointList *points)
7935{
7936 DNP3ObjectG120V11 *object = NULL;
7937 uint32_t prefix = 0;
7938 uint32_t index = start;
7939
7940 if (prefix_code != 5) {
7941 goto error;
7942 }
7943
7944 while (count--) {
7945
7946 object = SCCalloc(1, sizeof(*object));
7947 if (unlikely(object == NULL)) {
7948 goto error;
7949 }
7950
7951 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7952 goto error;
7953 }
7954
7955 if (!DNP3ReadUint8(buf, len, &object->key_change_method)) {
7956 goto error;
7957 }
7958 if (!DNP3ReadUint16(buf, len, &object->username_len)) {
7959 goto error;
7960 }
7961 if (!DNP3ReadUint16(buf, len, &object->master_challenge_data_len)) {
7962 goto error;
7963 }
7964 if (object->username_len > 0) {
7965 memcpy(object->username, *buf, object->username_len);
7966 *buf += object->username_len;
7967 *len -= object->username_len;
7968 }
7969 object->username[object->username_len] = '\0';
7970 if (object->master_challenge_data_len > 0) {
7971 if (*len < object->master_challenge_data_len) {
7972 /* Not enough data. */
7973 goto error;
7974 }
7975 object->master_challenge_data = SCCalloc(1, object->master_challenge_data_len);
7976 if (unlikely(object->master_challenge_data == NULL)) {
7977 goto error;
7978 }
7979 memcpy(object->master_challenge_data, *buf, object->master_challenge_data_len);
7980 *buf += object->master_challenge_data_len;
7981 *len -= object->master_challenge_data_len;
7982 }
7983
7984 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
7985 goto error;
7986 }
7987
7988 object = NULL;
7989 index++;
7990 }
7991
7992 return 1;
7993error:
7994 if (object != NULL) {
7995 SCFree(object);
7996 }
7997
7998 return 0;
7999}
8000
8001static int DNP3DecodeObjectG120V12(const uint8_t **buf, uint32_t *len,
8002 uint8_t prefix_code, uint32_t start, uint32_t count,
8003 DNP3PointList *points)
8004{
8005 DNP3ObjectG120V12 *object = NULL;
8006 uint32_t prefix = 0;
8007 uint32_t index = start;
8008
8009 if (prefix_code != 5) {
8010 goto error;
8011 }
8012
8013 while (count--) {
8014
8015 object = SCCalloc(1, sizeof(*object));
8016 if (unlikely(object == NULL)) {
8017 goto error;
8018 }
8019
8020 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
8021 goto error;
8022 }
8023
8024 if (!DNP3ReadUint32(buf, len, &object->ksq)) {
8025 goto error;
8026 }
8027 if (!DNP3ReadUint16(buf, len, &object->user_number)) {
8028 goto error;
8029 }
8030 if (!DNP3ReadUint16(buf, len, &object->challenge_data_len)) {
8031 goto error;
8032 }
8033 if (object->challenge_data_len > 0) {
8034 if (*len < object->challenge_data_len) {
8035 /* Not enough data. */
8036 goto error;
8037 }
8038 object->challenge_data = SCCalloc(1, object->challenge_data_len);
8039 if (unlikely(object->challenge_data == NULL)) {
8040 goto error;
8041 }
8042 memcpy(object->challenge_data, *buf, object->challenge_data_len);
8043 *buf += object->challenge_data_len;
8044 *len -= object->challenge_data_len;
8045 }
8046
8047 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
8048 goto error;
8049 }
8050
8051 object = NULL;
8052 index++;
8053 }
8054
8055 return 1;
8056error:
8057 if (object != NULL) {
8058 SCFree(object);
8059 }
8060
8061 return 0;
8062}
8063
8064static int DNP3DecodeObjectG120V13(const uint8_t **buf, uint32_t *len,
8065 uint8_t prefix_code, uint32_t start, uint32_t count,
8066 DNP3PointList *points)
8067{
8068 DNP3ObjectG120V13 *object = NULL;
8069 uint32_t prefix = 0;
8070 uint32_t index = start;
8071
8072 if (prefix_code != 5) {
8073 goto error;
8074 }
8075
8076 while (count--) {
8077
8078 object = SCCalloc(1, sizeof(*object));
8079 if (unlikely(object == NULL)) {
8080 goto error;
8081 }
8082
8083 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
8084 goto error;
8085 }
8086
8087 if (!DNP3ReadUint32(buf, len, &object->ksq)) {
8088 goto error;
8089 }
8090 if (!DNP3ReadUint16(buf, len, &object->user_number)) {
8091 goto error;
8092 }
8093 if (!DNP3ReadUint16(buf, len, &object->encrypted_update_key_len)) {
8094 goto error;
8095 }
8096 if (object->encrypted_update_key_len > 0) {
8097 if (*len < object->encrypted_update_key_len) {
8098 /* Not enough data. */
8099 goto error;
8100 }
8101 object->encrypted_update_key_data = SCCalloc(1, object->encrypted_update_key_len);
8102 if (unlikely(object->encrypted_update_key_data == NULL)) {
8103 goto error;
8104 }
8105 memcpy(object->encrypted_update_key_data, *buf, object->encrypted_update_key_len);
8106 *buf += object->encrypted_update_key_len;
8107 *len -= object->encrypted_update_key_len;
8108 }
8109
8110 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
8111 goto error;
8112 }
8113
8114 object = NULL;
8115 index++;
8116 }
8117
8118 return 1;
8119error:
8120 if (object != NULL) {
8121 SCFree(object);
8122 }
8123
8124 return 0;
8125}
8126
8127static int DNP3DecodeObjectG120V14(const uint8_t **buf, uint32_t *len,
8128 uint8_t prefix_code, uint32_t start, uint32_t count,
8129 DNP3PointList *points)
8130{
8131 DNP3ObjectG120V14 *object = NULL;
8132 uint32_t prefix = 0;
8133 uint32_t index = start;
8134 uint32_t offset;
8135
8136 if (prefix_code != 5) {
8137 goto error;
8138 }
8139
8140 while (count--) {
8141
8142 object = SCCalloc(1, sizeof(*object));
8143 if (unlikely(object == NULL)) {
8144 goto error;
8145 }
8146
8147 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
8148 goto error;
8149 }
8150
8151 offset = *len;
8152
8153 object->digital_signature_len = prefix - (offset - *len);
8154 if (object->digital_signature_len > 0) {
8155 if (*len < object->digital_signature_len) {
8156 /* Not enough data. */
8157 goto error;
8158 }
8159 object->digital_signature = SCCalloc(1, object->digital_signature_len);
8160 if (unlikely(object->digital_signature == NULL)) {
8161 goto error;
8162 }
8163 memcpy(object->digital_signature, *buf, object->digital_signature_len);
8164 *buf += object->digital_signature_len;
8165 *len -= object->digital_signature_len;
8166 }
8167
8168 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
8169 goto error;
8170 }
8171
8172 object = NULL;
8173 index++;
8174 }
8175
8176 return 1;
8177error:
8178 if (object != NULL) {
8179 SCFree(object);
8180 }
8181
8182 return 0;
8183}
8184
8185static int DNP3DecodeObjectG120V15(const uint8_t **buf, uint32_t *len,
8186 uint8_t prefix_code, uint32_t start, uint32_t count,
8187 DNP3PointList *points)
8188{
8189 DNP3ObjectG120V15 *object = NULL;
8190 uint32_t prefix = 0;
8191 uint32_t index = start;
8192 uint32_t offset;
8193
8194 if (prefix_code != 5) {
8195 goto error;
8196 }
8197
8198 while (count--) {
8199
8200 object = SCCalloc(1, sizeof(*object));
8201 if (unlikely(object == NULL)) {
8202 goto error;
8203 }
8204
8205 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
8206 goto error;
8207 }
8208
8209 offset = *len;
8210
8211 object->mac_len = prefix - (offset - *len);
8212 if (object->mac_len > 0) {
8213 if (*len < object->mac_len) {
8214 /* Not enough data. */
8215 goto error;
8216 }
8217 object->mac = SCCalloc(1, object->mac_len);
8218 if (unlikely(object->mac == NULL)) {
8219 goto error;
8220 }
8221 memcpy(object->mac, *buf, object->mac_len);
8222 *buf += object->mac_len;
8223 *len -= object->mac_len;
8224 }
8225
8226 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
8227 goto error;
8228 }
8229
8230 object = NULL;
8231 index++;
8232 }
8233
8234 return 1;
8235error:
8236 if (object != NULL) {
8237 SCFree(object);
8238 }
8239
8240 return 0;
8241}
8242
8243static int DNP3DecodeObjectG121V1(const uint8_t **buf, uint32_t *len,
8244 uint8_t prefix_code, uint32_t start, uint32_t count,
8245 DNP3PointList *points)
8246{
8247 DNP3ObjectG121V1 *object = NULL;
8248 uint32_t prefix = 0;
8249 uint32_t index = start;
8250
8251 while (count--) {
8252
8253 object = SCCalloc(1, sizeof(*object));
8254 if (unlikely(object == NULL)) {
8255 goto error;
8256 }
8257
8258 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
8259 goto error;
8260 }
8261
8262 {
8263 uint8_t octet;
8264 if (!DNP3ReadUint8(buf, len, &octet)) {
8265 goto error;
8266 }
8267 object->online = (octet >> 0) & 0x1;
8268 object->restart = (octet >> 1) & 0x1;
8269 object->comm_lost = (octet >> 2) & 0x1;
8270 object->remote_forced = (octet >> 3) & 0x1;
8271 object->local_forced = (octet >> 4) & 0x1;
8272 object->reserved0 = (octet >> 5) & 0x1;
8273 object->discontinuity = (octet >> 6) & 0x1;
8274 object->reserved1 = (octet >> 7) & 0x1;
8275 }
8276 if (!DNP3ReadUint16(buf, len, &object->association_id)) {
8277 goto error;
8278 }
8279 if (!DNP3ReadUint32(buf, len, &object->count_value)) {
8280 goto error;
8281 }
8282
8283 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
8284 goto error;
8285 }
8286
8287 object = NULL;
8288 index++;
8289 }
8290
8291 return 1;
8292error:
8293 if (object != NULL) {
8294 SCFree(object);
8295 }
8296
8297 return 0;
8298}
8299
8300static int DNP3DecodeObjectG122V1(const uint8_t **buf, uint32_t *len,
8301 uint8_t prefix_code, uint32_t start, uint32_t count,
8302 DNP3PointList *points)
8303{
8304 DNP3ObjectG122V1 *object = NULL;
8305 uint32_t prefix = 0;
8306 uint32_t index = start;
8307
8308 while (count--) {
8309
8310 object = SCCalloc(1, sizeof(*object));
8311 if (unlikely(object == NULL)) {
8312 goto error;
8313 }
8314
8315 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
8316 goto error;
8317 }
8318
8319 {
8320 uint8_t octet;
8321 if (!DNP3ReadUint8(buf, len, &octet)) {
8322 goto error;
8323 }
8324 object->online = (octet >> 0) & 0x1;
8325 object->restart = (octet >> 1) & 0x1;
8326 object->comm_lost = (octet >> 2) & 0x1;
8327 object->remote_forced = (octet >> 3) & 0x1;
8328 object->local_forced = (octet >> 4) & 0x1;
8329 object->reserved0 = (octet >> 5) & 0x1;
8330 object->discontinuity = (octet >> 6) & 0x1;
8331 object->reserved1 = (octet >> 7) & 0x1;
8332 }
8333 if (!DNP3ReadUint16(buf, len, &object->association_id)) {
8334 goto error;
8335 }
8336 if (!DNP3ReadUint32(buf, len, &object->count_value)) {
8337 goto error;
8338 }
8339
8340 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
8341 goto error;
8342 }
8343
8344 object = NULL;
8345 index++;
8346 }
8347
8348 return 1;
8349error:
8350 if (object != NULL) {
8351 SCFree(object);
8352 }
8353
8354 return 0;
8355}
8356
8357static int DNP3DecodeObjectG122V2(const uint8_t **buf, uint32_t *len,
8358 uint8_t prefix_code, uint32_t start, uint32_t count,
8359 DNP3PointList *points)
8360{
8361 DNP3ObjectG122V2 *object = NULL;
8362 uint32_t prefix = 0;
8363 uint32_t index = start;
8364
8365 while (count--) {
8366
8367 object = SCCalloc(1, sizeof(*object));
8368 if (unlikely(object == NULL)) {
8369 goto error;
8370 }
8371
8372 if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
8373 goto error;
8374 }
8375
8376 {
8377 uint8_t octet;
8378 if (!DNP3ReadUint8(buf, len, &octet)) {
8379 goto error;
8380 }
8381 object->online = (octet >> 0) & 0x1;
8382 object->restart = (octet >> 1) & 0x1;
8383 object->comm_lost = (octet >> 2) & 0x1;
8384 object->remote_forced = (octet >> 3) & 0x1;
8385 object->local_forced = (octet >> 4) & 0x1;
8386 object->reserved0 = (octet >> 5) & 0x1;
8387 object->discontinuity = (octet >> 6) & 0x1;
8388 object->reserved1 = (octet >> 7) & 0x1;
8389 }
8390 if (!DNP3ReadUint16(buf, len, &object->association_id)) {
8391 goto error;
8392 }
8393 if (!DNP3ReadUint32(buf, len, &object->count_value)) {
8394 goto error;
8395 }
8396 if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
8397 goto error;
8398 }
8399
8400 if (!DNP3AddPoint(points, object, index, prefix_code, prefix)) {
8401 goto error;
8402 }
8403
8404 object = NULL;
8405 index++;
8406 }
8407
8408 return 1;
8409error:
8410 if (object != NULL) {
8411 SCFree(object);
8412 }
8413
8414 return 0;
8415}
8416
8417
8418void DNP3FreeObjectPoint(int group, int variation, void *point)
8419{
8420 switch(DNP3_OBJECT_CODE(group, variation)) {
8421 case DNP3_OBJECT_CODE(83, 1): {
8422 DNP3ObjectG83V1 *object = (DNP3ObjectG83V1 *) point;
8423 if (object->data_objects != NULL) {
8424 SCFree(object->data_objects);
8425 }
8426 break;
8427 }
8428 case DNP3_OBJECT_CODE(120, 1): {
8429 DNP3ObjectG120V1 *object = (DNP3ObjectG120V1 *) point;
8430 if (object->challenge_data != NULL) {
8431 SCFree(object->challenge_data);
8432 }
8433 break;
8434 }
8435 case DNP3_OBJECT_CODE(120, 2): {
8436 DNP3ObjectG120V2 *object = (DNP3ObjectG120V2 *) point;
8437 if (object->mac_value != NULL) {
8438 SCFree(object->mac_value);
8439 }
8440 break;
8441 }
8442 case DNP3_OBJECT_CODE(120, 5): {
8443 DNP3ObjectG120V5 *object = (DNP3ObjectG120V5 *) point;
8444 if (object->challenge_data != NULL) {
8445 SCFree(object->challenge_data);
8446 }
8447 if (object->mac_value != NULL) {
8448 SCFree(object->mac_value);
8449 }
8450 break;
8451 }
8452 case DNP3_OBJECT_CODE(120, 6): {
8453 DNP3ObjectG120V6 *object = (DNP3ObjectG120V6 *) point;
8454 if (object->wrapped_key_data != NULL) {
8455 SCFree(object->wrapped_key_data);
8456 }
8457 break;
8458 }
8459 case DNP3_OBJECT_CODE(120, 8): {
8460 DNP3ObjectG120V8 *object = (DNP3ObjectG120V8 *) point;
8461 if (object->certificate != NULL) {
8462 SCFree(object->certificate);
8463 }
8464 break;
8465 }
8466 case DNP3_OBJECT_CODE(120, 9): {
8467 DNP3ObjectG120V9 *object = (DNP3ObjectG120V9 *) point;
8468 if (object->mac_value != NULL) {
8469 SCFree(object->mac_value);
8470 }
8471 break;
8472 }
8473 case DNP3_OBJECT_CODE(120, 10): {
8474 DNP3ObjectG120V10 *object = (DNP3ObjectG120V10 *) point;
8475 if (object->user_public_key != NULL) {
8476 SCFree(object->user_public_key);
8477 }
8478 if (object->certification_data != NULL) {
8479 SCFree(object->certification_data);
8480 }
8481 break;
8482 }
8483 case DNP3_OBJECT_CODE(120, 11): {
8484 DNP3ObjectG120V11 *object = (DNP3ObjectG120V11 *) point;
8485 if (object->master_challenge_data != NULL) {
8486 SCFree(object->master_challenge_data);
8487 }
8488 break;
8489 }
8490 case DNP3_OBJECT_CODE(120, 12): {
8491 DNP3ObjectG120V12 *object = (DNP3ObjectG120V12 *) point;
8492 if (object->challenge_data != NULL) {
8493 SCFree(object->challenge_data);
8494 }
8495 break;
8496 }
8497 case DNP3_OBJECT_CODE(120, 13): {
8498 DNP3ObjectG120V13 *object = (DNP3ObjectG120V13 *) point;
8499 if (object->encrypted_update_key_data != NULL) {
8500 SCFree(object->encrypted_update_key_data);
8501 }
8502 break;
8503 }
8504 case DNP3_OBJECT_CODE(120, 14): {
8505 DNP3ObjectG120V14 *object = (DNP3ObjectG120V14 *) point;
8506 if (object->digital_signature != NULL) {
8507 SCFree(object->digital_signature);
8508 }
8509 break;
8510 }
8511 case DNP3_OBJECT_CODE(120, 15): {
8512 DNP3ObjectG120V15 *object = (DNP3ObjectG120V15 *) point;
8513 if (object->mac != NULL) {
8514 SCFree(object->mac);
8515 }
8516 break;
8517 }
8518 default:
8519 break;
8520 }
8521 SCFree(point);
8522}
8523
8524/**
8525 * \brief Decode a DNP3 object.
8526 *
8527 * \retval 0 on success. On failure a positive integer corresponding
8528 * to a DNP3 application layer event will be returned.
8529 */
8530int DNP3DecodeObject(int group, int variation, const uint8_t **buf,
8531 uint32_t *len, uint8_t prefix_code, uint32_t start,
8532 uint32_t count, DNP3PointList *points)
8533{
8534 int rc = 0;
8535
8536 switch (DNP3_OBJECT_CODE(group, variation)) {
8537 case DNP3_OBJECT_CODE(1, 1):
8538 rc = DNP3DecodeObjectG1V1(buf, len, prefix_code, start, count,
8539 points);
8540 break;
8541 case DNP3_OBJECT_CODE(1, 2):
8542 rc = DNP3DecodeObjectG1V2(buf, len, prefix_code, start, count,
8543 points);
8544 break;
8545 case DNP3_OBJECT_CODE(2, 1):
8546 rc = DNP3DecodeObjectG2V1(buf, len, prefix_code, start, count,
8547 points);
8548 break;
8549 case DNP3_OBJECT_CODE(2, 2):
8550 rc = DNP3DecodeObjectG2V2(buf, len, prefix_code, start, count,
8551 points);
8552 break;
8553 case DNP3_OBJECT_CODE(2, 3):
8554 rc = DNP3DecodeObjectG2V3(buf, len, prefix_code, start, count,
8555 points);
8556 break;
8557 case DNP3_OBJECT_CODE(3, 1):
8558 rc = DNP3DecodeObjectG3V1(buf, len, prefix_code, start, count,
8559 points);
8560 break;
8561 case DNP3_OBJECT_CODE(3, 2):
8562 rc = DNP3DecodeObjectG3V2(buf, len, prefix_code, start, count,
8563 points);
8564 break;
8565 case DNP3_OBJECT_CODE(4, 1):
8566 rc = DNP3DecodeObjectG4V1(buf, len, prefix_code, start, count,
8567 points);
8568 break;
8569 case DNP3_OBJECT_CODE(4, 2):
8570 rc = DNP3DecodeObjectG4V2(buf, len, prefix_code, start, count,
8571 points);
8572 break;
8573 case DNP3_OBJECT_CODE(4, 3):
8574 rc = DNP3DecodeObjectG4V3(buf, len, prefix_code, start, count,
8575 points);
8576 break;
8577 case DNP3_OBJECT_CODE(10, 1):
8578 rc = DNP3DecodeObjectG10V1(buf, len, prefix_code, start, count,
8579 points);
8580 break;
8581 case DNP3_OBJECT_CODE(10, 2):
8582 rc = DNP3DecodeObjectG10V2(buf, len, prefix_code, start, count,
8583 points);
8584 break;
8585 case DNP3_OBJECT_CODE(11, 1):
8586 rc = DNP3DecodeObjectG11V1(buf, len, prefix_code, start, count,
8587 points);
8588 break;
8589 case DNP3_OBJECT_CODE(11, 2):
8590 rc = DNP3DecodeObjectG11V2(buf, len, prefix_code, start, count,
8591 points);
8592 break;
8593 case DNP3_OBJECT_CODE(12, 1):
8594 rc = DNP3DecodeObjectG12V1(buf, len, prefix_code, start, count,
8595 points);
8596 break;
8597 case DNP3_OBJECT_CODE(12, 2):
8598 rc = DNP3DecodeObjectG12V2(buf, len, prefix_code, start, count,
8599 points);
8600 break;
8601 case DNP3_OBJECT_CODE(12, 3):
8602 rc = DNP3DecodeObjectG12V3(buf, len, prefix_code, start, count,
8603 points);
8604 break;
8605 case DNP3_OBJECT_CODE(13, 1):
8606 rc = DNP3DecodeObjectG13V1(buf, len, prefix_code, start, count,
8607 points);
8608 break;
8609 case DNP3_OBJECT_CODE(13, 2):
8610 rc = DNP3DecodeObjectG13V2(buf, len, prefix_code, start, count,
8611 points);
8612 break;
8613 case DNP3_OBJECT_CODE(20, 1):
8614 rc = DNP3DecodeObjectG20V1(buf, len, prefix_code, start, count,
8615 points);
8616 break;
8617 case DNP3_OBJECT_CODE(20, 2):
8618 rc = DNP3DecodeObjectG20V2(buf, len, prefix_code, start, count,
8619 points);
8620 break;
8621 case DNP3_OBJECT_CODE(20, 3):
8622 rc = DNP3DecodeObjectG20V3(buf, len, prefix_code, start, count,
8623 points);
8624 break;
8625 case DNP3_OBJECT_CODE(20, 4):
8626 rc = DNP3DecodeObjectG20V4(buf, len, prefix_code, start, count,
8627 points);
8628 break;
8629 case DNP3_OBJECT_CODE(20, 5):
8630 rc = DNP3DecodeObjectG20V5(buf, len, prefix_code, start, count,
8631 points);
8632 break;
8633 case DNP3_OBJECT_CODE(20, 6):
8634 rc = DNP3DecodeObjectG20V6(buf, len, prefix_code, start, count,
8635 points);
8636 break;
8637 case DNP3_OBJECT_CODE(20, 7):
8638 rc = DNP3DecodeObjectG20V7(buf, len, prefix_code, start, count,
8639 points);
8640 break;
8641 case DNP3_OBJECT_CODE(20, 8):
8642 rc = DNP3DecodeObjectG20V8(buf, len, prefix_code, start, count,
8643 points);
8644 break;
8645 case DNP3_OBJECT_CODE(21, 1):
8646 rc = DNP3DecodeObjectG21V1(buf, len, prefix_code, start, count,
8647 points);
8648 break;
8649 case DNP3_OBJECT_CODE(21, 2):
8650 rc = DNP3DecodeObjectG21V2(buf, len, prefix_code, start, count,
8651 points);
8652 break;
8653 case DNP3_OBJECT_CODE(21, 3):
8654 rc = DNP3DecodeObjectG21V3(buf, len, prefix_code, start, count,
8655 points);
8656 break;
8657 case DNP3_OBJECT_CODE(21, 4):
8658 rc = DNP3DecodeObjectG21V4(buf, len, prefix_code, start, count,
8659 points);
8660 break;
8661 case DNP3_OBJECT_CODE(21, 5):
8662 rc = DNP3DecodeObjectG21V5(buf, len, prefix_code, start, count,
8663 points);
8664 break;
8665 case DNP3_OBJECT_CODE(21, 6):
8666 rc = DNP3DecodeObjectG21V6(buf, len, prefix_code, start, count,
8667 points);
8668 break;
8669 case DNP3_OBJECT_CODE(21, 7):
8670 rc = DNP3DecodeObjectG21V7(buf, len, prefix_code, start, count,
8671 points);
8672 break;
8673 case DNP3_OBJECT_CODE(21, 8):
8674 rc = DNP3DecodeObjectG21V8(buf, len, prefix_code, start, count,
8675 points);
8676 break;
8677 case DNP3_OBJECT_CODE(21, 9):
8678 rc = DNP3DecodeObjectG21V9(buf, len, prefix_code, start, count,
8679 points);
8680 break;
8681 case DNP3_OBJECT_CODE(21, 10):
8682 rc = DNP3DecodeObjectG21V10(buf, len, prefix_code, start, count,
8683 points);
8684 break;
8685 case DNP3_OBJECT_CODE(21, 11):
8686 rc = DNP3DecodeObjectG21V11(buf, len, prefix_code, start, count,
8687 points);
8688 break;
8689 case DNP3_OBJECT_CODE(21, 12):
8690 rc = DNP3DecodeObjectG21V12(buf, len, prefix_code, start, count,
8691 points);
8692 break;
8693 case DNP3_OBJECT_CODE(22, 1):
8694 rc = DNP3DecodeObjectG22V1(buf, len, prefix_code, start, count,
8695 points);
8696 break;
8697 case DNP3_OBJECT_CODE(22, 2):
8698 rc = DNP3DecodeObjectG22V2(buf, len, prefix_code, start, count,
8699 points);
8700 break;
8701 case DNP3_OBJECT_CODE(22, 3):
8702 rc = DNP3DecodeObjectG22V3(buf, len, prefix_code, start, count,
8703 points);
8704 break;
8705 case DNP3_OBJECT_CODE(22, 4):
8706 rc = DNP3DecodeObjectG22V4(buf, len, prefix_code, start, count,
8707 points);
8708 break;
8709 case DNP3_OBJECT_CODE(22, 5):
8710 rc = DNP3DecodeObjectG22V5(buf, len, prefix_code, start, count,
8711 points);
8712 break;
8713 case DNP3_OBJECT_CODE(22, 6):
8714 rc = DNP3DecodeObjectG22V6(buf, len, prefix_code, start, count,
8715 points);
8716 break;
8717 case DNP3_OBJECT_CODE(22, 7):
8718 rc = DNP3DecodeObjectG22V7(buf, len, prefix_code, start, count,
8719 points);
8720 break;
8721 case DNP3_OBJECT_CODE(22, 8):
8722 rc = DNP3DecodeObjectG22V8(buf, len, prefix_code, start, count,
8723 points);
8724 break;
8725 case DNP3_OBJECT_CODE(23, 1):
8726 rc = DNP3DecodeObjectG23V1(buf, len, prefix_code, start, count,
8727 points);
8728 break;
8729 case DNP3_OBJECT_CODE(23, 2):
8730 rc = DNP3DecodeObjectG23V2(buf, len, prefix_code, start, count,
8731 points);
8732 break;
8733 case DNP3_OBJECT_CODE(23, 3):
8734 rc = DNP3DecodeObjectG23V3(buf, len, prefix_code, start, count,
8735 points);
8736 break;
8737 case DNP3_OBJECT_CODE(23, 4):
8738 rc = DNP3DecodeObjectG23V4(buf, len, prefix_code, start, count,
8739 points);
8740 break;
8741 case DNP3_OBJECT_CODE(23, 5):
8742 rc = DNP3DecodeObjectG23V5(buf, len, prefix_code, start, count,
8743 points);
8744 break;
8745 case DNP3_OBJECT_CODE(23, 6):
8746 rc = DNP3DecodeObjectG23V6(buf, len, prefix_code, start, count,
8747 points);
8748 break;
8749 case DNP3_OBJECT_CODE(23, 7):
8750 rc = DNP3DecodeObjectG23V7(buf, len, prefix_code, start, count,
8751 points);
8752 break;
8753 case DNP3_OBJECT_CODE(23, 8):
8754 rc = DNP3DecodeObjectG23V8(buf, len, prefix_code, start, count,
8755 points);
8756 break;
8757 case DNP3_OBJECT_CODE(30, 1):
8758 rc = DNP3DecodeObjectG30V1(buf, len, prefix_code, start, count,
8759 points);
8760 break;
8761 case DNP3_OBJECT_CODE(30, 2):
8762 rc = DNP3DecodeObjectG30V2(buf, len, prefix_code, start, count,
8763 points);
8764 break;
8765 case DNP3_OBJECT_CODE(30, 3):
8766 rc = DNP3DecodeObjectG30V3(buf, len, prefix_code, start, count,
8767 points);
8768 break;
8769 case DNP3_OBJECT_CODE(30, 4):
8770 rc = DNP3DecodeObjectG30V4(buf, len, prefix_code, start, count,
8771 points);
8772 break;
8773 case DNP3_OBJECT_CODE(30, 5):
8774 rc = DNP3DecodeObjectG30V5(buf, len, prefix_code, start, count,
8775 points);
8776 break;
8777 case DNP3_OBJECT_CODE(30, 6):
8778 rc = DNP3DecodeObjectG30V6(buf, len, prefix_code, start, count,
8779 points);
8780 break;
8781 case DNP3_OBJECT_CODE(31, 1):
8782 rc = DNP3DecodeObjectG31V1(buf, len, prefix_code, start, count,
8783 points);
8784 break;
8785 case DNP3_OBJECT_CODE(31, 2):
8786 rc = DNP3DecodeObjectG31V2(buf, len, prefix_code, start, count,
8787 points);
8788 break;
8789 case DNP3_OBJECT_CODE(31, 3):
8790 rc = DNP3DecodeObjectG31V3(buf, len, prefix_code, start, count,
8791 points);
8792 break;
8793 case DNP3_OBJECT_CODE(31, 4):
8794 rc = DNP3DecodeObjectG31V4(buf, len, prefix_code, start, count,
8795 points);
8796 break;
8797 case DNP3_OBJECT_CODE(31, 5):
8798 rc = DNP3DecodeObjectG31V5(buf, len, prefix_code, start, count,
8799 points);
8800 break;
8801 case DNP3_OBJECT_CODE(31, 6):
8802 rc = DNP3DecodeObjectG31V6(buf, len, prefix_code, start, count,
8803 points);
8804 break;
8805 case DNP3_OBJECT_CODE(31, 7):
8806 rc = DNP3DecodeObjectG31V7(buf, len, prefix_code, start, count,
8807 points);
8808 break;
8809 case DNP3_OBJECT_CODE(31, 8):
8810 rc = DNP3DecodeObjectG31V8(buf, len, prefix_code, start, count,
8811 points);
8812 break;
8813 case DNP3_OBJECT_CODE(32, 1):
8814 rc = DNP3DecodeObjectG32V1(buf, len, prefix_code, start, count,
8815 points);
8816 break;
8817 case DNP3_OBJECT_CODE(32, 2):
8818 rc = DNP3DecodeObjectG32V2(buf, len, prefix_code, start, count,
8819 points);
8820 break;
8821 case DNP3_OBJECT_CODE(32, 3):
8822 rc = DNP3DecodeObjectG32V3(buf, len, prefix_code, start, count,
8823 points);
8824 break;
8825 case DNP3_OBJECT_CODE(32, 4):
8826 rc = DNP3DecodeObjectG32V4(buf, len, prefix_code, start, count,
8827 points);
8828 break;
8829 case DNP3_OBJECT_CODE(32, 5):
8830 rc = DNP3DecodeObjectG32V5(buf, len, prefix_code, start, count,
8831 points);
8832 break;
8833 case DNP3_OBJECT_CODE(32, 6):
8834 rc = DNP3DecodeObjectG32V6(buf, len, prefix_code, start, count,
8835 points);
8836 break;
8837 case DNP3_OBJECT_CODE(32, 7):
8838 rc = DNP3DecodeObjectG32V7(buf, len, prefix_code, start, count,
8839 points);
8840 break;
8841 case DNP3_OBJECT_CODE(32, 8):
8842 rc = DNP3DecodeObjectG32V8(buf, len, prefix_code, start, count,
8843 points);
8844 break;
8845 case DNP3_OBJECT_CODE(33, 1):
8846 rc = DNP3DecodeObjectG33V1(buf, len, prefix_code, start, count,
8847 points);
8848 break;
8849 case DNP3_OBJECT_CODE(33, 2):
8850 rc = DNP3DecodeObjectG33V2(buf, len, prefix_code, start, count,
8851 points);
8852 break;
8853 case DNP3_OBJECT_CODE(33, 3):
8854 rc = DNP3DecodeObjectG33V3(buf, len, prefix_code, start, count,
8855 points);
8856 break;
8857 case DNP3_OBJECT_CODE(33, 4):
8858 rc = DNP3DecodeObjectG33V4(buf, len, prefix_code, start, count,
8859 points);
8860 break;
8861 case DNP3_OBJECT_CODE(33, 5):
8862 rc = DNP3DecodeObjectG33V5(buf, len, prefix_code, start, count,
8863 points);
8864 break;
8865 case DNP3_OBJECT_CODE(33, 6):
8866 rc = DNP3DecodeObjectG33V6(buf, len, prefix_code, start, count,
8867 points);
8868 break;
8869 case DNP3_OBJECT_CODE(33, 7):
8870 rc = DNP3DecodeObjectG33V7(buf, len, prefix_code, start, count,
8871 points);
8872 break;
8873 case DNP3_OBJECT_CODE(33, 8):
8874 rc = DNP3DecodeObjectG33V8(buf, len, prefix_code, start, count,
8875 points);
8876 break;
8877 case DNP3_OBJECT_CODE(34, 1):
8878 rc = DNP3DecodeObjectG34V1(buf, len, prefix_code, start, count,
8879 points);
8880 break;
8881 case DNP3_OBJECT_CODE(34, 2):
8882 rc = DNP3DecodeObjectG34V2(buf, len, prefix_code, start, count,
8883 points);
8884 break;
8885 case DNP3_OBJECT_CODE(34, 3):
8886 rc = DNP3DecodeObjectG34V3(buf, len, prefix_code, start, count,
8887 points);
8888 break;
8889 case DNP3_OBJECT_CODE(40, 1):
8890 rc = DNP3DecodeObjectG40V1(buf, len, prefix_code, start, count,
8891 points);
8892 break;
8893 case DNP3_OBJECT_CODE(40, 2):
8894 rc = DNP3DecodeObjectG40V2(buf, len, prefix_code, start, count,
8895 points);
8896 break;
8897 case DNP3_OBJECT_CODE(40, 3):
8898 rc = DNP3DecodeObjectG40V3(buf, len, prefix_code, start, count,
8899 points);
8900 break;
8901 case DNP3_OBJECT_CODE(40, 4):
8902 rc = DNP3DecodeObjectG40V4(buf, len, prefix_code, start, count,
8903 points);
8904 break;
8905 case DNP3_OBJECT_CODE(41, 1):
8906 rc = DNP3DecodeObjectG41V1(buf, len, prefix_code, start, count,
8907 points);
8908 break;
8909 case DNP3_OBJECT_CODE(41, 2):
8910 rc = DNP3DecodeObjectG41V2(buf, len, prefix_code, start, count,
8911 points);
8912 break;
8913 case DNP3_OBJECT_CODE(41, 3):
8914 rc = DNP3DecodeObjectG41V3(buf, len, prefix_code, start, count,
8915 points);
8916 break;
8917 case DNP3_OBJECT_CODE(41, 4):
8918 rc = DNP3DecodeObjectG41V4(buf, len, prefix_code, start, count,
8919 points);
8920 break;
8921 case DNP3_OBJECT_CODE(42, 1):
8922 rc = DNP3DecodeObjectG42V1(buf, len, prefix_code, start, count,
8923 points);
8924 break;
8925 case DNP3_OBJECT_CODE(42, 2):
8926 rc = DNP3DecodeObjectG42V2(buf, len, prefix_code, start, count,
8927 points);
8928 break;
8929 case DNP3_OBJECT_CODE(42, 3):
8930 rc = DNP3DecodeObjectG42V3(buf, len, prefix_code, start, count,
8931 points);
8932 break;
8933 case DNP3_OBJECT_CODE(42, 4):
8934 rc = DNP3DecodeObjectG42V4(buf, len, prefix_code, start, count,
8935 points);
8936 break;
8937 case DNP3_OBJECT_CODE(42, 5):
8938 rc = DNP3DecodeObjectG42V5(buf, len, prefix_code, start, count,
8939 points);
8940 break;
8941 case DNP3_OBJECT_CODE(42, 6):
8942 rc = DNP3DecodeObjectG42V6(buf, len, prefix_code, start, count,
8943 points);
8944 break;
8945 case DNP3_OBJECT_CODE(42, 7):
8946 rc = DNP3DecodeObjectG42V7(buf, len, prefix_code, start, count,
8947 points);
8948 break;
8949 case DNP3_OBJECT_CODE(42, 8):
8950 rc = DNP3DecodeObjectG42V8(buf, len, prefix_code, start, count,
8951 points);
8952 break;
8953 case DNP3_OBJECT_CODE(43, 1):
8954 rc = DNP3DecodeObjectG43V1(buf, len, prefix_code, start, count,
8955 points);
8956 break;
8957 case DNP3_OBJECT_CODE(43, 2):
8958 rc = DNP3DecodeObjectG43V2(buf, len, prefix_code, start, count,
8959 points);
8960 break;
8961 case DNP3_OBJECT_CODE(43, 3):
8962 rc = DNP3DecodeObjectG43V3(buf, len, prefix_code, start, count,
8963 points);
8964 break;
8965 case DNP3_OBJECT_CODE(43, 4):
8966 rc = DNP3DecodeObjectG43V4(buf, len, prefix_code, start, count,
8967 points);
8968 break;
8969 case DNP3_OBJECT_CODE(43, 5):
8970 rc = DNP3DecodeObjectG43V5(buf, len, prefix_code, start, count,
8971 points);
8972 break;
8973 case DNP3_OBJECT_CODE(43, 6):
8974 rc = DNP3DecodeObjectG43V6(buf, len, prefix_code, start, count,
8975 points);
8976 break;
8977 case DNP3_OBJECT_CODE(43, 7):
8978 rc = DNP3DecodeObjectG43V7(buf, len, prefix_code, start, count,
8979 points);
8980 break;
8981 case DNP3_OBJECT_CODE(43, 8):
8982 rc = DNP3DecodeObjectG43V8(buf, len, prefix_code, start, count,
8983 points);
8984 break;
8985 case DNP3_OBJECT_CODE(50, 1):
8986 rc = DNP3DecodeObjectG50V1(buf, len, prefix_code, start, count,
8987 points);
8988 break;
8989 case DNP3_OBJECT_CODE(50, 2):
8990 rc = DNP3DecodeObjectG50V2(buf, len, prefix_code, start, count,
8991 points);
8992 break;
8993 case DNP3_OBJECT_CODE(50, 3):
8994 rc = DNP3DecodeObjectG50V3(buf, len, prefix_code, start, count,
8995 points);
8996 break;
8997 case DNP3_OBJECT_CODE(50, 4):
8998 rc = DNP3DecodeObjectG50V4(buf, len, prefix_code, start, count,
8999 points);
9000 break;
9001 case DNP3_OBJECT_CODE(51, 1):
9002 rc = DNP3DecodeObjectG51V1(buf, len, prefix_code, start, count,
9003 points);
9004 break;
9005 case DNP3_OBJECT_CODE(51, 2):
9006 rc = DNP3DecodeObjectG51V2(buf, len, prefix_code, start, count,
9007 points);
9008 break;
9009 case DNP3_OBJECT_CODE(52, 1):
9010 rc = DNP3DecodeObjectG52V1(buf, len, prefix_code, start, count,
9011 points);
9012 break;
9013 case DNP3_OBJECT_CODE(52, 2):
9014 rc = DNP3DecodeObjectG52V2(buf, len, prefix_code, start, count,
9015 points);
9016 break;
9017 case DNP3_OBJECT_CODE(70, 1):
9018 rc = DNP3DecodeObjectG70V1(buf, len, prefix_code, start, count,
9019 points);
9020 break;
9021 case DNP3_OBJECT_CODE(70, 2):
9022 rc = DNP3DecodeObjectG70V2(buf, len, prefix_code, start, count,
9023 points);
9024 break;
9025 case DNP3_OBJECT_CODE(70, 3):
9026 rc = DNP3DecodeObjectG70V3(buf, len, prefix_code, start, count,
9027 points);
9028 break;
9029 case DNP3_OBJECT_CODE(70, 4):
9030 rc = DNP3DecodeObjectG70V4(buf, len, prefix_code, start, count,
9031 points);
9032 break;
9033 case DNP3_OBJECT_CODE(70, 5):
9034 rc = DNP3DecodeObjectG70V5(buf, len, prefix_code, start, count,
9035 points);
9036 break;
9037 case DNP3_OBJECT_CODE(70, 6):
9038 rc = DNP3DecodeObjectG70V6(buf, len, prefix_code, start, count,
9039 points);
9040 break;
9041 case DNP3_OBJECT_CODE(70, 7):
9042 rc = DNP3DecodeObjectG70V7(buf, len, prefix_code, start, count,
9043 points);
9044 break;
9045 case DNP3_OBJECT_CODE(70, 8):
9046 rc = DNP3DecodeObjectG70V8(buf, len, prefix_code, start, count,
9047 points);
9048 break;
9049 case DNP3_OBJECT_CODE(80, 1):
9050 rc = DNP3DecodeObjectG80V1(buf, len, prefix_code, start, count,
9051 points);
9052 break;
9053 case DNP3_OBJECT_CODE(81, 1):
9054 rc = DNP3DecodeObjectG81V1(buf, len, prefix_code, start, count,
9055 points);
9056 break;
9057 case DNP3_OBJECT_CODE(83, 1):
9058 rc = DNP3DecodeObjectG83V1(buf, len, prefix_code, start, count,
9059 points);
9060 break;
9061 case DNP3_OBJECT_CODE(86, 2):
9062 rc = DNP3DecodeObjectG86V2(buf, len, prefix_code, start, count,
9063 points);
9064 break;
9065 case DNP3_OBJECT_CODE(102, 1):
9066 rc = DNP3DecodeObjectG102V1(buf, len, prefix_code, start, count,
9067 points);
9068 break;
9069 case DNP3_OBJECT_CODE(120, 1):
9070 rc = DNP3DecodeObjectG120V1(buf, len, prefix_code, start, count,
9071 points);
9072 break;
9073 case DNP3_OBJECT_CODE(120, 2):
9074 rc = DNP3DecodeObjectG120V2(buf, len, prefix_code, start, count,
9075 points);
9076 break;
9077 case DNP3_OBJECT_CODE(120, 3):
9078 rc = DNP3DecodeObjectG120V3(buf, len, prefix_code, start, count,
9079 points);
9080 break;
9081 case DNP3_OBJECT_CODE(120, 4):
9082 rc = DNP3DecodeObjectG120V4(buf, len, prefix_code, start, count,
9083 points);
9084 break;
9085 case DNP3_OBJECT_CODE(120, 5):
9086 rc = DNP3DecodeObjectG120V5(buf, len, prefix_code, start, count,
9087 points);
9088 break;
9089 case DNP3_OBJECT_CODE(120, 6):
9090 rc = DNP3DecodeObjectG120V6(buf, len, prefix_code, start, count,
9091 points);
9092 break;
9093 case DNP3_OBJECT_CODE(120, 7):
9094 rc = DNP3DecodeObjectG120V7(buf, len, prefix_code, start, count,
9095 points);
9096 break;
9097 case DNP3_OBJECT_CODE(120, 8):
9098 rc = DNP3DecodeObjectG120V8(buf, len, prefix_code, start, count,
9099 points);
9100 break;
9101 case DNP3_OBJECT_CODE(120, 9):
9102 rc = DNP3DecodeObjectG120V9(buf, len, prefix_code, start, count,
9103 points);
9104 break;
9105 case DNP3_OBJECT_CODE(120, 10):
9106 rc = DNP3DecodeObjectG120V10(buf, len, prefix_code, start, count,
9107 points);
9108 break;
9109 case DNP3_OBJECT_CODE(120, 11):
9110 rc = DNP3DecodeObjectG120V11(buf, len, prefix_code, start, count,
9111 points);
9112 break;
9113 case DNP3_OBJECT_CODE(120, 12):
9114 rc = DNP3DecodeObjectG120V12(buf, len, prefix_code, start, count,
9115 points);
9116 break;
9117 case DNP3_OBJECT_CODE(120, 13):
9118 rc = DNP3DecodeObjectG120V13(buf, len, prefix_code, start, count,
9119 points);
9120 break;
9121 case DNP3_OBJECT_CODE(120, 14):
9122 rc = DNP3DecodeObjectG120V14(buf, len, prefix_code, start, count,
9123 points);
9124 break;
9125 case DNP3_OBJECT_CODE(120, 15):
9126 rc = DNP3DecodeObjectG120V15(buf, len, prefix_code, start, count,
9127 points);
9128 break;
9129 case DNP3_OBJECT_CODE(121, 1):
9130 rc = DNP3DecodeObjectG121V1(buf, len, prefix_code, start, count,
9131 points);
9132 break;
9133 case DNP3_OBJECT_CODE(122, 1):
9134 rc = DNP3DecodeObjectG122V1(buf, len, prefix_code, start, count,
9135 points);
9136 break;
9137 case DNP3_OBJECT_CODE(122, 2):
9138 rc = DNP3DecodeObjectG122V2(buf, len, prefix_code, start, count,
9139 points);
9140 break;
9141 default:
9142 return DNP3_DECODER_EVENT_UNKNOWN_OBJECT;
9143 }
9144
9145 return rc ? 0 : DNP3_DECODER_EVENT_MALFORMED;
9146}
9147
9148/* END GENERATED CODE */