Skip to content

Commit

Permalink
Added hardware MTU parameter to interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
markqvist committed May 29, 2022
1 parent d99d310 commit c6df629
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 10 deletions.
4 changes: 3 additions & 1 deletion RNS/Interfaces/AX25KISSInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def __init__(self, owner, name, callsign, ssid, port, speed, databits, parity, s

self.rxb = 0
self.txb = 0

self.HW_MTU = 564

self.pyserial = serial
self.serial = None
Expand Down Expand Up @@ -304,7 +306,7 @@ def readLoop(self):
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
Expand Down
3 changes: 3 additions & 0 deletions RNS/Interfaces/AutoInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def __init__(self, owner, name, group_id=None, discovery_scope=None, discovery_p
self.netifaces = netifaces
self.rxb = 0
self.txb = 0

self.HW_MTU = 1064

self.IN = True
self.OUT = False
self.name = name
Expand Down
10 changes: 8 additions & 2 deletions RNS/Interfaces/I2PInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -569,7 +571,7 @@ def read_loop(self):
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
Expand All @@ -595,7 +597,7 @@ def read_loop(self):
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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -757,6 +762,7 @@ def incoming_connection(self, handler):
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
Expand Down
4 changes: 3 additions & 1 deletion RNS/Interfaces/KISSInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ def __init__(self, owner, name, port, speed, databits, parity, stopbits, preambl
self.rxb = 0
self.txb = 0

self.HW_MTU = 564

if beacon_data == None:
beacon_data = ""

Expand Down Expand Up @@ -279,7 +281,7 @@ def readLoop(self):
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
Expand Down
5 changes: 4 additions & 1 deletion RNS/Interfaces/LocalInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -177,7 +180,7 @@ def read_loop(self):
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:
Expand Down
4 changes: 3 additions & 1 deletion RNS/Interfaces/PipeInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def __init__(self, owner, name, command, respawn_delay):

self.rxb = 0
self.txb = 0

self.HW_MTU = 1064

self.owner = owner
self.name = name
Expand Down Expand Up @@ -137,7 +139,7 @@ def readLoop(self):
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:
Expand Down
4 changes: 3 additions & 1 deletion RNS/Interfaces/RNodeInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ def __init__(self, owner, name, port, frequency = None, bandwidth = None, txpowe

self.rxb = 0
self.txb = 0

self.HW_MTU = 508

self.pyserial = serial
self.serial = None
Expand Down Expand Up @@ -439,7 +441,7 @@ def readLoop(self):
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):
Expand Down
4 changes: 3 additions & 1 deletion RNS/Interfaces/SerialInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def __init__(self, owner, name, port, speed, databits, parity, stopbits):

self.rxb = 0
self.txb = 0

self.HW_MTU = 564

self.pyserial = serial
self.serial = None
Expand Down Expand Up @@ -152,7 +154,7 @@ def readLoop(self):
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:
Expand Down
10 changes: 8 additions & 2 deletions RNS/Interfaces/TCPInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def __init__(self, owner, name, target_ip=None, target_port=None, connected_sock
self.rxb = 0
self.txb = 0

self.HW_MTU = 1064

self.IN = True
self.OUT = False
self.socket = None
Expand Down Expand Up @@ -293,7 +295,7 @@ def read_loop(self):
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
Expand All @@ -319,7 +321,7 @@ def read_loop(self):
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:
Expand Down Expand Up @@ -405,6 +407,9 @@ def get_broadcast_for_if(name):
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

Expand Down Expand Up @@ -460,6 +465,7 @@ def incoming_connection(self, handler):
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)
Expand Down
3 changes: 3 additions & 0 deletions RNS/Interfaces/UDPInterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ def get_broadcast_for_if(name):
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
Expand Down

0 comments on commit c6df629

Please sign in to comment.