Skip to content

Commit

Permalink
Add comms.setting support for MPTCP enable/disable
Browse files Browse the repository at this point in the history
Jira-Id: WC-264

Signed-off-by: Mika Joenpera <[email protected]>
  • Loading branch information
joenpera committed Nov 2, 2023
1 parent 50b5c52 commit 3483cf0
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
3 changes: 3 additions & 0 deletions common/scripts/mesh-11s_nats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,9 @@ main () {
_batman_iface="${INDEX}_BATMAN_IFACE"
batman_iface="${!_batman_iface}"

_mptcp="${INDEX}_MPTCP"
mptcp="${!_mptcp}" # enable disable

# shellcheck disable=SC2153
# shellcheck disable=SC2034
# this is for the future use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import json
import config


async def main():
# Connect to NATS!
nc = await client.connect_nats()
Expand All @@ -19,6 +20,7 @@ async def main():
"frequency": "2412",
"frequency_mcc": "2412", # multiradio not supporting
"routing": "batman-adv",
"mptcp": "disable", # MPTCP support feature flag, enable/disable
"priority": "long_range",
"ip": "10.20.15.3",
"subnet": "255.255.255.0",
Expand All @@ -36,6 +38,7 @@ async def main():
"frequency": "5220",
"frequency_mcc": "2412", # multiradio not supporting
"routing": "batman-adv",
"mptcp": "disable", # MPTCP support feature flag, enable/disable
"priority": "long_range",
"ip": "10.20.15.3",
"subnet": "255.255.255.0",
Expand All @@ -53,6 +56,7 @@ async def main():
"frequency": "5190",
"frequency_mcc": "2412", # multiradio not supporting
"routing": "batman-adv",
"mptcp": "disable", # MPTCP support feature flag, enable/disable
"priority": "long_range",
"ip": "10.20.15.3",
"subnet": "255.255.255.0",
Expand All @@ -62,7 +66,7 @@ async def main():
"batman_iface": "bat0",
},
],
"bridge": "br-lan bat0 eth1 lan1 eth0 usb0"
"bridge": "br-lan bat0 eth1 lan1 eth0 usb0",
}

cmd = json.dumps(cmd_dict)
Expand Down
40 changes: 25 additions & 15 deletions modules/sc-mesh-secure-deployment/src/nats/src/comms_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,24 @@ class CommsSettings: # pylint: disable=too-few-public-methods, too-many-instanc
def __init__(self, comms_status: [cs.CommsStatus, ...], logger):
self.logger: logging = logger
self.api_version: int = 1
self.radio_index = []
self.ssid = []
self.key = []
self.ap_mac = []
self.country = []
self.frequency = []
self.frequency_mcc = []
self.ip_address = []
self.subnet = []
self.tx_power = []
self.mode = []
self.routing = []
self.priority = []
self.radio_index: [int, ...] = []
self.ssid: [str, ...] = []
self.key: [str, ...] = []
self.ap_mac: [str, ...] = []
self.country: [str, ...] = []
self.frequency: [str, ...] = []
self.frequency_mcc: [str, ...] = []
self.ip_address: [str, ...] = []
self.subnet: [str, ...] = []
self.tx_power: [str, ...] = []
self.mode: [str, ...] = []
self.routing: [str, ...] = []
self.priority: [str, ...] = []
self.role: str = ""
self.mesh_vif = []
self.mesh_vif: [str, ...] = []
self.mptcp: [str, ...] = []
# self.phy = []
self.batman_iface = []
self.batman_iface: [str, ...] = []
self.bridge: str = ""
self.msversion: str = ""
self.delay: str = "" # delay for channel change
Expand Down Expand Up @@ -110,6 +111,10 @@ def validate_mesh_settings(self, index: int) -> (str, str):
return "FAIL", "Invalid mesh vif"
self.logger.debug("validate mesh settings mesh vif ok")

if validation.validate_mptcp(self.mptcp[index]) is False:
return "FAIL", "Invalid mptcp value"
self.logger.debug("validate mesh settings mptcp ok")

# if validation.validate_phy(self.phy[index]) is False:
# return "FAIL", "Invalid phy"
# self.logger.debug("validate mesh settings phy ok")
Expand Down Expand Up @@ -138,6 +143,7 @@ def __clean_all_settings(self) -> None:
self.routing: [str, ...] = []
self.priority: [str, ...] = []
self.mesh_vif: [str, ...] = []
self.mptcp: [str, ...] = []
# self.phy = []
self.batman_iface: [str, ...] = []

Expand Down Expand Up @@ -235,6 +241,7 @@ def handle_mesh_settings(
self.routing.append(quote(str(parameters["routing"])))
self.priority.append(quote(str(parameters["priority"])))
self.mesh_vif.append(quote(str(parameters["mesh_vif"])))
self.mptcp.append(quote(str(parameters["mptcp"])))
# self.phy.append(quote(str(parameters["phy"])))
self.batman_iface.append(quote(str(parameters["batman_iface"])))

Expand Down Expand Up @@ -329,6 +336,7 @@ def __save_settings(self, path: str, file: str, index: int) -> (str, str):
mesh_conf.write(
f"id{str(index)}_MESH_VIF={quote(self.mesh_vif[index])}\n"
)
mesh_conf.write(f"id{str(index)}_MPTCP={quote(self.mptcp[index])}\n")
# mesh_conf.write(f"id{str(index)}_PHY={quote(self.phy[index])}\n")
mesh_conf.write(
f"id{str(index)}_BATMAN_IFACE={quote(self.batman_iface[index])}\n"
Expand Down Expand Up @@ -379,6 +387,8 @@ def __read_configs(self, mesh_conf_lines) -> None:
self.priority.append(match[1])
elif name == "MESH_VIF":
self.mesh_vif.append(match[1])
elif name == "MPTCP":
self.mptcp.append(match[1])
# elif name == "PHY":
# self.phy.append(match[1])
elif name == "BATMAN_IFACE":
Expand Down
13 changes: 12 additions & 1 deletion modules/sc-mesh-secure-deployment/src/nats/src/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,4 +285,15 @@ def validate_batman_iface(batman_iface: str) -> bool:
return True
return False
except (ValueError, TypeError, AttributeError):
return False
return False
def validate_mptcp(mptcp: str) -> bool:
"""
Validates a given mptcp.
Returns True if the mptcp is valid, False otherwise.
"""
try:
if mptcp in ("enable", "disable"):
return True
return False
except (ValueError, TypeError, AttributeError):
return False

0 comments on commit 3483cf0

Please sign in to comment.