Wireshark mailing list archives

Convert tap userdata to hex string


From: Peter Smith <psmith135 () gmail com>
Date: Sun, 21 Feb 2010 11:05:29 +0200

Hi,

I am trying to use Lua script to extract reassembled packet data in
wireshark. I have the required packet data stored in a variable with
userdata type. Now I need to print that data as a hex string to pass it over
stdout to another program.
Could someone please help me how to write a lua function to print out a
userdata variable as a hex string?

I have the following code to get the reassembled WSP payload out of packet
in wireshark

===================================
wsp_extractor = Field.new("wsp")
tap = Listener.new(nil,"wsp")
function tap.packet(pinfo,tvb)
local wsp_pdu =  wsp_extractor()
if wsp_pdu then
-- print(tostring(wsp_pdu))
-- print ("PDU_LEN: " .. wsp_pdu.label)
end
end
===================================

Using either of the print statements results in error:
[string "wsp.lua"]:20: field cannot be represented as string because it may
contain invalid characters

Thanks.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev () wireshark org>
Archives:    http://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request () wireshark org?subject=unsubscribe

Current thread: