|
|
|
@ -315,9 +315,15 @@ func handleDHCP(content []byte, dstMAC net.HardwareAddr, srcMAC net.HardwareAddr
|
|
|
|
|
switch reqType {
|
|
|
|
|
case dhcp4.Discover:
|
|
|
|
|
if OldIP == nil {
|
|
|
|
|
log.Fatal(prefix, "DHCPDISCOVER but not previous address is known")
|
|
|
|
|
if NewIP == nil || !NewIP.IsGlobalUnicast() {
|
|
|
|
|
log.Warning(prefix, "DHCP request, but neither OldIP nor NewIP known")
|
|
|
|
|
sendDHCPRequest(dhcp4.Discover, net.IPv4zero)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
sendDHCPReply(req, dhcp4.Offer, NewIP, options, dstMAC)
|
|
|
|
|
} else {
|
|
|
|
|
sendDHCPReply(req, dhcp4.Offer, OldIP, options, dstMAC)
|
|
|
|
|
}
|
|
|
|
|
case dhcp4.Inform:
|
|
|
|
|
fallthrough
|
|
|
|
|
case dhcp4.Request:
|
|
|
|
|