udp packet reassembly and dissection with lua

asked 2019-12-03 14:51:39 +0000

BMWE gravatar image

updated 2019-12-03 14:52:31 +0000

Hello,

I'm trying to perform udp packet reassembly. I'm using following as example/guide. My code looks like that

local deligator = Proto("ABC","abc")
function deligator.init()
    partialBuffer = {}
end

function locals.proto_abc.dissector(buffer, pinfo, tree)
    --do something--
    local completeBuffer=ByteArray.new()

    print("-------------------------")
    print("Packet # " .. pinfo.number)

    if (condition to identify some data from previous packet) then
        print("BINGO")
        print("data from previous packet completeBuffer.len() = " .. completeBuffer.len())
        print("data from previous packet partialBuffer.len() = " .. partialBuffer.len())

        --concatinate previous packet data with current packet data and dessect
    else
        -- do something--
        if (condition that current packet shall contain extradata in next packet) then
            local d = buffer(some offset)
            local bytes = d:bytes()
            partialBuffer = buffer:range(x,y)   -- x,y are some numbers (Ive checked and they are correct)
            completeBuffer = completeBuffer .. bytes
            print("completeBuffer.len() = " .. completeBuffer.len())
            print("partialBuffer.len() = " .. partialBuffer.len())
        else
            --dissect the packet
        end
    end
end

When executing it, I'm getting error expired tvb on the print("data from previous packet completeBuffer.len() = " .. completeBuffer.len()) and on print("data from previous packet completeBuffer.len() = " .. completeBuffer.len()) i'm getting value of 0.

Please suggest what I'm doing wrong.

Regards

edit retag flag offensive close merge delete