Ask Your Question

Lua vlan tag value extraction

asked 2021-08-11 09:00:31 +0000

TalH gravatar image

Hello, I am writting a lua dissector (on top of UDP) and I need to use the vlan tag from the 802.1Q virtual lan layer. I can see the vlan I tried to extract the vlan tag like I extract the source address pinfo.cols.src. pinfo.cols.vlan is null in the coulmns in the GUI I can see the vlan tag correctly.

How do I get the vlan tag?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-08-11 12:35:33 +0000

cmaynard gravatar image

updated 2021-08-12 11:28:39 +0000

The VLAN Display Filter Reference page lists several VLAN-related fields. You can access any of them from your Lua dissector with something like so:

-- Ref:
local foo = Proto("FOO", "Foo")
local foo_vlan_id = ProtoField.uint16("foo.vlan_id", "VLAN ID")

-- Section Use Field extractor to grab field of interest
local vlan_id ="")

function foo.dissector(tvbuf, pinfo, tree)
    local foo_tree = tree:add(foo, "Foo")
    foo_tree:add(foo_vlan_id, vlan_id().value)
edit flag offensive delete link more


Works great. Thank you

TalH gravatar imageTalH ( 2021-08-12 05:06:06 +0000 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2021-08-11 09:00:31 +0000

Seen: 507 times

Last updated: Aug 12 '21