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

Feature: nclient4 BSD/macOS support #534

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

Conversation

vista-
Copy link

@vista- vista- commented May 23, 2024

This PR adds back BSD/macOS support for nclient4, which was removed when the library switch from using the raw package for sending/receiving broadcast UDP packets, instead using the packet library (which only supports Linux).

The PR also solves the build-scoping issue described in #526

Due to lack of support for raw datagram sockets in BSD, additional functionality had to be added for constructing the raw Ethernet frame. VLAN tag support has also been added to the BSD/macOS-related nclient4 code, which can be utilised to send/receive tagged frames. This can be useful for testing IPoE-based access networks.

Tests have also been added for the Ethernet frame and VLAN tag processing, based on the gopacket library.

There are two avenues of improving the code in the PR in the future (but I would prefer to avoid premature optimisation):

  • Create a byte array with the byte representation of the VLAN stack + EtherType field in it during initialisation, in NewRawUDPConn. This can be inserted at the EtherType offset of the Ethernet frame when sending, and performing a simple byte comparison at the EtherType offset when receiving frames.
  • Use gopacket for constructing the frame from scratch instead of doing it byte by byte.

Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 80.23952% with 33 lines in your changes missing coverage. Please review.

Project coverage is 73.65%. Comparing base (bf3278a) to head (4fa4462).

Current head 4fa4462 differs from pull request most recent head 64fb84e

Please upload reports for the commit 64fb84e to get more accurate results.

Files Patch % Lines
dhcpv4/nclient4/udp.go 56.09% 12 Missing and 6 partials ⚠️
dhcpv4/nclient4/conn_linux.go 64.28% 13 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #534      +/-   ##
==========================================
- Coverage   73.77%   73.65%   -0.13%     
==========================================
  Files          81       83       +2     
  Lines        5122     5197      +75     
==========================================
+ Hits         3779     3828      +49     
- Misses       1200     1225      +25     
- Partials      143      144       +1     

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

vista- added 9 commits May 23, 2024 14:53
Signed-off-by: vista <vista@birb.network>
Signed-off-by: vista <vista@birb.network>
…et.go

Signed-off-by: vista <vista@birb.network>
…rts Linux platforms)

Signed-off-by: vista <vista@birb.network>
Signed-off-by: vista <vista@birb.network>
Signed-off-by: vista <vista@birb.network>
…some comments

Signed-off-by: vista <vista@birb.network>
Signed-off-by: vista <vista@birb.network>
@vista- vista- force-pushed the feature/nclient4-bsd-support branch from 4fa4462 to 3191f87 Compare May 23, 2024 12:54
@vista-
Copy link
Author

vista- commented May 23, 2024

Force pushed commits with sign-offs.

@pmazzini pmazzini requested a review from hugelgupf May 23, 2024 13:01
@vista-
Copy link
Author

vista- commented Jun 13, 2024

Ping! :)

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