Skip to content

dhcpv4: parse and emit DHCP Option 42 (NTP servers) - #1205

Open
Aditya-9-6 wants to merge 1 commit into
smoltcp-rs:mainfrom
Aditya-9-6:feat/dhcp-parse-ntp-servers
Open

Aditya-9-6 wants to merge 1 commit into
smoltcp-rs:mainfrom
Aditya-9-6:feat/dhcp-parse-ntp-servers

Conversation

@Aditya-9-6

@Aditya-9-6 Aditya-9-6 commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1178.

Summary

This PR adds support for parsing and emitting DHCP Option 42 (Network Time Protocol Servers) as defined in RFC 2132 §8.3.

Changes

  • wire::dhcpv4:
    • Defined MAX_NTP_SERVER_COUNT: usize = 3;.
    • Added ntp_servers: Option<Vec<Ipv4Address, MAX_NTP_SERVER_COUNT>> to Repr.
    • Added parsing and serialization for field::OPT_NTP_SERVERS (42).
    • Added unit test test_emit_offer_ntp.
  • wire:
    • Re-exported DHCP_MAX_NTP_SERVER_COUNT.
  • socket::dhcpv4:
    • Included dhcpv4_field::OPT_NTP_SERVERS in DEFAULT_PARAMETER_REQUEST_LIST.
    • Added ntp_servers to dhcpv4::Config.
    • Filtered unicast addresses and exposed ntp_servers in Config events.
    • Updated DHCP socket tests to verify Option 42 handling.

Verification

  • cargo test --lib: 674 passed; 0 failed.
  • cargo fmt --check: Clean.
  • cargo clippy --lib --tests: Clean.

@codecov

codecov Bot commented Sep 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 82.62%. Comparing base (efcba2e) to head (58881bf).

Files with missing lines Patch % Lines
src/wire/dhcpv4.rs 98.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1205      +/-   ##
==========================================
+ Coverage   82.57%   82.62%   +0.04%     
==========================================
  Files          83       83              
  Lines       26174    26249      +75     
==========================================
+ Hits        21613    21687      +74     
- Misses       4561     4562       +1     

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

dhcp: parse option byte 42.

1 participant