scapy.contrib.isotp.isotp_packet

class scapy.contrib.isotp.isotp_packet.ISOTP(_pkt, /, *, data=b'')[source]

Bases: Packet

Packet class for ISOTP messages. This class contains additional slots for source address (tx_id), destination address (rx_id), extended source address (ext_address) and extended destination address (rx_ext_address) information. This information gets filled from ISOTPSockets or the ISOTPMessageBuilder, if it is available. Address information is not used for Packet comparison.

Parameters:
  • args – Arguments for Packet init, for example bytes string

  • kwargs – Keyword arguments for Packet init.

aliastypes
comment: bytes | None
default_fields: Dict[str, Any]
static defragment(can_frames: List[Packet], use_extended_addressing: bool | None = None) ISOTP | None[source]

Helper function to defragment a list of CAN frames to one ISOTP message

Parameters:
  • can_frames – A list of CAN frames

  • use_extended_addressing – Specify if extended ISO-TP addressing is used in the packets for defragmentation.

Returns:

An ISOTP message containing the data of the CAN frames or None

direction: int | None
explicit
ext_address: int | None
fields: Dict[str, Any]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|              DATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                            Fig. ISOTP                            
ISOTP fields

data

StrField

b''

fieldtype: Dict[str, AnyField]
fragment(*args: Any, **kargs: Any) List[Packet][source]

Helper function to fragment an ISOTP message into multiple CAN frames.

Parameters:

fd – type: Optional[bool]: will fragment the can frames with size CAN_FD_MAX_DLEN

Returns:

A list of CAN frames

name
original
overload_fields: Dict[Type[Packet], Dict[str, Any]]
overloaded_fields: Dict[str, Any]
packetfields: List[AnyField]
parent
payload: Packet
post_transforms
raw_packet_cache: bytes | None
raw_packet_cache_fields: Dict[str, Any] | None
rx_ext_address: int | None
rx_id: int | None
sent_time: EDecimal | float | None
sniffed_on: _GlobInterfaceType | None
stop_dissection_after
time: EDecimal | float
tx_id: int | None
underlayer
validate_fields() None[source]

Helper function to validate information in tx_id, rx_id, ext_address and rx_ext_address slots

wirelen: int | None
class scapy.contrib.isotp.isotp_packet.ISOTPHeader(_pkt, /, *, flags=<Flag 0 ()>, identifier=0, length=None, reserved=0)[source]

Bases: CAN

aliastypes
extract_padding(p: bytes) Tuple[bytes, bytes | None][source]
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|FLAGS|                        IDENTIFIER                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LENGTH    |                    RESERVED                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |
+-+-+-+-+-+-+-+-+

                         Fig. ISOTPHeader                         
ISOTPHeader fields

flags

FlagsField

<Flag 0 ()>

identifier

XBitField (29 bits)

0

length

ByteField

None

reserved

ThreeBytesField

0

guess_payload_class(payload: bytes) Type[Packet][source]

ISO-TP encodes the frame type in the first nibble of a frame. This is used to determine the payload_class

Parameters:

payload – payload bytes string

Returns:

Type of payload class

post_build(pkt: bytes, pay: bytes) bytes[source]

This will set the ByteField ‘length’ to the correct value.

class scapy.contrib.isotp.isotp_packet.ISOTPHeaderEA(_pkt, /, *, flags=<Flag 0 ()>, identifier=0, length=None, reserved=0, extended_address=0)[source]

Bases: ISOTPHeader

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|FLAGS|                        IDENTIFIER                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LENGTH    |                    RESERVED                   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               |EXTENDED ADDRES|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                        Fig. ISOTPHeaderEA                        
ISOTPHeaderEA fields

flags

FlagsField

<Flag 0 ()>

identifier

XBitField (29 bits)

0

length

ByteField

None

reserved

ThreeBytesField

0

extended_address

XByteField

0

post_build(pkt: bytes, pay: bytes) bytes[source]

This will set the ByteField ‘length’ to the correct value. ‘chb(len(pay) + 1)’ is required, because the field ‘extended_address’ is counted as payload on the CAN layer

class scapy.contrib.isotp.isotp_packet.ISOTPHeaderEA_FD(_pkt, /, *, flags=<Flag 0 ()>, identifier=0, length=None, fd_flags=<Flag 4 (fd_frame)>, reserved=0, extended_address=0)[source]

Bases: ISOTPHeaderEA

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|FLAGS|                        IDENTIFIER                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LENGTH    |    FD FLAGS   |            RESERVED           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|EXTENDED ADDRES|
+-+-+-+-+-+-+-+-+

                      Fig. ISOTPHeaderEA_FD                       
ISOTPHeaderEA_FD fields

flags

FlagsField

<Flag 0 ()>

identifier

XBitField (29 bits)

0

length

ByteField

None

fd_flags

FlagsField

<Flag 4 (fd_frame)>

reserved

ShortField

0

extended_address

XByteField

0

post_build(pkt: bytes, pay: bytes) bytes[source]
class scapy.contrib.isotp.isotp_packet.ISOTPHeader_FD(_pkt, /, *, flags=<Flag 0 ()>, identifier=0, length=None, fd_flags=<Flag 4 (fd_frame)>, reserved=0)[source]

Bases: ISOTPHeader

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|FLAGS|                        IDENTIFIER                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     LENGTH    |    FD FLAGS   |            RESERVED           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                       Fig. ISOTPHeader_FD                        
ISOTPHeader_FD fields

flags

FlagsField

<Flag 0 ()>

identifier

XBitField (29 bits)

0

length

ByteField

None

fd_flags

FlagsField

<Flag 4 (fd_frame)>

reserved

ShortField

0

post_build(pkt: bytes, pay: bytes) bytes[source]
class scapy.contrib.isotp.isotp_packet.ISOTP_CF(_pkt, /, *, type=2, index=0, data=b'')[source]

Bases: Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  TYPE | INDEX |      DATA     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. ISOTP_CF                           
ISOTP_CF fields

type

BitEnumField

2

index

BitField (4 bits)

0

data

StrField

b''

class scapy.contrib.isotp.isotp_packet.ISOTP_FC(_pkt, /, *, type=3, fc_flag=0, block_size=0, separation_time=0)[source]

Bases: Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  TYPE |FC FLAG|   BLOCK SIZE  |SEPARATION TIME|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. ISOTP_FC                           
ISOTP_FC fields

type

BitEnumField

3

fc_flag

BitEnumField

0

block_size

ByteField

0

separation_time

ByteField

0

class scapy.contrib.isotp.isotp_packet.ISOTP_FF(_pkt, /, *, type=1, message_size=0, extended_message_size=0, data=b'')[source]

Bases: Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  TYPE |      MESSAGE SIZE     |     EXTENDED MESSAGE SIZE     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |      DATA     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. ISOTP_FF                           
ISOTP_FF fields

type

BitEnumField

1

message_size

BitField (12 bits)

0

extended_message_size

IntField (Cond)

0

data

StrField

b''

class scapy.contrib.isotp.isotp_packet.ISOTP_FF_FD(_pkt, /, *, type=1, zero_field=0, message_size=0, data=b'')[source]

Bases: Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  TYPE |       ZERO FIELD      |          MESSAGE SIZE         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                               |      DATA     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. ISOTP_FF_FD                         
ISOTP_FF_FD fields

type

BitEnumField

1

zero_field

BitField (12 bits)

0

message_size

IntField

0

data

StrField

b''

class scapy.contrib.isotp.isotp_packet.ISOTP_SF(_pkt, /, *, type=0, message_size=None, data=b'')[source]

Bases: Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  TYPE |MESSAGE|              DATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                          Fig. ISOTP_SF                           
ISOTP_SF fields

type

BitEnumField

0

message_size

BitFieldLenField (4 bits)

None

data

StrLenField

b''

class scapy.contrib.isotp.isotp_packet.ISOTP_SF_FD(_pkt, /, *, type=0, zero_field=0, message_size=None, data=b'')[source]

Bases: Packet

aliastypes
fields_desc
Display RFC-like schema
 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  TYPE |ZERO FI|  MESSAGE SIZE |              DATA             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

                         Fig. ISOTP_SF_FD                         
ISOTP_SF_FD fields

type

BitEnumField

0

zero_field

BitField (4 bits)

0

message_size

FieldLenField

None

data

StrLenField

b''