Skip to content

Commit

Permalink
decode and encode unknown (raw), but typed data
Browse files Browse the repository at this point in the history
  • Loading branch information
alandekok committed Nov 11, 2024
1 parent aeae2ff commit 2143e30
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/tests/unit/protocols/cbor/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 2143e30

Please sign in to comment.