2012-10-30 67 views
3

我有一個運行TCP協議上方,並且具有一個以上的TCP數據包流的數據的解剖器。如何在LUA解剖器中重新組裝TCP數據包?

我想在轉換所有內容之前彙編數據,所以我明白我需要tcp_dissect_pdus(),但我找不到它的文檔或示例。

誰能告訴我它或幫助我瞭解如何使用它?

回答

5

沒有爲tcp_dissect_pdus沒有wslua API。但是你可以自己實現它。

如果你想組裝跨越兩個或多個包PDU時,它是相當簡單:

function slicer.dissector(tvb, pinfo, tree) 
    ... 
    local pdu_length = get_pdu_length(...) 
    if pdu_length > tvb:len() then 
     pinfo.desegment_len = pdu_length - tvb:len() 
    else 
     do_dissection(tvb, pifo, tree) 
    end 
    return 
end 

如果你不知道PDU的精確長度,你可以這樣做:

 pinfo.desegment_len = DESEGMENT_ONE_MORE_SEGMENT 

你應閱讀README.developer第2.7節。

+0

感謝您的回答!根據文檔我的解剖只會緩衝後調用 –

+0

包含我把_pinfo.desegment_len_的字節數,但如果F.E.我有一個3890字節的消息大小,解析器在每個數據包中被調用,不僅在它獲得字節量時。你知道爲什麼會這樣嗎? –

+2

從Wireshark 1.99.2開始,有一個用於tcp_dissect_pdus的Lua綁定。 https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Proto.html#lua_fn_dissect_tcp_pdus_tvb__tree__size__func__func___desegment__ –