THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

Can I create a subdissector based on CAN ID?

Hi,

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.

Possible:

dissector_add_for_decode_as("can.subdissector", myDissector_handle);

Not possible:

 dissector_add_uint("can.id", 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", "CAN ID", proto_can, FT_UINT32, BASE_HEX); in proto_register_socketcan function doesn't work.

Thanks in advance.

dyne94's avatar
1
dyne94
asked 2019-06-11 12:18:23 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

The code you show adds the can.id 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.

grahamb's avatar
23.8k
grahamb
answered 2019-06-11 18:50:21 +0000
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer