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: Optional[bytes]
default_fields: Dict[str, Any]
static defragment(can_frames: List[Packet], use_extended_addressing: Optional[bool] = None) Optional[ISOTP][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: Optional[int]
explicit
ext_address: Optional[int]
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.

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
post_transforms
raw_packet_cache: Optional[bytes]
raw_packet_cache_fields: Optional[Dict[str, Any]]
rx_ext_address: Optional[int]
rx_id: Optional[int]
sent_time: Union[EDecimal, float, None]
sniffed_on: Optional[_GlobInterfaceType]
time: Union[EDecimal, float]
tx_id: Optional[int]
underlayer
validate_fields() None[source]

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

wirelen: Optional[int]
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, Optional[bytes]][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(p: 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.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

BitField (Cond) (32 bits)

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''