From 901d4aad0520842589c44461e8d6fdd729d8e685 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Mon, 21 Dec 2020 16:04:17 +0100 Subject: [PATCH] Acknowledge Data TLVs Signed-off-by: Yohann D'ANELLO --- squinnondation/messages.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/squinnondation/messages.py b/squinnondation/messages.py index f36577e..a0da0fa 100644 --- a/squinnondation/messages.py +++ b/squinnondation/messages.py @@ -212,6 +212,9 @@ class DataTLV(TLV): # The message was already received return + # Acknowledge the packet + squirrel.send_packet(sender, Packet.construct(AckTLV.construct(sender.id, self.nonce))) + nickname_match = re.match("(.*): (.*)", msg) if nickname_match is None: squirrel.send_packet(sender, Packet.construct(WarningTLV.construct( @@ -263,6 +266,15 @@ class AckTLV(TLV): # TODO Implement AckTLV squirrel.add_system_message("I received an AckTLV. I don't know what to do with it. Please implement me!") + @staticmethod + def construct(sender_id: int, nonce: int) -> "AckTLV": + tlv = AckTLV() + tlv.type = 5 + tlv.length = 12 + tlv.sender_id = sender_id + tlv.nonce = nonce + return tlv + class GoAwayTLV(TLV): class GoAwayType(Enum):