First time here? Check out the FAQ!
THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

frame.len not working as expected in Lua

I want to use the frame.len to further dissect the packet. I used the following logic and it failed:

   frame_len_f     = Field.new("frame.len")
   local frame_len = frame_len_f()
   if frame_len == 62 then 
        local data_data   = data_data_f()
        local s_data_data = tostring(data_data)
        subtree:add(data_data_F,s_data_data)
   end

However, if I convert frame.len to string and compare to "62", it works:

   frame_len_f     = Field.new("frame.len")
   local frame_len = frame_len_f()
   local s_frame_len = tostring(frame_len)
   if s_frame_len == "62" then 
        local data_data   = data_data_f()
        local s_data_data = tostring(data_data)
        subtree:add(data_data_F,s_data_data)
   end

Can anyone explain what I did wrong in the first case. Thanks

derekyu's avatar
3
derekyu
asked 2017-12-20 03:45:45 +0000
Christian_R's avatar
2.1k
Christian_R
updated 2017-12-21 10:40:29 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

I think you want:

local frame_len = frame_len_f().value

Ref: Section 11.2.2.10. of the Wireshark Developers Guide.

cmaynard's avatar
11.1k
cmaynard
answered 2017-12-20 15:30:35 +0000
edit flag offensive 0 remove flag delete link

Comments

Thanks. That works. According to https://www.wireshark.org/docs/dfref/..., frame.len is an unsigned integer. It seems using Field.new() to obtain the value changes it to a Fieldinfo object. Is there a easy way to get the frame.len?

derekyu's avatar derekyu (2017-12-20 19:13:22 +0000) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer