forked from usi-systems/nocc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgotthard_dissector.lua
More file actions
33 lines (32 loc) · 1.62 KB
/
gotthard_dissector.lua
File metadata and controls
33 lines (32 loc) · 1.62 KB
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
33
-- trivial protocol example
-- declare our protocol
gotthard_proto = Proto("gotthard_proto","Gotthard Protocol")
local f_udp_dstport = Field.new("udp.dstport")
-- create a function to dissect it
function gotthard_proto.dissector(buffer,pinfo,tree)
--if f_udp_dstport() and f_udp_dstport().value == 9999 then
local hdrSize = 13
local valueSize = 128
local opSize = valueSize + 5
local opNames = {'NOP', 'READ', 'WRITE', 'VALUE', 'UPDATED'}
local msgType = buffer(0,1):bitfield(0,1) == 0 and "Request" or "Response"
pinfo.cols.protocol = "Gotthard " .. msgType
local subtree = tree:add(gotthard_proto,buffer(),"Gotthard " .. msgType)
subtree:add(buffer(0,1),"from_switch: " .. buffer(0,1):bitfield(1,1))
subtree:add(buffer(1,4),"cl_id: " .. buffer(1,4):uint())
subtree:add(buffer(5,4),"req_id: " .. buffer(5,4):uint())
subtree:add(buffer(9,1),"frag_seq: " .. buffer(9,1):uint())
subtree:add(buffer(10,1),"frag_cnt: " .. buffer(10,1):uint())
subtree:add(buffer(11,1),"status: " .. buffer(11,1):uint())
local op_cnt = buffer(12,1):uint()
subtree:add(buffer(12,1),"op_cnt: " .. op_cnt)
for i = 0, op_cnt-1 do
local op_type = buffer(hdrSize+(i*opSize),1):uint()
subtree:add(buffer(hdrSize+(i*opSize),1),"op_type: " .. opNames[op_type+1])
subtree:add(buffer(hdrSize+(i*opSize)+1,4),"op_key: " .. buffer(hdrSize+(i*opSize)+1,4):uint())
subtree:add(buffer(hdrSize+(i*opSize)+5,valueSize),"op_val: " .. buffer(hdrSize+(i*opSize)+5,valueSize))
end
end
-- load the udp.port table
udp_dst_table = DissectorTable.get("udp.port")
udp_dst_table:add(9999,gotthard_proto)