From 211d7867b616cadc160712b1bcb954d3b0efdf92 Mon Sep 17 00:00:00 2001 From: "Jarisch, Ferdinand" Date: Wed, 4 Dec 2024 12:58:38 +0100 Subject: [PATCH] fixup! feat(doip-discover): Greatly speed up DoIP discover --- src/gallia/commands/discover/doip.py | 8 +++----- src/gallia/transports/doip.py | 9 ++++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/gallia/commands/discover/doip.py b/src/gallia/commands/discover/doip.py index ee64e1811..d73351139 100644 --- a/src/gallia/commands/discover/doip.py +++ b/src/gallia/commands/discover/doip.py @@ -2,8 +2,6 @@ # # SPDX-License-Identifier: Apache-2.0 -from __future__ import annotations - import asyncio import socket from collections.abc import Iterable @@ -18,11 +16,9 @@ from gallia.log import get_logger from gallia.services.uds.core.service import TesterPresentRequest, TesterPresentResponse from gallia.transports.doip import ( - DiagnosticMessage, DiagnosticMessageNegativeAckCodes, DoIPConnection, DoIPEntityStatusResponse, - DoIPFrame, DoIPNegativeAckError, DoIPRoutingActivationDeniedError, GenericHeader, @@ -326,7 +322,9 @@ async def enumerate_target_addresses( search_space = range(start, stop + 1) target_template = f"doip://{tgt_hostname}:{tgt_port}?protocol_version={self.protocol_version}&activation_type={correct_rat:#x}&src_addr={correct_src:#x}&target_addr={{:#x}}" - conn = await self.create_DoIP_conn(tgt_hostname, tgt_port, correct_rat, correct_src, 0xAFFE, fast_queue=True) + conn = await self.create_DoIP_conn( + tgt_hostname, tgt_port, correct_rat, correct_src, 0xAFFE, fast_queue=True + ) reader_task = asyncio.create_task(self.task_read_diagnostic_messages(conn, target_template)) for target_addr in search_space: diff --git a/src/gallia/transports/doip.py b/src/gallia/transports/doip.py index 0489aacda..5d1d0174a 100644 --- a/src/gallia/transports/doip.py +++ b/src/gallia/transports/doip.py @@ -512,7 +512,14 @@ async def connect( # noqa: PLR0913 sock = writer.get_extra_info("socket") sock.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack("ii", 1, 0)) - return cls(reader, writer, src_addr, target_addr, protocol_version, separate_diagnostic_message_queue) + return cls( + reader, + writer, + src_addr, + target_addr, + protocol_version, + separate_diagnostic_message_queue, + ) async def _read_frame(self) -> DoIPFrame | tuple[None, None]: # Header is fixed size 8 byte.