Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lppb.lua
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
local lppb = Proto("lppb","Length Prefixed Protocol Buffers");

len_F = ProtoField.string("lppb.len","Length")
lppb.fields = {len_F}

lppb.prefs.port = Pref.uint("TCP Port:", 0, "")
lppb.prefs.schema = Pref.string("Schema:", "", "E.g. MY.PROTOBUF.MESSAGE")
lppb.prefs.prefix_size = Pref.uint("Prefix size (bytes):", 4, "")
lppb.prefs.prefix_endianess = Pref.bool("Little Endian ?", true, "Check this to decode the length prefix as if it were encoded as Little Endian")

function get_message_len(tvb, pinfo, tree)
local len = tvb:range(0, lppb.prefs.prefix_size):uint()
return len + lppb.prefs.prefix_size
local length_buf = tvb:range(0, lppb.prefs.prefix_size)
local len = 0
if lppb.prefs.prefix_endianess then
len = Struct.unpack('<I', length_buf:string())
else
len = length_buf:uint()
end
local result = len + lppb.prefs.prefix_size
return result
end

function dissect_message(tvb, pinfo, tree)
Expand Down