def build_platform_xml( emane_manager: "EmaneManager", control_net: CtrlNet, emane_net: EmaneNet, iface: CoreInterface, nem_id: int, ) -> None: """ Create platform xml for a specific node. :param emane_manager: emane manager with emane configurations :param control_net: control net node for this emane network :param emane_net: emane network associated with interface :param iface: interface running emane :param nem_id: nem id to use for this interface :return: the next nem id that can be used for creating platform xml files """ # build nem xml nem_definition = nem_file_name(iface) nem_element = etree.Element( "nem", id=str(nem_id), name=iface.localname, definition=nem_definition ) # check if this is an external transport, get default config if an interface # specific one does not exist config = emane_manager.get_iface_config(emane_net, iface) if is_external(config): nem_element.set("transport", "external") platform_endpoint = "platformendpoint" add_param(nem_element, platform_endpoint, config[platform_endpoint]) transport_endpoint = "transportendpoint" add_param(nem_element, transport_endpoint, config[transport_endpoint]) else: transport_name = transport_file_name(iface) transport_element = etree.SubElement( nem_element, "transport", definition=transport_name ) add_param(transport_element, "device", iface.name) transport_configs = {"otamanagerdevice", "eventservicedevice"} platform_element = etree.Element("platform") for configuration in emane_manager.emane_config.emulator_config: name = configuration.id if iface.is_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) mac = _MAC_PREFIX + ":00:00:" mac += f"{(nem_id >> 8) & 0xFF:02X}:{nem_id & 0xFF:02X}" iface.set_mac(mac) doc_name = "platform" file_name = f"{iface.name}-platform.xml" create_iface_file(iface, platform_element, doc_name, file_name)
def build_platform_xml( nem_id: int, nem_port: int, emane_net: EmaneNet, iface: CoreInterface, config: Dict[str, str], ) -> None: """ Create platform xml for a nem/interface. :param nem_id: nem id for current node/interface :param nem_port: control port to configure for emane :param emane_net: emane network associate with node and interface :param iface: node interface to create platform xml for :param config: emane configuration for interface :return: nothing """ # create top level platform element platform_element = etree.Element("platform") for configuration in emane_net.model.platform_config: name = configuration.id value = config[configuration.id] add_param(platform_element, name, value) add_param(platform_element, emane_net.model.platform_controlport, f"0.0.0.0:{nem_port}") # build nem xml nem_definition = nem_file_name(iface) nem_element = etree.Element("nem", id=str(nem_id), name=iface.localname, definition=nem_definition) # create model based xml files emane_net.model.build_xml_files(config, iface) # check if this is an external transport if is_external(config): nem_element.set("transport", "external") platform_endpoint = "platformendpoint" add_param(nem_element, platform_endpoint, config[platform_endpoint]) transport_endpoint = "transportendpoint" add_param(nem_element, transport_endpoint, config[transport_endpoint]) # define transport element transport_name = transport_file_name(iface) transport_element = etree.SubElement(nem_element, "transport", definition=transport_name) add_param(transport_element, "device", iface.name) # add nem element to platform element platform_element.append(nem_element) # generate and assign interface mac address based on nem id mac = _MAC_PREFIX + ":00:00:" mac += f"{(nem_id >> 8) & 0xFF:02X}:{nem_id & 0xFF:02X}" iface.set_mac(mac) doc_name = "platform" file_name = platform_file_name(iface) create_node_file(iface.node, platform_element, doc_name, file_name)