Skip to content

Commit

Permalink
fixup! feat(doip-discover): Greatly speed up DoIP discover
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdinandjarisch committed Dec 4, 2024
1 parent 9704227 commit 211d786
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/gallia/commands/discover/doip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# SPDX-License-Identifier: Apache-2.0

from __future__ import annotations

import asyncio
import socket
from collections.abc import Iterable
Expand All @@ -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,
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion src/gallia/transports/doip.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 211d786

Please sign in to comment.