insomniacslk / dhcp

DHCPv6 and DHCPv4 packet library, client and server written in Go
BSD 3-Clause "New" or "Revised" License
685 stars 168 forks source link

Feature: nclient4 BSD/macOS support #534

Open vista- opened 2 months ago

vista- commented 2 months ago

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 https://github.com/insomniacslk/dhcp/issues/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):

codecov[bot] commented 2 months ago

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

:exclamation: 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 :warning:
dhcpv4/nclient4/conn_linux.go 64.28% 13 Missing and 2 partials :warning:
Additional details and impacted files ```diff @@ 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 ```

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

vista- commented 2 months ago

Force pushed commits with sign-offs.

vista- commented 1 month ago

Ping! :)