Ask Your Question
0

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

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-07-14 16:56:06 +0000

ng215 gravatar image

To add new data to a table correct you must use the table.insert function . For example:

table.insert(partialBuffer, buffer:range(x,y))

Additional documentation and information: https://www.lua.org/pil/19.2.html

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

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

Seen: 658 times

Last updated: Jul 14 '21