scapy.contrib.isotp.isotp_utils

class scapy.contrib.isotp.isotp_utils.ISOTPMessageBuilder(use_ext_addr=None, did=None, basecls=<class 'scapy.contrib.isotp.isotp_packet.ISOTP'>)[source]

Bases: object

Initialize a ISOTPMessageBuilder object

Utility class to build ISOTP messages out of CAN frames, used by both ISOTP.defragment() and ISOTPSession.

This class attempts to interpret some CAN frames as ISOTP frames, both with and without extended addressing at the same time. For example, if an extended address of 07 is being used, all frames will also be interpreted as ISOTP single-frame messages.

CAN frames are fed to an ISOTPMessageBuilder object with the feed() method and the resulting ISOTP frames can be extracted using the pop() method.

Parameters
  • use_ext_addr – True for only attempting to defragment with extended addressing, False for only attempting to defragment without extended addressing, or None for both

  • did – Destination Identifier

  • basecls – The class of packets that will be returned, defaults to ISOTP

class Bucket(total_len, first_piece, ts)[source]

Bases: object

Helper class to store not finished ISOTP messages while building.

push(piece)[source]
property count

Returns the number of ready ISOTP messages built from the provided can frames

Returns

Number of ready ISOTP messages

feed(can)[source]

Attempt to feed an incoming CAN frame into the state machine

pop(identifier=None, ext_addr=None)[source]

Returns a built ISOTP message

Parameters
  • identifier – if not None, only return isotp messages with this destination

  • ext_addr – if identifier is not None, only return isotp messages with this extended address for destination

Returns

an ISOTP packet, or None if no message is ready

class scapy.contrib.isotp.isotp_utils.ISOTPMessageBuilderIter(builder)[source]

Bases: object

Iterator class for ISOTPMessageBuilder

next()[source]
slots = ['builder']
class scapy.contrib.isotp.isotp_utils.ISOTPSession(*args, **kwargs)[source]

Bases: scapy.sessions.DefaultSession

Defragment ISOTP packets ‘on-the-flow’.

Usage:
>>> sniff(session=ISOTPSession)
on_packet_received(pkt)[source]