Ask Your Question
0

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
0

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: https://www.wireshark.org/docs/wsdg_html/#wsluarm_modules
local foo = Proto("FOO", "Foo")
local foo_vlan_id = ProtoField.uint16("foo.vlan_id", "VLAN ID")

-- Section 11.2.1.1: Use Field extractor to grab field of interest
local vlan_id = Field.new("vlan.id")

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

Comments

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

Stats

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

Seen: 61 times

Last updated: Aug 12