def response_rec_callback( self, knxipframe: KNXIPFrame, source: HPAI, _: KNXIPTransport ) -> None: """Verify and handle knxipframe. Callback from internal transport.""" if not isinstance(knxipframe.body, DescriptionResponse): logger.warning("Wrong knxipframe for DescriptionRequest: %s", knxipframe) return self.response_received_event.set() # Set gateway descriptior attribute gateway = GatewayDescriptor( ip_addr=self.transport.remote_addr[0], port=self.transport.remote_addr[1], local_ip=self.transport.getsockname()[0], ) gateway.parse_dibs(knxipframe.body.dibs) self.gateway_descriptor = gateway
def test_parser(self, raw, expected): """Test parsing GatewayDescriptor objects from real-world responses.""" response = KNXIPFrame() response.from_knx(raw) assert isinstance(response.body, (SearchResponse, SearchResponseExtended)) descriptor = GatewayDescriptor( ip_addr=response.body.control_endpoint.ip_addr, port=response.body.control_endpoint.port, ) descriptor.parse_dibs(response.body.dibs) assert descriptor.supports_routing is expected["supports_routing"] assert descriptor.supports_tunnelling is expected["supports_tunnelling"] assert descriptor.supports_tunnelling_tcp is expected[ "supports_tunnelling_tcp"] assert descriptor.supports_secure is expected["supports_secure"] assert descriptor.routing_requires_secure is expected[ "routing_requires_secure"] assert (descriptor.tunnelling_requires_secure is expected["tunnelling_requires_secure"])