lua-users home
lua-l archive

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


Steve,

Thanks for your C extension, especially for it's win32 compiled version. It's almost working for me except that it apparently truncates the resulting string to 4 characters. My C skills are almost zero so I can't figure out where the problem is. Could you please take a look into it?
In my lua code I put some print statements for debugging and here is what I get:

=====================================
USERDATA LENGTH: 8706
CONVERTED LENGTH: 4
tshark: Lua: on packet 164 Error During execution of Listener Packet Callback:
[string "wsp.lua"]:7: bad argument #2 to 'format' (number expected, got no value)

... skipped packet summary ...

USERDATA LENGTH: 52044
CONVERTED LENGTH: 4

... skipped packet summary ...

USERDATA LENGTH: 786
CONVERTED LENGTH: 4
tshark: Lua: on packet 591 Error During execution of Listener Packet Callback happened 2 times:
 [string "wsp.lua"]:7: bad argument #2 to 'format' (number expected, got no value)

... skipped packet summary ...

USERDATA LENGTH: 36097
CONVERTED LENGTH: 4
tshark: Lua: on packet 612 Error During execution of Listener Packet Callback happened 4 times:
 [string "wsp.lua"]:7: bad argument #2 to 'format' (number expected, got no value)

... skipped packet summary ...

USERDATA LENGTH: 32302
CONVERTED LENGTH: 4
================================== 

And here is the lua code itself:

=====================================
ud = require "userdata"
function BytesToString(bytes)
  print ("USERDATA LENGTH: " .. bytes.len)
  print ("CONVERTED LENGTH: " .. string.len(ud.as_string(bytes)))
  s = {}
  for i = 1, bytes.len do
    s[i] = string.format("%02X ", string.byte(ud.as_string(bytes), i))
  end
  return concat(s)
end

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(ud.as_string(wsp_pdu))
print(BytesToString(wsp_pdu))
-- print ("PDU_LEN: " .. wsp_pdu.label)
end
end

=====================================

On Sun, Feb 21, 2010 at 12:05 PM, steve donovan <steve.j.donovan@gmail.com> wrote:
On Sun, Feb 21, 2010 at 11:53 AM, steve donovan
> Drop me a line if you have difficulty building this...

Source and dll (built for LfW) available here:

http://mysite.mweb.co.za/residents/sdonovan/lua/userdata.zip