PcapPlusPlus icon indicating copy to clipboard operation
PcapPlusPlus copied to clipboard

Add Layer Build and Validation for DoIP (Diagnostic over IP) Support

Open raissi-oussema opened this issue 11 months ago • 24 comments

DoIP Protocol Overview

The Diagnostic over IP (DoIP) protocol is used in automotive diagnostic systems to facilitate communication between diagnostic tools and ECUs (Electronic Control Units) over IP-based networks. It enables remote diagnostics, configuration, and software updates over Ethernet, offering an efficient and scalable solution for modern vehicles.

Header Structure (8 bytes)

protocol version (1 byte) invert protocol version (1 byte) payload type (2 bytes) payload length (4 bytes)

Pyload types / code / structure

  • "Generic DOIP header Nack" (0x0000) (header + nackCode (1 byte : required))
  • "Vehicle identification request" (0x0001) (header)
  • "Vehicle identification request with EID" (0x0002) (header + EID (6 bytes : required))
  • "Vehicle identification request with VIN" (0x0003) (header + VIN (17 bytes : required))
  • "Vehicle announcement message" (0x0004) (header + VIN (17 bytes : required) + logical address (2bytes : required) + EID (6 bytes : required) + GID (6 bytes : required) + further action (1 bytes : required)+ sync status (1 bytes : optional)).
  • "Routing activation request" (0x0005) (header + source address (2 bytes : required) + activation type (1 byte:required) + reservedISO (4 bytes : required) + reservedOEM (4 bytes : optional)).
  • "Routing activation response" (0x0006) (header + tester adress(2 bytes : required) + response code (1 byte:required) + reservedISO (4 bytes : required) + reservedOEM (4 bytes : optional)).
  • "Alive check request" (0x0007) (header)
  • "Alive check response" (0x0008) (header + source address (2 byte : required))
  • "DOIP entity status request" (0x4001) (header)
  • "DOIP entity status response" (0x4002) (header + node type (1 byte : required) + max concurrent socket (1 byte : required) + currently opened sockets (1 byte : required) + max data size(4 bytes : optional))
  • "Diagnostic power mode request information" (0x4003) (header)
  • "Diagnostic power mode response information" (0x4004) (header + power mode (1 byte : required))
  • "Diagnostic message" (0x8001) (header + source address (2 bytes : required) + target address (2 bytes : required) + UDS message (n bytes : required ; n > 1))
  • "Diagnostic message Ack" (0x8002) (header + source address (2 bytes : required) + target address (2 bytes : required) + ack code (1 byte : required)) + previous message (n bytes : optional ; n>0))
  • "Diagnostic message Nack" (0x8003) (header + source address (2 bytes : required) + target address (2 bytes : required) + Nack code (1 byte : required)) + previous message (n bytes : optional ; n>0))

raissi-oussema avatar Dec 07 '24 23:12 raissi-oussema

As per the contributing guidelines, please retarget the PR to the dev branch instead of the master.

Dimi1010 avatar Dec 08 '24 06:12 Dimi1010

Observed several issues in the CI pipelines, likely due to missing definitions for htobe16 and other endianness conversion macros. All tests and pre-commit checks are passed in my linux machine. Adding an import for "EndianPortable.h" in last PR is expected to resolve these problems.

raissi-oussema avatar Dec 08 '24 16:12 raissi-oussema

Codecov Report

:x: Patch coverage is 97.82828% with 43 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 83.43%. Comparing base (be201c4) to head (82a0fcd). :warning: Report is 1 commits behind head on dev.

Files with missing lines Patch % Lines
Packet++/src/DoIpLayer.cpp 96.74% 30 Missing and 1 partial :warning:
Packet++/header/DoIpLayer.h 96.16% 10 Missing :warning:
Packet++/src/TcpLayer.cpp 83.33% 1 Missing :warning:
Packet++/src/UdpLayer.cpp 83.33% 1 Missing :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1655      +/-   ##
==========================================
+ Coverage   82.88%   83.43%   +0.54%     
==========================================
  Files         292      295       +3     
  Lines       51834    53814    +1980     
  Branches    11293    11863     +570     
==========================================
+ Hits        42965    44902    +1937     
- Misses       7671     8093     +422     
+ Partials     1198      819     -379     
Flag Coverage Δ
alpine320 75.38% <95.01%> (+0.68%) :arrow_up:
fedora42 75.49% <94.92%> (+0.64%) :arrow_up:
macos-13 81.63% <95.71%> (+0.53%) :arrow_up:
macos-14 81.63% <95.71%> (+0.53%) :arrow_up:
macos-15 81.64% <95.71%> (+0.53%) :arrow_up:
mingw32 70.23% <71.72%> (+0.05%) :arrow_up:
mingw64 70.23% <71.81%> (+0.06%) :arrow_up:
rhel94 75.22% <94.27%> (+0.66%) :arrow_up:
ubuntu2004 59.18% <66.49%> (+0.30%) :arrow_up:
ubuntu2004-zstd 59.26% <66.49%> (+0.29%) :arrow_up:
ubuntu2204 75.15% <94.28%> (+0.65%) :arrow_up:
ubuntu2204-icpx 60.94% <62.77%> (+0.07%) :arrow_up:
ubuntu2404 75.41% <95.02%> (+0.70%) :arrow_up:
ubuntu2404-arm64 75.40% <95.02%> (+0.68%) :arrow_up:
unittest 83.43% <97.82%> (+0.54%) :arrow_up:
windows-2022 85.43% <95.75%> (+0.40%) :arrow_up:
windows-2025 85.45% <95.75%> (+0.39%) :arrow_up:
winpcap 85.45% <95.75%> (+0.39%) :arrow_up:
xdp 52.85% <94.28%> (+1.36%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Dec 10 '24 09:12 codecov[bot]

@raissi-oussema are you planning to continue working on this PR?

seladb avatar Jan 03 '25 06:01 seladb

Hi, I was engaged with other tasks, but I plan to get back to this PR soon. Thanks for your understanding!

raissi-oussema avatar Jan 05 '25 19:01 raissi-oussema

Design suggestions or code improvements are always welcome and greatly appreciated.

raissi-oussema avatar Jan 07 '25 21:01 raissi-oussema

@raissi-oussema to make it easier to review, do you think you can add some documentation on the DoIP protocol to the PR body?

It'd mostly be helpful to get more details on the header structure and different possible message

seladb avatar Jan 08 '25 08:01 seladb

@seladb I need support for CI pipelines, I can't figure out why are they still failing. And a clear documentation was successfully added to PR body to make it easier for you to start the code review.

raissi-oussema avatar Jan 12 '25 13:01 raissi-oussema

@seladb I need support for CI pipelines, I can't figure out why are they still failing. And a clear documentation was successfully added to PR body to make it easier for you to start the code review.

Doxigen pipeline: /__w/PcapPlusPlus/PcapPlusPlus/Packet++/header/DoIpLayer.h:42: error: Compound pcpp::DoIpLayer is not documented. (warning treated as error, aborting now)

XDP pipeline: That is an issue with the CI image. Merge latest changes from dev branch and it should be fine.

VS pipeline: Tbh, no idea om that one. It seems the opencoverage download link stopped working for a bit or something.

Dimi1010 avatar Jan 12 '25 14:01 Dimi1010

@seladb I need support for CI pipelines, I can't figure out why are they still failing. And a clear documentation was successfully added to PR body to make it easier for you to start the code review.

Doxigen pipeline: /__w/PcapPlusPlus/PcapPlusPlus/Packet++/header/DoIpLayer.h:42: error: Compound pcpp::DoIpLayer is not documented. (warning treated as error, aborting now)

XDP pipeline: That is an issue with the CI image. Merge latest changes from dev branch and it should be fine.

VS pipeline: Tbh, no idea om that one. It seems the opencoverage download link stopped working for a bit or something.

What could be the problem for dioxygen pipeline, doipLayer.h is well documented [line 42] ?

raissi-oussema avatar Jan 14 '25 12:01 raissi-oussema

@Dimi1010 Any additional feedback regarding design logic or code implementation is highly appreciated.

raissi-oussema avatar Jan 20 '25 12:01 raissi-oussema

@seladb Would you kindly let me know if there’s any additional feedback or changes needed for this PR to proceed with merging?

raissi-oussema avatar Jan 28 '25 07:01 raissi-oussema

@raissi-oussema I'm sorry for the delay, I'll take a look at the PR in the next couple of days

seladb avatar Feb 02 '25 03:02 seladb

@seladb , Kind reminder, could you please provide feedback about this PR

raissi-oussema avatar Feb 12 '25 12:02 raissi-oussema

@Dimi1010 , could you please trigger pipeline again? It looks like there was a problem with downloading some staff.

raissi-oussema avatar Feb 20 '25 07:02 raissi-oussema

@Dimi1010 , could you please support, what could be the reason of failed pipeline here ?

raissi-oussema avatar Apr 09 '25 12:04 raissi-oussema

@Dimi1010 , could you please support, what could be the reason of failed pipeline here ?

from the doxygen pipeline

/__w/PcapPlusPlus/PcapPlusPlus/Packet++/header/DoIpLayerData.h:1091: warning: Compound pcpp::DiagnosticPowerModeRequestData is not documented.
/__w/PcapPlusPlus/PcapPlusPlus/Packet++/header/DoIpLayerData.h:1066: warning: Compound pcpp::EntityStatusRequestData is not documented.
/__w/PcapPlusPlus/PcapPlusPlus/Packet++/header/DoIpLayerData.h:1116: warning: Compound pcpp::VehicleIdentificationRequestData is not documented.

Dimi1010 avatar Apr 09 '25 15:04 Dimi1010

@seladb , @Dimi1010 , refactoring is done, with more improvements, could you please check and provide feedbacks.

raissi-oussema avatar Apr 19 '25 11:04 raissi-oussema

@raissi-oussema I triggered CI and some tests fail, can you please check?

seladb avatar Apr 19 '25 20:04 seladb

I'm about trying to modify some other parsing logic using some structs to store fields like in announcement, routing request... and remove private vars. I'll try to share solution in 2 days. @seladb , @Dimi1010

raissi-oussema avatar Apr 22 '25 09:04 raissi-oussema

@seladb, could you please have a look, I've made serval changes in this current version and layer now is more aligned with other layer implementation, you can start reviewing this PR, Waiting for your feedbacks.

raissi-oussema avatar Apr 25 '25 08:04 raissi-oussema

@seladb , could you please have a look and suggest what we can improve more

raissi-oussema avatar May 04 '25 16:05 raissi-oussema

@seladb , could you have a look, I've made suggested changes.

raissi-oussema avatar May 06 '25 19:05 raissi-oussema

@seladb , Could you check if there are any areas left to improve or optimize further?

raissi-oussema avatar May 13 '25 20:05 raissi-oussema

@raissi-oussema please also note this comment: https://github.com/seladb/PcapPlusPlus/pull/1655#discussion_r2111155462

seladb avatar Jun 15 '25 03:06 seladb

@raissi-oussema I think this PR is almost ready to merge. Can you address the remaining comments?

seladb avatar Jul 11 '25 07:07 seladb

@raissi-oussema I think this PR is almost ready to merge. Can you address the remaining comments?

I was tied up with other tasks, but I’ll take care of the remaining work over the next two days. Thanks for your patience!

raissi-oussema avatar Jul 11 '25 22:07 raissi-oussema

@seladb, could you have a look, I've addressed the last comments and I made some improvements.

raissi-oussema avatar Jul 18 '25 19:07 raissi-oussema

@raissi-oussema thank you so much for working on this PR! 🙏 I really appreciate your hard work and dedication, and I'm sorry it took a bit long to get this PR merged. Great work, and thank you again for contributing to this project!

seladb avatar Aug 03 '25 08:08 seladb