scapy.contrib.cansocket_native

NativeCANSocket.

scapy.contrib.cansocket_native.CANSocket[source]

alias of NativeCANSocket

class scapy.contrib.cansocket_native.NativeCANSocket(channel: ~typing.Optional[str] = None, receive_own_messages: bool = False, can_filters: ~typing.Optional[~typing.List[~typing.Dict[str, int]]] = None, basecls: ~typing.Type[~scapy.packet.Packet] = <class 'scapy.layers.can.CAN'>, **kwargs: ~typing.Dict[str, ~typing.Any])[source]

Bases: SuperSocket

Initializes a Linux PF_CAN socket object.

Example

>>> socket = NativeCANSocket(channel="vcan0", can_filters=[{'can_id': 0x200, 'can_mask': 0x7FF}])
Parameters
  • channel – Network interface name

  • receive_own_messages – Messages, sent by this socket are will also be received.

  • can_filters – A list of can filter dictionaries.

  • basecls – Packet type in which received data gets interpreted.

  • kwargs – Various keyword arguments for compatibility with PythonCANSockets

desc = 'read/write packets at a given CAN interface using PF_CAN sockets'
recv_raw(x: int = 16) Tuple[Optional[Type[Packet]], Optional[bytes], Optional[float]][source]

Returns a tuple containing (cls, pkt_data, time)

send(x: Packet) int[source]