lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Thanks, guys, for your responses. I spent two days surfing the net to find a working sample but now I see it may be not an easy task. It makes it more difficult for me since I am not a programmer but rather a network engineer with some scripting skills...

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

Could someone please give a function sample that could do the trick? If it requires an extension it would great if it was working in win32.

Thanks.

On Sun, Feb 21, 2010 at 9:59 AM, Vaughan McAlley <ockegheim@gmail.com> wrote:
I agree... strings are an excellent way of getting arbitary data in
and out of Lua. All you probably need to do is pass the address and
length to lua_pushlstring. Lua makes its own copy, so you don't need
to worry about what Lua might do with it.

Vaughan

On 21 February 2010 18:10, steve donovan <steve.j.donovan@gmail.com> wrote:
> On Sat, Feb 20, 2010 at 11:58 PM, Peter Cawley <lua@corsix.org> wrote:
>> functions, etc. To get the contents of a userdata, you need to use the
>> C functions designed specifically for that userdata, which in turn
>> employ the base C API function lua_touserdata to get memory access to
>> the userdata.
>
> An interesting possibility is a small C extension which can work with
> arbitrary userdata as memory buffers, rather like how Alien works with
> buffers.  One could define a userdata-to-string converter, bearing in
> mind that Lua strings can contain embedded nuls and then use one of
> the struct, pack, etc libraries to decode that string.
>