From e5e14ad67b2f5a74b0b5cbe310b186c864e892a3 Mon Sep 17 00:00:00 2001 From: Blake Harnden <32446120+bharnden@users.noreply.github.com> Date: Mon, 21 Mar 2022 09:55:57 -0700 Subject: [PATCH] grpc: added wlan/emane links to grpc calls to allow knowing initial wireless link state, same as before changes --- daemon/core/api/grpc/grpcutils.py | 8 +++++++- daemon/core/emane/nodes.py | 4 ++-- daemon/core/nodes/network.py | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/daemon/core/api/grpc/grpcutils.py b/daemon/core/api/grpc/grpcutils.py index 5cec8c2e..e2cba7e9 100644 --- a/daemon/core/api/grpc/grpcutils.py +++ b/daemon/core/api/grpc/grpcutils.py @@ -355,6 +355,9 @@ def get_links(session: Session, node: NodeBase) -> List[core_pb2.Link]: link_protos = [] for core_link in session.link_manager.node_links(node): link_protos.extend(convert_core_link(core_link)) + if isinstance(node, (WlanNode, EmaneNet)): + for link_data in node.links(): + link_protos.append(convert_link_data(link_data)) return link_protos @@ -729,13 +732,16 @@ def convert_session(session: Session) -> wrappers.Session: """ emane_configs = get_emane_model_configs_dict(session) nodes = [] + links = [] for _id in session.nodes: node = session.nodes[_id] if not isinstance(node, (PtpNet, CtrlNet)): node_emane_configs = emane_configs.get(node.id, []) node_proto = get_node_proto(session, node, node_emane_configs) nodes.append(node_proto) - links = [] + if isinstance(node, (WlanNode, EmaneNet)): + for link_data in node.links(): + links.append(convert_link_data(link_data)) for core_link in session.link_manager.links(): links.extend(convert_core_link(core_link)) default_services = get_default_services(session) diff --git a/daemon/core/emane/nodes.py b/daemon/core/emane/nodes.py index 18d6b865..a32814e1 100644 --- a/daemon/core/emane/nodes.py +++ b/daemon/core/emane/nodes.py @@ -219,7 +219,7 @@ class EmaneNet(CoreNetworkBase): self.mobility.update_config(config) def links(self, flags: MessageFlags = MessageFlags.NONE) -> List[LinkData]: - links = super().links(flags) + links = [] emane_manager = self.session.emane # gather current emane links nem_ids = set() @@ -240,7 +240,7 @@ class EmaneNet(CoreNetworkBase): # ignore incomplete links if (nem2, nem1) not in emane_links: continue - link = emane_manager.get_nem_link(nem1, nem2) + link = emane_manager.get_nem_link(nem1, nem2, flags) if link: links.append(link) return links diff --git a/daemon/core/nodes/network.py b/daemon/core/nodes/network.py index 322a2732..eb1e4657 100644 --- a/daemon/core/nodes/network.py +++ b/daemon/core/nodes/network.py @@ -781,10 +781,10 @@ class WlanNode(CoreNetwork): :param flags: message flags :return: list of link data """ - links = super().links(flags) if self.model: - links.extend(self.model.links(flags)) - return links + return self.model.links(flags) + else: + return [] class TunnelNode(GreTapBridge):