Ask Your Question

How to add a column from ProtoField value

asked 2020-11-29 22:10:30 +0000

kahlenberg gravatar image

Hi, I wrote a Lua dissector script to capture a in-house developed protocol. I want to add a column "source" "target" into wireshark view. I can add protocol name but how can I add a column called source and assign it a value from ProtoField? I tried pinfo.cols.source = but I get error.

local mybussnifer_can = Proto("mysniffer", "Sniffer plugin")
local can_protocol_fields = mybussnifer_can.fields

can_protocol_fields.priority  = ProtoField.string("priority", "Priority")

can_protocol_fields.proto_dataformat = ProtoField.uint8("dataformat" , "DFormat ", base.HEX, protocol.str, nil, "Protocol Format")

can_protocol_fields.source = ProtoField.uint8("mysniffer.source", "Source", base.HEX, services.name_str , nil, "Source ID") = ProtoField.uint8("" , "Target", base.HEX, services.name_str , nil, "Target ID")

function mybussnifer_can.dissector(buffer, pinfo, tree)
    local buf_len = buffer:len()
    local offset = 0 
    local packet_len = f_frame_len().value
    local subtree = tree:add(mybussnifer_can, buffer(offset, packet_len))
    pinfo.cols.protocol =
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2020-11-29 22:16:51 +0000

Guy Harris gravatar image

how can I add a column called source and assign it a value from ProtoField?

By doing it somewhere other than in the code. :-)

That's a UI function; in the Wireshark preferences, select "Columns", add a column with the "+" button, give it whatever title you want (Source, or whatever), give it a type of "Custom", and in "Fields" give it the name of the field, e.g. "".

edit flag offensive delete link more


Oh man, Thank you :)

kahlenberg gravatar imagekahlenberg ( 2020-11-29 22:27:18 +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: 2020-11-29 22:10:30 +0000

Seen: 29 times

Last updated: Nov 29 '20