diff --git a/daemon/core/api/grpc/client.py b/daemon/core/api/grpc/client.py index 9c6b15c6..73393004 100644 --- a/daemon/core/api/grpc/client.py +++ b/daemon/core/api/grpc/client.py @@ -26,6 +26,10 @@ from core.api.grpc.configservices_pb2 import ( SetNodeConfigServiceRequest, SetNodeConfigServiceResponse, ) +from core.api.grpc.core_pb2 import ( + GetEmaneEventChannelRequest, + GetEmaneEventChannelResponse, +) class InterfaceHelper: @@ -1139,6 +1143,10 @@ class CoreGrpcClient: ) return self.stub.SetNodeConfigService(request) + def get_emane_event_channel(self, session_id: int) -> GetEmaneEventChannelResponse: + request = GetEmaneEventChannelRequest(session_id=session_id) + return self.stub.GetEmaneEventChannel(request) + def connect(self) -> None: """ Open connection to server, must be closed manually. diff --git a/daemon/core/api/grpc/server.py b/daemon/core/api/grpc/server.py index 3cc2020b..f155867d 100644 --- a/daemon/core/api/grpc/server.py +++ b/daemon/core/api/grpc/server.py @@ -32,6 +32,10 @@ from core.api.grpc.configservices_pb2 import ( SetNodeConfigServiceRequest, SetNodeConfigServiceResponse, ) +from core.api.grpc.core_pb2 import ( + GetEmaneEventChannelRequest, + GetEmaneEventChannelResponse, +) from core.api.grpc.events import EventStreamer from core.api.grpc.grpcutils import ( get_config_options, @@ -1630,3 +1634,14 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer): grpc.StatusCode.NOT_FOUND, f"node {node.name} missing service {request.name}", ) + + def GetEmaneEventChannel( + self, request: GetEmaneEventChannelRequest, context: ServicerContext + ) -> GetEmaneEventChannelResponse: + session = self.get_session(request.session_id, context) + group = None + port = None + device = None + if session.emane.eventchannel: + group, port, device = session.emane.eventchannel + return GetEmaneEventChannelResponse(group=group, port=port, device=device) diff --git a/daemon/core/emane/emanemanager.py b/daemon/core/emane/emanemanager.py index 0c508284..9a7b3a0d 100644 --- a/daemon/core/emane/emanemanager.py +++ b/daemon/core/emane/emanemanager.py @@ -91,6 +91,7 @@ class EmaneManager(ModelManager): self.set_configs(self.emane_config.default_values()) self.service = None + self.eventchannel = None self.event_device = None self.emane_check() @@ -204,13 +205,13 @@ class EmaneManager(ModelManager): if eventnet is not None: # direct EMANE events towards control net bridge self.event_device = eventnet.brname - eventchannel = (group, int(port), self.event_device) + self.eventchannel = (group, int(port), self.event_device) # disabled otachannel for event service # only needed for e.g. antennaprofile events xmit by models logging.info("using %s for event service traffic", self.event_device) try: - self.service = EventService(eventchannel=eventchannel, otachannel=None) + self.service = EventService(eventchannel=self.eventchannel, otachannel=None) except EventServiceException: logging.exception("error instantiating emane EventService") diff --git a/daemon/proto/core/api/grpc/core.proto b/daemon/proto/core/api/grpc/core.proto index fbf0367a..e515ab2e 100644 --- a/daemon/proto/core/api/grpc/core.proto +++ b/daemon/proto/core/api/grpc/core.proto @@ -140,6 +140,8 @@ service CoreApi { } rpc GetEmaneModelConfigs (GetEmaneModelConfigsRequest) returns (GetEmaneModelConfigsResponse) { } + rpc GetEmaneEventChannel (GetEmaneEventChannelRequest) returns (GetEmaneEventChannelResponse) { + } // xml rpc rpc SaveXml (SaveXmlRequest) returns (SaveXmlResponse) { @@ -710,6 +712,16 @@ message GetEmaneModelConfigsResponse { repeated ModelConfig configs = 1; } +message GetEmaneEventChannelRequest { + int32 session_id = 1; +} + +message GetEmaneEventChannelResponse { + string group = 1; + int32 port = 2; + string device = 3; +} + message SaveXmlRequest { int32 session_id = 1; }