protodef
Version:
A simple yet powerful way to define binary protocols
64 lines • 1.31 kB
JSON
[
{
"type":"switch",
"subtypes":[
{
"description": "container including a switch going to u8, u16 or u32",
"type": ["container",
[
{
"name":"action",
"type":"u8"
},
{
"name":"result",
"type":["switch",
{
"compareTo":"action",
"fields":{
"0":"u8",
"1":"u16",
"2":"u32"
}
}
]
}
]
],
"values":[
{
"description":"u8",
"value":{
"action":0,
"result":3
},
"buffer":["0x00","0x03"]
},
{
"description":"u32",
"value":{
"action":2,
"result":4294966272
},
"buffer":["0x02","0xff","0xff","0xfc","0x00"]
}
]
}
]
},
{
"type":"option",
"subtypes":[
{
"description":"optional u16",
"type":["option","u16"],
"values":[
{
"value":61303,
"buffer":["0x01", "0xef","0x77"]
}
]
}
]
}
]