mirror of
https://github.com/soypat/lneto.git
synced 2026-08-10 09:53:44 +00:00
no dhcp request on zeroed address (#33)
This commit is contained in:
+2
-1
@@ -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...)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user