/
ping.lua
32 lines (28 loc) · 1010 Bytes
/
ping.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local bin = require "plc52.bin"
local Reader = require("lightning-dissector.utils").Reader
local OrderedDict = require("lightning-dissector.utils").OrderedDict
local f = require("lightning-dissector.constants").fields.payload.deserialized
function deserialize(payload)
local reader = Reader:new(payload)
local packed_num_pong_bytes = reader:read(2)
local num_pong_bytes = string.unpack(">I2", packed_num_pong_bytes)
local packed_byteslen = reader:read(2)
local byteslen = string.unpack(">I2", packed_byteslen)
local packed_ignored = reader:read(byteslen)
return OrderedDict:new(
"num_pong_bytes", OrderedDict:new(
f.num_pong_bytes.raw, bin.stohex(packed_num_pong_bytes),
f.num_pong_bytes.deserialized, num_pong_bytes
),
"byteslen", OrderedDict:new(
f.byteslen.raw, bin.stohex(packed_byteslen),
f.byteslen.deserialized, byteslen
),
f.ignored, bin.stohex(packed_ignored)
)
end
return {
number = 18,
name = "ping",
deserialize = deserialize
}