diff --git a/ebpfcat/ebpfcat.py b/ebpfcat/ebpfcat.py index 491e097bc17d05ffa178b7e83d4776a60c827969..4b81ddc469acee1c5f98082e570f2568a1cb75cd 100644 --- a/ebpfcat/ebpfcat.py +++ b/ebpfcat/ebpfcat.py @@ -473,8 +473,8 @@ class SterilePacket(Packet): super().append(cmd, *args) self.counters[self.size - 2] = {counter} - def sterile(self, index, protocol=0x88A4): - ret = bytearray(self.assemble(index, protocol)) + def sterile(self, index, ethertype=0x88A4): + ret = bytearray(self.assemble(index, ethertype)) for pos, cmd in self.on_the_fly: ret[pos] = ECCmd.NOP.value return ret @@ -636,7 +636,7 @@ class SyncGroup(SyncGroupBase): self.packet_index = SyncGroup.packet_index SyncGroup.packet_index += 1 self.asm_packet = self.packet.assemble(self.packet_index, - self.ec.protocol) + self.ec.ethertype) self.task = ensure_future(self.run()) return self.task @@ -659,7 +659,7 @@ class FastSyncGroup(SyncGroupBase, XDP): async def run(self): with self.ec.register_sync_group(self) as self.packet_index: self.asm_packet = self.packet.sterile(self.packet_index, - self.ec.protocol) + self.ec.ethertype) # prime the pump: two packets to get things going self.ec.send_packet(self.asm_packet) self.ec.send_packet(self.asm_packet) diff --git a/ebpfcat/ethercat.py b/ebpfcat/ethercat.py index 99fc9e45416411996d998e2420e51fce6ee0f845..3f845238299f888637bf981016b074fb8414b17c 100644 --- a/ebpfcat/ethercat.py +++ b/ebpfcat/ethercat.py @@ -250,7 +250,7 @@ class Packet: self.data.append((cmd, data, idx) + address) self.size = newsize - def assemble(self, index, protocol=0x88A4): + def assemble(self, index, ethertype=0x88A4): """Assemble the datagrams into a packet :param index: an identifier for the packet @@ -259,7 +259,7 @@ class Packet: that may be used as an identifier for the packet. """ ret = [pack("<HBBiHHHH", (self.size-2) | 0x1000, 0, 0, - index, 0x8002, 0, protocol, 0)] + index, 0x8002, 0, ethertype, 0)] for i, (cmd, data, *dgram) in enumerate(self.data, start=1): ret.append(pack("<BBhHHH" if len(dgram) == 3 else "<BBiHH", cmd.value, *dgram, @@ -299,7 +299,7 @@ class EtherCat(Protocol): This class supports both to send individual datagrams and wait for their response, but also to send and receive entire packets. """ - protocol = 0x88A4 # this is the incoming protocol, not necessary EtherCAT + ethertype = 0x88A4 # this is the incoming protocol, not necessary EtherCAT def __init__(self, network): """ @@ -375,7 +375,7 @@ class EtherCat(Protocol): index = randint(2000, 1000000000) while index in self.wait_futures: index = randint(2000, 1000000000) - self.send_packet(packet.assemble(index, self.protocol)) + self.send_packet(packet.assemble(index, self.ethertype)) return await self.receive_index(index) async def receive_index(self, index): @@ -475,7 +475,7 @@ class EtherCat(Protocol): def connection_made(self, transport): """start the send loop once the connection is made""" socket = transport.get_extra_info('socket') - socket.bind((self.addr[0], self.protocol)) + socket.bind((self.addr[0], self.ethertype)) self.transport = transport ensure_future(self.sendloop())