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