scapy.layers.can

基于Wireshark解剖器的CANopen协议的最小实现. 参见https://wiki.wireshark.org/CANopen

class scapy.layers.can.CAN

Bases: scapy.packet.Packet

基于Wireshark解剖器的CANopen协议的最小实现. 参见https://wiki.wireshark.org/CANopen

aliastypes
extract_padding(p)
fields_desc
CAN领域

flags

FlagsField (3位)

<Flag 0 ()>

identifier

XBitField (29位)

0

length

FieldLenField

None

reserved

ThreeBytesField

0

data

StrLenField

b''

static inv_endianness(pkt)

反转CAN数据包的前四个字节的顺序

该方法专门用于在pcap格式和socketCAN格式之间转换CAN数据包

Parameters

pkt – CAN数据包的str

Returns

交换前四个字节的数据包str

post_build(pkt, pay)

构建时实现交换字节功能

这是基于Packet.self_build默认方法的副本. 目标是仅影响CAN层数据,并保持底层(例如LinuxCooked)不变

post_dissect(s)
pre_dissect(s)

剖析时实现交换字节功能

class scapy.layers.can.SignalPacket

Bases: scapy.packet.Packet

aliastypes
post_dissect(s)

SignalFields可在具有无序字段的数据包上进行剖析. SignalFields的顺序是从start参数定义的. 构建后,必须从SignalPacket中删除所有SignalFields长度消耗的字节.

pre_dissect(s)
class scapy.layers.can.SignalField(name, default, start, size, scaling=1, unit='', offset=0, ndigits=3, fmt='B')

Bases: scapy.fields.ScalingField

addfield(pkt, s, val)
getfield(pkt, s)
i2len(pkt, x)
randval()
size
start
class scapy.layers.can.LESignedSignalField(name, default, start, size, scaling=1, unit='', offset=0, ndigits=3)

Bases: scapy.layers.can.SignalField

class scapy.layers.can.LEUnsignedSignalField(name, default, start, size, scaling=1, unit='', offset=0, ndigits=3)

Bases: scapy.layers.can.SignalField

class scapy.layers.can.LEFloatSignalField(name, default, start, scaling=1, unit='', offset=0, ndigits=3)

Bases: scapy.layers.can.SignalField

class scapy.layers.can.BEFloatSignalField(name, default, start, scaling=1, unit='', offset=0, ndigits=3)

Bases: scapy.layers.can.SignalField

class scapy.layers.can.BESignedSignalField(name, default, start, size, scaling=1, unit='', offset=0, ndigits=3)

Bases: scapy.layers.can.SignalField

class scapy.layers.can.BEUnsignedSignalField(name, default, start, size, scaling=1, unit='', offset=0, ndigits=3)

Bases: scapy.layers.can.SignalField

scapy.layers.can.rdcandump(filename, count=-1, interface=None)

读取candump日志文件并返回数据包列表

filename:要读取的文件count:只读<count>个数据包接口:仅返回来自指定接口的数据包

class scapy.layers.can.CandumpReader(filename, interface=None)

Bases: object

有状态的Candump读取器. 每个数据包都作为CAN数据包返回

close()
dispatch(callback)

为每个读取的数据包调用指定的回调例程

这只是主循环的一项便利功能,它允许在线程中轻松启动数据包处理.

fileno()
next()

在一组数据包上实现迭代器协议

nonblocking_socket = True
static open(filename)

打开(如果需要)文件名.

read_all(count=-1)

返回candump文件中所有数据包的列表

read_allowed_exceptions = ()
read_packet(size=65535)

返回从文件读取的单个数据包;如果应用过滤器,则返回"无"

当没有更多数据包可用时引发EOFError

recv(size=65535)

模拟套接字

static select(sockets, remain=None)
class scapy.layers.can.SignalHeader

Bases: scapy.layers.can.CAN

aliastypes
extract_padding(s)
fields_desc
SignalHeader字段

flags

FlagsField (3位)

<Flag 0 ()>

identifier

XBitField (29位)

0

length

LenField

None

reserved

ThreeBytesField

0