Skip to content

Add serializeLayer() for Eth, IPv4, IPv6, TCP and UDP layers - #2261

Open
seladb wants to merge 27 commits into
devfrom
protocol-layer-serialization
Open

seladb wants to merge 27 commits into
devfrom
protocol-layer-serialization

Conversation

@seladb

@seladb seladb commented Sep 18, 2026

Copy link
Copy Markdown
Owner

Adds concrete serializeLayer() implementations for the core protocol layers, building on the serialization framework from #2259.

What's included:

  • EthLayer: source/destination MAC address, EtherType
  • IPv4Layer: source/destination IP, ID, protocol, total length, fragmentation, options
  • IPv6Layer: source/destination IP, payload length, fragmentation, next header, extension headers
  • TcpLayer: ports, sequence number, flags, window size, checksum, options
  • UdpLayer: ports, checksum

Base branch is packet-serialization-foundation (#2259)

Comment thread .github/workflows/build_and_test.yml Outdated
@codecov

codecov Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.54804% with 94 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.64%. Comparing base (c9d247c) to head (90a2c3b).

Files with missing lines Patch % Lines
Packet++/src/TcpLayer.cpp 46.31% 51 Missing ⚠️
Packet++/src/IPv4Layer.cpp 47.14% 37 Missing ⚠️
Packet++/header/IPv6Layer.h 0.00% 3 Missing and 1 partial ⚠️
Packet++/src/IPv6Extensions.cpp 86.66% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #2261      +/-   ##
==========================================
- Coverage   82.68%   82.64%   -0.04%     
==========================================
  Files         339      339              
  Lines       62024    62285     +261     
  Branches    13095    13172      +77     
==========================================
+ Hits        51285    51478     +193     
- Misses       9862     9931      +69     
+ Partials      877      876       -1     
Flag Coverage Δ
23.11.6 7.05% <0.00%> (+0.01%) ⬆️
24.11.5 7.02% <0.00%> (-0.07%) ⬇️
25.11.1 7.03% <0.00%> (-0.01%) ⬇️
alpine320 76.60% <52.45%> (-0.12%) ⬇️
fedora42 76.10% <50.51%> (-0.13%) ⬇️
macos-15 82.39% <70.14%> (-0.02%) ⬇️
macos-26 82.40% <70.14%> (-0.02%) ⬇️
macos-26-intel 82.33% <70.14%> (-0.02%) ⬇️
mingw32 70.97% <47.50%> (-0.15%) ⬇️
mingw64 ?
npcap 85.44% <70.45%> (-0.03%) ⬇️
rhel94 75.94% <50.76%> (-0.13%) ⬇️
ubuntu2204 75.96% <50.76%> (-0.12%) ⬇️
ubuntu2404 76.22% <50.76%> (-0.16%) ⬇️
ubuntu2604 76.18% <50.51%> (-0.15%) ⬇️
ubuntu2604-arm64 76.08% <51.98%> (-0.13%) ⬇️
ubuntu2604-icpx 58.82% <27.10%> (-0.18%) ⬇️
unittest 82.64% <66.54%> (-0.04%) ⬇️
windows-2022 85.44% <70.45%> (-0.03%) ⬇️
windows-2025 85.12% <62.31%> (-0.05%) ⬇️
winpcap 85.31% <62.31%> (-0.05%) ⬇️
xdp 53.87% <50.76%> (+0.01%) ⬆️

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

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

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

@seladb
seladb marked this pull request as ready for review September 19, 2026 09:12
Base automatically changed from packet-serialization-foundation to dev September 24, 2026 09:16
Comment thread Packet++/src/IPv6Layer.cpp Outdated

@Dimi1010 Dimi1010 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this should be the last couple of things.

Comment thread Packet++/src/IPv4Layer.cpp Outdated
Comment on lines 365 to 372
IPv6Extension* curExt = m_FirstExtension;
while (curExt != nullptr)
{
switch (curExt->getExtensionType())
{
case IPv6Extension::IPv6Fragmentation:
result += "Fragment,";
break;
case IPv6Extension::IPv6HopByHop:
result += "Hop-By-Hop,";
break;
case IPv6Extension::IPv6Destination:
result += "Destination,";
break;
case IPv6Extension::IPv6Routing:
result += "Routing,";
break;
case IPv6Extension::IPv6AuthenticationHdr:
result += "Authentication,";
break;
default:
result += "Unknown,";
break;
}

result += curExt->getExtensionTypeAsString();
result += ",";
curExt = curExt->getNextHeader();
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: while we are changing this, it can be changed to a for-loop.
for(IPv6Extension const* curExt = m_FirstExtension; curExt != nullptr; curExt = curExt->getNextHeader())

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Addressed in 781392c

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

curExt = curExt->getNextHeader(); in the loop body needs to be removed.

Comment thread Packet++/src/TcpLayer.cpp Outdated
Comment thread Packet++/src/TcpLayer.cpp Outdated
…ializedFields`

- Add `@brief` to all `SerializedFields` fields
@seladb

seladb commented Sep 29, 2026

Copy link
Copy Markdown
Owner Author

I also addressed the comments from this PR in 87f8c98

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.

2 participants