Wireshark-dev: [Wireshark-dev] Convert tap userdata to hex string

From: Peter Smith <psmith135@xxxxxxxxx>
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.