Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
-- trivial protocol example
-- inspired by
-- declare our protocol
trivial_proto = Proto("trivial","Trivial Protocol")
-- create a function to dissect it
function trivial_proto.dissector(buffer,pinfo,tree)
local trivial_pdu_len = 4
pinfo.cols.protocol = "TRIVIAL"
local subtree = tree:add(trivial_proto,buffer(),"Trivial Protocol Data")
subtree:add(buffer(0,2),"The first two bytes: " .. buffer(0,2):uint())
subtree = subtree:add(buffer(2,2),"The next two bytes")
subtree:add(buffer(2,1),"The 3rd byte: " .. buffer(2,1):uint())
subtree:add(buffer(3,1),"The 4th byte: " .. buffer(3,1):uint())
-- return number of bytes consumed so that more trivial PDUs can be discovered
return trivial_pdu_len
-- load the tcp.port table
tcp_table = DissectorTable.get("tcp.port")
-- register our protocol to handle udp port 7777
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.