Ask Your Question
0

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 = mybussnifer_can.fields.source.name 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")

can_protocol_fields.target = ProtoField.uint8("mysniffer.target" , "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 = mybussnifer_can.name
end
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

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. "mybussnifer_can.fields.source.name".

edit flag offensive delete link more

Comments

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

Stats

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

Seen: 2,015 times

Last updated: Nov 29 '20