This is our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

length_octect=tvb_get_guint8(tvb,2)&0x3FF;(last ten bits offset value)

ti = proto_tree_add_text(data_tree, tvb, offset, length_octect, "data");

I used the above function in c for the offset length.How to get the length_octect in lua script

I tried something like this:

local length_octect=(buffer((offset,2) or 0x3FF):unit()

data=subtree:add(F.data,buffer(offset,length_octect))

but it is giving error as: Lua Error: C:\Program Files\Wireshark1\myproto.lua:104: No such 'unit' function/method/field for object type 'TvbRange'

asked 20 Apr '15, 23:22

lakshmi's gravatar image

lakshmi
16669
accept rate: 0%

edited 20 Apr '15, 23:31


You've got typo in your function name. Try uint() not unit().

permanent link

answered 20 Apr '15, 23:44

izopizo's gravatar image

izopizo
2024714
accept rate: 0%

yes, i changed that . Now iam getting the following error:

Expert Info (Warn/Malformed): Trying to fetch an unsigned integer with length 18

(20 Apr '15, 23:51) lakshmi

Expert Info (Warn/Malformed): Trying to fetch an unsigned integer with length 18

This warning I am getting for every length greater than 4.

(21 Apr '15, 01:36) lakshmi

This seems to be expected, pr the Lua reference manual found here: https://www.wireshark.org/docs/wsdg_html_chunked/lua_module_Tvb.html

11.8.3.3. tvbrange:uint()

Get a Big Endian (network order) unsigned integer from a TvbRange. The range must be 1, 2, 3 or 4 octets long. Returns

The unsigned integer value.

(21 Apr '15, 05:03) Pascal Quantin
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×431
×193

question asked: 20 Apr '15, 23:22

question was seen: 4,027 times

last updated: 21 Apr '15, 05:03

p​o​w​e​r​e​d by O​S​Q​A