From c6df6293b240d8a8fe22bf7a2759e343eb4351ae Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 29 May 2022 15:43:50 +0200 Subject: [PATCH] Added hardware MTU parameter to interfaces --- RNS/Interfaces/AX25KISSInterface.py | 4 +++- RNS/Interfaces/AutoInterface.py | 3 +++ RNS/Interfaces/I2PInterface.py | 10 ++++++++-- RNS/Interfaces/KISSInterface.py | 4 +++- RNS/Interfaces/LocalInterface.py | 5 ++++- RNS/Interfaces/PipeInterface.py | 4 +++- RNS/Interfaces/RNodeInterface.py | 4 +++- RNS/Interfaces/SerialInterface.py | 4 +++- RNS/Interfaces/TCPInterface.py | 10 ++++++++-- RNS/Interfaces/UDPInterface.py | 3 +++ 10 files changed, 41 insertions(+), 10 deletions(-) diff --git a/RNS/Interfaces/AX25KISSInterface.py b/RNS/Interfaces/AX25KISSInterface.py index 66f5eca..27e7e59 100644 --- a/RNS/Interfaces/AX25KISSInterface.py +++ b/RNS/Interfaces/AX25KISSInterface.py @@ -79,6 +79,8 @@ class AX25KISSInterface(Interface): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 564 self.pyserial = serial self.serial = None @@ -304,7 +306,7 @@ class AX25KISSInterface(Interface): in_frame = True command = KISS.CMD_UNKNOWN data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU+AX25.HEADER_SIZE): + elif (in_frame and len(data_buffer) < self.HW_MTU+AX25.HEADER_SIZE): if (len(data_buffer) == 0 and command == KISS.CMD_UNKNOWN): # We only support one HDLC port for now, so # strip off the port nibble diff --git a/RNS/Interfaces/AutoInterface.py b/RNS/Interfaces/AutoInterface.py index fffdff6..0f4c02d 100644 --- a/RNS/Interfaces/AutoInterface.py +++ b/RNS/Interfaces/AutoInterface.py @@ -60,6 +60,9 @@ class AutoInterface(Interface): self.netifaces = netifaces self.rxb = 0 self.txb = 0 + + self.HW_MTU = 1064 + self.IN = True self.OUT = False self.name = name diff --git a/RNS/Interfaces/I2PInterface.py b/RNS/Interfaces/I2PInterface.py index f72f848..11300a9 100644 --- a/RNS/Interfaces/I2PInterface.py +++ b/RNS/Interfaces/I2PInterface.py @@ -306,6 +306,8 @@ class I2PInterfacePeer(Interface): def __init__(self, parent_interface, owner, name, target_i2p_dest=None, connected_socket=None, max_reconnect_tries=None): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 1064 self.IN = True self.OUT = False @@ -569,7 +571,7 @@ class I2PInterfacePeer(Interface): in_frame = True command = KISS.CMD_UNKNOWN data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (len(data_buffer) == 0 and command == KISS.CMD_UNKNOWN): # We only support one HDLC port for now, so # strip off the port nibble @@ -595,7 +597,7 @@ class I2PInterfacePeer(Interface): elif (byte == HDLC.FLAG): in_frame = True data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (byte == HDLC.ESC): escape = True else: @@ -660,6 +662,9 @@ class I2PInterface(Interface): def __init__(self, owner, name, rns_storagepath, peers, connectable = False): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 1064 + self.online = False self.clients = 0 self.owner = owner @@ -757,6 +762,7 @@ class I2PInterface(Interface): spawned_interface.announce_rate_grace = self.announce_rate_grace spawned_interface.announce_rate_penalty = self.announce_rate_penalty spawned_interface.mode = self.mode + spawned_interface.HW_MTU = self.HW_MTU RNS.log("Spawned new I2PInterface Peer: "+str(spawned_interface), RNS.LOG_VERBOSE) RNS.Transport.interfaces.append(spawned_interface) self.clients += 1 diff --git a/RNS/Interfaces/KISSInterface.py b/RNS/Interfaces/KISSInterface.py index 1ef1a32..087471c 100644 --- a/RNS/Interfaces/KISSInterface.py +++ b/RNS/Interfaces/KISSInterface.py @@ -73,6 +73,8 @@ class KISSInterface(Interface): self.rxb = 0 self.txb = 0 + self.HW_MTU = 564 + if beacon_data == None: beacon_data = "" @@ -279,7 +281,7 @@ class KISSInterface(Interface): in_frame = True command = KISS.CMD_UNKNOWN data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (len(data_buffer) == 0 and command == KISS.CMD_UNKNOWN): # We only support one HDLC port for now, so # strip off the port nibble diff --git a/RNS/Interfaces/LocalInterface.py b/RNS/Interfaces/LocalInterface.py index 57301a7..e63eecc 100644 --- a/RNS/Interfaces/LocalInterface.py +++ b/RNS/Interfaces/LocalInterface.py @@ -49,6 +49,9 @@ class LocalClientInterface(Interface): def __init__(self, owner, name, target_port = None, connected_socket=None): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 1064 + self.online = False self.IN = True @@ -177,7 +180,7 @@ class LocalClientInterface(Interface): elif (byte == HDLC.FLAG): in_frame = True data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (byte == HDLC.ESC): escape = True else: diff --git a/RNS/Interfaces/PipeInterface.py b/RNS/Interfaces/PipeInterface.py index 58738fc..4f62f4d 100644 --- a/RNS/Interfaces/PipeInterface.py +++ b/RNS/Interfaces/PipeInterface.py @@ -56,6 +56,8 @@ class PipeInterface(Interface): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 1064 self.owner = owner self.name = name @@ -137,7 +139,7 @@ class PipeInterface(Interface): elif (byte == HDLC.FLAG): in_frame = True data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (byte == HDLC.ESC): escape = True else: diff --git a/RNS/Interfaces/RNodeInterface.py b/RNS/Interfaces/RNodeInterface.py index f86f905..0a5828d 100644 --- a/RNS/Interfaces/RNodeInterface.py +++ b/RNS/Interfaces/RNodeInterface.py @@ -111,6 +111,8 @@ class RNodeInterface(Interface): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 508 self.pyserial = serial self.serial = None @@ -439,7 +441,7 @@ class RNodeInterface(Interface): command = KISS.CMD_UNKNOWN data_buffer = b"" command_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (len(data_buffer) == 0 and command == KISS.CMD_UNKNOWN): command = byte elif (command == KISS.CMD_DATA): diff --git a/RNS/Interfaces/SerialInterface.py b/RNS/Interfaces/SerialInterface.py index 4cc8161..4166a46 100755 --- a/RNS/Interfaces/SerialInterface.py +++ b/RNS/Interfaces/SerialInterface.py @@ -62,6 +62,8 @@ class SerialInterface(Interface): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 564 self.pyserial = serial self.serial = None @@ -152,7 +154,7 @@ class SerialInterface(Interface): elif (byte == HDLC.FLAG): in_frame = True data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (byte == HDLC.ESC): escape = True else: diff --git a/RNS/Interfaces/TCPInterface.py b/RNS/Interfaces/TCPInterface.py index d1dbf8a..e4e6340 100644 --- a/RNS/Interfaces/TCPInterface.py +++ b/RNS/Interfaces/TCPInterface.py @@ -79,6 +79,8 @@ class TCPClientInterface(Interface): self.rxb = 0 self.txb = 0 + self.HW_MTU = 1064 + self.IN = True self.OUT = False self.socket = None @@ -293,7 +295,7 @@ class TCPClientInterface(Interface): in_frame = True command = KISS.CMD_UNKNOWN data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (len(data_buffer) == 0 and command == KISS.CMD_UNKNOWN): # We only support one HDLC port for now, so # strip off the port nibble @@ -319,7 +321,7 @@ class TCPClientInterface(Interface): elif (byte == HDLC.FLAG): in_frame = True data_buffer = b"" - elif (in_frame and len(data_buffer) < RNS.Reticulum.MTU): + elif (in_frame and len(data_buffer) < self.HW_MTU): if (byte == HDLC.ESC): escape = True else: @@ -405,6 +407,9 @@ class TCPServerInterface(Interface): def __init__(self, owner, name, device=None, bindip=None, bindport=None, i2p_tunneled=False): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 1064 + self.online = False self.clients = 0 @@ -460,6 +465,7 @@ class TCPServerInterface(Interface): spawned_interface.announce_rate_grace = self.announce_rate_grace spawned_interface.announce_rate_penalty = self.announce_rate_penalty spawned_interface.mode = self.mode + spawned_interface.HW_MTU = self.HW_MTU spawned_interface.online = True RNS.log("Spawned new TCPClient Interface: "+str(spawned_interface), RNS.LOG_VERBOSE) RNS.Transport.interfaces.append(spawned_interface) diff --git a/RNS/Interfaces/UDPInterface.py b/RNS/Interfaces/UDPInterface.py index af9560d..f4c26cc 100644 --- a/RNS/Interfaces/UDPInterface.py +++ b/RNS/Interfaces/UDPInterface.py @@ -57,6 +57,9 @@ class UDPInterface(Interface): def __init__(self, owner, name, device=None, bindip=None, bindport=None, forwardip=None, forwardport=None): self.rxb = 0 self.txb = 0 + + self.HW_MTU = 1064 + self.IN = True self.OUT = False self.name = name