Ask Your Question
0

DissectorTable.get("mpls.label"):get_dissector(2097) returns nil

asked 2025-05-19 11:22:51 +0000

PCrossley gravatar image

updated 2025-05-19 11:38:30 +0000

grahamb gravatar image

I'm attempting to build my first LUA dissector. Specifically I'm writing something to decode PWE3 ControlWords (RFC4385) in more detail than the default one. The dissector I've written works fine but I need to pass the payload to an ethernet dissector.

https://www.wireshark.org/docs/wsdg_h... 11.3 indicates that this should be possible

In another blog I found I should use a call of the form:

DissectorTable.get("mpls.label"):get_dissector(2097):call(buffer(4):tvb(), pinfo, tree)

But this just gives me LUA errors "attempt to index a null value"

I tried this:

local my_table = DissectorTable.list()

for k,v in pairs(my_table) do
   print(k.." = "..v)
end

Which proved that the Dissector Table has entries

And this :

local my_dissectors = Dissector.list()

for k,v in pairs(my_dissectors) do
   print(k.." = "..v)
end

Which shows:

...
2097 = pw_eth_nocw
...

So I think I must be pretty close.

Any help would be much appreciated

end

edit retag flag offensive close merge delete

Comments

Section 10.3. Example: Dissector written in Lua in the WSDG has an example.
You might want to break down your call() into the component pieces and print the contents of each before the call statement to see if the nil value is displayed.

Or add nil checks for components:

if dissector ~= nil then
Chuckc gravatar imageChuckc ( 2025-05-19 13:17:53 +0000 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2025-05-19 14:38:06 +0000

PCrossley gravatar image

Many thanks to Graham for re-formatting my question and Chuckc for pointing me to another example (I'd found many that didn't work)

I've finally settled on:

Dissector.get("pw_eth_nocw"):call(buffer(4):tvb(), pinfo, tree)

I found the name of the dissector from :

local my_dissectors = Dissector.list()
for k,v in pairs(my_dissectors) do
   print(k.." = "..v)
end
edit flag offensive delete link more

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: 2025-05-19 11:22:51 +0000

Seen: 21 times

Last updated: 2 days ago