Wireshark-dev: Re: [Wireshark-dev] [RFC] CANOpen dissector
From: Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx>
Date: Fri, 2 Dec 2011 21:57:17 +0100
On Fri, Dec 2, 2011 at 5:48 PM, Stephen Fisher <steve@xxxxxxxxxxxxxxxxxx> wrote:
> On Fri, Dec 02, 2011 at 04:21:15PM +0100, Yegor Yefremov wrote:
>
>> I'm writing a CANOpen dissector
>> (http://en.wikipedia.org/wiki/CANopen). The dissector itself is almost
>> ready. The main problem I have is, how do I hook this dissector on to
>> SocketCan one? CAN has no ports, so I can't decide on this basis. My
>> suggestion were to create a drop-down list in SocketCan dissector to
>> select high-level CAN protocol (like CANOpen, DeviceNet etc.). What do
>> you think about this?
>
> Does the SocketCan protocol have any indication which protocol is next
> (CANOpen, DeviceNet, etc)?  If so, you can use the call_dissector() to
> pass a tvbuff to the next dissector (from SocketCan to CANOpen for
> example).  You would "break off" the rest of the packet that SocketCan
> is dissecting with something like tvb_new_subset() which creates a new
> tvbuff out of a backing tvbuff based on certain offset and length.

No SocketCan has no notion of the underlying protocol. AFAIK SocketCAN
gets one CAN frame per read from the kernel. The CAN frame consists of
an ID field with some flags (4 bytes), data length (1 byte) and the
data itself (max. 8 bytes). Each protocol is using these fields for
its purpose, but there are (could be) same CAN frames in each
protocol.

So your play field is very limited. That's why I'm thinking about
making an option to choose the desired high level protocol in
socketcan settings.

Yegor