Coverage Report

Created: 2025-12-31 06:43

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