Skip to content
Permalink
Browse files

added support for BlockFetch

  • Loading branch information...
karknu committed Jul 12, 2019
1 parent 82322b9 commit 0ae9e1f93f1789c2609e007dbded2414cf9c512b
Showing with 23 additions and 9 deletions.
  1. +23 −9 ouroboros-network/wireshark-plugin/ouroboros_network.lua
@@ -15,7 +15,9 @@ local conv_ids = {
[0x0001] = "DeltaQueue Initiator",
[0x8001] = "DeltaQueue Responder",
[0x0002] = "ChainSync Initiator",
[0x8002] = "ChainSync Responder"
[0x8002] = "ChainSync Responder",
[0x0003] = "BlockFetch Initiator",
[0x8003] = "BlockFetch Responder"
}
local on_conversation = ProtoField.uint16("ouroboros.conv", "Conversation", base.HEX, conv_ids, nil, "Conversation ids")

@@ -30,15 +32,27 @@ local chainsync_msg_codes = {
[7] = "MsgDone"
}

local on_chainsync_msg = ProtoField.uint8("ouroboros.msg", "ChainSync Message", base.DEC, chainsync_msg_codes, nil, "ChainSync Message Types")
local on_chainsync_msg = ProtoField.uint8("ouroboros.chainmsg", "ChainSync Message", base.DEC, chainsync_msg_codes, nil, "ChainSync Message Types")

local blockfetch_msg_codes = {
[0] = "MsgRequestRange",
[1] = "MsgClientDone",
[2] = "MsgStartBatch",
[3] = "MsgNoBlocks",
[4] = "MsgBlock",
[5] = "MsgBatchDone"
}

local on_blockfetch_msg = ProtoField.uint8("ouroboros.blockmsg", "BlockFetch Message", base.DEC, blockfetch_msg_codes, nil, "BlockFetch Message Types")

local ON_HDR_LEN = 8

ouroboros.fields = {
on_transmission_time,
on_conversation,
on_length,
on_chainsync_msg
on_chainsync_msg,
on_blockfetch_msg
}

function ouroboros.dissector(tvbuf, pktinfo, root)
@@ -82,17 +96,17 @@ dissectOuroboros = function (tvbuf, pktinfo, root, offset)

local subtree = root:add(ouroboros, tvbuf(), "Ouroboros")
local conv = tvbuf:range(offset + 4, 2)
local convId = conv:uint()
local convId = bit32.band(0x7fff, conv:uint())

subtree:add(on_transmission_time, tvbuf:range(offset, 4))
subtree:add(on_conversation, conv)
subtree:add(on_length, length)

if convId == 2 or convId == 0x8002 then
-- XXX Without completly parsing the CBOR payload we can't be sure that this is
-- the correct message type since a CBOR message may be split into
-- multiple MUX segements.
subtree:add(on_chainsync_msg, tvbuf:range(offset + 9, 1))
-- XXX Without completly parsing the CBOR payload we can't be sure that this is
-- the correct message type since a CBOR message may be split into
-- multiple MUX segements.
if convId == 2 then subtree:add(on_chainsync_msg, tvbuf:range(offset + 9, 1))
elseif convId == 3 then subtree:add(on_blockfetch_msg, tvbuf:range(offset + 9, 1))
end

return ON_HDR_LEN + length

0 comments on commit 0ae9e1f

Please sign in to comment.
You can’t perform that action at this time.