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

I'm having a problem with getting the value of a protofield to the Info column. I've defined the following ProtoField:

f.payload = ProtoField.uint8("observation.payload","payload",base.HEX,{ [0] = "Off", [1] = "On"},0x10)

I want add this field value (On or Off) to How can I do it?

asked 05 Jun '12, 02:00

ekrako's gravatar image

accept rate: 0%

edited 05 Jun '12, 16:00

helloworld's gravatar image


You can't extract the value from a ProtoField (see similar question). Instead, you have to parse the buffer, and add the value manually to the Info column, which is fairly easy to do. Try this:

local VALS_ON_OFF = { [0] = "Off", [1] = "On" }

local proto_foo = Proto("foo", "Foo Protocol")
local f = proto_foo.fields
f.payload = ProtoField.uint8("observation.payload", "payload", base.HEX, VALS_ON_OFF, 0x10)

function proto_foo.dissector(buf, pinfo, tree)
   local t = tree:add(proto_foo, buf())

   -- assume observation.payload is at byte 0
   t:add(f.payload, buf(0,1))

   -- 0x10 has one bit set, that's bit 3 from the left
   local bitval = buf(0,1):bitfield(3)

   -- set the Info column based on the bit value = "payload: "..VALS_ON_OFF[bitval]
permanent link

answered 05 Jun '12, 15:54

helloworld's gravatar image

accept rate: 28%

edited 05 Jun '12, 16:01

Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 05 Jun '12, 02:00

question was seen: 2,777 times

last updated: 05 Jun '12, 16:01

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