suricata
app-layer-dnp3-objects.c
Go to the documentation of this file.
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 
31 void DNP3FreeObjectPoint(int group, int variation, void *point);
32 
33 #if 0
34 static 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  */
45 DNP3PointList *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  */
58 void 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  */
84 static 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  */
108 static 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  */
132 static 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  */
165 static 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  */
189 static 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  */
224 static 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  */
260 static 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  */
294 static 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  if (!DNP3ReadUint32(buf, len, out)) {
322  return 0;
323  }
324  break;
325  case sizeof(uint16_t): {
326  /* Temp value for strict-aliasing. */
327  uint16_t val = 0;
328  if (!DNP3ReadUint16(buf, len, &val)) {
329  return 0;
330  }
331  *out = val;
332  break;
333  }
334  case sizeof(uint8_t): {
335  /* Temp value for strict-aliasing. */
336  uint8_t val = 0;
337  if (!DNP3ReadUint8(buf, len, &val)) {
338  return 0;
339  }
340  *out = val;
341  break;
342  }
343  default:
344  *out = 0;
345  break;
346  }
347 
348  return 1;
349 }
350 
351 /**
352  * \brief Add an object to a DNP3PointList.
353  *
354  * \retval 1 if successfull, 0 on failure.
355  */
356 static int DNP3AddPoint(DNP3PointList *list, void *object, uint32_t point_index,
357  uint8_t prefix_code, uint32_t prefix)
358 {
359  DNP3Point *point = SCCalloc(1, sizeof(*point));
360  if (unlikely(point == NULL)) {
361  return 0;
362  }
363  TAILQ_INSERT_TAIL(list, point, next);
364  point->data = object;
365  point->prefix = prefix;
366  point->index = point_index;
367  switch (prefix_code) {
368  case 0x00:
369  break;
370  case 0x01:
371  case 0x02:
372  case 0x03:
373  point->index = prefix;
374  break;
375  case 0x04:
376  case 0x05:
377  case 0x06:
378  point->size = prefix;
379  break;
380  default:
381  break;
382  }
383 
384  return 1;
385 }
386 
387 /* START GENERATED CODE */
388 
389 /* Code generated by:
390  * ./scripts/dnp3-gen/dnp3-gen.py
391  */
392 
393 static int DNP3DecodeObjectG1V1(const uint8_t **buf, uint32_t *len,
394  uint8_t prefix_code, uint32_t start, uint32_t count,
395  DNP3PointList *points)
396 {
397  DNP3ObjectG1V1 *object = NULL;
398  int bytes = (count / 8) + 1;
399  uint32_t prefix = 0;
400  int point_index = start;
401 
402  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
403  goto error;
404  }
405 
406  for (int i = 0; i < bytes; i++) {
407 
408  uint8_t octet;
409 
410  if (!DNP3ReadUint8(buf, len, &octet)) {
411  goto error;
412  }
413 
414  for (int j = 0; j < 8 && count; j = j + 1) {
415 
416  object = SCCalloc(1, sizeof(*object));
417  if (unlikely(object == NULL)) {
418  goto error;
419  }
420 
421  object->state = (octet >> j) & 0x1;
422 
423  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
424  goto error;
425  }
426 
427  object = NULL;
428  count--;
429  point_index++;
430  }
431 
432  }
433 
434  return 1;
435 error:
436  if (object != NULL) {
437  SCFree(object);
438  }
439  return 0;
440 }
441 
442 static int DNP3DecodeObjectG1V2(const uint8_t **buf, uint32_t *len,
443  uint8_t prefix_code, uint32_t start, uint32_t count,
444  DNP3PointList *points)
445 {
446  DNP3ObjectG1V2 *object = NULL;
447  uint32_t prefix = 0;
448  uint32_t point_index = start;
449 
450  while (count--) {
451 
452  object = SCCalloc(1, sizeof(*object));
453  if (unlikely(object == NULL)) {
454  goto error;
455  }
456 
457  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
458  goto error;
459  }
460 
461  {
462  uint8_t octet;
463  if (!DNP3ReadUint8(buf, len, &octet)) {
464  goto error;
465  }
466  object->online = (octet >> 0) & 0x1;
467  object->restart = (octet >> 1) & 0x1;
468  object->comm_lost = (octet >> 2) & 0x1;
469  object->remote_forced = (octet >> 3) & 0x1;
470  object->local_forced = (octet >> 4) & 0x1;
471  object->chatter_filter = (octet >> 5) & 0x1;
472  object->reserved = (octet >> 6) & 0x1;
473  object->state = (octet >> 7) & 0x1;
474  }
475 
476  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
477  goto error;
478  }
479 
480  object = NULL;
481  point_index++;
482  }
483 
484  return 1;
485 error:
486  if (object != NULL) {
487  SCFree(object);
488  }
489 
490  return 0;
491 }
492 
493 static int DNP3DecodeObjectG2V1(const uint8_t **buf, uint32_t *len,
494  uint8_t prefix_code, uint32_t start, uint32_t count,
495  DNP3PointList *points)
496 {
497  DNP3ObjectG2V1 *object = NULL;
498  uint32_t prefix = 0;
499  uint32_t point_index = start;
500 
501  while (count--) {
502 
503  object = SCCalloc(1, sizeof(*object));
504  if (unlikely(object == NULL)) {
505  goto error;
506  }
507 
508  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
509  goto error;
510  }
511 
512  if (!DNP3ReadUint8(buf, len, &object->state)) {
513  goto error;
514  }
515 
516  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
517  goto error;
518  }
519 
520  object = NULL;
521  point_index++;
522  }
523 
524  return 1;
525 error:
526  if (object != NULL) {
527  SCFree(object);
528  }
529 
530  return 0;
531 }
532 
533 static int DNP3DecodeObjectG2V2(const uint8_t **buf, uint32_t *len,
534  uint8_t prefix_code, uint32_t start, uint32_t count,
535  DNP3PointList *points)
536 {
537  DNP3ObjectG2V2 *object = NULL;
538  uint32_t prefix = 0;
539  uint32_t point_index = start;
540 
541  while (count--) {
542 
543  object = SCCalloc(1, sizeof(*object));
544  if (unlikely(object == NULL)) {
545  goto error;
546  }
547 
548  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
549  goto error;
550  }
551 
552  {
553  uint8_t octet;
554  if (!DNP3ReadUint8(buf, len, &octet)) {
555  goto error;
556  }
557  object->online = (octet >> 0) & 0x1;
558  object->restart = (octet >> 1) & 0x1;
559  object->comm_lost = (octet >> 2) & 0x1;
560  object->remote_forced = (octet >> 3) & 0x1;
561  object->local_forced = (octet >> 4) & 0x1;
562  object->chatter_filter = (octet >> 5) & 0x1;
563  object->reserved = (octet >> 6) & 0x1;
564  object->state = (octet >> 7) & 0x1;
565  }
566  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
567  goto error;
568  }
569 
570  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
571  goto error;
572  }
573 
574  object = NULL;
575  point_index++;
576  }
577 
578  return 1;
579 error:
580  if (object != NULL) {
581  SCFree(object);
582  }
583 
584  return 0;
585 }
586 
587 static int DNP3DecodeObjectG2V3(const uint8_t **buf, uint32_t *len,
588  uint8_t prefix_code, uint32_t start, uint32_t count,
589  DNP3PointList *points)
590 {
591  DNP3ObjectG2V3 *object = NULL;
592  uint32_t prefix = 0;
593  uint32_t point_index = start;
594 
595  while (count--) {
596 
597  object = SCCalloc(1, sizeof(*object));
598  if (unlikely(object == NULL)) {
599  goto error;
600  }
601 
602  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
603  goto error;
604  }
605 
606  {
607  uint8_t octet;
608  if (!DNP3ReadUint8(buf, len, &octet)) {
609  goto error;
610  }
611  object->online = (octet >> 0) & 0x1;
612  object->restart = (octet >> 1) & 0x1;
613  object->comm_lost = (octet >> 2) & 0x1;
614  object->remote_forced = (octet >> 3) & 0x1;
615  object->local_forced = (octet >> 4) & 0x1;
616  object->chatter_filter = (octet >> 5) & 0x1;
617  object->reserved = (octet >> 6) & 0x1;
618  object->state = (octet >> 7) & 0x1;
619  }
620  if (!DNP3ReadUint16(buf, len, &object->timestamp)) {
621  goto error;
622  }
623 
624  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
625  goto error;
626  }
627 
628  object = NULL;
629  point_index++;
630  }
631 
632  return 1;
633 error:
634  if (object != NULL) {
635  SCFree(object);
636  }
637 
638  return 0;
639 }
640 
641 static int DNP3DecodeObjectG3V1(const uint8_t **buf, uint32_t *len,
642  uint8_t prefix_code, uint32_t start, uint32_t count,
643  DNP3PointList *points)
644 {
645  DNP3ObjectG3V1 *object = NULL;
646  int bytes = (count / 8) + 1;
647  uint32_t prefix = 0;
648  int point_index = start;
649 
650  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
651  goto error;
652  }
653 
654  for (int i = 0; i < bytes; i++) {
655 
656  uint8_t octet;
657 
658  if (!DNP3ReadUint8(buf, len, &octet)) {
659  goto error;
660  }
661 
662  for (int j = 0; j < 8 && count; j = j + 2) {
663 
664  object = SCCalloc(1, sizeof(*object));
665  if (unlikely(object == NULL)) {
666  goto error;
667  }
668 
669  object->state = (octet >> j) & 0x3;
670 
671  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
672  goto error;
673  }
674 
675  object = NULL;
676  count--;
677  point_index++;
678  }
679 
680  }
681 
682  return 1;
683 error:
684  if (object != NULL) {
685  SCFree(object);
686  }
687  return 0;
688 }
689 
690 static int DNP3DecodeObjectG3V2(const uint8_t **buf, uint32_t *len,
691  uint8_t prefix_code, uint32_t start, uint32_t count,
692  DNP3PointList *points)
693 {
694  DNP3ObjectG3V2 *object = NULL;
695  uint32_t prefix = 0;
696  uint32_t point_index = start;
697 
698  while (count--) {
699 
700  object = SCCalloc(1, sizeof(*object));
701  if (unlikely(object == NULL)) {
702  goto error;
703  }
704 
705  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
706  goto error;
707  }
708 
709  {
710  uint8_t octet;
711  if (!DNP3ReadUint8(buf, len, &octet)) {
712  goto error;
713  }
714  object->online = (octet >> 0) & 0x1;
715  object->restart = (octet >> 1) & 0x1;
716  object->comm_lost = (octet >> 2) & 0x1;
717  object->remote_forced = (octet >> 3) & 0x1;
718  object->local_forced = (octet >> 4) & 0x1;
719  object->chatter_filter = (octet >> 5) & 0x1;
720  object->state = (octet >> 6) & 0x3;
721  }
722 
723  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
724  goto error;
725  }
726 
727  object = NULL;
728  point_index++;
729  }
730 
731  return 1;
732 error:
733  if (object != NULL) {
734  SCFree(object);
735  }
736 
737  return 0;
738 }
739 
740 static int DNP3DecodeObjectG4V1(const uint8_t **buf, uint32_t *len,
741  uint8_t prefix_code, uint32_t start, uint32_t count,
742  DNP3PointList *points)
743 {
744  DNP3ObjectG4V1 *object = NULL;
745  uint32_t prefix = 0;
746  uint32_t point_index = start;
747 
748  while (count--) {
749 
750  object = SCCalloc(1, sizeof(*object));
751  if (unlikely(object == NULL)) {
752  goto error;
753  }
754 
755  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
756  goto error;
757  }
758 
759  {
760  uint8_t octet;
761  if (!DNP3ReadUint8(buf, len, &octet)) {
762  goto error;
763  }
764  object->online = (octet >> 0) & 0x1;
765  object->restart = (octet >> 1) & 0x1;
766  object->comm_lost = (octet >> 2) & 0x1;
767  object->remote_forced = (octet >> 3) & 0x1;
768  object->local_forced = (octet >> 4) & 0x1;
769  object->chatter_filter = (octet >> 5) & 0x1;
770  object->state = (octet >> 6) & 0x3;
771  }
772 
773  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
774  goto error;
775  }
776 
777  object = NULL;
778  point_index++;
779  }
780 
781  return 1;
782 error:
783  if (object != NULL) {
784  SCFree(object);
785  }
786 
787  return 0;
788 }
789 
790 static int DNP3DecodeObjectG4V2(const uint8_t **buf, uint32_t *len,
791  uint8_t prefix_code, uint32_t start, uint32_t count,
792  DNP3PointList *points)
793 {
794  DNP3ObjectG4V2 *object = NULL;
795  uint32_t prefix = 0;
796  uint32_t point_index = start;
797 
798  while (count--) {
799 
800  object = SCCalloc(1, sizeof(*object));
801  if (unlikely(object == NULL)) {
802  goto error;
803  }
804 
805  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
806  goto error;
807  }
808 
809  {
810  uint8_t octet;
811  if (!DNP3ReadUint8(buf, len, &octet)) {
812  goto error;
813  }
814  object->online = (octet >> 0) & 0x1;
815  object->restart = (octet >> 1) & 0x1;
816  object->comm_lost = (octet >> 2) & 0x1;
817  object->remote_forced = (octet >> 3) & 0x1;
818  object->local_forced = (octet >> 4) & 0x1;
819  object->chatter_filter = (octet >> 5) & 0x1;
820  object->state = (octet >> 6) & 0x3;
821  }
822  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
823  goto error;
824  }
825 
826  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
827  goto error;
828  }
829 
830  object = NULL;
831  point_index++;
832  }
833 
834  return 1;
835 error:
836  if (object != NULL) {
837  SCFree(object);
838  }
839 
840  return 0;
841 }
842 
843 static int DNP3DecodeObjectG4V3(const uint8_t **buf, uint32_t *len,
844  uint8_t prefix_code, uint32_t start, uint32_t count,
845  DNP3PointList *points)
846 {
847  DNP3ObjectG4V3 *object = NULL;
848  uint32_t prefix = 0;
849  uint32_t point_index = start;
850 
851  while (count--) {
852 
853  object = SCCalloc(1, sizeof(*object));
854  if (unlikely(object == NULL)) {
855  goto error;
856  }
857 
858  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
859  goto error;
860  }
861 
862  {
863  uint8_t octet;
864  if (!DNP3ReadUint8(buf, len, &octet)) {
865  goto error;
866  }
867  object->online = (octet >> 0) & 0x1;
868  object->restart = (octet >> 1) & 0x1;
869  object->comm_lost = (octet >> 2) & 0x1;
870  object->remote_forced = (octet >> 3) & 0x1;
871  object->local_forced = (octet >> 4) & 0x1;
872  object->chatter_filter = (octet >> 5) & 0x1;
873  object->state = (octet >> 6) & 0x3;
874  }
875  if (!DNP3ReadUint16(buf, len, &object->relative_time_ms)) {
876  goto error;
877  }
878 
879  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
880  goto error;
881  }
882 
883  object = NULL;
884  point_index++;
885  }
886 
887  return 1;
888 error:
889  if (object != NULL) {
890  SCFree(object);
891  }
892 
893  return 0;
894 }
895 
896 static int DNP3DecodeObjectG10V1(const uint8_t **buf, uint32_t *len,
897  uint8_t prefix_code, uint32_t start, uint32_t count,
898  DNP3PointList *points)
899 {
900  DNP3ObjectG10V1 *object = NULL;
901  int bytes = (count / 8) + 1;
902  uint32_t prefix = 0;
903  int point_index = start;
904 
905  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
906  goto error;
907  }
908 
909  for (int i = 0; i < bytes; i++) {
910 
911  uint8_t octet;
912 
913  if (!DNP3ReadUint8(buf, len, &octet)) {
914  goto error;
915  }
916 
917  for (int j = 0; j < 8 && count; j = j + 1) {
918 
919  object = SCCalloc(1, sizeof(*object));
920  if (unlikely(object == NULL)) {
921  goto error;
922  }
923 
924  object->state = (octet >> j) & 0x1;
925 
926  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
927  goto error;
928  }
929 
930  object = NULL;
931  count--;
932  point_index++;
933  }
934 
935  }
936 
937  return 1;
938 error:
939  if (object != NULL) {
940  SCFree(object);
941  }
942  return 0;
943 }
944 
945 static int DNP3DecodeObjectG10V2(const uint8_t **buf, uint32_t *len,
946  uint8_t prefix_code, uint32_t start, uint32_t count,
947  DNP3PointList *points)
948 {
949  DNP3ObjectG10V2 *object = NULL;
950  uint32_t prefix = 0;
951  uint32_t point_index = start;
952 
953  while (count--) {
954 
955  object = SCCalloc(1, sizeof(*object));
956  if (unlikely(object == NULL)) {
957  goto error;
958  }
959 
960  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
961  goto error;
962  }
963 
964  {
965  uint8_t octet;
966  if (!DNP3ReadUint8(buf, len, &octet)) {
967  goto error;
968  }
969  object->online = (octet >> 0) & 0x1;
970  object->restart = (octet >> 1) & 0x1;
971  object->comm_lost = (octet >> 2) & 0x1;
972  object->remote_forced = (octet >> 3) & 0x1;
973  object->local_forced = (octet >> 4) & 0x1;
974  object->reserved0 = (octet >> 5) & 0x1;
975  object->reserved1 = (octet >> 6) & 0x1;
976  object->state = (octet >> 7) & 0x1;
977  }
978 
979  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
980  goto error;
981  }
982 
983  object = NULL;
984  point_index++;
985  }
986 
987  return 1;
988 error:
989  if (object != NULL) {
990  SCFree(object);
991  }
992 
993  return 0;
994 }
995 
996 static int DNP3DecodeObjectG11V1(const uint8_t **buf, uint32_t *len,
997  uint8_t prefix_code, uint32_t start, uint32_t count,
998  DNP3PointList *points)
999 {
1000  DNP3ObjectG11V1 *object = NULL;
1001  uint32_t prefix = 0;
1002  uint32_t point_index = start;
1003 
1004  while (count--) {
1005 
1006  object = SCCalloc(1, sizeof(*object));
1007  if (unlikely(object == NULL)) {
1008  goto error;
1009  }
1010 
1011  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1012  goto error;
1013  }
1014 
1015  {
1016  uint8_t octet;
1017  if (!DNP3ReadUint8(buf, len, &octet)) {
1018  goto error;
1019  }
1020  object->online = (octet >> 0) & 0x1;
1021  object->restart = (octet >> 1) & 0x1;
1022  object->comm_lost = (octet >> 2) & 0x1;
1023  object->remote_forced = (octet >> 3) & 0x1;
1024  object->local_forced = (octet >> 4) & 0x1;
1025  object->reserved0 = (octet >> 5) & 0x1;
1026  object->reserved1 = (octet >> 6) & 0x1;
1027  object->state = (octet >> 7) & 0x1;
1028  }
1029 
1030  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1031  goto error;
1032  }
1033 
1034  object = NULL;
1035  point_index++;
1036  }
1037 
1038  return 1;
1039 error:
1040  if (object != NULL) {
1041  SCFree(object);
1042  }
1043 
1044  return 0;
1045 }
1046 
1047 static int DNP3DecodeObjectG11V2(const uint8_t **buf, uint32_t *len,
1048  uint8_t prefix_code, uint32_t start, uint32_t count,
1049  DNP3PointList *points)
1050 {
1051  DNP3ObjectG11V2 *object = NULL;
1052  uint32_t prefix = 0;
1053  uint32_t point_index = start;
1054 
1055  while (count--) {
1056 
1057  object = SCCalloc(1, sizeof(*object));
1058  if (unlikely(object == NULL)) {
1059  goto error;
1060  }
1061 
1062  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1063  goto error;
1064  }
1065 
1066  {
1067  uint8_t octet;
1068  if (!DNP3ReadUint8(buf, len, &octet)) {
1069  goto error;
1070  }
1071  object->online = (octet >> 0) & 0x1;
1072  object->restart = (octet >> 1) & 0x1;
1073  object->comm_lost = (octet >> 2) & 0x1;
1074  object->remote_forced = (octet >> 3) & 0x1;
1075  object->local_forced = (octet >> 4) & 0x1;
1076  object->reserved0 = (octet >> 5) & 0x1;
1077  object->reserved1 = (octet >> 6) & 0x1;
1078  object->state = (octet >> 7) & 0x1;
1079  }
1080  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
1081  goto error;
1082  }
1083 
1084  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1085  goto error;
1086  }
1087 
1088  object = NULL;
1089  point_index++;
1090  }
1091 
1092  return 1;
1093 error:
1094  if (object != NULL) {
1095  SCFree(object);
1096  }
1097 
1098  return 0;
1099 }
1100 
1101 static int DNP3DecodeObjectG12V1(const uint8_t **buf, uint32_t *len,
1102  uint8_t prefix_code, uint32_t start, uint32_t count,
1103  DNP3PointList *points)
1104 {
1105  DNP3ObjectG12V1 *object = NULL;
1106  uint32_t prefix = 0;
1107  uint32_t point_index = start;
1108 
1109  while (count--) {
1110 
1111  object = SCCalloc(1, sizeof(*object));
1112  if (unlikely(object == NULL)) {
1113  goto error;
1114  }
1115 
1116  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1117  goto error;
1118  }
1119 
1120  {
1121  uint8_t octet;
1122  if (!DNP3ReadUint8(buf, len, &octet)) {
1123  goto error;
1124  }
1125  object->op_type = (octet >> 0) & 0xf;
1126  object->qu = (octet >> 4) & 0x1;
1127  object->cr = (octet >> 5) & 0x1;
1128  object->tcc = (octet >> 6) & 0x3;
1129  }
1130  if (!DNP3ReadUint8(buf, len, &object->count)) {
1131  goto error;
1132  }
1133  if (!DNP3ReadUint32(buf, len, &object->ontime)) {
1134  goto error;
1135  }
1136  if (!DNP3ReadUint32(buf, len, &object->offtime)) {
1137  goto error;
1138  }
1139  {
1140  uint8_t octet;
1141  if (!DNP3ReadUint8(buf, len, &octet)) {
1142  goto error;
1143  }
1144  object->status_code = (octet >> 0) & 0x7f;
1145  object->reserved = (octet >> 7) & 0x1;
1146  }
1147 
1148  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1149  goto error;
1150  }
1151 
1152  object = NULL;
1153  point_index++;
1154  }
1155 
1156  return 1;
1157 error:
1158  if (object != NULL) {
1159  SCFree(object);
1160  }
1161 
1162  return 0;
1163 }
1164 
1165 static int DNP3DecodeObjectG12V2(const uint8_t **buf, uint32_t *len,
1166  uint8_t prefix_code, uint32_t start, uint32_t count,
1167  DNP3PointList *points)
1168 {
1169  DNP3ObjectG12V2 *object = NULL;
1170  uint32_t prefix = 0;
1171  uint32_t point_index = start;
1172 
1173  while (count--) {
1174 
1175  object = SCCalloc(1, sizeof(*object));
1176  if (unlikely(object == NULL)) {
1177  goto error;
1178  }
1179 
1180  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1181  goto error;
1182  }
1183 
1184  {
1185  uint8_t octet;
1186  if (!DNP3ReadUint8(buf, len, &octet)) {
1187  goto error;
1188  }
1189  object->op_type = (octet >> 0) & 0xf;
1190  object->qu = (octet >> 4) & 0x1;
1191  object->cr = (octet >> 5) & 0x1;
1192  object->tcc = (octet >> 6) & 0x3;
1193  }
1194  if (!DNP3ReadUint8(buf, len, &object->count)) {
1195  goto error;
1196  }
1197  if (!DNP3ReadUint32(buf, len, &object->ontime)) {
1198  goto error;
1199  }
1200  if (!DNP3ReadUint32(buf, len, &object->offtime)) {
1201  goto error;
1202  }
1203  {
1204  uint8_t octet;
1205  if (!DNP3ReadUint8(buf, len, &octet)) {
1206  goto error;
1207  }
1208  object->status_code = (octet >> 0) & 0x7f;
1209  object->reserved = (octet >> 7) & 0x1;
1210  }
1211 
1212  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1213  goto error;
1214  }
1215 
1216  object = NULL;
1217  point_index++;
1218  }
1219 
1220  return 1;
1221 error:
1222  if (object != NULL) {
1223  SCFree(object);
1224  }
1225 
1226  return 0;
1227 }
1228 
1229 static int DNP3DecodeObjectG12V3(const uint8_t **buf, uint32_t *len,
1230  uint8_t prefix_code, uint32_t start, uint32_t count,
1231  DNP3PointList *points)
1232 {
1233  DNP3ObjectG12V3 *object = NULL;
1234  int bytes = (count / 8) + 1;
1235  uint32_t prefix = 0;
1236  int point_index = start;
1237 
1238  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1239  goto error;
1240  }
1241 
1242  for (int i = 0; i < bytes; i++) {
1243 
1244  uint8_t octet;
1245 
1246  if (!DNP3ReadUint8(buf, len, &octet)) {
1247  goto error;
1248  }
1249 
1250  for (int j = 0; j < 8 && count; j = j + 1) {
1251 
1252  object = SCCalloc(1, sizeof(*object));
1253  if (unlikely(object == NULL)) {
1254  goto error;
1255  }
1256 
1257  object->point = (octet >> j) & 0x1;
1258 
1259  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1260  goto error;
1261  }
1262 
1263  object = NULL;
1264  count--;
1265  point_index++;
1266  }
1267 
1268  }
1269 
1270  return 1;
1271 error:
1272  if (object != NULL) {
1273  SCFree(object);
1274  }
1275  return 0;
1276 }
1277 
1278 static int DNP3DecodeObjectG13V1(const uint8_t **buf, uint32_t *len,
1279  uint8_t prefix_code, uint32_t start, uint32_t count,
1280  DNP3PointList *points)
1281 {
1282  DNP3ObjectG13V1 *object = NULL;
1283  uint32_t prefix = 0;
1284  uint32_t point_index = start;
1285 
1286  while (count--) {
1287 
1288  object = SCCalloc(1, sizeof(*object));
1289  if (unlikely(object == NULL)) {
1290  goto error;
1291  }
1292 
1293  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1294  goto error;
1295  }
1296 
1297  {
1298  uint8_t octet;
1299  if (!DNP3ReadUint8(buf, len, &octet)) {
1300  goto error;
1301  }
1302  object->status_code = (octet >> 0) & 0x7f;
1303  object->commanded_state = (octet >> 7) & 0x1;
1304  }
1305 
1306  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1307  goto error;
1308  }
1309 
1310  object = NULL;
1311  point_index++;
1312  }
1313 
1314  return 1;
1315 error:
1316  if (object != NULL) {
1317  SCFree(object);
1318  }
1319 
1320  return 0;
1321 }
1322 
1323 static int DNP3DecodeObjectG13V2(const uint8_t **buf, uint32_t *len,
1324  uint8_t prefix_code, uint32_t start, uint32_t count,
1325  DNP3PointList *points)
1326 {
1327  DNP3ObjectG13V2 *object = NULL;
1328  uint32_t prefix = 0;
1329  uint32_t point_index = start;
1330 
1331  while (count--) {
1332 
1333  object = SCCalloc(1, sizeof(*object));
1334  if (unlikely(object == NULL)) {
1335  goto error;
1336  }
1337 
1338  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1339  goto error;
1340  }
1341 
1342  {
1343  uint8_t octet;
1344  if (!DNP3ReadUint8(buf, len, &octet)) {
1345  goto error;
1346  }
1347  object->status_code = (octet >> 0) & 0x7f;
1348  object->commanded_state = (octet >> 7) & 0x1;
1349  }
1350  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
1351  goto error;
1352  }
1353 
1354  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1355  goto error;
1356  }
1357 
1358  object = NULL;
1359  point_index++;
1360  }
1361 
1362  return 1;
1363 error:
1364  if (object != NULL) {
1365  SCFree(object);
1366  }
1367 
1368  return 0;
1369 }
1370 
1371 static int DNP3DecodeObjectG20V1(const uint8_t **buf, uint32_t *len,
1372  uint8_t prefix_code, uint32_t start, uint32_t count,
1373  DNP3PointList *points)
1374 {
1375  DNP3ObjectG20V1 *object = NULL;
1376  uint32_t prefix = 0;
1377  uint32_t point_index = start;
1378 
1379  while (count--) {
1380 
1381  object = SCCalloc(1, sizeof(*object));
1382  if (unlikely(object == NULL)) {
1383  goto error;
1384  }
1385 
1386  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1387  goto error;
1388  }
1389 
1390  {
1391  uint8_t octet;
1392  if (!DNP3ReadUint8(buf, len, &octet)) {
1393  goto error;
1394  }
1395  object->online = (octet >> 0) & 0x1;
1396  object->restart = (octet >> 1) & 0x1;
1397  object->comm_lost = (octet >> 2) & 0x1;
1398  object->remote_forced = (octet >> 3) & 0x1;
1399  object->local_forced = (octet >> 4) & 0x1;
1400  object->rollover = (octet >> 5) & 0x1;
1401  object->discontinuity = (octet >> 6) & 0x1;
1402  object->reserved0 = (octet >> 7) & 0x1;
1403  }
1404  if (!DNP3ReadUint32(buf, len, &object->count)) {
1405  goto error;
1406  }
1407 
1408  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1409  goto error;
1410  }
1411 
1412  object = NULL;
1413  point_index++;
1414  }
1415 
1416  return 1;
1417 error:
1418  if (object != NULL) {
1419  SCFree(object);
1420  }
1421 
1422  return 0;
1423 }
1424 
1425 static int DNP3DecodeObjectG20V2(const uint8_t **buf, uint32_t *len,
1426  uint8_t prefix_code, uint32_t start, uint32_t count,
1427  DNP3PointList *points)
1428 {
1429  DNP3ObjectG20V2 *object = NULL;
1430  uint32_t prefix = 0;
1431  uint32_t point_index = start;
1432 
1433  while (count--) {
1434 
1435  object = SCCalloc(1, sizeof(*object));
1436  if (unlikely(object == NULL)) {
1437  goto error;
1438  }
1439 
1440  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1441  goto error;
1442  }
1443 
1444  {
1445  uint8_t octet;
1446  if (!DNP3ReadUint8(buf, len, &octet)) {
1447  goto error;
1448  }
1449  object->online = (octet >> 0) & 0x1;
1450  object->restart = (octet >> 1) & 0x1;
1451  object->comm_lost = (octet >> 2) & 0x1;
1452  object->remote_forced = (octet >> 3) & 0x1;
1453  object->local_forced = (octet >> 4) & 0x1;
1454  object->rollover = (octet >> 5) & 0x1;
1455  object->discontinuity = (octet >> 6) & 0x1;
1456  object->reserved0 = (octet >> 7) & 0x1;
1457  }
1458  if (!DNP3ReadUint16(buf, len, &object->count)) {
1459  goto error;
1460  }
1461 
1462  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1463  goto error;
1464  }
1465 
1466  object = NULL;
1467  point_index++;
1468  }
1469 
1470  return 1;
1471 error:
1472  if (object != NULL) {
1473  SCFree(object);
1474  }
1475 
1476  return 0;
1477 }
1478 
1479 static int DNP3DecodeObjectG20V3(const uint8_t **buf, uint32_t *len,
1480  uint8_t prefix_code, uint32_t start, uint32_t count,
1481  DNP3PointList *points)
1482 {
1483  DNP3ObjectG20V3 *object = NULL;
1484  uint32_t prefix = 0;
1485  uint32_t point_index = start;
1486 
1487  while (count--) {
1488 
1489  object = SCCalloc(1, sizeof(*object));
1490  if (unlikely(object == NULL)) {
1491  goto error;
1492  }
1493 
1494  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1495  goto error;
1496  }
1497 
1498  {
1499  uint8_t octet;
1500  if (!DNP3ReadUint8(buf, len, &octet)) {
1501  goto error;
1502  }
1503  object->online = (octet >> 0) & 0x1;
1504  object->restart = (octet >> 1) & 0x1;
1505  object->comm_lost = (octet >> 2) & 0x1;
1506  object->remote_forced = (octet >> 3) & 0x1;
1507  object->local_forced = (octet >> 4) & 0x1;
1508  object->rollover = (octet >> 5) & 0x1;
1509  object->reserved0 = (octet >> 6) & 0x1;
1510  object->reserved1 = (octet >> 7) & 0x1;
1511  }
1512  if (!DNP3ReadUint32(buf, len, &object->count)) {
1513  goto error;
1514  }
1515 
1516  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1517  goto error;
1518  }
1519 
1520  object = NULL;
1521  point_index++;
1522  }
1523 
1524  return 1;
1525 error:
1526  if (object != NULL) {
1527  SCFree(object);
1528  }
1529 
1530  return 0;
1531 }
1532 
1533 static int DNP3DecodeObjectG20V4(const uint8_t **buf, uint32_t *len,
1534  uint8_t prefix_code, uint32_t start, uint32_t count,
1535  DNP3PointList *points)
1536 {
1537  DNP3ObjectG20V4 *object = NULL;
1538  uint32_t prefix = 0;
1539  uint32_t point_index = start;
1540 
1541  while (count--) {
1542 
1543  object = SCCalloc(1, sizeof(*object));
1544  if (unlikely(object == NULL)) {
1545  goto error;
1546  }
1547 
1548  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1549  goto error;
1550  }
1551 
1552  {
1553  uint8_t octet;
1554  if (!DNP3ReadUint8(buf, len, &octet)) {
1555  goto error;
1556  }
1557  object->online = (octet >> 0) & 0x1;
1558  object->restart = (octet >> 1) & 0x1;
1559  object->comm_lost = (octet >> 2) & 0x1;
1560  object->remote_forced = (octet >> 3) & 0x1;
1561  object->local_forced = (octet >> 4) & 0x1;
1562  object->rollover = (octet >> 5) & 0x1;
1563  object->reserved0 = (octet >> 6) & 0x1;
1564  object->reserved1 = (octet >> 7) & 0x1;
1565  }
1566  if (!DNP3ReadUint16(buf, len, &object->count)) {
1567  goto error;
1568  }
1569 
1570  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1571  goto error;
1572  }
1573 
1574  object = NULL;
1575  point_index++;
1576  }
1577 
1578  return 1;
1579 error:
1580  if (object != NULL) {
1581  SCFree(object);
1582  }
1583 
1584  return 0;
1585 }
1586 
1587 static int DNP3DecodeObjectG20V5(const uint8_t **buf, uint32_t *len,
1588  uint8_t prefix_code, uint32_t start, uint32_t count,
1589  DNP3PointList *points)
1590 {
1591  DNP3ObjectG20V5 *object = NULL;
1592  uint32_t prefix = 0;
1593  uint32_t point_index = start;
1594 
1595  while (count--) {
1596 
1597  object = SCCalloc(1, sizeof(*object));
1598  if (unlikely(object == NULL)) {
1599  goto error;
1600  }
1601 
1602  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1603  goto error;
1604  }
1605 
1606  if (!DNP3ReadUint32(buf, len, &object->count)) {
1607  goto error;
1608  }
1609 
1610  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1611  goto error;
1612  }
1613 
1614  object = NULL;
1615  point_index++;
1616  }
1617 
1618  return 1;
1619 error:
1620  if (object != NULL) {
1621  SCFree(object);
1622  }
1623 
1624  return 0;
1625 }
1626 
1627 static int DNP3DecodeObjectG20V6(const uint8_t **buf, uint32_t *len,
1628  uint8_t prefix_code, uint32_t start, uint32_t count,
1629  DNP3PointList *points)
1630 {
1631  DNP3ObjectG20V6 *object = NULL;
1632  uint32_t prefix = 0;
1633  uint32_t point_index = start;
1634 
1635  while (count--) {
1636 
1637  object = SCCalloc(1, sizeof(*object));
1638  if (unlikely(object == NULL)) {
1639  goto error;
1640  }
1641 
1642  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1643  goto error;
1644  }
1645 
1646  if (!DNP3ReadUint16(buf, len, &object->count)) {
1647  goto error;
1648  }
1649 
1650  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1651  goto error;
1652  }
1653 
1654  object = NULL;
1655  point_index++;
1656  }
1657 
1658  return 1;
1659 error:
1660  if (object != NULL) {
1661  SCFree(object);
1662  }
1663 
1664  return 0;
1665 }
1666 
1667 static int DNP3DecodeObjectG20V7(const uint8_t **buf, uint32_t *len,
1668  uint8_t prefix_code, uint32_t start, uint32_t count,
1669  DNP3PointList *points)
1670 {
1671  DNP3ObjectG20V7 *object = NULL;
1672  uint32_t prefix = 0;
1673  uint32_t point_index = start;
1674 
1675  while (count--) {
1676 
1677  object = SCCalloc(1, sizeof(*object));
1678  if (unlikely(object == NULL)) {
1679  goto error;
1680  }
1681 
1682  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1683  goto error;
1684  }
1685 
1686  if (!DNP3ReadUint32(buf, len, &object->count)) {
1687  goto error;
1688  }
1689 
1690  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1691  goto error;
1692  }
1693 
1694  object = NULL;
1695  point_index++;
1696  }
1697 
1698  return 1;
1699 error:
1700  if (object != NULL) {
1701  SCFree(object);
1702  }
1703 
1704  return 0;
1705 }
1706 
1707 static int DNP3DecodeObjectG20V8(const uint8_t **buf, uint32_t *len,
1708  uint8_t prefix_code, uint32_t start, uint32_t count,
1709  DNP3PointList *points)
1710 {
1711  DNP3ObjectG20V8 *object = NULL;
1712  uint32_t prefix = 0;
1713  uint32_t point_index = start;
1714 
1715  while (count--) {
1716 
1717  object = SCCalloc(1, sizeof(*object));
1718  if (unlikely(object == NULL)) {
1719  goto error;
1720  }
1721 
1722  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1723  goto error;
1724  }
1725 
1726  if (!DNP3ReadUint16(buf, len, &object->count)) {
1727  goto error;
1728  }
1729 
1730  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1731  goto error;
1732  }
1733 
1734  object = NULL;
1735  point_index++;
1736  }
1737 
1738  return 1;
1739 error:
1740  if (object != NULL) {
1741  SCFree(object);
1742  }
1743 
1744  return 0;
1745 }
1746 
1747 static int DNP3DecodeObjectG21V1(const uint8_t **buf, uint32_t *len,
1748  uint8_t prefix_code, uint32_t start, uint32_t count,
1749  DNP3PointList *points)
1750 {
1751  DNP3ObjectG21V1 *object = NULL;
1752  uint32_t prefix = 0;
1753  uint32_t point_index = start;
1754 
1755  while (count--) {
1756 
1757  object = SCCalloc(1, sizeof(*object));
1758  if (unlikely(object == NULL)) {
1759  goto error;
1760  }
1761 
1762  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1763  goto error;
1764  }
1765 
1766  {
1767  uint8_t octet;
1768  if (!DNP3ReadUint8(buf, len, &octet)) {
1769  goto error;
1770  }
1771  object->online = (octet >> 0) & 0x1;
1772  object->restart = (octet >> 1) & 0x1;
1773  object->comm_lost = (octet >> 2) & 0x1;
1774  object->remote_forced = (octet >> 3) & 0x1;
1775  object->local_forced = (octet >> 4) & 0x1;
1776  object->rollover = (octet >> 5) & 0x1;
1777  object->discontinuity = (octet >> 6) & 0x1;
1778  object->reserved0 = (octet >> 7) & 0x1;
1779  }
1780  if (!DNP3ReadUint32(buf, len, &object->count)) {
1781  goto error;
1782  }
1783 
1784  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1785  goto error;
1786  }
1787 
1788  object = NULL;
1789  point_index++;
1790  }
1791 
1792  return 1;
1793 error:
1794  if (object != NULL) {
1795  SCFree(object);
1796  }
1797 
1798  return 0;
1799 }
1800 
1801 static int DNP3DecodeObjectG21V2(const uint8_t **buf, uint32_t *len,
1802  uint8_t prefix_code, uint32_t start, uint32_t count,
1803  DNP3PointList *points)
1804 {
1805  DNP3ObjectG21V2 *object = NULL;
1806  uint32_t prefix = 0;
1807  uint32_t point_index = start;
1808 
1809  while (count--) {
1810 
1811  object = SCCalloc(1, sizeof(*object));
1812  if (unlikely(object == NULL)) {
1813  goto error;
1814  }
1815 
1816  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1817  goto error;
1818  }
1819 
1820  {
1821  uint8_t octet;
1822  if (!DNP3ReadUint8(buf, len, &octet)) {
1823  goto error;
1824  }
1825  object->online = (octet >> 0) & 0x1;
1826  object->restart = (octet >> 1) & 0x1;
1827  object->comm_lost = (octet >> 2) & 0x1;
1828  object->remote_forced = (octet >> 3) & 0x1;
1829  object->local_forced = (octet >> 4) & 0x1;
1830  object->rollover = (octet >> 5) & 0x1;
1831  object->discontinuity = (octet >> 6) & 0x1;
1832  object->reserved0 = (octet >> 7) & 0x1;
1833  }
1834  if (!DNP3ReadUint16(buf, len, &object->count)) {
1835  goto error;
1836  }
1837 
1838  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1839  goto error;
1840  }
1841 
1842  object = NULL;
1843  point_index++;
1844  }
1845 
1846  return 1;
1847 error:
1848  if (object != NULL) {
1849  SCFree(object);
1850  }
1851 
1852  return 0;
1853 }
1854 
1855 static int DNP3DecodeObjectG21V3(const uint8_t **buf, uint32_t *len,
1856  uint8_t prefix_code, uint32_t start, uint32_t count,
1857  DNP3PointList *points)
1858 {
1859  DNP3ObjectG21V3 *object = NULL;
1860  uint32_t prefix = 0;
1861  uint32_t point_index = start;
1862 
1863  while (count--) {
1864 
1865  object = SCCalloc(1, sizeof(*object));
1866  if (unlikely(object == NULL)) {
1867  goto error;
1868  }
1869 
1870  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1871  goto error;
1872  }
1873 
1874  {
1875  uint8_t octet;
1876  if (!DNP3ReadUint8(buf, len, &octet)) {
1877  goto error;
1878  }
1879  object->online = (octet >> 0) & 0x1;
1880  object->restart = (octet >> 1) & 0x1;
1881  object->comm_lost = (octet >> 2) & 0x1;
1882  object->remote_forced = (octet >> 3) & 0x1;
1883  object->local_forced = (octet >> 4) & 0x1;
1884  object->rollover = (octet >> 5) & 0x1;
1885  object->reserved0 = (octet >> 6) & 0x1;
1886  object->reserved1 = (octet >> 7) & 0x1;
1887  }
1888  if (!DNP3ReadUint32(buf, len, &object->count)) {
1889  goto error;
1890  }
1891 
1892  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1893  goto error;
1894  }
1895 
1896  object = NULL;
1897  point_index++;
1898  }
1899 
1900  return 1;
1901 error:
1902  if (object != NULL) {
1903  SCFree(object);
1904  }
1905 
1906  return 0;
1907 }
1908 
1909 static int DNP3DecodeObjectG21V4(const uint8_t **buf, uint32_t *len,
1910  uint8_t prefix_code, uint32_t start, uint32_t count,
1911  DNP3PointList *points)
1912 {
1913  DNP3ObjectG21V4 *object = NULL;
1914  uint32_t prefix = 0;
1915  uint32_t point_index = start;
1916 
1917  while (count--) {
1918 
1919  object = SCCalloc(1, sizeof(*object));
1920  if (unlikely(object == NULL)) {
1921  goto error;
1922  }
1923 
1924  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1925  goto error;
1926  }
1927 
1928  {
1929  uint8_t octet;
1930  if (!DNP3ReadUint8(buf, len, &octet)) {
1931  goto error;
1932  }
1933  object->online = (octet >> 0) & 0x1;
1934  object->restart = (octet >> 1) & 0x1;
1935  object->comm_lost = (octet >> 2) & 0x1;
1936  object->remote_forced = (octet >> 3) & 0x1;
1937  object->local_forced = (octet >> 4) & 0x1;
1938  object->rollover = (octet >> 5) & 0x1;
1939  object->reserved0 = (octet >> 6) & 0x1;
1940  object->reserved1 = (octet >> 7) & 0x1;
1941  }
1942  if (!DNP3ReadUint16(buf, len, &object->count)) {
1943  goto error;
1944  }
1945 
1946  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
1947  goto error;
1948  }
1949 
1950  object = NULL;
1951  point_index++;
1952  }
1953 
1954  return 1;
1955 error:
1956  if (object != NULL) {
1957  SCFree(object);
1958  }
1959 
1960  return 0;
1961 }
1962 
1963 static int DNP3DecodeObjectG21V5(const uint8_t **buf, uint32_t *len,
1964  uint8_t prefix_code, uint32_t start, uint32_t count,
1965  DNP3PointList *points)
1966 {
1967  DNP3ObjectG21V5 *object = NULL;
1968  uint32_t prefix = 0;
1969  uint32_t point_index = start;
1970 
1971  while (count--) {
1972 
1973  object = SCCalloc(1, sizeof(*object));
1974  if (unlikely(object == NULL)) {
1975  goto error;
1976  }
1977 
1978  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
1979  goto error;
1980  }
1981 
1982  {
1983  uint8_t octet;
1984  if (!DNP3ReadUint8(buf, len, &octet)) {
1985  goto error;
1986  }
1987  object->online = (octet >> 0) & 0x1;
1988  object->restart = (octet >> 1) & 0x1;
1989  object->comm_lost = (octet >> 2) & 0x1;
1990  object->remote_forced = (octet >> 3) & 0x1;
1991  object->local_forced = (octet >> 4) & 0x1;
1992  object->rollover = (octet >> 5) & 0x1;
1993  object->discontinuity = (octet >> 6) & 0x1;
1994  object->reserved1 = (octet >> 7) & 0x1;
1995  }
1996  if (!DNP3ReadUint32(buf, len, &object->count)) {
1997  goto error;
1998  }
1999  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2000  goto error;
2001  }
2002 
2003  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2004  goto error;
2005  }
2006 
2007  object = NULL;
2008  point_index++;
2009  }
2010 
2011  return 1;
2012 error:
2013  if (object != NULL) {
2014  SCFree(object);
2015  }
2016 
2017  return 0;
2018 }
2019 
2020 static int DNP3DecodeObjectG21V6(const uint8_t **buf, uint32_t *len,
2021  uint8_t prefix_code, uint32_t start, uint32_t count,
2022  DNP3PointList *points)
2023 {
2024  DNP3ObjectG21V6 *object = NULL;
2025  uint32_t prefix = 0;
2026  uint32_t point_index = start;
2027 
2028  while (count--) {
2029 
2030  object = SCCalloc(1, sizeof(*object));
2031  if (unlikely(object == NULL)) {
2032  goto error;
2033  }
2034 
2035  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2036  goto error;
2037  }
2038 
2039  {
2040  uint8_t octet;
2041  if (!DNP3ReadUint8(buf, len, &octet)) {
2042  goto error;
2043  }
2044  object->online = (octet >> 0) & 0x1;
2045  object->restart = (octet >> 1) & 0x1;
2046  object->comm_lost = (octet >> 2) & 0x1;
2047  object->remote_forced = (octet >> 3) & 0x1;
2048  object->local_forced = (octet >> 4) & 0x1;
2049  object->rollover = (octet >> 5) & 0x1;
2050  object->discontinuity = (octet >> 6) & 0x1;
2051  object->reserved1 = (octet >> 7) & 0x1;
2052  }
2053  if (!DNP3ReadUint16(buf, len, &object->count)) {
2054  goto error;
2055  }
2056  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2057  goto error;
2058  }
2059 
2060  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2061  goto error;
2062  }
2063 
2064  object = NULL;
2065  point_index++;
2066  }
2067 
2068  return 1;
2069 error:
2070  if (object != NULL) {
2071  SCFree(object);
2072  }
2073 
2074  return 0;
2075 }
2076 
2077 static int DNP3DecodeObjectG21V7(const uint8_t **buf, uint32_t *len,
2078  uint8_t prefix_code, uint32_t start, uint32_t count,
2079  DNP3PointList *points)
2080 {
2081  DNP3ObjectG21V7 *object = NULL;
2082  uint32_t prefix = 0;
2083  uint32_t point_index = start;
2084 
2085  while (count--) {
2086 
2087  object = SCCalloc(1, sizeof(*object));
2088  if (unlikely(object == NULL)) {
2089  goto error;
2090  }
2091 
2092  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2093  goto error;
2094  }
2095 
2096  {
2097  uint8_t octet;
2098  if (!DNP3ReadUint8(buf, len, &octet)) {
2099  goto error;
2100  }
2101  object->online = (octet >> 0) & 0x1;
2102  object->restart = (octet >> 1) & 0x1;
2103  object->comm_lost = (octet >> 2) & 0x1;
2104  object->remote_forced = (octet >> 3) & 0x1;
2105  object->local_forced = (octet >> 4) & 0x1;
2106  object->rollover = (octet >> 5) & 0x1;
2107  object->reserved0 = (octet >> 6) & 0x1;
2108  object->reserved1 = (octet >> 7) & 0x1;
2109  }
2110  if (!DNP3ReadUint32(buf, len, &object->count)) {
2111  goto error;
2112  }
2113  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2114  goto error;
2115  }
2116 
2117  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2118  goto error;
2119  }
2120 
2121  object = NULL;
2122  point_index++;
2123  }
2124 
2125  return 1;
2126 error:
2127  if (object != NULL) {
2128  SCFree(object);
2129  }
2130 
2131  return 0;
2132 }
2133 
2134 static int DNP3DecodeObjectG21V8(const uint8_t **buf, uint32_t *len,
2135  uint8_t prefix_code, uint32_t start, uint32_t count,
2136  DNP3PointList *points)
2137 {
2138  DNP3ObjectG21V8 *object = NULL;
2139  uint32_t prefix = 0;
2140  uint32_t point_index = start;
2141 
2142  while (count--) {
2143 
2144  object = SCCalloc(1, sizeof(*object));
2145  if (unlikely(object == NULL)) {
2146  goto error;
2147  }
2148 
2149  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2150  goto error;
2151  }
2152 
2153  {
2154  uint8_t octet;
2155  if (!DNP3ReadUint8(buf, len, &octet)) {
2156  goto error;
2157  }
2158  object->online = (octet >> 0) & 0x1;
2159  object->restart = (octet >> 1) & 0x1;
2160  object->comm_lost = (octet >> 2) & 0x1;
2161  object->remote_forced = (octet >> 3) & 0x1;
2162  object->local_forced = (octet >> 4) & 0x1;
2163  object->rollover = (octet >> 5) & 0x1;
2164  object->reserved0 = (octet >> 6) & 0x1;
2165  object->reserved1 = (octet >> 7) & 0x1;
2166  }
2167  if (!DNP3ReadUint16(buf, len, &object->count)) {
2168  goto error;
2169  }
2170  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2171  goto error;
2172  }
2173 
2174  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2175  goto error;
2176  }
2177 
2178  object = NULL;
2179  point_index++;
2180  }
2181 
2182  return 1;
2183 error:
2184  if (object != NULL) {
2185  SCFree(object);
2186  }
2187 
2188  return 0;
2189 }
2190 
2191 static int DNP3DecodeObjectG21V9(const uint8_t **buf, uint32_t *len,
2192  uint8_t prefix_code, uint32_t start, uint32_t count,
2193  DNP3PointList *points)
2194 {
2195  DNP3ObjectG21V9 *object = NULL;
2196  uint32_t prefix = 0;
2197  uint32_t point_index = start;
2198 
2199  while (count--) {
2200 
2201  object = SCCalloc(1, sizeof(*object));
2202  if (unlikely(object == NULL)) {
2203  goto error;
2204  }
2205 
2206  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2207  goto error;
2208  }
2209 
2210  if (!DNP3ReadUint32(buf, len, &object->count)) {
2211  goto error;
2212  }
2213 
2214  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2215  goto error;
2216  }
2217 
2218  object = NULL;
2219  point_index++;
2220  }
2221 
2222  return 1;
2223 error:
2224  if (object != NULL) {
2225  SCFree(object);
2226  }
2227 
2228  return 0;
2229 }
2230 
2231 static int DNP3DecodeObjectG21V10(const uint8_t **buf, uint32_t *len,
2232  uint8_t prefix_code, uint32_t start, uint32_t count,
2233  DNP3PointList *points)
2234 {
2235  DNP3ObjectG21V10 *object = NULL;
2236  uint32_t prefix = 0;
2237  uint32_t point_index = start;
2238 
2239  while (count--) {
2240 
2241  object = SCCalloc(1, sizeof(*object));
2242  if (unlikely(object == NULL)) {
2243  goto error;
2244  }
2245 
2246  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2247  goto error;
2248  }
2249 
2250  if (!DNP3ReadUint16(buf, len, &object->count)) {
2251  goto error;
2252  }
2253 
2254  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2255  goto error;
2256  }
2257 
2258  object = NULL;
2259  point_index++;
2260  }
2261 
2262  return 1;
2263 error:
2264  if (object != NULL) {
2265  SCFree(object);
2266  }
2267 
2268  return 0;
2269 }
2270 
2271 static int DNP3DecodeObjectG21V11(const uint8_t **buf, uint32_t *len,
2272  uint8_t prefix_code, uint32_t start, uint32_t count,
2273  DNP3PointList *points)
2274 {
2275  DNP3ObjectG21V11 *object = NULL;
2276  uint32_t prefix = 0;
2277  uint32_t point_index = start;
2278 
2279  while (count--) {
2280 
2281  object = SCCalloc(1, sizeof(*object));
2282  if (unlikely(object == NULL)) {
2283  goto error;
2284  }
2285 
2286  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2287  goto error;
2288  }
2289 
2290  if (!DNP3ReadUint32(buf, len, &object->count)) {
2291  goto error;
2292  }
2293 
2294  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2295  goto error;
2296  }
2297 
2298  object = NULL;
2299  point_index++;
2300  }
2301 
2302  return 1;
2303 error:
2304  if (object != NULL) {
2305  SCFree(object);
2306  }
2307 
2308  return 0;
2309 }
2310 
2311 static int DNP3DecodeObjectG21V12(const uint8_t **buf, uint32_t *len,
2312  uint8_t prefix_code, uint32_t start, uint32_t count,
2313  DNP3PointList *points)
2314 {
2315  DNP3ObjectG21V12 *object = NULL;
2316  uint32_t prefix = 0;
2317  uint32_t point_index = start;
2318 
2319  while (count--) {
2320 
2321  object = SCCalloc(1, sizeof(*object));
2322  if (unlikely(object == NULL)) {
2323  goto error;
2324  }
2325 
2326  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2327  goto error;
2328  }
2329 
2330  if (!DNP3ReadUint16(buf, len, &object->count)) {
2331  goto error;
2332  }
2333 
2334  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2335  goto error;
2336  }
2337 
2338  object = NULL;
2339  point_index++;
2340  }
2341 
2342  return 1;
2343 error:
2344  if (object != NULL) {
2345  SCFree(object);
2346  }
2347 
2348  return 0;
2349 }
2350 
2351 static int DNP3DecodeObjectG22V1(const uint8_t **buf, uint32_t *len,
2352  uint8_t prefix_code, uint32_t start, uint32_t count,
2353  DNP3PointList *points)
2354 {
2355  DNP3ObjectG22V1 *object = NULL;
2356  uint32_t prefix = 0;
2357  uint32_t point_index = start;
2358 
2359  while (count--) {
2360 
2361  object = SCCalloc(1, sizeof(*object));
2362  if (unlikely(object == NULL)) {
2363  goto error;
2364  }
2365 
2366  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2367  goto error;
2368  }
2369 
2370  {
2371  uint8_t octet;
2372  if (!DNP3ReadUint8(buf, len, &octet)) {
2373  goto error;
2374  }
2375  object->online = (octet >> 0) & 0x1;
2376  object->restart = (octet >> 1) & 0x1;
2377  object->comm_lost = (octet >> 2) & 0x1;
2378  object->remote_forced = (octet >> 3) & 0x1;
2379  object->local_forced = (octet >> 4) & 0x1;
2380  object->rollover = (octet >> 5) & 0x1;
2381  object->discontinuity = (octet >> 6) & 0x1;
2382  object->reserved0 = (octet >> 7) & 0x1;
2383  }
2384  if (!DNP3ReadUint32(buf, len, &object->count)) {
2385  goto error;
2386  }
2387 
2388  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2389  goto error;
2390  }
2391 
2392  object = NULL;
2393  point_index++;
2394  }
2395 
2396  return 1;
2397 error:
2398  if (object != NULL) {
2399  SCFree(object);
2400  }
2401 
2402  return 0;
2403 }
2404 
2405 static int DNP3DecodeObjectG22V2(const uint8_t **buf, uint32_t *len,
2406  uint8_t prefix_code, uint32_t start, uint32_t count,
2407  DNP3PointList *points)
2408 {
2409  DNP3ObjectG22V2 *object = NULL;
2410  uint32_t prefix = 0;
2411  uint32_t point_index = start;
2412 
2413  while (count--) {
2414 
2415  object = SCCalloc(1, sizeof(*object));
2416  if (unlikely(object == NULL)) {
2417  goto error;
2418  }
2419 
2420  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2421  goto error;
2422  }
2423 
2424  {
2425  uint8_t octet;
2426  if (!DNP3ReadUint8(buf, len, &octet)) {
2427  goto error;
2428  }
2429  object->online = (octet >> 0) & 0x1;
2430  object->restart = (octet >> 1) & 0x1;
2431  object->comm_lost = (octet >> 2) & 0x1;
2432  object->remote_forced = (octet >> 3) & 0x1;
2433  object->local_forced = (octet >> 4) & 0x1;
2434  object->rollover = (octet >> 5) & 0x1;
2435  object->discontinuity = (octet >> 6) & 0x1;
2436  object->reserved0 = (octet >> 7) & 0x1;
2437  }
2438  if (!DNP3ReadUint16(buf, len, &object->count)) {
2439  goto error;
2440  }
2441 
2442  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2443  goto error;
2444  }
2445 
2446  object = NULL;
2447  point_index++;
2448  }
2449 
2450  return 1;
2451 error:
2452  if (object != NULL) {
2453  SCFree(object);
2454  }
2455 
2456  return 0;
2457 }
2458 
2459 static int DNP3DecodeObjectG22V3(const uint8_t **buf, uint32_t *len,
2460  uint8_t prefix_code, uint32_t start, uint32_t count,
2461  DNP3PointList *points)
2462 {
2463  DNP3ObjectG22V3 *object = NULL;
2464  uint32_t prefix = 0;
2465  uint32_t point_index = start;
2466 
2467  while (count--) {
2468 
2469  object = SCCalloc(1, sizeof(*object));
2470  if (unlikely(object == NULL)) {
2471  goto error;
2472  }
2473 
2474  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2475  goto error;
2476  }
2477 
2478  {
2479  uint8_t octet;
2480  if (!DNP3ReadUint8(buf, len, &octet)) {
2481  goto error;
2482  }
2483  object->online = (octet >> 0) & 0x1;
2484  object->restart = (octet >> 1) & 0x1;
2485  object->comm_lost = (octet >> 2) & 0x1;
2486  object->remote_forced = (octet >> 3) & 0x1;
2487  object->local_forced = (octet >> 4) & 0x1;
2488  object->rollover = (octet >> 5) & 0x1;
2489  object->reserved0 = (octet >> 6) & 0x1;
2490  object->reserved1 = (octet >> 7) & 0x1;
2491  }
2492  if (!DNP3ReadUint32(buf, len, &object->count)) {
2493  goto error;
2494  }
2495 
2496  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2497  goto error;
2498  }
2499 
2500  object = NULL;
2501  point_index++;
2502  }
2503 
2504  return 1;
2505 error:
2506  if (object != NULL) {
2507  SCFree(object);
2508  }
2509 
2510  return 0;
2511 }
2512 
2513 static int DNP3DecodeObjectG22V4(const uint8_t **buf, uint32_t *len,
2514  uint8_t prefix_code, uint32_t start, uint32_t count,
2515  DNP3PointList *points)
2516 {
2517  DNP3ObjectG22V4 *object = NULL;
2518  uint32_t prefix = 0;
2519  uint32_t point_index = start;
2520 
2521  while (count--) {
2522 
2523  object = SCCalloc(1, sizeof(*object));
2524  if (unlikely(object == NULL)) {
2525  goto error;
2526  }
2527 
2528  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2529  goto error;
2530  }
2531 
2532  {
2533  uint8_t octet;
2534  if (!DNP3ReadUint8(buf, len, &octet)) {
2535  goto error;
2536  }
2537  object->online = (octet >> 0) & 0x1;
2538  object->restart = (octet >> 1) & 0x1;
2539  object->comm_lost = (octet >> 2) & 0x1;
2540  object->remote_forced = (octet >> 3) & 0x1;
2541  object->local_forced = (octet >> 4) & 0x1;
2542  object->rollover = (octet >> 5) & 0x1;
2543  object->reserved0 = (octet >> 6) & 0x1;
2544  object->reserved1 = (octet >> 7) & 0x1;
2545  }
2546  if (!DNP3ReadUint16(buf, len, &object->count)) {
2547  goto error;
2548  }
2549 
2550  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2551  goto error;
2552  }
2553 
2554  object = NULL;
2555  point_index++;
2556  }
2557 
2558  return 1;
2559 error:
2560  if (object != NULL) {
2561  SCFree(object);
2562  }
2563 
2564  return 0;
2565 }
2566 
2567 static int DNP3DecodeObjectG22V5(const uint8_t **buf, uint32_t *len,
2568  uint8_t prefix_code, uint32_t start, uint32_t count,
2569  DNP3PointList *points)
2570 {
2571  DNP3ObjectG22V5 *object = NULL;
2572  uint32_t prefix = 0;
2573  uint32_t point_index = start;
2574 
2575  while (count--) {
2576 
2577  object = SCCalloc(1, sizeof(*object));
2578  if (unlikely(object == NULL)) {
2579  goto error;
2580  }
2581 
2582  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2583  goto error;
2584  }
2585 
2586  {
2587  uint8_t octet;
2588  if (!DNP3ReadUint8(buf, len, &octet)) {
2589  goto error;
2590  }
2591  object->online = (octet >> 0) & 0x1;
2592  object->restart = (octet >> 1) & 0x1;
2593  object->comm_lost = (octet >> 2) & 0x1;
2594  object->remote_forced = (octet >> 3) & 0x1;
2595  object->local_forced = (octet >> 4) & 0x1;
2596  object->rollover = (octet >> 5) & 0x1;
2597  object->reserved0 = (octet >> 6) & 0x1;
2598  object->reserved1 = (octet >> 7) & 0x1;
2599  }
2600  if (!DNP3ReadUint32(buf, len, &object->count)) {
2601  goto error;
2602  }
2603  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2604  goto error;
2605  }
2606 
2607  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2608  goto error;
2609  }
2610 
2611  object = NULL;
2612  point_index++;
2613  }
2614 
2615  return 1;
2616 error:
2617  if (object != NULL) {
2618  SCFree(object);
2619  }
2620 
2621  return 0;
2622 }
2623 
2624 static int DNP3DecodeObjectG22V6(const uint8_t **buf, uint32_t *len,
2625  uint8_t prefix_code, uint32_t start, uint32_t count,
2626  DNP3PointList *points)
2627 {
2628  DNP3ObjectG22V6 *object = NULL;
2629  uint32_t prefix = 0;
2630  uint32_t point_index = start;
2631 
2632  while (count--) {
2633 
2634  object = SCCalloc(1, sizeof(*object));
2635  if (unlikely(object == NULL)) {
2636  goto error;
2637  }
2638 
2639  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2640  goto error;
2641  }
2642 
2643  {
2644  uint8_t octet;
2645  if (!DNP3ReadUint8(buf, len, &octet)) {
2646  goto error;
2647  }
2648  object->online = (octet >> 0) & 0x1;
2649  object->restart = (octet >> 1) & 0x1;
2650  object->comm_lost = (octet >> 2) & 0x1;
2651  object->remote_forced = (octet >> 3) & 0x1;
2652  object->local_forced = (octet >> 4) & 0x1;
2653  object->rollover = (octet >> 5) & 0x1;
2654  object->discontinuity = (octet >> 6) & 0x1;
2655  object->reserved0 = (octet >> 7) & 0x1;
2656  }
2657  if (!DNP3ReadUint16(buf, len, &object->count)) {
2658  goto error;
2659  }
2660  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2661  goto error;
2662  }
2663 
2664  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2665  goto error;
2666  }
2667 
2668  object = NULL;
2669  point_index++;
2670  }
2671 
2672  return 1;
2673 error:
2674  if (object != NULL) {
2675  SCFree(object);
2676  }
2677 
2678  return 0;
2679 }
2680 
2681 static int DNP3DecodeObjectG22V7(const uint8_t **buf, uint32_t *len,
2682  uint8_t prefix_code, uint32_t start, uint32_t count,
2683  DNP3PointList *points)
2684 {
2685  DNP3ObjectG22V7 *object = NULL;
2686  uint32_t prefix = 0;
2687  uint32_t point_index = start;
2688 
2689  while (count--) {
2690 
2691  object = SCCalloc(1, sizeof(*object));
2692  if (unlikely(object == NULL)) {
2693  goto error;
2694  }
2695 
2696  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2697  goto error;
2698  }
2699 
2700  {
2701  uint8_t octet;
2702  if (!DNP3ReadUint8(buf, len, &octet)) {
2703  goto error;
2704  }
2705  object->online = (octet >> 0) & 0x1;
2706  object->restart = (octet >> 1) & 0x1;
2707  object->comm_lost = (octet >> 2) & 0x1;
2708  object->remote_forced = (octet >> 3) & 0x1;
2709  object->local_forced = (octet >> 4) & 0x1;
2710  object->rollover = (octet >> 5) & 0x1;
2711  object->reserved0 = (octet >> 6) & 0x1;
2712  object->reserved1 = (octet >> 7) & 0x1;
2713  }
2714  if (!DNP3ReadUint32(buf, len, &object->count)) {
2715  goto error;
2716  }
2717  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2718  goto error;
2719  }
2720 
2721  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2722  goto error;
2723  }
2724 
2725  object = NULL;
2726  point_index++;
2727  }
2728 
2729  return 1;
2730 error:
2731  if (object != NULL) {
2732  SCFree(object);
2733  }
2734 
2735  return 0;
2736 }
2737 
2738 static int DNP3DecodeObjectG22V8(const uint8_t **buf, uint32_t *len,
2739  uint8_t prefix_code, uint32_t start, uint32_t count,
2740  DNP3PointList *points)
2741 {
2742  DNP3ObjectG22V8 *object = NULL;
2743  uint32_t prefix = 0;
2744  uint32_t point_index = start;
2745 
2746  while (count--) {
2747 
2748  object = SCCalloc(1, sizeof(*object));
2749  if (unlikely(object == NULL)) {
2750  goto error;
2751  }
2752 
2753  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2754  goto error;
2755  }
2756 
2757  {
2758  uint8_t octet;
2759  if (!DNP3ReadUint8(buf, len, &octet)) {
2760  goto error;
2761  }
2762  object->online = (octet >> 0) & 0x1;
2763  object->restart = (octet >> 1) & 0x1;
2764  object->comm_lost = (octet >> 2) & 0x1;
2765  object->remote_forced = (octet >> 3) & 0x1;
2766  object->local_forced = (octet >> 4) & 0x1;
2767  object->rollover = (octet >> 5) & 0x1;
2768  object->reserved0 = (octet >> 6) & 0x1;
2769  object->reserved1 = (octet >> 7) & 0x1;
2770  }
2771  if (!DNP3ReadUint16(buf, len, &object->count)) {
2772  goto error;
2773  }
2774  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
2775  goto error;
2776  }
2777 
2778  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2779  goto error;
2780  }
2781 
2782  object = NULL;
2783  point_index++;
2784  }
2785 
2786  return 1;
2787 error:
2788  if (object != NULL) {
2789  SCFree(object);
2790  }
2791 
2792  return 0;
2793 }
2794 
2795 static int DNP3DecodeObjectG23V1(const uint8_t **buf, uint32_t *len,
2796  uint8_t prefix_code, uint32_t start, uint32_t count,
2797  DNP3PointList *points)
2798 {
2799  DNP3ObjectG23V1 *object = NULL;
2800  uint32_t prefix = 0;
2801  uint32_t point_index = start;
2802 
2803  while (count--) {
2804 
2805  object = SCCalloc(1, sizeof(*object));
2806  if (unlikely(object == NULL)) {
2807  goto error;
2808  }
2809 
2810  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2811  goto error;
2812  }
2813 
2814  {
2815  uint8_t octet;
2816  if (!DNP3ReadUint8(buf, len, &octet)) {
2817  goto error;
2818  }
2819  object->online = (octet >> 0) & 0x1;
2820  object->restart = (octet >> 1) & 0x1;
2821  object->comm_lost = (octet >> 2) & 0x1;
2822  object->remote_forced = (octet >> 3) & 0x1;
2823  object->local_forced = (octet >> 4) & 0x1;
2824  object->rollover = (octet >> 5) & 0x1;
2825  object->discontinuity = (octet >> 6) & 0x1;
2826  object->reserved0 = (octet >> 7) & 0x1;
2827  }
2828  if (!DNP3ReadUint32(buf, len, &object->count)) {
2829  goto error;
2830  }
2831 
2832  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2833  goto error;
2834  }
2835 
2836  object = NULL;
2837  point_index++;
2838  }
2839 
2840  return 1;
2841 error:
2842  if (object != NULL) {
2843  SCFree(object);
2844  }
2845 
2846  return 0;
2847 }
2848 
2849 static int DNP3DecodeObjectG23V2(const uint8_t **buf, uint32_t *len,
2850  uint8_t prefix_code, uint32_t start, uint32_t count,
2851  DNP3PointList *points)
2852 {
2853  DNP3ObjectG23V2 *object = NULL;
2854  uint32_t prefix = 0;
2855  uint32_t point_index = start;
2856 
2857  while (count--) {
2858 
2859  object = SCCalloc(1, sizeof(*object));
2860  if (unlikely(object == NULL)) {
2861  goto error;
2862  }
2863 
2864  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2865  goto error;
2866  }
2867 
2868  {
2869  uint8_t octet;
2870  if (!DNP3ReadUint8(buf, len, &octet)) {
2871  goto error;
2872  }
2873  object->online = (octet >> 0) & 0x1;
2874  object->restart = (octet >> 1) & 0x1;
2875  object->comm_lost = (octet >> 2) & 0x1;
2876  object->remote_forced = (octet >> 3) & 0x1;
2877  object->local_forced = (octet >> 4) & 0x1;
2878  object->rollover = (octet >> 5) & 0x1;
2879  object->reserved0 = (octet >> 6) & 0x1;
2880  object->reserved1 = (octet >> 7) & 0x1;
2881  }
2882  if (!DNP3ReadUint16(buf, len, &object->count)) {
2883  goto error;
2884  }
2885 
2886  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2887  goto error;
2888  }
2889 
2890  object = NULL;
2891  point_index++;
2892  }
2893 
2894  return 1;
2895 error:
2896  if (object != NULL) {
2897  SCFree(object);
2898  }
2899 
2900  return 0;
2901 }
2902 
2903 static int DNP3DecodeObjectG23V3(const uint8_t **buf, uint32_t *len,
2904  uint8_t prefix_code, uint32_t start, uint32_t count,
2905  DNP3PointList *points)
2906 {
2907  DNP3ObjectG23V3 *object = NULL;
2908  uint32_t prefix = 0;
2909  uint32_t point_index = start;
2910 
2911  while (count--) {
2912 
2913  object = SCCalloc(1, sizeof(*object));
2914  if (unlikely(object == NULL)) {
2915  goto error;
2916  }
2917 
2918  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2919  goto error;
2920  }
2921 
2922  {
2923  uint8_t octet;
2924  if (!DNP3ReadUint8(buf, len, &octet)) {
2925  goto error;
2926  }
2927  object->online = (octet >> 0) & 0x1;
2928  object->restart = (octet >> 1) & 0x1;
2929  object->comm_lost = (octet >> 2) & 0x1;
2930  object->remote_forced = (octet >> 3) & 0x1;
2931  object->local_forced = (octet >> 4) & 0x1;
2932  object->rollover = (octet >> 5) & 0x1;
2933  object->reserved0 = (octet >> 6) & 0x1;
2934  object->reserved1 = (octet >> 7) & 0x1;
2935  }
2936  if (!DNP3ReadUint32(buf, len, &object->count)) {
2937  goto error;
2938  }
2939 
2940  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2941  goto error;
2942  }
2943 
2944  object = NULL;
2945  point_index++;
2946  }
2947 
2948  return 1;
2949 error:
2950  if (object != NULL) {
2951  SCFree(object);
2952  }
2953 
2954  return 0;
2955 }
2956 
2957 static int DNP3DecodeObjectG23V4(const uint8_t **buf, uint32_t *len,
2958  uint8_t prefix_code, uint32_t start, uint32_t count,
2959  DNP3PointList *points)
2960 {
2961  DNP3ObjectG23V4 *object = NULL;
2962  uint32_t prefix = 0;
2963  uint32_t point_index = start;
2964 
2965  while (count--) {
2966 
2967  object = SCCalloc(1, sizeof(*object));
2968  if (unlikely(object == NULL)) {
2969  goto error;
2970  }
2971 
2972  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
2973  goto error;
2974  }
2975 
2976  {
2977  uint8_t octet;
2978  if (!DNP3ReadUint8(buf, len, &octet)) {
2979  goto error;
2980  }
2981  object->online = (octet >> 0) & 0x1;
2982  object->restart = (octet >> 1) & 0x1;
2983  object->comm_lost = (octet >> 2) & 0x1;
2984  object->remote_forced = (octet >> 3) & 0x1;
2985  object->local_forced = (octet >> 4) & 0x1;
2986  object->rollover = (octet >> 5) & 0x1;
2987  object->reserved0 = (octet >> 6) & 0x1;
2988  object->reserved1 = (octet >> 7) & 0x1;
2989  }
2990  if (!DNP3ReadUint16(buf, len, &object->count)) {
2991  goto error;
2992  }
2993 
2994  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
2995  goto error;
2996  }
2997 
2998  object = NULL;
2999  point_index++;
3000  }
3001 
3002  return 1;
3003 error:
3004  if (object != NULL) {
3005  SCFree(object);
3006  }
3007 
3008  return 0;
3009 }
3010 
3011 static int DNP3DecodeObjectG23V5(const uint8_t **buf, uint32_t *len,
3012  uint8_t prefix_code, uint32_t start, uint32_t count,
3013  DNP3PointList *points)
3014 {
3015  DNP3ObjectG23V5 *object = NULL;
3016  uint32_t prefix = 0;
3017  uint32_t point_index = start;
3018 
3019  while (count--) {
3020 
3021  object = SCCalloc(1, sizeof(*object));
3022  if (unlikely(object == NULL)) {
3023  goto error;
3024  }
3025 
3026  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3027  goto error;
3028  }
3029 
3030  {
3031  uint8_t octet;
3032  if (!DNP3ReadUint8(buf, len, &octet)) {
3033  goto error;
3034  }
3035  object->online = (octet >> 0) & 0x1;
3036  object->restart = (octet >> 1) & 0x1;
3037  object->comm_lost = (octet >> 2) & 0x1;
3038  object->remote_forced = (octet >> 3) & 0x1;
3039  object->local_forced = (octet >> 4) & 0x1;
3040  object->rollover = (octet >> 5) & 0x1;
3041  object->discontinuity = (octet >> 6) & 0x1;
3042  object->reserved0 = (octet >> 7) & 0x1;
3043  }
3044  if (!DNP3ReadUint32(buf, len, &object->count)) {
3045  goto error;
3046  }
3047  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3048  goto error;
3049  }
3050 
3051  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3052  goto error;
3053  }
3054 
3055  object = NULL;
3056  point_index++;
3057  }
3058 
3059  return 1;
3060 error:
3061  if (object != NULL) {
3062  SCFree(object);
3063  }
3064 
3065  return 0;
3066 }
3067 
3068 static int DNP3DecodeObjectG23V6(const uint8_t **buf, uint32_t *len,
3069  uint8_t prefix_code, uint32_t start, uint32_t count,
3070  DNP3PointList *points)
3071 {
3072  DNP3ObjectG23V6 *object = NULL;
3073  uint32_t prefix = 0;
3074  uint32_t point_index = start;
3075 
3076  while (count--) {
3077 
3078  object = SCCalloc(1, sizeof(*object));
3079  if (unlikely(object == NULL)) {
3080  goto error;
3081  }
3082 
3083  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3084  goto error;
3085  }
3086 
3087  {
3088  uint8_t octet;
3089  if (!DNP3ReadUint8(buf, len, &octet)) {
3090  goto error;
3091  }
3092  object->online = (octet >> 0) & 0x1;
3093  object->restart = (octet >> 1) & 0x1;
3094  object->comm_lost = (octet >> 2) & 0x1;
3095  object->remote_forced = (octet >> 3) & 0x1;
3096  object->local_forced = (octet >> 4) & 0x1;
3097  object->rollover = (octet >> 5) & 0x1;
3098  object->discontinuity = (octet >> 6) & 0x1;
3099  object->reserved0 = (octet >> 7) & 0x1;
3100  }
3101  if (!DNP3ReadUint16(buf, len, &object->count)) {
3102  goto error;
3103  }
3104  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3105  goto error;
3106  }
3107 
3108  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3109  goto error;
3110  }
3111 
3112  object = NULL;
3113  point_index++;
3114  }
3115 
3116  return 1;
3117 error:
3118  if (object != NULL) {
3119  SCFree(object);
3120  }
3121 
3122  return 0;
3123 }
3124 
3125 static int DNP3DecodeObjectG23V7(const uint8_t **buf, uint32_t *len,
3126  uint8_t prefix_code, uint32_t start, uint32_t count,
3127  DNP3PointList *points)
3128 {
3129  DNP3ObjectG23V7 *object = NULL;
3130  uint32_t prefix = 0;
3131  uint32_t point_index = start;
3132 
3133  while (count--) {
3134 
3135  object = SCCalloc(1, sizeof(*object));
3136  if (unlikely(object == NULL)) {
3137  goto error;
3138  }
3139 
3140  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3141  goto error;
3142  }
3143 
3144  {
3145  uint8_t octet;
3146  if (!DNP3ReadUint8(buf, len, &octet)) {
3147  goto error;
3148  }
3149  object->online = (octet >> 0) & 0x1;
3150  object->restart = (octet >> 1) & 0x1;
3151  object->comm_lost = (octet >> 2) & 0x1;
3152  object->remote_forced = (octet >> 3) & 0x1;
3153  object->local_forced = (octet >> 4) & 0x1;
3154  object->rollover = (octet >> 5) & 0x1;
3155  object->reserved0 = (octet >> 6) & 0x1;
3156  object->reserved1 = (octet >> 7) & 0x1;
3157  }
3158  if (!DNP3ReadUint32(buf, len, &object->count)) {
3159  goto error;
3160  }
3161  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3162  goto error;
3163  }
3164 
3165  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3166  goto error;
3167  }
3168 
3169  object = NULL;
3170  point_index++;
3171  }
3172 
3173  return 1;
3174 error:
3175  if (object != NULL) {
3176  SCFree(object);
3177  }
3178 
3179  return 0;
3180 }
3181 
3182 static int DNP3DecodeObjectG23V8(const uint8_t **buf, uint32_t *len,
3183  uint8_t prefix_code, uint32_t start, uint32_t count,
3184  DNP3PointList *points)
3185 {
3186  DNP3ObjectG23V8 *object = NULL;
3187  uint32_t prefix = 0;
3188  uint32_t point_index = start;
3189 
3190  while (count--) {
3191 
3192  object = SCCalloc(1, sizeof(*object));
3193  if (unlikely(object == NULL)) {
3194  goto error;
3195  }
3196 
3197  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3198  goto error;
3199  }
3200 
3201  {
3202  uint8_t octet;
3203  if (!DNP3ReadUint8(buf, len, &octet)) {
3204  goto error;
3205  }
3206  object->online = (octet >> 0) & 0x1;
3207  object->restart = (octet >> 1) & 0x1;
3208  object->comm_lost = (octet >> 2) & 0x1;
3209  object->remote_forced = (octet >> 3) & 0x1;
3210  object->local_forced = (octet >> 4) & 0x1;
3211  object->rollover = (octet >> 5) & 0x1;
3212  object->reserved0 = (octet >> 6) & 0x1;
3213  object->reserved1 = (octet >> 7) & 0x1;
3214  }
3215  if (!DNP3ReadUint16(buf, len, &object->count)) {
3216  goto error;
3217  }
3218  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3219  goto error;
3220  }
3221 
3222  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3223  goto error;
3224  }
3225 
3226  object = NULL;
3227  point_index++;
3228  }
3229 
3230  return 1;
3231 error:
3232  if (object != NULL) {
3233  SCFree(object);
3234  }
3235 
3236  return 0;
3237 }
3238 
3239 static int DNP3DecodeObjectG30V1(const uint8_t **buf, uint32_t *len,
3240  uint8_t prefix_code, uint32_t start, uint32_t count,
3241  DNP3PointList *points)
3242 {
3243  DNP3ObjectG30V1 *object = NULL;
3244  uint32_t prefix = 0;
3245  uint32_t point_index = start;
3246 
3247  while (count--) {
3248 
3249  object = SCCalloc(1, sizeof(*object));
3250  if (unlikely(object == NULL)) {
3251  goto error;
3252  }
3253 
3254  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3255  goto error;
3256  }
3257 
3258  {
3259  uint8_t octet;
3260  if (!DNP3ReadUint8(buf, len, &octet)) {
3261  goto error;
3262  }
3263  object->online = (octet >> 0) & 0x1;
3264  object->restart = (octet >> 1) & 0x1;
3265  object->comm_lost = (octet >> 2) & 0x1;
3266  object->remote_forced = (octet >> 3) & 0x1;
3267  object->local_forced = (octet >> 4) & 0x1;
3268  object->over_range = (octet >> 5) & 0x1;
3269  object->reference_err = (octet >> 6) & 0x1;
3270  object->reserved0 = (octet >> 7) & 0x1;
3271  }
3272  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3273  goto error;
3274  }
3275 
3276  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3277  goto error;
3278  }
3279 
3280  object = NULL;
3281  point_index++;
3282  }
3283 
3284  return 1;
3285 error:
3286  if (object != NULL) {
3287  SCFree(object);
3288  }
3289 
3290  return 0;
3291 }
3292 
3293 static int DNP3DecodeObjectG30V2(const uint8_t **buf, uint32_t *len,
3294  uint8_t prefix_code, uint32_t start, uint32_t count,
3295  DNP3PointList *points)
3296 {
3297  DNP3ObjectG30V2 *object = NULL;
3298  uint32_t prefix = 0;
3299  uint32_t point_index = start;
3300 
3301  while (count--) {
3302 
3303  object = SCCalloc(1, sizeof(*object));
3304  if (unlikely(object == NULL)) {
3305  goto error;
3306  }
3307 
3308  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3309  goto error;
3310  }
3311 
3312  {
3313  uint8_t octet;
3314  if (!DNP3ReadUint8(buf, len, &octet)) {
3315  goto error;
3316  }
3317  object->online = (octet >> 0) & 0x1;
3318  object->restart = (octet >> 1) & 0x1;
3319  object->comm_lost = (octet >> 2) & 0x1;
3320  object->remote_forced = (octet >> 3) & 0x1;
3321  object->local_forced = (octet >> 4) & 0x1;
3322  object->over_range = (octet >> 5) & 0x1;
3323  object->reference_err = (octet >> 6) & 0x1;
3324  object->reserved0 = (octet >> 7) & 0x1;
3325  }
3326  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3327  goto error;
3328  }
3329 
3330  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3331  goto error;
3332  }
3333 
3334  object = NULL;
3335  point_index++;
3336  }
3337 
3338  return 1;
3339 error:
3340  if (object != NULL) {
3341  SCFree(object);
3342  }
3343 
3344  return 0;
3345 }
3346 
3347 static int DNP3DecodeObjectG30V3(const uint8_t **buf, uint32_t *len,
3348  uint8_t prefix_code, uint32_t start, uint32_t count,
3349  DNP3PointList *points)
3350 {
3351  DNP3ObjectG30V3 *object = NULL;
3352  uint32_t prefix = 0;
3353  uint32_t point_index = start;
3354 
3355  while (count--) {
3356 
3357  object = SCCalloc(1, sizeof(*object));
3358  if (unlikely(object == NULL)) {
3359  goto error;
3360  }
3361 
3362  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3363  goto error;
3364  }
3365 
3366  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3367  goto error;
3368  }
3369 
3370  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3371  goto error;
3372  }
3373 
3374  object = NULL;
3375  point_index++;
3376  }
3377 
3378  return 1;
3379 error:
3380  if (object != NULL) {
3381  SCFree(object);
3382  }
3383 
3384  return 0;
3385 }
3386 
3387 static int DNP3DecodeObjectG30V4(const uint8_t **buf, uint32_t *len,
3388  uint8_t prefix_code, uint32_t start, uint32_t count,
3389  DNP3PointList *points)
3390 {
3391  DNP3ObjectG30V4 *object = NULL;
3392  uint32_t prefix = 0;
3393  uint32_t point_index = start;
3394 
3395  while (count--) {
3396 
3397  object = SCCalloc(1, sizeof(*object));
3398  if (unlikely(object == NULL)) {
3399  goto error;
3400  }
3401 
3402  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3403  goto error;
3404  }
3405 
3406  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3407  goto error;
3408  }
3409 
3410  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3411  goto error;
3412  }
3413 
3414  object = NULL;
3415  point_index++;
3416  }
3417 
3418  return 1;
3419 error:
3420  if (object != NULL) {
3421  SCFree(object);
3422  }
3423 
3424  return 0;
3425 }
3426 
3427 static int DNP3DecodeObjectG30V5(const uint8_t **buf, uint32_t *len,
3428  uint8_t prefix_code, uint32_t start, uint32_t count,
3429  DNP3PointList *points)
3430 {
3431  DNP3ObjectG30V5 *object = NULL;
3432  uint32_t prefix = 0;
3433  uint32_t point_index = start;
3434 
3435  while (count--) {
3436 
3437  object = SCCalloc(1, sizeof(*object));
3438  if (unlikely(object == NULL)) {
3439  goto error;
3440  }
3441 
3442  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3443  goto error;
3444  }
3445 
3446  {
3447  uint8_t octet;
3448  if (!DNP3ReadUint8(buf, len, &octet)) {
3449  goto error;
3450  }
3451  object->online = (octet >> 0) & 0x1;
3452  object->restart = (octet >> 1) & 0x1;
3453  object->comm_lost = (octet >> 2) & 0x1;
3454  object->remote_forced = (octet >> 3) & 0x1;
3455  object->local_forced = (octet >> 4) & 0x1;
3456  object->over_range = (octet >> 5) & 0x1;
3457  object->reference_err = (octet >> 6) & 0x1;
3458  object->reserved0 = (octet >> 7) & 0x1;
3459  }
3460  if (!DNP3ReadFloat32(buf, len, &object->value)) {
3461  goto error;
3462  }
3463 
3464  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3465  goto error;
3466  }
3467 
3468  object = NULL;
3469  point_index++;
3470  }
3471 
3472  return 1;
3473 error:
3474  if (object != NULL) {
3475  SCFree(object);
3476  }
3477 
3478  return 0;
3479 }
3480 
3481 static int DNP3DecodeObjectG30V6(const uint8_t **buf, uint32_t *len,
3482  uint8_t prefix_code, uint32_t start, uint32_t count,
3483  DNP3PointList *points)
3484 {
3485  DNP3ObjectG30V6 *object = NULL;
3486  uint32_t prefix = 0;
3487  uint32_t point_index = start;
3488 
3489  while (count--) {
3490 
3491  object = SCCalloc(1, sizeof(*object));
3492  if (unlikely(object == NULL)) {
3493  goto error;
3494  }
3495 
3496  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3497  goto error;
3498  }
3499 
3500  {
3501  uint8_t octet;
3502  if (!DNP3ReadUint8(buf, len, &octet)) {
3503  goto error;
3504  }
3505  object->online = (octet >> 0) & 0x1;
3506  object->restart = (octet >> 1) & 0x1;
3507  object->comm_lost = (octet >> 2) & 0x1;
3508  object->remote_forced = (octet >> 3) & 0x1;
3509  object->local_forced = (octet >> 4) & 0x1;
3510  object->over_range = (octet >> 5) & 0x1;
3511  object->reference_err = (octet >> 6) & 0x1;
3512  object->reserved0 = (octet >> 7) & 0x1;
3513  }
3514  if (!DNP3ReadFloat64(buf, len, &object->value)) {
3515  goto error;
3516  }
3517 
3518  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3519  goto error;
3520  }
3521 
3522  object = NULL;
3523  point_index++;
3524  }
3525 
3526  return 1;
3527 error:
3528  if (object != NULL) {
3529  SCFree(object);
3530  }
3531 
3532  return 0;
3533 }
3534 
3535 static int DNP3DecodeObjectG31V1(const uint8_t **buf, uint32_t *len,
3536  uint8_t prefix_code, uint32_t start, uint32_t count,
3537  DNP3PointList *points)
3538 {
3539  DNP3ObjectG31V1 *object = NULL;
3540  uint32_t prefix = 0;
3541  uint32_t point_index = start;
3542 
3543  while (count--) {
3544 
3545  object = SCCalloc(1, sizeof(*object));
3546  if (unlikely(object == NULL)) {
3547  goto error;
3548  }
3549 
3550  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3551  goto error;
3552  }
3553 
3554  {
3555  uint8_t octet;
3556  if (!DNP3ReadUint8(buf, len, &octet)) {
3557  goto error;
3558  }
3559  object->online = (octet >> 0) & 0x1;
3560  object->restart = (octet >> 1) & 0x1;
3561  object->comm_lost = (octet >> 2) & 0x1;
3562  object->remote_forced = (octet >> 3) & 0x1;
3563  object->local_forced = (octet >> 4) & 0x1;
3564  object->over_range = (octet >> 5) & 0x1;
3565  object->reference_err = (octet >> 6) & 0x1;
3566  object->reserved0 = (octet >> 7) & 0x1;
3567  }
3568  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3569  goto error;
3570  }
3571 
3572  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3573  goto error;
3574  }
3575 
3576  object = NULL;
3577  point_index++;
3578  }
3579 
3580  return 1;
3581 error:
3582  if (object != NULL) {
3583  SCFree(object);
3584  }
3585 
3586  return 0;
3587 }
3588 
3589 static int DNP3DecodeObjectG31V2(const uint8_t **buf, uint32_t *len,
3590  uint8_t prefix_code, uint32_t start, uint32_t count,
3591  DNP3PointList *points)
3592 {
3593  DNP3ObjectG31V2 *object = NULL;
3594  uint32_t prefix = 0;
3595  uint32_t point_index = start;
3596 
3597  while (count--) {
3598 
3599  object = SCCalloc(1, sizeof(*object));
3600  if (unlikely(object == NULL)) {
3601  goto error;
3602  }
3603 
3604  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3605  goto error;
3606  }
3607 
3608  {
3609  uint8_t octet;
3610  if (!DNP3ReadUint8(buf, len, &octet)) {
3611  goto error;
3612  }
3613  object->online = (octet >> 0) & 0x1;
3614  object->restart = (octet >> 1) & 0x1;
3615  object->comm_lost = (octet >> 2) & 0x1;
3616  object->remote_forced = (octet >> 3) & 0x1;
3617  object->local_forced = (octet >> 4) & 0x1;
3618  object->over_range = (octet >> 5) & 0x1;
3619  object->reference_err = (octet >> 6) & 0x1;
3620  object->reserved0 = (octet >> 7) & 0x1;
3621  }
3622  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3623  goto error;
3624  }
3625 
3626  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3627  goto error;
3628  }
3629 
3630  object = NULL;
3631  point_index++;
3632  }
3633 
3634  return 1;
3635 error:
3636  if (object != NULL) {
3637  SCFree(object);
3638  }
3639 
3640  return 0;
3641 }
3642 
3643 static int DNP3DecodeObjectG31V3(const uint8_t **buf, uint32_t *len,
3644  uint8_t prefix_code, uint32_t start, uint32_t count,
3645  DNP3PointList *points)
3646 {
3647  DNP3ObjectG31V3 *object = NULL;
3648  uint32_t prefix = 0;
3649  uint32_t point_index = start;
3650 
3651  while (count--) {
3652 
3653  object = SCCalloc(1, sizeof(*object));
3654  if (unlikely(object == NULL)) {
3655  goto error;
3656  }
3657 
3658  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3659  goto error;
3660  }
3661 
3662  {
3663  uint8_t octet;
3664  if (!DNP3ReadUint8(buf, len, &octet)) {
3665  goto error;
3666  }
3667  object->online = (octet >> 0) & 0x1;
3668  object->restart = (octet >> 1) & 0x1;
3669  object->comm_lost = (octet >> 2) & 0x1;
3670  object->remote_forced = (octet >> 3) & 0x1;
3671  object->local_forced = (octet >> 4) & 0x1;
3672  object->over_range = (octet >> 5) & 0x1;
3673  object->reference_err = (octet >> 6) & 0x1;
3674  object->reserved0 = (octet >> 7) & 0x1;
3675  }
3676  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3677  goto error;
3678  }
3679  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3680  goto error;
3681  }
3682 
3683  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3684  goto error;
3685  }
3686 
3687  object = NULL;
3688  point_index++;
3689  }
3690 
3691  return 1;
3692 error:
3693  if (object != NULL) {
3694  SCFree(object);
3695  }
3696 
3697  return 0;
3698 }
3699 
3700 static int DNP3DecodeObjectG31V4(const uint8_t **buf, uint32_t *len,
3701  uint8_t prefix_code, uint32_t start, uint32_t count,
3702  DNP3PointList *points)
3703 {
3704  DNP3ObjectG31V4 *object = NULL;
3705  uint32_t prefix = 0;
3706  uint32_t point_index = start;
3707 
3708  while (count--) {
3709 
3710  object = SCCalloc(1, sizeof(*object));
3711  if (unlikely(object == NULL)) {
3712  goto error;
3713  }
3714 
3715  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3716  goto error;
3717  }
3718 
3719  {
3720  uint8_t octet;
3721  if (!DNP3ReadUint8(buf, len, &octet)) {
3722  goto error;
3723  }
3724  object->online = (octet >> 0) & 0x1;
3725  object->restart = (octet >> 1) & 0x1;
3726  object->comm_lost = (octet >> 2) & 0x1;
3727  object->remote_forced = (octet >> 3) & 0x1;
3728  object->local_forced = (octet >> 4) & 0x1;
3729  object->over_range = (octet >> 5) & 0x1;
3730  object->reference_err = (octet >> 6) & 0x1;
3731  object->reserved0 = (octet >> 7) & 0x1;
3732  }
3733  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3734  goto error;
3735  }
3736  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
3737  goto error;
3738  }
3739 
3740  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3741  goto error;
3742  }
3743 
3744  object = NULL;
3745  point_index++;
3746  }
3747 
3748  return 1;
3749 error:
3750  if (object != NULL) {
3751  SCFree(object);
3752  }
3753 
3754  return 0;
3755 }
3756 
3757 static int DNP3DecodeObjectG31V5(const uint8_t **buf, uint32_t *len,
3758  uint8_t prefix_code, uint32_t start, uint32_t count,
3759  DNP3PointList *points)
3760 {
3761  DNP3ObjectG31V5 *object = NULL;
3762  uint32_t prefix = 0;
3763  uint32_t point_index = start;
3764 
3765  while (count--) {
3766 
3767  object = SCCalloc(1, sizeof(*object));
3768  if (unlikely(object == NULL)) {
3769  goto error;
3770  }
3771 
3772  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3773  goto error;
3774  }
3775 
3776  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3777  goto error;
3778  }
3779 
3780  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3781  goto error;
3782  }
3783 
3784  object = NULL;
3785  point_index++;
3786  }
3787 
3788  return 1;
3789 error:
3790  if (object != NULL) {
3791  SCFree(object);
3792  }
3793 
3794  return 0;
3795 }
3796 
3797 static int DNP3DecodeObjectG31V6(const uint8_t **buf, uint32_t *len,
3798  uint8_t prefix_code, uint32_t start, uint32_t count,
3799  DNP3PointList *points)
3800 {
3801  DNP3ObjectG31V6 *object = NULL;
3802  uint32_t prefix = 0;
3803  uint32_t point_index = start;
3804 
3805  while (count--) {
3806 
3807  object = SCCalloc(1, sizeof(*object));
3808  if (unlikely(object == NULL)) {
3809  goto error;
3810  }
3811 
3812  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3813  goto error;
3814  }
3815 
3816  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
3817  goto error;
3818  }
3819 
3820  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3821  goto error;
3822  }
3823 
3824  object = NULL;
3825  point_index++;
3826  }
3827 
3828  return 1;
3829 error:
3830  if (object != NULL) {
3831  SCFree(object);
3832  }
3833 
3834  return 0;
3835 }
3836 
3837 static int DNP3DecodeObjectG31V7(const uint8_t **buf, uint32_t *len,
3838  uint8_t prefix_code, uint32_t start, uint32_t count,
3839  DNP3PointList *points)
3840 {
3841  DNP3ObjectG31V7 *object = NULL;
3842  uint32_t prefix = 0;
3843  uint32_t point_index = start;
3844 
3845  while (count--) {
3846 
3847  object = SCCalloc(1, sizeof(*object));
3848  if (unlikely(object == NULL)) {
3849  goto error;
3850  }
3851 
3852  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3853  goto error;
3854  }
3855 
3856  {
3857  uint8_t octet;
3858  if (!DNP3ReadUint8(buf, len, &octet)) {
3859  goto error;
3860  }
3861  object->online = (octet >> 0) & 0x1;
3862  object->restart = (octet >> 1) & 0x1;
3863  object->comm_lost = (octet >> 2) & 0x1;
3864  object->remote_forced = (octet >> 3) & 0x1;
3865  object->local_forced = (octet >> 4) & 0x1;
3866  object->over_range = (octet >> 5) & 0x1;
3867  object->reference_err = (octet >> 6) & 0x1;
3868  object->reserved0 = (octet >> 7) & 0x1;
3869  }
3870  if (!DNP3ReadFloat32(buf, len, &object->value)) {
3871  goto error;
3872  }
3873 
3874  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3875  goto error;
3876  }
3877 
3878  object = NULL;
3879  point_index++;
3880  }
3881 
3882  return 1;
3883 error:
3884  if (object != NULL) {
3885  SCFree(object);
3886  }
3887 
3888  return 0;
3889 }
3890 
3891 static int DNP3DecodeObjectG31V8(const uint8_t **buf, uint32_t *len,
3892  uint8_t prefix_code, uint32_t start, uint32_t count,
3893  DNP3PointList *points)
3894 {
3895  DNP3ObjectG31V8 *object = NULL;
3896  uint32_t prefix = 0;
3897  uint32_t point_index = start;
3898 
3899  while (count--) {
3900 
3901  object = SCCalloc(1, sizeof(*object));
3902  if (unlikely(object == NULL)) {
3903  goto error;
3904  }
3905 
3906  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3907  goto error;
3908  }
3909 
3910  {
3911  uint8_t octet;
3912  if (!DNP3ReadUint8(buf, len, &octet)) {
3913  goto error;
3914  }
3915  object->online = (octet >> 0) & 0x1;
3916  object->restart = (octet >> 1) & 0x1;
3917  object->comm_lost = (octet >> 2) & 0x1;
3918  object->remote_forced = (octet >> 3) & 0x1;
3919  object->local_forced = (octet >> 4) & 0x1;
3920  object->over_range = (octet >> 5) & 0x1;
3921  object->reference_err = (octet >> 6) & 0x1;
3922  object->reserved0 = (octet >> 7) & 0x1;
3923  }
3924  if (!DNP3ReadFloat64(buf, len, &object->value)) {
3925  goto error;
3926  }
3927 
3928  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3929  goto error;
3930  }
3931 
3932  object = NULL;
3933  point_index++;
3934  }
3935 
3936  return 1;
3937 error:
3938  if (object != NULL) {
3939  SCFree(object);
3940  }
3941 
3942  return 0;
3943 }
3944 
3945 static int DNP3DecodeObjectG32V1(const uint8_t **buf, uint32_t *len,
3946  uint8_t prefix_code, uint32_t start, uint32_t count,
3947  DNP3PointList *points)
3948 {
3949  DNP3ObjectG32V1 *object = NULL;
3950  uint32_t prefix = 0;
3951  uint32_t point_index = start;
3952 
3953  while (count--) {
3954 
3955  object = SCCalloc(1, sizeof(*object));
3956  if (unlikely(object == NULL)) {
3957  goto error;
3958  }
3959 
3960  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
3961  goto error;
3962  }
3963 
3964  {
3965  uint8_t octet;
3966  if (!DNP3ReadUint8(buf, len, &octet)) {
3967  goto error;
3968  }
3969  object->online = (octet >> 0) & 0x1;
3970  object->restart = (octet >> 1) & 0x1;
3971  object->comm_lost = (octet >> 2) & 0x1;
3972  object->remote_forced = (octet >> 3) & 0x1;
3973  object->local_forced = (octet >> 4) & 0x1;
3974  object->over_range = (octet >> 5) & 0x1;
3975  object->reference_err = (octet >> 6) & 0x1;
3976  object->reserved0 = (octet >> 7) & 0x1;
3977  }
3978  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
3979  goto error;
3980  }
3981 
3982  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
3983  goto error;
3984  }
3985 
3986  object = NULL;
3987  point_index++;
3988  }
3989 
3990  return 1;
3991 error:
3992  if (object != NULL) {
3993  SCFree(object);
3994  }
3995 
3996  return 0;
3997 }
3998 
3999 static int DNP3DecodeObjectG32V2(const uint8_t **buf, uint32_t *len,
4000  uint8_t prefix_code, uint32_t start, uint32_t count,
4001  DNP3PointList *points)
4002 {
4003  DNP3ObjectG32V2 *object = NULL;
4004  uint32_t prefix = 0;
4005  uint32_t point_index = start;
4006 
4007  while (count--) {
4008 
4009  object = SCCalloc(1, sizeof(*object));
4010  if (unlikely(object == NULL)) {
4011  goto error;
4012  }
4013 
4014  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4015  goto error;
4016  }
4017 
4018  {
4019  uint8_t octet;
4020  if (!DNP3ReadUint8(buf, len, &octet)) {
4021  goto error;
4022  }
4023  object->online = (octet >> 0) & 0x1;
4024  object->restart = (octet >> 1) & 0x1;
4025  object->comm_lost = (octet >> 2) & 0x1;
4026  object->remote_forced = (octet >> 3) & 0x1;
4027  object->local_forced = (octet >> 4) & 0x1;
4028  object->over_range = (octet >> 5) & 0x1;
4029  object->reference_err = (octet >> 6) & 0x1;
4030  object->reserved0 = (octet >> 7) & 0x1;
4031  }
4032  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4033  goto error;
4034  }
4035 
4036  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4037  goto error;
4038  }
4039 
4040  object = NULL;
4041  point_index++;
4042  }
4043 
4044  return 1;
4045 error:
4046  if (object != NULL) {
4047  SCFree(object);
4048  }
4049 
4050  return 0;
4051 }
4052 
4053 static int DNP3DecodeObjectG32V3(const uint8_t **buf, uint32_t *len,
4054  uint8_t prefix_code, uint32_t start, uint32_t count,
4055  DNP3PointList *points)
4056 {
4057  DNP3ObjectG32V3 *object = NULL;
4058  uint32_t prefix = 0;
4059  uint32_t point_index = start;
4060 
4061  while (count--) {
4062 
4063  object = SCCalloc(1, sizeof(*object));
4064  if (unlikely(object == NULL)) {
4065  goto error;
4066  }
4067 
4068  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4069  goto error;
4070  }
4071 
4072  {
4073  uint8_t octet;
4074  if (!DNP3ReadUint8(buf, len, &octet)) {
4075  goto error;
4076  }
4077  object->online = (octet >> 0) & 0x1;
4078  object->restart = (octet >> 1) & 0x1;
4079  object->comm_lost = (octet >> 2) & 0x1;
4080  object->remote_forced = (octet >> 3) & 0x1;
4081  object->local_forced = (octet >> 4) & 0x1;
4082  object->over_range = (octet >> 5) & 0x1;
4083  object->reference_err = (octet >> 6) & 0x1;
4084  object->reserved0 = (octet >> 7) & 0x1;
4085  }
4086  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4087  goto error;
4088  }
4089  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4090  goto error;
4091  }
4092 
4093  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4094  goto error;
4095  }
4096 
4097  object = NULL;
4098  point_index++;
4099  }
4100 
4101  return 1;
4102 error:
4103  if (object != NULL) {
4104  SCFree(object);
4105  }
4106 
4107  return 0;
4108 }
4109 
4110 static int DNP3DecodeObjectG32V4(const uint8_t **buf, uint32_t *len,
4111  uint8_t prefix_code, uint32_t start, uint32_t count,
4112  DNP3PointList *points)
4113 {
4114  DNP3ObjectG32V4 *object = NULL;
4115  uint32_t prefix = 0;
4116  uint32_t point_index = start;
4117 
4118  while (count--) {
4119 
4120  object = SCCalloc(1, sizeof(*object));
4121  if (unlikely(object == NULL)) {
4122  goto error;
4123  }
4124 
4125  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4126  goto error;
4127  }
4128 
4129  {
4130  uint8_t octet;
4131  if (!DNP3ReadUint8(buf, len, &octet)) {
4132  goto error;
4133  }
4134  object->online = (octet >> 0) & 0x1;
4135  object->restart = (octet >> 1) & 0x1;
4136  object->comm_lost = (octet >> 2) & 0x1;
4137  object->remote_forced = (octet >> 3) & 0x1;
4138  object->local_forced = (octet >> 4) & 0x1;
4139  object->over_range = (octet >> 5) & 0x1;
4140  object->reference_err = (octet >> 6) & 0x1;
4141  object->reserved0 = (octet >> 7) & 0x1;
4142  }
4143  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4144  goto error;
4145  }
4146  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4147  goto error;
4148  }
4149 
4150  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4151  goto error;
4152  }
4153 
4154  object = NULL;
4155  point_index++;
4156  }
4157 
4158  return 1;
4159 error:
4160  if (object != NULL) {
4161  SCFree(object);
4162  }
4163 
4164  return 0;
4165 }
4166 
4167 static int DNP3DecodeObjectG32V5(const uint8_t **buf, uint32_t *len,
4168  uint8_t prefix_code, uint32_t start, uint32_t count,
4169  DNP3PointList *points)
4170 {
4171  DNP3ObjectG32V5 *object = NULL;
4172  uint32_t prefix = 0;
4173  uint32_t point_index = start;
4174 
4175  while (count--) {
4176 
4177  object = SCCalloc(1, sizeof(*object));
4178  if (unlikely(object == NULL)) {
4179  goto error;
4180  }
4181 
4182  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4183  goto error;
4184  }
4185 
4186  {
4187  uint8_t octet;
4188  if (!DNP3ReadUint8(buf, len, &octet)) {
4189  goto error;
4190  }
4191  object->online = (octet >> 0) & 0x1;
4192  object->restart = (octet >> 1) & 0x1;
4193  object->comm_lost = (octet >> 2) & 0x1;
4194  object->remote_forced = (octet >> 3) & 0x1;
4195  object->local_forced = (octet >> 4) & 0x1;
4196  object->over_range = (octet >> 5) & 0x1;
4197  object->reference_err = (octet >> 6) & 0x1;
4198  object->reserved0 = (octet >> 7) & 0x1;
4199  }
4200  if (!DNP3ReadFloat32(buf, len, &object->value)) {
4201  goto error;
4202  }
4203 
4204  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4205  goto error;
4206  }
4207 
4208  object = NULL;
4209  point_index++;
4210  }
4211 
4212  return 1;
4213 error:
4214  if (object != NULL) {
4215  SCFree(object);
4216  }
4217 
4218  return 0;
4219 }
4220 
4221 static int DNP3DecodeObjectG32V6(const uint8_t **buf, uint32_t *len,
4222  uint8_t prefix_code, uint32_t start, uint32_t count,
4223  DNP3PointList *points)
4224 {
4225  DNP3ObjectG32V6 *object = NULL;
4226  uint32_t prefix = 0;
4227  uint32_t point_index = start;
4228 
4229  while (count--) {
4230 
4231  object = SCCalloc(1, sizeof(*object));
4232  if (unlikely(object == NULL)) {
4233  goto error;
4234  }
4235 
4236  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4237  goto error;
4238  }
4239 
4240  {
4241  uint8_t octet;
4242  if (!DNP3ReadUint8(buf, len, &octet)) {
4243  goto error;
4244  }
4245  object->online = (octet >> 0) & 0x1;
4246  object->restart = (octet >> 1) & 0x1;
4247  object->comm_lost = (octet >> 2) & 0x1;
4248  object->remote_forced = (octet >> 3) & 0x1;
4249  object->local_forced = (octet >> 4) & 0x1;
4250  object->over_range = (octet >> 5) & 0x1;
4251  object->reference_err = (octet >> 6) & 0x1;
4252  object->reserved0 = (octet >> 7) & 0x1;
4253  }
4254  if (!DNP3ReadFloat64(buf, len, &object->value)) {
4255  goto error;
4256  }
4257 
4258  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4259  goto error;
4260  }
4261 
4262  object = NULL;
4263  point_index++;
4264  }
4265 
4266  return 1;
4267 error:
4268  if (object != NULL) {
4269  SCFree(object);
4270  }
4271 
4272  return 0;
4273 }
4274 
4275 static int DNP3DecodeObjectG32V7(const uint8_t **buf, uint32_t *len,
4276  uint8_t prefix_code, uint32_t start, uint32_t count,
4277  DNP3PointList *points)
4278 {
4279  DNP3ObjectG32V7 *object = NULL;
4280  uint32_t prefix = 0;
4281  uint32_t point_index = start;
4282 
4283  while (count--) {
4284 
4285  object = SCCalloc(1, sizeof(*object));
4286  if (unlikely(object == NULL)) {
4287  goto error;
4288  }
4289 
4290  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4291  goto error;
4292  }
4293 
4294  {
4295  uint8_t octet;
4296  if (!DNP3ReadUint8(buf, len, &octet)) {
4297  goto error;
4298  }
4299  object->online = (octet >> 0) & 0x1;
4300  object->restart = (octet >> 1) & 0x1;
4301  object->comm_lost = (octet >> 2) & 0x1;
4302  object->remote_forced = (octet >> 3) & 0x1;
4303  object->local_forced = (octet >> 4) & 0x1;
4304  object->over_range = (octet >> 5) & 0x1;
4305  object->reference_err = (octet >> 6) & 0x1;
4306  object->reserved0 = (octet >> 7) & 0x1;
4307  }
4308  if (!DNP3ReadFloat32(buf, len, &object->value)) {
4309  goto error;
4310  }
4311  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4312  goto error;
4313  }
4314 
4315  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4316  goto error;
4317  }
4318 
4319  object = NULL;
4320  point_index++;
4321  }
4322 
4323  return 1;
4324 error:
4325  if (object != NULL) {
4326  SCFree(object);
4327  }
4328 
4329  return 0;
4330 }
4331 
4332 static int DNP3DecodeObjectG32V8(const uint8_t **buf, uint32_t *len,
4333  uint8_t prefix_code, uint32_t start, uint32_t count,
4334  DNP3PointList *points)
4335 {
4336  DNP3ObjectG32V8 *object = NULL;
4337  uint32_t prefix = 0;
4338  uint32_t point_index = start;
4339 
4340  while (count--) {
4341 
4342  object = SCCalloc(1, sizeof(*object));
4343  if (unlikely(object == NULL)) {
4344  goto error;
4345  }
4346 
4347  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4348  goto error;
4349  }
4350 
4351  {
4352  uint8_t octet;
4353  if (!DNP3ReadUint8(buf, len, &octet)) {
4354  goto error;
4355  }
4356  object->online = (octet >> 0) & 0x1;
4357  object->restart = (octet >> 1) & 0x1;
4358  object->comm_lost = (octet >> 2) & 0x1;
4359  object->remote_forced = (octet >> 3) & 0x1;
4360  object->local_forced = (octet >> 4) & 0x1;
4361  object->over_range = (octet >> 5) & 0x1;
4362  object->reference_err = (octet >> 6) & 0x1;
4363  object->reserved0 = (octet >> 7) & 0x1;
4364  }
4365  if (!DNP3ReadFloat64(buf, len, &object->value)) {
4366  goto error;
4367  }
4368  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4369  goto error;
4370  }
4371 
4372  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4373  goto error;
4374  }
4375 
4376  object = NULL;
4377  point_index++;
4378  }
4379 
4380  return 1;
4381 error:
4382  if (object != NULL) {
4383  SCFree(object);
4384  }
4385 
4386  return 0;
4387 }
4388 
4389 static int DNP3DecodeObjectG33V1(const uint8_t **buf, uint32_t *len,
4390  uint8_t prefix_code, uint32_t start, uint32_t count,
4391  DNP3PointList *points)
4392 {
4393  DNP3ObjectG33V1 *object = NULL;
4394  uint32_t prefix = 0;
4395  uint32_t point_index = start;
4396 
4397  while (count--) {
4398 
4399  object = SCCalloc(1, sizeof(*object));
4400  if (unlikely(object == NULL)) {
4401  goto error;
4402  }
4403 
4404  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4405  goto error;
4406  }
4407 
4408  {
4409  uint8_t octet;
4410  if (!DNP3ReadUint8(buf, len, &octet)) {
4411  goto error;
4412  }
4413  object->online = (octet >> 0) & 0x1;
4414  object->restart = (octet >> 1) & 0x1;
4415  object->comm_lost = (octet >> 2) & 0x1;
4416  object->remote_forced = (octet >> 3) & 0x1;
4417  object->local_forced = (octet >> 4) & 0x1;
4418  object->over_range = (octet >> 5) & 0x1;
4419  object->reference_err = (octet >> 6) & 0x1;
4420  object->reserved0 = (octet >> 7) & 0x1;
4421  }
4422  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4423  goto error;
4424  }
4425 
4426  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4427  goto error;
4428  }
4429 
4430  object = NULL;
4431  point_index++;
4432  }
4433 
4434  return 1;
4435 error:
4436  if (object != NULL) {
4437  SCFree(object);
4438  }
4439 
4440  return 0;
4441 }
4442 
4443 static int DNP3DecodeObjectG33V2(const uint8_t **buf, uint32_t *len,
4444  uint8_t prefix_code, uint32_t start, uint32_t count,
4445  DNP3PointList *points)
4446 {
4447  DNP3ObjectG33V2 *object = NULL;
4448  uint32_t prefix = 0;
4449  uint32_t point_index = start;
4450 
4451  while (count--) {
4452 
4453  object = SCCalloc(1, sizeof(*object));
4454  if (unlikely(object == NULL)) {
4455  goto error;
4456  }
4457 
4458  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4459  goto error;
4460  }
4461 
4462  {
4463  uint8_t octet;
4464  if (!DNP3ReadUint8(buf, len, &octet)) {
4465  goto error;
4466  }
4467  object->online = (octet >> 0) & 0x1;
4468  object->restart = (octet >> 1) & 0x1;
4469  object->comm_lost = (octet >> 2) & 0x1;
4470  object->remote_forced = (octet >> 3) & 0x1;
4471  object->local_forced = (octet >> 4) & 0x1;
4472  object->over_range = (octet >> 5) & 0x1;
4473  object->reference_err = (octet >> 6) & 0x1;
4474  object->reserved0 = (octet >> 7) & 0x1;
4475  }
4476  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4477  goto error;
4478  }
4479 
4480  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4481  goto error;
4482  }
4483 
4484  object = NULL;
4485  point_index++;
4486  }
4487 
4488  return 1;
4489 error:
4490  if (object != NULL) {
4491  SCFree(object);
4492  }
4493 
4494  return 0;
4495 }
4496 
4497 static int DNP3DecodeObjectG33V3(const uint8_t **buf, uint32_t *len,
4498  uint8_t prefix_code, uint32_t start, uint32_t count,
4499  DNP3PointList *points)
4500 {
4501  DNP3ObjectG33V3 *object = NULL;
4502  uint32_t prefix = 0;
4503  uint32_t point_index = start;
4504 
4505  while (count--) {
4506 
4507  object = SCCalloc(1, sizeof(*object));
4508  if (unlikely(object == NULL)) {
4509  goto error;
4510  }
4511 
4512  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4513  goto error;
4514  }
4515 
4516  {
4517  uint8_t octet;
4518  if (!DNP3ReadUint8(buf, len, &octet)) {
4519  goto error;
4520  }
4521  object->online = (octet >> 0) & 0x1;
4522  object->restart = (octet >> 1) & 0x1;
4523  object->comm_lost = (octet >> 2) & 0x1;
4524  object->remote_forced = (octet >> 3) & 0x1;
4525  object->local_forced = (octet >> 4) & 0x1;
4526  object->over_range = (octet >> 5) & 0x1;
4527  object->reference_err = (octet >> 6) & 0x1;
4528  object->reserved0 = (octet >> 7) & 0x1;
4529  }
4530  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4531  goto error;
4532  }
4533  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4534  goto error;
4535  }
4536 
4537  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4538  goto error;
4539  }
4540 
4541  object = NULL;
4542  point_index++;
4543  }
4544 
4545  return 1;
4546 error:
4547  if (object != NULL) {
4548  SCFree(object);
4549  }
4550 
4551  return 0;
4552 }
4553 
4554 static int DNP3DecodeObjectG33V4(const uint8_t **buf, uint32_t *len,
4555  uint8_t prefix_code, uint32_t start, uint32_t count,
4556  DNP3PointList *points)
4557 {
4558  DNP3ObjectG33V4 *object = NULL;
4559  uint32_t prefix = 0;
4560  uint32_t point_index = start;
4561 
4562  while (count--) {
4563 
4564  object = SCCalloc(1, sizeof(*object));
4565  if (unlikely(object == NULL)) {
4566  goto error;
4567  }
4568 
4569  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4570  goto error;
4571  }
4572 
4573  {
4574  uint8_t octet;
4575  if (!DNP3ReadUint8(buf, len, &octet)) {
4576  goto error;
4577  }
4578  object->online = (octet >> 0) & 0x1;
4579  object->restart = (octet >> 1) & 0x1;
4580  object->comm_lost = (octet >> 2) & 0x1;
4581  object->remote_forced = (octet >> 3) & 0x1;
4582  object->local_forced = (octet >> 4) & 0x1;
4583  object->over_range = (octet >> 5) & 0x1;
4584  object->reference_err = (octet >> 6) & 0x1;
4585  object->reserved0 = (octet >> 7) & 0x1;
4586  }
4587  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
4588  goto error;
4589  }
4590  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4591  goto error;
4592  }
4593 
4594  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4595  goto error;
4596  }
4597 
4598  object = NULL;
4599  point_index++;
4600  }
4601 
4602  return 1;
4603 error:
4604  if (object != NULL) {
4605  SCFree(object);
4606  }
4607 
4608  return 0;
4609 }
4610 
4611 static int DNP3DecodeObjectG33V5(const uint8_t **buf, uint32_t *len,
4612  uint8_t prefix_code, uint32_t start, uint32_t count,
4613  DNP3PointList *points)
4614 {
4615  DNP3ObjectG33V5 *object = NULL;
4616  uint32_t prefix = 0;
4617  uint32_t point_index = start;
4618 
4619  while (count--) {
4620 
4621  object = SCCalloc(1, sizeof(*object));
4622  if (unlikely(object == NULL)) {
4623  goto error;
4624  }
4625 
4626  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4627  goto error;
4628  }
4629 
4630  {
4631  uint8_t octet;
4632  if (!DNP3ReadUint8(buf, len, &octet)) {
4633  goto error;
4634  }
4635  object->online = (octet >> 0) & 0x1;
4636  object->restart = (octet >> 1) & 0x1;
4637  object->comm_lost = (octet >> 2) & 0x1;
4638  object->remote_forced = (octet >> 3) & 0x1;
4639  object->local_forced = (octet >> 4) & 0x1;
4640  object->over_range = (octet >> 5) & 0x1;
4641  object->reference_err = (octet >> 6) & 0x1;
4642  object->reserved0 = (octet >> 7) & 0x1;
4643  }
4644  if (!DNP3ReadFloat32(buf, len, &object->value)) {
4645  goto error;
4646  }
4647 
4648  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4649  goto error;
4650  }
4651 
4652  object = NULL;
4653  point_index++;
4654  }
4655 
4656  return 1;
4657 error:
4658  if (object != NULL) {
4659  SCFree(object);
4660  }
4661 
4662  return 0;
4663 }
4664 
4665 static int DNP3DecodeObjectG33V6(const uint8_t **buf, uint32_t *len,
4666  uint8_t prefix_code, uint32_t start, uint32_t count,
4667  DNP3PointList *points)
4668 {
4669  DNP3ObjectG33V6 *object = NULL;
4670  uint32_t prefix = 0;
4671  uint32_t point_index = start;
4672 
4673  while (count--) {
4674 
4675  object = SCCalloc(1, sizeof(*object));
4676  if (unlikely(object == NULL)) {
4677  goto error;
4678  }
4679 
4680  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4681  goto error;
4682  }
4683 
4684  {
4685  uint8_t octet;
4686  if (!DNP3ReadUint8(buf, len, &octet)) {
4687  goto error;
4688  }
4689  object->online = (octet >> 0) & 0x1;
4690  object->restart = (octet >> 1) & 0x1;
4691  object->comm_lost = (octet >> 2) & 0x1;
4692  object->remote_forced = (octet >> 3) & 0x1;
4693  object->local_forced = (octet >> 4) & 0x1;
4694  object->over_range = (octet >> 5) & 0x1;
4695  object->reference_err = (octet >> 6) & 0x1;
4696  object->reserved0 = (octet >> 7) & 0x1;
4697  }
4698  if (!DNP3ReadFloat64(buf, len, &object->value)) {
4699  goto error;
4700  }
4701 
4702  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4703  goto error;
4704  }
4705 
4706  object = NULL;
4707  point_index++;
4708  }
4709 
4710  return 1;
4711 error:
4712  if (object != NULL) {
4713  SCFree(object);
4714  }
4715 
4716  return 0;
4717 }
4718 
4719 static int DNP3DecodeObjectG33V7(const uint8_t **buf, uint32_t *len,
4720  uint8_t prefix_code, uint32_t start, uint32_t count,
4721  DNP3PointList *points)
4722 {
4723  DNP3ObjectG33V7 *object = NULL;
4724  uint32_t prefix = 0;
4725  uint32_t point_index = start;
4726 
4727  while (count--) {
4728 
4729  object = SCCalloc(1, sizeof(*object));
4730  if (unlikely(object == NULL)) {
4731  goto error;
4732  }
4733 
4734  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4735  goto error;
4736  }
4737 
4738  {
4739  uint8_t octet;
4740  if (!DNP3ReadUint8(buf, len, &octet)) {
4741  goto error;
4742  }
4743  object->online = (octet >> 0) & 0x1;
4744  object->restart = (octet >> 1) & 0x1;
4745  object->comm_lost = (octet >> 2) & 0x1;
4746  object->remote_forced = (octet >> 3) & 0x1;
4747  object->local_forced = (octet >> 4) & 0x1;
4748  object->over_range = (octet >> 5) & 0x1;
4749  object->reference_err = (octet >> 6) & 0x1;
4750  object->reserved0 = (octet >> 7) & 0x1;
4751  }
4752  if (!DNP3ReadFloat32(buf, len, &object->value)) {
4753  goto error;
4754  }
4755  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4756  goto error;
4757  }
4758 
4759  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4760  goto error;
4761  }
4762 
4763  object = NULL;
4764  point_index++;
4765  }
4766 
4767  return 1;
4768 error:
4769  if (object != NULL) {
4770  SCFree(object);
4771  }
4772 
4773  return 0;
4774 }
4775 
4776 static int DNP3DecodeObjectG33V8(const uint8_t **buf, uint32_t *len,
4777  uint8_t prefix_code, uint32_t start, uint32_t count,
4778  DNP3PointList *points)
4779 {
4780  DNP3ObjectG33V8 *object = NULL;
4781  uint32_t prefix = 0;
4782  uint32_t point_index = start;
4783 
4784  while (count--) {
4785 
4786  object = SCCalloc(1, sizeof(*object));
4787  if (unlikely(object == NULL)) {
4788  goto error;
4789  }
4790 
4791  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4792  goto error;
4793  }
4794 
4795  {
4796  uint8_t octet;
4797  if (!DNP3ReadUint8(buf, len, &octet)) {
4798  goto error;
4799  }
4800  object->online = (octet >> 0) & 0x1;
4801  object->restart = (octet >> 1) & 0x1;
4802  object->comm_lost = (octet >> 2) & 0x1;
4803  object->remote_forced = (octet >> 3) & 0x1;
4804  object->local_forced = (octet >> 4) & 0x1;
4805  object->over_range = (octet >> 5) & 0x1;
4806  object->reference_err = (octet >> 6) & 0x1;
4807  object->reserved0 = (octet >> 7) & 0x1;
4808  }
4809  if (!DNP3ReadFloat64(buf, len, &object->value)) {
4810  goto error;
4811  }
4812  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
4813  goto error;
4814  }
4815 
4816  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4817  goto error;
4818  }
4819 
4820  object = NULL;
4821  point_index++;
4822  }
4823 
4824  return 1;
4825 error:
4826  if (object != NULL) {
4827  SCFree(object);
4828  }
4829 
4830  return 0;
4831 }
4832 
4833 static int DNP3DecodeObjectG34V1(const uint8_t **buf, uint32_t *len,
4834  uint8_t prefix_code, uint32_t start, uint32_t count,
4835  DNP3PointList *points)
4836 {
4837  DNP3ObjectG34V1 *object = NULL;
4838  uint32_t prefix = 0;
4839  uint32_t point_index = start;
4840 
4841  while (count--) {
4842 
4843  object = SCCalloc(1, sizeof(*object));
4844  if (unlikely(object == NULL)) {
4845  goto error;
4846  }
4847 
4848  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4849  goto error;
4850  }
4851 
4852  if (!DNP3ReadUint16(buf, len, &object->deadband_value)) {
4853  goto error;
4854  }
4855 
4856  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4857  goto error;
4858  }
4859 
4860  object = NULL;
4861  point_index++;
4862  }
4863 
4864  return 1;
4865 error:
4866  if (object != NULL) {
4867  SCFree(object);
4868  }
4869 
4870  return 0;
4871 }
4872 
4873 static int DNP3DecodeObjectG34V2(const uint8_t **buf, uint32_t *len,
4874  uint8_t prefix_code, uint32_t start, uint32_t count,
4875  DNP3PointList *points)
4876 {
4877  DNP3ObjectG34V2 *object = NULL;
4878  uint32_t prefix = 0;
4879  uint32_t point_index = start;
4880 
4881  while (count--) {
4882 
4883  object = SCCalloc(1, sizeof(*object));
4884  if (unlikely(object == NULL)) {
4885  goto error;
4886  }
4887 
4888  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4889  goto error;
4890  }
4891 
4892  if (!DNP3ReadUint32(buf, len, &object->deadband_value)) {
4893  goto error;
4894  }
4895 
4896  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4897  goto error;
4898  }
4899 
4900  object = NULL;
4901  point_index++;
4902  }
4903 
4904  return 1;
4905 error:
4906  if (object != NULL) {
4907  SCFree(object);
4908  }
4909 
4910  return 0;
4911 }
4912 
4913 static int DNP3DecodeObjectG34V3(const uint8_t **buf, uint32_t *len,
4914  uint8_t prefix_code, uint32_t start, uint32_t count,
4915  DNP3PointList *points)
4916 {
4917  DNP3ObjectG34V3 *object = NULL;
4918  uint32_t prefix = 0;
4919  uint32_t point_index = start;
4920 
4921  while (count--) {
4922 
4923  object = SCCalloc(1, sizeof(*object));
4924  if (unlikely(object == NULL)) {
4925  goto error;
4926  }
4927 
4928  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4929  goto error;
4930  }
4931 
4932  if (!DNP3ReadFloat32(buf, len, &object->deadband_value)) {
4933  goto error;
4934  }
4935 
4936  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4937  goto error;
4938  }
4939 
4940  object = NULL;
4941  point_index++;
4942  }
4943 
4944  return 1;
4945 error:
4946  if (object != NULL) {
4947  SCFree(object);
4948  }
4949 
4950  return 0;
4951 }
4952 
4953 static int DNP3DecodeObjectG40V1(const uint8_t **buf, uint32_t *len,
4954  uint8_t prefix_code, uint32_t start, uint32_t count,
4955  DNP3PointList *points)
4956 {
4957  DNP3ObjectG40V1 *object = NULL;
4958  uint32_t prefix = 0;
4959  uint32_t point_index = start;
4960 
4961  while (count--) {
4962 
4963  object = SCCalloc(1, sizeof(*object));
4964  if (unlikely(object == NULL)) {
4965  goto error;
4966  }
4967 
4968  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
4969  goto error;
4970  }
4971 
4972  {
4973  uint8_t octet;
4974  if (!DNP3ReadUint8(buf, len, &octet)) {
4975  goto error;
4976  }
4977  object->online = (octet >> 0) & 0x1;
4978  object->restart = (octet >> 1) & 0x1;
4979  object->comm_lost = (octet >> 2) & 0x1;
4980  object->remote_forced = (octet >> 3) & 0x1;
4981  object->local_forced = (octet >> 4) & 0x1;
4982  object->over_range = (octet >> 5) & 0x1;
4983  object->reference_err = (octet >> 6) & 0x1;
4984  object->reserved0 = (octet >> 7) & 0x1;
4985  }
4986  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
4987  goto error;
4988  }
4989 
4990  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
4991  goto error;
4992  }
4993 
4994  object = NULL;
4995  point_index++;
4996  }
4997 
4998  return 1;
4999 error:
5000  if (object != NULL) {
5001  SCFree(object);
5002  }
5003 
5004  return 0;
5005 }
5006 
5007 static int DNP3DecodeObjectG40V2(const uint8_t **buf, uint32_t *len,
5008  uint8_t prefix_code, uint32_t start, uint32_t count,
5009  DNP3PointList *points)
5010 {
5011  DNP3ObjectG40V2 *object = NULL;
5012  uint32_t prefix = 0;
5013  uint32_t point_index = start;
5014 
5015  while (count--) {
5016 
5017  object = SCCalloc(1, sizeof(*object));
5018  if (unlikely(object == NULL)) {
5019  goto error;
5020  }
5021 
5022  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5023  goto error;
5024  }
5025 
5026  {
5027  uint8_t octet;
5028  if (!DNP3ReadUint8(buf, len, &octet)) {
5029  goto error;
5030  }
5031  object->online = (octet >> 0) & 0x1;
5032  object->restart = (octet >> 1) & 0x1;
5033  object->comm_lost = (octet >> 2) & 0x1;
5034  object->remote_forced = (octet >> 3) & 0x1;
5035  object->local_forced = (octet >> 4) & 0x1;
5036  object->over_range = (octet >> 5) & 0x1;
5037  object->reference_err = (octet >> 6) & 0x1;
5038  object->reserved0 = (octet >> 7) & 0x1;
5039  }
5040  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5041  goto error;
5042  }
5043 
5044  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5045  goto error;
5046  }
5047 
5048  object = NULL;
5049  point_index++;
5050  }
5051 
5052  return 1;
5053 error:
5054  if (object != NULL) {
5055  SCFree(object);
5056  }
5057 
5058  return 0;
5059 }
5060 
5061 static int DNP3DecodeObjectG40V3(const uint8_t **buf, uint32_t *len,
5062  uint8_t prefix_code, uint32_t start, uint32_t count,
5063  DNP3PointList *points)
5064 {
5065  DNP3ObjectG40V3 *object = NULL;
5066  uint32_t prefix = 0;
5067  uint32_t point_index = start;
5068 
5069  while (count--) {
5070 
5071  object = SCCalloc(1, sizeof(*object));
5072  if (unlikely(object == NULL)) {
5073  goto error;
5074  }
5075 
5076  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5077  goto error;
5078  }
5079 
5080  {
5081  uint8_t octet;
5082  if (!DNP3ReadUint8(buf, len, &octet)) {
5083  goto error;
5084  }
5085  object->online = (octet >> 0) & 0x1;
5086  object->restart = (octet >> 1) & 0x1;
5087  object->comm_lost = (octet >> 2) & 0x1;
5088  object->remote_forced = (octet >> 3) & 0x1;
5089  object->local_forced = (octet >> 4) & 0x1;
5090  object->over_range = (octet >> 5) & 0x1;
5091  object->reference_err = (octet >> 6) & 0x1;
5092  object->reserved0 = (octet >> 7) & 0x1;
5093  }
5094  if (!DNP3ReadFloat32(buf, len, &object->value)) {
5095  goto error;
5096  }
5097 
5098  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5099  goto error;
5100  }
5101 
5102  object = NULL;
5103  point_index++;
5104  }
5105 
5106  return 1;
5107 error:
5108  if (object != NULL) {
5109  SCFree(object);
5110  }
5111 
5112  return 0;
5113 }
5114 
5115 static int DNP3DecodeObjectG40V4(const uint8_t **buf, uint32_t *len,
5116  uint8_t prefix_code, uint32_t start, uint32_t count,
5117  DNP3PointList *points)
5118 {
5119  DNP3ObjectG40V4 *object = NULL;
5120  uint32_t prefix = 0;
5121  uint32_t point_index = start;
5122 
5123  while (count--) {
5124 
5125  object = SCCalloc(1, sizeof(*object));
5126  if (unlikely(object == NULL)) {
5127  goto error;
5128  }
5129 
5130  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5131  goto error;
5132  }
5133 
5134  {
5135  uint8_t octet;
5136  if (!DNP3ReadUint8(buf, len, &octet)) {
5137  goto error;
5138  }
5139  object->online = (octet >> 0) & 0x1;
5140  object->restart = (octet >> 1) & 0x1;
5141  object->comm_lost = (octet >> 2) & 0x1;
5142  object->remote_forced = (octet >> 3) & 0x1;
5143  object->local_forced = (octet >> 4) & 0x1;
5144  object->over_range = (octet >> 5) & 0x1;
5145  object->reference_err = (octet >> 6) & 0x1;
5146  object->reserved0 = (octet >> 7) & 0x1;
5147  }
5148  if (!DNP3ReadFloat64(buf, len, &object->value)) {
5149  goto error;
5150  }
5151 
5152  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5153  goto error;
5154  }
5155 
5156  object = NULL;
5157  point_index++;
5158  }
5159 
5160  return 1;
5161 error:
5162  if (object != NULL) {
5163  SCFree(object);
5164  }
5165 
5166  return 0;
5167 }
5168 
5169 static int DNP3DecodeObjectG41V1(const uint8_t **buf, uint32_t *len,
5170  uint8_t prefix_code, uint32_t start, uint32_t count,
5171  DNP3PointList *points)
5172 {
5173  DNP3ObjectG41V1 *object = NULL;
5174  uint32_t prefix = 0;
5175  uint32_t point_index = start;
5176 
5177  while (count--) {
5178 
5179  object = SCCalloc(1, sizeof(*object));
5180  if (unlikely(object == NULL)) {
5181  goto error;
5182  }
5183 
5184  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5185  goto error;
5186  }
5187 
5188  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
5189  goto error;
5190  }
5191  if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5192  goto error;
5193  }
5194 
5195  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5196  goto error;
5197  }
5198 
5199  object = NULL;
5200  point_index++;
5201  }
5202 
5203  return 1;
5204 error:
5205  if (object != NULL) {
5206  SCFree(object);
5207  }
5208 
5209  return 0;
5210 }
5211 
5212 static int DNP3DecodeObjectG41V2(const uint8_t **buf, uint32_t *len,
5213  uint8_t prefix_code, uint32_t start, uint32_t count,
5214  DNP3PointList *points)
5215 {
5216  DNP3ObjectG41V2 *object = NULL;
5217  uint32_t prefix = 0;
5218  uint32_t point_index = start;
5219 
5220  while (count--) {
5221 
5222  object = SCCalloc(1, sizeof(*object));
5223  if (unlikely(object == NULL)) {
5224  goto error;
5225  }
5226 
5227  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5228  goto error;
5229  }
5230 
5231  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5232  goto error;
5233  }
5234  if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5235  goto error;
5236  }
5237 
5238  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5239  goto error;
5240  }
5241 
5242  object = NULL;
5243  point_index++;
5244  }
5245 
5246  return 1;
5247 error:
5248  if (object != NULL) {
5249  SCFree(object);
5250  }
5251 
5252  return 0;
5253 }
5254 
5255 static int DNP3DecodeObjectG41V3(const uint8_t **buf, uint32_t *len,
5256  uint8_t prefix_code, uint32_t start, uint32_t count,
5257  DNP3PointList *points)
5258 {
5259  DNP3ObjectG41V3 *object = NULL;
5260  uint32_t prefix = 0;
5261  uint32_t point_index = start;
5262 
5263  while (count--) {
5264 
5265  object = SCCalloc(1, sizeof(*object));
5266  if (unlikely(object == NULL)) {
5267  goto error;
5268  }
5269 
5270  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5271  goto error;
5272  }
5273 
5274  if (!DNP3ReadFloat32(buf, len, &object->value)) {
5275  goto error;
5276  }
5277  if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5278  goto error;
5279  }
5280 
5281  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5282  goto error;
5283  }
5284 
5285  object = NULL;
5286  point_index++;
5287  }
5288 
5289  return 1;
5290 error:
5291  if (object != NULL) {
5292  SCFree(object);
5293  }
5294 
5295  return 0;
5296 }
5297 
5298 static int DNP3DecodeObjectG41V4(const uint8_t **buf, uint32_t *len,
5299  uint8_t prefix_code, uint32_t start, uint32_t count,
5300  DNP3PointList *points)
5301 {
5302  DNP3ObjectG41V4 *object = NULL;
5303  uint32_t prefix = 0;
5304  uint32_t point_index = start;
5305 
5306  while (count--) {
5307 
5308  object = SCCalloc(1, sizeof(*object));
5309  if (unlikely(object == NULL)) {
5310  goto error;
5311  }
5312 
5313  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5314  goto error;
5315  }
5316 
5317  if (!DNP3ReadFloat64(buf, len, &object->value)) {
5318  goto error;
5319  }
5320  if (!DNP3ReadUint8(buf, len, &object->control_status)) {
5321  goto error;
5322  }
5323 
5324  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5325  goto error;
5326  }
5327 
5328  object = NULL;
5329  point_index++;
5330  }
5331 
5332  return 1;
5333 error:
5334  if (object != NULL) {
5335  SCFree(object);
5336  }
5337 
5338  return 0;
5339 }
5340 
5341 static int DNP3DecodeObjectG42V1(const uint8_t **buf, uint32_t *len,
5342  uint8_t prefix_code, uint32_t start, uint32_t count,
5343  DNP3PointList *points)
5344 {
5345  DNP3ObjectG42V1 *object = NULL;
5346  uint32_t prefix = 0;
5347  uint32_t point_index = start;
5348 
5349  while (count--) {
5350 
5351  object = SCCalloc(1, sizeof(*object));
5352  if (unlikely(object == NULL)) {
5353  goto error;
5354  }
5355 
5356  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5357  goto error;
5358  }
5359 
5360  {
5361  uint8_t octet;
5362  if (!DNP3ReadUint8(buf, len, &octet)) {
5363  goto error;
5364  }
5365  object->online = (octet >> 0) & 0x1;
5366  object->restart = (octet >> 1) & 0x1;
5367  object->comm_lost = (octet >> 2) & 0x1;
5368  object->remote_forced = (octet >> 3) & 0x1;
5369  object->local_forced = (octet >> 4) & 0x1;
5370  object->over_range = (octet >> 5) & 0x1;
5371  object->reference_err = (octet >> 6) & 0x1;
5372  object->reserved0 = (octet >> 7) & 0x1;
5373  }
5374  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
5375  goto error;
5376  }
5377 
5378  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5379  goto error;
5380  }
5381 
5382  object = NULL;
5383  point_index++;
5384  }
5385 
5386  return 1;
5387 error:
5388  if (object != NULL) {
5389  SCFree(object);
5390  }
5391 
5392  return 0;
5393 }
5394 
5395 static int DNP3DecodeObjectG42V2(const uint8_t **buf, uint32_t *len,
5396  uint8_t prefix_code, uint32_t start, uint32_t count,
5397  DNP3PointList *points)
5398 {
5399  DNP3ObjectG42V2 *object = NULL;
5400  uint32_t prefix = 0;
5401  uint32_t point_index = start;
5402 
5403  while (count--) {
5404 
5405  object = SCCalloc(1, sizeof(*object));
5406  if (unlikely(object == NULL)) {
5407  goto error;
5408  }
5409 
5410  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5411  goto error;
5412  }
5413 
5414  {
5415  uint8_t octet;
5416  if (!DNP3ReadUint8(buf, len, &octet)) {
5417  goto error;
5418  }
5419  object->online = (octet >> 0) & 0x1;
5420  object->restart = (octet >> 1) & 0x1;
5421  object->comm_lost = (octet >> 2) & 0x1;
5422  object->remote_forced = (octet >> 3) & 0x1;
5423  object->local_forced = (octet >> 4) & 0x1;
5424  object->over_range = (octet >> 5) & 0x1;
5425  object->reference_err = (octet >> 6) & 0x1;
5426  object->reserved0 = (octet >> 7) & 0x1;
5427  }
5428  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5429  goto error;
5430  }
5431 
5432  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5433  goto error;
5434  }
5435 
5436  object = NULL;
5437  point_index++;
5438  }
5439 
5440  return 1;
5441 error:
5442  if (object != NULL) {
5443  SCFree(object);
5444  }
5445 
5446  return 0;
5447 }
5448 
5449 static int DNP3DecodeObjectG42V3(const uint8_t **buf, uint32_t *len,
5450  uint8_t prefix_code, uint32_t start, uint32_t count,
5451  DNP3PointList *points)
5452 {
5453  DNP3ObjectG42V3 *object = NULL;
5454  uint32_t prefix = 0;
5455  uint32_t point_index = start;
5456 
5457  while (count--) {
5458 
5459  object = SCCalloc(1, sizeof(*object));
5460  if (unlikely(object == NULL)) {
5461  goto error;
5462  }
5463 
5464  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5465  goto error;
5466  }
5467 
5468  {
5469  uint8_t octet;
5470  if (!DNP3ReadUint8(buf, len, &octet)) {
5471  goto error;
5472  }
5473  object->online = (octet >> 0) & 0x1;
5474  object->restart = (octet >> 1) & 0x1;
5475  object->comm_lost = (octet >> 2) & 0x1;
5476  object->remote_forced = (octet >> 3) & 0x1;
5477  object->local_forced = (octet >> 4) & 0x1;
5478  object->over_range = (octet >> 5) & 0x1;
5479  object->reference_err = (octet >> 6) & 0x1;
5480  object->reserved0 = (octet >> 7) & 0x1;
5481  }
5482  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->value)) {
5483  goto error;
5484  }
5485  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5486  goto error;
5487  }
5488 
5489  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5490  goto error;
5491  }
5492 
5493  object = NULL;
5494  point_index++;
5495  }
5496 
5497  return 1;
5498 error:
5499  if (object != NULL) {
5500  SCFree(object);
5501  }
5502 
5503  return 0;
5504 }
5505 
5506 static int DNP3DecodeObjectG42V4(const uint8_t **buf, uint32_t *len,
5507  uint8_t prefix_code, uint32_t start, uint32_t count,
5508  DNP3PointList *points)
5509 {
5510  DNP3ObjectG42V4 *object = NULL;
5511  uint32_t prefix = 0;
5512  uint32_t point_index = start;
5513 
5514  while (count--) {
5515 
5516  object = SCCalloc(1, sizeof(*object));
5517  if (unlikely(object == NULL)) {
5518  goto error;
5519  }
5520 
5521  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5522  goto error;
5523  }
5524 
5525  {
5526  uint8_t octet;
5527  if (!DNP3ReadUint8(buf, len, &octet)) {
5528  goto error;
5529  }
5530  object->online = (octet >> 0) & 0x1;
5531  object->restart = (octet >> 1) & 0x1;
5532  object->comm_lost = (octet >> 2) & 0x1;
5533  object->remote_forced = (octet >> 3) & 0x1;
5534  object->local_forced = (octet >> 4) & 0x1;
5535  object->over_range = (octet >> 5) & 0x1;
5536  object->reference_err = (octet >> 6) & 0x1;
5537  object->reserved0 = (octet >> 7) & 0x1;
5538  }
5539  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->value)) {
5540  goto error;
5541  }
5542  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5543  goto error;
5544  }
5545 
5546  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5547  goto error;
5548  }
5549 
5550  object = NULL;
5551  point_index++;
5552  }
5553 
5554  return 1;
5555 error:
5556  if (object != NULL) {
5557  SCFree(object);
5558  }
5559 
5560  return 0;
5561 }
5562 
5563 static int DNP3DecodeObjectG42V5(const uint8_t **buf, uint32_t *len,
5564  uint8_t prefix_code, uint32_t start, uint32_t count,
5565  DNP3PointList *points)
5566 {
5567  DNP3ObjectG42V5 *object = NULL;
5568  uint32_t prefix = 0;
5569  uint32_t point_index = start;
5570 
5571  while (count--) {
5572 
5573  object = SCCalloc(1, sizeof(*object));
5574  if (unlikely(object == NULL)) {
5575  goto error;
5576  }
5577 
5578  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5579  goto error;
5580  }
5581 
5582  {
5583  uint8_t octet;
5584  if (!DNP3ReadUint8(buf, len, &octet)) {
5585  goto error;
5586  }
5587  object->online = (octet >> 0) & 0x1;
5588  object->restart = (octet >> 1) & 0x1;
5589  object->comm_lost = (octet >> 2) & 0x1;
5590  object->remote_forced = (octet >> 3) & 0x1;
5591  object->local_forced = (octet >> 4) & 0x1;
5592  object->over_range = (octet >> 5) & 0x1;
5593  object->reference_err = (octet >> 6) & 0x1;
5594  object->reserved0 = (octet >> 7) & 0x1;
5595  }
5596  if (!DNP3ReadFloat32(buf, len, &object->value)) {
5597  goto error;
5598  }
5599 
5600  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5601  goto error;
5602  }
5603 
5604  object = NULL;
5605  point_index++;
5606  }
5607 
5608  return 1;
5609 error:
5610  if (object != NULL) {
5611  SCFree(object);
5612  }
5613 
5614  return 0;
5615 }
5616 
5617 static int DNP3DecodeObjectG42V6(const uint8_t **buf, uint32_t *len,
5618  uint8_t prefix_code, uint32_t start, uint32_t count,
5619  DNP3PointList *points)
5620 {
5621  DNP3ObjectG42V6 *object = NULL;
5622  uint32_t prefix = 0;
5623  uint32_t point_index = start;
5624 
5625  while (count--) {
5626 
5627  object = SCCalloc(1, sizeof(*object));
5628  if (unlikely(object == NULL)) {
5629  goto error;
5630  }
5631 
5632  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5633  goto error;
5634  }
5635 
5636  {
5637  uint8_t octet;
5638  if (!DNP3ReadUint8(buf, len, &octet)) {
5639  goto error;
5640  }
5641  object->online = (octet >> 0) & 0x1;
5642  object->restart = (octet >> 1) & 0x1;
5643  object->comm_lost = (octet >> 2) & 0x1;
5644  object->remote_forced = (octet >> 3) & 0x1;
5645  object->local_forced = (octet >> 4) & 0x1;
5646  object->over_range = (octet >> 5) & 0x1;
5647  object->reference_err = (octet >> 6) & 0x1;
5648  object->reserved0 = (octet >> 7) & 0x1;
5649  }
5650  if (!DNP3ReadFloat64(buf, len, &object->value)) {
5651  goto error;
5652  }
5653 
5654  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5655  goto error;
5656  }
5657 
5658  object = NULL;
5659  point_index++;
5660  }
5661 
5662  return 1;
5663 error:
5664  if (object != NULL) {
5665  SCFree(object);
5666  }
5667 
5668  return 0;
5669 }
5670 
5671 static int DNP3DecodeObjectG42V7(const uint8_t **buf, uint32_t *len,
5672  uint8_t prefix_code, uint32_t start, uint32_t count,
5673  DNP3PointList *points)
5674 {
5675  DNP3ObjectG42V7 *object = NULL;
5676  uint32_t prefix = 0;
5677  uint32_t point_index = start;
5678 
5679  while (count--) {
5680 
5681  object = SCCalloc(1, sizeof(*object));
5682  if (unlikely(object == NULL)) {
5683  goto error;
5684  }
5685 
5686  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5687  goto error;
5688  }
5689 
5690  {
5691  uint8_t octet;
5692  if (!DNP3ReadUint8(buf, len, &octet)) {
5693  goto error;
5694  }
5695  object->online = (octet >> 0) & 0x1;
5696  object->restart = (octet >> 1) & 0x1;
5697  object->comm_lost = (octet >> 2) & 0x1;
5698  object->remote_forced = (octet >> 3) & 0x1;
5699  object->local_forced = (octet >> 4) & 0x1;
5700  object->over_range = (octet >> 5) & 0x1;
5701  object->reference_err = (octet >> 6) & 0x1;
5702  object->reserved0 = (octet >> 7) & 0x1;
5703  }
5704  if (!DNP3ReadFloat32(buf, len, &object->value)) {
5705  goto error;
5706  }
5707  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5708  goto error;
5709  }
5710 
5711  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5712  goto error;
5713  }
5714 
5715  object = NULL;
5716  point_index++;
5717  }
5718 
5719  return 1;
5720 error:
5721  if (object != NULL) {
5722  SCFree(object);
5723  }
5724 
5725  return 0;
5726 }
5727 
5728 static int DNP3DecodeObjectG42V8(const uint8_t **buf, uint32_t *len,
5729  uint8_t prefix_code, uint32_t start, uint32_t count,
5730  DNP3PointList *points)
5731 {
5732  DNP3ObjectG42V8 *object = NULL;
5733  uint32_t prefix = 0;
5734  uint32_t point_index = start;
5735 
5736  while (count--) {
5737 
5738  object = SCCalloc(1, sizeof(*object));
5739  if (unlikely(object == NULL)) {
5740  goto error;
5741  }
5742 
5743  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5744  goto error;
5745  }
5746 
5747  {
5748  uint8_t octet;
5749  if (!DNP3ReadUint8(buf, len, &octet)) {
5750  goto error;
5751  }
5752  object->online = (octet >> 0) & 0x1;
5753  object->restart = (octet >> 1) & 0x1;
5754  object->comm_lost = (octet >> 2) & 0x1;
5755  object->remote_forced = (octet >> 3) & 0x1;
5756  object->local_forced = (octet >> 4) & 0x1;
5757  object->over_range = (octet >> 5) & 0x1;
5758  object->reference_err = (octet >> 6) & 0x1;
5759  object->reserved0 = (octet >> 7) & 0x1;
5760  }
5761  if (!DNP3ReadFloat64(buf, len, &object->value)) {
5762  goto error;
5763  }
5764  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5765  goto error;
5766  }
5767 
5768  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5769  goto error;
5770  }
5771 
5772  object = NULL;
5773  point_index++;
5774  }
5775 
5776  return 1;
5777 error:
5778  if (object != NULL) {
5779  SCFree(object);
5780  }
5781 
5782  return 0;
5783 }
5784 
5785 static int DNP3DecodeObjectG43V1(const uint8_t **buf, uint32_t *len,
5786  uint8_t prefix_code, uint32_t start, uint32_t count,
5787  DNP3PointList *points)
5788 {
5789  DNP3ObjectG43V1 *object = NULL;
5790  uint32_t prefix = 0;
5791  uint32_t point_index = start;
5792 
5793  while (count--) {
5794 
5795  object = SCCalloc(1, sizeof(*object));
5796  if (unlikely(object == NULL)) {
5797  goto error;
5798  }
5799 
5800  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5801  goto error;
5802  }
5803 
5804  {
5805  uint8_t octet;
5806  if (!DNP3ReadUint8(buf, len, &octet)) {
5807  goto error;
5808  }
5809  object->status_code = (octet >> 0) & 0x7f;
5810  object->reserved0 = (octet >> 7) & 0x1;
5811  }
5812  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->commanded_value)) {
5813  goto error;
5814  }
5815 
5816  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5817  goto error;
5818  }
5819 
5820  object = NULL;
5821  point_index++;
5822  }
5823 
5824  return 1;
5825 error:
5826  if (object != NULL) {
5827  SCFree(object);
5828  }
5829 
5830  return 0;
5831 }
5832 
5833 static int DNP3DecodeObjectG43V2(const uint8_t **buf, uint32_t *len,
5834  uint8_t prefix_code, uint32_t start, uint32_t count,
5835  DNP3PointList *points)
5836 {
5837  DNP3ObjectG43V2 *object = NULL;
5838  uint32_t prefix = 0;
5839  uint32_t point_index = start;
5840 
5841  while (count--) {
5842 
5843  object = SCCalloc(1, sizeof(*object));
5844  if (unlikely(object == NULL)) {
5845  goto error;
5846  }
5847 
5848  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5849  goto error;
5850  }
5851 
5852  {
5853  uint8_t octet;
5854  if (!DNP3ReadUint8(buf, len, &octet)) {
5855  goto error;
5856  }
5857  object->status_code = (octet >> 0) & 0x7f;
5858  object->reserved0 = (octet >> 7) & 0x1;
5859  }
5860  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->commanded_value)) {
5861  goto error;
5862  }
5863 
5864  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5865  goto error;
5866  }
5867 
5868  object = NULL;
5869  point_index++;
5870  }
5871 
5872  return 1;
5873 error:
5874  if (object != NULL) {
5875  SCFree(object);
5876  }
5877 
5878  return 0;
5879 }
5880 
5881 static int DNP3DecodeObjectG43V3(const uint8_t **buf, uint32_t *len,
5882  uint8_t prefix_code, uint32_t start, uint32_t count,
5883  DNP3PointList *points)
5884 {
5885  DNP3ObjectG43V3 *object = NULL;
5886  uint32_t prefix = 0;
5887  uint32_t point_index = start;
5888 
5889  while (count--) {
5890 
5891  object = SCCalloc(1, sizeof(*object));
5892  if (unlikely(object == NULL)) {
5893  goto error;
5894  }
5895 
5896  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5897  goto error;
5898  }
5899 
5900  {
5901  uint8_t octet;
5902  if (!DNP3ReadUint8(buf, len, &octet)) {
5903  goto error;
5904  }
5905  object->status_code = (octet >> 0) & 0x7f;
5906  object->reserved0 = (octet >> 7) & 0x1;
5907  }
5908  if (!DNP3ReadUint32(buf, len, (uint32_t *)&object->commanded_value)) {
5909  goto error;
5910  }
5911  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5912  goto error;
5913  }
5914 
5915  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5916  goto error;
5917  }
5918 
5919  object = NULL;
5920  point_index++;
5921  }
5922 
5923  return 1;
5924 error:
5925  if (object != NULL) {
5926  SCFree(object);
5927  }
5928 
5929  return 0;
5930 }
5931 
5932 static int DNP3DecodeObjectG43V4(const uint8_t **buf, uint32_t *len,
5933  uint8_t prefix_code, uint32_t start, uint32_t count,
5934  DNP3PointList *points)
5935 {
5936  DNP3ObjectG43V4 *object = NULL;
5937  uint32_t prefix = 0;
5938  uint32_t point_index = start;
5939 
5940  while (count--) {
5941 
5942  object = SCCalloc(1, sizeof(*object));
5943  if (unlikely(object == NULL)) {
5944  goto error;
5945  }
5946 
5947  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5948  goto error;
5949  }
5950 
5951  {
5952  uint8_t octet;
5953  if (!DNP3ReadUint8(buf, len, &octet)) {
5954  goto error;
5955  }
5956  object->status_code = (octet >> 0) & 0x7f;
5957  object->reserved0 = (octet >> 7) & 0x1;
5958  }
5959  if (!DNP3ReadUint16(buf, len, (uint16_t *)&object->commanded_value)) {
5960  goto error;
5961  }
5962  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
5963  goto error;
5964  }
5965 
5966  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
5967  goto error;
5968  }
5969 
5970  object = NULL;
5971  point_index++;
5972  }
5973 
5974  return 1;
5975 error:
5976  if (object != NULL) {
5977  SCFree(object);
5978  }
5979 
5980  return 0;
5981 }
5982 
5983 static int DNP3DecodeObjectG43V5(const uint8_t **buf, uint32_t *len,
5984  uint8_t prefix_code, uint32_t start, uint32_t count,
5985  DNP3PointList *points)
5986 {
5987  DNP3ObjectG43V5 *object = NULL;
5988  uint32_t prefix = 0;
5989  uint32_t point_index = start;
5990 
5991  while (count--) {
5992 
5993  object = SCCalloc(1, sizeof(*object));
5994  if (unlikely(object == NULL)) {
5995  goto error;
5996  }
5997 
5998  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
5999  goto error;
6000  }
6001 
6002  {
6003  uint8_t octet;
6004  if (!DNP3ReadUint8(buf, len, &octet)) {
6005  goto error;
6006  }
6007  object->status_code = (octet >> 0) & 0x7f;
6008  object->reserved0 = (octet >> 7) & 0x1;
6009  }
6010  if (!DNP3ReadFloat32(buf, len, &object->commanded_value)) {
6011  goto error;
6012  }
6013 
6014  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6015  goto error;
6016  }
6017 
6018  object = NULL;
6019  point_index++;
6020  }
6021 
6022  return 1;
6023 error:
6024  if (object != NULL) {
6025  SCFree(object);
6026  }
6027 
6028  return 0;
6029 }
6030 
6031 static int DNP3DecodeObjectG43V6(const uint8_t **buf, uint32_t *len,
6032  uint8_t prefix_code, uint32_t start, uint32_t count,
6033  DNP3PointList *points)
6034 {
6035  DNP3ObjectG43V6 *object = NULL;
6036  uint32_t prefix = 0;
6037  uint32_t point_index = start;
6038 
6039  while (count--) {
6040 
6041  object = SCCalloc(1, sizeof(*object));
6042  if (unlikely(object == NULL)) {
6043  goto error;
6044  }
6045 
6046  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6047  goto error;
6048  }
6049 
6050  {
6051  uint8_t octet;
6052  if (!DNP3ReadUint8(buf, len, &octet)) {
6053  goto error;
6054  }
6055  object->status_code = (octet >> 0) & 0x7f;
6056  object->reserved0 = (octet >> 7) & 0x1;
6057  }
6058  if (!DNP3ReadFloat64(buf, len, &object->commanded_value)) {
6059  goto error;
6060  }
6061 
6062  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6063  goto error;
6064  }
6065 
6066  object = NULL;
6067  point_index++;
6068  }
6069 
6070  return 1;
6071 error:
6072  if (object != NULL) {
6073  SCFree(object);
6074  }
6075 
6076  return 0;
6077 }
6078 
6079 static int DNP3DecodeObjectG43V7(const uint8_t **buf, uint32_t *len,
6080  uint8_t prefix_code, uint32_t start, uint32_t count,
6081  DNP3PointList *points)
6082 {
6083  DNP3ObjectG43V7 *object = NULL;
6084  uint32_t prefix = 0;
6085  uint32_t point_index = start;
6086 
6087  while (count--) {
6088 
6089  object = SCCalloc(1, sizeof(*object));
6090  if (unlikely(object == NULL)) {
6091  goto error;
6092  }
6093 
6094  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6095  goto error;
6096  }
6097 
6098  {
6099  uint8_t octet;
6100  if (!DNP3ReadUint8(buf, len, &octet)) {
6101  goto error;
6102  }
6103  object->status_code = (octet >> 0) & 0x7f;
6104  object->reserved0 = (octet >> 7) & 0x1;
6105  }
6106  if (!DNP3ReadFloat32(buf, len, &object->commanded_value)) {
6107  goto error;
6108  }
6109  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6110  goto error;
6111  }
6112 
6113  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6114  goto error;
6115  }
6116 
6117  object = NULL;
6118  point_index++;
6119  }
6120 
6121  return 1;
6122 error:
6123  if (object != NULL) {
6124  SCFree(object);
6125  }
6126 
6127  return 0;
6128 }
6129 
6130 static int DNP3DecodeObjectG43V8(const uint8_t **buf, uint32_t *len,
6131  uint8_t prefix_code, uint32_t start, uint32_t count,
6132  DNP3PointList *points)
6133 {
6134  DNP3ObjectG43V8 *object = NULL;
6135  uint32_t prefix = 0;
6136  uint32_t point_index = start;
6137 
6138  while (count--) {
6139 
6140  object = SCCalloc(1, sizeof(*object));
6141  if (unlikely(object == NULL)) {
6142  goto error;
6143  }
6144 
6145  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6146  goto error;
6147  }
6148 
6149  {
6150  uint8_t octet;
6151  if (!DNP3ReadUint8(buf, len, &octet)) {
6152  goto error;
6153  }
6154  object->status_code = (octet >> 0) & 0x7f;
6155  object->reserved0 = (octet >> 7) & 0x1;
6156  }
6157  if (!DNP3ReadFloat64(buf, len, &object->commanded_value)) {
6158  goto error;
6159  }
6160  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6161  goto error;
6162  }
6163 
6164  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6165  goto error;
6166  }
6167 
6168  object = NULL;
6169  point_index++;
6170  }
6171 
6172  return 1;
6173 error:
6174  if (object != NULL) {
6175  SCFree(object);
6176  }
6177 
6178  return 0;
6179 }
6180 
6181 static int DNP3DecodeObjectG50V1(const uint8_t **buf, uint32_t *len,
6182  uint8_t prefix_code, uint32_t start, uint32_t count,
6183  DNP3PointList *points)
6184 {
6185  DNP3ObjectG50V1 *object = NULL;
6186  uint32_t prefix = 0;
6187  uint32_t point_index = start;
6188 
6189  while (count--) {
6190 
6191  object = SCCalloc(1, sizeof(*object));
6192  if (unlikely(object == NULL)) {
6193  goto error;
6194  }
6195 
6196  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6197  goto error;
6198  }
6199 
6200  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6201  goto error;
6202  }
6203 
6204  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6205  goto error;
6206  }
6207 
6208  object = NULL;
6209  point_index++;
6210  }
6211 
6212  return 1;
6213 error:
6214  if (object != NULL) {
6215  SCFree(object);
6216  }
6217 
6218  return 0;
6219 }
6220 
6221 static int DNP3DecodeObjectG50V2(const uint8_t **buf, uint32_t *len,
6222  uint8_t prefix_code, uint32_t start, uint32_t count,
6223  DNP3PointList *points)
6224 {
6225  DNP3ObjectG50V2 *object = NULL;
6226  uint32_t prefix = 0;
6227  uint32_t point_index = start;
6228 
6229  while (count--) {
6230 
6231  object = SCCalloc(1, sizeof(*object));
6232  if (unlikely(object == NULL)) {
6233  goto error;
6234  }
6235 
6236  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6237  goto error;
6238  }
6239 
6240  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6241  goto error;
6242  }
6243  if (!DNP3ReadUint32(buf, len, &object->interval)) {
6244  goto error;
6245  }
6246 
6247  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6248  goto error;
6249  }
6250 
6251  object = NULL;
6252  point_index++;
6253  }
6254 
6255  return 1;
6256 error:
6257  if (object != NULL) {
6258  SCFree(object);
6259  }
6260 
6261  return 0;
6262 }
6263 
6264 static int DNP3DecodeObjectG50V3(const uint8_t **buf, uint32_t *len,
6265  uint8_t prefix_code, uint32_t start, uint32_t count,
6266  DNP3PointList *points)
6267 {
6268  DNP3ObjectG50V3 *object = NULL;
6269  uint32_t prefix = 0;
6270  uint32_t point_index = start;
6271 
6272  while (count--) {
6273 
6274  object = SCCalloc(1, sizeof(*object));
6275  if (unlikely(object == NULL)) {
6276  goto error;
6277  }
6278 
6279  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6280  goto error;
6281  }
6282 
6283  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6284  goto error;
6285  }
6286 
6287  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6288  goto error;
6289  }
6290 
6291  object = NULL;
6292  point_index++;
6293  }
6294 
6295  return 1;
6296 error:
6297  if (object != NULL) {
6298  SCFree(object);
6299  }
6300 
6301  return 0;
6302 }
6303 
6304 static int DNP3DecodeObjectG50V4(const uint8_t **buf, uint32_t *len,
6305  uint8_t prefix_code, uint32_t start, uint32_t count,
6306  DNP3PointList *points)
6307 {
6308  DNP3ObjectG50V4 *object = NULL;
6309  uint32_t prefix = 0;
6310  uint32_t point_index = start;
6311 
6312  while (count--) {
6313 
6314  object = SCCalloc(1, sizeof(*object));
6315  if (unlikely(object == NULL)) {
6316  goto error;
6317  }
6318 
6319  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6320  goto error;
6321  }
6322 
6323  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6324  goto error;
6325  }
6326  if (!DNP3ReadUint32(buf, len, &object->interval_count)) {
6327  goto error;
6328  }
6329  if (!DNP3ReadUint8(buf, len, &object->interval_units)) {
6330  goto error;
6331  }
6332 
6333  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6334  goto error;
6335  }
6336 
6337  object = NULL;
6338  point_index++;
6339  }
6340 
6341  return 1;
6342 error:
6343  if (object != NULL) {
6344  SCFree(object);
6345  }
6346 
6347  return 0;
6348 }
6349 
6350 static int DNP3DecodeObjectG51V1(const uint8_t **buf, uint32_t *len,
6351  uint8_t prefix_code, uint32_t start, uint32_t count,
6352  DNP3PointList *points)
6353 {
6354  DNP3ObjectG51V1 *object = NULL;
6355  uint32_t prefix = 0;
6356  uint32_t point_index = start;
6357 
6358  while (count--) {
6359 
6360  object = SCCalloc(1, sizeof(*object));
6361  if (unlikely(object == NULL)) {
6362  goto error;
6363  }
6364 
6365  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6366  goto error;
6367  }
6368 
6369  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6370  goto error;
6371  }
6372 
6373  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6374  goto error;
6375  }
6376 
6377  object = NULL;
6378  point_index++;
6379  }
6380 
6381  return 1;
6382 error:
6383  if (object != NULL) {
6384  SCFree(object);
6385  }
6386 
6387  return 0;
6388 }
6389 
6390 static int DNP3DecodeObjectG51V2(const uint8_t **buf, uint32_t *len,
6391  uint8_t prefix_code, uint32_t start, uint32_t count,
6392  DNP3PointList *points)
6393 {
6394  DNP3ObjectG51V2 *object = NULL;
6395  uint32_t prefix = 0;
6396  uint32_t point_index = start;
6397 
6398  while (count--) {
6399 
6400  object = SCCalloc(1, sizeof(*object));
6401  if (unlikely(object == NULL)) {
6402  goto error;
6403  }
6404 
6405  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6406  goto error;
6407  }
6408 
6409  if (!DNP3ReadUint48(buf, len, &object->timestamp)) {
6410  goto error;
6411  }
6412 
6413  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6414  goto error;
6415  }
6416 
6417  object = NULL;
6418  point_index++;
6419  }
6420 
6421  return 1;
6422 error:
6423  if (object != NULL) {
6424  SCFree(object);
6425  }
6426 
6427  return 0;
6428 }
6429 
6430 static int DNP3DecodeObjectG52V1(const uint8_t **buf, uint32_t *len,
6431  uint8_t prefix_code, uint32_t start, uint32_t count,
6432  DNP3PointList *points)
6433 {
6434  DNP3ObjectG52V1 *object = NULL;
6435  uint32_t prefix = 0;
6436  uint32_t point_index = start;
6437 
6438  while (count--) {
6439 
6440  object = SCCalloc(1, sizeof(*object));
6441  if (unlikely(object == NULL)) {
6442  goto error;
6443  }
6444 
6445  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6446  goto error;
6447  }
6448 
6449  if (!DNP3ReadUint16(buf, len, &object->delay_secs)) {
6450  goto error;
6451  }
6452 
6453  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6454  goto error;
6455  }
6456 
6457  object = NULL;
6458  point_index++;
6459  }
6460 
6461  return 1;
6462 error:
6463  if (object != NULL) {
6464  SCFree(object);
6465  }
6466 
6467  return 0;
6468 }
6469 
6470 static int DNP3DecodeObjectG52V2(const uint8_t **buf, uint32_t *len,
6471  uint8_t prefix_code, uint32_t start, uint32_t count,
6472  DNP3PointList *points)
6473 {
6474  DNP3ObjectG52V2 *object = NULL;
6475  uint32_t prefix = 0;
6476  uint32_t point_index = start;
6477 
6478  while (count--) {
6479 
6480  object = SCCalloc(1, sizeof(*object));
6481  if (unlikely(object == NULL)) {
6482  goto error;
6483  }
6484 
6485  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6486  goto error;
6487  }
6488 
6489  if (!DNP3ReadUint16(buf, len, &object->delay_ms)) {
6490  goto error;
6491  }
6492 
6493  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6494  goto error;
6495  }
6496 
6497  object = NULL;
6498  point_index++;
6499  }
6500 
6501  return 1;
6502 error:
6503  if (object != NULL) {
6504  SCFree(object);
6505  }
6506 
6507  return 0;
6508 }
6509 
6510 static int DNP3DecodeObjectG70V1(const uint8_t **buf, uint32_t *len,
6511  uint8_t prefix_code, uint32_t start, uint32_t count,
6512  DNP3PointList *points)
6513 {
6514  DNP3ObjectG70V1 *object = NULL;
6515  uint32_t prefix = 0;
6516  uint32_t point_index = start;
6517 
6518  while (count--) {
6519 
6520  object = SCCalloc(1, sizeof(*object));
6521  if (unlikely(object == NULL)) {
6522  goto error;
6523  }
6524 
6525  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6526  goto error;
6527  }
6528 
6529  if (!DNP3ReadUint16(buf, len, &object->filename_size)) {
6530  goto error;
6531  }
6532  if (!DNP3ReadUint8(buf, len, &object->filetype_code)) {
6533  goto error;
6534  }
6535  if (!DNP3ReadUint8(buf, len, &object->attribute_code)) {
6536  goto error;
6537  }
6538  if (!DNP3ReadUint16(buf, len, &object->start_record)) {
6539  goto error;
6540  }
6541  if (!DNP3ReadUint16(buf, len, &object->end_record)) {
6542  goto error;
6543  }
6544  if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6545  goto error;
6546  }
6547  if (!DNP3ReadUint48(buf, len, &object->created_timestamp)) {
6548  goto error;
6549  }
6550  if (!DNP3ReadUint16(buf, len, &object->permission)) {
6551  goto error;
6552  }
6553  if (!DNP3ReadUint32(buf, len, &object->file_id)) {
6554  goto error;
6555  }
6556  if (!DNP3ReadUint32(buf, len, &object->owner_id)) {
6557  goto error;
6558  }
6559  if (!DNP3ReadUint32(buf, len, &object->group_id)) {
6560  goto error;
6561  }
6562  if (!DNP3ReadUint8(buf, len, &object->file_function_code)) {
6563  goto error;
6564  }
6565  if (!DNP3ReadUint8(buf, len, &object->status_code)) {
6566  goto error;
6567  }
6568  if (object->filename_size > 0) {
6569  if (*len < object->filename_size) {
6570  /* Not enough data. */
6571  goto error;
6572  }
6573  memcpy(object->filename, *buf, object->filename_size);
6574  *buf += object->filename_size;
6575  *len -= object->filename_size;
6576  }
6577  object->filename[object->filename_size] = '\0';
6578  if (!DNP3ReadUint16(buf, len, &object->data_size)) {
6579  goto error;
6580  }
6581  if (object->data_size > 0) {
6582  if (*len < object->data_size) {
6583  /* Not enough data. */
6584  goto error;
6585  }
6586  memcpy(object->data, *buf, object->data_size);
6587  *buf += object->data_size;
6588  *len -= object->data_size;
6589  }
6590  object->data[object->data_size] = '\0';
6591 
6592  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6593  goto error;
6594  }
6595 
6596  object = NULL;
6597  point_index++;
6598  }
6599 
6600  return 1;
6601 error:
6602  if (object != NULL) {
6603  SCFree(object);
6604  }
6605 
6606  return 0;
6607 }
6608 
6609 static int DNP3DecodeObjectG70V2(const uint8_t **buf, uint32_t *len,
6610  uint8_t prefix_code, uint32_t start, uint32_t count,
6611  DNP3PointList *points)
6612 {
6613  DNP3ObjectG70V2 *object = NULL;
6614  uint32_t prefix = 0;
6615  uint32_t point_index = start;
6616 
6617  while (count--) {
6618 
6619  object = SCCalloc(1, sizeof(*object));
6620  if (unlikely(object == NULL)) {
6621  goto error;
6622  }
6623 
6624  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6625  goto error;
6626  }
6627 
6628  if (!DNP3ReadUint16(buf, len, &object->username_offset)) {
6629  goto error;
6630  }
6631  if (!DNP3ReadUint16(buf, len, &object->username_size)) {
6632  goto error;
6633  }
6634  if (!DNP3ReadUint16(buf, len, &object->password_offset)) {
6635  goto error;
6636  }
6637  if (!DNP3ReadUint16(buf, len, &object->password_size)) {
6638  goto error;
6639  }
6640  if (!DNP3ReadUint32(buf, len, &object->authentication_key)) {
6641  goto error;
6642  }
6643  if (object->username_size > 0) {
6644  if (*len < object->username_size) {
6645  /* Not enough data. */
6646  goto error;
6647  }
6648  memcpy(object->username, *buf, object->username_size);
6649  *buf += object->username_size;
6650  *len -= object->username_size;
6651  }
6652  object->username[object->username_size] = '\0';
6653  if (object->password_size > 0) {
6654  if (*len < object->password_size) {
6655  /* Not enough data. */
6656  goto error;
6657  }
6658  memcpy(object->password, *buf, object->password_size);
6659  *buf += object->password_size;
6660  *len -= object->password_size;
6661  }
6662  object->password[object->password_size] = '\0';
6663 
6664  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6665  goto error;
6666  }
6667 
6668  object = NULL;
6669  point_index++;
6670  }
6671 
6672  return 1;
6673 error:
6674  if (object != NULL) {
6675  SCFree(object);
6676  }
6677 
6678  return 0;
6679 }
6680 
6681 static int DNP3DecodeObjectG70V3(const uint8_t **buf, uint32_t *len,
6682  uint8_t prefix_code, uint32_t start, uint32_t count,
6683  DNP3PointList *points)
6684 {
6685  DNP3ObjectG70V3 *object = NULL;
6686  uint32_t prefix = 0;
6687  uint32_t point_index = start;
6688 
6689  while (count--) {
6690 
6691  object = SCCalloc(1, sizeof(*object));
6692  if (unlikely(object == NULL)) {
6693  goto error;
6694  }
6695 
6696  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6697  goto error;
6698  }
6699 
6700  if (!DNP3ReadUint16(buf, len, &object->filename_offset)) {
6701  goto error;
6702  }
6703  if (!DNP3ReadUint16(buf, len, &object->filename_size)) {
6704  goto error;
6705  }
6706  if (!DNP3ReadUint48(buf, len, &object->created)) {
6707  goto error;
6708  }
6709  if (!DNP3ReadUint16(buf, len, &object->permissions)) {
6710  goto error;
6711  }
6712  if (!DNP3ReadUint32(buf, len, &object->authentication_key)) {
6713  goto error;
6714  }
6715  if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6716  goto error;
6717  }
6718  if (!DNP3ReadUint16(buf, len, &object->operational_mode)) {
6719  goto error;
6720  }
6721  if (!DNP3ReadUint16(buf, len, &object->maximum_block_size)) {
6722  goto error;
6723  }
6724  if (!DNP3ReadUint16(buf, len, &object->request_id)) {
6725  goto error;
6726  }
6727  if (object->filename_size > 0) {
6728  if (*len < object->filename_size) {
6729  /* Not enough data. */
6730  goto error;
6731  }
6732  memcpy(object->filename, *buf, object->filename_size);
6733  *buf += object->filename_size;
6734  *len -= object->filename_size;
6735  }
6736  object->filename[object->filename_size] = '\0';
6737 
6738  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6739  goto error;
6740  }
6741 
6742  object = NULL;
6743  point_index++;
6744  }
6745 
6746  return 1;
6747 error:
6748  if (object != NULL) {
6749  SCFree(object);
6750  }
6751 
6752  return 0;
6753 }
6754 
6755 static int DNP3DecodeObjectG70V4(const uint8_t **buf, uint32_t *len,
6756  uint8_t prefix_code, uint32_t start, uint32_t count,
6757  DNP3PointList *points)
6758 {
6759  DNP3ObjectG70V4 *object = NULL;
6760  uint32_t prefix = 0;
6761  uint32_t point_index = start;
6762  uint32_t offset;
6763 
6764  if (!DNP3PrefixIsSize(prefix_code)) {
6765  goto error;
6766  }
6767 
6768  while (count--) {
6769 
6770  object = SCCalloc(1, sizeof(*object));
6771  if (unlikely(object == NULL)) {
6772  goto error;
6773  }
6774 
6775  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6776  goto error;
6777  }
6778 
6779  offset = *len;
6780 
6781  if (!DNP3ReadUint32(buf, len, &object->file_handle)) {
6782  goto error;
6783  }
6784  if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6785  goto error;
6786  }
6787  if (!DNP3ReadUint16(buf, len, &object->maximum_block_size)) {
6788  goto error;
6789  }
6790  if (!DNP3ReadUint16(buf, len, &object->request_id)) {
6791  goto error;
6792  }
6793  if (!DNP3ReadUint8(buf, len, &object->status_code)) {
6794  goto error;
6795  }
6796  object->optional_text_len = prefix - (offset - *len);
6797  if (object->optional_text_len > 0) {
6798  if (*len < object->optional_text_len) {
6799  /* Not enough data. */
6800  goto error;
6801  }
6802  memcpy(object->optional_text, *buf, object->optional_text_len);
6803  *buf += object->optional_text_len;
6804  *len -= object->optional_text_len;
6805  }
6806  object->optional_text[object->optional_text_len] = '\0';
6807 
6808  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6809  goto error;
6810  }
6811 
6812  object = NULL;
6813  point_index++;
6814  }
6815 
6816  return 1;
6817 error:
6818  if (object != NULL) {
6819  SCFree(object);
6820  }
6821 
6822  return 0;
6823 }
6824 
6825 static int DNP3DecodeObjectG70V5(const uint8_t **buf, uint32_t *len,
6826  uint8_t prefix_code, uint32_t start, uint32_t count,
6827  DNP3PointList *points)
6828 {
6829  DNP3ObjectG70V5 *object = NULL;
6830  uint32_t prefix = 0;
6831  uint32_t point_index = start;
6832  uint32_t offset;
6833 
6834  if (!DNP3PrefixIsSize(prefix_code)) {
6835  goto error;
6836  }
6837 
6838  while (count--) {
6839 
6840  object = SCCalloc(1, sizeof(*object));
6841  if (unlikely(object == NULL)) {
6842  goto error;
6843  }
6844 
6845  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6846  goto error;
6847  }
6848 
6849  offset = *len;
6850 
6851  if (!DNP3ReadUint32(buf, len, &object->file_handle)) {
6852  goto error;
6853  }
6854  if (!DNP3ReadUint32(buf, len, &object->block_number)) {
6855  goto error;
6856  }
6857  object->file_data_len = prefix - (offset - *len);
6858  if (object->file_data_len > 0) {
6859  if (*len < object->file_data_len) {
6860  /* Not enough data. */
6861  goto error;
6862  }
6863  memcpy(object->file_data, *buf, object->file_data_len);
6864  *buf += object->file_data_len;
6865  *len -= object->file_data_len;
6866  }
6867  object->file_data[object->file_data_len] = '\0';
6868 
6869  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6870  goto error;
6871  }
6872 
6873  object = NULL;
6874  point_index++;
6875  }
6876 
6877  return 1;
6878 error:
6879  if (object != NULL) {
6880  SCFree(object);
6881  }
6882 
6883  return 0;
6884 }
6885 
6886 static int DNP3DecodeObjectG70V6(const uint8_t **buf, uint32_t *len,
6887  uint8_t prefix_code, uint32_t start, uint32_t count,
6888  DNP3PointList *points)
6889 {
6890  DNP3ObjectG70V6 *object = NULL;
6891  uint32_t prefix = 0;
6892  uint32_t point_index = start;
6893  uint32_t offset;
6894 
6895  if (!DNP3PrefixIsSize(prefix_code)) {
6896  goto error;
6897  }
6898 
6899  while (count--) {
6900 
6901  object = SCCalloc(1, sizeof(*object));
6902  if (unlikely(object == NULL)) {
6903  goto error;
6904  }
6905 
6906  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6907  goto error;
6908  }
6909 
6910  offset = *len;
6911 
6912  if (!DNP3ReadUint32(buf, len, &object->file_handle)) {
6913  goto error;
6914  }
6915  if (!DNP3ReadUint32(buf, len, &object->block_number)) {
6916  goto error;
6917  }
6918  if (!DNP3ReadUint8(buf, len, &object->status_code)) {
6919  goto error;
6920  }
6921  object->optional_text_len = prefix - (offset - *len);
6922  if (object->optional_text_len > 0) {
6923  if (*len < object->optional_text_len) {
6924  /* Not enough data. */
6925  goto error;
6926  }
6927  memcpy(object->optional_text, *buf, object->optional_text_len);
6928  *buf += object->optional_text_len;
6929  *len -= object->optional_text_len;
6930  }
6931  object->optional_text[object->optional_text_len] = '\0';
6932 
6933  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
6934  goto error;
6935  }
6936 
6937  object = NULL;
6938  point_index++;
6939  }
6940 
6941  return 1;
6942 error:
6943  if (object != NULL) {
6944  SCFree(object);
6945  }
6946 
6947  return 0;
6948 }
6949 
6950 static int DNP3DecodeObjectG70V7(const uint8_t **buf, uint32_t *len,
6951  uint8_t prefix_code, uint32_t start, uint32_t count,
6952  DNP3PointList *points)
6953 {
6954  DNP3ObjectG70V7 *object = NULL;
6955  uint32_t prefix = 0;
6956  uint32_t point_index = start;
6957 
6958  while (count--) {
6959 
6960  object = SCCalloc(1, sizeof(*object));
6961  if (unlikely(object == NULL)) {
6962  goto error;
6963  }
6964 
6965  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
6966  goto error;
6967  }
6968 
6969  if (!DNP3ReadUint16(buf, len, &object->filename_offset)) {
6970  goto error;
6971  }
6972  if (!DNP3ReadUint16(buf, len, &object->filename_size)) {
6973  goto error;
6974  }
6975  if (!DNP3ReadUint16(buf, len, &object->file_type)) {
6976  goto error;
6977  }
6978  if (!DNP3ReadUint32(buf, len, &object->file_size)) {
6979  goto error;
6980  }
6981  if (!DNP3ReadUint48(buf, len, &object->created_timestamp)) {
6982  goto error;
6983  }
6984  if (!DNP3ReadUint16(buf, len, &object->permissions)) {
6985  goto error;
6986  }
6987  if (!DNP3ReadUint16(buf, len, &object->request_id)) {
6988  goto error;
6989  }
6990  if (object->filename_size > 0) {
6991  if (*len < object->filename_size) {
6992  /* Not enough data. */
6993  goto error;
6994  }
6995  memcpy(object->filename, *buf, object->filename_size);
6996  *buf += object->filename_size;
6997  *len -= object->filename_size;
6998  }
6999  object->filename[object->filename_size] = '\0';
7000 
7001  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7002  goto error;
7003  }
7004 
7005  object = NULL;
7006  point_index++;
7007  }
7008 
7009  return 1;
7010 error:
7011  if (object != NULL) {
7012  SCFree(object);
7013  }
7014 
7015  return 0;
7016 }
7017 
7018 static int DNP3DecodeObjectG70V8(const uint8_t **buf, uint32_t *len,
7019  uint8_t prefix_code, uint32_t start, uint32_t count,
7020  DNP3PointList *points)
7021 {
7022  DNP3ObjectG70V8 *object = NULL;
7023  uint32_t prefix = 0;
7024  uint32_t point_index = start;
7025  uint32_t offset;
7026 
7027  if (prefix_code != 5) {
7028  goto error;
7029  }
7030 
7031  while (count--) {
7032 
7033  object = SCCalloc(1, sizeof(*object));
7034  if (unlikely(object == NULL)) {
7035  goto error;
7036  }
7037 
7038  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7039  goto error;
7040  }
7041 
7042  offset = *len;
7043 
7044  object->file_specification_len = prefix - (offset - *len);
7045  if (object->file_specification_len > 0) {
7046  if (*len < object->file_specification_len) {
7047  /* Not enough data. */
7048  goto error;
7049  }
7050  memcpy(object->file_specification, *buf, object->file_specification_len);
7051  *buf += object->file_specification_len;
7052  *len -= object->file_specification_len;
7053  }
7054  object->file_specification[object->file_specification_len] = '\0';
7055 
7056  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7057  goto error;
7058  }
7059 
7060  object = NULL;
7061  point_index++;
7062  }
7063 
7064  return 1;
7065 error:
7066  if (object != NULL) {
7067  SCFree(object);
7068  }
7069 
7070  return 0;
7071 }
7072 
7073 static int DNP3DecodeObjectG80V1(const uint8_t **buf, uint32_t *len,
7074  uint8_t prefix_code, uint32_t start, uint32_t count,
7075  DNP3PointList *points)
7076 {
7077  DNP3ObjectG80V1 *object = NULL;
7078  int bytes = (count / 8) + 1;
7079  uint32_t prefix = 0;
7080  int point_index = start;
7081 
7082  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7083  goto error;
7084  }
7085 
7086  for (int i = 0; i < bytes; i++) {
7087 
7088  uint8_t octet;
7089 
7090  if (!DNP3ReadUint8(buf, len, &octet)) {
7091  goto error;
7092  }
7093 
7094  for (int j = 0; j < 8 && count; j = j + 1) {
7095 
7096  object = SCCalloc(1, sizeof(*object));
7097  if (unlikely(object == NULL)) {
7098  goto error;
7099  }
7100 
7101  object->state = (octet >> j) & 0x1;
7102 
7103  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7104  goto error;
7105  }
7106 
7107  object = NULL;
7108  count--;
7109  point_index++;
7110  }
7111 
7112  }
7113 
7114  return 1;
7115 error:
7116  if (object != NULL) {
7117  SCFree(object);
7118  }
7119  return 0;
7120 }
7121 
7122 static int DNP3DecodeObjectG81V1(const uint8_t **buf, uint32_t *len,
7123  uint8_t prefix_code, uint32_t start, uint32_t count,
7124  DNP3PointList *points)
7125 {
7126  DNP3ObjectG81V1 *object = NULL;
7127  uint32_t prefix = 0;
7128  uint32_t point_index = start;
7129 
7130  while (count--) {
7131 
7132  object = SCCalloc(1, sizeof(*object));
7133  if (unlikely(object == NULL)) {
7134  goto error;
7135  }
7136 
7137  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7138  goto error;
7139  }
7140 
7141  {
7142  uint8_t octet;
7143  if (!DNP3ReadUint8(buf, len, &octet)) {
7144  goto error;
7145  }
7146  object->fill_percentage = (octet >> 0) & 0x7f;
7147  object->overflow_state = (octet >> 7) & 0x1;
7148  }
7149  if (!DNP3ReadUint8(buf, len, &object->group)) {
7150  goto error;
7151  }
7152  if (!DNP3ReadUint8(buf, len, &object->variation)) {
7153  goto error;
7154  }
7155 
7156  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7157  goto error;
7158  }
7159 
7160  object = NULL;
7161  point_index++;
7162  }
7163 
7164  return 1;
7165 error:
7166  if (object != NULL) {
7167  SCFree(object);
7168  }
7169 
7170  return 0;
7171 }
7172 
7173 static int DNP3DecodeObjectG83V1(const uint8_t **buf, uint32_t *len,
7174  uint8_t prefix_code, uint32_t start, uint32_t count,
7175  DNP3PointList *points)
7176 {
7177  DNP3ObjectG83V1 *object = NULL;
7178  uint32_t prefix = 0;
7179  uint32_t point_index = start;
7180 
7181  while (count--) {
7182 
7183  object = SCCalloc(1, sizeof(*object));
7184  if (unlikely(object == NULL)) {
7185  goto error;
7186  }
7187 
7188  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7189  goto error;
7190  }
7191 
7192  if (*len < 4) {
7193  goto error;
7194  }
7195  memcpy(object->vendor_code, *buf, 4);
7196  object->vendor_code[4] = '\0';
7197  *buf += 4;
7198  *len -= 4;
7199  if (!DNP3ReadUint16(buf, len, &object->object_id)) {
7200  goto error;
7201  }
7202  if (!DNP3ReadUint16(buf, len, &object->length)) {
7203  goto error;
7204  }
7205  if (object->length > 0) {
7206  if (*len < object->length) {
7207  /* Not enough data. */
7208  goto error;
7209  }
7210  object->data_objects = SCCalloc(1, object->length);
7211  if (unlikely(object->data_objects == NULL)) {
7212  goto error;
7213  }
7214  memcpy(object->data_objects, *buf, object->length);
7215  *buf += object->length;
7216  *len -= object->length;
7217  }
7218 
7219  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7220  goto error;
7221  }
7222 
7223  object = NULL;
7224  point_index++;
7225  }
7226 
7227  return 1;
7228 error:
7229  if (object != NULL) {
7230  SCFree(object);
7231  }
7232 
7233  return 0;
7234 }
7235 
7236 static int DNP3DecodeObjectG86V2(const uint8_t **buf, uint32_t *len,
7237  uint8_t prefix_code, uint32_t start, uint32_t count,
7238  DNP3PointList *points)
7239 {
7240  DNP3ObjectG86V2 *object = NULL;
7241  uint32_t prefix = 0;
7242  uint32_t point_index = start;
7243 
7244  while (count--) {
7245 
7246  object = SCCalloc(1, sizeof(*object));
7247  if (unlikely(object == NULL)) {
7248  goto error;
7249  }
7250 
7251  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7252  goto error;
7253  }
7254 
7255  {
7256  uint8_t octet;
7257  if (!DNP3ReadUint8(buf, len, &octet)) {
7258  goto error;
7259  }
7260  object->rd = (octet >> 0) & 0x1;
7261  object->wr = (octet >> 1) & 0x1;
7262  object->st = (octet >> 2) & 0x1;
7263  object->ev = (octet >> 3) & 0x1;
7264  object->df = (octet >> 4) & 0x1;
7265  object->padding0 = (octet >> 5) & 0x1;
7266  object->padding1 = (octet >> 6) & 0x1;
7267  object->padding2 = (octet >> 7) & 0x1;
7268  }
7269 
7270  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7271  goto error;
7272  }
7273 
7274  object = NULL;
7275  point_index++;
7276  }
7277 
7278  return 1;
7279 error:
7280  if (object != NULL) {
7281  SCFree(object);
7282  }
7283 
7284  return 0;
7285 }
7286 
7287 static int DNP3DecodeObjectG102V1(const uint8_t **buf, uint32_t *len,
7288  uint8_t prefix_code, uint32_t start, uint32_t count,
7289  DNP3PointList *points)
7290 {
7291  DNP3ObjectG102V1 *object = NULL;
7292  uint32_t prefix = 0;
7293  uint32_t point_index = start;
7294 
7295  while (count--) {
7296 
7297  object = SCCalloc(1, sizeof(*object));
7298  if (unlikely(object == NULL)) {
7299  goto error;
7300  }
7301 
7302  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7303  goto error;
7304  }
7305 
7306  if (!DNP3ReadUint8(buf, len, &object->value)) {
7307  goto error;
7308  }
7309 
7310  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7311  goto error;
7312  }
7313 
7314  object = NULL;
7315  point_index++;
7316  }
7317 
7318  return 1;
7319 error:
7320  if (object != NULL) {
7321  SCFree(object);
7322  }
7323 
7324  return 0;
7325 }
7326 
7327 static int DNP3DecodeObjectG120V1(const uint8_t **buf, uint32_t *len,
7328  uint8_t prefix_code, uint32_t start, uint32_t count,
7329  DNP3PointList *points)
7330 {
7331  DNP3ObjectG120V1 *object = NULL;
7332  uint32_t prefix = 0;
7333  uint32_t point_index = start;
7334  uint32_t offset;
7335 
7336  if (prefix_code != 5) {
7337  goto error;
7338  }
7339 
7340  while (count--) {
7341 
7342  object = SCCalloc(1, sizeof(*object));
7343  if (unlikely(object == NULL)) {
7344  goto error;
7345  }
7346 
7347  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7348  goto error;
7349  }
7350 
7351  offset = *len;
7352 
7353  if (!DNP3ReadUint32(buf, len, &object->csq)) {
7354  goto error;
7355  }
7356  if (!DNP3ReadUint16(buf, len, &object->usr)) {
7357  goto error;
7358  }
7359  if (!DNP3ReadUint8(buf, len, &object->mal)) {
7360  goto error;
7361  }
7362  if (!DNP3ReadUint8(buf, len, &object->reason)) {
7363  goto error;
7364  }
7365  object->challenge_data_len = prefix - (offset - *len);
7366  if (object->challenge_data_len > 0) {
7367  if (*len < object->challenge_data_len) {
7368  /* Not enough data. */
7369  goto error;
7370  }
7371  object->challenge_data = SCCalloc(1, object->challenge_data_len);
7372  if (unlikely(object->challenge_data == NULL)) {
7373  goto error;
7374  }
7375  memcpy(object->challenge_data, *buf, object->challenge_data_len);
7376  *buf += object->challenge_data_len;
7377  *len -= object->challenge_data_len;
7378  }
7379 
7380  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7381  goto error;
7382  }
7383 
7384  object = NULL;
7385  point_index++;
7386  }
7387 
7388  return 1;
7389 error:
7390  if (object != NULL) {
7391  SCFree(object);
7392  }
7393 
7394  return 0;
7395 }
7396 
7397 static int DNP3DecodeObjectG120V2(const uint8_t **buf, uint32_t *len,
7398  uint8_t prefix_code, uint32_t start, uint32_t count,
7399  DNP3PointList *points)
7400 {
7401  DNP3ObjectG120V2 *object = NULL;
7402  uint32_t prefix = 0;
7403  uint32_t point_index = start;
7404  uint32_t offset;
7405 
7406  if (prefix_code != 5) {
7407  goto error;
7408  }
7409 
7410  while (count--) {
7411 
7412  object = SCCalloc(1, sizeof(*object));
7413  if (unlikely(object == NULL)) {
7414  goto error;
7415  }
7416 
7417  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7418  goto error;
7419  }
7420 
7421  offset = *len;
7422 
7423  if (!DNP3ReadUint32(buf, len, &object->csq)) {
7424  goto error;
7425  }
7426  if (!DNP3ReadUint16(buf, len, &object->usr)) {
7427  goto error;
7428  }
7429  object->mac_value_len = prefix - (offset - *len);
7430  if (object->mac_value_len > 0) {
7431  if (*len < object->mac_value_len) {
7432  /* Not enough data. */
7433  goto error;
7434  }
7435  object->mac_value = SCCalloc(1, object->mac_value_len);
7436  if (unlikely(object->mac_value == NULL)) {
7437  goto error;
7438  }
7439  memcpy(object->mac_value, *buf, object->mac_value_len);
7440  *buf += object->mac_value_len;
7441  *len -= object->mac_value_len;
7442  }
7443 
7444  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7445  goto error;
7446  }
7447 
7448  object = NULL;
7449  point_index++;
7450  }
7451 
7452  return 1;
7453 error:
7454  if (object != NULL) {
7455  SCFree(object);
7456  }
7457 
7458  return 0;
7459 }
7460 
7461 static int DNP3DecodeObjectG120V3(const uint8_t **buf, uint32_t *len,
7462  uint8_t prefix_code, uint32_t start, uint32_t count,
7463  DNP3PointList *points)
7464 {
7465  DNP3ObjectG120V3 *object = NULL;
7466  uint32_t prefix = 0;
7467  uint32_t point_index = start;
7468 
7469  while (count--) {
7470 
7471  object = SCCalloc(1, sizeof(*object));
7472  if (unlikely(object == NULL)) {
7473  goto error;
7474  }
7475 
7476  if (!DNP3ReadPrefix(buf, len, prefix_code, &prefix)) {
7477  goto error;
7478  }
7479 
7480  if (!DNP3ReadUint32(buf, len, &object->csq)) {
7481  goto error;
7482  }
7483  if (!DNP3ReadUint16(buf, len, &object->user_number)) {
7484  goto error;
7485  }
7486 
7487  if (!DNP3AddPoint(points, object, point_index, prefix_code, prefix)) {
7488  goto error;
7489  }
7490 
7491  object = NULL;
7492  point_index++;
7493  }
7494 
7495  return 1;
7496 error:
7497  if (object != NULL) {
7498  SCFree(object);
7499  }
7500 
7501  return 0;
7502 }
7503 
7504 static int DNP3DecodeObjectG120V4(const uint8_t **buf, uint32_t *len,
7505  uint8_t prefix_code, uint32_t start, uint32_t count,
7506  DNP3PointList *points)
7507 {
7508  DNP3ObjectG120V4 *object = NULL;
7509  uint32_t prefix = 0;
7510