no dhcp request on zeroed address (#33)

This commit is contained in:
Pat Whittingslow
2026-02-05 22:18:27 +01:00
committed by GitHub
parent fba97c990a
commit 199d978c99
2 changed files with 2 additions and 6 deletions
+2 -1
View File
@@ -11,6 +11,7 @@ import (
"net/netip"
"github.com/soypat/lneto"
"github.com/soypat/lneto/internal"
"github.com/soypat/lneto/ipv4"
)
@@ -90,7 +91,7 @@ func (c *Client) BeginRequest(xid uint32, cfg RequestConfig) error {
c.state = StateInit
c.currentXID = xid
c.reqHostname = cfg.Hostname
c.reqIP = addr4{addr: cfg.RequestedAddr, valid: true}
c.reqIP = addr4{addr: cfg.RequestedAddr, valid: !internal.IsZeroed(cfg.RequestedAddr[:]...)} // TODO(pato): what's lighter? Comparing the [4]byte or ...byte
c.clientMAC = cfg.ClientHardwareAddr
if cfg.ClientID != "" {
c.clientID = append(c.clientID[:0], cfg.ClientID...)
-5
View File
@@ -564,8 +564,3 @@ func addr4(addr [4]byte, ok bool) netip.Addr {
}
return netip.AddrFrom4(addr)
}
func hash(b []byte) uint16 {
var csum lneto.CRC791
return csum.PayloadSum16(b)
}