daemon: fixed issues when emane generated platform.xml for raw interfaces

This commit is contained in:
Blake Harnden 2020-07-03 08:51:17 -07:00
parent ddcb0205f3
commit ac1c27b1c8
2 changed files with 21 additions and 24 deletions

View file

@ -31,7 +31,6 @@ from core.emulator.enumerations import (
from core.errors import CoreCommandError, CoreError
from core.nodes.base import CoreNode, NodeBase
from core.nodes.interface import CoreInterface, TunTap
from core.nodes.physical import Rj45Node
from core.xml import emanexml
if TYPE_CHECKING:
@ -531,19 +530,21 @@ class EmaneManager(ModelManager):
cfgloglevel = self.session.options.get_config_int("emane_log_level")
realtime = self.session.options.get_config_bool("emane_realtime", default=True)
if cfgloglevel:
logging.info("setting user-defined EMANE log level: %d", cfgloglevel)
logging.info("setting user-defined emane log level: %d", cfgloglevel)
loglevel = str(cfgloglevel)
emanecmd = f"emane -d -l {loglevel}"
if realtime:
emanecmd += " -r"
otagroup, _otaport = self.get_config("otamanagergroup").split(":")
otadev = self.get_config("otamanagerdevice")
otanetidx = self.session.get_control_net_index(otadev)
eventgroup, _eventport = self.get_config("eventservicegroup").split(":")
eventdev = self.get_config("eventservicedevice")
eventservicenetidx = self.session.get_control_net_index(eventdev)
node = iface.node
if not isinstance(node, Rj45Node):
transport_type = emanexml.get_transport_type(iface)
if not transport_type == TransportType.RAW:
otagroup, _otaport = self.get_config("otamanagergroup").split(":")
otadev = self.get_config("otamanagerdevice")
otanetidx = self.session.get_control_net_index(otadev)
eventgroup, _eventport = self.get_config("eventservicegroup").split(":")
eventdev = self.get_config("eventservicedevice")
eventservicenetidx = self.session.get_control_net_index(eventdev)
# control network not yet started here
self.session.add_remove_control_iface(
node, 0, remove=False, conf_required=False
@ -559,6 +560,7 @@ class EmaneManager(ModelManager):
node, eventservicenetidx, remove=False, conf_required=False
)
# multicast route is needed for OTA data
logging.info("OTA GROUP(%s) OTA DEV(%s)", otagroup, otadev)
node.node_net_client.create_route(otagroup, otadev)
# multicast route is also needed for event data if on control network
if eventservicenetidx >= 0 and eventgroup != otagroup:
@ -588,7 +590,8 @@ class EmaneManager(ModelManager):
node = iface.node
if not node.up:
continue
if isinstance(node, Rj45Node):
transport_type = emanexml.get_transport_type(iface)
if transport_type == TransportType.RAW:
node.host_cmd(kill_emaned, wait=False)
else:
node.cmd(kill_emaned, wait=False)

View file

@ -13,7 +13,6 @@ from core.emulator.enumerations import TransportType
from core.errors import CoreError
from core.nodes.interface import CoreInterface
from core.nodes.network import CtrlNet
from core.nodes.physical import Rj45Node
from core.xml import corexml
if TYPE_CHECKING:
@ -93,7 +92,8 @@ def create_iface_file(
:return:
"""
node = iface.node
if isinstance(node, Rj45Node):
transport_type = get_transport_type(iface)
if transport_type == TransportType.RAW:
file_path = os.path.join(node.session.session_dir, file_name)
else:
file_path = os.path.join(node.nodedir, file_name)
@ -185,21 +185,15 @@ def build_platform_xml(
)
add_param(transport_element, "device", iface.name)
# determine platform element to add xml to
if iface.transport_type == TransportType.RAW:
otadev = control_net.brname
eventdev = control_net.brname
else:
otadev = None
eventdev = None
transport_type = get_transport_type(iface)
transport_configs = {"otamanagerdevice", "eventservicedevice"}
platform_element = etree.Element("platform")
if otadev:
emane_manager.set_config("otamanagerdevice", otadev)
if eventdev:
emane_manager.set_config("eventservicedevice", eventdev)
for configuration in emane_manager.emane_config.emulator_config:
name = configuration.id
value = emane_manager.get_config(name)
if transport_type == TransportType.RAW and name in transport_configs:
value = control_net.brname
else:
value = emane_manager.get_config(name)
add_param(platform_element, name, value)
platform_element.append(nem_element)
emane_net.setnemid(iface, nem_id)