scapy.contrib.cansocket_native

NativeCANSocket.

scapy.contrib.cansocket_native.CANSocket[source]

alias of scapy.contrib.cansocket_native.NativeCANSocket

class scapy.contrib.cansocket_native.NativeCANSocket(channel=None, receive_own_messages=False, can_filters=None, basecls=<class 'scapy.layers.can.CAN'>, **kwargs)[source]

Bases: scapy.supersocket.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=16)[source]

Returns a tuple containing (cls, pkt_data, time)

send(x)[source]