Ask Your Question

Can I create a subdissector based on CAN ID?

asked 2019-06-11 12:18:23 +0000

dyne94 gravatar image


in my previous approaches I tried to create a dissector which should decode the payload of CAN messages. The implemented socketCAN dissector allows only the option to trigger my subdissector with the "decode as" preference option. But in my case I want to decode automatically on specific CAN IDs.


dissector_add_for_decode_as("can.subdissector", myDissector_handle);

Not possible:

 dissector_add_uint("", 0x01, myDissector_handle);

What changes I have to do in the socketCAN dissector (packet-socketcan.c) to allow calling subdissectors with can id?

Simply add subdissector_table = register_dissector_table("", "CAN ID", proto_can, FT_UINT32, BASE_HEX); in proto_register_socketcan function doesn't work.

Thanks in advance.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-06-11 18:50:21 +0000

grahamb gravatar image

The code you show adds the table to the socket-can dissector, but you also need to add code in the appropriate spot to actually call the sub-dissectors based on the can id.

For an example, look at packet-tcp.c where it calls sub-dissectors based on the tcp port, around line 5756:

dissector_try_uint_new(subdissector_table, tcpd->server_port, next_tvb, pinfo, tree, TRUE, tcpinfo)

This uses the port, tcpd->server-port, as the index into the subdissector_table.

See Sect. 1.7.1 in README.dissector for more info.

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


Asked: 2019-06-11 12:18:23 +0000

Seen: 637 times

Last updated: Jun 11 '19