Created
March 7, 2014 20:01
-
-
Save yotommy/9418831 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- trivial protocol example | |
-- inspired by http://wiki.wireshark.org/Lua/Dissectors | |
-- 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 | |
end | |
-- load the tcp.port table | |
tcp_table = DissectorTable.get("tcp.port") | |
-- register our protocol to handle udp port 7777 | |
tcp_table:add(7777,trivial_proto) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment