#  Test vectors for BFD Packets
#
#  Copyright 2023 Network RADIUS SAS (legal@networkradius.com)
#
proto bfd
proto-dictionary bfd
fuzzer-out bfd

#
#  A basic BFD packet.
#
encode-proto Packet = { version = 1, diagnostic = none, state = up, poll = false, final = false, control-plane-independent = false, auth-present = false, demand = false, multipoint = false, detect-multi = 3, my-discriminator = 0xdeadbeef, your-discriminator = 0x21126809, desired-min-tx-interval = 31us, required-min-tx-interval = 127us, required-min-echo-interval = 255us }
match 20 c0 03 18 de ad be ef 21 12 68 09 00 00 00 1f 00 00 00 7f 00 00 00 ff

decode-proto -
match Packet-Type = ::Up, Packet = { version = 1, diagnostic = ::none, state = ::up, poll = no, final = no, control-plane-independent = no, auth-present = no, demand = no, multipoint = no, detect-multi = 3, length = 24, my-discriminator = 3735928559, your-discriminator = 554854409, desired-min-tx-interval = 31, required-min-tx-interval = 127, required-min-echo-interval = 255 }


#
#  And with additional data.
#
#  The BFD packet is exactly the same, but we also have a 3 octet string "foo", which is encoded via the internal dictionary, after the packet.
#
encode-proto Packet = { version = 1, diagnostic = none, state = up, poll = false, final = false, control-plane-independent = false, auth-present = false, demand = false, multipoint = false, detect-multi = 3, my-discriminator = 0xdeadbeef, your-discriminator = 0x21126809, desired-min-tx-interval = 31us, required-min-tx-interval = 127us, required-min-echo-interval = 255us }, Additional-Data = { More-Data = "foo" }
match 20 c0 03 18 de ad be ef 21 12 68 09 00 00 00 1f 00 00 00 7f 00 00 00 ff 00 01 03 66 6f 6f

decode-proto -
match Packet-Type = ::Up, Packet = { version = 1, diagnostic = ::none, state = ::up, poll = no, final = no, control-plane-independent = no, auth-present = no, demand = no, multipoint = no, detect-multi = 3, length = 24, my-discriminator = 3735928559, your-discriminator = 554854409, desired-min-tx-interval = 31, required-min-tx-interval = 127, required-min-echo-interval = 255 }, Additional-Data = { More-Data = "foo" }

#
#  With authentication type
#
decode-proto 20 c4 03 21 de ad be ef 21 12 68 09 00 00 00 1f 00 00 00 7f 00 00 00 ff 01 0a 0f 00 68 65 6c 6c 6f
match Packet-Type = ::Up, Packet = { version = 1, diagnostic = ::none, state = ::up, poll = no, final = no, control-plane-independent = no, auth-present = yes, demand = no, multipoint = no, detect-multi = 3, length = 33, my-discriminator = 3735928559, your-discriminator = 554854409, desired-min-tx-interval = 31, required-min-tx-interval = 127, required-min-echo-interval = 255, auth-type = ::simple-password, auth-type.simple-password = { key-id = 15, reserved = 0, password = "hello" } }


#
#  @todo - this is wrong!  The auth-type field isn't encoded, likely because of confusion with Auth-Type :(
#
encode-proto Packet-Type = Up, Packet = { version = 1, diagnostic = none, state = up, poll = no, final = no, control-plane-independent = no, auth-present = yes, demand = no, multipoint = no, detect-multi = 3, length = 24, my-discriminator = 3735928559, your-discriminator = 554854409, desired-min-tx-interval = 31, required-min-tx-interval = 127, required-min-echo-interval = 255, auth-type.simple-password = { key-id = 15, reserved = 0, password = "hello" } }
match 20 c4 03 21 de ad be ef 21 12 68 09 00 00 00 1f 00 00 00 7f 00 00 00 ff 00 0a 0f 00 68 65 6c 6c 6f

#
#  Because auth-type=0, is unknown, we don't have any matching child struct for type 0,
#  and the auth-type field is raw.
#
decode-proto -
match Packet-Type = ::Up, Packet = { version = 1, diagnostic = ::none, state = ::up, poll = no, final = no, control-plane-independent = no, auth-present = yes, demand = no, multipoint = no, detect-multi = 3, length = 33, my-discriminator = 3735928559, your-discriminator = 554854409, desired-min-tx-interval = 31, required-min-tx-interval = 127, required-min-echo-interval = 255, auth-type = 0, raw.auth-type.0 = 0x0a0f0068656c6c6f }

encode-proto -
match 20 c4 03 21 de ad be ef 21 12 68 09 00 00 00 1f 00 00 00 7f 00 00 00 ff 00 0a 0f 00 68 65 6c 6c 6f

count
match 19
