openthread icon indicating copy to clipboard operation
openthread copied to clipboard

[dataset] add `ValidateTlvs()`, helper methods, and unit test

Open abtink opened this issue 1 year ago • 1 comments

This commit enhances dataset handling:

  • Adds ValidateTlvs() which parses and validates all known TLVs within the Dataset and checks for any duplicates.
  • Introduces a set of SetFrom() methods for constructing a Dataset from various types of inputs, e.g., other Dataset, TLV sequences, DatasetInfo structures, bytes read from Message. Now they consistently clear the Dataset before setting it.
  • Adds WriteTlvsFrom() to update a Dataset replacing/appending a set of TLVs.
  • Adds AppendTlvsFrom() to append an already encoded sequence of TLVs without validating/checking the format.
  • Renames Get/SetSize() to Get/SetLength() for consistency.
  • Adds test_dataset.cpp unit test for basic Dataset validation.

abtink avatar Apr 29 '24 18:04 abtink

Size Report of OpenThread

Merging #10111 into main(0c6c2fedadf6516282f4430da89d2b99d551934a).

name branch text data bss total
ot-cli-ftd main 466840 856 66364 534060
#10111 466952 856 66364 534172
+/- +112 0 0 +112
ot-ncp-ftd main 435756 760 61576 498092
#10111 435836 760 61576 498172
+/- +80 0 0 +80
libopenthread-ftd.a main 235928 95 40310 276333
#10111 236136 95 40310 276541
+/- +208 0 0 +208
libopenthread-cli-ftd.a main 57545 0 8075 65620
#10111 57553 0 8075 65628
+/- +8 0 0 +8
libopenthread-ncp-ftd.a main 31863 0 5916 37779
#10111 31863 0 5916 37779
+/- 0 0 0 0
ot-cli-mtd main 364504 760 51220 416484
#10111 364616 760 51220 416596
+/- +112 0 0 +112
ot-ncp-mtd main 347036 760 46448 394244
#10111 347116 760 46448 394324
+/- +80 0 0 +80
libopenthread-mtd.a main 157999 0 25182 183181
#10111 158203 0 25182 183385
+/- +204 0 0 +204
libopenthread-cli-mtd.a main 39787 0 8059 47846
#10111 39787 0 8059 47846
+/- 0 0 0 0
libopenthread-ncp-mtd.a main 24743 0 5916 30659
#10111 24743 0 5916 30659
+/- 0 0 0 0
ot-cli-ftd-br main 549976 864 131212 682052
#10111 550072 864 131212 682148
+/- +96 0 0 +96
libopenthread-ftd-br.a main 324242 100 105134 429476
#10111 324446 100 105134 429680
+/- +204 0 0 +204
libopenthread-cli-ftd-br.a main 71208 0 8099 79307
#10111 71216 0 8099 79315
+/- +8 0 0 +8
ot-rcp main 62248 564 20604 83416
#10111 62248 564 20604 83416
+/- 0 0 0 0
libopenthread-rcp.a main 9542 0 5052 14594
#10111 9542 0 5052 14594
+/- 0 0 0 0
libopenthread-radio.a main 18870 0 214 19084
#10111 18870 0 214 19084
+/- 0 0 0 0

size-report[bot] avatar Apr 29 '24 18:04 size-report[bot]