From 2143e30f38e41eb907e3d36039690124a49451d8 Mon Sep 17 00:00:00 2001 From: "Alan T. DeKok" Date: Mon, 11 Nov 2024 10:32:51 -0500 Subject: [PATCH] decode and encode unknown (raw), but typed data --- src/tests/unit/protocols/cbor/base.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tests/unit/protocols/cbor/base.txt b/src/tests/unit/protocols/cbor/base.txt index b69e7a5e0dd4c..457798b72ba89 100644 --- a/src/tests/unit/protocols/cbor/base.txt +++ b/src/tests/unit/protocols/cbor/base.txt @@ -57,5 +57,20 @@ match 9f a1 18 1a 9f a1 19 19 7f 9f a1 18 ca d9 03 ea a2 01 19 0e 10 28 1a 1d cd decode-pair - match Vendor-Specific = { Nokia-SR = { Dhcp6-Renew-Time = 3600.5 } } +# +# We changed 'ca' to 'ff', which isn't in the Nokia-SR dictionary. +# But because CBOR is typed, we can decode typed data. +# +decode-pair 9f a1 18 1a 9f a1 19 19 7f 9f a1 18 ff d9 03 ea a2 01 19 0e 10 28 1a 1d cd 65 00 ff ff ff +match Vendor-Specific = { Nokia-SR = { raw.255 = 3600.5 } } + +# +# Note that we have to add a cast here :( +# +# Otherwise the "3600.5" is interpreted as a bare word / string. +# +encode-pair Vendor-Specific = { Nokia-SR = { raw.255 = (time_delta) 3600.5 } } +match 9f a1 18 1a 9f a1 19 19 7f 9f a1 18 ff 66 33 36 30 30 2e 35 ff ff ff + count -match 26 +match 30