summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wireshark/hbbp_dissector.lua26
1 files changed, 12 insertions, 14 deletions
diff --git a/wireshark/hbbp_dissector.lua b/wireshark/hbbp_dissector.lua
index 73316f5..ca58d35 100644
--- a/wireshark/hbbp_dissector.lua
+++ b/wireshark/hbbp_dissector.lua
@@ -1,24 +1,22 @@
-hbbp_proto = Proto("hbbp","Home Brew Broadcast Protocol")
+hbbp_proto = Proto("hbbp", "Home Brew Broadcast Protocol")
+
-- create a function to dissect it
-function hbbp_proto.dissector(buffer,pinfo,tree)
+function hbbp_proto.dissector(buffer, pinfo, tree)
pinfo.cols.protocol = "HBBP"
- local subtree = tree:add(hbbp_proto,buffer(),"HBBP Data")
-
+ local subtree = tree:add(hbbp_proto, buffer(), "HBBP Data")
+
+ -- find the \0 that seperates task and payload
local i = 0
local b = buffer():bytes()
-
- while (i<b:len() and b:get_index(i)~=0) do
+ while i < b:len() and b:get_index(i) ~= 0 do
i = i + 1
end
- if i==0 then
- return (nil)
- end
- subtree:add(buffer(0,i),"Task: " .. buffer(0,i):string())
+
+ subtree:add(buffer(0, i), "Task: " .. buffer(0, i):string())
if b:get_index(i) == 0 then
- subtree:add(buffer(i+1),"Payload: [Length " .. buffer:len()-i .. "]")
+ subtree:add(buffer(i + 1),"Payload [Length " .. buffer:len() - i .. "]")
end
end
--- load the udp.port table
-udp_table = DissectorTable.get("udp.port")
+
-- register our protocol to handle udp port 4950
-udp_table:add(4950,hbbp_proto) \ No newline at end of file
+DissectorTable.get("udp.port"):add(4950, hbbp_proto) \ No newline at end of file
contact: Jan Huwald // Impressum