Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from

Conversation

raissi-oussema
Copy link

@raissi-oussema raissi-oussema commented Dec 7, 2024

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 > 0))
  • "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))

@Dimi1010
Copy link
Collaborator

Dimi1010 commented Dec 8, 2024

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

@tigercosmos tigercosmos changed the base branch from master to dev December 8, 2024 09:37
@egecetin egecetin closed this Dec 8, 2024
@egecetin egecetin reopened this Dec 8, 2024
@egecetin egecetin linked an issue Dec 8, 2024 that may be closed by this pull request
@raissi-oussema
Copy link
Author

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.

Comment on lines 250 to 253
/**
* Diagnostic over IP protocol (DOIP)
*/
const ProtocolType DOIP = 38;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ID 38 is already taken by DHCPv6 protocol. The next available ID is 58, please add it after GTPv2

@@ -437,7 +437,6 @@ namespace pcpp

HttpResponseStatusCode() = default;

// cppcheck-suppress noExplicitConstructor
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing this cppcheck-suppress comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cppcheck flags this as an incorrect suppression on my local machine. Let me know if you think I should revert it.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is interesting. Which version of CPPcheck are you using?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2.7 as recommanded in CONTRIBUTING.md and still flags incorrect suppression, I'm keeping this changes so can I commit my recents updates,

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why update this file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as my previous comment, I only removed some suppress-checks detected as incorrect

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add one pcap file with all of these packets?

Copy link
Author

@raissi-oussema raissi-oussema Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes sure, I'll revert suppress-checks and add pcap file containig all tested packets in next PR, also try to cover some missing checks based on codecov feedback

Copy link

codecov bot commented Dec 10, 2024

Codecov Report

Attention: Patch coverage is 94.81690% with 92 lines in your changes missing coverage. Please review.

Project coverage is 83.55%. Comparing base (d60c699) to head (3c5dc4d).

Files with missing lines Patch % Lines
Packet++/src/DoIpLayerData.cpp 90.87% 38 Missing and 18 partials ⚠️
Packet++/src/DoIpLayer.cpp 88.13% 10 Missing and 11 partials ⚠️
Tests/Packet++Test/Tests/DoIpTests.cpp 98.63% 0 Missing and 12 partials ⚠️
Packet++/header/DoIpLayerData.h 76.92% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #1655      +/-   ##
==========================================
+ Coverage   83.11%   83.55%   +0.43%     
==========================================
  Files         277      283       +6     
  Lines       48207    50042    +1835     
  Branches    10192    10704     +512     
==========================================
+ Hits        40069    41813    +1744     
- Misses       7243     7300      +57     
- Partials      895      929      +34     
Flag Coverage Δ
alpine320 75.36% <83.20%> (+0.25%) ⬆️
fedora40 75.43% <84.02%> (+0.27%) ⬆️
macos-13 80.95% <89.84%> (+0.33%) ⬆️
macos-14 80.95% <89.84%> (+0.33%) ⬆️
macos-15 80.89% <89.29%> (+0.30%) ⬆️
mingw32 70.74% <68.61%> (-0.12%) ⬇️
mingw64 70.73% <68.67%> (-0.10%) ⬇️
npcap 85.30% <87.22%> (+0.04%) ⬆️
rhel94 75.26% <84.02%> (+0.28%) ⬆️
ubuntu2004 58.40% <53.95%> (-0.19%) ⬇️
ubuntu2004-zstd 58.48% <53.95%> (-0.20%) ⬇️
ubuntu2204 75.19% <84.00%> (+0.29%) ⬆️
ubuntu2204-icpx 61.42% <60.47%> (-0.03%) ⬇️
ubuntu2404 75.44% <83.20%> (+0.28%) ⬆️
unittest 83.55% <94.81%> (+0.43%) ⬆️
windows-2019 85.33% <87.12%> (+0.04%) ⬆️
windows-2022 85.36% <87.22%> (+0.04%) ⬆️
winpcap 85.32% <87.22%> (+0.06%) ⬆️
xdp 51.56% <84.00%> (+1.03%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@seladb
Copy link
Owner

seladb commented Jan 3, 2025

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

@raissi-oussema
Copy link
Author

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

raissi-oussema and others added 2 commits January 6, 2025 01:52
.improve  maps searchs for doipEnumsToStrings
.cover more uses cases based on codecov feedback
@raissi-oussema
Copy link
Author

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

@seladb
Copy link
Owner

seladb commented Jan 8, 2025

@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

@raissi-oussema
Copy link
Author

@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.

@Dimi1010
Copy link
Collaborator

Dimi1010 commented Jan 12, 2025

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support of doip (diagnostic over IP protocol)
5 participants